/*
 * Rails AI Agent - Multi-Agent Chat Design System
 * Three-column layout: Agent Sidebar | History | Chat Area
 */

/* ============================================
   1. DESIGN TOKENS
   ============================================ */
:root {
  /* Primary (Brand) */
  --color-primary-50: #f0f9ff;
  --color-primary-100: #e0f2fe;
  --color-primary-500: #0ea5e9;
  --color-primary-600: #0284c7;
  --color-primary-900: #0c4a6e;

  /* Functional */
  --color-success: #10b981;
  --color-warning: #f59e0b;
  --color-error: #ef4444;
  --color-info: #6366f1;

  /* Neutral */
  --color-white: #ffffff;
  --color-gray-50: #f8fafc;
  --color-gray-100: #f1f5f9;
  --color-gray-200: #e2e8f0;
  --color-gray-400: #94a3b8;
  --color-gray-600: #475569;
  --color-gray-900: #0f172a;

  /* Semantic aliases */
  --color-primary: var(--color-primary-500);
  --color-primary-hover: var(--color-primary-600);
  --color-primary-light: var(--color-primary-50);
  --color-bg: var(--color-gray-50);
  --color-surface: var(--color-white);
  --color-sidebar-bg: #0f172a;
  --color-sidebar-hover: #1e293b;
  --color-sidebar-active: #334155;
  --color-text: var(--color-gray-900);
  --color-text-secondary: var(--color-gray-600);
  --color-text-muted: var(--color-gray-400);
  --color-border: var(--color-gray-200);
  --color-error-bg: #fef2f2;
  --color-thinking: #8b5cf6;
  --color-thinking-bg: #f5f3ff;
  --color-tool: #3b82f6;
  --color-tool-bg: #eff6ff;

  /* Typography */
  --font-sans: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", Menlo, Monaco, Consolas, monospace;
  --text-xs: 12px;
  --text-sm: 14px;
  --text-base: 16px;
  --text-lg: 18px;
  --text-xl: 20px;
  --text-2xl: 24px;
  --text-3xl: 30px;

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 200ms ease;
  --transition-slow: 300ms ease-out;
}

/* Dark theme tokens */
[data-theme="dark"] {
  --color-white: #0f172a;
  --color-gray-50: #1e293b;
  --color-gray-100: #334155;
  --color-gray-200: #475569;
  --color-gray-400: #94a3b8;
  --color-gray-600: #cbd5e1;
  --color-gray-900: #f8fafc;
}

/* ============================================
   2. RESET & BASE
   ============================================ */
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
}

kbd {
  font: inherit;
}

/* ============================================
   3. CHAT LAYOUT — Three Columns
   ============================================ */
.chat-layout {
  display: flex;
  height: 100dvh;
  overflow: hidden;
}

/* --- Left Column: Agent Sidebar --- */
.agent-sidebar {
  width: 260px;
  background: var(--color-white);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
}

.agent-sidebar-header {
  padding: 20px 16px 12px;
  border-bottom: 1px solid var(--color-border);
}

.agent-sidebar-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0;
}

.agent-sidebar-search {
  margin-top: 12px;
  position: relative;
}

.agent-sidebar-search input {
  width: 100%;
  padding: 8px 12px 8px 32px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-family: var(--font-sans);
  color: var(--color-text);
  background: var(--color-gray-50);
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.agent-sidebar-search input:focus {
  border-color: var(--color-primary-500);
  box-shadow: 0 0 0 3px rgb(14 165 233 / 0.1);
}

.agent-sidebar-search input::placeholder {
  color: var(--color-text-muted);
}

.agent-sidebar-search svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-muted);
  pointer-events: none;
}

.agent-sidebar-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.08) transparent;
}

.agent-sidebar-list::-webkit-scrollbar { width: 4px; }
.agent-sidebar-list::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.08);
  border-radius: 4px;
}

/* Agent card */
.agent-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 12px;
  min-height: 64px;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
  background: transparent;
  text-decoration: none;
  width: 100%;
  text-align: left;
  font-family: var(--font-sans);
  color: var(--color-text-secondary);
  position: relative;
  overflow: hidden;
}

.agent-card:hover {
  background: var(--color-gray-50);
  border-color: var(--color-gray-200);
  color: var(--color-gray-900);
}

.agent-card.active {
  background: var(--color-primary-50);
  border-color: var(--color-primary-500);
  color: var(--color-primary-900);
}

.agent-card.active .agent-card-name {
  color: var(--color-primary-900);
}

.agent-card.disabled {
  opacity: 0.5;
  pointer-events: none;
}

.agent-card-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-weight: 600;
  font-size: var(--text-sm);
  color: #fff;
}

.agent-card-avatar.default-avatar {
  background: var(--color-primary-50);
  color: var(--color-primary-500);
}

.agent-card-avatar.default-avatar svg {
  width: 20px;
  height: 20px;
}

.agent-card-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.agent-card-name {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-gray-900);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.agent-card-desc {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.agent-card-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: 600;
  background: var(--color-primary-50);
  color: var(--color-primary-500);
}

/* Agent sidebar footer */
.agent-sidebar-footer {
  padding: 8px;
  border-top: 1px solid var(--color-border);
}

.agent-sidebar-footer .footer-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  text-decoration: none;
  transition: all var(--transition-fast);
}

.agent-sidebar-footer .footer-link:hover {
  background: var(--color-gray-50);
  color: var(--color-text-secondary);
}

.agent-sidebar-footer .footer-link svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* --- Middle Column: History Sidebar --- */
.history-sidebar {
  width: 280px;
  background: var(--color-gray-50);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
}

.history-sidebar-header {
  padding: 20px 16px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.history-sidebar-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0;
}

.new-chat-btn {
  background: var(--color-white);
  color: var(--color-text-secondary);
  border: 1px dashed var(--color-gray-200);
  border-radius: var(--radius-md);
  padding: 8px 14px;
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all var(--transition-fast);
  font-family: var(--font-sans);
}

.new-chat-btn:hover {
  border-color: var(--color-primary-500);
  color: var(--color-primary-600);
  background: var(--color-primary-50);
}

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

/* Time group labels */
.history-group-label {
  padding: 16px 16px 8px;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Conversation list */
.conversation-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  flex: 1;
  padding: 0 8px 8px;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.06) transparent;
}

.conversation-list::-webkit-scrollbar { width: 4px; }
.conversation-list::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.08);
  border-radius: 4px;
}

.conversation-link {
  color: var(--color-text-secondary);
  text-decoration: none;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: all var(--transition-fast);
  display: block;
  position: relative;
}

.conversation-link:hover {
  background: var(--color-gray-100);
  color: var(--color-gray-900);
}

.conversation-link.active {
  background: var(--color-gray-100);
  color: var(--color-gray-900);
  font-weight: 500;
}

.conversation-link.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: var(--color-primary-500);
  border-radius: 1px;
}

/* History sidebar footer */
.history-sidebar-footer {
  padding: 8px;
  border-top: 1px solid var(--color-border);
}

/* ============================================
   4. CHAT MAIN AREA
   ============================================ */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--color-bg);
  min-width: 0;
  position: relative;
}

/* Agent bar (top of chat area) */
.chat-agent-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  background: var(--color-white);
  border-bottom: 1px solid var(--color-border);
  font-size: var(--text-sm);
  flex-shrink: 0;
}

.agent-bar-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.agent-bar-name {
  font-weight: 600;
  color: var(--color-text);
}

