/*
 * The overlay viewer: a top bar, the PDF on the left and its Lean counterparts
 * on the right (a bottom sheet below 1000px). Colors are tokens; the page
 * itself stays white in both themes, so the marks drawn on it use their own
 * on-page tokens.
 */
:root {
  color-scheme: light dark;
  --bg: #f6f5f2;
  --surface: #ffffff;
  --stage: #e7e5df;
  --text: #1c1b19;
  --muted: #58544d;
  --faint: #706c64;
  --ghost: #bdb8ae;
  --line: #e6e3dc;
  --line-strong: #d6d2c9;
  --code-bg: #f7f6f2;
  --hover: #f1efea;
  --bridge: #3d55c9;
  --bridge-ink: #2c3f9e;
  --bridge-soft: rgba(61, 85, 201, 0.10);
  --kw: #7a4a8c;
  --ok: #2d7d55;
  --warn: #986110;
  --violet: #6f52b5;
  --bad: #b8382c;
  --bad-soft: #fbecea;
  --neutral: #706c65;
  --shadow: 0 1px 2px rgba(20, 18, 14, 0.06), 0 8px 24px rgba(20, 18, 14, 0.10);
  /* On the page, which is white in both themes. */
  --on-page-bridge: #3d55c9;
  --on-page-soft: rgba(61, 85, 201, 0.10);
  --on-page-hot: rgba(61, 85, 201, 0.26);
  --region-stroke: #b86e12;
  --region-fill: rgba(240, 170, 40, 0.10);
  --region-fill-hover: rgba(240, 170, 40, 0.20);
  --region-quiet: rgba(105, 101, 93, 0.70);
  --sans: system-ui, -apple-system, "Segoe UI", sans-serif;
  /* system-ui last, for a glyph the rest lack: Firefox on macOS finds U+2096 no other way. */
  --serif: ui-serif, "New York", "Iowan Old Style", Palatino, Georgia, serif, system-ui;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace, system-ui;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131417;
    --surface: #1a1c20;
    --stage: #0e0f11;
    --text: #e9e7e2;
    --muted: #a39f97;
    --faint: #8f8c87;
    --ghost: #4f4c47;
    --line: #2a2d32;
    --line-strong: #383c42;
    --code-bg: #212328;
    --hover: #23262b;
    --bridge: #8b9dff;
    --bridge-ink: #aab7ff;
    --bridge-soft: rgba(139, 157, 255, 0.14);
    --kw: #c9a2dc;
    --ok: #5fbf8a;
    --warn: #e0a54a;
    --violet: #b29cf0;
    --bad: #f07a6c;
    --bad-soft: #3a1f1c;
    --neutral: #8f8b84;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
  }

  :root:not([data-theme="light"]) #pdf-canvas {
    filter: brightness(0.92);
  }
}

:root[data-theme="dark"] {
  --bg: #131417;
  --surface: #1a1c20;
  --stage: #0e0f11;
  --text: #e9e7e2;
  --muted: #a39f97;
  --faint: #8f8c87;
  --ghost: #4f4c47;
  --line: #2a2d32;
  --line-strong: #383c42;
  --code-bg: #212328;
  --hover: #23262b;
  --bridge: #8b9dff;
  --bridge-ink: #aab7ff;
  --bridge-soft: rgba(139, 157, 255, 0.14);
  --kw: #c9a2dc;
  --ok: #5fbf8a;
  --warn: #e0a54a;
  --violet: #b29cf0;
  --bad: #f07a6c;
  --bad-soft: #3a1f1c;
  --neutral: #8f8b84;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
}

:root[data-theme="dark"] #pdf-canvas {
  filter: brightness(0.92);
}

* {
  box-sizing: border-box;
}

/* Out of sight, still read: what a minimal overlay keeps for screen readers. */
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* A chip out of sight comes back while it holds keyboard focus. */
.status-chip.visually-hidden:focus-within {
  position: relative !important;
  width: auto;
  height: auto;
  margin: 0;
  overflow: visible;
  clip-path: none;
}

[hidden] {
  display: none !important;
}

sub,
sup {
  position: relative;
  font-size: 0.7em;
  line-height: 0;
  vertical-align: baseline;
}

sub {
  bottom: -0.25em;
}

sup {
  top: -0.45em;
}

html {
  height: 100%;
}

body {
  display: grid;
  grid-template-rows: 48px minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--sans);
}

button,
input,
select {
  color: inherit;
  font: inherit;
}

button {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}

button:disabled {
  cursor: default;
  opacity: 0.35;
}

