:root {
  font:
    16px/1.4 system-ui,
    sans-serif;
  color-scheme: light;
  --bg: #f2f7fb;
  --surface: #fff;
  --soft: #eaf3f8;
  --text: #174562;
  --muted: #496574;
  --border: #bfced9;
  --input-border: #718b9b;
  --primary: #174562;
  --on-primary: #fff;
  --accent: #2d94d2;
  --link: #175780;
  --error: #a32720;
  --notice: #fff6d6;
  --notice-text: #624d12;
  --notice-border: #a0801e;
  --focus: #906500;
  color: var(--text);
  background: var(--bg);
}
:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #101c26;
  --surface: #192b38;
  --soft: #223a4b;
  --text: #edf5fa;
  --muted: #b5cbd9;
  --border: #516b7d;
  --input-border: #7c96a8;
  --primary: #91d1f5;
  --on-primary: #102e43;
  --accent: #64bbed;
  --link: #91d1f5;
  --error: #ffb1aa;
  --notice: #3b321b;
  --notice-text: #ffe3a1;
  --notice-border: #d6b259;
  --focus: #ffd578;
}
/* Before the script sets the theme, a dark system already starts dark (Kuba 26.10). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --bg: #101c26;
    --surface: #192b38;
    --soft: #223a4b;
    --text: #edf5fa;
    --muted: #b5cbd9;
    --border: #516b7d;
    --input-border: #7c96a8;
    --primary: #91d1f5;
    --on-primary: #102e43;
    --accent: #64bbed;
    --link: #91d1f5;
    --error: #ffb1aa;
    --notice: #3b321b;
    --notice-text: #ffe3a1;
    --notice-border: #d6b259;
    --focus: #ffd578;
  }
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
button,
input,
select,
textarea {
  font: inherit;
}
button {
  cursor: pointer;
  background: var(--primary);
  color: var(--on-primary);
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 0.55rem 0.8rem;
  min-height: 44px;
}
button.secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--input-border);
}
button:disabled {
  background: var(--soft);
  color: var(--muted);
  border-color: var(--border);
  cursor: default;
}
a {
  color: var(--link);
}
header {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 6px 0;
  background: var(--surface);
  border-bottom: 4px solid var(--accent);
}
header h1 {
  font-size: 1.25rem;
  line-height: 1.2;
  margin: 0;
  flex: 1;
  min-width: 0;
  text-align: center;
  white-space: nowrap;
}
.title-mobile {
  display: none;
}
.jsfp-header h1 {
  white-space: normal;
  overflow-wrap: anywhere;
}
.header-inner {
  margin: 0 auto;
  padding: 0 clamp(12px, 2vw, 48px);
}
.header-top {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr) 140px;
  align-items: center;
  gap: 12px;
}
.header-center {
  min-width: 0;
  text-align: center;
  border-inline: 1px solid var(--border);
  padding: 0 12px;
}
.header-center .header-meta {
  font-size: 0.875rem;
}
.header-center .small,
.header-meta {
  margin: 0.2rem 0;
  overflow-wrap: anywhere;
}
.header-meta {
  font-size: 0.75rem;
  line-height: 1.3;
}
.brand-logo {
  display: block;
  width: 140px;
  max-width: 100%;
  height: auto;
  flex: none;
  background: #fff;
  padding: 4px;
  border-radius: 5px;
}
.header-tools {
  display: flex;
  align-items: center;
  flex: none;
  justify-self: end;
}
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 44px;
  padding: 6px;
  background: var(--soft);
  color: var(--text);
  border-color: var(--input-border);
  white-space: nowrap;
}
.theme-icon {
  display: flex;
}
.theme-icon svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.switch-track {
  width: 26px;
  height: 16px;
  border: 1px solid var(--input-border);
  border-radius: 20px;
  background: var(--surface);
  padding: 2px;
}
.switch-track span {
  display: block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary);
}
.theme-toggle[aria-checked='true'] .switch-track span {
  transform: translateX(10px);
}
main {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 1rem;
  margin: 0.75rem auto;
  padding: 0 clamp(12px, 2vw, 48px);
}
#content {
  min-width: 0;
}
#survey-sidebar,
#survey-tools {
  min-width: 0;
  align-self: start;
  position: sticky;
  top: calc(var(--survey-header-height, 8rem) + 1rem);
  max-height: calc(100dvh - var(--survey-header-height, 8rem) - 2rem);
  overflow: auto;
  padding: 3px;
}
nav {
  position: static;
}
nav button {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  margin-bottom: 0.4rem;
}
nav button[aria-current='step'] {
  background: var(--primary);
  color: var(--on-primary);
}
section.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  margin-bottom: 0.75rem;
}
section.panel p {
  overflow-wrap: anywhere;
  max-width: 80ch;
}
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.75rem 0;
}
fieldset {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin: 0.85rem 0;
  padding: 0.75rem;
  min-width: 0;
}
legend {
  font-weight: 650;
  padding: 0 0.4rem;
  max-width: min(100%, 80ch);
}
.hint {
  color: var(--muted);
  margin: 0.4rem 0;
  font-size: 0.875rem;
  line-height: 1.4;
}
.check {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  margin: 0.35rem 0;
  min-height: 28px;
}
.check input {
  width: auto;
  margin-top: 0.35rem;
}
label {
  display: block;
}
input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--input-border);
  border-radius: 5px;
  padding: 0.55rem;
  background: var(--bg);
  color: var(--text);
}
input[readonly],
textarea[readonly] {
  background: var(--surface);
}
input:disabled,
textarea:disabled,
select:disabled {
  background: var(--soft);
  color: var(--muted);
}
textarea {
  resize: vertical;
}
input[type='radio'],
input[type='checkbox'] {
  width: auto;
  accent-color: var(--primary);
}
.meta {
  margin-top: 0.6rem;
  padding-top: 0.4rem;
  border-top: 1px dashed var(--border);
}
.states {
  display: flex;
  gap: 0.2rem 1rem;
  flex-wrap: wrap;
}
.tableScroll {
  overflow: auto;
}
table {
  border-collapse: collapse;
  width: 100%;
  min-width: 520px;
}
th,
td {
  padding: 0.5rem;
  border: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}
th {
  background: var(--soft);
}
.tableScroll th,
.tableScroll td {
  min-width: 180px;
}
.tableScroll th:last-child,
.tableScroll td:last-child {
  min-width: 130px;
}
.issue,
#status.error {
  color: var(--error);
}
.issue {
  font-weight: 600;
}
.notice {
  padding: 0.8rem;
  background: var(--notice);
  color: var(--notice-text);
  border-left: 4px solid var(--notice-border);
}
.small {
  font-size: 0.9rem;
  color: var(--muted);
}
/* In the sticky header, so the survey's messages stay on screen on a phone too (Kuba 31.10). */
#status {
  margin: 6px 0 0;
  overflow-wrap: anywhere;
}
#status:empty {
  display: none;
}
details summary {
  cursor: pointer;
  font-weight: 600;
  padding: 0.4rem 0;
}
pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: var(--soft);
  padding: 1rem;
}
*:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}
.skip {
  position: absolute;
  left: -999px;
  top: 0.3rem;
  background: var(--surface);
  padding: 0.6rem;
  z-index: 3;
}
.skip:focus {
  left: 0.5rem;
}
.matrix {
  display: grid;
  gap: 0.8rem;
}
@media (max-width: 760px) {
  header {
    padding: 5px 0;
  }
  .header-inner {
    padding: 0 0.7rem;
  }
  .header-top {
    grid-template-columns: 108px minmax(0, 1fr) 80px;
    gap: 6px;
  }
  .header-center {
    display: contents;
    border: 0;
    padding: 0;
  }
  .header-center h1 {
    border-inline: 1px solid var(--border);
    padding: 0 6px;
  }
  .header-center h1 {
    grid-column: 2;
    grid-row: 1;
  }
  .header-center > :not(h1) {
    grid-column: 1/-1;
  }
  .header-tools {
    grid-column: 3;
    grid-row: 1;
  }
  header h1 {
    font-size: 0.875rem;
  }
  .jsfp-header h1 {
    grid-column: 1 / -1;
    grid-row: 2;
    border-inline: 0;
  }
  .title-desktop {
    display: none;
  }
  .title-mobile {
    display: inline;
  }
  .brand-logo {
    width: 108px;
    padding: 3px;
  }
  .theme-toggle {
    font-size: 0.75rem;
    padding: 6px;
    gap: 4px;
    min-width: 80px;
  }
  .theme-icon svg {
    width: 16px;
    height: 16px;
  }
  .switch-track {
    width: 26px;
    height: 16px;
    padding: 2px;
  }
  .switch-track span {
    width: 10px;
    height: 10px;
  }
  .theme-toggle[aria-checked='true'] .switch-track span {
    transform: translateX(10px);
  }
}
@media (max-width: 1100px) {
  .header-inner {
    padding: 0 0.7rem;
  }
  main {
    display: block;
    margin: 0.75rem auto;
    padding: 0 0.7rem;
  }
  #survey-sidebar,
  #survey-tools {
    position: static;
    max-height: none;
    overflow: visible;
    padding: 0;
  }
  #draft-actions .toolbar {
    grid-template-columns: 1fr;
  }
  nav button {
    font-size: 0.9rem;
  }
  .panel {
    padding: 1rem !important;
  }
  fieldset {
    padding: 0.65rem;
  }
  .states {
    display: block;
  }
  legend {
    font-size: 0.98rem;
  }
  .toolbar button {
    flex-grow: 1;
  }
}
@media (forced-colors: active) {
  .switch-track span {
    background: ButtonText;
  }
  .theme-toggle {
    border: 1px solid ButtonText;
  }
}

