/* GT Standard L Extended — DXC brand header font */
@font-face {
  font-family: "GT Standard L Extended";
  src: url("/static/fonts/GT-Standard-L-Extended-Regular.otf") format("opentype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "GT Standard L Extended";
  src: url("/static/fonts/GT-Standard-L-Extended-Medium.otf") format("opentype");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "GT Standard L Extended";
  src: url("/static/fonts/GT-Standard-L-Extended-Bold.otf") format("opentype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
:root {
  color-scheme: light;
  --bg: #f6f3f0;
  --bg-image: none;
  --bg-overlay: none;
  --card: rgba(255,255,255,0.84);
  --card-strong: rgba(255,255,255,0.92);
  --modal-bg: rgba(255,255,255,0.98);
  --border: rgba(14,16,32,0.10);
  --border-strong: rgba(14,16,32,0.18);
  --text: #0e1020;
  --muted: #4a4a68;
  --accent: #004aac;
  --accent-hover: #003a8c;
  --accent-fg: #ffffff;
  --bot-bubble: rgba(255,255,255,0.92);
  --bot-avatar-bg: rgba(0,74,172,0.08);
  --welcome-surface: rgba(0,74,172,0.06);
  --welcome-border: rgba(14,16,32,0.08);
  --input-bg: rgba(255,255,255,0.88);
  --hero-shadow: 0 28px 60px rgba(14,16,32,0.10);
  --green: #1a7835;
  --error: #c53a17;
  --error-fg: #c53a17;
  --amber: #a76a00;
  --ai-1: #4995ff;
  --ai-2: #004aac;
  --ai-3: #004aac;
  --ai-4: #4995ff;
  --shadow: 0 1px 4px rgba(14,16,32,0.06);
  --shadow-md: 0 10px 30px rgba(0,0,0,0.05);
  --shadow-glass: 0 10px 30px rgba(0,0,0,0.05), inset 0 0 0 1px rgba(255,255,255,0.46);
  --focus-ring: rgba(0,74,172,0.22);
  --hover-surface: rgba(0,74,172,0.06);
  --header-glass: #0e1020;
  --header-glass-border: rgba(255,255,255,0.22);
  --avatar-size: 40px;
  --avatar-gap: 8px;
}
html.dark {
  color-scheme: dark;
  --bg: #130f0d;
  --bg-image: url("/static/img/bg-dark.png");
  --bg-overlay: linear-gradient(180deg, rgba(20,16,13,0.78) 0%, rgba(18,14,11,0.66) 24%, rgba(15,11,9,0.84) 100%);
  --card: rgba(34,25,21,0.78);
  --card-strong: rgba(40,29,24,0.88);
  --modal-bg: rgba(40,29,24,0.98);
  --border: rgba(233,176,102,0.16);
  --border-strong: rgba(233,176,102,0.30);
  --text: #f9ead6;
  --muted: #cfaf8a;
  --accent: #f1d7b2;
  --accent-hover: #f6e3c7;
  --accent-fg: #20150e;
  --bot-bubble: rgba(38, 28, 24, 0.82);
  --bot-avatar-bg: rgba(36,26,22,0.72);
  --welcome-surface: rgba(31,23,19,0.52);
  --welcome-border: rgba(233,176,102,0.14);
  --input-bg: rgba(30,22,18,0.88);
  --hero-shadow: 0 30px 72px rgba(0,0,0,0.42);
  --green: #62c784;
  --error: #f39a47;
  --error-fg: #ffd1a3;
  --amber: #f2c866;
  --ai-1: #f4d08e;
  --ai-2: #dca165;
  --ai-3: #a97448;
  --ai-4: #f9e1c2;
  --shadow: 0 14px 34px rgba(0,0,0,0.24), 0 4px 12px rgba(0,0,0,0.18);
  --shadow-md: 0 28px 60px rgba(0,0,0,0.34), 0 10px 20px rgba(0,0,0,0.22);
  --shadow-glass: 0 28px 64px rgba(0,0,0,0.30), inset 0 0 0 1px rgba(255,240,219,0.06);
  --focus-ring: rgba(241,199,138,0.18);
  --hover-surface: rgba(255,226,190,0.08);
  --header-glass: rgba(30,22,18,0.54);
  --header-glass-border: rgba(255,233,204,0.06);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg-image) center/cover fixed no-repeat, var(--bg-overlay), var(--bg);
  font-family: "Inter", Arial, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  letter-spacing: 0.005em;
}
.app {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  width: 100%;
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0));
}
/* Iframe: no body scroll, let parent handle it */
.is-iframe body { overflow: hidden; }
.is-iframe .authgate { position: absolute; }
.is-iframe header { padding: 0 16px; }

