:root {
  --navy: #203c73;
  --navy-dark: #172e5a;
  --gold: #d6a229;
  --gold-soft: #fbf5e7;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #dbe3ee;
  --surface: #ffffff;
  --background: #f5f7fa;
  --danger: #b4233b;
  --danger-bg: #fff1f3;
  --success: #14804a;
  --shadow: 0 24px 70px rgba(32, 60, 115, 0.12);
  --radius-lg: 24px;
  --radius-md: 15px;
  color-scheme: light;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; scroll-behavior: smooth; }
body { min-height: 100%; margin: 0; overflow-x: hidden; background: var(--background); color: var(--ink); }
button, input, textarea, select { font: inherit; }
button, a, input, textarea, select, canvas { -webkit-tap-highlight-color: transparent; }
button, a { touch-action: manipulation; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; color: var(--navy); font-size: clamp(1.8rem, 5vw, 2.6rem); line-height: 1.12; letter-spacing: -0.035em; }
h2 { margin-bottom: 24px; color: var(--navy); font-size: 1.35rem; }
h3 { color: var(--navy); }
.is-hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.muted { color: var(--muted); }
.eyebrow { margin-bottom: 8px; color: var(--gold); font-size: 0.76rem; font-weight: 800; letter-spacing: 0.2em; text-transform: uppercase; }

