:root {
  --night: #20201d;
  --night-soft: #2b2a26;
  --paper: #f3eee5;
  --paper-deep: #e8dfd1;
  --ink: #292722;
  --muted: #706b63;
  --line: #c9bcae;
  --accent: #a55247;
  --accent-deep: #733d37;
  --white: #fbf7ef;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--night); scroll-behavior: smooth; }

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background-color: var(--night);
  font-family: "Songti SC", "STSong", "Noto Serif CJK SC", "SimSun", serif;
  overflow-x: hidden;
}

a { color: inherit; }

.letter-shell {
  width: min(100%, 1060px);
  margin: 0 auto;
  padding: max(22px, env(safe-area-inset-top)) clamp(18px, 5vw, 58px) max(48px, env(safe-area-inset-bottom));
}

.top-nav {
  width: min(100%, 880px);
  min-height: 44px;
  margin: 0 auto clamp(38px, 8vw, 86px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  color: rgba(251, 247, 239, 0.68);
  font-family: "PingFang SC", "Helvetica Neue", sans-serif;
  font-size: 0.75rem;
}

.top-nav a,
.page-ending a {
  text-decoration: none;
  border-bottom: 1px solid rgba(251, 247, 239, 0.35);
}

.top-nav a:focus-visible,
.page-ending a:focus-visible {
  outline: 3px solid #d7a59b;
  outline-offset: 5px;
}

.letter-hero {
  width: min(100%, 880px);
  margin: 0 auto clamp(42px, 8vw, 82px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 0.72fr);
  gap: clamp(30px, 7vw, 84px);
  align-items: end;
}

.hero-copy { padding-bottom: 8px; }

.eyebrow,
.note-label {
  margin: 0 0 18px;
  color: #d9a39a;
  font-family: "PingFang SC", "Helvetica Neue", sans-serif;
  font-size: 0.72rem;
}

.hero-copy h1 {
  margin: 0;
  color: var(--white);
  font-size: clamp(2.7rem, 5vw, 4.8rem);
  font-weight: 500;
  line-height: 1.12;
  text-wrap: balance;
}

.hero-copy h1 em {
  display: inline-block;
  padding-bottom: 0.08em;
  color: #e0aca2;
  font-style: normal;
}

.hero-lede {
  max-width: 25em;
  margin: 24px 0 0;
  color: rgba(251, 247, 239, 0.7);
  font-size: clamp(1rem, 2vw, 1.12rem);
  line-height: 1.85;
  text-wrap: pretty;
}

.memory-sheet {
  position: relative;
  margin: 0;
  padding: 14px;
  background: var(--paper);
  transform: rotate(2deg);
  box-shadow: 0 22px 46px rgba(0, 0, 0, 0.24);
}

.memory-sheet img {
  display: block;
  width: 100%;
  height: clamp(330px, 34vw, 420px);
  object-fit: cover;
  object-position: center 72%;
}

.memory-sheet figcaption {
  display: grid;
  gap: 7px;
  padding: 16px 8px 8px;
  color: var(--ink);
}

.memory-sheet figcaption span,
.memory-sheet figcaption small {
  font-family: "PingFang SC", "Helvetica Neue", sans-serif;
}

.memory-sheet figcaption span {
  color: var(--accent);
  font-size: 0.72rem;
}

.memory-sheet figcaption strong {
  font-size: 1.18rem;
  font-weight: 500;
}

.memory-sheet figcaption small {
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.7;
}

.letter-paper {
  position: relative;
  width: min(100%, 760px);
  margin: 0 auto;
  padding: clamp(40px, 8vw, 82px) clamp(24px, 8vw, 76px) clamp(52px, 9vw, 92px);
  background-color: var(--paper);
  background-image: url("../../assets/paper-texture.png");
  background-size: 580px auto;
  border: 1px solid rgba(201, 188, 174, 0.72);
  box-shadow: 0 24px 62px rgba(0, 0, 0, 0.18);
}

.letter-paper::after {
  content: "";
  position: absolute;
  inset: 16px;
  border: 1px solid rgba(165, 82, 71, 0.17);
  pointer-events: none;
}

.letter-meta,
.letter-body { position: relative; z-index: 1; }

.letter-meta {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(112, 107, 99, 0.35);
  color: var(--muted);
  font-family: "PingFang SC", "Helvetica Neue", sans-serif;
  font-size: 0.75rem;
}

.letter-body {
  max-width: 66ch;
  margin: 42px auto 0;
  font-size: clamp(1.03rem, 2.4vw, 1.18rem);
  line-height: 2.08;
  text-wrap: pretty;
}

.letter-body > p { margin: 0; }
.letter-body > p + p { margin-top: 1.08em; }

.breath-line {
  margin-top: 2em !important;
  color: var(--accent-deep);
  font-size: 1.32em;
  line-height: 1.6;
}

.accountability-note {
  position: relative;
  margin: clamp(42px, 8vw, 70px) 0;
  padding: clamp(24px, 5vw, 40px) clamp(20px, 5vw, 36px);
  background: rgba(232, 223, 209, 0.72);
  border-left: 3px solid var(--accent);
}

.accountability-note::before {
  content: "";
  position: absolute;
  top: 20px;
  right: 22px;
  width: 28px;
  height: 1px;
  background: var(--accent);
  transform: rotate(-28deg);
}

.accountability-note .note-label { margin-bottom: 20px; color: var(--accent-deep); }
.accountability-note p { margin: 0; }
.accountability-note p + p { margin-top: 1em; }
.accountability-note p:nth-of-type(2) { color: var(--accent-deep); font-size: 1.25em; }

.letter-ending {
  margin-top: clamp(56px, 10vw, 88px);
  padding-top: 30px;
  border-top: 1px solid rgba(112, 107, 99, 0.35);
  color: var(--accent-deep);
}

.letter-ending p { margin: 0; }
.letter-ending p + p { margin-top: 1em; }
.letter-ending span { display: block; margin-top: 28px; color: var(--muted); font-family: "PingFang SC", "Helvetica Neue", sans-serif; font-size: 0.78rem; }

.page-ending {
  width: min(100%, 760px);
  margin: 26px auto 0;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 18px;
  color: rgba(251, 247, 239, 0.62);
  font-family: "PingFang SC", "Helvetica Neue", sans-serif;
  font-size: 0.74rem;
  line-height: 1.7;
}

@media (max-width: 720px) {
  .letter-hero { grid-template-columns: 1fr; gap: 36px; }
  .hero-copy { padding-bottom: 0; }
  .memory-sheet { width: min(78vw, 340px); justify-self: end; }
  .memory-sheet img { height: min(96vw, 420px); }
  .page-ending { align-items: flex-start; flex-direction: column; }
}

@media (min-width: 721px) {
  .hero-copy h1 { white-space: nowrap; }
}

@media (max-width: 480px) {
  .top-nav { align-items: flex-start; font-size: 0.68rem; }
  .hero-copy h1 { font-size: clamp(2.6rem, 14vw, 4.2rem); }
  .letter-paper { padding-right: 22px; padding-left: 22px; }
  .letter-paper::after { inset: 10px; }
  .letter-meta { font-size: 0.68rem; }
  .letter-body { font-size: 1.04rem; line-height: 2; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
