/* ============================================
   RAG ChatBot — Document Intelligence Platform
   Theme: Light (Exact Screenshot Match) & Pure Dark (Gray & Black, No Blue)
   ============================================ */

/* --- Reset & Base Variables --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root,
[data-theme="light"] {
  /* Surfaces */
  --bg-app: #ffffff;
  --bg-sidebar: #ffffff;
  --bg-header: #ffffff;
  --bg-card: #ffffff;
  --bg-hover: #f9fafb;
  --bg-active: #eff6ff;
  --bg-input: #ffffff;
  --bg-pill: #ffffff;
  --bg-pill-hover: #f3f4f6;

  /* Typography */
  --text-primary: #111827;
  --text-secondary: #6b7280;
  --text-tertiary: #9ca3af;
  --text-quaternary: #e5e7eb;

  /* Brand Accents */
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --primary-light-border: #dbeafe;
  
  /* Mint / Grounded Engine */
  --mint-bg: #ecfdf5;
  --mint-text: #059669;
  --mint-border: #a7f3d0;

  /* Status Colors */
  --status-green: #22c55e;
  --status-green-pulse: rgba(34, 197, 94, 0.3);
  --status-error: #ef4444;
  --status-error-bg: #fef2f2;
  --status-error-border: #fecaca;

  /* Borders */
  --border-subtle: #f3f4f6;
  --border-default: #e5e7eb;
  --border-strong: #d1d5db;
  --border-focus: #3b82f6;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.04);
  --shadow-card: 0 2px 10px rgba(0, 0, 0, 0.04);
  --shadow-dropdown: 0 10px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);

  /* Avatars */
  --avatar-user-bg: #f3e8ff;
  --avatar-user-text: #9333ea;
  --avatar-ai-bg: #eff6ff;
  --avatar-ai-text: #2563eb;

  /* Badges */
  --badge-pdf: #ef4444;
  --badge-docx: #2563eb;
  --badge-md: #f97316;
  --badge-txt: #64748b;
}

/* ==================== PURE DARK MODE (GRAY & BLACK, NO BLUE) ==================== */
[data-theme="dark"] {
  /* Pure Black & Gray Surfaces — Absolutely NO Blue */
  --bg-app: #000000;
  --bg-sidebar: #0a0a0a;
  --bg-header: #0a0a0a;
  --bg-card: #121212;
  --bg-hover: #1c1c1c;
  --bg-active: #222222;
  --bg-input: #121212;
  --bg-pill: #161616;
  --bg-pill-hover: #222222;

  /* Neutral Monochrome Typography */
  --text-primary: #ffffff;
  --text-secondary: #a3a3a3;
  --text-tertiary: #737373;
  --text-quaternary: #404040;

  /* Brand Accents — Clean neutral contrast */
  --primary: #2563eb;
  --primary-hover: #3b82f6;
  --primary-light: #1f1f1f;
  --primary-light-border: #333333;

  /* Mint / Grounded Engine in Dark Mode */
  --mint-bg: rgba(16, 185, 129, 0.12);
  --mint-text: #34d399;
  --mint-border: rgba(16, 185, 129, 0.25);

  /* Status Colors */
  --status-green: #22c55e;
  --status-green-pulse: rgba(34, 197, 94, 0.35);
  --status-error: #f87171;
  --status-error-bg: rgba(239, 68, 68, 0.12);
  --status-error-border: rgba(239, 68, 68, 0.25);

  /* Deep Gray & Charcoal Borders */
  --border-subtle: #171717;
  --border-default: #262626;
  --border-strong: #333333;
  --border-focus: #525252;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.6);
  --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.7);
  --shadow-dropdown: 0 12px 30px rgba(0, 0, 0, 0.85);

  /* Avatars */
  --avatar-user-bg: #222222;
  --avatar-user-text: #e5e5e5;
  --avatar-ai-bg: #1f1f1f;
  --avatar-ai-text: #60a5fa;
}

