/* Layout and components. Tokens live in theme.css and are never redefined
   here -- every colour below is a var(), so the light/dark switch is one file.

   The proportions are ported from the mobile app rather than reinvented: the
   transcript is a reading column, the composer is a fixed row under it, and
   the source chips scroll horizontally so a long document title never forces
   the answer narrow. */

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--family);
  font-size: var(--font-body);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }

/* ---------- shell ---------- */
.shell { display: flex; min-height: 100vh; }
.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.chat-title {
  flex: 1;
  text-align: center;
  margin: 0;
  min-width: 0;
  font-size: var(--font-h3);
  font-weight: var(--weight-semibold);
}
/* The heading's look on the button inside it, so the wordmark is clickable
   without announcing itself as a control in the middle of the bar. The
   ellipsis lives here rather than on the h1: the button is the element that
   actually holds the text, so it is the one that can overflow. */
.chat-title-button {
  max-width: 100%;
  padding: var(--space-xs) var(--space-sm);
  border: 0;
  border-radius: var(--radius-md);
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-title-button:hover { background: var(--surface-alt); }
.chat-title-button:active { opacity: .7; }
.status-line {
  margin: 0;
  padding: var(--space-sm) var(--space-lg);
  background: var(--warn-bg);
  color: var(--warn);
  font-size: var(--font-tiny);
  text-align: center;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 var(--space-xs);
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
}
.icon-button:hover { background: var(--surface-alt); color: var(--text); }
.icon-button.danger:hover { background: var(--danger-bg); color: var(--danger); }

/* ---------- sidebar ---------- */
.sidebar {
  width: 268px;
  flex-shrink: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
}
.sidebar-head {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border);
}
.sidebar-brand {
  flex: 1;
  font-size: var(--font-h3);
  font-weight: var(--weight-bold);
  letter-spacing: -0.5px;
}
.new-chat {
  border: 1px solid var(--accent-border);
  background: var(--accent-bg);
  color: var(--accent);
  font-size: var(--font-tiny);
  font-weight: var(--weight-semibold);
  padding: 6px var(--space-md);
  border-radius: var(--radius-pill);
  cursor: pointer;
}
.new-chat:hover { background: var(--accent-border); }

.sidebar-search {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin: var(--space-sm) var(--space-md) 0;
  padding: 0 var(--space-md);
  background: var(--surface-alt);
  border-radius: var(--radius-md);
  color: var(--text-faint);
}
.sidebar-search input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: var(--font-small);
  padding: var(--space-sm) 0;
  outline: none;
}

.conversations { flex: 1; overflow-y: auto; padding: var(--space-sm); }
.sidebar-empty {
  color: var(--text-faint);
  font-size: var(--font-small);
  text-align: center;
  padding: var(--space-xl) var(--space-md);
}
.group-title {
  color: var(--text-dim);
  font-size: var(--font-tiny);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: var(--space-md) var(--space-sm) var(--space-xs);
}
.conversation {
  position: relative;
  display: flex;
  align-items: center;
  border-radius: var(--radius-md);
}
.conversation:hover { background: var(--surface-alt); }
.conversation.active { background: var(--accent-bg); }
.conversation-open {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: flex-start;
  padding: var(--space-sm) var(--space-md);
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.conversation-title {
  max-width: 100%;
  font-size: var(--font-small);
  font-weight: var(--weight-medium);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conversation-time { color: var(--text-faint); font-size: var(--font-tiny); }
/* Revealed on hover, but always present for keyboard users.
   Overlaid rather than laid out: opacity:0 still reserves its box, and at a
   268px sidebar those two buttons took 78px -- 29% of the rail -- from the
   title permanently, clipping "What is a STIR sequence for?" to "What is a
   STIR seq..." while the space sat empty. Absolute keeps them reachable and
   gives the width back to the name. */
.conversation-actions {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  gap: 2px;
  padding-right: var(--space-xs);
  opacity: 0;
  pointer-events: none;
  /* A fade behind the buttons, so a long title runs under them rather than
     colliding with them at the moment they appear. */
  background: linear-gradient(to right, transparent, var(--surface-alt) 24%);
  padding-left: var(--space-xl);
  border-radius: var(--radius-md);
}
.conversation:hover .conversation-actions,
.conversation:focus-within .conversation-actions { opacity: 1; pointer-events: auto; }
.conversation.active .conversation-actions {
  background: linear-gradient(to right, transparent, var(--accent-bg) 24%);
}

/* ---------- chat ---------- */
.chat { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.chat-body { position: relative; flex: 1; min-height: 0; display: flex; }
.transcript {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-lg);
  scroll-behavior: auto;
}
.turns, .transcript > .turn, .transcript > .working {
  max-width: 760px;
  margin-inline: auto;
  width: 100%;
}

.turn.user { display: flex; justify-content: flex-end; margin-bottom: var(--space-lg); padding-left: var(--space-xxl); }
.user-bubble {
  background: var(--user-bubble);
  color: var(--user-text);
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-xl);
  border-bottom-right-radius: var(--radius-sm);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.turn.assistant { margin-bottom: var(--space-xl); }

/* ---------- markdown ---------- */
.md { overflow-wrap: anywhere; }
.md p { margin: 0 0 var(--space-sm); line-height: var(--line-height); }
.md h1 { font-size: var(--font-h1); margin: var(--space-xs) 0 var(--space-sm); }
.md h2 { font-size: var(--font-h2); margin: var(--space-xs) 0 var(--space-sm); }
.md h3 { font-size: var(--font-h3); margin: var(--space-xs) 0 var(--space-sm); }
.md h4, .md h5, .md h6 { font-size: var(--font-body, 1em); margin: var(--space-xs) 0 var(--space-sm); }
.md ul, .md ol { margin: 0 0 var(--space-sm); padding-left: 26px; line-height: var(--line-height); }
.md li { margin-bottom: var(--space-xs); }
.md li::marker { color: var(--text-dim); }
.md li > p { margin: 0; }
.md li > ul, .md li > ol { margin: var(--space-xs) 0 0; }
.md blockquote > :last-child { margin-bottom: 0; }
.md a { color: var(--accent); text-decoration: underline; }
.md img { max-width: 100%; height: auto; border-radius: var(--radius-sm); }
.md blockquote {
  margin: 0 0 var(--space-sm);
  padding-left: var(--space-md);
  border-left: 3px solid var(--border-strong);
  color: var(--text-dim);
}
.md pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-md);
  margin: 0 0 var(--space-sm);
  overflow-x: auto;
}
.md pre code { font-family: var(--family-mono); font-size: var(--font-small); }
.md code {
  font-family: var(--family-mono);
  font-size: var(--font-small);
  color: var(--accent);
  background: var(--code-bg);
  padding: 0 4px;
  border-radius: 4px;
}
.md hr { height: 1px; border: 0; background: var(--border); margin: var(--space-md) 0; }
.md-table-wrap { overflow-x: auto; margin: 0 0 var(--space-sm); }
.md table { border-collapse: collapse; font-size: var(--font-small); overflow-wrap: normal; }
.md th, .md td { border: 1px solid var(--border); padding: 4px 8px; text-align: left; vertical-align: top; }
.md th { color: var(--text-dim); font-weight: 600; background: var(--code-bg); }
.md td > code, .md th > code { white-space: nowrap; }

/* Citation markers. The valid form is a button; the invented form is a span
   that is struck through and NOT interactive -- see markdown.js. */
.cite {
  display: inline;
  font-weight: var(--weight-bold);
  font-size: inherit;
  color: var(--accent);
  background: var(--accent-bg);
  border: 0;
  border-radius: 4px;
  padding: 1px 4px;
  cursor: pointer;
}
button.cite:hover { background: var(--accent-border); }
.cite-inert { cursor: default; }
.cite-invalid {
  color: var(--danger);
  background: transparent;
  text-decoration: line-through;
  font-weight: var(--weight-semibold);
  cursor: default;
  padding: 0;
}

