:root {
    color-scheme: light;
    --paper: #faf8f3;
    --ink: #263a31;
    --muted: #59645d;
    --accent: #9a5d48;
    --line: #d9ded7;
    --surface: #f0eee7;
    --attending: #426b4c;
    --declining: #98514c;
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font-body);
    line-height: 1.65;
}

a {
    color: inherit;
}

.skip-link {
    position: absolute;
    top: -4rem;
    left: 1rem;
    z-index: 1;
    padding: 0.6rem 0.9rem;
    background: var(--ink);
    color: white;
}

.skip-link:focus {
    top: 1rem;
}

.site-header {
    border-bottom: 1px solid var(--line);
}

.nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    width: min(100% - 3rem, 68rem);
    min-height: 4.5rem;
    margin: 0 auto;
}

.brand {
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 1.15rem;
    text-decoration: none;
}

.nav-back {
    color: var(--muted);
    font-size: 0.9rem;
    text-underline-offset: 0.25em;
}

main {
    width: min(100% - 3rem, 48rem);
    margin: 0 auto;
}

.rsvp {
    padding: clamp(2.5rem, 6vw, 4rem) 0;
}

.eyebrow {
    margin: 0 0 0.6rem;
    color: var(--accent);
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-align: center;
    text-transform: uppercase;
}

h1,
.attendee-card legend,
.allergies legend {
    font-weight: 400;
}

h1 {
    margin: 0 0 0.6rem;
    font-size: clamp(2rem, 5vw, 3.2rem);
    line-height: 1.15;
    text-align: center;
}

.rsvp-intro {
    max-width: 36rem;
    margin: 0 auto;
    color: var(--muted);
    text-align: center;
}

.rsvp-form {
    max-width: 42rem;
    margin: 1.5rem auto 0;
}

.required-note {
    margin: 0 0 0.75rem;
    color: var(--muted);
    font-size: 0.9rem;
}

.required-mark {
    color: var(--accent);
    font-weight: 700;
}

.rsvp-summary {
    max-width: 42rem;
    margin: 1.5rem auto 0;
}

.rsvp-summary h1:focus {
    outline: none;
}

.summary-count {
    margin: 0.75rem 0 0;
    color: var(--muted);
    text-align: center;
}

.summary-list {
    display: grid;
    gap: 0.75rem;
    margin: 1.25rem 0;
    padding: 0;
    list-style: none;
}

.summary-attendee {
    padding: 1rem;
    border: 1px solid var(--line);
    background: white;
}

.summary-attendee h2 {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 400;
    line-height: 1.3;
}

.summary-attendee p {
    margin: 0.35rem 0 0;
}

.summary-attendance {
    font-weight: 700;
}

.summary-attendance.attending {
    color: var(--attending);
}

.summary-attendance.declining {
    color: var(--declining);
}

.summary-restrictions {
    color: var(--muted);
}

.summary-back {
    display: flex;
    width: fit-content;
    max-width: 100%;
    min-height: 2.7rem;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    padding: 0.5rem 1rem;
    background: var(--ink);
    color: white;
    font-weight: 600;
    text-decoration: none;
}

.summary-back:hover {
    background: var(--attending);
}

.summary-back:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 3px;
}

.attendee-list {
    display: grid;
    gap: 1.5rem;
}

.attendee-card {
    min-width: 0;
    margin: 0;
    padding: 1rem;
    border: 1px solid var(--line);
}

.attendee-card legend,
.allergies legend {
    padding: 0 0.4rem;
    font-size: 1.2rem;
}

.attendee-card {
    border-radius: 0.6rem;
    background: var(--surface);
    box-shadow: 0 2px 8px rgba(38, 58, 49, 0.08);
}

.attendee-card > legend {
    max-width: 100%;
    padding: 0.2rem 0.75rem;
    border-radius: 0.35rem;
    background: var(--accent);
    color: white;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.attendee-topline {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 0.5rem;
}

.attendee-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

.attendee-fields label,
.allergy-options label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.attendee-fields > label,
.attendee-fields .other-allergy {
    align-items: flex-start;
    flex-direction: column;
}

.attendee-fields input[type="text"] {
    width: 100%;
    min-height: 2.5rem;
    padding: 0.5rem 0.65rem;
    border: 1px solid var(--line);
    border-radius: 0.2rem;
    background: white;
    color: var(--ink);
    font: inherit;
}

.attendance-options,
.allergy-mode-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-column: 1 / -1;
    gap: 0.6rem;
    margin: 0;
    padding: 0;
    border: 0;
}

