:root {
  --red: #8d1f27;
  --red-dark: #5f151c;
  --rose: #c96b71;
  --blush: #e8c5c0;
  --ivory: #f6f0e5;
  --paper: #fffaf0;
  --ink: #3f302f;
  --muted: #876f6a;
  --gold: #b38a4a;
  --green: #63705b;
  --page-shadow: 0 28px 80px rgba(54, 20, 20, 0.22);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  color: var(--ink);
  background: #2f2423;
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  letter-spacing: 0;
}

button,
input,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}

.book {
  position: relative;
  width: 100%;
  height: 100%;
  perspective: 2200px;
  background: #312625;
}

.chapter {
  position: absolute;
  inset: 0;
  display: grid;
  min-width: 0;
  min-height: 100%;
  overflow: hidden;
  background: var(--ivory);
  transform-origin: left center;
  transform: rotateY(0deg);
  transition: transform 850ms cubic-bezier(.68, 0, .24, 1), opacity 380ms ease;
  backface-visibility: hidden;
  box-shadow: var(--page-shadow);
}

.chapter::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(rgba(80, 49, 43, 0.055) 0.7px, transparent 0.7px),
    radial-gradient(rgba(179, 138, 74, 0.04) 0.7px, transparent 0.7px);
  background-position: 0 0, 6px 7px;
  background-size: 11px 11px, 13px 13px;
  mix-blend-mode: multiply;
}

.chapter.is-past {
  transform: rotateY(-105deg);
  pointer-events: none;
}

.chapter.is-future {
  pointer-events: none;
}

.chapter-inner {
  position: relative;
  z-index: 1;
  width: min(1180px, calc(100% - 120px));
  min-height: 100%;
  margin: 0 auto;
  padding: 110px 0 96px;
}

.eyebrow {
  margin: 0 0 22px;
  color: var(--gold);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: 0.22em;
}

.chapter-no {
  margin: 0 0 40px;
  color: rgba(141, 31, 39, 0.18);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(64px, 8vw, 116px);
  line-height: 0.75;
}

h1,
h2,
blockquote {
  font-family: "STKaiti", "KaiTi", serif;
  font-weight: 400;
}

h2 {
  margin: 0;
  color: var(--red-dark);
  font-size: clamp(40px, 5vw, 72px);
  line-height: 1.35;
}

.body-copy {
  max-width: 540px;
  margin: 34px 0 0;
  color: var(--muted);
  font-family: "STSong", "SimSun", serif;
  font-size: 17px;
  line-height: 2;
}

.topbar {
  position: fixed;
  z-index: 50;
  top: 24px;
  right: 30px;
  left: 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}