.landing-page { background: radial-gradient(circle at 8% 5%, rgba(32,60,115,.13), transparent 32rem), radial-gradient(circle at 95% 92%, rgba(214,162,41,.13), transparent 30rem), var(--background); }
.landing-shell { position: relative; display: grid; min-height: 100vh; place-items: center; padding: 28px 20px; overflow: hidden; }
.ambient { position: absolute; width: 320px; height: 320px; border-radius: 999px; filter: blur(70px); pointer-events: none; }
.ambient-navy { left: -170px; top: -170px; background: rgba(32,60,115,.15); }
.ambient-gold { right: -190px; bottom: -170px; background: rgba(214,162,41,.18); }
.landing-card { position: relative; width: 100%; min-width: 0; max-width: 570px; overflow: hidden; padding: 42px clamp(24px, 7vw, 56px); border: 1px solid rgba(255,255,255,.9); border-radius: 32px; background: var(--surface); box-shadow: var(--shadow); text-align: center; animation: rise .45s ease both; }
.brand-rule { position: absolute; inset: 0 0 auto; height: 6px; background: linear-gradient(90deg, var(--navy), var(--gold), var(--navy)); }
.landing-logo { display: block; width: 170px; height: 88px; margin: 0 auto 22px; object-fit: contain; }
.landing-copy { max-width: 430px; margin: 16px auto 0; color: #475569; font-size: 1.03rem; line-height: 1.7; }
.security-note { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 30px 0 0; padding-top: 22px; border-top: 1px solid #edf1f6; color: var(--muted); font-size: .88rem; line-height: 1.5; }
.security-note span { display: grid; width: 22px; height: 22px; flex: 0 0 auto; place-items: center; border-radius: 50%; background: #e9f8ef; color: var(--success); font-weight: 900; }
.success-card .button { margin-top: 28px; }
.success-mark, .error-mark { display: grid; width: 68px; height: 68px; margin: 8px auto 20px; place-items: center; border-radius: 50%; background: #e8f8ef; color: var(--success); font-size: 2rem; font-weight: 900; }
.error-mark { background: var(--danger-bg); color: var(--danger); }

.button { display: inline-flex; min-height: 48px; align-items: center; justify-content: center; gap: 9px; border: 0; border-radius: 13px; padding: 12px 22px; cursor: pointer; font-weight: 750; transition: transform .18s ease, box-shadow .18s ease, background .18s ease; }
.button:hover { transform: translateY(-1px); }
.button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, .choice input:focus-visible + span, .check-row input:focus-visible + span { outline: 3px solid rgba(214,162,41,.35); outline-offset: 2px; }
.button:disabled { cursor: not-allowed; opacity: .58; transform: none; }
.button-primary { background: var(--navy); color: #fff; box-shadow: 0 12px 24px rgba(32,60,115,.2); }
.button-primary:hover { background: var(--navy-dark); }
.button-secondary { border: 1px solid var(--line); background: #fff; color: #334155; box-shadow: none; }
.button-outline { border: 1px dashed var(--navy); background: rgba(32,60,115,.035); color: var(--navy); box-shadow: none; }
.button-large { width: min(100%, 255px); min-height: 56px; margin-top: 30px; text-transform: uppercase; letter-spacing: .035em; }

.site-header { border-bottom: 1px solid var(--line); background: rgba(255,255,255,.94); backdrop-filter: blur(14px); }
.header-inner { display: flex; width: min(100%, 1050px); min-height: 78px; margin: auto; align-items: center; justify-content: space-between; gap: 18px; padding: 10px 20px; }
.header-inner img { width: 108px; height: 56px; object-fit: contain; }
.header-copy { display: grid; gap: 4px; text-align: right; }
.header-copy span { color: var(--gold); font-size: .68rem; font-weight: 850; letter-spacing: .16em; text-transform: uppercase; }
.header-copy strong { color: var(--navy); font-size: .9rem; }
.form-shell { width: min(100%, 1050px); margin: auto; padding: 30px 20px 48px; }
.state-card { display: grid; width: min(100%, 560px); min-height: 300px; margin: 8vh auto 0; place-items: center; align-content: center; border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 36px; background: #fff; box-shadow: var(--shadow); text-align: center; }
.state-card h1 { margin-top: 16px; font-size: 1.5rem; }
.state-card p { margin: 10px 0 22px; color: var(--muted); }
.spinner { width: 38px; height: 38px; border: 4px solid #dbe4f1; border-top-color: var(--navy); border-radius: 50%; animation: spin .8s linear infinite; }
.form-heading { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin-bottom: 20px; }
.form-heading h1 { font-size: clamp(1.75rem, 4vw, 2.35rem); }
.form-heading .muted { margin: 7px 0 0; }
.save-status { min-height: 20px; margin: 0; color: var(--muted); font-size: .82rem; font-weight: 650; }
.progress { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin-bottom: 24px; }
.progress-item { min-width: 0; }
.progress-bar { height: 8px; border-radius: 20px; background: #dce3ec; transition: background .2s ease; }
.progress-item.complete .progress-bar, .progress-item.current .progress-bar { background: var(--navy); }
.progress-label { display: none; margin-top: 8px; overflow: hidden; color: #94a3b8; font-size: .7rem; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.progress-item.current .progress-label { color: var(--navy); }
.form-card { border: 1px solid var(--line); border-radius: var(--radius-lg); padding: clamp(20px, 5vw, 36px); background: #fff; box-shadow: 0 18px 50px rgba(15,23,42,.07); }
.form-step { display: grid; gap: 22px; animation: fade .2s ease both; }
.form-step > h2:not(.sr-only) { margin-bottom: 0; }
.field-grid { display: grid; gap: 16px; }
.field, .signature-field { display: grid; min-width: 0; gap: 8px; color: #334155; font-size: .88rem; font-weight: 700; }
.field b, legend b, .check-row b, .signature-field b { color: var(--danger); }
.field input, .field textarea, .field select { width: 100%; min-height: 50px; border: 1px solid #cfd9e6; border-radius: 12px; background: #fff; padding: 12px 14px; color: var(--ink); outline: none; transition: border-color .18s ease, box-shadow .18s ease; }
.field textarea { min-height: 112px; resize: vertical; line-height: 1.5; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--gold); box-shadow: 0 0 0 4px rgba(214,162,41,.11); }
.field input[readonly] { background: #f8fafc; color: var(--muted); }
.question { min-width: 0; margin: 0; border: 1px solid var(--line); border-radius: 18px; padding: 18px; background: #f9fbfd; }
.question legend { max-width: 100%; padding: 0 5px; color: var(--navy); font-size: .98rem; font-weight: 800; line-height: 1.45; }
.question legend small { color: var(--muted); font-weight: 550; }
.choice-grid { display: grid; gap: 10px; }
.choice { position: relative; display: block; cursor: pointer; }
.choice input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.choice span { display: flex; min-height: 50px; align-items: center; gap: 10px; border: 1px solid #d5deea; border-radius: 12px; padding: 11px 13px; background: #fff; color: #475569; font-size: .86rem; font-weight: 700; transition: .16s ease; }
.choice span::before { width: 18px; height: 18px; flex: 0 0 auto; border: 1.5px solid #b7c2d1; border-radius: 5px; content: ""; }
.choice input[type="radio"] + span::before { border-radius: 50%; }
.choice input:checked + span { border-color: var(--navy); background: var(--navy); color: #fff; box-shadow: 0 7px 18px rgba(32,60,115,.13); }
.choice input:checked + span::before { border: 5px solid #fff; background: var(--gold); }
.conditional { margin-top: 16px; }
.repeat-list { display: grid; gap: 14px; margin-top: 17px; }
.repeat-card { border: 1px solid var(--line); border-radius: 16px; padding: 16px; background: #fff; }
.repeat-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 15px; }
.repeat-heading h3 { margin: 0; font-size: .98rem; }
.remove-item, #clear-signature { min-height: 44px; border: 0; border-radius: 10px; padding: 8px 12px; background: transparent; color: var(--danger); cursor: pointer; font-size: .78rem; font-weight: 800; }
.add-button { width: 100%; margin-top: 14px; }
.consent-copy { border: 1px solid rgba(32,60,115,.14); border-radius: 18px; padding: clamp(18px, 4vw, 26px); background: rgba(32,60,115,.035); color: #475569; font-size: .9rem; line-height: 1.65; }
.consent-copy h3 { margin-bottom: 14px; font-size: 1.16rem; }
.consent-copy p { margin-bottom: 9px; }
.check-row { display: flex; min-height: 58px; align-items: flex-start; gap: 12px; border: 1px solid var(--line); border-radius: 14px; padding: 15px; cursor: pointer; color: #334155; font-size: .9rem; font-weight: 700; line-height: 1.45; }
.check-row input { width: 21px; height: 21px; flex: 0 0 auto; margin: 0; accent-color: var(--navy); }
.review-grid { display: grid; gap: 14px; }
.review-card { border: 1px solid var(--line); border-radius: 16px; padding: 17px; background: #f9fbfd; }
.review-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.review-heading h3 { margin: 0; font-size: .95rem; }
.edit-section { min-height: 42px; border: 0; background: transparent; color: var(--navy); cursor: pointer; font-size: .8rem; font-weight: 850; }
.review-card p { margin: 0; overflow-wrap: anywhere; color: #475569; font-size: .87rem; line-height: 1.6; white-space: pre-line; }
.canvas-wrap { overflow: hidden; border: 2px dashed #cbd5e1; border-radius: 16px; background: #fff; }
#signature-canvas { display: block; width: 100%; height: 210px; cursor: crosshair; touch-action: none; }
.canvas-footer { display: flex; min-height: 52px; align-items: center; justify-content: space-between; gap: 10px; border-top: 1px solid var(--line); padding: 4px 8px 4px 14px; color: var(--muted); font-size: .75rem; }
#clear-signature { color: var(--navy); }
.alert { border-radius: 12px; padding: 13px 15px; font-size: .87rem; font-weight: 700; line-height: 1.5; }
.alert-error { border: 1px solid #fecdd3; background: var(--danger-bg); color: var(--danger); }
#form-error { margin-top: 24px; }
.form-actions { display: flex; justify-content: space-between; gap: 12px; margin-top: 28px; padding-top: 24px; border-top: 1px solid var(--line); }
.privacy-note { margin: 18px 0 0; color: var(--muted); font-size: .75rem; line-height: 1.5; text-align: center; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } }

@media (min-width: 640px) {
  .two-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .three-columns { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .four-columns { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .review-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .progress-label { display: block; }
}

@media (max-width: 639px) {
  .landing-card { padding-top: 34px; padding-bottom: 30px; border-radius: 25px; }
  .landing-logo { width: 145px; height: 74px; }
  .form-shell { padding: 22px 14px 36px; }
  .form-heading { align-items: flex-start; }
  .save-status { text-align: right; }
  .form-card { border-radius: 20px; padding: 18px 15px; }
  .question { padding: 15px 12px; }
  .choice-grid.four-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-actions { flex-direction: column-reverse; }
  .form-actions .button { width: 100%; }
  .canvas-footer { align-items: flex-start; flex-direction: column; padding: 8px 12px; }
  #clear-signature { width: 100%; border: 1px solid var(--line); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
