/* The Compare view: 2 to 4 reports side by side, as sheets on the desk.
 *
 * Built by js/compare/*. Every state class lives on the view's root,
 * `#compareView`, never on body: `is-focus-layout`, `has-<feature>` (a
 * feature's controls show only once it is switched on) and, from the
 * analysis features, their own. Shared controls (.btn, .seg, .toggle,
 * .picker, .tag, .rb and the role variables) are in css/style.css.
 *
 * The toolbar never wraps: controls fold into Options in tiers, `.tb-x`
 * below 1440 px, `.tb-w` below 1100 px, `.tb-m` below 700 px, and Options
 * lists the folded ones through `data-tier`. The against picker never
 * shrinks, and a measured fold backs the fixed tiers up: where the row would
 * still overflow, `#compareView.is-tight` folds `.tb-w` and `.tb-x` as well
 * (js/compare/toolbar.js `fitToolbar`). Wherever `.tb-x` is folded, Add
 * column also has a tile after the last column (`.cmp-addcol`). Below
 * 700 px one column shows at a time, whatever the layout says. */

/* ── The view ─────────────────────────────────────────────────────────── */
/* The view is the window under the 56 px app header (design spec 11): the
 * toolbar, then the columns down to the window's bottom edge. The footer kit
 * sits below the fold and the page scrolls to reach it. An earlier version
 * kept the footer in sight under the columns, which cost every column 70 to
 * 98 px of text (450 px of column at 1024x768).
 *
 * Only a wheel over the toolbar or a column head can scroll the page now:
 * every scroller inside the view (a column's text, its frame, a form, a
 * popover) contains its own scroll, so reading a column to its end never
 * carries on into the page. While the visitor hides the header (H) the view
 * is the whole window. */
#compareView { display: none; }
html[data-dossier-view="compare"] #compareView {
  --cmp-top: var(--header-h-app, 56px);
  display: flex;
  flex-direction: column;
  height: calc(100dvh - var(--cmp-top));
  min-height: 0;
}
html[data-chrome="off"] #compareView { --cmp-top: 0px; }
/* A wheel over the toolbar takes the page to the footer and the toolbar
 * under the sticky header. Focus that moves into it from the keyboard then
 * brings it back below the header, not under it (WCAG 2.4.11). */
html[data-dossier-view="compare"] { scroll-padding-top: var(--header-h-app, 56px); }
html[data-dossier-view="compare"][data-chrome="off"] { scroll-padding-top: 0; }
html[data-dossier-booting] #compareView { visibility: hidden; }
#compareView:not(.has-diff) [data-feature="diff"],
#compareView:not(.has-panels) [data-feature="panels"],
#compareView:not(.has-blind) [data-feature="blind"] { display: none !important; }

/* ── Toolbar ──────────────────────────────────────────────────────────── */
.cmp-toolbar {
  flex: none;
  position: relative;
  z-index: var(--z-toolbar);
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: var(--toolbar-h);
  padding: 9px 12px;
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
}
.tb-title { display: inline-flex; align-items: center; gap: 2px; min-width: 0; flex: 0 1 auto; }
.set-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: 240px;
  height: 36px;
  padding: 0 6px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-primary);
  /* The product's serif, fixed: the title is chrome, not reading text, so it
   * does not follow Display's Typeface. */
  font-family: var(--font-serif);
  font-size: var(--text-base);
  font-weight: 600;
  text-align: left;
}
.set-title__text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* The pencil keeps its room when hidden: the switcher button beside the
 * title must not move as focus or the pointer comes and goes. */
.set-title .ic { flex: none; width: 14px; height: 14px; color: var(--text-secondary); visibility: hidden; }
.set-title:hover, .set-title:focus-visible { border-color: var(--border-strong); }
.set-title:hover .ic, .set-title:focus-visible .ic { visibility: visible; }
.cmp-inline-input {
  width: min(240px, 60vw);
  height: 36px;
  font-family: var(--font-serif);
  font-size: var(--text-base);
  font-weight: 600;
}
.tb-sep { flex: none; width: 1px; height: 24px; margin: 0 3px; background: var(--border); }
.cmp-toolbar .btn, .cmp-toolbar .picker { padding-inline: 9px; }
.cmp-toolbar .btn--icon { padding: 0; }
.cmp-toolbar .seg > button { padding-inline: 9px; }
.cmp-toolbar .picker select {
  height: 34px;
  margin: 0 -24px 0 0;
  padding: 0 24px 0 0;
  border: 0;
  background: transparent;
  color: var(--text-primary);
  font-weight: 500;
  appearance: none;
  cursor: pointer;
}
.cmp-toolbar .picker select:focus-visible { outline: none; }
.cmp-toolbar .picker:has(select:focus-visible) { outline: var(--focus-width) solid var(--focus); outline-offset: var(--focus-offset); }
.cmp-toolbar .picker .caret { pointer-events: none; }
.tb-spacer { flex: 1; }
.tb-row2 { display: contents; }
.tb-nav { display: inline-flex; align-items: center; gap: 4px; }
.counter {
  min-width: 50px;
  text-align: center;
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1.1;
  font-variant-numeric: var(--numerals-data);
  white-space: nowrap;
}
.counter small { display: block; font-size: var(--text-xs); font-weight: 400; color: var(--text-secondary); }
/* Never squeezed below its 36 px: the title and the set's name give way. It
 * shrank to 23 px at 1100 px, under the 24 px target size (WCAG 2.5.8). */
.tb-options { display: none; flex: none; }
.focus-switch { display: none; }
.tb-all { display: none; }
#compareView.is-focus-layout .focus-switch { display: inline-flex; min-width: 0; }
#compareView.is-focus-layout .tb-all { display: inline-flex; }
.focus-switch > button { display: inline-flex; align-items: center; gap: 6px; }
.focus-switch .rb { width: 20px; height: 20px; }
.focus-switch > button[aria-selected="true"] .rb { border-color: var(--on-action); }

/* ── The brief: what every report was asked to write (js/compare/brief.js) ─
 * One line above the columns, hidden while there is no brief, so a
 * comparison without one loses no column height. Show all wraps it. */
.cmp-brief {
  flex: none;
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-height: 34px;
  padding: 3px 12px;
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
}
.cmp-brief[hidden] { display: none; }
.cmp-brief__lbl { flex: none; font-size: var(--text-xs); font-weight: 600; color: var(--text-secondary); }
.cmp-brief__text {
  flex: 1;
  min-width: 0;
  font-family: var(--font-reading);
  font-size: var(--text-sm);
  line-height: 1.5;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cmp-brief.is-open { align-items: flex-start; padding-block: 8px; }
.cmp-brief.is-open .cmp-brief__text { white-space: pre-wrap; max-width: var(--measure); max-height: min(30vh, 12em); overflow: auto; overscroll-behavior: contain; }
.cmp-brief .btn { flex: none; height: 28px; }
.cmp-brief .btn[hidden] { display: none; }
.cmp-brief__form { flex: 1; display: grid; gap: 6px; max-width: 52rem; padding-block: 6px; }
.cmp-brief__form label { font-size: var(--text-xs); font-weight: 600; color: var(--text-secondary); }
.cmp-brief__hint { font-weight: 400; color: var(--text-secondary); }
.cmp-brief__form textarea { width: 100%; max-height: 30vh; resize: vertical; font-family: var(--font-reading); }
.cmp-brief__actions { display: flex; gap: 8px; }
.brief-add { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; margin-top: 10px; font-size: var(--text-xs); color: var(--text-secondary); }
.brief-add[hidden] { display: none; }

/* ── Popovers: Options, menus, the switcher ───────────────────────────── */
.cmp-pop {
  position: fixed;
  z-index: var(--z-panel);
  max-height: calc(100dvh - 80px);
  overflow: auto;
  overscroll-behavior: contain;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-1);
  color: var(--text-primary);
  box-shadow: var(--shadow-pop);
}
.cmp-pop[hidden] { display: none; }
.cmp-pop h2 { margin-bottom: 10px; font-size: var(--text-sm); font-weight: 600; }
.cmp-options { width: 300px; }
.cmp-options .opt { display: none; gap: 6px; padding: 10px 0; border-top: 1px solid var(--border); }
.cmp-options .opt > span { font-size: var(--text-xs); color: var(--text-secondary); }
.cmp-options .seg { width: 100%; }
.cmp-options .seg > button { flex: 1; }
.cmp-options .btn { justify-content: flex-start; }
/* The title in Options is the set's own, up to 120 characters: it ends in an
 * ellipsis inside the panel instead of running past a 390 px sheet. */
