/*
 * BCA Study Portal — ADDI, the AI study assistant ("✨ Ask ADDI")
 *
 * The assistant is presented as a CHAT WINDOW, not a form:
 *
 *   · header  — avatar, name, live status dot, window controls (⟳ – ×)
 *   · thread  — scrollable conversation: student bubbles right, ADDI left
 *   · composer— auto-growing input, round send button, quick-action chips
 *
 * Styled to match the portal's dark academic reader design (same navy/cyan
 * palette and Arial stack used across the reader page).
 *
 * IMPORTANT: the JS toggles the `hidden` attribute on several flex/grid
 * elements, and an author `display` rule would beat the browser default for
 * [hidden]. The single guard in section 1 keeps that contract intact.
 */

/* ============================================================
   1. Theme tokens + hidden-state guard
   ============================================================ */

:root {
  --addi-cyan: #6fe5ff;
  --addi-blue: #68a0ff;
  --addi-ink: #08111c;
  --addi-text: #eaf3ff;
  --addi-muted: rgba(190, 208, 230, 0.72);
  --addi-line: rgba(143, 169, 206, 0.22);
  --addi-panel: rgba(11, 18, 28, 0.985);
  --addi-bubble-ai: rgba(18, 28, 42, 0.95);
  --addi-font: Arial, Helvetica, sans-serif;
  --addi-mono: Consolas, "Courier New", monospace;
}

#ask-ai-button[hidden],
#ask-ai-fab[hidden],
#ask-mini-bar[hidden],
#ask-modal[hidden],
#ask-modal [hidden] {
  display: none !important;
}

/* ============================================================
   2. Near-selection "✨ Ask ADDI" button
   NOTE: no `display` rule on the base selector on purpose — the
   `hidden` attribute must keep controlling visibility.
   ============================================================ */

#ask-ai-button.ask-ai-button {
  position: fixed;
  z-index: 1500;
  padding: 0.5rem 1.05rem;
  font-family: var(--addi-font);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #79edff;
  background: linear-gradient(135deg, rgba(111, 229, 255, 0.18), rgba(104, 160, 255, 0.12));
  border: 1px solid rgba(111, 229, 255, 0.45);
  border-radius: 999px;
  box-shadow: 0 8px 24px rgba(2, 7, 18, 0.5);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

#ask-ai-button.ask-ai-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 28px rgba(2, 7, 18, 0.6);
  background: linear-gradient(135deg, rgba(111, 229, 255, 0.28), rgba(104, 160, 255, 0.2));
}

#ask-ai-button.ask-ai-button:active {
  transform: translateY(0);
}

/* ============================================================
   3. Floating assistant launcher (fixed bottom-right, JS-injected)
   The button IS the logo: images/logo1.png ("ASK Addi — Your BCA
   Learning Companion"). It therefore has no chrome of its own — no
   background, no border, no text — the rounded badge in the artwork
   provides the whole silhouette, and the shadow/breathe ring follows
   it via the border-radius below.
   ============================================================ */

#ask-ai-fab.ask-ai-fab {
  --addi-fab-w: 164px; /* 600x258 artwork → ~164x70px on screen (crisp on HiDPI) */
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 1400; /* below the modal (1600), above page content */
  display: block;
  width: var(--addi-fab-w);
  padding: 0;
  background: none;
  border: 0;
  border-radius: 14px;
  box-shadow: 0 10px 26px rgba(2, 7, 18, 0.55), 0 0 0 0 rgba(111, 229, 255, 0.45);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  animation: addi-fab-breathe 3.6s ease-in-out infinite;
  transition: transform 0.16s ease, box-shadow 0.16s ease, filter 0.16s ease;
}

#ask-ai-fab.ask-ai-fab .ask-ai-fab-img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 14px;
  pointer-events: none; /* the whole badge stays one single button target */
  -webkit-user-drag: none;
}

#ask-ai-fab.ask-ai-fab:hover {
  filter: brightness(1.08);
  transform: translateY(-2px);
  box-shadow: 0 14px 30px rgba(2, 7, 18, 0.6), 0 0 0 6px rgba(111, 229, 255, 0.12);
}