.survey-completion {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 8px;
  margin-top: 4px;
  font-size: 0.8rem;
  line-height: 1.3;
}
.survey-completion label {
  font-weight: 600;
}
.survey-completion progress {
  grid-column: 1/-1;
  display: block;
  width: 100%;
  height: 8px;
  accent-color: var(--primary);
  border: 0;
  border-radius: 4px;
  background: var(--soft);
}
.survey-completion progress::-webkit-progress-bar {
  background: var(--soft);
  border-radius: 4px;
}
.survey-completion progress::-webkit-progress-value {
  background: var(--primary);
  border-radius: 4px;
}
.survey-completion progress::-moz-progress-bar {
  background: var(--primary);
  border-radius: 4px;
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
:is(
  h2,
  fieldset,
  input,
  select,
  textarea,
  button,
  a,
  #validation-summary,
  #status,
  #survey-sidebar,
  #survey-tools,
  #content
) {
  scroll-margin-top: calc(var(--survey-header-height, 8rem) + 1rem);
}

.answer-state {
  margin: 0 0 0.4rem;
  padding: 0 0 0.4rem;
  border-bottom: 1px solid var(--border);
}

#survey-notice {
  font-size: 0.8rem;
  line-height: 1.35;
  margin: 0.5rem 0 0;
  padding: 0.4rem 0.6rem;
  overflow-wrap: anywhere;
}
#draft-actions {
  display: block;
  margin: 0 0 0.6rem;
  padding: 0.7rem;
  background: var(--soft);
  border: 1px solid var(--border);
  border-radius: 8px;
}
#draft-actions .toolbar {
  display: grid;
  gap: 0.5rem;
  margin: 0.5rem 0;
}
#draft-actions button {
  min-width: 0;
  width: 100%;
  min-height: 64px;
  text-align: center;
}
#draft-actions .toolbar:has(> button:only-of-type) {
  grid-template-columns: 1fr;
}
#draft-actions label {
  font-size: 0.875rem;
  overflow-wrap: anywhere;
}
#draft-tools {
  margin: 0 0 0.7rem;
  font-size: 0.875rem;
}
#draft-tools p {
  margin: 0.5rem 0;
  overflow-wrap: anywhere;
}
.comment-required,
.required-marker {
  color: var(--text);
}