/* ---------- figures ---------- */
.figures { display: flex; flex-wrap: wrap; gap: var(--space-md); margin: var(--space-sm) 0; }
.figure { margin: 0; max-width: 320px; }
.figure-button { display: block; padding: 0; border: 0; background: none; cursor: zoom-in; }
.figure img {
  max-width: 100%;
  height: auto;
  display: block;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}
.figure figcaption {
  color: var(--text-dim);
  font-size: var(--font-tiny);
  line-height: 18px;
  margin-top: var(--space-xs);
}

/* ---------- sources ---------- */
.sources {
  display: flex;
  gap: var(--space-sm);
  align-items: center;
  margin-top: var(--space-sm);
  overflow-x: auto;
  scrollbar-width: thin;
  padding-bottom: var(--space-xs);
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  max-width: 280px;
  min-height: 36px;
  padding: 0 var(--space-md) 0 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  cursor: pointer;
}
button.chip:hover { background: var(--accent-bg); }
.chip-index {
  min-width: 22px;
  height: 22px;
  line-height: 22px;
  text-align: center;
  border-radius: var(--radius-pill);
  background: var(--accent-bg);
  color: var(--accent);
  font-size: var(--font-tiny);
  font-weight: var(--weight-bold);
  padding: 0 5px;
}
.chip-title {
  font-size: var(--font-tiny);
  font-weight: var(--weight-medium);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Marks a citation that came from the user's own uploaded documents
   rather than the shared corpus. The icon is the whole signal -- the
   library's name is in the citation sheet, not competing with the
   document title for room on the chip. */
.chip-library {
  display: inline-flex;
  align-items: center;
  color: var(--text-faint);
  flex: 0 0 auto;
}
/* The ungrounded warning: the answer did not consult the library at all. */
.chip-warn {
  background: var(--warn-bg);
  border-color: transparent;
  color: var(--warn);
  padding-left: var(--space-md);
  cursor: default;
}
.chip-warn span { font-size: var(--font-tiny); font-weight: var(--weight-medium); }
/* Under a verified answer: the per-sentence citation check (chat.js renderQuoteCheck). */
.quote-removed {
  margin: var(--space-sm) 0 0;
  padding: var(--space-sm) var(--space-md);
  background: var(--warn-bg);
  color: var(--warn);
  border-radius: var(--radius-sm);
  font-size: var(--font-small);
  font-weight: var(--weight-medium);
}
.quote-check { margin-top: var(--space-sm); font-size: var(--font-small); color: var(--text-dim); }
.quote-check summary { cursor: pointer; font-weight: var(--weight-medium); padding: var(--space-xs) 0; }
.quote-check[open] summary { margin-bottom: var(--space-xs); }
.quote-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: var(--space-sm) var(--space-md);
  margin-bottom: var(--space-xs);
}
.quote-head { display: flex; align-items: center; gap: var(--space-sm); flex-wrap: wrap; }
.quote-verdict {
  font-family: var(--family-mono);
  font-size: var(--font-tiny);
  font-weight: var(--weight-medium);
  border-radius: var(--radius-pill);
  padding: 0 var(--space-sm);
}
.quote-verdict.ok { color: var(--success); background: var(--accent-bg); }
.quote-verdict.bad { color: var(--danger); background: var(--danger-bg); }
.quote-where { font-family: var(--family-mono); font-size: var(--font-tiny); color: var(--text-faint); }
.quote-text { margin-top: var(--space-xs); color: var(--text); overflow-wrap: anywhere; }
.quote-detail { margin-top: var(--space-xs); font-size: var(--font-tiny); color: var(--text-faint); overflow-wrap: anywhere; }
.quote-raw {
  margin: var(--space-xs) 0 0;
  padding: var(--space-sm);
  background: var(--code-bg);
  border-radius: var(--radius-sm);
  font-family: var(--family-mono);
  font-size: var(--font-tiny);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
/* Under an answer that streamed but could not be stored. */
.turn-note-error {
  margin: var(--space-sm) 0 0;
  padding: var(--space-sm) var(--space-md);
  background: var(--danger-bg);
  color: var(--danger);
  border-radius: var(--radius-sm);
  font-size: var(--font-tiny);
}

/* ---------- working indicator ---------- */
.working {
  display: inline-flex;
  flex-direction: column;
  gap: var(--space-sm);
  align-self: flex-start;
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  margin-bottom: var(--space-lg);
  max-width: 100%;
}
.working-line { display: flex; align-items: center; gap: var(--space-sm); }
.working-label { font-size: var(--font-small); font-weight: var(--weight-medium); }
.working-clock {
  color: var(--text-faint);
  font-size: var(--font-tiny);
  font-variant-numeric: tabular-nums;
  margin-left: var(--space-xs);
}
.working-query {
  color: var(--text-dim);
  font-size: var(--font-tiny);
  line-height: 19px;
  padding-left: 28px;
}
.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--accent-border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2.4s; }
}

/* ---------- jump-to-latest ---------- */
.jump-pill {
  position: absolute;
  bottom: var(--space-md);
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 var(--space-lg) 0 var(--space-md);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--accent);
  font-size: var(--font-small);
  font-weight: var(--weight-medium);
  box-shadow: var(--shadow-pill);
  cursor: pointer;
}
.jump-pill:hover { background: var(--accent-bg); }

/* ---------- empty state ---------- */
.empty-state {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
  justify-content: center;
  min-height: 60vh;
  padding: var(--space-xl) 0;
}
.blurb { margin: 0; color: var(--text-dim); line-height: var(--line-height); max-width: 460px; }
/* Prompt tips: icon, title, one line. Deliberately not boxed, so they do
   not read as buttons next to the suggestions below them. */