.agent-bar-meta {
  color: var(--color-text-muted);
  font-size: var(--text-xs);
}

/* KB bar */
.chat-kb-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: rgba(139, 92, 246, 0.08);
  border-bottom: 1px solid rgba(139, 92, 246, 0.15);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
}

.kb-bar-name {
  font-weight: 500;
}

.kb-bar-meta {
  color: var(--color-text-muted);
  font-size: var(--text-xs);
}

/* ============================================
   5. WELCOME PAGE
   ============================================ */
.chat-welcome {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  max-width: 480px;
  margin: 0 auto;
  text-align: center;
}

.chat-welcome-logo {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, var(--color-primary-500), #8b5cf6);
  border-radius: var(--radius-xl);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
}

.chat-welcome-logo svg {
  width: 24px;
  height: 24px;
  color: #fff;
}

.chat-welcome h2 {
  font-size: var(--text-2xl);
  font-weight: 600;
  color: var(--color-gray-900);
  margin: 0 0 24px;
}

/* Router Agent Entry */
.router-entry {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  background: linear-gradient(135deg, #7c3aed, #8b5cf6, #6366f1);
  border-radius: var(--radius-xl);
  cursor: pointer;
  transition: all var(--transition-normal);
  text-align: left;
  color: #fff;
  margin-bottom: 16px;
  box-shadow: 0 4px 16px rgba(124, 58, 237, 0.25);
}

.router-entry:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(124, 58, 237, 0.35);
}

.router-entry:active {
  transform: translateY(0);
}

.router-entry-icon {
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.router-entry-icon svg {
  width: 22px;
  height: 22px;
}

.router-entry-info {
  flex: 1;
  min-width: 0;
}

.router-entry-title {
  font-size: var(--text-base);
  font-weight: 600;
  margin-bottom: 2px;
}

.router-entry-desc {
  font-size: var(--text-xs);
  opacity: 0.85;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.router-entry-arrow {
  width: 28px;
  height: 28px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--transition-fast);
}

.router-entry:hover .router-entry-arrow {
  background: rgba(255, 255, 255, 0.35);
}

/* Router Mode Buttons */
.router-modes {
  display: flex;
  gap: 8px;
  width: 100%;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.router-mode-btn {
  flex: 1;
  min-width: 160px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 10px;
  background: var(--color-white);
  border: 1px solid var(--color-gray-200);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--transition-normal);
  text-align: center;
  font-family: var(--font-sans);
}

.router-mode-btn.active {
  border-color: var(--color-primary-500);
  background: var(--color-primary-50);
  box-shadow: var(--shadow-sm);
}

.router-mode-btn:hover {
  border-color: var(--color-primary-500);
  background: var(--color-primary-50);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.router-mode-btn:active {
  transform: translateY(0);
}

.router-mode-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  background: #eff6ff;
  color: #3b82f6;
  flex-shrink: 0;
}

.router-mode-icon.research {
  background: #f5f3ff;
  color: #8b5cf6;
}

.router-mode-icon.orchestrate {
  background: #f0fdf4;
  color: #10b981;
}

.router-mode-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.router-mode-text strong {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-gray-900);
}

.router-mode-text span {
  font-size: 11px;
  color: var(--color-text-muted);
  line-height: 1.3;
}

.chat-welcome-prompts {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.welcome-prompt-card {
  width: 100%;
  background: var(--color-white);
  border: 1px solid var(--color-gray-200);
  border-radius: var(--radius-lg);
  padding: 16px;
  cursor: pointer;
  transition: all var(--transition-normal);
  text-align: left;
  font-family: var(--font-sans);
}

.welcome-prompt-card:hover {
  border-color: var(--color-primary-500);
  background: var(--color-primary-50);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.welcome-prompt-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-gray-900);
  margin-bottom: 4px;
}

.welcome-prompt-title span.prompt-icon {
  font-size: var(--text-lg);
  line-height: 1;
}

.welcome-prompt-desc {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  line-height: 1.4;
}

.chat-welcome-hint {
  margin-top: 24px;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

/* Legacy empty state (kept for compatibility) */
.chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--color-text-muted);
  padding: 40px 20px;
}

.chat-empty-icon {
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, var(--color-primary-500), #8b5cf6);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-empty-icon svg {
  width: 28px;
  height: 28px;
  color: #fff;
}

.chat-empty p {
  font-size: var(--text-base);
  margin: 0;
}

.chat-empty-hint {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

/* ============================================
   6. MESSAGES
   ============================================ */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.06) transparent;
}

.messages::-webkit-scrollbar { width: 6px; }
.messages::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 3px;
}

/* Message row */
.message {
  display: flex;
  gap: 12px;
  animation: messageIn 0.3s ease-out;
  max-width: 768px;
  margin: 0 auto;
  width: 100%;
}

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

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

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

/* Avatar */
.message-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: var(--text-sm);
  font-weight: 600;
  margin-top: 2px;
}

.message.assistant .message-avatar {
  background: linear-gradient(135deg, var(--color-primary-500), #8b5cf6);
  color: #fff;
}

.message.user .message-avatar {
  background: var(--color-gray-200);
  color: var(--color-text-secondary);
  order: 1;
}

/* ============================================
   7. MESSAGE BUBBLES
   ============================================ */
.bubble {
  max-width: 75%;
  padding: 12px 16px;
  border-radius: var(--radius-xl);
  line-height: 1.6;
  word-wrap: break-word;
  position: relative;
}

/* User bubble */
.message.user .bubble {
  background: var(--color-primary-500);
  color: #fff;
  border-radius: 16px 16px 4px 16px;
  white-space: pre-wrap;
  box-shadow: var(--shadow-sm);
}

/* Assistant bubble */
.message.assistant .bubble {
  background: var(--color-white);
  color: var(--color-gray-900);
  border-radius: 16px 16px 16px 4px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-gray-100);
  white-space: normal;
  max-width: 85%;
}

.bubble.error {
  background: var(--color-error-bg) !important;
  color: var(--color-error) !important;
  border-color: #fecaca !important;
}

/* Message actions bar */
.message-actions {
  display: flex;
  gap: 4px;
  margin-top: 8px;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.message:hover .message-actions {
  opacity: 1;
}

.message-action-btn {
  background: none;
  border: none;
  padding: 4px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.message-action-btn:hover {
  background: var(--color-gray-100);
  color: var(--color-gray-600);
}

.message-action-btn svg {
  width: 16px;
  height: 16px;
}

/* ============================================
   8. CODE BLOCKS
   ============================================ */
.message.assistant .bubble code {
  background: var(--color-gray-100);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.875em;
  font-family: var(--font-mono);
  color: #e11d48;
}

.message.assistant .bubble pre {
  background: #1e293b;
  color: #e2e8f0;
  border-radius: var(--radius-md);
  padding: 0;
  overflow: hidden;
  margin: 10px 0;
  font-size: 13px;
  line-height: 1.6;
  border: 1px solid #334155;
}

.message.assistant .bubble pre.mermaid {
  background: #fff;
  border: 1px solid #e2e8f0;
  max-height: none;
  text-align: center;
  padding: 16px;
  overflow-x: auto;
}

.message.assistant .bubble pre.mermaid svg {
  max-width: 100%;
  height: auto;
}

.message.assistant .bubble pre code {
  background: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
  border-radius: 0;
  display: block;
  overflow-x: auto;
  padding: 16px;
}

/* Code block header */
.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: #0f172a;
  font-size: var(--text-xs);
  color: #94a3b8;
  font-family: var(--font-sans);
}

.code-block-lang {
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
}

.code-copy-btn {
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 2px;
  display: flex;
  align-items: center;
  font-size: var(--text-xs);
  font-family: var(--font-sans);
  gap: 4px;
  transition: color var(--transition-fast);
}

.code-copy-btn:hover {
  color: #e2e8f0;
}

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

/* ============================================
   9. TYPING & SEARCHING INDICATORS
   ============================================ */
.typing-indicator {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  padding: 4px 0;
}

.typing-indicator span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-text-muted);
  animation: typingDot 1.4s ease-in-out infinite;
}

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

