/* CSS Custom Properties for theming */
:root {
  /* Light mode colors (default) */
  --bg-primary: #ffffff;
  --bg-secondary: #f9fafb;
  --bg-tertiary: #f3f4f6;
  --text-primary: #111827;
  --text-secondary: #4b5563;
  --text-tertiary: #6b7280;
  --border-color: #e5e7eb;
  --border-light: #f3f4f6;
  --shadow-color: rgba(0, 0, 0, 0.1);
  --accent-color: #0066CC;
  --accent-hover: #0052a3;
  --user-message-bg: #0066CC;
  --user-message-text: #ffffff;
  --assistant-message-bg: #ffffff;
  --assistant-message-border: #e5e7eb;
  --input-bg: #ffffff;
  --input-border: #d1d5db;
  --input-focus-ring: rgba(0, 102, 204, 0.2);
  /* Engineer message styling (admin replies) */
  --engineer-message-bg: #fff7ed;
  --engineer-message-border: #fed7aa;
  --engineer-message-accent: #f97316;
  --engineer-message-text: #7c2d12;
  --engineer-label-color: #c2410c;
}

/* Dark mode */
[data-theme="dark"] {
  --bg-primary: #1f2937;
  --bg-secondary: #111827;
  --bg-tertiary: #374151;
  --text-primary: #f9fafb;
  --text-secondary: #d1d5db;
  --text-tertiary: #9ca3af;
  --border-color: #374151;
  --border-light: #4b5563;
  --shadow-color: rgba(0, 0, 0, 0.3);
  --accent-color: #3b82f6;
  --accent-hover: #2563eb;
  --user-message-bg: #3b82f6;
  --user-message-text: #ffffff;
  --assistant-message-bg: #374151;
  --assistant-message-border: #4b5563;
  --input-bg: #374151;
  --input-border: #4b5563;
  --input-focus-ring: rgba(59, 130, 246, 0.3);
  /* Engineer message styling (admin replies) - dark mode */
  --engineer-message-bg: rgba(249, 115, 22, 0.15);
  --engineer-message-border: rgba(249, 115, 22, 0.3);
  --engineer-message-accent: #f97316;
  --engineer-message-text: #fdba74;
  --engineer-label-color: #fb923c;
}

/* System preference support */
@media (prefers-color-scheme: dark) {
  [data-theme="system"] {
    --bg-primary: #1f2937;
    --bg-secondary: #111827;
    --bg-tertiary: #374151;
    --text-primary: #f9fafb;
    --text-secondary: #d1d5db;
    --text-tertiary: #9ca3af;
    --border-color: #374151;
    --border-light: #4b5563;
    --shadow-color: rgba(0, 0, 0, 0.3);
    --accent-color: #3b82f6;
    --accent-hover: #2563eb;
    --user-message-bg: #3b82f6;
    --user-message-text: #ffffff;
    --assistant-message-bg: #374151;
    --assistant-message-border: #4b5563;
    --input-bg: #374151;
    --input-border: #4b5563;
    --input-focus-ring: rgba(59, 130, 246, 0.3);
    /* Engineer message styling (admin replies) - system dark mode */
    --engineer-message-bg: rgba(249, 115, 22, 0.15);
    --engineer-message-border: rgba(249, 115, 22, 0.3);
    --engineer-message-accent: #f97316;
    --engineer-message-text: #fdba74;
    --engineer-label-color: #fb923c;
  }
}

/* Base styles */
body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Chat container background */
.chat-container {
  background-color: var(--bg-secondary) !important;
}

/* Override Tailwind bg-gray-50 for dark mode */
[data-theme="dark"] .bg-gray-50,
[data-theme="dark"] .chat-container {
  background-color: var(--bg-secondary) !important;
}

@media (prefers-color-scheme: dark) {
  [data-theme="system"] .bg-gray-50,
  [data-theme="system"] .chat-container {
    background-color: var(--bg-secondary) !important;
  }
}

/* FIXED HEADER - stays at top, offset for slim sidebar */
.chat-header {
  position: fixed;
  top: 0;
  left: 52px;
  right: 0;
  z-index: 50;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  box-shadow: 0 4px 6px -1px var(--shadow-color);
  transition: right 0.3s ease, background-color 0.3s ease;
}

/* Header history button */
.header-history-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.15s ease;
}

.header-history-btn:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border-color: var(--text-tertiary);
}

.header-history-btn:active {
  transform: scale(0.95);
}

/* Scrollbar styling */
.chat-container::-webkit-scrollbar {
  width: 6px;
}

.chat-container::-webkit-scrollbar-track {
  background: transparent;
}

.chat-container::-webkit-scrollbar-thumb {
  background: #e5e7eb;
  border-radius: 3px;
}

/* FIXED FOOTER INPUT - Main sticky fix, offset for slim sidebar */
.chat-footer {
  position: fixed;
  bottom: 0;
  left: 52px;
  right: 0;
  z-index: 50;
  background: var(--bg-primary);
  border-top: 1px solid var(--border-color);
  padding: 1rem 1.5rem;
  box-shadow: 0 -4px 6px -1px var(--shadow-color);
  transition: right 0.3s ease, background-color 0.3s ease;
}

/* Responsive padding for wider screens */
@media (min-width: 1024px) {
  .chat-footer {
    padding: 1.25rem 2rem;
  }
}

@media (min-width: 1280px) {
  .chat-footer {
    padding: 1.25rem 3rem;
  }
}

/* Main content area - offset for slim sidebar */
.main-content {
  margin-left: 52px;
}

/* Space for fixed header and footer - prevents content from being hidden */
.chat-container {
  padding-top: 70px;
  padding-bottom: 120px;
}

/* Footer stays fixed - no shift when side panel opens (matches header behavior) */

/* Status indicator */
.status-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: 0.5rem;
  color: #0369a1;
  font-size: 0.875rem;
  margin-bottom: 0.5rem;
}

.status-indicator .spinner {
  width: 16px;
  height: 16px;
  border: 2px solid #bae6fd;
  border-top-color: #0369a1;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* Agent avatar */
.agent-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  object-fit: cover;
}

/* Thinking mode dropdown */
.thinking-dropdown select {
  appearance: none;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  padding: 0.5rem 2rem 0.5rem 0.75rem;
  font-size: 0.875rem;
  color: var(--text-primary);
  cursor: pointer;
  transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

.thinking-dropdown select option {
  background: var(--bg-primary);
  color: var(--text-primary);
}

.thinking-dropdown::after {
  content: '▼';
  font-size: 0.625rem;
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--text-tertiary);
}

.thinking-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: #fef3c7;
  border: 1px solid #fcd34d;
  color: #92400e;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
}

/* ============================================
   SETTINGS COG & POPUP STYLES
   ============================================ */

.settings-cog-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  background: var(--bg-primary);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.settings-cog-btn:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border-color: var(--text-muted);
}

.settings-popup {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  width: 260px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  z-index: 100;
  animation: popup-appear 0.15s ease-out;
}

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

.settings-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
}

.settings-popup-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
}

.settings-popup-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 0.25rem;
  transition: all 0.15s;
}

.settings-popup-close:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.settings-popup-body {
  padding: 0.75rem 1rem;
}

.settings-section {
  margin-bottom: 1rem;
}

.settings-section:last-child {
  margin-bottom: 0;
}

.settings-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.settings-toggle-group {
  display: flex;
  gap: 0.25rem;
  background: var(--bg-secondary);
  padding: 0.25rem;
  border-radius: 0.5rem;
}

.settings-toggle-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.5rem 0.75rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: 0.375rem;
  transition: all 0.15s;
}

.settings-toggle-btn:hover:not(.active):not(:disabled) {
  color: var(--text-primary);
}

