/* Compare tool — entry card + the full-screen viewer, rebuilt on the redact
   editor's shell (mirrors styles/redact.css: centered overlay card, two-row
   toolbar, left sidebar, morphing stage, reused .redact-review-bar walk card,
   mobile off-canvas drawer). Consumes global tokens (styles/main.css);
   --cmp-ins/--cmp-del/--cmp-box are defined there. */

/* ===== Entry: two-dropzone picker ===== */
.compare-slots { display: grid; grid-template-columns: 1fr auto 1fr; gap: 14px; align-items: stretch; margin-top: 12px; }
.compare-slot { display: flex; flex-direction: column; }
.compare-slot-label { font-size: 13px; font-weight: 600; color: var(--text-soft); margin-bottom: 6px; }
.compare-slot.filled .dropzone { border-style: solid; border-color: var(--primary); }
.compare-slot-file { font-size: 13px; color: var(--text); margin-top: 8px; display: flex; align-items: center; gap: 6px; word-break: break-all; }
.compare-swap { align-self: center; }
.compare-swap .btn { min-width: 44px; min-height: 44px; }
/* Explicit trigger — also the fallback when auto-open didn't fire, so the user
   never has to re-pick a file just to re-open the comparison. */
.compare-actions { display: flex; justify-content: flex-end; margin-top: 16px; }
.compare-run { display: inline-flex; align-items: center; gap: 8px; }
.compare-progress { margin-top: 16px; }
.compare-progress .progress-track { position: relative; height: 8px; background: var(--bg-soft); border-radius: 999px; overflow: hidden; }
.compare-progress .progress-fill { height: 100%; width: 0; background: var(--primary); transition: width .2s ease; }
.compare-progress .progress-label { font-size: 13px; color: var(--text-soft); margin-bottom: 6px; }
/* The staged fill (8→40→72%) can sit on one value for a couple seconds during a
   slow extract; a sweeping sheen keeps the bar visibly alive so it reads as
   "working", not "stalled". Clipped by the track's overflow:hidden. */
.compare-progress.is-working .progress-track::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--primary) 55%, transparent), transparent);
  transform: translateX(-100%);
  animation: cmpProgSweep 1.15s ease-in-out infinite;
}
@keyframes cmpProgSweep { to { transform: translateX(100%); } }
@media (prefers-reduced-motion: reduce) {
  .compare-progress.is-working .progress-track::after { animation: none; display: none; }
}
@media (max-width: 640px) {
  .compare-slots { grid-template-columns: 1fr; }
  /* Single-column grid items stretch to full width by default; a full-width
     swap wrapper rotated 90° projects its 286px width into 286px of vertical
     height, overlapping the dropzones above and below. Shrink it to the button
     so the rotation stays a compact 44px chip centred in the gap. */
  .compare-swap { justify-self: center; transform: rotate(90deg); }
}

/* ===== Full-screen overlay + centered editor card (mirrors .redact-overlay) ===== */
.compare-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(8, 10, 16, 0.88);
  display: flex; align-items: center; justify-content: center;
  padding: 0;
  /* Mirror the redact/sign editors: the scrim fades while the box rises (below),
     rather than the whole overlay sliding as one flat unit. The shared keyframes
     (editorOverlayIn/Out, editorBoxIn/Out) live in app.css. The editor fills the
     entire viewport edge-to-edge — the scrim only shows during the fade. */
  animation: editorOverlayIn .2s ease;
}
.compare-overlay.closing { animation: editorOverlayOut .2s ease forwards; pointer-events: none; }
.compare-overlay.closing .compare-editor { animation: editorBoxOut .2s ease forwards; }

.compare-editor {
  background: var(--bg-elev);
  border: 0;
  border-radius: 0;
  display: flex; flex-direction: column;
  position: relative;              /* containing block for the review-walk card */
  max-width: 100vw;
  height: 100vh;
  height: 100dvh;
  width: 100vw;
  overflow: hidden;
  box-shadow: none;
  animation: editorBoxIn .32s cubic-bezier(.2, .7, .3, 1);   /* box rises into the fading scrim */
}
/* Reduced-motion guard placed AFTER the base rules above so it wins the cascade
   (equal specificity → later source order decides). Covers open and close. */
@media (prefers-reduced-motion: reduce) {
  .compare-overlay, .compare-overlay.closing,
  .compare-editor, .compare-overlay.closing .compare-editor { animation: none; }
}