@keyframes typingDot {
  0%, 60%, 100% { opacity: 0.3; transform: scale(0.85); }
  30% { opacity: 1; transform: scale(1); }
}

.bubble.searching {
  background: var(--color-tool-bg) !important;
  color: var(--color-tool) !important;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: var(--text-sm);
  padding: 10px 16px;
  border-color: #bfdbfe !important;
}

.search-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid #bfdbfe;
  border-top-color: var(--color-tool);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================
   10. CHAT INPUT
   ============================================ */
.chat-input-form {
  padding: 16px 24px 24px;
  background: var(--color-bg);
  flex-shrink: 0;
}

.input-wrapper {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  background: var(--color-white);
  border: 1px solid var(--color-gray-200);
  border-radius: var(--radius-lg);
  padding: 8px 8px 8px 16px;
  box-shadow: var(--shadow-md);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.input-wrapper:focus-within {
  border-color: var(--color-primary-500);
  box-shadow: var(--shadow-md), 0 0 0 3px rgb(14 165 233 / 0.1);
}

.chat-input {
  flex: 1;
  border: none;
  padding: 6px 0;
  font-size: var(--text-base);
  font-family: var(--font-sans);
  resize: none;
  outline: none;
  line-height: 1.5;
  max-height: 200px;
  background: transparent;
  color: var(--color-gray-900);
}

.chat-input::placeholder {
  color: var(--color-text-muted);
}

.chat-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Upload button */
.upload-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  color: var(--color-text-muted);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition-fast), background var(--transition-fast);
}

.upload-btn:hover {
  color: var(--color-primary-500);
  background: var(--color-primary-50);
}

/* Send button */
.send-btn {
  background: var(--color-primary-500);
  color: #fff;
  border: none;
  border-radius: var(--radius-full);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all var(--transition-fast);
  padding: 0;
  opacity: 0.4;
}

.send-btn:not(:disabled) {
  opacity: 1;
}

.send-btn svg {
  width: 16px;
  height: 16px;
}

.send-btn:hover:not(:disabled) {
  background: var(--color-primary-600);
}

.send-btn:active:not(:disabled) {
  transform: scale(0.92);
}

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

.stop-btn {
  background: var(--color-error, #ef4444);
  color: #fff;
  border: none;
  border-radius: var(--radius-full);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all var(--transition-fast);
  padding: 0;
}

.stop-btn svg {
  width: 14px;
  height: 14px;
}

.stop-btn:hover:not(:disabled) {
  filter: brightness(1.1);
}

.stop-btn:active:not(:disabled) {
  transform: scale(0.92);
}

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

/* ============================================
   11. THINKING & TOOL USE
   ============================================ */
.thinking-block {
  margin-bottom: 10px;
  border-left: 3px solid var(--color-thinking);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--color-thinking-bg);
}

.thinking-block summary {
  padding: 8px 12px;
  font-size: var(--text-xs);
  color: var(--color-thinking);
  cursor: pointer;
  user-select: none;
  font-weight: 500;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}

.thinking-block summary::before {
  content: "";
  display: inline-block;
  width: 0;
  height: 0;
  border-left: 5px solid var(--color-thinking);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: transform var(--transition-fast);
}

.thinking-block[open] summary::before {
  transform: rotate(90deg);
}

.thinking-block summary::-webkit-details-marker {
  display: none;
}

.thinking-content {
  padding: 4px 12px 10px;
  font-size: 13px;
  color: var(--color-text-secondary);
  white-space: pre-wrap;
  word-wrap: break-word;
  line-height: 1.55;
}

.sub-agent-block {
  margin-bottom: 10px;
  border: 1px solid var(--color-primary-100);
  border-left: 3px solid var(--color-primary-500);
  border-radius: var(--radius-md);
  background: var(--color-primary-50);
  overflow: hidden;
}

.sub-agent-block summary {
  padding: 8px 12px;
  font-size: var(--text-xs);
  color: var(--color-primary-900);
  cursor: pointer;
  user-select: none;
  font-weight: 600;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 7px;
}

.sub-agent-block summary::before {
  content: "";
  display: inline-block;
  width: 0;
  height: 0;
  border-left: 5px solid var(--color-primary-500);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: transform var(--transition-fast);
}

.sub-agent-block[open] summary::before {
  transform: rotate(90deg);
}

.sub-agent-block summary::-webkit-details-marker {
  display: none;
}

.sub-agent-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.sub-agent-thinking,
.sub-agent-output {
  margin: 0 12px 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(14, 165, 233, 0.18);
}

.sub-agent-section-label {
  margin-bottom: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-muted);
}

.sub-agent-thinking-content {
  font-size: 13px;
  color: var(--color-text-secondary);
  white-space: pre-wrap;
  word-wrap: break-word;
  line-height: 1.55;
}

.sub-agent-output {
  color: var(--color-gray-900);
}

.tool-use-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 4px 0;
  padding: 5px 12px;
  font-size: var(--text-xs);
  color: var(--color-tool);
  background: var(--color-tool-bg);
  border-radius: var(--radius-full);
  border: 1px solid #bfdbfe;
  font-weight: 500;
}

.tool-use-tag svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.kb-tool-use-tag {
  background: rgba(139, 92, 246, 0.08);
  border-color: rgba(139, 92, 246, 0.3);
  color: #8b5cf6;
}

.export-tool-use-tag {
  background: rgba(16, 185, 129, 0.08);
  border-color: rgba(16, 185, 129, 0.3);
  color: #10b981;
}

/* ============================================
   12. FILE UPLOAD & PREVIEW
   ============================================ */
.file-preview-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 24px 8px;
}

.file-preview-list:empty {
  display: none;
}

.file-preview-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--color-white);
  border: 1px solid var(--color-gray-200);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--color-gray-900);
}

.file-preview-icon {
  color: var(--color-primary-500);
  display: flex;
  align-items: center;
}

.file-preview-name {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-preview-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-muted);
  font-size: 1.1rem;
  line-height: 1;
  padding: 0 2px;
  margin-left: 2px;
  transition: color var(--transition-fast);
}

.file-preview-remove:hover {
  color: var(--color-error);
}

.image-preview-thumb {
  width: 32px;
  height: 32px;
  object-fit: cover;
  border-radius: 4px;
}

/* User bubble: images and files */
.bubble-images {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.bubble-images a {
  display: block;
  line-height: 0;
}

.bubble-image {
  max-width: 300px;
  max-height: 200px;
  border-radius: var(--radius-md);
  object-fit: cover;
  cursor: pointer;
  transition: opacity var(--transition-fast);
}

.bubble-image:hover {
  opacity: 0.9;
}

.bubble-files {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.bubble-file-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.18);
  border-radius: var(--radius-md);
  font-size: var(--text-xs);
  color: #fff;
  text-decoration: none;
  transition: background var(--transition-fast);
}