.settings-toggle-btn.active {
  background: var(--bg-primary);
  color: var(--text-primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

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

.font-size-group .settings-toggle-btn {
  padding: 0.5rem;
}

.settings-hint {
  font-size: 0.6875rem;
  color: var(--text-light);
  margin-top: 0.375rem;
}

/* ============================================
   TALK TO ENGINEER BUTTON STYLES
   ============================================ */

.talk-to-engineer-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.talk-to-engineer-btn:hover:not(:disabled) {
  background: var(--bg-secondary);
  border-color: #3b82f6;
  color: #3b82f6;
}

.talk-to-engineer-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.talk-to-engineer-btn.pending {
  background: #fef3c7;
  border-color: #f59e0b;
  color: #92400e;
}

.talk-to-engineer-btn.connected {
  background: #dcfce7;
  border-color: #22c55e;
  color: #166534;
}

.engineer-pulse {
  width: 8px;
  height: 8px;
  background: #f59e0b;
  border-radius: 50%;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.5;
    transform: scale(1.2);
  }
}

.engineer-connected-dot {
  width: 8px;
  height: 8px;
  background: #22c55e;
  border-radius: 50%;
}

/* New Chat button styling */
.new-chat-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: transparent;
  border: none;
  border-radius: 0.5rem;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

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

/* ============================================
   RESPONSIVE STYLES
   ============================================ */

@media (max-width: 640px) {
  /* Adjust for smaller slim sidebar on mobile */
  .chat-header {
    left: 48px;
  }

  .chat-footer {
    left: 48px;
  }

  .main-content {
    margin-left: 48px;
  }

  /* Hide button text on mobile, show icons only */
  .engineer-btn-text {
    display: none;
  }

  .new-chat-text {
    display: none;
  }

  .talk-to-engineer-btn {
    padding: 0.5rem;
  }

  .new-chat-btn {
    padding: 0.5rem;
  }

  .header-title {
    font-size: 0.875rem;
  }

  .settings-cog-btn {
    width: 40px;
    height: 40px;
  }

  .settings-popup {
    width: 240px;
  }
}

@media (max-width: 480px) {
  .header-left img {
    height: 1.5rem;
  }

  .header-title {
    font-size: 0.8125rem;
  }

  .header-right {
    gap: 0.25rem !important;
  }
}

/* Font size adjustments based on user preference */
[data-font-size="small"] .message-content {
  font-size: 0.8125rem;
}

[data-font-size="medium"] .message-content {
  font-size: 0.9375rem;
}

[data-font-size="large"] .message-content {
  font-size: 1.0625rem;
}

/* Image styles */
.inline-image {
  margin: 1rem 0;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  overflow: hidden;
  background: white;
  display: block;
  max-width: 100%;
}

.inline-image img {
  display: block;
  width: 100%;
  height: auto;
  cursor: zoom-in;
  object-fit: contain;
}

.inline-image:hover {
  border-color: #0066CC;
  box-shadow: 0 4px 12px rgba(0, 102, 204, 0.15);
}

.inline-image .img-caption {
  padding: 0.5rem 0.75rem;
  font-size: 0.75rem;
  color: #6b7280;
  border-top: 1px solid #f3f4f6;
  background: #fafafa;
}

/* Image size classes */
.img-small { max-width: 250px; }
.img-medium { max-width: 500px; }
.img-large { max-width: 700px; }
.img-full { width: 100%; max-width: 100%; }

/* Web source images inline in chat responses */
.web-source-images {
  margin: 0.75rem 0;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.web-source-img-wrapper {
  max-width: 200px;
  border-radius: 0.375rem;
  overflow: hidden;
  border: 1px solid #e5e7eb;
  transition: all 0.2s;
}

.web-source-img-wrapper:hover {
  border-color: #166534;
  box-shadow: 0 2px 8px rgba(22, 101, 52, 0.15);
}

.web-source-img-wrapper img {
  width: 100%;
  height: auto;
  display: block;
  cursor: zoom-in;
}

/* Web images gallery */
.web-images-gallery {
  margin-bottom: 1rem;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  overflow: hidden;
}

.gallery-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.75rem;
  background: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
}

.gallery-title {
  font-size: 0.8125rem;
  font-weight: 500;
  color: #374151;
}

.gallery-count {
  font-size: 0.75rem;
  color: #6b7280;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.5rem;
  padding: 0.75rem;
}

.gallery-item {
  border-radius: 0.375rem;
  overflow: hidden;
  border: 1px solid #e5e7eb;
  cursor: zoom-in;
  transition: all 0.2s;
}

.gallery-item:hover {
  border-color: #0066CC;
  box-shadow: 0 2px 8px rgba(0, 102, 204, 0.15);
}

.gallery-item img {
  width: 100%;
  height: auto;
  display: block;
}

.gallery-item-loading {
  min-height: 80px;
  background: #f3f4f6;
}

/* Score badge */
.score-badge {
  background: linear-gradient(135deg, #f0fdf4, #dcfce7);
  color: #166534;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid #86efac;
}

/* Source badge */
.source-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.625rem;
  background: linear-gradient(135deg, #f0f9ff, #e0f2fe);
  border: 1px solid #bae6fd;
  border-radius: 0.375rem;
  font-size: 0.8125rem;
  color: #0369a1;
  margin-top: 0.5rem;
}

.source-badge.web-source {
  background: linear-gradient(135deg, #f0fdf4, #dcfce7);
  border-color: #86efac;
  color: #166534;
}

/* Web source metadata */
.web-source-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
  color: #6b7280;
  margin-bottom: 0.5rem;
}

.web-source-meta .favicon {
  width: 16px;
  height: 16px;
  border-radius: 2px;
}

.web-source-meta .domain {
  font-weight: 500;
  color: #374151;
}

.web-source-meta .separator {
  color: #d1d5db;
}

.web-source-meta .date {
  color: #9ca3af;
}

/* Visit website button */
.visit-website-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  background: #166534;
  color: white;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.2s;
  margin-top: 0.5rem;
}

.visit-website-btn:hover {
  background: #14532d;
}

/* Chunk content */
.chunk-content-box {
  background: white;
  border-radius: 0.5rem;
  padding: 1rem;
}

.chunk-image {
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  overflow: hidden;
  cursor: zoom-in;
}

.chunk-image img {
  width: 100%;
  height: auto;
  display: block;
}

.chunk-image:hover {
  border-color: #0066CC;
}

/* Full content section */
.full-content-section {
  margin-top: 1rem;
  border-top: 1px solid #e5e7eb;
  padding-top: 1rem;
}

.full-content-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.625rem 0.875rem;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  color: #4b5563;
  cursor: pointer;
  transition: all 0.2s;
}

.full-content-toggle:hover {
  background: #f3f4f6;
  color: #1f2937;
}

.full-content-toggle .toggle-icon {
  width: 1rem;
  height: 1rem;
  transition: transform 0.2s;
}

.full-content-toggle .toggle-icon.open {
  transform: rotate(180deg);
}

.full-content-box {
  margin-top: 0.75rem;
  padding: 1rem;
  background: #fafafa;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
}

.full-content-warning {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: #fef3c7;
  border: 1px solid #fcd34d;
  border-radius: 0.375rem;
  font-size: 0.8125rem;
  color: #92400e;
  margin-bottom: 0.75rem;
}

.full-content-text {
  font-size: 0.8125rem;
  line-height: 1.6;
  color: #4b5563;
  max-height: 400px;
  overflow-y: auto;
}

/* Reasoning/Thinking Block Styles */
.thinking-block {
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  background: #f9fafb;
  overflow: hidden;
  transition: all 0.3s ease;
}

.thinking-block.thinking-active {
  border-color: #c7d2fe;
  background: linear-gradient(135deg, #f5f3ff 0%, #ede9fe 100%);
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.1);
}

.thinking-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.75rem 1rem;
  background: transparent;
  border: none;
  font-size: 0.875rem;
  color: #6b7280;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
}

.thinking-active .thinking-toggle {
  color: #6366f1;
}

.thinking-toggle:hover {
  background: rgba(0, 0, 0, 0.03);
}

.thinking-chevron {
  flex-shrink: 0;
  transition: transform 0.2s ease;
  color: #9ca3af;
}

.thinking-active .thinking-chevron {
  color: #6366f1;
}

.thinking-chevron.expanded {
  transform: rotate(90deg);
}

.thinking-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
}

.thinking-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

.thinking-brain-icon {
  animation: pulse-rotate 2s ease-in-out infinite;
  color: #6366f1;
}

@keyframes pulse-rotate {
  0%, 100% { transform: rotate(0deg); opacity: 1; }
  50% { transform: rotate(180deg); opacity: 0.7; }
}

.thinking-label {
  font-weight: 600;
}

.thinking-status {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

.thinking-dot {
  width: 6px;
  height: 6px;
  background: #6366f1;
  border-radius: 50%;
  animation: thinking-bounce 1.4s ease-in-out infinite;
}

.thinking-dot:nth-child(1) { animation-delay: 0s; }
.thinking-dot:nth-child(2) { animation-delay: 0.2s; }
.thinking-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes thinking-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
  40% { transform: scale(1); opacity: 1; }
}

.thinking-content {
  border-top: 1px solid #e5e7eb;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.7);
  max-height: 300px;
  overflow-y: auto;
}

.thinking-active .thinking-content {
  border-top-color: #c7d2fe;
  background: rgba(255, 255, 255, 0.9);
}

.thinking-content pre {
  margin: 0;
  font-family: 'Inter', sans-serif;
  font-size: 0.8125rem;
  line-height: 1.7;
  color: #4b5563;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.thinking-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  text-align: center;
}

.thinking-placeholder p {
  margin: 0;
  margin-top: 1rem;
  font-size: 0.8125rem;
  color: #6366f1;
  font-weight: 500;
}

.thinking-wave {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 30px;
}