#ask-ai-fab.ask-ai-fab:active {
  transform: translateY(0) scale(0.98);
}

#ask-ai-fab.ask-ai-fab:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 3px;
}

/* Hidden while the assistant window is open (full size OR minimized). */
#ask-ai-fab.ask-ai-fab.ask-ai-fab--hidden {
  display: none !important;
}

@keyframes addi-fab-breathe {
  0%, 100% { box-shadow: 0 10px 26px rgba(2, 7, 18, 0.55), 0 0 0 0 rgba(111, 229, 255, 0.45); }
  50% { box-shadow: 0 10px 26px rgba(2, 7, 18, 0.55), 0 0 0 9px rgba(111, 229, 255, 0); }
}

/* ============================================================
   4. Minimized dock chip
   Replaces the FAB while ADDI is minimized so the conversation
   stays one click away during the student's journey.
   ============================================================ */

#ask-mini-bar.ask-mini-bar {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 1590; /* above the FAB, below the open panel */
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.3rem 0.35rem 0.3rem 0.3rem;
  background: linear-gradient(180deg, rgba(14, 23, 35, 0.99), rgba(10, 17, 27, 0.99));
  border: 1px solid rgba(111, 229, 255, 0.4);
  border-radius: 999px;
  box-shadow: 0 12px 34px rgba(2, 7, 18, 0.62);
  color: var(--addi-text);
  font-family: var(--addi-font);
  animation: addi-chip-in 0.24s cubic-bezier(0.2, 0.9, 0.25, 1);
}

.ask-mini-bar-main {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0.85rem 0.4rem 0.45rem;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--addi-text);
  background: none;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.14s ease;
}

.ask-mini-bar-main:hover {
  background: rgba(111, 229, 255, 0.12);
}

.ask-mini-bar-main:focus-visible,
.ask-mini-bar-close:focus-visible {
  outline: 2px solid var(--addi-cyan);
  outline-offset: 2px;
}

.ask-mini-bar-text {
  white-space: nowrap;
}

.ask-mini-bar-close {
  width: 1.7rem;
  height: 1.7rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  font-size: 1.05rem;
  line-height: 1;
  color: var(--addi-muted);
  background: none;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.14s ease, color 0.14s ease;
}

.ask-mini-bar-close:hover {
  color: #ffffff;
  background: rgba(248, 169, 155, 0.18);
}

@keyframes addi-chip-in {
  from { opacity: 0; transform: translateY(10px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ============================================================
   5. Chat window shell (overlay, backdrop, panel)
   ============================================================ */

#ask-modal.ask-modal {
  position: fixed;
  inset: 0;
  z-index: 1600;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  font-family: var(--addi-font);
  color: var(--addi-text);
}

#ask-modal.ask-modal.open {
  display: flex;
}

.ask-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 9, 15, 0.68);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: addi-fade-in 0.18s ease;
}

/* Minimized: the page underneath stays fully usable, the window is docked. */
#ask-modal.ask-modal.open.minimized {
  pointer-events: none;
  background: none;
}

#ask-modal.ask-modal.open.minimized .ask-modal-backdrop,
#ask-modal.ask-modal.open.minimized .ask-modal-panel {
  display: none;
}

.ask-modal-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 620px;
  height: min(84vh, 720px);
  overflow: hidden;
  background: var(--addi-panel);
  border: 1px solid rgba(140, 171, 210, 0.24);
  border-radius: 20px;
  box-shadow: 0 28px 70px rgba(2, 7, 18, 0.7), 0 0 0 1px rgba(111, 229, 255, 0.06);
  animation: addi-panel-in 0.24s cubic-bezier(0.2, 0.9, 0.25, 1);
}

/* A soft cyan glow along the top edge = the signature ADDI look. */
.ask-modal-panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--addi-cyan), var(--addi-blue), transparent);
  opacity: 0.85;
}

@keyframes addi-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes addi-panel-in {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes addi-message-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes addi-dot-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* ============================================================
   6. Header — identity, live status, window controls
   ============================================================ */

.ask-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex: 0 0 auto;
  padding: 0.9rem 1rem 0.9rem 1.15rem;
  background: linear-gradient(180deg, rgba(23, 36, 54, 0.8), rgba(17, 27, 41, 0.3));
  border-bottom: 1px solid var(--addi-line);
}

