:root {
  --bg: #f6efe2;
  --surface: #fffdf8;
  --surface-2: #f3e8d6;
  --ink: #1d2a22;
  --muted: #5e6b62;
  --line: #e6d6bd;
  --pine: #14472f;
  --pine-ink: #fdf8ee;
  --berry: #b3261e;
  --berry-soft: #fbe4e1;
  --gold: #c9973a;
  --gold-soft: #f8ecd2;
  --snow: #ffffff;
  --flake-bg: rgb(20 71 47 / 5%);
  --ok: #2f6b45;
  --ok-soft: #e3f1e6;
  --shadow: 0 1px 2px rgb(40 30 10 / 6%), 0 4px 16px rgb(40 30 10 / 6%);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121a16;
    --surface: #1a241f;
    --surface-2: #222e28;
    --ink: #eef0ea;
    --muted: #a3ada6;
    --line: #2f3c35;
    --pine: #2c5641;
    --pine-ink: #f4f1e8;
    --berry: #ef6b60;
    --berry-soft: #3a1f1c;
    --gold: #e0b45e;
    --gold-soft: #3a3020;
    --snow: #e9f1ff;
    --flake-bg: rgb(255 255 255 / 4%);
    --ok: #7dc596;
    --ok-soft: #1d3326;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 4px 16px rgb(0 0 0 / 25%);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
h1, h2, h3 { font-family: Fraunces, Georgia, serif; font-weight: 700; line-height: 1.15; margin: 0; }
a { color: inherit; }
button, input { font: inherit; color: inherit; }

.wrap { max-width: 1040px; margin: 0 auto; padding: 0 16px; }
.loading { padding: 80px 16px; text-align: center; color: var(--muted); }

/* ---------- header ---------- */
.top {
  background: var(--pine);
  color: var(--pine-ink);
  padding: 18px 0 0;
}
.top .wrap { display: flex; flex-direction: column; gap: 14px; }
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand h1 { font-size: 1.5rem; }
.brand .hello { font-size: .9rem; opacity: .8; }
.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.tab {
  border: 0; background: transparent; color: inherit; opacity: .75;
  padding: 10px 14px; border-radius: 10px 10px 0 0; cursor: pointer; white-space: nowrap; font-weight: 500;
}
.tab:hover { opacity: 1; }
.tab[aria-selected="true"] { background: var(--bg); color: var(--ink); opacity: 1; }

.menu-btn {
  border: 1px solid rgb(255 255 255 / 25%); background: transparent; color: inherit;
  border-radius: 999px; padding: 6px 12px; cursor: pointer; font-size: .9rem;
}
.menu { position: relative; }
.menu-list {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 10;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow); min-width: 180px; padding: 6px; display: none;
}
.menu.open .menu-list { display: block; }
.menu-list button {
  display: block; width: 100%; text-align: left; border: 0; background: transparent;
  padding: 9px 12px; border-radius: 8px; cursor: pointer;
}
.menu-list button:hover { background: var(--surface-2); }

main { padding: 24px 0 64px; }

/* ---------- assignment banner ---------- */
.banner {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  background: var(--gold-soft); border: 1px solid color-mix(in srgb, var(--gold) 40%, transparent);
  border-radius: var(--radius); padding: 16px 18px; margin-bottom: 24px;
}
.banner .gift-emoji { font-size: 2rem; }
.banner .label { font-size: .85rem; color: var(--muted); }
.banner .who { font-family: Fraunces, Georgia, serif; font-size: 1.5rem; font-weight: 700; }
.banner .spacer { flex: 1; }
.banner.waiting { background: var(--surface-2); border-color: var(--line); }

