:root {
  color-scheme: light;
  --ink: #2f2a24;
  --muted: #74695d;
  --paper: #f6e4c3;
  --paper-deep: #e7c991;
  --paper-soft: #fff4dc;
  --seal: #b24b3b;
  --green: #5f7560;
  --blue: #4f7181;
  --line: rgba(75, 55, 35, 0.22);
  --ruled-lines: repeating-linear-gradient(
    0deg,
    transparent 0 33px,
    rgba(108, 76, 41, 0.15) 33px 34px
  );
  --shadow: 0 22px 70px rgba(65, 40, 18, 0.24);
  --font-serif: "Times New Roman", "Songti SC", "SimSun", serif;
  --font-sans: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  color: var(--ink);
  font-family: var(--font-sans);
  background:
    radial-gradient(circle at 18% 16%, rgba(255, 255, 255, 0.54), transparent 24rem),
    radial-gradient(circle at 88% 78%, rgba(142, 99, 45, 0.14), transparent 20rem),
    linear-gradient(135deg, rgba(190, 142, 80, 0.18), transparent 32%),
    var(--paper);
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  content: "";
  background-image:
    linear-gradient(rgba(96, 67, 38, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(96, 67, 38, 0.045) 1px, transparent 1px),
    radial-gradient(circle, rgba(70, 46, 24, 0.12) 0 0.8px, transparent 1px);
  background-size: 34px 34px, 34px 34px, 9px 9px;
  mix-blend-mode: multiply;
  opacity: 0.62;
}

body::after {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  content: "";
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.2), transparent 18%, transparent 82%, rgba(97, 61, 29, 0.12)),
    repeating-linear-gradient(112deg, rgba(92, 58, 28, 0.025) 0 1px, transparent 1px 7px);
}

a {
  color: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.loading-scene {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 28%, rgba(255, 252, 238, 0.9), transparent 24rem),
    linear-gradient(140deg, rgba(164, 94, 57, 0.16), transparent 34%),
    var(--paper);
  transition: opacity 650ms ease, visibility 650ms ease;
}

.loading-scene.is-finished {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.loader-stage {
  position: relative;
  width: min(650px, 92vw);
  height: min(460px, 72vh);
  display: grid;
  place-items: center;
  perspective: 1200px;
}

.loader-copy {
  position: absolute;
  left: 50%;
  bottom: clamp(16px, 4vh, 32px);
  width: min(480px, 92vw);
  transform: translateX(-50%);
  text-align: center;
}

.loader-copy p {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 15px;
}

.progress-track {
  position: relative;
  width: min(360px, 82vw);
  height: 4px;
  margin: 0 auto;
  overflow: hidden;
  background: rgba(83, 57, 31, 0.16);
}

.progress-bar {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--seal), #cf8b53);
  transition: width 240ms ease;
}

.intro-mail {
  position: relative;
  width: min(430px, 82vw);
  aspect-ratio: 1.42;
  transform-style: preserve-3d;
}

.intro-mail svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.draw-line {
  fill: none;
  stroke: #6f4b2f;
  stroke-width: 3.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1200;
  stroke-dashoffset: 1200;
  filter: drop-shadow(0 10px 16px rgba(75, 42, 16, 0.16));
  animation: drawEnvelope 760ms ease-in-out forwards;
}

.draw-line.side-2 {
  animation-delay: 80ms;
}

.draw-line.side-3 {
  animation-delay: 160ms;
}

.draw-line.side-4 {
  animation-delay: 240ms;
}

.draw-line.middle {
  animation-delay: 880ms;
  animation-duration: 900ms;
}

.envelope-fill,
.envelope-flap,
.envelope-front,
.wax-seal {
  opacity: 0;
  animation: fadeIn 520ms ease forwards;
  animation-delay: 640ms;
}

.envelope-fill {
  fill: #f1d3a1;
}

.envelope-front {
  fill: #e5bc7d;
  animation-delay: 1360ms;
}

.envelope-flap {
  fill: #dba665;
  transform-box: fill-box;
  transform-origin: 50% 100%;
  animation-delay: 1360ms;
}

.wax-seal {
  fill: var(--seal);
  animation-delay: 1500ms;
}

