:root {
  --ink: #1c1915;
  --muted: #6d645b;
  --paper: #f3ecdf;
  --card: #fbf7f0;
  --line: #e2d8c8;
  --seal: #8f2d2a;
  --moss: #234237;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  padding: 0 40px;
  overflow-x: clip;
  background:
    radial-gradient(900px 420px at 80% -10%, #fffaf2 0%, transparent 60%),
    var(--paper);
  color: var(--ink);
  font-family: Outfit, "Segoe UI", sans-serif;
}

.nav, .stage, .rail, .how, .letters, .foot {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
}

.nav {
  height: 84px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 15px;
}

.brand {
  font-family: Fraunces, Georgia, serif;
  font-size: 22px;
  font-weight: 620;
  letter-spacing: -0.03em;
  color: inherit;
  text-decoration: none;
}

.nav a { color: var(--muted); text-decoration: none; margin-left: 28px; }
.nav a:hover { color: var(--ink); }

.stage {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 64px;
  align-items: center;
  min-height: calc(100vh - 168px);
}

h1 {
  margin: 0;
  font-family: Fraunces, Georgia, serif;
  font-weight: 500;
  font-size: 84px;
  line-height: 0.92;
  letter-spacing: -0.045em;
}

h1 em { font-style: italic; font-weight: 500; }

.lede {
  max-width: 520px;
  margin: 28px 0 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.5;
}

button, .text-button {
  font: 500 16px Outfit, sans-serif;
  cursor: pointer;
}

#seal-button {
  border: 0;
  background: var(--moss);
  color: #f6f1e7;
  padding: 16px 22px;
  border-radius: 999px;
}

#seal-button { margin-top: 32px; }
#seal-button:disabled { opacity: 0.55; cursor: default; }

.fine, .error, .letters-lede, .empty { color: var(--muted); font-size: 13px; }
.fine { margin: 14px 0 0; }
.error { margin: 10px 0 0; color: var(--seal); }

.letter {
  background: var(--card);
  border: 1px solid #efe6d8;
  border-radius: 18px;
  box-shadow: 0 30px 70px rgba(70, 48, 20, 0.08);
  padding: 28px 28px 26px;
  transform: rotate(1.25deg);
  animation: settle 1.1s ease both;
}

.letter.is-sealed { transform: rotate(0deg); transition: transform 0.6s ease; }

.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
}

.row span { color: var(--muted); }

.row input[type="email"] {
  border: 0;
  background: transparent;
  font: 500 15px Outfit, sans-serif;
  color: var(--ink);
  text-align: right;
  flex: 1;
  width: auto;
  min-width: 0;
  padding: 0;
}