.ask-modal-header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.ask-modal-header-text {
  min-width: 0;
}

.ask-modal-header-text h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #f4f8ff;
}

.ask-modal-subtitle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0.15rem 0 0;
  font-size: 0.76rem;
  color: var(--addi-muted);
  white-space: nowrap;
}

.ask-modal-status-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--addi-cyan);
  animation: addi-status-pulse 2.4s ease-out infinite;
}

.ask-modal--busy .ask-modal-status-dot {
  background: #ffd166;
  animation-duration: 1.1s;
}

@keyframes addi-status-pulse {
  0% { box-shadow: 0 0 0 0 rgba(111, 229, 255, 0.5); }
  70% { box-shadow: 0 0 0 7px rgba(111, 229, 255, 0); }
  100% { box-shadow: 0 0 0 0 rgba(111, 229, 255, 0); }
}

.ask-modal-window-controls {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex: 0 0 auto;
}

.ask-modal-window-btn {
  width: 2rem;
  height: 2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  font-size: 1rem;
  line-height: 1;
  color: #cfe0f6;
  background: rgba(15, 25, 38, 0.6);
  border: 1px solid rgba(143, 169, 206, 0.22);
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.14s ease, color 0.14s ease, border-color 0.14s ease, transform 0.14s ease;
}

.ask-modal-window-btn:hover:enabled {
  color: #ffffff;
  background: rgba(111, 229, 255, 0.16);
  border-color: rgba(111, 229, 255, 0.45);
}

.ask-modal-window-btn:active:enabled {
  transform: scale(0.94);
}

.ask-modal-window-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.ask-modal-window-btn:focus-visible {
  outline: 2px solid var(--addi-cyan);
  outline-offset: 2px;
}

.ask-modal-window-btn--close:hover:enabled {
  color: #ffffff;
  background: rgba(248, 120, 120, 0.22);
  border-color: rgba(248, 120, 120, 0.55);
}

/* --- ADDI avatar logo -----------------------------------------
   The chat window's avatar is the brand logo (images/logo1.png,
   600x258), cropped to the mascot by the rule below. ------------- */

.addi-avatar-img {
  display: block;
  width: 100%;
  height: 100%;
  /* The avatar box is square while the artwork is 600x258, so
     "cover" shows a square slice of the banner. Anchoring that
     slice to the RIGHT edge lands exactly on the mascot
     (wave, book, antenna) and leaves the wordmark out. */
  object-fit: cover;
  object-position: 100% 50%;
  border-radius: 50%;
  pointer-events: none;
  -webkit-user-drag: none;
}

.addi-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.35rem;
  height: 2.35rem;
  flex: 0 0 auto;
  font-size: 1.15rem;
  line-height: 1;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(111, 229, 255, 0.22), rgba(104, 160, 255, 0.16));
  border: 1px solid rgba(111, 229, 255, 0.45);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.addi-avatar--sm {
  width: 1.9rem;
  height: 1.9rem;
  font-size: 0.95rem;
}

/* --- Context chip ------------------------------------------- */

.ask-modal-context {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 0 0 auto;
  width: fit-content;
  max-width: calc(100% - 2.2rem);
  margin: 0.7rem 1.1rem 0;
  padding: 0.42rem 0.8rem;
  font-size: 0.78rem;
  color: #cfe6ff;
  background: rgba(111, 229, 255, 0.08);
  border: 1px solid rgba(111, 229, 255, 0.22);
  border-radius: 999px;
}

.ask-modal-context-icon {
  font-size: 0.9em;
  line-height: 1;
}