.thinking-wave span {
  display: block;
  width: 4px;
  height: 100%;
  background: linear-gradient(180deg, #6366f1 0%, #8b5cf6 100%);
  border-radius: 2px;
  animation: wave 1.2s ease-in-out infinite;
}

.thinking-wave span:nth-child(1) { animation-delay: 0s; height: 60%; }
.thinking-wave span:nth-child(2) { animation-delay: 0.1s; height: 80%; }
.thinking-wave span:nth-child(3) { animation-delay: 0.2s; height: 100%; }
.thinking-wave span:nth-child(4) { animation-delay: 0.3s; height: 80%; }
.thinking-wave span:nth-child(5) { animation-delay: 0.4s; height: 60%; }

@keyframes wave {
  0%, 100% { transform: scaleY(0.5); opacity: 0.5; }
  50% { transform: scaleY(1); opacity: 1; }
}

/* Engineer message entrance animation */
@keyframes pulse-once {
  0% {
    transform: scale(0.95);
    opacity: 0;
    box-shadow: 0 0 0 0 rgba(249, 115, 22, 0.7);
  }
  50% {
    box-shadow: 0 0 0 10px rgba(249, 115, 22, 0);
  }
  100% {
    transform: scale(1);
    opacity: 1;
    box-shadow: 0 0 0 0 rgba(249, 115, 22, 0);
  }
}

.animate-pulse-once {
  animation: pulse-once 0.6s ease-out;
}

.thinking-content::-webkit-scrollbar {
  width: 6px;
}

.thinking-content::-webkit-scrollbar-track {
  background: transparent;
}

.thinking-content::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 3px;
}

.thinking-content::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}

/* ==========================================
   DARK MODE OVERRIDES
   ========================================== */

/* Header specific */
[data-theme="dark"] .chat-header .font-semibold,
[data-theme="dark"] .chat-header span {
  color: var(--text-primary) !important;
}

[data-theme="dark"] .chat-header button {
  color: var(--text-secondary) !important;
}

[data-theme="dark"] .chat-header button:hover {
  background-color: var(--bg-tertiary) !important;
}

/* Footer specific */
[data-theme="dark"] .chat-footer p {
  color: var(--text-tertiary) !important;
}

/* Message bubbles */
[data-theme="dark"] .bg-white,
[data-theme="dark"] .border-gray-200 {
  background-color: var(--assistant-message-bg) !important;
  border-color: var(--assistant-message-border) !important;
}

[data-theme="dark"] .bg-oss-blue {
  background-color: var(--user-message-bg) !important;
}

/* Text colors */
[data-theme="dark"] .text-gray-900,
[data-theme="dark"] .text-gray-800 {
  color: var(--text-primary) !important;
}

[data-theme="dark"] .text-gray-700,
[data-theme="dark"] .text-gray-600 {
  color: var(--text-secondary) !important;
}

[data-theme="dark"] .text-gray-500,
[data-theme="dark"] .text-gray-400 {
  color: var(--text-tertiary) !important;
}

/* Border colors */
[data-theme="dark"] .border-gray-300,
[data-theme="dark"] .border-gray-200,
[data-theme="dark"] .border-gray-100 {
  border-color: var(--border-color) !important;
}

/* Input fields */
[data-theme="dark"] textarea,
[data-theme="dark"] input[type="text"],
[data-theme="dark"] select {
  background-color: var(--input-bg) !important;
  border-color: var(--input-border) !important;
  color: var(--text-primary) !important;
}

[data-theme="dark"] textarea::placeholder,
[data-theme="dark"] input::placeholder {
  color: var(--text-tertiary) !important;
}

/* Buttons */
[data-theme="dark"] .hover\:bg-gray-100:hover,
[data-theme="dark"] .hover\:bg-gray-200:hover {
  background-color: var(--bg-tertiary) !important;
}

/* Markdown content */
[data-theme="dark"] .markdown-content {
  color: var(--text-primary) !important;
}

[data-theme="dark"] .markdown-content h1,
[data-theme="dark"] .markdown-content h2,
[data-theme="dark"] .markdown-content h3,
[data-theme="dark"] .markdown-content h4 {
  color: var(--text-primary) !important;
}

[data-theme="dark"] .markdown-content p,
[data-theme="dark"] .markdown-content li {
  color: var(--text-secondary) !important;
}

[data-theme="dark"] .markdown-content code {
  background-color: var(--bg-tertiary) !important;
  color: #f472b6 !important;
}

[data-theme="dark"] .markdown-content pre {
  background-color: #1e293b !important;
  border-color: var(--border-color) !important;
}

[data-theme="dark"] .markdown-content blockquote {
  border-left-color: var(--accent-color) !important;
  background-color: var(--bg-tertiary) !important;
  color: var(--text-secondary) !important;
}

/* Side panel */
[data-theme="dark"] .side-panel {
  background-color: var(--bg-primary) !important;
  border-color: var(--border-color) !important;
}

[data-theme="dark"] .side-panel-header {
  background-color: var(--bg-primary) !important;
  border-color: var(--border-color) !important;
}

[data-theme="dark"] .side-panel-content {
  background-color: var(--bg-secondary) !important;
}

[data-theme="dark"] .chunk-content-box {
  background-color: var(--bg-primary) !important;
}

/* Thinking block - dark mode */
[data-theme="dark"] .thinking-block {
  background-color: var(--bg-secondary) !important;
  border-color: var(--border-color) !important;
}

[data-theme="dark"] .thinking-block.thinking-active {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.15) 0%, rgba(139, 92, 246, 0.1) 100%) !important;
  border-color: rgba(99, 102, 241, 0.3) !important;
}

[data-theme="dark"] .thinking-toggle {
  color: var(--text-primary) !important;
}

[data-theme="dark"] .thinking-toggle:hover {
  background-color: var(--bg-tertiary) !important;
}

[data-theme="dark"] .thinking-label {
  color: var(--text-primary) !important;
}

[data-theme="dark"] .thinking-icon {
  color: var(--text-secondary) !important;
}

[data-theme="dark"] .thinking-chevron {
  color: var(--text-tertiary) !important;
}

[data-theme="dark"] .thinking-content {
  background-color: var(--bg-primary) !important;
  border-color: var(--border-color) !important;
}

[data-theme="dark"] .thinking-content pre {
  color: var(--text-secondary) !important;
}

[data-theme="dark"] .thinking-status {
  color: var(--text-tertiary) !important;
}

/* Gallery and images */
[data-theme="dark"] .web-images-gallery,
[data-theme="dark"] .gallery-header {
  background-color: var(--bg-tertiary) !important;
  border-color: var(--border-color) !important;
}

[data-theme="dark"] .gallery-title {
  color: var(--text-primary) !important;
}

[data-theme="dark"] .gallery-count {
  color: var(--text-tertiary) !important;
}

[data-theme="dark"] .gallery-item {
  border-color: var(--border-color) !important;
}

[data-theme="dark"] .gallery-item-loading {
  background: var(--bg-tertiary) !important;
}

[data-theme="dark"] .chunk-image {
  border-color: var(--border-color) !important;
}

[data-theme="dark"] .chunk-image > div {
  background: var(--bg-tertiary) !important;
  border-top-color: var(--border-color) !important;
  color: var(--text-tertiary) !important;
}

[data-theme="dark"] .inline-image {
  background-color: var(--bg-tertiary) !important;
  border-color: var(--border-color) !important;
}

/* Full content section */
[data-theme="dark"] .full-content-toggle {
  background-color: var(--bg-tertiary) !important;
  border-color: var(--border-color) !important;
  color: var(--text-secondary) !important;
}

[data-theme="dark"] .full-content-box {
  background-color: var(--bg-primary) !important;
  border-color: var(--border-color) !important;
}

[data-theme="dark"] .full-content-text {
  color: var(--text-secondary) !important;
}

[data-theme="dark"] .full-content-warning {
  background: rgba(251, 191, 36, 0.1) !important;
  color: #fbbf24 !important;
}

[data-theme="dark"] .full-content-warning svg {
  color: #fbbf24 !important;
}

/* Popout window */
[data-theme="dark"] .popout-window {
  background-color: var(--bg-primary) !important;
  border-color: var(--border-color) !important;
}

[data-theme="dark"] .popout-header {
  background-color: var(--bg-tertiary) !important;
  border-color: var(--border-color) !important;
}