.cmp-options .opt__title { min-width: 0; max-width: 100%; }
.cmp-options .opt__title .ic { flex: none; }
.cmp-options .opt__title .set-title__text { min-width: 0; }
.cmp-options h2 + .opt, .cmp-options .opt:first-of-type { border-top: 0; padding-top: 0; }

.cmp-menu { display: grid; min-width: 220px; padding: 6px; }
/* "Show as" and its three choices are one group (role="group"). */
.cmp-menu__group { display: grid; }
.cmp-menu [role^="menuitem"] {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-primary);
  font-size: var(--text-sm);
  text-align: left;
}
.cmp-menu [role^="menuitem"]:hover, .cmp-menu [role^="menuitem"]:focus-visible { background: var(--surface-2); }
.cmp-menu [role^="menuitem"]:focus-visible { outline-offset: -2px; }
.cmp-menu [role="menuitemradio"]::before {
  content: "";
  flex: none;
  width: 14px;
  height: 14px;
  border: 1.5px solid var(--border-strong);
  border-radius: 50%;
}
.cmp-menu [role="menuitemradio"][aria-checked="true"]::before {
  border-color: var(--action);
  background: radial-gradient(circle, var(--action) 0 3.5px, transparent 4px);
}
.cmp-menu > [data-danger] { color: var(--danger); }
.cmp-menu__sep { height: 1px; margin: 5px 4px; background: var(--border); }
.cmp-menu__label { padding: 4px 10px 2px; font-size: var(--text-xs); color: var(--text-secondary); }
/* "Use a saved report": the library's reports, title over kind and pages. */
.cmp-menu--saved { max-height: min(60vh, 420px); overflow-y: auto; width: min(340px, calc(100vw - 16px)); }
.cmp-menu--saved [role="menuitem"] { display: grid; gap: 2px; padding-block: 6px; text-align: start; }
.cmp-menu__title { overflow-wrap: anywhere; }
.cmp-menu__meta { font-size: var(--text-xs); color: var(--text-secondary); }
.cmp-menu__note { padding: 6px 8px; font-size: var(--text-xs); color: var(--text-secondary); }

.cmp-switcher { width: 380px; display: grid; gap: 10px; }
.cmp-switcher .sw__heading { margin: 0; }
.sw__filter { width: 100%; }
.sw__list { display: grid; gap: 2px; max-height: 360px; overflow: auto; overscroll-behavior: contain; margin: 0; padding: 0; list-style: none; }
.sw__row { display: flex; align-items: center; gap: 2px; border-radius: var(--radius-sm); }
.sw__row[hidden] { display: none; }
.sw__row.is-current { background: var(--manila); box-shadow: inset 3px 0 0 var(--accent); }
.sw__open {
  display: grid;
  flex: 1;
  min-width: 0;
  gap: 2px;
  padding: 8px 10px 8px 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-primary);
  text-align: left;
}
button.sw__open:hover { background: var(--surface-2); }
.sw__row.is-current button.sw__open:hover { background: var(--manila-strong); }
.sw__title { overflow: hidden; font-size: var(--text-sm); font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.sw__meta { font-size: var(--text-xs); color: var(--text-secondary); }
.sw__row .cmp-inline-input { flex: 1; width: auto; font-family: var(--font-ui); font-size: var(--text-sm); }
.sw__delete:hover { color: var(--danger); }
.sw__empty { font-size: var(--text-xs); color: var(--text-secondary); }
.sw__actions { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 10px; border-top: 1px solid var(--border); }

/* --header-h-app, not --header-h: the kit's root --header-h is the 68 px
 * content-mode bar, and this page's bar is the 56 px app one (as in
 * css/shell.css). With the wrong one a phone sheet and its scrim started
 * 12 px below the bar and the toolbar showed through the gap. While the
 * visitor hides the header (H), the sheet and scrim start at the top. */
.cmp-scrim { position: fixed; inset: var(--header-h-app, 56px) 0 0; z-index: calc(var(--z-sheet) - 1); background: var(--scrim); }
html[data-chrome="off"] .cmp-scrim { top: 0; }
.cmp-scrim[hidden] { display: none; }

/* ── Columns ──────────────────────────────────────────────────────────── */
.cmp-body { position: relative; flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr); }
.cmp-panel[hidden] { display: none; }
.cmp-columns {
  --cols: 2;
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(var(--col-min), 1fr));
  grid-template-rows: auto minmax(0, 1fr);
  gap: 0 var(--col-gap);
  min-height: 0;
  padding: 10px;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
}
#compareView.is-focus-layout .cmp-columns { grid-template-columns: minmax(0, 1fr); }
#compareView.is-focus-layout .col:not(.is-focus) { display: none; }

/* A column is a sheet. Its role is a coloured top edge, a lettered badge and
 * a word; never a tint behind its text. The whole sheet sits on the desk,
 * bottom edge included, above the footer (see "The view"); `clip` keeps its
 * scrolling text and frame inside the rounded corners. */
