/*
 * Bifrosta — local stylesheet. No web fonts, no external assets, no remote
 * requests. Everything here ships inside the package.
 *
 * Direction: "PDF reference desk". The document evidence is the visual centre;
 * chrome stays quiet so that source and destination pages can be compared.
 */

:root {
  /* Colour ---------------------------------------------------------------- */
  --accent: #3c5592;
  --accent-hover: #34497d;
  --accent-text: #ffffff;
  --bg: #f4f5f8;
  --surface: #ffffff;
  --surface-sunken: #f7f8fa;
  --ink: #1f2933;
  --ink-2: #4b5965;
  --control-border: #74818b;
  --divider: #d5dce0;
  --error: #a12828;
  --error-bg: #fdf2f2;
  --success: #24613b;
  --success-bg: #f1f8f3;
  --warning-text: #805000;
  --warning-bg: #fff4d6;
  --info-bg: #eef2fa;
  --focus: #1d4ed8;

  /* Type ------------------------------------------------------------------ */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Consolas, monospace;
  --fs-12: 12px;
  --fs-14: 14px;
  --fs-16: 16px;
  --fs-20: 20px;
  --fs-24: 24px;

  /* Space ----------------------------------------------------------------- */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-6: 24px;
  --s-8: 32px;

  /* Shape ----------------------------------------------------------------- */
  --r-control: 6px;
  --r-panel: 8px;
  --h-control: 36px;
  --max-width: 1520px;
  --list-width: 340px;
  --motion: 140ms;
}

/*
 * Touch and pen targets get the larger control height regardless of viewport
 * width: a coarse pointer on a wide screen still needs 44px.
 */
@media (pointer: coarse) {
  :root {
    --h-control: 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --motion: 0ms;
  }
  *,
  *::before,
  *::after {
    transition-duration: 0ms !important;
    animation-duration: 0ms !important;
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--fs-14);
  line-height: 1.45;
}

body {
  padding: var(--s-6) var(--s-6) var(--s-8);
}

.app {
  max-width: var(--max-width);
  margin: 0 auto;
}

/* Typography --------------------------------------------------------------- */

h1,
h2,
h3 {
  line-height: 1.2;
  margin: 0;
  color: var(--ink);
}

h1 {
  font-size: var(--fs-20);
  font-weight: 700;
  letter-spacing: 0.01em;
}

h2 {
  font-size: var(--fs-20);
  font-weight: 600;
}

h3 {
  font-size: var(--fs-16);
  font-weight: 600;
}

p {
  margin: 0;
}

code,
.mono,
pre,
.num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.num,
.counts,
.doc-chip span,
.candidate-fact-value {
  font-variant-numeric: tabular-nums;
}

/* Header ------------------------------------------------------------------- */

.app-header {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-4);
  align-items: center;
  justify-content: space-between;
  padding-bottom: var(--s-4);
  border-bottom: 1px solid var(--divider);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  min-width: 0;
}

.brand-mark {
  color: var(--accent);
  flex: none;
}

.brand p {
  margin-top: 2px;
  color: var(--ink-2);
  font-size: var(--fs-12);
}

.doc-chip {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--s-2) var(--s-3);
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: var(--r-control);
  max-width: 100%;
  min-width: 0;
}

.doc-chip strong {
  font-size: var(--fs-14);
  font-weight: 600;
  overflow-wrap: anywhere;
}

.doc-chip span {
  color: var(--ink-2);
  font-size: var(--fs-12);
}

/* Stepper ------------------------------------------------------------------ */

.steps {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-1);
  margin: var(--s-4) 0;
  padding: var(--s-1);
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: var(--r-panel);
}

.step {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  min-height: var(--h-control);
  padding: 0 var(--s-3);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-control);
  color: var(--ink-2);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--motion) ease, border-color var(--motion) ease, color var(--motion) ease;
}

.step .step-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid var(--control-border);
  font-size: var(--fs-12);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.steps .step:hover:not(:disabled):not([aria-disabled='true']) {
  background: var(--info-bg);
  border-color: var(--divider);
  color: var(--ink);
}