.monogram {
  color: var(--red);
  font-family: Georgia, serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.mode-switch {
  display: flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid rgba(141, 31, 39, 0.18);
  border-radius: 6px;
  background: rgba(255, 250, 240, 0.82);
  backdrop-filter: blur(12px);
  pointer-events: auto;
}

.mode-button,
.icon-button,
.nav-button,
.restart-button {
  display: grid;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 0;
  place-items: center;
  background: transparent;
  cursor: pointer;
}

.mode-button {
  border-radius: 4px;
  color: var(--muted);
}

.mode-button.is-active {
  color: var(--paper);
  background: var(--red);
}

.music-button {
  border: 1px solid rgba(141, 31, 39, 0.18);
  border-radius: 50%;
  color: var(--red);
  background: rgba(255, 250, 240, 0.82);
  backdrop-filter: blur(12px);
  pointer-events: auto;
}

.music-button.is-playing span {
  animation: pulse-note 1.6s ease-in-out infinite;
}

@keyframes pulse-note {
  50% { transform: scale(1.2) rotate(8deg); }
}

.cover {
  color: var(--paper);
  background: var(--red-dark);
}

.cover::before {
  opacity: 0.34;
  mix-blend-mode: screen;
}

.cover::after {
  content: "囍";
  position: absolute;
  top: 50%;
  left: 50%;
  color: rgba(232, 201, 143, 0.035);
  font-family: "STKaiti", "KaiTi", serif;
  font-size: min(72vw, 780px);
  line-height: 1;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.cover-frame {
  position: relative;
  z-index: 2;
  display: flex;
  width: calc(100% - 70px);
  min-height: calc(100% - 70px);
  margin: 35px;
  padding: 70px 30px;
  border: 1px solid rgba(231, 198, 134, 0.7);
  align-items: center;
  flex-direction: column;
  justify-content: center;
  text-align: center;
}

.cover-frame::before,
.cover-frame::after {
  content: "";
  position: absolute;
  width: 70px;
  height: 70px;
  border-color: var(--gold);
  opacity: 0.8;
}

.cover-frame::before {
  top: 12px;
  left: 12px;
  border-top: 2px solid;
  border-left: 2px solid;
}

.cover-frame::after {
  right: 12px;
  bottom: 12px;
  border-right: 2px solid;
  border-bottom: 2px solid;
}

.cover .eyebrow {
  color: #e8c98f;
}

.seal {
  display: grid;
  width: 78px;
  height: 78px;
  margin: 14px 0 28px;
  padding: 0;
  border: 1px solid rgba(255, 239, 207, 0.66);
  border-radius: 50%;
  color: var(--red-dark);
  background: #e8c98f;
  box-shadow: 0 0 0 8px rgba(232, 201, 143, 0.12);
  place-items: center;
  cursor: pointer;
  transition: transform 220ms ease, box-shadow 220ms ease;
}

.seal:hover {
  transform: scale(1.04);
  box-shadow: 0 0 0 12px rgba(232, 201, 143, 0.13);
}

.seal span {
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 42px;
  line-height: 1;
}

.cover h1 {
  margin: 0;
  color: #fff8e9;
  font-size: clamp(46px, 6vw, 80px);
  line-height: 1.05;
}

.cover h1 span {
  color: #e8c98f;
  font-family: Georgia, serif;
  font-size: 0.46em;
}

.cover-date {
  margin: 32px 0 0;
  color: #e8c98f;
  font-family: Georgia, serif;
  font-size: 15px;
  letter-spacing: 0.15em;
}

.cover-line {
  width: 44px;
  height: 1px;
  margin: 28px 0;
  background: rgba(232, 201, 143, 0.7);
}

.cover-note {
  margin: 0;
  color: rgba(255, 248, 233, 0.84);
  font-family: "STSong", "SimSun", serif;
  font-size: 16px;
  line-height: 1.9;
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(320px, 0.82fr);
  gap: 8vw;
  align-items: center;
}

.memory-window {
  position: relative;
  display: flex;
  width: 100%;
  aspect-ratio: 4 / 5;
  min-height: 0;
  border: 1px solid rgba(141, 31, 39, 0.22);
  align-items: center;
  flex-direction: column;
  justify-content: center;
  color: rgba(95, 21, 28, 0.6);
  background:
    linear-gradient(135deg, rgba(141, 31, 39, 0.07), rgba(179, 138, 74, 0.13)),
    repeating-linear-gradient(45deg, transparent 0 18px, rgba(255, 255, 255, 0.25) 18px 19px);
}

.memory-window::after {
  content: "";
  position: absolute;
  inset: 18px;
  border: 1px solid rgba(179, 138, 74, 0.35);
}

.memory-window span {
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 28px;
}

.memory-window small {
  margin-top: 10px;
  color: var(--gold);
  font-family: Georgia, serif;
  font-size: 10px;
  letter-spacing: 0.18em;
}

.promise {
  color: var(--paper);
  background: var(--red-dark);
}

.promise::after {
  content: "";
  position: absolute;
  top: -24vh;
  right: -9vw;
  width: min(56vw, 720px);
  aspect-ratio: 1;
  border: 1px solid rgba(232, 201, 143, 0.22);
  border-radius: 50%;
}

.centered-copy {
  display: flex;
  align-items: center;
  flex-direction: column;
  justify-content: center;
  text-align: center;
}

.promise .chapter-no {
  color: rgba(232, 201, 143, 0.18);
}

.promise blockquote {
  margin: 20px 0 70px;
  color: #fff7e7;
  font-size: clamp(36px, 5vw, 68px);
  line-height: 1.6;
}

.timeline {
  display: grid;
  width: min(760px, 100%);
  grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid rgba(232, 201, 143, 0.38);
}

.timeline div {
  position: relative;
  display: flex;
  padding-top: 24px;
  align-items: center;
  flex-direction: column;
}

.timeline div::before {
  content: "";
  position: absolute;
  top: -5px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #e8c98f;
}

.timeline time {
  color: #e8c98f;
  font-family: Georgia, serif;
  font-size: 12px;
  letter-spacing: 0.08em;
}

.timeline span {
  margin-top: 9px;
  color: rgba(255, 248, 233, 0.8);
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 18px;
}

.date-page {
  background: #f3e7d8;
}

.date-layout {
  display: grid;
  grid-template-columns: minmax(300px, 0.8fr) minmax(360px, 0.7fr);
  gap: 8vw;
  align-items: center;
  justify-content: center;
}

.big-date {
  color: var(--red);
  font-family: Georgia, serif;
  font-size: clamp(230px, 32vw, 500px);
  font-weight: 700;
  line-height: 0.72;
  text-align: center;
}

.date-copy h2 {
  margin-bottom: 16px;
}

.lunar {
  margin: 0 0 42px;
  color: var(--muted);
  font-family: "STSong", "SimSun", serif;
}

.time-grid {
  display: grid;
  max-width: 420px;
  margin-bottom: 38px;
  grid-template-columns: repeat(2, 1fr);
  border-top: 1px solid rgba(141, 31, 39, 0.25);
  border-bottom: 1px solid rgba(141, 31, 39, 0.25);
}

.time-grid div {
  display: flex;
  padding: 22px 0;
  align-items: baseline;
  gap: 16px;
}

.time-grid div + div {
  padding-left: 24px;
  border-left: 1px solid rgba(141, 31, 39, 0.25);
}

.time-grid span {
  color: var(--muted);
  font-size: 13px;
}

.time-grid strong {
  color: var(--red);
  font-family: Georgia, serif;
  font-size: 24px;
}

.command-button,
.submit-button {
  min-height: 44px;
  padding: 0 26px;
  border: 1px solid var(--red);
  border-radius: 4px;
  color: var(--paper);
  background: var(--red);
  cursor: pointer;
  transition: color 180ms ease, background 180ms ease, transform 180ms ease;
}

.command-button:hover,
.submit-button:hover {
  transform: translateY(-2px);
  color: var(--red);
  background: transparent;
}

.venue {
  background: #e9e1d4;
}

.venue-layout {
  display: grid;
  grid-template-columns: minmax(360px, 1.1fr) minmax(320px, 0.7fr);
  gap: 8vw;
  align-items: center;
}

.map-art {
  position: relative;
  width: 100%;
  aspect-ratio: 5 / 4;
  overflow: hidden;
  background:
    linear-gradient(32deg, transparent 47%, rgba(99, 112, 91, 0.12) 48% 52%, transparent 53%),
    linear-gradient(146deg, transparent 45%, rgba(141, 31, 39, 0.07) 46% 52%, transparent 53%),
    #f7f1e7;
  box-shadow: inset 0 0 0 1px rgba(63, 48, 47, 0.12);
}

.road {
  position: absolute;
  height: 2px;
  background: rgba(99, 112, 91, 0.32);
  transform-origin: left center;
}

.road-a { top: 22%; left: -10%; width: 120%; transform: rotate(18deg); }
.road-b { top: 80%; left: 4%; width: 100%; transform: rotate(-32deg); }
.road-c { top: 8%; left: 48%; width: 80%; transform: rotate(82deg); }

.map-pin {
  position: absolute;
  top: 47%;
  left: 55%;
  display: grid;
  width: 62px;
  height: 62px;
  border-radius: 50% 50% 50% 0;
  color: #fff5e8;
  background: var(--red);
  place-items: center;
  transform: translate(-50%, -65%) rotate(-45deg);
  box-shadow: 0 14px 26px rgba(95, 21, 28, 0.25);
}

.map-pin span {
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 25px;
  transform: rotate(45deg);
}

.venue-copy h2 {
  margin-bottom: 24px;
}

.venue-copy > p:not(.chapter-no):not(.eyebrow) {
  margin: 0 0 36px;
  color: var(--muted);
  line-height: 1.8;
}

.invitation-card {
  background: #ead7d2;
}

.card-layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.7fr) minmax(300px, 0.72fr);
  gap: 8vw;
  align-items: center;
}