.tips { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-lg); margin-bottom: var(--space-lg); }
.tip { display: flex; flex-direction: column; gap: var(--space-sm); }
.tip-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 10px;
  background: var(--accent-bg); color: var(--accent);
}
.tip-title { font-size: var(--font-small); font-weight: var(--weight-medium); color: var(--text); margin-bottom: 2px; }
.tip-body { font-size: var(--font-tiny); line-height: 1.45; color: var(--text-dim); }
.suggestions-label { font-size: var(--font-tiny); color: var(--text-faint); margin-bottom: calc(var(--space-sm) - var(--space-lg)); }
@media (max-width: 640px) {
  .tips { grid-template-columns: 1fr; gap: var(--space-md); }
  .tip { flex-direction: row; align-items: center; gap: var(--space-md); }
  .tip-icon { flex: 0 0 auto; }
}
.suggestions { display: flex; flex-direction: column; gap: var(--space-sm); }
.suggestion {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  min-height: 56px;
  padding: var(--space-md) var(--space-lg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  font-size: var(--font-small);
  font-weight: var(--weight-medium);
  line-height: 21px;
  text-align: left;
  cursor: pointer;
}
.suggestion:hover { background: var(--surface-alt); }
.suggestion .icon { color: var(--text-faint); flex: 0 0 auto; }

/* ---------- composer ---------- */
.composer { background: var(--bg); padding: var(--space-sm) var(--space-md) var(--space-md); }
.composer-field {
  display: flex;
  align-items: flex-end;
  gap: var(--space-sm);
  max-width: 760px;
  margin-inline: auto;
  padding: 6px 6px 6px var(--space-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
}
.composer-field:focus-within { border-color: var(--accent-border); }
.composer-input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: none;
  resize: none;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: var(--font-body);
  line-height: var(--line-height);
  padding: var(--space-sm) 0;
  max-height: 140px;
  overflow-y: hidden;
}
.composer-input::placeholder { color: var(--text-faint); }
.send {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--surface-alt);
  color: var(--text-faint);
  cursor: pointer;
  transition: transform 0.08s ease;
}
.send.ready { background: var(--accent-solid); color: var(--accent-text); }
.send:disabled { cursor: default; }
.send:active { transform: scale(0.88); }
/* Stop: a red square, because it ends something rather than sending it. */
.send.stop { background: var(--danger); color: var(--accent-text); }
.stop-glyph { width: 14px; height: 14px; border-radius: 3px; background: currentColor; }
/* The vendor filter: a quiet row under the field, aligned with its text. */
.composer-options {
  display: flex;
  max-width: 760px;
  margin: var(--space-xs) auto 0;
  padding-inline: var(--space-sm);
}
.composer-options[hidden] { display: none; }
.composer-options { position: relative; }
/* The AI disclosure: always visible, never louder than the vendor row. */
.ai-disclosure {
  max-width: 760px;
  margin: var(--space-xs) auto 0;
  text-align: center;
  color: var(--text-faint);
  font-size: var(--font-tiny);
  /* AI_DISCLOSURE is two sentences on two lines. */
  white-space: pre-line;
}
.vendor-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text-dim);
  font: inherit;
  font-size: var(--font-tiny);
  font-weight: var(--weight-medium);
  cursor: pointer;
}
.vendor-pill:hover { background: var(--surface-alt); color: var(--text); }
.vendor-pill:focus-visible { outline: none; border-color: var(--accent-border); }
/* A filter is on: tinted so a narrowed search never goes unnoticed. */
.vendor-pill.active { background: var(--accent-bg); border-color: var(--accent-border); color: var(--accent); }
.vendor-menu {
  position: absolute;
  bottom: calc(100% + 6px);
  left: var(--space-sm);
  z-index: 20;
  min-width: 240px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sheet);
}
.vendor-menu[hidden] { display: none; }
.vendor-menu-head {
  padding: 6px 10px 4px;
  color: var(--text-faint);
  font-size: var(--font-tiny);
  font-weight: var(--weight-semibold);
}
.vendor-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: var(--font-small);
  text-align: left;
  cursor: pointer;
}
.vendor-item:hover, .vendor-item:focus-visible { background: var(--surface-alt); outline: none; }
.vendor-tick { color: var(--accent); visibility: hidden; }
.vendor-item[aria-checked="true"] { font-weight: var(--weight-semibold); }
.vendor-item[aria-checked="true"] .vendor-tick { visibility: visible; }
.vendor-menu-foot {
  margin-top: 4px;
  padding: 8px 10px 4px;
  border-top: 1px solid var(--border);
  color: var(--text-faint);
  font-size: var(--font-tiny);
}

/* ---------- settings ---------- */
/* Settings header: the back arrow sits on the title's baseline, not above it,
   so the panel opens with one line of chrome instead of two. */
.settings-head {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}
.settings-back { flex: 0 0 auto; }

/* The scroll area is the whole pane, as the transcript is; the content is a
   centred column inside it. A 620px scroll box put its scrollbar in the
   middle of the screen, against the cards. */
.settings-view {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: var(--space-xl) var(--space-lg) var(--space-xxl);
  width: 100%;
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.settings-view > * {
  max-width: 620px;
  margin-left: auto;
  margin-right: auto;
}
.settings-view h1 { font-size: var(--font-h2); margin: 0 0 var(--space-xl); }
/* Inside the header row the bottom margin belongs to the row, not the
   heading -- otherwise the h1 keeps its 24px and the arrow beside it
   sits visibly below the title's centre line. */
.settings-view .settings-head h1 { margin: 0; }
.setting { margin-bottom: var(--space-xl); }
.setting-label {
  display: block;
  font-size: var(--font-small);
  font-weight: var(--weight-medium);
  margin-bottom: var(--space-sm);
}
.setting-help { color: var(--text-dim); font-size: var(--font-tiny); line-height: 20px; margin: var(--space-sm) 0 0; }
.segmented {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: var(--surface-alt);
  border-radius: var(--radius-md);
  flex-wrap: wrap;
}
.segment {
  border: 0;
  background: transparent;
  color: var(--text-dim);
  font-size: var(--font-small);
  font-weight: var(--weight-medium);
  padding: 8px var(--space-md);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.segment.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-pill); }
.ghost-button {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  font-size: var(--font-small);
  padding: var(--space-sm) var(--space-lg);
  border-radius: var(--radius-md);
  cursor: pointer;
}
.ghost-button:hover { background: var(--surface-alt); color: var(--text); }

/* ---- Settings: sections of cards with rows ------------------------------ */
.settings-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 1px 2px rgba(28, 27, 25, 0.04), 0 4px 16px rgba(28, 27, 25, 0.05);
  margin-bottom: var(--space-lg);
  overflow: hidden;
}
.settings-card-head {
  padding: var(--space-lg) var(--space-lg) var(--space-md);
  border-bottom: 1px solid var(--border);
}
.settings-card-title {
  font-size: var(--font-body);
  font-weight: 600;
  color: var(--text);
  margin: 0;
}
.settings-card-desc {
  font-size: var(--font-tiny);
  color: var(--text-dim);
  margin: 2px 0 0;
}
.settings-row {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: 14px var(--space-lg);
  flex-wrap: wrap;
}
.settings-row + .settings-row { border-top: 1px solid var(--border); }
.settings-row-icon {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  color: var(--text-dim);
  display: grid;
  place-items: center;
}
.settings-avatar {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-bg);
  color: var(--accent);
  font-weight: var(--weight-medium);
  display: grid;
  place-items: center;
}
.settings-row-text { flex: 1 1 220px; min-width: 0; }
.settings-row-title {
  font-size: var(--font-small);
  font-weight: var(--weight-medium);
  color: var(--text);
  overflow-wrap: anywhere;
}
.settings-row-sub {
  font-size: var(--font-tiny);
  color: var(--text-dim);
  line-height: 19px;
  margin-top: 2px;
}
.settings-row-side {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex: 0 0 auto;
  margin-left: auto;
}
.settings-row-wrap .settings-row-side { flex-wrap: wrap; }
.settings-row > .settings-notice { flex-basis: 100%; margin: 0; }

.settings-badge {
  font-size: 12px;
  font-weight: var(--weight-medium);
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
}
.settings-badge.ok { background: var(--accent-bg); color: var(--success); }
.settings-badge.warn { background: var(--warn-bg); color: var(--warn); }
.settings-badge.muted { background: var(--surface-alt); color: var(--text-faint); }

.settings-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--font-small);
  font-weight: var(--weight-medium);
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
}
.settings-btn:disabled { opacity: 0.55; cursor: default; }
.settings-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.settings-btn:focus:not(:focus-visible) { outline: none; }
.settings-btn.primary { background: var(--accent-solid); color: var(--accent-text); }
.settings-btn.primary:hover:not(:disabled) { filter: brightness(1.08); }
.settings-btn.secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.settings-btn.secondary:hover:not(:disabled) { background: var(--surface-alt); }
.settings-btn.ghost { background: transparent; color: var(--accent); padding-inline: 10px; }
.settings-btn.ghost:hover:not(:disabled) { background: var(--accent-bg); }
.settings-btn.danger { background: transparent; color: var(--danger); border-color: var(--border); }
.settings-btn.danger:hover:not(:disabled) { background: var(--danger-bg); border-color: transparent; }
.settings-btn.danger-solid { background: var(--danger); color: #fff; }
.settings-btn.danger-solid:hover:not(:disabled) { filter: brightness(1.08); }

.vx-dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  padding: var(--space-xl);
  width: min(420px, calc(100vw - 32px));
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
}
.vx-dialog::backdrop { background: var(--overlay); }
.vx-dialog-title { font-size: var(--font-body); font-weight: 600; margin: 0 0 var(--space-sm); }
.vx-dialog-body { font-size: var(--font-small); color: var(--text-dim); line-height: 21px; margin: 0; }
.vx-dialog-actions { display: flex; justify-content: flex-end; gap: var(--space-sm); margin-top: var(--space-xl); }
.vx-dialog-input { display: block; width: 100%; box-sizing: border-box; margin-top: var(--space-lg); }
.vx-dialog-label { display: block; font-size: var(--font-small); color: var(--text-dim); margin-top: var(--space-lg); }
.vx-dialog-label strong { color: var(--text); font-weight: 600; overflow-wrap: anywhere; }
.vx-dialog-label + .vx-dialog-input { margin-top: var(--space-sm); }