input:not([type='checkbox']):not([type='radio']),
select {
  min-height: 44px;
}
textarea {
  min-height: 64px;
}
h2 {
  font-size: 1.25rem;
  line-height: 1.3;
  margin: 0.25rem 0 0.75rem;
}
.pending-save {
  font-weight: 600;
}

#progress-count {
  grid-column: 2;
  justify-self: end;
}
.switch-track,
.theme-icon {
  flex: none;
}

/* Compact questions keep complete instructions available on demand. */
#form fieldset {
  margin: 0.5rem 0;
  padding: 0.5rem;
}
#form .field-help {
  margin: 0;
  font-size: 0.875rem;
}
#form .field-help summary {
  min-height: 44px;
  display: list-item;
  padding: 0.65rem 0;
}
#form .field-help .hint {
  margin: 0.25rem 0;
}
#form .answer-state {
  margin: 0;
  padding: 0;
  border: 0;
}
#form .states {
  display: flex;
  flex-wrap: wrap;
  gap: 0 0.65rem;
}
#form .states .check {
  align-items: center;
  margin: 0;
  min-height: 44px;
}
#form .states input {
  margin: 0;
}
#form .meta {
  margin-top: 0.25rem;
  padding: 0;
  border: 0;
  font-size: 0.875rem;
}
#form .meta textarea {
  min-height: 44px;
  font-size: 1rem;
  padding: 0.5rem;
}
#progress-count {
  grid-column: 1/-1;
  justify-self: center;
}