.invitation-preview {
  height: min(74vh, 760px);
  margin: 0;
  filter: drop-shadow(0 20px 34px rgba(74, 35, 35, 0.22));
  transform: rotate(1.4deg);
}

.invitation-preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.rsvp {
  background: var(--paper);
}

.rsvp-layout {
  display: grid;
  grid-template-columns: minmax(300px, 0.72fr) minmax(360px, 0.64fr);
  gap: 9vw;
  align-items: center;
}

.rsvp-heading > p:last-child {
  margin: 28px 0 0;
  color: var(--muted);
}

.rsvp-form {
  display: grid;
  gap: 18px;
}

.rsvp-form > label {
  display: grid;
  gap: 8px;
}

.rsvp-form label > span,
.rsvp-form legend {
  color: var(--muted);
  font-size: 12px;
}

.rsvp-form input[type="text"],
.rsvp-form input[type="number"],
.rsvp-form textarea {
  width: 100%;
  border: 0;
  border-bottom: 1px solid rgba(141, 31, 39, 0.28);
  border-radius: 0;
  color: var(--ink);
  background: transparent;
}

.rsvp-form input[type="text"],
.rsvp-form input[type="number"] {
  height: 42px;
}

.rsvp-form textarea {
  resize: vertical;
  min-height: 72px;
  padding: 10px 0;
}