/* System preference dark mode */
@media (prefers-color-scheme: dark) {
  /* Header specific */
  [data-theme="system"] .chat-header .font-semibold,
  [data-theme="system"] .chat-header span {
    color: var(--text-primary) !important;
  }

  [data-theme="system"] .chat-header button {
    color: var(--text-secondary) !important;
  }

  [data-theme="system"] .chat-header button:hover {
    background-color: var(--bg-tertiary) !important;
  }

  /* Footer specific */
  [data-theme="system"] .chat-footer p {
    color: var(--text-tertiary) !important;
  }

  [data-theme="system"] .bg-white,
  [data-theme="system"] .border-gray-200 {
    background-color: var(--assistant-message-bg) !important;
    border-color: var(--assistant-message-border) !important;
  }

  [data-theme="system"] .bg-oss-blue {
    background-color: var(--user-message-bg) !important;
  }

  [data-theme="system"] .text-gray-900,
  [data-theme="system"] .text-gray-800 {
    color: var(--text-primary) !important;
  }

  [data-theme="system"] .text-gray-700,
  [data-theme="system"] .text-gray-600 {
    color: var(--text-secondary) !important;
  }

  [data-theme="system"] .text-gray-500,
  [data-theme="system"] .text-gray-400 {
    color: var(--text-tertiary) !important;
  }

  [data-theme="system"] .border-gray-300,
  [data-theme="system"] .border-gray-200,
  [data-theme="system"] .border-gray-100 {
    border-color: var(--border-color) !important;
  }

  [data-theme="system"] textarea,
  [data-theme="system"] input[type="text"],
  [data-theme="system"] select {
    background-color: var(--input-bg) !important;
    border-color: var(--input-border) !important;
    color: var(--text-primary) !important;
  }

  [data-theme="system"] .markdown-content {
    color: var(--text-primary) !important;
  }

  [data-theme="system"] .markdown-content code {
    background-color: var(--bg-tertiary) !important;
    color: #f472b6 !important;
  }

  [data-theme="system"] .markdown-content pre {
    background-color: #1e293b !important;
    border-color: var(--border-color) !important;
  }

  [data-theme="system"] .side-panel,
  [data-theme="system"] .side-panel-header,
  [data-theme="system"] .chunk-content-box {
    background-color: var(--bg-primary) !important;
    border-color: var(--border-color) !important;
  }

  [data-theme="system"] .thinking-block {
    background-color: var(--bg-secondary) !important;
    border-color: var(--border-color) !important;
  }

  [data-theme="system"] .thinking-block.thinking-active {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15) 0%, rgba(139, 92, 246, 0.1) 100%) !important;
    border-color: rgba(99, 102, 241, 0.3) !important;
  }

  [data-theme="system"] .thinking-toggle,
  [data-theme="system"] .thinking-label {
    color: var(--text-primary) !important;
  }

  [data-theme="system"] .thinking-content {
    background-color: var(--bg-primary) !important;
    border-color: var(--border-color) !important;
  }

  [data-theme="system"] .thinking-content pre {
    color: var(--text-secondary) !important;
  }

  /* Welcome screen - system dark mode */
  [data-theme="system"] .welcome-title {
    color: var(--text-primary) !important;
  }

  [data-theme="system"] .welcome-subtitle {
    color: var(--text-tertiary) !important;
  }

  [data-theme="system"] .welcome-suggestion {
    background-color: var(--bg-tertiary) !important;
    border-color: var(--border-color) !important;
    color: var(--text-secondary) !important;
  }

  [data-theme="system"] .welcome-suggestion:hover {
    background-color: var(--bg-primary) !important;
  }

  /* Side panel content - system dark mode */
  [data-theme="system"] .chunk-text,
  [data-theme="system"] .chunk-text-segment {
    color: var(--text-secondary) !important;
  }

  [data-theme="system"] .side-panel-header .font-semibold {
    color: var(--text-primary) !important;
  }

  [data-theme="system"] .source-badge {
    background: var(--bg-tertiary) !important;
    color: var(--text-secondary) !important;
  }

  /* Gallery - system dark mode */
  [data-theme="system"] .web-images-gallery,
  [data-theme="system"] .gallery-header {
    background-color: var(--bg-tertiary) !important;
    border-color: var(--border-color) !important;
  }

  [data-theme="system"] .gallery-title {
    color: var(--text-primary) !important;
  }

  [data-theme="system"] .gallery-count {
    color: var(--text-tertiary) !important;
  }

  [data-theme="system"] .gallery-item {
    border-color: var(--border-color) !important;
  }

  [data-theme="system"] .chunk-image {
    border-color: var(--border-color) !important;
  }

  /* Full content - system dark mode */
  [data-theme="system"] .full-content-toggle {
    background-color: var(--bg-tertiary) !important;
    border-color: var(--border-color) !important;
    color: var(--text-secondary) !important;
  }

  [data-theme="system"] .full-content-box {
    background-color: var(--bg-primary) !important;
    border-color: var(--border-color) !important;
  }

  [data-theme="system"] .full-content-text {
    color: var(--text-secondary) !important;
  }
}

/* ==========================================
   WELCOME SCREEN STYLES
   ========================================== */

/* Welcome screen - light mode (default) */
.welcome-title {
  color: #111827;
}

.welcome-subtitle {
  color: #6b7280;
}

.welcome-suggestion {
  background-color: #ffffff;
  border: 1px solid #e5e7eb;
  color: #374151;
  transition: all 0.2s ease;
}

.welcome-suggestion:hover {
  background-color: #f9fafb;
}

/* Welcome screen - dark mode */
[data-theme="dark"] .welcome-title {
  color: var(--text-primary) !important;
}

[data-theme="dark"] .welcome-subtitle {
  color: var(--text-tertiary) !important;
}

[data-theme="dark"] .welcome-suggestion {
  background-color: var(--bg-tertiary) !important;
  border-color: var(--border-color) !important;
  color: var(--text-secondary) !important;
}

[data-theme="dark"] .welcome-suggestion:hover {
  background-color: var(--bg-primary) !important;
}

/* Markdown content styling */
.markdown-content h1 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  margin-top: 1rem;
}

.markdown-content h2 {
  font-size: 1.125rem;
  font-weight: 600;
  margin-top: 1rem;
  margin-bottom: 0.5rem;
}

.markdown-content h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-top: 0.75rem;
  margin-bottom: 0.25rem;
}

.markdown-content p {
  margin-bottom: 0.5rem;
  line-height: 1.6;
}

.markdown-content ul,
.markdown-content ol {
  margin-left: 1.25rem;
  margin-bottom: 0.5rem;
}

.markdown-content ul {
  list-style-type: disc;
}

.markdown-content ol {
  list-style-type: decimal;
}

.markdown-content li {
  margin-bottom: 0.25rem;
  line-height: 1.5;
}

.markdown-content strong {
  font-weight: 600;
}

.markdown-content code:not(pre code) {
  background: #f3f4f6;
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  font-size: 0.875rem;
}

.markdown-content pre {
  position: relative;
  background: #1f2937;
  color: #f9fafb;
  padding: 1rem;
  padding-top: 2.5rem;
  border-radius: 0.5rem;
  overflow-x: auto;
  margin: 0.75rem 0;
  font-size: 0.875rem;
}

.markdown-content pre code {
  background: transparent;
  padding: 0;
  color: inherit;
}

.markdown-content a {
  color: #0066CC;
  text-decoration: underline;
}

.markdown-content blockquote {
  border-left: 3px solid #0066CC;
  padding-left: 0.75rem;
  color: #6b7280;
  margin: 0.5rem 0;
  background: #f9fafb;
  padding: 0.5rem 0.75rem;
  border-radius: 0 0.25rem 0.25rem 0;
}

/* Code copy button */
.copy-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  background: #374151;
  color: #d1d5db;
  border: none;
  border-radius: 0.25rem;
  cursor: pointer;
}

.copy-btn:hover {
  background: #4b5563;
  color: #fff;
}

.copy-btn.copied {
  background: #10b981;
  color: #fff;
}

/* Side panel markdown adjustments */
.side-panel-content .markdown-content {
  font-size: 0.875rem;
  line-height: 1.7;
}

.side-panel-content .markdown-content h1,
.side-panel-content .markdown-content h2,
.side-panel-content .markdown-content h3 {
  margin-top: 1rem;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: #111827;
}

.side-panel-content .markdown-content h1 {
  font-size: 1.125rem;
}

.side-panel-content .markdown-content h2 {
  font-size: 1rem;
}

.side-panel-content .markdown-content h3 {
  font-size: 0.9375rem;
}

.side-panel-content .markdown-content p {
  margin-bottom: 0.5rem;
}

.side-panel-content .markdown-content ul,
.side-panel-content .markdown-content ol {
  margin-left: 1.25rem;
  margin-bottom: 0.5rem;
}

.side-panel-content .markdown-content li {
  margin-bottom: 0.25rem;
}

.side-panel-content .markdown-content code {
  background: #e5e7eb;
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  font-size: 0.8125rem;
}

/* Side panel table styling */
.side-panel-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.75rem 0;
  font-size: 0.8125rem;
}

.side-panel-content th,
.side-panel-content td {
  border: 1px solid #d1d5db;
  padding: 0.5rem 0.75rem;
  text-align: left;
}

.side-panel-content th {
  background: #e5e7eb;
  font-weight: 600;
}

.side-panel-content tr:nth-child(even) {
  background: #f9fafb;
}

.side-panel-content tr:hover {
  background: #f3f4f6;
}

/* Chunk text styling */
.chunk-text {
  font-size: 0.875rem;
  line-height: 1.7;
  color: #374151;
  white-space: pre-wrap;
}

.chunk-text-segment {
  font-size: 0.875rem;
  line-height: 1.7;
  color: #374151;
  margin-bottom: 0.5rem;
}

/* ==========================================
   DARK MODE - Side Panel & Markdown
   ========================================== */

