:root {
  --bg: #eef4ff;
  --card: #ffffff;
  --text: #182235;
  --muted: #667085;
  --primary: #2457d6;
  --primary-dark: #163fa8;
  --border: #d8e0ee;
  --danger: #b42318;
  --soft: #f7f9fc;
  --shadow: 0 20px 60px rgba(22, 40, 75, 0.14);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--text);
  background: linear-gradient(135deg, #edf4ff 0%, #f9fbff 55%, #eaf0ff 100%);
}

.page-shell {
  width: 100%;
  min-height: 100vh;
  padding: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.form-card {
  width: 100%;
  background: var(--card);
  border-radius: 0;
  box-shadow: none;
  padding: clamp(18px, 5vw, 42px);
}

.form-header {
  text-align: center;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--primary);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.78rem;
}

h1, h2, h3, p {
  margin-top: 0;
}

h1 {
  margin-bottom: 10px;
  font-size: clamp(1.8rem, 5vw, 3rem);
}

h2 {
  margin-bottom: 8px;
  font-size: clamp(1.35rem, 4vw, 2rem);
}

.intro,
.page-help,
.step-label {
  color: var(--muted);
}

.progress {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8edf6;
  margin-bottom: 10px;
}

.progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), #5d8cff);
  transition: width 0.25s ease;
}

.step-label {
  text-align: center;
  font-weight: 700;
  margin-bottom: 26px;
}

.form-page {
  display: none;
  animation: fadeIn 0.2s ease;
}

.form-page.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.grid {
  display: grid;
  gap: 16px;
  margin-bottom: 16px;
}

.grid label,
.grid fieldset {
  margin-bottom: 0;
}

.two-columns,
.three-columns {
  grid-template-columns: 1fr;
}

label,
fieldset {
  display: block;
  margin-bottom: 16px;
}

label,
legend {
  font-weight: 700;
}

.required-mark {
  color: var(--danger);
}

input,
select,
textarea {
  width: 100%;
  margin-top: 7px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 13px 14px;
  font: inherit;
  color: var(--text);
  background: #fff;
  transition: border-color 0.2s, box-shadow 0.2s;
}

select {
  min-height: 48px;
  line-height: normal;
  appearance: auto;
  -webkit-appearance: menulist;
  background-color: #fff;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(36, 87, 214, 0.13);
}

.choice-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-top: 20px;
}

.choice-card {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--soft);
  cursor: pointer;
}

.choice-card input {
  width: auto;
  margin-top: 4px;
  flex-shrink: 0;
}

.choice-card strong,
.choice-card small {
  display: block;
}

.choice-card small {
  margin-top: 4px;
  color: var(--muted);
  font-weight: 400;
}

/* Highlight the selected choice card */
.choice-card:has(input:checked) {
  border-color: var(--primary);
  background: #eef4ff;
  box-shadow: 0 0 0 3px rgba(36, 87, 214, 0.15);
}

.children-list {
  display: grid;
  gap: 14px;
  margin-bottom: 16px;
}

.child-card {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--soft);
}

.child-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.child-card-title {
  margin: 0;
  font-size: 1rem;
}

.remove-child {
  border: none;
  background: transparent;
  color: var(--danger);
  font-weight: 700;
  cursor: pointer;
  padding: 4px 8px;
  flex-shrink: 0;
}

.conditional-group {
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--soft);
  margin-bottom: 18px;
}

.conditional-group legend {
  padding: 0 4px;
}

.donation-panel {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: linear-gradient(135deg, #f7f9fc 0%, #eef4ff 100%);
  box-shadow: 0 12px 30px rgba(22, 40, 75, 0.08);
}

.donation-toggle {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin: 0;
  padding: 20px;
  cursor: pointer;
  transition: background 0.2s;
}

.donation-toggle:hover,
.donation-toggle:has(input:focus-visible) {
  background: rgba(36, 87, 214, 0.07);
}

.donation-toggle input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.donation-check {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
  border: 2px solid #b8c5dc;
  border-radius: 10px;
  background: #fff;
  color: #fff;
  box-shadow: inset 0 0 0 3px #fff;
  transition: border-color 0.2s, background 0.2s, transform 0.2s;
}

.donation-check::after {
  content: '✓';
  font-size: 1rem;
  font-weight: 800;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.2s, transform 0.2s;
}

.donation-toggle:has(input:checked) .donation-check {
  border-color: var(--primary);
  background: var(--primary);
  transform: scale(1.04);
}

.donation-toggle:has(input:checked) .donation-check::after {
  opacity: 1;
  transform: scale(1);
}

.donation-copy {
  display: grid;
  gap: 5px;
}

.donation-kicker {
  color: var(--primary);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.donation-copy strong {
  font-size: 1.08rem;
}

.donation-copy small {
  color: var(--muted);
  font-weight: 400;
}

.donation-amount-panel {
  padding: 0 20px 20px;
}

.donation-amount-panel label {
  margin: 0;
  padding: 16px;
  border: 1px solid rgba(36, 87, 214, 0.18);
  border-radius: 16px;
  background: #fff;
}

.summary-box,
.captcha-wrap {
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--soft);
  margin-bottom: 18px;
}

.submission-state {
  text-align: center;
  padding: clamp(24px, 6vw, 52px) 0;
}

.submission-state p {
  color: var(--muted);
  font-size: 1.05rem;
}

.loading-track {
  width: min(100%, 420px);
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8edf6;
  margin: 26px auto 0;
}

.loading-bar {
  width: 45%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), #5d8cff);
  animation: loadingSlide 1.15s ease-in-out infinite;
}

@keyframes loadingSlide {
  0% { transform: translateX(-110%); }
  50% { transform: translateX(80%); }
  100% { transform: translateX(230%); }
}

.status-icon {
  width: 58px;
  height: 58px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  margin-bottom: 18px;
  font-size: 2rem;
  font-weight: 700;
}

.success-state .status-icon {
  color: #067647;
  background: #dcfae6;
}

.error-state .status-icon {
  color: var(--danger);
  background: #fee4e2;
}

.error-message {
  min-height: 24px;
  color: var(--danger);
  font-weight: 700;
  margin: 18px 0 0;
}

.button-row {
  display: flex;
  flex-direction: column-reverse;
  gap: 12px;
  margin-top: 22px;
}

.button-row button {
  width: 100%;
}

/* Keep the back button space reserved so layout doesn't jump */
#backBtn {
  visibility: visible;
}

#backBtn.hidden-nav {
  visibility: hidden;
  pointer-events: none;
}

button {
  border-radius: 12px;
  padding: 13px 18px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s, background 0.2s, border-color 0.2s;
}

button:hover {
  transform: translateY(-1px);
}

.primary-button {
  border: 1px solid var(--primary);
  background: var(--primary);
  color: #fff;
}

.primary-button:hover {
  background: var(--primary-dark);
}

.secondary-button {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
}

.submit-button,
.hidden,
.family-only,
.single-only {
  display: none;
}

@media (min-width: 600px) {
  .page-shell {
    padding: 24px 16px;
    align-items: center;
  }

  .form-card {
    width: min(100%, 920px);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: clamp(22px, 4vw, 42px);
  }

  .choice-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 720px) {
  .page-shell {
    padding: 40px;
  }

  .two-columns {
    grid-template-columns: repeat(2, 1fr);
  }

  .three-columns {
    grid-template-columns: 1.4fr 0.8fr 0.8fr;
  }

  .button-row {
    flex-direction: row;
    justify-content: space-between;
  }

  .button-row button {
    width: auto;
    min-width: 150px;
  }

}
