:root {
  color-scheme: light dark;
  --bg: #f7f7f5;
  --surface: #ffffff;
  --text: #1c1c1e;
  --text-muted: #5b5b5f;
  --border: #dcdcd8;
  --accent: #3b5bdb;
  --accent-contrast: #ffffff;
  --danger: #c92a2a;
  --danger-bg: #fff0f0;
  --radius: 0.6rem;
  --max-width: 46rem;
  --focus-ring: 3px solid #3b5bdb80;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17181c;
    --surface: #202127;
    --text: #eceef1;
    --text-muted: #a6a8b0;
    --border: #34363d;
    --accent: #7c93ff;
    --accent-contrast: #12141a;
    --danger: #ff8787;
    --danger-bg: #3a1f1f;
    --focus-ring: 3px solid #7c93ff80;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 1rem/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-reduced-motion: no-preference) {
  a, button { transition: background-color .15s ease, border-color .15s ease, color .15s ease; }
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: var(--accent-contrast);
  padding: 0.6em 1em;
  z-index: 100;
}
.skip-link:focus { left: 0.5rem; top: 0.5rem; border-radius: var(--radius); }

a { color: var(--accent); }
a:focus-visible, button:focus-visible, input:focus-visible, [tabindex]:focus-visible {
  outline: var(--focus-ring);
  outline-offset: 2px;
}

.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.site-header__inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1rem clamp(1rem, 4vw, 1.5rem);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.site-title {
  font-weight: 700;
  font-size: 1.1rem;
  text-decoration: none;
  color: var(--text);
}
.site-nav a { font-size: 0.9rem; text-decoration: none; }
.site-nav a:hover { text-decoration: underline; }

main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: clamp(1rem, 4vw, 2rem) clamp(1rem, 4vw, 1.5rem) 4rem;
}

.site-footer {
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
  padding: 1.5rem 1rem 3rem;
}

h1 { font-size: clamp(1.4rem, 4vw, 1.9rem); line-height: 1.25; margin: 0 0 0.75rem; }
h2 { font-size: clamp(1.15rem, 3vw, 1.4rem); margin: 2rem 0 0.75rem; }
h3 { font-size: 1.05rem; margin: 1.25rem 0 0.5rem; }
p { margin: 0 0 1rem; }
.lede { color: var(--text-muted); font-size: 1.05rem; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}
.card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-decoration: none;
  color: var(--text);
}
.card:hover { border-color: var(--accent); }
.card h2 { margin-top: 0; }
.card__meta {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 0.75rem;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: clamp(1.25rem, 4vw, 2rem);
}

.notice {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin: 1.25rem 0;
  font-size: 0.95rem;
}
.notice--muted { border-left-color: var(--text-muted); }

.field { margin-bottom: 1.25rem; }
.field label, .field legend {
  display: block;
  font-weight: 600;
  margin-bottom: 0.4rem;
  padding: 0;
}
.field input[type="number"] {
  width: 100%;
  max-width: 12rem;
  font-size: 1rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
}
.field fieldset { border: none; padding: 0; margin: 0; }
.hint { color: var(--text-muted); font-size: 0.85rem; margin-top: 0.35rem; }
.error-text { color: var(--danger); font-size: 0.85rem; margin-top: 0.35rem; }
.field--error input { border-color: var(--danger); }

.radio-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
}
.radio-row:last-child { border-bottom: none; }
.radio-row input[type="radio"] { width: 1.15rem; height: 1.15rem; }
.radio-row label { font-weight: 400; margin: 0; flex: 1; cursor: pointer; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 44px;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius);
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-contrast);
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { filter: brightness(1.08); }
.btn--secondary {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn--danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger);
}
.btn[disabled], .btn[aria-disabled="true"] {
  opacity: 0.5;
  pointer-events: none;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.5rem;
}
.btn-row--center { justify-content: center; }

.progress-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}
progress {
  flex: 1;
  height: 0.6rem;
  border-radius: 1rem;
  overflow: hidden;
  accent-color: var(--accent);
}
progress::-webkit-progress-bar { background: var(--border); border-radius: 1rem; }
progress::-webkit-progress-value { background: var(--accent); border-radius: 1rem; }

.item-text {
  font-size: clamp(1.15rem, 3.5vw, 1.4rem);
  font-weight: 600;
  margin: 0.5rem 0 1.5rem;
}

.recap-list { list-style: none; margin: 1rem 0; padding: 0; }
.recap-row {
  display: flex;
  gap: 0.75rem;
  align-items: baseline;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
}
.recap-row__num { color: var(--text-muted); width: 2.5rem; flex-shrink: 0; }
.recap-row__text { flex: 1; }
.recap-row__answer { color: var(--text-muted); text-align: right; white-space: nowrap; }
.recap-row__answer--missing { color: var(--danger); }
.recap-row a { text-decoration: none; }
.recap-row a:hover { text-decoration: underline; }

.bar-row { margin: 1rem 0 1.5rem; }
.bar-row__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.35rem;
  gap: 0.5rem;
}
.bar-row__label { font-weight: 600; }
.bar-row__value { color: var(--text-muted); font-size: 0.9rem; white-space: nowrap; }
.bar-track {
  height: 0.7rem;
  background: var(--border);
  border-radius: 1rem;
  overflow: hidden;
}
.bar-fill { height: 100%; background: var(--accent); border-radius: 1rem; }