.ask-modal-context-value {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============================================================
   7. Conversation thread
   ============================================================ */

.ask-modal-thread {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1rem 1.1rem 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.ask-modal-thread::-webkit-scrollbar {
  width: 9px;
}

.ask-modal-thread::-webkit-scrollbar-track {
  background: transparent;
}

.ask-modal-thread::-webkit-scrollbar-thumb {
  background: rgba(143, 169, 206, 0.3);
  border: 2px solid transparent;
  background-clip: content-box;
  border-radius: 999px;
}

.ask-modal-thread::-webkit-scrollbar-thumb:hover {
  background: rgba(111, 229, 255, 0.45);
  background-clip: content-box;
}

/* One message row: avatar + bubble, or a right-aligned student bubble. */
.ask-ai-row {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  max-width: 100%;
  animation: addi-message-in 0.2s ease;
}

.ask-ai-row--user {
  justify-content: flex-end;
}

.addi-bubble {
  max-width: min(84%, 460px);
  padding: 0.7rem 0.9rem;
  font-size: 0.9rem;
  line-height: 1.6;
  color: rgba(238, 246, 255, 0.96);
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.addi-bubble--ai {
  background: var(--addi-bubble-ai);
  border: 1px solid var(--addi-line);
  border-left: 3px solid rgba(111, 229, 255, 0.55);
  border-radius: 4px 14px 14px 14px;
}

.addi-bubble--user {
  color: #eaf6ff;
  background: linear-gradient(135deg, rgba(111, 229, 255, 0.18), rgba(104, 160, 255, 0.15));
  border: 1px solid rgba(111, 229, 255, 0.35);
  border-radius: 14px 4px 14px 14px;
  white-space: pre-wrap;
  user-select: text;
}

.ask-modal-intro-bubble p {
  margin: 0 0 0.45rem;
}

.ask-modal-intro-bubble p:last-child {
  margin-bottom: 0;
}

/* "ADDI is typing" dots */
.addi-typing {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  padding: 0.2rem 0;
}

.addi-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--addi-cyan);
  opacity: 0.4;
  animation: addi-dot-bounce 1.1s ease-in-out infinite;
}

.addi-typing span:nth-child(2) {
  animation-delay: 0.15s;
}

.addi-typing span:nth-child(3) {
  animation-delay: 0.3s;
}

/* Selected-text card inside the thread */
.ask-modal-selection-block {
  margin: 0;
  padding: 0.7rem 0.9rem;
  background: rgba(111, 229, 255, 0.06);
  border: 1px dashed rgba(111, 229, 255, 0.32);
  border-radius: 12px;
}

.ask-modal-label {
  margin: 0 0 0.35rem;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--addi-cyan);
}

.ask-modal-text {
  margin: 0;
  font-family: var(--addi-mono);
  font-size: 0.8rem;
  line-height: 1.55;
  color: rgba(233, 241, 253, 0.9);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 20vh;
  overflow-y: auto;
}

.ask-modal-status {
  margin: 0.55rem 0 0;
  font-size: 0.85rem;
  font-style: italic;
  color: var(--addi-cyan);
}

.addi-bubble--ai .ask-modal-status:first-child {
  margin-top: 0;
}

/* ============================================================
   8. AI answer typography (Markdown → safe subset)
   Gemini sends Markdown; js/ask-ai.js escapes all values first,
   so only these structural tags are ever rendered.
   ============================================================ */

.ask-modal-answer {
  font-size: 0.9rem;
  line-height: 1.65;
}

.ask-modal-answer > *:first-child {
  margin-top: 0;
}

.ask-modal-answer > *:last-child {
  margin-bottom: 0;
}

.ask-modal-answer p {
  margin: 0 0 0.7rem;
}

.ask-modal-answer strong {
  color: #f7fbff;
  font-weight: 700;
}

.ask-modal-answer em {
  color: rgba(233, 241, 253, 0.92);
}

/* Inline code */
.ask-modal-answer code {
  font-family: var(--addi-mono);
  font-size: 0.86em;
  padding: 0.06em 0.36em;
  color: #9fe9ff;
  background: rgba(111, 229, 255, 0.1);
  border: 1px solid rgba(111, 229, 255, 0.18);
  border-radius: 4px;
  word-break: break-word;
}

/* Fenced code blocks (e.g. ```c ... ```) */
.ask-modal-answer pre.ask-ai-code {
  margin: 0 0 0.85rem;
  padding: 0.75rem 0.9rem;
  background: rgba(5, 10, 17, 0.9);
  border: 1px solid var(--addi-line);
  border-left: 3px solid rgba(111, 229, 255, 0.55);
  border-radius: 9px;
  overflow-x: auto;
  white-space: pre;
  line-height: 1.55;
}