.bubble-file-link:hover {
  background: rgba(255, 255, 255, 0.3);
  text-decoration: none;
  color: #fff;
}

.bubble-file-link svg {
  flex-shrink: 0;
}

/* File download link */
.file-download-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 8px 0 4px;
  padding: 6px 12px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: var(--radius-md);
  color: var(--color-primary-600);
  text-decoration: none;
  font-size: var(--text-sm);
  transition: all var(--transition-fast);
}

.file-download-tag:hover {
  background: #dbeafe;
  text-decoration: none;
}

.file-download-tag svg {
  width: 14px;
  height: 14px;
}

/* ============================================
   13. MARKDOWN CONTENT
   ============================================ */
.message.assistant .bubble p { margin: 0 0 10px; }
.message.assistant .bubble p:last-child { margin-bottom: 0; }

.message.assistant .bubble ul,
.message.assistant .bubble ol {
  margin: 6px 0 10px;
  padding-left: 22px;
}

.message.assistant .bubble li { margin-bottom: 4px; }
.message.assistant .bubble li > p { margin-bottom: 4px; }

.message.assistant .bubble blockquote {
  border-left: 3px solid var(--color-primary-500);
  margin: 10px 0;
  padding: 8px 16px;
  color: var(--color-text-secondary);
  background: var(--color-primary-50);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.message.assistant .bubble table {
  border-collapse: collapse;
  margin: 10px 0;
  font-size: 0.9em;
  width: auto;
}

.message.assistant .bubble th,
.message.assistant .bubble td {
  border: 1px solid var(--color-border);
  padding: 8px 12px;
  text-align: left;
}

.message.assistant .bubble th {
  background: var(--color-gray-50);
  font-weight: 600;
  color: var(--color-gray-900);
}

.message.assistant .bubble h1,
.message.assistant .bubble h2,
.message.assistant .bubble h3,
.message.assistant .bubble h4 {
  margin: 16px 0 8px;
  line-height: 1.3;
  color: var(--color-gray-900);
}

.message.assistant .bubble h1 { font-size: 1.3em; }
.message.assistant .bubble h2 { font-size: 1.15em; }
.message.assistant .bubble h3 { font-size: 1.05em; }

.message.assistant .bubble hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 12px 0;
}

.message.assistant .bubble a {
  color: var(--color-primary-500);
  text-decoration: none;
  font-weight: 500;
}

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

.message.assistant .bubble strong {
  font-weight: 600;
  color: var(--color-gray-900);
}

.message.assistant .bubble img {
  max-width: 100%;
  border-radius: var(--radius-md);
  margin: 8px 0;
}

/* ============================================
   14. AGENT SELECTION PANEL (legacy overlay)
   ============================================ */
.agent-panel {
  display: none;
  position: fixed;
  top: 0;
  left: 260px;
  width: 360px;
  height: 100%;
  background: var(--color-white);
  border-right: 1px solid var(--color-border);
  z-index: 100;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}

.agent-panel.open {
  display: flex;
}

.agent-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
}

.agent-panel-header h3 {
  margin: 0;
  font-size: var(--text-base);
  color: var(--color-gray-900);
}

.agent-panel-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--color-text-muted);
  padding: 0 4px;
}

.agent-panel-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.agent-pick-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: background var(--transition-fast);
  border: 1px solid transparent;
  background: transparent;
  width: 100%;
  text-align: left;
  font-family: var(--font-sans);
  color: var(--color-text-secondary);
}

.agent-pick-card:hover {
  background: var(--color-gray-50);
  border-color: var(--color-gray-200);
  color: var(--color-gray-900);
}

.agent-pick-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 600;
  font-size: var(--text-sm);
  flex-shrink: 0;
}

.agent-pick-icon.default {
  background: var(--color-primary-50);
  color: var(--color-primary-500);
}

.agent-pick-icon svg {
  width: 20px;
  height: 20px;
}

.agent-pick-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.agent-pick-info strong {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-gray-900);
}

.agent-pick-info span {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============================================
   15. AGENT COLOR VARIANTS
   ============================================ */
:root {
  --agent-blue: #3b82f6;
  --agent-purple: #8b5cf6;
  --agent-green: #10b981;
  --agent-red: #ef4444;
  --agent-orange: #f97316;
  --agent-violet: #7c3aed;
  --agent-yellow: #eab308;
  --agent-teal: #14b8a6;
  --agent-pink: #ec4899;
}

/* ============================================
   16. RESPONSIVE
   ============================================ */
/* Mobile: < 768px — Single column */
@media (max-width: 767px) {
  .agent-sidebar {
    position: fixed;
    left: -260px;
    top: 0;
    height: 100dvh;
    z-index: 40;
    transition: left var(--transition-slow);
    box-shadow: var(--shadow-xl);
  }

  .agent-sidebar.open {
    left: 0;
  }

  .history-sidebar {
    position: fixed;
    left: -280px;
    top: 0;
    height: 100dvh;
    z-index: 40;
    transition: left var(--transition-slow);
    box-shadow: var(--shadow-xl);
  }

  .history-sidebar.open {
    left: 0;
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 35;
  }

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

  .messages {
    padding: 16px;
    gap: 16px;
  }

  .bubble {
    max-width: 88%;
  }

  .chat-input-form {
    padding: 12px 16px 16px;
  }

  .message-avatar {
    width: 28px;
    height: 28px;
    font-size: 12px;
  }

  .message {
    gap: 8px;
  }

  /* Mobile header with toggle buttons */
  .chat-mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: var(--color-white);
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
  }

  .chat-mobile-header .mobile-toggle-btn {
    background: none;
    border: none;
    padding: 6px;
    cursor: pointer;
    color: var(--color-text-secondary);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
  }

  .chat-mobile-header .mobile-toggle-btn:hover {
    background: var(--color-gray-100);
  }

  .chat-mobile-header .mobile-title {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--color-gray-900);
  }
}

/* Tablet: 768px - 1023px — Two columns (hide agent sidebar) */
@media (min-width: 768px) and (max-width: 1023px) {
  .agent-sidebar {
    position: fixed;
    left: -260px;
    top: 0;
    height: 100dvh;
    z-index: 40;
    transition: left var(--transition-slow);
    box-shadow: var(--shadow-xl);
  }

  .agent-sidebar.open {
    left: 0;
  }

  .chat-mobile-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--color-white);
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
  }

  .chat-mobile-header .mobile-toggle-btn {
    background: none;
    border: none;
    padding: 6px;
    cursor: pointer;
    color: var(--color-text-secondary);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
  }

  .chat-mobile-header .mobile-toggle-btn:hover {
    background: var(--color-gray-100);
  }

  .chat-mobile-header .mobile-title {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--color-gray-900);
  }

  .history-sidebar {
    width: 240px;
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 35;
  }

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

/* Desktop: 1024px+ — Three columns */
@media (min-width: 1024px) {
  .chat-mobile-header {
    display: none;
  }

  .sidebar-overlay {
    display: none !important;
  }
}

/* Large: 1440px+ */
@media (min-width: 1440px) {
  .message {
    max-width: 960px;
  }
}

/* ============================================
   17. REDUCED MOTION
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  .message { animation: none; }
  .typing-indicator span,
  .search-spinner { animation: none; }
  * { transition-duration: 0ms !important; }
}

/* ============================================
   18. AGENTS PAGE (Preserved)
   ============================================ */