a {
  color: var(--bridge-ink);
}

p,
h1,
h2,
h3,
h4 {
  margin: 0;
}

[tabindex="-1"]:focus {
  outline: none;
}

:focus-visible {
  outline: 2px solid var(--bridge);
  outline-offset: 2px;
  border-radius: 4px;
}

kbd {
  padding: 0 4px;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  font-family: var(--sans);
  font-size: 11px;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 8px;
  left: 8px;
  padding: 6px 10px;
  border-radius: 6px;
  background: var(--surface);
  color: var(--bridge-ink);
  transform: translateY(-200%);
}

.skip-link:focus {
  transform: none;
}

/* ---- the top bar -------------------------------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.back-link {
  flex: none;
  color: var(--muted);
  font-size: 13px;
  text-decoration: none;
  white-space: nowrap;
}

.back-link:not(.has-arrow)::before {
  content: "← ";
}

.back-link:hover {
  color: var(--text);
  text-decoration: underline;
}

/* With no back link, no divider either: the bar starts with the title. */
.back-link[hidden] + .topbar-sep {
  display: none;
}

.topbar-sep {
  flex: none;
  width: 1px;
  height: 18px;
  background: var(--line-strong);
}

.topbar h1 {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  font-size: 14px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Reading mode stays named and reachable even on a narrow screen. */
.reading-toggle {
  flex: none;
  min-width: 88px;
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.reading-toggle:hover {
  background: var(--hover);
  color: var(--text);
}

.reading-toggle[aria-expanded="false"] {
  border-color: var(--bridge);
  background: var(--bridge-soft);
  color: var(--bridge-ink);
}

.shortcut-menu {
  position: relative;
  flex: none;
}

.shortcut-toggle {
  width: 30px;
  height: 30px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  color: var(--muted);
  font-size: 14px;
}

.shortcut-toggle:hover,
.shortcut-toggle[aria-expanded="true"] {
  background: var(--hover);
  color: var(--text);
}

.shortcut-help {
  position: fixed;
  z-index: 500;
  top: 56px;
  right: 16px;
  width: min(390px, calc(100vw - 32px));
  max-height: calc(100dvh - 70px);
  overflow: auto;
  padding: 16px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 13px;
}

.shortcut-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.shortcut-heading h2 {
  margin: 0;
  font: 600 15px var(--sans);
}

.shortcut-list {
  margin: 0;
}

.shortcut-list > div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 6px 0;
}

.shortcut-list dd {
  flex: none;
  margin: 0;
  white-space: nowrap;
}

.shortcut-note,
.shortcut-context {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.shortcut-context summary {
  cursor: pointer;
}

.shortcut-context p:last-child {
  margin-bottom: 0;
}

/* Faithfulness: a switch drawn before its label. */
.switch {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 8px;
  position: relative;
  height: 30px;
  padding: 0 10px 0 48px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.switch:hover {
  background: var(--hover);
  color: var(--text);
}

.switch::before,
.switch::after {
  content: "";
  position: absolute;
  top: 50%;
  transition: transform 120ms, background-color 120ms;
}

.switch::before {
  left: 12px;
  width: 28px;
  height: 16px;
  margin-top: -8px;
  border-radius: 999px;
  background: var(--neutral);
}

.switch::after {
  left: 14px;
  width: 12px;
  height: 12px;
  margin-top: -6px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

.switch[aria-pressed="true"] {
  color: var(--text);
}

.switch[aria-pressed="true"]::before {
  background: var(--bridge);
}

.switch[aria-pressed="true"]::after {
  transform: translateX(12px);
}

/* The status chip: its <details> holds the note on how the PDF is checked. */
.status-chip {
  position: relative;
  flex: none;
}

.status-chip summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--muted);
  cursor: pointer;
  font-size: 12.5px;
  list-style: none;
  white-space: nowrap;
}

.status-chip summary::-webkit-details-marker {
  display: none;
}

.status-chip summary:hover {
  color: var(--text);
}

.status-glyph {
  font-weight: 700;
}

.status-glyph:empty {
  display: none;
}

.status-chip.is-ok .status-glyph {
  color: var(--ok);
}

.status-chip.is-bad .status-glyph,
.status-chip.is-bad .status-text {
  color: var(--bad);
}

.status-pop {
  position: absolute;
  z-index: 30;
  top: 34px;
  right: 0;
  width: 320px;
  max-width: calc(100vw - 32px);
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

/* ---- the workspace -------------------------------------------------------- */

.main {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
}

.error {
  padding: 10px 16px;
  background: var(--bad-soft);
  color: var(--bad);
}

.workspace {
  display: grid;
  grid-row: 2;
  grid-template-columns: minmax(0, 1fr) 8px
    clamp(280px, var(--details-width, clamp(380px, 40vw, 600px)), calc(100% - 8px));
  min-height: 0;
}

/* Override both the desktop split and the narrow-screen bottom sheet. */
.workspace.is-reading {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
}

/* A visible grip and a generous hit area without covering the PDF or its links. */
.panel-divider {
  position: relative;
  z-index: 3;
  cursor: col-resize;
  touch-action: none;
  background: var(--surface);
  border-inline: 1px solid var(--line);
}
.panel-divider::after {
  content: "";
  position: absolute;
  top: calc(50% - 20px);
  left: 2px;
  width: 2px;
  height: 40px;
  border-radius: 2px;
  background: var(--faint);
}
.panel-divider:hover,
.panel-divider:focus-visible,
.is-resizing .panel-divider {
  background: var(--bridge-soft);
  outline: 2px solid var(--bridge);
  outline-offset: -2px;
}
.workspace.is-resizing,
.workspace.is-resizing * {
  cursor: col-resize !important;
  user-select: none !important;
}
.workspace.is-reading .panel-divider { display: none; }

.viewer-column {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--stage);
}

.page-scroller {
  height: 100%;
  overflow: auto;
  padding: 28px 28px 96px;
}

.page-scroller:focus-visible {
  outline-offset: -2px;
}

.page-stage {
  position: relative;
  margin: 0 auto;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08), 0 8px 28px rgba(0, 0, 0, 0.12);
}

#pdf-canvas {
  display: block;
}

