:root {
  --ink: #4e2630;
  --berry: #e95373;
  --berry-dark: #b93253;
  --cream: #fff9ef;
  --paper: #fffdf5;
  --pink: #ffdbe2;
  --yellow: #ffd76a;
  --line: rgba(126, 72, 77, 0.16);
  --shadow: 0 22px 60px rgba(87, 36, 49, 0.16);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; background: var(--cream); }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 12%, rgba(255, 215, 106, 0.25), transparent 24rem),
    var(--cream);
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  overflow-x: hidden;
}
body.is-locked { overflow: hidden; }
button, input, a { -webkit-tap-highlight-color: transparent; }
button, input { font: inherit; }
button { color: inherit; }
a { color: inherit; }
img { display: block; max-width: 100%; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.eyebrow {
  margin: 0 0 1rem; font-size: .72rem; font-weight: 800; letter-spacing: .18em;
  text-transform: uppercase; color: rgba(255,255,255,.82);
}
.eyebrow.dark { color: var(--berry-dark); }

/* Lock screen */
.lock-screen {
  position: fixed; inset: 0; z-index: 1000; display: grid; min-height: 100svh; overflow-y: auto;
  transition: opacity .7s ease, visibility .7s ease;
}
.lock-screen.is-opening { opacity: 0; visibility: hidden; }
.lock-photo, .lock-shade { position: absolute; inset: 0; }
.lock-photo {
  background: url("assets/hero.webp") center 42% / cover no-repeat;
  transform: scale(1.03); animation: breathe 9s ease-in-out infinite alternate;
}
.lock-shade {
  background: linear-gradient(180deg, rgba(54,17,27,.12) 0%, rgba(54,17,27,.26) 38%, rgba(54,17,27,.86) 100%);
}
.lock-content {
  position: relative; z-index: 1; align-self: stretch; display: flex; flex-direction: column;
  width: 100%; min-height: 100svh;
  padding: calc(4rem + env(safe-area-inset-top)) 1.25rem calc(2rem + env(safe-area-inset-bottom));
  color: #fff; animation: rise .8s .15s both;
}
.lock-content h1, .hero h1, .section-heading h2, .letter-intro h2, footer h2 {
  font-family: "STKaiti", "KaiTi", "Songti SC", serif;
}
.lock-content h1 {
  margin: 0; font-size: clamp(2.8rem, 14vw, 4.4rem); line-height: .98; letter-spacing: -.04em;
  text-wrap: balance; text-shadow: 0 3px 24px rgba(48,16,24,.24);
}
.lock-note { max-width: 24rem; margin: 1rem 0 1.35rem; font-size: .98rem; line-height: 1.7; color: rgba(255,255,255,.84); }
.password-form { display: grid; grid-template-columns: 1fr; gap: .7rem; width: min(100%, 30rem); margin-top: auto; }
.password-inputs {
  display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: clamp(.38rem, 2vw, .7rem);
  padding: .75rem; border: 1px solid rgba(255,255,255,.42); border-radius: 1.5rem;
  background: linear-gradient(120deg, rgba(255,226,239,.7), rgba(238,226,255,.64));
  box-shadow: 0 12px 34px rgba(60,18,29,.18); backdrop-filter: blur(16px);
}
.password-digit {
  width: 100%; min-width: 0; height: clamp(3.55rem, 15vw, 4.35rem); padding: 0;
  border: 2px solid rgba(245,142,178,.55); border-radius: 1.15rem; outline: none;
  background: rgba(255,255,255,.9); color: var(--berry-dark); text-align: center;
  font-size: clamp(1.3rem, 6vw, 1.7rem); font-weight: 900; caret-color: var(--berry-dark);
  box-shadow: 0 5px 12px rgba(185,50,83,.12);
  transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}
.password-digit:focus {
  border-color: #fff; box-shadow: 0 0 0 4px rgba(255,255,255,.28), 0 7px 16px rgba(185,50,83,.16);
  transform: translateY(-2px);
}
.password-digit[aria-invalid="true"] { border-color: #ffd76a; }
.password-form.shake { animation: shake .35s ease; }
.password-form button, .big-link, .letter-toggle {
  min-height: 3.65rem; border: 0; border-radius: 1.1rem; background: #fff; color: var(--berry-dark);
  font-weight: 900; text-decoration: none; cursor: pointer; box-shadow: 0 8px 24px rgba(60,18,29,.2);
}
.password-form button { font-size: 1.05rem; }
.password-form button:disabled { cursor: not-allowed; opacity: .6; box-shadow: none; }
.password-error { min-height: 1.2rem; margin: 0; padding-left: .2rem; color: #ffe2a2; font-size: .82rem; font-weight: 700; }

/* Hero */
.site { display: none; }
.site.is-visible { display: block; animation: siteIn .8s ease both; }
.hero { position: relative; display: grid; min-height: 100svh; overflow: hidden; color: white; }
.hero-photo, .hero-scrim { position: absolute; inset: 0; }
.hero-photo { background: url("assets/hero.webp") center 42% / cover no-repeat; }
.hero-scrim { background: linear-gradient(180deg, rgba(51,15,24,.08), rgba(51,15,24,.1) 36%, rgba(51,15,24,.84) 100%); }
.hero-content {
  position: relative; z-index: 1; align-self: stretch; display: flex; flex-direction: column;
  min-height: 100svh;
  padding: calc(4rem + env(safe-area-inset-top)) 1.25rem calc(2rem + env(safe-area-inset-bottom));
}
.hero-content > * { opacity: 0; animation: rise .65s both; }
.site.is-visible .hero-content .eyebrow { animation-delay: .2s; }
.site.is-visible .hero-content .doodle { animation-delay: .28s; }
.site.is-visible .hero-content h1 { animation-delay: .36s; }
.site.is-visible .hero-content > p:not(.eyebrow):not(.doodle) { animation-delay: .44s; }
.site.is-visible .hero-content .big-link { animation-delay: .52s; }
.hero h1 { margin: 0; font-size: clamp(3.3rem, 17vw, 5.6rem); line-height: .9; letter-spacing: -.07em; text-shadow: 0 4px 24px rgba(48,16,24,.22); }
.doodle { position: absolute; right: 1.5rem; top: 6.25rem; margin: 0; font-size: 3.5rem; color: var(--yellow); transform: rotate(12deg); }
.hero-content > p:not(.eyebrow):not(.doodle) { max-width: 24rem; margin: 1.2rem 0 1.5rem; line-height: 1.7; color: rgba(255,255,255,.83); }
.big-link { display: inline-flex; align-items: center; justify-content: space-between; width: min(100%, 24rem); margin-top: auto; padding: 0 1.25rem; }
.big-link span { font-size: 1.5rem; }
/* Shared sections */
.memories, .letter-section { padding: 5.5rem 1.15rem; }
.section-heading, .letter-intro { max-width: 34rem; margin: 0 auto 2rem; }
.section-heading h2, .letter-intro h2 { margin: 0; font-size: clamp(2.6rem, 12vw, 4.2rem); line-height: 1; letter-spacing: -.05em; }
.section-heading > p:last-child, .letter-intro > p:last-of-type { margin: 1rem 0 0; line-height: 1.75; color: #79545c; }
.reveal { opacity: 0; transform: translateY(25px); transition: opacity .65s ease, transform .65s ease; }
.reveal.is-revealed { opacity: 1; transform: none; }

/* Carousel */
.memories { position: relative; overflow: hidden; }
.memories::before, .memories::after {
  content: ""; position: absolute; z-index: -1; border-radius: 50%; filter: blur(1px); opacity: .5;
}
.memories::before { width: 15rem; height: 15rem; right: -8rem; top: 7rem; background: var(--pink); }
.memories::after { width: 9rem; height: 9rem; left: -5rem; bottom: 6rem; background: var(--yellow); }
.carousel-shell { max-width: 34rem; margin: auto; }
.photo-stack { position: relative; perspective: 1000px; }
.photo-stack::before, .photo-stack::after {
  content: ""; position: absolute; inset: .5rem .8rem 1.1rem; border: 1px solid var(--line); background: #fff; border-radius: 1.6rem;
  box-shadow: var(--shadow);
}
.photo-stack::before { transform: rotate(-3deg); background: #ffe9cd; }
.photo-stack::after { transform: rotate(2.5deg); background: #ffdce5; }
.photo-card {
  position: relative; z-index: 2; margin: 0; padding: .65rem .65rem 1.35rem; border-radius: 1.6rem;
  background: #fff; box-shadow: var(--shadow); touch-action: pan-y; user-select: none;
  transition: transform .34s ease, opacity .25s ease;
}
.photo-card.is-next { transform: translateX(110%) rotate(8deg); opacity: 0; }
.photo-card.is-prev { transform: translateX(-110%) rotate(-8deg); opacity: 0; }
.photo-open { display: block; width: 100%; padding: 0; border: 0; border-radius: 1.15rem; overflow: hidden; background: #f2e5df; cursor: zoom-in; }
.photo-open img { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; transition: opacity .2s ease, transform .4s ease; }
.photo-open:active img { transform: scale(.985); }
.photo-card figcaption { padding: 1rem .45rem 0; }
.memory-date { margin: 0 0 .45rem; color: var(--berry-dark); font-size: .72rem; font-weight: 900; letter-spacing: .15em; }
.photo-card h3 { margin: 0; font-size: 1.2rem; line-height: 1.45; letter-spacing: -.02em; }
.carousel-meta { display: flex; align-items: center; gap: .75rem; margin: 1.5rem .2rem 1rem; font-size: .75rem; font-weight: 900; color: #966d75; }
.progress { flex: 1; height: 3px; overflow: hidden; background: #ead7d6; }
.progress span { display: block; width: 4.7619%; height: 100%; background: var(--berry); transition: width .35s ease; }
.carousel-actions { display: grid; grid-template-columns: 3.7rem 1fr 3.7rem; align-items: center; gap: .8rem; }
.carousel-actions p { margin: 0; text-align: center; color: #8d6870; font-size: .78rem; }
.round-button {
  width: 3.7rem; height: 3.7rem; border: 1px solid var(--line); border-radius: 50%; background: white;
  box-shadow: 0 8px 22px rgba(87,36,49,.1); font-size: 1.35rem; cursor: pointer;
}
.round-button.primary { background: var(--berry); color: white; border-color: var(--berry); }
.round-button:active { transform: scale(.94); }

/* Letter */
.letter-section { background: var(--pink); }
.letter-toggle { display: flex; justify-content: space-between; align-items: center; width: 100%; margin-top: 1.5rem; padding: 0 1.25rem; background: var(--berry); color: white; }
.letter-toggle span:last-child { color: var(--yellow); font-size: 1.35rem; }
.letter-paper {
  position: relative; max-width: 42rem; margin: 0 auto; padding: 2rem 1.25rem 2.5rem;
  background:
    repeating-linear-gradient(180deg, transparent 0, transparent 2.15rem, rgba(107,146,177,.13) 2.2rem),
    var(--paper);
  background-position: 0 2.8rem; box-shadow: 0 28px 70px rgba(87,36,49,.22);
  transform-origin: top center; animation: unfold .7s cubic-bezier(.22,.8,.22,1) both;
}
.letter-paper::before { content: ""; position: absolute; top: 0; bottom: 0; left: 2.4rem; width: 1px; background: rgba(233,83,115,.2); }
.letter-copy { position: relative; z-index: 1; padding-left: 1.7rem; font-family: "STKaiti", "KaiTi", "Songti SC", serif; font-size: 1.08rem; line-height: 2.05; }
.letter-copy p { margin: 0 0 1.1rem; }
.letter-copy strong { color: var(--berry-dark); font-size: 1.2rem; }
.letter-copy em { color: var(--berry-dark); font-weight: 700; }
.signoff { padding-top: 1.2rem; text-align: right; }
.letter-close { display: block; min-height: 3.4rem; margin: 2rem auto 0; padding: 0 1.3rem; border: 1px solid var(--line); border-radius: 999px; background: white; font-weight: 900; cursor: pointer; }

/* Footer and dialog */
footer { padding: 6rem 1.25rem calc(5rem + env(safe-area-inset-bottom)); text-align: center; background: var(--berry); color: white; }
footer > p:first-child { margin: 0; color: var(--yellow); font-size: 3.2rem; }
footer h2 { margin: .3rem 0; font-size: 3rem; }
footer p:not(:first-child) { margin: .8rem auto 1.5rem; max-width: 22rem; color: rgba(255,255,255,.78); line-height: 1.7; }
footer a { display: inline-grid; place-items: center; min-height: 3.6rem; padding: 0 1.5rem; border: 1px solid rgba(255,255,255,.5); border-radius: 999px; text-decoration: none; font-weight: 800; }
.photo-dialog { width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: rgba(34,15,21,.96); color: white; }
.photo-dialog::backdrop { background: rgba(34,15,21,.96); }
.photo-dialog[open] { display: grid; place-items: center; animation: fadeIn .25s ease; }
.photo-dialog img { max-width: 100%; max-height: 82svh; object-fit: contain; }
.photo-dialog > button { position: fixed; z-index: 2; right: 1rem; top: calc(1rem + env(safe-area-inset-top)); width: 3.4rem; height: 3.4rem; border: 0; border-radius: 50%; background: rgba(255,255,255,.14); color: white; font-size: 2rem; }
.photo-dialog p { position: fixed; bottom: calc(1rem + env(safe-area-inset-bottom)); left: 1.25rem; right: 1.25rem; margin: 0; text-align: center; font-size: .88rem; }

@keyframes breathe { from { transform: scale(1.03); } to { transform: scale(1.09); } }
@keyframes rise { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
@keyframes siteIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes shake { 25% { transform: translateX(-7px); } 50% { transform: translateX(7px); } 75% { transform: translateX(-4px); } }
@keyframes unfold { from { opacity: 0; transform: perspective(900px) rotateX(-12deg) scaleY(.92); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

@media (min-width: 720px) {
  .lock-content, .hero-content { padding-left: max(7vw, 2rem); }
  .lock-content { padding-top: max(8vh, 5rem); padding-bottom: max(7vh, 3rem); }
  .hero-content { padding-top: max(8vh, 5rem); padding-bottom: 8rem; }
  .doodle { right: max(8vw, 2rem); }
  .memories, .letter-section { padding-top: 7.5rem; padding-bottom: 7.5rem; }
  .photo-open img { aspect-ratio: 4 / 4.6; }
  .letter-paper { padding: 3rem 3.4rem 4rem; }
  .letter-copy { padding-left: 2.4rem; font-size: 1.14rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