.attendance-options legend,
.allergy-mode-options legend {
    grid-column: 1 / -1;
    margin-bottom: 0;
    font-size: 1rem;
    font-weight: 700;
}

.allergies {
    grid-column: 1 / -1;
    margin: 0;
    padding: 0;
    border: 0;
}

.allergy-options {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
}

.allergy-options .restriction-choice {
    position: relative;
    min-height: 2.5rem;
    font-size: 1.05rem;
    cursor: pointer;
}

.allergy-options .restriction-choice input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

@media (hover: hover) {
    .allergy-options .restriction-choice:hover {
        color: var(--accent);
    }
}

.restriction-choice input:focus-visible + .restriction-toggle {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

.allergy-options .restriction-choice span {
    line-height: 1.3;
}

.restriction-toggle {
    position: relative;
    flex: 0 0 2.2rem;
    height: 1.3rem;
    border: 1px solid var(--muted);
    border-radius: 1rem;
    background: var(--line);
}

.restriction-toggle::before {
    position: absolute;
    top: 50%;
    left: 0.15rem;
    width: 0.9rem;
    height: 0.9rem;
    border-radius: 50%;
    background: white;
    transform: translateY(-50%);
    content: "";
}

.restriction-choice input:checked + .restriction-toggle {
    border-color: var(--accent);
    background: var(--accent);
}

.restriction-choice input:checked + .restriction-toggle::before {
    transform: translate(0.9rem, -50%);
}

.restriction-confirmation {
    color: var(--accent);
    font-weight: 700;
    visibility: hidden;
}

.restriction-confirmation::before {
    content: "\2713";
}

.restriction-choice input:checked ~ .restriction-confirmation {
    visibility: visible;
}

.other-allergy {
    margin-top: 0.75rem;
}

.favorite-song span {
    color: var(--muted);
    font-size: 0.9rem;
    overflow-wrap: anywhere;
}

.favorite-song {
    grid-column: 1 / -1;
}

.choice-button {
    position: relative;
    display: block;
    width: 100%;
    min-width: 0;
    cursor: pointer;
}

.choice-button input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.choice-button span {
    display: flex;
    position: relative;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 2.6rem;
    padding: 0.4rem 0.65rem;
    border: 1px solid var(--line);
    border-radius: 0.35rem;
    background: white;
    color: var(--ink);
    font-weight: 600;
    line-height: 1.25;
    text-align: center;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.choice-button:hover span {
    border-color: var(--accent);
}

.choice-button input:checked + span {
    border-color: var(--ink);
    background: var(--ink);
    color: white;
}

.allergy-mode-options .choice-button input:checked + span {
    border-color: var(--accent);
    background: var(--accent);
}

.attendance-options input[data-attendance="yes"]:checked + span {
    border-color: var(--attending);
    background: var(--attending);
    color: white;
}

.attendance-options input[data-attendance="no"]:checked + span {
    border-color: var(--declining);
    background: var(--declining);
    color: white;
}

.choice-button input:focus-visible + span {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

.rsvp-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-top: 0.75rem;
}

.rsvp-form button,
.rsvp-confirm button {
    min-height: 2.5rem;
    padding: 0.45rem 0.85rem;
    border: 1px solid var(--ink);
    border-radius: 0.2rem;
    background: var(--ink);
    color: white;
    font: inherit;
    cursor: pointer;
}

.rsvp-form button.secondary,
.rsvp-confirm button.secondary {
    background: transparent;
    color: var(--ink);
}

.rsvp-form button:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.rsvp-confirm,
.rsvp-loading {
    width: min(100% - 2rem, 26rem);
    padding: 1.5rem;
    border: 1px solid var(--line);
    border-radius: 0.6rem;
    background: var(--paper);
    color: var(--ink);
    box-shadow: 0 8px 30px rgba(38, 58, 49, 0.2);
}

.rsvp-confirm::backdrop,
.rsvp-loading::backdrop {
    background: rgba(38, 58, 49, 0.5);
}

.rsvp-confirm h2 {
    margin: 0;
    font-size: 1.3rem;
    line-height: 1.3;
}

.rsvp-confirm h2:focus {
    outline: none;
}

.rsvp-confirm p {
    margin: 0.75rem 0 1.25rem;
}

.rsvp-confirm-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

.rsvp-confirm-actions button {
    flex: 1 1 9rem;
}

.rsvp-confirm button:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

.rsvp-loading {
    text-align: center;
}

.rsvp-loading p {
    margin: 0.75rem 0 0;
    font-size: 1.1rem;
    font-weight: 700;
}

.rsvp-loading p:focus {
    outline: none;
}

.rsvp-loading-rings {
    position: relative;
    display: block;
    width: 5rem;
    height: 3.5rem;
    margin: 0 auto;
    animation: rsvp-rings 1.5s ease-in-out infinite;
}

.rsvp-loading-rings::before,
.rsvp-loading-rings::after {
    position: absolute;
    top: 0.4rem;
    width: 2.5rem;
    height: 2.5rem;
    border: 0.2rem solid var(--accent);
    border-radius: 50%;
    content: "";
}

.rsvp-loading-rings::before {
    left: 0.25rem;
}

.rsvp-loading-rings::after {
    right: 0.25rem;
}

@keyframes rsvp-rings {
    0%, 100% { transform: translateY(0) rotate(-4deg); }
    50% { transform: translateY(-0.3rem) rotate(4deg); }
}

.rsvp-limit,
.rsvp-status,
.rsvp-privacy {
    margin: 0.55rem 0 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.rsvp-status {
    min-height: 1.5em;
    color: var(--ink);
    font-weight: 700;
}

.honeypot,
.submit-frame {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    clip-path: inset(50%);
}

footer {
    padding: 1.5rem;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 0.85rem;
    text-align: center;
}

@media (max-width: 600px) {
    .nav {
        width: min(100% - 1.5rem, 68rem);
        min-height: 3.25rem;
    }

    main {
        width: min(100% - 1.5rem, 48rem);
    }

    .rsvp {
        padding: 1rem 0 1.5rem;
    }

    .eyebrow {
        margin-bottom: 0.3rem;
    }

    h1 {
        margin-bottom: 0.4rem;
        font-size: clamp(1.7rem, 8vw, 2.4rem);
    }

    .rsvp-intro {
        font-size: 0.9rem;
        line-height: 1.4;
    }

    .rsvp-form {
        margin-top: 0.75rem;
    }

    .rsvp-summary {
        margin-top: 0.75rem;
    }

    .summary-attendee {
        padding: 0.75rem;
    }

    .attendee-list {
        gap: 1rem;
    }

    .attendee-card {
        padding: 0.7rem;
    }

    .attendee-card legend,
    .allergies legend {
        font-size: 1.05rem;
    }

    .attendee-topline {
        margin-bottom: 0.35rem;
    }

    .attendee-fields {
        gap: 0.5rem;
    }

    .attendee-fields input[type="text"] {
        min-height: 2.35rem;
        padding: 0.35rem 0.5rem;
    }

    .attendance-options,
    .allergy-mode-options {
        gap: 0.45rem;
    }

    .choice-button span,
    .rsvp-form button {
        min-height: 2.35rem;
        padding: 0.35rem 0.5rem;
        font-size: 0.9rem;
    }

    .allergy-options .restriction-choice {
        font-size: 1rem;
    }

    .favorite-song span {
        font-size: 0.8rem;
        line-height: 1.3;
    }

    .rsvp-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.5rem;
        margin-top: 0.6rem;
    }

    .rsvp-limit,
    .rsvp-status,
    .rsvp-privacy {
        margin-top: 0.4rem;
        font-size: 0.78rem;
        line-height: 1.35;
    }

    footer {
        padding: 1rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    .rsvp-loading-rings {
        animation: none;
    }
}
