/* ── Citations ──────────────────────────────────────────────
   Inline: small numbered pills that invert on hover and show a card with the
   source. Under the answer: one quiet "N sources" pill in the action row that
   opens a list — one row per document, however many passages it lent. */

/* Inline, not inline-block: an atomic box would let the line break between a
   marker and the punctuation after it. */
.cite {
  display: inline; margin: 0 1px; padding: 1px 5.5px;
  font-size: 10.5px; font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums;
  vertical-align: 0.14em;
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
  color: var(--muted); background: var(--surface-hi);
  border-radius: var(--r-pill); text-decoration: none;
  transition: color 0.15s var(--ease), background 0.15s var(--ease);
}
.cite:hover, .cite:focus-visible { color: var(--on-accent); background: var(--accent); outline: none; }

.cite-card {
  position: fixed; z-index: 1000; top: 0; left: 0;
  width: min(320px, calc(100vw - 16px));
  display: grid; gap: 6px; padding: 12px 14px;
  background: var(--bg-raised); color: var(--text);
  border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-md);
  font-size: 13px; line-height: 1.45;
  pointer-events: none; visibility: hidden; opacity: 0; transform: translateY(4px);
  transition: opacity 0.14s var(--ease), transform 0.14s var(--ease), visibility 0.14s;
}
.cite-card.is-on { visibility: visible; opacity: 1; transform: none; }
.cite-card-from { display: flex; align-items: center; gap: 7px; color: var(--subtle); font-size: 12px; }
.cite-card-title, .cite-card-snippet { display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; }
.cite-card-title { font-weight: 600; -webkit-line-clamp: 2; }
.cite-card-snippet { color: var(--muted); -webkit-line-clamp: 4; }

/* A source's mark: the site's initial, or a page for the knowledge base. */
.src-badge {
  flex: none; display: inline-grid; place-items: center;
  width: 18px; height: 18px; border-radius: 50%;
  font-size: 10px; font-weight: 600; color: var(--muted);
  background: var(--bg-raised); box-shadow: inset 0 0 0 1px var(--line-hi);
}
.src-badge svg { width: 11px; height: 11px; }

.sources-pill {
  display: inline-flex; align-items: center; gap: 7px;
  height: 28px; padding: 0 9px 0 5px;
  font: inherit; font-size: 12.5px; color: var(--muted);
  background: transparent; border: 1px solid var(--line); border-radius: var(--r-pill);
  cursor: pointer;
  transition: color 0.15s var(--ease), background 0.15s var(--ease), border-color 0.15s var(--ease);
}
.sources-pill:hover, .sources-pill.is-open { color: var(--text); background: var(--surface-hi); border-color: var(--line-hi); }
.sources-pill:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* The first mark sits on top, like a fanned hand of cards. */
.src-stack { display: inline-flex; }
.src-stack .src-badge { position: relative; }
.src-stack .src-badge + .src-badge { margin-left: -4px; }
.src-stack .src-badge:nth-child(1) { z-index: 3; }
.src-stack .src-badge:nth-child(2) { z-index: 2; }
.src-stack .src-badge { box-shadow: inset 0 0 0 1px var(--line-hi), 0 0 0 2px var(--bg); }
.sources-chevron { display: inline-grid; transition: transform 0.2s var(--ease); }
.sources-pill.is-open .sources-chevron { transform: rotate(180deg); }
.sources-chevron svg { width: 13px; height: 13px; }

.sources-list {
  list-style: none; margin: 4px 0 2px; padding: 4px;
  width: min(560px, 100%);
  display: grid; gap: 1px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  animation: sources-in 0.2s var(--ease);
}
@keyframes sources-in { from { opacity: 0; transform: translateY(-4px); } }

.source-row {
  display: flex; align-items: center; gap: 10px;
  min-height: 46px; padding: 6px 10px;
  border-radius: 11px; color: var(--text); text-decoration: none;
  transition: background 0.15s var(--ease);
}
.source-row:hover, .source-row:focus-visible { background: var(--surface-hi); outline: none; }
.source-row-n { flex: none; width: 14px; color: var(--subtle); font-size: 12px; font-variant-numeric: tabular-nums; text-align: right; }
.source-row-text { flex: 1; min-width: 0; display: grid; gap: 1px; }
.source-row-title, .source-row-where { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source-row-title { font-size: 13.5px; font-weight: 500; }
.source-row-where { font-size: 12px; color: var(--subtle); }
.source-row-open { flex: none; display: inline-grid; color: var(--subtle); opacity: 0; transition: opacity 0.15s var(--ease); }
.source-row:hover .source-row-open, .source-row:focus-visible .source-row-open { opacity: 1; }
.source-row-open svg { width: 14px; height: 14px; }

@media (hover: none), (pointer: coarse) {
  .sources-pill { height: 36px; padding-right: 12px; }
  .source-row { min-height: 52px; }
  .source-row-open { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .sources-list { animation: none; }
  .cite-card, .sources-chevron { transition: none; }
}
