/* css/ask.css – Full-height chat, fixed input at bottom, transparent AI replies, action buttons */

:root {
  --ask-accent: #009688;
  --ask-bubble-user: #e0f2f1;
  --ask-bg: #f5f7f9;
}

[data-theme="dark"] {
  --ask-bubble-user: #2e3b45;
  --ask-bg: #12181c;
}

/* ===== Reset & Base ===== */
html, body {
  margin: 0;
  padding: 0;
  height: 100%;          /* fallback */
  min-height: 100dvh;    /* modern mobile viewport */
}

body {
  display: flex;
  flex-direction: column;
  background: var(--ask-bg);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  overflow: hidden;      /* prevent body scroll, only inner scroll */
}

/* ===== Navbar – always at top ===== */
.navbar {
  flex-shrink: 0;        /* never shrink */
  z-index: 20;
  background: var(--card-bg);
  backdrop-filter: var(--backdrop-blur);
  -webkit-backdrop-filter: var(--backdrop-blur);
  border-bottom: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  padding: 0.65rem 1rem;
  margin: 10px 10px 0 10px;
  border-radius: 10px;
}

/* ===== Main container – fills remaining height ===== */
.ask-main {
  flex: 1 1 0;           /* take all remaining vertical space */
  min-height: 0;         /* allow shrinking */
  display: flex;
  justify-content: center;
  padding: 0 10px 0 10px; /* match navbar margins */
  overflow: hidden;      /* contain children */
  background: var(--ask-bg);
}

.ask-container {
  width: 100%;
  max-width: 900px;
  display: flex;
  flex-direction: column;
  height: 100%;          /* fill .ask-main */
  min-height: 0;
  background: var(--ask-bg);
}

/* ===== Chat messages – scrollable ===== */
.chat-messages {
  flex: 1 1 0;           /* take all available space */
  min-height: 0;
  overflow-y: auto;
  padding: 1.5rem 1.8rem;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  background: var(--ask-bg);
  scroll-behavior: smooth;
}

/* ===== Input area – fixed at bottom ===== */
.chat-input-area {
  flex-shrink: 0;        /* never shrink */
  padding: 0.5rem 0.75rem;
  background: transparent;
  margin: 8px 0;
}

/* ===== Empty state ===== */
.empty-chat {
  text-align: center;
  color: var(--text-secondary);
  padding: 2rem;
  margin: auto;
}

/* Shown in the chat pane while a picked history conversation is being
   fetched (js/ask.js loadConversation). The .route-skeleton-bar shimmer
   lives HERE (its only user) — it used to be defined in css/main.css and was
   dropped from there, which is why the loading shimmer disappeared. */
