:root {
  --bg: #faf6f0;
  --surface: #ffffff;
  --text: #1f2a2e;
  --muted: #5d6a6e;
  --line: #e4ddd2;
  --accent: #b3261e;
  --accent-ink: #ffffff;
  --accent-soft: #fbe9e7;
  --green: #1e7a46;
  --green-soft: #e3f4ea;
  --gold-soft: #fdf3d8;
  --gold: #8a5a00;
  --grey-soft: #eef0f1;
  --danger: #a01818;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.04);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14191b;
    --surface: #1d2427;
    --text: #e9eef0;
    --muted: #a3afb3;
    --line: #2f383c;
    --accent: #ef6a5f;
    --accent-ink: #1a0b0a;
    --accent-soft: #3a2220;
    --green: #6fd39b;
    --green-soft: #183326;
    --gold-soft: #3a3016;
    --gold: #f0c46b;
    --grey-soft: #262e31;
    --danger: #ff8a80;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
main { max-width: 760px; margin: 0 auto; padding: 0 16px 48px; }
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; margin-top: 1.25em; }
p { margin: 0 0 .75em; }

header.site, footer.site { max-width: 760px; margin: 0 auto; padding: 16px; }
header.site .brand { font-weight: 700; font-size: 1.1rem; text-decoration: none; color: var(--text); }
footer.site { color: var(--muted); font-size: .85rem; text-align: center; }

.hero { padding: 24px 0 8px; }
.hero p { color: var(--muted); font-size: 1.05rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin: 16px 0;
}
.card.narrow { max-width: 460px; }
.card.center { text-align: center; margin-top: 48px; }
.card-accent { border-color: var(--accent); background: linear-gradient(var(--accent-soft), var(--surface) 70%); }
.card-result { border: 2px solid var(--green); }
.card-result .receiver { color: var(--green); }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }

.campaign-head { padding: 16px 0 0; }
.facts { display: flex; flex-wrap: wrap; gap: 8px 28px; margin: 0; }
.facts div { display: flex; gap: 8px; align-items: baseline; }
.facts dt { color: var(--muted); font-size: .9rem; }
.facts dd { margin: 0; font-weight: 600; }