/* Current step: the only filled control in the stepper. */
.steps .step-active,
.steps .step-active:hover:not(:disabled):not([aria-disabled='true']) {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

.steps .step-active .step-index {
  border-color: var(--accent-text);
  color: var(--accent-text);
}

/* Closed step: visually unavailable; reason is on title + aria-describedby. */
.steps .step:disabled,
.steps .step[aria-disabled='true'] {
  color: var(--ink-2);
  opacity: 0.5;
  cursor: not-allowed;
}

.steps .step:disabled .step-index,
.steps .step[aria-disabled='true'] .step-index {
  border-style: dashed;
}

/* Banners and live regions ------------------------------------------------- */

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

.banner {
  display: block;
  margin: var(--s-3) 0;
  padding: var(--s-3) var(--s-4);
  background: var(--surface);
  border: 1px solid var(--divider);
  border-left: 4px solid var(--control-border);
  border-radius: var(--r-control);
  color: var(--ink);
}

.banner strong {
  font-weight: 600;
}

.banner .detail {
  color: var(--ink-2);
}

.banner-error {
  background: var(--error-bg);
  border-left-color: var(--error);
}

.banner-error strong {
  color: var(--error);
}

.banner-error .banner-summary {
  display: flex;
  align-items: center;
  gap: var(--s-1);
}

.banner-error .detail {
  display: block;
  max-width: 80ch;
  margin-top: var(--s-1);
  overflow-wrap: anywhere;
}

.banner-success {
  background: var(--success-bg);
  border-left-color: var(--success);
}

.banner-success strong {
  color: var(--success);
}

.banner-info,
.banner-busy {
  background: var(--info-bg);
  border-left-color: var(--accent);
}

.banner-warning {
  background: var(--warning-bg);
  border-left-color: var(--warning-text);
  color: var(--warning-text);
}

/* Panels ------------------------------------------------------------------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: var(--r-panel);
  padding: var(--s-6);
}

.panel > h2 {
  margin-bottom: var(--s-1);
}

.hint {
  color: var(--ink-2);
  margin: var(--s-1) 0 var(--s-4);
  max-width: 78ch;
}

.section-label {
  display: block;
  margin-bottom: var(--s-2);
  color: var(--ink-2);
  font-size: var(--fs-12);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Controls ----------------------------------------------------------------- */

button {
  min-height: var(--h-control);
  padding: 0 var(--s-4);
  background: var(--accent);
  color: var(--accent-text);
  border: 1px solid var(--accent);
  border-radius: var(--r-control);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--motion) ease, border-color var(--motion) ease;
}

button:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

button:disabled {
  background: var(--surface-sunken);
  border-color: var(--divider);
  color: var(--ink-2);
  opacity: 0.75;
  cursor: not-allowed;
}

/* Secondary controls. `.step` is deliberately absent: the stepper owns its
 * own complete set of states below, and must not inherit this background. */
.button-secondary,
.chip,
.offset-row button,
.bulk button,
.suggestion button,
fieldset button,
.candidate-actions button {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--control-border);
  font-weight: 600;
}

.button-secondary:hover:not(:disabled),
.chip:hover:not(:disabled),
.offset-row button:hover:not(:disabled),
.bulk button:hover:not(:disabled),
.suggestion button:hover:not(:disabled),
fieldset button:hover:not(:disabled),
.candidate-actions button:hover:not(:disabled) {
  background: var(--info-bg);
  border-color: var(--accent);
}

/*
 * The pressed member of a decision group. Defined after the secondary styles
 * so a pressed control is filled wherever the group lives.
 */
.is-current {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

.is-current:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--accent-text);
}

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

/* Keep a visible ring for programmatic focus too. */
:focus:not(:focus-visible) {
  outline: none;
}

label {
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
  font-size: var(--fs-14);
  font-weight: 600;
  color: var(--ink);
}

.field-hint {
  font-weight: 400;
  font-size: var(--fs-12);
  color: var(--ink-2);
}

input[type="text"],
input[type="number"] {
  min-height: var(--h-control);
  padding: 0 var(--s-3);
  background: var(--surface);
  border: 1px solid var(--control-border);
  border-radius: var(--r-control);
  color: var(--ink);
  font: inherit;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

input[type="text"]:hover,
input[type="number"]:hover {
  border-color: var(--accent);
}

/* An invalid field keeps its error border on hover, not only for AT. */
input[aria-invalid='true'],
input[aria-invalid='true']:hover {
  border-color: var(--error);
  box-shadow: inset 0 0 0 1px var(--error);
}

/* Inline message under one field; the same tokens as the pattern summary. */
.field-error {
  margin: var(--s-2) 0 0;
  padding: var(--s-2) var(--s-3);
  background: var(--error-bg);
  border: 1px solid var(--error);
  border-left-width: 4px;
  border-radius: var(--r-control);
  color: var(--error);
  max-width: 78ch;
}

input[type="number"] {
  width: 120px;
}

input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

/* Chips are controls, so they use the control height token, not a smaller one. */
.chip {
  min-height: var(--h-control);
  padding: 0 var(--s-4);
  border-radius: 999px;
  font-size: var(--fs-14);
}

.chip-active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

/* Pressed chips keep white text, so their hover must stay dark. */
.chip-active:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--accent-text);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  margin-top: var(--s-6);
  padding-top: var(--s-4);
  border-top: 1px solid var(--divider);
}