.facet-row { margin: 0.85rem 0; }
.facet-row .bar-track { height: 0.45rem; }
.facet-row__title { font-weight: 600; font-size: 0.95rem; }
.facet-row__text { font-size: 0.88rem; color: var(--text-muted); margin: 0.3rem 0 0; }

.domain-block {
  border-top: 1px solid var(--border);
  padding-top: 1.75rem;
  margin-top: 1.75rem;
}
.domain-block__title { display: flex; align-items: baseline; gap: 0.6rem; flex-wrap: wrap; }
.badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.15rem 0.55rem;
  border-radius: 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

table.export-preview { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
table.export-preview th, table.export-preview td {
  text-align: left;
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid var(--border);
}

.error-page { text-align: center; padding: 3rem 1rem; }
.error-page .code { font-size: 3rem; font-weight: 800; color: var(--text-muted); margin: 0; }

/* Percentile-width utility classes (0-100), used instead of inline styles so the
   CSP can ship with no 'unsafe-inline' and no per-request nonce. */
.pct-0 { width: 0%; }
.pct-1 { width: 1%; }
.pct-2 { width: 2%; }
.pct-3 { width: 3%; }
.pct-4 { width: 4%; }
.pct-5 { width: 5%; }
.pct-6 { width: 6%; }
.pct-7 { width: 7%; }
.pct-8 { width: 8%; }
.pct-9 { width: 9%; }
.pct-10 { width: 10%; }
.pct-11 { width: 11%; }
.pct-12 { width: 12%; }
.pct-13 { width: 13%; }
.pct-14 { width: 14%; }
.pct-15 { width: 15%; }
.pct-16 { width: 16%; }
.pct-17 { width: 17%; }
.pct-18 { width: 18%; }
.pct-19 { width: 19%; }
.pct-20 { width: 20%; }
.pct-21 { width: 21%; }
.pct-22 { width: 22%; }
.pct-23 { width: 23%; }
.pct-24 { width: 24%; }
.pct-25 { width: 25%; }
.pct-26 { width: 26%; }
.pct-27 { width: 27%; }
.pct-28 { width: 28%; }
.pct-29 { width: 29%; }
.pct-30 { width: 30%; }
.pct-31 { width: 31%; }
.pct-32 { width: 32%; }
.pct-33 { width: 33%; }
.pct-34 { width: 34%; }
.pct-35 { width: 35%; }
.pct-36 { width: 36%; }
.pct-37 { width: 37%; }
.pct-38 { width: 38%; }
.pct-39 { width: 39%; }
.pct-40 { width: 40%; }
.pct-41 { width: 41%; }
.pct-42 { width: 42%; }
.pct-43 { width: 43%; }
.pct-44 { width: 44%; }
.pct-45 { width: 45%; }
.pct-46 { width: 46%; }
.pct-47 { width: 47%; }
.pct-48 { width: 48%; }
.pct-49 { width: 49%; }
.pct-50 { width: 50%; }
.pct-51 { width: 51%; }
.pct-52 { width: 52%; }
.pct-53 { width: 53%; }
.pct-54 { width: 54%; }
.pct-55 { width: 55%; }
.pct-56 { width: 56%; }
.pct-57 { width: 57%; }
.pct-58 { width: 58%; }
.pct-59 { width: 59%; }
.pct-60 { width: 60%; }
.pct-61 { width: 61%; }
.pct-62 { width: 62%; }
.pct-63 { width: 63%; }
.pct-64 { width: 64%; }
.pct-65 { width: 65%; }
.pct-66 { width: 66%; }
.pct-67 { width: 67%; }
.pct-68 { width: 68%; }
.pct-69 { width: 69%; }
.pct-70 { width: 70%; }
.pct-71 { width: 71%; }
.pct-72 { width: 72%; }
.pct-73 { width: 73%; }
.pct-74 { width: 74%; }
.pct-75 { width: 75%; }
.pct-76 { width: 76%; }
.pct-77 { width: 77%; }
.pct-78 { width: 78%; }
.pct-79 { width: 79%; }
.pct-80 { width: 80%; }
.pct-81 { width: 81%; }
.pct-82 { width: 82%; }
.pct-83 { width: 83%; }
.pct-84 { width: 84%; }
.pct-85 { width: 85%; }
.pct-86 { width: 86%; }
.pct-87 { width: 87%; }
.pct-88 { width: 88%; }
.pct-89 { width: 89%; }
.pct-90 { width: 90%; }
.pct-91 { width: 91%; }
.pct-92 { width: 92%; }
.pct-93 { width: 93%; }
.pct-94 { width: 94%; }
.pct-95 { width: 95%; }
.pct-96 { width: 96%; }
.pct-97 { width: 97%; }
.pct-98 { width: 98%; }
.pct-99 { width: 99%; }
.pct-100 { width: 100%; }

@media print {
  .site-header, .site-footer, .btn-row, .no-print { display: none !important; }
  body { background: #fff; color: #000; }
  .panel, .domain-block { border-color: #ccc !important; }
  main { max-width: none; padding: 0; }
}