.agents-page {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px;
}

.agents-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 32px;
}

.agents-header h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-gray-900);
}

.agents-subtitle {
  margin: 4px 0 0;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.agents-actions {
  display: flex;
  gap: 8px;
}

.agent-category { margin-bottom: 32px; }

.category-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-gray-900);
  margin: 0 0 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--color-border);
}

.agent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.agent-card-admin {
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 16px;
  transition: box-shadow var(--transition-fast), border-color var(--transition-fast);
}

.agent-card-admin:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--color-primary-500);
}

.agent-card-header-admin {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.agent-color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.agent-source-badge {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-weight: 500;
}

.agent-source-badge.submodule { background: #eff6ff; color: #3b82f6; }
.agent-source-badge.custom { background: #f0fdf4; color: #16a34a; }

.agent-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-gray-900);
  margin: 0 0 6px;
}

.agent-desc {
  font-size: 0.8rem;
  color: var(--color-text-secondary);
  margin: 0 0 12px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.agent-meta {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.agent-meta-item {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: var(--color-gray-100);
  color: var(--color-text-secondary);
}

.agent-enabled { background: #f0fdf4; color: #16a34a; }
.agent-disabled { background: #fef2f2; color: #ef4444; }
.agent-card-actions { display: flex; gap: 6px; }

/* ============================================
   19. BUTTONS & FORMS (Preserved)
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: none;
  text-decoration: none;
  font-family: var(--font-sans);
}

.btn-primary { background: var(--color-primary-500); color: #fff; }
.btn-primary:hover { background: var(--color-primary-600); }
.btn-secondary { background: var(--color-white); color: var(--color-text-secondary); border: 1px solid var(--color-border); }
.btn-secondary:hover { background: var(--color-gray-50); border-color: var(--color-text-muted); }
.btn-danger { background: var(--color-error); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-sm { padding: 4px 10px; font-size: var(--text-xs); }

.agent-form-page {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px;
  max-width: 720px;
}

.agent-form-page h1 {
  margin: 0 0 24px;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-gray-900);
}

.agent-form { display: flex; flex-direction: column; gap: 20px; }

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: var(--text-sm); font-weight: 500; color: var(--color-gray-900); }

.form-input {
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: var(--font-sans);
  color: var(--color-gray-900);
  background: var(--color-white);
  transition: border-color var(--transition-fast);
}

.form-input:focus {
  outline: none;
  border-color: var(--color-primary-500);
  box-shadow: 0 0 0 3px rgb(14 165 233 / 0.1);
}

.form-input:disabled {
  background: var(--color-gray-50);
  color: var(--color-text-muted);
}

.form-textarea-lg {
  min-height: 300px;
  resize: vertical;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.5;
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-hint { font-size: var(--text-xs); color: var(--color-text-muted); }

.form-errors {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  color: var(--color-error);
  font-size: var(--text-sm);
}

.form-errors p { margin: 0; }

.range-wrapper { display: flex; align-items: center; gap: 12px; }
.form-range { flex: 1; accent-color: var(--color-primary-500); }
.range-value { font-size: var(--text-sm); font-weight: 600; color: var(--color-gray-900); min-width: 2.5em; text-align: center; }

.checkbox-group { display: flex; gap: 16px; }
.checkbox-label { display: flex; align-items: center; gap: 6px; font-size: var(--text-sm); color: var(--color-gray-900); cursor: pointer; }

.form-actions {
  display: flex;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--color-border);
}

/* ============================================
   20. KNOWLEDGE BASE (Preserved)
   ============================================ */
.kb-type-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.kb-type-badge.wiki { background: #f0fdf4; color: #16a34a; }
.kb-type-badge.rag { background: #eff6ff; color: #3b82f6; }

.kb-description {
  color: var(--color-text-secondary);
  margin-bottom: 24px;
  line-height: 1.6;
}

.kb-page-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.kb-page-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--color-white);
  border-bottom: 1px solid var(--color-border);
  transition: background var(--transition-fast);
}

.kb-page-item:last-child { border-bottom: none; }
.kb-page-item:hover { background: var(--color-primary-50); }

.kb-page-info { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }

.kb-page-type {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 500;
  background: var(--color-gray-100);
  color: var(--color-text-secondary);
}

.kb-page-title {
  font-weight: 500;
  color: var(--color-gray-900);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kb-page-title:hover { color: var(--color-primary-500); }
.kb-page-meta { font-size: var(--text-xs); color: var(--color-text-muted); white-space: nowrap; }
.kb-page-actions { display: flex; gap: 6px; flex-shrink: 0; }

.kb-breadcrumb { font-size: var(--text-sm); color: var(--color-text-muted); margin-bottom: 4px; }
.kb-breadcrumb a { color: var(--color-primary-500); text-decoration: none; }
.kb-breadcrumb a:hover { text-decoration: underline; }

.kb-page-content {
  margin-top: 16px;
  padding: 20px;
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  line-height: 1.8;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--color-text-muted);
  font-size: var(--text-base);
}

/* Knowledge Architect */
.ka-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  padding: 40px;
}

.ka-welcome-icon { color: var(--color-primary-500); margin-bottom: 16px; }
.ka-welcome h1, .ka-welcome h2 { font-size: 1.5rem; margin: 0 0 8px; }
.ka-welcome > p { color: var(--color-text-muted); margin: 0 0 32px; }

.ka-features { display: flex; gap: 24px; margin-bottom: 24px; }

.ka-feature {
  display: flex;
  flex-direction: column;
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: left;
  min-width: 160px;
}

.ka-feature strong { margin-bottom: 4px; font-size: var(--text-base); }
.ka-feature span { font-size: var(--text-xs); color: var(--color-text-muted); }

.ka-hint { color: var(--color-text-muted); font-size: var(--text-sm); }

.ka-warning {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  margin-top: 16px;
}

.ka-warning code {
  background: rgba(245, 158, 11, 0.15);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: var(--text-xs);
}

.kb-select-link {
  display: flex !important;
  align-items: center;
  gap: 8px;
  padding: 10px 12px !important;
  border-radius: var(--radius-md);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  color: var(--color-gray-900);
  font-size: var(--text-sm);
}

.kb-select-link:hover { background: var(--color-gray-100); }
.kb-select-name { flex: 1; }
.kb-select-count { font-size: var(--text-xs); color: var(--color-text-muted); }

/* ============================================
   21. ADMIN LAYOUT (Preserved)
   ============================================ */
.admin-layout {
  display: flex;
  height: 100dvh;
  background: var(--color-bg);
}

.admin-sidebar {
  width: 240px;
  background: #0c1222;
  color: #94a3b8;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  overflow-y: auto;
}

.admin-sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.admin-brand-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.admin-brand-icon svg { width: 16px; height: 16px; color: #fff; }

.admin-brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.admin-brand-text strong { font-size: var(--text-sm); color: #f1f5f9; font-weight: 600; }
.admin-brand-text span { font-size: 0.7rem; color: #64748b; text-transform: uppercase; letter-spacing: 0.06em; }

.admin-nav { display: flex; flex-direction: column; padding: 8px; gap: 2px; }

.admin-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: #94a3b8;
  text-decoration: none;
  font-size: var(--text-sm);
  font-weight: 450;
  transition: all var(--transition-fast);
}

.admin-nav-item:hover, .admin-nav-item:focus-visible {
  background: rgba(255, 255, 255, 0.06);
  color: #e2e8f0;
}

.admin-nav-item:focus-visible,
.admin-mobile-toggle:focus-visible,
.admin-sidebar-extension .kb-select-link:focus-visible {
  outline: 2px solid #60a5fa;
  outline-offset: 2px;
}

.admin-nav-item.active {
  background: rgba(37, 99, 235, 0.15);
  color: #60a5fa;
  font-weight: 500;
}

.admin-nav-icon { width: 18px; height: 18px; flex-shrink: 0; }

.admin-body { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  height: 56px;
  background: var(--color-white);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

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

.admin-mobile-toggle {
  display: none;
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  color: var(--color-text-secondary);
}

.admin-mobile-toggle svg { width: 20px; height: 20px; }

.admin-breadcrumb {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.admin-breadcrumb a { color: var(--color-text-secondary); text-decoration: none; transition: color var(--transition-fast); }
.admin-breadcrumb a:hover { color: var(--color-primary-500); }
.admin-breadcrumb .separator { color: var(--color-border); }
.admin-breadcrumb .current { color: var(--color-gray-900); font-weight: 500; }

.admin-content { flex: 1; overflow-y: auto; padding: 28px 32px; }

.admin-page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 28px;
}

.admin-page-header h1 {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--color-gray-900);
  letter-spacing: -0.01em;
}

.admin-page-subtitle { margin: 4px 0 0; font-size: var(--text-sm); color: var(--color-text-muted); }
.admin-page-actions { display: flex; gap: 8px; flex-shrink: 0; }

.admin-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.admin-card {
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 20px;
  transition: box-shadow var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
  position: relative;
}

.admin-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
  border-color: #c7d2fe;
}

.admin-card-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }

.admin-card-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: var(--text-sm);
  color: #fff;
  flex-shrink: 0;
}

.admin-card-icon svg { width: 18px; height: 18px; }
.admin-card-icon.kb-icon { background: linear-gradient(135deg, #2563eb, #0ea5e9); }

.admin-agent-icon-large { width: 40px; height: 40px; font-size: var(--text-base); }

.admin-title-row { display: flex; align-items: center; gap: 12px; }
.admin-detail-description { font-weight: 400 !important; }
.admin-pre-reset { margin: 0; }
.admin-field-spaced { margin-top: 16px; }
.admin-checkbox-wrap { flex-wrap: wrap; gap: 12px; }
.admin-section-spaced { margin-bottom: 24px; }

.admin-muted-copy { margin: 0; color: var(--color-text-secondary); line-height: 1.7; }

.admin-content-reset { margin-top: 0; border: none; padding: 0; background: transparent; }

.admin-sidebar-note { color: #64748b; padding: 8px 12px; margin: 0; font-size: var(--text-sm); }

.admin-welcome-panel {
  height: auto;
  min-height: calc(100dvh - 180px);
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
}

.admin-card-badges { display: flex; gap: 6px; }

.admin-card h3 { font-size: 0.95rem; font-weight: 600; color: var(--color-gray-900); margin: 0 0 6px; }

.admin-card-desc {
  font-size: 0.82rem;
  color: var(--color-text-secondary);
  margin: 0 0 16px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.admin-card-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.admin-card-meta { display: flex; gap: 6px; flex-wrap: wrap; }
.admin-card-actions { display: flex; gap: 6px; flex-shrink: 0; }

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 500;
}

.status-badge.active { background: #dcfce7; color: #15803d; }
.status-badge.inactive { background: #fef2f2; color: #dc2626; }
.status-badge.info { background: #eff6ff; color: #2563eb; }
.status-badge.source { background: #f0fdf4; color: #16a34a; }
.status-badge.preset { background: #eff6ff; color: #3b82f6; }

.status-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.status-badge.info::before,
.status-badge.source::before,
.status-badge.preset::before { display: none; }

.admin-section { margin-bottom: 32px; }

.admin-section-title {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin: 0 0 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--color-border);
}

.admin-form { max-width: 680px; display: flex; flex-direction: column; gap: 20px; }

.admin-form-section {
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 20px 24px;
}

.admin-form-section-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-gray-900);
  margin: 0 0 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--color-border);
}

.admin-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.admin-detail-item {
  padding: 12px 16px;
  background: var(--color-gray-50);
  border-radius: 8px;
  border: 1px solid var(--color-border);
}

.admin-detail-item label {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  font-weight: 500;
  margin-bottom: 4px;
}

.admin-detail-item p { margin: 0; font-size: var(--text-sm); color: var(--color-gray-900); font-weight: 500; }

.admin-list {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.admin-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--color-white);
  border-bottom: 1px solid var(--color-border);
  transition: background var(--transition-fast);
}

.admin-list-item:last-child { border-bottom: none; }
.admin-list-item:hover { background: var(--color-gray-50); }

.admin-list-info { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }

.admin-list-title {
  font-weight: 500;
  color: var(--color-gray-900);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-list-title:hover { color: var(--color-primary-500); }
.admin-list-meta { font-size: var(--text-xs); color: var(--color-text-muted); white-space: nowrap; }
.admin-list-actions { display: flex; gap: 6px; flex-shrink: 0; }

.admin-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
}

.admin-empty-icon {
  width: 48px;
  height: 48px;
  background: var(--color-gray-100);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  color: var(--color-text-muted);
}

.admin-empty-icon svg { width: 24px; height: 24px; }

.admin-empty h3 { font-size: var(--text-base); font-weight: 600; color: var(--color-gray-900); margin: 0 0 6px; }
.admin-empty p { font-size: var(--text-sm); color: var(--color-text-muted); margin: 0 0 20px; }

.admin-sidebar-extension {
  padding: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.admin-sidebar-extension .sidebar-section-title {
  padding: 8px 12px 6px;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #475569;
  font-weight: 600;
}

.admin-sidebar-extension .kb-select-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  color: #94a3b8;
  font-size: var(--text-sm);
  text-decoration: none;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  font-family: var(--font-sans);
}

.admin-sidebar-extension .kb-select-link:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #e2e8f0;
}

.admin-sidebar-extension .kb-select-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-sidebar-extension .kb-select-count { font-size: 0.72rem; color: #475569; flex-shrink: 0; }

.admin-sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 190;
  background: rgba(15, 23, 42, 0.42);
  border: none;
  padding: 0;
  cursor: pointer;
}

.admin-sidebar-backdrop:not([hidden]) { display: block; }

/* Admin responsive */
@media (max-width: 768px) {
  .admin-sidebar {
    position: fixed;
    top: 0;
    left: -240px;
    z-index: 200;
    height: 100dvh;
    transition: left 250ms ease;
  }

  .admin-sidebar.open { left: 0; }
  .admin-mobile-toggle { display: flex; }
  .admin-content { padding: 20px 16px; }
  .admin-card-grid { grid-template-columns: 1fr; }
  .admin-detail-grid { grid-template-columns: 1fr; }
  .admin-page-header { flex-direction: column; gap: 12px; }
  .admin-page-actions { width: 100%; }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .admin-sidebar { width: 200px; }
  .admin-card-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
}

/* ============================================
   Agent Transfer Notice
   ============================================ */
.agent-transfer-notice {
  background: var(--color-primary-50);
  border: 1px solid var(--color-primary-100);
  color: var(--color-primary-900);
  font-size: var(--text-sm);
  padding: 10px 14px !important;
}

.agent-transfer-notice .transfer-icon {
  margin-right: 6px;
}

/* ============================================
   22. HOME DASHBOARD
   ============================================ */
.chat-home-layout {
  min-height: 100dvh;
  padding: 20px;
  gap: 18px;
  background:
    radial-gradient(circle at top left, rgba(129, 140, 248, 0.12), transparent 24%),
    radial-gradient(circle at right center, rgba(244, 114, 182, 0.12), transparent 26%),
    linear-gradient(135deg, #f6f7ff 0%, #eef3ff 46%, #f9fbff 100%);
}

.chat-home-layout .chat-main,
.chat-home-layout .home-sidebar,
.chat-home-layout .home-nav {
  min-height: 0;
}

.home-nav {
  width: 92px;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 28px;
  box-shadow: 0 24px 60px rgba(88, 102, 148, 0.12);
  backdrop-filter: blur(18px);
  padding: 22px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
}

.home-nav-brand {
  display: flex;
  justify-content: center;
  width: 100%;
}

.home-nav-logo {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: linear-gradient(135deg, #4f46e5, #8b5cf6);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 16px 26px rgba(99, 102, 241, 0.3);
}

.home-nav-logo svg {
  width: 24px;
  height: 24px;
}

.home-nav-menu,
.home-nav-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.home-nav-footer {
  margin-top: auto;
}

.home-nav-item {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 8px;
  border-radius: 18px;
  text-decoration: none;
  color: #6c7693;
  transition: transform var(--transition-fast), background var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast);
}

.home-nav-item:hover {
  background: rgba(255, 255, 255, 0.86);
  color: #4f46e5;
  transform: translateY(-1px);
}

.home-nav-item.active {
  background: #fff;
  color: #4f46e5;
  box-shadow: 0 14px 34px rgba(113, 110, 255, 0.16);
}

.home-nav-item-static {
  cursor: default;
}

.home-nav-item-static:hover {
  transform: none;
  color: #6c7693;
  background: transparent;
}

.home-nav-item-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.home-nav-item-icon svg {
  width: 22px;
  height: 22px;
}

.home-nav-item-label {
  font-size: 0.82rem;
  font-weight: 500;
}

.home-sidebar {
  width: 366px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  flex-shrink: 0;
}

.home-panel {
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 30px;
  box-shadow: 0 24px 60px rgba(88, 102, 148, 0.1);
  backdrop-filter: blur(18px);
}

.agents-panel,
.conversations-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.agents-panel {
  flex: 1.08;
}

.conversations-panel {
  flex: 1;
}

.home-panel-header,
.home-panel-footer {
  padding: 22px 22px 0;
}

.home-panel-footer {
  padding: 0 22px 22px;
}

.home-panel-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: #1b2440;
}

.home-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.home-panel-action {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(103, 92, 255, 0.08);
  color: #635bff;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
}

.home-panel-action svg {
  width: 16px;
  height: 16px;
}

.home-panel-icons {
  display: flex;
  gap: 8px;
}

.home-icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid rgba(213, 219, 240, 0.7);
  background: #fff;
  color: #7581a3;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.home-icon-btn svg {
  width: 16px;
  height: 16px;
}

.home-agents-list {
  padding: 18px 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
}

.home-agent-card {
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid rgba(227, 231, 245, 0.9);
  border-radius: 22px;
  padding: 16px 18px;
  min-height: 92px;
  align-items: flex-start;
  gap: 14px;
  box-shadow: 0 12px 28px rgba(108, 118, 147, 0.07);
}

.home-agent-card.active {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(241, 244, 255, 0.94));
  border-color: rgba(131, 119, 255, 0.38);
  box-shadow: 0 18px 40px rgba(103, 92, 255, 0.16);
}

.home-agent-avatar {
  width: 48px;
  height: 48px;
  border-radius: 18px;
  font-size: 1rem;
  box-shadow: inset 0 0 0 4px rgba(255, 255, 255, 0.6);
}

.home-agent-avatar.default-avatar {
  background: linear-gradient(135deg, #dbeafe, #ede9fe);
  color: #635bff;
}

.home-agent-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}

.home-agent-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.66rem;
  font-weight: 700;
  color: #635bff;
  background: rgba(99, 91, 255, 0.12);
}

.home-agent-status {
  position: absolute;
  left: 80px;
  bottom: 14px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: #7d87a8;
}

.home-agent-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9ca3af;
}

.home-agent-status-dot.online {
  background: #4ade80;
}

.home-agent-status-dot.idle {
  background: #f59e0b;
}

.home-agent-status-dot.busy {
  background: #f87171;
}

.home-footer-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(251, 252, 255, 0.9);
  color: #635bff;
  text-decoration: none;
  font-weight: 600;
}