/*
 * PDF.js's text layer: the page's own text, transparent, above the canvas and
 * below the region boxes, so it can be selected and copied. The vendored
 * build's `TextLayer` writes the spans and sets, on each of them, `left` and
 * `top` as percentages of the UNROTATED page, `font-family`, `--font-height`
 * (in page units), `--scale-x` and `--rotate`; on the container it sets
 * `width` and `height` from `--total-scale-factor` and `--scale-round-*`, and
 * `data-main-rotation`. viewer.js sets `--total-scale-factor` (the viewport's
 * scale times its user unit). Only the two build files are vendored
 * (`vendor/pdfjs/PINNED.md`), so the rules that read all of that are these,
 * which follow PDF.js's own text layer stylesheet. The one value they leave
 * alone is `--min-font-size`, the build's measurement of the browser's own
 * minimum font size: a browser that enforces one draws a very small span
 * larger than its glyphs, and the selection there is a line or so coarse.
 */
.text-layer {
  --scale-round-x: 1px;
  --scale-round-y: 1px;
  position: absolute;
  inset: 0;
  overflow: clip;
  caret-color: CanvasText;
  forced-color-adjust: none;
  line-height: 1;
  text-align: initial;
  text-size-adjust: none;
  transform-origin: 0 0;
}

/* The spans are placed on the unrotated page; the layer turns with the reader's rotation. */
.text-layer[data-main-rotation="90"] {
  transform: rotate(90deg) translateY(-100%);
}

.text-layer[data-main-rotation="180"] {
  transform: rotate(180deg) translate(-100%, -100%);
}

.text-layer[data-main-rotation="270"] {
  transform: rotate(270deg) translateX(-100%);
}

.text-layer span,
.text-layer br {
  position: absolute;
  color: transparent;
  cursor: text;
  font-size: calc(var(--font-height, 1px) * var(--total-scale-factor, 1));
  transform: rotate(var(--rotate, 0deg)) scaleX(var(--scale-x, 1));
  transform-origin: 0 0;
  white-space: pre;
}

.text-layer ::selection {
  /* The page is white in both themes, so the selection uses an on-page token. */
  background: var(--on-page-hot);
}

/*
 * The boxes take the pointer, the rest of the page passes it to the text layer:
 * a click on a box opens its card, and a drag anywhere else selects text. An
 * SVG root with no `pointer-events` would take every pointer in its own box,
 * selection included, since it covers the whole page.
 */
.overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

/* PDF links take precedence where a source region overlaps a hyperlink. */
.pdf-links {
  position: absolute;
  inset: 0;
  overflow: clip;
  pointer-events: none;
}

.pdf-link {
  position: absolute;
  pointer-events: auto;
}

.pdf-link:hover,
.pdf-link:focus-visible {
  outline: 2px solid #345bd6;
}

