@font-face {
  font-family: "Caveat";
  src: url("/fonts/caveat-latin.woff2") format("woff2");
  font-style: normal;
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: "Winter Kai UI";
  src: url("/fonts/winter-kai-ui.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Winter Kai";
  src: url("/fonts/winter-kai.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}
:root {
  color-scheme: dark;
  --ink: #f5f1e8;
  --muted: #c5bfb3;
  --handwriting: "Caveat", "Winter Kai UI", "Winter Kai", "Kaiti SC", STKaiti, KaiTi, "PingFang SC", "Microsoft YaHei", sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: #080909; color: var(--ink); font: 1rem var(--handwriting); }
button, input, textarea { font: inherit; }
button { color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
button:focus-visible, input:focus-visible { outline: 2px solid #c1fff3; outline-offset: 4px; }
.scene {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  min-height: max(630px, 100svh);
  background: radial-gradient(ellipse at 50% 65%, #18211d 0%, #0b0e0d 40%, #070808 72%);
}
.scene::before, .scene::after { content: ""; position: absolute; inset: 0; pointer-events: none; }
.scene::before { z-index: -3; background: url("/midnight.jpg") center 67% / cover; filter: grayscale(1); opacity: .20; }
.scene::after { z-index: -2; background: radial-gradient(ellipse at 50% 60%, transparent 18%, #050606ac 77%); }
#winter, .branches { position: absolute; inset: 0; width: 100%; height: 100%; }
#winter { z-index: -1; }
.intro {
  position: absolute;
  width: 100%;
  top: clamp(31px, 5.2vh, 64px);
  text-align: center;
  padding-inline: 12px;
  pointer-events: none;
}
h1 {
  margin: 0;
  font: 500 clamp(2rem, 4.4vw, 3.8rem)/1.13 "Caveat", cursive;
  letter-spacing: 0;
  text-shadow: 0 0 36px #f1ddae29, 0 4px 15px #050606;
}
.branches { pointer-events: none; }
.branch {
  --scale: 1;
  --tilt: 0deg;
  --presence: 0;
  position: absolute;
  display: grid;
  place-items: center;
  width: 53px;
  height: 47px;
  padding: 0;
  border: 0;
  background: none;
  opacity: var(--presence);
  transform: translate(-50%, -50%) scale(var(--scale)) rotate(var(--tilt));
  pointer-events: auto;
  touch-action: manipulation;
}
.branch::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  height: 13px;
  width: 4px;
  border: 1px solid #d3b67a9e;
  border-radius: 50%;
  transform: translateX(-50%);
}
.branch img { width: 41px; height: auto; margin-top: 7px; filter: drop-shadow(0 3px 4px #000d); transition: scale .2s, filter .2s; }
.branch img:nth-of-type(2) { display: none; }
.branch.filled img:first-of-type { display: none; }
.branch.filled img:nth-of-type(2) { display: block; }
.branch:hover img, .branch:focus-visible img { scale: 1.14; filter: drop-shadow(0 0 7px #ffe2a2a8); }
.invitation { z-index: 2; position: absolute; bottom: calc(46px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); width: max-content; max-width: calc(100% - 24px); text-align: center; }
.invitation p { margin: 0 0 13px; font-size: .875rem; color: #ddd4c1; }
.invitation-actions { display: flex; justify-content: center; gap: clamp(6px, 1.5vw, 14px); }
.invitation-actions .primary { flex: 0 0 auto; padding-inline: clamp(10px, 3.4vw, 25px); white-space: nowrap; }
.participation {
  min-width: 0;
  min-height: 44px;
  padding: 5px clamp(9px, 2.5vw, 14px);
  border: 1px solid #c5a97740;
  border-radius: 999px;
  background: #181612e8;
  color: #eee4d1;
  font-size: clamp(.84rem, 2.8vw, 1rem);
  line-height: 1.35;
  text-wrap: balance;
}
.participation strong { color: #f2cb80; font-size: 1.4em; font-variant-numeric: tabular-nums; text-shadow: 0 0 14px #f2cb8066; }
.participation:hover, .participation:focus-visible { border-color: #c5a977; color: #fff7e5; }
.primary {
  padding: 11px 25px;
  min-height: 44px;
  border-radius: 999px;
  border: 1px solid #b9a2718c;
  background: #222c25;
  color: #fbf4e5;
  font-size: .94rem;
  letter-spacing: .05em;
  box-shadow: inset 0 1px #fff1d320, 0 0 21px #b6d2a710;
  transition: background .2s, box-shadow .2s, opacity .2s;
}
.primary:hover:not(:disabled) { box-shadow: inset 0 1px #fff1d333, 0 0 20px #e4c17c37; background: #334034; }
.primary:disabled { opacity: .44; }
.footer { position: absolute; inset: auto clamp(14px, 3.7vw, 58px) max(17px, env(safe-area-inset-bottom)) ; display: flex; justify-content: space-between; gap: 12px; }
.quiet { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; border: 0; background: none; color: #c6bcac; padding: 0 5px; font-size: .875rem; }
.quiet:hover { color: #fff7e5; }
.quiet svg { width: 16px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
dialog {
  width: min(510px, calc(100vw - 28px));
  max-height: calc(100svh - 32px);
  padding: 0;
  color: #f4ede2;
  border: 1px solid #b795655e;
  border-radius: 5px;
  background: #1d1719;
  box-shadow: 0 28px 85px #000c;
  overscroll-behavior: contain;
}
dialog::backdrop { background: #060505aa; backdrop-filter: blur(8px); }
dialog[open] { animation: arrive .28s ease-out both; }
@keyframes arrive { from { opacity: 0; translate: 0 12px; } to { opacity: 1; translate: 0 0; } }
.dialog-inner { position: relative; padding: 31px clamp(16px, 5vw, 26px) 25px; }
.dialog-inner h2 { font: 500 1.8rem/1.25 var(--handwriting); margin: 0 28px 16px 0; letter-spacing: .035em; }
#letter .dialog-inner {
  --letter-stage-height: min(432px, calc(100svh - 90px));
  display: grid;
  align-items: center;
  min-height: calc(var(--letter-stage-height) + 56px);
  background: radial-gradient(ellipse at 50% 40%, #43282c, #201619 76%);
}
#letter .unwrap, #letter .letter-content { grid-area: 1 / 1; }
.close { position: absolute; right: 4px; top: 3px; display: grid; place-items: center; border: 0; background: #20171a; width: 40px; height: 40px; color: #f4e7d5; font-size: 1.5rem; z-index: 4; border-radius: 50%; }
.unwrap {
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  text-align: center;
  min-height: var(--letter-stage-height);
}
.unwrap h2 { margin: 0 0 35px; }
.unwrap p { color: #dbccbf; font-size: .9rem; margin: 21px 0 0; }
.unwrap.opening h2, .unwrap.opening p { opacity: 0; transition: opacity .24s ease; }
.envelope {
  width: min(302px, 87%);
  aspect-ratio: 1.66;
  border: 0;
  background: none;
  position: relative;
  padding: 0;
  perspective: 650px;
  filter: drop-shadow(0 12px 17px #0008);
}
.envelope-back, .envelope-front, .envelope-flap, .envelope-fold, .envelope-lining, .ribbon { display: block; position: absolute; inset: 0; }
.envelope-back { background: #b18c6c url("/art/stationery.jpg") center 99% / 120% 320%; border-radius: 2px; }
.envelope-front {
  background: linear-gradient(142deg, #a98d5d45, #e7cd9920 46%, #fcf3df30), url("/art/stationery.jpg") center 50% / 220%;
  clip-path: polygon(0 0, 50% 57%, 100% 0, 100% 100%, 0 100%); border-radius: 2px;
}
.envelope-flap {
  transform-style: preserve-3d;
  transform-origin: center top;
  transition: transform .48s .24s cubic-bezier(.22,.75,.23,1);
}
.envelope-fold, .envelope-lining {
  backface-visibility: hidden;
  clip-path: polygon(0 0, 100% 0, 100% 6%, 51% 62%, 49% 62%, 0 6%);
}
.envelope-fold { background: linear-gradient(163deg, #fef6e347, #b29b7042), url("/art/stationery.jpg") center 50% / 190%; }
.envelope-lining { transform: rotateY(180deg); background: linear-gradient(#b9936580, #f7e7bd28), url("/art/stationery.jpg") center 57% / 180%; }
.envelope-wax { position: absolute; width: 16%; height: auto; left: 42%; top: 48%; backface-visibility: hidden; filter: drop-shadow(0 2px 2px #41302568); }
.ribbon::before, .ribbon::after, .ribbon i, .ribbon b { content: ""; position: absolute; display: block; background: linear-gradient(115deg, #46141d, #9b3549 48%, #5e1727 81%); box-shadow: inset 0 0 0 1px #d5aa9b2e, 0 2px 4px #2b101999; }
.ribbon::before { width: 100%; height: 8%; left: 0; top: 48%; }
.ribbon::after { height: 100%; width: 4%; top: 0; left: 48%; }
.ribbon i { top: 41%; width: 17%; height: 12%; left: 35%; border-radius: 40% 64% 47% 39%; transform: rotate(19deg); z-index: 1; }
.ribbon i:nth-child(2) { left: 48%; transform: scaleX(-1) rotate(19deg); }
.ribbon i:nth-child(3), .ribbon i:nth-child(4) { top: 50%; width: 5%; height: 25%; left: 44%; clip-path: polygon(0 0,100% 0,100% 100%,50% 85%,0 100%); border-radius: 0; transform: rotate(27deg); }
.ribbon i:nth-child(4) { left: 52%; transform: rotate(-27deg); }
.ribbon b { inset: 46% 47% auto; width: 6%; height: 10%; border-radius: 4px; z-index: 2; }
.unwrap.opening .ribbon { animation: loosen .53s ease both; }
.unwrap.opening .ribbon::before { animation: slide-ribbon .45s ease both; }
.unwrap.opening .ribbon::after { animation: slide-ribbon .45s .04s ease both; transform-origin: bottom; }
.unwrap.opening .envelope-flap { transform: rotateX(174deg); }
.unwrap.opening .envelope-wax { opacity: 0; transition: opacity .16s .22s; }
.unwrap.opening .envelope:focus-visible { outline: none; }
@keyframes loosen {
  30% { transform: translate(6px, -3px) scaleX(1.09) rotate(-6deg); }
  63% { opacity: .86; }
  to { transform: translate(50px, 27px) rotate(-16deg) scaleX(1.27); opacity: 0; }
}
@keyframes slide-ribbon { to { scale: 1.36 .72; opacity: 0; } }

.letter-content { min-width: 0; }
.paper { position: relative; perspective: 1100px; }
.emerging .paper { z-index: 1; opacity: 0; pointer-events: none; transform-origin: top center; }
.emerging .paper-turn { transform: rotateY(180deg); }
.emerging .card-actions { visibility: hidden; }

.paper-turn { position: relative; transform-style: preserve-3d; }
.paper-front, .paper-back {
  border-radius: 2px;
  backface-visibility: hidden;
  box-shadow: 0 10px 28px #14070c91;
}
.paper-front {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 280px;
  padding: clamp(25px, 6vw, 39px);
  color: #302f2b;
  background: #f8f7f2 url("/art/card-paper.jpg") center / cover;
  color-scheme: light;
}
.paper-front:focus { outline: none; }
.paper-back {
  position: absolute;
  inset: 0;
  transform: rotateY(180deg);
  background: #ded8bd url("/art/card-cloth.jpg") center / cover;
}
.paper-front textarea, .paper-front input {
  color: #302f2b;
  font-family: var(--handwriting);
  background: transparent;
  border: 0;
  border-radius: 0;
}
.paper-front input:focus-visible { outline: 1px solid #817d73; outline-offset: 5px; }
.paper-front textarea::placeholder { color: #6d685f; }
.paper-front textarea {
  display: block;
  width: 100%;
  height: 171px;
  min-height: 100px;
  max-height: 30svh;
  resize: none;
  outline: none;
  caret-color: #302f2b;
  padding: 0;
  font-size: 1.12rem;
  line-height: 1.75;
}
.paper-front .signature { display: flex; align-items: center; gap: 12px; margin-top: 18px; font-size: .9rem; }
.signature input { min-width: 28px; width: min(160px, 75%); padding: 4px 0; border-bottom: 1px solid #817b6d84; }
.card-actions { display: grid; justify-items: center; margin-top: 17px; }
.form-error { color: #ffc5ba; font-size: .875rem; margin: 10px 0 0; }
.form-error:empty { display: none; }
blockquote, .note-text { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.75; font-family: var(--handwriting); }
blockquote { margin: 0; }
.note-by { color: #645e55; overflow-wrap: anywhere; }
#read-one .note-by { margin: 15px 0 0; text-align: right; }
.collection > p { color: var(--muted); }
#notes, #draft-list { display: grid; gap: 13px; }
#draft-list button { text-align: start; font: inherit; }
#draft-list button:hover, #draft-list button:focus-visible { outline: 2px solid #c3a979; outline-offset: 2px; }
.note-card {
  padding: 17px 19px;
  border: 1px solid #fff4dca0;
  border-radius: 2px;
  background: #f8f7f2 url("/art/card-paper.jpg") center / cover;
  color: #442e28;
}
.note-card p { margin: 0; }
.note-card .note-by { text-align: right; margin-top: 7px; font-size: .875rem; }
#read-one blockquote { max-height: min(34svh, 275px); overflow: auto; }
#show-more { margin-top: 15px; }
.toast { position: fixed; z-index: 5; left: 50%; bottom: 25px; transform: translateX(-50%); width: max-content; max-width: calc(100vw - 30px); text-align: center; border-radius: 99px; background: #27231c; padding: 12px 19px; color: #fcf0dc; border: 1px solid #c5a36ead; opacity: 0; pointer-events: none; transition: opacity .2s; }
.toast.visible { opacity: 1; }
@media (max-width: 600px) {
  .intro { top: 6.4%; }
  .branch img { width: 35px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; transition-delay: 0ms !important; }
}
