
:root {
  --deep: #ebe1d1;
  --sheet: rgba(255, 252, 246, 0.9);
  --sheet-edge: rgba(255, 255, 255, 0.75);
  --surface: rgba(255, 255, 255, 0.6);
  --shadow: rgba(84, 50, 20, 0.32);
  --ink: #1f1c18;
  --muted: #6b6258;
  --line: rgba(90, 62, 36, 0.15);
  --accent: #b24a26;
  --accent-ink: #fffaf4;
  --accent-soft: #f6e1d3;
  --free: #2f6b4f;
  --free-soft: #e0efe5;
  --glow-1: rgba(224, 120, 72, 0.55);
  --glow-2: rgba(242, 186, 92, 0.5);
  --glow-3: rgba(128, 170, 138, 0.48);
  --glow-4: rgba(158, 138, 206, 0.36);
  --contour: rgba(110, 66, 34, 0.26);
  --grain-blend: multiply;
  --grain-opacity: 0.2;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Charter, "Source Serif Pro", Georgia, serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --deep: #0e0c0a;
    --sheet: rgba(24, 21, 18, 0.88);
    --sheet-edge: rgba(255, 240, 220, 0.07);
    --surface: rgba(255, 255, 255, 0.035);
    --shadow: rgba(0, 0, 0, 0.65);
    --ink: #ede6dc;
    --muted: #a69c8e;
    --line: rgba(255, 236, 214, 0.1);
    --accent: #e8825a;
    --accent-ink: #1a1410;
    --accent-soft: #3a241a;
    --free: #7cc6a0;
    --free-soft: #1a2e23;
    --glow-1: rgba(206, 92, 50, 0.42);
    --glow-2: rgba(196, 136, 60, 0.24);
    --glow-3: rgba(40, 122, 110, 0.42);
    --glow-4: rgba(96, 74, 176, 0.38);
    --contour: rgba(255, 214, 170, 0.14);
    --grain-blend: soft-light;
    --grain-opacity: 0.35;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--deep); }
body {
  margin: 0;
  color: var(--ink);
  font: 17px/1.6 var(--sans);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--accent); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Backdrop: drifting dusk light, a topographic map, and paper grain. */
.backdrop { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.backdrop .glow {
  position: absolute; inset: -25%;
  background:
    radial-gradient(38% 42% at 24% 26%, var(--glow-1), transparent 70%),
    radial-gradient(34% 38% at 80% 20%, var(--glow-2), transparent 70%),
    radial-gradient(40% 44% at 72% 80%, var(--glow-3), transparent 70%),
    radial-gradient(30% 36% at 18% 84%, var(--glow-4), transparent 70%);
  animation: drift 60s ease-in-out infinite alternate;
  will-change: transform;
}
.backdrop .lines {
  position: absolute; inset: 0; background: var(--contour);
  -webkit-mask: url(/contours.svg?v=1x2jk1q) center / cover no-repeat;
  mask: url(/contours.svg?v=1x2jk1q) center / cover no-repeat;
}
.backdrop .grain {
  position: absolute; inset: 0;
  background: url(/grain.svg?v=1x2jk1q) repeat;
  mix-blend-mode: var(--grain-blend); opacity: var(--grain-opacity);
}
@keyframes drift {
  0% { transform: translate3d(-3%, -2%, 0) rotate(0deg) scale(1); }
  50% { transform: translate3d(2%, 3%, 0) rotate(5deg) scale(1.06); }
  100% { transform: translate3d(4%, -1%, 0) rotate(-3deg) scale(1.02); }
}
@media (prefers-reduced-motion: reduce) { .backdrop .glow { animation: none; } }

header.site, footer.site {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  max-width: 1100px; width: 100%; margin: 0 auto; padding: 22px 24px;
}
header.site .brand {
  font: 600 26px/1 var(--serif); color: var(--ink); text-decoration: none; letter-spacing: -0.01em;
}
header.site .brand span { color: var(--accent); }
header.site nav {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap; justify-content: flex-end; font-size: 15px;
  padding: 6px 6px 6px 18px; border-radius: 999px;
  background: var(--sheet); border: 1px solid var(--sheet-edge);
  -webkit-backdrop-filter: blur(14px) saturate(1.2); backdrop-filter: blur(14px) saturate(1.2);
  box-shadow: 0 10px 30px -20px var(--shadow);
}
header.site nav a:not(.button) { color: var(--ink); text-decoration: none; }
header.site nav a:not(.button):hover { color: var(--accent); }
header.site nav form { margin: 0; padding-right: 12px; }
.balance { border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; font-variant-numeric: tabular-nums; }
footer.site { margin-top: auto; color: var(--muted); font-size: 13px; flex-wrap: wrap; }
.footer-links { display: flex; gap: 18px; flex-wrap: wrap; }
.footer-links a { color: var(--muted); text-decoration: none; }
.footer-links a:hover { color: var(--accent); text-decoration: underline; }

/* The reading sheet floats on the backdrop. */
main {
  width: calc(100% - 32px); max-width: 760px; margin: 8px auto 48px;
  padding: 48px 60px 60px;
  background: var(--sheet);
  border: 1px solid var(--sheet-edge);
  border-radius: 28px;
  box-shadow: 0 60px 120px -60px var(--shadow), 0 12px 32px -20px var(--shadow);
}
main.wide { max-width: 1100px; }

.flash {
  max-width: 760px; width: calc(100% - 32px); margin: 0 auto 12px; padding: 11px 18px;
  background: var(--free-soft); color: var(--free); border-radius: 14px; font-size: 15px;
  box-shadow: 0 10px 30px -22px var(--shadow);
}
.flash.error { background: var(--accent-soft); color: var(--accent); }

h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: -0.01em; line-height: 1.2; }
h1 { font-size: clamp(34px, 6vw, 48px); margin: 0 0 12px; }