.home-footer-link svg {
  width: 18px;
  height: 18px;
}

.home-conversation-list {
  padding: 18px 18px 14px;
  gap: 10px;
}

.conversation-list-card {
  display: block;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid rgba(227, 231, 245, 0.9);
  box-shadow: 0 10px 24px rgba(108, 118, 147, 0.06);
}

.conversation-list-card.active,
.conversation-list-card:hover {
  background: linear-gradient(180deg, rgba(248, 249, 255, 0.98), rgba(241, 244, 255, 0.95));
  border-color: rgba(131, 119, 255, 0.28);
}

.conversation-list-card.active::before {
  left: 8px;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 999px;
}

.conversation-list-card-title-row,
.conversation-list-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.conversation-list-card-title-row {
  margin-bottom: 6px;
}

.conversation-list-card-title {
  color: #1f2944;
  font-size: 0.95rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conversation-list-card-time,
.conversation-list-card-meta {
  font-size: 0.78rem;
  color: #8a93af;
}

.conversation-list-card-meta span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-list-empty {
  padding: 28px 14px;
  text-align: center;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

.chat-home-main {
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 34px;
  box-shadow: 0 28px 72px rgba(88, 102, 148, 0.13);
  backdrop-filter: blur(20px);
  overflow: hidden;
}

.chat-home-agent-bar {
  background: transparent;
  border-bottom: none;
  padding: 14px 32px 0;
}

.chat-home-messages {
  padding: 0 24px 24px;
}

.chat-home-messages:has(.message) {
  padding-top: 24px;
}

.chat-home-main .chat-kb-bar {
  margin: 10px 32px 0;
  border: 1px solid rgba(227, 231, 245, 0.95);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
}

.chat-home-welcome {
  max-width: 100%;
  width: 100%;
  padding: 18px 14px 0;
  margin: 0;
  text-align: left;
  justify-content: flex-start;
}

.chat-home-topbar {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 44px;
}

.chat-home-search {
  min-width: 280px;
  max-width: 420px;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(227, 231, 245, 0.95);
  box-shadow: 0 12px 28px rgba(108, 118, 147, 0.06);
  color: #9aa3bd;
}

.chat-home-search svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.chat-home-search kbd {
  margin-left: auto;
  padding: 4px 8px;
  border-radius: 999px;
  background: #f4f6ff;
  color: #8d96b3;
  font-size: 0.76rem;
}

.chat-home-topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-home-circle-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(227, 231, 245, 0.95);
  background: rgba(255, 255, 255, 0.92);
  color: #7b84a2;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 12px 26px rgba(108, 118, 147, 0.06);
}

.chat-home-circle-btn svg,
.chat-home-primary-btn svg {
  width: 18px;
  height: 18px;
}

.chat-home-primary-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: none;
  padding: 14px 22px;
  border-radius: 999px;
  background: linear-gradient(135deg, #635bff, #7c5cff);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 18px 40px rgba(103, 92, 255, 0.28);
}

.chat-home-hero {
  width: 100%;
  min-height: 320px;
  border-radius: 34px;
  padding: 58px 38px 42px;
  margin-bottom: 24px;
  background:
    radial-gradient(circle at 12% 20%, rgba(255, 255, 255, 0.92), transparent 24%),
    radial-gradient(circle at 88% 30%, rgba(153, 170, 255, 0.2), transparent 18%),
    linear-gradient(135deg, rgba(255, 255, 255, 0.98) 0%, rgba(245, 247, 255, 0.96) 44%, rgba(239, 240, 255, 0.98) 100%);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.chat-home-hero::before,
.chat-home-hero::after {
  content: "";
  position: absolute;
  border-radius: 999px;
  filter: blur(0.4px);
}

.chat-home-hero::before {
  width: 560px;
  height: 220px;
  left: -72px;
  bottom: 20px;
  background: linear-gradient(135deg, rgba(160, 174, 255, 0.18), rgba(255, 255, 255, 0));
  transform: rotate(14deg);
}

.chat-home-hero::after {
  width: 420px;
  height: 260px;
  right: -40px;
  bottom: -38px;
  background: linear-gradient(135deg, rgba(245, 154, 213, 0.16), rgba(133, 124, 255, 0.14));
  transform: rotate(-22deg);
}

.chat-home-chip,
.chat-home-hero h1,
.chat-home-hero p {
  position: relative;
  z-index: 1;
}

.chat-home-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  color: #525f7f;
  font-size: 0.95rem;
  box-shadow: 0 10px 22px rgba(108, 118, 147, 0.08);
  margin-bottom: 22px;
}

.chat-home-hero h1 {
  margin: 0 0 18px;
  font-size: clamp(2.2rem, 4vw, 3.9rem);
  line-height: 1.02;
  color: #18233d;
  letter-spacing: -0.04em;
}

.chat-home-hero h1 span {
  display: block;
  margin-top: 8px;
  background: linear-gradient(135deg, #635bff, #7a67ff, #5b8cff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.chat-home-hero p {
  max-width: 620px;
  margin: 0;
  font-size: 1.25rem;
  line-height: 1.6;
  color: #66718f;
}

.chat-home-router-entry {
  width: min(820px, 100%);
  margin: -20px auto 18px;
}

.chat-home-feature-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 22px;
}

.chat-home-main .chat-home-feature-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.chat-home-feature-card {
  min-height: 214px;
  border: 1px solid rgba(227, 231, 245, 0.92);
  border-radius: 28px;
  padding: 28px 22px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 18px 40px rgba(108, 118, 147, 0.08);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 14px;
  color: #1f2944;
  cursor: pointer;
  transition: transform var(--transition-normal), box-shadow var(--transition-normal), border-color var(--transition-normal);
  font-family: var(--font-sans);
}

.chat-home-feature-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 24px 48px rgba(103, 92, 255, 0.12);
  border-color: rgba(131, 119, 255, 0.34);
}