.message-loading-skeleton {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 1rem 0;
}
.route-skeleton-bar {
  height: 1.1rem;
  width: 100%;
  border-radius: 0.6rem;
  background: linear-gradient(90deg, var(--surface) 25%, var(--border-light) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: routeSkeletonShimmer 1.3s ease-in-out infinite;
}
.route-skeleton-bar--short { width: 55%; }
@keyframes routeSkeletonShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.empty-chat-icon { margin: 0 auto 0.9rem; width: 104px; height: 104px; }
/* rehablix logo engraved into the page background */
.engraved-logo { display: block; width: 100%; height: 100%; overflow: visible; }
.engraved-logo .engrave-fill {
  fill: var(--accent);
  stroke: var(--accent);
  stroke-width: 6; stroke-linejoin: round;
}
.engraved-logo .engrave-shadow { flood-color: #000; flood-opacity: 0.34; }
.engraved-logo .engrave-light { flood-color: #fff; flood-opacity: 0.5; }
[data-theme="dark"] .engraved-logo .engrave-shadow { flood-opacity: 0.55; }
[data-theme="dark"] .engraved-logo .engrave-light { flood-opacity: 0.22; }
.empty-chat p { margin: 0.3rem 0; font-size: 0.95rem; }
.empty-chat .empty-chat-greeting { font-size: 1.3rem; font-weight: 600; color: var(--text-primary); }
.empty-chat-hint { font-size: 0.8rem; opacity: 0.7; }

/* ===== Messages ===== */
.message {
  display: flex;
  flex-direction: column;
  max-width: 100%;
  animation: messageSlide 0.25s ease;
}

.message.user {
  align-self: flex-end;
  max-width: 85%;
}

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

.message-bubble {
  line-height: 1.6;
  font-size: 0.95rem;
  word-wrap: break-word;
  padding: 0.9rem 1.2rem;
}

.message.user .message-bubble {
  background: var(--ask-bubble-user);
  border: 1px solid var(--border-light);
  border-radius: 1.2rem 1.2rem 1.8rem 1.2rem;
  color: var(--text-primary);
}

.message.assistant .message-bubble {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0.5rem 0;
  color: var(--text-primary);
}

/* While a reply is still streaming in, content is set via textContent (raw
   text, not yet markdown-parsed) — preserve line breaks until the final
   render swaps this class out for properly parsed HTML. */
.message.assistant .message-bubble.streaming-text {
  white-space: normal; /* rendered as live Markdown (js/ask.js renderStreamingHtml) */
}
.message.assistant .message-bubble.streaming-text::after {
  content: '';
  display: inline-block;
  width: 0.5em;
  height: 1em;
  margin-left: 2px;
  background: var(--accent);
  vertical-align: text-bottom;
  animation: streamCursorBlink 0.9s steps(1) infinite;
}
@keyframes streamCursorBlink {
  50% { opacity: 0; }
}

.message-time {
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
  padding: 0 0.5rem;
}

.message.user .message-time { text-align: right; }
.message.assistant .message-time { text-align: left; }

/* ===== Action buttons ===== */
.message-actions {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.5rem;
  opacity: 0;
  transition: opacity 0.2s ease;
}

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

.action-btn {
  background: transparent;
  border: 1px solid var(--border-light);
  border-radius: 0.4rem;
  padding: 0.3rem 0.6rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-family: inherit;
  white-space: nowrap;
}

.action-btn:hover {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}

.action-btn i { font-size: 0.7rem; }

/* ===== Markdown styling ===== */
.message.assistant .message-bubble h1,
.message.assistant .message-bubble h2,
.message.assistant .message-bubble h3,
.message.assistant .message-bubble h4 {
  margin-top: 1em;
  margin-bottom: 0.3em;
}
.message.assistant .message-bubble ul,
.message.assistant .message-bubble ol {
  padding-left: 1.2rem;
  margin: 0.5rem 0;
}
.message.assistant .message-bubble p { margin: 0.5rem 0; }
.message.assistant .message-bubble pre {
  background: var(--surface);
  padding: 0.8rem;
  border-radius: 0.5rem;
  overflow-x: auto;
  border: 1px solid var(--border-light);
}
.message.assistant .message-bubble code { font-family: monospace; font-size: 0.9em; }
.message.assistant .message-bubble blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 1rem;
  margin-left: 0;
  color: var(--text-secondary);
}
/* A table keeps readable column widths and scrolls sideways when it is wider
   than the screen, instead of being squeezed until words break letter by letter.
   js/ask.js puts every table in a .lixa-table-scroll box. */
.message.assistant .message-bubble .lixa-table-scroll {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  margin: 1rem 0;
}
.message.assistant .message-bubble table {
  border-collapse: collapse;
  width: max-content;       /* as wide as its columns need … */
  min-width: 100%;          /* … but never narrower than the message */
  max-width: none;          /* the scroll box limits it, not the table itself */
  margin: 0;
}
.message.assistant .message-bubble th,
.message.assistant .message-bubble td {
  min-width: 6rem;
  max-width: 17rem;         /* long text wraps inside a comfortable column */
  word-break: normal;
  overflow-wrap: break-word;
  hyphens: none;
  vertical-align: top;
}
.message.assistant .message-bubble th,
.message.assistant .message-bubble td {
  border: 1px solid var(--border-light);
  padding: 0.5rem 0.75rem;
  text-align: left;
}
.message.assistant .message-bubble th {
  background: var(--surface);
  font-weight: 600;
}
.message.assistant .message-bubble hr {
  border: none;
  border-top: 1px solid var(--border-light);
  margin: 1.5rem 0;
}

/* ===== Typing indicator ===== */
.typing-indicator {
  align-self: flex-start;
  padding: 0.6rem 1.4rem;
  background: transparent;
  border: none;
  border-radius: 0;
  display: flex;
  gap: 0.3rem;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  background: var(--text-secondary);
  border-radius: 50%;
  animation: typingBounce 1.4s infinite ease-in-out both;
}
.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }
.typing-indicator span:nth-child(3) { animation-delay: 0s; }

/* ===== Composer (input area) ===== */
.composer {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: 1.4rem;
  box-shadow: var(--shadow-sm);
  padding: 0.5rem 0.6rem 0.5rem 0.9rem;
  transition: border 0.2s;
}

.composer:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 150, 136, 0.15);
}

