:root {
  --red: #b40003;
  --red-dark: #920a0c;
  --red-tint: #fbefef;
  --sky: #669bbc;
  --ink: #1d2229;
  --muted: #5b6470;
  --line: #d6dbe1;
  --wash: #f4f6f8;
  --white: #ffffff;
  --radius: 6px;
  --font: 'Public Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--white); color: var(--ink); font: 400 16px/1.5 var(--font); }
[hidden] { display: none !important; }

.uav { max-width: 760px; margin: 0 auto; padding: 32px 20px 40px; }

/* header */
.head { margin-bottom: 28px; }
.title { margin: 0 0 8px; font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.1rem); line-height: 1.15; font-weight: 700; letter-spacing: -0.015em; }
.intro { margin: 0; max-width: 62ch; color: var(--muted); }
.notice {
  display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: center; justify-content: space-between;
  margin-top: 16px; padding: 12px 14px; border-left: 3px solid var(--sky); background: #eef4f8; font-size: 0.94rem;
}

/* progress: one segment per step */
.progress { margin-bottom: 8px; }
.step-count { margin: 0 0 8px; font-size: 0.875rem; font-weight: 600; color: var(--muted); }
.segs { display: grid; grid-template-columns: repeat(9, 1fr); gap: 4px; }
.seg { height: 4px; border-radius: 2px; background: var(--line); transition: background-color .2s; }
.seg.done { background: var(--red-dark); }
.seg.current { background: var(--red); }

/* step */
.step { padding-top: 20px; }
.step-title {
  margin: 0 0 24px; padding-bottom: 14px; border-bottom: 1px solid var(--line);
  font-size: 1.45rem; line-height: 1.2; font-weight: 700; outline: none;
}

/* fields */
.field { margin: 0 0 26px; padding: 0; border: 0; min-width: 0; }
.label { display: block; padding: 0; margin: 0 0 8px; font-weight: 600; font-size: 1rem; line-height: 1.35; max-width: 64ch; }
.req { color: var(--red); }
.help { margin: -4px 0 10px; font-size: 0.875rem; color: var(--muted); max-width: 64ch; }
.sublabel { display: block; margin: 0 0 4px; font-size: 0.875rem; color: var(--muted); }

