/**
 * Redpoint Chat Analyst Styles
 * Professional chat interface matching the Company Screener design
 */

/* ============================================
   Chat-specific CSS Variables (extends shared.css)
   ============================================ */
:root {
  --sidebar-width: 280px;
  --header-height: 56px;
  --drawer-width: 50%;

  /* Chat-specific */
  --color-user-bg: var(--color-primary);
  --color-user-text: white;
  --color-assistant-bg: var(--color-bg);
  --color-assistant-border: var(--color-border);
  --color-tool-running: #dbeafe;
  --color-tool-running-border: #93c5fd;
  --color-tool-running-text: #1d4ed8;
  --color-tool-completed: var(--color-success-light);
  --color-tool-completed-border: #86efac;
  --color-tool-completed-text: #166534;
}

/* ============================================
   Reset & Base
   ============================================ */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.5;
  color: var(--color-text-primary);
  background: var(--color-bg-secondary);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* ============================================
   App Layout
   ============================================ */
.chat-app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

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

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

.header-left h1 {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text-primary);
}

.header-center {
  display: flex;
  align-items: center;
}

.mode-toggle {
  display: flex;
  background: var(--color-bg-tertiary);
  border-radius: var(--radius-md);
  padding: 3px;
}

.mode-btn {
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 500;
  border: none;
  background: transparent;
  color: var(--color-text-secondary);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.mode-btn.active {
  background: var(--color-bg);
  color: var(--color-primary);
  box-shadow: var(--shadow-sm);
}

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

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

.connection-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--color-text-muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-text-muted);
}

.connection-status.connected .status-dot {
  background: var(--color-success);
}

.connection-status.connected {
  color: var(--color-success);
}

/* Gmail Status Wrapper & Dropdown */
.gmail-status-wrapper {
  position: relative;
}

.gmail-status-wrapper .connection-status {
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}

.gmail-status-wrapper .connection-status:hover {
  background: var(--color-bg-tertiary);
}

.gmail-status-wrapper .connection-status.connected {
  cursor: pointer;
}

.gmail-status-wrapper .dropdown-arrow {
  margin-left: 4px;
  opacity: 0.6;
  transition: transform var(--transition-fast);
}

.gmail-status-wrapper.open .dropdown-arrow {
  transform: rotate(180deg);
}

.gmail-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  min-width: 160px;
  z-index: 100;
  animation: dropdown-appear 0.15s ease;
}

.gmail-dropdown.hidden {
  display: none;
}

.gmail-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  font-size: 13px;
  color: var(--color-text-primary);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: left;
}

.gmail-dropdown-item:hover {
  background: var(--color-bg-secondary);
  color: var(--color-error);
}

.gmail-dropdown-item svg {
  flex-shrink: 0;
  color: var(--color-text-muted);
}

.gmail-dropdown-item:hover svg {
  color: var(--color-error);
}

.gmail-dropdown-item.gmail-connect:hover {
  color: var(--color-success);
}

.gmail-dropdown-item.gmail-connect:hover svg {
  color: var(--color-success);
}

/* Show/hide based on connection state */
.gmail-status-wrapper.connected .gmail-connect,
.drive-status-wrapper.connected .gmail-connect {
  display: none;
}

.gmail-status-wrapper:not(.connected) .gmail-disconnect,
.drive-status-wrapper:not(.connected) .gmail-disconnect {
  display: none;
}

/* Drive connection widget — mirrors gmail-status-wrapper */
.drive-status-wrapper {
  position: relative;
}

.drive-status-wrapper .connection-status {
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}

.drive-status-wrapper .connection-status:hover {
  background: var(--color-bg-tertiary);
}

.drive-status-wrapper .dropdown-arrow {
  margin-left: 4px;
  opacity: 0.6;
  transition: transform var(--transition-fast);
}

.drive-status-wrapper.open .dropdown-arrow {
  transform: rotate(180deg);
}

.drive-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  min-width: 180px;
  z-index: 100;
  animation: dropdown-appear 0.15s ease;
}

.drive-dropdown.hidden {
  display: none;
}

/* ============================================
   Buttons
   ============================================ */
/* Chat-specific button overrides (base in shared.css) */
.btn-primary {
  box-shadow: 0 2px 4px rgba(196, 18, 48, 0.2);
  position: relative;
  overflow: hidden;
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(196, 18, 48, 0.3);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0) scale(0.98);
  box-shadow: 0 1px 2px rgba(196, 18, 48, 0.2);
}

.btn-primary:disabled {
  box-shadow: none;
}

/* Send button specific enhancements */
.btn-send {
  position: relative;
}

.btn-send::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.2);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

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

/* Send button loading state */
.btn-send.loading {
  pointer-events: none;
}

.btn-send.loading::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* Send button success flash */
.btn-send.success {
  background: var(--color-success);
  animation: success-flash 0.3s ease;
}

@keyframes success-flash {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

.btn-secondary.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.btn-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  color: var(--color-text-secondary);
  transition: all var(--transition-fast);
}

.btn-icon:hover:not(:disabled) {
  background: var(--color-bg-secondary);
  color: var(--color-primary);
  border-color: var(--color-primary);
  transform: translateY(-1px);
}

.btn-icon:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-icon.btn-sm {
  width: 24px;
  height: 24px;
}

kbd {
  display: inline-block;
  padding: 2px 6px;
  font-size: 10px;
  font-family: var(--font-mono);
  background: var(--color-bg-tertiary);
  border: 1px solid var(--color-border);
  border-radius: 3px;
  margin-left: 6px;
  color: var(--color-text-muted);
}

/* ============================================
   Body Layout
   ============================================ */
.chat-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* ============================================
   Conversation Sidebar
   ============================================ */
.conversation-sidebar {
  width: var(--sidebar-width);
  background: var(--color-bg);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex-shrink: 0;
}

.conversation-sidebar.collapsed {
  display: none;
}

.sidebar-section {
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border-light);
}

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

.sidebar-section h3 {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0;
}

/* New Chat Button */
.new-chat-section {
  background: var(--color-bg-secondary);
}

.btn-new-chat {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: 0 2px 6px rgba(196, 18, 48, 0.25);
  position: relative;
}

.btn-new-chat:hover {
  background: var(--color-primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(196, 18, 48, 0.35);
}

.btn-new-chat:active {
  transform: translateY(0) scale(0.98);
  box-shadow: 0 1px 3px rgba(196, 18, 48, 0.2);
}

.btn-new-chat kbd {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.3);
  color: white;
  margin-left: auto;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.btn-new-chat:hover kbd {
  opacity: 1;
}

/* Suggested Prompts */
.suggested-prompts {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#suggested-section .section-header {
  cursor: pointer;
  user-select: none;
}

#suggested-section .section-header .expand-icon {
  transition: transform 0.2s ease;
  font-size: 10px;
  color: var(--color-text-muted);
}

#suggested-section.collapsed .section-header .expand-icon {
  transform: rotate(-90deg);
}

#suggested-section.collapsed .suggested-prompts {
  display: none;
}

.sidebar-section h3 {
  font-weight: 600;
  letter-spacing: 0.75px;
}

.prompt-chip {
  padding: 10px 14px;
  font-size: 12px;
  text-align: left;
  background: var(--color-bg);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: var(--radius-md);
  cursor: pointer;
  color: var(--color-text-secondary);
  transition: all var(--transition-fast);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

.prompt-chip:hover {
  background: var(--color-primary-light);
  border-color: var(--color-primary);
  color: var(--color-primary);
  transform: translateX(4px);
  box-shadow: 0 2px 8px rgba(196, 18, 48, 0.1);
}

/* Transcript Filters */
.transcript-filters {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.filter-group label {
  font-size: 11px;
  font-weight: 500;
  color: var(--color-text-muted);
}

.filter-select {
  padding: 8px 10px;
  font-size: 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  color: var(--color-text-primary);
  cursor: pointer;
  transition: all var(--transition-fast);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%236B7280' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

.filter-select:hover {
  border-color: var(--color-text-muted);
}

.filter-select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px var(--color-primary-light);
}

/* Company Multiselect */
.company-multiselect {
  position: relative;
}

.company-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 6px 8px;
  min-height: 34px;
  font-size: 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  cursor: pointer;
  transition: all var(--transition-fast);
  align-items: center;
}

.company-chips:hover {
  border-color: var(--color-text-muted);
}

.company-placeholder {
  color: var(--color-text-muted);
  font-size: 12px;
}

.company-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  background: var(--color-primary-light);
  border: 1px solid rgba(196, 18, 48, 0.2);
  border-radius: 4px;
  font-size: 11px;
  color: var(--color-primary);
  line-height: 1.3;
  max-width: 200px;
}

.company-chip-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.company-chip-remove {
  background: none;
  border: none;
  color: var(--color-primary);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0;
  opacity: 0.6;
  flex-shrink: 0;
}

.company-chip-remove:hover {
  opacity: 1;
}

.company-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 200px;
  overflow-y: auto;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  z-index: 50;
  margin-top: 4px;
}

.company-dropdown-search {
  position: sticky;
  top: 0;
  padding: 6px 8px;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border-light);
  z-index: 1;
}

.company-dropdown-search input {
  width: 100%;
  padding: 5px 8px;
  font-size: 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  outline: none;
  box-sizing: border-box;
}

.company-dropdown-search input:focus {
  border-color: var(--color-primary);
}

.company-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.company-dropdown-item:hover {
  background: var(--color-bg-tertiary);
}

.company-dropdown-item.selected {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.company-dropdown-check {
  width: 14px;
  height: 14px;
  border: 1px solid var(--color-border);
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 10px;
}

.company-dropdown-item.selected .company-dropdown-check {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: white;
}

.company-dropdown-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.company-dropdown-count {
  color: var(--color-text-muted);
  font-size: 11px;
  flex-shrink: 0;
}

/* Transcript Multiselect */
.transcript-multiselect {
  position: relative;
}

.transcript-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 6px 8px;
  min-height: 34px;
  font-size: 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  cursor: pointer;
  transition: all var(--transition-fast);
  align-items: center;
}

.transcript-chips:hover {
  border-color: var(--color-text-muted);
}

.transcript-placeholder {
  color: var(--color-text-muted);
  font-size: 12px;
}

.transcript-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  background: #dbeafe;
  border: 1px solid #93c5fd;
  border-radius: 4px;
  font-size: 11px;
  color: #1e40af;
  line-height: 1.3;
  max-width: 220px;
}

.transcript-chip-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.transcript-chip-remove {
  background: none;
  border: none;
  color: #1e40af;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0;
  opacity: 0.6;
  flex-shrink: 0;
}