.settings-badge.danger { background: var(--danger-bg); color: var(--danger); }


.settings-notice {
  font-size: var(--font-tiny);
  padding: 10px var(--space-lg);
  border-top: 1px solid var(--border);
}
.settings-notice.ok { color: var(--success); background: var(--accent-bg); }
.settings-notice.info { color: var(--text-dim); background: var(--surface-alt); }
.settings-notice.error { color: var(--danger); background: var(--danger-bg); }

.settings-input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: var(--font-small);
  font-family: inherit;
}
.settings-input:focus { outline: 2px solid var(--accent-border); outline-offset: 0; border-color: var(--accent); }

@media (max-width: 560px) {
  .settings-row-side { margin-left: 48px; }
  .settings-row-wrap .settings-row-side { margin-left: 0; width: 100%; }
}

/* Collapsed sidebar (desktop). Width rather than display:none so the column
   animates out and its contents are not re-laid-out on every toggle;
   visibility takes it out of the tab order once it is gone. */
.sidebar-collapsed .sidebar {
  width: 0;
  min-width: 0;
  overflow: hidden;
  border-right-color: transparent;
  visibility: hidden;
}
.sidebar { transition: width 0.18s ease; }
@media (prefers-reduced-motion: reduce) {
  .sidebar { transition: none; }
}

/* ---------- feedback ---------- */
/* The form behind the topbar's speech bubble and the settings panel's button.
   A centred panel rather than the citation sheet's bottom slide: that sheet is
   a reading surface the reader dismisses, this is a form they type into, and a
   sheet anchored to the bottom edge is where a phone keyboard appears. */
.feedback-backdrop {
  position: fixed;
  inset: 0;
  background: var(--overlay);
}
.feedback-panel {
  position: fixed;
  inset: 0;
  margin: auto;
  width: min(560px, calc(100vw - 2 * var(--space-lg)));
  max-height: min(88vh, 720px);
  height: fit-content;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sheet);
  padding: var(--space-lg);
  overflow-y: auto;
}

.feedback-head {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}
.feedback-title {
  flex: 1;
  margin: 0;
  font-size: var(--font-h2);
  font-weight: var(--weight-semibold);
}
.feedback-dismiss { flex: 0 0 auto; margin: -4px -4px 0 0; }

.feedback-field { margin-bottom: var(--space-xl); }

/* Five numbered radios. Wide enough to be a tap target at phone width, which
   is the --hit-target minimum rather than a size chosen to look right. */
.feedback-rating { display: flex; gap: var(--space-sm); flex-wrap: wrap; }
.feedback-star {
  min-width: var(--hit-target);
  height: var(--hit-target);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text-dim);
  font-size: var(--font-body);
  font-weight: var(--weight-medium);
  cursor: pointer;
}
.feedback-star:hover { background: var(--surface-alt); color: var(--text); }
.feedback-star.on {
  background: var(--accent-bg);
  border-color: var(--accent-border);
  color: var(--accent);
  font-weight: var(--weight-semibold);
}

.feedback-text {
  width: 100%;
  padding: var(--space-md);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: var(--font-small);
  line-height: var(--line-height);
  resize: vertical;
}
.feedback-text:focus-within, .feedback-text:focus { outline: none; border-color: var(--accent-border); }
.feedback-text::placeholder { color: var(--text-faint); }

.feedback-check { display: flex; align-items: flex-start; gap: var(--space-sm); }
.feedback-checkbox {
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
  flex: 0 0 auto;
  accent-color: var(--accent-solid);
  cursor: pointer;
}
.feedback-check-label {
  font-size: var(--font-small);
  font-weight: var(--weight-medium);
  cursor: pointer;
}

/* What is sent, immediately above the button that sends it. Dimmer than the
   form but never faint: this is the sentence the user is relying on. */
.feedback-disclosure {
  margin: 0 0 var(--space-md);
  padding: var(--space-md);
  background: var(--surface-alt);
  border-radius: var(--radius-md);
  color: var(--text-dim);
  font-size: var(--font-tiny);
  line-height: 20px;
}

.feedback-error {
  margin: 0 0 var(--space-md);
  padding: var(--space-sm) var(--space-md);
  background: var(--danger-bg);
  color: var(--danger);
  border-radius: var(--radius-sm);
  font-size: var(--font-tiny);
  line-height: 20px;
}

.feedback-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
}
.feedback-send {
  border: 0;
  border-radius: var(--radius-md);
  background: var(--surface-alt);
  color: var(--text-faint);
  font-size: var(--font-small);
  font-weight: var(--weight-semibold);
  padding: var(--space-sm) var(--space-xl);
  cursor: pointer;
}
.feedback-send.ready { background: var(--accent-solid); color: var(--accent-text); }
.feedback-send:disabled { cursor: default; }

/* A confirmation borrowing the status line. The line's own colours are the
   warning amber, which is wrong for a thank-you, so a notice repaints it in
   the accent -- same position, same quietness, opposite meaning. */
.status-line.notice { background: var(--accent-bg); color: var(--accent); }

/* The topbar control, disabled until the conversation has something in it.
   Dimmed and not clickable, but kept in place rather than hidden: a control
   that appears and disappears as you chat is harder to find than one that is
   always there and sometimes unavailable. */
#feedbackButton:disabled { opacity: .4; cursor: default; }
#feedbackButton:disabled:hover { background: transparent; color: var(--text-dim); }

/* ---------- narrow screens ---------- */
.scrim { display: none; }

@media (max-width: 720px) {
  /* The sidebar becomes a drawer. It stays in the DOM -- and stays focusable
     only when open -- so the conversation list is one tap away rather than a
     separate route. */
  .sidebar {
    position: fixed;
    z-index: 30;
    top: 0;
    left: 0;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform 0.18s ease;
    box-shadow: var(--shadow-sheet);
  }
  .sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-open .scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 20;
    background: var(--overlay);
  }
  .transcript { padding: var(--space-md); }
  .turn.user { padding-left: var(--space-lg); }
  .figure { max-width: 100%; }
  .conversation-actions { opacity: 1; }
  @media (prefers-reduced-motion: reduce) {
    .sidebar { transition: none; }
  }
}

/* ---------- library ---------- */
/* The documents an answer is drawn from. A wider column than the settings
   panel: a row is a name, two counts, a date and three controls, and at 620px
   the name was ellipsised while the actions sat in whitespace. */
.library-view {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-xl) var(--space-lg);
  max-width: 820px;
  margin-inline: auto;
  width: 100%;
}
/* The settings header's shape, plus the upload control on the same line: the
   primary action on this page is adding a document, and a button at the end of
   a long list is a button nobody finds. */
.library-head {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}
.library-back { flex: 0 0 auto; }
.library-head h1 {
  flex: 1;
  margin: 0;
  font-size: var(--font-h2);
}
.library-add {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.library-intro {
  margin: 0 0 var(--space-xl);
  color: var(--text-dim);
  font-size: var(--font-tiny);
  line-height: 20px;
  max-width: 560px;
}

.library-list { display: flex; flex-direction: column; gap: var(--space-sm); }
.library-loading {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-xl) 0;
  color: var(--text-dim);
  font-size: var(--font-small);
}