.authgate {
  position: fixed;
  inset: 0;
  background: var(--bg-image) center/cover no-repeat, var(--bg-overlay), var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
  padding: 24px;
}
.authgate .spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.authgate p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  max-width: 320px;
}
/* --- OASIS glass header --- */
header {
  position: relative;
  z-index: 30;
  padding: 0 24px;
  height: 56px;
  border-bottom: none;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--header-glass);
  color: #ffffff;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  box-shadow: none;
  flex: 0 0 auto;
  transition: background 0.2s;
}
header .logo-mark {
  height: 40px;
  width: auto;
  flex: 0 0 auto;
  display: block;
  object-fit: contain;
}
header .header-divider {
  width: 1px;
  height: 24px;
  background: rgba(255,255,255,0.18);
  flex: 0 0 auto;
  margin: 0 2px;
}
header .dot {
  position: relative;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  flex: 0 0 auto;
  cursor: help;
}
header .dot.healthy {
  background: var(--green);
}
header .dot.healthy::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--green);
  animation: dotPulse 2.4s ease-out infinite;
}
header .dot.degraded {
  background: var(--error);
}
@keyframes dotPulse {
  0% { transform: scale(1); opacity: 0.55; }
  70%, 100% { transform: scale(2.8); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  header .dot.healthy::after { animation: none; }
}
header h1 {
  font-family: "GT Standard L Extended", Inter, Arial, sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: #ffffff;
  margin: 0;
  white-space: nowrap;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
header h1 .title-short { display: none; }
header h1 .title-full { display: inline; }
/* Help action label: full text on desktop, short "About me" on mobile. */
.input-action .help-short { display: none; }
.input-action .help-full { display: inline; }
.header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.header-actions .who {
  display: none;
  font-size: 12px;
  color: rgba(255,255,255,0.55);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}
.header-btn {
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.85);
  border: 1px solid rgba(255,255,255,0.22);
  padding: 0 12px;
  height: 32px;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  border-radius: 999px;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.18s ease;
}
.header-btn:hover:not(:disabled) { background: rgba(255,255,255,0.16); color: #ffffff; border-color: rgba(255,255,255,0.4); transform: translateY(-1px); }
.header-btn:active:not(:disabled) { transform: translateY(0); }
/* Icon button: matches the SVG icon language used across the app instead of a
   bare text glyph. Square, with a centered 20px glyph. */
.menu-btn { display: inline-flex; align-items: center; justify-content: center; padding: 5px; width: 32px; height: 32px; }
.menu-btn svg { width: 18px; height: 18px; display: block; }

/* Language button shows the current language's native name next to the globe icon, so it
   doesn't stay icon-only/square like the plain menu-btn (triple-dot) button. */
.lang-btn { width: auto; justify-content: flex-start; gap: 6px; padding: 5px 10px 5px 8px; }
.lang-btn-label { font-size: 12px; font-weight: 600; white-space: nowrap; }

/* Highlights the currently active language in the language dropdown. */
.dropdown-item.lang-current { background: var(--hover-surface); font-weight: 700; }

/* --- Theme switch (light/dark) --- */
.theme-switch {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  flex: 0 0 auto;
}
.theme-switch input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}
.theme-switch-track {
  width: 34px;
  height: 19px;
  border-radius: 999px;
  background: var(--border-strong);
  position: relative;
  transition: background 0.2s;
  flex: 0 0 auto;
}
.theme-switch input:checked + .theme-switch-track { background: var(--accent); }
.theme-switch-thumb {
  position: absolute;
  left: 2px;
  top: 2px;
  width: 15px;
  height: 15px;
  border-radius: 999px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  line-height: 1;
  transition: transform 0.2s, background 0.2s;
}
.theme-switch input:checked + .theme-switch-track .theme-switch-thumb {
  transform: translateX(15px);
  background: var(--accent-fg);
}
.theme-switch input:focus-visible + .theme-switch-track { box-shadow: 0 0 0 3px var(--focus-ring); }

/* --- Chat area (centered, Copilot-style) --- */
.chat-area {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0));
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.chat-area .spacer-top {
  flex: 1;
  align-self: stretch;
  width: 100%;
  min-height: 40px;
}
/* Breathing room above the composer when scrolled to the latest message. */
.chat-area .spacer-bottom {
  flex: 0 0 auto;
  align-self: stretch;
  width: 100%;
  height: 52px;
  min-height: 52px;
}
/* Welcome: equal flex spacers so the homepage block is centered (pre-fade layout). */
.chat-area:has(#welcomeScreen) .spacer-bottom {
  flex: 1 1 auto;
  height: auto;
  min-height: 40px;
}
.chat-inner {
  box-sizing: border-box;
  max-width: 820px;
  width: 100%;
  margin: 0;
  padding: 0 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
/* Composer lives in welcome on homepage — collapse empty dock so centering isn't skewed. */
.input-dock:not(:has(.input-area)) {
  height: 0;
  min-height: 0;
  padding: 0;
  overflow: hidden;
}
#log {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.msg {
  min-width: 0;
  padding: 10px 15px;
  border-radius: 14px;
  line-height: 1.5;
  font-size: 14px;
  white-space: pre-wrap;
  word-wrap: break-word;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: msgIn 0.28s cubic-bezier(0.2, 0, 0, 1);
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
/* Sender labels are visually redundant (avatar + alignment convey it) but kept for screen readers. */
.msg .who {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.msg-row {
  display: flex;
  align-items: flex-start;
  gap: var(--avatar-gap);
  max-width: 78%;
  animation: msgIn 0.25s ease-out;
}
.msg-row.bot { align-self: flex-start; overflow: visible; }
/* WW: Consecutive same-sender messages group tighter */
.msg-row.bot + .msg-row.bot { margin-top: -6px; }
.msg-row.bot + .msg-row.bot .msg-avatar { visibility: hidden; }
.msg.bot {
  position: relative;
  overflow: visible;
  background: var(--bot-bubble);
  color: var(--text);
  border-radius: 14px;
  border-bottom-left-radius: 5px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--ai-2);
  box-shadow: var(--shadow);
}
.msg-stack {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
  overflow: visible;
}
.msg-stack .msg { flex: 0 1 auto; animation: none; }
.msg-footer {
  display: flex;
  flex-direction: row;
  align-items: center;
  min-height: 28px;
  padding: 0 2px;
}
/* Sibling of the bubble — inside .msg it gets clipped by backdrop-filter. */
.msg-rating-mark {
  position: absolute;
  top: 0;
  left: 16px;
  z-index: 3;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--card-strong);
  color: var(--muted);
  box-shadow: var(--shadow);
  pointer-events: none;
  transform: translateY(-50%);
}
.msg-rating-mark[hidden] { display: none !important; }
.msg-rating-mark svg { width: 12px; height: 12px; display: block; }
.msg-rating-mark.liked {
  color: var(--green);
  border-color: color-mix(in srgb, var(--green) 45%, var(--border));
  background: color-mix(in srgb, var(--green) 16%, var(--card-strong));
}
.msg-rating-mark.disliked {
  color: var(--error);
  border-color: color-mix(in srgb, var(--error) 45%, var(--border));
  background: color-mix(in srgb, var(--error) 16%, var(--card-strong));
}
.msg-rating-mark.reported {
  color: var(--amber);
  border-color: color-mix(in srgb, var(--amber) 45%, var(--border));
  background: color-mix(in srgb, var(--amber) 16%, var(--card-strong));
}
.msg-actions {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.15s;
}
.msg-row.bot:hover .msg-actions,
.msg-actions:focus-within,
.msg-actions.speaking { opacity: 1; }
.msg-actions .msg-action {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: transparent;
  box-shadow: none;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: color 0.15s, background 0.15s;
}
/* Beat global `button:hover:not(:disabled)` accent fill. */
.msg-row .msg-action:hover {
  color: var(--text);
  background: var(--hover-surface);
  border: none;
  box-shadow: none;
}
.msg-action:focus-visible {
  outline: 2px solid var(--border-strong);
  outline-offset: 1px;
}
.msg-action svg { width: 16px; height: 16px; display: block; }
.msg-action.active-like { color: var(--green); background: color-mix(in srgb, var(--green) 12%, transparent); }
.msg-action.active-dislike { color: var(--error); background: color-mix(in srgb, var(--error) 12%, transparent); }
.msg-action.active-speak { color: var(--text); background: var(--hover-surface); }
.msg-action.copy-btn.copied { color: var(--green); background: color-mix(in srgb, var(--green) 12%, transparent); }
.msg-stack > .quick-replies {
  margin: 4px 0 2px;
  margin-left: 0;
  align-self: stretch;
}
@media (hover: none) {
  .msg-actions { opacity: 0.7; }
}
/* N: Message timestamps — visible by default, hidden on hover when action menu appears */
.msg-ts {
  font-size: 10px;
  color: var(--muted);
  opacity: 0.6;
  padding: 0 2px;
  white-space: nowrap;
  transition: opacity 0.15s;
}
.msg-row.bot:hover .msg-ts { opacity: 0; }
/* User-side timestamps: right-aligned, direct child of #log */
#log > .msg-ts { align-self: flex-end; padding-right: 4px; }
/* TT: Delivery checkmark on user timestamps */
#log > .msg-ts { display: flex; align-items: center; gap: 3px; justify-content: flex-end; }
.msg-ts .delivered-check { color: var(--green); display: none; }
.msg-ts .delivered-check.show { display: inline-block; }
/* Inside msg-footer: sits after actions, pushed right */
.msg-footer .msg-ts { margin-left: auto; }
.msg-avatar {
  flex: 0 0 auto;
  width: var(--avatar-size);
  height: var(--avatar-size);
  margin-top: 1px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--bot-avatar-bg);
  border: 1px solid rgba(255,255,255,0.20);
  box-shadow: var(--shadow);
}
.msg-avatar img { width: 90%; height: 90%; display: block; }
.msg.you {
  align-self: flex-end;
  max-width: 78%;
  background: var(--accent);
  color: var(--accent-fg);
  border-radius: 14px;
  border-bottom-right-radius: 5px;
  box-shadow: var(--shadow);
}
.msg.bot {
  background: var(--bot-bubble);
  color: var(--text);
  border-radius: 14px;
  border-bottom-left-radius: 5px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--ai-2);
  box-shadow: var(--shadow);
}
.msg.bot.muted {
  color: var(--muted);
  border-style: dashed;
  border-left-color: var(--border);
}
.msg-row.bot:has(.msg.bot.muted) .msg-avatar { opacity: 0.5; }
html.dark .msg.bot.muted {
  color: #d9c3a8;
  border-color: rgba(233,176,102,0.22);
}
/* Safety decline bubble: distinct from `muted` (which means "chat closed"). Darker dashed
   border and a slightly darker text than plain muted; avatar is NOT dimmed. */