html, body {
  height: 100%;
  width: 100%;
  font-family: 'Plus Jakarta Sans', 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-app);
  color: var(--text-primary);
  line-height: 1.5;
  overflow: hidden;
  transition: background-color 0.2s ease, color 0.2s ease;
  -webkit-font-smoothing: antialiased;
}

/* Accessibility helper */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ==================== LAYOUT ==================== */
.app-layout {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* ==================== SIDEBAR ==================== */
.sidebar {
  width: 270px;
  min-width: 270px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-default);
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
  z-index: 40;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), width 0.25s ease;
}

.sidebar.collapsed {
  width: 0px;
  min-width: 0px;
  transform: translateX(-100%);
  border-right: none;
}

/* Sidebar Header */
.sidebar-header {
  height: 64px;
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
}

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

.brand-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-size: 15.5px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  line-height: 1.1;
}

.brand-sub {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--text-secondary);
  margin-top: 1px;
}

.sidebar-collapse-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border-default);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.sidebar-collapse-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

/* Sidebar Sections */
.sidebar-section {
  padding: 16px 14px 10px;
  display: flex;
  flex-direction: column;
}

.conversation-section {
  flex: 1;
  overflow-y: auto;
  padding-top: 10px;
}

.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding: 0 4px;
}

.section-title {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.section-icon-btn {
  width: 20px;
  height: 20px;
  border: 1px solid var(--border-default);
  background: var(--bg-card);
  color: var(--text-secondary);
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.15s ease;
}

.section-icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

/* Large Upload Card matching reference */
.large-upload-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 22px 14px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.18s ease;
  user-select: none;
  text-align: center;
  margin-bottom: 14px;
}

.large-upload-card:hover {
  border-color: var(--border-strong);
  background-color: var(--bg-hover);
}

.large-upload-card.drag-over {
  border-color: var(--primary);
  background-color: var(--primary-light);
}

.upload-icon-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
}

.upload-main-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.upload-sub-text {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.35;
}

/* Empty State for Documents */
.empty-docs-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px 10px;
}

.empty-docs-icon-box {
  color: var(--text-tertiary);
  margin-bottom: 10px;
}

.empty-docs-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 3px;
}

.empty-docs-desc {
  font-size: 11.5px;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* Document Items (When docs are loaded) */
.doc-list-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 200px;
  overflow-y: auto;
}

.doc-row-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid transparent;
  background-color: transparent;
  transition: all 0.15s ease;
}

.doc-row-item:hover {
  background-color: var(--bg-hover);
  border-color: var(--border-subtle);
}

.doc-row-item.active {
  background-color: var(--bg-active);
  border-color: var(--border-default);
}

.doc-left-group {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  flex: 1;
}

.doc-type-icon {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10.5px;
  font-weight: 700;
  flex-shrink: 0;
}

.doc-type-icon.pdf {
  background-color: rgba(239, 68, 68, 0.12);
  color: #ef4444;
}

.doc-type-icon.docx {
  background-color: rgba(37, 99, 235, 0.12);
  color: #2563eb;
}

.doc-type-icon.md {
  background-color: rgba(249, 115, 22, 0.12);
  color: #f97316;
}

.doc-type-icon.txt {
  background-color: rgba(100, 116, 139, 0.12);
  color: #64748b;
}

.doc-text-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.doc-filename {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.doc-submeta {
  font-size: 10.5px;
  color: var(--text-secondary);
}

.doc-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--status-green);
  flex-shrink: 0;
  margin-left: 6px;
  box-shadow: 0 0 0 2px var(--status-green-pulse);
}

.doc-status-dot.indexing {
  background-color: #f59e0b;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.3);
  animation: pulse 1.4s infinite;
}

.doc-status-dot.failed {
  background-color: var(--status-error);
}

.doc-delete-btn {
  display: none;
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
}

.doc-row-item:hover .doc-delete-btn {
  display: flex;
}

