/* ══════════════════════════════════════════════════════════════
   SafeSoft Chat — chat.css
   ══════════════════════════════════════════════════════════════ */

/* ── Reset & base ─────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

/* ── Design tokens ────────────────────────────────────────── */
:root {
  color-scheme: light;

  --bg0: #f8fafc;
  --bg1: #ffffff;
  --bg2: #f1f5f9;
  --bg3: rgba(255,255,255,0.72);

  --text0: #1f3360;
  --text1: #334155;
  --muted: #64748b;

  --border: #e2e8f0;
  --shadow-xl: 0 25px 50px -12px rgba(0,0,0,0.35);
  --shadow-md: 0 10px 25px rgba(2,6,23,0.10);

  --brand0: #4f46e5;
  --brand1: #7c3aed;
  --brand2: #06b6d4;

  --radius-xl: 28px;
  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 12px;

  --app-bg:
    radial-gradient(1200px 800px at 10% 10%, rgba(79,70,229,0.22), transparent 60%),
    radial-gradient(900px 700px at 75% 25%, rgba(6,182,212,0.16), transparent 55%),
    linear-gradient(135deg, #eef2ff 0%, #f8fafc 40%, #ecfeff 100%);
}

html[data-theme="dark"] {
  color-scheme: dark;

  --bg0: #0b1220;
  --bg1: #0f172a;
  --bg2: #111c33;
  --bg3: rgba(15,23,42,0.55);

  --text0: #e5e7eb;
  --text1: #cbd5e1;
  --muted: #94a3b8;

  --border: rgba(148,163,184,0.22);
  --shadow-xl: 0 25px 50px -12px rgba(0,0,0,0.6);
  --shadow-md: 0 10px 25px rgba(0,0,0,0.35);

  --brand0: #818cf8;
  --brand1: #a78bfa;
  --brand2: #22d3ee;

  --app-bg:
    radial-gradient(1200px 800px at 20% 10%, rgba(129,140,248,0.30), transparent 60%),
    radial-gradient(900px 700px at 80% 30%, rgba(167,139,250,0.22), transparent 55%),
    linear-gradient(135deg, #050a14 0%, #0b1220 100%);
}

/* ── Page ─────────────────────────────────────────────────── */
html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--text0);
}
body {
  background: var(--app-bg);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* ── App shell ────────────────────────────────────────────── */
.app-shell {
  width: min(1380px, calc(100vw - 48px));
  height: min(900px, calc(100vh - 48px));
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 18px;
  min-height: 0;
}

/* ── Sidebar overlay (mobile only) ───────────────────────── */
.sidebar-overlay {
  display: none;           /* toggled to block by JS on mobile */
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.52);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 260ms ease;
}
.sidebar-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  background: var(--bg3);
  border: 1px solid rgba(148,163,184,0.22);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(10px);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow: hidden;
  min-height: 0;
}

/* ── Brand block ──────────────────────────────────────────── */
.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, rgba(79,70,229,0.14), rgba(6,182,212,0.10));
  border: 1px solid rgba(129,140,248,0.22);
}
.brand-logo {
  height: 54px;
  width: auto;
  filter: drop-shadow(0 10px 18px rgba(2,6,23,0.20));
}
.brand-meta { min-width: 0; }
.brand-name { font-weight: 700; font-size: 23px; letter-spacing: 0.3px; }
.brand-subtitle { font-size: 0.82rem; color: var(--muted); }

/* ── New conversation button ──────────────────────────────── */
.new-conv-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 16px;
  border-radius: 999px;
  border: 1px dashed rgba(129,140,248,0.45);
  background: rgba(129,140,248,0.07);
  color: var(--brand0);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 160ms, border-color 160ms, transform 120ms;
}
.new-conv-btn:hover  { background: rgba(129,140,248,0.15); border-color: rgba(129,140,248,0.65); }
.new-conv-btn:active { transform: translateY(1px); }
.new-conv-icon { font-size: 1.1rem; line-height: 1; }