.input {
  display: block; width: 100%; min-height: 46px; padding: 10px 12px;
  font: inherit; color: var(--ink); background: var(--white);
  border: 1px solid #b9c0c9; border-radius: var(--radius);
  transition: border-color .15s, box-shadow .15s;
}
textarea.input { min-height: 112px; resize: vertical; }
.input:hover { border-color: #8e97a3; }
.input:focus { outline: none; border-color: var(--sky); box-shadow: 0 0 0 3px rgba(102, 155, 188, .35); }
.field:not(.field-textarea):not(.field-address):not(.field-name):not(.field-repeater) > .input,
.field > .affix { max-width: 420px; }

.affix { position: relative; display: block; }
.affix-mark { position: absolute; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.affix-pre .affix-mark { left: 12px; }
.affix-pre .input { padding-left: 26px; }
.affix-post .affix-mark { right: 12px; }
.affix-post .input { padding-right: 30px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.span-2 { grid-column: 1 / -1; }

/* choices */
.choices { display: grid; gap: 8px; }
.choices-grid { grid-template-columns: 1fr 1fr; gap: 6px 16px; }
.choice { display: flex; align-items: flex-start; gap: 10px; padding: 6px 0; cursor: pointer; line-height: 1.35; }
.choice input { flex: none; width: 20px; height: 20px; margin: 0; accent-color: var(--red); cursor: pointer; }
.choice input:focus-visible { outline: 3px solid var(--sky); outline-offset: 2px; }

/* yes / no as a two-button switch */
.choices-yesno { display: inline-grid; grid-template-columns: repeat(2, minmax(88px, auto)); gap: 0; }
.choices-yesno .choice {
  position: relative; justify-content: center; padding: 10px 20px; border: 1px solid #b9c0c9;
  background: var(--white); font-weight: 600;
}
.choices-yesno .choice:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.choices-yesno .choice:last-child { border-radius: 0 var(--radius) var(--radius) 0; margin-left: -1px; }
.choices-yesno input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; }
.choices-yesno .choice:hover { border-color: #8e97a3; z-index: 1; }
.choices-yesno .choice:has(input:checked) { background: var(--ink); border-color: var(--ink); color: var(--white); z-index: 2; }
.choices-yesno .choice:has(input:focus-visible) { outline: 3px solid var(--sky); outline-offset: 2px; z-index: 3; }

/* repeater */
.repeater { display: grid; gap: 14px; }
.rep-row { padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--wash); }
.rep-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.rep-title { margin: 0; font-size: 1rem; font-weight: 700; }
.add-btn {
  justify-self: start; padding: 10px 14px; font: 600 0.95rem var(--font); color: var(--red-dark);
  background: var(--white); border: 1px dashed var(--red-dark); border-radius: var(--radius); cursor: pointer;
}
.add-btn:hover { background: var(--red-tint); }

/* file */
.file { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.file-name { color: var(--muted); font-size: 0.94rem; word-break: break-all; }
.file:focus-within .btn-secondary { outline: 3px solid var(--sky); outline-offset: 2px; }

/* signature */
.sig-canvas {
  display: block; width: 100%; max-width: 520px; height: 170px; touch-action: none; cursor: crosshair;
  background: var(--white) linear-gradient(var(--line), var(--line)) no-repeat 16px calc(100% - 40px) / calc(100% - 32px) 1px;
  border: 1px solid #b9c0c9; border-radius: var(--radius);
}
.sig-canvas:focus-visible { outline: 3px solid var(--sky); outline-offset: 2px; }
.sig-foot { display: flex; justify-content: space-between; gap: 12px; max-width: 520px; margin-top: 6px; }
.sig-foot .help { margin: 0; }

/* declaration */
.declaration { margin: 8px 0 26px; padding: 18px 20px; border-left: 3px solid var(--red); background: var(--wash); }
.declaration-title { margin: 0 0 8px; font-size: 1rem; font-weight: 700; }
.declaration p { margin: 0; font-size: 0.94rem; line-height: 1.6; max-width: 70ch; }

.verify { margin: 4px 0 8px; }
.turnstile { min-height: 65px; }

/* errors */
.error { margin: 8px 0 0; font-size: 0.9rem; font-weight: 600; color: var(--red-dark); }
.has-error .input,
.has-error .sig-canvas,
.has-error.field-yesno .choice { border-color: var(--red-dark); }
.has-error > .label { color: var(--red-dark); }
.has-error .sub-street2 .input { border-color: #b9c0c9; }
.has-error.has-cell-errors .input { border-color: #b9c0c9; }
.has-error.has-cell-errors .input[aria-invalid="true"] { border-color: var(--red-dark); }
.banner {
  margin: 8px 0 0; padding: 12px 14px; border-left: 3px solid var(--red-dark);
  background: var(--red-tint); color: var(--red-dark); font-weight: 600; font-size: 0.94rem;
}

/* buttons */
.nav { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.nav .btn-primary { margin-left: auto; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 46px; padding: 10px 22px;
  font: 600 1rem var(--font); border-radius: var(--radius); cursor: pointer; text-decoration: none;
  border: 1px solid transparent; transition: background-color .15s, border-color .15s;
}
.btn:focus-visible, .link-btn:focus-visible, .add-btn:focus-visible { outline: 3px solid var(--sky); outline-offset: 2px; }
.btn-primary { background: var(--red); color: var(--white); min-width: 140px; }
.btn-primary:hover { background: var(--red-dark); }
.btn-primary:disabled { opacity: .65; cursor: progress; }
.btn-secondary { background: var(--white); color: var(--ink); border-color: #b9c0c9; }
.btn-secondary:hover { border-color: var(--ink); }
.link-btn { padding: 2px 0; font: 600 0.9rem var(--font); color: var(--red-dark); background: none; border: 0; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

.legend-note { margin: 16px 0 0; font-size: 0.85rem; color: var(--muted); }
.success { padding: 24px 0; outline: none; }
.success .title { color: var(--ink); }

/* hidden helpers */
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.hp { position: absolute; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden; }

@media (max-width: 560px) {
  .uav { padding: 20px 16px 32px; }
  .grid-2, .choices-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .nav .btn { flex: 1; }
  .btn-primary { min-width: 0; }
}

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