.transcript-chip-remove:hover {
  opacity: 1;
}

.transcript-dropdown {
  position: fixed;
  max-height: 280px;
  width: 400px;
  overflow-y: auto;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 100;
}

.transcript-dropdown-search {
  position: sticky;
  top: 0;
  padding: 6px 8px;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border-light);
  z-index: 1;
}

.transcript-dropdown-search input {
  width: 100%;
  padding: 5px 8px;
  font-size: 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  outline: none;
  box-sizing: border-box;
}

.transcript-dropdown-search input:focus {
  border-color: #2563eb;
}

.transcript-dropdown-header {
  padding: 6px 10px 4px;
  font-size: 10px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-top: 1px solid var(--color-border-light);
}

.transcript-dropdown-header:first-child {
  border-top: none;
}

.transcript-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  font-size: 11px;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.transcript-dropdown-item:hover {
  background: var(--color-bg-tertiary);
}

.transcript-dropdown-item.selected {
  background: #dbeafe;
  color: #1e40af;
}

.transcript-dropdown-check {
  width: 14px;
  height: 14px;
  border: 1px solid var(--color-border);
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 10px;
}

.transcript-dropdown-item.selected .transcript-dropdown-check {
  background: #2563eb;
  border-color: #2563eb;
  color: white;
}

.transcript-dropdown-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.transcript-internal-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  color: #9333ea;
  background: #f3e8ff;
  border-radius: 3px;
  padding: 1px 5px;
  margin-right: 6px;
  flex-shrink: 0;
}

.source-filter-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.source-pill {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 12px;
  border: 1px solid #d1d5db;
  background: transparent;
  color: #6b7280;
  cursor: pointer;
  transition: all 0.15s;
}

.source-pill:hover {
  border-color: #9ca3af;
  color: #374151;
}

.source-pill.active {
  background: #2563eb;
  border-color: #2563eb;
  color: white;
}

/* Conversation List */
.conversations-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.conversation-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.empty-conversations {
  font-size: 12px;
  color: var(--color-text-muted);
  text-align: center;
  padding: 16px 8px;
}

.conversation-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--color-bg);
  border: 1px solid transparent;
  border-left: 3px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
}

.conversation-item:hover {
  border-color: rgba(196, 18, 48, 0.2);
  border-left-color: var(--color-primary);
  background: rgba(255, 255, 255, 0.5);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.conversation-item.active {
  background: var(--color-primary-light);
  border-color: rgba(196, 18, 48, 0.3);
  border-left-color: var(--color-primary);
  border-left-width: 4px;
  box-shadow: 0 2px 4px rgba(196, 18, 48, 0.08);
}

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

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

.conversation-meta {
  font-size: 11px;
  color: var(--color-text-muted);
  margin-top: 2px;
}

.conversation-actions {
  display: flex;
  gap: 4px;
}

.conversation-actions button {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  opacity: 0;
  transform: translateX(4px);
}

/* Stagger animation for action buttons */
.conversation-item:hover .conversation-actions button {
  opacity: 1;
  transform: translateX(0);
}

.conversation-item:hover .conversation-actions button:nth-child(1) {
  transition-delay: 0ms;
}

.conversation-item:hover .conversation-actions button:nth-child(2) {
  transition-delay: 30ms;
}

.conversation-item:hover .conversation-actions button:nth-child(3) {
  transition-delay: 60ms;
}

.conversation-item:hover .conversation-actions button:nth-child(4) {
  transition-delay: 90ms;
}

.conversation-actions button:hover {
  background: var(--color-bg-tertiary);
  color: var(--color-text-primary);
  transform: scale(1.1);
}

.conversation-actions button.share-btn:hover {
  color: #2563eb;
  background: #dbeafe;
}

.conversation-actions button.delete-btn:hover {
  color: var(--color-error);
  background: var(--color-error-light);
}

/* ============================================
   Main Chat Area
   ============================================ */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--color-bg-secondary);
  min-width: 0;
  position: relative;
  border: none;
}

.messages-container {
  flex: 1;
  overflow-y: auto;
  overflow-anchor: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: relative;
  z-index: 2;
  background: var(--color-bg);
  /* GPU layer — isolate scroll repaints from fixed elements */
  will-change: scroll-position;
  -webkit-transform: translateZ(0);
}

/* Empty State */
.chat-empty-state {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 140px; /* Leave room for input area */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--color-text-muted);
  pointer-events: none;
  z-index: 3; /* Above messages-container (z-index: 2) */
  background: var(--color-bg); /* Cover messages container when visible */
}

.chat-empty-state.hidden {
  display: none;
}

.empty-state-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 560px;
  pointer-events: auto;
}

.chat-empty-state .empty-icon {
  margin-bottom: 16px;
  color: var(--color-border);
  opacity: 0.5;
}

.chat-empty-state h2 {
  font-size: 18px;
  font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: 6px;
}

.chat-empty-state .empty-subtext {
  font-size: 13px;
  max-width: 400px;
  line-height: 1.5;
  color: var(--color-text-muted);
  margin-bottom: 24px;
}

/* Prompt Suggestion Cards */
.prompt-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
}

.prompt-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  padding: 14px 16px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  position: relative;
  opacity: 0;
  animation: card-fade-in 0.3s ease forwards;
}

.prompt-card:nth-child(1) { animation-delay: 0s; }
.prompt-card:nth-child(2) { animation-delay: 0.08s; }
.prompt-card:nth-child(3) { animation-delay: 0.16s; }
.prompt-card:nth-child(4) { animation-delay: 0.24s; }

@keyframes card-fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.prompt-card:hover {
  border-color: var(--color-primary);
  box-shadow: 0 4px 12px rgba(196, 18, 48, 0.1);
  transform: translateY(-2px);
}

.prompt-card:active {
  transform: scale(0.98);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.prompt-card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: 4px;
}

.prompt-card:hover .prompt-card-title {
  color: var(--color-primary);
}

.prompt-card-preview {
  font-size: 12px;
  color: var(--color-text-muted);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.prompt-card-arrow {
  position: absolute;
  top: 14px;
  right: 12px;
  color: var(--color-text-muted);
  opacity: 0;
  transform: translateX(-4px);
  transition: all 0.2s ease;
}

.prompt-card:hover .prompt-card-arrow {
  opacity: 1;
  transform: translateX(0);
  color: var(--color-primary);
}

/* Messages */
.message {
  max-width: 80%;
  animation: message-appear 0.2s ease;
}

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

.message-user {
  align-self: flex-end;
}

.message-user .message-content {
  background: var(--color-user-bg);
  color: var(--color-user-text);
  padding: 12px 16px;
  border-radius: 18px 18px 4px 18px;
  box-shadow: var(--shadow-sm);
}

.message-assistant {
  align-self: flex-start;
}

.message-assistant .message-content {
  background: var(--color-assistant-bg);
  border: none;
  border-left: 2px solid var(--color-border);
  padding: 16px 20px;
  border-radius: 0 12px 12px 0;
  box-shadow: none;
}

/* Hide empty message content bubble */
.message-assistant .message-content:has(.message-content-text:empty) {
  display: none;
}

.message-content {
  font-size: 14px;
  line-height: 1.6;
}

.message-content p {
  margin: 0 0 12px 0;
}

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

.message-content code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--color-bg-tertiary);
  padding: 2px 6px;
  border-radius: 4px;
}

.message-user .message-content code {
  background: rgba(255, 255, 255, 0.2);
}

.message-content pre {
  margin: 12px 0;
  padding: 12px;
  background: var(--color-bg-tertiary);
  border-radius: var(--radius-md);
  overflow-x: auto;
}

.message-content pre code {
  background: none;
  padding: 0;
}

.message-timestamp {
  font-size: 10px;
  color: var(--color-text-muted);
  margin-top: 4px;
}

.message-user .message-timestamp {
  text-align: right;
}

/* Truncation Warning */
.truncation-warning {
  margin-top: 16px;
  padding: 12px 14px;
  font-size: 13px;
  color: #92400e;
  background: #fef3c7;
  border: 1px solid #fcd34d;
  border-radius: var(--radius-md);
  border-left: 3px solid var(--color-warning);
}

/* Message Actions (Copy, Regenerate) */
.message-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

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

.message-action-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text-secondary);
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.message-action-btn:hover {
  color: var(--color-primary);
  border-color: var(--color-primary);
  background: var(--color-primary-light);
}

.message-action-btn.copied {
  color: var(--color-success);
  border-color: var(--color-success);
  background: var(--color-success-light);
}

.message-action-btn svg {
  flex-shrink: 0;
}

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

/* Follow-Up Suggestion Chips */
.follow-up-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--color-border-light);
}

.follow-up-chip {
  padding: 6px 14px;
  font-size: 13px;
  font-family: var(--font-sans);
  color: var(--color-text-secondary);
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: 20px;
  cursor: pointer;
  transition: all var(--transition-fast);
  opacity: 0;
  animation: chip-fade-in 0.3s ease forwards;
  max-width: 100%;
  text-align: left;
  line-height: 1.4;
}

.follow-up-chip:nth-child(1) { animation-delay: 0s; }
.follow-up-chip:nth-child(2) { animation-delay: 0.08s; }
.follow-up-chip:nth-child(3) { animation-delay: 0.16s; }

@keyframes chip-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.follow-up-chip:hover {
  color: var(--color-primary);
  border-color: var(--color-primary);
  background: var(--color-primary-light);
}

.follow-up-chip:active {
  transform: scale(0.97);
}

/* Feedback divider */
.feedback-divider {
  width: 1px;
  height: 20px;
  background: var(--color-border);
  margin: 0 4px;
}

/* Feedback buttons */
.feedback-btn {
  padding: 6px 8px !important;
}

.feedback-btn.active {
  color: var(--color-primary);
  border-color: var(--color-primary);
  background: var(--color-primary-light);
}

.feedback-btn.inactive {
  opacity: 0.4;
}

.feedback-up.active svg {
  fill: var(--color-success);
  stroke: var(--color-success);
}

.feedback-down.active svg {
  fill: var(--color-error);
  stroke: var(--color-error);
}

/* Feedback textarea */
.feedback-textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  color: var(--color-text-primary);
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
  min-height: 100px;
  box-sizing: border-box;
}

.feedback-textarea:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.feedback-textarea::placeholder {
  color: var(--color-text-muted);
}

