/* ── Help assistant: corner button + side panel (js/assistant.js) ─────────────────────────────────────────────────
   Button: navy TTC badge with the logo's ring of dots and a "?". Panel: slides in from the right under the topbar,
   above the Live AI Stream drawer (z 60), below the nav drawer (190+) and modals; full screen at ≤640 px. */

.assistant-fab {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 180;
  width: 42px;   /* a quarter smaller than the first 56 px (Alex, 2026-10-08) */
  height: 42px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid var(--brand-badge-ring);
  background: var(--brand-navy);
  box-shadow: 0 6px 18px var(--shadow);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform .15s ease;
}
.assistant-fab[hidden] { display: none; }
.assistant-fab:hover { transform: translateY(-2px); }
.assistant-fab:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }
.assistant-fab svg { width: 100%; height: 100%; display: block; }
/* The ring stands still and turns one full circle now and then (first ~6 s after load, then every 45 s), and
   once on hover — enough to be noticed, not enough to nag. */
.assistant-fab .af-ring { transform-origin: 32px 32px; animation: af-nudge 45s ease-in-out 6s infinite; }
.assistant-fab:hover .af-ring { animation: af-spin 1.4s ease-in-out 1; }
.assistant-fab .af-q { fill: var(--brand-orange); font: 700 30px/1 var(--font); }
.assistant-open .assistant-fab { opacity: 0; pointer-events: none; }

