/*
  VOICE   Warm family notes, plain words, nothing salesy.
  IDEA    Gift tags. Each person's list hangs from a paper tag in their own colour; gifts are cards
          with the product photo on a white well, like a catalogue page.
  COLOUR  Pine band and sign-in ground, snow-white page, cranberry for the one main action,
          gold only for "most wanted". Night: the same pine, darker.
  TYPE    Fraunces for names and titles, Figtree for everything else.
  MOTION  Press feedback on every control, sheets and toasts slide in. The things that loop are the
          snow, Santa's occasional sleigh and the elves (snow.js), and they stay off for people who asked for less motion.
*/
:root {
  color-scheme: light dark;
  --pine: #14432f;
  --pine-deep: #0d2f21;
  --pine-ink: #e9f2ec;
  --cranberry: #b3122e;
  --cranberry-press: #95101f;
  --gold: #c8931d;
  --bg: light-dark(#ffffff, #0c1d16);
  --surface: light-dark(#ffffff, #12291f);
  --surface-2: light-dark(#f3f5f1, #183327);
  --ink: light-dark(#14201a, #e8efe9);
  --muted: light-dark(#5b6a61, #9fb2a6);
  --line: light-dark(#e2e7e1, #23443a);
  --well: #ffffff;
  --focus: light-dark(#1f6b4a, #8fd3ad);
  --shadow: 0 1px 2px rgb(10 30 20 / .06), 0 6px 20px -8px rgb(10 30 20 / .18);
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
  --radius: 14px;
  --display: "Fraunces", Georgia, "Times New Roman", serif;
  --body: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
}
:root[data-theme=light] { color-scheme: light; }
:root[data-theme=dark] { color-scheme: dark; }

* { box-sizing: border-box; min-width: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 var(--body); overflow-x: clip;
  -webkit-tap-highlight-color: transparent;
}
img { display: block; max-width: 100%; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
a { color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 8px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.wrap { width: min(1240px, 100% - max(5vw, 32px)); margin-inline: auto; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 18px; border-radius: 999px; border: 1.5px solid transparent;
  font-weight: 600; font-size: 15px; line-height: 1.2; text-decoration: none; white-space: nowrap;
  transition: transform 160ms var(--ease-out), background-color 150ms ease, border-color 150ms ease, color 150ms ease;
}
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--cranberry); color: #fff; }
.btn-primary:active:not(:disabled) { background: var(--cranberry-press); }
.btn-outline { border-color: currentColor; background: transparent; color: light-dark(var(--pine), #bfe3cc); }
.btn-pine { background: var(--pine); color: #fff; }
.btn-quiet { background: var(--surface-2); color: var(--ink); }
.btn-danger { background: transparent; color: light-dark(#a1122a, #ff8a9a); padding-inline: 10px; }
.btn-danger.is-armed { background: light-dark(#a1122a, #c2213d); color: #fff; }
.btn-block { width: 100%; }
.btn-sm { min-height: 44px; padding: 8px 14px; font-size: 14px; }
@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover:not(:disabled) { background: var(--cranberry-press); }
  .btn-outline:hover:not(:disabled) { background: light-dark(rgb(20 67 47 / .07), rgb(191 227 204 / .1)); }
  .btn-pine:hover:not(:disabled) { background: var(--pine-deep); }
  .btn-quiet:hover:not(:disabled) { background: var(--line); }
}
.link-btn {
  background: none; border: 0; padding: 10px 4px; min-height: 44px; color: var(--muted);
  font-size: 14px; font-weight: 600; text-decoration: underline; text-underline-offset: 3px;
}
.spinner {
  width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent;
  animation: spin 600ms linear infinite;
}
@keyframes spin { to { transform: rotate(1turn); } }

/* ---------- fields ---------- */
.field { display: grid; gap: 6px; }
.field label, .label { font-size: 14px; font-weight: 600; }
.input, .textarea {
  width: 100%; min-height: 48px; padding: 12px 14px; font-size: 16px;
  border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
.textarea { min-height: 84px; resize: vertical; line-height: 1.45; }
.input:focus, .textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px light-dark(rgb(31 107 74 / .18), rgb(143 211 173 / .22)); }
.input.pin { letter-spacing: .5em; font-size: 22px; text-align: center; font-variant-numeric: tabular-nums; }
.error { color: light-dark(#a1122a, #ff8a9a); font-size: 14px; font-weight: 600; margin: 0; }
.error:empty { display: none; }
.hint { color: var(--muted); font-size: 14px; margin: 0; }

/* ---------- sign in ---------- */
.auth {
  min-height: 100dvh; display: grid; place-items: center;
  padding: max(24px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
  background-color: var(--pine);
  background-image:
    radial-gradient(circle at 20% 30%, rgb(255 255 255 / .09) 0 2px, transparent 3px),
    radial-gradient(circle at 70% 60%, rgb(255 255 255 / .07) 0 1.5px, transparent 2.5px),
    radial-gradient(circle at 45% 85%, rgb(255 255 255 / .06) 0 2.5px, transparent 3.5px);
  background-size: 180px 180px, 130px 130px, 240px 240px;
}
.auth-card {
  width: min(440px, 100%); background: var(--surface); color: var(--ink);
  border-radius: 22px; padding: clamp(24px, 5vw, 36px); box-shadow: 0 30px 60px -20px rgb(0 0 0 / .45);
}
.auth-title { font: 600 clamp(30px, 6vw, 40px)/1.05 var(--display); margin: 0 0 6px; text-wrap: balance; letter-spacing: -0.01em; }
.auth-sub { color: var(--muted); margin: 0 0 22px; }
.auth form { display: grid; gap: 16px; }
.auth h2 { font: 600 26px/1.1 var(--display); margin: 0 0 4px; }
.auth-step { display: grid; gap: 16px; }
.auth-step[data-enter] { animation: step-in 260ms var(--ease-out); }
@keyframes step-in { from { opacity: 0; transform: translateY(6px); } }
.who {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 168px), 1fr)); gap: 8px;
  max-height: min(46dvh, 380px); overflow-y: auto; padding: 2px; margin: 0 -2px;
}
.who-btn {
  display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 8px 12px; text-align: left;
  background: var(--surface-2); border: 1.5px solid transparent; border-radius: 14px; font-weight: 600;
  transition: transform 160ms var(--ease-out), border-color 150ms ease;
}
.who-btn span:last-child { overflow-wrap: anywhere; line-height: 1.2; }
.who-btn:active { transform: scale(0.97); }
@media (hover: hover) and (pointer: fine) { .who-btn:hover { border-color: var(--line); } }
.row { display: flex; gap: 8px; align-items: center; justify-content: space-between; flex-wrap: wrap; }

/* ---------- avatar ---------- */
.avatar {
  --c: var(--cranberry);
  flex: none; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  background: var(--c); color: #fff; font-size: 13px; font-weight: 700; letter-spacing: .02em;
}
.c0 { --c: #b3122e; } .c1 { --c: #1f6b4a; } .c2 { --c: #8a5a07; } .c3 { --c: #1d5c7a; }
.c4 { --c: #9a4a1c; } .c5 { --c: #3d5260; } .c6 { --c: #0f6e66; } .c7 { --c: #6b5a24; }

/* ---------- header band ---------- */
.band { background: var(--pine); color: var(--pine-ink); padding-top: max(18px, env(safe-area-inset-top)); }
:root[data-theme=dark] .band { background: var(--pine-deep); }
@media (prefers-color-scheme: dark) { :root:not([data-theme=light]) .band { background: var(--pine-deep); } }
.top { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding-block: 14px 20px; }
.brand h1 { font: 600 clamp(30px, 5vw, 48px)/1.05 var(--display); margin: 0; letter-spacing: -0.015em; text-wrap: balance; color: #fff; }
.countdown { margin: 8px 0 0; color: #cfe3d6; font-weight: 500; }
.countdown strong { color: #fff; font-variant-numeric: tabular-nums; }
.user { position: relative; flex: none; }
.user-btn {
  display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 6px 12px 6px 6px;
  border-radius: 999px; border: 1.5px solid rgb(255 255 255 / .22); background: rgb(255 255 255 / .06); color: #fff; font-weight: 600;
  transition: transform 160ms var(--ease-out), background-color 150ms ease;
}
.user-btn:active { transform: scale(0.97); }
.user-btn .user-name { max-width: 14ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (hover: hover) and (pointer: fine) { .user-btn:hover { background: rgb(255 255 255 / .12); } }
.menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 20; min-width: 220px; padding: 6px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
  transform-origin: top right; transition: opacity 150ms var(--ease-out), transform 150ms var(--ease-out);
}
.menu[data-closed] { opacity: 0; transform: scale(0.96); pointer-events: none; }
.menu button {
  display: block; width: 100%; text-align: left; min-height: 44px; padding: 10px 12px; border: 0; border-radius: 10px;
  background: none; font-weight: 500;
}
.menu button:hover, .menu button:focus-visible { background: var(--surface-2); outline: none; }

.chips {
  display: flex; gap: 8px; overflow-x: auto; padding-bottom: 16px; scrollbar-width: none;
  overscroll-behavior-x: contain; scroll-snap-type: x proximity;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; scroll-snap-align: start; display: inline-flex; align-items: center; gap: 8px; min-height: 44px;
  padding: 6px 14px 6px 8px; border-radius: 999px; border: 1.5px solid rgb(255 255 255 / .18);
  background: transparent; color: #e6f1ea; font-weight: 600; font-size: 15px;
  transition: transform 160ms var(--ease-out), background-color 150ms ease, color 150ms ease;
}
.chip.plain { padding-left: 14px; }
.chip .count { font-variant-numeric: tabular-nums; color: rgb(255 255 255 / .6); font-weight: 600; }
.chip .avatar { width: 28px; height: 28px; font-size: 12px; box-shadow: 0 0 0 2px rgb(255 255 255 / .9); }
.chip:active { transform: scale(0.97); }
.chip[aria-pressed=true] { background: #fff; color: var(--pine); border-color: #fff; }
.chip[aria-pressed=true] .count { color: var(--muted); }
@media (hover: hover) and (pointer: fine) { .chip:hover:not([aria-pressed=true]) { background: rgb(255 255 255 / .1); } }

/* ---------- lists ---------- */
main.wrap { padding-block: clamp(24px, 4vw, 44px) 80px; display: grid; gap: clamp(36px, 5vw, 56px); }
.list { display: grid; gap: 18px; }
.list-head { display: flex; align-items: center; gap: 12px 16px; flex-wrap: wrap; }
.list-head .hint { flex: 1 1 260px; }
.tag {
  --c: var(--pine);
  display: inline-flex; align-items: center; margin: 0; padding: 9px 22px 10px 40px; max-width: 100%;
  background: var(--c); color: #fff; font: 600 clamp(22px, 3vw, 28px)/1.1 var(--display); letter-spacing: -0.005em;
  border-radius: 0 10px 10px 0;
  clip-path: polygon(20px 0, 100% 0, 100% 100%, 20px 100%, 0 50%);
  -webkit-mask: radial-gradient(circle 5px at 24px 50%, transparent 96%, #000 100%);
  mask: radial-gradient(circle 5px at 24px 50%, transparent 96%, #000 100%);
}
.tag span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-count { color: var(--muted); font-size: 15px; font-weight: 500; font-variant-numeric: tabular-nums; }

.add {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: start;
  padding: 14px; border-radius: 18px; background: var(--surface-2);
}
.add .input { background: var(--surface); }
.add-extra { grid-column: 1 / -1; display: grid; gap: 10px; }
.add-opts { grid-column: 1 / -1; display: flex; gap: 4px 16px; align-items: center; flex-wrap: wrap; }
.check { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; font-size: 14px; font-weight: 600; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--cranberry); margin: 0; }
.add .error { grid-column: 1 / -1; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 210px), 1fr)); gap: clamp(12px, 2vw, 20px); }
@media (max-width: 520px) { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; } }
.empty {
  grid-column: 1 / -1; margin: 0; padding: 22px; border-radius: 16px; border: 1.5px dashed var(--line);
  color: var(--muted); text-align: center;
}

/* ---------- gift card ---------- */
.gift {
  position: relative; display: flex; flex-direction: column; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
  transition: transform 200ms var(--ease-out), box-shadow 200ms var(--ease-out);
}
.gift[data-new] { animation: card-in 320ms var(--ease-out); }
@keyframes card-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
.thumb {
  position: relative; display: block; aspect-ratio: 1 / 1; background: var(--well); overflow: hidden;
  border-bottom: 1px solid var(--line); text-decoration: none;
}
.thumb img { width: 100%; height: 100%; object-fit: contain; padding: 8%; transition: transform 300ms var(--ease-out), opacity 200ms ease, filter 200ms ease; }
@media (hover: hover) and (pointer: fine) {
  .gift:hover { transform: translateY(-2px); box-shadow: 0 2px 4px rgb(10 30 20 / .06), 0 14px 30px -12px rgb(10 30 20 / .28); }
  .gift:hover .thumb img { transform: scale(1.03); }
}
.ph {
  --h: 350; width: 100%; height: 100%; display: grid; place-content: center; justify-items: center; gap: 6px; padding: 12px; text-align: center;
  background: hsl(var(--h) 45% 94%); color: hsl(var(--h) 45% 28%);
}
.ph b { font: 600 clamp(40px, 8vw, 60px)/1 var(--display); }
.ph small { font-size: 13px; font-weight: 600; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.star {
  position: absolute; left: 8px; top: 8px; display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 9px; border-radius: 999px; background: var(--gold); color: #2b1d02; font-size: 12px; font-weight: 700;
}
.gift-body { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px 14px; flex: 1; }
.gift-title { margin: 0; font-size: 15px; font-weight: 600; line-height: 1.35; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.gift-title a { text-decoration: none; }
.gift-title a:hover { text-decoration: underline; text-underline-offset: 2px; }
.gift-meta { display: flex; justify-content: space-between; gap: 8px; margin: 0; font-size: 13px; color: var(--muted); }
.gift-meta .site { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gift-meta .price { flex: none; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
.gift-note { margin: 2px 0 0; padding: 8px 10px; border-radius: 10px; background: var(--surface-2); font-size: 13px; line-height: 1.4; }
.gift-note span {
  overflow-wrap: anywhere; white-space: pre-line;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.gift-actions { margin-top: auto; padding-top: 8px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.gift-actions .btn { flex: 1 1 auto; }
.btn.claim-btn[aria-pressed=true],
.btn.claim-btn[aria-pressed=true]:hover:not(:disabled) { background: var(--pine); border-color: var(--pine); color: #fff; }
:root[data-theme=dark] .btn.claim-btn[aria-pressed=true] { background: #2e7d57; border-color: #2e7d57; }
.taken {
  display: flex; align-items: center; gap: 8px; min-height: 40px; font-size: 13px; font-weight: 600; color: var(--muted);
}
.taken .avatar { width: 24px; height: 24px; font-size: 11px; }
.gift.is-taken .thumb img, .gift.is-taken .ph { opacity: .45; filter: grayscale(.5); }
.gift.is-mine-claim { border-color: light-dark(#9cc8b0, #2f6b52); }
.ribbon {
  position: absolute; right: 8px; top: 8px; padding: 4px 9px; border-radius: 999px; font-size: 12px; font-weight: 700;
  background: var(--pine); color: #fff;
}
.gift.is-loading .thumb { background: linear-gradient(100deg, var(--surface-2) 30%, var(--line) 50%, var(--surface-2) 70%) 0 0 / 300% 100%; animation: shimmer 1.2s linear infinite; }
.gift.is-loading .skel { height: 12px; border-radius: 6px; background: var(--surface-2); }
@keyframes shimmer { to { background-position: -150% 0; } }
.owner-line { margin: 0; font-size: 13px; color: var(--muted); font-weight: 600; }
.btn.bought-btn[aria-pressed=true],
.btn.bought-btn[aria-pressed=true]:hover:not(:disabled) { background: var(--gold); border-color: var(--gold); color: #2b1d02; }
.gift.is-bought .ribbon { background: var(--gold); color: #2b1d02; }
.people li .who-tag.reset-code { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--ink); letter-spacing: .04em; }
.removed-note { margin: 0; flex: 1 1 100%; font-size: 13px; font-weight: 600; color: light-dark(var(--cranberry), #ff9aa8); }
.gift.is-removed .thumb img, .gift.is-removed .ph { opacity: .45; filter: grayscale(.8); }
.shop-sub { display: flex; align-items: center; gap: 8px; margin: 20px 0 12px; font-size: 17px; font-weight: 700; }
.shop-sub .count { color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }
#shop-grid > .shop-sub:first-child { margin-top: 4px; }

/* ---------- dialogs ---------- */
dialog {
  border: 0; padding: 0; color: var(--ink); background: var(--surface); border-radius: 22px;
  width: min(520px, 100vw - 24px); max-height: min(88dvh, 820px); box-shadow: 0 40px 80px -24px rgb(0 0 0 / .5);
  opacity: 1; transform: translateY(0) scale(1);
  transition: opacity 220ms var(--ease-out), transform 300ms var(--ease-drawer), overlay 300ms allow-discrete, display 300ms allow-discrete;
}
dialog:not([open]) { opacity: 0; transform: translateY(12px) scale(0.98); transition-duration: 160ms; }
@starting-style { dialog[open] { opacity: 0; transform: translateY(12px) scale(0.98); } }
dialog::backdrop { background: rgb(6 20 13 / .55); transition: background-color 250ms ease, overlay 250ms allow-discrete, display 250ms allow-discrete; }
@starting-style { dialog[open]::backdrop { background: rgb(6 20 13 / 0); } }
.sheet { display: grid; gap: 16px; padding: 22px; overflow-y: auto; max-height: inherit; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.sheet h2 { margin: 0; font: 600 26px/1.1 var(--display); min-width: 0; overflow-wrap: anywhere; }
.icon-btn {
  width: 44px; height: 44px; flex: none; display: grid; place-items: center; border-radius: 50%; border: 0;
  background: var(--surface-2); transition: transform 160ms var(--ease-out);
}
.icon-btn:active { transform: scale(0.94); }
.sheet-foot { display: flex; gap: 8px; justify-content: flex-end; align-items: center; flex-wrap: wrap; padding-top: 4px; }
.sheet-foot .spacer { flex: 1; }
.img-edit { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 14px; align-items: center; }
.img-edit .thumb { border: 1px solid var(--line); border-radius: 12px; }
.img-edit .btns { display: flex; flex-wrap: wrap; gap: 6px; }
.drop-hint { grid-column: 1 / -1; }
.people { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }
.people li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.people li .name { flex: 1 1 120px; font-weight: 600; overflow-wrap: anywhere; }
.people li .who-tag { font-size: 12px; color: var(--muted); font-weight: 600; }
@media (max-width: 600px) {
  dialog { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 22px 22px 0 0; max-height: 92dvh; }
  dialog:not([open]), dialog[open] { --y: 0; }
  dialog:not([open]) { transform: translateY(100%); opacity: 1; }
  @starting-style { dialog[open] { transform: translateY(100%); opacity: 1; } }
  .sheet { padding-bottom: max(22px, env(safe-area-inset-bottom)); }
}

/* ---------- toast ---------- */
.toasts { position: fixed; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 50; width: min(440px, 100vw - 24px); display: grid; gap: 8px; pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 16px; border-radius: 14px;
  background: #10261c; color: #f1f7f3; box-shadow: 0 16px 40px -12px rgb(0 0 0 / .45); font-size: 15px;
  border: 1px solid rgb(255 255 255 / .12);
  transition: opacity 400ms ease, transform 400ms ease;
}
@starting-style { .toast { opacity: 0; transform: translateY(100%); } }
.toast.is-leaving { opacity: 0; transform: translateY(8px); transition-duration: 200ms; }
.toast p { margin: 0; flex: 1; }
.toast .btn { min-height: 44px; padding: 6px 14px; background: rgb(255 255 255 / .12); color: #fff; }

/* ---------- footer ---------- */
.foot { color: var(--muted); font-size: 13px; text-align: center; padding: 0 16px 40px; }

@media (max-width: 600px) {
  .top { padding-block: 8px 16px; }
  .user-btn .user-name { display: none; }
  .user-btn { padding-right: 8px; }
  .add { grid-template-columns: 1fr; }
  .add > .btn { width: 100%; }
  .gift-body { padding: 10px 10px 12px; }
  .gift-actions .btn { width: 100%; }
  .img-edit { grid-template-columns: 88px minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
  .gift, .thumb img, .btn, .chip, .who-btn, .user-btn, dialog, .toast, .menu { transition-property: opacity, background-color, color, border-color !important; }
  .gift:hover, .gift:hover .thumb img { transform: none !important; }
  .spinner { animation: spin 900ms linear infinite !important; animation-iteration-count: infinite !important; }
}

/* ---------- families: start, invite, organizer ---------- */
.or { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 14px; margin-top: 4px; }
.or::before, .or::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.code-box {
  display: grid; gap: 4px; padding: 14px 16px; border-radius: 14px; background: var(--surface-2);
  border: 1.5px dashed light-dark(#c9b98f, #5a5130);
}
.code-box span { font-size: 13px; font-weight: 600; color: var(--muted); }
.code-box strong { font: 600 22px/1.25 var(--display); overflow-wrap: anywhere; letter-spacing: .01em; user-select: all; }
.share-row { display: flex; gap: 8px; flex-wrap: wrap; }
.share-row .btn { flex: 1 1 140px; }
.sheet .code-box, .sheet .share-row { margin-top: 4px; }
.family-name-row { display: grid; gap: 6px; margin-bottom: 8px; }
.family-name-row label { font-size: 14px; font-weight: 600; }
.family-name-row .row { flex-wrap: nowrap; }
.family-name-row .input { flex: 1; min-width: 0; }
.family-code-row { display: grid; gap: 8px; justify-items: start; padding: 10px 0 12px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.family-code-row strong { color: var(--ink); overflow-wrap: anywhere; }
.danger-zone { display: grid; gap: 8px; justify-items: start; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); }

/* long family names and links wrap instead of widening the page */
.auth-title, .brand h1, [data-title] { overflow-wrap: anywhere; }
.toast p { overflow-wrap: anywhere; }
.toast { border: 1px solid light-dark(transparent, rgb(255 255 255 / .18)); }

/* falling snow: over the page, under the menu and toasts, never in the way of a tap */
.snow { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 10; pointer-events: none; }
.snow[hidden] { display: none; }
/* Santa's sleigh flies just behind the snow, so flakes fall in front of it */
.sleigh { position: fixed; left: 0; top: 0; z-index: 9; height: auto; pointer-events: none; user-select: none; will-change: transform; }
.sleigh[hidden] { display: none; }
/* elves peek up from a bottom corner; the picture's flat bottom sits on the screen edge */
.elf { position: fixed; bottom: 0; z-index: 9; height: auto; transform: translateY(104%); transform-origin: 50% 100%; pointer-events: none; user-select: none; will-change: transform; }
.elf[hidden] { display: none; }

/* ---------- more than one family ---------- */
/* the family name in the band, as a button, only for people in two or more families */
.fam-switch {
  display: inline-flex; align-items: center; gap: 10px; min-height: 44px; max-width: 100%; padding: 0; margin: 0;
  border: 0; background: none; color: inherit; font: inherit; letter-spacing: inherit; text-align: left;
  transition: transform 160ms var(--ease-out);
}
.fam-switch:active { transform: scale(0.98); }
.fam-chev {
  flex: none; width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%;
  border: 1.5px solid rgb(255 255 255 / .3); background: rgb(255 255 255 / .06);
  transition: background-color 150ms ease;
}
@media (hover: hover) and (pointer: fine) { .fam-switch:hover .fam-chev { background: rgb(255 255 255 / .16); } }
.fam-list { display: grid; gap: 8px; }
.fam-pick { width: 100%; justify-content: space-between; }
.fam-pick .fam-name { flex: 1; overflow-wrap: anywhere; line-height: 1.25; }
.fam-pick .who-tag { flex: none; font-size: 12px; font-weight: 600; color: var(--muted); }
.fam-pick[aria-current=true] { border-color: light-dark(var(--pine), #8fd3ad); }
.menu button.is-armed, .menu button.is-armed:hover, .menu button.is-armed:focus-visible {
  background: light-dark(#a1122a, #c2213d); color: #fff;
}
/* unclaiming a gift for someone outside this family asks twice, since it has no Undo */
.btn.claim-btn.is-armed, :root .btn.claim-btn.is-armed[aria-pressed], :root .btn.claim-btn.is-armed[aria-pressed]:hover:not(:disabled) {
  background: light-dark(#a1122a, #c2213d); border-color: light-dark(#a1122a, #c2213d); color: #fff; white-space: normal;
}
.shop-away { margin: 28px 0 0; }
#shop-grid > .shop-away:first-child { margin-top: 4px; }
@media (prefers-reduced-motion: reduce) { .fam-switch { transition-property: opacity !important; } }

/* optional family code when starting a family, and the organizer's own-code row */
.optional { font-weight: 400; color: var(--muted); }
.field-hint { font-size: 13px; margin-top: 4px; }
.family-owncode { width: 100%; margin: 4px 0 0; }
.family-owncode label { font-weight: 500; color: var(--muted); }

/* ---------- kids and pets ---------- */
fieldset.for-row, fieldset.bring { border: 0; margin: 0; padding: 0; min-width: 0; }
fieldset legend.label { padding: 0; margin-bottom: 6px; }
.for-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.add .for-row { grid-column: 1 / -1; }
/* a choice of one (For: Me / Emma; Kid / Pet), as pills */
.seg {
  position: relative; display: inline-flex; align-items: center; min-height: 44px; padding: 8px 16px;
  border-radius: 999px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink);
  font-weight: 600; font-size: 15px; line-height: 1.2; overflow-wrap: anywhere; cursor: pointer;
  transition: transform 160ms var(--ease-out), background-color 150ms ease, border-color 150ms ease, color 150ms ease;
}
.seg input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.seg:active { transform: scale(0.97); }
.seg:has(input:checked) { background: light-dark(var(--pine), #2e7d57); border-color: light-dark(var(--pine), #2e7d57); color: #fff; }
.seg:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
@media (hover: hover) and (pointer: fine) { .seg:hover:not(:has(input:checked)) { border-color: var(--muted); } }
.bring { display: grid; gap: 2px; }
.bring .hint { margin-bottom: 4px; }
.check .who-tag { font-size: 12px; font-weight: 600; color: var(--muted); }
.kind-tag {
  display: inline-flex; align-items: center; min-height: 26px; padding: 2px 10px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); font: 700 13px/1.2 var(--body); letter-spacing: .02em; vertical-align: middle;
}
.list-head .looked-after { flex: 1 1 100%; }
.dep-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.dep-actions .btn { white-space: normal; text-align: center; }
/* Buttons carrying a name (up to 40 characters) wrap instead of pushing the sheet sideways. */
#dep-stop, #dep-remove { white-space: normal; text-align: center; max-width: 100%; overflow-wrap: anywhere; }
.dep-actions .btn-primary { flex: 0 1 auto; }
.kid-row .fam-name small { display: block; margin-top: 2px; font-size: 13px; font-weight: 500; color: var(--muted); }
.dep-part { display: grid; gap: 10px; padding-top: 14px; border-top: 1px solid var(--line); }
.dep-part > .btn { justify-self: start; }
.sheet h3.label { margin: 0; }
.dep-signin .row { align-items: end; }
.dep-signin .row .field { flex: 1 1 140px; }
.dep-signin > .btn { justify-self: stretch; }
select.input {
  appearance: none; -webkit-appearance: none; padding-right: 40px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4' fill='none' stroke='%237d8c83' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
}
@media (prefers-reduced-motion: reduce) { .seg { transition-property: opacity, background-color, color, border-color !important; } }
