:root {
  --ink: #000000;
  --paper: #ffffff;
  --wash: #f3f8f5;
  --leaf: #0d5f4f;
  --leaf-dark: #063f34;
  --sage: #dcece6;
  --gold: #d59c26;
  --gold-wash: #fff5d8;
  --line: #9bb0a8;
  --danger: #8b1e14;
  --shadow: 0 22px 62px rgba(0, 0, 0, 0.12);
  --focus: 0 0 0 4px rgba(13, 95, 79, 0.26);
}

:root[data-theme="inverted"] {
  --ink: #ffffff;
  --paper: #000000;
  --wash: #111b18;
  --leaf: #6ed4bb;
  --leaf-dark: #d8fff4;
  --sage: #163d34;
  --gold: #ffd36b;
  --gold-wash: #322812;
  --line: #8aa098;
  --danger: #ff978b;
  --shadow: 0 22px 62px rgba(0, 0, 0, 0.7);
  --focus: 0 0 0 4px rgba(110, 212, 187, 0.35);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 6%, color-mix(in srgb, var(--sage) 75%, transparent), transparent 31rem),
    linear-gradient(145deg, var(--wash), var(--paper) 56%, color-mix(in srgb, var(--gold-wash) 72%, var(--paper)));
  font-family: "Atkinson Hyperlegible Next", "Atkinson Hyperlegible", Arial, Helvetica, sans-serif;
  font-size: 18px;
  line-height: 1.55;
}

button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
a { color: var(--leaf-dark); }
.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; }

.skip-link {
  position: fixed;
  z-index: 50;
  top: 10px;
  left: 10px;
  transform: translateY(-180%);
  padding: 10px 14px;
  border: 2px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
}
.skip-link:focus { transform: translateY(0); }

.prototype-banner {
  padding: 11px 24px;
  border-bottom: 2px solid var(--gold);
  background: var(--gold-wash);
  color: var(--ink);
  text-align: center;
  font-size: 0.9rem;
}

.site-header {
  max-width: 1280px;
  margin: 0 auto;
  padding: 22px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  color: var(--ink);
  text-decoration: none;
}
.brand-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--leaf-dark);
  color: var(--paper);
  font-size: 1.7rem;
  font-weight: 800;
}
.brand b, .brand small { display: block; }
.brand small { font-size: 0.82rem; }

.header-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 9px; }

.app-shell {
  width: min(1280px, calc(100% - 40px));
  margin: 0 auto 44px;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}

.progress-panel {
  position: sticky;
  top: 18px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  box-shadow: 0 12px 38px rgba(0, 0, 0, 0.08);
}

.progress-summary { display: flex; justify-content: space-between; gap: 12px; font-size: 0.86rem; }
.progress-track { height: 9px; margin: 10px 0 12px; overflow: hidden; border-radius: 99px; background: var(--sage); }
.progress-track span { display: block; width: 0; height: 100%; background: var(--leaf-dark); transition: width 180ms ease; }
.progress-time { margin: 0 0 18px; font-size: 0.8rem; }

.section-nav { list-style: none; padding: 0; margin: 0; display: grid; gap: 5px; }
.section-nav button {
  width: 100%;
  min-height: 46px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--ink);
  text-align: left;
}
.section-nav button[aria-current="step"] { border-color: var(--line); background: var(--sage); font-weight: 800; }
.nav-number { width: 28px; height: 28px; flex: 0 0 auto; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; font-size: 0.78rem; }
.nav-number.nav-start { width: 46px; border-radius: 999px; font-size: 0.68rem; text-transform: uppercase; }
.section-nav button[aria-current="step"] .nav-number { background: var(--leaf-dark); color: var(--paper); }
.nav-check { margin-left: auto; font-weight: 800; }

.local-note { margin-top: 20px; padding: 14px; border-left: 4px solid var(--gold); background: var(--gold-wash); font-size: 0.76rem; }
.local-note b, .local-note span { display: block; }

