/* AnythingLLM Chat Styles (Bubble + Embed)
   Clean, consistent, and theme-friendly styling */

/* Base */
.anythingllm-bubble-widget,
.anythingllm-embed-widget {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
    Ubuntu, Cantarell, sans-serif;
  font-size: 14px;
  line-height: 1.4;
  /* Prevent iOS text auto-resize/zoom side effects */
  -webkit-text-size-adjust: 100%;
  /* Isolate stacking and layout to avoid theme bleed */
  isolation: isolate;
  contain: layout style paint;
}

/* -------- Bubble Widget -------- */
.anythingllm-bubble-widget {
  position: fixed;
  z-index: 999999;
}

/* Position variants */
.anythingllm-bubble-widget[data-position="bottom-right"] { bottom: 20px; right: 20px; }
.anythingllm-bubble-widget[data-position="bottom-left"] { bottom: 20px; left: 20px; }
.anythingllm-bubble-widget[data-position="top-right"] { top: 20px; right: 20px; }
.anythingllm-bubble-widget[data-position="top-left"] { top: 20px; left: 20px; }

/* Bubble Button */
.anythingllm-bubble-button {
  width: 60px; height: 60px; border-radius: 50%; color: #fff; border: none;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); transition: all 0.3s ease;
  position: relative;
}
.anythingllm-bubble-widget[data-size="small"] .anythingllm-bubble-button { width: 50px; height: 50px; }
.anythingllm-bubble-widget[data-size="large"] .anythingllm-bubble-button { width: 70px; height: 70px; }
.anythingllm-bubble-button:hover { transform: scale(1.05); box-shadow: 0 6px 16px rgba(0,0,0,0.2); }
.anythingllm-bubble-icon, .anythingllm-bubble-close { width: 24px; height: 24px; transition: all 0.3s ease; }

/* Chat Window */
.anythingllm-chat-window {
  position: absolute; width: 380px; height: 600px; background: #fff; border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12); display: flex; flex-direction: column;
  overflow: hidden; transition: all 0.3s ease;
}
.anythingllm-bubble-widget[data-position="bottom-right"] .anythingllm-chat-window,
.anythingllm-bubble-widget[data-position="top-right"] .anythingllm-chat-window { right: 0; }
.anythingllm-bubble-widget[data-position="bottom-left"] .anythingllm-chat-window,
.anythingllm-bubble-widget[data-position="top-left"] .anythingllm-chat-window { left: 0; }
.anythingllm-bubble-widget[data-position="bottom-right"] .anythingllm-chat-window,
.anythingllm-bubble-widget[data-position="bottom-left"] .anythingllm-chat-window { bottom: 80px; }
.anythingllm-bubble-widget[data-position="top-right"] .anythingllm-chat-window,
.anythingllm-bubble-widget[data-position="top-left"] .anythingllm-chat-window { top: 80px; }