.msg.bot.muted-rejection {
  color: color-mix(in srgb, var(--text) 78%, var(--muted));
  border-style: dashed;
  border-width: 1.5px;
  border-color: color-mix(in srgb, var(--amber) 45%, var(--border-strong));
  border-left: 3px solid var(--amber);
  background: color-mix(in srgb, var(--amber) 7%, var(--bot-bubble));
}
html.dark .msg.bot.muted-rejection {
  color: #e7d3b4;
  border-color: color-mix(in srgb, var(--amber) 40%, var(--border-strong));
  border-left-color: var(--amber);
  background: color-mix(in srgb, var(--amber) 14%, var(--bot-bubble));
}
.msg.bot.error {
  color: var(--error-fg);
  border-color: color-mix(in srgb, var(--error) 50%, var(--border));
  background: color-mix(in srgb, var(--error) 14%, var(--bot-bubble));
}
html.dark .msg.bot.error {
  color: var(--error-fg);
  border-color: color-mix(in srgb, var(--error) 40%, var(--border));
  background: color-mix(in srgb, var(--error) 18%, var(--bot-bubble));
}
.msg.bot.partial {
  border-style: dashed;
  opacity: 0.96;
}
.msg.bot.warning {
  color: var(--amber);
  border-style: dashed;
  border-color: color-mix(in srgb, var(--amber) 55%, var(--border));
  background: color-mix(in srgb, var(--amber) 12%, var(--bot-bubble));
}
html.dark .msg.bot.warning {
  border-color: color-mix(in srgb, var(--amber) 45%, var(--border));
  background: color-mix(in srgb, var(--amber) 18%, var(--bot-bubble));
}
/* Report ("not harmful") action on safety-blocked bubbles — always visible (the footer is not
   hover-gated for these muted bubbles) and turns amber once submitted. */
.msg-actions.msg-report { opacity: 1; }
.report-btn.active-report,
.report-btn[data-done="1"] { color: var(--amber); cursor: default; }
.msg.you.failed {
  outline: 2px solid color-mix(in srgb, var(--error) 55%, transparent);
  outline-offset: 2px;
  opacity: 0.92;
  position: relative;
}
.msg.you.failed::after {
  content: "!";
  position: absolute;
  top: -7px;
  right: -7px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--error);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px rgba(0,0,0,0.18);
}
/* Blocked customer message (safety decline / invalidate): amber warning outline + badge.
   Distinct from `.failed` (red, transient network-retry marker that is stripped on next send). */
.msg.you.warning {
  outline: 2px solid color-mix(in srgb, var(--amber) 60%, transparent);
  outline-offset: 2px;
  opacity: 0.94;
  position: relative;
}
.msg.you.warning::after {
  content: "!";
  position: absolute;
  top: -7px;
  right: -7px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--amber);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px rgba(0,0,0,0.18);
}
.msg-partial-meta,
.msg-retry-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 2px 0 4px;
  padding: 0 2px;
}
.msg-retry-wrap {
  align-self: flex-end;
  max-width: 78%;
}
.msg-stopped-marker {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 6px;
  padding: 3px 10px 3px 8px;
  border-radius: 6px;
  background: var(--hover-surface);
  border: 1px solid var(--border);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--muted);
}
.msg-stopped-marker::before {
  content: "";
  display: block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--muted);
  flex-shrink: 0;
}
.msg-retry-btn {
  border: 1px solid var(--border-strong);
  background: var(--card-strong);
  color: var(--text);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.msg-retry-btn:hover:not(:disabled) {
  background: var(--hover-surface);
  border-color: var(--accent);
}
.msg-retry-btn:focus-visible {
  outline: 2px solid var(--border-strong);
  outline-offset: 1px;
}
.msg.status {
  background: color-mix(in srgb, var(--bot-bubble) 72%, transparent);
  color: var(--muted);
  border: 1px solid transparent;
  border-radius: 14px;
  border-bottom-left-radius: 5px;
  box-shadow: none;
  padding: 6px 12px;
  font-style: normal;
  font-size: 12.5px;
}
.msg.status.typing {
  background: color-mix(in srgb, var(--bot-bubble) 72%, transparent);
  border: 1px solid transparent;
  box-shadow: none;
  padding: 6px 12px;
  font-size: 12.5px;
}
.msg.status.typing .who,
.msg.status .who { display: none; }
/* Status/typing bubbles are much shorter than the 40px avatar - center them
   against it instead of top-aligning, so the avatar doesn't tower beneath. */
.msg-row:has(> .msg.status) { align-items: center; }
/* While deltas stream, aria-busy suppresses polite live-region chatter from #log.
   Keep a small min height so an empty first frame doesn't collapse the bubble. */
.msg.bot[aria-busy="true"] {
  min-height: 1.25em;
}
.msg.bot[aria-busy="true"] > .msg-body {
  min-height: 1.25em;
}
.msg.bot[aria-busy="true"] > .msg-body:empty::after {
  content: "";
  display: inline-block;
  width: 0.55em;
  height: 1em;
  vertical-align: -0.15em;
  border-radius: 1px;
  background: currentColor;
  opacity: 0.35;
  animation: stream-caret 1s steps(1) infinite;
}
@keyframes stream-caret {
  50% { opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .msg.bot[aria-busy="true"] > .msg-body:empty::after { animation: none; opacity: 0.45; }
}
.status-loader {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.status-loader-text {
  line-height: 1.35;
  color: var(--muted);
  font-weight: 500;
}
.typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 0;
}
.typing-dots span {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--muted);
  animation: dotBounce 1.3s ease-in-out infinite;
}
.typing-dots span:nth-child(1) { animation-delay: 0s; }
.typing-dots span:nth-child(2) { animation-delay: 0.18s; }
.typing-dots span:nth-child(3) { animation-delay: 0.36s; }
@keyframes dotBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.35; }
  30% { transform: translateY(-4px); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .typing-dots span { animation: none; opacity: 0.6; }
}

/* --- Quick reply chips --- */
.quick-replies {
  align-self: flex-start;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: -2px 0 2px;
  /* Lines up with the bubble's left edge in a .msg-row, not the log's own edge - the
     preceding bot bubble is indented past the avatar badge. */
  margin-left: calc(var(--avatar-size) + var(--avatar-gap));
  animation: msgIn 0.25s ease-out;
}
.quick-reply {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--card-strong);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 15px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.quick-reply:active:not(:disabled) { transform: scale(0.97); }
.quick-reply .qr-icon {
  display: inline-flex;
  color: var(--muted);
  flex: 0 0 auto;
}
.quick-reply .qr-icon svg { width: 13px; height: 13px; display: block; }
.quick-reply:hover:not(:disabled) {
  /* Keep an opaque fill — --hover-surface alone is translucent and looks washed out. */
  background: color-mix(in srgb, var(--text) 7%, var(--card-strong));
  border-color: var(--border-strong);
}
.quick-reply:hover:not(:disabled) .qr-icon { color: var(--text); }
.quick-reply.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.quick-reply.primary .qr-icon { color: var(--accent-fg); }
.quick-reply.primary:hover:not(:disabled) { background: var(--accent-hover); color: var(--accent-fg); }
.quick-reply.primary:hover:not(:disabled) .qr-icon { color: var(--accent-fg); }
/* Centered quick-reply rows (e.g. closed-chat actions). */
.quick-replies.centered { align-self: center; justify-content: center; margin-left: 0; }