/* Upload progress */
.upload-progress-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 6px;
}

.upload-file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  font-size: 11.5px;
  background: var(--bg-hover);
  border-radius: 6px;
  border: 1px dashed var(--border-default);
}

/* Conversations List */
.history-list-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.conversation-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid transparent;
}

.conversation-item:hover {
  background-color: var(--bg-hover);
}

.conversation-item.active {
  background-color: var(--bg-active);
  border-color: var(--border-default);
}

.conv-left-col {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.conversation-icon {
  font-size: 14px;
  color: var(--primary);
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.conv-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.conversation-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

[data-theme="dark"] .conversation-item.active .conversation-title {
  color: #ffffff;
}

.conversation-time {
  font-size: 10.5px;
  color: var(--text-secondary);
}

.conv-delete-btn {
  display: none;
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  flex-shrink: 0;
}

.conversation-item:hover .conv-delete-btn {
  display: flex;
}

.conv-delete-btn:hover {
  color: var(--status-error);
  background: var(--status-error-bg);
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--border-subtle);
}

.sidebar-status-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  border-radius: 9px;
  border: 1px solid var(--border-default);
  background-color: var(--bg-card);
}

.status-col {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.status-indicator-line,
.engine-indicator-line {
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: #9ca3af;
}

.status-dot.connected {
  background-color: var(--status-green);
  box-shadow: 0 0 0 2px var(--status-green-pulse);
}

.status-dot.disconnected {
  background-color: var(--status-error);
}

.status-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-primary);
}

.shield-icon {
  color: var(--text-secondary);
}

.engine-label {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 500;
}

.info-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.info-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* ==================== MAIN CONTENT ==================== */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
  background-color: var(--bg-app);
  overflow: hidden;
}

/* Main Header */
.main-header {
  height: 64px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-default);
  background-color: var(--bg-header);
  flex-shrink: 0;
}

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

.mobile-menu-btn {
  display: none;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border-default);
  background: var(--bg-card);
  border-radius: 6px;
  color: var(--text-primary);
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.header-titles {
  display: flex;
  flex-direction: column;
}

.header-title-line {
  display: flex;
  align-items: center;
  gap: 9px;
}

.header-main-title {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  line-height: 1.2;
}

.badge-grounded {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 9999px;
  background-color: var(--mint-bg);
  border: 1px solid var(--mint-border);
  color: var(--mint-text);
  font-size: 11px;
  font-weight: 600;
}

.header-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
  margin-top: 1px;
}

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

/* Theme Toggle Button */
.theme-toggle-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border-default);
  background: var(--bg-card);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.theme-toggle-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.sun-icon {
  display: block;
}

.moon-icon {
  display: none;
}

[data-theme="dark"] .sun-icon {
  display: none;
}

[data-theme="dark"] .moon-icon {
  display: block;
}

/* User Avatar */
.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background-color: var(--bg-card);
  border: 1px solid var(--border-default);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
  user-select: none;
}

/* ==================== MESSAGES & CHAT AREA ==================== */
.messages-scroll-area {
  flex: 1;
  overflow-y: auto;
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  scroll-behavior: smooth;
}

/* Welcome Container */
.welcome-container {
  max-width: 720px;
  width: 100%;
  margin: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Hero Input Card */
.hero-input-card {
  width: 100%;
  background-color: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: 12px;
  box-shadow: var(--shadow-card);
  padding: 16px 18px 12px;
  display: flex;
  flex-direction: column;
  text-align: left;
  transition: border-color 0.15s ease;
}

.hero-input-card:focus-within {
  border-color: var(--border-strong);
}

.hero-input-card textarea {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 14.5px;
  font-family: inherit;
  resize: none;
  outline: none;
  line-height: 1.5;
  min-height: 48px;
}

.hero-input-card textarea::placeholder {
  color: var(--text-tertiary);
}

.hero-input-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
  padding-top: 6px;
}