.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: .9rem; margin-top: .75em; }
.notice { background: var(--gold-soft); color: var(--text); border-radius: 8px; padding: 10px 12px; }
.notice-gift { background: var(--accent-soft); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.flash { border-radius: 8px; padding: 12px 14px; margin: 16px 0; font-weight: 500; }
.flash-ok { background: var(--green-soft); color: var(--green); }
.flash-error { background: var(--accent-soft); color: var(--danger); }
.flash-toast {
  position: fixed; z-index: 10; top: 12px; left: 50%; transform: translateX(-50%);
  width: min(560px, calc(100% - 32px)); margin: 0;
  box-shadow: 0 4px 20px rgba(0,0,0,.18); cursor: pointer;
  transition: opacity .3s, transform .3s;
}
.flash-toast-gone { opacity: 0; transform: translate(-50%, -12px); pointer-events: none; }

label { font-weight: 600; display: block; margin-bottom: 4px; }
input[type=text], input[type=password], input[type=date], input[type=email], input:not([type]), select, textarea {
  width: 100%;
  font: inherit;
  color: inherit;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}
textarea { resize: vertical; min-height: 9em; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.stack { display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
.stack > .btn { align-self: flex-start; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-form .wide { grid-column: 1 / -1; }
@media (max-width: 560px) { .grid-form { grid-template-columns: 1fr; } }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.inline-form select { width: auto; flex: 1 1 140px; }

.btn {
  display: inline-block;
  font: inherit;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 10px 20px;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
  text-decoration: none;
  line-height: 1.2;
}
.btn:hover { filter: brightness(1.07); }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.btn-secondary { background: transparent; color: var(--accent); border-color: var(--accent); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-link { background: none; border: 0; color: var(--accent); padding: 4px 0; text-decoration: underline; font-weight: 500; }
.btn-small { padding: 6px 14px; font-size: .9rem; }
.btn-big { padding: 14px 28px; font-size: 1.1rem; }
.toolbar { display: flex; justify-content: space-between; align-items: center; padding-top: 8px; }

.copy-field { margin-top: 12px; }
.copy-row { display: flex; gap: 8px; flex-wrap: wrap; }
.copy-row input { font-family: ui-monospace, monospace; font-size: .85rem; }
.copy-row .btn { flex: none; }
.copy-row > input { flex: 1 1 200px; min-width: 0; }
.email-send > summary { list-style: none; cursor: pointer; }
.email-send > summary::-webkit-details-marker { display: none; }
.email-form { margin-top: 12px; }
.email-form label { font-weight: 500; }
/* The form follows the toggle. Browsers without :has keep it visible, so it
   is never out of reach. */
@supports selector(:has(*)) {
  .copy-field .email-form { display: none; }
  .copy-field:has(.email-send[open]) .email-form { display: block; }
}
.email-send[open] > summary { border-color: var(--accent); background: var(--accent-soft); }
.email-row { display: flex; gap: 8px; flex-wrap: wrap; }
.email-row input { flex: 1 1 200px; min-width: 0; }
.btn-copy { display: inline-flex; align-items: center; gap: 6px; }
.btn-icon { padding: 6px 9px; }
.btn-copy.copied { border-color: var(--green); color: var(--green); }
.icon { flex: none; }

.pill { display: inline-block; font-size: .8rem; font-weight: 600; padding: 2px 10px; border-radius: 999px; }
.pill-open { background: var(--gold-soft); color: var(--gold); }
.pill-done { background: var(--green-soft); color: var(--green); }

.members { list-style: none; margin: 0; padding: 0; }
.member {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) auto;
  grid-template-areas: "name actions" "badges badges";
  gap: 6px 12px;
  align-items: center;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.member:first-child { border-top: 0; }
.member-me .member-name { color: var(--accent); }
.member-help {
  background: var(--gold-soft);
  border-radius: 8px;
  border-top-color: transparent;
  padding-left: 10px;
  padding-right: 10px;
  margin: 4px -10px;
}
.member-help + .member { border-top-color: transparent; }
.my-status {
  display: inline-flex; gap: 8px; align-items: center;
  margin: 0 0 12px; padding: 6px 14px; border-radius: 999px;
  background: var(--grey-soft); color: var(--muted); font-weight: 600;
}
.my-status-ready { background: var(--green-soft); color: var(--green); }
.card-accent .facts { margin: 0 0 12px; }
.greeting { margin: 0 0 14px; padding: 12px 14px; border-left: 3px solid var(--gold); background: var(--surface); border-radius: 0 8px 8px 0; }
.card-mine > summary { cursor: pointer; font-weight: 600; font-size: 1.05rem; }
.card-mine[open] > summary { margin-bottom: 12px; }
.card-help {
  border-color: var(--gold);
  background: var(--gold-soft);
  display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between;
}
.card-help p { margin: 0; font-size: 1.05rem; }
.member-name { grid-area: name; font-weight: 600; }
.member-actions { grid-area: actions; justify-self: end; }
.member-actions .btn { white-space: nowrap; }
@media (max-width: 520px) {
  .member { grid-template-columns: 1fr; grid-template-areas: "name" "badges" "actions"; }
  .member-actions { justify-self: start; }
}
.badges { grid-area: badges; list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; }
.badge { font-size: .8rem; padding: 3px 10px; border-radius: 999px; background: var(--grey-soft); color: var(--muted); }
.badge-yes, .badge-ready { background: var(--green-soft); color: var(--green); }
.badge-ready { font-weight: 700; }
.badge-no, .badge-wait { background: var(--grey-soft); color: var(--muted); }
.badge-think { background: var(--gold-soft); color: var(--gold); }
.badge-gift { background: var(--accent-soft); color: var(--accent); }
.badge-help { background: var(--gold); color: var(--surface); font-weight: 700; }

.campaigns, .exclusions { list-style: none; margin: 0 0 12px; padding: 0; }
.campaigns li, .exclusions li {
  display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center;
  padding: 10px 0; border-top: 1px solid var(--line);
}
.campaigns li:first-child, .exclusions li:first-child { border-top: 0; }
.campaigns a { font-weight: 600; }
.campaigns .btn-icon { line-height: 1; }
.exclusions li { justify-content: space-between; }

.box { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }
.surprises { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.prose > :last-child { margin-bottom: 0; }
.prose ul, .prose ol { padding-left: 1.4em; margin: 0 0 .75em; }
.prose a { word-break: break-word; }

.md-editor { display: flex; flex-direction: column; gap: 6px; }
.md-bar { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.md-bar[hidden] { display: none; }
.md-bar button {
  font: inherit; font-size: .9rem; color: var(--text);
  background: var(--grey-soft); border: 1px solid var(--line); border-radius: 6px;
  padding: 5px 10px; cursor: pointer; min-width: 36px;
}
.md-bar button:disabled { opacity: .4; cursor: default; }
.md-bar button.active { background: var(--surface); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.md-tabs { display: flex; gap: 4px; margin-left: auto; }
.md-preview { border: 1px dashed var(--line); border-radius: 8px; padding: 10px 12px; }

.switch-form { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.switch-form.stack { align-items: flex-start; }
.switch { display: flex; align-items: center; gap: 12px; cursor: pointer; font-weight: 500; margin: 0; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track {
  flex: none; width: 46px; height: 26px; border-radius: 999px; background: var(--line);
  position: relative; transition: background .15s;
}
.switch-track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px;
  border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.3);
}
.switch input:checked + .switch-track { background: var(--green); }
/* "Still thinking" is a pause, not a success, so it is not green. */
.switch-think input:checked + .switch-track { background: var(--gold); }
.switch input:checked + .switch-track::after { transform: translateX(20px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }
.js .js-hide { display: none; }

/* ==========================================================================
   Christmas theme. Everything festive lives in this block and only
   overrides the tokens and a few surfaces above, so it can be dropped as a
   whole. Decoration never carries meaning and stays out of the way of
   reading: snow is faint, sits behind the content and stops for people who
   ask for less motion.
   ========================================================================== */

:root {
  --bg: #f8f3ea;
  --surface: #fffdf8;
  --text: #1d2a22;
  --muted: #5b6a60;
  --line: #e6dccb;
  --accent: #b0151f;          /* Christmas red */
  --accent-ink: #ffffff;
  --accent-soft: #fbe6e4;
  --green: #1c6b3c;           /* fir green */
  --green-soft: #e1f1e6;
  --gold: #8f6410;
  --gold-soft: #fbf0d6;
  --grey-soft: #efece4;
  --danger: #a3121b;
  --pine: #123d29;            /* header band */
  --pine-ink: #fdf8ec;
  --snow: rgba(140, 160, 150, .16);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1a14;            /* winter night */
    --surface: #15261d;
    --text: #edf3ee;
    --muted: #a3b5a9;
    --line: #26392e;
    --accent: #ff6b6b;
    --accent-ink: #1c0909;
    --accent-soft: #3b1c1c;
    --green: #7ad6a0;
    --green-soft: #173527;
    --gold: #eac46f;
    --gold-soft: #352d15;
    --grey-soft: #1e3026;
    --danger: #ff8f8f;
    --pine: #0a2618;
    --pine-ink: #f4efe2;
    --snow: rgba(255, 255, 255, .10);
  }
}

/* Gentle snowfall on top of the pattern, behind everything else. */
body::before {
  content: "";
  /* The layer moves by one tile and starts one tile higher, and every
     tile size divides that distance, so the loop restarts seamlessly. */
  position: fixed; inset: -240px 0 0 0;
  pointer-events: none; z-index: 0;
  background-image:
    radial-gradient(circle at 10% 10%, var(--snow) 0 2.5px, transparent 3.5px),
    radial-gradient(circle at 60% 40%, var(--snow) 0 2px, transparent 3px),
    radial-gradient(circle at 85% 75%, var(--snow) 0 1.5px, transparent 2.5px);
  background-size: 240px 240px, 120px 120px, 80px 80px;
  animation: snowfall 30s linear infinite;
}
@keyframes snowfall {
  from { transform: translateY(0); }
  to   { transform: translateY(240px); }
}
@media (prefers-reduced-motion: reduce) {
  body::before { animation: none; }
}
/* Positioned without a z-index, content paints above the snow (which
   comes earlier in the page) without opening a stacking context of its
   own, so the toast inside it can rise above the sticky header. */
main, footer.site { position: relative; }

/* Fir-green band across the top with a candy-cane edge. */
/* The header spans the full width; its content lines up with the column
   through padding, so nothing reaches past the viewport. */
header.site {
  /* Stays at the top while the page scrolls under it. */
  position: sticky; top: 0; z-index: 5;
  max-width: none;
  padding: 16px max(16px, calc((100% - 760px) / 2 + 16px)) 23px;
  background: var(--pine);
  margin-bottom: 8px;
}
header.site::after {
  content: "";
  position: absolute; left: 0; right: 0; bottom: 0; height: 7px;
  background: repeating-linear-gradient(-45deg, #c8102e 0 9px, #fdf8ec 9px 18px);
}
header.site .brand { color: var(--pine-ink); letter-spacing: .02em; }
header.site .brand-campaign {
  display: block;
  font-family: Georgia, "Iowan Old Style", "Palatino Linotype", "Times New Roman", serif;
  font-size: 1.5rem; font-weight: 600; line-height: 1.25;
  overflow-wrap: anywhere;
}
/* A sticky header must not eat a phone screen: at most two lines. */
@media (max-width: 600px) {
  header.site { padding-top: 12px; padding-bottom: 19px; }
  header.site .brand-campaign {
    font-size: 1.25rem;
    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
    overflow: hidden;
  }
}
.campaign-head { padding-top: 8px; }
header.site .brand::after { content: " ✦"; color: #e8c46a; }

/* Headings in a warm serif. */
h1, h2, .card-mine > summary {
  font-family: Georgia, "Iowan Old Style", "Palatino Linotype", "Times New Roman", serif;
  font-weight: 600;
}
.campaign-head h1, .hero h1 { color: var(--pine); }
@media (prefers-color-scheme: dark) {
  .campaign-head h1, .hero h1 { color: var(--text); }
}

/* Cards: warmer paper and a fine gold top line. */
.card { border-top: 3px solid var(--gold-soft); }
.card-accent { border-top-color: var(--accent); }
.card-result { border-top-color: var(--green); }
.card-help { border-top-color: var(--gold); }

/* The result card gets a bow. */
.card-result { position: relative; }
.card-result::after {
  content: "🎀";
  position: absolute; top: 10px; right: 14px; font-size: 1.5rem;
}

footer.site::before { content: "❄ "; color: var(--muted); }
footer.site::after { content: " ❄"; color: var(--muted); }

/* --- Photo background --------------------------------------------------------
   Gifts on dark wood, fixed behind everything. A fixed layer instead of
   background-attachment: fixed, which mobile Safari ignores and would then
   stretch the photo over the whole page height. The wood in the middle
   stays dark behind the cards; a light veil in light mode and a darker one
   at night keep the edges from competing with the content. */
html { background: #2a1d15; }
body { background: transparent; }
body::after {
  content: "";
  position: fixed; inset: 0; z-index: -1;
  background:
    linear-gradient(rgba(20, 12, 8, .18), rgba(20, 12, 8, .18)),
    url("bg-gifts-1920.jpg") center / cover no-repeat;
}
@media (max-width: 800px) {
  body::after {
    background:
      linear-gradient(rgba(20, 12, 8, .30), rgba(20, 12, 8, .30)),
      url("bg-gifts-1200.jpg") center / cover no-repeat;
  }
}
@media (prefers-color-scheme: dark) {
  body::after {
    background:
      linear-gradient(rgba(5, 12, 9, .55), rgba(5, 12, 9, .55)),
      url("bg-gifts-1920.jpg") center / cover no-repeat;
  }
}
@media (prefers-color-scheme: dark) and (max-width: 800px) {
  body::after {
    background:
      linear-gradient(rgba(5, 12, 9, .62), rgba(5, 12, 9, .62)),
      url("bg-gifts-1200.jpg") center / cover no-repeat;
  }
}

/* Snow stays, a touch brighter so it shows on wood. */
:root { --snow: rgba(255, 255, 255, .22); }
@media (prefers-color-scheme: dark) { :root { --snow: rgba(255, 255, 255, .14); } }

/* Text that sits right on the photo is light with a soft shadow. */
/* Notices have their own background, so they are left out. */
.campaign-head, .hero, .toolbar, main > p:not(.flash), footer.site {
  color: #f8f1e4;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .65);
}
.campaign-head .facts dt, .toolbar .muted, .hero p { color: #e9dcc6; }
.hero h1, .campaign-head h1 { color: #fff8ec; }
main > p:not(.flash) > a, .toolbar .btn-link { color: #ffd98a; }
.campaign-head .pill, .toolbar .btn { text-shadow: none; }
footer.site::before, footer.site::after { color: #e9dcc6; }

/* Cards read as paper laid on the table. */
.card { box-shadow: 0 6px 24px rgba(0, 0, 0, .28); }
