/* Rapha chat assistant: floating launcher + conversation panel (side panel on desktop, sheet on phones).
   Colours come from the shared theme tokens (MAN-002 via app-2026.css). */
.assistant-control { min-height:44px; padding:10px 14px; border:1px solid var(--line-strong); border-radius:12px; background:var(--surface); color:var(--brand); font:600 13px 'IBM Plex Sans',sans-serif; cursor:pointer; }
.assistant-control:focus-visible { outline:3px solid var(--brand); outline-offset:3px; }
.assistant-control:disabled { opacity:.55; cursor:default; }

/* Avatar: brand conic ring around an R */
.rapha-avatar { display:inline-grid; place-items:center; flex:none; width:32px; height:32px; border-radius:50%; color:#fff; font:700 15px/1 'IBM Plex Sans',sans-serif;
  background:conic-gradient(from 210deg, #208EA4, #56377B, #E0629A, #208EA4); box-shadow:inset 0 0 0 2px rgba(255,255,255,.35); }
.rapha-avatar.lg { width:44px; height:44px; font-size:19px; }
.rapha-avatar.sm { width:22px; height:22px; font-size:11px; }

/* Launcher */
.rapha-launcher { position:fixed; z-index:22; right:max(24px, env(safe-area-inset-right)); bottom:28px; display:inline-flex; align-items:center; gap:10px;
  min-height:56px; padding:6px 20px 6px 6px; border-radius:999px; border:1px solid var(--glass-line, var(--line-strong)); color:var(--ink);
  background:var(--glass-strong, var(--surface)); -webkit-backdrop-filter:blur(20px) saturate(1.7); backdrop-filter:blur(20px) saturate(1.7);
  box-shadow:var(--elev-3, 0 12px 30px rgba(0,0,0,.25)); font:700 14px 'IBM Plex Sans',sans-serif; cursor:pointer; }
.rapha-launcher .rapha-avatar { width:44px; height:44px; font-size:19px; }
.rapha-launcher:hover { border-color:var(--brand); }
.rapha-launcher:focus-visible { outline:3px solid var(--brand); outline-offset:3px; }
.rapha-launcher[aria-expanded="true"] { visibility:hidden; }
body.has-rapha .nav-fab { bottom:100px; }
body[data-view="home"].has-rapha .rapha-launcher { bottom:28px; }

/* Result shortcut */
.assistant-result { display:inline-flex; align-items:center; gap:8px; margin:0 0 18px; border-radius:999px; padding:8px 16px 8px 8px; }
.assistant-result[hidden] { display:none; }

/* Panel */
.rapha-chat { box-sizing:border-box; display:none; flex-direction:column; gap:0; padding:0; overflow:hidden; color:var(--ink);
  margin:0 0 0 auto; width:min(440px, 100%); height:100dvh; max-height:100dvh; max-width:100%;
  background:var(--glass-strong, var(--surface)); -webkit-backdrop-filter:blur(30px) saturate(1.8); backdrop-filter:blur(30px) saturate(1.8);
  border:1px solid var(--glass-line, var(--line-strong)); border-radius:var(--r-2xl, 28px) 0 0 var(--r-2xl, 28px);
  box-shadow:var(--elev-3, 0 20px 60px rgba(0,0,0,.35)); }
.rapha-chat[open] { display:flex; }
.rapha-chat::backdrop { background:rgba(10,12,12,.35); -webkit-backdrop-filter:blur(3px); backdrop-filter:blur(3px); }
.rapha-header { display:flex; align-items:center; justify-content:space-between; gap:12px; padding:18px 18px 12px; border-bottom:1px solid var(--line); }
.rapha-who { display:flex; align-items:center; gap:12px; min-width:0; }
.rapha-who h2 { margin:0; font:700 20px/1.1 'IBM Plex Sans',sans-serif; letter-spacing:-.02em; }
.rapha-presence { margin:3px 0 0; font-size:12px; color:var(--ink-faint); }
.rapha-header-actions { display:flex; gap:8px; flex:none; }
.rapha-new { min-height:40px; padding:8px 12px; border-radius:999px; font-size:12px; }
.rapha-close { width:40px; min-height:40px; padding:0; border-radius:50%; font-size:22px; line-height:1; color:var(--ink-soft); }
.rapha-context { padding:8px 18px; font-size:12px; color:var(--ink-soft); background:color-mix(in srgb, var(--surface-sunk) 70%, transparent); border-bottom:1px solid var(--line); overflow-wrap:anywhere; }

.rapha-thread { flex:1; min-height:0; overflow-y:auto; overscroll-behavior:contain; padding:16px 16px 8px; display:flex; flex-direction:column; gap:12px; }
.rapha-msg { display:flex; gap:8px; align-items:flex-end; max-width:100%; }
.rapha-msg-you { justify-content:flex-end; }
.rapha-bubble { max-width:86%; min-width:0; padding:10px 14px; border-radius:20px; font-size:14px; line-height:1.6; overflow-wrap:anywhere; }
.rapha-msg-bot .rapha-bubble { background:var(--surface); border:1px solid var(--line); border-bottom-left-radius:6px; box-shadow:var(--elev-1, none); }
.rapha-msg-you .rapha-bubble { margin:0; background:color-mix(in srgb, #208EA4 18%, var(--surface)); border:1px solid color-mix(in srgb, #208EA4 40%, transparent); border-bottom-right-radius:6px; font-weight:500; color:var(--ink); }
.rapha-bubble section { margin:0; padding:4px 0; min-height:0; }
.rapha-bubble section + section { border-top:1px solid var(--line); margin-top:6px; padding-top:8px; }
.rapha-bubble h3 { margin:0 0 4px; font:700 14px/1.35 'IBM Plex Sans',sans-serif; }
.rapha-bubble p { margin:2px 0; white-space:pre-wrap; }
.assistant-mode { font-size:11px !important; font-weight:700; letter-spacing:.03em; text-transform:uppercase; color:var(--brand); margin:0 0 6px !important; }
.assistant-citations { font-size:11px; color:var(--brand); margin:2px 0 0; }
.assistant-citation { border:0; background:transparent; padding:6px 4px; min-height:32px; color:var(--brand); text-decoration:underline; cursor:pointer; font:inherit; }
.rapha-extra { display:flex; flex-direction:column; gap:8px; margin-top:10px; }
.assistant-generate { min-height:40px; border-radius:999px; background:var(--brand-tint); font-size:12.5px; }
.assistant-visuals > summary, .assistant-sources > summary { min-height:36px; display:flex; align-items:center; cursor:pointer; color:var(--brand); font-size:12.5px; font-weight:600; }
.assistant-sources { margin-top:6px; font-size:12px; line-height:1.6; }
.assistant-sources h4 { margin:8px 0 2px; font-size:12px; }
.assistant-visuals[hidden] { display:none; }
.rapha-typing .rapha-bubble { display:inline-flex; gap:5px; padding:14px 16px; }
.rapha-typing span { width:7px; height:7px; border-radius:50%; background:var(--ink-faint); animation:rapha-dot 1.2s infinite ease-in-out; }
.rapha-typing span:nth-child(2) { animation-delay:.15s; } .rapha-typing span:nth-child(3) { animation-delay:.3s; }
@keyframes rapha-dot { 0%,80%,100% { opacity:.3; transform:translateY(0); } 40% { opacity:1; transform:translateY(-3px); } }

.rapha-picker { display:flex; align-items:center; gap:8px; margin:0 16px 8px; font-size:12.5px; color:var(--ink-soft); }
.rapha-picker select { flex:1; min-width:0; min-height:44px; border:1px solid var(--line-strong); border-radius:12px; padding:8px 10px; color:var(--ink); background:var(--surface); font:inherit; }
.rapha-picker[hidden] { display:none; }
.rapha-composer[hidden], .assistant-generate[hidden] { display:none; }
.rapha-suggestions { display:flex; gap:8px; overflow-x:auto; padding:4px 16px 10px; scrollbar-width:none; }
.rapha-suggestions::-webkit-scrollbar { display:none; }
.rapha-chip { flex:none; min-height:38px; padding:8px 14px; border-radius:999px; font-size:12.5px; white-space:nowrap; background:var(--surface); }
.rapha-chip:hover { border-color:var(--brand); }
.rapha-composer { display:flex; gap:8px; align-items:center; margin:0 16px; padding:6px 6px 6px 16px; border:1px solid var(--line-strong); border-radius:999px; background:var(--surface); }
.rapha-composer:focus-within { border-color:var(--brand); box-shadow:0 0 0 4px color-mix(in srgb, #208EA4 18%, transparent); }
.assistant-ask-input { flex:1; min-width:0; min-height:40px; border:0; background:transparent; color:var(--ink); font:inherit; font-size:14px; outline:none; }
.assistant-ask-input:disabled { opacity:.7; }
.assistant-ask-send { flex:none; width:44px; height:44px; display:grid; place-items:center; border-radius:50%; border:0; cursor:pointer; color:#000;
  background:linear-gradient(180deg, rgba(255,255,255,.25), rgba(255,255,255,0) 55%), #208EA4; }
.assistant-ask-send:disabled { opacity:.4; cursor:default; }
.assistant-ask-send:focus-visible { outline:3px solid var(--brand); outline-offset:3px; }
.assistant-status { min-height:18px; margin:6px 18px 0; font-size:12px; line-height:1.5; color:var(--ink-soft); }
.assistant-privacy { margin:2px 18px calc(12px + env(safe-area-inset-bottom)); font-size:11.5px; line-height:1.6; color:var(--ink-faint); }
.assistant-privacy summary { min-height:32px; display:flex; align-items:center; cursor:pointer; }

@media (max-width:860px) {
  .rapha-launcher { right:max(16px, env(safe-area-inset-right)); bottom:calc(92px + env(safe-area-inset-bottom)); padding:6px; min-height:56px; }
  .rapha-launcher-label { display:none; }
  body.has-rapha .nav-fab { bottom:calc(160px + env(safe-area-inset-bottom)); }
  body[data-view="home"].has-rapha .rapha-launcher { bottom:calc(92px + env(safe-area-inset-bottom)); }
}
@media (max-width:600px) {
  .rapha-chat { width:100%; height:92dvh; max-height:92dvh; margin:auto 0 0; border-radius:var(--r-2xl, 28px) var(--r-2xl, 28px) 0 0; }
  .rapha-new { padding:8px 10px; }
}
@media (prefers-reduced-transparency:reduce) {
  .rapha-launcher, .rapha-chat { -webkit-backdrop-filter:none; backdrop-filter:none; background:var(--surface); }
}
@media (prefers-reduced-motion:reduce) { .rapha-typing span { animation:none; } }