/* Load step ---------------------------------------------------------------- */

.panel-load > h2 {
  margin-bottom: var(--s-4);
}

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-8);
  background: var(--surface-sunken);
  border: 2px dashed var(--control-border);
  border-radius: var(--r-panel);
  text-align: center;
  transition: border-color var(--motion) ease, background var(--motion) ease;
}

.dropzone-active {
  border-color: var(--accent);
  background: var(--info-bg);
}

.dropzone p {
  color: var(--ink-2);
}

.dropzone-icon {
  color: var(--accent);
}

/*
 * Prose block, not a grid: a heading, its list and a trailing note belong
 * together. Side-by-side groups opt in with `.notes-columns` and wrap each
 * group in `.notes-group`.
 */
.notes {
  margin-top: var(--s-6);
  padding-top: var(--s-4);
  border-top: 1px solid var(--divider);
  max-width: 96ch;
}

.notes-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--s-6);
  max-width: none;
}

.notes-group > :first-child {
  margin-top: 0;
}

.notes h3 {
  margin-bottom: var(--s-2);
}

.notes ul,
.notes ol {
  margin: 0;
  padding-left: var(--s-4);
  color: var(--ink-2);
}

.notes li {
  margin: var(--s-1) 0;
}

/* Pattern form ------------------------------------------------------------- */

.presets {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  margin-bottom: var(--s-4);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--s-4);
}

.toggles {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-4) var(--s-6);
  margin: var(--s-4) 0;
}

.toggles label,
.toggle-inline {
  flex-direction: row;
  align-items: center;
  gap: var(--s-2);
  font-weight: 400;
}

.toggle-inline {
  display: flex;
  margin: var(--s-3) 0;
}

.preview-pattern {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2);
  margin: var(--s-4) 0 var(--s-2);
  color: var(--ink-2);
}

.preview-pattern code {
  padding: var(--s-1) var(--s-2);
  background: var(--surface-sunken);
  border: 1px solid var(--divider);
  border-radius: var(--r-control);
  color: var(--ink);
  font-size: var(--fs-14);
}

details {
  margin: var(--s-2) 0;
}

/* Keep the native disclosure marker: `display: inline-flex` would remove it. */
summary {
  color: var(--ink-2);
  cursor: pointer;
  padding: var(--s-1) 0;
  font-weight: 600;
}

summary:hover {
  color: var(--ink);
}

details pre {
  margin: var(--s-2) 0 0;
  padding: var(--s-3);
  background: var(--surface-sunken);
  border: 1px solid var(--divider);
  border-radius: var(--r-control);
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
  font-size: var(--fs-12);
}

.errors {
  margin: var(--s-3) 0 0;
  padding: var(--s-3) var(--s-4) var(--s-3) var(--s-6);
  background: var(--error-bg);
  border: 1px solid var(--error);
  border-radius: var(--r-control);
  color: var(--error);
}

.errors li {
  margin: var(--s-1) 0;
}

/* Calibration -------------------------------------------------------------- */

/*
 * A narrow readable form beside the document it describes. Shared by the
 * pattern and calibration steps; both stack below 1024px.
 */
.step-split,
.calibration {
  display: grid;
  grid-template-columns: minmax(340px, 1fr) auto;
  gap: var(--s-6);
  align-items: start;
}

/* Read-only page browser next to the pattern form. */
.page-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2);
  margin-bottom: var(--s-3);
}

.page-nav button {
  min-width: var(--h-control);
  padding: 0 var(--s-3);
}

.page-nav-readout {
  font-size: var(--fs-12);
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}

.offset-row {
  display: flex;
  align-items: flex-end;
  gap: var(--s-2);
}

.offset-row button {
  width: var(--h-control);
  padding: 0;
  font-size: var(--fs-16);
}

fieldset {
  margin: var(--s-4) 0;
  padding: var(--s-3) var(--s-4) var(--s-4);
  border: 1px solid var(--divider);
  border-radius: var(--r-panel);
}

legend {
  padding: 0 var(--s-2);
  color: var(--ink-2);
  font-size: var(--fs-12);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.sample-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--s-3);
}

.mapping {
  margin: var(--s-3) 0;
  color: var(--ink-2);
}

/* Printed vs physical explainer: the core distinction of this step. */
.mapping-example {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-3);
  margin: var(--s-3) 0;
  padding: var(--s-3) var(--s-4);
  background: var(--surface-sunken);
  border: 1px solid var(--divider);
  border-radius: var(--r-panel);
}