.col {
  display: grid;
  grid-row: span 2;
  grid-template-rows: subgrid;
  grid-template-columns: minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  overflow: clip;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sheet);
  box-shadow: var(--shadow-sheet);
}
.col.is-over { outline: 2px solid var(--accent); outline-offset: -2px; }
.col__head {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 10px 12px 0 14px;
  border-top: 4px solid var(--role, var(--border-strong));
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius-sheet) var(--radius-sheet) 0 0;
}
.col__row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.col__label { min-width: 0; overflow: hidden; font-size: var(--text-sm); font-weight: 600; line-height: 1.3; text-overflow: ellipsis; white-space: nowrap; }
.col__row .tag { flex: none; }
.col__kind { margin-left: auto; font-size: var(--text-xs); color: var(--text-secondary); white-space: nowrap; }
.col__menu, .col__close { flex: none; }
.col__close { margin-left: auto; }
.col__who {
  margin-top: 3px;
  overflow: hidden;
  font-size: var(--text-xs);
  color: var(--text-secondary);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.col__who .role-name { font-weight: 600; color: var(--role-ink, var(--text-primary)); }
.col__stats { margin: 4px 0 10px; font-size: var(--text-xs); color: var(--text-secondary); font-variant-numeric: var(--numerals-data); }
.col__stats-items { display: flex; flex-wrap: wrap; gap: 0 10px; }
.col__stats-items > span { white-space: nowrap; }
.col__stats b { font-weight: 600; color: var(--text-primary); }
.col__delta { color: var(--text-secondary); }
.col__diff {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  margin-top: auto;
  padding: 5px 0 6px;
  border-top: 1px dashed var(--border);
  font-size: var(--text-xs);
  color: var(--text-secondary);
}
.col__diff > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.col__diff b { font-weight: 600; color: var(--text-primary); font-variant-numeric: var(--numerals-data); }

.col__body { position: relative; min-width: 0; min-height: 0; }
.col__scroll {
  position: absolute;
  inset: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 16px 16px 96px var(--col-gutter);
  scrollbar-width: thin;
}
.col__scroll:focus-visible { outline-offset: -2px; }
.col__body--frame { display: flex; flex-direction: column; }
.col__notes { flex: none; padding: 10px 12px 0; }
.col__notes .col-note { margin-bottom: 10px; }
.col__frame {
  flex: 1;
  width: 100%;
  min-height: 0;
  border: 0;
  /* The report's own page, as its author made it: paper white in both
   * themes, so a page with no background of its own stays readable. */
  background: #fff;
  color-scheme: light;
}

/* Column notice: a plain sentence at the top of the column, not a tooltip. */
.col-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0 0 16px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  line-height: 1.45;
  color: var(--text-secondary);
}
.col-note .ic { flex: none; width: 15px; height: 15px; margin-top: 1px; }
.col-note b { font-weight: 600; color: var(--text-primary); }

/* ── Reader: one typography for every column in Dossier format ────────── */
.reader {
  font-family: var(--font-reading);
  font-size: var(--compare-reading-size);
  line-height: var(--compare-leading);
  font-variant-numeric: var(--numerals);
  color: var(--text-primary);
  overflow-wrap: break-word;
}
/* One or two columns, or Focus, are where long reading happens: the text
 * keeps to the measure and the column's spare width goes to its margins. */
.reader__doc { max-width: var(--measure); margin-inline: auto; }
.reader--dossier .reader__doc { max-width: var(--sheet-width); }
.col__scroll > .col-note { max-width: var(--measure); margin-inline: auto; }
.reader__doc > :first-child { margin-top: 0; }
.reader .r-h { font-weight: 600; line-height: 1.3; scroll-margin-top: 16px; text-wrap: balance; }
.reader .r-h1 { margin-top: 1.2em; font-size: var(--text-xl); line-height: 1.22; letter-spacing: -.005em; }
.reader .r-h2 { margin-top: 1.5em; font-size: var(--text-lg); }
.reader .r-h3 { margin-top: 1.3em; font-size: calc(var(--compare-reading-size) * 1.08); }
.reader .r-h4, .reader .r-h5, .reader .r-h6 { margin-top: 1.2em; font-size: var(--compare-reading-size); }
.reader .r-h5, .reader .r-h6 { color: var(--text-secondary); }
.reader__doc > .r-h:first-child { margin-top: 0; }
.reader p, .reader ul, .reader ol, .reader .r-table, .reader pre, .reader blockquote,
.reader figure, .reader details, .reader hr { margin-top: .7em; }
.reader ul, .reader ol { padding-left: 1.3em; }
.reader ul { list-style: disc; }
.reader ol { list-style: decimal; }
.reader li + li, .reader li > ul, .reader li > ol { margin-top: .35em; }
.reader li::marker { color: var(--text-secondary); }
.reader a { color: inherit; text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
.reader a:hover { text-decoration-thickness: 2.5px; }
.reader code {
  padding: 1px 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-family: var(--font-mono);
  font-size: .86em;
}
.reader pre {
  overflow-x: auto;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: var(--text-xs);
  line-height: 1.5;
}
.reader pre code { padding: 0; border: 0; background: none; font-size: inherit; }
.reader blockquote { padding-left: 14px; border-left: 3px solid var(--border-strong); color: var(--text-secondary); }
.reader hr { border: 0; border-top: 1px solid var(--border); }
.reader details > summary { cursor: pointer; font-weight: 600; }
.reader mark { background: var(--manila); color: inherit; }
.reader .r-table { max-width: 100%; overflow-x: auto; }
.reader .r-table:focus-visible { outline-offset: -2px; }
.reader table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  line-height: 1.4;
  font-variant-numeric: var(--numerals-data);
}
.reader caption { padding-bottom: 6px; text-align: left; font-weight: 600; }
.reader th {
  padding: 6px 8px 6px 0;
  border-bottom: 2px solid var(--text-primary);
  font-size: var(--text-xs);
  font-weight: 600;
  text-align: left;
  color: var(--text-secondary);
}
.reader td { padding: 7px 8px 7px 0; border-bottom: 1px solid var(--border); vertical-align: baseline; }
.reader figure { margin-inline: 0; }
.reader .r-fig img { display: block; max-width: 100%; height: auto; border-radius: var(--radius-sm); }
.reader figcaption { margin-top: 6px; font-family: var(--font-ui); font-size: var(--text-xs); color: var(--text-secondary); }
.reader .r-fig--missing {
  padding: 10px 12px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  color: var(--text-secondary);
}
.reader .r-fig--missing p { margin: 0; }

/* A Dossier document, drawn by the report renderer, inside a column: the
 * column is already the sheet, so the report loses its own. */
.reader--dossier { padding-left: 16px; }
.reader--dossier .report-shell { max-width: none; margin: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
.reader--dossier .report-header { padding: 0 0 20px; }
.reader--dossier .report-title-row { grid-template-columns: minmax(0, 1fr); gap: 16px; }
.reader--dossier .report-title { font-size: var(--text-xl); }
.reader--dossier .report-page { padding: 24px 0 0; }
.reader--dossier .report-page + .report-page { margin-top: 24px; border-top: 1px solid var(--border); }

/* ── Empty column: the drop zone ──────────────────────────────────────── */
.col--empty { border-style: dashed; border-color: var(--border-strong); background: transparent; box-shadow: none; }
.col--empty .col__head { border-top: 4px dashed var(--border-strong); background: var(--surface-1); }
.col--empty .rb { --role: var(--role-neutral); --role-soft: var(--role-neutral-soft); --role-ink: var(--role-neutral-ink); }
.drop {
  position: absolute;
  inset: 12px;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 10px;
  padding: 24px;
  overflow: auto;
  overscroll-behavior: contain;
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-1);
  text-align: center;
}
.drop .big { width: 32px; height: 32px; color: var(--text-secondary); }
.drop h3 { font-family: var(--font-ui); font-size: var(--text-base); font-weight: 600; }
.drop p { max-width: 32ch; font-size: var(--text-xs); line-height: 1.5; color: var(--text-secondary); }
.drop .actions { display: grid; gap: 6px; width: min(240px, 100%); margin-top: 4px; }
.drop.is-over { border-color: var(--accent); background: var(--manila); }