.library-row {
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.library-row-main { flex: 1; min-width: 0; }
.library-name {
  font-size: var(--font-small);
  font-weight: var(--weight-medium);
  overflow-wrap: anywhere;
}
.library-meta {
  margin-top: 2px;
  color: var(--text-faint);
  font-size: var(--font-tiny);
}
/* Switched off: dimmed so the list reads at a glance as mostly-on with
   exceptions, but never hidden -- it has to be findable to be switched back
   on. The actions keep full opacity, because one of them is how you do that. */
.library-row.off { background: var(--bg); }
.library-row.off .library-name,
.library-row.off .library-meta { color: var(--text-faint); }
.library-row.failed { border-color: var(--danger-bg); }

/* The processing block. Only present while there is something to say, so a
   finished row collapses to a name and a line of metadata. */
.library-progress { margin-top: var(--space-sm); }
.library-progress-line {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  color: var(--accent);
}
.library-progress.failed .library-progress-line { color: var(--danger); }
.library-progress-label {
  font-size: var(--font-tiny);
  font-weight: var(--weight-medium);
}
.library-progress-detail {
  margin-top: var(--space-xs);
  color: var(--text-dim);
  font-size: var(--font-tiny);
  line-height: 19px;
  overflow-wrap: anywhere;
}
/* A real <progress>, restyled in both engines: the element carries the right
   semantics, and appearance:none is the only way to get the app's own colours
   onto it. */
.library-bar {
  appearance: none;
  -webkit-appearance: none;
  display: block;
  width: 100%;
  max-width: 320px;
  height: 4px;
  margin-top: var(--space-sm);
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--surface-alt);
  color: var(--accent);
}
.library-bar::-webkit-progress-bar {
  background: var(--surface-alt);
  border-radius: var(--radius-pill);
}
.library-bar::-webkit-progress-value {
  background: var(--accent);
  border-radius: var(--radius-pill);
}
.library-bar::-moz-progress-bar {
  background: var(--accent);
  border-radius: var(--radius-pill);
}

/* Always visible, unlike the conversation row's: this list is short, the row
   is tall enough to hold them, and a hover-only reveal on a touchscreen means
   an action nobody can reach. */
.library-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 0 0 auto;
}
.library-actions .icon-button:disabled { opacity: .35; cursor: default; }
.library-actions .icon-button:disabled:hover { background: transparent; color: var(--text-dim); }
/* Switched on reads as the affirmative state, so it carries the accent; off is
   simply dim, not a warning -- the user chose it. */
.library-toggle[aria-pressed="true"] { color: var(--accent); }

.library-empty {
  align-items: flex-start;
  min-height: 0;
  gap: var(--space-md);
  padding: var(--space-xxl) 0;
}
.library-empty-title {
  margin: 0;
  font-size: var(--font-h3);
  font-weight: var(--weight-semibold);
}
.library-empty .ghost-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* The upload sheet borrows .feedback-panel wholesale; only the file input is
   its own, and it needs to not overflow the panel at phone width. */
.library-file {
  display: block;
  width: 100%;
  max-width: 100%;
  padding: var(--space-md);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: var(--font-tiny);
  cursor: pointer;
}
.library-file::file-selector-button {
  margin-right: var(--space-md);
  padding: 6px var(--space-md);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-pill);
  background: var(--accent-bg);
  color: var(--accent);
  font: inherit;
  font-size: var(--font-tiny);
  font-weight: var(--weight-semibold);
  cursor: pointer;
}

/* What was picked, listed before it is sent. A `multiple` input says only
   "5 files", which is the wrong amount of information for something that
   takes minutes per file -- so the sheet names them, with sizes, and totals
   them on the last line. Scrolls rather than growing the sheet past the
   viewport: a folder of twenty PDFs must not push the Add button off screen. */
.library-picked {
  list-style: none;
  margin: var(--space-md) 0 0;
  padding: 0;
  max-height: 180px;
  overflow-y: auto;
  font-size: var(--font-tiny);
}
.library-picked-item,
.library-picked-total {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-md);
  padding: var(--space-xs) 0;
}
.library-picked-item + .library-picked-item,
.library-picked-total {
  border-top: 1px solid var(--border);
}
.library-picked-name {
  /* A filename is arbitrary length and must not widen the sheet. */
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.library-picked-size {
  flex: none;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.library-picked-total {
  justify-content: flex-end;
  color: var(--text-dim);
  font-weight: var(--weight-semibold);
}

@media (max-width: 720px) {
  .library-view { padding: var(--space-lg) var(--space-md); }
  /* The name and its metadata take the width; the three controls drop to their
     own line and align right, which keeps them at --hit-target without
     squeezing a long filename into two characters. */
  .library-row { flex-direction: column; gap: var(--space-sm); }
  .library-actions { align-self: flex-end; }
  .library-actions .icon-button {
    min-width: var(--hit-target);
    height: var(--hit-target);
  }
  .library-bar { max-width: 100%; }
  /* The header's action loses its label at phone width -- the icon carries it,
     and the aria-label is on the button either way. */
  .library-head h1 { font-size: var(--font-h3); }
  .library-add span { display: none; }
  .library-add { padding: var(--space-sm) var(--space-md); }
}

/* --- toasts (static/toast.js) -----------------------------------------------
   Messages that arrive on their own schedule -- an upload's progress, a
   document that finished processing -- over whatever screen is open. One
   stack, bottom right; full width at phone size. Above overlays (z 100), so
   "ready" is seen even with a document open. */
.toast-stack {
  position: fixed;
  right: var(--space-lg, 16px);
  bottom: var(--space-lg, 16px);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm, 8px);
  width: min(380px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm, 8px);
  padding: 12px 8px 12px 14px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sheet);
  font-size: var(--font-small);
  line-height: 20px;
  animation: toast-in 160ms ease-out;
}
.toast-error { border-left-color: var(--danger); }
.toast-icon { flex: none; display: flex; padding-top: 2px; color: var(--accent); }
.toast-error .toast-icon { color: var(--danger); }
.toast-body { flex: 1; min-width: 0; }
.toast-text { margin: 0; overflow-wrap: anywhere; }
.toast-action {
  margin-top: 6px;
  padding: 4px 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-weight: var(--weight-semibold);
  cursor: pointer;
}
.toast-action:hover { text-decoration: underline; }
.toast-close { flex: none; width: 32px; height: 32px; margin: -6px 0; color: var(--text-dim); }
.toast-bar {
  appearance: none;
  -webkit-appearance: none;
  display: block;
  width: 100%;
  height: 4px;
  margin-top: 8px;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--surface-alt);
  color: var(--accent);
}
.toast-bar::-webkit-progress-bar { background: var(--surface-alt); border-radius: var(--radius-pill); }
.toast-bar::-webkit-progress-value { background: var(--accent); border-radius: var(--radius-pill); }
.toast-bar::-moz-progress-bar { background: var(--accent); border-radius: var(--radius-pill); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .toast { animation: none; }
}
@media (max-width: 560px) {
  .toast-stack { left: 16px; right: 16px; bottom: 16px; width: auto; }
}

/* ---------- reviews (static/reviews.js) ---------- */

/* Severity: one pair of colours per rating, used by every pill, chip and
   chosen option. Soft for Good/P4/P3, solid for P2/P1 so the serious ones
   are seen first in a list. --sev-ink is the hover colour of an unchosen
   option. */