.mapping-example dl {
  display: flex;
  align-items: baseline;
  gap: var(--s-2);
  margin: 0;
}

.mapping-example dt {
  color: var(--ink-2);
  font-size: var(--fs-12);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.mapping-example dd {
  margin: 0;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--fs-16);
  font-weight: 600;
}

.mapping-arrow {
  color: var(--ink-2);
  flex: none;
}

.suggestion {
  padding: var(--s-3) var(--s-4);
  background: var(--surface-sunken);
  border: 1px solid var(--divider);
  border-radius: var(--r-panel);
}

.suggestion .hint {
  margin: var(--s-2) 0 0;
}

.mapping-status {
  margin-top: var(--s-4);
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}

.warn {
  color: var(--warning-text);
  background: var(--warning-bg);
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-control);
}

.ok {
  color: var(--success);
}

/* Page previews ------------------------------------------------------------ */

.preview {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  min-width: 0;
}

.preview-label {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  font-size: var(--fs-12);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.preview-label .icon {
  color: var(--accent);
}

.preview-frame {
  position: relative;
  display: inline-block;
  background: var(--surface);
  border: 1px solid var(--control-border);
  border-radius: var(--r-control);
  overflow: hidden;
  min-width: 80px;
  min-height: 60px;
  align-self: flex-start;
}

.preview-canvas {
  display: block;
}

.preview-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s-2);
  background: rgba(244, 245, 248, 0.92);
  color: var(--ink-2);
  font-size: var(--fs-12);
  text-align: center;
}

.preview-error {
  color: var(--error);
}

figcaption {
  max-width: 360px;
  color: var(--ink-2);
  font-size: var(--fs-12);
}

/* Review ------------------------------------------------------------------- */

.review-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-3);
  align-items: center;
  justify-content: space-between;
  padding-bottom: var(--s-3);
  margin-bottom: var(--s-4);
  border-bottom: 1px solid var(--divider);
}

.filters,
.counts,
.bulk {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  align-items: center;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  padding: 2px var(--s-2);
  background: var(--surface-sunken);
  border: 1px solid var(--divider);
  border-radius: 999px;
  color: var(--ink-2);
  font-size: var(--fs-12);
  font-weight: 600;
  white-space: nowrap;
}

.badge-approved {
  background: var(--success-bg);
  border-color: var(--success);
  color: var(--success);
}

.badge-rejected {
  color: var(--ink-2);
}

.badge-pending {
  border-color: var(--control-border);
  color: var(--ink);
}

.badge-blocked,
.badge-issue {
  background: var(--warning-bg);
  border-color: var(--warning-text);
  color: var(--warning-text);
}

.badge-existing {
  background: var(--info-bg);
  border-color: var(--accent);
  color: var(--accent);
}

.review-body {
  display: grid;
  grid-template-columns: var(--list-width) minmax(0, 1fr);
  gap: var(--s-6);
  align-items: start;
}

.candidate-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 620px;
  overflow-y: auto;
  border: 1px solid var(--divider);
  border-radius: var(--r-panel);
  background: var(--surface);
}

.candidate-list > li + li {
  border-top: 1px solid var(--divider);
}

.candidate-row {
  display: flex;
  flex-direction: column;
}

.candidate-row-selected {
  background: var(--info-bg);
  box-shadow: inset 3px 0 0 var(--accent);
}

.candidate {
  width: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
  padding: var(--s-3) var(--s-3) var(--s-2);
  background: transparent;
  border: 0;
  border-radius: 0;
  color: var(--ink);
  font-weight: 400;
  text-align: left;
  cursor: pointer;
}

/*
 * These beat the generic `button:hover` rule on specificity. Without that the
 * row would take the accent background while keeping ink-coloured text.
 */
.candidate:hover:not(:disabled) {
  background: var(--surface-sunken);
  border-color: transparent;
  color: var(--ink);
}

.candidate-row-selected .candidate:hover:not(:disabled) {
  background: transparent;
}

.candidate-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
}

.candidate-text {
  font-size: var(--fs-14);
  font-weight: 600;
  font-family: var(--font-mono);
  overflow-wrap: anywhere;
}

/* Three named facts per candidate: what was found, what it says, where it goes. */
.candidate-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
  gap: 2px var(--s-2);
  margin-top: var(--s-1);
}

.candidate-fact {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.candidate-fact-label {
  color: var(--ink-2);
  font-size: var(--fs-12);
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1.3;
  text-transform: uppercase;
}

.candidate-fact-value {
  font-size: var(--fs-14);
  font-weight: 600;
}

.candidate-fact-value.is-unresolved {
  color: var(--warning-text);
}

.candidate-flags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-1);
}

