/* PaperLens record-rendering grammar — rv-* result grid, ev-* evidence,
 * confidence badges, editable cells, PDF highlight overlay. Tokens only. */

.rv-root { font-size: 13px; }
/* fields flow horizontally as key→value pairs, wrapping into as many columns as fit
   (min 260px each); collapses to a single column in narrow/nested containers. */
.rv-obj { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  gap: 0 24px; width: 100%; align-items: start; }
.rv-row { display: flex; gap: 14px; justify-content: space-between; align-items: baseline;
  min-width: 0; padding: 6px 0; border-bottom: 1px solid var(--border); }
.rv-key { font-weight: 600; color: var(--text-muted); flex: 0 0 auto; }
.rv-val { color: var(--text); line-height: 1.5; word-break: break-word; flex: 0 1 auto;
  min-width: 0; text-align: left; }
/* nested objects/tables take the full row width and stack the value under the key */
.rv-row.rv-row-block { grid-column: 1 / -1; flex-direction: column; align-items: stretch; gap: 3px; }
.rv-row.rv-row-block > .rv-val { text-align: left; }
.rv-val.rv-nested { width: 100%; padding: 2px 0; }
.rv-num { color: var(--accent-2); font-variant-numeric: tabular-nums; font-family: var(--font-mono); }
.rv-null { color: var(--text-muted); font-style: italic; }
.rv-editable.rv-empty { min-width: 1.6em; display: inline-block; }
.rv-editable.rv-empty:empty::before { content: "—"; color: var(--text-muted); font-style: italic; }
.rv-editable.rv-empty:focus:empty::before { content: ""; }

/* wide/nested tables scroll horizontally inside the panel rather than crushing columns */
.rv-tablewrap { overflow-x: auto; max-width: 100%; }
.rv-table { border-collapse: collapse; font-size: 12.5px; margin: 2px 0; }
/* word-break:normal overrides the inherited break-word so words don't split letter-by-letter
   in a narrow column; min/max-width keep cells readable, and long labels wrap at spaces. */
.rv-table th, .rv-table td { border: 1px solid var(--border); padding: 3px 8px; text-align: left;
  vertical-align: top; word-break: normal; overflow-wrap: break-word; min-width: 64px; max-width: 280px; }
.rv-table th { background: var(--bg); font-weight: 600; color: var(--text-muted); white-space: nowrap; }
/* a cell holding a nested table/object must not be width-capped — its own wrapper scrolls */
.rv-table td:has(.rv-tablewrap), .rv-table td:has(.rv-obj) { max-width: none; }

/* render_hints "cards": one card per array element — header line, sub-table, details below */
.rv-card { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px;
  margin: 8px 0; background: var(--surface); }
.rc-head { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-bottom: 8px; font-size: 12.5px; }
.rc-hk { color: var(--text-muted); font-weight: 600; margin-right: 3px; }
.rc-below { margin-top: 8px; }

/* edit-in-place — corrections route through the verification layer */
.rv-editable { cursor: text; border-bottom: 1px dashed transparent; border-radius: 3px; padding: 0 2px;
  transition: background .15s, border-color .15s; }
.rv-editable:hover { background: var(--accent-wash); border-bottom-color: var(--accent); }
.rv-editable:focus { outline: none; background: var(--accent-wash); box-shadow: 0 0 0 2px var(--accent-wash); }
/* blank fields (e.g. a manually added finding) still need a clickable target */
.rv-editable:empty { display: inline-block; min-width: 3.5em; min-height: 1.1em;
  border-bottom-color: var(--accent); }
.rv-edited { background: var(--override-bg); border-bottom: 2px solid var(--override-line); border-radius: 2px 2px 0 0; }

/* typed edit controls declared by a preset's field_types (dropdown / multi-select) */
.rv-selwrap { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; max-width: 100%; }
.rv-select, .rv-other { font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 4px; padding: 2px 6px; max-width: 100%; }
.rv-select:focus, .rv-other:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-wash); }
.rv-multi { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.rv-chk { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; cursor: pointer; white-space: nowrap; }
.rv-chk input { width: auto; margin: 0; }

/* confidence badges */
.confidence-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.confidence-badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px;
  border-radius: 999px; font-size: 12px; font-weight: 600; border: 1px solid; }
