.icon.envelope { mask-image: url(icons/envelope-simple.svg); mask-position: center; mask-size: contain; mask-repeat: no-repeat; }

/* A photograph mounted on the same sheet as the handwritten dedication. */
#letter {
  bottom: auto; height: 100dvh; min-height: 0; overflow: auto; overscroll-behavior: contain;
  justify-content: flex-start; gap: 0; scrollbar-width: thin;
  padding: max(74px, env(safe-area-inset-top)) max(24px, 5vw) max(22px, env(safe-area-inset-bottom));
  background: radial-gradient(ellipse at 43% 42%, #2d233749, #101424ac 81%);
  backdrop-filter: blur(5px);
}
#letter .keepsake {
  display: grid; grid-template-columns: minmax(0, 1.07fr) minmax(0, .93fr);
  align-items: center; gap: clamp(26px, 3.8vw, 54px);
  width: min(920px, 100%); padding: clamp(29px, 3.3vw, 44px);
  margin: auto 0 0; flex: none; text-align: left; color: #2b463a;
  border: 1px solid #e8d5a8; outline: 1px solid #a08d605d; outline-offset: -9px;
  background: repeating-linear-gradient(16deg, #a9936610 0 .5px, transparent .6px 4px),
    radial-gradient(ellipse at 78% 18%, #fbf6e8, transparent 70%),
    linear-gradient(123deg, #e9dcc0, #f4ecda 44%, #f5ecd6);
  box-shadow: 0 25px 70px #070b14a6, 0 3px 6px #17191250, inset 0 0 30px #b0956520;
  transform: rotate(-.55deg);
}
.card-print {
  position: relative; margin: 0; padding: 8px; transform: rotate(-2.2deg);
  background: #fbf5e4; border: 1px solid #bea77594;
  box-shadow: 1px 4px 9px #4937244d, 0 1px 2px #59493631; 
}
#card-photo { display: block; width: 100%; aspect-ratio: 4/3; height: auto; background: #17252b; }
.card-print::before, .card-print::after {
  content: ""; position: absolute; z-index: 1; width: 24px; height: 24px;
  background: linear-gradient(139deg, #624f32, #c4a86e 42%, #7c6640 48%, #aa8e58 54%, #534932);
  clip-path: polygon(0 0, 100% 0, 0 100%);
}
.card-print::before { left: -2px; top: -2px; }
.card-print::after { right: -2px; bottom: -2px; transform: rotate(180deg); }
.card-writing { min-width: 0; position: relative; padding: 6px 2px 4px 0; }
#letter .card-writing > .fir { width: 21px; height: 21px; color: #837541; }
.card-writing::before {
  content: ""; position: absolute; top: 16px; left: 31px; width: 37px; height: 1px;
  background: linear-gradient(90deg, #aa9768, #ac9a7000);
}
#letter .card-writing h2 {
  margin: 7px 0 16px; font: 500 italic clamp(37px, 4.65vw, 61px)/.92 var(--serif);
  color: #86463d; letter-spacing: -.055em;
}
#letter .card-writing strong {
  display: block; font: 600 clamp(17px, 1.8vw, 23px)/1.55 var(--cn);
  letter-spacing: .06em; overflow-wrap: anywhere;
}
#letter .card-writing p {
  margin: 8px 0 0; color: #3e5041; font: 500 clamp(14px, 1.5vw, 16px)/1.9 var(--cn);
  white-space: pre-wrap; overflow-wrap: anywhere;
}
#card-wish {
  display: flex; align-items: baseline; gap: 7px; margin: 13px 0 0;
  border-inline-start: 2px solid #baa16b; padding: 3px 0 3px 10px;
  color: #745447; font: 500 13px/1.75 var(--cn); overflow-wrap: anywhere;
}
#letter #card-wish .icon { width: 12px; height: 12px; color: #957642; align-self: flex-start; margin-top: 5px; }
#letter #card-from {
  display: block; width: fit-content; max-width: 100%; margin: 21px 0 0 auto;
  border: 0; padding: 0; font: 500 italic 23px/1.25 var(--serif), var(--cn);
  overflow-wrap: anywhere; color: #6a503b;
}
#letter .letter-actions { flex: none; flex-wrap: wrap; gap: 10px; margin-top: 26px; }
#letter .letter-actions button { gap: 8px; padding-inline: 19px; min-height: 42px; }
#letter .outlined-button {
  display: inline-flex; justify-content: center; align-items: center; border: 1px solid #dfc28b8c;
  border-radius: 30px; background: #2b292add; color: #f0e1c4; font: 500 14px var(--cn);
}
#letter .outlined-button:hover { background: #403935; }
#letter .letter-actions .icon { width: 15px; height: 15px; }
#letter #replay { margin: 7px 0 auto; flex: none; min-height: 35px; }

