/* Questionnaire pilot: a plain, calm screen that works from phone width up. */

:root {
  /* Keep the document workspace light, independently of the system theme. */
  color-scheme: only light;
  --bg: #f6f6f4;
  --surface: #ffffff;
  --text: #1d2125;
  --muted: #586068;
  --border: #d8dbde;
  --input-border: #868d95;
  --accent: #1c5d87;
  --on-accent: #ffffff;
  --focus: #2f6fdb;
  --code-bg: #f0f1f2;
  --error: #a3261f;
  --error-bg: #fbeeed;
  --ok: #1f6a3a;
  --ok-bg: #edf6f0;
  --amber: #7d4600;
  --amber-bg: #fdf1e1;
  --blue: #1c5d87;
  --blue-bg: #e8f1f8;
  /* The review tags, as the approved mockup has them: Needs you orange, Check yellow, Done green. */
  --needs: #b44b0b;
  --needs-bg: #fff0e3;
  --needs-line: #f6c9a5;
  --check: #7a5a00;
  --check-bg: #fff8d6;
  --check-line: #ecd98a;
  --done: #1d6b3a;
  --done-bg: #e9f7ee;
  --done-line: #b9e2c7;
  --select: #2459d6;
  --select-bg: #e8efff;
  /* A person's own value on the review screen: "Changed by you", blue as in the mockup. */
  --mine: #1f4fb8;
  --mine-bg: #e8efff;
  --mine-line: #b8c9f3;
  /* The quoted words inside a cited passage (the source viewer), bold on a soft highlight. */
  --mark-bg: #fdeeb0;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand {
  margin: 0;
  font-weight: 600;
}

.session {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  color: var(--muted);
}

/* Live updates: a dot and a word; amber while the page reconnects. */
.live {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.875rem;
  color: var(--amber);
}

.live::before {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: currentColor;
}

.live.on {
  color: var(--ok);
}

.live[hidden] {
  display: none;
}

main {
  max-width: 60rem;
  margin: 0 auto;
  padding: 1.5rem 1rem 4rem;
}

h1,
h2,
h3 {
  line-height: 1.25;
  overflow-wrap: anywhere;
}

h1 {
  margin: 0 0 0.5rem;
  font-size: 1.6rem;
}

h2 {
  margin: 2rem 0 0.75rem;
  font-size: 1.2rem;
}

h3 {
  margin: 0 0 0.25rem;
  font-size: 1.05rem;
}

/* Headings get focus from the script when a screen opens; no ring needed. */
h1:focus {
  outline: none;
}

p {
  margin: 0.5rem 0;
}

a {
  color: var(--accent);
  text-underline-offset: 0.15em;
}

.meta {
  color: var(--muted);
  font-size: 0.9rem;
}

.panel,
.card {
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.panel > h2:first-child {
  margin-top: 0;
}

.narrow {
  max-width: 26rem;
}

/* Panels side by side when there is room, else one above the other. */
.panels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr));
  gap: 1rem;
}

/* Forms */

.field {
  margin-bottom: 1rem;
}

label {
  display: block;
  margin-bottom: 0.3rem;
  font-weight: 600;
}

label .meta {
  font-weight: 400;
}

/* A short explanation under an input. */
.hint {
  margin: 0.3rem 0 0;
}

input {
  max-width: 100%;
  font: inherit;
  color: inherit;
}

textarea, select {
  width: 100%;
  padding: 0.55rem 0.7rem;
  font: inherit;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--input-border);
  border-radius: 6px;
}