/* Regions: coverage sets the stroke's dash, a verdict (when shown) its color. */
.overlay-region {
  fill: var(--region-fill);
  stroke: var(--region-stroke);
  stroke-width: 1.25;
  vector-effect: non-scaling-stroke;
  cursor: pointer;
  outline: none;
  pointer-events: visible;
}

.overlay-region[data-coverage="partial"] {
  stroke-dasharray: 4 3;
}

.overlay-region[data-coverage="quiet"] {
  fill: transparent;
  stroke: var(--region-quiet);
  stroke-dasharray: 1.5 3;
  stroke-width: 1.5;
}

/* A proof step's box: the step's passage, not a statement, so the page's items stay what stands out. */
.overlay-region[data-step] {
  fill: transparent;
  stroke-opacity: 0.45;
  stroke-width: 1;
}

.overlay-region[data-step]:hover,
.overlay-region[data-step]:focus-visible,
.overlay-region[data-step].is-hot {
  stroke-opacity: 1;
}

.overlay-region[data-verdict="faithful"] {
  stroke: #2d7d55;
}

.overlay-region[data-verdict="convention"],
.overlay-region[data-verdict="proxy"] {
  stroke: #a86b12;
}

.overlay-region[data-verdict="attribution_gap"] {
  stroke: #6f52b5;
}

.overlay-region[data-verdict="deviation"] {
  stroke: #b8382c;
}

.overlay-region[data-verdict="fixed"] {
  stroke: #8a857c;
}

.overlay-region:hover,
.overlay-region:focus-visible,
.overlay-region.is-hot {
  fill: var(--region-fill-hover);
  stroke-width: 1.75;
}

.overlay-region[data-coverage="quiet"]:hover,
.overlay-region[data-coverage="quiet"]:focus-visible,
.overlay-region[data-coverage="quiet"].is-hot {
  fill: rgba(105, 101, 93, 0.10);
}

/* A keyboard focus is an indigo ring, as on every other control. */
.overlay-region:focus-visible {
  stroke: var(--on-page-bridge);
  stroke-dasharray: none;
  stroke-width: 2;
}

.overlay.has-selection .overlay-region {
  opacity: 0.6;
}

.overlay.has-selection .overlay-region:hover,
.overlay.has-selection .overlay-region:focus-visible,
.overlay.has-selection .overlay-region.is-hot {
  opacity: 1;
}

.overlay .overlay-region[aria-pressed="true"] {
  opacity: 1;
  fill: var(--on-page-soft);
  stroke: var(--on-page-bridge);
  stroke-dasharray: none;
  stroke-width: 2;
}

.overlay .overlay-region[data-step][aria-pressed="true"] {
  stroke-opacity: 1;
}

.overlay .overlay-region[aria-pressed="true"].is-hot {
  fill: var(--on-page-hot);
  stroke-width: 2.5;
  filter: drop-shadow(0 0 4px rgba(61, 85, 201, 0.45));
}

/* The selected region's bar, in the page's left margin: the item head's bar on the page. */
.region-bar {
  position: absolute;
  left: -12px;
  width: 4px;
  border-radius: 2px;
  background: var(--on-page-bridge);
  pointer-events: none;
}

.region-peek {
  position: absolute;
  z-index: 3;
  display: flex;
  align-items: baseline;
  gap: 8px;
  max-width: 440px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: 12.5px;
  pointer-events: none;
  white-space: nowrap;
}

.peek-label {
  flex: none;
  font-family: var(--serif);
  font-size: 13px;
  font-weight: 600;
}

.peek-name {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  text-overflow: ellipsis;
}

.peek-more {
  flex: none;
  color: var(--faint);
  font-size: 12px;
}

/* The PDF controls: one floating pill at the bottom of the PDF pane. */
.toolbar {
  max-width: calc(100% - 16px);
  overflow-x: auto;
  overflow-y: hidden;
  position: absolute;
  z-index: 5;
  bottom: 16px;
  left: 50%;
  display: flex;
  align-items: center;
  gap: 2px;
  height: 40px;
  padding: 0 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow);
  transform: translateX(-50%);
  white-space: nowrap;
}

/* Keep every control usable by scrolling when the PDF pane is narrowed. */
.toolbar > * {
  flex-shrink: 0;
}

@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .toolbar {
    background: color-mix(in srgb, var(--surface) 86%, transparent);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
  }
}

.icon {
  display: inline-grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 6px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
}

.icon:hover:not(:disabled) {
  background: var(--hover);
  color: var(--text);
}