.rsvp-form fieldset {
  display: flex;
  margin: 0;
  padding: 0;
  border: 0;
  gap: 24px;
}

.rsvp-form legend {
  margin-bottom: 10px;
}

.rsvp-form fieldset label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.rsvp-form input[type="radio"] {
  width: 16px;
  height: 16px;
  accent-color: var(--red);
}

.submit-button {
  width: 100%;
  margin-top: 8px;
}

.ending {
  color: var(--paper);
  background: var(--red-dark);
}

.ending-inner {
  display: flex;
  align-items: center;
  flex-direction: column;
  justify-content: center;
  text-align: center;
}

.double-happiness {
  display: grid;
  width: 116px;
  height: 116px;
  margin: 8px 0 38px;
  border: 1px solid rgba(232, 201, 143, 0.5);
  color: #e8c98f;
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 66px;
  place-items: center;
  transform: rotate(45deg);
}

.double-happiness span {
  line-height: 1;
  transform: rotate(-45deg);
}

.ending h2 {
  color: #fff7e7;
}

.signature {
  margin: 38px 0 8px;
  color: rgba(255, 247, 231, 0.82);
  font-family: "STSong", "SimSun", serif;
}

.ending-date {
  margin: 0;
  color: #e8c98f;
  font-size: 12px;
}

.restart-button {
  margin-top: 34px;
  border: 1px solid rgba(232, 201, 143, 0.5);
  border-radius: 50%;
  color: #e8c98f;
}

.page-nav {
  position: fixed;
  z-index: 50;
  right: 30px;
  bottom: 24px;
  left: 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}

.nav-button {
  border: 1px solid rgba(141, 31, 39, 0.2);
  border-radius: 50%;
  color: var(--red);
  background: rgba(255, 250, 240, 0.82);
  backdrop-filter: blur(12px);
  pointer-events: auto;
}

.nav-button:disabled {
  opacity: 0.35;
  cursor: default;
}

.page-status {
  display: flex;
  width: min(340px, 36vw);
  align-items: center;
  gap: 12px;
  color: var(--red);
  font-family: Georgia, serif;
  font-size: 11px;
}

.progress-track {
  flex: 1;
  height: 1px;
  overflow: hidden;
  background: rgba(141, 31, 39, 0.22);
}

.progress-track span {
  display: block;
  width: 12.5%;
  height: 100%;
  background: var(--red);
  transition: width 500ms ease;
}

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

.petal {
  position: absolute;
  top: -24px;
  width: 10px;
  height: 16px;
  border-radius: 70% 30% 70% 30%;
  opacity: 0.45;
  background: #d89393;
  animation: fall linear infinite;
}

@keyframes fall {
  to { transform: translate3d(var(--drift), calc(100vh + 50px), 0) rotate(420deg); }
}

