:root {
  --paper: #f6f1e6;
  --card: #fffefa;
  --ink: #242b26;
  --muted: #6e746d;
  --subtle: #8e9086;
  --line: #eae3d4;
  --green: #245541;
  --green-dark: #183e2e;
  --gold: #9a7943;
  --danger: #a9493c;
  --serif: 'Playfair Display', Georgia, serif;
  --display-serif: 'Cormorant Garamond', 'Playfair Display', Georgia, serif;
  --sans: 'DM Sans', Arial, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-bottom: 100px;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, p {
  margin: 0;
}

.page-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  padding: 10px 20px calc(90px + env(safe-area-inset-bottom, 0px));
}

.topbar {
  width: min(100%, 580px);
  margin: 0 auto;
  padding: 10px 0 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.church-logo {
  display: block;
  width: 148px;
  height: 145px;
  object-fit: contain;
}

.form-card {
  width: min(100%, 580px);
  margin: 6px auto 0;
  padding: 26px 38px 0;
  background: var(--card);
  border: 1px solid #e7dec9;
  border-radius: 14px;
  box-shadow: 0 22px 60px rgba(40, 48, 36, 0.08);
  overflow: hidden;
}

.card-topline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #8b6a35;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
}

.eyebrow-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #ad4945;
  box-shadow: 0 0 0 3px rgba(173, 73, 69, 0.11);
}

.step-label {
  color: var(--subtle);
  font-size: 11px;
  font-weight: 500;
}

.progress-track {
  height: 2px;
  margin-top: 13px;
  background: #eee7d8;
}

.progress-track span {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #245541 0%, #b7934f 100%);
}

/* RSVP Form — Clean, Neat & Standard Editorial Style */
.rsvp-heading {
  padding: 2px 0 18px;
}

.rsvp-heading > span {
  display: inline-block;
  color: var(--gold);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.18em;
}

.rsvp-heading h2 {
  margin-top: 6px;
  color: #263d31;
  font: 600 22px/1.25 var(--serif);
}

.rsvp-heading p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.name-field {
  margin-bottom: 20px;
}

.field label {
  display: block;
  margin-bottom: 6px;
  color: #424943;
  font-size: 12px;
  font-weight: 600;
}

.required {
  margin-left: 3px;
  color: #b47e55;
}

.name-field input {
  width: 100%;
  height: 44px;
  border: 1px solid #e2ddd0;
  border-radius: 6px;
  outline: 0;
  background: #fff;
  padding: 0 13px;
  color: var(--ink);
  font: 400 13.5px var(--sans);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.name-field input::placeholder {
  color: #b3b5ad;
}

.name-field input:focus,
.select-field select:focus,
.count-field input:focus,
.meal-field input:focus {
  border-color: #6b8875;
  box-shadow: 0 0 0 3px rgba(36, 85, 65, 0.09);
}

.error {
  display: block;
  min-height: 14px;
  padding-top: 4px;
  color: var(--danger);
  font-size: 11px;
  line-height: 1.4;
}

.guest-section {
  padding: 17px 0;
  border-top: 1px solid var(--line);
}

.section-heading {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  margin-bottom: 12px;
}

.section-heading > div {
  min-width: 0;
}

.section-number {
  padding-top: 3px;
  color: var(--gold);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  flex: none;
}

.section-heading h2 {
  color: #26382f;
  font: 600 16px/1.25 var(--serif);
}

.section-heading p {
  margin-top: 3px;
  color: var(--subtle);
  font-size: 12px;
}

.count-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.select-field,
.count-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  color: #4b524b;
  font-size: 12px;
  font-weight: 600;
}