.candidate-actions {
  display: flex;
  gap: var(--s-2);
  padding: 0 var(--s-3) var(--s-3);
}

.candidate-actions button {
  min-height: var(--h-control);
  flex: 1 1 auto;
  padding: 0 var(--s-3);
  font-size: var(--fs-14);
}

.candidate-actions .is-current,
.candidate-actions .is-current:hover:not(:disabled) {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

.candidate-actions .is-current:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.candidate-detail {
  min-width: 0;
  padding: var(--s-4);
  border: 1px solid var(--divider);
  border-radius: var(--r-panel);
  background: var(--surface);
}

.detail-head h3 {
  margin-bottom: var(--s-2);
  font-family: var(--font-mono);
}

.detail-facts {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2) var(--s-6);
  margin-bottom: var(--s-3);
}

.context {
  margin: var(--s-3) 0;
  padding: var(--s-3);
  background: var(--surface-sunken);
  border: 1px solid var(--divider);
  border-radius: var(--r-control);
  color: var(--ink-2);
  font-family: var(--font-mono);
  font-size: var(--fs-12);
}

.context mark {
  padding: 0 2px;
  background: #fde68a;
  color: var(--ink);
  border-radius: 3px;
}

.issues {
  margin: var(--s-3) 0;
  padding: var(--s-3) var(--s-4) var(--s-3) var(--s-6);
  background: var(--warning-bg);
  border: 1px solid var(--warning-text);
  border-radius: var(--r-control);
  color: var(--warning-text);
}

/* Paired evidence: source and destination side by side above 1280px. */
.detail-previews {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s-4);
  margin-top: var(--s-4);
  padding-top: var(--s-4);
  border-top: 1px solid var(--divider);
}

.empty {
  color: var(--ink-2);
  padding: var(--s-4);
}

.destination-missing {
  max-width: 340px;
  align-self: start;
  background: var(--warning-bg);
  border: 1px solid var(--warning-text);
  border-radius: var(--r-control);
  color: var(--warning-text);
}

/* Export ------------------------------------------------------------------- */

.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--s-3);
  margin: 0 0 var(--s-4);
}

.facts > div {
  padding: var(--s-3);
  background: var(--surface-sunken);
  border: 1px solid var(--divider);
  border-radius: var(--r-control);
}

.facts dt {
  color: var(--ink-2);
  font-size: var(--fs-12);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.facts dd {
  margin: var(--s-1) 0 0;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.facts dd.mono {
  font-size: var(--fs-12);
  font-weight: 400;
}

.report {
  margin-top: var(--s-4);
  padding: var(--s-3) var(--s-4);
  background: var(--success-bg);
  border: 1px solid var(--success);
  border-radius: var(--r-panel);
}

.report h3 {
  color: var(--success);
}

.report ul {
  margin: var(--s-2) 0 0;
  padding-left: var(--s-4);
  color: var(--ink-2);
}

.report .warn {
  background: transparent;
  padding: 0;
}

/* Footer ------------------------------------------------------------------- */

.app-footer {
  margin-top: var(--s-6);
  padding-top: var(--s-3);
  border-top: 1px solid var(--divider);
  color: var(--ink-2);
  font-size: var(--fs-12);
}

/* Icons -------------------------------------------------------------------- */

.icon {
  flex: none;
  vertical-align: -0.125em;
}

/* Responsive --------------------------------------------------------------- */

/* Between 1024 and 1279: keep the list beside the detail, stack the previews. */
@media (max-width: 1279px) {
  .detail-previews {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 1023px) {
  body {
    padding: var(--s-4) var(--s-4) var(--s-6);
  }

  .review-body,
  .step-split,
  .calibration {
    grid-template-columns: minmax(0, 1fr);
  }

  .candidate-list {
    max-height: 340px;
  }

  .preview-frame {
    align-self: center;
  }
}

@media (max-width: 900px) {
  .notes-columns {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--s-4);
  }
}

/* Narrow reflow and touch targets. */
@media (max-width: 767px) {
  :root {
    --h-control: 44px;
  }

  body {
    padding: var(--s-3) var(--s-3) var(--s-6);
  }

  html,
  body,
  label,
  input[type="text"],
  input[type="number"] {
    font-size: var(--fs-16);
  }

  .panel {
    padding: var(--s-4);
  }

  .app-header {
    align-items: flex-start;
  }

  .steps {
    flex-direction: column;
  }

  .step {
    justify-content: flex-start;
    width: 100%;
  }

  .review-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

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

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