:root {
  --paper: #f3eadc;
  --paper-2: #ebdfcc;
  --card: #fbf6ee;
  --ink: #2a1c14;
  --ink-2: #5e4a3c;
  --muted: #8f7a68;
  --gold: #a8834b;
  --gold-2: #d6b97f;
  --rose: #b06a62;
  --wax: #8e2f2b;
  --line: rgba(120, 90, 55, 0.22);
  --serif: "Cormorant Garamond", "Cormorant", "Iowan Old Style", "Palatino", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, sans-serif;
  --ease: cubic-bezier(.2, .7, .2, 1);
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--paper); }
body {
  margin: 0;
  min-height: 100dvh;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.45;
  background:
    radial-gradient(120% 60% at 50% -10%, #fbf4e8 0%, transparent 60%),
    radial-gradient(90% 50% at 50% 110%, #e8d8bf 0%, transparent 70%),
    var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
/* paper grain */
body::before {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  opacity: .32;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .45  0 0 0 0 .35  0 0 0 0 .22  0 0 0 .18 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  z-index: 0;
}

#app {
  position: relative;
  z-index: 1;
  max-width: 34rem;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 28px) 20px calc(env(safe-area-inset-bottom, 0px) + 40px);
  min-height: 100dvh;
}

button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }

/* ───── type ───── */
.kicker {
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 500;
}
.display {
  font-weight: 400;
  font-style: italic;
  font-size: clamp(56px, 17vw, 84px);
  line-height: .95;
  letter-spacing: -.01em;
  margin: 0;
}
.display .amp { color: var(--gold); }
h2.title { font-weight: 400; font-style: italic; font-size: 34px; line-height: 1.1; margin: 6px 0 0; }
.muted { color: var(--muted); }
.center { text-align: center; }

.ornament {
  display: flex; align-items: center; gap: 12px;
  color: var(--gold);
  margin: 18px auto;
  max-width: 220px;
}
.ornament::before, .ornament::after {
  content: ""; flex: 1; height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-2), transparent);
}
.ornament span { font-size: 14px; letter-spacing: .3em; }

/* ───── portraits ───── */
.arch {
  position: relative;
  border-radius: 999px 999px 6px 6px;
  overflow: hidden;
  background-color: var(--paper-2);
  background-repeat: no-repeat;
  box-shadow: 0 0 0 1px rgba(255,255,255,.6) inset, 0 10px 24px -14px rgba(60, 35, 15, .55);
}
.arch::after {
  content: "";
  position: absolute; inset: 4px;
  border-radius: inherit;
  border: 1px solid rgba(255, 240, 210, .75);
  pointer-events: none;
}
.frame {
  padding: 5px;
  border-radius: 999px 999px 10px 10px;
  background: linear-gradient(160deg, #e9d3a3, #a8834b 45%, #e5cc96 70%, #8d6a36);
}

/* ───── login ───── */
.hero { text-align: center; padding-top: 4vh; }
.hero .sub { font-style: italic; color: var(--ink-2); font-size: 20px; margin: 10px 0 0; }

.people {
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: 18px 14px;
  margin: 34px auto 0;
  max-width: 26rem;
}
.person {
  width: calc((100% - 28px) / 3);
  max-width: 120px;
  text-align: center;
  transition: transform .5s var(--ease), opacity .4s var(--ease), filter .4s;
}
.person .arch { aspect-ratio: 3 / 4; }
.person .name { margin-top: 8px; font-size: 20px; font-style: italic; }
.person:active { transform: scale(.97); }
.people.picked .person { opacity: .28; filter: saturate(.4); transform: scale(.94); }
.people.picked .person.on { opacity: 1; filter: none; transform: scale(1.04); }

.sheet {
  margin: 26px auto 0;
  max-width: 22rem;
  text-align: center;
  animation: rise .55s var(--ease) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
@keyframes fade { from { opacity: 0; } }

.field {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--gold-2);
  background: transparent;
  padding: 10px 2px 8px;
  font-size: 26px;
  text-align: center;
  font-style: italic;
  outline: none;
  border-radius: 0;
  transition: border-color .3s;
}
.field::placeholder { color: #bba790; }
.field:focus { border-bottom-color: var(--gold); }
textarea.field { text-align: left; font-size: 22px; resize: none; min-height: 7.5em; line-height: 1.4; font-style: normal; }
input.field.left { text-align: left; font-style: normal; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 52px;
  padding: 0 30px;
  border-radius: 999px;
  background: var(--ink);
  color: #f7efe2;
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: .22em;
  text-transform: uppercase;
  font-weight: 500;
  box-shadow: 0 10px 22px -12px rgba(42, 28, 20, .8);
  transition: transform .2s var(--ease), opacity .2s;
}
.btn:active { transform: scale(.97); }
.btn[disabled] { opacity: .45; }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: none; border: 1px solid var(--line); }
.btn.gold { background: linear-gradient(160deg, #c9a46a, #9c773f); }
.btn.wide { width: 100%; }
.link {
  font-family: var(--sans); font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: var(--muted);
  padding: 10px;
}
.error { color: var(--rose); font-style: italic; min-height: 1.5em; margin: 10px 0 0; }

/* ───── home ───── */
.top { display: flex; align-items: center; gap: 14px; animation: fade .6s both; }
.top .arch { width: 54px; aspect-ratio: 3/4; flex: none; }
.top .who { flex: 1; }
.top h1 { margin: 0; font-weight: 400; font-style: italic; font-size: 32px; line-height: 1.05; }

.card {
  position: relative;
  margin-top: 22px;
  padding: 24px 22px;
  background: var(--card);
  border-radius: 22px;
  box-shadow: 0 1px 0 rgba(255,255,255,.8) inset, 0 18px 40px -28px rgba(70, 40, 15, .55), 0 0 0 1px var(--line);
  animation: rise .6s var(--ease) both;
}
.card:nth-of-type(2) { animation-delay: .06s; }
.card:nth-of-type(3) { animation-delay: .12s; }
.card h3 { margin: 6px 0 4px; font-weight: 400; font-size: 28px; font-style: italic; line-height: 1.1; }
.card p { margin: 6px 0 0; color: var(--ink-2); }
.card .actions { margin-top: 18px; display: flex; gap: 10px; flex-wrap: wrap; }

.progress { height: 2px; background: var(--paper-2); border-radius: 2px; margin-top: 16px; overflow: hidden; }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold-2), var(--gold)); transition: width .8s var(--ease); }