.chat-input-area textarea {
  width: 100%;
  resize: none;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.98rem;
  outline: none;
  min-height: 24px;
  max-height: 40vh; max-height: 40dvh;
  padding: 0.4rem 0.1rem 0.6rem;
  line-height: 1.4;
}

.composer-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.composer-controls-right {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.plus-btn {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-light);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  font-size: 1rem;
  transition: all 0.2s;
}

.plus-btn:hover,
.plus-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}

.plus-btn.active i { transform: rotate(45deg); }
.plus-btn i { transition: transform 0.2s; }

/* Attach menu popover */
.attach-menu {
  position: absolute;
  bottom: calc(100% + 0.5rem);
  left: 0;
  background: var(--card-bg);
  border: 1px solid var(--border-light);
  border-radius: 0.9rem;
  box-shadow: var(--shadow-md, 0 8px 24px rgba(0,0,0,0.18));
  padding: 0.4rem;
  display: flex;
  flex-direction: column;
  min-width: 190px;
  z-index: 30;
  animation: popoverIn 0.15s ease;
}

/* FIX: ensure hidden attribute hides it */
.attach-menu[hidden] {
  display: none !important;
}

.attach-menu button {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  background: transparent;
  border: none;
  color: var(--text-primary);
  padding: 0.6rem 0.7rem;
  border-radius: 0.6rem;
  font-size: 0.88rem;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
}

.attach-menu button:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.attach-menu button i {
  width: 18px;
  text-align: center;
  color: var(--accent);
}

.composer-wrap { position: relative; }

#sendBtn {
  background: var(--accent);
  color: white;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 1rem;
  flex-shrink: 0;
}

#sendBtn:hover {
  filter: brightness(1.1);
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0, 150, 136, 0.3);
}

#sendBtn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* While a request is running, Send and the microphone give way to one Stop
   button in the Send position (js/ask.js syncComposer). */
#sendBtn[hidden], #micBtn[hidden], .stop-btn[hidden] { display: none !important; }
.stop-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.85rem;
  flex-shrink: 0;
  transition: all 0.2s;
  animation: stopBtnPulse 1.6s ease-in-out infinite;
}
.stop-btn:hover { filter: brightness(1.1); transform: scale(1.05); }
.stop-btn:disabled { opacity: 0.6; cursor: default; }
@keyframes stopBtnPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(0, 150, 136, 0.35); }
  50% { box-shadow: 0 0 0 7px rgba(0, 150, 136, 0); }
}
@media (prefers-reduced-motion: reduce) { .stop-btn { animation: none; } }