/* Process Section - collapsible container for thinking + tools */
.message-process {
  background: var(--color-bg-tertiary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  margin-bottom: 12px;
  overflow: hidden;
}

.message-process.hidden {
  display: none;
}

.message-process-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text-secondary);
  user-select: none;
  transition: background var(--transition-fast);
}

.message-process-header:hover {
  background: var(--color-bg-secondary);
}

.process-toggle {
  font-size: 10px;
  transition: transform 0.2s ease;
  display: inline-block;
}

.message-process.collapsed .process-toggle {
  transform: rotate(-90deg);
}

.process-label {
  flex: 1;
}

.process-count {
  font-size: 11px;
  color: var(--color-text-muted);
  font-weight: 400;
}

.message-process.collapsed .message-process-content {
  display: none;
}

.message-process-content {
  padding: 0 14px 14px;
}

/* Thinking text inside process section */
.message-thinking {
  font-size: 13px;
  color: var(--color-text-secondary);
  font-style: italic;
  line-height: 1.5;
  padding: 8px 0 8px 12px;
  border-left: 2px solid var(--color-border);
  margin-bottom: 8px;
}

.message-thinking:empty {
  display: none;
}

.message-thinking p {
  margin: 0 0 8px 0;
}

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

/* Streaming indicator on process section */
.message-process.streaming {
  border-color: var(--color-primary);
}

.message-process.streaming .message-process-header::after {
  content: '';
  width: 6px;
  height: 6px;
  background: var(--color-primary);
  border-radius: 50%;
  animation: pulse 1.5s ease-in-out infinite;
  margin-left: auto;
}

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

/* Tool Indicators */
.message-tools {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Remove margin when tools are inside process section */
.message-process .message-tools {
  margin-bottom: 0;
}

.tool-indicator {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--color-bg-tertiary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 12px;
}

.tool-indicator.running {
  background: var(--color-tool-running);
  border-color: var(--color-tool-running-border);
  color: var(--color-tool-running-text);
}

.tool-indicator.completed {
  background: var(--color-tool-completed);
  border-color: var(--color-tool-completed-border);
  color: var(--color-tool-completed-text);
}

.tool-indicator.error {
  background: var(--color-error-light);
  border-color: #fca5a5;
  color: #dc2626;
}

.provider-status-notice {
  font-size: 12px;
  color: var(--color-text-muted, #6b7280);
  padding: 4px 10px;
  margin-bottom: 6px;
  border-left: 2px solid var(--color-border, #e5e7eb);
  font-style: italic;
}

.tool-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(29, 78, 216, 0.2);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.7s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

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

/* Elegant Apple-style spinner */
.spinner-elegant {
  width: 20px;
  height: 20px;
  position: relative;
}

.spinner-elegant::before {
  content: '';
  position: absolute;
  inset: 0;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

.tool-name {
  font-weight: 500;
}

.tool-detail {
  font-family: var(--font-mono);
  font-size: 11px;
  opacity: 0.8;
}

.show-sql-btn {
  padding: 2px 8px;
  font-size: 11px;
  background: rgba(255, 255, 255, 0.3);
  border: 1px solid currentColor;
  border-radius: var(--radius-sm);
  color: inherit;
  cursor: pointer;
  opacity: 0.8;
  transition: all var(--transition-fast);
}

.show-sql-btn:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.5);
}

.tool-sql {
  width: 100%;
  margin-top: 8px;
}

.tool-sql pre {
  margin: 0;
  padding: 12px;
  background: var(--color-bg-tertiary);
  border-radius: var(--radius-sm);
  overflow-x: auto;
  max-height: 200px;
}

.tool-sql code {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--color-text-primary);
  white-space: pre-wrap;
  word-break: break-word;
}

/* Results Preview */
.message-results {
  margin-top: 12px;
}

.results-preview {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--color-bg);
}

.results-preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: var(--color-bg-tertiary);
  border-bottom: 1px solid var(--color-border);
}

.results-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  color: var(--color-text-secondary);
  transition: color var(--transition-fast);
}

.results-toggle:hover {
  color: var(--color-text-primary);
}

.results-toggle .toggle-icon {
  display: inline-block;
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid currentColor;
  transition: transform var(--transition-fast);
}

.results-preview.collapsed .toggle-icon {
  transform: rotate(-90deg);
}

.results-preview.collapsed .results-preview-body {
  display: none;
}

.results-preview.collapsed .results-preview-header {
  border-bottom: none;
}

.results-count {
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text-secondary);
}

.expand-results-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--color-primary);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.expand-results-btn:hover {
  background: var(--color-primary-light);
}

.results-preview-actions {
  display: flex;
  gap: 6px;
}

.preview-action-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 500;
  color: var(--color-text-secondary);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.preview-action-btn:hover {
  color: var(--color-primary);
  border-color: var(--color-primary);
  background: var(--color-primary-light);
}

.preview-action-btn.save-watchlist-btn {
  color: #2563eb;
  border-color: rgba(37, 99, 235, 0.3);
}

.preview-action-btn.save-watchlist-btn:hover {
  color: #1d4ed8;
  border-color: #2563eb;
  background: rgba(37, 99, 235, 0.08);
}

.results-preview-body {
  max-height: 200px;
  overflow: auto;
}

/* Simple HTML table for preview */
.preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.preview-table th,
.preview-table td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--color-border-light);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

.preview-table th {
  font-weight: 600;
  color: var(--color-text-secondary);
  background: var(--color-bg-secondary);
  position: sticky;
  top: 0;
  z-index: 1;
}

.preview-table tbody tr:hover {
  background: var(--color-bg-secondary);
}

.preview-table tbody tr:last-child td {
  border-bottom: none;
}

/* Keep AG Grid styles for full drawer */
.results-preview-body .ag-theme-alpine {
  --ag-row-height: 32px;
  --ag-header-height: 32px;
  --ag-font-size: 12px;
}

/* Chart Preview */
.chart-preview {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--color-bg);
  margin-top: 8px;
}

.chart-header {
  padding: 12px 16px;
  background: var(--color-bg-tertiary);
  border-bottom: 1px solid var(--color-border);
}

.chart-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-primary);
}

.chart-container {
  padding: 16px;
  height: 300px;
  position: relative;
}

.chart-container canvas {
  max-width: 100%;
  max-height: 100%;
}

/* Email Draft Preview Card */
.draft-preview {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--color-bg);
  margin-top: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
}

.draft-preview.sent {
  border-color: #22c55e30;
  box-shadow: 0 1px 3px rgba(34, 197, 94, 0.08);
}

.draft-preview.sent .draft-preview-header {
  background: #22c55e08;
}

.draft-preview.sent .draft-status-label {
  color: #22c55e;
}

.draft-preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--color-bg-tertiary);
  border-bottom: 1px solid var(--color-border);
}

.draft-preview-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 13px;
  color: var(--color-text);
}

.draft-preview-label svg {
  opacity: 0.5;
}

.draft-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.draft-edit-btn,
.draft-send-btn {
  font-size: 12px;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.draft-edit-btn:hover {
  color: var(--color-text);
  border-color: var(--color-text-secondary);
  background: var(--color-bg-hover);
}

/* Send button: subtle by default, prominent in edit mode */
.draft-send-btn {
  background: var(--color-bg);
  border-color: var(--color-border);
  color: var(--color-text-secondary);
}

.draft-send-btn:hover:not(:disabled) {
  color: #22c55e;
  border-color: #22c55e;
  background: #22c55e0a;
}

.draft-preview.editing .draft-send-btn {
  background: #22c55e;
  border-color: #22c55e;
  color: #fff;
}

.draft-preview.editing .draft-send-btn:hover:not(:disabled) {
  background: #16a34a;
  border-color: #16a34a;
}

.draft-send-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.draft-open-gmail {
  display: flex;
  align-items: center;
  color: var(--color-text-secondary);
  text-decoration: none;
  padding: 5px;
  border-radius: var(--radius-sm);
  opacity: 0.5;
  transition: all var(--transition-fast);
}

.draft-open-gmail:hover {
  color: var(--color-primary);
  opacity: 1;
}

.draft-preview-fields {
  padding: 16px 16px 10px;
}

.draft-field {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 0;
}

.draft-field-label {
  font-size: 12px;
  color: var(--color-text-secondary);
  min-width: 52px;
  flex-shrink: 0;
  opacity: 0.7;
}

.draft-input {
  flex: 1;
  font-size: 13px;
  color: var(--color-text);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-family: inherit;
  transition: all var(--transition-fast);
}

.draft-input:read-only {
  border-color: transparent;
  background: transparent;
}

.draft-preview.editing .draft-input {
  border-color: var(--color-border);
  background: var(--color-bg-tertiary);
}

.draft-preview.editing .draft-input:focus {
  border-color: var(--color-primary);
  outline: none;
}

.email-pill {
  display: inline-block;
  background: var(--color-bg-tertiary);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 2px 10px;
  font-size: 12px;
  font-family: var(--font-mono);
}

.draft-preview-divider {
  height: 1px;
  background: var(--color-border);
  margin: 8px 16px 0;
  opacity: 0.5;
}

.draft-body-editor {
  padding: 16px 16px 20px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--color-text);
  min-height: 60px;
  outline: none;
  word-wrap: break-word;
}

.draft-body-editor p,
.draft-body-editor div {
  margin: 0;
  padding: 0;
}

.draft-body-editor[contenteditable="true"] {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  margin: 8px 16px 4px;
  padding: 12px 14px;
  background: var(--color-bg-tertiary);
}

.draft-body-editor[contenteditable="true"]:focus {
  border-color: var(--color-primary);
}

/* Rich text toolbar */
.draft-toolbar {
  display: flex;
  gap: 4px;
  padding: 4px 16px 12px;
}

.draft-toolbar button {
  padding: 4px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-bg);
  color: var(--color-text-secondary);
  cursor: pointer;
  font-size: 12px;
  transition: all var(--transition-fast);
  line-height: 1.4;
}

.draft-toolbar button:hover {
  background: var(--color-bg-hover);
  color: var(--color-text);
  border-color: var(--color-text-secondary);
}

.draft-signature-preview {
  padding: 0 16px 14px;
  font-size: 12px;
  color: var(--color-text-secondary);
  opacity: 0.5;
}

.draft-signature-preview:empty {
  display: none;
}

/* Meeting Prep Briefing Card */
.meeting-prep-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--color-bg);
  margin-top: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
}

.prep-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--color-bg-tertiary);
  border-bottom: 1px solid var(--color-border);
}

.prep-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 14px;
  color: var(--color-text);
}

.prep-title svg { opacity: 0.5; }

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

.prep-section {
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
}

.prep-section:last-child { border-bottom: none; }