/* ===== Two-row toolbar (mirrors .redact-toolbar) ===== */
.compare-toolbar { display: flex; flex-direction: column; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--bg-elev); }
.compare-toolbar-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px 14px; flex-wrap: wrap; }
.compare-toolbar-meta-left { display: flex; align-items: baseline; gap: 10px; min-width: 0; flex-wrap: wrap; }
.compare-toolbar-meta-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.compare-toolbar-main { display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; }
.compare-title { font-weight: 600; font-size: 14px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 46vw; }
.compare-counts { font-size: 13px; color: var(--text-soft); font-variant-numeric: tabular-nums; }
.compare-ocr-note { font-size: 12px; color: var(--text-mute); white-space: nowrap; }
.compare-toolbar-actions { display: flex; align-items: center; gap: 8px; }
/* The "View controls" overflow is mobile-only: on desktop the visual controls stay
   inline, so the trigger + menu are hidden (the @media block flips it on). */
.compare-more, .compare-more-menu { display: none; }
.compare-toolbar-actions .cmp-lock { margin-right: 5px; vertical-align: -2px; opacity: .85; }
.compare-close-btn { display: inline-flex; align-items: center; justify-content: center; }

/* "More" export overflow — keeps the primary "Redlined PDF" visible while the
   secondary exports (Change report, Summary) tuck behind a menu. Absolute-positioned
   INSIDE the overlay (not portaled) so it clears the overlay's own z-index:1000. */
.compare-export-more { position: relative; display: inline-flex; }
.compare-export-more-btn { display: inline-flex; align-items: center; gap: 3px; }
.compare-export-more-btn .cmp-chev { opacity: .8; transition: transform .15s cubic-bezier(.2, .7, .3, 1); }
.compare-export-more.open .compare-export-more-btn .cmp-chev { transform: rotate(180deg); }
.compare-export-menu {
  display: none; position: absolute; top: calc(100% + 6px); right: 0;
  min-width: 210px; flex-direction: column; gap: 4px;
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius, 12px); box-shadow: 0 12px 32px rgba(15, 23, 42, 0.22);
  padding: 8px; z-index: 70; transform-origin: top right;
  animation: menuIn 0.15s cubic-bezier(0.2, 0.7, 0.3, 1);
}
.compare-export-more.open .compare-export-menu { display: flex; }
.compare-export-menu > .btn { width: 100%; justify-content: flex-start; min-height: 40px; }