/* Chunk text dark mode */
[data-theme="dark"] .chunk-text,
[data-theme="dark"] .chunk-text-segment {
  color: var(--text-secondary) !important;
}

/* Side panel markdown content dark mode */
[data-theme="dark"] .side-panel-content .markdown-content {
  color: var(--text-secondary);
}

[data-theme="dark"] .side-panel-content .markdown-content h1,
[data-theme="dark"] .side-panel-content .markdown-content h2,
[data-theme="dark"] .side-panel-content .markdown-content h3 {
  color: var(--text-primary) !important;
}

[data-theme="dark"] .side-panel-content .markdown-content p,
[data-theme="dark"] .side-panel-content .markdown-content li {
  color: var(--text-secondary);
}

[data-theme="dark"] .side-panel-content .markdown-content code:not(pre code) {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

[data-theme="dark"] .side-panel-content .markdown-content a {
  color: #60a5fa;
}

[data-theme="dark"] .side-panel-content .markdown-content blockquote {
  background: var(--bg-tertiary);
  border-left-color: #60a5fa;
  color: var(--text-tertiary);
}

/* Side panel table dark mode */
[data-theme="dark"] .side-panel-content th,
[data-theme="dark"] .side-panel-content td {
  border-color: var(--border-color);
  color: var(--text-secondary);
}

[data-theme="dark"] .side-panel-content th {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

[data-theme="dark"] .side-panel-content tr:nth-child(even) {
  background: var(--bg-secondary);
}

[data-theme="dark"] .side-panel-content tr:hover {
  background: var(--bg-tertiary);
}

/* General markdown dark mode */
[data-theme="dark"] .markdown-content code:not(pre code) {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

[data-theme="dark"] .markdown-content a {
  color: #60a5fa;
}

[data-theme="dark"] .markdown-content blockquote {
  background: var(--bg-tertiary);
  border-left-color: #60a5fa;
  color: var(--text-tertiary);
}

/* System preference dark mode */
@media (prefers-color-scheme: dark) {
  [data-theme="system"] .chunk-text,
  [data-theme="system"] .chunk-text-segment {
    color: var(--text-secondary) !important;
  }

  [data-theme="system"] .side-panel-content .markdown-content {
    color: var(--text-secondary);
  }

  [data-theme="system"] .side-panel-content .markdown-content h1,
  [data-theme="system"] .side-panel-content .markdown-content h2,
  [data-theme="system"] .side-panel-content .markdown-content h3 {
    color: var(--text-primary) !important;
  }

  [data-theme="system"] .side-panel-content .markdown-content p,
  [data-theme="system"] .side-panel-content .markdown-content li {
    color: var(--text-secondary);
  }

  [data-theme="system"] .side-panel-content .markdown-content code:not(pre code) {
    background: var(--bg-tertiary);
    color: var(--text-primary);
  }

  [data-theme="system"] .side-panel-content th,
  [data-theme="system"] .side-panel-content td {
    border-color: var(--border-color);
    color: var(--text-secondary);
  }

  [data-theme="system"] .side-panel-content th {
    background: var(--bg-tertiary);
    color: var(--text-primary);
  }
}

/* Typing indicator animation */
.typing-dot {
  animation: typing 1.4s infinite;
}

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

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

@keyframes typing {
  0%, 60%, 100% {
    transform: translateY(0);
  }
  30% {
    transform: translateY(-6px);
  }
}

/* Streaming cursor - disabled */
/* .streaming-cursor::after {
  content: '▊';
  animation: blink 1s infinite;
  color: #0066CC;
}

@keyframes blink {
  0%, 50% {
    opacity: 1;
  }
  51%, 100% {
    opacity: 0;
  }
} */

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

.animate-spin {
  animation: spin 1s linear infinite;
}

/* Fade in animation */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in {
  animation: fadeIn 0.3s ease-out;
}

/* Slide in from right */
@keyframes slideInRight {
  from {
    transform: translateX(100%);
  }
  to {
    transform: translateX(0);
  }
}

/* Slide in from bottom */
@keyframes slideInBottom {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

/* Pulse animation for loading states */
@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.pulse {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Inline citation badges */
.inline-citation {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  border: 1px solid #bae6fd;
  padding: 0.25rem 0.5rem;
  border-radius: 0.375rem;
  font-size: 0.75rem;
  color: #0369a1;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
  margin: 0.125rem 0.25rem;
  vertical-align: middle;
  white-space: nowrap;
  max-width: 280px;
  overflow: hidden;
}

.inline-citation span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.inline-citation:hover {
  background: #0369a1;
  color: white;
  border-color: #0369a1;
}

.inline-citation:hover .cite-page {
  color: rgba(255, 255, 255, 0.8);
}

.inline-citation .cite-icon {
  width: 0.875rem;
  height: 0.875rem;
  flex-shrink: 0;
}

.inline-citation .cite-page {
  color: #6b7280;
  margin-left: 0.125rem;
}

.inline-citation.figure-source {
  margin-left: 0.5rem;
}

/* PDF citation styling - blue theme */
.inline-citation.pdf-citation {
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%) !important;
  border: 1px solid #bae6fd !important;
  color: #0369a1 !important;
}

.inline-citation.pdf-citation:hover {
  background: #0369a1 !important;
  color: white !important;
  border-color: #0369a1 !important;
}

.inline-citation.pdf-citation:hover .cite-page {
  color: rgba(255, 255, 255, 0.8) !important;
}

/* Web citation styling - green theme */
.inline-citation.web-citation {
  background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%) !important;
  border: 1px solid #86efac !important;
  color: #166534 !important;
}

.inline-citation.web-citation:hover {
  background: #166534 !important;
  color: white !important;
  border-color: #166534 !important;
}

/* Citation footer */
.citation-footer {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid #e5e7eb;
}

.citation-footer-title {
  font-size: 0.75rem;
  font-weight: 500;
  color: #6b7280;
  margin-bottom: 0.5rem;
}

.citation-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

.citation-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.5rem;
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: 0.375rem;
  font-size: 0.6875rem;
  color: #0369a1;
  cursor: pointer;
  transition: all 0.2s;
}

.citation-chip:hover {
  background: #e0f2fe;
  border-color: #7dd3fc;
}

.citation-chip svg {
  width: 0.75rem;
  height: 0.75rem;
}

/* ==========================================
   DARK MODE - Citation badges
   ========================================== */

[data-theme="dark"] .inline-citation {
  background: var(--bg-tertiary) !important;
  border-color: var(--border-color) !important;
}

[data-theme="dark"] .inline-citation.pdf-citation {
  background: rgba(14, 165, 233, 0.15) !important;
  border-color: rgba(14, 165, 233, 0.3) !important;
  color: #7dd3fc !important;
}

[data-theme="dark"] .inline-citation.pdf-citation:hover {
  background: #0284c7 !important;
  border-color: #0284c7 !important;
  color: white !important;
}

[data-theme="dark"] .inline-citation.pdf-citation .cite-page {
  color: #94a3b8 !important;
}

[data-theme="dark"] .inline-citation.pdf-citation:hover .cite-page {
  color: rgba(255, 255, 255, 0.8) !important;
}

[data-theme="dark"] .inline-citation.web-citation {
  background: rgba(34, 197, 94, 0.15) !important;
  border-color: rgba(34, 197, 94, 0.3) !important;
  color: #86efac !important;
}

[data-theme="dark"] .inline-citation.web-citation:hover {
  background: #16a34a !important;
  border-color: #16a34a !important;
  color: white !important;
}

/* Citation footer dark mode */
[data-theme="dark"] .citation-footer {
  border-top-color: var(--border-color);
}

[data-theme="dark"] .citation-footer-title {
  color: var(--text-tertiary);
}

[data-theme="dark"] .citation-chip {
  background: rgba(14, 165, 233, 0.15);
  border-color: rgba(14, 165, 233, 0.3);
  color: #7dd3fc;
}

[data-theme="dark"] .citation-chip:hover {
  background: rgba(14, 165, 233, 0.25);
  border-color: rgba(14, 165, 233, 0.5);
}

/* System preference dark mode */
@media (prefers-color-scheme: dark) {
  [data-theme="system"] .inline-citation.pdf-citation {
    background: rgba(14, 165, 233, 0.15) !important;
    border-color: rgba(14, 165, 233, 0.3) !important;
    color: #7dd3fc !important;
  }

  [data-theme="system"] .inline-citation.pdf-citation:hover {
    background: #0284c7 !important;
    border-color: #0284c7 !important;
    color: white !important;
  }

  [data-theme="system"] .inline-citation.web-citation {
    background: rgba(34, 197, 94, 0.15) !important;
    border-color: rgba(34, 197, 94, 0.3) !important;
    color: #86efac !important;
  }

  [data-theme="system"] .inline-citation.web-citation:hover {
    background: #16a34a !important;
    border-color: #16a34a !important;
    color: white !important;
  }

  [data-theme="system"] .citation-footer {
    border-top-color: var(--border-color);
  }

  [data-theme="system"] .citation-footer-title {
    color: var(--text-tertiary);
  }

  [data-theme="system"] .citation-chip {
    background: rgba(14, 165, 233, 0.15);
    border-color: rgba(14, 165, 233, 0.3);
    color: #7dd3fc;
  }
}

/* Feedback Modal */
.feedback-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
}

.feedback-modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.feedback-modal {
  background: white;
  border-radius: 1rem;
  padding: 1.5rem;
  width: 90%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  transform: scale(0.95);
  transition: transform 0.2s ease;
}

.feedback-modal-overlay.open .feedback-modal {
  transform: scale(1);
}

.feedback-modal-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.feedback-modal-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.feedback-modal-icon.positive {
  background: #dcfce7;
}

.feedback-modal-icon.negative {
  background: #fee2e2;
}

.feedback-modal-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: #1f2937;
}