/* Cream writing paper seated in a deep green velvet folio. */
#gift-desk {
  color-scheme: light; width: min(840px, calc(100% - 36px)); max-width: none;
  max-height: calc(100dvh - 30px); margin: auto; padding: 0; overflow: auto;
  overscroll-behavior: contain; scrollbar-width: thin;
  border: 1px solid #c5ad79; border-radius: 5px; background: #f0e6d1;
  color: #304839; box-shadow: 0 27px 100px #03080dc2, 0 1px 6px #0007;
}
#gift-desk::backdrop { background: #091017ab; backdrop-filter: blur(5px); }
#gift-form {
  position: relative; isolation: isolate; display: grid; grid-template: auto / minmax(0, .87fr) minmax(0, 1.13fr);
}
#desk-close {
  position: sticky; top: 7px; grid-area: 1 / 1 / -1 / -1; z-index: 8; align-self: start; justify-self: end;
  width: 42px; min-height: 42px; margin: 7px 8px 0 0; border-radius: 50%;
  display: grid; place-items: center; color: #475448; background: #f4ebd9f2;
}
#desk-close .icon { width: 16px; height: 16px; }
#desk-close:hover { background: #e9dcc4; }
#gift-desk :focus-visible { outline: 2px solid #96663e; outline-offset: 2px; }
.desk-writing {
  grid-area: 1 / 2; min-width: 0; padding: 48px clamp(24px, 3.8vw, 46px) 32px;
  background: repeating-linear-gradient(16deg, #a9936609 0 .6px, transparent .7px 3px),
    linear-gradient(115deg, #e7dac0, #faf3e3 40%, #efe5ce);
}
#desk-title { margin: 0 0 24px; color: #324b3d; font: 600 clamp(23px, 3vw, 30px)/1.3 var(--cn); letter-spacing: .055em; }
.name-lines { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 15px; }
.desk-writing label { display: block; min-width: 0; color: #485243; font: 600 13px/1.6 var(--cn); }
.desk-writing label small { font: 500 11px DM, sans-serif; color: #6c6a58; }
.desk-writing input, .desk-writing textarea {
  display: block; width: 100%; max-width: 100%; border: 0; border-bottom: 1px solid #a99a796e;
  border-radius: 0; padding: 7px 1px; margin: 1px 0 0; background: transparent;
  color: #223e33; font: 500 15px/1.65 var(--cn); caret-color: #784632;
}
.desk-writing textarea {
  padding: 5px 8px; border: 1px solid #b4a78985; border-radius: 2px;
  background: #fffdf338; min-height: 84px; resize: vertical;
}
.desk-writing input::placeholder, .desk-writing textarea::placeholder { color: #787664; opacity: 1; }
.desk-writing .message-line { margin: 18px 0 20px; }
.desk-writing .message-line textarea { margin-top: 5px; }
#gift-desk #seal-gift {
  min-height: 43px; padding-inline: 19px; font-size: 14px; color: #f7e8c6;
  border-color: #3d604d; background: linear-gradient(120deg, #284e3f, #365341);
  box-shadow: inset 0 0 0 2px #345543, inset 0 0 0 3px #bfa87565;
}
#seal-gift .icon { width: 16px; height: 16px; }
#desk-status { margin: 11px 0 0; color: #626655; font: 500 12px/1.7 DM, "Microsoft YaHei", sans-serif; overflow-wrap: anywhere; }

.envelope-pane {
  grid-area: 1 / 1; position: relative; overflow: hidden; display: grid; place-items: center;
  min-width: 0; min-height: 100%; padding: 38px 0 10px; border-right: 1px solid #b09c72;
  background: repeating-linear-gradient(56deg, #c2b38d09 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at 38% 28%, #37564a, #203e34 48%, #112e29 84%);
}
.envelope-pane::before {
  content: ""; position: absolute; inset: 12px; pointer-events: none;
  border: 1px solid #b99e635e; outline: 1px solid #c6ae7731; outline-offset: 3px;
}
.envelope-model {
  position: relative; width: min(75%, 280px); aspect-ratio: 1.58; margin-top: 21%;
  perspective: 850px; transform: rotate(-5deg); filter: drop-shadow(3px 11px 9px #07170f80);
}
.envelope-back, .envelope-front { position: absolute; inset: 0; border-radius: 2px; }
.envelope-back { z-index: 0; border: 1px solid #95865e; background: linear-gradient(130deg, #142f27, #3a5842); }
.envelope-front {
  z-index: 3; clip-path: polygon(0 0, 50% 51%, 100% 0, 100% 100%, 0 100%); 
  border: 1px solid #b3a06c83; background: linear-gradient(155deg, #688069, #375b47 42%, #2e503f 80%);
}
.envelope-front::before, .envelope-front::after { content: ""; position: absolute; inset: 0; }
.envelope-front::before {
  clip-path: polygon(0 0, 47% 48%, 0 99%); background: linear-gradient(36deg, #345844, #68836a);
}
.envelope-front::after {
  clip-path: polygon(100% 0, 53% 48%, 100% 99%); background: linear-gradient(167deg, #72896d, #496850 65%, #32553f);
}
.envelope-flap {
  position: absolute; z-index: 1; inset: 0 0 auto; height: 64%; transform-origin: 50% 0;
  transform: rotateX(174deg); clip-path: polygon(0 0, 100% 0, 50% 100%);
  background: repeating-linear-gradient(112deg, #ccba880d 0 1px, transparent 1px 3px),
    linear-gradient(156deg, #788a66, #587756 40%, #36573f);
}
.note-slip {
  position: absolute; left: 9%; width: 82%; bottom: 23%; height: 126%; z-index: 2; 
  transform: rotate(4deg); transform-origin: 48% 96%; clip-path: inset(0); text-align: center; overflow: hidden;
  border: 1px solid #c4ae7b; outline: 1px solid #b6a17a90; outline-offset: -6px;
  background: repeating-linear-gradient(23deg, #aa956509 0 1px, transparent 1px 4px),
    linear-gradient(130deg, #fbf2d8, #e5d6ac); color: #785044; box-shadow: 0 2px 7px #1e302940;
}
.note-slip .fir { display: block; margin: 8% auto 0; width: 15px; height: 15px; color: #807446; }
.note-slip em { display: block; margin: 2% 3% 2%; font: 500 italic clamp(28px, 3.1vw, 42px)/1 var(--serif); letter-spacing: -.04em; }
#slip-name { display: block; padding: 0 8%; color: #405444; font: 500 13px/1.5 var(--cn); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wax-mark {
  position: absolute; z-index: 6; top: 50%; left: 50%; display: grid; place-items: center; width: 35px; aspect-ratio: 1;
  border-radius: 48% 45% 49% 43% / 46% 53% 42% 51%; transform: translate(-50%, -18%) scale(.15); opacity: 0;
  background: radial-gradient(ellipse at 30% 17%, #c66957, #904336 36%, #713129 78%, #4a251e);
  box-shadow: inset 0 2px 2px #edaa7d80, inset -1px -2px 3px #4b201d, 1px 3px 4px #10291b7d;
}
.wax-mark::before { content: ""; position: absolute; inset: 4px; border-radius: 50%; border: 1px solid #e69c6c73; box-shadow: 0 1px 0 #481e1d; }
.wax-mark .fir { width: 15px; height: 15px; color: #efbc8c; }
#gift-form[data-sealed=true] .envelope-model { transform: translateY(-16%) rotate(-2deg); }
#gift-form[data-sealed=true] .note-slip { transform: translateY(44%) rotate(0); clip-path: inset(0 0 35%); }
#gift-form[data-sealed=true] .envelope-flap { z-index: 5; transform: rotateX(0); }
#gift-form[data-sealed=true] .wax-mark { opacity: 1; transform: translate(-50%, -18%) scale(1); }
@media (prefers-reduced-motion: no-preference) {
  #gift-desk[open] { animation: desk-open .28s ease-out both; }
  @keyframes desk-open { from { opacity: 0; translate: 0 8px; } }
  #gift-form[data-sealed=true] .envelope-model { transition: transform .78s .34s cubic-bezier(.32, .05, .24, 1); }
  #gift-form[data-sealed=true] .note-slip { transition: transform .46s cubic-bezier(.45, 0, .78, .46), clip-path .46s cubic-bezier(.45, 0, .78, .46); }
  #gift-form[data-sealed=true] .envelope-flap { transition: transform .60s .27s cubic-bezier(.4, 0, .19, 1), z-index 0s .54s; }
  #gift-form[data-sealed=true] .wax-mark { animation: wax-impress .37s .79s both; }
  @keyframes wax-impress {
    0% { opacity: 0; transform: translate(-50%, -25%) scale(1.29); }
    47% { opacity: 1; transform: translate(-50%, -16%) scale(.92, .86); }
    78% { transform: translate(-50%, -19%) scale(1.03, 1.04); }
  }
}
@media (max-width: 680px) {
  #letter { padding: 64px max(16px, 4.6vw) max(17px, env(safe-area-inset-bottom)); }
  #letter .keepsake { width: min(425px, 100%); grid-template-columns: 1fr; gap: 16px; padding: 21px 23px 18px; }
  .card-print { width: 91%; margin-inline: auto; padding: 5px; }
  .card-print::before, .card-print::after { width: 18px; height: 18px; }
  .card-writing { padding: 0 3px; }
  #letter .card-writing > .fir { position: absolute; top: 3px; right: 3px; width: 17px; height: 17px; }
  .card-writing::before { display: none; }
  #letter .card-writing h2 { margin: 0 25px 9px 0; font-size: clamp(33px, 9vw, 46px); }
  #letter .card-writing strong { font-size: 17px; }
  #letter .card-writing p { margin-top: 5px; font-size: 14px; line-height: 1.7; }
  #letter #card-from { margin-top: 12px; font-size: 20px; }
  #card-wish { margin-top: 10px; font-size: 12px; }
  #letter .letter-actions { margin-top: 17px; gap: 8px; }
  #letter .letter-actions button { padding-inline: 15px; }
  #gift-desk { width: min(435px, calc(100% - 22px)); max-height: calc(100dvh - 16px); }
  #gift-form { grid-template: auto auto / minmax(0, 1fr); }
  #desk-close { background: #f2e9d6; border: 1px solid #af9c72a6; }
  .envelope-pane { border-right: 0; border-bottom: 1px solid #a28d60; min-height: 0; height: 190px; padding: 0; }
  .envelope-model { width: 148px; margin-top: 40px; }
  .note-slip em { font-size: 25px; }
  .note-slip .fir { width: 11px; height: 11px; }
  #slip-name { font-size: 11px; }
  .wax-mark { width: 27px; }
  .wax-mark .fir { width: 12px; height: 12px; }
  .desk-writing { grid-area: 2 / 1; padding: 22px clamp(20px, 6vw, 30px) 21px; }
  #desk-title { font-size: 23px; margin-bottom: 15px; }
  .desk-writing input, .desk-writing textarea { font-size: 16px; }
  .desk-writing .message-line { margin: 13px 0 16px; }
}
@media (max-height: 520px) and (min-width: 681px) {
  #letter { padding: 8px 28px 12px; }
  #letter .keepsake { width: min(700px, 94%); gap: 24px; padding: 20px 25px; }
  #letter .card-writing h2 { font-size: 38px; margin: 3px 0 7px; }
  #letter .card-writing strong { font-size: 17px; }
  #letter .card-writing p { font-size: 13px; line-height: 1.6; margin-block: 4px; }
  #letter .letter-actions { margin-top: 12px; }
  #gift-desk { max-height: calc(100dvh - 12px); }
  .desk-writing { padding-block: 23px 18px; }
  #desk-title { font-size: 23px; margin-bottom: 12px; }
  .desk-writing .message-line { margin: 9px 0 12px; }
  .desk-writing textarea { min-height: 60px; }
}
@media (max-height: 520px) and (min-aspect-ratio: 1/1) {
  #letter { top: 65px; height: calc(100dvh - 65px); padding-top: 8px; }
}