/* --- Triple-dot menu --- */
.menu-container { position: relative; }
.dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 6px;
  background: var(--card-strong);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-md), 0 12px 28px rgba(18,18,18,0.14);
  padding: 5px;
  min-width: 212px;
  z-index: 40;
  transform-origin: top right;
  animation: dropdownIn 0.16s cubic-bezier(0.2, 0, 0, 1);
}
@keyframes dropdownIn {
  from { opacity: 0; transform: scale(0.94) translateY(-4px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .dropdown-menu { animation: none; }
}
.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  background: transparent;
  color: var(--text);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
}
.di-icon {
  display: inline-flex;
  flex: 0 0 auto;
  color: var(--muted);
}
.di-icon svg { width: 16px; height: 16px; display: block; }
button.dropdown-item:hover:not(:disabled) { background: var(--hover-surface); color: var(--text); }
button.dropdown-item:hover:not(:disabled) .di-icon { color: var(--text); }
.dropdown-divider { height: 1px; background: var(--border); margin: 5px 8px; }
.dropdown-switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
}
.dropdown-switch-row .di-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.dropdown-switch-row:hover { background: var(--hover-surface); }

/* --- Inline formatting inside bot replies --- */
.msg strong { font-weight: 700; }
.msg em { font-style: italic; }
.msg a { color: inherit; text-decoration: underline; }
/* G: Bot links use the warm accent so they're clearly clickable */
.msg.bot a { color: var(--ai-3); text-decoration: none; transition: color 0.18s ease; }
html.dark .msg.bot a { color: var(--ai-4); }
.msg.bot a:hover { color: var(--text); }
.msg code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9em;
  background: rgba(119,86,46,0.08);
  border: 1px solid rgba(119,86,46,0.12);
  padding: 1px 6px;
  border-radius: 5px;
}
html.dark .msg code { background: rgba(233,176,102,0.10); border-color: rgba(233,176,102,0.12); }
.msg.you code, .msg.you a { color: #fff; }
.msg.you code { background: rgba(255,255,255,0.22); }

/* Bot bubbles now render structured HTML (paragraphs + lists) from formatMarkdown,
   so spacing comes from block elements rather than literal newlines. Turn off the
   inherited pre-wrap for bot bubbles only - user bubbles still rely on it. */
.msg.bot { white-space: normal; }
.msg.bot > .msg-body { display: block; }
.msg.bot > span { display: block; }
.msg.bot p { margin: 0 0 10px; }
.msg.bot p:last-child { margin-bottom: 0; }

/* Numbered procedures: hanging indent via a chip marker, so wrapped lines align
   under the text rather than under the number. */
.msg.bot ol.md-list {
  list-style: none;
  margin: 4px 0 10px;
  padding: 0;
  counter-reset: md-step;
}
.msg.bot ol.md-list > li {
  counter-increment: md-step;
  position: relative;
  padding-left: 30px;
  margin: 0 0 9px;
}
.msg.bot ol.md-list > li:last-child { margin-bottom: 0; }
.msg.bot ol.md-list > li::before {
  content: counter(md-step);
  position: absolute;
  left: 0;
  top: 0.05em;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  background: rgba(241,197,107,0.18);
  border: 1px solid rgba(204,138,77,0.25);
  color: var(--ai-3);
  font-size: 11.5px;
  font-weight: 700;
  line-height: 21px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
html.dark .msg.bot ol.md-list > li::before { background: rgba(241,199,138,0.14); border-color: rgba(241,199,138,0.22); color: var(--ai-4); }
.msg.bot ul.md-list {
  margin: 4px 0 10px;
  padding-left: 22px;
  list-style: disc outside;
}
.msg.bot ul.md-list > li { margin: 0 0 6px; }
.msg.bot ul.md-list > li::marker { color: var(--ai-2); }
.msg.bot ul.md-list > li:last-child { margin-bottom: 0; }

/* Sub-bullets under a numbered step: subtle left rail, quieter text. */
.msg.bot ul.md-sub {
  list-style: none;
  margin: 7px 0 0;
  padding: 0 0 0 2px;
  border-left: 2px solid var(--ai-2);
}
.msg.bot ul.md-sub > li {
  margin: 0;
  padding: 2px 0 2px 11px;
  color: var(--muted);
  font-size: 0.95em;
}

/* Nav-path chips: **Help -> License -> Register Online** reads as a real UI path. */
.msg.bot kbd {
  font-family: inherit;
  font-size: 0.86em;
  font-weight: 600;
  background: rgba(241,197,107,0.15);
  border: 1px solid rgba(204,138,77,0.22);
  border-bottom-width: 2px;
  border-radius: 6px;
  padding: 1px 7px;
  color: var(--ai-3);
  white-space: nowrap;
}
html.dark .msg.bot kbd { background: rgba(241,199,138,0.12); border-color: rgba(241,199,138,0.18); color: var(--ai-4); }
.msg.bot .kbd-sep { color: var(--ai-2); margin: 0 4px; font-size: 0.9em; }

/* Source attribution: small labeled chip instead of a floating italic parenthetical. */
.msg.bot .md-source {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 10px;
  font-size: 0.86em;
  color: var(--muted);
}
.msg.bot .md-source-tag {
  flex: 0 0 auto;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-size: 0.82em;
  font-weight: 700;
  color: var(--muted);
  background: var(--card-strong);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 5px;
}

/* Markdown table: responsive wrap + themed styling. */
.msg.bot .md-table-wrap {
  overflow-x: auto;
  margin: 6px 0;
  -webkit-overflow-scrolling: touch;
}
.msg.bot .md-table {
  border-collapse: collapse;
  font-size: 0.88em;
  width: 100%;
  min-width: 280px;
}
.msg.bot .md-table th,
.msg.bot .md-table td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: left;
  vertical-align: top;
}
.msg.bot .md-table th {
  background: var(--hover-surface);
  font-weight: 600;
  white-space: nowrap;
}
.msg.bot .md-table tr:nth-child(even) td {
  background: color-mix(in srgb, var(--hover-surface) 40%, transparent);
}
html.dark .msg.bot .md-table th { background: var(--hover-surface); }
html.dark .msg.bot .md-table tr:nth-child(even) td {
  background: color-mix(in srgb, var(--hover-surface) 30%, transparent);
}

/* Miss/hit disclosure: articles consulted — collapsed toggle. */
.msg.bot .md-checked-articles {
  margin: 8px 0 4px;
  padding: 0;
}
button.md-checked-toggle,
button.md-checked-toggle:hover:not(:disabled),
button.md-checked-toggle:active:not(:disabled),
button.md-checked-toggle:focus:not(:disabled) {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 4px 8px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--ai-3);
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: none;
  transform: none;
}
button.md-checked-toggle:hover:not(:disabled) {
  color: var(--text);
  background: var(--hover-surface);
}
button.md-checked-toggle:focus-visible {
  outline: 2px solid var(--border-strong);
  outline-offset: 1px;
}
.md-checked-toggle::before {
  content: "";
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 4px 0 4px 6px;
  border-color: transparent transparent transparent currentColor;
  transition: transform 0.15s ease;
  flex: 0 0 auto;
}
.md-checked-toggle[aria-expanded="true"]::before {
  transform: rotate(90deg);
}
html[dir="rtl"] .md-checked-toggle::before {
  border-width: 4px 6px 4px 0;
  border-color: transparent currentColor transparent transparent;
}
html[dir="rtl"] .md-checked-toggle[aria-expanded="true"]::before {
  transform: rotate(-90deg);
}
.md-checked-list {
  list-style: none;
  margin: 0;
  padding: 0 10px;
  display: flex;
  flex-direction: column;
  gap: 0;
  border-radius: 10px;
  background: color-mix(in srgb, var(--card-strong) 70%, transparent);
  border: 1px solid transparent;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition:
    max-height 0.22s ease,
    opacity 0.18s ease,
    padding 0.22s ease,
    margin 0.22s ease,
    border-color 0.18s ease;
}
.md-checked-list.is-open {
  max-height: 16rem;
  opacity: 1;
  margin: 4px 0 0;
  padding: 8px 10px;
  border-color: var(--border);
  background: color-mix(in srgb, var(--accent) 8%, var(--card-strong));
}
.md-checked-list[hidden] {
  display: flex !important;
}
.md-checked-row {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
  align-items: start;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 8px;
  font-size: 12px;
  color: var(--text);
  line-height: 1.35;
  transition:
    background-color 0.18s ease,
    box-shadow 0.18s ease;
}
/* Whole row lifts on hover (works whether the label is a link or plain span). */
.md-checked-row:has(a.md-checked-label):hover {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
}
.md-checked-mark {
  width: 6px;
  height: 6px;
  margin-top: 0.45em;
  border-radius: 50%;
  background: color-mix(in srgb, var(--muted) 55%, transparent);
  justify-self: center;
  transition:
    background-color 0.18s ease,
    transform 0.18s ease;
}
.md-checked-row:first-child .md-checked-mark {
  background: var(--text);
  opacity: 0.55;
}
.md-checked-row:has(a.md-checked-label):hover .md-checked-mark {
  background: var(--ai-3);
  opacity: 1;
  transform: scale(1.25);
}
html.dark .md-checked-row:has(a.md-checked-label):hover .md-checked-mark {
  background: var(--ai-4);
}
.md-checked-label {
  min-width: 0;
  overflow-wrap: anywhere;
  text-decoration: none;
  transition: color 0.18s ease;
}
/* Citation chips: clickable blue, no default underline (the row/dot frame the item).
   Raise specificity to beat the generic `.msg.bot a` link styling. */