.prep-section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-secondary);
  opacity: 0.7;
  margin-bottom: 6px;
}

.prep-company-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 4px;
}

.prep-domain {
  font-weight: 400;
  color: var(--color-text-secondary);
  font-size: 13px;
}

.prep-description {
  font-size: 13px;
  color: var(--color-text-secondary);
  margin-bottom: 6px;
  line-height: 1.4;
}

.prep-meta {
  font-size: 12px;
  color: var(--color-text-secondary);
  margin-top: 4px;
}

.prep-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 10px;
  margin-top: 6px;
  margin-right: 6px;
}

.prep-portfolio {
  background: #3b82f610;
  color: #3b82f6;
  border: 1px solid #3b82f630;
}

.prep-deal {
  background: #8b5cf610;
  color: #8b5cf6;
  border: 1px solid #8b5cf630;
}

.prep-score {
  background: #06b6d410;
  color: #0891b2;
  border: 1px solid #06b6d430;
}

.prep-score:hover {
  background: #06b6d420;
}

.prep-attendee {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
}

.prep-linkedin {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 4px;
  background: #0a66c2;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  text-decoration: none;
  flex-shrink: 0;
}

.prep-linkedin:hover { opacity: 0.8; }

.prep-linkedin-placeholder {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.prep-attendee-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text);
}

.prep-attendee-title {
  font-size: 12px;
  color: var(--color-text-secondary);
}

.prep-relationship {
  font-size: 12px;
  color: var(--color-text-secondary);
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid var(--color-border);
  opacity: 0.8;
}

.prep-note {
  display: flex;
  gap: 8px;
  padding: 3px 0;
  font-size: 12px;
}

.prep-note-date {
  color: var(--color-text-secondary);
  flex-shrink: 0;
  min-width: 50px;
}

.prep-note-text {
  color: var(--color-text);
  line-height: 1.4;
}

.prep-doc-link {
  color: var(--color-primary);
  text-decoration: none;
}

.prep-doc-link:hover {
  text-decoration: underline;
}

.prep-doc {
  font-size: 12px;
  color: var(--color-text-secondary);
  padding: 2px 0;
}

/* Email Autocomplete Dropdown */
.email-autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 52px;
  right: 0;
  z-index: 100;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  max-height: 220px;
  overflow-y: auto;
  margin-top: 2px;
}

.email-autocomplete-item {
  padding: 8px 12px;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.email-autocomplete-item:hover,
.email-autocomplete-item.active {
  background: var(--color-bg-hover);
}

.email-autocomplete-item .ac-main {
  display: flex;
  align-items: center;
  gap: 8px;
}

.email-autocomplete-item .ac-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text);
}

.email-autocomplete-item .ac-email {
  font-size: 12px;
  color: var(--color-text-secondary);
  font-family: var(--font-mono);
}

.email-autocomplete-item .ac-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}

.email-autocomplete-item .ac-title {
  font-size: 11px;
  color: var(--color-text-secondary);
  opacity: 0.7;
}

.email-autocomplete-item .ac-source {
  font-size: 10px;
  color: var(--color-text-secondary);
  opacity: 0.5;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Legacy class kept for compatibility */
.draft-preview-body {
  padding: 16px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--color-text);
  white-space: pre-wrap;
}

/* Web Search Preview */
.web-search-preview {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--color-bg);
  margin-top: 8px;
}

.web-search-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--color-bg-tertiary);
  cursor: pointer;
  user-select: none;
  transition: background var(--transition-fast);
}

.web-search-header:hover {
  background: var(--color-bg-secondary);
}

.web-search-toggle {
  font-size: 10px;
  transition: transform 0.2s ease;
  display: inline-block;
}

.web-search-preview.collapsed .web-search-toggle {
  transform: rotate(-90deg);
}

.web-search-icon {
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
}

.web-search-title {
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text-secondary);
}

.web-search-count {
  font-size: 11px;
  color: var(--color-text-muted);
  font-weight: 400;
}

.web-search-body {
  padding: 12px 14px;
  border-top: 1px solid var(--color-border-light);
}

.web-search-preview.collapsed .web-search-body {
  display: none;
}

.web-search-sources {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.web-source-item {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 12px;
  line-height: 1.4;
}

.source-index {
  font-weight: 600;
  color: var(--color-primary);
  flex-shrink: 0;
}

.source-link {
  color: var(--color-text-primary);
  text-decoration: none;
  word-break: break-word;
  transition: color var(--transition-fast);
}

.source-link:hover {
  color: var(--color-primary);
  text-decoration: underline;
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  gap: 5px;
  padding: 14px 18px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 16px 16px 16px 4px;
  align-self: flex-start;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.typing-dot {
  width: 7px;
  height: 7px;
  background: var(--color-text-muted);
  border-radius: 50%;
  animation: typing-bounce 1.2s infinite cubic-bezier(0.4, 0, 0.2, 1);
}

.typing-dot:nth-child(1) { animation-delay: 0s; }
.typing-dot:nth-child(2) { animation-delay: 0.15s; }
.typing-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes typing-bounce {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-5px);
    opacity: 1;
  }
}

/* Streaming Indicator - shows during message generation */
.message-assistant.streaming::after {
  content: '';
  display: block;
  width: 100%;
  height: 2px;
  margin-top: 12px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    var(--color-primary) 50%,
    transparent 100%
  );
  background-size: 200% 100%;
  animation: streaming-progress 1.5s infinite ease-in-out;
  border-radius: 1px;
}

@keyframes streaming-progress {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Blinking cursor during streaming */
.message-assistant.streaming .message-content::after {
  content: '▍';
  animation: cursor-blink 0.7s steps(1) infinite;
  color: var(--text-secondary, #888);
  font-weight: 300;
}

@keyframes cursor-blink {
  50% { opacity: 0; }
}

/* Skeleton Loaders */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--color-bg-tertiary) 0%,
    var(--color-border) 50%,
    var(--color-bg-tertiary) 100%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite ease-in-out;
  border-radius: var(--radius-sm);
}

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-text {
  height: 14px;
  margin-bottom: 8px;
}

.skeleton-text.short {
  width: 60%;
}

.skeleton-text.medium {
  width: 80%;
}

.skeleton-text.long {
  width: 100%;
}

.skeleton-chart {
  height: 200px;
  margin-bottom: 12px;
}

.skeleton-table {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.skeleton-row {
  display: flex;
  gap: 12px;
}

.skeleton-cell {
  height: 24px;
  flex: 1;
}

/* ============================================
   Input Area
   ============================================ */
.input-container {
  padding: 16px 24px;
  background: var(--color-bg);
  border-top: 1px solid var(--color-border);
  border-bottom: none;
  position: relative;
  z-index: 4; /* Above empty-state (z-index: 3) so textarea isn't clipped */
  flex-shrink: 0;
}

.input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  padding: 12px 16px;
  background: #f3f4f6;
  border: 1px solid #d1d5db;
  border-radius: 12px;
  transition: border-color var(--transition-normal), box-shadow var(--transition-normal), background var(--transition-normal);
  min-height: 48px;
}

.input-wrapper:focus-within {
  border-color: rgba(196, 18, 48, 0.5);
  box-shadow: 0 0 0 3px rgba(196, 18, 48, 0.1), 0 0 12px rgba(196, 18, 48, 0.15);
  background: #ffffff;
}

/* Auto-grow textarea using CSS Grid trick:
   Mirror div + textarea share the same grid cell.
   The mirror auto-sizes to content, the cell follows,
   and the textarea stretches to fill. No JS measurement. */
.grow-wrap {
  display: grid;
  flex: 1;
  min-width: 0;
}

.grow-mirror,
.grow-wrap > textarea {
  grid-area: 1 / 1 / 2 / 2;
  font-size: 14px;
  font-family: inherit;
  line-height: 1.5;
  padding: 4px 0;
  box-sizing: border-box;
  border: none;
  min-height: 24px;
  max-height: 300px;
}

.grow-mirror {
  visibility: hidden;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow: hidden;
  pointer-events: none;
}

.grow-wrap > textarea {
  background: transparent;
  resize: none;
  color: var(--color-text-primary);
  overflow-y: auto;
}

.grow-wrap > textarea:focus {
  outline: none;
}

.grow-wrap > textarea::placeholder {
  color: var(--color-text-muted);
}

.input-actions {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.char-count {
  font-size: 11px;
  color: var(--color-text-muted);
  white-space: nowrap;
  transition: color var(--transition-normal), opacity 0.2s ease;
  font-variant-numeric: tabular-nums;
  opacity: 0;
}

.char-count.visible {
  opacity: 1;
}

/* Character counter color states */
.char-count.warning {
  color: #F59E0B;
}

.char-count.danger {
  color: #EF4444;
  font-weight: 500;
}

/* Attach button */
.btn-attach {
  padding: 6px 8px;
  background: transparent;
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.btn-attach:hover {
  color: var(--color-primary);
  border-color: var(--color-primary);
  background: rgba(196, 18, 48, 0.05);
}

/* Drag-over highlight on input wrapper */
.input-wrapper.drag-over {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(196, 18, 48, 0.1);
  background: #ffffff;
}

/* Attachment preview area above input */
.attachment-preview {
  display: none;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 16px 0;
}

.attachment-preview.visible {
  display: flex;
}

.attachment-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px 4px 10px;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 12px;
  color: var(--color-text-secondary);
  max-width: 240px;
}

.attachment-chip-icon {
  flex-shrink: 0;
}

.attachment-chip-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 140px;
}

.attachment-chip-size {
  color: var(--color-text-muted);
  font-size: 11px;
  flex-shrink: 0;
}

.attachment-chip-remove {
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0 2px;
  flex-shrink: 0;
}

.attachment-chip-remove:hover {
  color: #ef4444;
}

.attachment-chip-thumb {
  width: 36px;
  height: 36px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}

.attachment-chip-image {
  padding: 3px 8px 3px 3px;
}

/* Attachment badges in user messages */
.message-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 6px;
}

.message-attachment-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  font-size: 11px;
  white-space: nowrap;
}

.btn-send {
  padding: 8px 12px;
}

.btn-boost {
  padding: 6px 8px;
  background: transparent;
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.btn-boost:hover {
  color: var(--color-primary);
  border-color: var(--color-primary);
  background: rgba(196, 18, 48, 0.05);
}

.btn-boost:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-boost.loading svg {
  animation: boost-spin 0.8s linear infinite;
}

.btn-boost.boosted {
  color: var(--color-primary);
  border-color: var(--color-primary);
  animation: boost-flash 0.4s ease;
}

@keyframes boost-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes boost-flash {
  0% { background: rgba(196, 18, 48, 0.15); }
  100% { background: transparent; }
}

.btn-stop {
  padding: 8px 12px;
  background: #dc2626;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s;
}

.btn-stop:hover {
  background: #b91c1c;
}

.input-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  gap: 12px;
}