.confidence-high { background: var(--conf-high-bg); border-color: var(--conf-high-bd); color: var(--conf-high); }
.confidence-medium { background: var(--conf-med-bg); border-color: var(--conf-med-bd); color: var(--conf-med); }
.confidence-low { background: var(--conf-low-bg); border-color: var(--conf-low-bd); color: var(--conf-low); }

/* evidence blocks (detail panel) */
.ev-block { border-left: 3px solid var(--accent); padding-left: 12px; margin: 8px 0; }
.ev-snippet { font-size: 12.5px; font-style: italic; color: var(--text); line-height: 1.6; margin: 0 0 6px; }
.ev-snippet::before { content: "\201C"; } .ev-snippet::after { content: "\201D"; }
.ev-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.ev-tag { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px;
  background: var(--bg); color: var(--text-muted); font-family: var(--font-mono); }
.ev-tag.ev-page { background: var(--accent-wash); color: var(--accent); }
.ev-tag.ev-source { background: var(--success-bg); color: var(--success); }

/* PDF page + highlight overlay (the signature evidence trace) */
.page { position: relative; width: calc(var(--pdf-zoom, 1) * 100%); min-width: calc(var(--pdf-zoom, 1) * 460px);
  max-width: calc(var(--pdf-zoom, 1) * 900px); margin: 0 auto 18px; background: var(--surface);
  box-shadow: var(--shadow-sm); }
.pageimg { display: block; width: 100%; }
.overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.pagelabel { position: absolute; top: 4px; left: 4px; background: var(--accent); color: var(--on-accent);
  font-size: 11px; padding: 1px 6px; border-radius: 3px; z-index: 2; }
/* Only ONE evidence is shown at a time: every rect is transparent by default (no wall of
   highlights that makes the page unreadable), and clicking a value/field paints just that
   one (.sel), replacing the previous. .hot is the transient hover preview. */
rect.hl { fill: transparent; stroke: none; }
rect.hl.sel { fill: var(--highlight-focus); stroke: var(--highlight-stroke); stroke-width: 2; }
rect.hl.hot { fill: var(--highlight-focus); stroke: var(--highlight-stroke); stroke-width: 2; }
.val-check { font-size: 11px; color: var(--conf-med); margin-left: 8px; cursor: help; white-space: nowrap; }
rect.hl.flash { fill: var(--highlight-focus); stroke: var(--highlight-stroke); stroke-width: 2.5;
  animation: hl-pulse .5s ease 0s 3; }
@keyframes hl-pulse { 50% { fill: var(--green-focus); stroke: var(--green-stroke); } }

/* an extracted value that has linked evidence — hover previews, click jumps */
.rv-linked { cursor: pointer; border-bottom: 1px dotted var(--accent-3); }
.rv-linked:hover { background: var(--highlight); }
/* the field-name key is also click-to-evidence, but stays a plain label (no underline) */
.rv-key.rv-linked { border-bottom: none; }
/* read-only value with no cited evidence — still locatable in the PDF on click */
.rv-probe { cursor: pointer; }
.rv-probe:hover { background: var(--highlight); }

/* per-record card (panel) */
.record { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 12px;
  background: var(--surface); }
/* study-level info shown once above the per-condition entries */
.study-block { border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg);
  padding: 8px 12px; margin-bottom: 14px; }
.study-block > summary { cursor: pointer; font-weight: 600; }
.study-block .study-body { margin-top: 8px; }
.study-block .study-shared { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--border); }
.study-block .study-sub { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; }
.record.focus { animation: rec-focus 2.3s ease; }
@keyframes rec-focus { 0%, 100% { box-shadow: none; } 12%, 62% { box-shadow: 0 0 0 3px var(--accent-wash); border-color: var(--accent); } }
.rectitle { font-weight: 600; margin-bottom: 8px; display: flex; gap: 8px; align-items: center; }
.recdel { margin-left: auto; border: none; background: none; cursor: pointer; font-size: 12px; opacity: .4; }
.recdel:hover { opacity: 1; }

/* sub-view tabs (metadata / correlations / effect sizes …) inside a record card */
.subtabs { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0 12px; border-bottom: 1px solid var(--border); }
/* every tab is a visible chip (not only the active one) so a reviewer sees there are more */
.subtab { font-size: 13px; font-weight: 600; border: 1px solid var(--border); border-bottom: none; background: var(--bg); cursor: pointer;
  padding: 6px 14px; border-radius: var(--radius-sm) var(--radius-sm) 0 0; color: var(--text-muted); margin-bottom: -1px; }
