:root {
  color-scheme: light dark;
  --page: #f7f5f1;
  --surface: #fff;
  --ink: #1d1d1f;
  --muted: #5a5853;
  --line: #e4e0d8;
  --field-line: #b5b0a6;
  --button-line: #d4cfc5;
  --accent: #8a5a00;
  --button: #8f5e00;
  --on-button: #fff;
  --accent-wash: #fbf1dc;
  --error: #a3262b;
  --danger: #a3262b;
  --ok: #2f6b3d;
  --shadow: 0 22px 44px -22px #0000004d, 0 2px 8px #00000012;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--page);
}

@media (prefers-color-scheme: dark) {
  :root {
    --page: #121212;
    --surface: #1c1c1e;
    --ink: #f5f5f7;
    --muted: #bcbab4;
    --line: #34332f;
    --field-line: #6e6c66;
    --button-line: #4a4843;
    --accent: #f3c46b;
    --button: #f0bf5f;
    --on-button: #2b1c00;
    --accent-wash: #33291a;
    --error: #ffb3b0;
    --danger: #ffb3b0;
    --ok: #9ed8a9;
    --shadow: 0 20px 40px -14px #000a, 0 3px 8px #0005;
  }
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; line-height: 1.5; background: var(--page); }
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button, summary, .theme, .check, .answer, label.button { cursor: pointer; }
button:disabled { cursor: default; opacity: .6; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.wrap { width: min(1120px, calc(100% - 64px)); margin-inline: auto; }

.masthead { border-bottom: 1px solid var(--line); }
.masthead-quiet { border-bottom: 0; }
.brand { min-height: 66px; display: flex; align-items: center; gap: 11px; font-weight: 750; letter-spacing: -.02em; }
.brand-link { display: flex; align-items: center; gap: 11px; min-height: 44px; color: inherit; text-decoration: none; }
.brand-mark { flex: none; color: var(--button); }
.brand-mark .mark-line { stroke: var(--on-button); }
.brand-by { color: var(--muted); font-weight: 500; }
.nav { display: flex; gap: 22px; margin-left: auto; }
.nav-link { display: inline-flex; align-items: center; min-height: 44px; padding: 0 4px; color: var(--ink); font-size: .92rem; font-weight: 620; text-decoration: none; }
.nav-link:hover { color: var(--accent); }

.intro { padding-block: 44px 30px; max-width: 760px; }
h1 { font-size: clamp(2.2rem, 5vw, 3.6rem); font-weight: 680; line-height: 1.07; letter-spacing: -.045em; overflow-wrap: anywhere; }
.intro p { margin-top: 14px; font-size: clamp(1rem, 2vw, 1.2rem); color: var(--muted); }
h2 { font-size: 1.2rem; font-weight: 680; letter-spacing: -.02em; }

/* Buttons and fields */
button, .button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px;
  border: 1px solid var(--button-line); border-radius: 12px; background: var(--surface); color: var(--ink); font-weight: 620; text-decoration: none; }
button:hover:not(:disabled), .button:hover { border-color: var(--field-line); }
.primary { background: var(--button); border-color: var(--button); color: var(--on-button); }
.primary:hover:not(:disabled) { border-color: var(--button); filter: brightness(1.06); }
.danger { color: var(--danger); }
.danger-solid { background: var(--danger); border-color: var(--danger); color: var(--surface); }
.text-button { min-height: 44px; padding: 0 6px; border: 0; background: none; color: var(--muted); font-weight: 560; text-decoration: underline; text-underline-offset: 3px; }
.field { display: grid; gap: 6px; min-width: 0; }
.field > label, .group > legend { font-weight: 620; font-size: .95rem; }
.group > legend { padding: 0; margin-bottom: 2px; font-size: 1.02rem; }
.optional { color: var(--muted); font-weight: 450; }
input[type=text], input[type=date], input[type=time], select, textarea { width: 100%; min-height: 46px; padding: 10px 12px;
  border: 1px solid var(--field-line); border-radius: 10px; background: var(--surface); }