.input-footer-left,
.input-footer-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.input-footer .mode-toggle {
  padding: 2px;
}

.input-footer .mode-btn {
  padding: 4px 12px;
  font-size: 12px;
}

/* Deep Research Toggle */
/* List Context Badge */
.list-context-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 8px;
  font-size: 12px;
  font-weight: 500;
  color: #2563eb;
  background: rgba(37, 99, 235, 0.08);
  border: 1px solid rgba(37, 99, 235, 0.25);
  border-radius: 16px;
  white-space: nowrap;
  animation: badgeFadeIn 0.2s ease-out;
}

@keyframes badgeFadeIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.list-context-badge svg {
  flex-shrink: 0;
  stroke: #2563eb;
}

.list-context-name {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-context-count {
  color: rgba(37, 99, 235, 0.6);
  font-weight: 400;
}

.list-context-dismiss {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  padding: 0;
  margin-left: 2px;
  background: none;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  color: #2563eb;
  opacity: 0.5;
  transition: opacity var(--transition-fast), background var(--transition-fast);
}

.list-context-dismiss:hover {
  opacity: 1;
  background: rgba(37, 99, 235, 0.15);
}

.list-context-badge.hidden {
  display: none;
}

.deep-research-toggle {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text-muted);
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.deep-research-toggle:hover {
  color: var(--color-text-secondary);
  border-color: var(--color-text-muted);
  background: var(--color-bg-secondary);
}

.deep-research-toggle.active {
  color: #7c3aed;
  border-color: #7c3aed;
  background: rgba(124, 58, 237, 0.08);
}

.deep-research-toggle.active:hover {
  background: rgba(124, 58, 237, 0.14);
}

.deep-research-toggle.active .deep-research-icon {
  stroke: #7c3aed;
}

.model-selector {
  display: flex;
  align-items: center;
  gap: 6px;
  position: relative;
}

/* Segmented Control */
.model-segmented {
  display: flex;
  background: var(--color-bg-tertiary);
  border-radius: var(--radius-md);
  padding: 2px;
  gap: 2px;
}

.model-segment {
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text-secondary);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.model-segment:hover:not(.active) {
  color: var(--color-text-primary);
  background: rgba(0, 0, 0, 0.04);
}

.model-segment.active {
  color: white;
  background: var(--color-primary);
  box-shadow: 0 1px 3px rgba(196, 18, 48, 0.3);
}

/* More Models Button */
.model-more-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg-tertiary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

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

/* Model Dropdown */
.model-dropdown {
  position: absolute;
  bottom: 100%;
  right: 0;
  margin-bottom: 8px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  min-width: 180px;
  z-index: 100;
  animation: dropdown-appear 0.15s ease;
}

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

.model-dropdown.hidden {
  display: none;
}

.model-dropdown-section {
  padding: 8px 0;
  border-bottom: 1px solid var(--color-border-light);
}

.model-dropdown-section:last-child {
  border-bottom: none;
}

.model-dropdown-header {
  padding: 4px 12px 6px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-muted);
}

.model-dropdown-item {
  display: block;
  width: 100%;
  padding: 8px 12px;
  font-size: 13px;
  text-align: left;
  color: var(--color-text-primary);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.model-dropdown-item:hover {
  background: var(--color-bg-secondary);
}

.model-dropdown-item.active {
  color: var(--color-primary);
  background: var(--color-primary-light);
}

.model-dropdown-item.active::before {
  content: '✓ ';
  font-weight: 600;
}

/* Legacy select (hidden but kept for compatibility) */
.model-select {
  padding: 4px 8px;
  font-size: 12px;
  font-family: var(--font-sans);
  color: var(--color-text-secondary);
  background: var(--color-bg-tertiary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.model-select:hover {
  border-color: var(--color-text-muted);
}

.model-select:focus {
  outline: none;
  border-color: var(--color-primary);
}

.input-hints {
  font-size: 11px;
  color: var(--color-text-muted);
  text-align: right;
}

.input-hints kbd {
  margin: 0 2px;
}

/* ============================================
   Results Drawer
   ============================================ */
.results-drawer {
  position: fixed;
  top: var(--header-height);
  right: 0;
  bottom: 0;
  width: var(--drawer-width);
  background: var(--color-bg);
  box-shadow: var(--shadow-lg);
  transform: translateX(100%);
  transition: transform var(--transition-slow);
  z-index: 100;
  display: flex;
  flex-direction: column;
}

.results-drawer.visible {
  transform: translateX(0);
}

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

.drawer-header h2 {
  font-size: 16px;
  font-weight: 600;
}

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

.drawer-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.results-stats {
  padding: 12px 20px;
  font-size: 13px;
  color: var(--color-text-secondary);
  border-bottom: 1px solid var(--color-border-light);
}

.results-stats .stat {
  display: inline;
}

.results-stats strong {
  color: var(--color-primary);
}

.stat-sep {
  margin: 0 8px;
  color: var(--color-border);
}

#results-grid {
  flex: 1;
}

#results-grid.ag-theme-alpine {
  --ag-row-height: 36px;
  --ag-header-height: 40px;
  --ag-font-size: 13px;
}

/* ============================================
   Modals (chat-specific overrides — base in shared.css)
   ============================================ */
.modal-backdrop {
  animation: fade-in 0.2s ease;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content {
  padding: 28px;
  max-width: 440px;
  width: 90%;
}

.modal-description {
  font-size: 14px;
  color: var(--color-text-secondary);
  margin-bottom: 16px;
}

.filter-input {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  color: var(--color-text-primary);
  transition: all var(--transition-fast);
}

.filter-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}

.modal-actions {
  gap: 12px;
  margin-top: 24px;
}

.modal-actions .btn-secondary,
.modal-actions .btn-primary {
  padding: 10px 20px;
  font-size: 14px;
}

/* Export Options */
.export-options {
  display: flex;
  gap: 12px;
}

.export-option {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  color: var(--color-text-secondary);
  transition: all var(--transition-fast);
}

.export-option:hover {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.export-option span {
  font-size: 13px;
  font-weight: 500;
}

/* Shortcuts Modal */
.shortcuts-content {
  max-width: 480px;
}

.shortcuts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.shortcut {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--color-text-secondary);
}

.shortcut kbd {
  min-width: 50px;
  text-align: center;
  margin-left: 0;
}

/* Custom Instructions Modal */
.custom-instructions-content {
  max-width: 520px;
}

.custom-instructions-textarea {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  line-height: 1.5;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  color: var(--color-text-primary);
  resize: vertical;
  transition: border-color var(--transition-fast);
}

.custom-instructions-textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}

.custom-instructions-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 6px;
}

.custom-instructions-counter {
  font-size: 12px;
  color: var(--color-text-tertiary);
}

#custom-instructions-btn.has-instructions {
  position: relative;
}

#custom-instructions-btn.has-instructions::after {
  content: '';
  position: absolute;
  top: 4px;
  right: 4px;
  width: 6px;
  height: 6px;
  background: var(--color-primary);
  border-radius: 50%;
}

/* ============================================
   Toast Notifications
   ============================================ */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 300;
  max-width: 350px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  animation: toast-in 0.3s ease;
}

.toast.removing {
  animation: toast-out 0.3s ease forwards;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes toast-out {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(100%);
  }
}

.toast-success {
  border-left: 3px solid var(--color-success);
}

.toast-error {
  border-left: 3px solid var(--color-error);
}

.toast-info {
  border-left: 3px solid var(--color-primary);
}

.toast-icon {
  font-size: 16px;
}

.toast-success .toast-icon { color: var(--color-success); }
.toast-error .toast-icon { color: var(--color-error); }
.toast-info .toast-icon { color: var(--color-primary); }

.toast-message {
  flex: 1;
  font-size: 13px;
  color: var(--color-text-primary);
}

/* ============================================
   Loading Overlay
   ============================================ */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 400;
  animation: fade-in var(--transition-normal);
}

.loading-overlay.hidden {
  display: none;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

#loading-text {
  font-size: 14px;
  color: var(--color-text-secondary);
  animation: pulse-text 2s ease-in-out infinite;
}

@keyframes pulse-text {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

/* ============================================
   Markdown Content Styling
   ============================================ */
.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4 {
  margin: 20px 0 10px 0;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--color-text-primary);
}

.message-content h1 { font-size: 18px; }
.message-content h2 {
  font-size: 16px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--color-border-light);
}
.message-content h3 { font-size: 14px; }
.message-content h4 { font-size: 13px; }

.message-content ul,
.message-content ol {
  margin: 10px 0;
  padding-left: 20px;
}

.message-content li {
  margin: 6px 0;
  line-height: 1.6;
}

.message-content blockquote {
  margin: 12px 0;
  padding: 12px 16px;
  border-left: 3px solid var(--color-primary);
  background: var(--color-bg-secondary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-style: italic;
  color: var(--color-text-primary);
}

.message-content blockquote em {
  font-style: normal;
  color: var(--color-text-secondary);
  font-size: 12px;
}

.message-content a {
  color: var(--color-primary);
  text-decoration: underline;
  text-decoration-color: rgba(196, 18, 48, 0.3);
  text-underline-offset: 2px;
  transition: all var(--transition-fast);
}

.message-content a:hover {
  text-decoration-color: var(--color-primary);
  color: var(--color-primary-hover);
}

.message-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 13px;
}

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

.message-content th {
  background: var(--color-bg-tertiary);
  font-weight: 600;
}

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

/* Collapsible Markdown Tables */
.table-wrapper {
  margin: 12px 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.table-wrapper.collapsible .table-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  background: var(--color-bg-tertiary);
  border: none;
  border-bottom: 1px solid var(--color-border);
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text-secondary);
  cursor: pointer;
  text-align: left;
  transition: all var(--transition-fast);
}

.table-wrapper.collapsible .table-toggle:hover {
  background: var(--color-bg-secondary);
  color: var(--color-text-primary);
}

.table-toggle .toggle-icon {
  display: inline-block;
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid currentColor;
  transition: transform var(--transition-fast);
}

.table-wrapper.collapsed .toggle-icon {
  transform: rotate(-90deg);
}

.table-wrapper.collapsed .table-content {
  display: none;
}

.table-content {
  max-height: 300px;
  overflow: auto;
}