.msg.bot a.md-checked-label {
  color: var(--ai-3);
  text-decoration: none;
}
html.dark .msg.bot a.md-checked-label {
  color: var(--ai-4);
}
.msg.bot .md-checked-row:hover a.md-checked-label {
  color: color-mix(in srgb, var(--ai-3) 80%, #000);
}
html.dark .msg.bot .md-checked-row:hover a.md-checked-label {
  color: color-mix(in srgb, var(--ai-4) 80%, #fff);
}
span.md-checked-label {
  color: inherit;
}
@media (prefers-reduced-motion: reduce) {
  .md-checked-row,
  .md-checked-mark,
  .md-checked-label {
    transition: none;
  }
}

/* --- Welcome screen --- */
.welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  width: 100%;
  min-width: 0;
  padding: 24px 0 12px;
  animation: msgIn 0.35s ease-out;
}
.welcome .icon {
  width: 72px;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
  border-radius: 16px;
  background: var(--bot-avatar-bg);
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: msgIn 0.4s ease-out;
}
.welcome .icon img { width: 80%; height: 80%; display: block; }
.welcome h2 {
  font-family: "GT Standard L Extended", Inter, Arial, sans-serif;
  font-size: 26px;
  font-weight: 700;
  margin: 0 0 8px;
  color: var(--accent);
  text-shadow: none;
  letter-spacing: 0.03em;
  min-height: 1.2em;
}
.welcome p {
  font-size: 15px;
  color: var(--muted);
  line-height: 1.55;
  margin: 0 0 18px;
  width: 100%;
  max-width: 440px;
  animation: msgIn 0.4s ease-out 0.1s backwards;
}

/* --- Input area --- */
.input-dock {
  flex: 0 0 auto;
  position: relative;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
/* Soft dissolve into the composer when scrolled up — short band, not a tall veil. */
.chat-fade {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 100%;
  width: min(820px, calc(100% - 32px));
  height: 28px;
  pointer-events: none;
  z-index: 15;
  opacity: 0;
  transition: opacity 0.2s ease;
  background: linear-gradient(
    to bottom,
    transparent 0%,
    color-mix(in srgb, var(--bg) 70%, transparent) 100%
  );
  -webkit-mask-image: linear-gradient(to right, transparent 0%, black 15%, black 85%, transparent 100%);
  mask-image: linear-gradient(to right, transparent 0%, black 15%, black 85%, transparent 100%);
}
.input-dock.scrolled-up .chat-fade { opacity: 1; }
.input-area {
  position: relative;
  flex: 0 0 auto;
  padding: 0 24px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.welcome .input-area { width: 100%; min-width: 0; padding: 0; gap: 10px; }
.welcome .scroll-bottom,
.welcome .chat-fade { display: none; }
.welcome .input-area .disclaimer { display: none; }

/* --- Persistent input-action bar (Product + Help) --- */
.input-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 8px;
  max-width: 820px;
  width: 100%;
}
.welcome .input-actions { justify-content: center; }
.input-action {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card-strong);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.18s ease;
  box-shadow: var(--shadow);
}
.input-action:hover:not(:disabled) {
  background: color-mix(in srgb, var(--accent) 6%, var(--card-strong));
  border-color: var(--border-strong);
  transform: translateY(-1px);
}
.input-action:active:not(:disabled) { transform: translateY(0); }
.input-action:disabled { opacity: 0.45; cursor: default; }
.input-action-label { color: var(--muted); }
.input-action-value { font-weight: 600; }
.input-action svg { flex: 0 0 auto; display: inline-block; vertical-align: -2px; }

/* Product dropdown from action button */
.action-product-wrap { position: relative; }
.action-product-menu {
  position: absolute;
  bottom: 100%;
  left: 0;
  margin-bottom: 6px;
  background: var(--card-strong);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-md), 0 12px 28px rgba(18,18,18,0.14);
  padding: 5px;
  min-width: 180px;
  z-index: 40;
  animation: dropdownIn 0.16s cubic-bezier(0.2, 0, 0, 1);
}
.action-product-menu .dropdown-item.product-current {
  background: var(--hover-surface);
  font-weight: 700;
}

/* Decorative per-product icon rendered to the right of the product name. */
.product-icon {
  width: 16px;
  height: 16px;
  vertical-align: middle;
  margin-left: 6px;
}
/* In the product dropdown, push the icon to the row's right edge so icons align
   regardless of product-name length. */
.action-product-menu .dropdown-item .product-icon { margin-left: auto; }

.input-shell {
  max-width: 820px;
  width: 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}