.ask-modal-answer pre.ask-ai-code code {
  padding: 0;
  color: rgba(230, 240, 253, 0.95);
  background: none;
  border: none;
  font-size: 0.82rem;
  word-break: normal;
}

/* Headings (capped at level 4 for the narrow chat column) */
.ask-modal-answer .ask-ai-h {
  margin: 0 0 0.5rem;
  color: #f4f8ff;
  letter-spacing: -0.01em;
  line-height: 1.3;
}

.ask-modal-answer .ask-ai-h1 {
  font-size: 1.15rem;
}

.ask-modal-answer .ask-ai-h2 {
  font-size: 1.05rem;
}

.ask-modal-answer .ask-ai-h3 {
  font-size: 0.98rem;
}

.ask-modal-answer .ask-ai-h4 {
  font-size: 0.92rem;
}

/* Lists */
.ask-modal-answer ul.ask-ai-ul,
.ask-modal-answer ol.ask-ai-ol {
  margin: 0 0 0.85rem;
  padding-left: 1.3rem;
}

.ask-modal-answer ul.ask-ai-ul li,
.ask-modal-answer ol.ask-ai-ol li {
  margin: 0.15rem 0;
  color: rgba(233, 241, 253, 0.9);
}

/* Tables — Gemini often answers comparisons this way */
.ask-ai-table-wrap {
  margin: 0 0 0.85rem;
  overflow-x: auto;
  border: 1px solid var(--addi-line);
  border-radius: 10px;
}

.ask-modal-answer table.ask-ai-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

.ask-modal-answer table.ask-ai-table th,
.ask-modal-answer table.ask-ai-table td {
  padding: 0.5rem 0.7rem;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid rgba(143, 169, 206, 0.16);
}

.ask-modal-answer table.ask-ai-table th {
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--addi-cyan);
  background: rgba(111, 229, 255, 0.07);
  white-space: nowrap;
}

.ask-modal-answer table.ask-ai-table tbody tr:nth-child(even) {
  background: rgba(111, 229, 255, 0.03);
}

.ask-modal-answer table.ask-ai-table tr:last-child td {
  border-bottom: none;
}

.ask-modal-answer table.ask-ai-table code {
  white-space: nowrap;
}

/* ============================================================
   9. Footer — limit notice, composer, quick-action chips
   ============================================================ */

.ask-modal-footer {
  flex: 0 0 auto;
  padding: 0.85rem 1.1rem 1rem;
  background: linear-gradient(180deg, rgba(13, 21, 32, 0.6), rgba(9, 15, 24, 0.95));
  border-top: 1px solid var(--addi-line);
}

/* Visually hidden label — keeps the composer accessible without a caption. */
.ask-modal-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* --- Composer ------------------------------------------------ */

.ask-modal-composer {
  display: flex;
  align-items: flex-end;
  gap: 0.55rem;
  padding: 0.4rem 0.4rem 0.4rem 0.25rem;
  background: rgba(16, 25, 38, 0.9);
  border: 1px solid rgba(143, 169, 206, 0.24);
  border-radius: 16px;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.ask-modal-composer:focus-within {
  border-color: rgba(111, 229, 255, 0.6);
  box-shadow: 0 0 0 3px rgba(111, 229, 255, 0.12);
}

.ask-modal-question {
  flex: 1 1 auto;
  min-width: 0;
  max-height: 160px;
  padding: 0.5rem 0.6rem;
  font-family: var(--addi-font);
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--addi-text);
  background: none;
  border: none;
  outline: none;
  resize: none;
  overflow-y: auto;
}

.ask-modal-question::placeholder {
  color: rgba(190, 208, 230, 0.45);
}

.ask-modal-question:disabled {
  opacity: 0.6;
}

.ask-modal-send {
  width: 2.35rem;
  height: 2.35rem;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  line-height: 1;
  color: var(--addi-ink);
  background: linear-gradient(135deg, var(--addi-cyan), var(--addi-blue));
  border: 1px solid rgba(111, 229, 255, 0.8);
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.14s ease, filter 0.14s ease, box-shadow 0.14s ease;
}