/* ── Forms in a column: paste, edit source, details ───────────────────── */
.col__body--form { overflow: auto; overscroll-behavior: contain; }
.col-form { display: flex; flex-direction: column; gap: 8px; min-height: 100%; padding: 14px; }
.col-form__label { font-size: var(--text-xs); font-weight: 600; color: var(--text-secondary); }
.col-form__text {
  flex: 1;
  min-height: 240px;
  width: 100%;
  resize: none;
  overscroll-behavior: contain;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: 1.5;
  /* Long lines wrap, so a number mid-paragraph is reached without scrolling
   * sideways. Wrap lines off (code) lets them run on. */
  white-space: pre-wrap;
  overflow-wrap: break-word;
}
.col-form__text.is-nowrap { white-space: pre; overflow-wrap: normal; overflow-x: auto; }
.col-form__wrap { margin-left: auto; }
.col-form__error { padding: 8px 10px; border-left: 3px solid var(--danger); background: var(--danger-soft); color: var(--danger); font-size: var(--text-xs); }
.col-form__error[hidden] { display: none; }
.col-form__actions { display: flex; flex-wrap: wrap; gap: 8px; }
.col-form--details { min-height: 0; }
.col-form__field { display: grid; gap: 4px; font-size: var(--text-xs); font-weight: 600; color: var(--text-secondary); }
.col-form__field[hidden] { display: none; }
.col-form__field input, .col-form__field select { font-weight: 400; color: var(--text-primary); }
.col-form__hint { font-weight: 400; }
/* Save and Cancel sit at a form's bottom edge, and the last column's bottom
 * edge is the toasts' corner: a status toast covered Save while saying
 * "Edit it, then Save". The rightmost form keeps that lane free. */
.col:last-of-type .col-form:not(.col-form--details),
#compareView.is-focus-layout .col.is-focus .col-form:not(.col-form--details) { padding-bottom: 88px; }

/* ── The Add column tile ──────────────────────────────────────────────── */
/* After the last column, wherever the toolbar has folded Add column into
 * Options (the width tiers below), while the set has room. A short tile at
 * the top of its own 44 px track, so the role menu it opens sits beside it
 * and on screen. Spanning both rows, it never makes the head row taller. */
.cmp-columns { --addcol-w: 44px; }
.cmp-addcol { display: none; grid-row: span 2; align-self: start; min-width: 0; }
.cmp-addcol__btn {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 12px 0 14px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sheet);
  background: transparent;
  color: var(--text-primary);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
}
.cmp-addcol__btn:hover { border-color: var(--accent); background: var(--surface-1); }
.cmp-addcol__btn .ic { flex: none; }
.cmp-addcol__word { writing-mode: vertical-rl; }

/* ── The undo toast ───────────────────────────────────────────────────── */
.cmp-toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: var(--z-toast);
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: min(440px, calc(100vw - 32px));
  padding: 8px 8px 8px 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface-1);
  color: var(--text-primary);
  box-shadow: var(--shadow-pop);
  font-size: var(--text-sm);
  opacity: 0;
  transform: translateY(8px);
  visibility: hidden;
  transition: opacity var(--dur) var(--ease-out), transform var(--dur) var(--ease-out), visibility 0s linear var(--dur);
}
.cmp-toast.is-visible { opacity: 1; transform: none; visibility: visible; transition-delay: 0s; }
.cmp-toast:empty { padding: 0; border: 0; }

/* ── Width tiers ──────────────────────────────────────────────────────── */
@media (max-width: 1439px) {
  .cmp-toolbar .tb-x { display: none; }
  .tb-options { display: inline-flex; }
  .cmp-options .opt[data-tier="x"] { display: grid; }
}
@media (max-width: 1099px) {
  .cmp-toolbar .tb-w { display: none; }
  .cmp-options .opt[data-tier="w"] { display: grid; }
  .set-title { max-width: 200px; }
}
/* The measured fold (js/compare/toolbar.js `fitToolbar`): the row would
 * overflow, or cut the title to nothing, at this width with these fonts and
 * this text spacing, so `.tb-w` and `.tb-x` fold whatever the width tier. */
@media (min-width: 700px) {
  #compareView.is-tight .cmp-toolbar .tb-w, #compareView.is-tight .cmp-toolbar .tb-x { display: none; }
  #compareView.is-tight .tb-options { display: inline-flex; }
  #compareView.is-tight .cmp-options .opt[data-tier="w"], #compareView.is-tight .cmp-options .opt[data-tier="x"] { display: grid; }
}
/* The Add column tile shows where Add column is folded (700 to 1439 px),
 * and only where its track costs no sideways scroll at the 340 px column
 * minimum, a classic scrollbar included: two columns from 800 px, three
 * from 1140 px. Never in the focus layout, never with four columns. */
@media (min-width: 800px) and (max-width: 1439px) {
  #compareView.can-add-col:not(.is-focus-layout) .cmp-columns:is([data-cols="1"], [data-cols="2"]) { grid-template-columns: repeat(var(--cols), minmax(var(--col-min), 1fr)) var(--addcol-w); }
  #compareView.can-add-col:not(.is-focus-layout) .cmp-columns:is([data-cols="1"], [data-cols="2"]) > .cmp-addcol { display: flex; }
}
@media (min-width: 1140px) and (max-width: 1439px) {
  #compareView.can-add-col:not(.is-focus-layout) .cmp-columns[data-cols="3"] { grid-template-columns: repeat(var(--cols), minmax(var(--col-min), 1fr)) var(--addcol-w); }
  #compareView.can-add-col:not(.is-focus-layout) .cmp-columns[data-cols="3"] > .cmp-addcol { display: flex; }
}

/* Phone: one column at a time; Options, menus and the switcher as sheets
 * under the header. */
@media (max-width: 699px) {
  /* The toolbar stays under the header kit's own menu; the sheets it opens
   * are siblings of it, not children, so they still sit over the scrim. */
  .cmp-toolbar { flex-wrap: wrap; gap: 8px; padding: 8px 12px; }
  .cmp-toolbar .tb-m, .tb-all, #compareView.is-focus-layout .tb-all { display: none; }
  .cmp-options .opt[data-tier="m"] { display: grid; }
  .focus-switch { display: inline-flex; flex: 1; min-width: 0; }
  .focus-switch > button { flex: 1; justify-content: center; min-width: 0; height: 34px; padding: 0 6px; }
  .focus-switch__word { overflow: hidden; text-overflow: ellipsis; }
  /* The one column shown spans the window, and the toasts span its foot. */
  .col-form:not(.col-form--details) { padding-bottom: 88px; }
  .tb-options { order: 2; }
  .tb-row2 { order: 3; display: flex; align-items: center; gap: 8px; width: 100%; }
  .tb-row2 > .tb-against { flex: 1; min-width: 0; }
  .tb-row2 > .tb-nav { margin-left: auto; }
  .tb-spacer { display: none; }
  .cmp-columns { display: block; height: 100%; padding: 0; overflow: hidden; }
  .col { display: none; height: 100%; border-inline: 0; border-bottom: 0; border-radius: 0; box-shadow: none; }
  .col.is-focus { display: flex; flex-direction: column; }
  .col__head { padding-top: 8px; border-radius: 0; }
  .col__body { flex: 1; }
  .col__scroll { padding: 18px 14px 80px var(--col-gutter); }
  .cmp-pop.is-sheet {
    top: var(--header-h-app, 56px) !important;
    left: 0 !important;
    right: 0;
    width: auto;
    max-height: calc(100dvh - var(--header-h-app, 56px) - 56px);
    z-index: var(--z-sheet);
    border: 0;
    border-bottom: 1px solid var(--border);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    box-shadow: var(--shadow-modal);
  }
  html[data-chrome="off"] .cmp-pop.is-sheet { top: 0 !important; max-height: calc(100dvh - 56px); }
  .cmp-options.is-sheet, .cmp-switcher.is-sheet { padding: 16px; }
  .cmp-menu { min-width: min(260px, calc(100vw - 16px)); }
  .cmp-toast { left: 16px; right: 16px; bottom: 16px; max-width: none; }
}
/* Phone switcher: four tabs (three on the narrowest phones) cannot all carry
 * a role word. Only the chosen tab keeps its word, at its own width. The
 * others show their letter, and their word stays as the tab's accessible
 * name, hidden the way .visually-hidden hides it. The ellipsis above stays
 * as a backstop for a large browser font. Measured: a tab needs 38 px plus
 * its word, so four words fit from about 465 px and three blind "Report N"
 * words from about 366 px. */