#form input::placeholder,
#form textarea::placeholder {
  color: var(--muted);
  opacity: 1;
}

#form .field-definition {
  margin-left: auto;
  min-height: 44px;
  font-size: 0.875rem;
  white-space: nowrap;
}
.field-dialog {
  width: min(720px, calc(100% - 2rem));
  max-height: calc(100dvh - 2rem);
  padding: 1rem;
  border: 1px solid var(--input-border);
  border-radius: 10px;
  color: var(--text);
  background: var(--surface);
  overflow: auto;
  overflow-wrap: anywhere;
}
.field-dialog::backdrop {
  background: rgb(0 0 0 / 0.6);
}
.dialog-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}
.dialog-heading :is(h2, h3) {
  margin: 0;
  min-width: 0;
  font-size: 1.1rem;
  line-height: 1.4;
}
.dialog-close {
  flex: none;
}
.dialog-content p {
  margin: 0.5rem 0;
}
.dialog-content .hint {
  color: var(--text);
  font-size: 1rem;
}
.value-requirement {
  margin: 0.15rem 0;
  color: var(--text);
  font-size: 0.875rem;
}

@media (max-width: 760px) {
  #form .field-definition {
    margin-left: 0;
  }
  .field-dialog {
    padding: 0.75rem;
  }
  .dialog-heading {
    gap: 0.5rem;
    flex-wrap: wrap;
  }
  .dialog-close {
    width: 100%;
  }
}
@media (min-width: 761px) {
  .header-center h1 {
    display: inline;
  }
  .header-center .header-meta {
    display: inline-block;
    margin: 0.2rem 0 0.2rem 0.75rem;
  }
}

/* Selected horizontal rows: real semantic fieldset remains the question group. */
:root {
  --invalid-bg: #f8f2f2;
  --invalid-border: #b02722;
  --valid: #22643b;
  --valid-bg: #ecf7ef;
}
:root[data-theme='dark'] {
  --invalid-bg: #302d35;
  --invalid-border: #ffa39b;
  --valid: #a0e2b4;
  --valid-bg: #203c30;
}
#form {
  display: grid;
  gap: 16px;
}
#form fieldset {
  display: grid;
  grid-template-columns: minmax(0, 42%) minmax(0, 1fr);
  gap: 12px 30px;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 18px;
  background: var(--soft);
  border-radius: 10px;
}
#form legend {
  font-size: 17px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