.ask-modal-send:hover:enabled {
  filter: brightness(1.08);
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(111, 229, 255, 0.25);
}

.ask-modal-send:active:enabled {
  transform: scale(0.95);
}

.ask-modal-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ask-modal-send:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 2px;
}

/* --- Quick-action chips -------------------------------------- */

.ask-modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.7rem;
}

.ask-modal-mode-btn {
  padding: 0.42rem 0.85rem;
  font-family: var(--addi-font);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  color: #9fe9ff;
  background: rgba(111, 229, 255, 0.08);
  border: 1px solid rgba(111, 229, 255, 0.3);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.14s ease, transform 0.14s ease, color 0.14s ease;
}

.ask-modal-mode-btn:hover:enabled {
  color: #d8f6ff;
  background: rgba(111, 229, 255, 0.18);
  transform: translateY(-1px);
}

.ask-modal-mode-btn:active:enabled {
  transform: translateY(0);
}

/* The chip that produced the most recent reply. */
.ask-modal-mode-btn--active,
.ask-modal-mode-btn[data-active-mode]:not([data-active-mode=""]) {
  color: var(--addi-ink);
  background: linear-gradient(135deg, var(--addi-cyan), var(--addi-blue));
  border-color: rgba(111, 229, 255, 0.85);
}

.ask-modal-mode-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ask-modal-mode-btn:focus-visible {
  outline: 2px solid var(--addi-cyan);
  outline-offset: 2px;
}

/* --- Daily usage line + friendly limit notice ----------------- */

.ask-modal-usage {
  margin: 0.7rem 0 0;
  font-size: 0.74rem;
  letter-spacing: 0.01em;
  color: rgba(190, 208, 230, 0.6);
  text-align: center;
}

.ask-modal-upsell {
  display: flex;
  align-items: flex-start;
  margin-bottom: 0.7rem;
  padding: 0.6rem 0.8rem;
  font-size: 0.8rem;
  line-height: 1.5;
  color: #ffe6a7;
  background: rgba(255, 209, 102, 0.09);
  border: 1px solid rgba(255, 209, 102, 0.3);
  border-left: 3px solid rgba(255, 209, 102, 0.7);
  border-radius: 10px;
}

.ask-modal-upsell-label {
  display: block;
}

/* ============================================================
   10. Responsive + motion preferences
   ============================================================ */

@media (max-width: 640px) {
  #ask-modal.ask-modal {
    padding: 0;
    align-items: flex-end;
  }

  .ask-modal-panel {
    max-width: 100%;
    height: 92vh;
    border-radius: 18px 18px 0 0;
  }

  .ask-modal-header {
    padding: 0.85rem 0.85rem 0.85rem 0.95rem;
  }

  .ask-modal-thread {
    padding: 0.85rem 0.85rem 0.5rem;
    gap: 0.7rem;
  }

  .addi-bubble {
    max-width: 90%;
  }

  .ask-modal-footer {
    padding: 0.7rem 0.85rem 0.9rem;
  }

  .ask-modal-mode-btn {
    padding: 0.4rem 0.75rem;
    font-size: 0.75rem;
  }

  #ask-ai-fab.ask-ai-fab,
  #ask-mini-bar.ask-mini-bar {
    right: 14px;
    bottom: 16px;
  }

  /* The logo launcher scales down with the viewport so it never crowds a
     phone screen: 164px → 132px wide (≈57px tall). */
  #ask-ai-fab.ask-ai-fab {
    --addi-fab-w: 132px;
  }
}

@media (max-width: 400px) {
  .ask-modal-subtitle-text {
    display: none; /* keep just the live status dot on tiny screens */
  }
}

@media (prefers-reduced-motion: reduce) {
  #ask-ai-fab.ask-ai-fab,
  .ask-modal-panel,
  .ask-modal-backdrop,
  #ask-mini-bar.ask-mini-bar,
  .ask-ai-row,
  .ask-modal-status-dot {
    animation: none !important;
    transition: none !important;
  }

  .addi-typing span {
    animation-duration: 2.4s;
  }
}

.ask-modal-status--error {
  color: #f8a99b;
}