/* Header */
.anythingllm-chat-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff; padding: 16px; display: flex; align-items: center; justify-content: space-between;
}
.anythingllm-header-content { display: flex; align-items: center; gap: 12px; }
.anythingllm-header-avatar { width: 40px; height: 40px; aspect-ratio: 1 / 1; background: rgba(255,255,255,0.2); border-radius: 50% !important; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.anythingllm-header-avatar svg { width: 20px; height: 20px; }
.anythingllm-header-avatar img { width: 100%; height: 100%; object-fit: cover; object-position: center; border-radius: 50% !important; display: block; }
.anythingllm-header-text h3 { margin: 0; font-size: 16px; font-weight: 600; }
.anythingllm-header-text h3 { color: #fff; }
.anythingllm-header-text p { margin: 0; font-size: 12px; opacity: 0.9; }
.anythingllm-minimize-btn { background: none; border: none; color: #fff; cursor: pointer; padding: 4px; border-radius: 4px; transition: background-color 0.2s ease; }
.anythingllm-minimize-btn:hover { background: rgba(255,255,255,0.1); }
.anythingllm-minimize-btn svg { width: 16px; height: 16px; }

/* Messages */
.anythingllm-messages-container { flex: 1; overflow-y: auto; overflow-x: auto; overscroll-behavior-x: contain; overscroll-behavior-y: contain; -webkit-overflow-scrolling: touch; touch-action: pan-y; padding: 16px; background: #f8f9fa; scroll-behavior: smooth; }
.anythingllm-messages { display: flex; flex-direction: column; gap: 16px; }
.anythingllm-message { display: flex; gap: 8px; max-width: 85%; }
.anythingllm-message-user { align-self: flex-end; flex-direction: row-reverse; }
.anythingllm-message-assistant { align-self: flex-start; }
.anythingllm-message-avatar { width: 32px; height: 32px; aspect-ratio: 1 / 1; border-radius: 50% !important; background: #667eea; color: #fff; display: flex; align-items: center; justify-content: center; flex-shrink: 0; overflow: hidden; }
.anythingllm-message-user .anythingllm-message-avatar { background: #28a745; }
.anythingllm-message-avatar svg { width: 16px; height: 16px; }
.anythingllm-message-avatar img { width: 100%; height: 100%; object-fit: cover; object-position: center; border-radius: 50% !important; display: block; }
.anythingllm-message-content { flex: 1; position: relative; }
.anythingllm-message-text { background: #fff; padding: 12px 16px; border-radius: 18px; box-shadow: 0 1px 2px rgba(0,0,0,0.1); word-wrap: break-word; color: #111827; }
.anythingllm-message-user .anythingllm-message-text { background: #667eea; color: #fff; }
.anythingllm-message-time { font-size: 11px; color: #6c757d; margin-top: 4px; padding: 0 16px; }
.anythingllm-message-user .anythingllm-message-time { text-align: right; }

/* Markdown content styles */
.anythingllm-message-text h1, .anythingllm-message-text h2, .anythingllm-message-text h3,
.anythingllm-message-text h4, .anythingllm-message-text h5, .anythingllm-message-text h6 {
  margin: 0 0 8px; font-weight: 600; line-height: 1.3;
}
.anythingllm-message-text h1 { font-size: 18px; }
.anythingllm-message-text h2 { font-size: 16px; }
.anythingllm-message-text h3 { font-size: 15px; }
.anythingllm-message-text p { margin: 0 0 8px; }
.anythingllm-message-text ul, .anythingllm-message-text ol { margin: 0 0 8px; padding-left: 20px; }
.anythingllm-message-text li { margin: 4px 0; }
.anythingllm-message-text blockquote { border-left: 3px solid #cbd5e1; padding-left: 10px; color: #4b5563; margin: 6px 0; }
.anythingllm-message-text hr { border: none; border-top: 1px solid #e5e7eb; margin: 10px 0; }

.anythingllm-message-text code { background: rgba(17, 24, 39, 0.06); color: #111827; padding: 0 4px; border-radius: 4px; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; }
.anythingllm-message-text pre { background: #0f172a; color: #e5e7eb; padding: 12px; border-radius: 10px; overflow: auto; margin: 8px 0; }
.anythingllm-message-text pre code { background: none; color: inherit; padding: 0; }

.anythingllm-message-text table {
  border-collapse: collapse;
  display: block;
  margin: 8px 0;
  width: max-content;
  max-width: 100%;
  min-width: 480px;
  table-layout: auto;
  background: #fff;
  color: #111827;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.anythingllm-message-text .anythingllm-table-wrap,
.anythingllm-saved-text .anythingllm-table-wrap { width: 100%; max-width: 100%; display: block; overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; margin: 8px 0; padding-bottom: 8px; overscroll-behavior-x: contain; touch-action: auto; }
.anythingllm-message-text .anythingllm-table-wrap table,
.anythingllm-saved-text .anythingllm-table-wrap table { width: max-content; min-width: 480px; table-layout: auto; border-collapse: collapse; }
@media (max-width: 480px) {
.anythingllm-message-text table { min-width: 320px; }
}
/* Improve table scroll UX */
.anythingllm-message-text .anythingllm-table-wrap,
.anythingllm-saved-text .anythingllm-table-wrap { padding-bottom: 0; scrollbar-width: thin; -ms-overflow-style: auto; }
.anythingllm-message-text .anythingllm-table-wrap::-webkit-scrollbar,
.anythingllm-saved-text .anythingllm-table-wrap::-webkit-scrollbar { height: 6px !important; width: 6px !important; }
.anythingllm-message-text .anythingllm-table-wrap::-webkit-scrollbar-track,
.anythingllm-saved-text .anythingllm-table-wrap::-webkit-scrollbar-track { background: rgba(0,0,0,0.04); border-radius: 3px; }
.anythingllm-message-text .anythingllm-table-wrap::-webkit-scrollbar-thumb,
.anythingllm-saved-text .anythingllm-table-wrap::-webkit-scrollbar-thumb { background: #cbd5e0; border-radius: 3px; }
.anythingllm-message-text .anythingllm-table-wrap::-webkit-scrollbar-thumb:hover,
.anythingllm-saved-text .anythingllm-table-wrap::-webkit-scrollbar-thumb:hover { background: #a0aec0; }
.anythingllm-message-text thead th {
  background: #f7f8fa;
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 1;
  white-space: normal;
  word-break: normal;
  overflow-wrap: break-word;
}
.anythingllm-message-text th, .anythingllm-message-text td {
  border: 1px solid #e5e7eb;
  padding: 8px 10px;
  text-align: left;
  white-space: normal;
  word-break: normal;
  overflow-wrap: break-word;
  hyphens: auto;
}
.anythingllm-message-text tbody tr:nth-child(odd) td { background: #fcfdff; }
.anythingllm-message-text caption { caption-side: top; font-weight: 600; padding: 6px 0; color: #374151; }
/* Lists inside table cells */
.anythingllm-message-text td ul, .anythingllm-message-text td ol { margin: 0; padding-left: 16px; }
.anythingllm-message-text td li { margin: 2px 0; }

/* Optional responsive stacked table fallback for small screens.
   Only applies when wrapper sets data-stack="true" to avoid losing headers. */
@media (max-width: 640px) {
.anythingllm-message-text .anythingllm-table-wrap[data-stack="true"],
.anythingllm-saved-text .anythingllm-table-wrap[data-stack="true"] { overflow-x: auto; }
.anythingllm-message-text .anythingllm-table-wrap[data-stack="true"] table,
.anythingllm-saved-text .anythingllm-table-wrap[data-stack="true"] table { width: 100%; min-width: 100%; }
.anythingllm-message-text .anythingllm-table-wrap[data-stack="true"] thead,
.anythingllm-saved-text .anythingllm-table-wrap[data-stack="true"] thead { display: none; }
.anythingllm-message-text .anythingllm-table-wrap[data-stack="true"] tbody tr,
.anythingllm-saved-text .anythingllm-table-wrap[data-stack="true"] tbody tr { display: block; margin: 8px 0; border-radius: 8px; }
.anythingllm-message-text .anythingllm-table-wrap[data-stack="true"] td,
.anythingllm-saved-text .anythingllm-table-wrap[data-stack="true"] td { display: grid; grid-template-columns: 140px 1fr; align-items: start; }
.anythingllm-message-text .anythingllm-table-wrap[data-stack="true"] td::before,
.anythingllm-saved-text .anythingllm-table-wrap[data-stack="true"] td::before { content: attr(data-label); font-weight: 600; color: #374151; padding-right: 8px; }
  .anythingllm-dark .anythingllm-message-text .anythingllm-table-wrap[data-stack="true"] td::before { color: #e5e7eb; }
}

/* Dark theme adjustments for Markdown */
.anythingllm-dark .anythingllm-message-text { background: #0b1220; color: #e5e7eb; }
.anythingllm-dark .anythingllm-message-user .anythingllm-message-text { background: #667eea; color: #fff; }
.anythingllm-dark .anythingllm-message-text blockquote { border-left-color: #475569; color: #ffffff; }
.anythingllm-dark .anythingllm-message-text hr { border-top-color: #9ca3af; opacity: 0.7; }
.anythingllm-dark .anythingllm-message-text code { background: rgba(255,255,255,0.08); color: #e5e7eb; }
.anythingllm-dark .anythingllm-message-text pre { background: #0a0f1f; color: #e5e7eb; }
.anythingllm-dark .anythingllm-message-text table {
  background: #0b1220;
  color: #e5e7eb;
  border-color: #1f2937;
  box-shadow: 0 1px 2px rgba(0,0,0,0.35);
}
.anythingllm-message-text h1,
.anythingllm-message-text h2,
.anythingllm-message-text h3,
.anythingllm-message-text h4,
.anythingllm-message-text h5,
.anythingllm-message-text h6 { color: inherit !important; }
.anythingllm-dark .anythingllm-message-text h1,
.anythingllm-dark .anythingllm-message-text h2,
.anythingllm-dark .anythingllm-message-text h3,
.anythingllm-dark .anythingllm-message-text h4,
.anythingllm-dark .anythingllm-message-text h5,
.anythingllm-dark .anythingllm-message-text h6 { color: #e5e7eb !important; }
.anythingllm-dark .anythingllm-message-text thead th {
  background: #111827;
  color: #e5e7eb;
}
.anythingllm-dark .anythingllm-message-text th,
.anythingllm-dark .anythingllm-message-text td {
  border-color: #1f2937;
}
.anythingllm-dark .anythingllm-message-text tbody tr:nth-child(odd) td {
  background: #0f172a;
}

/* Typing Indicator */
/* Remove bubble background so only dots are visible */
.anythingllm-typing-dots { display: flex; gap: 4px; padding: 0; background: transparent; border-radius: 0; box-shadow: none; }
.anythingllm-typing-dots span { width: 6px; height: 6px; background: #6c757d; border-radius: 50%; animation: anythingllm-typing 1.4s infinite ease-in-out; }
.anythingllm-typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.anythingllm-typing-dots span:nth-child(2) { animation-delay: -0.16s; }
@keyframes anythingllm-typing { 0%,80%,100%{transform:scale(0.8);opacity:0.5;} 40%{transform:scale(1);opacity:1;} }

/* Optional multilingual typing text (used instead of dots) */
.anythingllm-typing-text { padding: 0; background: transparent; color: #6c757d; font-size: 13px; }
.anythingllm-dark .anythingllm-typing-text { color: #e5e7eb; }

/* Input Area */
.anythingllm-input-area { background: #fff; border-top: 1px solid #e9ecef; padding: 16px; }
.anythingllm-input-container { display: flex; gap: 10px; align-items: center; background: #f3f4f6; border: 1px solid #e5e7eb; border-radius: 28px; padding: 6px 8px; }
.anythingllm-input-container:focus-within { border-color: #667eea; box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15); }
.anythingllm-message-input { flex: 1; min-width: 0; border: none; background: transparent; border-radius: 24px; padding: 10px 14px; resize: none; outline: none; font-family: inherit; font-size: 16px; line-height: 1.4; min-height: 36px; max-height: 120px; overflow-y: auto; }
.anythingllm-message-input:focus { border-color: transparent; }
.anythingllm-input-actions { display: flex; gap: 6px; align-items: center; margin-left: auto; }
.anythingllm-input-actions::before { content: none; display: none; width: 0; height: 0; margin: 0; }
.anythingllm-voice-btn, .anythingllm-send-btn { width: 36px; height: 36px; border: 1px solid #e5e7eb; border-radius: 50%; background: #eef1f4; color: #111827; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: transform 300ms ease, background-color 300ms ease, box-shadow 300ms ease, border-color 300ms ease; will-change: transform, background-color, box-shadow; }
.anythingllm-voice-btn:hover, .anythingllm-send-btn:hover:not(:disabled) { background: #e7ebf0; transform: translateZ(0) scale(1.05); }
.anythingllm-send-btn:disabled { background: #6c757d; cursor: not-allowed; transform: none; }
.anythingllm-voice-btn[data-recording="true"] { background: #fca5a5; border-color: #fca5a5; animation: anythingllm-pulse 1s infinite; }
@keyframes anythingllm-pulse { 0%{transform:scale(1);} 50%{transform:scale(1.1);} 100%{transform:scale(1);} }
.anythingllm-voice-btn svg, .anythingllm-send-btn svg { width: 16px; height: 16px; }
/* Font Awesome equivalents for input action icons */
.anythingllm-voice-btn i, .anythingllm-send-btn i { font-size: 16px; line-height: 1; display: inline-block; }
.anythingllm-chat-window .anythingllm-voice-btn svg path,
.anythingllm-chat-window .anythingllm-voice-btn svg rect,
.anythingllm-chat-window .anythingllm-send-btn svg path {
  fill: currentColor !important;
}
.anythingllm-chat-window .anythingllm-voice-btn svg,
.anythingllm-chat-window .anythingllm-send-btn svg {
  display: inline-block !important;
  visibility: visible !important;
  opacity: 1 !important;
}
/* Ensure FA icons are visible against aggressive theme overrides */
.anythingllm-chat-window .anythingllm-voice-btn i,
.anythingllm-chat-window .anythingllm-send-btn i {
  display: inline-block !important;
  visibility: visible !important;
  opacity: 1 !important;
}
/* Font Awesome icon fallback styling */
.anythingllm-fa-fallback {
  font-size: 16px;
  line-height: 1;
  display: inline-block !important;
  color: currentColor !important;
}
/* Ensure icon stays visible even when the send button is disabled */
.anythingllm-chat-window .anythingllm-send-btn:disabled svg,
.anythingllm-chat-window .anythingllm-voice-btn[disabled] svg {
  display: inline-block !important;
  visibility: visible !important;
  opacity: 1 !important;
}
/* Keep FA icons visible on disabled states */
.anythingllm-chat-window .anythingllm-send-btn:disabled i,
.anythingllm-chat-window .anythingllm-voice-btn[disabled] i {
  display: inline-block !important;
  visibility: visible !important;
  opacity: 1 !important;
}
.anythingllm-chat-window .anythingllm-send-btn:disabled svg path,
.anythingllm-chat-window .anythingllm-voice-btn[disabled] svg path,
.anythingllm-chat-window .anythingllm-voice-btn:disabled svg rect {
  fill: currentColor !important;
}
.anythingllm-char-counter { font-size: 11px; color: #6c757d; text-align: right; margin-top: 4px; }
.anythingllm-char-counter .anythingllm-char-count.warning { color: #ffc107; }
.anythingllm-char-counter .anythingllm-char-count.danger { color: #dc3545; }

/* Footer */
.anythingllm-chat-footer { background: #f8f9fa; padding: 8px 16px; border-top: 1px solid #e9ecef; text-align: center; }
.anythingllm-powered-by { font-size: 11px; color: #6c757d; }

/* -------- Dark Theme Enhancements -------- */
/* Text inputs & placeholders */
.anythingllm-dark .anythingllm-message-input { color: #e5e7eb; }
.anythingllm-dark .anythingllm-message-input::placeholder { color: #e5e7eb; opacity: 0.8; }

/* Message timestamps */
.anythingllm-dark .anythingllm-message-time { color: #9ca3af; }

/* Footer styling in dark mode */
.anythingllm-dark .anythingllm-chat-footer { background: #111827; border-top-color: #374151; }
.anythingllm-dark .anythingllm-powered-by { color: #e5e7eb; }

/* Inline recording UI in dark mode */
.anythingllm-dark .anythingllm-inline-recording .anythingllm-recording-timer { color: #e5e7eb; }
.anythingllm-dark .anythingllm-inline-recording .anythingllm-recording-status { color: #e5e7eb; }
.anythingllm-dark .anythingllm-inline-recording .anythingllm-waveform-inline { background: #1f2937; box-shadow: inset 0 0 0 1px #374151; }

/* Mobile Responsive */
@media (max-width: 480px) {
  /* On very small screens, render bubble chat as a fixed overlay
     to avoid layout constraints from transformed ancestors */
  .anythingllm-chat-window {
    position: fixed !important;
    left: 10px !important;
    right: 10px !important;
    bottom: calc(16px + var(--anythingllm-keyboard-offset, 0px)) !important;
    width: calc(100vw - 20px) !important;
    height: calc(
      var(--anythingllm-vh, 1vh) * 100
      - 32px
      - var(--anythingllm-keyboard-offset, 0px)
    ) !important;
    max-width: none !important;
    max-height: none !important;
    z-index: 1000000 !important;
  }
  /* Prevent iOS Safari auto-zoom on focus by ensuring 16px font-size */
  .anythingllm-message-input { font-size: 16px; line-height: 1.4; }
  .anythingllm-bubble-widget[data-position="bottom-right"] { bottom: 10px; right: 10px; left: auto; }
  .anythingllm-bubble-widget[data-position="bottom-left"] { bottom: 10px; left: 10px; right: auto; }
}

.anythingllm-fade-in { animation: anythingllm-fadeIn 0.3s ease forwards; }
.anythingllm-fade-out { animation: anythingllm-fadeOut 0.3s ease forwards; }
@keyframes anythingllm-fadeIn { from{opacity:0;transform:scale(0.8);} to{opacity:1;transform:scale(1);} }
@keyframes anythingllm-fadeOut { from{opacity:1;transform:scale(1);} to{opacity:0;transform:scale(0.8);} }

/* -------- Embed Widget -------- */
.anythingllm-embed-widget {
  /* Ensure host theme resets cannot strip rounding or clipping */
  border-radius: 12px !important; overflow: hidden !important; box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  background: #fff; margin: 20px 0;
  isolation: isolate; contain: layout style paint;
}
/* Propagate rounding to inner containers unless in fullscreen */
.anythingllm-embed-widget:not(.anythingllm-fullscreen) .anythingllm-chat-window {
  border-radius: inherit !important;
}
.anythingllm-chat-container { display: flex; flex-direction: column; }

/* Header */
.anythingllm-chat-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff; padding: 16px; display: flex; align-items: center; justify-content: space-between;
}
.anythingllm-header-actions { display: flex; gap: 8px; }
.anythingllm-header-actions { position: relative; }
.anythingllm-clear-btn, .anythingllm-fullscreen-btn, .anythingllm-theme-toggle, .anythingllm-saved-toggle-header { background: none; border: none; color: #fff; cursor: pointer; padding: 8px; border-radius: 6px; transition: background-color 0.2s ease; text-transform: none; }
.anythingllm-clear-btn:hover, .anythingllm-fullscreen-btn:hover, .anythingllm-theme-toggle:hover, .anythingllm-saved-toggle-header:hover { background: rgba(255,255,255,0.1); }
.anythingllm-clear-btn svg, .anythingllm-fullscreen-btn svg, .anythingllm-theme-toggle svg, .anythingllm-saved-toggle-header svg { width: 16px; height: 16px; display: inline-block !important; visibility: visible !important; opacity: 1 !important; }
/* Ensure header icons inherit current color under aggressive theme overrides */
.anythingllm-clear-btn svg path, .anythingllm-fullscreen-btn svg path,
.anythingllm-theme-toggle svg path, .anythingllm-saved-toggle-header svg path,
.anythingllm-clear-btn svg rect, .anythingllm-fullscreen-btn svg rect,
.anythingllm-theme-toggle svg rect, .anythingllm-saved-toggle-header svg rect { fill: currentColor !important; }
/* Header FA icon sizing */
.anythingllm-clear-btn i, .anythingllm-fullscreen-btn i, .anythingllm-theme-toggle i, .anythingllm-saved-toggle-header i { font-size: 16px !important; line-height: 1 !important; display: inline-block !important; color: currentColor !important; }

/* Messages */
.anythingllm-messages-container { flex: 1; overflow-y: auto; overflow-x: auto; overscroll-behavior-y: contain; -webkit-overflow-scrolling: touch; touch-action: pan-y; padding: 16px; background: #f8f9fa; scroll-behavior: smooth; }
.anythingllm-message { display: flex; gap: 12px; max-width: 85%; }

/* --- Mobile improvements for embed widget and input --- */
@media (max-width: 640px) {
  /* Reduce overall margin to avoid oversized space below the widget */
  .anythingllm-embed-widget { margin: 8px 0 0; }
  /* Ensure inline height config does not force excessive space on small screens */
  .anythingllm-embed-widget .anythingllm-chat-container { height: auto !important; min-height: calc(var(--anythingllm-vh, 1vh) * 60); }
  /* Keep the input bar visible and comfortable near device safe areas */
  .anythingllm-input-area { position: sticky; bottom: 0; z-index: 5; padding: 10px 12px; padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
  /* Use almost full width for messages; keep ~2–3px side padding */
  .anythingllm-messages-container { padding: 8px 3px; }
  .anythingllm-message { max-width: calc(100% - 6px); gap: 0; }
  .anythingllm-message-content { min-width: 0; }
  .anythingllm-message-text { width: 100%; }
  /* Hide avatars on small screens to save space */
  .anythingllm-message-avatar { display: none !important; }
  .anythingllm-message-time { padding: 0 8px; }
  .anythingllm-messages-container { padding-bottom: 8px; }
  .anythingllm-chat-footer { padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px)); }
  /* Make textarea flex child truly shrinkable on narrow widths */
  .anythingllm-message-input { min-width: 0; width: 100%; }
  .anythingllm-input-container { gap: 8px; padding: 6px 8px; }
  .anythingllm-char-counter { margin-top: 2px; }
  /* Prevent icons from stealing width; keep actions compact */
  .anythingllm-input-actions { flex-shrink: 0; }
}
/* Host-scoped mobile rules ensure reliability on iOS Safari and small screens */
:host(.anythingllm-mobile) .anythingllm-message-avatar { display: none !important; }
:host(.anythingllm-mobile) .anythingllm-message { max-width: calc(100% - 6px); gap: 0; }
.anythingllm-message-avatar { width: 36px; height: 36px; aspect-ratio: 1 / 1; border-radius: 50% !important; background: #667eea; color: #fff; display: flex; align-items: center; justify-content: center; flex-shrink: 0; overflow: hidden; }
.anythingllm-message-user .anythingllm-message-avatar { background: #28a745; }
.anythingllm-message-avatar svg { width: 18px; height: 18px; }
.anythingllm-message-avatar img { width: 100%; height: 100%; object-fit: cover; object-position: center; border-radius: 50% !important; display: block; }
.anythingllm-message-content { flex: 1; position: relative; }
.anythingllm-message-text { background: #fff; padding: 14px 18px; border-radius: 18px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); word-wrap: break-word; line-height: 1.5; color: #111827; }
.anythingllm-message-user .anythingllm-message-text { background: #667eea; color: #fff; }
.anythingllm-message-time { font-size: 11px; color: #6c757d; margin-top: 6px; padding: 0 18px; }
.anythingllm-message-user .anythingllm-message-time { text-align: right; }

/* Input Area */
.anythingllm-input-area { background: #fff; border-top: 1px solid #e9ecef; padding: 16px; }
.anythingllm-input-container { display: flex; gap: 10px; align-items: center; background: #f3f4f6; border: 1px solid #e5e7eb; border-radius: 28px; padding: 6px 8px; }
.anythingllm-input-container:focus-within { border-color: #667eea; box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15); }
.anythingllm-message-input { flex: 1; border: none; background: transparent; border-radius: 24px; padding: 10px 14px; resize: none; outline: none; font-family: inherit; font-size: 14px; line-height: 1.35; min-height: 36px; max-height: 120px; overflow-y: auto; }
.anythingllm-message-input:focus { border-color: transparent; }
.anythingllm-input-actions { display: flex; gap: 6px; align-items: center; margin-left: auto; }
.anythingllm-input-actions::before { content: none; display: none; width: 0; height: 0; margin: 0; }
.anythingllm-voice-btn, .anythingllm-send-btn { width: 36px; height: 36px; border: 1px solid #e5e7eb; border-radius: 50%; background: #eef1f4; color: #111827; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: transform 300ms ease, background-color 300ms ease, box-shadow 300ms ease, border-color 300ms ease; will-change: transform, background-color, box-shadow; }
.anythingllm-voice-btn:hover, .anythingllm-send-btn:hover:not(:disabled) { background: #e7ebf0; transform: translateZ(0) scale(1.05); }
.anythingllm-send-btn:disabled { background: #6c757d; cursor: not-allowed; transform: none; }
.anythingllm-voice-btn[data-recording="true"] { background: #fca5a5; border-color: #fca5a5; animation: anythingllm-pulse 1s infinite; }
.anythingllm-voice-btn svg, .anythingllm-send-btn svg { width: 16px; height: 16px; }

/* Active/inactive color scheme */
.anythingllm-send-btn:not(:disabled) { background: linear-gradient(135deg, #6366f1 0%, #7c3aed 100%); border-color: transparent; color: #fff; box-shadow: 0 6px 14px rgba(99,102,241,0.25); }
.anythingllm-voice-btn:not([data-recording="true"]) { background: linear-gradient(135deg, #6366f1 0%, #7c3aed 100%); border-color: transparent; color: #fff; box-shadow: 0 6px 14px rgba(99,102,241,0.25); }
.anythingllm-send-btn:not(:disabled):hover, .anythingllm-voice-btn:not([data-recording="true"]):hover { filter: brightness(1.05); }
.anythingllm-send-btn:disabled, .anythingllm-voice-btn[disabled] { background: #e5e7eb; color: #6b7280; border-color: #e5e7eb; box-shadow: none; }

/* Enforce visible icon colors against aggressive theme overrides */
.anythingllm-chat-window .anythingllm-send-btn:not(:disabled) { color: #fff !important; }
.anythingllm-chat-window .anythingllm-voice-btn:not([data-recording="true"]) { color: #fff !important; }
.anythingllm-chat-window .anythingllm-send-btn:disabled,
.anythingllm-chat-window .anythingllm-voice-btn[disabled] { color: #6b7280 !important; }

/* Header actions right alignment safeguard */
.anythingllm-header-actions { margin-left: auto; }

/* Fullscreen responsive spacing */
.anythingllm-embed-widget.anythingllm-fullscreen .anythingllm-input-area { padding: 18px; }
.anythingllm-embed-widget.anythingllm-fullscreen .anythingllm-input-container { gap: 12px; }

/* Recording overlay */
.anythingllm-recording-overlay { position: fixed; inset: 0; background: rgba(255,255,255,0.9); display: flex; align-items: center; justify-content: center; z-index: 999999; backdrop-filter: blur(2px); }
.anythingllm-recording-panel { background: #fff; border: 1px solid #e5e7eb; border-radius: 12px; padding: 20px; width: 360px; max-width: 90vw; box-shadow: 0 10px 24px rgba(0,0,0,0.12); text-align: center; }
.anythingllm-recording-icon { width: 28px; height: 28px; background: linear-gradient(135deg, #6366f1 0%, #7c3aed 100%); color: #fff; transform: rotate(25deg); border-radius: 6px; margin: 8px auto 16px; animation: anythingllm-record-spin 1.2s linear infinite; box-shadow: 0 6px 14px rgba(99,102,241,0.25); border: none; }
.anythingllm-recording-icon:hover { filter: brightness(1.05); }
.anythingllm-recording-icon:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(99,102,241,0.35); }
@keyframes anythingllm-record-spin { from{transform: translateZ(0) rotate(25deg);} to{transform: translateZ(0) rotate(385deg);} }
.anythingllm-recording-timer { font-size: 14px; color: #374151; margin-bottom: 12px; }
.anythingllm-waveform { width: 100%; height: 60px; border-radius: 8px; background: #f3f4f6; margin: 8px 0 12px; }
.anythingllm-recording-status { font-size: 14px; color: #4b5563; }
.anythingllm-recording-status.listening { animation: anythingllm-pulse 1.2s ease-in-out infinite; }
.anythingllm-recording-status.transcribing::after { content: '…'; animation: anythingllm-ellipsis 1.2s steps(4, end) infinite; }
@keyframes anythingllm-ellipsis { 0%{content:'';} 33%{content:'.';} 66%{content:'..';} 100%{content:'...';} }
.anythingllm-recording-complete { color: #10b981; }

/* Inline recording (integrated in input container) */
.anythingllm-inline-recording { flex: 1; display: flex; flex-direction: column; gap: 6px; padding: 6px 8px; }
.anythingllm-inline-recording .anythingllm-recording-panel { background: transparent; border: none; border-radius: 0; padding: 0; width: 100%; box-shadow: none; text-align: left; }
.anythingllm-inline-recording .anythingllm-recording-row { display: grid; grid-template-columns: auto 1fr auto 28px; align-items: center; gap: 8px; }
.anythingllm-inline-recording .anythingllm-recording-icon { margin: 0; background: linear-gradient(135deg, #7c3aed 0%, #3b82f6 100%); box-shadow: 0 6px 14px rgba(124,58,237,0.25); transition: opacity 200ms ease, transform 200ms ease, box-shadow 200ms ease; }
.anythingllm-inline-recording .anythingllm-recording-icon.is-hidden { opacity: 0; transform: scale(0.85); pointer-events: none; box-shadow: none; }
/* Send button disabled state */
.anythingllm-send-btn[aria-disabled="true"] { opacity: 0.6; pointer-events: none; }
.anythingllm-inline-recording .anythingllm-recording-timer { margin: 0; color: #374151; }
.anythingllm-inline-recording .anythingllm-waveform-inline { height: 36px; margin: 0; background: #f5f7fb; border-radius: 8px; box-shadow: inset 0 0 0 1px #e5e7eb; }
.anythingllm-inline-recording .anythingllm-recording-status { font-size: 13px; color: #374151; }

/* Accessibility helpers */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.anythingllm-char-counter { font-size: 11px; color: #6c757d; text-align: right; margin-top: 6px; }
.anythingllm-char-counter .anythingllm-char-count.warning { color: #ffc107; }
.anythingllm-char-counter .anythingllm-char-count.danger { color: #dc3545; }

/* Footer */
.anythingllm-chat-footer { background: #f8f9fa; padding: 12px 16px; border-top: 1px solid #e9ecef; text-align: center; }
.anythingllm-powered-by { font-size: 11px; color: #6c757d; }

/* Fullscreen */
.anythingllm-embed-widget.anythingllm-fullscreen { position: fixed; top: 0; left: 0; right: 0; bottom: 0; width: 100vw; height: calc(var(--anythingllm-vh, 1vh) * 100); max-width: none; z-index: 999999; border-radius: 0; margin: 0; overscroll-behavior: contain; touch-action: pan-y; overflow: hidden; }
.anythingllm-embed-widget.anythingllm-fullscreen .anythingllm-chat-container { height: calc(var(--anythingllm-vh, 1vh) * 100); display: grid; grid-template-rows: auto 1fr auto; }
/* Ensure input stays at 16px while fullscreen (regardless of viewport width reporting 980px on iOS) */
.anythingllm-embed-widget.anythingllm-fullscreen .anythingllm-message-input,
.anythingllm-bubble-widget.anythingllm-fullscreen .anythingllm-message-input { font-size: 16px !important; line-height: 1.4 !important; }

/* Bubble fullscreen */
.anythingllm-bubble-widget.anythingllm-fullscreen { position: fixed; inset: 0; width: 100vw; height: calc(var(--anythingllm-vh, 1vh) * 100); max-width: none; z-index: 999999; border-radius: 0; margin: 0; overscroll-behavior: contain; touch-action: pan-y; overflow: hidden; }
.anythingllm-bubble-widget.anythingllm-fullscreen .anythingllm-bubble-button { display: none; }
.anythingllm-bubble-widget.anythingllm-fullscreen .anythingllm-chat-window { position: fixed; top: 0; left: 0; right: 0; bottom: 0 !important; width: 100vw; /* rely on top/bottom for height to avoid iOS clipping */ height: auto; max-width: none; max-height: none; border-radius: 0; box-shadow: none; z-index: 1000000; overscroll-behavior: contain; touch-action: pan-y; }

/* Stabilize painting on iOS: avoid fixed+contain+3D combo that can hide content */
.anythingllm-bubble-widget.anythingllm-fullscreen,
.anythingllm-bubble-widget.anythingllm-fullscreen .anythingllm-chat-window,
.anythingllm-embed-widget.anythingllm-fullscreen {
  contain: none;
  backface-visibility: visible;
  transform: none;
}
.anythingllm-bubble-widget.anythingllm-fullscreen .anythingllm-chat-window { display: grid; grid-template-rows: auto 1fr auto; }
.anythingllm-bubble-widget.anythingllm-fullscreen .anythingllm-chat-window::after { content: ''; position: fixed; left: 0; right: 0; bottom: 0; height: 0; background: inherit; pointer-events: none; z-index: 1000002; }
.anythingllm-bubble-widget.anythingllm-fullscreen .anythingllm-input-area { position: static; bottom: auto; padding: 16px; padding-bottom: var(--anythingllm-input-bottom-extra, 0px); transform: translateY(calc(-1 * var(--anythingllm-keyboard-offset, 0px))); will-change: transform; }
.anythingllm-bubble-widget.anythingllm-fullscreen .anythingllm-chat-header { padding-top: calc(16px + env(safe-area-inset-top, 0px)); }
.anythingllm-bubble-widget.anythingllm-fullscreen .anythingllm-input-container { gap: 12px; }

/* Fullscreen: only add extra space equal to keyboard lift. Grid layout already accounts for input height. */
.anythingllm-bubble-widget.anythingllm-fullscreen .anythingllm-messages-container { padding-bottom: var(--anythingllm-keyboard-offset, 0px); }
.anythingllm-embed-widget.anythingllm-fullscreen .anythingllm-input-area { transform: translateY(calc(-1 * var(--anythingllm-keyboard-offset, 0px))); will-change: transform; padding: 16px; padding-bottom: var(--anythingllm-input-bottom-extra, 0px); }
.anythingllm-embed-widget.anythingllm-fullscreen .anythingllm-messages-container { padding-bottom: var(--anythingllm-keyboard-offset, 0px); }

/* Fullscreen scroll stability: avoid momentum scrolling glitches on iOS */
.anythingllm-bubble-widget.anythingllm-fullscreen .anythingllm-messages-container,
.anythingllm-embed-widget.anythingllm-fullscreen .anythingllm-messages-container {
  -webkit-overflow-scrolling: auto;
  will-change: scroll-position;
  /* Ensure grid middle row can actually scroll on mobile */
  min-height: 0;
}

/* iOS Chrome prefers momentum scrolling to avoid intermittent clipping */
.anythingllm-bubble-widget.anythingllm-ios-chrome.anythingllm-fullscreen .anythingllm-messages-container,
.anythingllm-embed-widget.anythingllm-ios-chrome.anythingllm-fullscreen .anythingllm-messages-container {
  -webkit-overflow-scrolling: touch;
  transform: translateZ(0);
  backface-visibility: hidden;
}

/* Fullscreen should not use sticky input positioning; keep it in normal flow */
.anythingllm-bubble-widget.anythingllm-fullscreen .anythingllm-input-area,
.anythingllm-embed-widget.anythingllm-fullscreen .anythingllm-input-area { position: static; bottom: auto; }

/* Hide footer in fullscreen to prevent extra bottom row/gap */
.anythingllm-bubble-widget.anythingllm-fullscreen .anythingllm-chat-footer,
.anythingllm-embed-widget.anythingllm-fullscreen .anythingllm-chat-footer { display: none !important; height: 0 !important; padding: 0 !important; border: 0 !important; }

/* Mobile Responsive */
@media (max-width: 768px) {
  .anythingllm-embed-widget { margin: 10px 0; }
  .anythingllm-chat-container { height: 400px; }
  .anythingllm-header-text h3 { font-size: 14px; }
  .anythingllm-header-text p { font-size: 11px; }
  .anythingllm-message { max-width: 90%; }
  .anythingllm-input-container { gap: 8px; }
  .anythingllm-voice-btn, .anythingllm-send-btn { width: 40px; height: 40px; }
  .anythingllm-voice-btn svg, .anythingllm-send-btn svg { width: 18px; height: 18px; }
  .anythingllm-voice-btn i, .anythingllm-send-btn i { font-size: 18px; }
}

/* Prefer dynamic viewport height when supported to avoid browser UI overlap */
@supports (height: 100dvh) {
.anythingllm-embed-widget.anythingllm-fullscreen { height: 100dvh; }
  .anythingllm-embed-widget.anythingllm-fullscreen .anythingllm-chat-container { height: 100dvh; display: grid; grid-template-rows: auto 1fr auto; }
  .anythingllm-bubble-widget.anythingllm-fullscreen { height: 100dvh; }
  .anythingllm-bubble-widget.anythingllm-fullscreen .anythingllm-chat-window { height: 100dvh; }
}

/* Desktop fallback: ensure fullscreen truly fills viewport even if dynamic units misreport */
@media (min-width: 769px) {
  .anythingllm-embed-widget.anythingllm-fullscreen,
  .anythingllm-embed-widget.anythingllm-fullscreen .anythingllm-chat-container,
  .anythingllm-bubble-widget.anythingllm-fullscreen,
  .anythingllm-bubble-widget.anythingllm-fullscreen .anythingllm-chat-window {
    height: 100vh !important;
  }
  .anythingllm-embed-widget.anythingllm-fullscreen,
  .anythingllm-bubble-widget.anythingllm-fullscreen .anythingllm-chat-window {
    top: 0 !important; left: 0 !important; right: 0 !important; bottom: 0 !important;
  }
  /* Desktop fullscreen: keep input bar flush to the bottom, no extra padding */
  .anythingllm-embed-widget.anythingllm-fullscreen .anythingllm-input-area,
  .anythingllm-bubble-widget.anythingllm-fullscreen .anythingllm-input-area {
    padding-bottom: 0 !important;
    transform: none !important;
    margin: 0 !important;
  }
  .anythingllm-embed-widget.anythingllm-fullscreen .anythingllm-messages-container,
  .anythingllm-bubble-widget.anythingllm-fullscreen .anythingllm-messages-container {
    padding-bottom: 0 !important;
  }
}

/* Fill out iOS safe-area at the bottom so fullscreen truly covers 100% */
.anythingllm-embed-widget.anythingllm-fullscreen .anythingllm-chat-container::after { content: ''; position: fixed; left: 0; right: 0; bottom: 0; height: 0; background: inherit; pointer-events: none; z-index: 1000002; }
/* Embed fullscreen: keep input exactly above keyboard while it’s open */
.anythingllm-embed-widget.anythingllm-fullscreen .anythingllm-input-area { padding-bottom: var(--anythingllm-input-bottom-extra, 0px); }

/* Remove any residual rounding/shadow on inner containers in fullscreen */
.anythingllm-embed-widget.anythingllm-fullscreen .anythingllm-chat-container,
.anythingllm-embed-widget.anythingllm-fullscreen .anythingllm-chat-window { border-radius: 0 !important; box-shadow: none !important; }

/* Dark theme backgrounds for fullscreen overlay inheritance */
.anythingllm-dark .anythingllm-chat-window,
.anythingllm-dark .anythingllm-chat-container { background: #1f2937; }
.anythingllm-dark .anythingllm-messages-container { background: #111827; }
.anythingllm-dark .anythingllm-input-area { background: #1f2937; border-color: #374151; }

/* Ensure the fullscreen overlay canvas itself is dark when theme is dark */
.anythingllm-embed-widget.anythingllm-fullscreen.anythingllm-dark,
.anythingllm-bubble-widget.anythingllm-fullscreen.anythingllm-dark { background: #111827; }

/* In fullscreen, neutralize any global radius variables */
.anythingllm-embed-widget.anythingllm-fullscreen,
.anythingllm-bubble-widget.anythingllm-fullscreen { --anythingllm-radius: 0; }

.anythingllm-slide-in { animation: anythingllm-slideIn 0.3s ease; }
.anythingllm-slide-out { animation: anythingllm-slideOut 0.3s ease; }
@keyframes anythingllm-slideIn { from{opacity:0;transform:translateY(20px);} to{opacity:1;transform:translateY(0);} }
@keyframes anythingllm-slideOut { from{opacity:1;transform:translateY(0);} to{opacity:0;transform:translateY(20px);} }

/* Scrollbar */
.anythingllm-messages-container::-webkit-scrollbar { width: 6px; height: 6px; }
.anythingllm-messages-container::-webkit-scrollbar-track { background: transparent; }
.anythingllm-messages-container::-webkit-scrollbar-thumb { background: #cbd5e0; border-radius: 3px; }
.anythingllm-messages-container::-webkit-scrollbar-thumb:hover { background: #a0aec0; }
/* Horizontal scrollbar: very subtle by default, more visible on hover */
.anythingllm-messages-container::-webkit-scrollbar:horizontal { height: 0; }
/* Firefox: keep scrollbars thin overall (no per-axis control available) */
.anythingllm-messages-container { scrollbar-width: thin; }
/* Drag scroll: use default cursor at rest; show grabbing only while dragging */
.anythingllm-drag-scroll { cursor: auto; }
.anythingllm-drag-scroll.grabbing { cursor: auto; }
.anythingllm-message-text dl.anythingllm-kv-list { margin: 10px 0; }

/* -------- Workspace Dropdown -------- */
.anythingllm-workspace-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 180px;
  max-width: 260px;
  max-height: 240px;
  overflow-y: auto;
  background: rgba(255,255,255,0.98);
  color: #111827;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  box-shadow: 0 10px 20px rgba(0,0,0,0.12);
  z-index: 20;
}
.anythingllm-workspace-list {
  list-style: none;
  margin: 0;
  padding: 6px;
}
.anythingllm-workspace-item {
  display: block;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: inherit;
}
.anythingllm-workspace-item:hover { background: #f3f4f6; }
.anythingllm-workspace-item.is-active { font-weight: 600; background: #eef2ff; }

/* Dark theme adjustments for dropdown */
.anythingllm-dark .anythingllm-workspace-dropdown {
  background: #111827;
  color: #e5e7eb;
  border-color: #374151;
  box-shadow: 0 12px 24px rgba(0,0,0,0.45);
}
.anythingllm-dark .anythingllm-workspace-item:hover { background: rgba(255,255,255,0.06); }
.anythingllm-dark .anythingllm-workspace-item.is-active { background: rgba(99,102,241,0.2); }
.anythingllm-workspace-inline { margin-left: auto; display: flex; align-items: center; }
.anythingllm-workspace-inline .anythingllm-workspace-list { list-style: none !important; margin: 0 !important; padding: 0 !important; display: flex !important; gap: 8px !important; }
.anythingllm-workspace-inline .anythingllm-workspace-item { display: inline-block; padding: 4px 10px; border-radius: 9999px; cursor: pointer; background: rgba(255,255,255,0.18); border: 1px solid rgba(255,255,255,0.25); color: #fff; font-size: 12px; line-height: 1; }
.anythingllm-workspace-inline .anythingllm-workspace-item:hover { filter: brightness(1.06); }
.anythingllm-workspace-inline .anythingllm-workspace-item.is-active { background: rgba(255,255,255,0.26); border-color: rgba(255,255,255,0.35); font-weight: 600; }
.anythingllm-dark .anythingllm-workspace-inline .anythingllm-workspace-item { background: rgba(255,255,255,0.10); border-color: rgba(255,255,255,0.18); color: #e5e7eb; }
.anythingllm-dark .anythingllm-workspace-inline .anythingllm-workspace-item.is-active { background: rgba(99,102,241,0.20); border-color: rgba(99,102,241,0.32); }
.anythingllm-message-text dl.anythingllm-kv-list dt { font-weight: 600; color: #374151; }
.anythingllm-message-text dl.anythingllm-kv-list dd { margin: 0 0 10px; }
.anythingllm-dark .anythingllm-message-text dl.anythingllm-kv-list dt { color: #374151; }
.anythingllm-message-text .anythingllm-table-wrap,
.anythingllm-saved-text .anythingllm-table-wrap { position: relative; }
.anythingllm-message-text .anythingllm-scroll-btn,
.anythingllm-saved-text .anythingllm-scroll-btn { position: absolute; bottom: 4px; display: none; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 9999px; border: none; background: rgba(99,102,241,0.9); color: #fff; font-size: 18px; line-height: 1; box-shadow: 0 1px 3px rgba(0,0,0,0.3); cursor: pointer; }
.anythingllm-message-text .anythingllm-scroll-btn-left,
.anythingllm-saved-text .anythingllm-scroll-btn-left { left: 6px; }
.anythingllm-message-text .anythingllm-scroll-btn-right,
.anythingllm-saved-text .anythingllm-scroll-btn-right { right: 6px; }
.anythingllm-dark .anythingllm-message-text .anythingllm-scroll-btn,
.anythingllm-dark .anythingllm-saved-text .anythingllm-scroll-btn,
.anythingllm-saved-panel.anythingllm-dark .anythingllm-saved-text .anythingllm-scroll-btn { background: rgba(99,102,241,0.7); color: #fff; }

/* Saved answers UI */
.anythingllm-messages-container { position: relative; }
.anythingllm-save-btn { position: absolute; right: 8px; bottom: 8px; width: 28px; height: 28px; border-radius: 9999px; border: 1px solid rgba(0,0,0,0.08); background: rgba(255,255,255,0.9); color: #4b5563; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; box-shadow: 0 2px 6px rgba(0,0,0,0.12); transition: background 0.2s ease, color 0.2s ease, opacity 0.2s ease, transform 0.1s ease; opacity: 0.92; z-index: 1; }
.anythingllm-save-btn:hover { opacity: 1; transform: translateY(-1px); }
.anythingllm-save-btn svg { width: 16px; height: 16px; }
.anythingllm-save-btn[data-saved="true"] { background: #4f46e5; color: #fff; border-color: #4f46e5; box-shadow: 0 4px 10px rgba(79,70,229,0.35); transform: translateY(-1px) scale(1.06); }
.anythingllm-save-btn[data-saved="true"] svg path { fill: #ffffff !important; stroke: #ffffff !important; }
.anythingllm-save-btn[data-saved="true"] i { color: #ffffff !important; }
.anythingllm-dark .anythingllm-save-btn { background: rgba(31,41,55,0.9); border-color: rgba(255,255,255,0.1); color: #9ca3af; }
.anythingllm-dark .anythingllm-save-btn[data-saved="true"] { background: #6366f1; color: #fff; border-color: transparent; box-shadow: 0 4px 10px rgba(99,102,241,0.45); }

.anythingllm-saved-toggle svg { width: 16px; height: 16px; }
/* Saved toggle FA icon sizing */
.anythingllm-saved-toggle i { font-size: 16px; line-height: 1; display: inline-block; }
/* Modal backdrop for Saved answers */
.anythingllm-saved-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.4); display: none; z-index: 1000002; }
.anythingllm-dark .anythingllm-saved-backdrop, .anythingllm-saved-backdrop.anythingllm-dark { background: rgba(0,0,0,0.6); }
/* Modal panel for Saved answers */
.anythingllm-saved-panel { position: fixed; inset: 0; margin: auto; transform: none; background: #ffffff; border: 1px solid #e5e7eb; border-radius: 12px; box-shadow: 0 12px 28px rgba(0,0,0,0.14); box-sizing: border-box; padding: 16px; padding-top: calc(16px + env(safe-area-inset-top)); padding-bottom: calc(16px + env(safe-area-inset-bottom)); display: none; overflow-x: hidden; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; width: min(880px, 96vw); max-height: min(calc(var(--anythingllm-vh, 1vh) * 86), calc(86vh - env(safe-area-inset-top) - env(safe-area-inset-bottom))); z-index: 1000003; touch-action: pan-y; }
.anythingllm-dark .anythingllm-saved-panel, .anythingllm-saved-panel.anythingllm-dark { background: #1f2937; border-color: #374151; color: #e5e7eb; }
.anythingllm-saved-search-wrap { padding: 6px 12px; border-bottom: 1px solid #e5e7eb; border-radius: 8px;}
.anythingllm-dark .anythingllm-saved-search-wrap { border-bottom-color: #374151; }
.anythingllm-saved-header { display: flex; align-items: center; gap: 8px; font-weight: 600; margin-bottom: 8px; }
.anythingllm-saved-title-text { flex: 0 0 auto; }
.anythingllm-saved-search { flex: 0 0 300px; max-width: 300px; min-width: 160px; box-sizing: border-box; padding: 5px 10px; border: 1px solid #e5e7eb; border-radius: 24px; background: #fff; color: #111827; outline: none; font-size: 16px; -webkit-appearance: none; appearance: none; }
.anythingllm-saved-close { margin-left: auto; }
.anythingllm-saved-search::placeholder { color: #6b7280; }
.anythingllm-dark .anythingllm-saved-search { border-color: #374151; background: #111827; color: #e5e7eb; }
.anythingllm-dark .anythingllm-saved-search::placeholder { color: #9ca3af; }
.anythingllm-saved-search:focus { border-color: #667eea; box-shadow: 0 0 0 3px rgba(102,126,234,0.15); }
.anythingllm-dark .anythingllm-saved-search:focus { border-color: #667eea; box-shadow: 0 0 0 3px rgba(102,126,234,0.25); }
/* Ensure consistent rounded corners by removing default WebKit search decorations */
.anythingllm-saved-search::-webkit-search-decoration,
.anythingllm-saved-search::-webkit-search-cancel-button,
.anythingllm-saved-search::-webkit-search-results-button,
.anythingllm-saved-search::-webkit-search-results-decoration { -webkit-appearance: none; }
@media (max-width: 480px) {
  .anythingllm-saved-header { flex-wrap: wrap; }
  .anythingllm-saved-search { flex: 1 1 auto; max-width: 100%; }
}
.anythingllm-saved-list { overflow-y: visible; max-height: none; display: flex; flex-direction: column; gap: 10px; }
.anythingllm-saved-list { padding-bottom: calc(22px + env(safe-area-inset-bottom)); }
/* Ensure last item has extra breathing room above the panel edge */
.anythingllm-saved-item:last-child { margin-bottom: 0; }

/* Fullscreen-only bottom cushion based on input area height */
:host(.anythingllm-fullscreen) .anythingllm-saved-panel {
  padding-bottom: calc(20px + var(--anythingllm-input-area-height, 72px) + env(safe-area-inset-bottom));
  scroll-padding-bottom: calc(28px + var(--anythingllm-input-area-height, 72px) + env(safe-area-inset-bottom));
}
:host(.anythingllm-fullscreen) .anythingllm-saved-list {
  padding-bottom: calc(24px + var(--anythingllm-input-area-height, 72px) + env(safe-area-inset-bottom));
}
.anythingllm-saved-title { font-weight: 600; margin-bottom: 6px; font-size: 14px; }
.anythingllm-saved-close { background: none; border: none; cursor: pointer; color: inherit; font-size: 18px; line-height: 1; border-radius: 6px; padding: 4px; }
.anythingllm-saved-close:hover { background: rgba(0,0,0,0.06); }
.anythingllm-dark .anythingllm-saved-close:hover { background: rgba(255,255,255,0.08); }
.anythingllm-saved-list { overflow-y: visible; max-height: none; display: flex; flex-direction: column; gap: 10px; }
.anythingllm-saved-item { border: 1px solid #e5e7eb; border-radius: 10px; padding: 10px; background: #fafafa; }
.anythingllm-dark .anythingllm-saved-item { border-color: #374151; background: #111827; }
.anythingllm-saved-time { font-size: 11px; color: #6b7280; margin-bottom: 6px; }
.anythingllm-dark .anythingllm-saved-time { color: #9ca3af; }
.anythingllm-saved-text { font-size: 14px; }
.anythingllm-saved-panel h1,
.anythingllm-saved-panel h2,
.anythingllm-saved-panel h3,
.anythingllm-saved-panel h4,
.anythingllm-saved-panel h5,
.anythingllm-saved-panel h6 { color: inherit !important; }
.anythingllm-dark .anythingllm-saved-panel h1,
.anythingllm-dark .anythingllm-saved-panel h2,
.anythingllm-dark .anythingllm-saved-panel h3,
.anythingllm-dark .anythingllm-saved-panel h4,
.anythingllm-dark .anythingllm-saved-panel h5,
.anythingllm-dark .anythingllm-saved-panel h6 { color: #e5e7eb !important; }

/* Workspace selector modal */
.anythingllm-workspace-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.4); display: none; z-index: 1000002; }
.anythingllm-dark .anythingllm-workspace-backdrop, .anythingllm-workspace-backdrop.anythingllm-dark { background: rgba(0,0,0,0.6); }
.anythingllm-workspace-panel { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); background: #ffffff; border: 1px solid #e5e7eb; border-radius: 12px; box-shadow: 0 12px 28px rgba(0,0,0,0.14); padding: 12px; display: none; overflow: auto; width: min(520px, 92vw); max-height: 80vh; z-index: 1000003; }
.anythingllm-dark .anythingllm-workspace-panel, .anythingllm-workspace-panel.anythingllm-dark { background: #1f2937; border-color: #374151; color: #e5e7eb; }
.anythingllm-workspace-header { display: flex; align-items: center; gap: 8px; font-weight: 600; margin-bottom: 8px; }
.anythingllm-workspace-title-text { flex: 0 0 auto; }
.anythingllm-workspace-close { margin-left: auto; background: none; border: none; cursor: pointer; color: inherit; font-size: 18px; line-height: 1; border-radius: 6px; padding: 4px; }
.anythingllm-workspace-close:hover { background: rgba(0,0,0,0.06); }
.anythingllm-dark .anythingllm-workspace-close:hover { background: rgba(255,255,255,0.08); }
.anythingllm-workspace-modal-list { margin-top: 4px; }
.anythingllm-workspace-select-list { list-style: none; margin: 0; padding: 6px; display: grid; grid-template-columns: 1fr; gap: 8px; }
.anythingllm-workspace-panel .anythingllm-workspace-item { display: block; padding: 12px 16px; border-radius: 10px; cursor: pointer; color: #374151; border: 1px solid #e5e7eb; background: #f9fafb; }
.anythingllm-workspace-panel .anythingllm-workspace-item:hover { background: #f3f4f6; }
.anythingllm-workspace-panel .anythingllm-workspace-item.is-active { background: #eef2ff; border-color: #c7d2fe; color: #111827; }
/* Dark styles apply when dark is on body or directly on panel */
.anythingllm-dark .anythingllm-workspace-panel .anythingllm-workspace-item,
.anythingllm-workspace-panel.anythingllm-dark .anythingllm-workspace-item { border-color: #374151; background: #111827; color: #f9fafb; }
.anythingllm-dark .anythingllm-workspace-panel .anythingllm-workspace-item:hover,
.anythingllm-workspace-panel.anythingllm-dark .anythingllm-workspace-item:hover { background: rgba(255,255,255,0.06); }
.anythingllm-dark .anythingllm-workspace-panel .anythingllm-workspace-item.is-active,
.anythingllm-workspace-panel.anythingllm-dark .anythingllm-workspace-item.is-active { background: rgba(99,102,241,0.24); border-color: rgba(99,102,241,0.32); color: #ffffff; }

/* Hide inline workspace chips on small screens and compact mode */
@media (max-width: 480px) { .anythingllm-workspace-inline { display: none !important; } }
.anythingllm-compact .anythingllm-workspace-inline { display: none !important; }
.anythingllm-saved-actions { display: flex; gap: 8px; margin-top: 8px; }
.anythingllm-saved-toggle { background: #e5e7eb; color: #111827; border: none; border-radius: 6px; padding: 6px 10px; cursor: pointer; text-transform: none; }
.anythingllm-saved-toggle:hover { filter: brightness(1.05); }
.anythingllm-dark .anythingllm-saved-toggle { background: #374151; color: #e5e7eb; }
.anythingllm-saved-copy { background: #e5e7eb; color: #111827; border: none; border-radius: 6px; padding: 6px 10px; cursor: pointer; }
.anythingllm-saved-copy:hover { filter: brightness(1.08); }
.anythingllm-dark .anythingllm-saved-copy { background: #374151; color: #e5e7eb; }
.anythingllm-saved-copy svg { width: 16px; height: 16px; display: block; }
.anythingllm-saved-collapsed { display: block; overflow: hidden; max-height: 6.5em; position: relative; }
.anythingllm-saved-collapsed::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2.2em; background: linear-gradient(to bottom, rgba(250,250,250,0), rgba(250,250,250,1)); }
.anythingllm-dark .anythingllm-saved-collapsed::after { background: linear-gradient(to bottom, rgba(17,24,39,0), rgba(17,24,39,1)); }
.anythingllm-saved-expanded { display: none; }
.anythingllm-saved-text.expanded .anythingllm-saved-collapsed { display: none; }
.anythingllm-saved-text.expanded .anythingllm-saved-expanded { display: block; }
.anythingllm-saved-remove { background: #ef4444; color: #fff; border: none; border-radius: 6px; padding: 6px 10px; cursor: pointer; }
.anythingllm-saved-remove:hover { filter: brightness(1.08); }
.anythingllm-saved-remove svg { width: 16px; height: 16px; display: block; }
.anythingllm-saved-empty { font-size: 13px; color: #6b7280; padding: 8px; text-align: center; }

/* Header-specific Saved toggle to avoid panel styles applying */
.anythingllm-saved-toggle.anythingllm-saved-toggle-header {
  background: none;
  color: #fff;
  border: none;
  padding: 8px;
  border-radius: 6px;
}
.anythingllm-saved-toggle.anythingllm-saved-toggle-header:hover {
  background: rgba(255,255,255,0.1);
}
.anythingllm-saved-toggle.anythingllm-saved-toggle-header svg { width: 16px; height: 16px; }
.anythingllm-saved-toggle.anythingllm-saved-toggle-header i { font-size: 16px; line-height: 1; display: inline-block; }
.anythingllm-bubble-widget.anythingllm-fullscreen .anythingllm-chat-footer { display: none !important; height: 0 !important; padding: 0 !important; border: 0 !important; }