.envelope-title {
  opacity: 0;
  fill: #5f3c24;
  font: 700 22px var(--font-serif);
  letter-spacing: 0;
  text-anchor: middle;
  animation: fadeIn 560ms ease forwards;
  animation-delay: 1920ms;
}

.mini-postcard {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 78%;
  aspect-ratio: 1.58;
  padding: 24px;
  border: 1px solid rgba(112, 78, 43, 0.22);
  background:
    linear-gradient(90deg, transparent 0 50%, rgba(90, 62, 36, 0.18) 50% calc(50% + 1px), transparent calc(50% + 1px)),
    repeating-linear-gradient(0deg, transparent 0 24px, rgba(117, 82, 46, 0.18) 24px 25px),
    #f8e8c8;
  box-shadow: var(--shadow);
  transform: translate(-50%, -50%) translateY(30px) scale(0.68);
  opacity: 0;
}

.mini-postcard::before {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 62px;
  height: 48px;
  border: 2px solid rgba(97, 73, 46, 0.34);
  content: "";
}

.mini-postcard strong {
  display: block;
  width: 52%;
  font-family: var(--font-serif);
  font-size: 36px;
  line-height: 1.05;
}

.loading-scene.is-opening .envelope-flap {
  animation: openFlap 650ms cubic-bezier(0.2, 0.85, 0.2, 1) forwards;
}

.loading-scene.is-opening .mini-postcard {
  animation: pullPostcard 1250ms cubic-bezier(0.2, 0.85, 0.2, 1) 280ms forwards;
}

.loading-scene.is-opening .intro-mail {
  animation: cameraPush 1450ms cubic-bezier(0.2, 0.85, 0.2, 1) 520ms forwards;
}

.site-shell {
  height: 100vh;
  padding: clamp(16px, 3vw, 34px);
  opacity: 0;
  transform: scale(0.985);
  transition: opacity 700ms ease, transform 700ms ease;
}

.site-shell.is-visible {
  opacity: 1;
  transform: scale(1);
}

.layout {
  width: min(1240px, 100%);
  height: calc(100vh - clamp(58px, 7vw, 82px));
  margin: 0 auto;
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr);
  gap: clamp(18px, 3vw, 34px);
  align-items: stretch;
}

.post-nav {
  align-self: center;
  padding: 0;
}

.nav-buttons {
  display: grid;
  gap: 10px;
}

