:root {
  color: #26231f;
  background: #f8f7f3;
  font-family: "Yu Mincho", "Hiragino Mincho ProN", "Noto Serif JP", "MS PMincho", serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(90deg, transparent calc(50% - 1px), rgba(97, 84, 63, .045) calc(50% - 1px), rgba(97, 84, 63, .045) 50%, transparent 50%),
    #f8f7f3;
}

button { font: inherit; }

button:focus-visible {
  outline: 2px solid #4f4030;
  outline-offset: 5px;
}

.page {
  display: grid;
  min-height: 100vh;
  align-content: center;
  width: min(100%, 760px);
  margin: 0 auto;
  padding: 48px 24px;
}

.page-header {
  margin-bottom: clamp(42px, 10vw, 82px);
  text-align: center;
}

h1 {
  margin: 0;
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 500;
  letter-spacing: .16em;
}

.letters {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(20px, 7vw, 72px);
  width: min(100%, 570px);
  margin: 0 auto;
}

.letter {
  display: grid;
  gap: 16px;
  padding: 0;
  border: 0;
  color: inherit;
  background: transparent;
  cursor: pointer;
}

.letter:hover .envelope,
.letter:focus-visible .envelope {
  transform: translateY(-5px) rotate(-1deg);
  box-shadow: 0 16px 24px rgba(47, 38, 26, .13);
}

.letter:nth-child(2):hover .envelope,
.letter:nth-child(2):focus-visible .envelope {
  transform: translateY(-5px) rotate(1deg);
}

.envelope {
  display: block;
  aspect-ratio: 1.44 / 1;
  box-shadow: 0 8px 18px rgba(47, 38, 26, .09);
  transition: transform .2s ease, box-shadow .2s ease;
}

.letter-name {
  font-size: 1rem;
  letter-spacing: .12em;
}

dialog {
  width: min(calc(100% - 32px), 780px);
  max-height: min(86vh, 900px);
  padding: 0;
  border: 1px solid #cfc6b7;
  color: #26231f;
  background: #fbfaf6;
  box-shadow: 0 20px 60px rgba(35, 27, 18, .24);
}

dialog::backdrop {
  background: rgba(43, 35, 25, .34);
  backdrop-filter: blur(2px);
}

.dialog-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  max-height: min(86vh, 900px);
}

.dialog-header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 24px 18px;
  border-bottom: 1px solid #ded7cb;
  background: #fbfaf6;
}

.dialog-author {
  margin: 0 0 6px;
  font-size: .92rem;
  letter-spacing: .14em;
}

h2 {
  margin: 0;
  font-size: clamp(1.25rem, 4vw, 1.65rem);
  font-weight: 500;
  letter-spacing: .08em;
}

.dialog-header form { margin: 0; }

.close-button {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  padding: 0;
  border: 1px solid #bfb4a3;
  border-radius: 50%;
  color: inherit;
  background: transparent;
  cursor: pointer;
  font-size: 1.5rem;
  line-height: 1;
}

.close-button:hover { background: #f0ece3; }

.dialog-body {
  overflow-y: auto;
  padding: clamp(28px, 6vw, 56px) clamp(22px, 7vw, 72px) clamp(38px, 8vw, 72px);
  font-size: max(1rem, 16px);
  line-height: 2.05;
  letter-spacing: .035em;
  overscroll-behavior: contain;
}

.dialog-body p {
  margin: 0 0 1.5em;
  white-space: pre-wrap;
}

.dialog-body p:last-child { margin-bottom: 0; }

@media (max-width: 430px) {
  .page { padding-inline: 20px; }
  .letters { gap: 18px; }
  .letter-name { font-size: .9rem; }
  .dialog-header { padding: 17px 18px 14px; }
  .dialog-body { line-height: 1.95; }
}

@media (prefers-reduced-motion: reduce) {
  .envelope { transition: none; }
}