.questionnaire-card {
  min-height: 760px;
  padding: clamp(28px, 5vw, 60px);
  border: 1px solid color-mix(in srgb, var(--line) 65%, transparent);
  border-radius: 28px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.status-message { min-height: 1.4rem; color: var(--leaf-dark); font-weight: 700; font-size: 0.86rem; }
.eyebrow { margin-bottom: 7px; color: var(--leaf-dark); font-size: 0.78rem; font-weight: 900; letter-spacing: 0.12em; text-transform: uppercase; }
h1, h2 { margin: 0; color: var(--ink); font-weight: 850; letter-spacing: -0.025em; line-height: 1.08; }
h1 { max-width: 760px; font-size: clamp(2.35rem, 6vw, 4.5rem); }
h2 { font-size: clamp(1.8rem, 4vw, 3rem); }
h3 { margin: 0; font-size: 1.15rem; }
.section-lead { max-width: 760px; margin: 16px 0 32px; font-size: 1.08rem; }

.question-group { margin: 34px 0 46px; padding-top: 28px; border-top: 1px solid var(--line); }
.question-group:first-of-type { padding-top: 0; border-top: 0; }
.question-group-header { max-width: 780px; margin-bottom: 22px; }
.question-group-header h3 { color: var(--leaf-dark); font-size: 1.35rem; }
.question-group-header p { margin: 7px 0 0; font-size: 0.92rem; }
.question-group .field:first-of-type { margin-top: 18px; }

.welcome-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 32px 0; }
.welcome-grid article { min-height: 150px; padding: 19px; border: 1px solid var(--line); border-radius: 18px; background: var(--wash); }
.welcome-grid b { display: block; margin-bottom: 7px; font-size: 1.05rem; }
.callout { padding: 18px 20px; border-left: 5px solid var(--gold); border-radius: 0 14px 14px 0; background: var(--gold-wash); }

.field { margin: 30px 0; scroll-margin-top: 24px; }
.field-label, legend { display: block; margin-bottom: 7px; font-weight: 850; font-size: 1.05rem; }
.field-code { display: inline-block; margin-left: 8px; color: var(--leaf-dark); font-family: ui-monospace, monospace; font-size: 0.68rem; font-weight: 700; vertical-align: 0.12em; }
.required-mark { color: var(--danger); }
.help { max-width: 760px; margin: 4px 0 11px; font-size: 0.86rem; }
.error { margin: 7px 0 0; color: var(--danger); font-weight: 800; font-size: 0.84rem; }

input[type="text"], input[type="number"], textarea, select {
  width: 100%;
  min-height: 52px;
  padding: 13px 15px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  color: var(--ink);
}
textarea { min-height: 122px; resize: vertical; }
input:focus-visible, textarea:focus-visible, select:focus-visible, button:focus-visible, summary:focus-visible { outline: 3px solid transparent; box-shadow: var(--focus); }
input[aria-invalid="true"], textarea[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--danger); }

fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.choice-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.choice-card {
  min-height: 78px;
  padding: 15px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  border: 2px solid var(--line);
  border-radius: 15px;
  background: var(--paper);
}
.choice-card:has(input:checked) { border-color: var(--leaf-dark); background: var(--sage); box-shadow: inset 0 0 0 1px var(--leaf-dark); }
.choice-card input { width: 22px; height: 22px; flex: 0 0 auto; margin-top: 2px; accent-color: var(--leaf-dark); }
.choice-card span { line-height: 1.35; }
.choice-card small { display: block; margin-top: 3px; font-size: 0.8rem; }
.choice-list { display: grid; gap: 9px; }
.choice-compact-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
.choice-compact-grid .choice-card { min-height: 48px; padding: 9px 12px; align-items: center; }
.choice-compact-grid .choice-card input { margin-top: 0; }
.option-groups { display: grid; gap: 24px; }
.option-group h4 { margin: 0 0 10px; color: var(--leaf-dark); font-size: 0.92rem; letter-spacing: 0.015em; }