/* envelope */
.envelope {
  position: relative;
  margin: 18px auto 4px;
  width: 100%;
  max-width: 300px;
  aspect-ratio: 1.55;
  border-radius: 10px;
  background: linear-gradient(170deg, #f2e4cb, #e3cfac);
  box-shadow: 0 16px 30px -18px rgba(70, 40, 15, .7), 0 0 0 1px rgba(150, 110, 60, .25) inset;
  overflow: hidden;
  display: block;
}
.envelope::before { /* lower flaps */
  content: ""; position: absolute; inset: 0;
  background:
    linear-gradient(to top right, #e8d6b7 49.6%, transparent 50%) left bottom / 51% 100% no-repeat,
    linear-gradient(to top left, #e6d3b2 49.6%, transparent 50%) right bottom / 51% 100% no-repeat;
}
.envelope .flap {
  position: absolute; left: 0; right: 0; top: 0; height: 58%;
  background: linear-gradient(175deg, #efdfc2, #dcc39b);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: top;
  transition: transform .7s var(--ease);
  filter: drop-shadow(0 3px 3px rgba(80,50,20,.2));
}
.seal {
  position: absolute; left: 50%; top: 58%;
  width: 62px; height: 62px; margin: -31px 0 0 -31px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #c0544c, var(--wax) 55%, #5e1a18);
  box-shadow: 0 4px 8px rgba(60, 10, 10, .45), 0 0 0 4px rgba(142,47,43,.35);
  display: grid; place-items: center;
  color: #f1cdbf; font-style: italic; font-size: 30px; line-height: 1;
  transition: transform .5s var(--ease), opacity .5s;
}
.envelope.open .flap { transform: rotateX(180deg); }
.envelope.open .seal { transform: scale(1.4); opacity: 0; }
.hint { text-align: center; font-style: italic; color: var(--muted); font-size: 17px; margin-top: 6px; }

.giftee-mini { display: flex; gap: 16px; align-items: center; margin-top: 14px; animation: rise .6s var(--ease) both; }
.giftee-mini .arch { width: 84px; aspect-ratio: 3/4; flex: none; }

.countdown { display: flex; gap: 22px; justify-content: center; margin: 18px 0 4px; }
.countdown div { text-align: center; }
.countdown b { display: block; font-weight: 400; font-size: 44px; line-height: 1; }
.countdown span { font-family: var(--sans); font-size: 10px; letter-spacing: .22em; text-transform: uppercase; color: var(--muted); }

/* ───── profile flow ───── */
.flow { display: flex; flex-direction: column; min-height: calc(100dvh - 68px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)); }
.flow-head { display: flex; align-items: center; justify-content: space-between; }
.dots { display: flex; gap: 5px; }
.dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--paper-2); transition: background .3s, transform .3s; }
.dots i.done { background: var(--gold-2); }
.dots i.now { background: var(--gold); transform: scale(1.5); }
.q { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 26px 0 16px; }
.q .numeral { font-style: italic; color: var(--gold); font-size: 20px; }
.q h2 { font-weight: 400; font-style: italic; font-size: clamp(36px, 10vw, 46px); line-height: 1.04; margin: 6px 0 26px; text-wrap: balance; }
.q-in { animation: rise .5s var(--ease) both; }
.flow-foot { display: flex; gap: 10px; align-items: center; }
.flow-foot .btn:last-child { flex: 1; }

.swatches { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 18px; }
.swatch {
  aspect-ratio: 1; border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0,0,0,.08) inset, 0 6px 12px -8px rgba(40,20,10,.6);
  position: relative;
  transition: transform .25s var(--ease);
}
.swatch.on { transform: scale(1.08); box-shadow: 0 0 0 2px var(--card), 0 0 0 3.5px var(--gold); }
.swatch-name { text-align: center; font-style: italic; color: var(--ink-2); min-height: 1.4em; margin: -4px 0 10px; }

