@font-face {
  font-family: 'Instrument Serif';
  src: url('/fonts/instrument-serif.woff2') format('woff2');
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Instrument Serif';
  src: url('/fonts/instrument-serif-italic.woff2') format('woff2');
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: 'DM Sans';
  src: url('/fonts/dm-sans.woff2') format('woff2');
  font-style: normal;
  font-weight: 100 1000;
  font-display: swap;
}

:root {
  color-scheme: light;
  --bg: #fbf6ee;
  --white: #fffdf8;
  --ink: #332521;
  --muted: #665650;
  --wine: #782e39;
  --wine-deep: #5e202a;
  --blush: #f3e0db;
  --border: #d9c7bb;
  --focus: #922745;
  --display: 'Instrument Serif', Georgia, 'Times New Roman', serif;
  --body: 'DM Sans', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}
* { box-sizing: border-box; }
body {
  min-height: 100vh;
  margin: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 1rem;
  line-height: 1.55;
}
main { flex: 1; }
main:focus { outline: none; }
::selection { background: #ebccd1; }
a { color: var(--wine); text-underline-offset: 0.2em; }
button, input, select, textarea { font: inherit; }
button, summary { cursor: pointer; }
button:disabled { cursor: default; opacity: .65; }
a, button, input, select, textarea { -webkit-tap-highlight-color: #782e3926; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 4px; }
[hidden] { display: none !important; }

.surface-width { width: min(calc(100% - 40px), 1120px); margin-inline: auto; }
.site-header { border-bottom: 1px solid #e7d9cf; }
.site-nav {
  width: min(calc(100% - 40px), 1120px);
  min-height: 67px;
  margin-inline: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--wine-deep);
  font-family: var(--display);
  font-size: clamp(1.45rem, 5.4vw, 1.85rem);
  line-height: 1;
  text-decoration: none;
}
.brand-envelope {
  position: relative;
  width: 21px;
  height: 15px;
  border: 1px solid currentColor;
  border-radius: 2px;
  display: inline-block;
  overflow: hidden;
  flex: none;
}
.brand-envelope::after {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  inset: -8px auto auto 2px;
  border-right: 1px solid currentColor;
  border-bottom: 1px solid currentColor;
  border-radius: 2px;
  transform: rotate(45deg);
}
.subtle-link {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  text-decoration-color: transparent;
  font-size: .86rem;
  font-weight: 650;
}
.subtle-link:hover { text-decoration-color: currentColor; }
.skip-link {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 10;
  padding: 8px 14px;
  background: var(--white);
  transform: translateY(-150%);
}
.skip-link:focus { transform: none; }

.home-hero {
  display: grid;
  align-items: center;
  gap: 34px;
  padding-block: 43px 54px;
}
.hero-copy h1 {
  margin: 0;
  color: var(--wine-deep);
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(3.75rem, 11.8vw, 5.6rem);
  line-height: .94;
  letter-spacing: -.035em;
}
.hero-copy h1 em { color: var(--wine); font-weight: 400; }
.hero-copy p {
  max-width: 30rem;
  margin-block: 24px 25px;
  color: var(--muted);
  font-size: clamp(1.03rem, 2vw, 1.17rem);
}
.hero-photo {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 5;
  height: auto;
  max-height: 570px;
  object-fit: cover;
  border-radius: 5px;
  background: #e7d1c2;
}
.actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}
.button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 9px;
  min-height: 48px;
  padding: 10px 17px;
  border: 1px solid var(--wine);
  border-radius: 5px;
  background: var(--wine);
  color: var(--white);
  font-size: .92rem;
  font-weight: 700;
  line-height: 1.35;
  text-decoration: none;
  text-align: center;
}
.button:hover { background: var(--wine-deep); border-color: var(--wine-deep); }
.button-light { background: transparent; border-color: #bd9d94; color: var(--wine-deep); }
.button-light:hover { background: var(--blush); border-color: #bd9d94; }
.button-small { min-height: 44px; padding-inline: 13px; }
.text-button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  border: 0;
  background: none;
  color: var(--wine);
  text-decoration: underline;
  text-underline-offset: .2em;
  padding: 0 4px;
}
.how-it-works {
  padding-block: 27px 56px;
  border-top: 1px solid var(--border);
}
.how-it-works h2, .page-title, .section-title, .letter-title {
  margin: 0;
  color: var(--wine-deep);
  font-family: var(--display);
  font-weight: 400;
  letter-spacing: -.025em;
  line-height: 1.02;
}
.how-it-works h2 { font-size: 2.65rem; }
.steps {
  display: grid;
  gap: 0;
  list-style: none;
  counter-reset: steps;
  margin: 18px 0 0;
  padding: 0;
}
.steps li {
  counter-increment: steps;
  display: grid;
  grid-template-columns: 32px 1fr;
  padding-block: 11px;
}
.steps li::before {
  content: '0' counter(steps);
  grid-row: span 2;
  color: var(--wine);
  font-family: var(--display);
  font-size: 1.24rem;
  line-height: 1.3;
}
.steps strong { font-size: .98rem; }
.steps p { margin: 2px 0 0; color: var(--muted); font-size: .93rem; }

.site-footer {
  min-height: 75px;
  border-top: 1px solid #e7d9cf;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  padding-block: 13px;
  color: var(--muted);
  font-size: .8rem;
}
.site-footer span:first-child { color: var(--wine); font-weight: 650; }

.page {
  width: min(calc(100% - 40px), 860px);
  margin-inline: auto;
  padding-block: 41px 58px;
}
.page-narrow { max-width: 510px; }
.page-header { margin-bottom: 26px; }
.page-title { font-size: clamp(3.05rem, 9.5vw, 5rem); overflow-wrap: anywhere; }
.page-header p { margin: 12px 0 0; color: var(--muted); }
.section-title { font-size: 2.2rem; }
.letter-title { font-size: 2.65rem; }

.form-card, .access-panel, .manage-panel, .note-panel {
  padding: clamp(17px, 4vw, 25px);
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--white);
}
.field { display: grid; gap: 6px; min-width: 0; margin-bottom: 17px; }
.field label, fieldset legend { font-size: .94rem; font-weight: 750; }
.field small, .form-note, .char-count { color: var(--muted); font-size: .84rem; }
.optional { color: var(--muted); font-weight: 450; }
.field input, .field select, .field textarea {
  width: 100%;
  min-height: 47px;
  padding: 10px 11px;
  border: 1px solid #bda99a;
  border-radius: 4px;
  background: #fffdfb;
  color: var(--ink);
  font-size: 1rem;
}
.field input, .field textarea { scroll-margin: 12px; }
.field textarea { min-height: 150px; resize: vertical; }
.field input::placeholder, .field textarea::placeholder { color: #77675f; }
.field .code-input { font-family: ui-monospace, monospace; }
.field-split {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  gap: 12px;
}
fieldset {
  padding: 0;
  margin: 0;
  border: 0;
  min-inline-size: 0;
}
.birthday-fields legend { margin-bottom: 6px; }
.birthday-fields label { font-weight: 500; color: var(--muted); font-size: .84rem; }
.form-note { margin: 13px 0 0; }
.error {
  background: #fae8e7;
  border-left: 2px solid var(--wine);
  color: #641e2a;
  margin: 0 0 15px;
  padding: 9px 11px;
  font-size: .91rem;
}
.error:empty, .status:empty { display: none; }
.status { margin: 0; font-size: .9rem; color: var(--wine-deep); }
.copy-field { margin: 0; }
.copy-row { display: flex; gap: 7px; align-items: stretch; }
.copy-row input { min-width: 0; padding: 6px 8px; }
.copy-row button { flex: none; }
.copy-panel { display: grid; gap: 13px; align-items: start; }
.access-panel p, .manage-panel p, .note-panel p { margin: 8px 0 15px; color: var(--muted); }
.access-panel { margin-bottom: 13px; }
.access-panel .status { margin-top: 7px; }
.manage-panel { margin-top: 24px; }
.manage-panel summary { min-height: 35px; display: list-item; color: var(--wine); }
.manage-panel[open] summary { margin-bottom: 10px; }
.manage-panel > .field { margin-top: 9px; }
.manage-panel > hr { border: 0; border-top: 1px solid var(--border); margin-block: 16px 12px; }
.owner-action { margin-bottom: 24px; }
.dashboard-section { margin-top: 26px; }
.char-count { justify-self: end; }

.envelope-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-block: 13px 0;
  padding: 0;
  list-style: none;
}
.envelope-grid li { min-width: 0; }
.envelope-card {
  position: relative;
  display: flex;
  width: 100%;
  min-height: 123px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 12px 6px;
  border: 1px solid #dfc9c0;
  border-radius: 5px;
  background: #f8ebe3;
  color: var(--ink);
  font: inherit;
  text-align: center;
}
button.envelope-card:hover { border-color: var(--wine); background: #f4e1d9; }
.envelope-card.is-ready { border-color: #c79797; background: var(--blush); }
.envelope-card.is-selected {
  border-color: var(--wine);
  box-shadow: inset 0 0 0 1px var(--wine);
  background: var(--blush);
}
.envelope-card.is-muted { background: #f8f2e9; color: var(--muted); }
.envelope-day {
  margin-top: 3px;
  font-weight: 750;
  font-size: .97rem;
  line-height: 1.3;
}
.envelope-status { color: var(--muted); font-size: .79rem; }
.envelope-card.is-ready .envelope-status, .envelope-card.is-selected .envelope-status { color: var(--wine-deep); }
.paper-envelope {
  --envelope-top: #f9e8da;
  --envelope-left: #ead1c2;
  --envelope-bottom: #f3ddce;
  position: relative;
  display: block;
  width: 55px;
  height: 36px;
  flex-shrink: 0;
  overflow: hidden;
  background: linear-gradient(130deg, var(--envelope-left) 49.5%, #c7ab9c 50%, #f7e7dc 51%);
  border: 1px solid #bea294;
  border-radius: 3px;
}
.paper-envelope::before, .paper-envelope::after {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  inset: 0;
}
.paper-envelope::before {
  clip-path: polygon(0 100%, 50% 32%, 100% 100%);
  background: var(--envelope-bottom);
}
.paper-envelope::after {
  clip-path: polygon(0 0, 100% 0, 50% 72%);
  background: var(--envelope-top);
}
.is-muted .paper-envelope {
  --envelope-top: #f4e8db;
  --envelope-left: #e9dac9;
  --envelope-bottom: #eee1d3;
}
.envelope-seal {
  position: absolute;
  z-index: 1;
  inset: 48% auto auto 50%;
  width: 12px;
  height: 12px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--wine);
  color: #ffd9c9;
  transform: translateX(-50%);
  font-size: .5rem;
  line-height: 1;
}
.stamp-actions { margin-top: 22px; }
.writer { margin-top: 18px; }
.writer .section-title { margin-bottom: 17px; }

dialog {
  width: min(calc(100% - 28px), 590px);
  max-height: calc(100% - 28px);
  max-height: calc(100dvh - 28px);
  padding: 13px;
  border: 1px solid #c5a499;
  border-radius: 7px;
  background: #f7e6db;
  color: var(--ink);
  overflow: auto;
}
dialog::backdrop { background: #382321ad; }
.letter-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  padding-inline: 5px;
  color: var(--wine-deep);
  font-size: .89rem;
  font-weight: 650;
}
.letter-toolbar form { margin: 0; }
.letter-paper {
  min-height: 210px;
  padding: clamp(21px, 5vw, 38px);
  background: #fffbf0;
  border: 1px solid #d5bcae;
  box-shadow: 0 5px 14px #53281b12;
}
.letter-paper.is-revealing { animation: reveal-letter .45s ease-out both; }
.letter-body {
  margin: 16px 0 0;
  font-family: var(--display);
  font-size: clamp(1.45rem, 4.75vw, 1.85rem);
  line-height: 1.28;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
.letter-signature {
  margin: 20px 0 0;
  color: var(--wine-deep);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.letter-footer {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-top: 6px;
  padding-inline: 5px;
}
.letter-footer .status { font-size: .82rem; }
@keyframes reveal-letter {
  from { opacity: 0; transform: translateY(14px) scale(.985); clip-path: inset(0 0 40% 0); }
  to { opacity: 1; transform: none; clip-path: inset(0); }
}

@media (min-width: 760px) {
  .site-nav { min-height: 76px; }
  .surface-width, .site-nav { width: min(calc(100% - 72px), 1120px); }
  .home-hero {
    grid-template-columns: 1fr .84fr;
    gap: clamp(44px, 7vw, 106px);
    padding-block: 55px 67px;
  }
  .hero-copy h1 { font-size: clamp(5.1rem, 8.4vw, 7.7rem); }
  .hero-copy p { margin-block: 27px 31px; }
  .hero-photo { max-height: 520px; }
  .button { padding-inline: 20px; }
  .button-small { padding-inline: 13px; }
  .how-it-works { padding-block: 26px 54px; }
  .steps { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 36px; }
  .site-footer { flex-direction: row; justify-content: space-between; align-items: center; }
  .page { padding-block: 58px 70px; }
  .page-header { margin-bottom: 30px; }
  .envelope-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
  .envelope-card { min-height: 141px; }
  .paper-envelope { width: 65px; height: 42px; }
  .envelope-seal { width: 14px; height: 14px; font-size: .55rem; }
}
@media (prefers-reduced-motion: reduce) {
  .letter-paper.is-revealing { animation: none; }
}