.hero-input-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Filter Pills with Dropdown */
.dropdown-wrapper {
  position: relative;
}

.filter-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 8px;
  border: 1px solid var(--border-default);
  background-color: var(--bg-pill);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.filter-pill-btn:hover {
  background-color: var(--bg-pill-hover);
  border-color: var(--border-strong);
}

.chevron-icon {
  color: var(--text-secondary);
}

/* Dropdown Menu */
.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: 9px;
  padding: 5px;
  box-shadow: var(--shadow-dropdown);
  display: none;
  flex-direction: column;
  gap: 2px;
  z-index: 50;
  min-width: 140px;
}

.dropdown-menu.open {
  display: flex;
}

.dropdown-item {
  padding: 6px 11px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.12s ease;
}

.dropdown-item:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

.dropdown-item.active {
  background-color: var(--bg-active);
  color: var(--text-primary);
  font-weight: 600;
}

.hero-input-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tool-icon-btn {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.tool-icon-btn:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

.stop-pill-btn {
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid var(--status-error);
  background: var(--status-error-bg);
  color: var(--status-error);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
}

.send-action-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: none;
  background-color: var(--primary);
  color: #ffffff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.18s ease;
}

.send-action-btn:not(:disabled):hover {
  background-color: var(--primary-hover);
  transform: scale(1.03);
}

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

/* ==================== CONVERSATION MESSAGES ==================== */
.messages-container-active {
  width: 100%;
  max-width: 760px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 20px 0;
}

.message-row {
  display: flex;
  gap: 14px;
  width: 100%;
  animation: fadeIn 0.2s ease-out;
}

.message-avatar-box {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 700;
}

.message-row.user .message-avatar-box {
  background-color: var(--avatar-user-bg);
  color: var(--avatar-user-text);
}

.message-row.assistant .message-avatar-box {
  background-color: var(--avatar-ai-bg);
  color: var(--avatar-ai-text);
}

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

.message-meta-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 5px;
}

.message-sender-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}

.message-timestamp {
  font-size: 11px;
  color: var(--text-tertiary);
  font-weight: 500;
}

.message-text {
  font-size: 14px;
  line-height: 1.65;
  color: var(--text-primary);
  word-break: break-word;
}

/* Streaming Status */
.stream-status-box {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px;
  border-radius: 6px;
  background: var(--bg-hover);
  border: 1px solid var(--border-default);
  font-size: 11.5px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.stream-spinner {
  width: 12px;
  height: 12px;
  border: 2px solid var(--border-default);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.message-text p {
  margin-bottom: 8px;
}

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

.message-text code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12.5px;
  background-color: var(--bg-hover);
  padding: 2px 5px;
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
}

.message-text pre {
  margin: 10px 0;
  padding: 12px;
  background: var(--bg-hover);
  border: 1px solid var(--border-default);
  border-radius: 8px;
  overflow-x: auto;
}

.message-text pre code {
  background: transparent;
  padding: 0;
  border: none;
}

.message-error {
  padding: 8px 12px;
  border-radius: 6px;
  background: var(--status-error-bg);
  border: 1px solid var(--status-error-border);
  color: var(--status-error);
  font-size: 12.5px;
  margin-top: 6px;
}

/* Sources Section */
.sources-container {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.sources-header-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
}

.sources-cards-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.source-citation-card {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 7px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-default);
  box-shadow: var(--shadow-sm);
  transition: all 0.15s ease;
  cursor: pointer;
}

.source-citation-card:hover {
  border-color: var(--border-strong);
  background-color: var(--bg-hover);
}

.source-icon-badge {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
}

.source-meta-col {
  display: flex;
  flex-direction: column;
}

.source-filename {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-primary);
}

.source-detail {
  font-size: 10px;
  color: var(--text-secondary);
}

.source-more-badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 7px;
  border: 1px solid var(--border-default);
  background-color: var(--bg-card);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
}