.subtab:hover { color: var(--text); background: var(--surface); }
.subtab.active { color: var(--accent); background: var(--surface); border-color: var(--border); }
.subpanel.hidden { display: none; }
.verify { display: flex; gap: 6px; margin-bottom: 10px; }
.vbtn { font-size: 11px; border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius-sm);
  padding: 3px 9px; cursor: pointer; }
.vbtn.ok:hover { background: var(--success-bg); border-color: var(--success); color: var(--success); }
.vbtn.flag:hover { background: var(--error-bg); border-color: var(--error); color: var(--error); }
.vbtn:disabled { opacity: .5; cursor: default; }
.chips { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; }

/* ── declarative presets: typed fields, citation state, confidence ─────────── */
.rv-missing { color: var(--text-muted); font-style: italic; border-bottom: 1px dotted var(--conf-med-bd); cursor: help; }
.rv-row-missing .rv-key { color: var(--conf-med); }
.rv-text { white-space: pre-wrap; display: inline-block; max-width: 100%; }
.rv-chip { display: inline-block; padding: 1px 7px; border-radius: 999px; background: var(--bg);
  border: 1px solid var(--border); font-size: 12px; margin: 1px 0; }
.rv-table.rv-typed td, .rv-table.rv-typed th { vertical-align: middle; }
.rv-kv td:first-child { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); }
/* a value's citation state — where its evidence is, at a glance */
.rv-cited { border-bottom: 1px dotted var(--accent-3); cursor: pointer; }
.rv-cited:hover { background: var(--highlight); }
.rv-cited-nofix { border-bottom: 1px dotted var(--conf-med-bd); cursor: pointer; }
.rv-covered { cursor: pointer; }
.rv-covered:hover { background: var(--highlight); }
.rv-uncited { box-shadow: inset 0 -2px 0 var(--conf-low-bg); }
.rv-uncited::after { content: "no evidence"; font-size: 10px; color: var(--conf-low); margin-left: 6px; font-style: italic; }
/* one citation chip per sub-entry row / table row / table */
.rv-rowcite { width: 20px; text-align: center; padding: 3px 4px !important; }
.ev-cite { display: inline-flex; align-items: center; gap: 3px; font-size: 10.5px; font-weight: 600; padding: 1px 6px;
  border-radius: 999px; background: var(--accent-wash); color: var(--accent); border: 1px solid var(--accent-3);
  cursor: pointer; white-space: nowrap; font-family: var(--font-mono); }
.ev-cite:hover { background: var(--highlight); }
.ev-cite.ev-none { background: var(--bg); color: var(--text-muted); border-color: var(--border); cursor: default; }
.uncited-list { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
/* confidence: a badge per group next to its fields, a dot for rollups, low = look here first */
.group-head { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; margin: 10px 0 4px; }
.conf-badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px;
  font: inherit; font-size: 11.5px; font-weight: 600; border: 1px solid var(--border); background: var(--bg);
  color: var(--text-muted); cursor: default; }
button.conf-badge { cursor: pointer; }
.conf-high { background: var(--conf-high-bg); border-color: var(--conf-high-bd); color: var(--conf-high); }
.conf-medium { background: var(--conf-med-bg); border-color: var(--conf-med-bd); color: var(--conf-med); }
.conf-low { background: var(--conf-low-bg); border-color: var(--conf-low-bd); color: var(--conf-low); }
.conf-caret { opacity: .7; font-size: 10px; }
.conf-notes { flex-basis: 100%; font-size: 12.5px; color: var(--text); background: var(--surface);
  border-left: 3px solid var(--border); padding: 4px 10px; margin: 2px 0 6px; }
.conf-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-left: 5px; vertical-align: middle;
  border: 1px solid transparent; }