.toolbar input {
  width: calc(4ch + 14px);
  height: 26px;
  padding: 0 4px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  text-align: center;
  -moz-appearance: textfield;
  appearance: textfield;
}

.toolbar input::-webkit-outer-spin-button,
.toolbar input::-webkit-inner-spin-button {
  margin: 0;
  -webkit-appearance: none;
}

.page-count,
.zoom-value {
  padding: 0 4px;
  color: var(--muted);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

.zoom-value {
  min-width: 44px;
  text-align: center;
}

.toolbar-sep {
  width: 1px;
  height: 18px;
  margin: 0 6px;
  background: var(--line-strong);
}

/* Find stays available in reading mode; its marks never take pointer events. */
.find-toggle {
  padding: 0 8px;
  height: 30px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 13px;
}

.find-toggle:hover,
.find-toggle[aria-expanded="true"] { background: var(--hover); color: var(--text); }

.find-bar {
  position: absolute;
  z-index: 6;
  top: 12px;
  right: 12px;
  display: grid;
  grid-template-columns: minmax(60px, 1fr) auto repeat(3, 28px);
  align-items: center;
  gap: 4px;
  width: min(460px, calc(100% - 24px));
  padding: 8px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.find-bar input {
  min-width: 0;
  width: 100%;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  font-size: 14px;
}

.find-bar .icon { width: 28px; }
.find-count { max-width: 145px; color: var(--muted); font-size: 12px; line-height: 1.3; }
.find-highlights { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.find-highlight { position: absolute; background: rgba(255, 218, 40, 0.42); }
.find-highlight.is-current { background: rgba(255, 145, 0, 0.55); outline: 2px solid #b95c00; }

/* ---- the formal pane ------------------------------------------------------- */

.details-column {
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  padding: 18px 24px 28px;
  background: var(--surface);
}

.text-button {
  color: var(--bridge-ink);
  font-size: 12.5px;
}

.text-button:hover:not(:disabled) {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.faint {
  color: var(--faint);
}

.foot {
  margin-top: 28px;
  color: var(--faint);
  font-size: 12px;
}

.dot {
  display: inline-block;
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--tone, var(--neutral));
}

/* Verdict tones: the verdict pill, a card's verdict, the dots. */
.verdict-badge.verdict-faithful,
.verdict-dot.verdict-faithful {
  --tone: var(--ok);
}

.verdict-badge.verdict-convention,
.verdict-badge.verdict-proxy,
.verdict-dot.verdict-convention,
.verdict-dot.verdict-proxy {
  --tone: var(--warn);
}

.verdict-badge.verdict-attribution_gap,
.verdict-dot.verdict-attribution_gap {
  --tone: var(--violet);
}

.verdict-badge.verdict-deviation,
.verdict-dot.verdict-deviation {
  --tone: var(--bad);
}

/* A fixed finding is kept as a record, in a neutral tone rather than its kind's. */
.verdict-badge.verdict-fixed,
.verdict-dot.verdict-fixed {
  --tone: var(--neutral);
}

.verdict-dot {
  width: 7px;
  height: 7px;
}

.verdict-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--tone, var(--muted));
  font-weight: 600;
  white-space: nowrap;
}

.verdict-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  flex: none;
  border-radius: 50%;
  background: var(--tone, var(--neutral));
}

/* The page index: what the panel shows with nothing selected. */
.index-heading {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 600;
  line-height: 1.25;
}

.index-meta {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12.5px;
}

.page-jump {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin-top: 10px;
}

.lede {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.notice {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12.5px;
}

.page-index {
  margin: 16px 0 0;
  padding: 0;
  border-top: 1px solid var(--line);
  list-style: none;
}

.page-index li {
  border-bottom: 1px solid var(--line);
}

.index-row {
  display: grid;
  grid-template-columns: 14px minmax(96px, max-content) minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  width: calc(100% + 16px);
  min-height: 40px;
  margin: 0 -8px;
  padding: 8px;
  border-radius: 6px;
  text-align: left;
}

.index-row:hover,
.index-row.is-hot {
  background: var(--hover);
}

.page-view {
  container-type: inline-size;
}

.index-label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: 45cqw;
}

.index-title {
  min-width: 0;
  overflow: hidden;
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* One line: the name gives way to an ellipsis, and its "+N" stays. */
.index-decl {
  display: flex;
  align-items: baseline;
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12.5px;
  white-space: nowrap;
}

.index-decl .decl {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.index-decl.is-empty {
  display: block;
  text-overflow: ellipsis;
}

.index-decl .ns {
  color: var(--faint);
}

.index-decl .more {
  flex: none;
  color: var(--faint);
  white-space: pre;
}

.index-decl.is-empty {
  color: var(--faint);
  font-family: var(--sans);
  font-style: italic;
}

/* A proof's steps under its row: one line each, their marks under the row's label. */
.step-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.page-index .step-list {
  margin-bottom: 6px;
  padding-left: 26px;
}

.page-index .step-list li {
  border-bottom: 0;
}

.step-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  width: calc(100% + 8px);
  margin: 0 -8px 0 0;
  padding: 2px 8px 2px 4px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 12.5px;
  text-align: left;
}

.step-row:hover,
.step-row.is-hot {
  background: var(--hover);
  color: var(--text);
}

.step-row .swatch {
  flex: none;
  align-self: center;
}

.step-number {
  flex: none;
  min-width: 2ch;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.step-text {
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.step-relation,
.step-page {
  flex: none;
  color: var(--faint);
  font-size: 11.5px;
  white-space: nowrap;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin-top: 16px;
  color: var(--muted);
  font-size: 12px;
}

.legend + .legend {
  margin-top: 8px;
}

.legend-entry {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.swatch {
  display: inline-block;
  width: 18px;
  height: 10px;
  border: 1.5px solid var(--region-stroke);
  border-radius: 2px;
  background: var(--region-fill);
}

.swatch.partial {
  border-style: dashed;
}

.swatch.quiet {
  border: 1.5px dotted var(--region-quiet);
  background: none;
}

/* The index rows' mark: the legend's swatch, smaller. */
.swatch.mini {
  width: 14px;
  height: 9px;
}

.keys {
  margin-top: 20px;
  color: var(--faint);
  font-size: 12px;
}

.keys kbd {
  color: var(--muted);
}

.page-view .foot {
  margin-top: 10px;
}

/* The item view. */
.nav-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 28px;
  color: var(--muted);
  font-size: 12.5px;
}

.nav-strip .text-button {
  height: 26px;
  padding: 0 8px;
  margin-left: -8px;
  border-radius: 6px;
  color: var(--muted);
}

.nav-strip .text-button:hover {
  background: var(--hover);
  color: var(--text);
  text-decoration: none;
}

.stepper {
  display: flex;
  align-items: center;
  gap: 2px;
  font-variant-numeric: tabular-nums;
}

.stepper .icon {
  width: 26px;
  height: 26px;
}

.stepper span {
  padding: 0 4px;
}

.item-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.item-choice {
  height: 26px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-family: var(--serif);
  font-size: 13px;
}

.item-choice[aria-pressed="true"] {
  border-color: transparent;
  background: var(--bridge-soft);
  color: var(--bridge-ink);
}

.item-head {
  margin-top: 10px;
  padding-left: 14px;
  border-left: 3px solid var(--bridge);
}

.item-label {
  font-weight: 600;
}

.item-title {
  display: block;
  font-family: var(--serif);
  font-size: 26px;
  line-height: 1.15;
}

.item-subtitle {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-family: var(--serif);
  font-size: 16px;
  font-style: italic;
  font-weight: 400;
  line-height: 1.3;
}

.item-meta {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 4px 8px;
  margin-top: 6px;
}

.target-summary {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--hover);
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

/* The pill's mark is the region's: solid amber, dashed amber or dotted gray. */
.target-summary::before,
.target-summary.coverage-not_formalized::before,
.target-summary.coverage-out_of_scope::before {
  content: "";
  flex: none;
  width: 12px;
  height: 8px;
  border: 1.5px dotted var(--region-quiet);
  border-radius: 2px;
}

.target-summary.coverage-formalized::before,
.target-summary.coverage-partial::before,
.target-summary.coverage-support_only::before,
.target-summary.coverage-example_only::before,
.target-summary.coverage-private_only::before {
  border: 1.5px solid var(--region-stroke);
  background: var(--region-fill);
}

.target-summary.coverage-partial::before,
.target-summary.coverage-support_only::before,
.target-summary.coverage-example_only::before,
.target-summary.coverage-private_only::before {
  border-style: dashed;
}

/* One line; the full locator is the title. */
.item-locator {
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.note-toggle {
  display: block;
  margin-top: 6px;
  color: var(--muted);
}

.coverage-note {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.verdict-notes {
  margin-top: 4px;
  padding-left: 17px;
}

.verdict-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 8px;
  margin-top: 6px;
  font-size: 13px;
}

.verdict-line .verdict-badge {
  font-size: 12px;
}

.verdict-summary {
  color: var(--text);
}

/* The key declarations: one card each, its statement in full. */
.key-section {
  margin-top: 22px;
}

/* The count and the filter, on one line above the cards. */
.key-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.key-count {
  margin: 0;
  color: var(--faint);
  font-size: 12.5px;
}

.filter {
  width: 160px;
  height: 28px;
  margin-left: auto;
  padding: 0 8px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  font-size: 12.5px;
}

.filter-empty {
  margin-bottom: 10px;
}

.key-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.key-card + .key-card {
  margin-top: 22px;
}

.proof-enclosing {
  margin: 4px 0 10px;
  color: var(--faint);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.proof-enclosing a, .proof-notation dd { font-family: var(--mono); }
.proof-conclusion { margin: 0 0 10px; line-height: 1.5; }
.proof-explanation { margin: 0 0 14px; line-height: 1.5; color: var(--muted); }
.proof-chain-links { list-style: none; padding: 0; margin: 0 0 16px; }
.proof-chain-link {
  display: block; width: 100%; text-align: left; padding: 6px 8px;
  border: 0; border-left: 2px solid transparent; border-radius: 0;
  background: transparent; color: var(--bridge-ink); line-height: 1.4;
}
.proof-chain-link[aria-pressed="true"] { border-left-color: var(--bridge); background: var(--bridge-soft); }
.proof-chain-number { color: var(--faint); }
.proof-details { margin: 12px 0 0; font-size: 13px; line-height: 1.5; }
.proof-details > summary { cursor: pointer; color: var(--muted); }
.proof-notation { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 6px 12px; }
.proof-notation dd { margin: 0; overflow-wrap: anywhere; }
.proof-chain-link:focus-visible, .proof-details > summary:focus-visible {
  outline: 2px solid var(--bridge); outline-offset: 3px;
}

.key-list + .more {
  margin-top: 14px;
}

.eyebrow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 20px;
}

.eyebrow-left {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  min-width: 0;
}

.kind {
  color: var(--faint);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.card-verdict {
  font-size: 11px;
}

.tag {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 6px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--muted);
  font-size: 11px;
}

.tag.is-sorry {
  border-color: var(--bad);
  color: var(--bad);
}

.source-link {
  flex: none;
  color: var(--bridge-ink);
  font-size: 13px;
  text-decoration: none;
  white-space: nowrap;
}

.source-link:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.no-link {
  flex: none;
  color: var(--faint);
  font-size: 12.5px;
  white-space: nowrap;
}

.decl-name {
  display: block;
  margin-top: 4px;
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.ns {
  color: var(--faint);
  font-weight: 400;
}

.ns.ditto {
  color: var(--ghost);
}

.lean {
  margin: 8px 0 0;
  padding: 12px 14px;
  overflow: hidden;
  border-radius: 8px;
  background: var(--code-bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  tab-size: 2;
}

/* Each source line is a block whose wrapped continuations hang 4ch inside its own indentation. */
.lean .ln {
  display: block;
  padding-left: var(--ind, 4ch);
  text-indent: calc(-1 * var(--ind, 4ch));
}

.lean .nb {
  white-space: nowrap;
}

/* A step's lines: the number sits in a gutter outside the text, which stays the snippet's. */
.lean.is-numbered .ln {
  position: relative;
  margin-left: 5ch;
}

.lean.is-numbered .ln::before {
  content: attr(data-line);
  position: absolute;
  left: -5ch;
  width: 4ch;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
  text-align: right;
  text-indent: 0;
  user-select: none;
}

.range-lines,
.range-more {
  margin-top: 4px;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 12.5px;
}

.range-lines {
  margin-top: 8px;
}

.lean.is-clamped {
  max-height: calc(14 * 1.65em + 24px);
  max-height: calc(14lh + 24px);
}

@supports ((-webkit-mask-image: linear-gradient(#000, transparent)) or (mask-image: linear-gradient(#000, transparent))) {
  .lean.is-clamped {
    -webkit-mask-image: linear-gradient(#000 82%, transparent);
    mask-image: linear-gradient(#000 82%, transparent);
  }
}

.tk-kw {
  color: var(--kw);
}

.tk-cm {
  color: var(--faint);
  font-style: italic;
}

.tk-el {
  color: var(--faint);
}

/* Verso tokens: a variable in italics, a link dotted, a hover's token and its binding lit. */
.tk-var {
  font-style: italic;
}

.tk-sort {
  color: var(--kw);
}

.tk-lit {
  color: var(--ok);
}

.lean a {
  color: inherit;
  text-decoration: underline dotted var(--ghost);
  text-underline-offset: 3px;
}

.lean a:hover {
  text-decoration-style: solid;
  text-decoration-color: currentColor;
}

.lean .has-hover {
  cursor: help;
}

.lean a.has-hover {
  cursor: pointer;
}

.lean .has-hover:hover,
.lean .is-bound {
  border-radius: 3px;
  background: var(--bridge-soft);
}

.lean .has-hover:focus-visible,
.lean a:focus-visible {
  border-radius: 3px;
  outline: 2px solid var(--bridge);
  outline-offset: 1px;
}

.hover-card {
  position: fixed;
  z-index: 40;
  top: 0;
  left: 0;
  box-sizing: border-box;
  max-width: min(560px, calc(100vw - 16px));
  max-height: min(50vh, 420px);
  overflow: auto;
  overscroll-behavior: contain;
  padding: 8px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.5;
}

.hover-sig {
  display: block;
  font-family: var(--mono);
  font-size: 12.5px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.hover-doc,
.hover-code {
  margin: 6px 0 0;
}

.hover-sig + .hover-doc,
.hover-sig + .hover-code {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.hover-doc {
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.hover-doc code,
.hover-code {
  border-radius: 3px;
  background: var(--code-bg);
  font-family: var(--mono);
  font-size: 12px;
}

.hover-doc code {
  padding: 0 3px;
}

.hover-code {
  padding: 6px 8px;
  white-space: pre-wrap;
}

.show-all {
  margin-top: 6px;
}

/* Related declarations: after a rule, quieter, one link per line. */
.related {
  margin-top: 36px;
  padding-top: 10px;
  border-top: 1px solid var(--line-strong);
}

.related-head {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 28px;
  padding-bottom: 4px;
}

.related-head h3 {
  color: var(--faint);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.related-role {
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
}

.related-head .count {
  color: var(--faint);
  font-size: 11px;
}

.related-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.related-link {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 0 -8px;
  padding: 5px 8px;
  border-radius: 6px;
  color: var(--muted);
  text-decoration: none;
}

.related-link.is-unlinked {
  color: var(--faint);
}

a.related-link:hover {
  background: var(--hover);
  color: var(--text);
}

a.related-link:hover .related-name .leaf {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.related-name {
  min-width: 0;
  font-family: var(--mono);
  font-size: 12.5px;
  overflow-wrap: anywhere;
}

.related-name .leaf {
  font-weight: 600;
}

.related-tag {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 6px;
  color: var(--faint);
  font-size: 11.5px;
  white-space: nowrap;
}

.more {
  margin-top: 8px;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

.empty-line {
  color: var(--muted);
  font-size: 14px;
}

.empty-line.is-strong {
  color: var(--text);
}

.checked-in {
  margin-top: 8px;
  color: var(--faint);
  font-size: 12.5px;
}

.step-parent {
  display: block;
  max-width: 100%;
  margin-bottom: 2px;
  overflow: hidden;
  font-size: 12.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cluster-line {
  margin-top: 6px;
  color: var(--faint);
  font-size: 12.5px;
}

.cluster-ids {
  font-family: var(--mono);
}

/* ---- narrow: the formal pane becomes a bottom sheet -------------------------- */

@media (max-width: 999px) {
  .panel-divider { display: none; }
  .workspace {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) 46%;
  }

  .details-column {
    padding: 14px 20px;
    border-top: 1px solid var(--line);
    border-left: 0;
    box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.10);
  }

  .page-scroller {
    padding: 20px 16px 72px;
  }

  .key-section {
    margin-top: 16px;
  }
}

@media (max-width: 599px) {
  .workspace {
    grid-template-rows: minmax(0, 1fr) 55%;
  }

  .toolbar { gap: 0; }
  .toolbar .icon { width: 28px; }
  .toolbar .toolbar-sep { margin: 0 3px; }
  .toolbar input { width: calc(3ch + 14px); }
  .toolbar .zoom-value { min-width: 40px; }

  .topbar {
    gap: 8px;
  }

  .switch {
    width: 48px;
    padding: 0;
    overflow: hidden;
    font-size: 0;
  }

  .status-text {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .page-scroller,
  .details-column {
    scroll-behavior: smooth;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}

@media (prefers-contrast: more) {
  .overlay-region {
    fill: transparent;
    stroke-width: 3;
  }
}

/* Native MathML from authored LaTeX labels; no remote fonts or inline styles. */
.item-title math, .item-subtitle math, .index-label math, #item-label math {
  font-size: 1em;
}
