/* PolitiSizeIT: the research view's reading pane, Phase 1 (public/research-view.js; AGENTS gotcha 154; the approved
   Aurora mockup's pane and layout, without page pictures). Theme tokens only (theme.css), so light and dark follow the
   page; gold (--map-pick) marks a matched sentence; nothing blue or red (gotcha 63). Layout boxes never transition
   (gotcha 75): the chat makes room in the same frame the pane appears.

   Three homes, decided by research-view.js (and chat-state.js before the first paint) as classes on <html>:
   - rv-open + rv-beside: a column at the right edge; the body makes room with its right padding, the sidebar's way.
   - rv-open on a window too narrow for that (but wider than a phone): the same panel over the chat from the right.
   - a phone (760px and under): a sheet that rises to about 45% of the screen and stops above the message box. */

.rv { display: none; }
html.rv-open .rv { display: flex; }

.rv,
.rv * { transition: none; }

.rv {
  position: fixed;
  z-index: 5;
  top: 0;
  right: 0;
  bottom: 0;
  width: var(--rv-w, 420px);
  flex-direction: column;
  min-width: 0;
  background: var(--surface);
  color: var(--text);
  border-left: 1px solid var(--line);
  font-family: var(--sans);
  padding-top: var(--safe-top);
}
/* Beside the chat: the page makes room, as it does for the sidebar on the left (app.css --side-w). */
html.rv-open.rv-beside body:has(.chat-stage) { padding-right: var(--rv-w, 420px); }
/* Over the chat (a laptop window too narrow for both): a panel with a shadow, under the sheets' dim (9). */
html.rv-open:not(.rv-beside) .rv {
  z-index: 8;
  width: min(420px, 92vw);
  box-shadow: 0 0 0 1px var(--line), 0 18px 50px -18px rgba(11, 11, 16, 0.28);
}

@media (max-width: 760px) {
  /* A sheet that stops above the message box (its height from research-view.js, --rv-cmp). Under the phone's box
     (z 30), the + sheet (60) and the drawer (70); it never touches the screen's top or bottom edge (gotcha 101). */
  .rv,
  html.rv-open:not(.rv-beside) .rv {
    top: auto;
    left: 0;
    right: 0;
    bottom: var(--rv-cmp, 76px);
    width: auto;
    height: min(45dvh, 420px);
    padding-top: 0;
    border-left: 0;
    border-radius: 22px 22px 0 0;
    z-index: 25;
    box-shadow: 0 0 0 1px var(--line), 0 -12px 40px -18px rgba(11, 11, 16, 0.32);
  }
  html.rv-open .chat-stage .thread { padding-bottom: calc(min(45dvh, 420px) + 16px); }
  /* The box's fade would lie over the sheet's last lines (the mockup's rule). */
  html.rv-open .composer-wrap::before { display: none; }
}

/* ---- head ---- */
.rv-head {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 56px;
  padding: 6px 8px 6px 16px;
  border-bottom: 1px solid var(--line);
}
.rv-id { display: flex; align-items: center; gap: 10px; min-width: 0; }
.rv-ico { flex: none; width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-2); color: var(--text-dim); }
.rv-name { display: flex; flex-direction: column; min-width: 0; }
.rv-title { margin: 0; font-size: 14px; font-weight: 600; line-height: 18px; }
.rv-title:focus { outline: none; }
.rv-title:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; border-radius: 4px; }
.rv-status { font-size: 12px; line-height: 16px; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rv-close {
  flex: none;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--text-dim);
  cursor: pointer;
}
@media (hover: hover) { .rv-close:hover { background: var(--ink-soft); color: var(--text); } }
.rv-close:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 1px; }
/* A thin moving edge while it reads, in the thinking colours the chat's own waiting look uses. */
.rv-head { position: relative; }
.rv.is-live .rv-head::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: linear-gradient(90deg, var(--vg-think-0), var(--vg-think-4), var(--vg-think-1), var(--vg-think-2), var(--vg-think-3), var(--vg-think-0));
  background-size: 200% 100%;
  animation: rv-edge 3s linear infinite;
}
@keyframes rv-edge { from { background-position: 0 0; } to { background-position: -200% 0; } }