@media (max-width: 479px) {
  .focus-switch:has(> [role="tab"]:nth-child(4)) > [role="tab"][aria-selected="true"] { flex: none; }
  .focus-switch:has(> [role="tab"]:nth-child(4)) > [role="tab"]:not([aria-selected="true"]) .focus-switch__word {
    position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
  }
}
@media (max-width: 379px) {
  .focus-switch:has(> [role="tab"]:nth-child(3)) > [role="tab"][aria-selected="true"] { flex: none; }
  .focus-switch:has(> [role="tab"]:nth-child(3)) > [role="tab"]:not([aria-selected="true"]) .focus-switch__word {
    position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
  }
}
@media (max-width: 699px) and (prefers-reduced-motion: no-preference) {
  .cmp-pop.is-sheet:not([hidden]) { animation: cmp-sheet-in var(--dur) var(--ease-out); }
}

/* Short windows (150 to 200% zoom, a landscape phone): every live column
 * head keeps its badge row and a one-row difference line, and the reading
 * text gets the height. The who line, the stats and the per-kind counts of
 * the difference line stay in the accessibility tree (and the counts in the
 * count's title), hidden the way .visually-hidden hides them, and the column
 * menu brings them back (`show-head-details`). All heads share one row, so
 * one column's wrapped counts made every head taller. Scoped to heads with a
 * menu or close button: an exported file's heads have none and keep every
 * line. The 560 px is mirrored in js/compare/popover.js as SHORT. */
@media (max-height: 560px) {
  #compareView .col__head:has(> .col__row > :is(.col__menu, .col__close)) { padding-top: 6px; }
  #compareView:not(.show-head-details) .col__head:has(> .col__row > :is(.col__menu, .col__close)) > :is(.col__who, .col__stats),
  #compareView:not(.show-head-details) .col__head:has(> .col__row > :is(.col__menu, .col__close)) > .col__diff > .key {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
  }
  #compareView .col__head:has(> .col__row > :is(.col__menu, .col__close)) > .col__diff { min-height: 30px; padding-block: 3px 4px; }
}
@keyframes cmp-sheet-in { from { transform: translateY(-8px); opacity: 0; } to { transform: none; opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .cmp-toast { transition: none; }
}

/* ── Print: columns one after another, each with its head ─────────────── */
@media print {
  html[data-dossier-view="compare"] #compareView { display: block; height: auto; }
  .cmp-toolbar, .cmp-pop, .cmp-scrim, .cmp-toast, .cmp-panel, .cmp-addcol, .ruler, .col-note, .drop { display: none !important; }
  .cmp-brief { border: 0; padding: 0 0 12px; }
  .cmp-brief__text { white-space: pre-wrap; max-height: none; overflow: visible; }
  .cmp-brief .btn { display: none; }
  .cmp-columns { display: block; padding: 0; overflow: visible; }
  .col, #compareView.is-focus-layout .col:not(.is-focus) { display: block; border: 0; box-shadow: none; break-before: page; }
  .col:first-child { break-before: auto; }
  .col__menu, .col__close { display: none; }
  .col__body { position: static; }
  .col__scroll { position: static; overflow: visible; padding: 12px 0 0; }
  .reader { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .col__frame { height: 90vh; }
}

@media (max-width: 699px) { .cmp-menu > [data-wide-only] { display: none; } }
.reader--dossier > .col-note { max-width: none; }

/* ══ Analysis: differences, the change ruler, the side panels, Blind ══════
 * Built by js/compare/analysis.js and its modules. Differences are their own
 * channel, never a role colour: a unit mark is a bar and a + - ~ glyph in
 * the gutter, a word mark is an underline or a strike, and colour is the
 * third cue (design spec 3.3, 7.3.6). */

/* ── The against picker and its menu ──────────────────────────────────── */
/* Never narrower than its picker: with `min-width: 0` it shrank while the
 * picker kept its width, so Previous and the counter painted over the base's
 * name and a click on the name stepped back instead of opening the menu
 * (1100 to 1260 px). The title gives way instead, and `is-tight` past that. */
.tb-against { display: inline-flex; flex: none; }
.picker.against { cursor: pointer; }
.picker.against .rb { width: 20px; height: 20px; }
.picker.against .picker__name { overflow: hidden; text-overflow: ellipsis; }
.picker.against:focus-visible { outline: var(--focus-width) solid var(--focus); outline-offset: var(--focus-offset); }
.cmp-diffmenu { width: 300px; display: grid; gap: 10px; }
.cmp-diffmenu h2 { margin: 0; }
.dm__bases { display: grid; gap: 2px; }
.dm__bases [role="radio"] {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-primary);
  font-size: var(--text-sm);
  text-align: left;
}
.dm__bases [role="radio"]:hover { background: var(--surface-2); }
.dm__bases [role="radio"]:focus-visible { outline-offset: -2px; }
.dm__bases [role="radio"][aria-checked="true"] { background: var(--manila); font-weight: 600; box-shadow: inset 3px 0 0 var(--accent); }
.dm__name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* "Each against its source" carries a hint under its name. */
.dm__bases [role="radio"]:has(.dm__hint) { flex-wrap: wrap; row-gap: 0; padding-block: 6px; }
.dm__hint { flex-basis: 100%; font-size: var(--text-xs); font-weight: 400; color: var(--text-secondary); }
.dm__opts { display: grid; gap: 2px; padding-top: 10px; border-top: 1px solid var(--border); }
.dm__opts .btn { justify-content: flex-start; }
.dm__empty { font-size: var(--text-xs); color: var(--text-secondary); }

/* ── The difference line in a column head ─────────────────────────────── */
/* The count, then what it is made of ("6 changed, 6 added, 3 removed"),
 * each part drawn the way its marks are, so the parts are also the key.
 * The line wraps between the count and the parts in a narrow column. */
.col__diff:has(.key) { flex-wrap: wrap; row-gap: 3px; }
.col__diff .col__count { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.col__diff .key { display: inline-flex; flex: none; flex-wrap: wrap; gap: 3px 6px; }
.col__diff .key > span:not(.visually-hidden) { padding: 0 4px; border-radius: 2px; color: var(--text-primary); font-family: var(--font-reading); font-size: var(--text-xs); white-space: nowrap; font-variant-numeric: var(--numerals-data); }
.col__diff .k-chg { background: var(--diff-change-unit); }
.col__diff .key--plain > span:not(.visually-hidden) { padding: 0; background: none; color: var(--text-secondary); font-family: inherit; text-decoration: none; }
.col__diff .k-ins, .cmp-numbers .k-ins { background: var(--diff-ins-word); text-decoration: underline 2px var(--diff-ins-line); text-underline-offset: 2px; }
.col__diff .k-del, .cmp-numbers .k-del { background: var(--diff-del-word); color: var(--text-secondary); text-decoration: line-through 2px var(--diff-del-line); }
.col__diff .k-mov { outline: 1px dotted var(--diff-change-bar); outline-offset: -1px; }
.col__diff .col__words { flex: none; margin-left: auto; }
/* "2 numbers changed": a button that lists them (js/compare/numbers.js); in a
 * saved file, words in secondary ink. */
.col__diff .col__nums { flex: none; }
.col__diff span.col__nums { color: var(--text-secondary); font-size: var(--text-xs); }
.cmp-numbers { width: min(420px, calc(100vw - 16px)); display: grid; gap: 8px; }
.cmp-numbers h2 { margin: 0; }
.nums__note { margin: 0; font-size: var(--text-xs); color: var(--text-secondary); }
.nums__list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; max-height: 50vh; margin: 0; padding: 0; overflow: auto; list-style: none; }
.nums__list li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 6px; }
.nums__list .k-ins, .nums__list .k-del { padding: 0 4px; border-radius: 2px; font-family: var(--font-reading); font-variant-numeric: var(--numerals-data); }
.nums__list li > button { margin-left: auto; }
.nums__where { flex-basis: 100%; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--text-xs); color: var(--text-secondary); }
/* A too-different column whose Word marks is off reads "32 differences from
 * B [Word marks]" on one row (design spec 7.3.4). Its changed, added and
 * removed parts stay in the line for a screen reader, and in the count's
 * title. With Word marks on the key is coloured and shows; a saved file has
 * no toggle, so its parts stay visible. */