/* ===== History drawer ===== */
.history-drawer {
  position: fixed;
  top: 0;
  left: -400px;
  width: 400px;
  height: 100vh; height: 100dvh;
  background: var(--card-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-right: 1px solid var(--border-light);
  z-index: 1000;
  transition: left 0.3s ease;
  display: flex;
  flex-direction: column;
}

.history-drawer.active { left: 0; }

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

.drawer-header h3 {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.1rem;
}

.drawer-close-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 0.25rem;
  border-radius: 0.5rem;
  transition: all 0.2s;
}

.drawer-close-btn:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.history-search[hidden] { display: none !important; }
.history-search {
  padding: 0.75rem 1.2rem;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--surface);
  flex-shrink: 0;
}

.history-search input {
  flex: 1;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border-light);
  border-radius: 2rem;
  background: var(--card-bg);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
}

.history-search input:focus { border-color: var(--accent); }

.history-content {
  flex: 1;
  overflow-y: auto;
  padding: 1.2rem;
}

/* Single-line row: truncated title, inline delete icon, relative time. */
.history-item {
  background: var(--surface);
  border-radius: 0.75rem;
  padding: 0.7rem 0.85rem;
  margin-bottom: 0.5rem;
  border: 1px solid var(--border-light);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.history-item:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* The conversation currently loaded in the chat pane — distinct from
   :hover so it stays visible once the pointer moves away. */
.history-item.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent);
}

.history-title {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-time {
  flex-shrink: 0;
  font-size: 0.72rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.history-item .delete-btn {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.history-item .delete-btn:hover {
  background: #fee2e2;
  color: #dc2626;
}

.empty-state {
  text-align: center;
  padding: 2rem;
  color: var(--text-secondary);
}

.empty-state i {
  font-size: 2.5rem;
  display: block;
  margin-bottom: 0.5rem;
  opacity: 0.5;
}

/* ===== Toast ===== */
#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: var(--surface);
  border-left: 4px solid var(--accent);
  padding: 12px 20px;
  border-radius: 12px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.15);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideUp 0.3s ease;
  font-size: 0.9rem;
}

.toast.success { border-left-color: #10b981; }
.toast.error { border-left-color: #dc2626; }
.toast.info { border-left-color: #3b82f6; }

/* ===== Animations ===== */
@keyframes slideUp {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes messageSlide {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes typingBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}
@keyframes popoverIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes copyPop {
  0% { transform: scale(1); }
  50% { transform: scale(1.4); }
  100% { transform: scale(1); }
}
@keyframes micPulse {
  0% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.5); }
  70% { box-shadow: 0 0 0 10px rgba(220, 38, 38, 0); }
  100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); }
}

/* ===== Attachments strip ===== */
/* Picked files sit side by side in ONE row that scrolls sideways (never stacked). */
.attachments-strip {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.5rem;
  padding: 0 0.25rem 0.5rem;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
}
.attachments-strip::-webkit-scrollbar { display: none; }
.attachments-strip > .attachment-chip { flex: 0 0 auto; }

.attachment-chip {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: 0.6rem;
  padding: 0.35rem 0.6rem;
  font-size: 0.78rem;
  color: var(--text-primary);
  max-width: 220px;
}

.attachment-chip i.file-type-icon { color: var(--accent); flex-shrink: 0; }
.attachment-chip .attachment-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.attachment-chip .attachment-status {
  font-size: 0.65rem;
  color: var(--text-secondary);
  flex-shrink: 0;
}
.attachment-chip .remove-attachment {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0;
  font-size: 0.85rem;
  flex-shrink: 0;
}
.attachment-chip .remove-attachment:hover { color: #dc2626; }

.message-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}
.message-attachments .attachment-chip {
  max-width: 180px;
  background: rgba(0, 0, 0, 0.04);
}
[data-theme="dark"] .message-attachments .attachment-chip {
  background: rgba(255, 255, 255, 0.06);
}

/* ===== Drawer "New Chat" action ===== */
.drawer-actions {
  padding: 0.75rem 1.5rem 0;
  flex-shrink: 0;
}
.drawer-actions .new-chat-btn {
  width: 100%;
  justify-content: center;
  margin-left: 0;
}

/* ===== User message popover ===== */
.message.user { position: relative; }
.message.user .message-bubble { cursor: default; user-select: none; -webkit-user-select: none; }

.user-msg-popover {
  position: absolute;
  top: 100%;
  margin-top: 0.4rem;
  right: 0;
  display: flex;
  gap: 0.35rem;
  background: var(--card-bg);
  border: 1px solid var(--border-light);
  border-radius: 0.6rem;
  padding: 0.3rem;
  box-shadow: var(--shadow-md, 0 4px 12px rgba(0,0,0,0.15));
  z-index: 5;
  animation: popoverIn 0.15s ease;
}

.user-msg-popover button {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  width: 32px;
  height: 32px;
  border-radius: 0.4rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
/* (an invisible bridge over the gap, so the mouse can reach the buttons without the hover ending) */
.user-msg-popover::before { content: ''; position: absolute; left: 0; right: 0; top: -0.5rem; height: 0.5rem; }
.user-msg-popover button:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

/* ===== Editing user message ===== */
.message.user.editing .message-bubble { display: none; }
.user-edit-box {
  display: none;
  flex-direction: column;
  gap: 0.4rem;
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: 1rem;
  padding: 0.6rem;
}
.message.user.editing .user-edit-box { display: flex; }
.user-edit-box textarea {
  resize: vertical;
  min-height: 60px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
}
.user-edit-box .edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}
.user-edit-box .edit-actions button {
  border: none;
  border-radius: 0.5rem;
  padding: 0.35rem 0.8rem;
  font-size: 0.8rem;
  cursor: pointer;
  font-family: inherit;
}
.user-edit-box .save-edit-btn {
  background: var(--accent);
  color: #fff;
}
.user-edit-box .cancel-edit-btn {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-light) !important;
}