.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  padding: 12px 20px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.35);
  font-size: 21px; font-style: italic;
  transition: all .25s var(--ease);
}
.chip .g { color: var(--gold); margin-right: 6px; font-style: normal; }
.chip.on { background: var(--ink); color: #f7efe2; border-color: var(--ink); }
.chip.on .g { color: var(--gold-2); }

/* ───── dossier ───── */
.portrait-hero { margin: 8px -20px 0; position: relative; }
.portrait-hero img { width: 100%; aspect-ratio: 4 / 3.4; object-fit: cover; mask-image: linear-gradient(#000 70%, transparent); -webkit-mask-image: linear-gradient(#000 70%, transparent); }
.portrait-hero .cap { position: relative; margin-top: -54px; text-align: center; }
.dossier { margin-top: 18px; }
.dossier .row { padding: 16px 0; border-bottom: 1px solid var(--line); animation: rise .6s var(--ease) both; }
.dossier .row:last-child { border-bottom: 0; }
.dossier .lbl { font-family: var(--sans); font-size: 10.5px; letter-spacing: .2em; text-transform: uppercase; color: var(--gold); }
.dossier .val { font-size: 23px; margin-top: 3px; white-space: pre-wrap; overflow-wrap: anywhere; display: flex; align-items: center; gap: 10px; }
.dossier .val .dot { width: 20px; height: 20px; border-radius: 50%; flex: none; box-shadow: 0 0 0 1px rgba(0,0,0,.1) inset; }
.empty { text-align: center; font-style: italic; color: var(--muted); padding: 30px 0; }

.back { display: inline-flex; align-items: center; gap: 8px; }

/* ───── admin ───── */
.admin-list .row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.admin-list .row:last-child { border-bottom: 0; }
.tag { font-family: var(--sans); font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.codes { font-family: ui-monospace, Menlo, monospace; font-size: 15px; }
.codes .row b { font-family: var(--serif); font-weight: 400; font-style: italic; font-size: 20px; }
.hold { position: relative; overflow: hidden; }
.hold i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: rgba(176,106,98,.45); }
.hold.go i { width: 100%; transition: width 1.6s linear; }

.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 24px);
  transform: translateX(-50%);
  background: var(--ink); color: #f7efe2;
  padding: 12px 20px; border-radius: 999px;
  font-style: italic; font-size: 18px;
  animation: rise .4s var(--ease) both;
  z-index: 10;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
.hold { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: none; }
.portrait-hero img { mask-image: linear-gradient(#000 62%, transparent 96%); -webkit-mask-image: linear-gradient(#000 62%, transparent 96%); }
.portrait-hero .cap { margin-top: -28px; }
.portrait-hero .cap .kicker { text-shadow: 0 0 10px var(--paper), 0 0 4px var(--paper); }
.admin-list .btn { white-space: nowrap; }