/* View toggle — segmented control (mirrors the redact view buttons) */
.compare-view-toggle { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.compare-view-toggle button { border: 0; background: transparent; padding: 6px 12px; font-size: 13px; color: var(--text-soft); cursor: pointer; min-height: 36px; }
.compare-view-toggle button + button { border-left: 1px solid var(--border); }
.compare-view-toggle button[aria-pressed="true"] { background: var(--primary); color: #fff; }

/* Visual-only controls (zoom + highlight + opacity), shown by view. The page-nav
   pager retired to the floating bottom-center pill (.pf-nav-float). */
.compare-visual-tools[hidden], .cmp-visual-range[hidden] { display: none; }
.cmp-visual-page { font-size: 13px; color: var(--text-soft); min-width: 92px; text-align: center; font-variant-numeric: tabular-nums; }
/* Inline zoom retired — zoom is the floating .pf-zoom-float pill (all viewports). */
.compare-visual-tools { display: inline-flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.cmp-visual-hl[aria-pressed="true"] { color: var(--cmp-box); background: color-mix(in srgb, var(--cmp-box) 12%, transparent); box-shadow: inset 0 0 0 1px var(--cmp-box); }
.cmp-vpill { display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 999px; background: color-mix(in srgb, var(--cmp-box) 16%, transparent); color: var(--cmp-box); font-size: 11px; font-weight: 600; }
.cmp-visual-range { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-soft); }
.cmp-visual-range input[type="range"] { width: 120px; accent-color: var(--primary); }

/* Highlight STYLE switch (Outline vs Pixels) — a compact segmented control modeled
   on .compare-view-toggle; the active segment takes the --cmp-box highlight accent. */
.cmp-hl-style { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.cmp-hl-style[hidden], .cmp-hl-legend[hidden], .cmp-hl-note[hidden] { display: none; }
.cmp-hl-style-btn { display: inline-flex; align-items: center; gap: 5px; border: 0; background: transparent; padding: 5px 10px; font-size: 12px; font-weight: 600; color: var(--text-soft); cursor: pointer; min-height: 32px; transition: background .15s ease, color .15s ease; }
.cmp-hl-style-btn + .cmp-hl-style-btn { border-left: 1px solid var(--border); }
.cmp-hl-style-btn svg { opacity: .8; }
.cmp-hl-style-btn:hover:not([aria-pressed="true"]) { background: color-mix(in srgb, var(--cmp-box) 10%, transparent); color: var(--text); }
.cmp-hl-style-btn[aria-pressed="true"] { background: var(--cmp-box); color: #fff; }
.cmp-hl-style-btn[aria-pressed="true"] svg { opacity: 1; }
.cmp-hl-style-btn:focus-visible { outline: 2px solid var(--cmp-box); outline-offset: -2px; }
.cmp-hl-style-btn:disabled { opacity: .42; cursor: not-allowed; }
.cmp-hl-style-btn:disabled:hover { background: transparent; color: var(--text-soft); }

/* Pixel-tint legend — meaning by label, not colour alone. The square swatches use
   rounded squares (echoing "pixels") and match the canvas tint colours exactly
   (#ef4444 / #16a34a; see overlayCanvas in compare-visual.js). */
.cmp-hl-legend { display: inline-flex; align-items: center; gap: 12px; font-size: 12px; color: var(--text-soft); }
.cmp-hl-legend-item { display: inline-flex; align-items: center; gap: 5px; }
.cmp-hl-dot { width: 11px; height: 11px; border-radius: 3px; display: inline-block; box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); }
.cmp-hl-dot-rem { background: #ef4444; }
.cmp-hl-dot-add { background: #16a34a; }

/* Inline reason shown when Pixels is present but disabled (a scan would flood a
   per-pixel tint) — keeps the option discoverable and explained, not hidden. */
.cmp-hl-note { font-size: 12px; line-height: 1.35; color: var(--text-soft); max-width: 230px; }

/* Ignore-watermark toggle — pressed = the watermark is hidden (the default). */
.compare-wm-toggle { display: inline-flex; align-items: center; gap: 6px; }
.compare-wm-toggle[aria-pressed="true"] { color: var(--primary); background: color-mix(in srgb, var(--primary) 12%, transparent); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 40%, transparent); }

/* OCR opt-in (scanned PDFs) */
.cmp-ocr-ctl { display: inline-flex; align-items: center; gap: 8px; }
.cmp-ocr-ctl [hidden] { display: none !important; }
.cmp-ocr-ctl .cmp-ocr-ico { margin-right: 6px; vertical-align: -2px; }
.cmp-ocr-run { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-soft); }
.cmp-ocr-label { white-space: nowrap; }
.cmp-spinner { width: 15px; height: 15px; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--primary); animation: cmpSpin .7s linear infinite; flex: none; }
@keyframes cmpSpin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .cmp-spinner { animation: none; } }

/* ===== Body = sidebar + stage (mirrors .redact-body) ===== */
.compare-body { flex: 1; display: flex; min-height: 0; position: relative; }

/* Changes sidebar — the redact category-sidebar analog. */
.compare-sidebar {
  flex: 0 0 296px; display: flex; flex-direction: column; min-height: 0;
  background: var(--bg); border-right: 1px solid var(--border);
}
.compare-sidebar-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 12px 14px 8px; }
.compare-sidebar-title { font-size: 11px; letter-spacing: .05em; color: var(--text-soft); font-weight: 600; }
.compare-sidebar-count { font-size: 12px; color: var(--text-soft); font-variant-numeric: tabular-nums; }
.compare-filters { padding: 0 8px 8px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; }
.compare-filter-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 4px; cursor: pointer; user-select: none; font-size: 13px; }
.compare-filter-row:hover { background: var(--bg-elev); }
.compare-filter-row input[type="checkbox"] { flex: 0 0 auto; cursor: pointer; }
.compare-filter-ico { display: inline-flex; flex: 0 0 auto; }
.compare-filter-row[data-kind="added"] .compare-filter-ico { color: var(--cmp-ins); }
.compare-filter-row[data-kind="deleted"] .compare-filter-ico { color: var(--cmp-del); }
.compare-filter-row[data-kind="modified"] .compare-filter-ico { color: var(--primary); }
.compare-filter-label { flex: 1; }
.compare-filter-count { font-size: 11px; color: var(--text-soft); font-variant-numeric: tabular-nums; background: var(--bg-elev); padding: 1px 6px; border-radius: 999px; }