.char-count {
  font-size: 10.5px;
  line-height: 1.2;
  color: var(--muted);
  padding-right: 4px;
  font-variant-numeric: tabular-nums;
}
.char-count.near-limit { color: var(--amber); font-weight: 600; }
.char-count.at-limit { color: var(--error); font-weight: 600; }
/* Scroll-to-bottom: simple centered arrow over the fade. */
.scroll-bottom {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  transform: translateX(-50%) translateY(8px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  background: color-mix(in srgb, var(--card-strong) 88%, transparent);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  border-radius: 50%;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease, background 0.15s ease, border-color 0.15s ease;
  z-index: 20;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.scroll-bottom.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}
.input-area .scroll-bottom:hover {
  background: var(--hover-surface);
  border-color: var(--border-strong);
}
.scroll-bottom svg { width: 16px; height: 16px; display: block; }
.input-area .disclaimer {
  font-size: 10.5px;
  line-height: 1.2;
  padding-top: 2px;
  color: var(--muted);
  text-align: center;
  max-width: 820px;
  width: 100%;
  margin: 0;
}
form#form {
  max-width: 820px;
  width: 100%;
  display: flex;
  gap: 6px;
  align-items: flex-end;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 8px 10px;
  box-shadow: var(--shadow-md);
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
form#form:hover:not(:focus-within) { border-color: var(--border-strong); box-shadow: var(--shadow-md); }
form#form:focus-within {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}
.composer-product {
  display: none !important;
  flex: 0 1 auto;
  align-self: center;
  max-width: 10.5rem;
  min-width: 4.75rem;
  width: max-content;
  height: 36px;
  margin: 0;
  padding: 0 1.75rem 0 12px;
  border: 1px solid transparent;
  border-radius: 12px;
  background-color: transparent;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none'%3E%3Cpath d='M6 9l6 6 6-6' stroke='%238a8378' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.55rem center;
  background-size: 12px;
  color: var(--muted);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.2;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  transition: color 0.15s, background-color 0.15s, border-color 0.15s;
}
.composer-product:hover:not(:disabled) {
  color: var(--text);
  background-color: var(--hover-surface);
  border-color: var(--border);
}
.composer-product:focus-visible {
  outline: none;
  color: var(--text);
  border-color: var(--border-strong);
  box-shadow: 0 0 0 1px var(--focus-ring);
}
.composer-product:disabled {
  opacity: 0.45;
  cursor: default;
}
html.dark .composer-product {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none'%3E%3Cpath d='M6 9l6 6 6-6' stroke='%23b8b0a4' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
#msg {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  align-self: center;
  padding: 9px 4px 9px 10px;
  font-size: 14px;
  color: var(--text);
  outline: none;
  font-family: inherit;
  line-height: 1.45;
  resize: none;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
  min-height: 38px;
  max-height: 120px;
}
#msg::placeholder { color: var(--muted); opacity: 1; }
/* Faded look while the composer is disabled (bot responding / chat locked):
   dims both the "Responding..." value and the "Type a message..." placeholder. */
#msg:disabled { color: var(--muted); opacity: 0.6; }
#msg:disabled::placeholder { color: var(--muted); opacity: 0.6; }
.mic-btn {
  position: relative;
  border: none;
  background: transparent;
  color: var(--muted);
  width: 38px;
  height: 38px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  padding: 0;
}
.mic-btn:hover:not(:disabled) { background: var(--hover-surface); color: var(--text); }
.mic-btn:disabled { opacity: 0.4; cursor: default; }
.mic-btn svg { width: 18px; height: 18px; display: block; }
.mic-btn.recording { color: var(--error); }
.mic-btn.recording::after {
  content: "";
  position: absolute;
  top: 4px;
  right: 4px;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--error);
  animation: micPulse 1.1s ease-in-out infinite;
}
@keyframes micPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(1.4); }
}
@media (prefers-reduced-motion: reduce) {
  .mic-btn.recording::after { animation: none; }
}
#send {
  border: none;
  background: var(--accent);
  color: var(--accent-fg);
  width: 38px;
  height: 38px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.12s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  padding: 0;
  position: relative;
  overflow: hidden;
}
/* 1: Warm glow on send button when textarea has content */
form#form:has(#msg:not(:placeholder-shown)) #send:not(:disabled) { box-shadow: 0 0 0 3px var(--focus-ring), 0 0 10px var(--focus-ring); }
#send:hover:not(:disabled) { background: var(--accent-hover); }
#send:active:not(:disabled) { transform: scale(0.96); }
#send:disabled { opacity: 0.4; cursor: default; }
#send .icon-send,
#send .icon-stop {
  position: absolute;
  width: 18px;
  height: 18px;
  fill: currentColor;
  display: block;
  transition: opacity 0.15s ease;
  pointer-events: none;
}
#send .icon-send { opacity: 1; }
#send .icon-stop {
  opacity: 0;
  width: 14px;
  height: 14px;
}
/* In-flight: same accent chip, glyph only — plane fades out, stop square fades in. */
#send.stop-mode .icon-send { opacity: 0; }
#send.stop-mode .icon-stop { opacity: 1; }
#send.stop-mode:disabled { opacity: 1; cursor: pointer; }
/* K2: Amber tint in stop mode — visually distinct from send */
#send.stop-mode { background: var(--ai-2); }
html.dark #send.stop-mode { color: var(--accent-fg); }
/* N2: Gentle breathing pulse while bot is responding */
#send.stop-mode:disabled { animation: sendPulse 2s ease-in-out infinite; }
@keyframes sendPulse { 0%, 100% { opacity: 0.5; } 50% { opacity: 1; } }
#send:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--focus-ring);
}
@media (prefers-reduced-motion: reduce) {
  #send,
  #send .icon-send,
  #send .icon-stop {
    transition: none;
  }
  #send.stop-mode:disabled { animation: none; }
  .md-checked-list,
  .md-checked-toggle::before {
    transition: none;
  }
}

/* --- Modals --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(14,16,32,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
  animation: overlayIn 0.18s ease-out;
}
html.dark .modal-overlay { background: rgba(10,6,4,0.55); }
@keyframes overlayIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes overlayOut {
  from { opacity: 1; }
  to { opacity: 0; }
}
@keyframes modalOut {
  from { opacity: 1; transform: scale(1) translateY(0); }
  to { opacity: 0; transform: scale(0.96) translateY(8px); }
}
@keyframes modalOutSheet {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(28px); }
}
.modal-overlay.closing { animation: overlayOut 0.18s ease forwards; }
.modal-overlay.closing .modal { animation: modalOut 0.2s cubic-bezier(0.4, 0, 1, 1) forwards; }
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.94) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes modalInSheet {
  from { opacity: 0; transform: translateY(28px); }
  to { opacity: 1; transform: translateY(0); }
}
.modal {
  background: var(--modal-bg);
  border-radius: 12px;
  position: relative;
  width: 100%;
  max-width: 460px;
  max-height: 90vh;
  overflow: hidden;
  box-shadow: var(--shadow-md), 0 12px 40px rgba(18,18,18,0.16);
  display: flex;
  flex-direction: column;
  animation: modalIn 0.24s cubic-bezier(0.2, 0, 0, 1);
  transform-origin: center;
}
/* Header/footer stay put; only the body scrolls, so the scrollbar no longer
   crosses the header or the modal's rounded top corner. */

/* --- Modal resize handle (left edge, like admin drawer) --- */
.modal-resize {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 8px;
  cursor: ew-resize;
  z-index: 3;
}
.modal-resize::after {
  content: "";
  position: absolute;
  left: 2px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 36px;
  border-radius: 2px;
  background: var(--border-strong, var(--border));
  opacity: 0.5;
}
.modal-resize:hover::after { opacity: 1; }
.modal.resizing { transition: none; user-select: none; }