#form .field-question,
#form .field-answer {
  min-width: 0;
}
#form .field-answer {
  align-self: center;
}
#form fieldset.type-rows {
  grid-template-columns: minmax(0, 1fr);
}
#form fieldset.type-rows .field-answer {
  width: 100%;
}
#form .field-definition {
  margin: 8px 0 0;
  background: transparent;
  color: var(--link);
  border: 1px solid var(--link);
  font-weight: 500;
  white-space: normal;
}
#form input:not([type='radio']):not([type='checkbox']),
#form select,
#form textarea {
  font-size: 16px;
  min-height: 46px;
}
#form .hint,
#form .states .check,
#form .meta {
  font-size: 14px;
}
#form .field-status {
  margin: 0.5rem 0;
  font-size: 14px;
  font-weight: 650;
}
#form [data-validation='valid'] .field-status {
  color: var(--valid);
}
#form [data-validation='invalid'] .field-status {
  color: var(--error);
}
#form .control-invalid:not(:disabled) {
  background: var(--invalid-bg);
  border: 2px solid var(--invalid-border);
}
#form .field-issues {
  margin: 0.4rem 0;
}
#form .field-issues .issue {
  margin: 0.25rem 0;
}
#form .tableScroll {
  max-width: 100%;
  min-width: 0;
}
#form .tableScroll :is(input, select, textarea) {
  font-size: 16px;
}
@media (max-width: 1100px) {
  #form fieldset {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
    padding: 14px;
  }
  #form .field-answer {
    align-self: auto;
  }
}
@media (forced-colors: active) {
  #form .control-invalid:not(:disabled) {
    border: 2px solid Mark;
  }
  #form [data-validation='valid'] .field-status {
    color: CanvasText;
  }
}

#form fieldset > legend {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
#form .question-label {
  font-size: 17px;
  font-weight: 650;
  line-height: 1.45;
  margin: 0 0 12px;
  overflow-wrap: anywhere;
}

/* Bound the complete survey and header on ultrawide displays. */
.header-inner,
main {
  width: 100%;
  max-width: 1440px;
}

/* Status strips occupy the same space in every state; descriptions never change row height. */
#form .control-shell {
  display: block;
  position: relative;
  min-width: 0;
  border-inline-start: 4px solid var(--input-border);
  padding-inline-start: 8px;
}
#form .control-shell[data-control-state='invalid'] {
  border-inline-start-color: var(--invalid-border);
}
#form .control-shell[data-control-state='valid'] {
  border-inline-start-color: var(--valid);
}
#form .control-shell[data-control-state='inactive'] {
  border-inline-start-color: var(--border);
}
#form .control-invalid:not(:disabled) {
  background: var(--invalid-bg);
  border: 1px solid var(--invalid-border);
}
#form .control-status {
  position: fixed;
  pointer-events: none;
  inset: auto;
  margin: 0;
  width: max-content;
  max-width: min(32rem, calc(100vw - 16px));
  max-height: calc(100dvh - 16px);
  overflow: auto;
  padding: 0.5rem 0.65rem;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--input-border);
  border-radius: 5px;
  font-size: 0.875rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
  opacity: 0;
}
#form .control-status:popover-open {
  opacity: 1;
}
#form .answer-state.control-shell {
  padding-inline-start: 8px;
}
#form .answer-value.control-shell {
  padding-inline-start: 8px;
}
#instructions-open {
  margin: 0.5rem 0 0;
}
/* Match the full survey area; keep each reading column comfortably short. */
#instructions-dialog {
  width: min(1440px, calc(100% - 2rem));
  max-height: calc(100dvh - 2rem);
  overflow: hidden;
  padding: 0;
}
#instructions-dialog[open] {
  display: flex;
  flex-direction: column;
}
#instructions-dialog .dialog-heading {
  flex: none;
  margin: 0;
  padding: 1rem;
  border-bottom: 1px solid var(--border);
}
#instructions-dialog .dialog-content {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 1rem;
  line-height: 1.6;
}
#instructions-dialog :is(p, li) {
  max-width: 70ch;
}
#instructions-dialog :is(h3, h4) {
  scroll-margin-top: 1rem;
  margin: 0 0 0.7rem;
  line-height: 1.4;
}
#instructions-dialog li {
  margin: 0.4rem 0;
}
#instructions-dialog .instruction-start {
  padding: 1rem;
  background: var(--soft);
  border-radius: 8px;
}
#instructions-dialog .instruction-start ol {
  margin: 0.5rem 0;
  padding-left: 1.5rem;
}
#instructions-dialog .instruction-index {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.5rem;
  margin: 1rem 0;
}
#instructions-dialog .instruction-index a {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--input-border);
  border-radius: 6px;
}
#instructions-dialog .instruction-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.5rem 2.5rem;
}
#instructions-dialog .instruction-grid > section {
  min-width: 0;
  border-top: 2px solid var(--border);
  padding-top: 1rem;
}
@media (max-width: 1000px) {
  #instructions-dialog .instruction-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  #instructions-dialog .instruction-index {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 760px) {
  #instructions-dialog {
    width: calc(100% - 1rem);
    max-height: calc(100dvh - 1rem);
  }
  #instructions-dialog .dialog-heading,
  #instructions-dialog .dialog-content {
    padding: 0.75rem;
  }
  #instructions-dialog .instruction-start {
    padding: 0.75rem;
  }
}
@media (max-width: 360px) {
  #instructions-dialog .instruction-index {
    grid-template-columns: minmax(0, 1fr);
  }
}
@media (forced-colors: active) {
  #form .control-shell {
    border-inline-start-color: CanvasText;
  }
  #form .control-shell[data-control-state='invalid'] {
    border-inline-start-style: dashed;
  }
  #form .control-shell[data-control-state='valid'] {
    border-inline-start-style: double;
  }
}