.rv-sev-none { --sev-fg: var(--success); --sev-bg: var(--accent-bg); --sev-ink: var(--success); }
.rv-sev-p4 { --sev-fg: var(--text-dim); --sev-bg: var(--surface-alt); --sev-ink: var(--text-faint); }
.rv-sev-p3 { --sev-fg: var(--warn); --sev-bg: var(--warn-bg); --sev-ink: var(--warn); }
.rv-sev-p2 { --sev-fg: #fff; --sev-bg: var(--warn); --sev-ink: var(--warn); }
.rv-sev-p1 { --sev-fg: #fff; --sev-bg: var(--danger); --sev-ink: var(--danger); }
.rv-status-open { --st: var(--accent); }
.rv-status-in_progress { --st: var(--warn); }
.rv-status-needs_retest { --st: #7c5cd6; }
.rv-status-resolved { --st: var(--success); }
.rv-status-wont_fix { --st: var(--text-faint); }

.rv-pill {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border-radius: var(--radius-pill);
  background: var(--sev-bg);
  color: var(--sev-fg);
  font-size: 12px;
  font-weight: var(--weight-semibold);
  line-height: 18px;
  white-space: nowrap;
}
.rv-pill.rv-status {
  gap: 5px;
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
  font-weight: var(--weight-medium);
}
.rv-pill.rv-status::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--st); }

.rv-dim { color: var(--text-faint); font-size: var(--font-tiny); }
.rv-gap { flex: 1; }
.rv-row { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-sm); }
.rv-label { font-size: var(--font-tiny); font-weight: var(--weight-semibold); color: var(--text-dim); }
.rv-hint { margin: 4px 0; color: var(--text-faint); font-size: var(--font-tiny); line-height: 18px; }
.rv-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  padding: 40px 20px;
  color: var(--text-faint);
  font-size: var(--font-small);
  line-height: 20px;
  text-align: center;
}
.rv-empty p { margin: 0; max-width: 280px; }
.rv-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: var(--font-tiny);
  font-weight: var(--weight-medium);
  cursor: pointer;
}
.rv-link:hover span { text-decoration: underline; }
.rv-danger { color: var(--danger); }
.rv-select {
  max-width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: var(--font-small);
}

/* The rating control. `chips`: separate pills that wrap, each with its
   colour dot and full name. `tiles`: five equal columns, code over word. */
.rv-sev-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.rv-sev-opt {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  font: inherit;
  cursor: pointer;
}
.rv-sev-opt:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.rv-sev-chips .rv-sev-opt {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px 4px 10px;
  border-radius: var(--radius-pill);
  font-size: var(--font-tiny);
  font-weight: var(--weight-medium);
  white-space: nowrap;
}
.rv-sev-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--sev-ink); }
.rv-sev-opt:not(.on):hover { border-color: var(--sev-ink); color: var(--sev-ink); }
.rv-sev-opt.on { border-color: transparent; background: var(--sev-bg); color: var(--sev-fg); font-weight: var(--weight-semibold); }
.rv-sev-opt.on .rv-sev-dot { background: currentColor; }
.rv-sev-tiles { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.rv-sev-tiles .rv-sev-opt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 7px 2px 6px;
  border-radius: var(--radius-sm);
  border-top: 3px solid var(--sev-ink);
}
.rv-sev-code { display: inline-flex; min-height: 18px; align-items: center; font-size: var(--font-small); font-weight: var(--weight-bold); }
.rv-sev-word { font-size: 12px; }
.rv-sev-tiles .rv-sev-opt.on { border-top-color: transparent; }
.rv-sev-meaning { margin: 6px 0 0; color: var(--text-dim); font-size: var(--font-tiny); line-height: 18px; }
.rv-sev-meaning:empty { display: none; }

/* Review mode: a labelled switch in the top bar, never an icon to decode. */
.rv-mode {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 12px 0 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text-dim);
  font: inherit;
  font-size: var(--font-small);
  font-weight: var(--weight-medium);
  white-space: nowrap;
  cursor: pointer;
}
.rv-mode[hidden] { display: none; }
.rv-mode:hover { border-color: var(--border-strong); color: var(--text); }
.rv-mode:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.rv-mode-track {
  position: relative;
  width: 30px;
  height: 18px;
  border-radius: 9px;
  background: var(--border-strong);
  transition: background .15s;
}
.rv-mode-track span {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .25);
  transition: transform .15s;
}
.rv-mode.on { border-color: var(--accent-border); background: var(--accent-bg); color: var(--accent); }
.rv-mode.on .rv-mode-track { background: var(--accent-solid); }
.rv-mode.on .rv-mode-track span { transform: translateX(12px); }
.rv-mode-short { display: none; }
@media (max-width: 560px) {
  .rv-mode { gap: 6px; padding: 0 10px 0 6px; font-size: var(--font-tiny); }
  .rv-mode-label { display: none; }
  .rv-mode-short { display: inline; }
}

/* A reviewer's reviews of a conversation, under its title in the sidebar. */
.conversation-reviews { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.conversation-review {
  display: inline-flex;
  align-items: stretch;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-size: 11px;
  line-height: 17px;
  white-space: nowrap;
}
.conversation-review-rated { padding: 0 6px; background: var(--sev-bg); color: var(--sev-fg); font-weight: var(--weight-semibold); }
.conversation-review-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0 7px 0 5px;
  background: var(--surface);
  color: var(--text-dim);
}
.conversation-review-status::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--st); }

/* The sidebar's Reviews entry: a destination like a conversation, lit while
   its page is open. */
.sidebar-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: var(--space-sm) var(--space-sm) 0;
  padding: 9px 12px;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: var(--font-small);
  font-weight: var(--weight-medium);
  text-align: left;
  cursor: pointer;
}
.sidebar-nav > span:nth-child(2) { flex: 1; }
.sidebar-nav:hover { background: var(--surface-alt); }
.sidebar-nav.active { background: var(--accent-bg); color: var(--accent); }
.sidebar-nav-count {
  min-width: 20px;
  padding: 0 6px;
  border-radius: var(--radius-pill);
  background: var(--accent-solid);
  color: var(--accent-text);
  font-size: 12px;
  font-weight: var(--weight-semibold);
  line-height: 20px;
  text-align: center;
}
.sidebar-nav-count:empty { display: none; }
.sidebar-nav + .sidebar-search, .sidebar-nav + .conversations { border-top: 1px solid var(--border); margin-top: var(--space-sm); }

/* --- the conversation and the panel, side by side --- */
.rv-layout { flex: 1; min-height: 0; display: flex; }
.rv-layout:has(> #view[hidden]) { display: none; }
.rv-layout > #view { flex: 1; min-width: 0; }
.rv-panel {
  flex: 0 0 380px;
  width: 380px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface);
  border-left: 1px solid var(--border);
}
.rv-panel[hidden] { display: none; }
.rv-panel-head {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 8px 8px 8px 16px;
  border-bottom: 1px solid var(--border);
}
.rv-panel-title {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-weight: var(--weight-semibold);
  color: var(--text);
}
.rv-count {
  min-width: 20px;
  padding: 0 6px;
  border-radius: var(--radius-pill);
  background: var(--accent-bg);
  color: var(--accent);
  font-size: 12px;
  line-height: 20px;
  text-align: center;
}
.rv-count:empty { display: none; }
.rv-panel-body { flex: 1; overflow-y: auto; padding: 14px 16px 24px; }
.rv-section { margin-bottom: 22px; }
.rv-section-title {
  margin: 0 0 8px;
  color: var(--text-faint);
  font-size: 12px;
  font-weight: var(--weight-semibold);
  letter-spacing: .05em;
  text-transform: uppercase;
}
.rv-quick { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-sm); padding: 4px 0; }
.rv-quick-label { color: var(--text-dim); font-size: var(--font-small); }
.rv-foot-hint { text-align: center; }