.modal > form, .modal > .modal-body, .modal > .feedback-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.modal > form::-webkit-scrollbar, .modal > .modal-body::-webkit-scrollbar, .modal > .feedback-body::-webkit-scrollbar { width: 12px; }
.modal > form::-webkit-scrollbar-thumb, .modal > .modal-body::-webkit-scrollbar-thumb, .modal > .feedback-body::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 999px;
  border: 3px solid var(--modal-bg);
  background-clip: padding-box;
}
@media (prefers-reduced-motion: reduce) {
  .modal-overlay, .modal, .modal-overlay.closing, .modal-overlay.closing .modal { animation: none; }
}
.modal-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
  background: transparent;
}
.modal-head h2 { font-size: 15px; font-weight: 600; margin: 0; flex: 1; }
.modal-head-icon {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  border-radius: 8px;
  background: color-mix(in srgb, var(--card-strong) 80%, var(--ai-2) 20%);
  color: var(--ai-2);
  display: flex;
  align-items: center;
  justify-content: center;
}
html.dark .modal-head-icon { background: rgba(249,225,194,0.10); color: var(--ai-4); }
.modal-x {
  background: transparent;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: none;
  padding: 0;
  transition: background 0.15s, color 0.15s;
}
.modal-x:hover:not(:disabled) { background: var(--hover-surface); color: var(--text); }
#supportForm, #licenseForm, #profileForm {
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.support-form-request-type { padding-bottom: 14px; border-bottom: 1px solid var(--border); }

/* -- File attachment area -- */
.attachment-area { display: flex; flex-direction: column; gap: 8px; }
.file-input-hidden { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.attachment-browse {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 8px; cursor: pointer;
  font-size: 13px; font-family: inherit; font-weight: 500;
  color: var(--muted); background: transparent;
  border: 1px dashed var(--border);
  transition: background .15s, border-color .15s, color .15s;
  align-self: flex-start;
}
.attachment-browse:hover {
  background: var(--bg); border-color: var(--border-strong);
  color: var(--text);
}
.attachment-browse svg { flex-shrink: 0; }
.file-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.file-chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--hover-surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 3px 10px; font-size: 12px; max-width: 220px;
}
.file-chip .chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip .chip-remove {
  cursor: pointer; border: none; background: none; padding: 0;
  font-size: 14px; line-height: 1; color: var(--text-muted); flex-shrink: 0;
  width: 20px; height: 20px; display: flex; align-items: center; justify-content: center;
  border-radius: 50%; transition: background .15s, color .15s;
}
.file-chip .chip-remove:hover { color: var(--error, #c0392b); background: rgba(192,57,43,0.12); }
.attachment-error { color: var(--error, #c0392b); font-size: 12px; margin: 0; }
.attachment-uploading { font-size: 12px; color: var(--text-muted); margin: 0; }
#supportFormFields, #licenseFields { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field.field-checkbox {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.field.field-checkbox .field-label { order: 2; }
.field.field-checkbox input[type="checkbox"] {
  order: 1;
  width: 1.1rem;
  height: 1.1rem;
  margin: 0;
  accent-color: var(--text);
}
.field.field-checkbox .field-hint {
  flex: 1 1 100%;
  order: 3;
  padding-left: calc(1.1rem + 8px);
}
.field-label { font-size: 13px; font-weight: 600; }
.field-label .req { color: var(--ai-2); }
.field-hint { font-size: 12px; color: var(--ai-3); display: flex; align-items: flex-start; gap: 4px; }
.field-hint::before { content: "ℹ"; font-size: 12px; opacity: 0.65; flex-shrink: 0; }
.field input, .field select, .field textarea {
  border: 1px solid var(--border);
  background: var(--input-bg);
  border-radius: 10px;
  padding: 9px 11px;
  font-size: 14px;
  color: var(--text);
  outline: none;
  width: 100%;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.field select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%2374543a'%3E%3Cpath d='M5 8l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
  padding-right: 32px;
}
html.dark .field select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%23cfaf8a'%3E%3Cpath d='M5 8l5 5 5-5z'/%3E%3C/svg%3E");
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--border-strong);
  box-shadow: 0 0 0 3px var(--focus-ring), 0 0 12px var(--focus-ring);
}
.field select:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  background-color: var(--bg);
}
.field textarea { resize: vertical; min-height: 56px; }
.field input.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.02em;
}
.field.invalid input, .field.invalid select, .field.invalid textarea { border-color: var(--error); animation: shake 0.3s; }
.modal-error {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--error-fg);
  background: color-mix(in srgb, var(--error) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--error) 25%, transparent);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
  margin: 0;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}
.modal-compact {
  max-width: 420px;
}
.modal-body-text {
  margin: 0;
  padding: 2px 4px 18px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

/* Slim confirm for composer product switch — not a full form modal */
.product-switch-dialog {
  position: relative;
  max-width: 360px;
  padding: 22px 22px 18px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--modal-bg);
  backdrop-filter: blur(18px) saturate(1.15);
  -webkit-backdrop-filter: blur(18px) saturate(1.15);
  box-shadow: 0 8px 28px rgba(47, 33, 22, 0.14);
}
.product-switch-x {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  font-size: 20px;
}
.product-switch-x:hover:not(:disabled) {
  background: var(--hover-surface);
  color: var(--text);
}
.product-switch-dialog h2 {
  margin: 0 28px 8px 0;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.25;
  color: var(--text);
}
.product-switch-copy {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.45;
}
.product-switch-actions {
  display: grid;
  grid-template-columns: 1fr 1.35fr;
  gap: 8px;
}
.product-switch-actions .btn-ghost {
  width: 100%;
  justify-content: center;
  min-height: 40px;
  border-radius: 11px;
}
.product-switch-confirm {
  width: 100%;
  min-height: 40px;
  border: none;
  border-radius: 11px;
  background: var(--accent);
  color: var(--accent-fg);
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.12s;
}
.product-switch-confirm:hover:not(:disabled) {
  background: var(--accent-hover);
}
.product-switch-confirm:active:not(:disabled) {
  transform: scale(0.98);
}
@media (max-width: 640px) {
  .product-switch-dialog {
    max-width: 100%;
    border-radius: 18px 18px 0 0;
    padding: 20px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  }
  .product-switch-actions {
    grid-template-columns: 1fr;
  }
}
.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-ghost:hover:not(:disabled) { background: var(--bg); color: var(--text); }
button {
  border: none;
  background: var(--accent);
  color: var(--accent-fg);
  padding: 8px 18px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}
button:hover:not(:disabled) { background: var(--accent-hover); }
button:active:not(:disabled) { transform: scale(0.97); }
button:disabled { opacity: 0.5; cursor: default; }
.privacy-modal .modal-body {
  padding: 4px 20px 18px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
}
.privacy-modal .modal-body h3 {
  font-size: 14px;
  font-weight: 600;
  margin: 16px 0 6px;
}
.privacy-modal .modal-body h3:first-child { margin-top: 0; }
.privacy-modal .modal-body p { margin: 4px 0; }
.privacy-modal .modal-body ul { margin: 4px 0; padding-left: 4px; list-style: none; }
.privacy-modal .modal-body li {
  margin: 6px 0;
  padding-left: 16px;
  position: relative;
}
.privacy-modal .modal-body li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: var(--ai-2);
}
html.dark .privacy-modal .modal-body li::before { background: var(--ai-3); }

