#modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 110;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
  overflow: hidden;
  background: rgba(75, 56, 47, 0.58);
  backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity 280ms ease;
}

#modal.is-open {
  opacity: 1;
}

#modal .modal-content {
  box-sizing: border-box;
  width: min(760px, 100%);
  max-height: min(88vh, 860px);
  overflow-y: auto;
  margin: 0;
  padding: 0;
  border-radius: 14px;
  border-top: 3px solid #d4a574;
  background: linear-gradient(170deg, #fffdfa 0%, #f5f2ed 100%);
  box-shadow: 0 24px 52px rgba(10, 26, 22, 0.28);
  position: relative;
  top: auto;
  transform: translateY(16px) scale(0.985);
  opacity: 0;
  transition: transform 340ms ease, opacity 340ms ease;
}

#modal.is-open .modal-content {
  transform: translateY(0) scale(1);
  opacity: 1;
}

#modal #modal-body {
  box-sizing: border-box;
  padding: 30px;
  text-align: left;
}

#modal .close {
  position: absolute;
  right: 14px;
  top: 10px;
  border: 0;
  padding: 0;
  background: transparent;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: #7d7a73;
  font-size: 30px;
  line-height: 1;
  cursor: pointer;
  transition: color 180ms ease, background 180ms ease;
}

#modal .close:focus-visible {
  outline: 2px solid #d4a574;
  outline-offset: 2px;
}

#modal .close:hover {
  color: #4b382f;
  background: rgba(212, 165, 116, 0.22);
}

#modal .form-container {
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  text-align: left;
}

#modal .form-container h2 {
  margin: 0;
  color: #4b382f;
  font-size: clamp(30px, 4.2vw, 42px);
  line-height: 1.04;
}

#modal #rsvp-form {
  margin-top: 12px;
  display: grid;
  gap: 0;
  text-align: left;
}

#modal label {
  display: block;
  margin: 0 0 7px;
  color: #4b382f;
  font-size: 13px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  font-weight: 700;
}

#modal input,
#modal textarea,
#modal select {
  box-sizing: border-box;
  width: 100%;
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid rgba(212, 165, 116, 0.64);
  background: rgba(255, 255, 255, 0.92);
  color: #4b382f;
  font-size: 15px;
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

#modal input:focus,
#modal textarea:focus,
#modal select:focus {
  outline: none;
  border-color: #d4a574;
  box-shadow: 0 0 0 3px rgba(212, 165, 116, 0.22);
}

#modal select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, #4b382f 50%),
    linear-gradient(135deg, #4b382f 50%, transparent 50%);
  background-position:
    calc(100% - 22px) calc(50% - 3px),
    calc(100% - 16px) calc(50% - 3px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 42px;
}

#modal .checkbox-group {
  margin: 2px 0 14px;
  display: flex;
  justify-content: flex-start;
}

#modal .checkbox-group label {
  text-transform: none;
  letter-spacing: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-size: 16px;
  font-weight: 500;
}

#modal .checkbox-group input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: #4b382f;
}

#modal .checkbox-group input:focus-visible {
  outline: 2px solid #d4a574;
  outline-offset: 2px;
}

#modal .checkbox-group input:focus-visible + span {
  border-radius: 4px;
  box-shadow: 0 0 0 3px rgba(212, 165, 116, 0.22);
}

#modal .diet-section {
  margin: 2px 0 14px;
}

#modal .diet-section {
  margin: 2px 0 14px;
}

#modal .diet-section select {
  margin-bottom: 0;
}

#modal .companions-section {
  margin: 4px 0 14px;
  display: grid;
  gap: 14px;
}

#modal .companions-list {
  display: grid;
  gap: 14px;
}

#modal .companion-card {
  padding: 16px;
  border: 1px solid rgba(212, 165, 116, 0.46);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.82);
}

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

#modal .companion-card-title {
  margin: 0;
  color: #4b382f;
  font-size: 16px;
  font-weight: 700;
  text-transform: none;
  letter-spacing: 0;
}

#modal .companion-remove {
  border: 0;
  background: transparent;
  color: #9f4f45;
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
  padding: 0;
}

#modal .companion-remove:focus-visible {
  outline: 2px solid #d4a574;
  outline-offset: 2px;
}

#modal .companions-add-button {
  justify-self: start;
  margin-top: 2px;
  padding: 10px 14px;
  border: 1px solid rgba(212, 165, 116, 0.82);
  border-radius: 999px;
  background: rgba(212, 165, 116, 0.16);
  color: #4b382f;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
}

#modal .companions-add-button:hover {
  background: rgba(212, 165, 116, 0.24);
}

#modal .companions-add-button:focus-visible {
  outline: 2px solid #d4a574;
  outline-offset: 2px;
}

#modal textarea {
  resize: vertical;
  min-height: 92px;
  margin-bottom: 14px;
}

#modal .allergies-section[hidden] {
  display: none !important;
}

#modal button[type="submit"] {
  margin-top: 8px;
  width: 100%;
  padding: 12px;
  border: 1px solid rgba(212, 165, 116, 0.82);
  border-radius: 999px;
  background: #d4a574;
  color: #4b382f;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  transition: transform 220ms ease, box-shadow 220ms ease, background 220ms ease;
}

#modal button[type="submit"]:hover {
  background: #dfb688;
  transform: translateY(-2px);
  box-shadow: 0 8px 18px rgba(16, 42, 36, 0.18);
}

@media (max-width: 680px) {
  #modal {
    padding: 12px;
  }

  #modal #modal-body {
    padding: 24px 18px;
  }

  #modal .form-container h2 {
    font-size: clamp(26px, 8vw, 34px);
  }
}

@media (prefers-reduced-motion: reduce) {
  #modal,
  #modal .modal-content,
  #modal .close,
  #modal button[type="submit"],
  #modal input,
  #modal textarea {
    transition: none;
  }
}
