:root {
  --rose: #df5b8b;
  --rose-dark: #7b2a47;
  --rose-mid: #b54870;
  --rose-soft: #ffb4cc;
  --paper: #fffdfb;
  --paper-pink: #fff4f8;
  --line: rgba(190, 79, 122, .18);
  --line-strong: rgba(190, 79, 122, .34);
  --text: #6d2943;
  --muted: #9c6579;
  --shadow: 0 28px 70px rgba(202, 88, 130, .20);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; overflow-x: hidden; }
body {
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 10% 0%, rgba(255, 184, 207, .58), transparent 30%),
    radial-gradient(circle at 92% 18%, rgba(255, 226, 235, .95), transparent 34%),
    linear-gradient(180deg, #fff8fa 0%, #ffe2ec 52%, #fff4f8 100%);
}

.bg-aura {
  position: fixed;
  border-radius: 999px;
  filter: blur(70px);
  opacity: .42;
  pointer-events: none;
  z-index: 0;
}
.aura-one { width: 260px; height: 260px; left: -100px; top: -70px; background: #ff9fbd; }
.aura-two { width: 300px; height: 300px; right: -120px; bottom: 10%; background: #ffd1df; }
.aura-three { width: 190px; height: 190px; left: 50%; bottom: -80px; background: #fff; opacity: .55; }

.pattern-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    linear-gradient(rgba(199, 96, 133, .04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(199, 96, 133, .04) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: radial-gradient(circle at center, black 34%, transparent 92%);
}

.petals { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 1; }
.petal {
  position: absolute;
  top: -30px;
  width: 12px;
  height: 18px;
  border-radius: 12px 12px 12px 3px;
  background: linear-gradient(135deg, #fff, #ff9fbe);
  opacity: .72;
  animation: fall linear infinite;
}
@keyframes fall {
  to { transform: translate3d(var(--x), 110vh, 0) rotate(420deg); }
}

.app {
  position: relative;
  z-index: 2;
  width: min(100%, 560px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 14px 44px;
}

.hidden { display: none !important; }

/* Envelope open scene */
.envelope-scene {
  min-height: calc(100vh - 40px);
  display: grid;
  place-items: center;
  align-content: center;
  gap: 22px;
}
.scene-title { text-align: center; }
.scene-title span,
.tag {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  color: var(--rose-dark);
  background: rgba(255,255,255,.72);
  font-size: .8rem;
  letter-spacing: .08em;
}
.scene-title h1 {
  margin: 14px 0 8px;
  font-size: clamp(2rem, 9vw, 3rem);
  line-height: 1.15;
  color: var(--rose-dark);
}
.scene-title p {
  color: var(--muted);
  line-height: 1.8;
  text-align: center;
}

.envelope-button {
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  perspective: 1200px;
}
.envelope {
  position: relative;
  width: min(86vw, 390px);
  height: 250px;
  transform-style: preserve-3d;
  transition: transform .7s ease;
}
.envelope-button:hover .envelope { transform: translateY(-4px) rotateX(3deg); }

.env-back {
  position: absolute;
  inset: 48px 0 0;
  border-radius: 22px;
  background: linear-gradient(180deg, #fff7fa, #ffdbe7);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.letter-peek {
  position: absolute;
  left: 32px;
  right: 32px;
  top: 22px;
  height: 150px;
  border-radius: 18px;
  background:
    repeating-linear-gradient(180deg, transparent, transparent 28px, rgba(216, 110, 149, .10) 29px),
    linear-gradient(180deg, #fff, #fff8fb);
  border: 1px solid rgba(190, 79, 122, .12);
  display: grid;
  place-items: center;
  color: var(--rose-dark);
  transform: translateY(46px);
  transition: transform 1s .35s ease;
  box-shadow: 0 18px 34px rgba(201, 100, 139, .12);
}
.letter-peek span { font-size: 1.6rem; font-weight: 800; }
.letter-peek small { margin-top: -44px; color: var(--muted); }
.env-left, .env-right, .env-bottom, .env-flap {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 202px;
  border-radius: 0 0 22px 22px;
}
.env-left {
  clip-path: polygon(0 0, 50% 56%, 0 100%);
  background: linear-gradient(135deg, #ffd4e2, #fff2f6);
}
.env-right {
  clip-path: polygon(100% 0, 50% 56%, 100% 100%);
  background: linear-gradient(225deg, #ffd4e2, #fff2f6);
}
.env-bottom {
  clip-path: polygon(0 100%, 50% 42%, 100% 100%);
  background: linear-gradient(180deg, #ffc6d9, #ffe8f0);
}
.env-flap {
  top: 48px;
  bottom: auto;
  height: 128px;
  transform-origin: 50% 0%;
  clip-path: polygon(0 0, 50% 100%, 100% 0);
  background: linear-gradient(180deg, #ffb4cc, #ffe1eb);
  border-top: 1px solid var(--line);
  transition: transform .9s ease;
  z-index: 4;
}
.env-seal {
  position: absolute;
  left: 50%;
  top: 132px;
  width: 54px;
  height: 54px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: linear-gradient(135deg, var(--rose), #ff9fbd);
  color: white;
  display: grid;
  place-items: center;
  font-size: 1.25rem;
  box-shadow: 0 12px 26px rgba(223, 93, 143, .25);
  z-index: 5;
  transition: opacity .35s ease, transform .6s ease;
}
.envelope.open .env-flap { transform: rotateX(178deg); }
.envelope.open .letter-peek { transform: translateY(-62px); }
.envelope.open .env-seal { opacity: 0; transform: translateX(-50%) scale(.6); }

.cover-hints {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}
.cover-hints span {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,.58);
  color: var(--rose-dark);
  font-size: .9rem;
}

/* Book scene */
.book-scene {
  min-height: calc(100vh - 40px);
  display: grid;
  place-items: start center;
}
.book-shell {
  width: 100%;
  border-radius: 34px;
  padding: 14px;
  background: linear-gradient(180deg, rgba(255,255,255,.84), rgba(255,246,250,.96));
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}
.book-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 2px 2px 12px;
}
.tiny-btn {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,.78);
  color: var(--rose-dark);
  padding: 9px 13px;
  font: inherit;
}
.progress {
  color: var(--rose-dark);
  font-size: .92rem;
  background: rgba(255,255,255,.55);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
}

.book-viewport {
  position: relative;
  perspective: 1500px;
}
.book-page {
  display: none;
  transform-origin: left center;
}
.book-page.active {
  display: block;
  animation: pageIn .52s cubic-bezier(.2,.78,.2,1);
}
@keyframes pageIn {
  from { opacity: 0; transform: rotateY(18deg) translateX(16px) scale(.985); }
  to { opacity: 1; transform: rotateY(0) translateX(0) scale(1); }
}
.paper-inner {
  position: relative;
  min-height: 720px;
  border-radius: 26px;
  padding: 18px;
  background:
    linear-gradient(90deg, rgba(139, 65, 93, .08), transparent 9%),
    repeating-linear-gradient(180deg, transparent, transparent 31px, rgba(216,110,149,.07) 32px),
    linear-gradient(180deg, var(--paper), var(--paper-pink));
  border: 1px solid rgba(190,79,122,.14);
  overflow: hidden;
}
.paper-inner::before {
  content: "";
  position: absolute;
  left: 22px;
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(190,79,122,.10);
}
.page-sticker {
  position: absolute;
  right: 16px;
  top: 18px;
  transform: rotate(3deg);
  padding: 9px 14px;
  border-radius: 999px;
  background: linear-gradient(135deg, #ffe2ec, #fff);
  border: 1px solid var(--line);
  color: var(--rose-dark);
  font-weight: 800;
  box-shadow: 0 10px 20px rgba(201,100,139,.10);
  z-index: 5;
}
.sticker-top { right: 24px; top: 22px; }

.cover-page { display: block; }
.cover-hero-grid {
  display: grid;
  gap: 16px;
}
.cover-art-wrap {
  position: relative;
}
.cover-art {
  width: 100%;
  border-radius: 22px;
  display: block;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  object-position: center 18%;
  border: 1px solid rgba(190,79,122,.12);
  box-shadow: 0 16px 28px rgba(201,100,139,.12);
  cursor: zoom-in;
}
.tap-tip {
  position: absolute;
  right: 12px;
  bottom: 12px;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.74);
  color: var(--rose-dark);
  font-size: .8rem;
}
h2 {
  margin: 14px 0 12px;
  font-size: clamp(2rem, 9vw, 2.75rem);
  line-height: 1.12;
  color: var(--rose-dark);
}
h3 { margin: 0; }
p {
  line-height: 1.86;
  color: var(--muted);
}
.info-cards {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}
.info-cards div, .note-card, .signature-line, .chat-intro, .album-ticket, .soft-note, .final-card, .final-wishes div, .final-sign {
  border: 1px solid rgba(190,79,122,.12);
  background: rgba(255,255,255,.62);
  border-radius: 18px;
  padding: 12px 14px;
}
.info-cards strong {
  display: inline-flex;
  width: 38px;
  height: 38px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(135deg, var(--rose), #ff9fbd);
  margin-right: 10px;
}
.info-cards span {
  color: var(--rose-dark);
  font-weight: 700;
}
.cover-note-row {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}
.soft-note h3 {
  margin: 8px 0 8px;
  color: var(--rose-dark);
  font-size: 1.25rem;
}
.soft-note p { margin: 0; }
.note-label {
  display: inline-flex;
  padding: 5px 10px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--rose), #ff9fbd);
  color: white;
  font-weight: 800;
  font-size: .78rem;
  letter-spacing: .04em;
}
.mini-wish-board {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}
.wish-chip {
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,.6);
  color: var(--rose-dark);
  font-weight: 700;
}
.cover-polaroids {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 11px;
  margin-top: 14px;
}
.mini-polaroid {
  border-radius: 16px;
  background: #fff;
  padding: 8px 8px 12px;
  border: 1px solid rgba(190,79,122,.12);
  box-shadow: 0 14px 28px rgba(201,100,139,.12);
  text-align: center;
}
.rotate-left { transform: rotate(-2deg); }
.rotate-right { transform: rotate(2deg); }
.mini-photo {
  height: 76px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 1.6rem;
  color: white;
  margin-bottom: 8px;
}
.heart-photo { background: radial-gradient(circle at 30% 20%, #fff4f8, #ff8eb3 45%, #df5b8b); }
.star-photo { background: linear-gradient(135deg, #ffd7e4, #ff8eb3); }
.cake-photo { background: linear-gradient(135deg, #ffe0e9, #ffb4cc); }
.mini-polaroid span {
  color: var(--rose-dark);
  font-weight: 800;
  font-size: .9rem;
}

.letter-layout { display: grid; gap: 14px; }
.letter-text {
  border-radius: 22px;
  padding: 16px;
  background: rgba(255,255,255,.62);
  border: 1px solid rgba(190,79,122,.10);
}
.letter-text p {
  margin: 0 0 14px;
  color: var(--text);
}
.letter-side-grid {
  display: grid;
  gap: 10px;
}
.note-card span {
  display: inline-flex;
  color: #fff;
  background: linear-gradient(135deg, var(--rose), #ff9fbd);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: .86rem;
  font-weight: 800;
}
.note-card p { margin: 8px 0 0; }
.signature-line {
  margin-top: 14px;
  display: flex;
  justify-content: space-between;
  color: var(--rose-dark);
  font-weight: 800;
}
.signature-line strong { color: var(--rose); }

.chat-intro {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}
.avatar-bubble {
  width: 58px;
  height: 58px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  color: white;
  font-weight: 900;
  background: linear-gradient(135deg, var(--rose), #ff9fbd);
  box-shadow: 0 12px 22px rgba(223,93,143,.18);
}
.chat-intro p { margin: 0; line-height: 1.65; font-size: .94rem; }

.chat-box {
  min-height: 250px;
  max-height: 300px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
  border-radius: 20px;
  background: rgba(255,255,255,.62);
  border: 1px solid rgba(190,79,122,.12);
}
.msg {
  max-width: 90%;
  border-radius: 18px;
  padding: 12px 14px;
  line-height: 1.82;
  white-space: pre-wrap;
  font-size: .98rem;
}
.msg.bot {
  align-self: flex-start;
  background: rgba(255,250,252,.95);
  border: 1px solid rgba(190,79,122,.14);
}
.msg.user {
  align-self: flex-end;
  color: white;
  background: linear-gradient(135deg, var(--rose), #ff9fbd);
}
.quick-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 9px;
  margin-top: 12px;
}
.quick-btn,
#sendBtn,
.nav-btn {
  border: none;
  border-radius: 18px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.quick-btn {
  padding: 11px 9px;
  background: rgba(255,255,255,.76);
  color: var(--rose-dark);
  border: 1px solid var(--line);
}
.input-row {
  display: grid;
  grid-template-columns: 1fr 84px;
  gap: 10px;
  margin-top: 12px;
}
#chatInput {
  resize: none;
  height: 64px;
  border-radius: 18px;
  border: 1px solid rgba(190,79,122,.14);
  background: rgba(255,255,255,.78);
  padding: 12px;
  color: var(--text);
  font: inherit;
  outline: none;
}
#sendBtn {
  color: #fff;
  background: linear-gradient(135deg, var(--rose), #ff9fbd);
}
.album-note {
  margin: 0 0 14px;
  border-radius: 18px;
  padding: 12px 14px;
  background: rgba(255,255,255,.66);
  border: 1px solid rgba(190,79,122,.12);
}
.photo-grid {
  display: grid;
  gap: 14px;
}
.photo-card {
  margin: 0;
  background: white;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid rgba(190,79,122,.12);
  box-shadow: 0 16px 30px rgba(201,100,139,.12);
}
.photo-card img {
  width: 100%;
  display: block;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  cursor: zoom-in;
}
.photo-caption {
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: .9rem;
}
.album-footer {
  margin-top: 14px;
  display: grid;
  gap: 12px;
}
.album-ticket {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.album-ticket span { color: var(--muted); }
.album-ticket strong { color: var(--rose-dark); }

.final-page {
  display: grid;
  align-content: center;
  gap: 16px;
}
.final-card {
  text-align: center;
  padding: 26px 18px;
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 180, 204, .35), transparent 38%),
    rgba(255,255,255,.66);
}
.final-heart {
  width: 76px;
  height: 76px;
  margin: 0 auto 14px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: white;
  background: linear-gradient(135deg, var(--rose), #ff9fbd);
  font-size: 2rem;
  box-shadow: 0 18px 36px rgba(223,93,143,.22);
}
.final-card h2 {
  font-size: clamp(1.9rem, 8vw, 2.55rem);
}
.final-card p {
  text-align: left;
}
.final-wishes {
  display: grid;
  gap: 10px;
}
.final-wishes div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.final-wishes strong {
  color: var(--rose-dark);
}
.final-wishes span {
  color: var(--muted);
}
.final-sign {
  display: flex;
  justify-content: space-between;
  font-weight: 800;
  color: var(--rose-dark);
}

.book-controls {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  padding-top: 14px;
  margin-top: 14px;
  border-top: 1px solid rgba(190,79,122,.12);
}
.nav-btn {
  padding: 13px 10px;
  color: var(--rose-dark);
  background: rgba(255,255,255,.78);
  border: 1px solid var(--line);
}
.nav-btn.primary {
  color: white;
  border: none;
  background: linear-gradient(135deg, var(--rose), #ff9fbd);
}
.nav-btn.soft {
  background: rgba(255,255,255,.56);
}

/* modal */
.modal,
.image-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
}
.modal-mask,
.image-mask {
  position: absolute;
  inset: 0;
  background: rgba(117, 49, 76, .26);
  backdrop-filter: blur(8px);
}
.modal-card {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(90vw, 390px);
  transform: translate(-50%, -50%);
  border-radius: 28px;
  padding: 20px;
  background: linear-gradient(180deg, rgba(255,255,255,.96), rgba(255,246,249,.98));
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.modal-close,
.image-close {
  position: absolute;
  right: 14px;
  top: 14px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.88);
  color: var(--rose-dark);
  font-size: 1.25rem;
  z-index: 2;
}
.modal-card h3 {
  margin: 14px 0 8px;
  color: var(--rose-dark);
}
.image-modal {
  display: grid;
  place-items: center;
  padding: 22px;
}
.image-modal img {
  position: relative;
  max-width: min(96vw, 920px);
  max-height: 86vh;
  object-fit: contain;
  border-radius: 24px;
  background: white;
  box-shadow: 0 30px 80px rgba(117,49,76,.32);
  z-index: 1;
}

.photo-card img,
.cover-art {
  transition: transform .25s ease, filter .25s ease;
}
.photo-card img:hover,
.cover-art:hover {
  transform: scale(1.015);
  filter: saturate(1.05);
}

@media (min-width: 700px) {
  .app { width: min(100%, 820px); }
  .paper-inner { min-height: 690px; }
  .cover-hero-grid {
    grid-template-columns: .9fr 1.1fr;
    align-items: start;
  }
  .cover-art {
    aspect-ratio: 3 / 4;
    max-height: 390px;
  }
  .cover-copy { padding-top: 34px; }
  .cover-note-row {
    grid-template-columns: 1.25fr .75fr;
  }
  .letter-layout {
    grid-template-columns: 1.25fr .75fr;
    align-items: stretch;
  }
  .letter-side-grid {
    align-content: stretch;
  }
  .photo-grid { grid-template-columns: repeat(2, 1fr); }
  .final-wishes { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .app {
    padding-inline: 10px;
  }
  .book-shell {
    padding: 12px;
    border-radius: 26px;
  }
  .paper-inner {
    min-height: 720px;
    padding: 14px;
    border-radius: 22px;
  }
  .cover-polaroids {
    grid-template-columns: repeat(3, 1fr);
  }
  .mini-photo {
    height: 64px;
  }
  .book-controls {
    gap: 7px;
  }
  .nav-btn {
    font-size: .92rem;
    padding: 12px 6px;
  }
}