.col__diff:has(> .col__words) > .key--plain { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ── Unit marks ────────────────────────────────────────────────────────── */
.reader .unit { position: relative; }
.reader .u-changed { background: var(--diff-change-unit); box-shadow: 0 0 0 7px var(--diff-change-unit); border-radius: 1px; }
.reader .u-added { background: var(--diff-ins-unit); box-shadow: 0 0 0 7px var(--diff-ins-unit); border-radius: 1px; }
/* Bars sit in the 30 px gutter; a glyph sits on paper at the top of each. */
.reader .u-changed::before, .reader .u-bar-chg::before {
  content: "";
  position: absolute;
  top: -6px;
  bottom: -6px;
  left: -21px;
  width: 3px;
  background: var(--diff-change-bar);
}
.reader .u-added::before, .reader .u-bar-add::before {
  content: "";
  position: absolute;
  top: -6px;
  bottom: -6px;
  left: -22px;
  width: 6px;
  border-inline: 2px solid var(--diff-ins-line);
}
.reader .u-changed::after, .reader .u-bar-chg::after, .reader .u-added::after, .reader .u-bar-add::after {
  position: absolute;
  top: -2px;
  left: -26px;
  width: 12px;
  padding: 1px 0 2px;
  background: var(--surface-1);
  font: 700 var(--text-sm)/1 var(--font-ui);
  text-align: center;
}
/* Decorative: the hidden "Changed" or "Added" prefix (js/compare/marks.js)
 * says it, so the glyph has empty alt text and is not read as "tilde" or
 * "plus" after every marked unit. The first declaration is for engines that
 * do not take the alt form. */
.reader .u-changed::after, .reader .u-bar-chg::after { content: "~"; content: "~" / ""; color: var(--diff-change-bar); }
.reader .u-added::after, .reader .u-bar-add::after { content: "+"; content: "+" / ""; color: var(--diff-ins-line); }
/* A list item's gutter is past its marker. */
.reader li.unit::before { left: calc(-21px - 1.3em); }
.reader li.u-added::before, .reader li.u-bar-add::before { left: calc(-22px - 1.3em); }
.reader li.unit::after { left: calc(-26px - 1.3em); }
/* A table row cannot hold a bar of its own: its first cell carries it. */
.reader tr.unit::before, .reader tr.unit::after { content: none; }
.reader tr.u-changed > *, .reader tr.u-added > * { box-shadow: none; }
.reader tr.u-changed { box-shadow: none; }
.reader tr.u-changed > :first-child { box-shadow: inset 3px 0 0 var(--diff-change-bar); padding-left: 8px; }
.reader tr.u-added { box-shadow: none; }
.reader tr.u-added > :first-child { box-shadow: inset 6px 0 0 var(--diff-ins-unit), inset 8px 0 0 var(--diff-ins-line); padding-left: 12px; }
.reader tr.u-bar-chg > :first-child { box-shadow: inset 3px 0 0 var(--diff-change-bar); padding-left: 8px; }
.reader tr.u-bar-add > :first-child { box-shadow: inset 2px 0 0 var(--diff-ins-line); padding-left: 8px; }
.u-label { display: block; margin-bottom: 2px; font: 600 var(--text-xs)/1.4 var(--font-ui); color: var(--diff-ins-line); }
.reader li > .u-label { display: inline; margin-right: 6px; }
/* A moved part: a dotted bar, and an arrow at its start (js/compare/marks.js). */
.reader .u-moved::before, .reader .u-bar-mov::before { content: ""; position: absolute; top: -6px; bottom: -6px; left: -21px; border-left: 3px dotted var(--diff-change-bar); }
.reader .u-move-start::after { content: "\2195"; content: "\2195" / ""; position: absolute; top: -2px; left: -26px; width: 12px; padding: 1px 0 2px; background: var(--surface-1); font: 700 var(--text-sm)/1 var(--font-ui); text-align: center; color: var(--diff-change-bar); }
.reader li.u-move-start::after { left: calc(-26px - 1.3em); }
.reader tr.u-moved > :first-child, .reader tr.u-bar-mov > :first-child { border-left: 3px dotted var(--diff-change-bar); padding-left: 8px; }
/* "Moved from after ...", and a changed part with no word marks saying why. */
.u-label--moved, .u-label--changed { color: var(--text-secondary); }

/* The change the counter points at: an outline and a tag matching it.
 * Raised over its neighbours: every unit is positioned, so the next one's
 * 7 px tint painted over the bottom edge of this outline. */
.reader .u-current { position: relative; z-index: 1; outline: 2px solid var(--diff-current); outline-offset: 9px; }
.reader tr.u-current { outline-offset: 2px; }
/* A row cannot hold its tag: its last cell does, at the outline's corner. */
.reader tr.u-current > :last-child { position: relative; }
.reader tr.u-current > :last-child > .cur-tag { top: -14px; right: -2px; }
.cur-tag {
  position: absolute;
  top: -21px;
  right: -9px;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  background: var(--diff-current);
  color: var(--on-accent);
  font: 600 var(--text-xs)/1 var(--font-ui);
  font-variant-numeric: var(--numerals-data);
  white-space: nowrap;
}
/* Held at the column's top edge while the change's top is above it
 * (js/compare/changes.js `holdTag`): a whole tag, not a cut one. */
.cur-tag.is-held { border-radius: var(--radius-sm); box-shadow: var(--shadow-pop); }
.cur-tag.is-out { visibility: hidden; }

/* Words: inserted underlined, removed struck and read past in secondary ink. */
.reader ins, .reader del {
  padding: 0 2px;
  border-radius: 2px;
  text-decoration-skip-ink: none;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
  font-variant-numeric: var(--numerals-data);
}
.reader ins { background: var(--diff-ins-word); color: inherit; text-decoration: underline 2px var(--diff-ins-line); text-underline-offset: 3px; }
.reader del { background: var(--diff-del-word); color: var(--text-secondary); text-decoration: line-through 2px var(--diff-del-line); }
.reader del + ins, .reader ins + del { margin-left: 2px; }
#compareView.hide-removed .reader .unit del { display: none; }

/* A removed run: a ghost row, dashed, collapsed to one line. */
.reader .ghost {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 10px;
  align-items: start;
  margin-top: .7em;
  padding: 8px 10px 9px;
  border: 1px dashed var(--diff-del-line);
  border-radius: var(--radius-sm);
  background: var(--diff-del-unit);
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  line-height: 1.45;
  color: var(--text-secondary);
  list-style: none;
}
.reader .ghost::after {
  content: "\2212";
  content: "\2212" / "";
  position: absolute;
  top: 7px;
  left: -26px;
  width: 12px;
  font: 700 var(--text-sm)/1 var(--font-ui);
  text-align: center;
  color: var(--diff-del-line);
}
.reader li.ghost::after { left: calc(-26px - 1.3em); }
.reader .ghost-row .ghost::after { content: none; }
.reader .ghost-row > td { padding: 6px 0; border-bottom: 0; }
.reader .ghost b { font-weight: 600; color: var(--text-primary); }
.ghost__what { grid-column: 1; }
.ghost__prev {
  grid-column: 1;
  overflow: hidden;
  font-family: var(--font-reading);
  font-size: var(--text-sm);
  line-height: 1.45;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ghost__prev del { padding: 0; }
.ghost__show { grid-row: 1 / span 2; grid-column: 2; align-self: center; }
.ghost__full { grid-column: 1 / -1; font-family: var(--font-reading); font-size: var(--text-sm); line-height: 1.5; }
.ghost__full[hidden] { display: none; }
.ghost__unit { margin-top: 6px; }
.ghost__unit--h { font-weight: 600; }
.reader .ghost.is-open .ghost__prev { display: none; }

/* ── The change ruler ──────────────────────────────────────────────────── */
/* A marked column's text starts a little lower, so the "1 of 9" tag of a
 * change at the very top is not cut off by the column head. */
.col.has-ruler .col__scroll { right: var(--ruler-width); padding-top: 32px; }
.ruler {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: var(--ruler-width);
  border-left: 1px solid var(--border);
  background: var(--surface-2);
  cursor: pointer;
}
.ruler .t { position: absolute; left: 2px; right: 2px; height: 3px; border-radius: 1px; }
.ruler .t-ins { background: var(--diff-ins-line); }
.ruler .t-del { background: var(--diff-del-line); }
.ruler .t-chg { background: var(--diff-change-bar); }
.ruler .t-mov { height: 5px; margin-top: -1px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--diff-change-bar); }
.ruler .t.is-current { left: -5px; right: 0; height: 7px; margin-top: -2px; border-radius: 2px 0 0 2px; background: var(--diff-current); }
.ruler .vp { position: absolute; left: 0; right: 0; border: 1px solid var(--text-muted); border-right: 0; border-radius: 2px 0 0 2px; pointer-events: none; }
#compareView.diff-off .ruler { display: none; }

/* ── Side panel: docked beside the columns, or lying over them ─────────── */
/* The panel slides in from the right edge: clipped here, so it never widens the page. */
#compareView .cmp-body { overflow: clip; }
#compareView.panel-open.panel-docked .cmp-body { grid-template-columns: minmax(0, 1fr) var(--panel-width); }
#compareView.panel-open .cmp-panel:not([hidden]) {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: auto;
  border-left: 1px solid var(--border);
  background: var(--surface-1);
  scrollbar-width: thin;
}
/* Focus that scrolls the panel stops clear of its sticky head and foot,
 * whose heights js/compare/panel.js measures (the foot grows with a wrapped
 * record sentence and the copy fallback). Docked, over the columns and as
 * the phone sheet alike. */