.feedback-modal-subtitle {
  font-size: 0.875rem;
  color: #6b7280;
}

.feedback-modal-field {
  margin-bottom: 1rem;
}

.feedback-modal-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: #374151;
  margin-bottom: 0.375rem;
}

.feedback-modal-input {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 1px solid #d1d5db;
  border-radius: 0.5rem;
  font-size: 0.9375rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.feedback-modal-input:focus {
  outline: none;
  border-color: #0066CC;
  box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

.feedback-modal-textarea {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 1px solid #d1d5db;
  border-radius: 0.5rem;
  font-size: 0.9375rem;
  min-height: 80px;
  resize: vertical;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.feedback-modal-textarea:focus {
  outline: none;
  border-color: #0066CC;
  box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

.feedback-modal-buttons {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.feedback-modal-btn {
  flex: 1;
  padding: 0.625rem 1rem;
  border-radius: 0.5rem;
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.feedback-modal-btn.cancel {
  background: white;
  border: 1px solid #d1d5db;
  color: #374151;
}

.feedback-modal-btn.cancel:hover {
  background: #f3f4f6;
}

.feedback-modal-btn.submit {
  background: #0066CC;
  border: none;
  color: white;
}

.feedback-modal-btn.submit:hover {
  background: #0052a3;
}

.feedback-modal-btn.submit:disabled {
  background: #9ca3af;
  cursor: not-allowed;
}

/* Feedback buttons */
.feedback-btn {
  padding: 0.25rem 0.5rem;
  border-radius: 0.375rem;
  transition: all 0.2s;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
}

.feedback-btn:hover {
  background: #f3f4f6;
}

.feedback-btn.active-positive {
  background: #dcfce7;
  border-color: #86efac;
  color: #166534;
}

.feedback-btn.active-negative {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #991b1b;
}

.feedback-submitted {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: #059669;
  padding: 0.25rem 0;
}

.feedback-submitted svg {
  width: 1rem;
  height: 1rem;
}

/* Lightbox */
.lightbox {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  cursor: zoom-out;
}

.lightbox img {
  max-width: 95vw;
  max-height: 95vh;
  object-fit: contain;
}

/* Settings Modal */
.settings-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.settings-modal {
  background: white;
  border-radius: 1rem;
  width: 90%;
  max-width: 700px;
  max-height: 85vh;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideUp 0.2s ease;
}

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

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid #e5e7eb;
}

.settings-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
  color: #111827;
  margin: 0;
}

.settings-close-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: #6b7280;
  cursor: pointer;
  transition: all 0.15s;
}

.settings-close-btn:hover {
  background: #f3f4f6;
  color: #111827;
}

.settings-content {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.settings-sidebar {
  width: 200px;
  border-right: 1px solid #e5e7eb;
  padding: 1rem 0.75rem;
  background: #f9fafb;
  flex-shrink: 0;
}

.settings-tab {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.625rem 0.875rem;
  border-radius: 0.5rem;
  border: none;
  background: transparent;
  color: #4b5563;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
}

.settings-tab:hover {
  background: #e5e7eb;
  color: #111827;
}

.settings-tab.active {
  background: white;
  color: #0066CC;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.settings-main {
  flex: 1;
  padding: 1.5rem;
  overflow-y: auto;
}

.settings-section h3 {
  font-size: 1.125rem;
  font-weight: 600;
  color: #111827;
  margin: 0 0 0.5rem 0;
}

.settings-description {
  font-size: 0.875rem;
  color: #6b7280;
  margin: 0 0 1.5rem 0;
}

.settings-option {
  margin-bottom: 1.5rem;
}

.settings-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 0.75rem;
}

.settings-value {
  font-size: 0.875rem;
  color: #6b7280;
  margin: 0;
}

.settings-description-small {
  font-size: 0.8125rem;
  color: #6b7280;
  margin: 0.25rem 0 0.75rem 0;
}

.settings-divider {
  height: 1px;
  background: #e5e7eb;
  margin: 1.5rem 0;
}

.settings-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: #0066CC;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 0.5rem;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s;
}

.settings-link-btn:hover {
  background: #dbeafe;
  border-color: #93c5fd;
}

/* Theme Selector */
.theme-selector {
  display: flex;
  gap: 1rem;
}

.theme-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem;
  border: 2px solid #e5e7eb;
  border-radius: 0.75rem;
  background: white;
  cursor: pointer;
  transition: all 0.15s;
  min-width: 100px;
}

.theme-option:hover {
  border-color: #93c5fd;
  background: #f8fafc;
}

.theme-option.active {
  border-color: #0066CC;
  background: #eff6ff;
}

.theme-option span {
  font-size: 0.8125rem;
  font-weight: 500;
  color: #374151;
}

.theme-preview {
  width: 60px;
  height: 40px;
  border-radius: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.light-preview {
  background: linear-gradient(135deg, #fefefe 0%, #f3f4f6 100%);
  border: 1px solid #e5e7eb;
  color: #f59e0b;
}

.dark-preview {
  background: linear-gradient(135deg, #1f2937 0%, #111827 100%);
  border: 1px solid #374151;
  color: #fbbf24;
}

.system-preview {
  background: linear-gradient(135deg, #fefefe 0%, #1f2937 100%);
  border: 1px solid #9ca3af;
}

.system-icon {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.system-icon svg:first-child {
  color: #f59e0b;
}

.system-icon svg:last-child {
  color: #fbbf24;
}

/* Account Info Card */
.account-info-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 0.75rem;
  margin-bottom: 1.5rem;
}

.account-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #0066CC;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 1rem;
  flex-shrink: 0;
}

.account-details {
  flex: 1;
  min-width: 0;
}

.account-name {
  font-weight: 600;
  color: #111827;
  margin: 0;
}

.account-email {
  font-size: 0.8125rem;
  color: #6b7280;
  margin: 0.25rem 0 0 0;
}

.account-email-primary {
  font-size: 0.9375rem;
  font-weight: 500;
  color: #111827;
  margin: 0;
}

/* Responsive */
@media (max-width: 640px) {
  .settings-modal {
    max-width: 100%;
    max-height: 100vh;
    border-radius: 0;
  }

  .settings-content {
    flex-direction: column;
  }

  .settings-sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid #e5e7eb;
    padding: 0.5rem;
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
  }

  .settings-tab {
    white-space: nowrap;
  }

  .theme-selector {
    flex-wrap: wrap;
  }

  .theme-option {
    min-width: 80px;
  }
}

/* ==========================================
   DARK MODE - MODALS
   ========================================== */

[data-theme="dark"] .settings-modal,
[data-theme="dark"] .feedback-modal {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
}

[data-theme="dark"] .settings-header {
  border-bottom-color: var(--border-color);
}

[data-theme="dark"] .settings-header h2 {
  color: var(--text-primary);
}

[data-theme="dark"] .settings-close-btn {
  color: var(--text-tertiary);
}

[data-theme="dark"] .settings-close-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

[data-theme="dark"] .settings-sidebar {
  background: var(--bg-secondary);
  border-right-color: var(--border-color);
}

[data-theme="dark"] .settings-tab {
  color: var(--text-secondary);
}

[data-theme="dark"] .settings-tab:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

[data-theme="dark"] .settings-tab.active {
  background: var(--bg-primary);
  color: var(--accent-color);
}

[data-theme="dark"] .settings-main {
  background: var(--bg-primary);
}

[data-theme="dark"] .settings-section h3 {
  color: var(--text-primary);
}

[data-theme="dark"] .settings-label {
  color: var(--text-secondary);
}

[data-theme="dark"] .settings-description,
[data-theme="dark"] .settings-description-small {
  color: var(--text-tertiary);
}

[data-theme="dark"] .theme-option {
  background: var(--bg-primary);
  border-color: var(--border-color);
}

[data-theme="dark"] .theme-option:hover {
  border-color: var(--accent-color);
  background: var(--bg-tertiary);
}

[data-theme="dark"] .theme-option.active {
  border-color: var(--accent-color);
  background: var(--bg-tertiary);
}

[data-theme="dark"] .theme-option span {
  color: var(--text-primary);
}

[data-theme="dark"] .account-info-card {
  background: var(--bg-secondary);
  border-color: var(--border-color);
}

[data-theme="dark"] .account-email-primary,
[data-theme="dark"] .account-name {
  color: var(--text-primary);
}

[data-theme="dark"] .account-email {
  color: var(--text-tertiary);
}

[data-theme="dark"] .settings-link-btn {
  background: var(--bg-tertiary);
  border-color: var(--border-color);
  color: var(--accent-color);
}

[data-theme="dark"] .settings-link-btn:hover {
  background: var(--bg-secondary);
}

[data-theme="dark"] .feedback-modal-title {
  color: var(--text-primary);
}

[data-theme="dark"] .feedback-modal-subtitle {
  color: var(--text-tertiary);
}

[data-theme="dark"] .feedback-modal-label {
  color: var(--text-secondary);
}

[data-theme="dark"] .feedback-modal-input,
[data-theme="dark"] .feedback-modal-textarea {
  background: var(--input-bg);
  border-color: var(--input-border);
  color: var(--text-primary);
}

[data-theme="dark"] .feedback-modal-btn.cancel {
  background: var(--bg-tertiary);
  border-color: var(--border-color);
  color: var(--text-primary);
}

[data-theme="dark"] .feedback-modal-btn.cancel:hover {
  background: var(--bg-secondary);
}

/* System preference dark mode */
@media (prefers-color-scheme: dark) {
  [data-theme="system"] .settings-modal,
  [data-theme="system"] .feedback-modal {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
  }

  [data-theme="system"] .settings-header {
    border-bottom-color: var(--border-color);
  }

  [data-theme="system"] .settings-header h2 {
    color: var(--text-primary);
  }

  [data-theme="system"] .settings-sidebar {
    background: var(--bg-secondary);
    border-right-color: var(--border-color);
  }

  [data-theme="system"] .settings-tab {
    color: var(--text-secondary);
  }

  [data-theme="system"] .settings-tab.active {
    background: var(--bg-primary);
    color: var(--accent-color);
  }

  [data-theme="system"] .settings-section h3 {
    color: var(--text-primary);
  }

  [data-theme="system"] .theme-option {
    background: var(--bg-primary);
    border-color: var(--border-color);
  }

  [data-theme="system"] .account-info-card {
    background: var(--bg-secondary);
    border-color: var(--border-color);
  }
}

/* ==========================================
   CITATION SIDE PANEL - OVERLAY DRAWER
   ========================================== */

/* Dark overlay backdrop - offset for slim sidebar */
.side-panel-overlay {
  position: fixed;
  top: 0;
  left: 52px;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 199;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  backdrop-filter: blur(2px);
}

.side-panel-overlay.open {
  opacity: 1;
  visibility: visible;
}

/* Side panel drawer - slides from right */
.side-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 520px;
  max-width: 90vw;
  height: 100vh;
  background: var(--bg-primary);
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
  z-index: 200;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
}

.side-panel.open {
  transform: translateX(0);
}

/* Header */
.side-panel-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  background: var(--bg-secondary);
  flex-shrink: 0;
}

/* Content area */
.side-panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  background: var(--bg-primary);
}