.compare-list-rows { flex: 1 1 auto; overflow-y: auto; min-height: 0; }
.compare-list-row { display: grid; grid-template-columns: 22px 1fr auto; gap: 8px; align-items: center; padding: 9px 14px; border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent); cursor: pointer; min-height: 44px; }
.compare-list-row:hover, .compare-list-row:focus-visible { background: var(--bg-elev); outline: none; }
.compare-list-row.active { background: color-mix(in srgb, var(--primary) 12%, transparent); }
.compare-list-ico { display: inline-flex; }
.compare-list-row[data-kind="added"] .compare-list-ico { color: var(--cmp-ins); }
.compare-list-row[data-kind="deleted"] .compare-list-ico { color: var(--cmp-del); }
.compare-list-row[data-kind="modified"] .compare-list-ico { color: var(--primary); }
.compare-list-snip { font-size: 13px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compare-list-page { font-size: 12px; color: var(--text-mute); font-variant-numeric: tabular-nums; }
.compare-list-empty { padding: 24px 16px; text-align: center; color: var(--text-soft); font-size: 13px; }
/* Scanned / identical-doc explainer in the sidebar (no change-list to show). */
.compare-sidebar-note { padding: 14px; font-size: 13px; line-height: 1.5; color: var(--text-soft); }
.compare-sidebar-note strong { color: var(--text); font-weight: 600; }
.compare-sidebar-foot { flex: 0 0 auto; margin-top: auto; padding: 10px 12px; border-top: 1px solid var(--border); }
.compare-review-all { width: 100%; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }

/* Drawer toggle (mobile-only) + count badge */
.compare-drawer-toggle { display: none; align-items: center; gap: 6px; min-height: 44px; }
.compare-drawer-count { min-width: 18px; padding: 0 5px; border-radius: 9px; font-size: 11px; font-weight: 600; line-height: 18px; text-align: center; background: var(--primary); color: #fff; }
.compare-drawer-count[hidden] { display: none; }
.compare-list-scrim { display: none; }

/* ===== Text stage (serif redline column) ===== */
.compare-pane { flex: 1; overflow: auto; padding: 28px clamp(16px, 5vw, 64px); font: 16px/1.7 ui-serif, Georgia, "Times New Roman", serif; color: var(--text); }
/* The serif column is centered + measure-capped; the visual view goes full-bleed. */
.compare-pane:not(.cmp-pane-visual) > * { max-width: 820px; margin-inline: auto; }
.cmp-eq { color: var(--text); }
.compare-pane ins.cmp-ins { color: var(--cmp-ins); text-decoration: underline; text-decoration-thickness: 2px; }
.compare-pane del.cmp-del { color: var(--cmp-del); text-decoration: line-through; }
.cmp-change { border-radius: 3px; padding: 0 1px; scroll-margin: 80px; }
.cmp-change.cmp-flash { background: color-mix(in srgb, var(--primary) 22%, transparent); transition: background 1.2s ease; }
/* Review-walk spotlight on the focused change — the "combo" treatment, matching
   redact's .redact-rect.focused: a bold white+amber ring (shape + motion, not
   color alone), a snap-in reticle, a caret that names it, and the OTHER change
   marks recede. */
.cmp-change.cmp-focus {
  position: relative;
  outline: none;
  border-radius: 3px;
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px #f59e0b, 0 0 12px 3px rgba(245, 158, 11, .5);
  animation: cmpFocusPulse 1.6s ease-in-out infinite;
}
.cmp-change.cmp-focus::after {
  content: "";
  position: absolute;
  inset: -6px;
  border: 3px solid #f59e0b;
  border-radius: 5px;
  pointer-events: none;
  animation: cmpFocusReticle .34s cubic-bezier(.18, .9, .2, 1) forwards;
}
.cmp-change.cmp-focus::before {
  content: var(--cap, "Reviewing");
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  background: #f59e0b;
  color: #1a1206;
  font: 700 11px/1.1 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: .04em;
  padding: 7px 10px 15px;
  white-space: nowrap;
  z-index: 8;
  pointer-events: none;
  clip-path: polygon(0 0, 100% 0, 100% 76%, 57% 76%, 50% 100%, 43% 76%, 0 76%);
  filter: drop-shadow(0 3px 7px rgba(0, 0, 0, .35));
  animation: cmpFocusCap .3s ease both;
}
@keyframes cmpFocusPulse {
  0%, 100% { box-shadow: 0 0 0 2px #fff, 0 0 0 4px #f59e0b, 0 0 10px 2px rgba(245, 158, 11, .42); }
  50%      { box-shadow: 0 0 0 2px #fff, 0 0 0 4px #f59e0b, 0 0 20px 7px rgba(245, 158, 11, .66); }
}
@keyframes cmpFocusReticle { 0% { transform: scale(1.5); opacity: 0; } 55% { opacity: 1; } 100% { transform: scale(1); opacity: 0; } }
@keyframes cmpFocusCap { from { opacity: 0; transform: translate(-50%, 4px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* Other change marks recede while a walk/jump is active. */
.compare-pane.reviewing .cmp-change:not(.cmp-focus) { opacity: .35; transition: opacity .28s ease; }

@media (prefers-reduced-motion: reduce) {
  .cmp-change.cmp-focus,
  .cmp-change.cmp-focus::after,
  .cmp-change.cmp-focus::before { animation: none !important; }
}
.cmp-br { display: block; height: 14px; }

/* Advisory banner: complex/multi-column layout, approximate text redline. Neutral
   surface, sans-serif so it reads as chrome (no edge stripe, no color-only signal). */
.cmp-approx-note { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin: 0 0 22px; padding: 11px 14px; background: var(--bg-soft); border: 1px solid var(--border); border-radius: var(--radius); font: 13px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--text-soft); }
.cmp-approx-ico { display: inline-flex; flex: none; color: var(--text-mute); }
.cmp-approx-text { flex: 1; min-width: 12ch; }
.cmp-approx-note .btn { flex: none; }

/* Empty / scanned states */
.compare-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; height: 100%; color: var(--text-soft); text-align: center; padding: 40px; }
.compare-empty .compare-empty-ico { color: var(--success); }

/* Bottom action bar — empty on desktop; JS relocates the export buttons here at
   ≤720px (mirrors the redact editor's .redact-actionbar). */
.compare-actionbar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--border); background: var(--bg-elev); }
.compare-actionbar[hidden] { display: none; }
.compare-actionbar .btn { flex: 1 1 auto; min-height: 46px; justify-content: center; }

/* ===== Review-walk card (reused redact .redact-review-bar, navOnly) ===== */
/* Compare's walk is read-only, so the two big buttons are Previous / Next (mirrors
   redact's two-big Skip/Redact for the same visual weight). Scoped to the nav card
   so redact's own card is untouched. The base card styling lives in redact.css. */
.redact-review-bar-nav .redact-review-navbig {
  flex: 1 1 calc(50% - 4px);
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  min-height: 48px; font-size: 15px;
}
.redact-review-bar-nav .redact-review-navbig svg {
  width: 17px; height: 17px; flex: 0 0 auto;
  transition: transform .15s ease;
}
.redact-review-bar-nav .redact-review-prevbig { order: 1; color: var(--text-soft); }
.redact-review-bar-nav .redact-review-nextbig { order: 2; }
/* Same directional nudge as the compact nav — chevron leans the way it travels. */
.redact-review-bar-nav .redact-review-prevbig:hover:not(:disabled) svg { transform: translateX(-2px); }
.redact-review-bar-nav .redact-review-nextbig:hover:not(:disabled) svg { transform: translateX(2px); }
.redact-review-bar-nav .redact-review-done { order: 3; margin-left: auto; flex: 0 0 auto; }
/* Page-location note where redact shows the "Will redact" state badge. */
.redact-review-note { font-size: 11.5px; font-weight: 600; color: var(--text-soft); flex: 0 0 auto; white-space: nowrap; font-variant-numeric: tabular-nums; }
/* The bottom-center nav pill and the bottom-center review-walk card claim the same
   spot, so hide the pill while the walk owns the screen (matches redact.css's
   `.redact-editor:has(.redact-review-bar) .pf-nav-float` rule). Base scope: the
   review walk runs on desktop too, where mobile's pill-hide media query doesn't fire. */
.compare-editor:has(.redact-review-bar) .pf-nav-float { display: none; }

/* ===== Visual stage (rendered page-pair) — pane goes full-bleed ===== */
.compare-pane.cmp-pane-visual { padding: 0; font: inherit; display: flex; flex-direction: column; overflow: hidden; }
.cmp-visual-body { flex: 1; display: flex; min-height: 0; }
.cmp-visual-thumbs { flex: 0 0 148px; overflow-y: auto; padding: 12px 10px; display: none; flex-direction: column; gap: 8px; background: var(--bg); border-right: 1px solid var(--border); }
.compare-pane.cmp-has-thumbs .cmp-visual-thumbs { display: flex; }
/* min-height floors the flex-shrink: overflow:hidden zeroes a flex item's auto
   min-size, so a short rail would shrink each strip into a thin clipped line
   instead of scrolling. 96px keeps it a readable page band, then the rail scrolls. */
.cmp-thumb { position: relative; border: 2px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; background: var(--bg-elev); overflow: hidden; min-height: 96px; transition: border-color .15s, box-shadow .15s, transform .15s; }
.cmp-thumb:hover { border-color: var(--primary-hover); transform: translateY(-1px); }
.cmp-thumb:active { transform: scale(0.97); }
.cmp-thumb:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.cmp-thumb.active { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary); }
.cmp-thumb.active:hover { transform: none; }
.cmp-thumb canvas { display: block; width: 100%; height: auto; }
.cmp-thumb-label { position: absolute; bottom: 4px; left: 4px; background: rgba(0,0,0,.7); color: #fff; font-size: 10px; font-weight: 600; padding: 1px 6px; border-radius: 999px; pointer-events: none; line-height: 1.4; }
.cmp-thumb-badge { position: absolute; top: 4px; right: 4px; min-width: 18px; height: 18px; padding: 0 5px; display: inline-flex; align-items: center; justify-content: center; background: var(--cmp-box); color: #fff; font-size: 10px; font-weight: 700; border-radius: 999px; pointer-events: none; line-height: 1; font-variant-numeric: tabular-nums; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.cmp-visual-stage { flex: 1; overflow: auto; scrollbar-gutter: stable; padding: 18px clamp(12px, 3vw, 28px); touch-action: pan-x pan-y;
  background: linear-gradient(45deg, rgba(0,0,0,0.05) 25%, transparent 25%, transparent 75%, rgba(0,0,0,0.05) 75%),
    linear-gradient(45deg, rgba(0,0,0,0.05) 25%, transparent 25%, transparent 75%, rgba(0,0,0,0.05) 75%) 10px 10px, var(--bg);
  background-size: 20px 20px; }
.cmp-visual-stage-inner { transform-origin: 50% 0; }
/* Grab-to-pan affordance: the stage scrolls on drag (compare-visual.js attachPan). */
.cmp-visual-stage { cursor: grab; }
.cmp-visual-stage.cmp-panning { cursor: grabbing; }
.cmp-vbusy, .cmp-vmissing { color: var(--text-mute); font-size: 13px; text-align: center; padding: 40px 16px; }
.cmp-vmissing { border: 1px dashed var(--border); border-radius: var(--radius); }
/* Content sizes to itself (auto tracks) so zoomed pages gain real, symmetric
   scroll range and the focal-point anchor holds. DON'T revert to 1fr/justify-center. */
.cmp-vpages { display: grid; grid-template-columns: auto auto; gap: 22px; align-items: start; width: max-content; margin-inline: auto; }
.cmp-vpage { display: flex; flex-direction: column; align-items: center; gap: 8px; min-width: 0; }
.cmp-vpage-label { font-size: 12px; font-weight: 600; color: var(--text-soft); text-transform: uppercase; letter-spacing: .04em; }
.cmp-vholder { position: relative; background: #fff; box-shadow: var(--shadow); border-radius: 2px; }
.cmp-vholder canvas { display: block; border-radius: 2px; }
.cmp-voverlay-wrap { width: max-content; margin-inline: auto; }
.cmp-voverlay { position: relative; background: #fff; box-shadow: var(--shadow); border-radius: 2px; }
.cmp-vlayer { position: absolute; top: 0; left: 0; display: block; }
/* Outlined change-box (shape, not color alone) — crisp inner ring + soft glow. */
.cmp-vbox { position: absolute; pointer-events: none; border: 2.5px solid var(--cmp-box); border-radius: 3px; background: color-mix(in srgb, var(--cmp-box) 15%, transparent); box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--cmp-box) 50%, transparent), 0 0 12px 2px color-mix(in srgb, var(--cmp-box) 55%, transparent); }

/* Pixel-tint highlight: a translucent canvas of ONLY the differing pixels, layered
   exactly over the page raster (.cmp-vlayer pins it). Deletions paint rose on the
   Original, additions green on the Revised, both on the Overlay stack. A quick fade
   keeps the mode switch smooth; never blocks pan/zoom. */
.cmp-vdiff { pointer-events: none; animation: cmpVdiffIn .18s cubic-bezier(0.22, 0.61, 0.36, 1); }
@keyframes cmpVdiffIn { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .cmp-vdiff { animation: none; } }

/* "Focus differences" wash: a translucent white canvas over the page raster with
   the diff regions punched clear, so matching content ghosts to a faint grey while
   the differences stay sharp. .cmp-vlayer pins it over the page; pointer-events:none
   keeps pan/zoom on the stage. NO opacity transition — the slider drives opacity
   live and a transition would lag the drag (direct manipulation = reduced-motion
   safe by construction). The fill alpha (0.85, in compare-fade.js) caps the ghost
   so matching content is never fully erased. */
.cmp-vfade { pointer-events: none; }

/* Review-walk spotlight on the focused visual difference — the SAME "combo"
   treatment as redact's .redact-rect.focused: a bold amber ring (shape + motion,
   not colour alone — the resting boxes are neutral --cmp-box), a snap-in reticle,
   a caret that names it, and the OTHER boxes recede. The page raster is always
   white, so amber reads in both themes. */
.cmp-vbox-focus {
  border-color: #f59e0b;
  background: color-mix(in srgb, #f59e0b 16%, transparent);
  box-shadow: 0 0 0 2px #fff, 0 0 0 5px #f59e0b, 0 0 16px 5px rgba(245, 158, 11, .5);
  z-index: 7;
  animation: cmpVboxFocusPulse 1.6s ease-in-out infinite;
}
@keyframes cmpVboxFocusPulse {
  0%, 100% { box-shadow: 0 0 0 2px #fff, 0 0 0 5px #f59e0b, 0 0 12px 3px rgba(245, 158, 11, .42); }
  50%      { box-shadow: 0 0 0 2px #fff, 0 0 0 5px #f59e0b, 0 0 24px 9px rgba(245, 158, 11, .66); }
}
/* The snap-in reticle: a ring child the controller appends to the focused box and
   recreates each step, so the land animation replays every time you advance. */
.cmp-vbox-reticle {
  position: absolute; inset: -8px;
  border: 3px solid #f59e0b; border-radius: 7px;
  pointer-events: none;
  animation: cmpVboxReticle .34s cubic-bezier(.18, .9, .2, 1) forwards;
}
@keyframes cmpVboxReticle { 0% { transform: scale(1.5); opacity: 0; } 55% { opacity: 1; } 100% { transform: scale(1); opacity: 0; } }
/* Caret naming the focused difference (content from --cap). Points DOWN via a
   clip-path tail; pointer-events:none = a label, never a control (no chevron). */
.cmp-vbox-focus::before {
  content: var(--cap, "Reviewing");
  position: absolute; bottom: calc(100% + 5px); left: 50%; transform: translateX(-50%);
  background: #f59e0b; color: #1a1206;
  font: 700 11px/1.1 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: .04em; padding: 7px 10px 15px; white-space: nowrap;
  z-index: 8; pointer-events: none;
  clip-path: polygon(0 0, 100% 0, 100% 76%, 57% 76%, 50% 100%, 43% 76%, 0 76%);
  filter: drop-shadow(0 3px 7px rgba(0, 0, 0, .35));
  animation: cmpVboxCap .3s ease both;
}
@keyframes cmpVboxCap { from { opacity: 0; transform: translate(-50%, 4px); } to { opacity: 1; transform: translate(-50%, 0); } }
/* While a region walk is active, the OTHER boxes recede so the focused one is the
   only bright mark. Reverts the instant the walk ends; never touches the page. */
.cmp-visual-stage.reviewing .cmp-vbox:not(.cmp-vbox-focus) {
  opacity: .26; filter: grayscale(.6);
  transition: opacity .28s ease, filter .28s ease;
}
@media (prefers-reduced-motion: reduce) {
  /* Keep the static ring + dimming + caret; drop the motion. */
  .cmp-vbox-focus, .cmp-vbox-reticle, .cmp-vbox-focus::before { animation: none !important; }
}

/* ===== Mobile (≤720px): full-bleed editor, off-canvas Changes drawer ===== */
@media (max-width: 720px) {
  .compare-overlay { padding: 0; align-items: flex-start; }
  .compare-editor { max-width: none; height: 100vh; height: 100dvh; width: 100%; border: none; border-radius: 0; }
  /* Top padding clears the iPhone notch when edge-to-edge (viewport-fit=cover). */
  .compare-toolbar { gap: 6px; padding: calc(8px + env(safe-area-inset-top)) 10px 8px; }

  /* Two-row toolbar (the Organize pattern): meta row = title/counts (left) and the
     Changes drawer toggle (right, in-flow — no absolute pin / gutter, so the tools row
     gets the full width); tools row = the view toggles + a ⋯ "View controls" overflow
     holding the pager/zoom/highlight/opacity. Exit is the ‹ Back button / device Back;
     exports drop to the bottom action bar. */
  .compare-toolbar-meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: nowrap; }
  /* meta-left flexes + clips so a long "orig → rev" title ellipsizes instead of
     shoving the Changes toggle off the right edge; meta-right stays its size. */
  .compare-toolbar-meta-left { display: flex; flex-direction: column; align-items: flex-start; flex: 1 1 0; min-width: 0; gap: 1px; }
  .compare-toolbar-meta-right { flex: none; }
  .compare-title { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .compare-toolbar-actions { position: static; display: flex; align-items: center; gap: 6px; flex: none; }
  .compare-toolbar-actions .btn { min-height: 44px; }
  /* Changes drawer toggle is the lone item in the meta-right — icon + count only. */
  .compare-drawer-toggle { display: inline-flex; min-width: 44px; min-height: 44px; }
  .compare-drawer-label { display: none; }

  /* Compact view toggle: drop the niche single-document plain views so the row fits. */
  .compare-view-toggle [data-view="orig"], .compare-view-toggle [data-view="rev"] { display: none; }
  .compare-toolbar-main { justify-content: flex-start; flex-wrap: nowrap; }

  /* ⋯ "View controls" overflow dropdown — pinned to the right of the tools row. */
  .compare-more { display: inline-flex; position: relative; margin-left: auto; }
  .compare-more-btn { display: inline-flex; min-width: 44px; min-height: 44px; }
  .compare-more-menu {
    display: none; position: absolute; top: calc(100% + 6px); right: 0;
    min-width: 220px; flex-direction: column; gap: 4px;
    background: var(--bg-elev); border: 1px solid var(--border);
    border-radius: var(--radius, 12px); box-shadow: 0 12px 32px rgba(15, 23, 42, 0.22);
    padding: 8px; z-index: 60; transform-origin: top right;
    animation: menuIn 0.15s cubic-bezier(0.2, 0.7, 0.3, 1);
  }
  .compare-more.open .compare-more-menu { display: flex; }
  /* The relocated visual-control groups become stacked, full-width rows. (Pager +
     zoom are floating chips now, so only the highlight/opacity tools land here.) */
  .compare-more-menu > * { width: 100%; }
  .compare-more-menu .compare-visual-tools { display: flex; flex-direction: column; gap: 8px; align-items: stretch; }
  .compare-more-menu .cmp-visual-hl { width: 100%; justify-content: flex-start; min-height: 44px; }
  .compare-more-menu .cmp-hl-style { width: 100%; }
  .compare-more-menu .cmp-hl-style-btn { flex: 1; justify-content: center; min-height: 40px; }
  .compare-more-menu .cmp-hl-legend { justify-content: flex-start; padding: 2px 2px 4px; }
  .compare-more-menu .cmp-visual-range { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
  .compare-more-menu .cmp-visual-range input[type="range"] { flex: 1; }
  .cmp-hl-word { display: none; }   /* "Highlight differences" → "Highlight" */

  /* Export "More" overflow in the bottom action bar: it shares the row 50/50 with the
     primary Redlined-PDF button, and its menu opens UPWARD (the bar is pinned to the
     screen bottom). */
  .compare-actionbar .compare-export-more { flex: 1 1 0; display: flex; }
  .compare-actionbar .compare-export-more-btn { width: 100%; min-height: 46px; justify-content: center; }
  .compare-actionbar .compare-export-menu {
    top: auto; bottom: calc(100% + 8px); left: 0; right: 0;
    min-width: 0; transform-origin: bottom center;
  }

  /* The sidebar parks off-canvas + slides in OVER the stage from the toolbar toggle. */
  .compare-sidebar {
    position: absolute; top: 0; right: 0; bottom: 0; left: auto;
    flex: none; width: min(320px, 86vw); z-index: 30;
    transform: translateX(100%); transition: transform .22s ease;
    box-shadow: -2px 0 22px rgba(0,0,0,.26);
  }
  .compare-editor.drawer-open .compare-sidebar { transform: translateX(0); }
  .compare-list-scrim { display: block; position: absolute; inset: 0; z-index: 25; background: rgba(0,0,0,.42); opacity: 0; pointer-events: none; transition: opacity .22s ease; }
  .compare-editor.drawer-open .compare-list-scrim { opacity: 1; pointer-events: auto; }
  /* The floating chips step aside when the Changes drawer or the review walk owns
     the screen (same rule the redact editor uses for its floats). */
  .compare-editor.drawer-open .pf-pager-float,
  .compare-editor.drawer-open .pf-zoom-float,
  .compare-editor:has(.redact-review-bar) .pf-pager-float,
  .compare-editor:has(.redact-review-bar) .pf-zoom-float { display: none; }
  /* Hide the thumbnail rail on phones (like redact); the floating pager navigates. */
  .compare-pane.cmp-has-thumbs .cmp-visual-thumbs { display: none; }
  .cmp-visual-stage { padding: 12px 10px; }
  .cmp-vpages { grid-template-columns: auto auto; gap: 10px; }
}
@media (max-width: 720px) and (prefers-reduced-motion: reduce) {
  .compare-sidebar, .compare-list-scrim { transition: none; }
}

/* ===== Findings callout ===== */
/* The compare viewer's "We found N changes" card. It reuses the .redact-scan-
   callout class for the shared editor-shell look. The redact TOOL itself moved to
   a persistent findings bar (styles/redact.css), so these base styles — once
   shared from redact.css — now live here with their only remaining consumer. */
.redact-scan-callout {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  z-index: 11;
  width: min(560px, calc(100% - 32px));
  background: var(--bg-elev);
  border: 1px solid color-mix(in srgb, var(--primary) 35%, var(--border));
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: redact-scan-drop 0.22s ease-out;
}
@keyframes redact-scan-drop {
  from { opacity: 0; transform: translate(-50%, -8px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .redact-scan-callout { animation: none; }
}
.redact-scan-callout-main {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding-right: 18px;   /* clear the dismiss ✕ */
}
.redact-scan-ico { flex: 0 0 auto; color: var(--primary); margin-top: 1px; }
.redact-scan-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.redact-scan-title { font-size: 15px; color: var(--text); }
.redact-scan-breakdown { font-size: 13px; color: var(--text-soft); }
.redact-scan-split { font-size: 12.5px; color: var(--text-soft); }
.redact-scan-split strong { color: #d97706; }   /* amber — same signal as the review tier */
.redact-scan-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.redact-scan-dismiss {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-soft);
  border-radius: 6px;
  cursor: pointer;
}
.redact-scan-dismiss:hover { background: var(--bg); color: var(--text); }

/* The .dismissing class plays a reversed entrance so the card exits as its own
   clean beat rather than vanishing instantly. kpFadeDown is defined in main.css. */
.redact-scan-callout.dismissing {
  animation: kpFadeDown .18s ease-in forwards;
  pointer-events: none;
}
@media (prefers-reduced-motion: reduce) {
  .redact-scan-callout.dismissing { animation: none; }
}