button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 600 15px/1 var(--sans); padding: 12px 20px; border-radius: 999px;
  border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink);
  text-decoration: none; cursor: pointer; transition: transform .08s ease, filter .15s ease;
}
button:hover, .button:hover { filter: brightness(1.06); }
button:active, .button:active { transform: translateY(1px); }
button.secondary, .button.secondary { background: transparent; color: var(--ink); border-color: var(--line); }
button.secondary:hover, .button.secondary:hover { border-color: var(--ink); filter: none; }
button.small, .button.small { padding: 8px 14px; font-size: 14px; }
button.danger { background: transparent; color: var(--accent); border-color: var(--accent); }
button.linkish { background: none; border: 0; padding: 0; color: var(--ink); font: inherit; font-weight: 400; }
button.linkish:hover { color: var(--accent); filter: none; }

/* Home */
.intro { padding: 0 0 12px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.intro .row-between h1 { margin: 0; }
.intro .row-between + p { margin-top: 12px; }
.intro p { color: var(--muted); font-size: 18px; max-width: 560px; }
.entries { list-style: none; margin: 0; padding: 0; }
.entry { padding: 28px 0; border-bottom: 1px solid var(--line); }
.entries li:last-child .entry { border-bottom: 0; padding-bottom: 0; }
.share { margin: 12px 0 0; font-size: 13px; color: var(--muted); }
.share code { font: 12px var(--mono); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 2px 6px; user-select: all; }
.entry h2 { font-size: 28px; margin: 4px 0 8px; }
.entry h2 a { color: var(--ink); text-decoration: none; }
.entry h2 a:hover { color: var(--accent); }
.entry .excerpt { font-family: var(--serif); font-size: 18px; color: var(--muted); margin: 0 0 12px; }
.meta { color: var(--muted); font-size: 14px; margin: 0; letter-spacing: 0.02em; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 0; }
.chip {
  display: inline-block; font-size: 13px; padding: 3px 10px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line); color: var(--muted); white-space: nowrap;
}
.chip.free, .chip.pass { background: var(--free-soft); border-color: transparent; color: var(--free); }
.chip.owned { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.chip.open { background: var(--free-soft); border-color: transparent; color: var(--free); }
.empty { color: var(--muted); padding: 32px 0 8px; }
.empty p { margin: 0 0 8px; max-width: 34em; }

/* Thought */
.thought header { margin: 0 0 24px; }
.thought h1 { margin-top: 8px; }
.prose { font: 20px/1.75 var(--serif); }
.prose p { margin: 0 0 1.1em; }
.prose h2 { font-size: 28px; margin: 1.6em 0 .5em; }
.prose h3 { font-size: 23px; margin: 1.4em 0 .4em; }
.prose h4, .prose h5 { font-size: 20px; margin: 1.2em 0 .4em; }
.prose blockquote { margin: 1.4em 0; padding: 0 0 0 20px; border-left: 3px solid var(--accent); color: var(--muted); font-style: italic; }
.prose hr { border: 0; text-align: center; margin: 2em 0; }
.prose hr::after { content: "· · ·"; color: var(--muted); letter-spacing: .5em; }
.prose img { max-width: 100%; height: auto; border-radius: 8px; }
.prose code { font: .85em var(--mono); background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; }
.prose pre { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px; overflow-x: auto; }
.prose pre code { background: none; border: 0; padding: 0; font-size: 15px; }
.prose ul, .prose ol { padding-left: 1.3em; margin: 0 0 1.1em; }
.prose li { margin: .3em 0; }
.teaser { max-height: 13em; overflow: hidden; -webkit-mask-image: linear-gradient(to bottom, #000 45%, transparent); mask-image: linear-gradient(to bottom, #000 45%, transparent); }
.colophon { text-align: center; color: var(--muted); font-size: 14px; margin: 48px 0 0; }
.back { margin-top: 48px; font-size: 15px; }

.banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 12px 16px; margin: 0 0 28px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--line); font-size: 15px; color: var(--muted);
}
.banner.pass { background: var(--free-soft); border-color: transparent; color: var(--free); }
.banner form { margin: 0; }

.paywall { margin: 8px 0 0; padding: 28px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); }
.paywall h2 { margin: 0 0 18px; font-size: 26px; }
.options { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.options.single { grid-template-columns: 1fr; }
.option { padding: 20px; border-radius: 14px; border: 1px solid var(--line); display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.option.primary { border-color: var(--accent); }
.option h3 { margin: 0; font-size: 20px; }
.option p { margin: 0; color: var(--muted); font-size: 15px; }
.option form { margin: 4px 0 0; }
.option .button, .option button { margin-top: 4px; }
.option .price { font: 600 30px/1.1 var(--serif); color: var(--ink); }
.option .count { color: var(--free); font-weight: 600; }
.note { color: var(--muted); font-size: 14px; }
.meter { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0; }
.meter i { width: 10px; height: 10px; border-radius: 50%; background: var(--free); display: block; }
.meter i.taken { background: var(--line); }

/* Panels & forms */
.panel h2 { font-size: 22px; margin: 36px 0 12px; }
.panel > h1:first-child { margin-top: 0; }
.panel.narrow { max-width: 420px; }
.narrow-form { max-width: 420px; margin-top: 12px; }
.lede { color: var(--muted); font-size: 18px; }
.stack { display: grid; gap: 16px; margin: 24px 0; }
label { display: grid; gap: 6px; font-size: 14px; font-weight: 600; }
label.inline { display: inline-flex; align-items: center; gap: 8px; font-weight: 400; margin-right: 20px; }
input, textarea {
  font: 16px/1.4 var(--sans); color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px; width: 100%;
}
input[type=radio] { width: auto; accent-color: var(--accent); }
input:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; }
textarea.mono { font: 15px/1.6 var(--mono); }
.small { font-size: 13px; font-weight: 400; }
.muted { color: var(--muted); }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; }
legend { font-size: 14px; font-weight: 600; padding: 0 6px; }