.conf-dot.conf-high { background: var(--conf-high-bd); }
.conf-dot.conf-medium { background: var(--conf-med-bd); }
.conf-dot.conf-low { background: var(--conf-low-bd); }
.conf-dot.conf-unknown { background: var(--border); }
.rv-row.rv-low { border-left: 3px solid var(--conf-low-bd); padding-left: 8px; margin-left: -11px; }
.rv-row.rv-low > .rv-key { color: var(--conf-low); }
.rv-row.rv-medium { border-left: 3px solid var(--conf-med-bd); padding-left: 8px; margin-left: -11px; }
td.rv-low { box-shadow: inset 3px 0 0 var(--conf-low-bd); }
.subtab .conf-dot { margin-left: 4px; }
.rc-conf { margin-left: auto; }
.rc-evsum { font-size: 12px; color: var(--conf-med); margin: -2px 0 8px; }
/* faint context: this entry's sources on the page; the clicked one stays strong */
rect.hl.ctx { fill: var(--highlight); stroke: none; }
/* entry nav: status + confidence at a glance, needs-attention count */
.rnav-tab .st-dot, .docsub-item .st-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-left: 6px; background: var(--border); vertical-align: middle; flex: none; }
.rnav-tab .st-dot.verified, .docsub-item .st-dot.verified { background: var(--success); }
.rnav-tab .st-dot.flagged, .docsub-item .st-dot.flagged { background: var(--error); }
.rnav-tab .needs { font-size: 10px; font-weight: 700; color: var(--conf-low); margin-left: 4px; }
/* progress + triage in the panel head */
.progress { font-weight: 600; color: var(--text-muted); }
.progress.done { color: var(--success); }
.triage { font: inherit; font-size: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); padding: 3px 6px; }
.kbd-help { position: fixed; right: 16px; bottom: 16px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-md); padding: 10px 14px; font-size: 12px; z-index: 50; }
.kbd-help kbd { font-family: var(--font-mono); background: var(--bg); border: 1px solid var(--border);
  border-radius: 3px; padding: 0 5px; }
.paper-fields { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--border); }
.issue-note { font-size: 12px; color: var(--conf-med); margin: 4px 0 8px; }