details.advanced { margin: 26px 0; padding: 17px 18px; border: 2px solid var(--line); border-radius: 16px; background: var(--wash); }
details.advanced summary { color: var(--leaf-dark); font-weight: 900; }
details.advanced[open] summary { margin-bottom: 18px; }
.technical-grid { display: grid; grid-template-columns: 1fr; gap: 9px; }

.selection-count { margin: 10px 0; font-size: 0.82rem; font-weight: 800; }
.ranking-list { list-style: none; padding: 0; margin: 10px 0; display: grid; gap: 8px; }
.ranking-item { display: grid; grid-template-columns: 44px 34px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 12px; border: 2px solid var(--line); border-radius: 12px; background: var(--wash); transition: border-color 120ms ease, box-shadow 120ms ease, opacity 120ms ease; }
.ranking-item.is-dragging { opacity: 0.58; }
.ranking-item.is-drop-target { border-color: var(--leaf-dark); box-shadow: var(--focus); }
.rank-drag-handle { width: 44px; height: 44px; display: grid; place-items: center; border: 2px dashed var(--line); border-radius: 10px; background: var(--paper); color: var(--leaf-dark); cursor: grab; font-size: 1.45rem; font-weight: 900; line-height: 1; touch-action: none; user-select: none; }
.rank-drag-handle:active { cursor: grabbing; }
.rank-number { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; background: var(--leaf-dark); color: var(--paper); font-weight: 900; }
.rank-label { min-width: 0; font-weight: 750; }
.rank-actions { display: flex; gap: 5px; }
.rank-arrow { width: 48px; height: 48px; padding: 0; display: grid; place-items: center; border: 2px solid var(--leaf-dark); border-radius: 11px; background: var(--paper); color: var(--leaf-dark); font-size: 1.4rem; font-weight: 950; line-height: 1; }
.rank-arrow:disabled { opacity: 0.36; cursor: not-allowed; }

.button, .icon-button, .text-button {
  min-height: 44px;
  padding: 10px 15px;
  border-radius: 11px;
  font-weight: 850;
}
.button { border: 2px solid var(--leaf-dark); }
.button-primary { background: var(--leaf-dark); color: var(--paper); }
.button-secondary, .button-quiet { background: var(--paper); color: var(--ink); }
.button-accent { border-color: var(--gold); background: var(--gold-wash); color: var(--ink); }
.button:disabled { opacity: 0.45; cursor: not-allowed; }
.icon-button, .text-button { border: 1px solid var(--line); background: var(--paper); color: var(--ink); }
.text-button { min-height: 34px; padding: 5px 9px; font-size: 0.8rem; }

.upload-zone { padding: 20px; border: 2px dashed var(--line); border-radius: 16px; background: var(--wash); }
.upload-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.upload-actions .button { display: inline-flex; align-items: center; justify-content: center; min-height: 48px; cursor: pointer; }
.visually-hidden-file { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.file-list { list-style: none; padding: 0; margin: 13px 0 0; display: grid; gap: 7px; }
.file-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); font-size: 0.82rem; }

.repeatable-list { display: grid; gap: 12px; }
.repeatable-card { padding: 18px; border: 2px solid var(--line); border-radius: 16px; background: var(--wash); }
.repeatable-card header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 13px; }
.repeatable-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.repeatable-grid label { font-size: 0.83rem; font-weight: 800; }

.rating { display: flex; flex-wrap: wrap; gap: 8px; }
.rating label { position: relative; }
.rating input { position: absolute; opacity: 0; }
.rating span { width: 52px; height: 52px; display: grid; place-items: center; border: 2px solid var(--line); border-radius: 12px; background: var(--paper); font-weight: 900; }
.rating input:checked + span { border-color: var(--leaf-dark); background: var(--sage); }
.section-ratings { display: grid; gap: 10px; }
.section-rating-row { padding: 12px; display: grid; grid-template-columns: minmax(170px, 1fr) auto; align-items: center; gap: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--wash); }
.section-rating-row .rating span { width: 42px; height: 42px; }

