:root {
  --fg: #1a1a1a;
  --bg: #ffffff;
  --muted: #4a4a4a;
  --muted-bg: #f4f5f7;
  --accent: #1746b8;
  --accent-fg: #ffffff;
  --accent-hover: #102f7e;
  --border: #c8c8d0;
  --border-strong: #8a8a92;
  --danger: #a51c1c;
  --danger-bg: #fdecec;
  --focus: #ffbf00;
  --radius: 6px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 2px 6px rgba(0, 0, 0, 0.08);
  --page-max: 920px;
  --content-max: 720px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 1rem;
  color: var(--fg);
  background: var(--bg);
  line-height: 1.55;
}

h1, h2, h3 { line-height: 1.25; }
h2 { font-size: 1.5rem; margin: 0 0 0.75rem; }
h3 { font-size: 1.125rem; margin: 0 0 0.5rem; }
p { margin: 0 0 0.75rem; }

a { color: var(--accent); }
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* Skip link --------------------------------------------------------------- */

.skip-link {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}
.skip-link:focus,
.skip-link:focus-visible {
  position: static;
  width: auto;
  height: auto;
  display: inline-block;
  margin: 0.5rem 1rem;
  padding: 0.5rem 1rem;
  background: #000;
  color: #fff;
  text-decoration: none;
  border-radius: var(--radius);
}

/* Layout ------------------------------------------------------------------ */

.site-header,
.site-main,
.site-footer {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 1rem 1.25rem;
}

.site-header {
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}

.site-title {
  font-size: 1.125rem;
  font-weight: 600;
  margin: 0;
  color: var(--muted);
}

.site-main { padding-bottom: 2.5rem; }

.site-footer {
  color: var(--muted);
  font-size: 0.875rem;
  border-top: 1px solid var(--border);
  margin-top: 2rem;
}

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

.page > section + section { margin-top: 1.5rem; }

/* Buttons ----------------------------------------------------------------- */

.btn {
  display: inline-block;
  padding: 0.65rem 1.15rem;
  background: var(--accent);
  color: var(--accent-fg);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  font: inherit;
  font-weight: 600;
  min-height: 2.75rem;
  line-height: 1.2;
}
.btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-secondary {
  background: transparent;
  color: var(--accent);
}
.btn-secondary:hover { background: rgba(23, 70, 184, 0.07); }

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1rem;
}

/* Forms ------------------------------------------------------------------- */

.form { margin: 0; }

.form-field {
  margin: 0 0 1.25rem;
}

.form-field > label,
.form-field > .field-label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.form-field input[type="text"],
.form-field input[type="number"],
.form-field input[type="email"],
.form-field textarea,
.form-field select {
  width: 100%;
  padding: 0.55rem 0.7rem;
  font: inherit;
  color: inherit;
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  min-height: 2.75rem;
}

.form-field textarea { min-height: 6rem; resize: vertical; }

.form-field .help {
  display: block;
  color: var(--muted);
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

.form-field .field-errors {
  list-style: none;
  margin: 0.35rem 0 0;
  padding: 0;
  color: var(--danger);
  font-size: 0.9rem;
}

.form-field.has-error input,
.form-field.has-error textarea,
.form-field.has-error select {
  border-color: var(--danger);
  background: var(--danger-bg);
}

.form-field fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem 0.5rem;
  margin: 0;
}

.form-field fieldset legend {
  font-weight: 600;
  padding: 0 0.25rem;
}

.choices {
  list-style: none;
  padding: 0;
  margin: 0.25rem 0 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.choices li label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0;
  font-weight: 400;
  cursor: pointer;
}

.choices input[type="radio"],
.choices input[type="checkbox"] {
  width: 1.1rem;
  height: 1.1rem;
}

.error-summary {
  border: 1px solid var(--danger);
  background: var(--danger-bg);
  color: var(--danger);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin: 0 0 1.25rem;
}

.error-summary h2 {
  font-size: 1rem;
  margin: 0 0 0.5rem;
}

.error-summary ul { margin: 0; padding-left: 1.25rem; }