/* Help target stays touch accessible; its visible symbol is a small circle. */
#form .field-definition {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  min-width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  margin: 0;
  background: transparent;
  flex: none;
}
.info-symbol {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  font-family: Georgia, serif;
  font-size: 17px;
  font-weight: 700;
  line-height: 1;
}
#form .required-marker {
  color: var(--error);
}
#form .field-status:empty,
#form .field-issues:empty {
  margin: 0;
}
.validation-section {
  margin: 0.5rem 0;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 0.25rem 0.75rem;
  background: var(--soft);
}
.validation-section summary {
  min-height: 44px;
  overflow-wrap: anywhere;
}
.validation-count {
  display: inline-block;
  white-space: nowrap;
  margin-inline-start: 0.4rem;
  color: var(--error);
}
.validation-errors {
  padding-inline-start: 1.3rem;
  margin: 0.4rem 0 0.75rem;
}
.validation-errors li {
  margin: 0.65rem 0;
  overflow-wrap: anywhere;
}
.summary-issue {
  display: block;
  font-size: 0.875rem;
  color: var(--muted);
  margin-top: 0.15rem;
}
.dialog-content h4 {
  margin: 1rem 0 0.35rem;
}

/* DOCX questions group their original subfields; normalized extras are explicit. */
#form .source-group {
  min-width: 0;
  margin: 0;
  padding: 0;
}
#form .source-group > :is(h3, h4) {
  margin: 0 0 0.7rem;
  padding: 0.65rem 0.75rem;
  border-bottom: 2px solid var(--accent);
  font-size: 1.1rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
#form .source-fields {
  display: grid;
  gap: 12px;
}
#form .extension-label {
  margin: 0 0 0.5rem;
  font-size: 0.8rem;
  color: var(--muted);
}
#form .extension-label > span {
  display: inline-block;
  margin-right: 0.4rem;
  padding: 0.1rem 0.4rem;
  border: 1px solid var(--input-border);
  border-radius: 4px;
  font-weight: 650;
  color: var(--text);
}
.field-source-context {
  color: var(--muted);
  font-size: 0.9rem;
}

#form .source-subsection {
  margin: 0.4rem 0 0;
  padding: 0.75rem;
  border-radius: 6px;
  background: var(--primary);
  color: var(--on-primary);
  font-size: 1.15rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