/* Under each answer, only while the panel is open. */
.rv-inline { display: none; }
.shell.rv-open .rv-inline:not(:empty) {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: var(--space-md);
}
.rv-inline-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 2px 10px 2px 2px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  font: inherit;
  font-size: var(--font-tiny);
  cursor: pointer;
}
.rv-inline-chip:hover { border-color: var(--border-strong); }
.rv-inline-sev {
  padding: 1px 8px;
  border-radius: var(--radius-pill);
  background: var(--sev-bg);
  color: var(--sev-fg);
  font-weight: var(--weight-semibold);
}
.rv-inline-meta { color: var(--text-dim); }
/* The answer whose review is open in the panel. */
.shell.rv-open .turn.assistant.rv-active {
  border-radius: var(--radius-sm);
  background: var(--accent-bg);
  box-shadow: 0 0 0 10px var(--accent-bg);
}
.turn-flash { animation: rv-flash 2.4s ease-out; border-radius: var(--radius-sm); }
@keyframes rv-flash {
  0%, 40% { background: var(--accent-bg); box-shadow: 0 0 0 10px var(--accent-bg); }
  100% { background: transparent; box-shadow: 0 0 0 10px transparent; }
}
@media (prefers-reduced-motion: reduce) { .turn-flash { animation: none; } }

/* Cards in the panel: collapsed to one line, one open at a time. */
.rv-card {
  margin-bottom: var(--space-sm);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg);
}
.rv-card.open { background: var(--surface); border-color: var(--border-strong); box-shadow: var(--shadow-pill); }
.rv-card-head {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  width: 100%;
  padding: 10px 10px 10px 12px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.rv-card-title { flex: 1; min-width: 0; display: flex; align-items: center; gap: var(--space-sm); }
.rv-card-what { font-size: var(--font-small); font-weight: var(--weight-medium); }
.rv-chevron { display: inline-flex; color: var(--text-faint); transition: transform .15s; }
.rv-card.open .rv-chevron { transform: rotate(180deg); }
.rv-card-peek { margin: -4px 12px 10px; color: var(--text-dim); font-size: var(--font-tiny); line-height: 18px; }
.rv-card-peek:empty, .rv-card.open .rv-card-peek { display: none; }
.rv-card-body { display: none; padding: 0 12px 12px; }
.rv-card.open .rv-card-body { display: block; }
.rv-quote {
  display: block;
  width: 100%;
  margin-bottom: 12px;
  padding: 6px 10px;
  border: 0;
  border-left: 3px solid var(--accent-border);
  border-radius: 0 6px 6px 0;
  background: var(--surface-alt);
  color: var(--text-dim);
  font: inherit;
  font-size: var(--font-tiny);
  line-height: 18px;
  text-align: left;
  cursor: pointer;
}
.rv-quote:hover { color: var(--text); }

/* The editor, in a card and on the Reviews page. */
.rv-editor { display: flex; flex-direction: column; gap: var(--space-sm); }
.rv-editor > .rv-label { margin-top: 4px; }
.rv-textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: var(--font-small);
  line-height: 20px;
  resize: none;
  overflow: hidden;
}
.rv-textarea::placeholder { color: var(--text-faint); }
.rv-textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
.rv-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.rv-tag {
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text-dim);
  font: inherit;
  font-size: var(--font-tiny);
  line-height: 18px;
  cursor: pointer;
}
.rv-tag:not(.on):not(.static):hover { border-color: var(--border-strong); color: var(--text); }
.rv-tag.on { background: var(--accent-bg); border-color: var(--accent-border); color: var(--accent); }
.rv-tag.static { cursor: default; }
.rv-tag.retired { border-style: dashed; }
.rv-extra { display: flex; flex-direction: column; gap: 6px; }
.rv-tag-x { display: inline-flex; align-items: center; gap: 4px; flex-direction: row-reverse; }
.rv-tag-x .icon { opacity: .7; }
.rv-quick[hidden] { display: none; }
.rv-extra[hidden] { display: none; }
.rv-choice {
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text-dim);
  font: inherit;
  font-size: var(--font-tiny);
  cursor: pointer;
}
.rv-choice.on { background: var(--accent-bg); border-color: var(--accent-border); color: var(--accent); }
.rv-editor-foot {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-top: 4px;
  padding-top: var(--space-sm);
  border-top: 1px solid var(--border);
}
.rv-save { display: inline-flex; align-items: center; gap: 4px; min-height: 18px; color: var(--text-faint); font-size: var(--font-tiny); }
.rv-save-saved { color: var(--success); }
.rv-save-error { color: var(--danger); gap: 8px; }
.rv-retest {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  padding: 10px 12px;
  border: 1px solid var(--rv-retest, #7c5cd6);
  border-radius: var(--radius-sm);
  background: rgba(124, 92, 214, 0.08);
}
.rv-retest[hidden] { display: none; }
.rv-retest-head { display: flex; align-items: center; gap: 6px; color: #7c5cd6; font-size: var(--font-small); }
.rv-retest-note, .rv-admin-note p, .rv-note { margin: 0; font-size: var(--font-small); line-height: 20px; white-space: pre-wrap; }
.rv-admin-note { display: flex; flex-direction: column; gap: 4px; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--surface-alt); }
.rv-admin-note[hidden] { display: none; }
.rv-retest-how { margin: 0; color: var(--text-dim); font-size: var(--font-tiny); }
.rv-admin-note p { margin-top: 4px; }

/* --- the Reviews page --- */
.reviews-view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.reviews-view[hidden] { display: none; }
.rv-page-head { display: flex; align-items: center; gap: 10px; padding: 12px 20px 4px 12px; }
.rv-page-head h1 { margin: 0; font-size: var(--font-h2); }
.rv-tabs {
  display: flex;
  gap: 2px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.rv-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: -1px;
  padding: 10px 12px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--text-dim);
  font: inherit;
  font-size: var(--font-small);
  white-space: nowrap;
  cursor: pointer;
}
.rv-tab:hover { color: var(--text); }
.rv-tab.on { border-bottom-color: var(--accent); color: var(--text); font-weight: var(--weight-semibold); }
.rv-tab-n { padding: 0 7px; border-radius: var(--radius-pill); background: var(--surface-alt); color: var(--text-dim); font-size: 12px; font-weight: var(--weight-medium); }
.rv-tab.on .rv-tab-n { background: var(--accent-bg); color: var(--accent); }
.rv-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-sm);
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
}
.rv-search {
  flex: 1 1 240px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-faint);
}
.rv-search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
.rv-search input { flex: 1; min-width: 0; padding: 7px 0; border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; font-size: var(--font-small); }
.rv-filter.set { border-color: var(--accent-border); background: var(--accent-bg); color: var(--accent); }
.rv-toggle { display: inline-flex; align-items: center; gap: 6px; color: var(--text-dim); font-size: var(--font-small); cursor: pointer; }
.rv-toggle input { accent-color: var(--accent-solid); }

.rv-split { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(300px, 400px) 1fr; }
.rv-list { overflow-y: auto; padding: 8px; border-right: 1px solid var(--border); outline: none; }
.rv-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.rv-item + .rv-item { margin-top: 2px; }
.rv-item:hover { background: var(--surface-alt); }
.rv-item.on { background: var(--accent-bg); }
.rv-list:focus-visible .rv-item.on { outline: 2px solid var(--accent); outline-offset: -2px; }
.rv-item-top { display: flex; align-items: center; gap: var(--space-sm); }
.rv-item-id { color: var(--text-dim); font-size: var(--font-tiny); font-weight: var(--weight-semibold); font-variant-numeric: tabular-nums; }
.rv-item-q, .rv-item-c {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}
.rv-item-q { font-size: var(--font-small); font-weight: var(--weight-medium); line-height: 20px; }
.rv-item-c { color: var(--text-dim); font-size: var(--font-tiny); line-height: 18px; }
.rv-item-sub { color: var(--text-faint); font-size: 12px; }