.md-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.md-table th,
.md-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--color-border-light);
}

.md-table th {
  white-space: nowrap;
  font-weight: 600;
  color: var(--color-text-secondary);
  background: var(--color-bg-secondary);
  position: sticky;
  top: 0;
  z-index: 1;
}

.md-table tbody tr:hover {
  background: var(--color-bg-secondary);
}

.md-table tbody tr:last-child td {
  border-bottom: none;
}

/* ============================================
   Responsive Adjustments
   ============================================ */
@media (max-width: 1200px) {
  .conversation-sidebar {
    width: 240px;
  }

  .results-drawer {
    width: 60%;
  }
}

@media (max-width: 900px) {
  .conversation-sidebar {
    width: 220px;
  }

  .results-drawer {
    width: 80%;
  }

  .header-center {
    display: none;
  }
}

/* ============================================
   Model Insight Highlighting
   ============================================ */
.model-insight {
  border-bottom: 2px solid rgba(99, 102, 241, 0.45);
  padding-bottom: 1px;
  transition: background var(--transition-fast);
}

.model-insight:hover {
  background: rgba(99, 102, 241, 0.08);
}

/* Legend appended after messages containing insights */
.insight-legend {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--color-text-muted);
  margin-top: 8px;
}

.insight-legend-line {
  display: inline-block;
  width: 18px;
  border-bottom: 2px solid rgba(99, 102, 241, 0.45);
}

/* ============================================
   Utility Classes
   ============================================ */
/* ============================================
   Skeleton Loading Indicator (replaces typing dots)
   ============================================ */
.skeleton-loading {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 20px 24px;
  background: var(--color-bg);
  border-left: 2px solid var(--color-border);
  border-radius: 0 12px 12px 0;
  align-self: flex-start;
  max-width: 65%;
  animation: message-appear 0.2s ease;
}

.skeleton-loading .skeleton-line {
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(
    90deg,
    var(--color-bg-tertiary) 25%,
    var(--color-border) 50%,
    var(--color-bg-tertiary) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite ease-in-out;
}

.skeleton-loading .skeleton-line:nth-child(1) { width: 85%; animation-delay: 0s; }
.skeleton-loading .skeleton-line:nth-child(2) { width: 70%; animation-delay: 0.1s; }
.skeleton-loading .skeleton-line:nth-child(3) { width: 55%; animation-delay: 0.2s; }

/* ============================================
   Conversation Search
   ============================================ */
.conversation-search {
  padding: 8px 12px;
}

.conversation-search-input {
  width: 100%;
  padding: 7px 10px 7px 30px;
  font-size: 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  color: var(--color-text-primary);
  outline: none;
  transition: all var(--transition-fast);
  box-sizing: border-box;
}

.conversation-search-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(196, 18, 48, 0.08);
}

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

.conversation-search-wrapper {
  position: relative;
}

.conversation-search-icon {
  position: absolute;
  left: 9px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-muted);
  pointer-events: none;
}

.conversation-search-clear {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 2px;
  display: none;
  font-size: 14px;
  line-height: 1;
}

.conversation-search-clear.visible {
  display: block;
}

.conversation-search-clear:hover {
  color: var(--color-text-primary);
}

.no-search-results {
  padding: 16px 12px;
  text-align: center;
  font-size: 12px;
  color: var(--color-text-muted);
}

/* ============================================
   Enhanced Empty State
   ============================================ */
.empty-state-greeting {
  font-size: 22px;
  font-weight: 700;
  color: var(--color-text-primary);
  margin-bottom: 4px;
}

.empty-state-categories {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  justify-content: center;
}

.category-chip {
  padding: 5px 12px;
  font-size: 11px;
  font-weight: 500;
  color: var(--color-text-secondary);
  background: var(--color-bg-tertiary);
  border: 1px solid var(--color-border);
  border-radius: 16px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.category-chip:hover,
.category-chip.active {
  color: var(--color-primary);
  border-color: var(--color-primary);
  background: var(--color-primary-light);
}

/* ============================================
   Inline Citations
   ============================================ */
.citation-ref {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  background: var(--color-primary-light);
  color: var(--color-primary);
  border-radius: 3px;
  cursor: pointer;
  vertical-align: super;
  line-height: 1;
  transition: all var(--transition-fast);
  text-decoration: none;
  margin: 0 1px;
}

.citation-ref:hover {
  background: var(--color-primary);
  color: white;
}

/* Source attribution bar */
.source-attribution {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--color-border-light);
}

.source-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  font-size: 10px;
  font-weight: 500;
  border-radius: 4px;
  border: 1px solid;
}

.source-badge.snowflake {
  color: #1d4ed8;
  background: #eff6ff;
  border-color: #bfdbfe;
}

.source-badge.web {
  color: #059669;
  background: #ecfdf5;
  border-color: #a7f3d0;
}

.source-badge.docs {
  color: #7c3aed;
  background: #f5f3ff;
  border-color: #c4b5fd;
}

.source-badge.gmail {
  color: #dc2626;
  background: #fef2f2;
  border-color: #fecaca;
}

.source-badge.transcripts {
  color: #d97706;
  background: #fffbeb;
  border-color: #fcd34d;
}

.source-badge-icon {
  font-size: 11px;
}

/* ============================================
   Enhanced Tool Steps
   ============================================ */
.tool-indicator .tool-step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  font-size: 10px;
  font-weight: 700;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.4);
  flex-shrink: 0;
}

.tool-indicator.running .tool-step-number {
  background: rgba(29, 78, 216, 0.15);
  color: #1d4ed8;
}

.tool-indicator.completed .tool-step-number {
  background: rgba(22, 101, 52, 0.15);
  color: #166534;
}

.tool-indicator .tool-duration {
  font-size: 10px;
  opacity: 0.7;
  font-family: var(--font-mono);
  margin-left: auto;
}

/* ============================================
   Progressive Disclosure (collapsible sections)
   ============================================ */
.response-section {
  margin-bottom: 8px;
}

.response-section-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 0;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-primary);
  user-select: none;
}

.response-section-header:hover {
  color: var(--color-primary);
}

.response-section-toggle {
  font-size: 10px;
  transition: transform 0.2s ease;
  display: inline-block;
  color: var(--color-text-muted);
}

.response-section.collapsed .response-section-toggle {
  transform: rotate(-90deg);
}

.response-section.collapsed .response-section-content {
  display: none;
}

.response-section-content {
  padding-left: 4px;
}

/* ============================================
   Enhanced Follow-Up Chips
   ============================================ */
.follow-up-chips {
  border-top: 1px solid var(--color-border-light);
}

.follow-up-chip {
  position: relative;
  padding-left: 26px;
}

.follow-up-chip::before {
  content: '→';
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  color: var(--color-text-muted);
  transition: color var(--transition-fast);
}

.follow-up-chip:hover::before {
  color: var(--color-primary);
}

/* ============================================
   Conversation Pinning
   ============================================ */
.conversation-item.pinned {
  border-left: 2px solid var(--color-primary);
}

.conversation-item .pin-indicator {
  font-size: 10px;
  color: var(--color-primary);
  margin-right: 4px;
  flex-shrink: 0;
}

.conversation-actions button.pin-btn:hover {
  color: var(--color-primary);
  background: var(--color-primary-light);
}

.conversation-item.pinned .conversation-actions button.pin-btn {
  color: var(--color-primary);
}

.pinned-divider {
  font-size: 10px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 8px 12px 4px;
}

/* ============================================
   Saved Prompt Templates
   ============================================ */
.saved-prompts-section {
  border-top: 1px solid var(--color-border-light);
  padding-top: 4px;
}

.saved-prompt-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 12px;
  color: var(--color-text-secondary);
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

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

.saved-prompt-item .prompt-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.saved-prompt-item .prompt-category {
  font-size: 10px;
  color: var(--color-text-muted);
  background: var(--color-bg-tertiary);
  padding: 1px 6px;
  border-radius: 8px;
  flex-shrink: 0;
}

.saved-prompt-item .delete-saved-prompt {
  display: none;
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 2px;
  font-size: 12px;
  line-height: 1;
  flex-shrink: 0;
}

.saved-prompt-item:hover .delete-saved-prompt {
  display: block;
}

.saved-prompt-item .delete-saved-prompt:hover {
  color: var(--color-error);
}

.save-prompt-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 6px 12px;
  font-size: 12px;
  color: var(--color-text-muted);
  background: none;
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  margin-top: 4px;
}

.save-prompt-btn:hover {
  color: var(--color-primary);
  border-color: var(--color-primary);
  background: var(--color-primary-light);
}

/* Save Prompt Modal */
.save-prompt-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.save-prompt-form input,
.save-prompt-form textarea,
.save-prompt-form select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  color: var(--color-text-primary);
  font-family: inherit;
  font-size: 13px;
  box-sizing: border-box;
}

.save-prompt-form textarea {
  resize: vertical;
  min-height: 80px;
}

.save-prompt-form input:focus,
.save-prompt-form textarea:focus,
.save-prompt-form select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(196, 18, 48, 0.08);
}

.save-prompt-form label {
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text-secondary);
  margin-bottom: -8px;
}

/* ============================================
   Source Panel (Right Drawer)
   ============================================ */
.source-panel {
  position: fixed;
  top: var(--header-height);
  right: 0;
  bottom: 0;
  width: 320px;
  background: var(--color-bg);
  border-left: 1px solid var(--color-border);
  box-shadow: -4px 0 12px rgba(0, 0, 0, 0.05);
  z-index: 50;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s ease;
}

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

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

.source-panel-header h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-primary);
}

.source-panel-close {
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

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

.source-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
}

.source-panel-empty {
  text-align: center;
  padding: 24px 16px;
  color: var(--color-text-muted);
  font-size: 13px;
}

.source-panel-group {
  margin-bottom: 16px;
}

.source-panel-group-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--color-border-light);
}

.source-panel-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 0;
  font-size: 12px;
  line-height: 1.4;
  border-bottom: 1px solid var(--color-border-light);
}

.source-panel-item:last-child {
  border-bottom: none;
}

.source-panel-item .source-num {
  font-weight: 700;
  color: var(--color-primary);
  flex-shrink: 0;
  min-width: 20px;
}

.source-panel-item a {
  color: var(--color-text-primary);
  text-decoration: none;
  word-break: break-word;
}

.source-panel-item a:hover {
  color: var(--color-primary);
  text-decoration: underline;
}

.source-panel-item .source-domain {
  display: block;
  font-size: 10px;
  color: var(--color-text-muted);
  margin-top: 2px;
}