/* ── Conversation list ────────────────────────────────────── */
.conv-list-wrapper {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow: hidden;
}
.sidebar-title {
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--muted);
}
.conv-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-right: 2px;
}
.conv-list::-webkit-scrollbar       { width: 4px; }
.conv-list::-webkit-scrollbar-track { background: transparent; }
.conv-list::-webkit-scrollbar-thumb { background: rgba(148,163,184,0.4); border-radius: 8px; }

.conv-empty {
  font-size: 0.82rem;
  color: var(--muted);
  text-align: center;
  padding: 18px 0;
  font-style: italic;
}

.conv-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 140ms, border-color 140ms;
  animation: fadeInUp 0.18s ease-out;
}
.conv-item:hover        { background: rgba(148,163,184,0.12); border-color: rgba(148,163,184,0.20); }
.conv-item.active       { background: rgba(129,140,248,0.13); border-color: rgba(129,140,248,0.28); }

.conv-item-title {
  flex: 1;
  min-width: 0;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text0);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv-item.active .conv-item-title { color: var(--brand0); font-weight: 650; }

.conv-item-edit {
  flex-shrink: 0;
  opacity: 0;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.78rem;
  padding: 2px 4px;
  border-radius: 6px;
  transition: opacity 140ms, background 140ms;
}
.conv-item:hover .conv-item-edit,
.conv-item.active .conv-item-edit { opacity: 1; }
.conv-item-edit:hover { background: rgba(148,163,184,0.25); }

.conv-rename-input {
  flex: 1;
  min-width: 0;
  font-size: 0.875rem;
  font-weight: 500;
  background: var(--bg1);
  color: var(--text0);
  border: 1px solid rgba(129,140,248,0.50);
  border-radius: 6px;
  padding: 2px 7px;
  outline: none;
}
.conv-rename-input:focus {
  border-color: var(--brand0);
  box-shadow: 0 0 0 3px rgba(129,140,248,0.18);
}