textarea { resize: vertical; min-height: 110px; line-height: 1.45; }
input:disabled { opacity: .5; }
[aria-invalid=true] { border-color: var(--error) !important; box-shadow: 0 0 0 1px var(--error); }
.hint { color: var(--muted); font-size: .88rem; }
.error { color: var(--error); font-size: .9rem; font-weight: 560; }
.error:empty, .form-status:empty, .hint:empty { display: none; }
.form-status { color: var(--error); font-weight: 560; }
.check { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; }
.check input, .answer input, .theme input { width: 20px; height: 20px; accent-color: var(--button); margin: 0; }

/* Home: your invites */
.mine { margin-bottom: 26px; padding: 18px 22px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.mine h2 { font-size: 1rem; }
.mine-list { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 6px 0 0; padding: 0; list-style: none; }
.mine-list a { display: inline-flex; align-items: center; min-height: 44px; font-weight: 600; }

/* Home: builder */
.builder { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); grid-template-areas: "form preview" "submit preview";
  column-gap: 48px; align-items: start; padding: 32px; border: 1px solid var(--line); border-radius: 24px; background: var(--surface); }
.invite-form { grid-area: form; display: grid; gap: 22px; }
.invite-form h2 { font-size: 1.35rem; }
.group { display: grid; gap: 12px; margin: 0; padding: 0; border: 0; min-width: 0; }
.row { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 12px; }
.preview-col { grid-area: preview; position: sticky; top: 24px; }
.preview-label { margin-bottom: 10px; color: var(--muted); font-size: .8rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.submit-row { grid-area: submit; display: grid; gap: 10px; justify-items: start; margin-top: 26px; }
.submit-row .primary { min-height: 50px; padding-inline: 26px; font-size: 1rem; }
.themes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.theme { position: relative; display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 6px 10px 6px 6px;
  border: 1px solid var(--line); border-radius: 12px; font-size: .92rem; font-weight: 600; }
.theme input { position: absolute; opacity: 0; }
.theme input:checked + .chip { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--button); }
.theme:has(input:checked) { border-color: var(--button); box-shadow: 0 0 0 1px var(--button); }
.theme input:focus-visible + .chip { outline: 3px solid var(--accent); outline-offset: 4px; }

/* Facts and questions */
.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 32px; padding-block: 52px 44px; }
.facts svg { color: var(--accent); }
.facts h2 { margin-top: 10px; font-size: 1.05rem; }
.facts p { margin-top: 6px; color: var(--muted); }
.faq { padding-block: 8px 60px; border-top: 1px solid var(--line); }
.faq > h2 { padding-top: 40px; font-size: 1.5rem; }
.questions { margin-top: 14px; }
details { border-bottom: 1px solid var(--line); }
summary { min-height: 56px; display: flex; align-items: center; font-weight: 620; list-style: none; }
summary::-webkit-details-marker { display: none; }
summary::after { content: '+'; margin-left: auto; padding-left: 16px; color: var(--muted); font-size: 1.3rem; font-weight: 400; }
details[open] summary::after { content: '−'; }
details p { padding-bottom: 18px; max-width: 70ch; color: var(--muted); }