/* --- Feedback modal --- */
.feedback-body {
  padding: 16px 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.feedback-body .feedback-label {
  font-size: 13px;
  font-weight: 600;
  margin: 0;
}
.feedback-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.feedback-option {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  transition: background 0.15s, border-color 0.15s;
}
.feedback-option:hover { background: var(--hover-surface); }
.feedback-option.selected { border-color: var(--border-strong); background: var(--hover-surface); }
.feedback-option input[type="radio"] { margin: 0; accent-color: var(--accent); width: 16px; height: 16px; }
.feedback-option[data-value="compliment"].selected { border-color: var(--green); background: color-mix(in srgb, var(--green) 12%, transparent); }
.feedback-option[data-value="compliment"] input[type="radio"] { accent-color: var(--green); }
.feedback-option[data-value="problem"].selected { border-color: var(--error); background: color-mix(in srgb, var(--error) 12%, transparent); }
.feedback-option[data-value="problem"] input[type="radio"] { accent-color: var(--error); }
.feedback-option[data-value="suggestion"].selected { border-color: var(--amber); background: color-mix(in srgb, var(--amber) 14%, transparent); }
.feedback-option[data-value="suggestion"] input[type="radio"] { accent-color: #d4ad42; }
.feedback-body textarea {
  border: 1px solid var(--border);
  background: var(--input-bg);
  border-radius: 10px;
  padding: 9px 11px;
  font-size: 14px;
  color: var(--text);
  outline: none;
  font-family: inherit;
  resize: vertical;
  min-height: 80px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.feedback-body textarea:focus {
  border-color: var(--border-strong);
  box-shadow: 0 0 0 3px var(--focus-ring);
}
.feedback-body .feedback-note {
  font-size: 12px;
  color: var(--muted);
  margin: 0;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}
.feedback-body textarea.invalid {
  border-color: var(--error);
  animation: shake 0.3s;
}

/* --- Toast (transient confirmations, not part of the chat) --- */
.toast {
  position: fixed;
  bottom: max(24px, calc(12px + env(safe-area-inset-bottom, 0px)));
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: #1A1A1A;
  color: #FAFAFA;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 18px 11px 15px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 8px 28px rgba(0,0,0,0.28);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 60;
  max-width: min(440px, calc(100vw - 32px));
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
/* J: Invert toast in dark mode so it doesn't disappear against the dark bg */
html.dark .toast { background: #f5eddd; color: #1a1008; box-shadow: 0 8px 28px rgba(0,0,0,0.40); }
html.dark .toast-success .toast-icon-success { color: #2a8a40; }
html.dark .toast-warn .toast-icon-warn { color: #a87a10; }
html.dark .toast-error .toast-icon-error { color: #c04040; }
.toast-icon { display: none; flex: 0 0 auto; }
.toast-icon svg { width: 17px; height: 17px; display: block; }
.toast-success .toast-icon-success { display: inline-flex; color: #36C85B; }
.toast-warn .toast-icon-warn { display: inline-flex; color: #F5A623; }
.toast-error .toast-icon-error { display: inline-flex; color: #FF7A7A; }
.toast-text { line-height: 1.3; }
@media (prefers-reduced-motion: reduce) {
  .feedback-body textarea.invalid { animation: none; }
  .toast { transition: opacity 0.25s; }
}

@media (max-width: 768px) {
  :root { --avatar-size: 34px; }
  .msg.you, .msg-row { max-width: 90%; }
  /* Hide the bot avatar in chat on mobile so the bubble reclaims the
     avatar width + gap and can fill more of the row. Home-screen icon
     (.welcome .icon) is a separate element and is unaffected. */
  .msg-row.bot .msg-avatar { display: none; }
  header { padding: 0 16px; gap: 8px; }
  header .logo-mark { height: 28px; }
  header h1 { font-size: 15px; }
  header h1 .title-full { display: none; }
  header h1 .title-short { display: inline; }
  .input-action .help-full { display: none; }
  .input-action .help-short { display: inline; }
  .newchat-icon { display: none !important; }
  .chat-inner { padding: 0 16px; }
  .chat-area .spacer-bottom { height: 40px; min-height: 40px; }
  .chat-area:has(#welcomeScreen) .spacer-bottom { height: auto; min-height: 40px; }
  .input-area { padding: 8px 16px 10px; }
  .welcome { padding: 20px 0 8px; }
  .welcome h2 { font-size: 18px; }
  .welcome p { padding: 0 8px; }
  .header-actions { gap: 4px; }
  .header-actions .who { max-width: 80px; }
  .header-btn { padding: 8px 12px; min-height: 36px; }
  .menu-btn { width: 36px; height: 36px; padding: 8px; }
  .lang-btn { width: 36px; justify-content: center; padding: 8px; gap: 0; }
  .lang-btn-label { display: none; }
  .quick-replies { gap: 6px; }
  .quick-reply { padding: 7px 14px; font-size: 12.5px; }
  #msg { min-height: 44px; }
  #send, .mic-btn { width: 44px; height: 44px; }
  .composer-product { max-width: 7.75rem; font-size: 12px; height: 40px; padding-left: 10px; }
  .modal { max-width: 100%; border-radius: 16px 16px 0 0; align-self: flex-end; max-height: 85vh; animation: modalInSheet 0.24s cubic-bezier(0.2, 0, 0, 1); }
  .modal-resize { display: none; }
  /* Drag handle pill — signals the bottom sheet is swipeable */
  .modal::before { content: ''; display: block; width: 36px; height: 4px; border-radius: 2px; background: var(--border-strong); margin: 8px auto 0; }
  .modal-overlay.closing .modal { animation: modalOutSheet 0.2s cubic-bezier(0.4, 0, 1, 1) forwards; }
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal-actions { flex-wrap: wrap; }
  .dropdown-menu { min-width: 200px; }
}
@media (max-width: 480px) {
  :root { --avatar-size: 32px; --avatar-gap: 6px; }
  .msg.you, .msg-row { max-width: 95%; }
  header { padding: 0 12px; }
  header .logo-mark { height: 22px; }
  header .header-actions .who { display: none; }
  header h1 { font-size: 13px; }
  .quick-replies.centered { padding: 0 4px; }
  .modal-actions { flex-direction: column-reverse; align-items: stretch; }
  .modal-actions button, .modal-actions .btn-ghost { width: 100%; }
  .toast { left: 16px; right: 16px; transform: translateY(12px); justify-content: center; text-align: center; }
  .toast.show { transform: translateY(0); }
}

/* E: Brand text selection (light + dark) */
::selection { background: rgba(0,74,172,0.20); color: var(--text); }
html.dark ::selection { background: rgba(241,199,138,0.32); color: var(--text); }
/* User bubble is accent-blue: force a light highlight + dark text so selected text stays readable. */
.msg.you ::selection, .msg.you::selection { background: rgba(255,255,255,0.55); color: #0e1020; }
html.dark .msg.you ::selection, html.dark .msg.you::selection { background: rgba(255,255,255,0.55); color: #0e1020; }

/* --- Keyboard focus indication (visible ring for keyboard users) --- */
.header-btn:focus-visible, .menu-btn:focus-visible, #newchat:focus-visible,
.quick-reply:focus-visible, .dropdown-item:focus-visible, .modal-x:focus-visible,
.scroll-bottom:focus-visible, .msg-action:focus-visible,
.mic-btn:focus-visible,
.btn-ghost:focus-visible, .feedback-option:has(input[type="radio"]:focus-visible) {
  outline: 2px solid var(--border-strong);
  outline-offset: 2px;
}

/* --- Respect reduced-motion for message/entry animations too --- */
@media (prefers-reduced-motion: reduce) {
  .msg, .msg-row, .quick-replies, .quick-reply, .welcome,
  .welcome .icon, .welcome h2, .welcome p { animation: none !important; }
}
