:root {
  --cream: #fbf5ea;
  --paper: #fffdf8;
  --red: #b3261e;
  --red-dark: #8e1b15;
  --green: #1e4d3b;
  --green-dark: #143528;
  --green-soft: #e4eee8;
  --gold: #c99a2e;
  --gold-soft: #f6ead0;
  --ink: #2b1d14;
  --muted: #7a6a5c;
  --line: #eadfcb;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(43, 29, 20, .06), 0 6px 20px rgba(43, 29, 20, .07);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--cream);
  min-height: 100dvh;
}
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--red); }
h1, h2, h3 { font-family: var(--serif); line-height: 1.15; margin: 0 0 .4em; font-weight: 700; }
h1 { font-size: 2rem; }
h2 { font-size: 1.45rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 .8em; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { text-align: center; }
.hidden { display: none !important; }

/* ---------- snow ---------- */
.snow { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
.snow span {
  position: absolute; top: -10px; color: #fff; opacity: .9;
  text-shadow: 0 0 2px rgba(30, 77, 59, .25);
  animation: fall linear infinite;
}
@keyframes fall { to { transform: translateY(105vh) translateX(20px); } }
@media (prefers-reduced-motion: reduce) { .snow { display: none; } }

/* ---------- layout ---------- */
#app { position: relative; z-index: 1; max-width: 560px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }
.top {
  background: var(--green);
  color: #fff;
  padding: 18px 20px 22px;
  border-radius: 0 0 26px 26px;
  position: relative;
  box-shadow: var(--shadow);
}
.top::after {
  content: ""; position: absolute; left: 20px; right: 20px; bottom: 8px; height: 3px;
  background: repeating-linear-gradient(90deg, var(--gold) 0 10px, transparent 10px 18px);
  opacity: .7; border-radius: 2px;
}
.top h1 { color: #fff; font-size: 1.6rem; margin: 0; }
.top .sub { color: #d7e6dd; font-size: .9rem; margin-top: 2px; }
.top .who { display: flex; align-items: center; gap: 12px; }
.top .who .badge-emoji { font-size: 2.2rem; background: rgba(255,255,255,.12); border-radius: 50%; width: 56px; height: 56px; display: grid; place-items: center; }
main { flex: 1; padding: 18px 16px 110px; }
main.plain { padding-bottom: 32px; }

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.card.festive { border-top: 4px solid var(--red); }
.card.gold { background: var(--gold-soft); border-color: #ead7a8; }
.card.green { background: var(--green-soft); border-color: #cfe0d6; }

.hero { text-align: center; padding: 40px 16px 8px; }
.hero .big { font-size: 4rem; line-height: 1; margin-bottom: 10px; }
.hero h1 { color: var(--green); font-size: 2.4rem; }

/* ---------- forms ---------- */
label { display: block; font-weight: 600; margin: 12px 0 6px; }
.hint { font-size: .9rem; color: var(--muted); margin-top: 4px; }
input[type=text], input[type=password], input[type=url], input[type=datetime-local], input[type=tel], textarea, select {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: #fff;
  font-size: 16px;
  outline: none;
  transition: border-color .15s;
}
input:focus, textarea:focus, select:focus { border-color: var(--green); }
textarea { min-height: 84px; resize: vertical; }
.pin-input { letter-spacing: .6em; text-align: center; font-size: 1.6rem !important; font-variant-numeric: tabular-nums; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 999px; padding: 13px 22px;
  background: var(--red); color: #fff; font-weight: 700; cursor: pointer;
  text-decoration: none; text-align: center; transition: transform .05s, background .15s;
  min-height: 48px;
}
.btn:hover { background: var(--red-dark); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.block { width: 100%; }
.btn.green { background: var(--green); }
.btn.green:hover { background: var(--green-dark); }
.btn.ghost { background: transparent; color: var(--green); border: 1.5px solid var(--line); }
.btn.ghost:hover { background: #fff; }
.btn.small { padding: 8px 14px; min-height: 36px; font-size: .9rem; }
.btn.danger { background: transparent; color: var(--red); border: 1.5px solid #f0c9c5; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 10px; }
.linkish { background: none; border: 0; color: var(--muted); text-decoration: underline; cursor: pointer; padding: 8px; font-size: .9rem; }

/* ---------- nickname grid ---------- */
.nick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-top: 8px; }
.nick {
  border: 1.5px solid var(--line); border-radius: 14px; background: #fff;
  padding: 12px 10px; text-align: center; cursor: pointer; transition: border-color .15s, transform .05s;
}
.nick:active { transform: scale(.98); }
.nick .e { font-size: 1.9rem; display: block; line-height: 1.2; }
.nick .n { font-weight: 600; font-size: .92rem; }
.nick.sel { border-color: var(--red); background: #fff4f2; box-shadow: 0 0 0 3px rgba(179, 38, 30, .12); }
.nick:disabled { opacity: .35; cursor: not-allowed; text-decoration: line-through; }

/* ---------- wishlist ---------- */
.item { display: flex; gap: 12px; padding: 14px 0; border-top: 1px dashed var(--line); }
.item:first-child { border-top: 0; padding-top: 4px; }
.item .thumb {
  width: 76px; height: 76px; border-radius: 12px; object-fit: cover; flex: none;
  background: var(--gold-soft); display: grid; place-items: center; font-size: 2rem; overflow: hidden;
}
.item .thumb img { width: 100%; height: 100%; object-fit: cover; }
.item .body { flex: 1; min-width: 0; }
.item .title { font-weight: 700; word-break: break-word; }
.item .link { font-size: .88rem; word-break: break-all; display: inline-block; margin-top: 2px; }
.item .notes { font-size: .92rem; color: var(--muted); white-space: pre-wrap; margin-top: 4px; word-break: break-word; }
.item .actions { margin-top: 8px; display: flex; gap: 8px; flex-wrap: wrap; }
.item.bought .title { text-decoration: line-through; color: var(--muted); }
.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; cursor: pointer; margin-top: 8px; font-size: .92rem; color: var(--green); }
.check input { width: 22px; height: 22px; accent-color: var(--green); }
.empty { text-align: center; color: var(--muted); padding: 18px 6px; }
.empty .e { font-size: 2.4rem; display: block; }

.tag {
  display: inline-block; background: #fff; border: 1.5px dashed var(--red); color: var(--red);
  border-radius: 10px; padding: 6px 12px; font-family: var(--serif); font-weight: 700; font-size: 1.1rem;
}
.notes-box { white-space: pre-wrap; background: #fff; border-radius: 12px; padding: 12px; border: 1px solid var(--line); }

/* ---------- chat ---------- */
.chat { display: flex; flex-direction: column; gap: 8px; padding: 6px 0 4px; }
.msg { max-width: 82%; padding: 10px 14px; border-radius: 18px; white-space: pre-wrap; word-break: break-word; box-shadow: 0 1px 1px rgba(0,0,0,.04); }
.msg .t { display: block; font-size: .72rem; opacity: .7; margin-top: 3px; }
.msg.theirs { background: #fff; border: 1px solid var(--line); align-self: flex-start; border-bottom-left-radius: 6px; }
.msg.mine { background: var(--green); color: #fff; align-self: flex-end; border-bottom-right-radius: 6px; }
.composer {
  position: fixed; left: 0; right: 0; bottom: 72px; z-index: 5;
  padding: 10px 12px; background: linear-gradient(to top, var(--cream) 70%, rgba(251,245,234,0));
}
.composer form { max-width: 560px; margin: 0 auto; display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { resize: none; min-height: 48px; max-height: 140px; border-radius: 22px; padding: 12px 16px; }
.composer .btn { min-width: 48px; padding: 12px 16px; }
main.with-composer { padding-bottom: 180px; }

/* ---------- bottom nav ---------- */
nav.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  background: var(--paper); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
nav.tabs .in { max-width: 560px; margin: 0 auto; display: grid; grid-template-columns: repeat(4, 1fr); }
nav.tabs a {
  text-decoration: none; color: var(--muted); text-align: center; padding: 9px 4px 10px;
  font-size: .8rem; font-weight: 700; position: relative; min-height: 66px; line-height: 1.2;
}
nav.tabs a .i { display: block; font-size: 1.45rem; line-height: 1.3; filter: grayscale(.6); }
nav.tabs a.on { color: var(--red); }
nav.tabs a.on .i { filter: none; }
.dot {
  position: absolute; top: 6px; left: calc(50% + 8px); min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--red); color: #fff; font-size: .7rem; line-height: 18px; font-weight: 700;
}

/* ---------- countdown ---------- */
.countdown { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; text-align: center; margin: 8px 0 4px; }
.countdown div { background: #fff; border-radius: 12px; padding: 10px 4px; border: 1px solid var(--line); }
.countdown b { display: block; font-family: var(--serif); font-size: 1.6rem; color: var(--red); font-variant-numeric: tabular-nums; }
.countdown span { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

/* ---------- toast & modal ---------- */
.toast {
  position: fixed; left: 50%; top: 16px; transform: translateX(-50%); z-index: 50;
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; box-shadow: var(--shadow);
  max-width: calc(100% - 32px); font-size: .95rem; animation: pop .2s ease-out;
}
.toast.err { background: var(--red-dark); }
@keyframes pop { from { opacity: 0; transform: translate(-50%, -8px); } }
.modal-bg { position: fixed; inset: 0; background: rgba(43, 29, 20, .45); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.modal {
  background: var(--paper); width: 100%; max-width: 560px; max-height: 92dvh; overflow: auto;
  border-radius: 22px 22px 0 0; padding: 20px 18px calc(24px + env(safe-area-inset-bottom));
  animation: up .2s ease-out;
}
@keyframes up { from { transform: translateY(30px); opacity: .6; } }
@media (min-width: 600px) { .modal-bg { align-items: center; } .modal { border-radius: 22px; } }

/* ---------- admin ---------- */
.people { list-style: none; padding: 0; margin: 0; }
.people li { display: flex; align-items: center; gap: 10px; padding: 11px 0; border-top: 1px solid var(--line); cursor: pointer; }
.people li:first-child { border-top: 0; }
.people .e { font-size: 1.6rem; width: 36px; text-align: center; }
.people .grow { flex: 1; min-width: 0; }
.pair { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.pair:first-child { border-top: 0; }
.pair .arrow { color: var(--gold); font-weight: 700; }
.pill { display: inline-block; font-size: .75rem; padding: 2px 8px; border-radius: 999px; background: var(--green-soft); color: var(--green); font-weight: 700; }
.pill.red { background: #fde8e6; color: var(--red); }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; }
.switch input { width: 46px; height: 26px; accent-color: var(--green); }
.adm-msg { border-left: 3px solid var(--line); padding: 6px 10px; margin: 8px 0; }
.adm-msg.s { border-color: var(--red); }
.adm-msg.r { border-color: var(--green); }

/* ---------- clarity helpers ---------- */
.form-error {
  background: #fde8e6; color: var(--red-dark); border: 1.5px solid #f0c9c5; border-radius: 12px;
  padding: 12px 14px; margin: 14px 0 0; font-weight: 600;
}
.creds { display: grid; gap: 10px; margin: 14px 0; }
.creds div { background: #fff; border: 2px dashed var(--gold); border-radius: 14px; padding: 12px; }
.creds span { display: block; font-size: .85rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.creds b { font-family: var(--serif); font-size: 1.7rem; color: var(--ink); letter-spacing: .04em; }
.sticky-next {
  position: sticky; bottom: 0; z-index: 4; padding: 12px 0 calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--cream) 75%, rgba(251,245,234,0));
}