/* ---- the list ---- */
.rv-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 12px 12px calc(14px + var(--safe-bottom)); }
@media (max-width: 760px) { .rv-body { padding-bottom: 14px; } }
.rv-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.rv-item {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg);
  min-width: 0;
  overflow-wrap: anywhere;
}
.rv-item-head { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 13.5px; line-height: 20px; }
.rv-item-ico { flex: none; width: 20px; height: 20px; display: grid; place-items: center; color: var(--text-faint); }
.rv-item-name { min-width: 0; font-weight: 600; color: var(--text); }
.rv-pdf-label { font-weight: 600; }
.rv-host { font-weight: 600; }
.rv-search .rv-item-name { font-weight: 500; color: var(--text-dim); }
.rv-words { margin: 6px 0 0; font-family: var(--reply-serif); font-size: 15px; line-height: 21px; color: var(--text); }
.rv-sub { margin: 8px 0 4px; font-size: 12px; line-height: 16px; font-weight: 500; color: var(--text-faint); }
.rv-results { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.rv-results li { display: flex; flex-wrap: wrap; gap: 0 6px; font-size: 13px; line-height: 18px; color: var(--text-dim); }
.rv-results .rv-host { font-weight: 500; color: var(--text); }
.rv-rtitle { color: var(--text-faint); }
.rv-note { margin: 6px 0 0; font-size: 13px; line-height: 18px; color: var(--text-faint); }
.rv-item.is-live .rv-note { color: var(--text-dim); }

/* "Official" is our code's word, never the page's: ink, not a colour. */
.rv-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 6px 0 0;
  min-height: 22px;
  padding: 0 9px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  font-size: 11.5px;
  line-height: 16px;
  font-weight: 500;
  color: var(--text-dim);
}
.rv-badge.is-official { padding-left: 7px; border-color: transparent; background: var(--ink-soft); color: var(--text); font-weight: 600; }
.rv-badge svg { flex: none; }
.rv-ptitle { margin: 8px 0 0; font-size: 13px; line-height: 18px; color: var(--text-dim); }

.rv-quotes { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.rv-quote { display: flex; gap: 9px; align-items: flex-start; padding: 8px 11px; border-radius: 10px; background: var(--surface-2); }
.rv-mark { flex: none; width: 8px; height: 8px; margin-top: 6px; border-radius: 2px; background: var(--map-pick); box-shadow: 0 0 0 1px var(--map-pick-line); }
.rv-qbody { min-width: 0; display: flex; flex-direction: column; }
.rv-matched { font-family: var(--sans); font-size: 11.5px; line-height: 15px; font-weight: 600; color: var(--text-faint); letter-spacing: .01em; }
.rv-qtext { font-family: var(--reply-serif); font-size: 14.5px; line-height: 21px; color: var(--text); }

.rv-legend,
.rv-foot { margin: 12px 4px 0; font-size: 11.5px; line-height: 16px; color: var(--text-faint); }
.rv-legend[hidden] { display: none; }

/* ---- the reply's button, under its steps ---- */
.rv-chip-row { display: flex; margin: 6px 0 4px; }
.rv-chip-msg { padding: 0; }
.rv-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 14px 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-dim);
  font: 500 13px/18px var(--sans);
  cursor: pointer;
  box-shadow: var(--shadow-box);
  transition: none;
}
@media (hover: hover) { .rv-chip:hover { color: var(--text); border-color: var(--text-faint); } }
.rv-chip:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.rv-chip[aria-expanded="true"] { color: var(--text); border-color: var(--text-faint); }
@media (pointer: coarse) { .rv-chip { min-height: 44px; } }
.rv-chip-dot { flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--text-faint); }
.rv-chip.is-live .rv-chip-dot { background: conic-gradient(var(--vg-think-0), var(--vg-think-2), var(--vg-think-3), var(--vg-think-0)); animation: rv-spin 2.4s linear infinite; }
@keyframes rv-spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .rv.is-live .rv-head::after,
  .rv-chip.is-live .rv-chip-dot { animation: none; }
}
@media (forced-colors: active) {
  .rv-mark { background: Highlight; box-shadow: none; }
  .rv.is-live .rv-head::after { display: none; }
}
