:root {
  color-scheme: light;
  --paper: #fbf6eb;
  --ink: #263d24;
  --muted: #6f765f;
  --gold: #cfa457;
  --marigold: #f37a16;
  --decline: #b33a2f;
  --decline-soft: #f8e4df;
  --soft-green: #dfe8d5;
  --clay: #9b4c20;
  --white: #fffdf7;
  --shadow: 0 24px 70px rgba(65, 45, 21, 0.24);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: Inter, system-ui, sans-serif;
  background:
    radial-gradient(circle at 12% 18%, rgba(243, 122, 22, 0.2), transparent 24rem),
    radial-gradient(circle at 88% 82%, rgba(207, 164, 87, 0.22), transparent 22rem),
    linear-gradient(135deg, #efe7d7 0%, #faf4e9 48%, #e9efdf 100%);
}

[hidden] {
  display: none !important;
}

button,
input,
textarea {
  font: inherit;
}

.preview-shell {
  width: min(1440px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: clamp(18px, 3vw, 42px) clamp(16px, 3vw, 42px) 36px;
}

.preview-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 68px;
  border-bottom: 1px solid rgba(56, 66, 42, 0.18);
}

.eyebrow,
.panel-kicker {
  margin: 0 0 5px;
  color: var(--clay);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-weight: 700;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(1.45rem, 2.6vw, 2.35rem);
}

h2 {
  font-size: clamp(1.65rem, 2.8vw, 2.6rem);
  line-height: 1;
}

.preview-actions,
.button-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-button,
.text-button,
.primary-button,
.secondary-button {
  min-height: 44px;
  border: 1px solid rgba(38, 61, 36, 0.22);
  cursor: pointer;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

.icon-button {
  width: 44px;
  border-radius: 999px;
  color: var(--ink);
  background: rgba(255, 253, 247, 0.78);
  font-size: 1.35rem;
}

.text-button,
.secondary-button {
  border-radius: 999px;
  color: var(--ink);
  background: rgba(255, 253, 247, 0.82);
  padding: 0 18px;
  font-weight: 700;
}

.primary-button {
  width: 100%;
  border: 0;
  border-radius: 999px;
  color: #fffdf8;
  background: var(--ink);
  padding: 0 22px;
  font-weight: 800;
  box-shadow: 0 12px 24px rgba(38, 61, 36, 0.24);
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(65, 45, 21, 0.14);
}

.invitation-stage {
  display: grid;
  grid-template-columns: minmax(320px, 0.86fr) minmax(330px, 440px);
  gap: clamp(22px, 4vw, 54px);
  align-items: center;
  padding-top: clamp(12px, 2.5vw, 28px);
}

.invitation-stage:has(#rsvpStep.is-active) {
  align-items: start;
}

.card-wrap {
  position: relative;
  display: grid;
  place-items: center;
  min-height: calc(100vh - 78px);
}

.invitation-stage:has(#rsvpStep.is-active) .card-wrap {
  align-items: start;
}

.invitation-card {
  position: relative;
  z-index: 1;
  width: min(600px, 100%);
  margin: 0;
  overflow: hidden;
  border-radius: 4px;
  background: var(--paper);
  box-shadow: var(--shadow);
  transform-origin: center;
  opacity: 1;
  animation: cardFromEnvelope 2200ms cubic-bezier(0.18, 0.82, 0.22, 1) both;
}

.invitation-card img {
  display: block;
  width: 100%;
  height: auto;
}

.envelope {
  position: absolute;
  z-index: 3;
  display: grid;
  place-items: center;
  width: min(470px, 92%);
  aspect-ratio: 1.62;
  border: 0;
  border-radius: 6px;
  background:
    linear-gradient(145deg, transparent 49.5%, rgba(255, 255, 255, 0.09) 50%, transparent 50.5%),
    linear-gradient(215deg, transparent 49.5%, rgba(0, 0, 0, 0.18) 50%, transparent 50.5%),
    linear-gradient(145deg, #28442c, #142a1a);
  box-shadow: var(--shadow);
  opacity: 1;
  pointer-events: none;
  transform: translateY(96px) scale(0.96);
  animation: envelopeExit 2200ms cubic-bezier(0.18, 0.82, 0.22, 1) both;
}

.envelope-flap {
  position: absolute;
  inset: 0;
  clip-path: polygon(0 0, 50% 56%, 100% 0);
  background: linear-gradient(180deg, #385b3d, #213b27);
  transform-origin: 50% 0;
  animation: flapOpen 850ms ease-in-out 180ms both;
}

.envelope-card {
  position: relative;
  display: grid;
  place-items: center;
  gap: 8px;
  width: 76%;
  height: 18%;
  align-self: start;
  margin-top: 18%;
  border: 1px solid rgba(251, 246, 235, 0.32);
  background: rgba(251, 246, 235, 0.14);
  color: transparent;
  transform: translateY(8px);
  animation: insertSlipsAway 720ms ease 120ms both;
}

.tiny-script {
  font-family: Parisienne, cursive;
  font-size: clamp(2rem, 5vw, 3.5rem);
}

.tiny-copy,
.envelope-copy {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.rsvp-panel {
  position: sticky;
  top: 22px;
  align-self: center;
  padding: clamp(24px, 3vw, 32px);
  border: 1px solid rgba(207, 164, 87, 0.44);
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.9);
  box-shadow: 0 20px 48px rgba(65, 45, 21, 0.16);
  backdrop-filter: blur(16px);
}

.rsvp-panel:has(#rsvpStep.is-active) {
  align-self: start;
}

.progress {
  display: flex;
  gap: 8px;
  margin-bottom: 26px;
}

.progress-dot {
  width: 38px;
  height: 4px;
  border-radius: 999px;
  background: rgba(38, 61, 36, 0.18);
}

.progress-dot.is-active {
  background: var(--marigold);
}

.flow-step {
  display: none;
}

.flow-step.is-active {
  display: grid;
  gap: 18px;
}

#rsvpStep {
  font-family: "Cormorant Garamond", Georgia, serif;
}

#rsvpStep .panel-kicker,
#rsvpStep button {
  font-family: Inter, system-ui, sans-serif;
}

label,
legend {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

input,
textarea {
  width: 100%;
  margin-top: 8px;
  border: 1px solid rgba(38, 61, 36, 0.24);
  border-radius: 6px;
  background: #fffaf1;
  color: var(--ink);
  padding: 13px 14px;
  outline: 0;
}

input:focus,
textarea:focus {
  border-color: var(--marigold);
  box-shadow: 0 0 0 4px rgba(243, 122, 22, 0.14);
}

textarea {
  resize: vertical;
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.segmented legend,
.group-box legend {
  grid-column: 1 / -1;
  margin-bottom: 10px;
}

.segmented label {
  min-height: 84px;
  cursor: pointer;
}

.segmented input,
.check-row input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  opacity: 0;
  pointer-events: none;
}

.segmented span {
  display: grid;
  place-items: center;
  height: 100%;
  min-height: 84px;
  border: 1px solid rgba(38, 61, 36, 0.2);
  border-radius: 8px;
  background: #fffaf1;
  color: var(--ink);
  text-align: center;
  font-size: 0.95rem;
}

.segmented input:checked + span {
  border-color: var(--ink);
  background: var(--soft-green);
  box-shadow: inset 0 0 0 2px var(--ink);
}

.segmented input[value="no"]:checked + span {
  border-color: var(--decline);
  background: var(--decline-soft);
  color: var(--decline);
  box-shadow: inset 0 0 0 2px var(--decline);
}

.group-box {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid rgba(207, 164, 87, 0.44);
  border-radius: 8px;
  background: rgba(251, 246, 235, 0.76);
}

.group-help,
.not-found p {
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

.quick-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.danger-button {
  color: var(--decline);
  border-color: rgba(179, 58, 47, 0.35);
}

.guest-list {
  display: grid;
  gap: 12px;
}

.guest-rsvp {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid rgba(38, 61, 36, 0.14);
  border-radius: 8px;
  background: rgba(255, 250, 241, 0.84);
}

.guest-name {
  color: var(--ink);
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 1.28rem;
  font-weight: 700;
}

.guest-rsvp .segmented {
  grid-template-columns: 1fr 1fr;
}

.guest-rsvp .segmented label,
.guest-rsvp .segmented span {
  min-height: 50px;
}

.button-row .primary-button,
.button-row .secondary-button {
  width: auto;
  flex: 1;
}

.confirmation p:not(.panel-kicker),
.not-found p {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.6;
}

.event-summary {
  display: grid;
  gap: 12px;
  padding: 18px 20px;
  border: 1px solid rgba(207, 164, 87, 0.58);
  border-left: 5px solid var(--marigold);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(255, 250, 241, 0.96), rgba(223, 232, 213, 0.76));
  box-shadow: 0 12px 26px rgba(65, 45, 21, 0.12);
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.18;
}

.event-summary span:first-child {
  color: var(--clay);
  font-size: 1.38rem;
}

.event-summary span:nth-child(2) {
  color: var(--ink);
  font-size: 1.26rem;
}

.event-summary span:last-child {
  color: #435a33;
  font-size: 1.12rem;
}

.event-summary--compact {
  gap: 10px;
  padding: 18px 20px;
}

@keyframes cardFromEnvelope {
  0% {
    opacity: 0;
    transform: translateY(118px) rotate(90deg) scale(0.29);
  }
  14% {
    opacity: 1;
    transform: translateY(118px) rotate(90deg) scale(0.29);
  }
  48% {
    opacity: 1;
    transform: translateY(-88px) rotate(90deg) scale(0.36);
  }
  70% {
    opacity: 1;
    transform: translateY(-68px) rotate(0deg) scale(0.56);
  }
  86% {
    opacity: 1;
    transform: translateY(8px) rotate(0deg) scale(0.84);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes envelopeExit {
  0% {
    opacity: 1;
    transform: translateY(96px) scale(0.96);
  }
  66% {
    opacity: 1;
    transform: translateY(96px) scale(0.96);
  }
  100% {
    opacity: 0;
    transform: translateY(132px) scale(0.9);
  }
}

@keyframes flapOpen {
  from {
    transform: rotateX(0deg);
  }
  to {
    transform: rotateX(64deg);
  }
}

@keyframes insertSlipsAway {
  from {
    opacity: 0.9;
    transform: translateY(8px);
  }
  to {
    opacity: 0;
    transform: translateY(-46px);
  }
}

@media (max-width: 920px) {
  .preview-bar {
    align-items: flex-start;
  }

  .invitation-stage {
    grid-template-columns: 1fr;
  }

  .card-wrap {
    min-height: 0;
  }

  .invitation-card {
    width: min(520px, 100%);
  }

  .rsvp-panel {
    position: static;
    min-height: auto;
  }
}

@media (max-width: 560px) {
  .preview-shell {
    padding-inline: 12px;
  }

  .preview-actions {
    display: none;
  }

  .segmented,
  .quick-actions,
  .button-row {
    grid-template-columns: 1fr;
  }

  .button-row {
    display: grid;
  }
}

.admin-body {
  background:
    radial-gradient(circle at 15% 18%, rgba(243, 122, 22, 0.16), transparent 22rem),
    linear-gradient(135deg, #fbf6eb 0%, #eef3e7 100%);
}

.admin-shell {
  width: min(1180px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: clamp(18px, 3vw, 36px);
}

.admin-login {
  display: grid;
  min-height: calc(100vh - 72px);
  place-items: center;
}

.admin-login-card {
  display: grid;
  width: min(420px, 100%);
  gap: 18px;
  padding: clamp(24px, 4vw, 34px);
  border: 1px solid rgba(207, 164, 87, 0.44);
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.92);
  box-shadow: 0 20px 48px rgba(65, 45, 21, 0.15);
}

.admin-dashboard {
  display: grid;
  gap: 22px;
}

.admin-header,
.admin-toolbar,
.admin-group-header,
.member-row,
.add-member-form {
  display: flex;
  align-items: end;
  gap: 12px;
}

.admin-header,
.admin-group-header,
.member-row {
  justify-content: space-between;
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 12px;
}

.stat-tile,
.admin-toolbar,
.admin-group,
.empty-state {
  border: 1px solid rgba(207, 164, 87, 0.34);
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.86);
  box-shadow: 0 14px 32px rgba(65, 45, 21, 0.1);
}

.stat-tile {
  display: grid;
  gap: 6px;
  padding: 16px;
}

.stat-tile span,
.admin-group p,
.empty-group,
.admin-message {
  color: var(--muted);
  font-size: 0.9rem;
}

.stat-tile strong {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 2.3rem;
  line-height: 1;
}

.admin-toolbar {
  padding: 16px;
}

.admin-toolbar label {
  flex: 1;
}

.admin-toolbar .primary-button,
.add-member-form .primary-button {
  width: auto;
}

.admin-message {
  min-height: 1.2em;
  font-weight: 700;
}

.admin-error,
.admin-message.is-error {
  min-height: 1.2em;
  margin: 0;
  color: var(--decline);
  font-weight: 700;
}

.group-grid {
  display: grid;
  gap: 16px;
}

.admin-group {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.admin-group h2 {
  font-size: clamp(1.45rem, 2vw, 2rem);
}

.admin-group p,
.empty-group {
  margin: 4px 0 0;
}

.member-list {
  display: grid;
  gap: 8px;
}

.member-row {
  min-height: 58px;
  padding: 10px 12px;
  border: 1px solid rgba(38, 61, 36, 0.12);
  border-radius: 8px;
  background: rgba(251, 246, 235, 0.68);
}

.member-row > div {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.status-pill {
  display: inline-grid;
  min-width: 82px;
  place-items: center;
  border-radius: 999px;
  padding: 5px 10px;
  background: #fffaf1;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.status-yes {
  background: var(--soft-green);
  color: var(--ink);
}

.status-no {
  background: var(--decline-soft);
  color: var(--decline);
}

.add-member-form {
  align-items: end;
  padding-top: 4px;
}

.add-member-form label {
  flex: 1;
}

.empty-state {
  padding: 26px;
  color: var(--muted);
  text-align: center;
  font-weight: 700;
}

@media (max-width: 820px) {
  .admin-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-header,
  .admin-toolbar,
  .admin-group-header,
  .add-member-form {
    align-items: stretch;
    flex-direction: column;
  }

  .admin-toolbar .primary-button,
  .add-member-form .primary-button {
    width: 100%;
  }
}