.side-panel-content::-webkit-scrollbar {
  width: 6px;
}

.side-panel-content::-webkit-scrollbar-track {
  background: transparent;
}

.side-panel-content::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

.side-panel-content::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}

/* PDF download button */
.pdf-download-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  background: #0066CC;
  color: white;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.2s;
  margin-top: 0.5rem;
}

.pdf-download-btn:hover {
  background: #004499;
}

/* ==========================================
   POPOUT WINDOW
   ========================================== */

.popout-window {
  position: fixed;
  background: var(--bg-primary);
  border-radius: 16px;
  box-shadow:
    0 32px 64px -12px rgba(0, 0, 0, 0.25),
    0 16px 32px -8px rgba(0, 0, 0, 0.15),
    0 0 0 1px rgba(0, 0, 0, 0.08);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 350px;
  min-height: 350px;
  animation: popout-appear 0.2s ease-out;
}

@keyframes popout-appear {
  0% {
    opacity: 0;
    transform: scale(0.95);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

.popout-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  cursor: move;
  user-select: none;
}

.popout-drag-area {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.popout-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.popout-controls {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
}

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

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

.popout-btn.popout-close:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}

.popout-btn:active {
  transform: scale(0.95);
}

.popout-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-primary);
}

.popout-body .side-panel-header {
  flex-shrink: 0;
}

.popout-body .side-panel-content {
  flex: 1;
  overflow-y: auto;
}

.popout-resize-handle {
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 16px;
  height: 16px;
  cursor: nwse-resize;
  opacity: 0.4;
  transition: opacity 0.15s ease;
}

.popout-resize-handle::before {
  content: '';
  position: absolute;
  right: 0;
  bottom: 0;
  width: 12px;
  height: 12px;
  border-right: 2px solid var(--text-tertiary);
  border-bottom: 2px solid var(--text-tertiary);
  border-radius: 0 0 4px 0;
}

.popout-resize-handle:hover {
  opacity: 1;
}

.popout-window:hover .popout-resize-handle {
  opacity: 0.6;
}

/* Cursor overrides for popout */
.popout-window * {
  cursor: default;
}

.popout-header,
.popout-header * {
  cursor: move;
}

.popout-header button,
.popout-header a {
  cursor: pointer;
}

.popout-resize-handle {
  cursor: nwse-resize;
}

/* ==========================================
   RESPONSIVE
   ========================================== */

@media (max-width: 768px) {
  .side-panel {
    width: 100%;
    max-width: 100vw;
  }
}

/* ==========================================
   DARK MODE
   ========================================== */

[data-theme="dark"] .side-panel {
  background: var(--bg-primary);
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .side-panel-overlay {
  background: rgba(0, 0, 0, 0.7);
}

[data-theme="dark"] .side-panel-header {
  background: var(--bg-secondary);
  border-bottom-color: var(--border-color);
}

[data-theme="dark"] .side-panel-header .text-lg,
[data-theme="dark"] .side-panel-header .text-gray-900,
[data-theme="dark"] .side-panel-header .font-semibold {
  color: var(--text-primary) !important;
}

[data-theme="dark"] .side-panel-header .text-gray-500,
[data-theme="dark"] .side-panel-header .text-gray-400,
[data-theme="dark"] .side-panel-header .text-gray-600 {
  color: var(--text-tertiary) !important;
}

/* Source badge dark mode */
[data-theme="dark"] .source-badge {
  background: var(--bg-tertiary) !important;
  color: var(--text-secondary) !important;
}

[data-theme="dark"] .source-badge.web-source {
  background: rgba(59, 130, 246, 0.15) !important;
  color: #60a5fa !important;
}

/* Web source meta dark mode */
[data-theme="dark"] .web-source-meta .domain {
  color: var(--text-primary) !important;
}

[data-theme="dark"] .web-source-meta .date {
  color: var(--text-tertiary) !important;
}

[data-theme="dark"] .web-source-meta .separator {
  color: var(--border-color) !important;
}

[data-theme="dark"] .side-panel-header button:hover {
  background: var(--bg-tertiary) !important;
}

[data-theme="dark"] .side-panel-content {
  background: var(--bg-primary);
}

[data-theme="dark"] .side-panel-content::-webkit-scrollbar-thumb {
  background: var(--border-light);
}

/* Popout window dark mode */
[data-theme="dark"] .popout-window {
  background: var(--bg-primary);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5), 0 0 0 1px var(--border-color);
}

[data-theme="dark"] .popout-header {
  background: var(--bg-secondary);
  border-bottom-color: var(--border-color);
}

[data-theme="dark"] .popout-title {
  color: var(--text-primary);
}

[data-theme="dark"] .popout-btn {
  color: var(--text-tertiary);
}

[data-theme="dark"] .popout-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

[data-theme="dark"] .popout-btn.popout-close:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
}

[data-theme="dark"] .popout-body {
  background: var(--bg-primary);
}

[data-theme="dark"] .popout-resize-handle::before {
  border-right-color: var(--text-tertiary);
  border-bottom-color: var(--text-tertiary);
}

/* System preference dark mode */
@media (prefers-color-scheme: dark) {
  [data-theme="system"] .side-panel {
    background: var(--bg-primary);
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.5);
  }

  [data-theme="system"] .side-panel-overlay {
    background: rgba(0, 0, 0, 0.7);
  }

  [data-theme="system"] .side-panel-header {
    background: var(--bg-secondary);
    border-bottom-color: var(--border-color);
  }

  [data-theme="system"] .popout-window {
    background: var(--bg-primary);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5), 0 0 0 1px var(--border-color);
  }

  [data-theme="system"] .popout-header {
    background: var(--bg-secondary);
    border-bottom-color: var(--border-color);
  }

  [data-theme="system"] .popout-title {
    color: var(--text-primary);
  }

  [data-theme="system"] .popout-btn {
    color: var(--text-tertiary);
  }

  [data-theme="system"] .popout-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
  }
}