/* ===== Suggested questions ===== */
.suggestions-container {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-light);
}
.suggestions-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin: 0 0 0.6rem 0;
  font-weight: 500;
}
.suggestions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.suggestion-chip {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: 1.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.82rem;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  text-align: left;
  white-space: normal;
  max-width: 100%;
  line-height: 1.4;
}
.suggestion-chip:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 150, 136, 0.15);
}
.suggestion-chip:active {
  transform: translateY(0) scale(0.98);
}

/* ===== Input extras ===== */
.icon-round-btn {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-light);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  font-size: 1rem;
  transition: all 0.2s;
}
.icon-round-btn:hover {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}
.icon-round-btn.recording {
  background: #dc2626;
  color: #fff;
  border-color: #dc2626;
  animation: micPulse 1.2s infinite;
}

.input-hint {
  margin: 0.3rem 0 0;
  font-size: 0.7rem;
  color: var(--text-secondary);
  text-align: center;
  opacity: 0.7;
}

/* ===== Links in AI responses ===== */
.message.assistant .message-bubble a {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid rgba(0, 150, 136, 0.25);
  border-radius: 0.5rem;
  padding: 0.1rem 0.55rem;
  font-weight: 600;
  text-decoration: none;
  line-height: 1.6;
  transition: all 0.15s ease;
}
.message.assistant .message-bubble a:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  transform: translateY(-1px);
}
.message.assistant .message-bubble a.external-link::after {
  content: '\f35d';
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  font-size: 0.7em;
  margin-left: 0.1rem;
  opacity: 0.85;
}
.message.assistant .message-bubble a.internal-link::after {
  content: '\f061';
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  font-size: 0.7em;
  margin-left: 0.1rem;
  opacity: 0.85;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .chat-messages { padding: 1rem; gap: 1rem; }
  .chat-input-area { padding: 0.5rem 0.7rem; }
  .chat-input-area textarea { font-size: 0.9rem; min-height: 40px; }
  #sendBtn, .stop-btn { width: 44px; height: 44px; }
  .history-drawer { width: 300px; left: -300px; }
  .message.user { max-width: 90%; }
  .message-actions { opacity: 1; }
  /* Icon-only on mobile — the label text takes up room that matters more on
     a narrow screen than the extra clarity it adds next to a familiar icon. */
  .action-btn-label { display: none; }
  .action-btn {
    padding: 0.45rem;
    font-size: 0.85rem;
    width: 34px;
    height: 34px;
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .chat-messages { padding: 0.8rem; gap: 0.8rem; }
  .chat-input-area { padding: 0.45rem 0.8rem; gap: 0.5rem; }
  .chat-input-area textarea { padding: 0.6rem 0.8rem; font-size: 0.85rem; }
  #sendBtn { width: 40px; height: 40px; font-size: 1rem; }
  .new-chat-btn { padding: 0.4rem 0.8rem; font-size: 0.8rem; }
  .toast { left: 1rem; right: 1rem; bottom: 1rem; }
  .attachment-chip { max-width: 150px; }
  .icon-round-btn { width: 40px; height: 40px; }
}

@media (hover: none) {
  .message.assistant .message-actions { opacity: 1; }
}

/* ===== Dark mode overrides ===== */
[data-theme="dark"] .message.user .message-bubble {
  background: var(--ask-bubble-user);
  border-color: #3e4b55;
}
[data-theme="dark"] .chat-input-area textarea {
  background: #1e2a32;
  border-color: #2e3b45;
}
[data-theme="dark"] .history-item {
  background: #1e2a32;
  border-color: #2e3b45;
}
[data-theme="dark"] .history-item:hover {
  background: #2e3b45;
  border-color: var(--accent);
}
[data-theme="dark"] .action-btn {
  border-color: #3e4b55;
}
[data-theme="dark"] .action-btn:hover {
  background: rgba(20, 184, 166, 0.15);
  border-color: var(--accent);
}
[data-theme="dark"] .message.assistant .message-bubble pre {
  background: #12181c;
  border-color: #2e3b45;
}
[data-theme="dark"] .message.assistant .message-bubble th {
  background: #1e2a32;
}
[data-theme="dark"] .suggestion-chip {
  background: #1e2a32;
  border-color: #2e3b45;
}
[data-theme="dark"] .suggestion-chip:hover {
  background: rgba(20, 184, 166, 0.1);
  border-color: var(--accent);
}
[data-theme="dark"] .suggestions-container {
  border-top-color: #2e3b45;
}
[data-theme="dark"] .message-actions {
  border-top-color: #2e3b45;
}
[data-theme="dark"] .action-btn {
  background: #1e2a32;
  border-color: #2e3b45;
  color: #9aa8b5;
}
[data-theme="dark"] .action-btn:hover {
  background: rgba(20, 184, 166, 0.1);
  border-color: var(--accent);
  color: var(--accent);
}
[data-theme="dark"] .action-btn.copy-btn:hover {
  background: rgba(99, 102, 241, 0.12);
}
[data-theme="dark"] .action-btn.download-btn:hover {
  background: rgba(245, 158, 11, 0.12);
}
[data-theme="dark"] .action-btn.regenerate-btn:hover {
  background: rgba(16, 185, 129, 0.12);
}

.action-btn.continue-btn {
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}
.action-btn.continue-btn:hover {
  background: var(--accent-soft);
}
.action-btn.continue-btn:disabled {
  opacity: 0.7;
  cursor: default;
}
/* Continue always shows its label (the other actions are icon-only on phones). */
.action-btn.continue-btn { width: auto; height: auto; min-height: 34px; padding: 0.4rem 0.85rem; gap: 0.4rem; }


/* ===== New Chat Button (in header) ===== */
.new-chat-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 0.5rem 1.2rem;
  border-radius: 2rem;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
  font-family: inherit;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0, 150, 136, 0.2);
}