/* System attestation fields cannot be edited or selected as respondent answers. */
#form .system-field .states .check,
#form .system-field .meta {
  display: none;
}
.completion-identity {
  margin: 1rem 0;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--soft);
}
.completion-identity h3 {
  margin: 0 0 0.75rem;
  font-size: 1.1rem;
}
.completion-identity label {
  margin: 0.5rem 0;
}
.completion-identity input[readonly],
#form [data-system-date] {
  background: var(--surface);
  color: var(--text);
  cursor: default;
}
#account-panel h2 {
  margin: 0 0 0.75rem;
  font-size: 1.1rem;
}
#account-login label {
  margin: 0.5rem 0;
}
#account-login button {
  margin-top: 0.5rem;
}
#account-panel strong {
  overflow-wrap: anywhere;
}

/* Independent navigation and tools keep the survey centered and readable. */
#survey-toc {
  padding: 0.7rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}
#survey-toc summary {
  min-height: 44px;
  font-size: 1.1rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
#survey-toc nav {
  margin-top: 0.5rem;
}
#survey-tools h2 {
  font-size: 1.1rem;
}
#survey-tools .panel {
  padding: 0.8rem;
}
#survey-tools button {
  width: 100%;
}
#survey-sidebar:focus-visible,
#survey-tools:focus-visible,
#content:focus-visible {
  outline-offset: 2px;
}
@media (max-width: 1100px) {
  #survey-sidebar {
    margin-bottom: 0.75rem;
  }
  #survey-tools {
    margin-top: 1rem;
  }
  #survey-toc nav {
    max-height: 50dvh;
    overflow: auto;
    padding: 3px;
  }
}

/* One empty text row; content includes one spare row and grows for visual wrapping. */
#form textarea,
#canonical-json {
  min-height: 0;
  line-height: 24px;
  padding: 10px;
  resize: none;
  overflow-y: hidden;
}

#survey-toc button[data-validation='valid'] {
  background: #e5f3e6;
  color: #174562;
  border-color: #85ab88;
}
#survey-toc button[data-validation='invalid'] {
  background: #fbe9e7;
  color: #174562;
  border-color: #c59b96;
}
:root[data-theme='dark'] #survey-toc button[data-validation='valid'] {
  background: #d8ebdc;
  color: #102e43;
  border-color: #8aae93;
}
:root[data-theme='dark'] #survey-toc button[data-validation='invalid'] {
  background: #f0dcda;
  color: #102e43;
  border-color: #bd9290;
}
#survey-toc button[aria-current='step'][data-validation='valid'],
#survey-toc button[aria-current='step'][data-validation='invalid'] {
  box-shadow: inset 0 0 0 2px var(--primary);
}

/* Clear action roles; colors never replace the button labels. */
:root {
  --navigation-bg: #174f78;
  --navigation-text: #fff;
  --validation-bg: #673b89;
  --validation-text: #fff;
  --submit-bg: #22643b;
  --submit-text: #fff;
}
:root[data-theme='dark'] {
  --navigation-bg: #91d1f5;
  --navigation-text: #102e43;
  --validation-bg: #d8b6f2;
  --validation-text: #28143d;
  --submit-bg: #a0e2b4;
  --submit-text: #173321;
}
.navigation-button:not(:disabled) {
  background: var(--navigation-bg);
  color: var(--navigation-text);
}
.validation-button:not(:disabled),
.instructions-button:not(:disabled) {
  background: var(--validation-bg);
  color: var(--validation-text);
}
.submit-survey:not(:disabled) {
  background: var(--submit-bg);
  color: var(--submit-text);
}
.submit-survey {
  font-size: 1.2rem;
  font-weight: 750;
  min-height: 56px;
  padding: 0.9rem 1.5rem;
}
.submit-survey[hidden] {
  display: none;
}
.instruction-symbol {
  display: inline-grid;
  place-items: center;
  border: 1px solid currentColor;
  border-radius: 50%;
  width: 1.4em;
  height: 1.4em;
  margin-right: 0.3em;
  font-weight: 750;
}
#survey-tools .dialog-close {
  width: auto;
}
.dialog-heading :is(h2, h3) {
  flex: 1;
  overflow-wrap: normal;
}
@media (max-width: 760px) {
  #survey-tools .dialog-close {
    width: 100%;
  }
  .dialog-heading :is(h2, h3) {
    flex-basis: 100%;
  }
}

