/* The assistant: a button that is a link, a panel that is a form, and an answer that is mostly
 * its own sources.
 *
 * The panel is anchored to the bottom of the viewport rather than the middle of the screen, so
 * on a phone the question box and the Ask button sit under the thumb rather than above the fold.
 * On a narrow screen it is a full-width sheet; on a wide one, a column beside the content.
 */

.asst {
  position: fixed;
  right: 18px;
  bottom: 18px;
  /* Above the sidebar and the preview bar, below a modal dialog — which the browser puts in its
     own layer anyway. */
  z-index: 38;
  display: flex;
  /* Reversed so the button stays on the bottom edge and the panel stacks above it, while the
     button keeps its place first in the tab order. */
  flex-direction: column-reverse;
  align-items: flex-end;
  gap: 10px;
  max-width: calc(100vw - 24px);
  /* The container spans a strip of the viewport it does not paint. Without this it would take
     taps meant for the page underneath. */
  pointer-events: none;
}
.asst-fab, .asst-panel { pointer-events: auto; }

/* ------------------------------------------------------------------- the button */

.asst-fab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 18px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: .9rem;
  font-weight: 560;
  box-shadow: 0 6px 20px rgba(11, 29, 66, .28);
  border: 1px solid var(--ink);
}
.asst-fab:hover { background: #16305f; text-decoration: none; }
.asst-fab:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.asst-fab .ic { flex: none; }

/* ------------------------------------------------------------------- the panel */

.asst-panel {
  width: min(480px, calc(100vw - 24px));
  max-height: min(78vh, 720px);
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  box-shadow: var(--shadow-lift);
  overflow: hidden;
}
.asst-panel[hidden] { display: none; }

.asst-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 14px 14px 18px;
  border-bottom: 1px solid var(--line);
}
/* The title takes the line and the close sits at the far edge; side by side they read as two
   headings jammed together. */
.asst-head strong { font-size: 1rem; color: var(--ink); flex: 1; }
.asst-head .btn { flex: none; }

/* Which audience is answering. It is a fact about the answer, so it reads as one — quiet on the
   investor side, and unmistakable when a sponsor is previewing somebody else's room. */
.asst-as {
  margin: 0;
  padding: 11px 18px;
  background: var(--accent-soft);
  color: #1a49a8;
  font-size: .8rem;
  line-height: 1.45;
  border-bottom: 1px solid var(--line);
}
.asst-as.preview { background: var(--warn-soft); color: #6d4205; }

.asst-form { padding: 16px 18px 6px; }
.asst-form label { margin-bottom: 5px; }
.asst-form select, .asst-form .ui-select { margin-bottom: 12px; }
/* Four lines, because that is about the length of a question somebody actually types here — "what
   does the model assume about churn, and what evidence is behind it" does not fit in two. */
.asst-form textarea { min-height: 96px; line-height: 1.5; }

/* The note explains the answer, so it belongs under the control that produces it, on its own line
   rather than wedged beside a button where it wraps into a column. */
.asst-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin: 12px 0 14px;
}
.asst-note {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: .8rem;
  line-height: 1.5;
}
.asst-actions .btn { min-height: 42px; padding: 0 22px; }

.asst-out { padding: 0 18px 18px; overflow-y: auto; flex: 1 1 auto; min-height: 0; }
.asst-out:empty { display: none; }

/* ------------------------------------------------------------------ the answer */

.asst-result { font-size: .9rem; }
.asst-text p { margin: 0 0 .7em; }
.asst-text p:last-child { margin-bottom: 0; }

/* A marker, not a footnote in the prose: small, raised, and unmistakably a link to the page it
   came from. */
.asst-cite {
  display: inline-block;
  margin-left: 2px;
  padding: 0 4px;
  border-radius: 4px;
  background: var(--accent-soft);
  color: #1a49a8;
  font-size: .72rem;
  font-weight: 640;
  vertical-align: .25em;
  line-height: 1.5;
}
a.asst-cite:hover { background: #dbe6fb; text-decoration: none; }

.asst-sources { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.asst-sources h3 { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.asst-sources ol { list-style: none; margin: 0; padding: 0; }
.asst-sources li { display: flex; gap: 9px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.asst-sources li:last-child { border-bottom: 0; }
.asst-sources .grow { min-width: 0; }
.asst-n {
  flex: none;
  width: 20px; height: 20px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 5px;
  background: var(--accent-soft);
  color: #1a49a8;
  font-size: .72rem;
  font-weight: 640;
}
.asst-quote {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: .82rem;
  line-height: 1.45;
  border-left: 2px solid var(--line-strong);
  padding-left: 8px;
}

/* Nothing found is a result, not an apology: it says what was looked through. */
.asst-none { margin: 0 0 .5em; font-weight: 560; color: var(--ink); }
.asst-searched {
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
  columns: 2;
  column-gap: 18px;
}
.asst-searched li {
  font-size: .82rem;
  color: var(--muted);
  break-inside: avoid;
  padding: 1px 0;
  overflow-wrap: anywhere;
}

.asst-working { color: var(--muted); font-size: .85rem; margin: 0; }

/* ------------------------------------------------------------------- the page */

/* The same thing on a page of its own, where the answer has room to be read. */
.card > .asst-as { border-radius: 8px; border-bottom: 0; margin-bottom: 14px; }
.card > .asst-result { font-size: .95rem; }
.card > .asst-result .asst-searched { columns: 3; }

@media (max-width: 640px) {
  .asst { right: 12px; bottom: 12px; left: 12px; align-items: stretch; }
  .asst-fab { justify-content: center; align-self: flex-end; }
  .asst-panel { width: 100%; max-height: 76vh; }
  .asst-searched, .card > .asst-result .asst-searched { columns: 1; }
}
