@font-face {
  font-family: "Handbook Garamond";
  src: url("/assets/fonts/garamond.woff2") format("woff2");
  font-weight: 400 500;
  font-display: swap;
}

@font-face {
  font-family: "Handbook Garamond";
  src: url("/assets/fonts/garamond-italic.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: "Handbook Serif";
  src: url("/assets/fonts/handbook-serif.woff2") format("woff2");
  font-weight: 400 500;
  font-display: swap;
}

@font-face {
  font-family: "Handbook Sans";
  src: url("/assets/fonts/handbook-sans.woff2") format("woff2");
  font-weight: 400 600;
  font-display: swap;
}

:root {
  color-scheme: light;
  --paper: #fffaf0;
  --warm-paper: #f4ecdd;
  --ink: #40352b;
  --muted: #6e5f50;
  --olive: #556045;
  --olive-paper: #e7e9db;
  --clay: #936952;
  --paper-edge: #d4c3a9;
  --fiber: url("/assets/fibers.png");
  --page-gutter: clamp(22px, 7.18vw, 28px);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --display: "Handbook Garamond", "Iowan Old Style", Georgia, serif;
  --serif: "Handbook Serif", "Songti SC", SimSun, serif;
  --sans: "Handbook Sans", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --ease: cubic-bezier(.2, .65, .32, 1);
}

*, *::before, *::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html {
  min-width: 0;
  background: var(--warm-paper);
  -webkit-text-size-adjust: 100%;
}

body {
  min-width: 0;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background: var(--fiber), linear-gradient(149deg, #f9f2e7, #f0e7d7);
  color: var(--ink);
  font: 400 16px/1.45 var(--sans);
}

h1, h2, p { margin: 0; }

button, textarea, input { color: inherit; font: inherit; }

button {
  min-height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button, textarea {
  transition: background-color 220ms var(--ease), border-color 220ms var(--ease), box-shadow 220ms var(--ease);
}

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

button:disabled { opacity: .63; cursor: default; }

textarea {
  display: block;
  width: 100%;
  min-width: 0;
  border: 1px solid #d3c4ae;
  border-radius: 6px;
  background-color: #faf3e6;
  font-size: 16px;
  resize: vertical;
}

textarea::placeholder { color: var(--muted); opacity: 1; }

.icon-library { position: absolute; width: 0; height: 0; overflow: hidden; }

.icon {
  display: block;
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.35;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#app, .gate {
  width: 100%;
  max-width: 500px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
}

#app { display: flex; flex-direction: column; }

.screen { min-width: 0; }

.page-leave, .page-enter { pointer-events: none; }
.page-leave { animation: page-leave 250ms cubic-bezier(0.4, 0, 0.2, 1) both; }
.page-enter { animation: page-enter 250ms cubic-bezier(0.4, 0, 0.2, 1) both; }

@keyframes page-leave {
  to { opacity: 0; transform: translateY(-8px); }
}

@keyframes page-enter {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.page {
  flex: 1;
  padding: calc(39px + var(--safe-top)) max(var(--page-gutter), var(--safe-right))
    34px max(var(--page-gutter), var(--safe-left));
}

.page-title {
  margin-top: 30px;
  font: 500 33px/1.4 var(--serif);
  overflow-wrap: anywhere;
}

.brand {
  display: flex;
  width: max-content;
  height: 27px;
  align-items: center;
  gap: 2px;
  font: 400 20px/1.35 var(--display);
}

.brand > span { display: inline-block; }
.brand > span:first-child { min-width: 21px; }
.brand > span:last-child { min-width: 18px; }
.brand-wave { display: block; width: 26px; height: 9px; color: var(--clay); }

.gate {
  display: grid;
  grid-auto-rows: max-content;
  align-content: center;
  justify-items: center;
  gap: 18px;
  padding: 36px;
  text-align: center;
}

.gate-brand { height: 55px; font-size: 40px; gap: 6px; }
.gate-brand .brand-wave { width: 40px; height: 15px; }
.gate p { color: var(--muted); overflow-wrap: anywhere; }
.gate .button-soft { padding-inline: 20px; }

.opening {
  padding: calc(56px + var(--safe-top)) max(var(--page-gutter), var(--safe-right))
    calc(54px + var(--safe-bottom)) max(var(--page-gutter), var(--safe-left));
}

.brand-large {
  display: grid;
  grid-template-columns: 90fr 99fr 89fr;
  gap: 2.4%;
  width: min(100%, 292px);
  height: 108px;
  margin: 0 auto;
  place-items: center;
  font-size: clamp(88px, 27.7vw, 108px);
  font-weight: 500;
  line-height: 1;
}

.brand-large .brand-wave { width: 100%; height: auto; align-self: center; margin-top: 31px; }
.brand-large > span { text-align: center; }

.age { margin-top: 49px; text-align: center; color: var(--muted); }
.age-since, .age-total { font-size: 15px; line-height: 22px; }
.age-since { letter-spacing: .4px; }

.age-units {
  display: grid;
  grid-template-columns: minmax(71px, max-content) minmax(79px, max-content) minmax(84px, max-content);
  width: max-content;
  max-width: 100%;
  min-height: 53px;
  align-items: baseline;
  margin: 2px auto 0;
  transform: translateY(-4px);
}

.age-units > span { display: flex; gap: 4px; align-items: baseline; white-space: nowrap; font-size: 13px; }
.age-units > span:last-child { gap: 12px; }
.age-units b { font: 400 51px/1.04 var(--display); color: var(--ink); }

.age-total { display: flex; justify-content: center; align-items: center; gap: 18px; margin-top: 16px; }
.age-total::before, .age-total::after { content: ""; width: 32px; height: 1px; background: var(--paper-edge); }

.home { padding-bottom: 24px; }
.home .brand-large { width: min(100%, 228px); height: 76px; font-size: clamp(58px, 19vw, 76px); }
.home .brand-wave { margin-top: 22px; }
.home .age { margin-top: 25px; }
.home .age-units b { font-size: 45px; }
.home .age-total { margin-top: 8px; }

.home-notes { display: grid; gap: 11px; margin-top: 31px; }

.home-note {
  min-width: 0;
  padding: 13px 16px 15px;
  border: 1px solid #dacdb8;
  border-radius: 6px;
  background: var(--fiber), var(--paper);
}

.home-note + .home-note { border-color: #d4d2bf; background-color: #eceddf; }
.home-note h2 { color: var(--muted); font-size: 13px; font-weight: 400; }
.home-note-value { margin-top: 5px; color: var(--ink); font-size: 18px; overflow-wrap: anywhere; }
#home-peer-empty { color: var(--muted); }

.home .peer-paper {
  min-height: 0;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  margin-top: 6px;
  padding: 0;
  border: 0;
  background: none;
}

.home .peer-paper .icon { width: 34px; height: 34px; }
.home .peer-note { margin-top: 4px; }

.home-entries { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; margin-top: 21px; }
.home-entries .button-soft { min-height: 50px; padding-inline: 4px; color: var(--olive); font-size: 14px; }
#home-throw[aria-expanded="true"] { border-color: #bfc5ad; background: var(--olive-paper); }

.home-write-link {
  display: flex;
  width: fit-content;
  max-width: 100%;
  min-height: 44px;
  align-items: center;
  gap: 7px;
  margin: 19px auto 0;
  padding-inline: 8px;
  border-radius: 4px;
  color: var(--olive);
  font-size: 14px;
  text-decoration: none;
}

.home-write-link .icon { width: 10px; height: 13px; }
.home-write-link:hover span { text-decoration: underline; text-underline-offset: 4px; }
.home-write-link:focus-visible { outline: 2px solid var(--olive); outline-offset: 3px; }

.for-her-hint { margin-top: 10px; color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.for-her .opening-envelope { margin-top: 4px; }
.for-her .card-stack { margin-top: 24px; }

.opening-envelope {
  position: relative;
  width: min(100%, 310px);
  margin: 45px auto 0;
  padding: 34px 0 23px;
  isolation: isolate;
}

.envelope-back, .envelope-front {
  position: absolute;
  inset: auto 0 23px;
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
  pointer-events: none;
}

.envelope-back { filter: drop-shadow(0 12px 11px rgb(90 66 34 / .17)); }
.envelope-flap { transform-origin: 50% 159px; }

.opening-paper {
  position: relative;
  width: 82.26%;
  margin-left: 7.1%;
  padding: 43px 9.4% 161px;
  border: 1px solid #d8c7ac;
  border-radius: 3px;
  background: var(--fiber), var(--paper);
  box-shadow: 0 5px 14px #5a422226;
  transform-origin: 0 0;
  transform: translateY(24px) rotate(-1deg);
  opacity: 0;
  transition: transform 460ms var(--ease), opacity 360ms var(--ease);
}

.opening-paper.is-open { transform: translateY(0) rotate(-2deg); opacity: 1; }

.opening-paper::before {
  position: absolute;
  inset: 28px 9.4% auto;
  height: 1px;
  background: #dcccb0;
  content: "";
}

.opening-paper h2 { font: 500 26px/1.4 var(--serif); font-weight: 400; }
.opening-paper p {
  margin-top: 17px;
  overflow-wrap: anywhere;
  padding-bottom: 7px;
  background: repeating-linear-gradient(transparent 0 30px, #e9dec9 30px 31px);
  color: var(--muted);
  font-size: 15px;
  line-height: 31px;
  white-space: pre-wrap;
}

.envelope-sign {
  position: absolute;
  bottom: 46px;
  left: 75.8%;
  color: var(--clay);
  font: italic 400 42px/1.35 var(--display);
}

.envelope-sign-line { color: var(--clay); }

.page-link {
  display: flex;
  min-height: 53px;
  min-width: 154px;
  width: max-content;
  max-width: 100%;
  margin: 30px auto 0;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  border-radius: 6px;
  color: var(--olive);
  font-size: 14px;
  line-height: 20px;
  letter-spacing: .13em;
}

.page-link .icon { width: 12px; height: 14px; }
.page-link:active, .quiet-action:active { background-color: #e7e9db88; }

.card-tabs {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  margin-top: 14px;
  border-bottom: 1px solid #dccfba;
}

.card-tab {
  position: relative;
  min-height: 48px;
  min-width: 0;
  padding: 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.card-tab[aria-pressed="true"], .card-tab[aria-selected="true"], .card-tab.is-active {
  color: var(--olive);
  font-weight: 500;
}

.card-tab[aria-pressed="true"]::after, .card-tab[aria-selected="true"]::after, .card-tab.is-active::after {
  position: absolute;
  inset: auto 16% 0;
  height: 4px;
  border-top: 1px solid var(--olive);
  border-radius: 48% 48% 0 0;
  box-shadow: inset 0 1px #55604548;
  transform: rotate(-1.5deg);
  content: "";
}

.card-stack {
  position: relative;
  z-index: 0;
  width: calc(100% - 24px);
  max-width: 344px;
  margin: 29px auto 0;
}

.card-stack::before, .card-stack::after {
  position: absolute;
  z-index: -1;
  border: 1px solid #cbd0ba;
  border-radius: 4px;
  box-shadow: 0 9px 22px #5a422215;
  transform-origin: 0 0;
  content: "";
}

.card-stack::before { inset: 14px 1px 10px 11px; background: #dce0cc; transform: rotate(4.2deg); }
.card-stack::after { inset: 4px 11px 10px 1px; border-color: #d6c5ad; background: #e9d8be; transform: rotate(-2deg); }

.card-sheet {
  position: relative;
  min-height: 346px;
  padding: 58px clamp(22px, 7.95vw, 31px) 25px;
  border: 1px solid #d9c8aa;
  border-radius: 4px;
  background: var(--fiber), var(--paper);
  box-shadow: 0 9px 22px #5a422226;
  touch-action: pan-y;
}

.card-sheet h2 { font: 500 25px/1.4 var(--serif); overflow-wrap: anywhere; }

.paper-tape {
  position: absolute;
  top: 4px;
  left: calc(50% - 42px);
  width: 84px;
  height: 18px;
  background: #d1cfad92;
  transform: rotate(-1.5deg);
  pointer-events: none;
}

.paper-tape::before {
  position: absolute;
  inset: 10px 4px auto;
  height: 1px;
  background: #b2ac8a62;
  content: "";
}

.card-underline {
  display: block;
  width: 122px;
  height: 11px;
  margin: 6px 0 17px 3px;
  fill: none;
  stroke: var(--clay);
  stroke-width: .88;
  stroke-linecap: round;
}

[data-card-field="date"] {
  color: var(--clay);
  font: 400 22px/35px var(--display);
  letter-spacing: .04em;
}

[data-card-field="body"] {
  min-height: 175px;
  background: repeating-linear-gradient(transparent 0 26px, #e9deca 26px 27px, transparent 27px 35px);
  color: var(--muted);
  line-height: 35px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.card-pagination {
  display: grid;
  grid-template-columns: 48px 94px 48px;
  min-height: 48px;
  width: max-content;
  gap: 6px;
  align-items: center;
  margin: 44px auto 0;
}

.round-button {
  display: grid;
  width: 48px;
  min-height: 48px;
  place-items: center;
  border: 1px solid #cdbba1;
  border-radius: 50%;
  color: var(--olive);
}

.round-button:first-child { color: #766a58; }
.round-button .icon { width: 12px; height: 14px; }
.round-button:active { background-color: #eee3d2; }

#card-index { color: var(--muted); text-align: center; font: 400 22px/1 var(--display); }
.cards .page-link { margin-top: 63px; }

.response-note {
  position: relative;
  isolation: isolate;
  width: min(100%, 292px);
  height: 292px;
  margin: 83px auto 0;
}

.response-note::before, .response-note::after {
  position: absolute;
  z-index: -1;
  height: 208px;
  border-radius: 4px;
  transform-origin: 0 0;
  content: "";
}

.response-note::before {
  inset: 27px 27px auto 28px;
  background: #e2e2cf;
  box-shadow: 0 8px 15px #504b3121;
  transform: rotate(7deg);
}

.response-note::after {
  inset: 23px 36px auto 10px;
  height: 204px;
  background: #e7d7bb;
  box-shadow: 0 5px 12px #5a422222;
  transform: rotate(-4deg);
}

.response-paper {
  position: absolute;
  inset: 36px 19px auto;
  height: 205px;
  padding-top: 27px;
  border: 1px solid #d6c3a8;
  border-radius: 3px;
  background: var(--fiber), var(--paper);
  box-shadow: 0 9px 17px #5a422226;
  text-align: center;
}

.response-paper > span {
  display: block;
  height: 107px;
  color: var(--clay);
  font: italic 400 88px/1 var(--display);
}

.response-paper .brand-wave { width: 54px; height: 17px; margin: 0 auto; }
.paper-fold { position: absolute; top: 0; right: 0; width: 38px; height: 38px; }

.response-paper::after {
  position: absolute;
  inset: 176px 11% auto;
  height: 1px;
  background: #e9dbc5;
  content: "";
}

.response-actions { display: flow-root; max-width: 310px; margin: 24px auto 0; text-align: center; }

.choice-buttons { display: grid; gap: 14px; margin-top: 60px; }

.button-soft {
  min-height: 54px;
  padding: 7px 14px;
  border: 1px solid #c7b69d;
  border-radius: 8px;
  background: #f8f0e2;
  color: var(--ink);
  font-size: 16px;
  font-weight: 500;
  overflow-wrap: anywhere;
}

.button-soft:active { background: #efe5d4; }
.unlocked-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; margin-top: 76px; }
.unlocked-actions .button-soft { min-height: 51px; color: var(--olive); font-size: 15px; }

#choice-feedback { color: var(--olive); font-size: 14px; line-height: 1.6; overflow-wrap: anywhere; }

.quiet-action { padding-inline: 9px; border-radius: 5px; color: var(--muted); font-size: 13px; }
#choice-change { min-width: 116px; margin-top: 31px; }

.section-status { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
#response-status:not([hidden]), #mail-status:not([hidden]) { margin: 0 0 14px; }

.mail-header {
  display: flex;
  min-height: 46px;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-top: 30px;
}

.mail-header .page-title { margin: 0; }
.mail .page-title, .weather .page-title { font-size: 34px; line-height: 1.38; }

.button-olive {
  display: inline-flex;
  min-height: 45px;
  padding: 7px 13px;
  gap: 10px;
  align-items: center;
  justify-content: center;
  border: 1px solid #c7cbbb;
  border-radius: 6px;
  background: var(--olive-paper);
  color: var(--olive);
  font-size: 14px;
  overflow-wrap: anywhere;
}

.button-olive:active { background: #dce1cf; }
#mail-write { min-width: 121px; min-height: 46px; }
#mail-write .icon { stroke-width: 1.05; }

.mail-group { margin-top: 35px; min-width: 0; }
.mail-group + .mail-group { margin-top: 42px; }
.mail-group h2 { color: var(--muted); font: 400 14px/20px var(--sans); letter-spacing: .35px; }
.mail-list { display: grid; gap: 16px; margin-top: 14px; }
.mail-empty { color: var(--muted); font-size: 14px; }

.mail-envelope {
  position: relative;
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 156px;
  border: 1px solid #cbbb9f;
  border-radius: 6px;
  padding: 24px 85px 17px 19px;
  background: #f3e6cd;
  box-shadow: 0 6px 15px #5742221f;
  text-align: left;
  overflow: hidden;
}

#mail-sent .mail-envelope { background-color: #f0e4cf; }
.mail-envelope:active, #mail-sent .mail-envelope:active { background-color: #ecdfc3; }

.mail-envelope-folds {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  fill: none;
  stroke: #b9a68a67;
  stroke-width: .85;
  pointer-events: none;
}

.mail-envelope-title, .mail-envelope-date, .mail-envelope-open { position: relative; display: block; }
.mail-envelope-title { font: 500 23px/1.4 var(--serif); overflow-wrap: anywhere; }
.mail-envelope-date { margin-top: 4px; color: var(--muted); font: 400 17px/1.25 var(--display); letter-spacing: .03em; }

.mail-stamp {
  position: absolute;
  top: 17px;
  right: 24px;
  display: grid;
  width: 48px;
  height: 55px;
  justify-items: center;
  align-content: center;
  border: 1px dotted #a9a48b;
  background: #dbdfca;
  color: var(--olive);
  font: italic 400 29px/1 var(--display);
  transform: rotate(6deg);
  pointer-events: none;
}

.mail-stamp::before { position: absolute; inset: 5px; border: 1px solid #b5b69c; content: ""; }
.mail-stamp svg { width: 26px; height: 6px; fill: none; stroke: currentColor; stroke-width: .74; }
#mail-sent .mail-stamp { background: #e6dbc5; }

.mail-envelope-open { display: flex; gap: 8px; align-items: center; margin-top: 23px; color: var(--olive); font-size: 13px; }
.mail-envelope-open .icon { width: 12px; height: 14px; }

.weather-date { margin: 10px 0 0 2px; color: var(--muted); font-size: 14px; line-height: 19px; }
.weather-form { margin-top: 36px; }
.weather-form > h2, .peer-weather > h2 { font: 400 15px/21px var(--sans); }
.weather-options { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin-top: 15px; }

.weather-options button {
  position: relative;
  display: flex;
  min-height: 85px;
  min-width: 0;
  padding: 10px 2px 9px;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  border: 1px solid #cfc6b3;
  border-radius: 7px;
  font-size: 13px;
  line-height: 19px;
  overflow-wrap: anywhere;
}

.weather-options [data-weather="sun"] { --weather-ink: #796135; background: #efe1bc; color: var(--weather-ink); }
.weather-options [data-weather="cloud"] { --weather-ink: #54634d; background: #e5e8db; color: var(--weather-ink); }
.weather-options [data-weather="rain"] { --weather-ink: #4d6267; background: #e0e7e5; color: var(--weather-ink); }
.weather-options [data-weather="wind"] { --weather-ink: #795e4c; background: #ede1d1; color: var(--weather-ink); }

.weather-options button[aria-pressed="true"] { border-color: var(--weather-ink); box-shadow: inset 0 0 0 .5px var(--weather-ink); }
.weather-options button:active { filter: brightness(.98); }
.weather-icon { width: 35px; height: 35px; stroke-width: 1.4; }
.weather-check { display: none; position: absolute; top: 7px; right: 7px; width: 11px; height: 10px; stroke-width: 1.2; }
.weather-options button[aria-pressed="true"] .weather-check { display: block; }

#weather-note {
  min-height: 93px;
  margin-top: 21px;
  padding: 13px 14px;
  resize: none;
  background-image: linear-gradient(#e7d9c3, #e7d9c3);
  background-size: calc(100% - 28px) 1px;
  background-position: center 61px;
  background-repeat: no-repeat;
  line-height: 32px;
}

.weather-save-row { display: flex; gap: 12px; align-items: center; justify-content: flex-end; margin-top: 14px; }
#weather-save { min-width: 119px; flex: none; }
.peer-weather { margin-top: 36px; padding-top: 26px; border-top: 1px solid #dcceb9; }

.peer-paper {
  display: grid;
  min-height: 111px;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
  margin-top: 10px;
  padding: 15px 16px;
  border: 1px solid #d0d1bf;
  border-radius: 6px;
  background: #e9eadc;
}

.peer-paper .icon { width: 52px; height: 52px; color: #5d6b54; stroke-width: 1.4; }
.peer-kind { color: var(--olive); font: 500 19px/1.4 var(--sans); }
.peer-note { margin-top: 9px; color: var(--muted); font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }

.tabbar {
  position: sticky;
  z-index: 1;
  bottom: 0;
  margin-top: auto;
  padding: 0 max(var(--page-gutter), var(--safe-right)) calc(34px + var(--safe-bottom))
    max(var(--page-gutter), var(--safe-left));
  background: var(--fiber), #f2eadb;
}

.tabbar-inner { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2px; padding-top: 8px; border-top: 1px solid #d8cbb8; }

.tabbar button {
  display: flex;
  min-height: 54px;
  padding: 6px 4px;
  flex-direction: column;
  gap: 3px;
  align-items: center;
  border-radius: 7px;
  color: var(--muted);
  font-size: 12px;
}

.tabbar .icon { width: 24px; height: 19px; stroke-width: 1.1; }
.tabbar button[aria-current="page"], .tabbar button[aria-selected="true"], .tabbar button.is-active, .tabbar button:active { background: var(--olive-paper); color: var(--olive); }

.paper-overlay {
  position: fixed;
  z-index: 3;
  inset: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
  align-items: center;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: calc(20px + var(--safe-top)) max(17px, var(--safe-right)) calc(20px + var(--safe-bottom)) max(17px, var(--safe-left));
  background: #584a3650;
}

.letter-panel {
  position: relative;
  width: min(100%, 344px);
  max-height: calc(100vh - 40px - var(--safe-top) - var(--safe-bottom));
  max-height: calc(100dvh - 40px - var(--safe-top) - var(--safe-bottom));
  overflow: auto;
  overscroll-behavior: contain;
  padding: 24px 21px 28px;
  border: 1px solid #d7c6a9;
  border-radius: 7px;
  background: var(--fiber), var(--paper);
  box-shadow: 0 12px 31px #5a422240;
  animation: unfold 280ms var(--ease) both;
}

@keyframes unfold {
  from { opacity: 0; transform: translateY(9px); }
  to { opacity: 1; transform: translateY(0); }
}

.close-letter {
  position: absolute;
  top: 11px;
  right: 13px;
  display: grid;
  width: 44px;
  min-height: 44px;
  place-items: center;
  border-radius: 50%;
  color: var(--muted);
}

.close-letter:active { background: #ede5d5; }
.close-letter .icon { width: 16px; height: 16px; stroke-width: 1.15; }

.letter-panel-header { min-height: 83px; padding: 0 44px 14px 0; border-bottom: 1px solid #e1d2b9; }
.letter-panel-header h2 { font: 500 25px/1.45 var(--serif); overflow-wrap: anywhere; }
.letter-meta { margin-top: 8px; color: var(--muted); font-size: 15px; }
#letter-reader-date { font: 400 16px/1.4 var(--display); }

#letter-reader-body {
  min-height: 118px;
  margin-top: 16px;
  background: repeating-linear-gradient(transparent 0 35px, #eadfc9 35px 36px);
  line-height: 36px;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

#letter-reader-image, #letter-preview {
  display: block;
  width: 100%;
  height: auto;
  margin-top: 14px;
  border: 1px solid #d9cdb7;
  border-radius: 5px;
}

#letter-preview { width: auto; max-width: 100%; max-height: 178px; object-fit: contain; }

#letter-form { display: flow-root; margin-top: 19px; }
#letter-body {
  min-height: 274px;
  padding: 11px 12px 10px;
  border-color: #ded1ba;
  background: repeating-linear-gradient(transparent 0 34px, #efe4d1 34px 35px, transparent 35px 36px), #fbf5ea;
  background-origin: content-box;
  line-height: 36px;
}

.letter-attachments { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-top: 9px; }
.letter-attachments .attach { display: flex; gap: 5px; align-items: center; color: var(--olive); }
#letter-status { margin-block: 8px; }
#letter-send { display: flex; min-width: 124px; min-height: 47px; margin: 19px 0 0 auto; }

@media (max-width: 374px) {
  .opening-envelope { width: min(100%, 302px); }
  .mail-stamp { right: 17px; }
  .peer-paper { gap: 12px; }
}

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