.rv-detail { overflow-y: auto; padding: 20px 28px 48px; }
.rv-detail > * { max-width: 780px; }
.rv-detail-head { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.rv-detail-title { display: flex; align-items: center; gap: 10px; }
.rv-detail-title h2 { margin: 0; font-size: var(--font-h2); font-variant-numeric: tabular-nums; }
.rv-detail-meta { margin: 4px 0 18px; color: var(--text-dim); font-size: var(--font-small); }
.rv-status-box {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 24px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}
.rv-status-seg {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  width: fit-content;
  max-width: 100%;
  padding: 3px;
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
}
.rv-seg {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  font-size: var(--font-small);
  cursor: pointer;
}
.rv-seg::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--st); opacity: .5; }
.rv-seg:hover { color: var(--text); }
.rv-seg.on { background: var(--surface); color: var(--text); font-weight: var(--weight-semibold); box-shadow: var(--shadow-pill); }
.rv-seg.on::before { opacity: 1; }
.rv-block { margin-bottom: 28px; }
.rv-block-title {
  margin: 0 0 10px;
  color: var(--text-faint);
  font-size: 12px;
  font-weight: var(--weight-semibold);
  letter-spacing: .05em;
  text-transform: uppercase;
}
.rv-comment { margin: 0 0 12px; font-size: var(--font-body); line-height: var(--line-height); white-space: pre-wrap; }
.rv-intent { margin-top: 12px; }
.rv-intent p { margin: 4px 0 0; font-size: var(--font-small); line-height: 20px; }
.rv-compared { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-sm); margin-top: 14px; font-size: var(--font-small); }
.rv-transcript { padding: 16px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--bg); }
.rv-transcript .turn:last-child { margin-bottom: 0; }

/* The admin's tag editor. */
.rv-dialog { width: min(560px, calc(100vw - 2 * var(--space-lg))); }
.rv-taglist { display: flex; flex-direction: column; margin: var(--space-md) 0; }
.rv-tagrow { display: flex; align-items: center; gap: var(--space-sm); padding: 6px 0; border-bottom: 1px solid var(--border); }
.rv-tagrow-name { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: var(--font-small); }
.rv-tagrow.retired .rv-tagrow-name > span:first-child { color: var(--text-faint); text-decoration: line-through; }
.rv-tagrow-actions { display: flex; align-items: center; gap: 2px; }
.rv-tagrow-actions .icon-button { width: 32px; height: 32px; }
.rv-tagrow-actions .icon-button:disabled { opacity: .35; cursor: default; }
.rv-tagrow-actions .rv-link { padding: 0 8px; }
.rv-keep { visibility: hidden; }
.rv-tag-add .settings-input { flex: 1; }

/* Narrow: the panel becomes a bottom sheet over the lower part of the
   conversation, and the page shows the list or the review, not both. */
@media (max-width: 900px) {
  .rv-panel {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 25;
    width: auto;
    height: min(60vh, 560px);
    border-left: 0;
    border-top: 1px solid var(--border);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    box-shadow: var(--shadow-sheet);
  }
  .shell.rv-open .transcript { padding-bottom: calc(min(60vh, 560px) + var(--space-lg)); }
  .rv-split { grid-template-columns: 1fr; }
  .rv-list { border-right: 0; }
  .rv-page.has-selection .rv-list { display: none; }
  .rv-page:not(.has-selection) .rv-detail { display: none; }
  .rv-detail { padding: 14px 16px 40px; }
  .rv-filters, .rv-tabs { padding-inline: 12px; }
}

/* Every field of the editor: a visible label, then the control. */
.rv-editor { gap: var(--space-md); }
.rv-field { display: flex; flex-direction: column; gap: 6px; }
.rv-field-label {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
  color: var(--text);
  font-size: var(--font-tiny);
  font-weight: var(--weight-semibold);
}
.rv-field-hint { color: var(--text-faint); font-weight: var(--weight-regular); }
.rv-field .rv-select { width: 100%; }
.rv-cmp-choices[hidden] { display: none; }

/* Issues: a field that opens into a checklist. */
.rv-issues { display: flex; flex-direction: column; gap: 6px; }
.rv-dropdown {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 38px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: var(--font-small);
  text-align: left;
  cursor: pointer;
}
.rv-dropdown:hover { border-color: var(--border-strong); }
.rv-dropdown:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
.rv-issues.open .rv-dropdown { border-color: var(--accent); border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.rv-dropdown-text { flex: 1; }
.rv-dropdown-text.placeholder { color: var(--text-faint); }
.rv-dropdown-chevron { display: inline-flex; color: var(--text-faint); transition: transform .15s; }
.rv-issues.open .rv-dropdown-chevron { transform: rotate(180deg); }
.rv-checklist {
  display: flex;
  flex-direction: column;
  margin-top: -7px;
  padding: 4px;
  border: 1px solid var(--accent);
  border-top: 0;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  background: var(--surface);
}
.rv-checklist[hidden] { display: none; }
.rv-check {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border-radius: 6px;
  font-size: var(--font-small);
  cursor: pointer;
}
.rv-check:hover { background: var(--surface-alt); }
.rv-check input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent-solid); cursor: pointer; }
.rv-check.retired span { color: var(--text-faint); }
.rv-checklist-done { align-self: flex-end; margin: 4px; padding-block: 4px; }
.rv-chosen[hidden] { display: none; }

/* Under an answer: the question, then the ratings. */
.rv-inline-label { color: var(--text-dim); font-size: var(--font-tiny); font-weight: var(--weight-semibold); }
.rv-inline-edit { color: var(--accent); font-weight: var(--weight-semibold); }
.rv-quick { flex-direction: column; align-items: flex-start; }

/* Status history on a review's page: a timeline, newest first. */
.rv-history { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 2px solid var(--border); }
.rv-history-item { position: relative; padding: 0 0 14px 12px; }
.rv-history-item::before {
  content: '';
  position: absolute;
  left: -21px;
  top: 5px;
  width: 10px;
  height: 10px;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--st);
}
.rv-history-item:last-child { padding-bottom: 0; }
.rv-history-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: var(--font-small); }
.rv-history-arrow { color: var(--text-faint); }
.rv-history-meta { margin-top: 2px; color: var(--text-faint); font-size: var(--font-tiny); }
.rv-history-note {
  margin: 6px 0 0;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  font-size: var(--font-small);
  line-height: 20px;
  white-space: pre-wrap;
}

/* Retests. */
.copied-divider {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  max-width: 760px;
  margin: 0 auto var(--space-xl);
  color: var(--text-faint);
  font-size: var(--font-tiny);
  text-align: center;
}
.copied-divider::before, .copied-divider::after { content: ''; flex: 1; border-top: 1px dashed var(--border-strong); }
.turn.copied { opacity: .7; }
.rv-retest-banner {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: var(--space-lg);
  padding: 10px 12px;
  border: 1px solid #7c5cd6;
  border-radius: var(--radius-sm);
  background: rgba(124, 92, 214, 0.08);
  color: var(--text);
  font-size: var(--font-small);
}
.rv-retest-banner p { margin: 0; color: var(--text-dim); font-size: var(--font-tiny); line-height: 18px; }
.rv-retest-banner .icon { color: #7c5cd6; }
.rv-retest-of {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 8px;
  border: 1px solid #7c5cd6;
  border-radius: var(--radius-pill);
  background: transparent;
  color: #7c5cd6;
  font: inherit;
  font-size: 11px;
  font-weight: var(--weight-semibold);
  cursor: pointer;
}
.rv-detail-retest { margin: -10px 0 18px; font-size: var(--font-small); color: var(--text-dim); }
.rv-retests { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.rv-retest-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.rv-retest-row:hover { border-color: var(--border-strong); }
.rv-history-item .rv-link { margin-top: 4px; }
.rv-card-sub { padding: 0 12px 8px; }