.validation-button[data-validation='valid']:not(:disabled) {
  background: #e5f3e6;
  color: #174562;
  border-color: #85ab88;
}
.validation-button[data-validation='invalid']:not(:disabled) {
  background: #fbe9e7;
  color: #174562;
  border-color: #c59b96;
}
:root[data-theme='dark'] .validation-button[data-validation='valid']:not(:disabled) {
  background: #d8ebdc;
  color: #102e43;
  border-color: #8aae93;
}
:root[data-theme='dark'] .validation-button[data-validation='invalid']:not(:disabled) {
  background: #f0dcda;
  color: #102e43;
  border-color: #bd9290;
}

.survey-navigation {
  justify-content: center;
}
.advanced-actions summary {
  cursor: pointer;
  min-height: 44px;
  padding: 0.5rem 0;
}
.draft-maintenance button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}
.draft-maintenance {
  justify-content: center;
}
.draft-action-icon {
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
#instructions-open {
  width: 100%;
  margin-bottom: 0.75rem;
}

#form .states[hidden],
#form .meta[hidden] {
  display: none;
}
.territorial-identity {
  margin-bottom: 1.5rem;
}
.territorial-identity > label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.5rem;
}
#terc-code {
  width: min(100%, 16rem);
}
.jsfp-territorial-identity {
  display: grid;
  grid-template-columns: minmax(0, 42%) minmax(0, 1fr);
  align-items: start;
  gap: 12px 30px;
  padding: 18px;
  background: var(--soft);
  border-radius: 10px;
}
.jsfp-territorial-identity > label {
  margin: 0;
  font-size: 17px;
  line-height: 1.45;
}
.jsfp-territorial-identity .territorial-answer {
  min-width: 0;
}
.jsfp-territorial-identity .territorial-answer p {
  margin: 0.5rem 0 0;
}
@media (max-width: 1100px) {
  .jsfp-territorial-identity {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
    padding: 14px;
  }
}
.certificate-picker {
  min-width: 0;
  width: 100%;
}
.certificate-options {
  max-height: 20rem;
  overflow-y: auto;
  border: 1px solid currentColor;
  padding: 0.5rem;
}
.certificate-options .check {
  min-height: 44px;
  overflow-wrap: anywhere;
}
.certificate-options [hidden] {
  display: none;
}
.certificate-picker ul {
  padding-left: 1.25rem;
}
.certificate-picker button {
  min-height: 44px;
  text-align: left;
  white-space: normal;
  overflow-wrap: anywhere;
}
#form fieldset[data-validation='invalid'] {
  background: var(--invalid-bg);
  border-color: var(--invalid-border);
}
.jsfp-maturity-matrix {
  width: 100%;
  min-width: 650px;
  table-layout: fixed;
}
.jsfp-maturity-matrix th:first-child {
  width: 42%;
}
.tableScroll .jsfp-maturity-matrix :is(th, td) {
  min-width: 0;
}
.jsfp-maturity-matrix thead th:not(:first-child) {
  text-align: center;
}
.jsfp-maturity-matrix td[colspan='5'] {
  padding: 0;
}
#form .jsfp-maturity-matrix fieldset {
  position: relative;
  grid-template-columns: minmax(0, 1fr);
  padding: 8px 0;
}
.jsfp-maturity-matrix .question-label {
  display: none;
}
.jsfp-maturity-matrix .rating-values {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
}
.jsfp-maturity-matrix .rating-values label {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 44px;
}
#form .jsfp-maturity-matrix .rating-values .control-shell {
  padding-inline-end: 8px;
  border-inline-end: 4px solid transparent;
}
.jsfp-maturity-matrix .rating-values input[type='radio'] {
  margin: 0;
}