.cmp-panel { scroll-padding-block: calc(var(--panel-head-h, 56px) + 8px) calc(var(--panel-foot-h, 104px) + 8px); }
#compareView.panel-open.panel-overlay .cmp-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: var(--z-panel);
  width: var(--panel-width);
  box-shadow: var(--shadow-modal);
}
@media (prefers-reduced-motion: no-preference) {
  #compareView.panel-open.panel-overlay .cmp-panel { animation: cmp-panel-in var(--dur) var(--ease-out); }
}
@keyframes cmp-panel-in { from { transform: translateX(12px); opacity: 0; } to { transform: none; opacity: 1; } }
.cmp-panel .panel { display: flex; flex: 1 0 auto; flex-direction: column; padding: 0 18px; }
.panel__head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 14px 0 10px;
  background: var(--surface-1);
}
.panel__head h2 { margin-right: auto; font-size: var(--text-base); font-weight: 600; }
.panel__body { display: flex; flex: 1 0 auto; flex-direction: column; }
.panel__intro { font-size: var(--text-xs); line-height: 1.5; color: var(--text-secondary); }
.panel__intro + .panel__intro { margin-top: 6px; }
.cmp-panel h3, .cmp-panel .prefer > legend { margin: 22px 0 8px; font-size: var(--text-xs); font-weight: 600; color: var(--text-secondary); }
.panel__foot {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: grid;
  gap: 6px;
  margin: auto -18px 0;
  padding: 12px 18px 14px;
  border-top: 1px solid var(--border);
  background: var(--surface-1);
}
.panel__foot p { font-size: var(--text-xs); color: var(--text-secondary); }
.panel__foot .btn { justify-content: center; }
.pin[aria-pressed="true"] { background: var(--manila); color: var(--text-primary); }

/* Sections matrix. "Missing" is secondary ink and a dashed circle, never red. */
.secmap { width: 100%; margin-top: 14px; border-collapse: collapse; font-size: var(--text-xs); }
.secmap thead th { padding: 0 0 8px; font-weight: 600; text-align: center; }
.secmap thead th:first-child { text-align: left; color: var(--text-secondary); }
.secmap thead .rb { margin: 0 auto; }
.secmap th[scope="row"] { padding: 0; font-weight: 400; text-align: left; }
.secmap th[scope="row"] button {
  display: block;
  width: 100%;
  padding: 8px 6px 8px 8px;
  border: 0;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  background: none;
  color: var(--text-primary);
  font-size: var(--text-sm);
  line-height: 1.3;
  text-align: left;
  cursor: pointer;
}
.secmap th[scope="row"] button:focus-visible { outline-offset: -2px; }
.secmap .sub { display: block; margin-top: 2px; font-size: var(--text-xs); color: var(--text-secondary); }
.secmap td { width: 64px; padding: 4px 2px; text-align: center; vertical-align: middle; color: var(--text-secondary); }
.secmap tbody tr { border-top: 1px solid var(--border); }
.secmap tbody tr:hover { background: var(--surface-2); }
.secmap tbody tr.is-here { background: var(--manila); }
.secmap tbody tr.is-here th button { box-shadow: inset 3px 0 0 var(--accent); font-weight: 600; }
.secmap__ok .ic { width: 15px; height: 15px; color: var(--text-secondary); vertical-align: middle; }
.ren { font-weight: 600; color: var(--text-primary); text-decoration: underline dotted 1.5px var(--text-secondary); text-underline-offset: 3px; }
.miss { display: inline-flex; align-items: center; gap: 4px; font-weight: 500; color: var(--text-secondary); }
.miss::before { content: ""; width: 9px; height: 9px; border: 1.5px dashed var(--text-secondary); border-radius: 50%; }
.secmap .na { color: var(--text-muted); }
.secmap tr.group { border-top: 0; }
.secmap tr.group td { padding: 16px 0 6px 8px; background: var(--surface-1); font-weight: 600; text-align: left; }
.coverage { display: grid; gap: 4px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); font-size: var(--text-xs); line-height: 1.45; color: var(--text-secondary); }
.coverage b { font-weight: 600; color: var(--text-primary); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 10px 0 14px; font-size: var(--text-xs); color: var(--text-secondary); }
.legend > span { display: inline-flex; align-items: center; gap: 6px; }
.legend .ic { width: 14px; height: 14px; }