/* ==================== FOLLOW-UP BOTTOM BAR ==================== */
.followup-bottom-bar {
  width: 100%;
  padding: 12px 28px 18px;
  background-color: var(--bg-app);
  display: flex;
  justify-content: center;
  flex-shrink: 0;
}

.followup-card {
  width: 100%;
  max-width: 760px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: 10px;
  padding: 8px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease;
}

.followup-card:focus-within {
  border-color: var(--border-strong);
}

.followup-card textarea {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 13.5px;
  font-family: inherit;
  resize: none;
  outline: none;
  line-height: 1.4;
  height: 22px;
  max-height: 100px;
}

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

.followup-hint {
  font-size: 11px;
  color: var(--text-tertiary);
  user-select: none;
}

/* Toast Container */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 9px 14px;
  border-radius: 7px;
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  box-shadow: var(--shadow-dropdown);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-primary);
  animation: slideIn 0.2s ease-out;
}

.toast.error {
  border-color: var(--status-error);
  color: var(--status-error);
}

.toast.success {
  border-color: var(--status-green);
}

.toast.out {
  opacity: 0;
  transform: translateY(6px);
  transition: all 0.2s ease;
}

/* Mobile Overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 35;
}

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

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

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

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

/* Responsive */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    transform: translateX(-100%);
  }

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

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

  .mobile-menu-btn {
    display: flex;
  }

  .main-header {
    padding: 0 16px;
  }

  .messages-scroll-area {
    padding: 16px;
  }

  .followup-bottom-bar {
    padding: 10px 14px 14px;
  }

  .followup-hint {
    display: none;
  }
}

/* ===== v2.1 example chips (additive) ===== */
.welcome-examples { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 18px 0 4px; }
.example-chip {
  font-family: inherit; font-size: 12.5px; font-weight: 500;
  color: var(--text-secondary, #9a9a9e); background: var(--bg-surface, #191a1b);
  border: 1px solid var(--border-default, #2a2a2c); padding: 7px 14px;
  border-radius: 999px; cursor: pointer; transition: all 0.15s ease;
}
.example-chip:hover { background: rgba(255,255,255,0.04); border-color: var(--accent, #5e6ad2); color: #ececf1; }
.accent-text { color: var(--accent, #5e6ad2); font-weight: 600; }

/* ==================== GOOGLE SIGN-IN GATE ==================== */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg-app);
}

/* An explicit display rule would beat the [hidden] attribute, so restore it */
.login-screen[hidden] {
  display: none;
}

.login-card {
  width: 100%;
  max-width: 400px;
  text-align: center;
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: 16px;
  padding: 40px 32px;
  box-shadow: var(--shadow-dropdown);
}

.login-brand-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 18px;
  border-radius: 18px;
  background: var(--primary-light);
  border: 1px solid var(--primary-light-border);
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.login-subtitle {
  margin-top: 10px;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text-secondary);
}

.google-signin-btn {
  margin-top: 24px;
  width: 100%;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: #ffffff;
  color: #1f2937;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: box-shadow 0.15s ease, background 0.15s ease;
}

.google-signin-btn:hover {
  background: #f8fafc;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}

.google-signin-btn:active {
  background: #f1f5f9;
}

.login-error {
  margin-top: 14px;
  font-size: 12.5px;
  color: var(--status-error);
}

.login-footer {
  margin-top: 20px;
  font-size: 11.5px;
  color: var(--text-tertiary);
}

/* ==================== SIGNED-IN USER CHIP ==================== */
.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px 4px 4px;
  border: 1px solid var(--border-default);
  border-radius: 999px;
  background: var(--bg-card);
}

.user-chip[hidden] {
  display: none;
}

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

.user-avatar-img[hidden] {
  display: none;
}

.user-avatar-fallback {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--avatar-user-bg);
  color: var(--avatar-user-text);
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}

.user-chip-name {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-primary);
}

.logout-btn {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.logout-btn:hover {
  background: var(--status-error-bg);
  color: var(--status-error);
}