/* ==========================================
   MOBILE RESPONSIVE
   ========================================== */

@media (max-width: 640px) {
  .side-panel-overlay {
    left: 48px;
  }
}

/* ==========================================
   SLIM PERSISTENT SIDEBAR
   ========================================== */

.slim-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 52px;
  height: 100vh;
  background: var(--bg-primary);
  border-right: 1px solid var(--border-color);
  z-index: 150;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 12px 0;
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.05);
}

.slim-sidebar-top,
.slim-sidebar-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.slim-sidebar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: transparent;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.15s ease;
  position: relative;
}

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

.slim-sidebar-btn:active {
  transform: scale(0.95);
}

.slim-new-chat:hover {
  color: #0066CC;
  background: rgba(0, 102, 204, 0.1);
}

.slim-logout:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
}

.slim-notifications {
  position: relative;
}

.slim-notification-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  background: linear-gradient(135deg, #ea580c, #dc2626);
  color: white;
  font-size: 10px;
  font-weight: 700;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: notification-pulse 2s ease-in-out infinite;
}

@keyframes notification-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(234, 88, 12, 0.4); }
  50% { box-shadow: 0 0 0 4px rgba(234, 88, 12, 0); }
}

.slim-user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #0066CC;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  margin-top: 4px;
  border: 2px solid transparent;
  transition: all 0.15s ease;
}

.slim-user-avatar:hover {
  border-color: rgba(255, 255, 255, 0.3);
  transform: scale(1.05);
  box-shadow: 0 2px 8px rgba(0, 102, 204, 0.4);
}

/* ==========================================
   CHAT HISTORY SIDEBAR - OVERLAY DRAWER
   ========================================== */

/* Dark overlay backdrop - covers content area only */
.history-overlay {
  position: fixed;
  top: 0;
  left: 52px;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 140;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.history-overlay.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* Sidebar drawer - slides out from slim sidebar */
.history-sidebar {
  position: fixed;
  top: 0;
  left: 52px;
  height: 100vh;
  width: 280px;
  max-width: calc(85vw - 52px);
  background: var(--bg-primary);
  z-index: 145;
  display: flex;
  flex-direction: column;
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.2);
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* Header */
.history-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
}

.history-sidebar-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 15px;
  color: var(--text-primary);
}

.history-close-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all 0.15s ease;
}

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

/* Sessions list */
.history-sessions {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.history-sessions::-webkit-scrollbar {
  width: 6px;
}

.history-sessions::-webkit-scrollbar-track {
  background: transparent;
}

.history-sessions::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

.history-sessions::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}

/* Loading state */
.history-loading {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-tertiary);
}

.history-spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 2px solid var(--border-color);
  border-top-color: #0066CC;
  border-radius: 50%;
  animation: history-spin 0.8s linear infinite;
}

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

.history-loading p {
  margin-top: 12px;
  font-size: 14px;
}

/* Error state */
.history-error {
  padding: 32px 16px;
  text-align: center;
  color: #ef4444;
  font-size: 14px;
}

.history-retry {
  display: block;
  margin: 12px auto 0;
  color: #0066CC;
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: underline;
  font-size: 14px;
}

.history-retry:hover {
  color: #0052a3;
}

/* Empty state */
.history-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 14px;
}

.history-empty-sub {
  margin-top: 4px;
  color: var(--text-light);
  font-size: 13px;
}

/* Session groups */
.history-group {
  padding: 8px 0;
}

.history-group-label {
  padding: 8px 16px 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Session items */
.history-session-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  text-align: left;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background 0.15s ease;
  position: relative;
}

.history-session-item:hover {
  background: var(--bg-tertiary);
}

.history-session-item.active {
  background: rgba(0, 102, 204, 0.1);
}

.history-session-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  background: #0066CC;
  border-radius: 0 2px 2px 0;
}

.history-session-content {
  flex: 1;
  min-width: 0;
}

.history-session-title {
  font-size: 13px;
  color: var(--text-primary);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin: 0;
}

.history-session-item.active .history-session-title {
  color: #0066CC;
  font-weight: 600;
}

.history-session-meta {
  font-size: 11px;
  color: var(--text-tertiary);
  margin: 2px 0 0;
}

/* Session actions container */
.history-session-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.history-session-item:hover .history-session-actions {
  opacity: 1;
}

/* Star button */
.history-star-btn {
  padding: 5px;
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all 0.15s ease;
  border-radius: 6px;
  flex-shrink: 0;
}

.history-star-btn:hover {
  color: #f59e0b;
  background: rgba(245, 158, 11, 0.1);
}

.history-star-btn.starred {
  color: #f59e0b;
  opacity: 1;
}

.history-star-btn.starred:hover {
  color: #d97706;
}

/* Always show star button when starred */
.history-session-item .history-star-btn.starred {
  opacity: 1;
}

/* Delete button */
.history-delete-btn {
  padding: 5px;
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all 0.15s ease;
  border-radius: 6px;
  flex-shrink: 0;
}

.history-delete-btn:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
}

/* Favorites section styling */
.history-favorites {
  background: rgba(245, 158, 11, 0.05);
  border-bottom: 1px solid rgba(245, 158, 11, 0.2);
}

.history-favorites-label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #d97706;
}

/* Session title row with unread badge */
.history-session-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.history-session-title-row .history-session-title {
  flex: 1;
  min-width: 0;
}

/* Unread badge */
.unread-badge {
  background: linear-gradient(135deg, #ea580c, #dc2626);
  color: white;
  font-size: 0.625rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 9999px;
  min-width: 16px;
  text-align: center;
  flex-shrink: 0;
  animation: unread-pulse 2s ease-in-out infinite;
}

@keyframes unread-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(234, 88, 12, 0.4); }
  50% { box-shadow: 0 0 0 4px rgba(234, 88, 12, 0); }
}

/* Admin message preview */
.admin-message-preview {
  font-size: 0.6875rem;
  color: #ea580c;
  font-style: italic;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ==========================================
   DARK MODE
   ========================================== */

[data-theme="dark"] .slim-sidebar {
  background: var(--bg-secondary);
  border-color: var(--border-color);
}

[data-theme="dark"] .slim-sidebar-btn:hover {
  background: var(--bg-tertiary);
}

[data-theme="dark"] .slim-user-avatar {
  background: #0066CC;
}

[data-theme="dark"] .history-overlay {
  background: rgba(0, 0, 0, 0.7);
}

[data-theme="dark"] .history-sidebar {
  background: var(--bg-primary);
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .history-sidebar-header {
  background: var(--bg-secondary);
  border-color: var(--border-color);
}

[data-theme="dark"] .history-sessions::-webkit-scrollbar-thumb {
  background: var(--border-light);
}

[data-theme="dark"] .history-session-item:hover {
  background: var(--bg-tertiary);
}

[data-theme="dark"] .history-session-item.active {
  background: rgba(0, 102, 204, 0.15);
}

[data-theme="dark"] .history-favorites {
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.3);
}

[data-theme="dark"] .admin-message-preview {
  color: #fb923c;
}

/* System dark mode */
@media (prefers-color-scheme: dark) {
  [data-theme="system"] .slim-sidebar {
    background: var(--bg-secondary);
    border-color: var(--border-color);
  }

  [data-theme="system"] .slim-sidebar-btn:hover {
    background: var(--bg-tertiary);
  }

  [data-theme="system"] .history-overlay {
    background: rgba(0, 0, 0, 0.7);
  }

  [data-theme="system"] .history-sidebar {
    background: var(--bg-primary);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
  }

  [data-theme="system"] .history-sidebar-header {
    background: var(--bg-secondary);
    border-color: var(--border-color);
  }

  [data-theme="system"] .history-session-item:hover {
    background: var(--bg-tertiary);
  }

  [data-theme="system"] .history-session-item.active {
    background: rgba(0, 102, 204, 0.15);
  }

  [data-theme="system"] .history-favorites {
    background: rgba(245, 158, 11, 0.1);
    border-color: rgba(245, 158, 11, 0.3);
  }

  [data-theme="system"] .admin-message-preview {
    color: #fb923c;
  }
}

/* ==========================================
   MOBILE RESPONSIVE
   ========================================== */

@media (max-width: 640px) {
  .slim-sidebar {
    width: 48px;
    padding: 8px 0;
  }

  .slim-sidebar-btn {
    width: 36px;
    height: 36px;
  }

  .slim-user-avatar {
    width: 32px;
    height: 32px;
    font-size: 12px;
  }

  .history-overlay {
    left: 48px;
  }

  .history-sidebar {
    left: 48px;
    width: calc(100vw - 48px);
    max-width: calc(100vw - 48px);
  }
}

/* Ensure slim sidebar stays on top of everything */
.slim-sidebar {
  z-index: 150 !important;
}


/*# sourceMappingURL=styles.eafdfe783947bc24f1fc.css.map*/