/* ── Sidebar footer / user card ───────────────────────────── */
.sidebar-footer {
  margin-top: auto;
  padding-top: 6px;
}
.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.user-avatar-wrap {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  border: 1.5px solid rgba(129,140,248,0.35);
  background: rgba(129,140,248,0.10);
  display: grid;
  place-items: center;
}
.user-avatar-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.user-avatar-initials {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--brand0);
  text-transform: uppercase;
}
.user-meta { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.user-name  { font-size: 0.82rem; font-weight: 700; color: var(--text0); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-email { font-size: 0.7rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Chat panel ───────────────────────────────────────────── */
.chat-panel {
  background: var(--bg3);
  border: 1px solid rgba(148,163,184,0.22);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  backdrop-filter: blur(10px);
  overflow: hidden;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0,1fr) auto;
}

/* ── Topbar ───────────────────────────────────────────────── */
.topbar {
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid rgba(148,163,184,0.18);
  background: linear-gradient(180deg, rgba(255,255,255,0.10), transparent);
}
.topbar-left  { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.topbar-title { font-weight: 700; font-size: 20px; letter-spacing: 0.2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Hamburger (mobile only — hidden on desktop) */
.menu-btn {
  display: none;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid rgba(148,163,184,0.25);
  background: rgba(148,163,184,0.10);
  color: var(--text0);
  font-size: 1.1rem;
  cursor: pointer;
  place-items: center;
  flex-shrink: 0;
  transition: background 150ms;
}
.menu-btn:hover { background: rgba(129,140,248,0.14); }

/* ── Theme toggle ─────────────────────────────────────────── */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  user-select: none;
  background: rgba(79,70,229,0.10);
  border: 1px solid rgba(79,70,229,0.28);
  color: var(--brand0);
  transition: transform 120ms, background 160ms, border-color 160ms;
}
.theme-toggle:hover        { background: rgba(79,70,229,0.18); border-color: rgba(79,70,229,0.45); }
.theme-toggle:active       { transform: translateY(1px); }
.theme-toggle:focus-visible{ outline: 3px solid rgba(129,140,248,0.55); outline-offset: 2px; }
.theme-toggle-icon  { font-size: 1rem; line-height: 1; }
.theme-toggle-text  { font-size: 0.85rem; font-weight: 700; letter-spacing: 0.2px; color: inherit; }

html[data-theme="dark"] .theme-toggle {
  background: rgba(129,140,248,0.14);
  border-color: rgba(129,140,248,0.30);
  color: #c7d2fe;
}
html[data-theme="dark"] .theme-toggle:hover {
  background: rgba(129,140,248,0.24);
  border-color: rgba(129,140,248,0.55);
}

/* ── Chat messages area ───────────────────────────────────── */
.chat-messages {
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 18px 64px 12px 20px;
  background:
    radial-gradient(1000px 600px at 10% 0%, rgba(79,70,229,0.10), transparent 55%),
    radial-gradient(900px 600px at 90% 10%, rgba(6,182,212,0.08), transparent 52%),
    rgba(148,163,184,0.06);
  scroll-behavior: smooth;
}
.chat-messages::-webkit-scrollbar       { width: 6px; }
.chat-messages::-webkit-scrollbar-track { background: rgba(148,163,184,0.25); border-radius: 10px; }
.chat-messages::-webkit-scrollbar-thumb { background: rgba(148,163,184,0.65); border-radius: 10px; }

/* ── Message bubbles ──────────────────────────────────────── */
.message {
  margin-bottom: 1.5rem;
  display: flex;
  flex-direction: column;
  animation: fadeInUp 0.25s ease-out;
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.message.user      { align-items: flex-end; }
.message.assistant { align-items: flex-start; width: 100%; }

.assistant-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  max-width: min(960px, 100%);
}
.assistant-avatar {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  object-fit: contain;
  border-radius: 12px;
  border: 1px solid rgba(129,140,248,0.28);
  background: rgba(255,255,255,0.92);
  box-shadow: 0 6px 16px rgba(2,6,23,0.10);
}
html[data-theme="dark"] .assistant-avatar { background: rgba(15,23,42,0.85); }

.assistant-row .message-content { flex: 1; min-width: 0; }

.message-content {
  width: fit-content;
  max-width: min(900px, 100%);
  padding: 0.95rem 1.05rem;
  border-radius: 18px;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.6;
  font-size: 0.95rem;
  position: relative;
}
.user .message-content {
  background: linear-gradient(115deg, var(--brand0), var(--brand1));
  color: white;
  border-bottom-right-radius: 0.3rem;
  box-shadow: 0 4px 8px rgba(0,0,0,0.05);
}
.assistant .message-content {
  background: var(--bg1);
  color: var(--text0);
  border-top-left-radius: 0.3rem;
  box-shadow: 0 12px 28px rgba(2,6,23,0.08);
  border: 1px solid rgba(129,140,248,0.18);
  padding-right: 33px;
}

/* "Vous" label next to user bubble */
.message.user .message-content::before {
  content: "Vous";
  position: absolute;
  right: -58px;
  top: 10px;
  width: 48px;
  height: 34px;
  border-radius: 12px;
  background: rgba(148,163,184,0.12);
  border: 1px solid rgba(148,163,184,0.18);
  display: grid;
  place-items: center;
  font-weight: 850;
  font-size: 0.74rem;
  color: var(--text1);
}

/* ── Markdown rendered inside bubbles ─────────────────────── */
.message-content h1, .message-content h2, .message-content h3 { margin: 1rem 0 0.4rem; font-weight: 600; }
.message-content h2 { font-size: 1.1rem; color: var(--text0); border-left: 4px solid var(--brand0); padding-left: 10px; }
.message-content h3 { font-size: 1rem; color: var(--text1); }
.message-content p  { margin: 0.4rem 0; }
.message-content ul, .message-content ol { margin: 0.4rem 0; padding-left: 1.4rem; }
.message-content li { margin: 0.25rem 0; }
.message-content hr { border: none; border-top: 1px solid var(--border); margin: 0.8rem 0; }
.message-content strong { font-weight: 600; }
.message-content em     { font-style: italic; }
.message-content code {
  background: var(--bg2);
  padding: 2px 6px;
  border-radius: 6px;
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 0.85em;
  color: #dc2626;
}
.message-content pre {
  background: #1e293b;
  color: #e2e8f0;
  padding: 12px;
  border-radius: 12px;
  overflow-x: auto;
  margin: 0.8rem 0;
}
.message-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.8rem 0;
  font-size: 0.85rem;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.message-content th { background: linear-gradient(135deg, var(--brand0), #6366f1); color: white; padding: 9px 12px; text-align: left; font-weight: 600; }
.message-content td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.message-content tr:last-child td { border-bottom: none; }
.message-content tr:nth-child(even) td { background: rgba(148,163,184,0.12); }

/* ── Streaming cursor & animations ───────────────────────── */
.streaming-cursor::after { content: '▍'; animation: blink 0.9s step-end infinite; color: #4f46e5; margin-left: 2px; }
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: 0; } }

@keyframes reflective-pulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(129,140,248,0.4); transform: scale(0.95); border-color: rgba(129,140,248,0.3); }
  50%     { box-shadow: 0 0 16px 4px rgba(129,140,248,0.7); transform: scale(1.08) translateY(-2px); border-color: rgba(129,140,248,0.9); }
}
.thinking-logo { animation: reflective-pulse 1.8s ease-in-out infinite; }

/* ── Typing indicator ─────────────────────────────────────── */
.typing-indicator-bubble {
  display: inline-flex;
  align-items: center;
  padding: 0.75rem 1.15rem;
  background: var(--bg1);
  border-radius: 1.6rem;
  box-shadow: 0 8px 22px rgba(2,6,23,0.08);
  border: 1px solid rgba(129,140,248,0.18);
}
.typing-dots { display: flex; gap: 5px; align-items: center; }
.typing-dots span { width: 8px; height: 8px; background: var(--brand0); border-radius: 50%; animation: wave 1.2s infinite; }
.typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.typing-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes wave { 0%,80%,100% { transform: scale(0.6); opacity: 0.5; } 40% { transform: scale(1); opacity: 1; } }

/* ── Message meta ─────────────────────────────────────────── */
.message-info { font-size: 0.65rem; margin-top: 6px; margin-left: 60px; color: var(--muted); }
.sources { margin-top: 10px; font-size: 0.7rem; background: var(--bg2); border-radius: 12px; padding: 8px 12px; border: 1px solid var(--border); }
.sources summary { font-weight: 600; color: var(--brand0); cursor: pointer; }

/* ── Composer ─────────────────────────────────────────────── */
.composer {
  padding: 14px 16px 16px;
  border-top: 1px solid rgba(148,163,184,0.18);
  background: linear-gradient(180deg, transparent, rgba(255,255,255,0.08));
}
.composer-inner {
  display: flex;
  gap: 8px;
  align-items: center;
  background: rgba(148,163,184,0.10);
  border: 1px solid rgba(148,163,184,0.18);
  border-radius: 999px;
  padding: 8px 8px 8px 12px;
}
.chat-input {
  flex: 1;
  min-width: 0;
  padding: 8px 4px;
  border: none;
  background: transparent;
  color: var(--text0);
  font-size: 0.98rem;
  outline: none;
}
.chat-input::placeholder { color: rgba(148,163,184,0.95); }

/* Voice lang select */
.voice-lang {
  height: 38px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid rgba(148,163,184,0.20);
  background: rgba(255,255,255,0.10);
  color: var(--text0);
  font-weight: 700;
  font-size: 0.8rem;
  cursor: pointer;
  outline: none;
  flex-shrink: 0;
}
html[data-theme="dark"] .voice-lang { background: rgba(15,23,42,0.35); }
.voice-lang:focus-visible { outline: 3px solid rgba(129,140,248,0.45); outline-offset: 2px; }

/* Icon buttons (voice, etc.) */
.icon-button {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 999px;
  border: 1px solid rgba(148,163,184,0.20);
  background: rgba(255,255,255,0.10);
  color: var(--text0);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 1.1rem;
  transition: transform 120ms, background 160ms, border-color 160ms;
}
html[data-theme="dark"] .icon-button { background: rgba(15,23,42,0.35); }
.icon-button:hover       { background: rgba(129,140,248,0.12); border-color: rgba(129,140,248,0.28); }
.icon-button:active      { transform: translateY(1px); }
.icon-button:focus-visible { outline: 3px solid rgba(129,140,248,0.45); outline-offset: 2px; }
.icon-button.is-listening {
  border-color: rgba(34,197,94,0.55);
  box-shadow: 0 0 0 4px rgba(34,197,94,0.18);
  background: rgba(34,197,94,0.10);
}
.icon-button:disabled { opacity: 0.35; cursor: not-allowed; }

/* Send button */
.send-button {
  flex-shrink: 0;
  border: none;
  border-radius: 999px;
  padding: 10px 18px;
  font-weight: 750;
  letter-spacing: 0.2px;
  color: white;
  cursor: pointer;
  background: linear-gradient(115deg, var(--brand0), var(--brand1));
  box-shadow: 0 14px 30px rgba(79,70,229,0.22);
  transition: transform 120ms, filter 160ms;
  white-space: nowrap;
}
.send-button:hover    { filter: brightness(1.05); }
.send-button:active   { transform: translateY(1px); }
.send-button:disabled { background: rgba(148,163,184,0.55); cursor: not-allowed; box-shadow: none; }

/* ── Badges & annotations ─────────────────────────────────── */
.error-bubble { background: #fee2e2; color: #991b1b; }

.load-more-banner {
  display: block;
  width: 100%;
  padding: 8px 0;
  margin-bottom: 12px;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 650;
  color: var(--brand0);
  background: rgba(129,140,248,0.07);
  border: 1px dashed rgba(129,140,248,0.35);
  border-radius: 999px;
  cursor: pointer;
  transition: background 150ms;
  user-select: none;
}
.load-more-banner:hover { background: rgba(129,140,248,0.15); }

/* Pre-bubble annotation chips */
.pre-bubble-note {
  display: flex;
  align-items: baseline;
  gap: 5px;
  margin-left: 56px;
  margin-bottom: 6px;
  font-size: 0.72rem;
  line-height: 1.45;
  padding: 4px 12px;
  border-radius: 20px;
  width: fit-content;
  max-width: calc(100% - 56px);
  word-break: break-word;
  animation: fadeInUp 0.18s ease-out;
}
.pre-bubble-note--translation { background: #f1f5ff; color: #6c63ff; border: 1px solid rgba(108,99,255,0.20); }
.pre-bubble-note--rewrite     { background: rgba(6,182,212,0.10); color: #0e7490; border: 1px solid rgba(6,182,212,0.22); }

html[data-theme="dark"] .pre-bubble-note--translation { background: rgba(108,99,255,0.15); color: #a78bfa; border-color: rgba(167,139,250,0.25); }
html[data-theme="dark"] .pre-bubble-note--rewrite     { background: rgba(34,211,238,0.10); color: #22d3ee; border-color: rgba(34,211,238,0.22); }

.annot-icon  { flex-shrink: 0; font-size: 0.8rem; line-height: 1; }
.annot-label { font-weight: 700; white-space: nowrap; flex-shrink: 0; }
.annot-text  { font-weight: 400; font-style: italic; word-break: break-word; }

.streaming-annot::after { content: '▍'; animation: blink 0.9s step-end infinite; margin-left: 1px; font-style: normal; }

/* Translation note (inline) */
.translation-note {
  direction: ltr !important;
  text-align: left !important;
  font-size: 0.7rem;
  color: #6c63ff;
  background: #f1f5ff;
  padding: 4px 10px;
  border-radius: 20px;
  margin-bottom: 8px;
  display: inline-block;
}
html[data-theme="dark"] .translation-note { background: rgba(108,99,255,0.15); color: #a78bfa; }

/* Relevance badge */
.relevance-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-left: 10px;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.2px;
  vertical-align: middle;
  white-space: nowrap;
  animation: fadeInUp 0.20s ease-out;
}
.relevance-badge--relevant     { background: rgba(34,197,94,0.12);  color: #15803d; border: 1px solid rgba(34,197,94,0.28); }
.relevance-badge--unanswered   { background: rgba(245,158,11,0.12); color: #92400e; border: 1px solid rgba(245,158,11,0.28); }
.relevance-badge--inappropriate{ background: rgba(239,68,68,0.10);  color: #991b1b; border: 1px solid rgba(239,68,68,0.24); }

html[data-theme="dark"] .relevance-badge--relevant      { background: rgba(34,197,94,0.15);  color: #4ade80;  border-color: rgba(74,222,128,0.30); }
html[data-theme="dark"] .relevance-badge--unanswered    { background: rgba(245,158,11,0.15); color: #fbbf24;  border-color: rgba(251,191,36,0.30); }
html[data-theme="dark"] .relevance-badge--inappropriate { background: rgba(239,68,68,0.15);  color: #fca5a5;  border-color: rgba(252,165,165,0.28); }

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE — Mobile (≤ 680px)
   Sidebar becomes a slide-in drawer from the left.
   ══════════════════════════════════════════════════════════════ */
@media (max-width: 680px) {
  /* Body fills the full screen edge-to-edge */
  body {
    align-items: stretch;
    justify-content: stretch;
  }

  .app-shell {
    /* Use 100% of the viewport — no margins, no min/max width */
    width: 100%;
    max-width: 100%;
    height: 100svh;          /* svh respects iOS address bar */
    grid-template-columns: 1fr;
    gap: 0;
  }

  /* Overlay for drawer backdrop — becomes visible */
  .sidebar-overlay { display: block; }

  /* Sidebar becomes a slide-in drawer */
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;       /* full height, anchored left */
    width: min(300px, 82vw);
    border-radius: 0 var(--radius-xl) var(--radius-xl) 0;
    z-index: 110;
    transform: translateX(-110%);
    transition: transform 280ms cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(20px);
    padding: 20px 16px 24px; /* extra top/bottom breathing room */
  }
  .sidebar.open { transform: translateX(0); }

  /* Show hamburger in topbar */
  .menu-btn { display: grid; }

  /* Chat panel fills the whole screen */
  .chat-panel {
    border-radius: 0;
    grid-column: 1;
    width: 100%;
  }

  /* Message area padding — no right gutter needed (no "Vous" label) */
  .chat-messages { padding: 14px 14px 10px; }

  /* Hide "Vous" label — no space on mobile */
  .message.user .message-content::before { display: none; }

  /* Slightly smaller avatar */
  .assistant-avatar { width: 36px; height: 36px; }
  .message-info     { margin-left: 48px; }
  .pre-bubble-note  { margin-left: 48px; max-width: calc(100% - 48px); }

  /* Theme toggle — icon only, no text */
  .theme-toggle-text { display: none; }
  .theme-toggle      { padding: 8px 10px; }

  /* Bigger tap targets in composer */
  .icon-button { width: 44px; height: 44px; }
  .send-button { padding: 10px 14px; font-size: 0.88rem; }
}