.error-summary a { color: var(--danger); }

/* Cards ------------------------------------------------------------------- */

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.card + .card { margin-top: 1rem; }

/* Pairwise survey --------------------------------------------------------- */

.progress {
  display: inline-block;
  background: var(--muted-bg);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.875rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  margin: 0 0 0.75rem;
}

.survey-question .question-text {
  font-size: 1.15rem;
  font-weight: 500;
  margin: 0 0 1.25rem;
}

.pairwise fieldset {
  border: 0;
  padding: 0;
  margin: 0;
}

.options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  align-items: stretch;
}

.option-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1rem 1.25rem;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.option-card[data-side="left"],
.option-card[data-side="right"] {
  /* No visual bias between sides: identical styling. */
}

.option-card .option-label {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0 0 0.5rem;
}

.option-card .rates {
  margin: 0.75rem 0 1rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem 1rem;
}

.option-card .rates .rate { margin: 0; }

.option-card .rates dt {
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-weight: 600;
}

.option-card .rates dd {
  margin: 0.1rem 0 0;
  font-variant-numeric: tabular-nums;
  font-size: 1.1rem;
  font-weight: 600;
}

.option-card .btn-choose {
  margin-top: auto;
  width: 100%;
}

/* Pictograph -------------------------------------------------------------- */

.plot {
  /* Negative horizontal margin cancels most of the card's 1rem side padding so
     the pictograph can grow wider. */
  margin: 0 0.3rem 0.75rem;
  text-align: center;
}
/* Caption shown before each pictograph_people_100 figure. Left-aligned for
   readability, overriding the figure's centered images. */
.plot .plot-caption {
  text-align: left;
  margin: 0.5rem 0 0.25rem;
}
/* Responsive image: scales the 160px source up to fill the available card
     width, never overflows, and scales down on narrow screens. */
.plot .plot-img {
  width: 100%;
  max-width: 100%;
  height: auto;
}
/* Text fallback for unsupported / unavailable plot types. */
.plot.plot-fallback {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 0.75rem;
  background: var(--muted-bg);
}
.plot .plot-body {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85rem;
  color: var(--muted);
  padding: 1rem 0.5rem;
}

/* Survey error page ------------------------------------------------------- */

.survey-error {
  border: 1px solid var(--border);
  border-left: 4px solid var(--danger);
  background: #fff;
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
}

/* Utilities --------------------------------------------------------------- */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.text-muted { color: var(--muted); }

/* Validation plot --------------------------------------------------------- */

.validation-figure { margin: 0 0 1rem; }

.validation-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.25rem;
  margin-bottom: 1.25rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.validation-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.8125rem;
}

.validation-legend-item svg {
  width: 20px;
  height: 20px;
}

.validation-svg {
  width: 100%;
  height: auto;
  display: block;
}

/* Align the slider track with the plot's x-axis: the axis spans viewBox
   x=28..1072 of W=1100, i.e. 2.545% insets on each side of the full-width SVG. */
.validation-plot .form-field > label {
  text-align: center;
}

.form-field input[type="range"][data-validation-slider] {
  display: block;
  box-sizing: border-box;
  width: calc(100% - 5.09%);
  margin: 0 2.545%;
}

.validation-threshold-display {
  margin-left: 2.545%;
  font-weight: 600;
}

.validation-metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin: 1rem 0;
}

.validation-metric {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
}

.validation-metric-title { margin: 0; font-size: 0.875rem; color: var(--muted); }
.validation-metric-value { margin: 0.25rem 0; font-size: 1.5rem; font-weight: 700; }
.validation-metric-rate { margin: 0; font-size: 0.875rem; color: var(--muted); }

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

@media (max-width: 640px) {
  body { font-size: 1.0625rem; }
  .options { grid-template-columns: 1fr; }
  .option-card .rates { grid-template-columns: 1fr 1fr; }
  .btn { width: 100%; }
  .btn-row .btn { width: 100%; }
  .validation-metrics { grid-template-columns: 1fr 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