/* Source panel toggle button in message actions */
.sources-toggle-btn {
  display: flex;
  align-items: center;
  gap: 4px;
}

.sources-count {
  font-size: 10px;
  font-weight: 700;
  background: var(--color-primary-light);
  color: var(--color-primary);
  padding: 0 5px;
  border-radius: 8px;
  min-width: 16px;
  text-align: center;
}

.hidden {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* ============================================
   Custom Scrollbars
   ============================================ */

/* Firefox */
.conversation-sidebar,
.conversation-list,
.messages-container {
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
}

/* WebKit (Chrome, Safari, Edge) */
.conversation-sidebar::-webkit-scrollbar,
.conversation-list::-webkit-scrollbar,
.messages-container::-webkit-scrollbar {
  width: 6px;
}

.conversation-sidebar::-webkit-scrollbar-track,
.conversation-list::-webkit-scrollbar-track,
.messages-container::-webkit-scrollbar-track {
  background: transparent;
}

.conversation-sidebar::-webkit-scrollbar-thumb,
.conversation-list::-webkit-scrollbar-thumb,
.messages-container::-webkit-scrollbar-thumb {
  background-color: var(--color-border);
  border-radius: 3px;
}

.conversation-sidebar::-webkit-scrollbar-thumb:hover,
.conversation-list::-webkit-scrollbar-thumb:hover,
.messages-container::-webkit-scrollbar-thumb:hover {
  background-color: var(--color-text-muted);
}

/* ===== Embed mode (iframe in Ask Atlas side panel) ===== */
.chat-embed-mode .unified-header,
.chat-embed-mode .conversation-sidebar,
.chat-embed-mode .empty-state-container,
.chat-embed-mode #toggle-chat-sidebar,
.chat-embed-mode .chat-header,
.chat-embed-mode .gmail-status-wrapper,
.chat-embed-mode #drive-status-wrapper,
.chat-embed-mode .mode-buttons,
.chat-embed-mode .model-selector,
.chat-embed-mode .suggested-prompts,
.chat-embed-mode #suggested-section,
.chat-embed-mode .chat-empty-state,
.chat-embed-mode .chat-greeting,
.chat-embed-mode .input-footer,
.chat-embed-mode .mobile-hamburger,
.chat-embed-mode .mobile-header {
  display: none !important;
}

/* Show input-footer only in fullscreen (parent adds .fullscreen to panel, but
   iframe can't see parent classes — use viewport width as proxy) */
@media (min-width: 1000px) {
  .chat-embed-mode .input-footer {
    display: flex !important;
  }
}

.chat-embed-mode .chat-layout {
  padding-top: 0 !important;
  gap: 0 !important;
}

.chat-embed-mode .chat-main {
  max-width: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
  display: flex !important;
  flex-direction: column !important;
}

.chat-embed-mode .messages-container:empty {
  flex: 0 !important;
  padding: 0 !important;
}

.chat-embed-mode .input-area {
  padding: 8px !important;
  max-height: none !important;
  background: #fff !important;
}

.chat-embed-mode .messages-container {
  padding: 8px !important;
  scroll-behavior: auto;
  background: #fff !important;
}

/* Embed mode on mobile — compact input, full height scroll */
@media (max-width: 767px) {
  .chat-embed-mode .chat-app {
    height: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
  }

  .chat-embed-mode .chat-body,
  .chat-embed-mode .chat-main {
    flex: 1 !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
  }

  .chat-embed-mode .messages-container {
    flex: 1 !important;
    min-height: 0 !important;
    overflow-y: scroll !important;
    -webkit-overflow-scrolling: touch !important;
    padding-bottom: 12px !important;
  }

  .chat-embed-mode .input-wrapper {
    border-radius: 20px;
    min-height: 36px;
    padding: 6px 12px;
  }

  .chat-embed-mode .input-container {
    padding: 6px 8px !important;
    flex-shrink: 0;
  }

  /* Hide bottom nav inside iframe */
  .chat-embed-mode .mobile-bottom-nav {
    display: none !important;
  }

  /* Full width messages */
  .chat-embed-mode .message {
    max-width: 100% !important;
  }

  /* Tables scroll horizontally */
  .chat-embed-mode .message-content table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    font-size: 11px;
  }
}

.chat-embed-mode .input-wrapper {
  flex-wrap: wrap !important;
  gap: 8px !important;
}

.chat-embed-mode .grow-wrap {
  width: 100% !important;
  flex: none !important;
  max-height: 120px !important;
  overflow-y: auto !important;
}

/* On narrow embed (Ask Atlas side panel), textarea + actions on one row */
@media (max-width: 767px) {
  .chat-embed-mode .input-wrapper {
    flex-wrap: nowrap !important;
  }
  .chat-embed-mode .grow-wrap {
    width: auto !important;
    flex: 1 1 0% !important;
    min-width: 60% !important;
  }
  .chat-embed-mode .input-actions {
    width: auto !important;
    flex-shrink: 1 !important;
  }
  .chat-embed-mode .char-count {
    display: none !important;
  }
}

.chat-embed-mode .chat-input,
.chat-embed-mode .grow-wrap > textarea {
  min-height: 36px !important;
  font-size: 13px !important;
}

.chat-embed-mode .input-actions {
  width: 100% !important;
  display: flex !important;
  justify-content: flex-end !important;
  gap: 8px !important;
}


.chat-embed-mode .message {
  max-width: 100% !important;
}

.chat-embed-mode .message-content-text,
.chat-embed-mode .message-thinking {
  max-width: 100% !important;
}