.review-root { margin-top: 30px; }
.review-toolbar { display: flex; flex-wrap: wrap; gap: 9px; margin-bottom: 18px; }
.review-alert { padding: 15px 17px; border: 2px solid var(--danger); border-radius: 14px; }
.review-section { margin: 14px 0; padding: 18px; border: 1px solid var(--line); border-radius: 16px; background: var(--wash); }
.review-section-header { align-items: center; display: flex; gap: 16px; justify-content: space-between; }
.review-section-header h3 { margin-bottom: 0; }
.review-section dl { display: grid; grid-template-columns: minmax(170px, 0.35fr) 1fr; gap: 8px 18px; }
.review-section dt { font-weight: 850; }
.review-section dd { margin: 0; overflow-wrap: anywhere; }
.derived-card { border-left: 5px solid var(--leaf-dark); }

.form-actions { margin-top: 38px; padding-top: 24px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 14px; border-top: 1px solid var(--line); }
.form-actions .button:last-child { justify-self: end; }
.step-count { font-size: 0.82rem; font-weight: 800; text-align: center; }

.toc-dialog { width: min(820px, calc(100% - 24px)); max-height: min(86vh, 900px); padding: 0; border: 2px solid var(--ink); border-radius: 20px; background: var(--paper); color: var(--ink); box-shadow: var(--shadow); }
.toc-dialog::backdrop { background: rgba(0, 0, 0, 0.68); }
.dialog-header { position: sticky; top: 0; z-index: 1; padding: 20px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); background: var(--paper); }
.toc-groups { padding: 18px 22px 26px; display: grid; gap: 20px; }
.toc-groups ul { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 5px; }
.toc-groups button { width: 100%; padding: 9px 11px; border: 1px solid transparent; border-radius: 9px; background: transparent; color: var(--ink); text-align: left; }
.toc-groups button:hover { border-color: var(--line); background: var(--wash); }

@media (max-width: 940px) {
  .site-header { align-items: flex-start; }
  .app-shell { grid-template-columns: 1fr; width: min(100% - 24px, 760px); }
  .progress-panel { position: static; }
  .section-nav { grid-template-columns: repeat(5, 1fr); }
  .section-nav button { justify-content: center; }
  .section-nav .nav-label, .section-nav .nav-check { display: none; }
  .local-note { display: none; }
  .choice-compact-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
  body { font-size: 17px; }
  .prototype-banner { padding-inline: 14px; text-align: left; }
  .site-header { padding: 16px 14px; flex-direction: column; }
  .header-actions { justify-content: flex-start; }
  .app-shell { width: calc(100% - 16px); }
  .progress-panel { padding: 15px; }
  .questionnaire-card { min-height: 0; padding: 27px 18px; border-radius: 20px; }
  .welcome-grid, .choice-grid, .choice-compact-grid, .repeatable-grid { grid-template-columns: 1fr; }
  .section-nav { grid-template-columns: repeat(5, 1fr); }
  .section-nav button { min-height: 42px; padding: 5px; }
  .form-actions { grid-template-columns: 1fr 1fr; }
  .step-count { grid-column: 1 / -1; grid-row: 1; }
  .form-actions .button { grid-row: 2; }
  .review-section dl { grid-template-columns: 1fr; }
  .review-section dd { margin-bottom: 10px; }
  .section-rating-row { grid-template-columns: 1fr; }
  .ranking-item { grid-template-columns: 44px 34px minmax(0, 1fr); }
  .rank-actions { grid-column: 2 / 4; justify-content: flex-end; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
:root .consent-text { white-space: pre-wrap; overflow-wrap: anywhere; margin-bottom: 1.5rem; }
:root .consent-presentation { margin-block: 1.5rem; }
:root .receipt-capability { overflow-wrap: anywhere; user-select: all; }
html[data-trusted-server] .field-code { display: none; }
body > main.questionnaire-card { max-width: 70rem; margin: 2rem auto; }
body > main.questionnaire-card pre { white-space: pre-wrap; overflow-wrap: anywhere; }