.select-field select {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 42px;
  border: 1px solid #e2ddd0;
  border-radius: 6px;
  outline: 0;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235b645c' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center;
  padding: 0 34px 0 12px;
  color: var(--ink);
  font: 400 13px var(--sans);
  cursor: pointer;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.toggle-row {
  display: flex;
  gap: 8px;
}

.registration-choice h2 {
  margin-bottom: 12px;
  color: var(--green-dark);
  font: 600 19px/1.35 var(--serif);
}

.registration-options .toggle-option {
  flex: 1;
  min-width: 0;
}

.registration-options .toggle-option span {
  min-height: 56px;
  padding: 12px;
  font-size: 16px;
}

.toggle-option {
  position: relative;
  min-width: 82px;
  cursor: pointer;
}

.toggle-option input {
  position: absolute;
  opacity: 0;
}

.toggle-option span {
  display: grid;
  place-items: center;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid #e3ded2;
  border-radius: 6px;
  background: #fff;
  color: #676d65;
  font-size: 12.5px;
  font-weight: 500;
  transition: all 0.18s ease;
}

.toggle-option input:checked + span {
  border-color: #7c9382;
  background: #eef3ec;
  color: var(--green-dark);
  font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(36, 85, 65, 0.05);
}

.toggle-option:focus-within span {
  outline: 2px solid #a9b5a3;
  outline-offset: 2px;
}

.count-panel {
  margin-top: 12px;
  padding: 14px;
  border: 1px solid #ebe4d6;
  border-radius: 7px;
  background: #fbfaf5;
  animation: arrive 0.2s ease-out;
}

.count-help {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.count-help strong {
  color: var(--green-dark);
}

.family-total {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 6px;
  background: #eef3ec;
  color: var(--green-dark);
  font-size: 14px;
  font-weight: 600;
}

.family-total small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.family-total output {
  font-size: 22px;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
  min-width: 1.5em;
  text-align: right;
  margin-left: auto;
}

.site-credit {
  position: fixed;
  z-index: 5;
  right: 16px;
  bottom: max(16px, env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  max-width: calc(100vw - 24px);
  min-height: 44px;
  padding: 10px 15px;
  border: 1px solid #dce4da;
  border-radius: 999px;
  background: #fffefa;
  box-shadow: 0 4px 18px rgba(24, 62, 46, 0.12);
  color: var(--muted);
  font-size: 12px;
}

.site-credit a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-block: -10px;
  color: var(--green-dark);
  font-size: 14px;
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: #b8c9bb;
  text-underline-offset: 3px;
}

.site-credit a:hover {
  text-decoration-color: currentColor;
}

.site-credit a:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 4px;
  border-radius: 2px;
}

.count-field input,
.meal-field input {
  width: 100%;
  height: 40px;
  border: 1px solid #e2ddd0;
  border-radius: 6px;
  outline: 0;
  background: #fff;
  padding: 0 10px;
  color: var(--ink);
  font: 500 13.5px var(--sans);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.meal-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin: 15px 0 8px;
}

.meal-heading span {
  font-size: 12px;
  font-weight: 600;
  color: #4b524b;
}

.meal-heading small {
  font-size: 11px;
  color: #909389;
}

.meal-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
}

.meal-field {
  min-width: 0;
}

.meal-field > span {
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 20px;
  margin-bottom: 5px;
  color: #555c54;
  font-size: 11px;
  font-weight: 600;
}

.food-dot {
  width: 6px;
  height: 6px;
  display: inline-block;
  border-radius: 50%;
  flex: none;
}

.food-dot.veg {
  background: #6c9264;
}

.food-dot.nonveg {
  background: #bc7b60;
}

.food-dot.none {
  background: #9aa096;
}

.group-error {
  margin-top: 5px;
}

.meal-progress {
  margin-top: 12px;
  color: var(--green-dark);
  font-size: 13px;
  line-height: 1.5;
}

.summary-box {
  margin-top: 14px;
  padding: 13px 15px;
  border-radius: 6px;
  background: #f1f4ed;
}

.summary-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #7d6d46;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.summary-title span {
  color: var(--green-dark);
  font: 600 15px var(--serif);
  letter-spacing: 0;
  text-transform: none;
}

.summary-items {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-top: 8px;
  color: #666c63;
  font-size: 11.5px;
}

.form-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
  padding: 16px 0 22px;
  border-top: 1px solid var(--line);
}

.required-note {
  color: var(--subtle);
  font-size: 11px;
}

.button {
  min-height: 48px;
  border: 0;
  border-radius: 6px;
  padding: 0 18px;
  font: 600 12.5px var(--sans);
  cursor: pointer;
  transition: background 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.button.primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: var(--green);
  color: #fff;
  box-shadow: 0 6px 14px rgba(29, 71, 52, 0.18);
}

.button.primary:hover {
  background: var(--green-dark);
  transform: translateY(-1px);
}

.button.primary:focus-visible {
  outline: 3px solid #a9b5a3;
  outline-offset: 3px;
}

.button:disabled {
  opacity: 0.75;
  cursor: wait;
}

.button-arrow {
  font-size: 15px;
}