@keyframes af-spin { from { transform: rotate(0); } to { transform: rotate(360deg); } }
@keyframes af-nudge {
  0%        { transform: rotate(0); }
  4%, 100%  { transform: rotate(360deg); }
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.assistant-panel {
  position: fixed;
  top: var(--topbar-height);
  right: 0;
  bottom: 0;
  z-index: 170;
  width: min(400px, 100vw);
  display: flex;
  flex-direction: column;
  background: var(--bg2);
  border-left: 1px solid var(--border2);
  box-shadow: -8px 0 24px var(--shadow);
  transform: translateX(100%);
  visibility: hidden;
  transition: transform .2s ease, visibility 0s linear .2s;
}
.assistant-open .assistant-panel { transform: none; visibility: visible; transition: transform .2s ease; }

.ap-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.ap-head .ap-badge { width: 30px; height: 30px; flex-shrink: 0; }
.ap-title { font-weight: 600; font-size: 14px; color: var(--text); }
.ap-head-text { min-width: 0; flex: 1; }
.ap-close {
  background: none; border: 0; color: var(--text2); font-size: 20px; line-height: 1;
  padding: 4px 8px; border-radius: var(--radius-sm); cursor: pointer;
}
.ap-close:hover { background: var(--chip-bg); color: var(--text); }

.ap-log {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.ap-intro { font-size: 13px; color: var(--text2); line-height: 1.5; margin-top: auto; }
.ap-intro p { margin: 4px 0 0; }
.ap-hello { font-size: 16px; font-weight: 600; color: var(--text); }
/* Suggested questions: a short list of rows, as Notion's assistant opens. */
.ap-suggest { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.ap-sugg {
  width: 100%; display: flex; gap: 8px; align-items: baseline;
  background: none; border: 0; border-radius: var(--radius-sm); padding: 7px 8px;
  color: var(--text); font: inherit; font-size: 13px; text-align: left; cursor: pointer;
}
.ap-sugg > span { color: var(--blue); flex-shrink: 0; }
.ap-sugg:hover { background: var(--chip-bg); }
.ap-sugg:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
.ap-sugg-loading { height: 30px; margin: 2px 0; border-radius: var(--radius-sm); background: var(--chip-bg); opacity: .6; }

/* Scope chip above the input: what the assistant looks at (This page / All of CMAI). */
.ap-scope { position: relative; padding: 8px 12px 0; border-top: 1px solid var(--border); }
.ap-chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
  background: var(--chip-bg); color: var(--text2); border: 1px solid var(--border2); border-radius: 999px;
  font: inherit; font-size: 12px; padding: 3px 10px; cursor: pointer;
}
.ap-chip:hover { color: var(--text); border-color: var(--blue-border); }
.ap-chip:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
.ap-chip.all { background: var(--blue-bg); border-color: var(--blue-border); color: var(--text); }
.ap-chip-text { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ap-chip-icon { color: var(--blue); flex-shrink: 0; }
.ap-chip-caret { color: var(--text3); flex-shrink: 0; }
.ap-scope-menu {
  position: absolute; left: 12px; right: 12px; bottom: calc(100% + 4px); z-index: 2;
  display: flex; flex-direction: column; padding: 4px;
  background: var(--surface); border: 1px solid var(--border2); border-radius: var(--radius-md);
  box-shadow: 0 6px 24px var(--shadow);
}
.ap-scope-menu button {
  display: flex; gap: 8px; align-items: flex-start; text-align: left;
  background: none; border: 0; border-radius: var(--radius-sm); padding: 7px 8px;
  color: var(--text); font: inherit; font-size: 13px; cursor: pointer;
}
.ap-scope-menu button:hover, .ap-scope-menu button:focus-visible { background: var(--chip-bg); outline: none; }
.ap-scope-menu button[aria-checked="true"] { box-shadow: inset 2px 0 0 var(--blue); }
.ap-scope-sub { display: block; font-size: 11px; color: var(--text3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 300px; }

.ap-msg { max-width: 92%; font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }
.ap-msg.user, .ap-text { white-space: pre-wrap; }
.ap-msg.user {
  align-self: flex-end;
  background: var(--blue-bg);
  border: 1px solid var(--blue-border);
  color: var(--text);
  padding: 8px 11px;
  border-radius: 12px 12px 2px 12px;
}
.ap-msg.bot {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 12px;
  border-radius: 12px 12px 12px 2px;
}
.ap-msg.bot strong { font-weight: 600; color: var(--text); }
.ap-msg.error { border-color: var(--amber-border); background: var(--amber-bg); }
/* The answer is still being written: a soft caret at the end (not animated for people who ask for less motion). */
.ap-msg.streaming .ap-text::after { content: "▍"; color: var(--text3); margin-left: 1px; animation: ap-caret 1s steps(2, start) infinite; }
@keyframes ap-caret { to { visibility: hidden; } }
@media (prefers-reduced-motion: reduce) { .ap-msg.streaming .ap-text::after { animation: none; } }
.ap-links { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; margin-top: 8px; }
.ap-go {
  background: var(--blue-bg); color: var(--text); border: 1px solid var(--blue); border-radius: var(--radius-sm);
  font: inherit; font-size: 12px; font-weight: 600; padding: 5px 10px; cursor: pointer; text-align: left;
}
.ap-go:hover { box-shadow: inset 0 0 0 1px var(--blue); filter: brightness(1.2); }
.ap-go:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.ap-feedback { display: flex; gap: 6px; margin-top: 6px; }
.ap-feedback button {
  background: none; border: 1px solid var(--border2); border-radius: var(--radius-sm);
  font-size: 12px; padding: 1px 7px; cursor: pointer; color: var(--text2);
}
.ap-feedback button[aria-pressed="true"] { border-color: var(--blue); background: var(--blue-bg); }
.ap-feedback button:disabled { cursor: default; }
.ap-thinking { align-self: flex-start; font-size: 12px; color: var(--text3); }
.ap-thinking::after { content: "…"; animation: ap-dots 1.2s steps(3, end) infinite; display: inline-block; width: 1.2em; overflow: hidden; vertical-align: bottom; }
@keyframes ap-dots { from { width: 0; } to { width: 1.2em; } }

.ap-form {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 8px 12px 12px;
}
.ap-form textarea {
  flex: 1;
  resize: none;
  min-height: 38px;
  max-height: 140px;
  padding: 8px 10px;
  font: 13px/1.4 var(--font);
  color: var(--text);
  background: var(--bg3);
  border: 1px solid var(--border-control);
  border-radius: var(--radius-md);
}
.ap-form textarea:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
.ap-form .btn { flex-shrink: 0; }
.ap-note { font-size: 10px; color: var(--text3); padding: 0 12px 10px; }

@media (max-width: 640px) {
  .assistant-fab { right: 14px; bottom: 14px; width: 38px; height: 38px; }
  .assistant-panel { top: 0; width: 100vw; z-index: 230; border-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .assistant-fab .af-ring, .assistant-fab:hover .af-ring, .ap-thinking::after { animation: none; }
  .assistant-fab:hover { transform: none; }
  .assistant-panel, .assistant-open .assistant-panel { transition: none; }
}