/* Footer and dialogs */
.site-footer { border-top: 1px solid var(--line); color: var(--muted); font-size: .9rem; }
.site-footer .wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; min-height: 72px; padding-block: 10px; }
.site-footer button { min-height: 44px; padding: 0 4px; border: 0; background: none; color: inherit; text-decoration: underline; text-underline-offset: 3px; }
.takedown a { color: inherit; }
dialog { width: min(520px, calc(100% - 32px)); padding: 26px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
dialog::backdrop { background: #0007; }
dialog p { margin-top: 10px; color: var(--muted); }
dialog form[method=dialog] > .primary, dialog > form > .primary { margin-top: 18px; }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.reasons { display: grid; margin: 12px 0 0; padding: 0; border: 0; }
.reasons legend { margin-bottom: 4px; font-weight: 620; }

/* Invite page */
.invite-page { background: var(--page-tint, var(--page)); }
.invite-main { padding-block: 12px 40px; }
.loading { padding-block: 80px; color: var(--muted); text-align: center; }
.gone { max-width: 560px; margin: 60px auto; display: grid; gap: 16px; justify-items: start; }
.gone p { color: var(--muted); }
.invite-layout { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr); gap: 40px; align-items: start; }
.card-col { position: sticky; top: 20px; }
.your-time { margin-top: 14px; color: var(--muted); text-align: center; font-size: .95rem; }
.side { display: grid; gap: 18px; }
.panel { padding: 24px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); }
.panel h2 { margin-bottom: 14px; }
.cal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cal-actions + .hint { margin-top: 10px; }
#reply-form { display: grid; gap: 16px; }
.answers { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 0; padding: 0; border: 0; min-width: 0; }
.answer { position: relative; display: flex; min-height: 48px; font-weight: 620; }
.answer input { position: absolute; opacity: 0; }
.answer span { display: flex; align-items: center; justify-content: center; width: 100%; border: 1px solid var(--button-line); border-radius: 12px; }
.answer input:checked + span { background: var(--accent-wash); border-color: var(--button); box-shadow: inset 0 0 0 1px var(--button); }
.answer input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
#reply-send { justify-self: start; }
.reply-done { display: grid; gap: 8px; }
.reply-summary { font-size: 1.05rem; font-weight: 620; }
.reply-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.loop { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px 24px; margin-top: 44px; padding: 26px 28px;
  border-radius: 20px; background: var(--surface); border: 1px solid var(--line); }
.loop p { margin-top: 4px; color: var(--muted); }
.report-line { margin-top: 18px; text-align: center; color: var(--muted); }

/* Host view */
.host-panel { display: grid; gap: 14px; margin-bottom: 28px; padding: 26px 28px; border: 1px solid var(--line); border-radius: 22px; background: var(--surface); }
.host-heading { font-size: clamp(1.8rem, 4vw, 2.4rem); }
.private-note { display: flex; gap: 8px; align-items: flex-start; color: var(--muted); font-size: .92rem; }
.private-note svg { flex: none; margin-top: 3px; }
.state { padding: 14px 16px; border-radius: 14px; background: var(--accent-wash); }
.state-title { font-weight: 680; }
.state-detail { color: var(--muted); }
.state-rejected, .state-hidden { background: color-mix(in srgb, var(--error) 12%, var(--surface)); }
.share { display: grid; gap: 6px; }
.share label { font-weight: 620; }
.share-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px; }
.replies { grid-column: 2; }
.tally { font-weight: 620; }
.reply-list { margin: 10px 0 0; padding: 0; list-style: none; }
.reply-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; border-top: 1px solid var(--line); }
.reply-who { display: grid; min-width: 0; }
.reply-name { font-weight: 620; overflow-wrap: anywhere; }
.reply-answer { color: var(--muted); font-size: .9rem; }
.answer-yes .reply-answer { color: var(--ok); }
.host-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
#delete-date { margin-top: 10px; }

@media (max-width: 900px) {
  .wrap { width: calc(100% - 32px); }
  .nav-wide { display: none; }
  .builder { grid-template-columns: minmax(0, 1fr); grid-template-areas: "form" "preview" "submit"; padding: 20px; border-radius: 20px; }
  .preview-col { position: static; margin-top: 28px; }
  .submit-row .primary { width: 100%; }
  .invite-layout { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .card-col { position: static; }
  .replies { grid-column: 1; }
  .facts { grid-template-columns: minmax(0, 1fr); gap: 26px; padding-block: 40px 30px; }
}

@media (max-width: 520px) {
  .intro { padding-block: 30px 22px; }
  .row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .row .field:first-child { grid-column: 1 / -1; }
  .themes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cal-actions { grid-template-columns: minmax(0, 1fr); }
  .share-row { grid-template-columns: minmax(0, 1fr) auto; }
  .share-row input { grid-column: 1 / -1; }
  .panel, .host-panel { padding: 20px; }
  .loop { padding: 22px; }
  .loop .button { width: 100%; }
}
