@font-face {
  font-family: "Love Script";
  src: url("assets/fonts/ma-shan-zheng-full.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --night: #120912;
  --night-soft: #24101e;
  --wine: #7d263e;
  --wine-deep: #4b1226;
  --wine-light: #ae5167;
  --gold: #c9a56c;
  --gold-light: #ead2a6;
  --paper: #fbf4df;
  --paper-warm: #f3e5c9;
  --ink: #49332d;
  --ink-soft: #74584e;
  --serif: "Songti SC", STSong, "Noto Serif CJK SC", "Source Han Serif SC", SimSun, serif;
  --script: "Love Script", "STKaiti", KaiTi, cursive;
  --ease-story: cubic-bezier(.22, .8, .24, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--night);
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  overflow-x: hidden;
  color: #f8ecdf;
  background:
    radial-gradient(circle at 50% -10%, rgba(133, 55, 77, .45), transparent 43%),
    radial-gradient(circle at 12% 82%, rgba(103, 42, 69, .28), transparent 38%),
    radial-gradient(circle at 91% 75%, rgba(150, 91, 69, .18), transparent 34%),
    linear-gradient(145deg, #100810 0%, #21101d 50%, #10090f 100%);
  font-family: var(--serif);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button {
  font: inherit;
}

button:focus-visible {
  outline: 2px solid var(--gold-light);
  outline-offset: 5px;
}

.ambient {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.ambient::before,
.ambient::after {
  position: absolute;
  width: 42vw;
  height: 42vw;
  min-width: 320px;
  min-height: 320px;
  border: 1px solid rgba(214, 173, 116, .08);
  border-radius: 50%;
  content: "";
}

.ambient::before {
  top: -26vw;
  left: -18vw;
  box-shadow: 0 0 0 56px rgba(214, 173, 116, .02), 0 0 0 112px rgba(214, 173, 116, .014);
}

.ambient::after {
  right: -25vw;
  bottom: -28vw;
  box-shadow: 0 0 0 70px rgba(214, 173, 116, .018), 0 0 0 140px rgba(214, 173, 116, .012);
}

.glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(3px);
  opacity: .6;
}

.glow-one {
  top: 12%;
  left: 17%;
  width: 6px;
  height: 6px;
  background: #ffe6b8;
  box-shadow: 0 0 28px 7px rgba(255, 211, 156, .45);
}

.glow-two {
  right: 19%;
  bottom: 22%;
  width: 4px;
  height: 4px;
  background: #f3b998;
  box-shadow: 0 0 30px 8px rgba(238, 161, 128, .36);
}

.grain {
  position: absolute;
  inset: -50%;
  opacity: .1;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.82' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.32'/%3E%3C/svg%3E");
  transform: rotate(9deg);
  mix-blend-mode: soft-light;
}

.mote {
  --size: 4px;
  --left: 20%;
  --delay: 0s;
  --duration: 16s;
  position: absolute;
  bottom: -30px;
  left: var(--left);
  width: var(--size);
  height: calc(var(--size) * 1.7);
  border-radius: 70% 0 70% 0;
  opacity: 0;
  background: linear-gradient(145deg, rgba(232, 194, 137, .9), rgba(172, 95, 83, .45));
  animation: drift var(--duration) linear var(--delay) infinite;
}

.mote-1 { --size: 5px; --left: 9%; --delay: -2s; --duration: 18s; }
.mote-2 { --size: 3px; --left: 27%; --delay: -11s; --duration: 15s; }
.mote-3 { --size: 6px; --left: 47%; --delay: -6s; --duration: 22s; }
.mote-4 { --size: 3px; --left: 68%; --delay: -15s; --duration: 17s; }
.mote-5 { --size: 5px; --left: 84%; --delay: -9s; --duration: 21s; }
.mote-6 { --size: 2px; --left: 94%; --delay: -4s; --duration: 14s; }

@keyframes drift {
  0% { opacity: 0; transform: translate3d(0, 0, 0) rotate(5deg); }
  12% { opacity: .42; }
  55% { transform: translate3d(28px, -52vh, 0) rotate(150deg); }
  88% { opacity: .2; }
  100% { opacity: 0; transform: translate3d(-18px, -108vh, 0) rotate(300deg); }
}

.love-letter {
  position: relative;
  z-index: 1;
  display: flex;
  min-height: 100vh;
  min-height: 100svh;
  width: 100%;
  padding: max(36px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.intro {
  position: relative;
  z-index: 2;
  margin: 0 0 clamp(22px, 4vh, 42px);
  text-align: center;
  animation: intro-arrive 1s var(--ease-story) both;
  transition: opacity .38s ease, transform .52s var(--ease-story);
}

.eyebrow {
  margin: 0 0 8px;
  color: rgba(234, 210, 166, .7);
  font: 500 .65rem/1.5 Georgia, serif;
  letter-spacing: .38em;
}

.intro h1 {
  margin: 0;
  color: #f9ead9;
  font: 400 clamp(2.7rem, 7vw, 4.6rem)/1.12 var(--script);
  letter-spacing: .08em;
  text-shadow: 0 8px 30px rgba(0, 0, 0, .32);
}

.since {
  display: flex;
  margin: 11px 0 0;
  align-items: center;
  justify-content: center;
  gap: 13px;
  color: rgba(248, 232, 216, .6);
  font-size: .75rem;
  letter-spacing: .15em;
}

.since span {
  width: 34px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(208, 169, 108, .55));
}

.since span:last-child {
  transform: rotate(180deg);
}

@keyframes intro-arrive {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.envelope-scene {
  position: relative;
  width: min(88vw, 520px);
  perspective: 1600px;
  animation: scene-arrive 1.05s .12s var(--ease-story) both;
}

@keyframes scene-arrive {
  from { opacity: 0; transform: translateY(24px) scale(.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.envelope {
  position: relative;
  width: 100%;
  aspect-ratio: 1.62 / 1;
  transform-style: preserve-3d;
  filter: drop-shadow(0 26px 28px rgba(0, 0, 0, .35));
  cursor: pointer;
}

.envelope-shadow {
  position: absolute;
  right: 8%;
  bottom: -8%;
  left: 8%;
  height: 13%;
  border-radius: 50%;
  opacity: .56;
  background: rgba(0, 0, 0, .65);
  filter: blur(17px);
  transform: translateZ(-20px);
  transition: transform .9s var(--ease-story), opacity .9s ease;
}

.envelope-back {
  position: absolute;
  inset: 0;
  z-index: 2;
  overflow: hidden;
  border: 1px solid rgba(255, 231, 198, .36);
  border-radius: 7px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, .14), transparent 32%),
    linear-gradient(160deg, #f4dfbd 0%, #e6c494 100%);
  box-shadow: inset 0 0 45px rgba(125, 62, 43, .15);
}

.envelope-back::before {
  position: absolute;
  inset: 11px;
  border: 1px solid rgba(116, 66, 51, .13);
  border-radius: 3px;
  content: "";
}

.preview-sheet {
  position: absolute;
  right: 6%;
  bottom: 4%;
  left: 6%;
  z-index: 3;
  display: flex;
  height: 88%;
  padding: 22px;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  border: 1px solid rgba(112, 72, 53, .18);
  border-radius: 3px 3px 0 0;
  color: var(--ink);
  background:
    linear-gradient(90deg, transparent 49.7%, rgba(111, 72, 58, .06) 50%, transparent 50.3%),
    linear-gradient(135deg, #fffaf0, #f4e8cf);
  box-shadow: 0 -8px 20px rgba(47, 19, 24, .12);
  transform: translateY(0) scale(.985);
  transform-origin: center bottom;
  transition: none;
}

.preview-flower {
  color: var(--wine);
  font-size: 1.15rem;
}

.preview-small {
  margin-top: 8px;
  color: var(--ink-soft);
  font: 400 .7rem/1.5 var(--serif);
  letter-spacing: .22em;
}

.preview-sheet strong {
  margin-top: 9px;
  color: var(--ink);
  font: 400 clamp(1rem, 3vw, 1.3rem)/1.4 var(--script);
  letter-spacing: .08em;
}

.flap {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.flap-top {
  z-index: 7;
  clip-path: polygon(0 0, 100% 0, 50% 73%);
  transform: rotateX(0deg);
  transform-origin: 50% 0;
  transform-style: preserve-3d;
}

.flap-top::before,
.flap-liner {
  position: absolute;
  inset: 0;
  clip-path: inherit;
  backface-visibility: hidden;
  content: "";
}

.flap-top::before {
  border-radius: 7px 7px 0 0;
  background:
    linear-gradient(146deg, rgba(255, 255, 255, .28), transparent 38%),
    linear-gradient(165deg, #f5dfba 0%, #dfbd8e 100%);
  box-shadow: inset 0 1px rgba(255, 255, 255, .35);
}

.flap-liner {
  display: block;
  background:
    radial-gradient(circle at 20% 25%, rgba(238, 198, 159, .11) 0 1px, transparent 1.6px),
    radial-gradient(circle at 70% 60%, rgba(238, 198, 159, .08) 0 1px, transparent 1.5px),
    linear-gradient(145deg, #6b1d33, #8b3046);
  background-size: 17px 17px, 23px 23px, auto;
  transform: rotateX(180deg);
}

.flap-left {
  z-index: 5;
  clip-path: polygon(0 0, 59% 51%, 0 100%);
  border-radius: 0 0 0 7px;
  background: linear-gradient(112deg, #efd4aa 0%, #dcb987 100%);
}

.flap-right {
  z-index: 5;
  clip-path: polygon(100% 0, 41% 51%, 100% 100%);
  border-radius: 0 0 7px;
  background: linear-gradient(248deg, #f1d8af 0%, #dab482 100%);
}

.flap-bottom {
  z-index: 6;
  clip-path: polygon(0 100%, 50% 38%, 100% 100%);
  border-radius: 0 0 7px 7px;
  background:
    linear-gradient(160deg, rgba(255, 255, 255, .13), transparent 42%),
    linear-gradient(180deg, #eccfa2 0%, #d7ae79 100%);
  filter: drop-shadow(0 -1px rgba(102, 54, 41, .12));
}

.envelope-address {
  position: absolute;
  top: 24%;
  left: 50%;
  z-index: 8;
  display: flex;
  flex-direction: column;
  align-items: center;
  color: #6d3a34;
  text-align: center;
  transform: translateX(-50%) rotate(-1.5deg);
  transition: opacity .26s ease, transform .45s var(--ease-story);
}

.address-small {
  font: 500 .56rem/1.4 Georgia, serif;
  letter-spacing: .32em;
  opacity: .56;
  white-space: nowrap;
}

.address-name {
  margin-top: 6px;
  font: 400 clamp(1.65rem, 5.7vw, 2.45rem)/1 var(--script);
  letter-spacing: .18em;
  white-space: nowrap;
}

.seal-button {
  position: absolute;
  top: 69%;
  left: 50%;
  z-index: 10;
  display: grid;
  width: clamp(68px, 15vw, 84px);
  height: clamp(68px, 15vw, 84px);
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: #f5d9af;
  background:
    radial-gradient(circle at 32% 27%, rgba(255, 255, 255, .18), transparent 21%),
    radial-gradient(circle at 50% 54%, #9e3850 0%, #772139 62%, #581127 100%);
  box-shadow:
    0 8px 13px rgba(54, 15, 27, .4),
    inset 0 0 0 3px rgba(255, 207, 174, .11),
    inset 0 -5px 8px rgba(55, 8, 25, .3);
  cursor: pointer;
  transform: translate(-50%, -50%);
  transition: transform .3s var(--ease-story), box-shadow .3s ease, opacity .25s ease;
}

.seal-button::before,
.seal-button::after {
  position: absolute;
  border-radius: 50%;
  content: "";
}

.seal-button::before {
  inset: 6px;
  border: 1px solid rgba(248, 205, 153, .35);
}

.seal-button::after {
  inset: -4px;
  border: 1px solid rgba(91, 16, 39, .48);
  clip-path: polygon(0 0, 78% 0, 100% 33%, 88% 100%, 20% 95%, 0 63%);
}

.seal-button:hover {
  box-shadow:
    0 11px 18px rgba(54, 15, 27, .48),
    0 0 0 7px rgba(230, 190, 135, .06),
    inset 0 0 0 3px rgba(255, 207, 174, .14),
    inset 0 -5px 8px rgba(55, 8, 25, .3);
  transform: translate(-50%, -53%) scale(1.055);
}

.seal-button:active {
  transform: translate(-50%, -48%) scale(.97);
}

.seal-highlight {
  position: absolute;
  top: 14%;
  left: 23%;
  width: 23%;
  height: 12%;
  border-radius: 50%;
  background: rgba(255, 233, 205, .14);
  transform: rotate(-28deg);
  filter: blur(1px);
}

.seal-inner {
  display: grid;
  width: 62%;
  height: 62%;
  place-items: center;
  border: 1px solid rgba(246, 213, 168, .42);
  border-radius: 50%;
  font: 400 clamp(1.6rem, 5vw, 2rem)/1 var(--script);
  text-shadow: 0 1px 1px rgba(65, 11, 27, .5);
}

.open-prompt {
  display: flex;
  margin: 28px 0 0;
  align-items: center;
  justify-content: center;
  gap: 13px;
  color: rgba(245, 225, 205, .63);
  font-size: .76rem;
  letter-spacing: .14em;
  transition: opacity .32s ease, transform .45s var(--ease-story);
}

.prompt-line {
  width: clamp(20px, 6vw, 44px);
  height: 1px;
  background: rgba(212, 174, 116, .34);
}

body.has-unlock-dialog {
  overflow: hidden;
}

.unlock-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  padding: max(20px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  place-items: center;
  overflow-y: auto;
  opacity: 0;
  background: rgba(14, 5, 13, .72);
  -webkit-backdrop-filter: blur(12px) saturate(.82);
  backdrop-filter: blur(12px) saturate(.82);
  transition: opacity .28s ease;
}

.unlock-overlay[hidden] {
  display: none;
}

.unlock-overlay.is-visible {
  opacity: 1;
}

.unlock-card {
  position: relative;
  width: min(100%, 440px);
  padding: 52px clamp(28px, 7vw, 48px) 38px;
  overflow: hidden;
  border: 1px solid rgba(211, 175, 117, .42);
  border-radius: 4px;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 9%, rgba(174, 116, 58, .08), transparent 27%),
    radial-gradient(circle at 92% 90%, rgba(126, 39, 62, .055), transparent 30%),
    repeating-linear-gradient(0deg, rgba(93, 62, 43, .017) 0, rgba(93, 62, 43, .017) 1px, transparent 1px, transparent 5px),
    linear-gradient(145deg, #fffaf0, #f5e8ce);
  box-shadow: 0 36px 90px rgba(0, 0, 0, .52), inset 0 0 52px rgba(126, 83, 47, .065);
  text-align: center;
  transform: translateY(18px) scale(.955);
  transition: transform .48s var(--ease-story);
}

.unlock-card::before {
  position: absolute;
  inset: 11px;
  border: 1px solid rgba(151, 113, 65, .16);
  pointer-events: none;
  content: "";
}

.unlock-card::after {
  position: absolute;
  top: -82px;
  right: -76px;
  width: 180px;
  height: 180px;
  border: 1px solid rgba(151, 113, 65, .08);
  border-radius: 50%;
  box-shadow: 0 0 0 24px rgba(151, 113, 65, .025), 0 0 0 48px rgba(151, 113, 65, .018);
  pointer-events: none;
  content: "";
}

.is-visible .unlock-card {
  transform: translateY(0) scale(1);
}

.unlock-close {
  position: absolute;
  top: 21px;
  right: 21px;
  z-index: 2;
  display: grid;
  width: 44px;
  height: 44px;
  padding: 0;
  place-items: center;
  border: 1px solid rgba(111, 74, 51, .16);
  border-radius: 50%;
  color: rgba(83, 54, 43, .57);
  background: rgba(255, 250, 239, .45);
  cursor: pointer;
  transition: color .22s ease, border-color .22s ease, transform .22s var(--ease-story);
}

.unlock-close:hover {
  border-color: rgba(111, 74, 51, .32);
  color: var(--wine);
  transform: rotate(4deg);
}

.unlock-close svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 1.6;
}

.unlock-seal {
  position: relative;
  z-index: 1;
  display: grid;
  width: 64px;
  height: 64px;
  margin: 0 auto 20px;
  place-items: center;
  border-radius: 50%;
  color: #f4d6ac;
  background:
    radial-gradient(circle at 32% 26%, rgba(255, 255, 255, .16), transparent 20%),
    radial-gradient(circle at 50% 54%, #9e3850, #772139 63%, #581127);
  box-shadow: 0 9px 20px rgba(84, 24, 41, .27), inset 0 0 0 3px rgba(255, 213, 168, .1);
  transition: transform .35s var(--ease-story), box-shadow .35s ease;
}

.unlock-seal::before {
  position: absolute;
  inset: 6px;
  border: 1px solid rgba(246, 213, 168, .43);
  border-radius: 50%;
  content: "";
}

.unlock-seal span {
  font: 400 1.65rem/1 var(--script);
}

.unlock-kicker {
  position: relative;
  z-index: 1;
  margin: 0 0 10px;
  color: rgba(110, 75, 52, .52);
  font: 500 .58rem/1.5 Georgia, serif;
  letter-spacing: .3em;
}

.unlock-card h2 {
  position: relative;
  z-index: 1;
  margin: 0;
  color: #61253a;
  font: 400 clamp(1.85rem, 7vw, 2.45rem)/1.25 var(--script);
  letter-spacing: .06em;
}

.unlock-description {
  position: relative;
  z-index: 1;
  margin: 12px 0 26px;
  color: rgba(77, 54, 46, .68);
  font-size: .82rem;
  line-height: 1.75;
  letter-spacing: .06em;
}

.unlock-form {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 12px;
}

.unlock-form label {
  color: rgba(77, 54, 46, .72);
  font-size: .72rem;
  letter-spacing: .16em;
  text-align: left;
}

.unlock-form input {
  width: 100%;
  height: 54px;
  padding: 0 18px;
  border: 1px solid rgba(111, 76, 54, .26);
  border-radius: 3px;
  outline: 0;
  color: #552538;
  background: rgba(255, 252, 244, .74);
  box-shadow: inset 0 2px 8px rgba(102, 67, 46, .045);
  font: 500 1rem/1 var(--serif);
  letter-spacing: .11em;
  text-align: center;
  transition: border-color .22s ease, box-shadow .22s ease, background .22s ease;
}

.unlock-form input::placeholder {
  color: rgba(91, 64, 52, .34);
  font-size: .78rem;
  font-weight: 400;
  letter-spacing: .1em;
}

.unlock-form input:focus {
  border-color: rgba(126, 39, 62, .58);
  background: rgba(255, 253, 247, .96);
  box-shadow: 0 0 0 3px rgba(126, 39, 62, .09), inset 0 2px 8px rgba(102, 67, 46, .035);
}

.unlock-submit {
  display: flex;
  min-height: 52px;
  padding: 0 21px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 1px solid rgba(79, 16, 36, .42);
  border-radius: 3px;
  color: #f8e8d5;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, .08), transparent 34%),
    linear-gradient(145deg, #812a42, #62182f);
  box-shadow: 0 10px 22px rgba(91, 26, 45, .17), inset 0 1px rgba(255, 255, 255, .08);
  cursor: pointer;
  font-size: .84rem;
  letter-spacing: .14em;
  transition: transform .25s var(--ease-story), box-shadow .25s ease, opacity .25s ease;
}

.unlock-submit:hover:not(:disabled) {
  box-shadow: 0 13px 26px rgba(91, 26, 45, .24), inset 0 1px rgba(255, 255, 255, .1);
  transform: translateY(-2px);
}

.unlock-submit:active:not(:disabled) {
  transform: translateY(0);
}

.unlock-submit:disabled {
  opacity: .68;
  cursor: wait;
}

.unlock-submit svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
  transition: transform .25s var(--ease-story);
}

.unlock-submit:hover:not(:disabled) svg {
  transform: translateX(3px);
}

.unlock-status {
  position: relative;
  z-index: 1;
  min-height: 1.5em;
  margin: 15px 0 0;
  color: rgba(91, 63, 50, .55);
  font-size: .7rem;
  line-height: 1.5;
  letter-spacing: .05em;
}

.unlock-card.is-invalid {
  animation: unlock-shake .38s ease both;
}

.unlock-card.is-invalid .unlock-form input {
  border-color: rgba(146, 42, 60, .68);
  box-shadow: 0 0 0 3px rgba(146, 42, 60, .08);
}

.unlock-card.is-invalid .unlock-status {
  color: #8b2d43;
}

.unlock-card.is-success .unlock-seal {
  box-shadow: 0 9px 20px rgba(84, 24, 41, .27), 0 0 0 8px rgba(126, 39, 62, .07), inset 0 0 0 3px rgba(255, 213, 168, .12);
  transform: scale(1.07);
}

.unlock-card.is-success .unlock-status {
  color: #6e2b40;
}

@keyframes unlock-shake {
  0%, 100% { transform: translateX(0); }
  28% { transform: translateX(-7px); }
  58% { transform: translateX(6px); }
  78% { transform: translateX(-3px); }
}

.noscript-message {
  display: none;
  min-height: 100vh;
  min-height: 100svh;
  padding: 28px;
  place-items: center;
  color: #f8ecdf;
  background: var(--night);
  font: 400 1rem/1.8 var(--serif);
  text-align: center;
}

.is-opening .flap-top {
  animation: lift-flap .82s var(--ease-story) forwards;
}

.is-opening .intro {
  animation: intro-exit .38s ease forwards;
}

@keyframes intro-exit {
  to {
    opacity: 0;
    transform: translateY(-12px);
  }
}

.is-opening .preview-sheet {
  animation: reveal-preview .95s .36s var(--ease-story) forwards;
}

.is-opening .seal-button {
  pointer-events: none;
  animation: break-seal .42s var(--ease-story) forwards;
}

.is-opening .envelope-address {
  opacity: 0;
  transform: translateX(-50%) translateY(-7px) rotate(-1.5deg);
}

.is-opening .open-prompt {
  opacity: 0;
  transform: translateY(7px);
}

.is-opening .envelope {
  animation: envelope-breathe 1.25s var(--ease-story) forwards;
}

.is-opening .envelope-shadow {
  opacity: .32;
  transform: translateY(8px) scale(.88) translateZ(-20px);
}

@keyframes lift-flap {
  0% { z-index: 7; transform: rotateX(0deg); }
  49% { z-index: 7; }
  50% { z-index: 2; }
  100% { z-index: 2; transform: rotateX(180deg); }
}

@keyframes reveal-preview {
  0% { z-index: 3; transform: translateY(0) scale(.985); }
  55% { z-index: 4; transform: translateY(-69%) scale(1); }
  100% { z-index: 9; transform: translateY(-94%) scale(1.025); }
}

@keyframes break-seal {
  0% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  45% { opacity: 1; transform: translate(-50%, -43%) scale(.9) rotate(-5deg); }
  100% { opacity: 0; transform: translate(-50%, -23%) scale(.58) rotate(-12deg); }
}

@keyframes envelope-breathe {
  0% { transform: translateY(0) scale(1); }
  52% { transform: translateY(9px) scale(.99); }
  100% { transform: translateY(26px) scale(.96); }
}

.letter-paper {
  position: relative;
  display: none;
  width: min(100%, 800px);
  margin: 0 auto;
  padding: clamp(70px, 10vw, 104px) clamp(28px, 9vw, 92px) clamp(54px, 8vw, 84px);
  overflow: hidden;
  border: 1px solid rgba(124, 84, 51, .24);
  border-radius: 2px;
  color: var(--ink);
  background:
    linear-gradient(90deg, transparent 49.72%, rgba(101, 69, 47, .045) 50%, transparent 50.28%),
    radial-gradient(circle at 11% 8%, rgba(176, 124, 63, .07), transparent 22%),
    radial-gradient(circle at 91% 94%, rgba(137, 74, 62, .06), transparent 26%),
    repeating-linear-gradient(0deg, rgba(93, 62, 43, .015) 0, rgba(93, 62, 43, .015) 1px, transparent 1px, transparent 5px),
    linear-gradient(145deg, #fffaf0 0%, var(--paper) 45%, #f5e8ce 100%);
  box-shadow:
    0 40px 80px rgba(3, 0, 3, .48),
    0 8px 24px rgba(22, 5, 14, .32),
    inset 0 0 65px rgba(126, 83, 47, .075);
}

.letter-paper::before,
.letter-paper::after {
  position: absolute;
  pointer-events: none;
  content: "";
}

.letter-paper::before {
  inset: 16px;
  border: 1px solid rgba(151, 113, 65, .17);
}

.letter-paper::after {
  top: 25%;
  right: -17%;
  width: 42%;
  aspect-ratio: 1;
  border: 1px solid rgba(151, 113, 65, .065);
  border-radius: 50%;
  box-shadow: 0 0 0 22px rgba(151, 113, 65, .025), 0 0 0 44px rgba(151, 113, 65, .018);
}

.is-open {
  justify-content: flex-start;
  padding-top: max(34px, env(safe-area-inset-top));
  padding-bottom: max(62px, env(safe-area-inset-bottom));
}

.is-open .intro,
.is-open .envelope-scene {
  display: none;
}

.is-open .letter-paper {
  display: block;
  animation: paper-arrive .88s var(--ease-story) both;
}

.is-closing .letter-paper {
  animation: paper-leave .46s cubic-bezier(.6, 0, .8, .3) both;
}

@keyframes paper-arrive {
  0% { opacity: 0; transform: translateY(48px) scale(.92); clip-path: inset(0 0 72% 0); }
  45% { opacity: 1; }
  100% { opacity: 1; transform: translateY(0) scale(1); clip-path: inset(0 0 0 0); }
}

@keyframes paper-leave {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0; transform: translateY(40px) scale(.96); }
}

.botanical {
  position: absolute;
  z-index: 0;
  width: clamp(118px, 24vw, 180px);
  fill: none;
  stroke: rgba(153, 115, 65, .32);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.15;
  pointer-events: none;
}

.botanical-top {
  top: 12px;
  left: 11px;
}

.botanical-bottom {
  right: 11px;
  bottom: 12px;
  transform: rotate(180deg);
}

.close-letter,
.music-toggle,
.edit-toggle {
  position: absolute;
  top: 26px;
  z-index: 3;
  display: flex;
  min-height: 44px;
  padding: 9px 12px;
  align-items: center;
  gap: 5px;
  border: 1px solid rgba(112, 77, 53, .18);
  border-radius: 999px;
  color: rgba(80, 53, 45, .68);
  background: rgba(255, 250, 239, .55);
  cursor: pointer;
  transition: color .25s ease, border-color .25s ease, background .25s ease, transform .25s var(--ease-story);
}

.close-letter {
  right: 29px;
}

.music-toggle {
  left: 29px;
}

.edit-toggle {
  left: 143px;
}

.close-letter svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.edit-toggle svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.music-bars {
  display: flex;
  width: 18px;
  height: 17px;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.music-bars i {
  width: 2px;
  height: 9px;
  border-radius: 2px;
  background: currentColor;
  transform-origin: center;
}

.music-bars i:nth-child(2) {
  height: 13px;
}

.music-bars i:nth-child(3) {
  height: 7px;
}

.music-toggle.is-playing .music-bars i {
  animation: music-breathe .9s ease-in-out infinite alternate;
}

.music-toggle.is-playing .music-bars i:nth-child(2) {
  animation-delay: -.38s;
  animation-duration: 1.12s;
}

.music-toggle.is-playing .music-bars i:nth-child(3) {
  animation-delay: -.67s;
  animation-duration: .78s;
}

@keyframes music-breathe {
  from { transform: scaleY(.48); }
  to { transform: scaleY(1.08); }
}

.close-letter > span,
.music-toggle > span:last-child,
.edit-toggle > span {
  font-size: .68rem;
  letter-spacing: .08em;
}

.close-letter:hover,
.music-toggle:hover,
.music-toggle.is-playing,
.edit-toggle:hover,
.edit-toggle.is-editing {
  border-color: rgba(112, 77, 53, .34);
  color: var(--wine);
  background: rgba(255, 250, 239, .88);
  transform: translateY(2px);
}

.close-letter:focus-visible,
.music-toggle:focus-visible,
.edit-toggle:focus-visible {
  outline-color: var(--wine);
}

#letterMusic {
  display: none;
}

.paper-header,
.letter-content,
.signature,
.paper-ending {
  position: relative;
  z-index: 1;
}

.paper-header {
  margin-bottom: clamp(38px, 7vw, 62px);
  text-align: center;
}

.paper-kicker {
  margin: 0 0 19px;
  color: rgba(110, 75, 52, .53);
  font: 500 .6rem/1.5 Georgia, serif;
  letter-spacing: .32em;
}

.paper-mark {
  position: relative;
  display: grid;
  width: 48px;
  height: 48px;
  margin: 0 auto 21px;
  place-items: center;
  border: 1px solid rgba(124, 39, 62, .4);
  border-radius: 50%;
  color: var(--wine);
}

.paper-mark::before,
.paper-mark::after {
  position: absolute;
  top: 50%;
  width: clamp(42px, 10vw, 82px);
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(151, 113, 65, .42));
  content: "";
}

.paper-mark::before {
  right: calc(100% + 13px);
}

.paper-mark::after {
  left: calc(100% + 13px);
  transform: rotate(180deg);
}

.paper-mark span {
  font: 400 1.5rem/1 var(--script);
}

.paper-header h2 {
  margin: 0;
  color: #562236;
  font: 400 clamp(2.4rem, 7vw, 4.1rem)/1.12 var(--script);
  letter-spacing: .08em;
}

.paper-header h2:focus {
  outline: none;
}

.paper-subtitle {
  margin: 13px 0 0;
  color: var(--ink-soft);
  font: 400 clamp(1rem, 2.8vw, 1.28rem)/1.5 var(--script);
  letter-spacing: .08em;
}

.letter-content {
  max-width: 34em;
  margin: 0 auto;
  color: var(--ink);
  font-size: clamp(1.02rem, .96rem + .25vw, 1.16rem);
  font-weight: 400;
  line-height: 2.08;
  letter-spacing: .055em;
  text-align: justify;
  text-justify: inter-ideograph;
}

.letter-content p {
  margin: 0 0 1.55em;
  text-indent: 2em;
}

.letter-content p:last-child {
  margin-bottom: 0;
}

.drop-year {
  color: var(--wine);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.06em;
  font-weight: 600;
  letter-spacing: .03em;
}

.letter-content blockquote {
  position: relative;
  margin: clamp(35px, 7vw, 58px) 0;
  padding: clamp(25px, 5vw, 38px) 8px;
  border-top: 1px solid rgba(147, 105, 60, .24);
  border-bottom: 1px solid rgba(147, 105, 60, .24);
  color: #6f2b40;
  font: 400 clamp(1.28rem, 3.6vw, 1.7rem)/1.8 var(--script);
  letter-spacing: .08em;
  text-align: center;
}

.letter-content blockquote .quote-mark {
  position: absolute;
  top: 3px;
  left: 1px;
  color: rgba(126, 39, 62, .15);
  font: 400 4.8rem/1 Georgia, serif;
}

.signature {
  display: flex;
  max-width: 34em;
  margin: clamp(50px, 9vw, 82px) auto 0;
  flex-direction: column;
  align-items: flex-end;
  color: #5c2b39;
}

.signature-line {
  max-width: 100%;
  font: 400 clamp(1.7rem, 5vw, 2.5rem)/1.25 var(--script);
  letter-spacing: .1em;
  text-align: right;
}

.signature-date {
  margin-top: 9px;
  color: rgba(91, 63, 50, .62);
  font-size: .72rem;
  letter-spacing: .14em;
}

.draft-tools {
  position: relative;
  z-index: 1;
  display: flex;
  max-width: 34em;
  margin: 34px auto 0;
  padding-top: 18px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-top: 1px solid rgba(147, 105, 60, .2);
}

.draft-tools p {
  margin: 0;
  color: rgba(91, 63, 50, .66);
  font-size: .72rem;
  line-height: 1.55;
  letter-spacing: .04em;
}

.draft-tools > div {
  display: flex;
  flex: 0 0 auto;
  gap: 7px;
}

.draft-tools button,
.edit-toolbar button {
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid rgba(112, 77, 53, .22);
  border-radius: 6px;
  color: #6b3947;
  background: rgba(255, 250, 239, .66);
  cursor: pointer;
  font-size: .74rem;
  letter-spacing: .03em;
}

.draft-tools button:hover,
.edit-toolbar button:hover {
  border-color: rgba(125, 38, 62, .42);
  background: #fffaf0;
}

.draft-tools button:disabled {
  opacity: .44;
  cursor: default;
}

.is-editing-letter [contenteditable="true"] {
  border-radius: 4px;
  outline: 1px dashed rgba(125, 38, 62, .36);
  outline-offset: 5px;
  background: rgba(255, 252, 242, .52);
  cursor: text;
}

.is-editing-letter [contenteditable="true"]:focus {
  outline: 2px solid rgba(125, 38, 62, .62);
  background: rgba(255, 253, 247, .92);
}

.is-editing-letter .letter-content p {
  text-indent: 0;
}

.is-editing-letter .letter-content blockquote {
  padding-right: 14px;
  padding-left: 14px;
}

.quote-text {
  position: static;
  display: block;
  width: 100%;
  white-space: pre-wrap;
}

.edit-toolbar {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  left: max(16px, env(safe-area-inset-left));
  z-index: 20;
  display: flex;
  width: min(760px, calc(100% - 32px));
  min-height: 70px;
  margin: 0 auto;
  padding: 12px 14px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid rgba(223, 190, 144, .28);
  border-radius: 8px;
  color: #f6e9da;
  background: rgba(28, 11, 24, .95);
  box-shadow: 0 18px 50px rgba(3, 0, 3, .45);
  backdrop-filter: blur(15px);
}

.edit-toolbar[hidden] {
  display: none;
}

.edit-toggle[hidden],
.draft-tools[hidden] {
  display: none;
}

.edit-toolbar-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 3px;
}

.edit-toolbar-copy strong {
  font-size: .8rem;
  letter-spacing: .08em;
}

.edit-toolbar-copy span {
  overflow: hidden;
  color: rgba(246, 233, 218, .66);
  font-size: .7rem;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.edit-toolbar-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 7px;
}

.edit-toolbar .edit-cancel,
.edit-toolbar .edit-export {
  color: rgba(246, 233, 218, .78);
  background: rgba(255, 255, 255, .06);
}

.edit-toolbar .edit-save {
  border-color: rgba(239, 206, 157, .52);
  color: #34131f;
  background: #e9c78f;
  font-weight: 600;
}

.has-edit-toolbar .love-letter {
  padding-bottom: max(142px, calc(env(safe-area-inset-bottom) + 120px));
}

.paper-ending {
  display: flex;
  margin: clamp(45px, 8vw, 70px) auto 0;
  align-items: center;
  justify-content: center;
  gap: 13px;
  color: rgba(126, 39, 62, .64);
}

.paper-ending span {
  width: 48px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(147, 105, 60, .38));
}

.paper-ending span:last-child {
  transform: rotate(180deg);
}

.paper-ending b {
  display: grid;
  width: 31px;
  height: 31px;
  place-items: center;
  border: 1px solid rgba(126, 39, 62, .27);
  border-radius: 50%;
  font: 400 .66rem/1 Georgia, serif;
}

.is-open .paper-header > *,
.is-open .letter-content > *,
.is-open .signature,
.is-open .paper-ending {
  animation: ink-reveal .64s var(--ease-story) both;
}

.is-open .paper-header > *:nth-child(1) { animation-delay: .38s; }
.is-open .paper-header > *:nth-child(2) { animation-delay: .44s; }
.is-open .paper-header > *:nth-child(3) { animation-delay: .5s; }
.is-open .paper-header > *:nth-child(4) { animation-delay: .56s; }
.is-open .letter-content > *:nth-child(1) { animation-delay: .61s; }
.is-open .letter-content > *:nth-child(2) { animation-delay: .66s; }
.is-open .letter-content > *:nth-child(3) { animation-delay: .71s; }
.is-open .letter-content > *:nth-child(4) { animation-delay: .76s; }
.is-open .letter-content > *:nth-child(5) { animation-delay: .81s; }
.is-open .letter-content > *:nth-child(6) { animation-delay: .86s; }
.is-open .letter-content > *:nth-child(7) { animation-delay: .91s; }
.is-open .letter-content > *:nth-child(8) { animation-delay: .96s; }
.is-open .letter-content > *:nth-child(9) { animation-delay: 1.01s; }
.is-open .signature { animation-delay: 1.06s; }
.is-open .paper-ending { animation-delay: 1.11s; }

@keyframes ink-reveal {
  from { opacity: 0; transform: translateY(9px); }
  to { opacity: 1; transform: translateY(0); }
}

.page-note {
  margin: clamp(26px, 4vh, 45px) 0 0;
  color: rgba(234, 210, 166, .3);
  font: 500 .56rem/1.5 Georgia, serif;
  letter-spacing: .4em;
  text-align: center;
  transition: opacity .32s ease;
}

.is-opening .page-note {
  opacity: 0;
}

.is-open .page-note {
  margin-top: 32px;
  color: rgba(234, 210, 166, .36);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 680px) {
  .love-letter {
    padding-right: max(12px, env(safe-area-inset-right));
    padding-left: max(12px, env(safe-area-inset-left));
  }

  .intro {
    margin-bottom: 28px;
  }

  .envelope-scene {
    width: min(94vw, 500px);
  }

  .letter-paper {
    width: 100%;
    padding: 79px clamp(21px, 7vw, 44px) 58px;
  }

  .letter-paper::before {
    inset: 10px;
  }

  .close-letter,
  .music-toggle,
  .edit-toggle {
    top: 22px;
    width: 44px;
    padding: 0;
    justify-content: center;
    border-radius: 50%;
  }

  .close-letter {
    right: 21px;
  }

  .music-toggle {
    left: 21px;
  }

  .edit-toggle {
    left: 73px;
  }

  .close-letter > span,
  .music-toggle > span:last-child,
  .edit-toggle > span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }

  .draft-tools {
    align-items: flex-start;
    flex-direction: column;
  }

  .draft-tools > div {
    width: 100%;
  }

  .draft-tools button {
    flex: 1 1 0;
  }

  .edit-toolbar {
    min-height: 0;
    padding: 11px;
    align-items: stretch;
    flex-direction: column;
    gap: 9px;
  }

  .edit-toolbar-copy {
    padding: 0 2px;
  }

  .edit-toolbar-actions button {
    min-width: 0;
    flex: 1 1 0;
    padding-right: 7px;
    padding-left: 7px;
  }

  .paper-header {
    margin-bottom: 38px;
  }

  .letter-content {
    line-height: 1.98;
    letter-spacing: .035em;
    text-align: left;
  }

  .letter-content p {
    margin-bottom: 1.4em;
  }

  .botanical {
    opacity: .68;
  }
}

@media (max-width: 420px) {
  .love-letter:not(.is-open) {
    padding-top: max(24px, env(safe-area-inset-top));
  }

  .eyebrow {
    font-size: .58rem;
    letter-spacing: .28em;
  }

  .intro h1 {
    font-size: 2.8rem;
  }

  .since {
    gap: 8px;
    font-size: .68rem;
    letter-spacing: .09em;
  }

  .since span {
    width: 19px;
  }

  .envelope-scene {
    width: 94vw;
  }

  .open-prompt {
    gap: 8px;
    font-size: .69rem;
    letter-spacing: .09em;
  }

  .preview-sheet {
    padding-top: 15px;
  }

  .preview-small {
    margin-top: 4px;
  }

  .preview-sheet strong {
    margin-top: 5px;
  }

  .paper-kicker {
    letter-spacing: .19em;
  }

  .paper-header h2 {
    font-size: clamp(1.88rem, 8.8vw, 2.2rem);
    letter-spacing: .035em;
    white-space: nowrap;
  }

  .letter-content {
    font-size: 1rem;
  }

  .letter-content blockquote {
    margin: 32px 0;
    padding-right: 0;
    padding-left: 0;
    font-size: 1.24rem;
  }

  .letter-content blockquote br {
    display: none;
  }

  .unlock-card {
    padding: 44px 27px 31px;
  }

  .unlock-seal {
    width: 58px;
    height: 58px;
    margin-bottom: 16px;
  }

  .unlock-description {
    margin-bottom: 21px;
  }
}

@media (max-height: 620px) {
  .unlock-overlay {
    place-items: start center;
  }

  .unlock-card {
    margin: 0;
  }
}

@media (max-height: 640px) and (min-width: 520px) {
  .love-letter:not(.is-open) {
    justify-content: flex-start;
    padding-top: 22px;
  }

  .intro {
    margin-bottom: 15px;
  }

  .intro h1 {
    font-size: 2.7rem;
  }

  .since {
    margin-top: 5px;
  }

  .envelope-scene {
    width: min(70vh, 450px);
  }

  .open-prompt {
    margin-top: 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }

  .mote {
    display: none;
  }
}

@media print {
  :root {
    color-scheme: light;
  }

  body {
    background: #fff;
  }

  .ambient,
  .intro,
  .envelope-scene,
  .close-letter,
  .music-toggle,
  .edit-toggle,
  .draft-tools,
  .edit-toolbar,
  .page-note {
    display: none !important;
  }

  .love-letter {
    display: block;
    min-height: 0;
    padding: 0;
  }

  .letter-paper,
  .is-open .letter-paper {
    display: block !important;
    width: 100%;
    padding: 18mm 16mm;
    border: 0;
    box-shadow: none;
    animation: none !important;
  }

  .letter-content {
    font-size: 11pt;
  }
}