textarea { resize: vertical; font-family: ui-monospace, monospace; }
.list-heading, .pagination { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.list-heading h2 { margin: 0; }
.filters { display: flex; flex-wrap: wrap; align-items: end; gap: 0.75rem; margin: 1.25rem 0; }
.filters > div { flex: 1 1 8rem; }
.filters > div:first-child { flex: 2 1 12rem; }
.filters label { font-size: 0.85rem; }
.pagination { margin-top: 1rem; }
.pagination span { color: var(--muted); font-size: 0.9rem; }
.questionnaire-table { min-width: 42rem; }
dialog { width: min(44rem, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); overflow-y: auto; padding: 1.5rem; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
dialog::backdrop { background: rgb(0 0 0 / 40%); }
dialog input:not([type="file"]) { max-width: none; }
.context-preview { margin-top: 1rem; padding: 1rem; background: var(--code-bg); border: 1px solid var(--border); border-radius: 8px; }
.context-preview ul { max-height: 12rem; overflow-y: auto; padding-left: 1.25rem; }
.context-preview li { overflow-wrap: anywhere; }

input:not([type="file"]) {
  width: 100%;
  max-width: 26rem;
  padding: 0.55rem 0.7rem;
  background: var(--surface);
  border: 1px solid var(--input-border);
  border-radius: 6px;
}

button {
  min-height: 2.75rem;
  padding: 0.5rem 1rem;
  font: inherit;
  color: var(--on-accent);
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 6px;
  cursor: pointer;
}

button.secondary {
  color: var(--accent);
  background: transparent;
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

/* Messages stay in the page when empty, so screen readers keep listening. */

.message {
  margin: 0.75rem 0 0;
}

.message:empty {
  margin: 0;
}

.message.error,
.message.ok {
  padding: 0.5rem 0.75rem;
  border-left: 4px solid;
  border-radius: 4px;
}

.message.error {
  color: var(--error);
  background: var(--error-bg);
}

.message.ok {
  color: var(--ok);
  background: var(--ok-bg);
}

/* The list */

.cards {
  display: grid;
  gap: 0.75rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* The job */

progress {
  display: block;
  width: 100%;
  max-width: 26rem;
  height: 0.6rem;
  margin: 0.5rem 0;
  accent-color: var(--accent);
}

.code {
  max-height: 70vh;
  margin: 0.75rem 0 0;
  padding: 0.75rem;
  overflow: auto;
  font: 0.85rem/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

/* Long lines (the setup's rules are paragraphs) wrap instead of scrolling sideways. */
.code.wrap {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* The setup of an imported questionnaire: each name beside its value (above it on a phone). */

.setup {
  margin-bottom: 1rem;
}

.facts {
  margin: 0.5rem 0 0;
}

.facts > div {
  display: grid;
  grid-template-columns: 11rem minmax(0, 1fr);
  gap: 0.1rem 1rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
}

.facts > div:last-child {
  border-bottom: 0;
}

.facts dt {
  color: var(--muted);
}

/* Long values, such as the S3 address, break anywhere rather than widen the page. */
.facts dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.facts dd .meta {
  margin: 0.25rem 0 0;
}

/* The results */

.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 0.6rem 0.75rem;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
  overflow-wrap: anywhere;
}

tbody tr:last-child td {
  border-bottom: 0;
}

th {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

.key {
  display: block;
  font: 0.8rem/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--muted);
}

.badge {
  display: inline-block;
  padding: 0.1rem 0.55rem;
  font-size: 0.85rem;
  white-space: nowrap;
  background: var(--code-bg);
  border-radius: 999px;
}

.badge.needs_you {
  color: var(--needs);
  background: var(--needs-bg);
  box-shadow: inset 0 0 0 1px var(--needs-line);
}

.badge.check {
  color: var(--check);
  background: var(--check-bg);
  box-shadow: inset 0 0 0 1px var(--check-line);
}

.badge.done {
  color: var(--done);
  background: var(--done-bg);
  box-shadow: inset 0 0 0 1px var(--done-line);
}

.badge.mine {
  color: var(--mine);
  background: var(--mine-bg);
  box-shadow: inset 0 0 0 1px var(--mine-line);
}

.badge.needs_you, .badge.check, .badge.done, .badge.mine { font-weight: 600; }

.answers {
  margin: 0;
  padding-left: 1.5rem;
}

.answers > li {
  margin-bottom: 1.25rem;
  padding-left: 0.25rem;
}

.answers > li.empty {
  list-style: none;
}

.sources ul {
  margin: 0.25rem 0 0;
  padding-left: 1.25rem;
}

/* The filled-in form keeps its own light page, whatever the screen's theme. */
.form-frame {
  display: block;
  width: 100%;
  height: 75vh;
  margin-top: 0.75rem;
  color-scheme: light;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
}

/* Preparation is a read-only source view, not a stretched answer-editing canvas. */
.preparation-panel { margin-top: 1rem; }
.preview-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem; }
.preview-heading h2, .preview-heading .actions { margin: 0; }
.preview-heading [aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.check-option { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin: 1rem 0 0; font-size: 0.9rem; font-weight: 400; }
.check-option input[type="checkbox"] { width: 1rem; min-width: 1rem; }
.check-option .meta { flex-basis: 100%; margin-left: 1.5rem; }
.preview-surface { margin-top: 0.75rem; min-height: 14rem; padding: 0.75rem; background: #e9ebed; overflow: auto; }
.working-preview, .original-preview { display: block; width: 100%; max-width: 57rem; height: 78vh; min-height: 26rem; margin: 0 auto; border: 0; background: #fff; color-scheme: light; }
.preview-placeholder { max-width: 42rem; margin: 3rem auto; color: #343c44; }
#preparation-warnings { margin-top: 0.75rem; }
#preparation-warning-list { max-height: 18rem; overflow: auto; overflow-wrap: anywhere; }
#open-original-pdf { align-self: center; }
@media (max-width: 30rem) {
  .preview-heading .actions { width: 100%; flex-wrap: nowrap; }
  .preview-heading .actions button { flex: 1 1 auto; }
  .preview-surface { padding: 0.25rem; }
}

@media (max-width: 30rem) {
  main {
    padding-top: 1rem;
  }

  h1 {
    font-size: 1.35rem;
  }

  .actions button {
    flex: 1 1 100%;
  }

  .facts > div {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* The questionnaire's page is about the agent's work: a progress card while it works, then its
   filled page with the answers beside it (the approved review mockup), and one closed Details
   area for everything else. Wider than the list, so the answers and the page fit side by side. */
main:has(> #detail-view:not([hidden])) { max-width: 92rem; }

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

/* The questionnaire's bar: back, its name, and Details; on the review screen also the counts and
   "Next to do" (the approved mockup's top bar). */
.detail-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem; margin-bottom: 0.25rem; }
.bar-back { display: inline-flex; align-items: center; justify-content: center; min-width: 2.25rem; min-height: 2.25rem; font-size: 1.3rem; color: var(--muted); text-decoration: none; border-radius: 6px; }
.bar-back:hover { color: var(--text); background: var(--code-bg); }
.bar-name { flex: 1 1 16rem; min-width: 0; }
.bar-name h1 { margin: 0; }
.bar-name .meta { margin: 0.1rem 0 0; }
.bar-review { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.bar-end { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.bar-end button { min-height: 2.5rem; padding: 0.25rem 0.9rem; }
.count { min-height: 2.5rem; padding: 0.25rem 0.85rem; font-weight: 600; border: 1px solid; border-radius: 999px; }
.count.needs_you { color: var(--needs); background: var(--needs-bg); border-color: var(--needs-line); }
.count.check { color: var(--check); background: var(--check-bg); border-color: var(--check-line); }
.count:disabled { opacity: 1; cursor: default; }
.count:not(:disabled):hover { filter: brightness(0.97); }
#next-todo { min-height: 2.5rem; padding: 0.25rem 1rem; font-weight: 600; background: var(--select); border-color: var(--select); }

/* The card that follows the run. */
.agent-card { margin-top: 1rem; border-left: 4px solid var(--border); }
.agent-card.running { border-left-color: var(--accent); }
.agent-card.done { border-left-color: var(--ok); }
.agent-card.stopped { border-left-color: var(--amber); }
.agent-card-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem; }
.agent-card-head h2 { margin: 0; }
.chip { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.1rem 0.65rem; font-size: 0.85rem; font-weight: 600; white-space: nowrap; color: var(--muted); background: var(--code-bg); border-radius: 999px; }
.chip.running { color: var(--blue); background: var(--blue-bg); }
.chip.running::before { content: ""; width: 0.5rem; height: 0.5rem; border-radius: 50%; background: currentColor; animation: pulse 1.6s ease-in-out infinite; }
.chip.done { color: var(--ok); background: var(--ok-bg); }
.chip.stopped { color: var(--amber); background: var(--amber-bg); }
.agent-stage { max-width: 48rem; margin: 0.75rem 0 0; font-size: 1.15rem; font-weight: 600; }
.agent-card.done .agent-stage, .agent-card.stopped .agent-stage { font-size: 1rem; font-weight: 400; }
.agent-stage:empty { display: none; }
.progress-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.75rem; margin: 0.6rem 0 0.25rem; }
.progress-row .meta { white-space: nowrap; }
.agent-says { max-width: 48rem; margin: 0.6rem 0 0; padding-left: 0.7rem; color: #343c44; border-left: 3px solid var(--border); overflow-wrap: anywhere; }
.agent-says:empty { display: none; }
.agent-card #agent-elapsed:empty { display: none; }
.agent-next { max-width: 48rem; margin-top: 1rem; padding: 0.75rem 1rem; background: var(--amber-bg); border-radius: 8px; }
.agent-next h3 { margin: 0 0 0.25rem; font-size: 1rem; color: var(--amber); }
.agent-next p { margin: 0; }
/* Keep going: Resume and Raise limit (only when offered), when the run resumes by itself, the raise form. */
.agent-next #agent-auto-resume { margin-top: 0.5rem; }
.agent-next .actions { margin-top: 0.75rem; }
.raise-form { display: flex; flex-direction: column; gap: 0.4rem; max-width: 28rem; margin-top: 1rem; }
.raise-form label { font-weight: 600; }
.raise-form label:not(:first-child) { margin-top: 0.6rem; }
.raise-form input, .raise-form textarea { width: 100%; box-sizing: border-box; }
.raise-form textarea { font-family: inherit; }
.raise-form .actions { margin-top: 0.6rem; }
/* The agent's notice when a large share of the questions need a person (AMENDMENTS B6). */
.agent-share { max-width: 48rem; margin: 0.75rem 0 0; font-weight: 600; color: var(--amber); }
/* Once done: what the run leaves for a person, above the answers; kept compact. */
.person-list { margin: 0 0 0.75rem; padding: 0.6rem 1rem; background: var(--amber-bg); border-radius: 8px; }
.person-list h3 { margin: 0 0 0.25rem; font-size: 1rem; color: var(--amber); }
.person-list p { margin: 0 0 0.25rem; }
.person-list ul { max-height: 10rem; margin: 0.25rem 0 0; padding-left: 1.25rem; overflow-y: auto; font-size: 0.9rem; }
.person-list li { margin: 0.15rem 0; overflow-wrap: anywhere; }
#detail-view.reviewing .person-list { flex: 0 0 auto; margin: 0; border-bottom: 1px solid var(--border); border-radius: 0; }

/* The bar: a share of the sections when known, else a band that moves. */
#agent-progress {
  flex: 1 1 16rem;
  width: auto;
  max-width: none;
  height: 0.75rem;
  margin: 0;
  -webkit-appearance: none;
  appearance: none;
  overflow: hidden;
  color: var(--accent);
  background: var(--blue-bg);
  border: 0;
  border-radius: 999px;
}
#agent-progress::-webkit-progress-bar { background: var(--blue-bg); border-radius: 999px; }
#agent-progress::-webkit-progress-value { background: var(--accent); border-radius: 999px; transition: width 0.4s ease; }
#agent-progress::-moz-progress-bar { background: var(--accent); border-radius: 999px; }
#agent-progress:indeterminate {
  background: linear-gradient(90deg, transparent 0 35%, var(--accent) 35% 65%, transparent 65% 100%) var(--blue-bg);
  background-size: 250% 100%;
  animation: band 1.6s linear infinite;
}
#agent-progress:indeterminate::-webkit-progress-bar { background: transparent; }
#agent-progress:indeterminate::-moz-progress-bar { background: transparent; }
@keyframes band { from { background-position: 100% 0; } to { background-position: 0% 0; } }
@keyframes pulse { 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) {
  #agent-progress:indeterminate, .chip.running::before, .step.now::before { animation: none; }
  #agent-progress:indeterminate { background-position: 50% 0; }
}

/* The five steps: one under another on a phone, side by side when there is room. */
.steps { display: grid; gap: 0.5rem; margin: 1.1rem 0 0; padding: 0; list-style: none; }
.step { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.6rem; color: var(--muted); font-size: 0.95rem; }
.step::before { content: ""; position: relative; z-index: 1; display: inline-flex; flex: 0 0 auto; align-items: center; justify-content: center; width: 1.5rem; height: 1.5rem; font-size: 0.8rem; font-weight: 700; line-height: 1; background: var(--surface); border: 2px solid var(--border); border-radius: 50%; }
.step.done { color: var(--text); }
.step.done::before { content: "✓"; color: var(--on-accent); background: var(--ok); border-color: var(--ok); }
.step.now { color: var(--text); font-weight: 600; }
.step.now::before { background: radial-gradient(circle, var(--accent) 0 38%, var(--surface) 43%); border-color: var(--accent); animation: pulse 1.6s ease-in-out infinite; }
.step.stopped { color: var(--amber); font-weight: 600; }
.step.stopped::before { content: "!"; color: var(--amber); background: var(--amber-bg); border-color: var(--amber); }
.step-note { font-weight: 400; color: var(--muted); }
.step-note::before { content: "· "; }
@media (min-width: 48rem) {
  .steps { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0.5rem; }
  .step { flex-direction: column; align-items: center; text-align: center; }
  .step:not(:first-child)::after { content: ""; position: absolute; top: 0.7rem; right: 50%; width: 100%; height: 2px; background: var(--border); }
  .step.done::after, .step.now::after, .step.stopped::after { background: var(--ok); }
  .step-note { display: block; }
  .step-note::before { content: none; }
}

/* The start panel: the main card with no run yet, and in Details afterwards. */
#agent-start-slot #agent-panel { margin-top: 1rem; }
#intake-saved { margin: 0 0 0.5rem; }
.agent-approval { margin-top: 1rem; padding: 1rem; background: var(--code-bg); border: 1px solid var(--border); border-radius: 8px; }
.agent-approval h3 { margin-top: 0; }
.agent-approval h4 { margin: 1rem 0 0.25rem; font-size: 1rem; }
.agent-approval ul { margin: 0.25rem 0 0; padding-left: 1.25rem; }
#agent-blocked h4 { color: var(--error); }

/* The agent's page, alone while it works and with the answers beside it once done. */
.agent-review { margin-top: 1.25rem; }
.review-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.25rem 1rem; }
.review-head h2 { margin: 0; }
.review-head .meta { margin: 0; }
.agent-answers { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; margin-top: 0.75rem; }
.agent-answer-list { max-height: 60vh; overflow: auto; overflow-wrap: anywhere; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
.agent-frame { min-height: 14rem; overflow: hidden; background: #e9ebed; border: 1px solid var(--border); border-radius: 8px; }
.agent-filled { display: block; width: 100%; height: 75vh; min-height: 26rem; border: 0; background: #fff; color-scheme: light; }
@media (min-width: 60rem) {
  .agent-answers.with-list { grid-template-columns: minmax(18rem, 24rem) minmax(0, 1fr); }
  .agent-answer-list { max-height: 82vh; }
  .agent-filled { height: 82vh; }
}

.list-head { position: sticky; top: 0; z-index: 1; padding: 0.75rem 0.9rem 0.6rem; background: var(--surface); border-bottom: 1px solid var(--border); }
.list-label { margin-bottom: 0.25rem; font-size: 0.8rem; color: var(--muted); }
.section-picker { font-weight: 600; }
.list-head p { margin: 0.4rem 0 0; }
.list-hint { font-size: 0.85rem; }
.list-empty { padding: 1rem; }
.answer-items { margin: 0; padding: 0.35rem 0.4rem 1rem; list-style: none; }
.answer-item { display: flex; align-items: flex-start; gap: 0.6rem; width: 100%; min-height: 0; padding: 0.5rem; text-align: left; color: var(--text); background: transparent; border: 0; border-radius: 6px; font-size: 0.95rem; }
.answer-item:hover { background: #f0f3f5; }
.answer-item.is-selected { background: var(--select-bg); box-shadow: inset 3px 0 0 var(--select); }
.answer-item-value.needs { font-style: normal; color: var(--needs); }
.answer-item-main { flex: 1; min-width: 0; }
.answer-item-title { display: block; font-weight: 600; }
.answer-item-value { display: block; overflow: hidden; color: var(--muted); font-size: 0.875rem; white-space: nowrap; text-overflow: ellipsis; }
.answer-item-value.empty { font-style: italic; }
.dot { display: inline-flex; flex: 0 0 auto; align-items: center; justify-content: center; width: 1.3rem; height: 1.3rem; margin-top: 0.1rem; font-size: 0.75rem; font-weight: 800; color: var(--muted); background: var(--code-bg); border-radius: 50%; }
.dot.needs_you { color: var(--needs); background: var(--needs-bg); box-shadow: inset 0 0 0 1px var(--needs-line); }
.dot.check { color: var(--check); background: var(--check-bg); box-shadow: inset 0 0 0 1px var(--check-line); }
.dot.done { color: var(--done); background: var(--done-bg); box-shadow: inset 0 0 0 1px var(--done-line); }
.dot.mine { color: var(--mine); background: var(--mine-bg); box-shadow: inset 0 0 0 1px var(--mine-line); }

/* One answer: its question, its answer and its sources. */
.answer-card { padding: 0.75rem 1rem 1.5rem; }
.back-button { min-height: 0; padding: 0.25rem 0; font-weight: 600; color: var(--accent); background: none; border: 0; }
.crumb { margin: 0.5rem 0 0; font-size: 0.85rem; color: var(--muted); }
.answer-card-title { margin: 0.15rem 0 0.5rem; font-size: 1.15rem; }
.answer-card-title:focus { outline: none; }
.tagline { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; margin: 0; font-size: 0.9rem; color: var(--muted); }
.card-sec { margin-top: 1rem; }
.card-sec h4 { margin: 0 0 0.3rem; font-size: 0.75rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.answer { margin: 0; font-size: 1.05rem; font-weight: 600; white-space: pre-wrap; }
.answer.empty { font-weight: 400; font-style: italic; color: var(--muted); }
.answer-lines { margin: 0; padding-left: 1.1rem; font-weight: 600; }
.why, .question { margin: 0; white-space: pre-wrap; }
/* The AI's own one sentence on why, right under the tag; its longer reason waits under More detail. */
.why-line { margin: 0.4rem 0 0; font-size: 0.95rem; }
.more-detail > summary { cursor: pointer; font-size: 0.85rem; color: var(--accent); }
.more-detail[open] > summary { margin-bottom: 0.4rem; }
.source { margin-top: 0.5rem; padding: 0.6rem 0.75rem; border: 1px solid var(--border); border-radius: 8px; }
.source-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.25rem 0.5rem; }
.source-kind { padding: 0.05rem 0.4rem; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase; color: var(--muted); background: var(--code-bg); border-radius: 4px; }
.source-name { font-weight: 600; }
.source-where { font-size: 0.85rem; color: var(--muted); }
.quote { margin: 0.4rem 0 0; padding: 0.2rem 0 0.2rem 0.7rem; font-size: 0.9rem; white-space: pre-wrap; border-left: 3px solid #b9cfe0; }
.badge b { margin-right: 0.1rem; }
.conflict { color: var(--amber); }

/* Details: closed until someone opens it. */
.more { margin-top: 2rem; padding-top: 0.25rem; border-top: 1px solid var(--border); }
.more > summary { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.25rem 0.6rem; padding: 0.75rem 0; font-size: 1.05rem; font-weight: 600; cursor: pointer; list-style: none; }
.more > summary::-webkit-details-marker { display: none; }
.more > summary::before { content: "▸"; color: var(--muted); }
.more[open] > summary::before { content: "▾"; }
.more > summary .meta { font-weight: 400; }
.more-body { display: grid; gap: 1rem; }
.more-body .panel, .more-body .preparation-panel { margin: 0; }
.sub { margin: 1rem 0 0.25rem; font-size: 0.95rem; }
.history { margin: 0.25rem 0 0; padding-left: 1.25rem; font-size: 0.9rem; }

/* The review screen's left side: filters, the list of what is left, a table's boxes. */
.review-filters { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.5rem; }
.filter { min-height: 2rem; padding: 0.15rem 0.7rem; font-size: 0.85rem; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 999px; }
.filter[aria-pressed="true"] { color: var(--on-accent); background: var(--text); border-color: var(--text); }
.list-title { margin: 0.4rem 0 0; font-size: 1.15rem; }
.list-title:focus { outline: none; }
.todo-sec { margin-top: 0.5rem; }
.todo-sec-title { margin: 0; padding: 0.4rem 0.9rem 0; font-size: 0.85rem; color: var(--muted); }
.todo-sec .answer-items { padding-bottom: 0.25rem; }
.targets { margin: 0; padding: 0; list-style: none; }
.target { display: flex; align-items: flex-start; gap: 0.5rem; padding: 0.3rem 0; border-bottom: 1px solid #eef0f2; }
.target:last-child { border-bottom: 0; }
.target .dot { width: 1.1rem; height: 1.1rem; font-size: 0.65rem; }
.target-main { display: flex; flex-direction: column; min-width: 0; }
.target-name { font-size: 0.8rem; color: var(--muted); }
.target-value { font-weight: 600; white-space: pre-wrap; }
.target-value.empty { font-weight: 400; color: var(--muted); }
.answer-item-title { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.whole-question { margin: -0.25rem 0 0.5rem; font-size: 0.85rem; color: var(--muted); }
.whole-question > summary { cursor: pointer; color: var(--accent); }
.whole-question p { margin: 0.25rem 0 0; }
.target-row { margin: 0 0 0.25rem; font-size: 0.9rem; }
.target-row-key { font-size: 0.75rem; font-weight: 700; color: var(--muted); }
.looked > summary { cursor: pointer; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
/* A table of rows: one line per row (its name and what is left in it); a click opens its first cell. */
.row-list { margin: 0; padding: 0; list-style: none; }
.row-item { display: flex; align-items: center; gap: 0.5rem; width: 100%; min-height: 0; padding: 0.35rem 0.25rem; text-align: left; color: var(--text); background: transparent; border: 0; border-bottom: 1px solid #eef0f2; border-radius: 0; font-size: 0.92rem; }
.row-list li:last-child .row-item { border-bottom: 0; }
.row-item:hover { background: #f0f3f5; }
.row-item .dot { width: 1.1rem; height: 1.1rem; margin-top: 0; font-size: 0.65rem; }
.row-name { flex: 1; min-width: 0; overflow: hidden; font-weight: 600; white-space: nowrap; text-overflow: ellipsis; }
.row-left { flex: 0 0 auto; font-size: 0.82rem; color: var(--muted); }
.rows-open .row-name { font-weight: 400; color: var(--muted); }
.row-list-wrap .meta { margin: 0.35rem 0 0; }
/* One cell of a table: "Whole table · N rows, M need you" leads back to the row list. */
.whole-line { margin: 1rem 0 0; }
.whole-line .link-button { min-height: 0; padding: 0; font-weight: 600; color: var(--accent); background: none; border: 0; text-align: left; text-decoration: underline; text-underline-offset: 2px; }
/* The source viewer: numbered tabs, one per document, then the open document's cited passage as
   formatted text with the quoted words marked (as the RightOrigins panel shows them). */
.source-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem 0.4rem; }
.source-label { color: var(--muted); font-size: 0.85rem; margin-right: 0.1rem; }
/* A name may shrink below its text (min-width: 0) so a narrow answers panel cuts it with "…". */
.source-chip { display: inline-flex; align-items: center; gap: 0.4rem; min-width: 0; max-width: min(16rem, 100%); min-height: 1.9rem; padding: 0.15rem 0.6rem; color: var(--text); background: var(--code-bg); border: 1px solid var(--border); border-radius: 6px; font-size: 0.85rem; cursor: pointer; }
.source-chip:hover { border-color: var(--accent); }
.source-chip:focus-visible, .source-more:focus-visible, .source-close:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.source-chip .source-icon { margin-top: 0; }
.source-chip-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source-more { min-height: 1.9rem; padding: 0.15rem 0.3rem; color: var(--accent); background: transparent; border: 0; font-weight: 600; font-size: 0.85rem; cursor: pointer; }
.source-bar { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.source-bar h4 { margin: 0; }
.source-close { min-height: 2rem; padding: 0.1rem 0.4rem; color: var(--muted); background: transparent; border: 0; font-size: 1.15rem; line-height: 1; cursor: pointer; }
.source-viewer { margin-top: 0.4rem; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.source-tabs { display: flex; flex-wrap: wrap; gap: 0.25rem; padding: 0.4rem 0.5rem 0; background: var(--code-bg); border-bottom: 1px solid var(--border); }
.source-tab { min-width: 2rem; min-height: 2rem; padding: 0.1rem 0.6rem; font-weight: 600; color: var(--muted); background: transparent; border: 1px solid transparent; border-bottom: 0; border-radius: 6px 6px 0 0; }
.source-tab[aria-selected="true"] { color: var(--text); background: var(--surface); border-color: var(--border); margin-bottom: -1px; }
.source-tab:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.source-panel { padding: 0.6rem 0.75rem 0.75rem; }
.source-doc { display: flex; align-items: flex-start; gap: 0.5rem; }
.source-doc .source-name { min-width: 0; overflow-wrap: anywhere; }
.source-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.25rem 0.75rem; margin-top: 0.1rem; }
.source-open { margin-left: auto; font-size: 0.85rem; font-weight: 600; color: var(--accent); }
/* Each kind of source has its own small drawn icon: a page, a page with a tick, a rule, the form. */
.source-icon { position: relative; flex: 0 0 auto; width: 0.85rem; height: 1.05rem; margin-top: 0.2rem; border: 1.5px solid var(--muted); border-radius: 2px; }
.source-icon::after { content: ""; position: absolute; left: 0.15rem; right: 0.15rem; top: 0.25rem; height: 0.4rem; border-top: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); }
.source-icon.document { border-color: var(--accent); }
.source-icon.document::after { border-color: var(--accent); }
.source-icon.past_answer { border-color: var(--done); }
.source-icon.past_answer::after { left: 0.2rem; top: 0.3rem; width: 0.3rem; height: 0.45rem; border: 0; border-right: 1.5px solid var(--done); border-bottom: 1.5px solid var(--done); transform: rotate(45deg); }
.source-icon.rule { width: 1rem; height: 1rem; border-color: var(--amber); border-radius: 50%; }
.source-icon.rule::after { left: 0.36rem; right: auto; top: 0.18rem; width: 0; height: 0.45rem; border: 0; border-left: 1.5px solid var(--amber); }
.source-icon.form { width: 1.05rem; height: 0.85rem; border-color: var(--mine); }
.source-icon.form::after { top: 0.15rem; height: 0.3rem; border-color: var(--mine); }
.passage-heading { margin: 0.4rem 0 0; font-size: 0.8rem; font-weight: 600; color: var(--muted); }
.passage { margin-top: 0.4rem; font-size: 0.9rem; overflow-wrap: anywhere; }
.passage > :first-child { margin-top: 0; }
.passage > :last-child { margin-bottom: 0; }
.passage p { margin: 0.4rem 0; }
.passage h5, .passage h6 { margin: 0.6rem 0 0.25rem; font-size: 0.95rem; }
.passage h6 { font-size: 0.88rem; }
.passage ul, .passage ol { margin: 0.4rem 0; padding-left: 1.3rem; }
.passage code { padding: 0 0.2rem; font-size: 0.85em; background: var(--code-bg); border-radius: 3px; }
.passage-table { max-width: 100%; margin: 0.4rem 0; overflow-x: auto; }
.passage table { border-collapse: collapse; font-size: 0.85rem; }
.passage th, .passage td { padding: 0.25rem 0.45rem; text-align: left; vertical-align: top; border: 1px solid var(--border); overflow-wrap: normal; }
.passage th { background: var(--code-bg); }
.passage tbody tr:last-child td { border-bottom: 1px solid var(--border); }
.passage mark { font-weight: 700; color: inherit; background: var(--mark-bg); border-radius: 2px; }
.passage-pager { display: flex; align-items: center; justify-content: center; gap: 0.5rem; margin-top: 0.6rem; font-size: 0.85rem; color: var(--muted); }
.pager-step { min-width: 2rem; min-height: 2rem; padding: 0; font-size: 1.1rem; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 6px; }
.pager-step:disabled { opacity: 0.4; }

/* The review screen's right side: Show original and the legend above the form, and the divider. */
.form-pane { display: flex; flex-direction: column; min-width: 0; }
.form-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1rem; padding: 0.5rem 0.9rem; background: var(--surface); border-bottom: 1px solid var(--border); }
.form-tools button { min-height: 2.25rem; padding: 0.25rem 0.9rem; }
.form-tools button[aria-pressed="true"] { color: var(--on-accent); background: var(--accent); }
.legend { display: flex; flex-wrap: wrap; gap: 0.4rem; }
/* Edit: a switch, as the mockup has it. */
.edit-tools { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.6rem; margin-right: auto; }
.form-tools .switch { display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.25rem 0.75rem 0.25rem 0.4rem; font-weight: 600; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 999px; }
.form-tools .switch[aria-pressed="true"] { color: var(--text); background: var(--select-bg); border-color: #b8c9f3; }
.switch-track { position: relative; width: 2.1rem; height: 1.2rem; background: #c3cad1; border-radius: 999px; transition: background 0.15s; }
.switch-knob { position: absolute; top: 0.15rem; left: 0.15rem; width: 0.9rem; height: 0.9rem; background: #fff; border-radius: 50%; box-shadow: 0 1px 2px #0003; transition: left 0.15s; }
.switch[aria-pressed="true"] .switch-track { background: var(--select); }
.switch[aria-pressed="true"] .switch-knob { left: 1.05rem; }
.tools-hint { font-size: 0.85rem; color: var(--muted); }
/* The open answer's own actions: change it on the form, Looks right, Undo. */
.answer-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem; margin-top: 0.6rem; }
.answer-actions button { min-height: 2.25rem; padding: 0.25rem 0.9rem; }
.answer-actions .looks-right { color: var(--done); font-weight: 600; background: var(--done-bg); border: 1px solid #3fa463; }
.answer-actions .link-button, .toast-undo { min-height: 0; padding: 0 0.15rem; font-weight: 600; color: var(--accent); background: none; border: 0; text-decoration: underline; text-underline-offset: 2px; }
.toast-undo { color: #9cc3ff; }
.before { margin: 0; white-space: pre-wrap; color: var(--muted); }
.before.empty { font-style: italic; }
/* An unchecked draft (D9): muted, never styled as an answer. */
.unchecked { color: var(--muted); }
.unchecked.before, .answer-item-value.unchecked { font-style: italic; }
.unchecked .target-value { color: var(--muted); }
.legend .badge { font-size: 0.8rem; }
.splitter { position: relative; cursor: col-resize; background: var(--surface); border-left: 1px solid var(--border); border-right: 1px solid var(--border); touch-action: none; outline: none; }
.splitter-grip { position: absolute; top: 50%; left: 50%; width: 3px; height: 2.25rem; transform: translate(-50%, -50%); border-radius: 3px; background: repeating-linear-gradient(to bottom, #aab6c0 0 3px, transparent 3px 6px); }
.splitter:hover, .splitter:focus-visible, .resizing > .splitter { background: var(--select-bg); border-color: #b8c9f3; }
.splitter:hover .splitter-grip, .splitter:focus-visible .splitter-grip, .resizing > .splitter .splitter-grip { background: repeating-linear-gradient(to bottom, var(--select) 0 3px, transparent 3px 6px); }
.agent-answers.resizing { cursor: col-resize; user-select: none; }
.agent-answers.resizing iframe { pointer-events: none; }
.review-toast { position: fixed; left: 50%; bottom: 1.25rem; z-index: 50; max-width: min(36rem, calc(100vw - 2rem)); margin: 0; padding: 0.6rem 0.9rem; font-size: 0.9rem; color: #fff; background: #1f2933; border-radius: 10px; box-shadow: 0 8px 24px #0004; transform: translateX(-50%); }

/* The review screen fills the window under the bar: the answers and the form scroll on their own. */
main:has(> #detail-view.reviewing:not([hidden])) { max-width: none; padding: 0; }
#detail-view.reviewing .detail-bar { margin: 0; padding: 0.5rem 1rem; background: var(--surface); border-bottom: 1px solid var(--border); }
#detail-view.reviewing .bar-name { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 0.75rem; }
#detail-view.reviewing .bar-name h1 { overflow: hidden; font-size: 1.1rem; white-space: nowrap; text-overflow: ellipsis; }
#detail-view.reviewing .bar-name .meta { font-size: 0.8rem; }
#detail-view.reviewing > .message:not(:empty), #detail-view.reviewing #agent-answers-message:not(:empty) { margin: 0.5rem 1rem; }
#detail-view.reviewing > .agent-review { margin: 0; }
.agent-answers.reviewing { gap: 0; margin: 0; background: var(--surface); border-top: 0; }
.agent-answers.reviewing > .agent-answer-list { border: 0; border-radius: 0; }
.agent-answers.reviewing .agent-frame { border: 0; border-radius: 0; background: #eef1f3; }

@media (min-width: 54rem) {
  body:has(#detail-view.reviewing:not([hidden])) { display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }
  body:has(#detail-view.reviewing:not([hidden])) > main { display: flex; flex: 1 1 auto; flex-direction: column; width: 100%; min-height: 0; }
  #detail-view.reviewing { display: flex; flex: 1 1 auto; flex-direction: column; min-height: 0; }
  #detail-view.reviewing > .agent-review { display: flex; flex: 1 1 auto; flex-direction: column; min-height: 0; }
  .agent-answers.reviewing { flex: 1 1 auto; min-height: 0; grid-template-columns: var(--left-width, 26.25rem) 9px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
  .agent-answers.reviewing > .agent-answer-list { max-height: none; min-height: 0; }
  .agent-answers.reviewing .form-pane { min-height: 0; }
  .agent-answers.reviewing .agent-frame { flex: 1 1 auto; min-height: 0; }
  .agent-answers.reviewing .agent-filled { height: 100%; min-height: 0; }
  /* Details opens beside the form, over it, as the mockup's Details menu does. */
  #detail-view.reviewing > .more { position: fixed; top: 0; right: 0; bottom: 0; z-index: 40; width: min(38rem, 100vw); margin: 0; padding: 0 1rem 2rem; overflow: auto; background: var(--bg); border-top: 0; border-left: 1px solid var(--border); box-shadow: -12px 0 32px #17212b2e; }
}
#detail-view.reviewing > .more:not([open]) { display: none; }
#detail-view.reviewing > .more > summary { position: sticky; top: 0; z-index: 1; background: var(--bg); border-bottom: 1px solid var(--border); }
#detail-view.reviewing > .more > summary::before { content: none; }
#detail-view.reviewing > .more > summary::after { content: "Close ✕"; margin-left: auto; font-size: 0.9rem; font-weight: 400; color: var(--accent); }
#detail-view.reviewing > .more > .more-body { padding-top: 1rem; }
.details-download { display: flex; justify-content: flex-end; }

/* On a phone the review screen stacks: the answers first, then the form; no divider. */
@media (max-width: 53.99rem) {
  .agent-answers.reviewing { grid-template-columns: minmax(0, 1fr); }
  .agent-answers.reviewing > .splitter { display: none; }
  .agent-answers.reviewing > .agent-answer-list { max-height: 55vh; border-bottom: 1px solid var(--border); }
  .agent-answers.reviewing .agent-filled { height: 75vh; }
  #detail-view.reviewing .bar-name { flex: 1 1 0; }
  #detail-view.reviewing .bar-review { order: 3; width: 100%; gap: 0.4rem; }
  #detail-view.reviewing .count, #detail-view.reviewing #next-todo { min-height: 2.25rem; padding: 0.2rem 0.65rem; font-size: 0.85rem; }
  #detail-view.reviewing #next-todo { margin-left: auto; }
  #detail-view.reviewing > .more { margin: 1rem; }
  .legend { display: none; }
}