.date-field { position: relative; display: inline-flex; justify-content: flex-end; min-width: 0; }
.date-field.is-open { z-index: 5; }
.date-parts { display: inline-flex; align-items: baseline; gap: 0.42em; white-space: nowrap; }
.date-parts button {
  margin: 0;
  padding: 0 0 1px;
  border: 0;
  border-bottom: 1px solid rgba(143, 45, 42, 0.45);
  background: transparent;
  color: var(--ink);
  font: 500 15px Outfit, sans-serif;
  line-height: 1.25;
}
.date-parts button.is-open { color: var(--seal); border-bottom-color: var(--seal); }
.date-field.is-locked .date-parts button {
  border-bottom-color: transparent;
  cursor: default;
}
.date-native {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  border: 0;
}
.calendar {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  z-index: 4;
  width: 292px;
  max-width: calc(100vw - 48px);
  padding: 8px;
  background: var(--card);
  border: 1px solid #efe6d8;
  border-radius: 16px;
  box-shadow: 0 22px 50px rgba(70, 48, 20, 0.14);
}
.calendar.is-years { width: min(400px, calc(100vw - 48px)); }
.cal-years, .cal-months, .cal-days { display: grid; gap: 4px; }
.cal-years {
  grid-template-columns: repeat(6, 1fr);
  max-height: min(420px, calc(100vh - 220px));
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}
.cal-months { grid-template-columns: 1fr 1fr; }
.cal-days { grid-template-columns: repeat(7, 1fr); gap: 2px; }
.calendar button {
  border: 0;
  background: transparent;
  color: var(--ink);
  border-radius: 8px;
  font: 500 15px Outfit, sans-serif;
  padding: 8px 4px;
  text-align: center;
}
.cal-years button, .cal-months button {
  font-family: Fraunces, Georgia, serif;
  font-size: 17px;
  font-weight: 500;
}
.cal-years button { padding: 7px 0; font-size: 16px; white-space: nowrap; }
.cal-months button { text-align: left; padding: 8px 12px; }
.cal-days .dow { color: var(--muted); font-size: 11px; text-align: center; padding: 4px 0 2px; }
.calendar button.is-selected { background: var(--moss); color: #f6f1e7; }
.calendar button:disabled { color: #c8bfb2; cursor: default; }
.calendar button:hover:not(:disabled):not(.is-selected) { background: #f0e6d6; }

.body {
  display: block;
  width: 100%;
  min-height: 168px;
  margin: 22px 0 8px;
  padding: 0;
  border: 0;
  resize: none;
  background: transparent;
  color: var(--ink);
  font-family: Fraunces, Georgia, serif;
  font-size: 28px;
  line-height: 1.25;
  letter-spacing: -0.03em;
  min-width: 0;
}

.letter :focus-visible, button:focus-visible, .nav a:focus-visible {
  outline: 2px solid var(--moss);
  outline-offset: 3px;
}

.seal-row { display: flex; justify-content: flex-end; }

.seal {
  width: 74px;
  height: 74px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #c45a52, var(--seal) 55%, #6d1d1b);
  color: #f8e7d2;
  display: grid;
  place-items: center;
  font-family: Fraunces, Georgia, serif;
  font-size: 13px;
  letter-spacing: 0.14em;
  box-shadow: inset 0 0 0 6px rgba(255, 220, 180, 0.18), 0 10px 20px rgba(120, 30, 24, 0.18);
  animation: pulse 3.6s ease-in-out infinite;
}

.letter.is-sealed .seal { animation: stamp 0.45s ease both; }

.rail {
  position: relative;
  z-index: 0;
  height: 84px;
  display: flex;
  align-items: center;
  gap: 18px;
  color: var(--muted);
  font-size: 13px;
}

.track { position: relative; flex: 1; height: 2px; background: #ddd3c4; }

.track i {
  position: absolute;
  top: -5px;
  left: 18%;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--seal);
  animation: travel 7s ease-in-out infinite;
}

.track i.is-set { animation: none; }

.how, .letters { padding: 28px 0 12px; }

h2 {
  margin: 0 0 28px;
  font-family: Fraunces, Georgia, serif;
  font-weight: 500;
  font-size: 40px;
  letter-spacing: -0.04em;
}

.how ol {
  list-style: none;
  margin: 0;
  padding: 28px 0 8px;
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 32px;
}

.how em {
  font-family: Fraunces, Georgia, serif;
  font-style: italic;
  color: var(--seal);
  font-size: 18px;
}

.how strong, .letter-item strong { display: block; margin: 8px 0; font-weight: 500; font-size: 18px; }
.how p, .letter-item p { margin: 0; color: var(--muted); line-height: 1.45; }

.letters-lede { margin: -12px 0 22px; font-size: 16px; }

.sign-in {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 0 0 8px;
}

.sign-in label {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  flex: 1 1 280px;
  color: var(--muted);
}

.sign-in[hidden], #sign-out[hidden], #sign-note[hidden] { display: none; }

.sign-in input {
  width: 240px;
  flex: 1 1 180px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  font: 360 16px Outfit, sans-serif;
  padding: 10px 0;
}

.sign-in button, .gate a {
  border: 0;
  background: var(--moss);
  color: #f6f1e7;
  padding: 12px 18px;
  border-radius: 999px;
  text-decoration: none;
}

.sign-note { margin: 0 0 18px; color: var(--muted); }
.sign-note a { color: var(--seal); }

#sign-out { margin: -8px 0 12px; }

.gate {
  min-height: 70vh;
  display: grid;
  place-items: center;
  text-align: center;
  font-family: Fraunces, Georgia, serif;
  font-size: 28px;
}

.gate a { font-family: Outfit, sans-serif; font-size: 16px; }

#letter-list { list-style: none; margin: 0; padding: 0; }

.letter-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 24px;
  padding: 18px 0;
  border-top: 1px solid var(--line);
}

.letter-item p { grid-column: 1; }
.letter-item .text-button { grid-column: 2; grid-row: 1; }

.text-button {
  align-self: center;
  border: 0;
  background: transparent;
  color: var(--seal);
  padding: 8px 0;
}

.foot {
  padding: 48px 0 36px;
  color: var(--muted);
  font-family: Fraunces, Georgia, serif;
  font-size: 18px;
}

@keyframes settle { from { opacity: 0; transform: translateY(16px) rotate(1.25deg); } }
@keyframes pulse { 50% { transform: scale(1.04); } }
@keyframes stamp { from { transform: scale(1.35); } to { transform: scale(1); } }
@keyframes travel { 50% { left: 78%; } }

@media (max-width: 860px) {
  body { padding: 0 20px; }
  .nav { gap: 12px; }
  .nav-links { display: flex; gap: 16px; }
  .nav a { margin-left: 0; font-size: 14px; }
  .stage > *, .letter, .row, .body, .how, .letters { min-width: 0; max-width: 100%; }
  .stage { grid-template-columns: 1fr; gap: 36px; min-height: 0; padding-bottom: 12px; }
  h1 { font-size: 52px; }
  .letter { transform: none; }
  .how ol { grid-template-columns: 1fr; gap: 22px; }
  .sign-in { flex-wrap: wrap; }
  .sign-in input { width: 100%; }
  .body { font-size: 24px; min-height: 120px; }
}

@media (prefers-reduced-motion: reduce) {
  .letter, .seal, .track i { animation: none; }
  html { scroll-behavior: auto; }
}