/* === Mobile Chat Layout === */
@media (max-width: 767px) {
  /* Conversation sidebar — 85% slide-over, tap overlay to close */
  body.atlas-mobile .conversation-sidebar {
    position: fixed !important;
    top: 0;
    left: -85%;
    width: 85%;
    height: 100%;
    z-index: 300;
    background: #fff;
    transition: left 250ms ease;
    box-shadow: 2px 0 8px rgba(0,0,0,0.1);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 80px;
  }

  body.atlas-mobile .conversation-sidebar.mobile-open {
    left: 0;
  }

  /* Conversation items — full width titles */
  body.atlas-mobile .conversation-item {
    padding: 14px 16px;
    border-left: none !important;
    border-radius: 0;
    border-bottom: 1px solid #f3f4f6;
  }

  /* Hide edit/delete/pin action buttons — save space for title */
  body.atlas-mobile .conversation-actions {
    display: none !important;
  }

  body.atlas-mobile .conversation-info {
    width: 100%;
  }

  body.atlas-mobile .conversation-title {
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    font-size: 15px;
    font-weight: 600;
    max-width: 100%;
  }

  body.atlas-mobile .conversation-meta {
    font-size: 12px;
    margin-top: 4px;
    color: #9ca3af;
  }

  /* Hide non-essential sidebar sections on mobile — just show conversations */
  body.atlas-mobile .conversation-sidebar #suggested-section,
  body.atlas-mobile .conversation-sidebar .saved-prompts-section,
  body.atlas-mobile .conversation-sidebar #transcript-filters-section,
  body.atlas-mobile .conversation-sidebar .conversation-search,
  body.atlas-mobile .conversation-sidebar .conversations-section .section-header {
    display: none !important;
  }

  /* Mobile sidebar header with title + close button */
  body.atlas-mobile .mobile-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 16px 12px;
    border-bottom: 1px solid #e5e7eb;
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 1;
  }
  body.atlas-mobile .mobile-sidebar-header h3 {
    font-size: 17px;
    font-weight: 700;
    margin: 0;
    color: #111827;
  }
  body.atlas-mobile .mobile-sidebar-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    color: #6b7280;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  body.atlas-mobile .mobile-sidebar-close:active {
    background: #f3f4f6;
  }

  /* Swipe-to-delete backdrop */
  body.atlas-mobile .swipe-delete-backdrop {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 80px;
    background: #ef4444;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0;
    z-index: -1;
    opacity: 0;
    transform: translateX(100%);
    pointer-events: none;
  }

  /* Conversation items need clipping for swipe */
  body.atlas-mobile .conversation-item {
    position: relative;
    overflow: visible;
    background: #fff;
    z-index: 1;
  }

  /* Clear All button at bottom of sidebar */
  body.atlas-mobile .mobile-sidebar-clear-all {
    display: block;
    width: calc(100% - 32px);
    margin: 16px auto 24px;
    padding: 12px;
    font-size: 13px;
    font-weight: 600;
    color: #ef4444;
    background: none;
    border: 1.5px solid #fecaca;
    border-radius: 10px;
    cursor: pointer;
    text-align: center;
  }
  body.atlas-mobile .mobile-sidebar-clear-all:active {
    background: #fef2f2;
  }

  /* Overlay behind sidebar */
  body.atlas-mobile .mobile-sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.3);
    z-index: 299;
  }

  body.atlas-mobile .mobile-sidebar-overlay.mobile-open {
    display: block;
  }

  /* Ensure sidebar covers bottom nav and input */
  body.atlas-mobile .conversation-sidebar.mobile-open ~ .mobile-bottom-nav,
  body.atlas-mobile .mobile-sidebar-overlay.mobile-open ~ .mobile-bottom-nav {
    z-index: 100;
  }

  /* Hamburger button */
  body.atlas-mobile .mobile-hamburger {
    background: none;
    border: none;
    padding: 4px;
    margin-right: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    color: #374151;
  }

  body.atlas-mobile .mobile-chat-minimize {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 4px 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    color: #6b7280;
    z-index: 5;
    -webkit-tap-highlight-color: transparent;
  }
  body.atlas-mobile .mobile-chat-minimize:active {
    background: #f3f4f6;
  }

  /* Minimized conversation pill — expand/collapse like search + ask atlas pills */
  .chat-minimized-pill {
    position: fixed;
    bottom: calc(var(--mobile-nav-height, 84px) + 72px + 16px + env(safe-area-inset-bottom, 0px));
    right: 16px;
    z-index: 99;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background: #111827;
    color: #fff;
    border: none;
    border-radius: 24px;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0,0,0,0.15);
    -webkit-tap-highlight-color: transparent;
    transition: all 0.2s ease, bottom 0.25s ease;
    font-family: 'DM Sans', -apple-system, sans-serif;
    font-size: 13px;
    font-weight: 600;
    max-width: 220px;
    will-change: transform;
    -webkit-transform: translateZ(0);
  }
  .chat-minimized-pill:active { transform: scale(0.92); }
  /* Collapsed state — circle icon only */
  .chat-minimized-pill.collapsed {
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 50%;
    justify-content: center;
  }
  .chat-minimized-pill.collapsed .chat-minimized-label { display: none; }
  /* Green activity dot — top-right corner */
  .chat-minimized-dot {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #22c55e;
    border: 2px solid #111827;
  }
  .chat-minimized-icon { width: 18px; height: 18px; flex-shrink: 0; }
  .chat-minimized-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Chat body — single column, no sidebar */
  body.atlas-mobile .chat-body {
    display: flex;
    flex-direction: column;
  }

  /* Chat main area — full width */
  body.atlas-mobile .chat-main {
    width: 100% !important;
    max-width: 100% !important;
  }

  /* Chat header — hide desktop toolbar items on mobile */
  body.atlas-mobile .chat-header {
    min-height: 48px;
    padding: 10px 16px;
    position: relative;
    /* GPU layer — prevents iOS flicker during scroll */
    will-change: transform;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
  }

  /* Hide desktop header-right and header-center on mobile */
  body.atlas-mobile .chat-header .header-right,
  body.atlas-mobile .chat-header .header-center {
    display: none !important;
  }

  /* Also target individually in case structure differs */
  body.atlas-mobile .chat-header .gmail-status-wrapper,
  body.atlas-mobile .chat-header .drive-status-wrapper,
  body.atlas-mobile .chat-header #share-header-btn,
  body.atlas-mobile .chat-header #sources-btn,
  body.atlas-mobile .chat-header #export-btn,
  body.atlas-mobile .chat-header #custom-instructions-btn {
    display: none !important;
  }

  /* Show hamburger for conversation sidebar */
  body.atlas-mobile .chat-header #toggle-chat-sidebar {
    display: flex !important;
  }

  /* Hide header title on mobile — nav already shows "Chat" */
  body.atlas-mobile .chat-header .header-left h1 {
    display: none !important;
  }

  /* Chat layout — fixed header, scrollable messages, fixed input above nav */
  body.atlas-mobile .chat-app,
  body.atlas-mobile .chat-body,
  body.atlas-mobile .chat-main {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0; /* Critical for nested flex scroll */
    overflow: hidden;
  }

  body.atlas-mobile .chat-app {
    margin-top: 0 !important;
    height: 100vh !important;
    height: 100dvh !important;
  }

  /* Messages area — this is the ONLY scrollable container */
  body.atlas-mobile .messages-container {
    padding: 16px;
    padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px)); /* Space for fixed input bar */
    flex: 1;
    min-height: 0;
    overflow-y: scroll !important;
    -webkit-overflow-scrolling: touch;
  }

  /* When nav bar is visible, add extra padding for input above nav */
  body.atlas-mobile:not(.mobile-nav-hidden) .messages-container {
    padding-bottom: calc(72px + var(--mobile-nav-height) + env(safe-area-inset-bottom, 0px));
  }

  /* Input area — fixed at bottom, at true bottom when nav hidden */
  body.atlas-mobile .input-container {
    padding: 8px 12px;
    position: fixed;
    bottom: env(safe-area-inset-bottom, 0px);
    left: 0;
    right: 0;
    background: #fff;
    z-index: 150;
    /* GPU layer — prevents iOS Safari repaint flicker during scroll */
    will-change: transform;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    border-top: 1px solid #e5e7eb;
    transition: transform 0.2s ease;
  }

  /* Hide input bar when scrolling up through conversation */
  body.atlas-mobile .input-container.input-hidden {
    transform: translateY(100%);
    transition: bottom 0.25s ease;
  }

  /* When nav is visible (non-chat pages with input), position above nav */
  body.atlas-mobile:not(.mobile-nav-hidden) .input-container {
    bottom: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom, 0px));
  }

  body.atlas-mobile #chat-input {
    font-size: 16px !important; /* Prevents iOS zoom on focus */
  }

  /* Clean mobile input style — white bg, subtle border */
  body.atlas-mobile .input-wrapper {
    border-radius: 22px !important;
    padding: 8px 14px !important;
    min-height: 40px !important;
    border: 1.5px solid #e5e7eb !important;
    background: #ffffff !important;
    transition: none !important;
  }

  body.atlas-mobile .input-wrapper:focus-within {
    border-color: #d1d5db !important;
    box-shadow: none !important;
    background: #ffffff !important;
  }

  /* Hide "New Chat" button in sidebar on mobile — unnecessary */
  body.atlas-mobile .new-chat-section {
    display: none !important;
  }

  /* Send button — red brand color */
  body.atlas-mobile .input-actions .send-btn {
    background: #C41230 !important;
    border-radius: 50% !important;
    width: 32px;
    height: 32px;
    min-width: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  body.atlas-mobile .input-actions .send-btn svg {
    stroke: #fff !important;
  }

  /* Hide character count on mobile */
  body.atlas-mobile .char-count {
    display: none;
  }

  /* Grow-wrap textarea — compact on mobile */
  body.atlas-mobile .grow-wrap > textarea {
    min-height: 20px !important;
    max-height: 120px !important;
    font-size: 15px !important;
  }

  /* Hide boost button on mobile */
  body.atlas-mobile .btn-boost {
    display: none !important;
  }

  /* Input actions — just attach + send */
  body.atlas-mobile .input-actions {
    gap: 6px;
  }

  /* Send button — compact dark circle */
  body.atlas-mobile .btn-send {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Hide input footer (mode toggles, model selector) on mobile — too clunky */
  body.atlas-mobile .input-footer {
    display: none !important;
  }

  /* Empty state — centered greeting + stacked prompt cards */
  body.atlas-mobile .chat-empty-state {
    position: relative !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
    padding: 24px var(--mobile-gutter, 16px);
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: auto !important;
    gap: 8px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Replace generic icon with Atlas logo on mobile */
  body.atlas-mobile .chat-empty-state .empty-icon {
    display: block !important;
    width: 56px;
    height: 56px;
    margin-bottom: 12px;
    background: url('/icons/atlas-black.png') center/contain no-repeat;
    border-radius: 14px;
    opacity: 1 !important;
  }
  body.atlas-mobile .chat-empty-state .empty-icon svg {
    display: none !important;
  }

  /* chat-main needs flex layout so empty state fills space */
  body.atlas-mobile .chat-main {
    display: flex !important;
    flex-direction: column !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 80px;
  }

  /* Empty state inner wrapper */
  body.atlas-mobile .chat-empty-state .empty-state-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    gap: 8px;
  }

  body.atlas-mobile .chat-empty-state h2,
  body.atlas-mobile .empty-state-greeting {
    font-size: 22px;
    font-weight: 700;
    margin: 0 0 4px;
    text-align: center;
  }

  body.atlas-mobile .chat-empty-state .empty-subtext,
  body.atlas-mobile .empty-state-subtext {
    margin: 0 0 20px;
    font-size: 13px;
    text-align: center;
    color: #9ca3af;
    line-height: 1.4;
  }

  /* Prompt cards — 2-column grid */
  body.atlas-mobile .prompt-cards {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 0;
    width: 100%;
  }

  body.atlas-mobile .prompt-card {
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    background: #f9fafb;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 52px;
  }

  body.atlas-mobile .prompt-card-title {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.3;
    color: #111827;
  }

  /* Hide preview text and arrow on mobile — just show the title */
  body.atlas-mobile .prompt-card-preview {
    display: none;
  }

  body.atlas-mobile .prompt-card-arrow {
    display: none;
  }

  /* Category chips — hide on mobile empty state (too cluttered) */
  body.atlas-mobile .category-chips,
  body.atlas-mobile .empty-state-categories {
    display: none !important;
  }

  /* Hide bottom nav when keyboard is open (iOS) */
  @supports (height: 100dvh) {
    body.atlas-mobile:has(#chat-input:focus) .mobile-bottom-nav {
      display: none;
    }
  }

  /* Messages — full width on mobile, no 80% cap */
  body.atlas-mobile .message {
    max-width: 100%;
  }

  body.atlas-mobile .message-assistant .message-content {
    padding: 12px 14px;
    border-left: none;
    border-radius: 0;
  }

  /* Tables — horizontal scroll, full width */
  body.atlas-mobile .message-content table,
  body.atlas-mobile .preview-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    font-size: 12px;
  }

  body.atlas-mobile .message-content table th,
  body.atlas-mobile .message-content table td {
    white-space: nowrap;
    padding: 6px 10px;
  }

  /* Tool calls — hide individual tool indicators on mobile + embed, show compact summary */
  body.atlas-mobile .message-tools .tool-indicator,
  .chat-embed-mode .message-tools .tool-indicator {
    display: none !important;
  }
  body.atlas-mobile .message-tools,
  .chat-embed-mode .message-tools {
    position: relative;
  }
  body.atlas-mobile .message-tools::before,
  .chat-embed-mode .message-tools::before {
    content: 'Searching...';
    display: block;
    font-size: 12px;
    color: #9ca3af;
    font-style: italic;
    padding: 4px 0;
  }
  /* Once all tools complete, hide the "Searching..." and collapse */
  body.atlas-mobile .message-tools:not(:has(.running))::before,
  .chat-embed-mode .message-tools:not(:has(.running))::before {
    display: none;
  }
  body.atlas-mobile .message-tools:not(:has(.running)),
  .chat-embed-mode .message-tools:not(:has(.running)) {
    display: none;
  }
  /* Hide process/thinking toggle on mobile + embed */
  body.atlas-mobile .message-process-toggle,
  .chat-embed-mode .message-process-toggle {
    display: none !important;
  }

  /* Tool results — full width */
  body.atlas-mobile .tool-result,
  body.atlas-mobile .tool-call-container {
    max-width: 100%;
    overflow-x: auto;
  }

  /* Minimized conversation pill — hide on scroll, show when stopped */
  body.atlas-mobile.mobile-nav-hidden .chat-minimized-pill {
    transform: translateY(calc(100% + 20px));
    transition: transform 0.25s ease;
  }
  .chat-minimized-pill {
    transition: transform 0.25s ease;
  }

  /* Results drawer full-screen on mobile */
  body.atlas-mobile .results-drawer {
    width: 100% !important;
    max-width: 100% !important;
  }
}

/* Mobile overrides outside media query — ensures class-based rules always win */
body.atlas-mobile .input-wrapper {
  background: #ffffff !important;
}
body.atlas-mobile .input-wrapper .grow-wrap,
body.atlas-mobile .input-wrapper .grow-wrap > textarea,
body.atlas-mobile .input-wrapper .grow-mirror {
  background: transparent !important;
}
body.atlas-mobile .input-wrapper:focus-within {
  background: #ffffff !important;
}