/* ── the chain review layout (display.review.layout = "chain") ───────────────── */
.cs-plus { color: var(--conf-high); stroke: var(--conf-high); fill: var(--conf-high); border-color: var(--conf-high); }
.cs-minus { color: var(--conf-low); stroke: var(--conf-low); fill: var(--conf-low); border-color: var(--conf-low); }
.cs-zero { color: var(--text-muted); stroke: var(--text-muted); fill: var(--text-muted); border-color: var(--text-muted); }
.cs-mixed { color: var(--conf-med); stroke: var(--conf-med); fill: var(--conf-med); border-color: var(--conf-med); }
.chain-head { display: flex; align-items: center; gap: 8px; margin: 4px 0 10px; }
.chain-head .chain-title { font: 600 15px/1.3 var(--font-serif); margin: 0; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chain-head .chain-prog { font-size: 12px; white-space: nowrap; }
.chain-nav { border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius-sm); width: 28px; height: 28px; font-size: 15px; cursor: pointer; color: var(--text); }
.chain-nav:hover { border-color: var(--accent-3); } .chain-nav:disabled { opacity: .4; cursor: default; }
.chain-dag { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 10px 12px 8px; margin-bottom: 12px; }
.chain-dagscroll { overflow: auto; }
.chain-svg text { font: 11.5px system-ui, sans-serif; fill: var(--text); }
.chain-svg .chain-n rect { fill: var(--bg); stroke: var(--border); stroke-width: 1.2; } .chain-svg .chain-n.unplaced rect { stroke-dasharray: 4 3; }
.chain-svg .chain-line { fill: none; stroke-width: 1.8; opacity: .85; } .chain-svg .chain-hit { fill: none; stroke: transparent; stroke-width: 14; }
.chain-svg .chain-dot { fill: var(--surface); stroke-width: 1.6; } .chain-svg .chain-sign { font: 700 11px ui-monospace, Menlo, monospace; stroke: none; }
.chain-svg .chain-e { cursor: pointer; } .chain-svg .chain-e:hover .chain-line, .chain-svg .chain-e.on .chain-line { stroke-width: 3.2; opacity: 1; }
.chain-svg .chain-e.dim { opacity: .18; }
.chain-legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 11.5px; color: var(--text-muted); margin-top: 6px; }
.chain-legend i { display: inline-block; width: 16px; height: 0; border-top: 2px solid; vertical-align: middle; margin-right: 5px; }
.chain-card { transition: opacity .15s; } .chain-card.dim { opacity: .3; } .chain-card.cur { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.chain-card.dim:hover { opacity: .8; }
.chain-id { font-size: 12px; color: var(--text-muted); }
.chain-edge { display: flex; align-items: center; flex-wrap: wrap; cursor: pointer; margin: 2px 0 0; }
.chain-node { border: 1.2px solid var(--border); background: var(--bg); border-radius: 7px; padding: 4px 10px; font-weight: 600; font-size: 13.5px; max-width: 44%; }
.chain-node small { display: block; font: 400 10px ui-monospace, Menlo, monospace; color: var(--text-muted); margin-top: 1px; }
.chain-arrow { flex: 0 0 auto; display: flex; align-items: center; margin: 0 2px; }
.chain-arrow .ln { width: 26px; height: 0; border-top: 2px solid; }
.chain-arrow .sg { width: 20px; height: 20px; border-radius: 50%; border: 2px solid; display: flex; align-items: center; justify-content: center; font: 700 12px/1 ui-monospace, Menlo, monospace; background: var(--surface); }
.chain-arrow .hd { width: 0; height: 0; border-top: 5px solid transparent; border-bottom: 5px solid transparent; border-left: 8px solid; }
.chain-stmt { font-weight: 600; font-size: 13.5px; margin: 2px 0 0; }
.chain-scope { font-size: 12px; margin: 6px 0 0; }
.chain-dl { display: grid; grid-template-columns: 92px 1fr; gap: 8px 12px; margin: 12px 0 0; }
.chain-dl dt { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); font-weight: 700; padding-top: 4px; }
.chain-dl dd { margin: 0; min-width: 0; }
.chain-q { font: italic 13.5px/1.5 var(--font-serif); } .chain-q .ev-cite { font-style: normal; margin-left: 4px; vertical-align: middle; }
.chain-pg { font-size: 11px; margin-left: 6px; }
.chain-none { font-size: 12.5px; }
.chain-res { margin-bottom: 8px; } .chain-line { font-size: 13px; line-height: 1.7; } .chain-line b { font-weight: 600; }
.chain-num { font: 12.5px ui-monospace, SFMono-Regular, Menlo, monospace; font-variant-numeric: tabular-nums; background: var(--bg); padding: 1px 6px; border-radius: 4px; white-space: nowrap; }
.chain-chk { font-size: 11px; margin-left: 6px; white-space: nowrap; } .chain-chk.agrees { color: var(--conf-high); } .chain-chk.mismatch { color: var(--conf-low); font-weight: 700; } .chain-chk.unchecked { color: var(--text-muted); }
.chain-rowlab { font-size: 12px; margin: 0 0 4px; }
.chain-op { font-size: 12.5px; margin-top: 2px; display: grid; grid-template-columns: 44px 1fr; gap: 2px 8px; }
.chain-op .k { color: var(--text-muted); font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; padding-top: 3px; }
.chain-why summary { font-size: 11.5px; cursor: pointer; } .chain-why div { font-size: 12px; margin-top: 2px; }
.chain-lineq { font-size: 12.5px; }
.tag { display: inline-block; font-size: 10.5px; border: 1px solid var(--border); border-radius: 9px; padding: 0 7px; color: var(--text-muted); margin: 1px 4px 0 0; white-space: nowrap; }
.tag.warn { border-color: var(--conf-med); color: var(--conf-med); }
.chain-foot { display: flex; gap: 6px; align-items: center; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); }
.chain-foot .vbtn { padding: 4px 12px; font-size: 12px; } .chain-sup { margin-left: auto; cursor: help; } .chain-note { font-size: 11.5px; cursor: help; }
.chain-card .status { margin-left: 2px; }
.chain-review { display: inline-flex; gap: 6px; align-items: center; flex: 1; min-width: 0; }
.chain-review[hidden] { display: none; }        /* an explicit display beats the UA's [hidden] rule */
.chain-review select, .chain-review input { font: inherit; font-size: 12px; padding: 3px 6px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface); color: var(--text); }
.chain-review input { flex: 1; min-width: 90px; }
.chain-foot .vbtn.on[data-status="verified"] { background: var(--success-bg); border-color: var(--success); color: var(--success); font-weight: 600; }
.chain-foot .vbtn.on[data-status="flagged"] { background: var(--error-bg); border-color: var(--error); color: var(--error); font-weight: 600; }
.hist-note { font-size: 12px; color: var(--text); margin: 2px 0 0 2px; }
.chain-construct { font-style: italic; } .tag.chain-stratum { border-color: var(--accent-3); color: var(--accent); }
.chain-modelnote { font-size: 12.5px; color: var(--text-muted); }