.chat-home-feature-link {
  text-decoration: none;
}

.chat-home-feature-card strong {
  font-size: 1.1rem;
}

.chat-home-feature-card p {
  margin: 0;
  color: #7a84a2;
  line-height: 1.6;
  font-size: 0.95rem;
}

.chat-home-feature-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #635bff;
}

.chat-home-feature-icon svg {
  width: 28px;
  height: 28px;
}

.chat-home-feature-icon.lilac { background: #f0e9ff; color: #8b5cf6; }
.chat-home-feature-icon.blue { background: #e9efff; color: #4f6bff; }
.chat-home-feature-icon.mint { background: #e8fbf0; color: #22c55e; }
.chat-home-feature-icon.amber { background: #fff1dd; color: #f59e0b; }
.chat-home-feature-icon.pink { background: #ffe8f5; color: #d946ef; }

.chat-home-input-form {
  padding: 0 24px 18px;
  background: transparent;
}

.chat-home-input-wrapper {
  padding: 0;
  border: none;
  border-radius: 34px;
  background: transparent;
  box-shadow: none;
}

.chat-home-input-shell {
  width: 100%;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(209, 215, 237, 0.96);
  border-radius: 30px;
  padding: 18px 18px 14px;
  box-shadow: 0 22px 50px rgba(108, 118, 147, 0.1);
}

.chat-home-input {
  display: block;
  width: 100%;
  min-height: 34px;
  padding: 0;
  font-size: 1.05rem;
}

.chat-home-input-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
}

.chat-home-input-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-home-toolbar-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(227, 231, 245, 0.95);
  background: #fff;
  color: #66718f;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.chat-home-toolbar-btn svg {
  width: 18px;
  height: 18px;
}

.chat-home-send-btn {
  width: 44px;
  height: 44px;
}

.chat-home-security-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 14px;
  color: #8b94af;
  font-size: 0.88rem;
}

.chat-home-security-note svg {
  width: 16px;
  height: 16px;
}

@media (max-width: 1439px) {
  .chat-home-layout {
    padding: 14px;
    gap: 14px;
  }

  .home-sidebar {
    width: 320px;
  }

  .chat-home-feature-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .chat-home-main .chat-home-feature-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1199px) {
  .chat-home-layout {
    display: grid;
    grid-template-columns: 84px 300px minmax(0, 1fr);
  }

  .home-sidebar {
    width: 100%;
  }

  .chat-home-feature-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .chat-home-main .chat-home-feature-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .chat-home-hero {
    padding: 44px 26px 34px;
  }
}

@media (max-width: 1023px) {
  .chat-home-layout {
    display: flex;
    padding: 0;
    gap: 0;
    background: linear-gradient(180deg, #f5f7ff 0%, #eef2ff 100%);
  }

  .home-nav {
    display: none;
  }

  .home-sidebar {
    width: auto;
    display: contents;
  }

  .agents-panel,
  .conversations-panel {
    position: fixed;
    top: 0;
    bottom: 0;
    left: -360px;
    width: min(360px, calc(100vw - 28px));
    z-index: 40;
    border-radius: 0 28px 28px 0;
    transition: left var(--transition-slow);
  }

  .agents-panel.open,
  .conversations-panel.open {
    left: 0;
  }

  .chat-home-main {
    border-radius: 0;
    border: none;
    box-shadow: none;
    background: transparent;
  }

  .chat-home-messages {
    padding: 0 12px 16px;
  }

  .chat-home-topbar {
    display: none;
  }

  .chat-home-welcome {
    padding-top: 8px;
  }

  .chat-home-router-entry {
    width: 100%;
    margin: -12px 0 16px;
  }

  .chat-home-feature-grid {
    grid-template-columns: 1fr;
  }

  .chat-home-main .chat-kb-bar {
    margin: 8px 16px 0;
  }

  .chat-home-input-form {
    padding: 0 12px 14px;
  }

  .chat-home-agent-bar {
    padding: 10px 16px 0;
  }
}

@media (max-width: 767px) {
  .chat-home-hero {
    min-height: 0;
    padding: 34px 18px 28px;
    border-radius: 26px;
  }

  .chat-home-hero h1 {
    font-size: 2.2rem;
  }

  .chat-home-hero p {
    font-size: 1rem;
  }

  .chat-home-feature-card {
    min-height: 0;
    padding: 22px 18px;
    border-radius: 24px;
  }

  .chat-home-input-shell {
    border-radius: 24px;
    padding: 16px 14px 12px;
  }
}