.new-chat-btn:hover {
  filter: brightness(1.1);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0, 150, 136, 0.35);
}

.new-chat-btn:active {
  transform: translateY(0) scale(0.97);
}

.new-chat-btn i {
  font-size: 0.85rem;
}

/* ===== New Chat Button (in drawer) ===== */
.drawer-actions .new-chat-btn {
  width: 100%;
  justify-content: center;
  margin-left: 0;
  padding: 0.6rem 1.2rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 2rem;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
  font-family: inherit;
  box-shadow: 0 2px 8px rgba(0, 150, 136, 0.2);
}

.drawer-actions .new-chat-btn:hover {
  filter: brightness(1.1);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0, 150, 136, 0.35);
}

.drawer-actions .new-chat-btn:active {
  transform: translateY(0) scale(0.97);
}

.drawer-actions .new-chat-btn i {
  font-size: 0.9rem;
}

/* ===== Dark mode ===== */
[data-theme="dark"] .new-chat-btn {
  background: #14b8a6;
  box-shadow: 0 2px 8px rgba(20, 184, 166, 0.3);
}

[data-theme="dark"] .new-chat-btn:hover {
  box-shadow: 0 4px 16px rgba(20, 184, 166, 0.5);
}

[data-theme="dark"] .drawer-actions .new-chat-btn {
  background: #14b8a6;
  box-shadow: 0 2px 8px rgba(20, 184, 166, 0.3);
}