.nav-button {
  position: relative;
  min-height: 46px;
  padding: 0 20px;
  border: 3px solid #e7514f;
  color: #5c3c31;
  font: 700 15px var(--font-sans);
  text-align: center;
  background:
    linear-gradient(#fffdf6, #fff7e8) padding-box,
    linear-gradient(135deg, #ff706d, #d9403d) border-box;
  box-shadow:
    inset 0 0 0 2px rgba(231, 81, 79, 0.22),
    0 8px 16px rgba(83, 55, 28, 0.12);
  cursor: pointer;
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.nav-button:hover {
  transform: translateX(4px);
  box-shadow:
    inset 0 0 0 2px rgba(231, 81, 79, 0.34),
    0 12px 18px rgba(83, 55, 28, 0.16);
}

.nav-button.is-active {
  color: #b72f2f;
  border-color: #d93634;
  box-shadow:
    inset 0 0 0 2px rgba(217, 54, 52, 0.42),
    0 12px 22px rgba(160, 55, 41, 0.18);
}

.nav-button::before,
.nav-button::after {
  position: absolute;
  width: 9px;
  height: 9px;
  background: #e7514f;
  content: "";
}

.nav-button::before {
  left: -6px;
  top: 50%;
  transform: translateY(-50%);
}

.nav-button::after {
  right: -6px;
  top: 50%;
  transform: translateY(-50%);
}

.postcard-space {
  display: grid;
  align-items: center;
  min-width: 0;
  height: 100%;
}

.postcard {
  position: relative;
  height: min(700px, calc(100vh - 96px));
  overflow: hidden;
  background:
    linear-gradient(90deg, transparent 0 146px, rgba(97, 72, 43, 0.24) 146px 147px, transparent 147px),
    linear-gradient(90deg, transparent 0 calc(100% - 176px), rgba(97, 72, 43, 0.18) calc(100% - 176px) calc(100% - 175px), transparent calc(100% - 175px)),
    var(--ruled-lines),
    linear-gradient(135deg, rgba(255, 255, 255, 0.36), transparent 38%),
    var(--paper-soft);
  box-shadow: var(--shadow);
  transform-style: preserve-3d;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.postcard:active {
  cursor: grabbing;
}

.postcard-meta,
.postcard-content {
  position: relative;
  z-index: 1;
  min-width: 0;
}

.postcard-meta {
  position: absolute;
  z-index: 12;
  left: clamp(28px, 4.8vw, 62px);
  top: clamp(36px, 5vw, 74px);
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 86px;
  pointer-events: none;
}

.brand-mark {
  display: inline-flex;
  width: 56px;
  height: 56px;
  align-items: center;
  justify-content: center;
  border: 2px solid rgba(105, 70, 38, 0.32);
  border-radius: 50%;
  color: var(--seal);
  font: 700 29px var(--font-serif);
  transform: rotate(-9deg);
}

.site-record {
  position: fixed;
  left: 50%;
  bottom: 13px;
  z-index: 8;
  transform: translateX(-50%);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  text-align: center;
}

.postcard-content {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  height: 100%;
  padding: 0;
  transform-style: preserve-3d;
  isolation: isolate;
}

.book-stage {
  position: relative;
  display: grid;
  width: 100%;
  height: 100%;
  min-width: 0;
  justify-self: stretch;
  perspective: 2100px;
  perspective-origin: 50% 46%;
  transform-style: preserve-3d;
}

.book-spread {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  filter: drop-shadow(0 18px 22px rgba(70, 43, 19, 0.1));
}

.book-spread::before {
  position: absolute;
  top: -14px;
  bottom: -14px;
  left: 50%;
  z-index: 6;
  width: 1px;
  background: rgba(94, 67, 38, 0.24);
  box-shadow:
    -10px 0 18px rgba(78, 50, 22, 0.12),
    10px 0 18px rgba(78, 50, 22, 0.12);
  content: "";
  transform: translateX(-0.5px);
  pointer-events: none;
}

.book-page-slot {
  position: relative;
  min-width: 0;
  height: 100%;
  overflow: hidden;
  transform-style: preserve-3d;
}

.book-page {
  position: absolute;
  inset: 0;
  display: flex;
  min-width: 0;
  height: 100%;
  padding: 0;
  overflow: hidden;
  background:
    linear-gradient(90deg, transparent 0 146px, rgba(97, 72, 43, 0.2) 146px 147px, transparent 147px),
    var(--ruled-lines),
    linear-gradient(135deg, rgba(255, 255, 255, 0.42), transparent 38%),
    var(--paper-soft);
  border: 0;
  box-shadow:
    inset 0 0 0 1px rgba(105, 70, 38, 0.08),
    0 14px 28px rgba(83, 55, 28, 0.08);
  backface-visibility: hidden;
}

.book-page .page-body {
  position: relative;
  display: flex;
  width: auto;
  min-width: 0;
  height: auto;
  flex-direction: column;
  overflow: hidden;
  margin-block: 102px 68px;
  padding: 0 28px;
}

.book-page--left {
  background:
    linear-gradient(90deg, transparent 0 146px, rgba(97, 72, 43, 0.2) 146px 147px, transparent 147px),
    linear-gradient(90deg, transparent 0 80%, rgba(85, 59, 33, 0.16)),
    var(--ruled-lines),
    linear-gradient(135deg, rgba(255, 255, 255, 0.42), transparent 38%),
    var(--paper-soft);
}

.book-page--left .page-body {
  flex: 1 1 auto;
  margin-left: clamp(156px, 14vw, 214px);
  margin-right: 0;
}

.book-page--right {
  background:
    linear-gradient(90deg, transparent 0 calc(100% - 176px), rgba(97, 72, 43, 0.15) calc(100% - 176px) calc(100% - 175px), transparent calc(100% - 175px)),
    linear-gradient(270deg, transparent 0 80%, rgba(85, 59, 33, 0.14)),
    var(--ruled-lines),
    linear-gradient(135deg, rgba(255, 255, 255, 0.42), transparent 38%),
    var(--paper-soft);
}

.book-page--right .page-body {
  flex: 0 1 calc(100% - clamp(156px, 14vw, 214px));
  margin-left: auto;
  margin-right: clamp(42px, 5vw, 72px);
}

.book-page--blank {
  display: grid;
  place-items: center;
}

.page-body--home-blank {
  align-items: center;
  justify-content: center;
}

.mirror-spacer {
  visibility: hidden;
  pointer-events: none;
}

.book-blank-mark {
  color: rgba(99, 69, 39, 0.16);
  font: 700 30px var(--font-serif);
  letter-spacing: 0;
  transform: rotate(-9deg);
}

.book-flip-sheet {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 10;
  display: none;
  width: 50%;
  pointer-events: none;
  transform-style: preserve-3d;
  --flip-angle: 0deg;
  --flip-progress: 0;
  --flip-shadow: 0.16;
  --flip-glint: 0;
  --flip-curl-x: 50%;
  will-change: transform;
}

.book-flip-sheet::before {
  position: absolute;
  inset: -2px;
  z-index: -1;
  background: linear-gradient(
    90deg,
    rgba(59, 36, 15, 0.46),
    transparent 22%,
    transparent 78%,
    rgba(59, 36, 15, 0.22)
  );
  content: "";
  filter: blur(11px);
  opacity: calc(0.12 + var(--flip-shadow));
  transform: translateZ(-2px);
}

.book-flip-sheet.is-flipping {
  display: block;
}

.book-flip-sheet.flip-next {
  left: 50%;
  transform: rotateY(var(--flip-angle));
  transform-origin: left center;
}

.book-flip-sheet.flip-prev {
  left: 0;
  transform: rotateY(var(--flip-angle));
  transform-origin: right center;
}

.book-flip-sheet.is-settling {
  transition: transform 560ms cubic-bezier(0.18, 0.84, 0.18, 1);
}

.book-flip-sheet.is-dragging {
  transition: none;
}

.flip-face {
  position: absolute;
  inset: 0;
  overflow: hidden;
  backface-visibility: hidden;
  transform-style: preserve-3d;
}

.flip-front {
  transform: rotateY(0deg) translateZ(0.3px);
}

.flip-back {
  transform: rotateY(180deg) translateZ(0.3px);
}

.flip-face::before,
.flip-face::after {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  content: "";
}

.flip-face::before {
  opacity: var(--flip-shadow);
  background:
    radial-gradient(ellipse at var(--flip-curl-x) 50%, rgba(255, 255, 255, 0.64), transparent 0 92px),
    linear-gradient(90deg, rgba(55, 34, 14, 0.3), transparent 28%, transparent 72%, rgba(255, 255, 255, 0.28));
  mix-blend-mode: multiply;
}

.flip-face::after {
  opacity: var(--flip-glint);
  background:
    radial-gradient(ellipse at var(--flip-curl-x) 50%, rgba(255, 249, 229, 0.72), transparent 0 138px),
    linear-gradient(90deg, transparent 0 58%, rgba(255, 255, 255, 0.58) 64%, transparent 72%);
}

.book-page h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 36px;
  line-height: 68px;
}

.section-desc {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 34px;
}

.entry-list {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
  list-style: none;
}

.entry {
  display: block;
  height: 68px;
  min-height: 68px;
  padding: 0;
  overflow: hidden;
  text-decoration: none;
}

.entry-title {
  display: block;
  height: 34px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 17px;
  font-weight: 800;
  line-height: 34px;
}

.entry-action-link {
  display: block;
  height: 68px;
  overflow: hidden;
  color: var(--blue);
  font-size: 13px;
  font-weight: 800;
  text-align: right;
  text-decoration: none;
}

.entry-action-link span {
  display: inline-flex;
  height: 28px;
  align-items: center;
  justify-content: center;
  margin-top: 3px;
  padding: 0 12px;
  line-height: 1;
  letter-spacing: 0;
  white-space: nowrap;
}

.entry p {
  height: 34px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 34px;
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 1;
}

.friend-groups {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  overflow: hidden;
}

.friend-group h3 {
  margin: 0;
  color: var(--green);
  font-size: 15px;
  line-height: 34px;
  letter-spacing: 0;
}

.home-panel .page-body {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.home-body--title {
  align-items: flex-start;
  text-align: left;
}

.home-body--subtitle {
  align-items: flex-start;
  text-align: left;
}

.home-panel h2 {
  max-width: 720px;
  font-weight: 900;
  font-size: 64px;
  line-height: 1.08;
}

.home-panel .section-desc {
  max-width: 620px;
  margin-top: 0;
  font-size: 22px;
}

@keyframes drawEnvelope {
  to {
    stroke-dashoffset: 0;
  }
}

@keyframes fadeIn {
  to {
    opacity: 1;
  }
}

@keyframes openFlap {
  from {
    transform: rotateX(0deg);
  }

  to {
    transform: rotateX(-148deg);
  }
}

@keyframes pullPostcard {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) translateY(30px) scale(0.68);
  }

  22% {
    opacity: 1;
  }

  72% {
    opacity: 1;
    transform: translate(-50%, -80%) translateY(-92px) scale(0.94);
  }

  100% {
    opacity: 1;
    transform: translate(-50%, -92%) translateY(-120px) scale(1.16);
  }
}

@keyframes cameraPush {
  to {
    transform: scale(1.34) translateY(18px);
    opacity: 0;
  }
}

@media (max-width: 820px) {
  .site-shell {
    padding: 12px;
  }

  .layout {
    grid-template-columns: 1fr;
    gap: 12px;
    height: calc(100vh - 48px);
    grid-template-rows: auto minmax(0, 1fr);
  }

  .post-nav {
    z-index: 5;
    align-self: stretch;
    padding: 0;
    border-left: 0;
    background: linear-gradient(rgba(246, 228, 195, 0.94), rgba(246, 228, 195, 0.74));
    backdrop-filter: blur(8px);
  }

  .nav-buttons {
    display: flex;
    gap: 6px;
    overflow: hidden;
    padding: 0 2px;
  }

  .nav-button {
    flex: 1 1 0;
    min-width: 0;
    min-height: 42px;
    padding: 0 2px;
    border-width: 2px;
    font-size: 12px;
    text-align: center;
    white-space: nowrap;
  }

  .nav-button::before,
  .nav-button::after {
    display: none;
  }

  .nav-button:hover {
    transform: translateY(-2px);
  }

  .postcard {
    height: 100%;
    background:
      var(--ruled-lines),
      linear-gradient(135deg, rgba(255, 255, 255, 0.36), transparent 38%),
      var(--paper-soft);
  }

  .postcard-meta {
    position: relative;
    left: auto;
    top: auto;
    bottom: auto;
    width: auto;
    min-height: 68px;
    flex-direction: row;
    justify-content: flex-start;
    gap: 14px;
    padding: 17px 26px 0;
    align-items: flex-start;
  }

  .brand-mark {
    width: 46px;
    height: 46px;
    font-size: 24px;
  }

  .site-record {
    bottom: 8px;
    width: calc(100% - 24px);
    font-size: 12px;
  }

  .postcard-content {
    position: absolute;
    inset: 0;
    height: 100%;
    padding: 0;
  }

  .home-panel .page-body {
    justify-content: flex-start;
  }

  .home-panel h2 {
    font-size: 42px;
    line-height: 1.12;
  }

  .book-page {
    padding: 0;
  }

  .book-page .page-body {
    margin-block: 102px 34px;
    padding: 0 8px;
  }

  .book-page--left .page-body {
    margin-left: 12px;
  }

  .book-page--right .page-body {
    flex: 1 1 auto;
    margin-left: 0;
    margin-right: 12px;
  }

  .book-page h2 {
    font-size: 26px;
    line-height: 34px;
  }

  .home-panel .home-body--title h2 {
    font-size: 38px;
    line-height: 1.12;
  }

  .section-desc {
    margin-bottom: 0;
    font-size: 13px;
    line-height: 34px;
  }

  .entry {
    height: 34px;
    min-height: 34px;
  }

  .entry-title {
    font-size: 11px;
    line-height: 34px;
  }

  .entry-action-link {
    height: 34px;
    font-size: 10px;
  }

  .entry-action-link span {
    height: 24px;
    margin-top: 5px;
    padding: 0 7px;
  }

  .entry p {
    display: none;
  }

  .friend-groups {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .friend-group h3 {
    font-size: 12px;
    line-height: 34px;
  }
}

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