:root {
  color-scheme: light dark;
  --paper: #f4f2ee;
  --surface: #fbfaf7;
  --ink: #342f2c;
  --muted: #716963;
  --line: #d7d0c8;
  --accent: #9c4356;
  --accent-ink: #fffaf7;
  --focus: #8d3348;
  --font-display: Georgia, "Times New Roman", serif;
  --font-body: "Trebuchet MS", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--paper);
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

button,
textarea {
  font: inherit;
}

a {
  color: inherit;
}

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

.page {
  width: min(100%, 900px);
  margin: 0 auto;
  padding: 26px clamp(18px, 5vw, 60px) 64px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-height: 36px;
  color: var(--muted);
  font-size: 12px;
}

.recipient {
  margin: 0;
  color: var(--accent);
  font-family: var(--font-display);
  font-size: 14px;
  font-style: italic;
}

.letter {
  width: min(100%, 700px);
  margin: 44px auto 0;
  padding: clamp(26px, 6vw, 64px);
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--surface);
  box-shadow: 8px 9px 0 color-mix(in srgb, var(--line) 52%, transparent);
  animation: arrive 650ms cubic-bezier(0.2, 0.75, 0.25, 1) both;
}

.letter-heading {
  max-width: 500px;
  margin: 0 auto 50px;
  text-align: center;
}

.letter-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  margin: 0 auto 23px;
  border: 1px solid var(--accent);
  border-radius: 50%;
  color: var(--accent);
  font-family: var(--font-display);
  font-size: 16px;
  font-style: italic;
  transform: rotate(-7deg);
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 14px;
  font-family: var(--font-display);
  font-size: clamp(36px, 6.5vw, 54px);
  font-weight: 400;
  letter-spacing: -0.05em;
  line-height: 1.08;
}

.letter-heading > p {
  margin-bottom: 0;
  color: var(--muted);
  font-family: var(--font-display);
  font-size: 16px;
  font-style: italic;
}

.letter-body {
  max-width: 550px;
  margin: 0 auto;
}

.letter-section {
  padding: 26px 0 28px;
  border-top: 1px solid var(--line);
}

.letter-section h2,
.reply-intro h2 {
  margin-bottom: 12px;
  font-family: var(--font-display);
  font-size: 23px;
  font-weight: 400;
  letter-spacing: -0.02em;
}

.letter-section p {
  margin-bottom: 14px;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.85;
}

.letter-section p:last-child {
  margin-bottom: 0;
}

.reply-section {
  max-width: 550px;
  margin: 14px auto 0;
  padding: 30px 0 0;
  border-top: 1px solid var(--line);
}

.reply-intro h2 {
  margin-bottom: 8px;
}

.reply-intro p {
  margin-bottom: 23px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.reply-form label {
  display: block;
  margin-bottom: 9px;
  font-size: 13px;
  font-weight: 700;
}

.reply-form textarea {
  display: block;
  width: 100%;
  min-height: 150px;
  padding: 14px 15px;
  resize: vertical;
  border: 1px solid #a69e96;
  border-radius: 3px;
  color: var(--ink);
  background: var(--surface);
  font-size: 15px;
  line-height: 1.65;
}

.reply-form textarea::placeholder {
  color: #716963;
  opacity: 1;
}

.reply-form textarea:disabled {
  opacity: 0.76;
  resize: none;
}

.reply-meta {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin: 10px 0 18px;
}

.privacy-notice,
.character-count {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.privacy-notice {
  max-width: 390px;
}

.character-count {
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
}

.reply-form button {
  min-height: 50px;
  padding: 0 22px;
  border: 1px solid var(--accent);
  border-radius: 3px;
  color: var(--accent-ink);
  background: var(--accent);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 160ms ease, background-color 160ms ease;
}

.reply-form button:hover:not(:disabled) {
  color: #fffaf7;
  background: #803549;
}

.reply-form button:active:not(:disabled) {
  transform: translateY(1px);
}

.reply-form button:disabled {
  cursor: default;
  opacity: 0.7;
}

.reply-status {
  min-height: 22px;
  margin: 12px 0 0;
  color: var(--accent);
  font-size: 13px;
  line-height: 1.5;
}

.continue-section {
  display: grid;
  justify-items: start;
  gap: 12px;
  margin-top: 18px;
}

.continue-section[hidden] {
  display: none;
}

.continue-section p {
  margin: 0;
  color: var(--ink);
  font-size: 14px;
}

.continue-link {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  padding: 0 22px;
  border: 1px solid var(--accent);
  border-radius: 3px;
  color: var(--accent-ink);
  background: var(--accent);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  transition: transform 160ms ease, background-color 160ms ease;
}

.continue-link:hover {
  color: #fffaf7;
  background: #803549;
}

.continue-link:active {
  transform: translateY(1px);
}

.letter-footer {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  max-width: 550px;
  margin: 40px auto 0;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--font-display);
  font-size: 15px;
  font-style: italic;
}

.letter-footer p {
  margin: 0;
  color: var(--ink);
}

.letter-footer span {
  flex: 0 0 auto;
}

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

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #24211f;
    --surface: #2c2825;
    --ink: #f2ebe5;
    --muted: #c0b5ac;
    --line: #514842;
    --accent: #e28a9d;
    --accent-ink: #241719;
    --focus: #f1a5b4;
  }

  .reply-form textarea {
    border-color: #8a7d74;
  }

  .reply-form textarea::placeholder {
    color: #c0b5ac;
  }
}

@media (max-width: 560px) {
  .page {
    padding: 18px 14px 42px;
  }

  .letter {
    margin-top: 28px;
    padding: 30px 22px 26px;
  }

  .letter-heading {
    margin-bottom: 35px;
  }

  .reply-meta {
    flex-direction: column;
    gap: 5px;
  }

  .reply-form button {
    width: 100%;
  }
}

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