/* ---------- buttons + inputs ---------- */
.btn {
  border: 1px solid transparent; border-radius: 10px; padding: 10px 16px; cursor: pointer;
  font-weight: 600; background: var(--pine); color: var(--pine-ink); transition: filter .15s;
}
.btn:hover { filter: brightness(1.1); }
.btn:disabled { opacity: .55; cursor: default; filter: none; }
.btn.secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn.danger { background: var(--berry); color: #fff; }
.btn.small { padding: 6px 12px; font-size: .875rem; border-radius: 8px; }
.btn.link { background: none; border: 0; color: var(--muted); padding: 6px 8px; font-weight: 500; }
.btn.link:hover { color: var(--ink); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: .875rem; font-weight: 500; color: var(--muted); }
input[type="text"], input[type="password"], input[type="url"], input:not([type]) {
  width: 100%; padding: 11px 13px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); outline: none;
}
input:focus { border-color: var(--pine); box-shadow: 0 0 0 3px color-mix(in srgb, var(--pine) 20%, transparent); }
.error { color: var(--berry); font-size: .9rem; min-height: 1.2em; }
.hint { color: var(--muted); font-size: .875rem; }

/* ---------- sign in ---------- */
.auth {
  min-height: 100vh; display: grid; place-items: center; padding: 32px 16px;
  background:
    radial-gradient(circle at 15% 10%, color-mix(in srgb, var(--berry) 14%, transparent), transparent 40%),
    radial-gradient(circle at 85% 90%, color-mix(in srgb, var(--gold) 18%, transparent), transparent 45%),
    var(--bg);
}
.auth-card {
  width: 100%; max-width: 440px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 20px; box-shadow: var(--shadow); padding: 28px 24px; display: flex; flex-direction: column; gap: 18px;
}
.auth-card h1 { font-size: 2rem; }
.auth-card .sub { color: var(--muted); margin-top: 6px; }
.names { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.name-btn {
  border: 1px solid var(--line); background: var(--surface-2); border-radius: 12px; padding: 12px 10px;
  cursor: pointer; font-weight: 600; text-align: center;
}
.name-btn:hover { border-color: var(--pine); }
.pin-input { font-size: 1.5rem !important; letter-spacing: .4em; text-align: center; }

/* ---------- sections ---------- */
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0 0 14px; flex-wrap: wrap; }
.section-head h2 { font-size: 1.6rem; }
.person { margin-bottom: 36px; }
.person.mine-person {
  background: var(--surface); border: 2px solid var(--gold); border-radius: 18px; padding: 18px;
}
.badge {
  display: inline-block; font-size: .75rem; font-weight: 600; padding: 3px 9px; border-radius: 999px;
  background: var(--gold); color: #fff; vertical-align: middle; margin-left: 8px; font-family: Inter, sans-serif;
}
.empty { color: var(--muted); background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); padding: 18px; }

/* ---------- add form ---------- */
.add-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 24px; display: flex; flex-direction: column; gap: 12px; box-shadow: var(--shadow);
}
.add-row { display: flex; gap: 10px; }
.add-row input { flex: 1; min-width: 0; }
.preview {
  display: flex; gap: 12px; align-items: center; background: var(--surface-2); border-radius: 10px; padding: 10px;
}
.preview img { width: 64px; height: 64px; object-fit: contain; background: #fff; border-radius: 8px; flex: none; }
.preview .ph { width: 64px; height: 64px; border-radius: 8px; display: grid; place-items: center; background: var(--surface); font-size: 1.6rem; flex: none; }
.preview .meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }

/* ---------- gift cards ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.gift {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow);
}
.gift .thumb {
  aspect-ratio: 4 / 3; background: #fff; display: grid; place-items: center; overflow: hidden;
  border-bottom: 1px solid var(--line);
}
.gift .thumb img { width: 100%; height: 100%; object-fit: contain; padding: 10px; }
.gift .thumb.text-only {
  background: linear-gradient(135deg, var(--gold-soft), var(--berry-soft)); font-size: 2.6rem;
}
.gift .body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.gift .title { font-weight: 600; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.gift .site { font-size: .8rem; color: var(--muted); }
.gift .note { font-size: .9rem; color: var(--muted); overflow-wrap: anywhere; }
.gift .actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: auto; padding-top: 8px; }
.gift.claimed-other { opacity: .65; }
.claim-tag { font-size: .8rem; font-weight: 600; padding: 4px 10px; border-radius: 999px; }
.claim-tag.me { background: var(--ok-soft); color: var(--ok); }
.claim-tag.other { background: var(--surface-2); color: var(--muted); }

/* ---------- organizer ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 20px; box-shadow: var(--shadow); }
.panel h3 { font-size: 1.25rem; margin-bottom: 4px; }
.people-table { width: 100%; border-collapse: collapse; margin-top: 12px; }
.people-table th, .people-table td { text-align: left; padding: 10px 6px; border-top: 1px solid var(--line); vertical-align: middle; }
.people-table th { font-size: .8rem; color: var(--muted); font-weight: 500; border-top: 0; }
.people-table input { padding: 6px 9px; max-width: 150px; }
.row-actions { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.pill { font-size: .75rem; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.form-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-top: 12px; }
.form-row .field { flex: 1; min-width: 150px; }

/* ---------- dialog ---------- */
dialog {
  border: 1px solid var(--line); border-radius: 18px; padding: 22px; background: var(--surface); color: var(--ink);
  width: min(440px, calc(100vw - 32px)); box-shadow: var(--shadow);
}
dialog::backdrop { background: rgb(0 0 0 / 45%); }
dialog form { display: flex; flex-direction: column; gap: 14px; }
dialog h3 { font-size: 1.35rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px;
  opacity: 0; pointer-events: none; transition: all .25s; z-index: 50; max-width: calc(100vw - 32px); text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 620px) {
  .brand h1 { font-size: 1.25rem; }
  .add-row { flex-direction: column; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .gift .body { padding: 10px; }
  .people-table thead { display: none; }
  .people-table tr { display: grid; grid-template-columns: 1fr auto; gap: 6px; padding: 10px 0; border-top: 1px solid var(--line); }
  .people-table td { border: 0; padding: 2px 0; }
  .people-table td.house { grid-column: 1 / -1; }
  .people-table td.acts { grid-column: 1 / -1; }
  .row-actions { justify-content: flex-start; }
}

/* =====================================================================
   Christmas theme
   ===================================================================== */

/* Faint snowflake pattern on the page background */
body {
  background-color: var(--bg);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 120 120'%3E%3Cg fill='none' stroke='%2314472f' stroke-opacity='.07' stroke-width='1.5' stroke-linecap='round'%3E%3Cg transform='translate(30 30)'%3E%3Cpath d='M0-10V10M-8.7-5 8.7 5M-8.7 5 8.7-5'/%3E%3C/g%3E%3Cg transform='translate(90 85) scale(.7)'%3E%3Cpath d='M0-10V10M-8.7-5 8.7 5M-8.7 5 8.7-5'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}
@media (prefers-color-scheme: dark) {
  body { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 120 120'%3E%3Cg fill='none' stroke='%23ffffff' stroke-opacity='.06' stroke-width='1.5' stroke-linecap='round'%3E%3Cg transform='translate(30 30)'%3E%3Cpath d='M0-10V10M-8.7-5 8.7 5M-8.7 5 8.7-5'/%3E%3C/g%3E%3Cg transform='translate(90 85) scale(.7)'%3E%3Cpath d='M0-10V10M-8.7-5 8.7 5M-8.7 5 8.7-5'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E"); }
}

/* Falling snow */
.snow { position: fixed; inset: 0; pointer-events: none; z-index: 40; overflow: hidden; }
.snow i {
  position: absolute; top: -12px; border-radius: 50%; background: var(--snow);
  box-shadow: 0 0 4px rgb(255 255 255 / 60%);
  animation-name: snow-fall, snow-sway;
  animation-timing-function: linear, ease-in-out;
  animation-iteration-count: infinite, infinite;
  animation-direction: normal, alternate;
}
@media (prefers-color-scheme: light) { .snow i { background: #ffffff; box-shadow: 0 0 2px rgb(20 71 47 / 35%); } }
@keyframes snow-fall { to { transform: translateY(105vh); } }
@keyframes snow-sway { from { margin-left: -14px; } to { margin-left: 14px; } }

/* Festive title font */
.brand h1, .auth-card h1 {
  font-family: "Mountains of Christmas", Fraunces, Georgia, serif;
  letter-spacing: .01em;
}
.brand h1 { font-size: 2rem; color: #fff6e0; text-shadow: 0 2px 0 rgb(0 0 0 / 25%); }
.auth-card h1 { font-size: 2.6rem; color: var(--berry); }

/* Header: pine green with a candy-cane stripe and a string of lights */
.top {
  position: relative;
  background:
    radial-gradient(circle at 12% -30%, rgb(255 255 255 / 12%), transparent 45%),
    linear-gradient(180deg, #1b5a3c, var(--pine));
  padding-bottom: 0;
}
.top::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -8px; height: 8px; z-index: 2;
  background: repeating-linear-gradient(-45deg, #c62828 0 10px, #fffaf0 10px 20px);
  box-shadow: 0 2px 4px rgb(0 0 0 / 12%);
}
.lights {
  display: flex; justify-content: space-between; gap: 6px; height: 14px; margin: -4px 0 2px;
  background: radial-gradient(ellipse at 50% -40%, transparent 60%, rgb(255 255 255 / 35%) 61%, transparent 66%) 0 0 / 46px 14px repeat-x;
}
.lights b {
  width: 8px; height: 11px; border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%; margin-top: 3px;
  background: var(--c); box-shadow: 0 0 8px 1px var(--c);
  animation: twinkle 2.4s ease-in-out infinite; animation-delay: var(--d);
}
@keyframes twinkle { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .lights b { animation: none; } }
.tab[aria-selected="true"] { box-shadow: inset 0 3px 0 var(--berry); }
main { padding-top: 32px; }

/* Primary buttons in Christmas red */
.btn { background: var(--berry); color: #fff; box-shadow: 0 1px 0 rgb(0 0 0 / 10%); }
.btn.secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn.link { background: none; box-shadow: none; }
.menu-btn { background: rgb(255 255 255 / 8%); }

/* Sign-in card wrapped like a present */
.auth {
  background:
    radial-gradient(circle at 15% 10%, color-mix(in srgb, var(--berry) 22%, transparent), transparent 42%),
    radial-gradient(circle at 85% 90%, color-mix(in srgb, var(--pine) 30%, transparent), transparent 48%);
}
.auth-card { position: relative; overflow: hidden; padding-top: 40px; border: 0; }
.auth-card::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 10px;
  background: repeating-linear-gradient(-45deg, #c62828 0 10px, #fffaf0 10px 20px);
}
.auth-card::after {
  content: "🎀"; position: absolute; top: 2px; right: 18px; font-size: 1.9rem; transform: rotate(12deg);
}
.name-btn { background: var(--surface-2); border-width: 2px; transition: transform .12s, border-color .12s; }
.name-btn:hover { border-color: var(--berry); transform: translateY(-2px); }

/* Banner as a gift tag */
.banner {
  background: linear-gradient(135deg, var(--gold-soft), var(--berry-soft));
  border: 2px dashed color-mix(in srgb, var(--berry) 45%, transparent);
}
.banner .who { color: var(--berry); }
.banner.waiting { background: var(--surface); border-color: var(--line); }
.banner.waiting .who { color: var(--ink); }

/* Gift cards with a ribbon */
.gift { position: relative; border-top: 0; }
.gift::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 5px; z-index: 1;
  background: linear-gradient(90deg, var(--berry), #d9443a 50%, var(--berry));
}
.gift .thumb.text-only {
  background:
    linear-gradient(90deg, transparent 46%, color-mix(in srgb, var(--berry) 35%, transparent) 46% 54%, transparent 54%),
    linear-gradient(135deg, var(--berry-soft), color-mix(in srgb, var(--pine) 14%, var(--surface)));
}
.person.mine-person {
  border: 2px solid var(--berry);
  background:
    linear-gradient(var(--surface), var(--surface)) padding-box,
    repeating-linear-gradient(-45deg, #c62828 0 10px, #fffaf0 10px 20px) border-box;
  border-color: transparent; border-width: 4px;
}
.badge { background: var(--berry); }
.section-head h2 { color: var(--pine); }
@media (prefers-color-scheme: dark) { .section-head h2 { color: #cfe8d6; } }
.panel h3 { color: var(--pine); }
@media (prefers-color-scheme: dark) { .panel h3 { color: #cfe8d6; } }
.add-card { border-top: 4px solid var(--pine); }
#toast { background: var(--pine); color: #fff; }

/* Hidden match in the banner */
.banner .who.hidden-name { letter-spacing: .15em; color: var(--muted); user-select: none; }
.banner-actions { display: flex; gap: 8px; flex-wrap: wrap; }