/* Review: the reviewer's marks, counted, never scored. */
.blind-hint { margin-top: 10px; padding: 8px 10px; border-left: 3px solid var(--border-strong); background: var(--surface-2); font-size: var(--text-xs); line-height: 1.45; color: var(--text-secondary); }
.blind-hint.is-on { border-left-color: var(--accent); }
.tally { display: grid; gap: 6px; margin-top: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); font-size: var(--text-xs); }
.tally > * { display: flex; align-items: center; gap: 8px; }
.crit { border-top: 1px solid var(--border); }
.crit > summary { display: flex; align-items: center; gap: 8px; padding: 11px 0; list-style: none; cursor: pointer; }
.crit > summary::-webkit-details-marker { display: none; }
.crit > summary:focus-visible { outline-offset: -2px; }
.crit > summary .chev { flex: none; width: 14px; height: 14px; color: var(--text-secondary); transition: transform var(--dur) var(--ease-out); }
.crit[open] > summary .chev { transform: rotate(90deg); }
.crit__name { font-size: var(--text-sm); font-weight: 600; }
.crit__sum { min-width: 0; margin-left: auto; overflow: hidden; font-size: var(--text-xs); color: var(--text-secondary); text-overflow: ellipsis; white-space: nowrap; }
.crit[open] .crit__sum { display: none; }
.crit__rows { display: grid; gap: 4px; padding: 0 0 12px; }
/* No report yet: a criterion is a plain row to set up, not a disclosure
 * that opens on nothing (js/compare/review.js). */
.crit__rows:empty { display: none; }
.crit--idle > .crit__head { display: flex; align-items: center; min-height: 44px; margin: 0; padding: 0 36px 0 0; }
.panel__empty { margin-top: 12px; padding: 10px 12px; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); font-size: var(--text-xs); line-height: 1.5; color: var(--text-secondary); }
.crit__row { display: flex; align-items: center; gap: 8px; }
.crit__row .seg { flex: 1; min-width: 0; }
/* Segments share the row, and none is narrower than its word and check:
 * every label reads in full in the 360 px panel ("Adequate" was cut to
 * "Adeq..." once chosen). */
.crit__row .seg > button { display: inline-flex; flex: 1 1 0; align-items: center; justify-content: center; gap: 4px; min-width: max-content; height: 28px; padding: 0 5px; font-size: var(--text-xs); }
.seg.marks .seg__word { white-space: nowrap; }
/* Focus sits outside the segment, past the seg's own 2 px padding: the
 * chosen mark's ring is a 2 px folder-brown inset, and a focus outline in
 * the same colour in the same place could not be told from it. */
.crit__row .seg > button:focus-visible { position: relative; z-index: 1; outline: var(--focus-width) solid var(--focus); outline-offset: 2px; }
/* A chosen mark: manila fill, a 2 px folder-brown ring, a check, heavier type. */
.seg.marks > button[aria-checked="true"] { background: var(--manila-strong); color: var(--text-primary); font-weight: 600; box-shadow: inset 0 0 0 2px var(--accent); }
.seg.marks .ck { display: none; flex: none; width: 11px; height: 11px; }
.seg.marks > button[aria-checked="true"] .ck { display: block; }
/* Each criterion's menu: Rename, Clear marks, Move up, Move down, Remove
 * (design spec 7.3.9). The button sits at the right of the summary row,
 * outside the summary, which a button inside would toggle; the menu opens
 * under it, inside the panel, so it works in the phone sheet too. */
.crit-wrap { position: relative; }
.crit-wrap > .crit > summary { padding-right: 36px; }
.crit__more { position: absolute; top: 7px; right: 0; width: 30px; height: 30px; }
.crit__menu {
  position: absolute;
  top: 40px;
  right: 0;
  z-index: 3;
  min-width: 190px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-1);
  box-shadow: var(--shadow-pop);
}
.crit__menu[hidden] { display: none; }
.crit__input { width: 100%; margin-bottom: 6px; }
.add-crit { justify-self: start; align-self: flex-start; margin: 4px 0 0; }
.notes { display: grid; gap: 10px; }
.note { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: start; gap: 8px; }
.note textarea, .summary textarea, .copy-fallback textarea {
  width: 100%;
  min-height: 58px;
  padding: 7px 9px;
  resize: vertical;
  font-family: var(--font-reading);
  font-size: var(--text-sm);
  line-height: 1.45;
}
.prefer { display: grid; gap: 2px; margin: 0; padding: 0; border: 0; }
.prefer > legend { padding: 0; }
.prefer label { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: var(--radius-sm); font-size: var(--text-sm); cursor: pointer; }
.prefer label:hover { background: var(--surface-2); }
.prefer input { width: 16px; height: 16px; margin: 0; }
.prefer label:has(input:checked) { background: var(--manila); font-weight: 600; }
.copy-fallback { display: grid; gap: 6px; }
.copy-fallback[hidden] { display: none; }

/* ── Blind: numbers and neutral stripes; names, roles and kinds leave ──── */
#compareView.blind .col__kind, #compareView.blind .col__mode { display: none; }

/* ── Share and export dialog, in Compare (js/export-dialog.js) ──────────────
 * Why a choice is not offered, said under it at full secondary ink rather
 * than inside the dimmed, untabbable button. */
.ds-export__why {
  max-width: var(--measure, 65ch);
  margin: -2px 0 var(--space-1);
  padding: 0 var(--space-4);
  font-size: var(--text-xs);
  line-height: 1.5;
  color: var(--text-secondary);
}

/* ── Widths ────────────────────────────────────────────────────────────── */
@media (max-width: 699px) {
  .tb-row2 > .tb-against .picker { flex: 1; min-width: 0; }
  .tb-against { flex: 1; }
  /* Below 700 px the panel opens only as a sheet under the header. */
  #compareView .cmp-panel.is-sheet {
    position: fixed;
    top: var(--header-h-app, 56px);
    right: 0;
    left: 0;
    bottom: auto;
    z-index: var(--z-sheet);
    display: flex;
    flex-direction: column;
    width: auto;
    max-height: calc(100dvh - var(--header-h-app, 56px) - 56px);
    overflow: auto;
    border: 0;
    border-bottom: 1px solid var(--border);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    background: var(--surface-1);
    box-shadow: var(--shadow-modal);
  }
  html[data-chrome="off"] #compareView .cmp-panel.is-sheet { top: 0; max-height: calc(100dvh - 56px); }
  .panel__wide { display: none; }
  .cmp-diffmenu.is-sheet { width: auto; }
}
@media (max-width: 699px) and (prefers-reduced-motion: no-preference) {
  #compareView .cmp-panel.is-sheet:not([hidden]) { animation: cmp-sheet-in var(--dur) var(--ease-out); }
}
@media (forced-colors: active) {
  .reader .u-current { outline-color: Highlight; }
  .seg.marks > button[aria-checked="true"] { outline: 2px solid CanvasText; }
}
@media print {
  .ruler, .cur-tag, .ghost__show { display: none !important; }
  .reader .u-current { outline: 0; }
}