.toast {
  position: fixed;
  z-index: 90;
  right: 50%;
  bottom: 86px;
  max-width: calc(100% - 40px);
  padding: 11px 18px;
  border-radius: 4px;
  color: var(--paper);
  background: rgba(63, 48, 47, 0.94);
  opacity: 0;
  pointer-events: none;
  transform: translate(50%, 10px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(50%, 0);
}

body.scroll-mode .book {
  overflow-x: hidden;
  overflow-y: auto;
  perspective: none;
  scroll-snap-type: y mandatory;
  scroll-behavior: smooth;
}

body.scroll-mode .chapter {
  position: relative;
  min-height: 100svh;
  transform: none;
  opacity: 1;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  box-shadow: none;
  backface-visibility: visible;
}

body.scroll-mode .chapter.is-past,
body.scroll-mode .chapter.is-future {
  pointer-events: auto;
}

body.scroll-mode .nav-button {
  transform: rotate(90deg);
}

body.dark-page .monogram,
body.dark-page .page-status {
  color: #f0cf94;
}

body.dark-page .progress-track {
  background: rgba(240, 207, 148, 0.28);
}

body.dark-page .progress-track span {
  background: #f0cf94;
}

@media (max-width: 760px) {
  .chapter-inner {
    width: calc(100% - 44px);
    padding: 92px 0 86px;
  }

  .topbar {
    top: max(14px, env(safe-area-inset-top));
    right: 16px;
    left: 16px;
  }

  .page-nav {
    right: 16px;
    bottom: max(14px, env(safe-area-inset-bottom));
    left: 16px;
  }

  .page-status {
    width: min(210px, 52vw);
  }

  .cover-frame {
    width: calc(100% - 28px);
    min-height: calc(100% - 28px);
    margin: 14px;
    padding: 80px 22px;
  }

  .cover h1 {
    font-size: 42px;
  }

  .split-layout,
  .date-layout,
  .venue-layout,
  .card-layout,
  .rsvp-layout {
    grid-template-columns: 1fr;
    gap: 34px;
  }

  .chapter-no {
    margin-bottom: 24px;
    font-size: 62px;
  }

  h2 {
    font-size: 36px;
  }

  .body-copy {
    margin-top: 22px;
    font-size: 15px;
    line-height: 1.85;
  }

  .memory-window {
    width: min(72vw, 310px);
    margin: 0 auto;
    aspect-ratio: 4 / 4.5;
  }

  .promise blockquote {
    margin: 10px 0 52px;
    font-size: 30px;
    line-height: 1.65;
  }

  .promise::after {
    top: 8vh;
    right: -45vw;
    width: 100vw;
  }

  .big-date {
    font-size: min(54vw, 250px);
    line-height: 0.68;
  }

  .date-layout {
    align-content: center;
  }

  .date-copy {
    text-align: center;
  }

  .date-copy .time-grid {
    margin-right: auto;
    margin-left: auto;
  }

  .venue-layout {
    align-content: center;
  }

  .map-art {
    width: min(100%, 460px);
    margin: 0 auto;
    aspect-ratio: 5 / 3.5;
  }

  .venue-copy {
    text-align: center;
  }

  .venue-copy .chapter-no {
    display: none;
  }

  .invitation-preview {
    height: min(46svh, 480px);
    order: -1;
  }

  .rsvp-layout {
    align-content: center;
    gap: 28px;
  }

  .rsvp-heading .chapter-no {
    display: none;
  }

  .rsvp-heading h2 {
    font-size: 32px;
  }

  .rsvp-heading > p:last-child {
    margin-top: 14px;
    font-size: 13px;
  }

  .rsvp-form {
    gap: 12px;
  }

  .ending h2 {
    font-size: 42px;
  }
}

@media (max-height: 720px) and (min-width: 761px) {
  .chapter-inner {
    padding-top: 88px;
    padding-bottom: 72px;
  }

  .chapter-no {
    margin-bottom: 22px;
    font-size: 64px;
  }

  h2 {
    font-size: 44px;
  }

  .promise blockquote {
    margin-bottom: 38px;
    font-size: 40px;
  }

  .invitation-preview {
    height: 68vh;
  }
}

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