.packs { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin: 28px 0; }
.pack { margin: 0; padding: 22px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); display: flex; flex-direction: column; gap: 6px; }
.pack p { margin: 0; }
.pack-name { color: var(--muted); font-size: 14px; text-transform: uppercase; letter-spacing: .08em; }
.pack-credits { font: 600 40px/1.1 var(--serif); }
.pack-credits span { font: 400 16px var(--sans); color: var(--muted); }
.pack-price { font-size: 18px; }
.pack-unit { color: var(--muted); font-size: 13px; margin-bottom: 10px !important; }
div.pack .pack-unit { margin-bottom: 0 !important; }
.pricing-band { margin-top: 40px; padding-top: 32px; border-top: 1px solid var(--line); }
.pricing-band h2 { margin: 0 0 6px; font-size: 26px; }
.pricing-band .packs { margin: 20px 0 12px; }
.prose.legal { font: 16.5px/1.7 var(--sans); }
.prose.legal h1 { font-size: clamp(32px, 5vw, 42px); }
.prose.legal h2 { font-size: 22px; margin: 1.8em 0 .5em; }
.prose.legal li { margin: .45em 0; }
.prose.legal .meta { margin-bottom: 1.6em; }
.actions.left { justify-content: flex-start; margin-top: 28px; }

ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain li { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
ul.plain li span { font-size: 14px; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 13px; color: var(--muted); font-weight: 600; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.plus { color: var(--free); }
.minus { color: var(--muted); }

/* Admin */
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin: 20px 0 28px; }
.stats div { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.stats dt { color: var(--muted); font-size: 13px; }
.stats dd { margin: 4px 0 0; font: 600 24px/1.2 var(--serif); font-variant-numeric: tabular-nums; }
.table-scroll { overflow-x: auto; }
.admin-table { min-width: 640px; }
.editor { display: grid; gap: 18px; margin-top: 20px; }
.editor button[type=submit] { justify-self: start; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; align-items: end; }
.danger-zone { margin-top: 40px; padding-top: 20px; border-top: 1px solid var(--line); }
.search { display: flex; gap: 10px; margin: 20px 0; max-width: 480px; }
.adjust { display: flex; gap: 6px; margin: 0; }
.adjust input { padding: 6px 8px; font-size: 14px; }
.adjust input[type=number] { width: 80px; }

/* Landing */
.hero { text-align: center; padding: 20px 0 8px; }
.hero .eyebrow { margin: 0; font-size: 13px; letter-spacing: 0.3em; text-transform: uppercase; color: var(--muted); }
.hero h1 { font-size: clamp(64px, 13vw, 128px); line-height: 0.95; letter-spacing: -0.035em; margin: 14px 0 20px; }
.hero h1 span { color: var(--accent); }
.hero .lede { max-width: 28em; margin: 0 auto 28px; font: 21px/1.55 var(--serif); color: var(--muted); }
.actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin: 0; }
.features { list-style: none; margin: 44px 0 0; padding: 32px 0 0; border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; }
.features h3 { font-size: 19px; margin: 0 0 6px; }
.features p { margin: 0; color: var(--muted); font-size: 15px; }

@media (max-width: 640px) {
  body { font-size: 16px; }
  header.site { padding: 14px 12px; flex-wrap: wrap; }
  header.site nav { gap: 12px; padding-left: 14px; font-size: 14px; }
  main { width: calc(100% - 16px); padding: 30px 20px 40px; border-radius: 20px; margin-bottom: 24px; }
  .flash { width: calc(100% - 16px); }
  .features { grid-template-columns: 1fr; gap: 18px; }
  .backdrop .lines { -webkit-mask-position: right top; mask-position: right top; }
  .options, .grid3 { grid-template-columns: 1fr; }
  .paywall { padding: 20px; }
  .prose { font-size: 19px; }
  .adjust { flex-wrap: wrap; }
}

/* ---- Opening canvas (first page of each visit) ---- */
.cover-toggle { position: fixed; top: 0; left: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
body:has(.cover-toggle:not(:checked)) { overflow: hidden; }
.cover {
  position: fixed; inset: 0; z-index: 100; overflow: hidden;
  background:
    radial-gradient(55% 50% at 18% 18%, rgba(255, 122, 92, .42), transparent 70%),
    radial-gradient(50% 45% at 86% 22%, rgba(196, 140, 255, .32), transparent 70%),
    radial-gradient(60% 55% at 80% 88%, rgba(96, 210, 180, .30), transparent 70%),
    radial-gradient(55% 50% at 14% 86%, rgba(255, 186, 102, .26), transparent 70%),
    radial-gradient(120% 90% at 50% 0%, #2d1a44 0%, #170f28 60%, #0d0918 100%);
  transition: opacity .9s ease .55s, visibility 0s linear 1.5s;
}
.cover canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.cover::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(75% 70% at 50% 50%, transparent 55%, rgba(8, 5, 16, .55) 100%);
}
.cover-center {
  position: absolute; inset: 0; z-index: 2;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px; text-align: center; pointer-events: none;
  transition: opacity .5s ease, transform 1s cubic-bezier(.2, .7, .2, 1), filter .6s ease;
}
.cover-center::before {
  content: ""; position: absolute; width: min(760px, 96vw); height: min(460px, 70vh); z-index: -1;
  background: radial-gradient(closest-side, rgba(14, 9, 26, .72), rgba(14, 9, 26, .34) 62%, transparent);
}
.cover-center > * { animation: cover-rise 1.1s cubic-bezier(.2, .7, .2, 1) both; }
.cover-center > :nth-child(2) { animation-delay: .15s; }
.cover-center > :nth-child(3) { animation-delay: .3s; }
.cover-center > :nth-child(4) { animation-delay: .45s; }
.cover-center > :nth-child(5) { animation-delay: .9s; }
@keyframes cover-rise { from { opacity: 0; transform: translateY(16px); } }
.cover-title {
  margin: 0; color: #fff6ea;
  font: italic 500 clamp(84px, 16vw, 196px)/.9 var(--serif); letter-spacing: -.04em;
  text-shadow: 0 0 36px rgba(255, 170, 120, .45), 0 0 110px rgba(255, 110, 150, .35);
}
.cover-title span { color: #ff8a5c; }
.cover-line { margin: 30px 0 0; max-width: 26em; color: rgba(255, 242, 228, .92); font: 400 clamp(19px, 2.4vw, 25px)/1.45 var(--serif); }
.cover-line.small { margin-top: 6px; color: rgba(255, 226, 200, .72); font: 400 clamp(14px, 1.6vw, 16px)/1.5 var(--sans); }
.cover-button {
  pointer-events: auto; cursor: pointer; user-select: none;
  margin-top: 32px; display: inline-flex; align-items: center; gap: 10px;
  padding: 16px 32px; border-radius: 999px;
  color: #23122a; font: 650 17px/1 var(--sans); letter-spacing: .01em;
  background: linear-gradient(120deg, #ffe0a8, #ffa27e 45%, #ff7fa8);
  box-shadow: 0 0 0 6px rgba(255, 190, 150, .12), 0 16px 44px -12px rgba(255, 120, 140, .75);
  transition: transform .25s cubic-bezier(.2, .7, .2, 1), box-shadow .25s ease;
}
.cover-button span { transition: transform .25s cubic-bezier(.2, .7, .2, 1); }
.cover-button:hover { transform: translateY(-2px) scale(1.03); box-shadow: 0 0 0 9px rgba(255, 190, 150, .16), 0 22px 54px -12px rgba(255, 120, 140, .85); }
.cover-button:hover span { transform: translateX(4px); }
.cover-toggle:focus-visible + .cover .cover-button { outline: 2px solid #ffe0a8; outline-offset: 5px; }
.cover-hint { margin: 20px 0 0; color: rgba(255, 236, 220, .5); font: 13px/1 var(--sans); letter-spacing: .06em; }
@media (hover: none) { .cover-hint { display: none; } }

/* Coming in: the words drift forward and blur while the colours scatter. */
.cover-toggle:checked + .cover { opacity: 0; visibility: hidden; pointer-events: none; }
.cover-toggle:checked + .cover .cover-center { opacity: 0; transform: scale(1.1); filter: blur(8px); }

@media (prefers-reduced-motion: reduce) {
  .cover-center > * { animation: none; }
  .cover { transition: opacity .4s ease, visibility 0s linear .4s; }
  .cover-toggle:checked + .cover .cover-center { transform: none; filter: none; }
}
@media print { .cover, .cover-toggle { display: none; } }

/* ---- Chinese type ---- */
html[lang="zh-CN"] { --serif: "Songti SC", "STSong", "Noto Serif SC", "Source Han Serif SC", "Iowan Old Style", Georgia, serif; }
.lang-switch { font-size: 14px; opacity: .8; }

/* ---- The envelope ---- */
.stage { position: relative; width: min(520px, 100%); margin: 6px auto 26px; perspective: 1400px; }
.stage[hidden] { display: none; }
.envelope { position: relative; width: 100%; aspect-ratio: 1.62; }
.env-back {
  position: absolute; inset: 0; border-radius: 10px;
  background: linear-gradient(160deg, #ead9b9, #d9c196);
  box-shadow: 0 34px 60px -32px rgba(70, 40, 10, .6), 0 6px 14px -8px rgba(70, 40, 10, .4);
}
.sheet {
  position: absolute; left: 6%; right: 6%; top: 7%; height: 84%; z-index: 1; border-radius: 5px;
  background: repeating-linear-gradient(to bottom, transparent 0 22px, rgba(150, 110, 60, .14) 22px 23px) 0 18px / 100% 100% no-repeat, #fffaf0;
  box-shadow: 0 2px 10px rgba(60, 35, 10, .18);
}
.env-front {
  position: absolute; inset: 0; z-index: 2; border-radius: 10px;
  background:
    linear-gradient(to top right, transparent 49.7%, rgba(120, 80, 30, .16) 50%, transparent 50.4%) left bottom / 50% 100% no-repeat,
    linear-gradient(to top left, transparent 49.7%, rgba(120, 80, 30, .16) 50%, transparent 50.4%) right bottom / 50% 100% no-repeat,
    linear-gradient(170deg, #f5e8cf, #e6d2ac);
  clip-path: polygon(0 0, 50% 58%, 100% 0, 100% 100%, 0 100%);
}
.env-address { position: absolute; left: 8%; right: 8%; bottom: 6%; z-index: 3; text-align: center; color: #5a3f23; }
.env-to { display: block; font: 12px/1.4 var(--sans); letter-spacing: .18em; opacity: .7; }
.env-title { display: block; margin-top: 4px; font: italic 600 clamp(17px, 3.2vw, 25px)/1.25 var(--serif); }
.env-flap {
  position: absolute; left: 0; right: 0; top: 0; height: 60%; z-index: 4; transform-origin: 50% 0;
  background: linear-gradient(180deg, #efe0c3, #d8c095);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  border-radius: 10px 10px 0 0;
}
.seal { position: absolute; left: 50%; top: 60%; width: 78px; height: 78px; margin: -39px 0 0 -39px; z-index: 5; filter: drop-shadow(0 5px 6px rgba(60, 0, 0, .45)); }
.seal-half { position: absolute; inset: 0; }
.seal-half svg { width: 100%; height: 100%; display: block; }
.seal-half.l { clip-path: polygon(0 0, 53% 0, 46% 22%, 56% 41%, 47% 61%, 55% 80%, 50% 100%, 0 100%); }
.seal-half.r { clip-path: polygon(53% 0, 100% 0, 100% 100%, 50% 100%, 55% 80%, 47% 61%, 56% 41%, 46% 22%); }
.opener { position: absolute; width: 64%; top: -8%; left: -72%; z-index: 6; opacity: 0; pointer-events: none; filter: drop-shadow(0 8px 8px rgba(0, 0, 0, .35)); }
.opener svg { width: 100%; height: auto; display: block; }
.stage-note { text-align: center; margin: 18px 0 0; opacity: 0; }
.stage:not(.saving) .stage-note { display: none; }
.stage-note h2 { margin: 0 0 6px; }

/* Opening with the letter opener: slit, crack, lift, rise. */
.stage.opening .opener { animation: opener-slit 1.1s cubic-bezier(.55, .05, .35, 1) forwards; }
@keyframes opener-slit {
  0% { opacity: 0; transform: translate(0, -14%) rotate(-7deg); }
  14% { opacity: 1; transform: translate(22%, 0) rotate(-2deg); }
  86% { opacity: 1; transform: translate(262%, 0) rotate(1deg); }
  100% { opacity: 0; transform: translate(290%, -24%) rotate(5deg); }
}
.stage.opening .seal-half.l { animation: seal-l .75s .95s cubic-bezier(.45, 0, .7, 1) forwards; }
.stage.opening .seal-half.r { animation: seal-r .75s 1s cubic-bezier(.45, 0, .7, 1) forwards; }
@keyframes seal-l { 20% { transform: translate(-3px, 0) rotate(-6deg); } 100% { transform: translate(-54px, 90px) rotate(-48deg); opacity: 0; } }
@keyframes seal-r { 20% { transform: translate(3px, 0) rotate(6deg); } 100% { transform: translate(54px, 96px) rotate(52deg); opacity: 0; } }
.stage.opening .env-flap { animation: flap-open .6s 1.4s ease-in-out forwards; }
@keyframes flap-open { 0% { transform: rotateX(0); z-index: 4; } 49% { z-index: 4; } 50% { z-index: 0; } 100% { transform: rotateX(180deg); z-index: 0; } }
.stage.opening .sheet { animation: sheet-rise .85s 1.9s cubic-bezier(.3, .7, .3, 1) forwards; }
@keyframes sheet-rise { to { transform: translateY(-46%); } }
.stage.opening .envelope { animation: env-away .55s 2.75s ease forwards; }
@keyframes env-away { to { opacity: 0; transform: translateY(26px) scale(.95); } }

/* A free read opens gently: no opener, the seal just lifts. */
.stage.opening.gentle .opener { animation: none; }
.stage.opening.gentle .seal-half.l, .stage.opening.gentle .seal-half.r { animation: seal-lift .5s .15s ease forwards; }
@keyframes seal-lift { to { transform: translateY(-30px) scale(1.12); opacity: 0; } }
.stage.opening.gentle .env-flap { animation-delay: .45s; }
.stage.opening.gentle .sheet { animation-delay: .95s; }
.stage.opening.gentle .envelope { animation-delay: 1.8s; }

/* Keeping a free read: the letter folds back in and the envelope is sealed. */
.stage.saving .env-flap { transform: rotateX(180deg); z-index: 0; animation: flap-close .55s .85s ease-in-out forwards; }
@keyframes flap-close { 0% { transform: rotateX(180deg); z-index: 0; } 49% { z-index: 0; } 50% { z-index: 4; } 100% { transform: rotateX(0); z-index: 4; } }
.stage.saving .sheet { transform: translateY(-46%); animation: sheet-sink .7s .1s cubic-bezier(.5, 0, .7, 1) forwards; }
@keyframes sheet-sink { to { transform: translateY(0); } }
.stage.saving .seal { opacity: 0; animation: seal-stamp .45s 1.45s cubic-bezier(.3, 1.4, .5, 1) forwards; }
@keyframes seal-stamp { from { opacity: 0; transform: scale(1.9) rotate(-12deg); } to { opacity: 1; transform: scale(1) rotate(0); } }
.stage.saving .envelope { animation: env-kept .8s 2s ease forwards; }
@keyframes env-kept { 50% { transform: translateY(-10px); } 100% { transform: translateY(-4px); } }
.stage.saving .stage-note { animation: note-in .6s 2.3s ease forwards; }
@keyframes note-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---- The letter ---- */
.letter {
  position: relative; overflow: hidden; color: #2a2118;
  background: linear-gradient(180deg, #fffaf1, #fbf2e2);
  border-radius: 6px; padding: 46px 52px 54px; margin: 0 0 8px;
  box-shadow: 0 34px 70px -40px rgba(60, 35, 10, .6), 0 2px 12px -4px rgba(60, 35, 10, .25);
}
.letter.protected { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.letter .meta { color: #8a7560; }
.letter h1 { color: #2a2118; margin: 6px 0 22px; font-size: clamp(30px, 5vw, 42px); }
.letter .prose { position: relative; z-index: 1; }
.letter .prose a { color: #a2421f; }
.letter .prose blockquote { color: #6d5a45; }
.letter .watermark { position: absolute; left: 0; top: 0; width: 1400px; height: 7000px; max-width: none; pointer-events: none; z-index: 2; -webkit-user-select: none; user-select: none; }
.letter .signoff { margin: 34px 0 0; text-align: right; color: #8a7560; font: italic 15px var(--serif); }
.letter.reveal { animation: letter-in .75s cubic-bezier(.2, .7, .2, 1) both; transform-origin: 50% 0; }
@keyframes letter-in { from { opacity: 0; transform: translateY(20px) scaleY(.9); } }
.letter.leaving { animation: letter-fold .65s ease forwards; transform-origin: 50% 100%; }
@keyframes letter-fold { to { opacity: 0; transform: translateY(70px) scale(.45); } }
.kept-line { text-align: center; color: var(--muted); font-size: 14px; margin: 14px 0 0; }

/* Shown instead of the letter while the window is in the background. */
body.away .letter { filter: blur(16px); }
.letter-away { display: none; }
body.away .letter-away {
  display: flex; position: fixed; inset: 0; z-index: 60; align-items: center; justify-content: center; padding: 24px; text-align: center;
  background: rgba(20, 13, 34, .45); color: #fff6ea; font: 18px/1.5 var(--serif);
}
.print-note { display: none; }
@media print {
  .letter, .stage, .free-bar { display: none !important; }
  .print-note { display: block; }
}

/* ---- Offers ---- */
.offer .price small { font: 400 14px var(--sans); color: var(--muted); text-decoration: line-through; margin-left: 6px; }
.offer .sale-until { color: var(--accent); font-size: 14px; }
.offer form { margin: 4px 0 0; }
.offer .error-inline { width: 100%; }
.free-bar {
  position: sticky; bottom: 12px; z-index: 20; margin: 22px 0 0; padding: 14px 18px; border-radius: 16px;
  display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap;
  background: var(--sheet); border: 1px solid var(--line); box-shadow: 0 22px 44px -22px var(--shadow);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
.free-bar p { margin: 0; font-size: 15px; color: var(--muted); max-width: 30em; }
.free-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.free-actions form { margin: 0; }
button[disabled] { opacity: .6; cursor: progress; }

/* ---- Library: little envelopes ---- */
.mini-envelopes { list-style: none; padding: 0; margin: 14px 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 20px; }
.mini {
  display: block; position: relative; aspect-ratio: 1.62; border-radius: 8px; overflow: hidden; text-decoration: none; color: #4b3520;
  background: linear-gradient(165deg, #f4e7cd, #e1cba3);
  box-shadow: 0 20px 34px -24px rgba(70, 40, 10, .65), 0 3px 8px -4px rgba(70, 40, 10, .35);
  transition: transform .25s cubic-bezier(.2, .7, .2, 1), box-shadow .25s ease;
}
.mini::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 56%; background: linear-gradient(180deg, #ebdabb, #d6bd92); clip-path: polygon(0 0, 100% 0, 50% 100%); }
.mini:hover { transform: translateY(-4px) rotate(-.6deg); box-shadow: 0 28px 40px -24px rgba(70, 40, 10, .7); }
.mini-seal { position: absolute; left: 50%; top: 56%; width: 34px; height: 34px; transform: translate(-50%, -50%); filter: drop-shadow(0 2px 3px rgba(60, 0, 0, .4)); }
.mini-seal svg { width: 100%; height: 100%; display: block; }
.mini-title { position: absolute; left: 10px; right: 10px; bottom: 16%; text-align: center; font: italic 600 17px/1.3 var(--serif); }
.mini-date { position: absolute; left: 10px; right: 10px; bottom: 6%; text-align: center; font-size: 11px; opacity: .65; }

/* ---- Owner ---- */
.share-links { margin: 10px 0 0; font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px 14px; }
.share-links code { font: 12px var(--mono); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 2px 6px; user-select: all; }
.en-panel { margin-top: 34px; padding-top: 22px; border-top: 1px solid var(--line); }
.en-status { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 0 0 14px; }
.en-status form { margin: 0; }
.grid2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; align-items: end; }
.hint { font-weight: 400; color: var(--muted); font-size: 13px; }

@media (max-width: 640px) {
  .letter { padding: 32px 22px 40px; }
  .grid2 { grid-template-columns: 1fr; }
  .seal { width: 50px; height: 50px; margin: -25px 0 0 -25px; }
  .env-address { bottom: 4%; }
}
@media (prefers-reduced-motion: reduce) {
  .stage *, .stage, .letter { animation-duration: .01s !important; animation-delay: 0s !important; }
}