.spinner {
  display: none;
  width: 14px;
  height: 14px;
  border: 1.8px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.is-loading .button-label,
.is-loading .button-arrow {
  display: none;
}

.is-loading .spinner {
  display: block;
}

.form-message {
  margin-bottom: 16px;
  color: var(--green);
  font-size: 12.5px;
  line-height: 1.5;
}

.form-message.is-error {
  color: var(--danger);
}

.card-footer {
  height: 44px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #988765;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.13em;
}

.card-footer span:last-child {
  color: #8d7040;
}

.page-foot {
  padding: 18px 0 4px;
  text-align: center;
  color: #8e7e5d;
  font: italic 13px var(--display-serif);
}

/* Success screen */
.success-screen {
  padding: 36px 0 32px;
  text-align: center;
  animation: arrive 0.35s ease-out;
}

.success-icon {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  margin: 0 auto 18px;
  border-radius: 50%;
  background: #edf2e9;
  border: 1px solid #d7c79f;
}

.success-icon svg {
  width: 28px;
  height: 28px;
  fill: none;
  stroke: var(--green);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 40;
  stroke-dashoffset: 40;
  animation: draw 0.6s 0.2s ease forwards;
}

.success-screen > .eyebrow {
  justify-content: center;
}

.success-screen h2 {
  margin-top: 14px;
  color: #1f3c2f;
  font: 500 34px/1.15 var(--serif);
}

.success-screen h2 em {
  color: var(--green);
  font-weight: 500;
}

.success-screen > p {
  margin: 10px auto 0;
  color: var(--muted);
  font-size: 13.5px;
}

.reference-box {
  margin: 16px auto;
  padding: 11px 14px;
  background: #f6f4ec;
  border-radius: 6px;
}

.reference-box span {
  display: block;
  margin-bottom: 4px;
  color: #8d8a7e;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.reference-box strong {
  color: var(--green-dark);
  font-size: 12px;
  word-break: break-all;
}

.success-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  max-width: 330px;
  margin: 0 auto 16px;
  padding: 12px 0;
  border-block: 1px solid var(--line);
}

.success-stats > div {
  border-right: 1px solid var(--line);
}

.success-stats > div:last-child {
  border: 0;
}

.success-stats strong {
  display: block;
  color: var(--green-dark);
  font: 600 20px var(--serif);
}

.success-stats span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.success-footnote {
  color: #878273;
  font-size: 12px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes arrive {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes draw {
  to { stroke-dashoffset: 0; }
}

[hidden] {
  display: none !important;
}

@media (max-width: 560px) {
  .registration-options {
    flex-direction: column;
  }
  .page-shell {
    padding: 8px 12px calc(90px + env(safe-area-inset-bottom, 0px));
  }

  .site-credit {
    left: 0;
    right: 0;
    bottom: 0;
    max-width: none;
    justify-content: center;
    border-radius: 0;
    border-inline: 0;
    border-bottom: 0;
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  }

  .church-logo {
    width: 124px;
    height: 122px;
  }

  .form-card {
    padding: 20px 18px 0;
    border-radius: 12px;
  }

  .rsvp-heading h2 {
    font-size: 19px;
  }

  .rsvp-heading p {
    font-size: 16px;
  }

  .guest-section {
    padding: 15px 0;
  }

  .count-panel {
    padding: 12px;
  }

  .meal-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
  }

  .meal-field {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 90px;
    align-items: center;
    gap: 10px;
  }

  .meal-field > span {
    margin: 0;
    font-size: 14px;
    overflow-wrap: anywhere;
  }

  .meal-heading span,
  .field label,
  .select-field,
  .count-field {
    font-size: 14px;
  }

  .meal-heading small,
  .error,
  .section-heading p,
  .summary-items {
    font-size: 13px;
    color: var(--muted);
  }

  .error {
    color: var(--danger);
  }

  .meal-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 3px;
  }

  .toggle-option {
    flex: 1;
  }

  .toggle-option span {
    font-size: 14px;
  }

  .form-footer {
    flex-direction: column-reverse;
    align-items: stretch;
    gap: 10px;
  }

  .form-footer .button {
    width: 100%;
    font-size: 16px;
  }

  .required-note {
    text-align: center;
  }

  .card-footer {
    height: auto;
    min-height: 44px;
    flex-wrap: wrap;
    gap: 4px 12px;
    padding-block: 10px;
  }

  input,
  select,
  .button {
    scroll-margin-block: 20px 100px;
  }

  .name-field input,
  .select-field select,
  .count-field input,
  .meal-field input {
    height: 48px;
    font-size: 16px;
  }

  .card-footer {
    font-size: 8px;
    letter-spacing: 0.09em;
  }
}

@media (max-width: 359px) {
  .count-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .form-card {
    padding-inline: 14px;
  }

  .family-total {
    padding-inline: 10px;
  }
}

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