[data-theme="dark"] .drawer-actions .new-chat-btn:hover {
  box-shadow: 0 4px 16px rgba(20, 184, 166, 0.5);
}
/* Persistent AI notice under the Lixa composer */
.ai-disclaimer {
  margin: 6px auto 0;
  text-align: center;
  font-size: 0.72rem;
  line-height: 1.4;
  color: var(--text-secondary);
  opacity: 0.85;
  padding: 0 16px;
}
/* Small-talk typing indicator: three dots, no status words */
.lixa-typing-dots { display: inline-flex; align-items: center; gap: 5px; padding: 0.75rem 0.9rem; }
.lixa-typing-dots span { width: 7px; height: 7px; border-radius: 50%; background: var(--text-secondary); opacity: 0.35; animation: lixaDot 1.1s ease-in-out infinite; }
.lixa-typing-dots span:nth-child(2) { animation-delay: 0.16s; }
.lixa-typing-dots span:nth-child(3) { animation-delay: 0.32s; }
@keyframes lixaDot { 0%, 70%, 100% { opacity: 0.3; transform: translateY(0); } 35% { opacity: 1; transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .lixa-typing-dots span { animation: none; opacity: 0.6; } }

/* ===== Lixa question form (several details asked as a form, not as text) ===== */
.lixa-qform-pending { display: inline-flex; align-items: center; gap: 0.5rem; margin: 0.5rem 0 0; font-size: 0.85rem; color: var(--text-secondary); }
.lixa-qform-card { display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; margin-top: 0.7rem; padding: 0.7rem 0.8rem 0.7rem 0.95rem; border: 1px solid var(--accent); border-radius: 0.9rem; background: var(--accent-soft); max-width: 460px; }
.lixa-qform-card-text { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }
.lixa-qform-card-text strong { font-size: 0.9rem; color: var(--text-primary); }
.lixa-qform-card-text span { font-size: 0.76rem; color: var(--text-secondary); }
.lixa-qform-open { flex-shrink: 0; display: inline-flex; align-items: center; gap: 0.45rem; min-height: 40px; padding: 0.45rem 0.95rem; border: none; border-radius: 0.7rem; background: var(--accent); color: #fff; font: inherit; font-size: 0.84rem; font-weight: 700; cursor: pointer; }
.lixa-qform-overlay { position: fixed; inset: 0; z-index: 5000; background: rgba(8, 14, 18, 0.55); display: flex; align-items: flex-end; justify-content: center; animation: lixaQformFade 0.15s ease; }
.lixa-qform { width: 100%; max-width: 520px; max-height: 92vh; max-height: 92dvh; display: flex; flex-direction: column; background: var(--surface); border-radius: 1.3rem 1.3rem 0 0; box-shadow: 0 -18px 50px rgba(0, 0, 0, 0.3); padding: 1rem 1rem calc(0.9rem + env(safe-area-inset-bottom)); animation: lixaQformUp 0.22s cubic-bezier(0.2, 0.8, 0.2, 1); }
.lixa-qform-head { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; }
.lixa-qform-head h3 { margin: 0; font-size: 1.08rem; font-weight: 700; color: var(--text-primary); }
.lixa-qform-x { flex: 0 0 38px; width: 38px; height: 38px; border: none; border-radius: 50%; background: var(--bg-page); color: var(--text-secondary); cursor: pointer; }
.lixa-qform-intro { margin: 0.3rem 0 0; font-size: 0.86rem; color: var(--text-secondary); line-height: 1.45; }
.lixa-qform-body { overflow-y: auto; margin-top: 0.8rem; padding-right: 0.15rem; display: flex; flex-direction: column; gap: 1rem; }
.lixa-qform-field { display: flex; flex-direction: column; gap: 0.45rem; }
.lixa-qform-label { font-size: 0.86rem; font-weight: 700; color: var(--text-primary); }
.lixa-qform-optional { font-weight: 500; font-size: 0.72rem; color: var(--text-secondary); margin-left: 0.3rem; }
.lixa-qform-input { width: 100%; box-sizing: border-box; font: inherit; font-size: 0.95rem; color: var(--text-primary); background: var(--bg-page); border: 1px solid var(--border-light); border-radius: 0.75rem; padding: 0.65rem 0.8rem; min-height: 44px; outline: none; }
textarea.lixa-qform-input { resize: vertical; line-height: 1.45; }
.lixa-qform-input:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.lixa-qform-other { font-size: 0.85rem; min-height: 40px; }
.lixa-qform-chips { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.lixa-qform-chip { display: inline-flex; align-items: center; gap: 0.4rem; min-height: 38px; padding: 0.35rem 0.8rem; border-radius: 2rem; border: 1px solid var(--border-light); background: var(--surface); color: var(--text-primary); font: inherit; font-size: 0.84rem; cursor: pointer; text-align: left; }
.lixa-qform-chip.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.lixa-qform-chip:focus-visible, .lixa-qform-open:focus-visible, .lixa-qform-submit:focus-visible, .lixa-qform-cancel:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.lixa-qform-hints .lixa-qform-chip { border-style: dashed; color: var(--text-secondary); font-size: 0.8rem; min-height: 34px; }
.lixa-qform-rec { font-size: 0.64rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; padding: 0.08rem 0.4rem; border-radius: 1rem; background: var(--accent); color: #fff; }
.lixa-qform-field.missing .lixa-qform-label { color: #dc2626; }
.lixa-qform-field.missing .lixa-qform-input { border-color: #dc2626; }
.lixa-qform-error { margin: 0.6rem 0 0; min-height: 1.1em; font-size: 0.82rem; color: #dc2626; }
.lixa-qform-error:empty { display: none; }
.lixa-qform-actions { display: flex; gap: 0.6rem; margin-top: 0.8rem; }
.lixa-qform-cancel { flex: 0 0 auto; min-height: 46px; padding: 0.5rem 0.9rem; border-radius: 0.8rem; border: 1px solid var(--border-light); background: var(--surface); color: var(--text-secondary); font: inherit; font-size: 0.86rem; font-weight: 600; cursor: pointer; }
.lixa-qform-submit { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; min-height: 46px; border: none; border-radius: 0.8rem; background: var(--accent); color: #fff; font: inherit; font-size: 0.95rem; font-weight: 700; cursor: pointer; }
@keyframes lixaQformFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes lixaQformUp { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (min-width: 640px) { .lixa-qform-overlay { align-items: center; } .lixa-qform { border-radius: 1.3rem; padding: 1.2rem; } }
@media (prefers-reduced-motion: reduce) { .lixa-qform-overlay, .lixa-qform { animation: none; } }
