.mailbox-page {
  min-height: 100vh;
}

.mailbox-main {
  max-width: 920px;
  min-height: calc(100vh - 170px);
  padding-top: 82px;
  padding-bottom: 72px;
}

.mailbox-intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 210px;
  align-items: center;
  gap: 28px;
}

.mailbox-intro-copy {
  min-width: 0;
}

.mailbox-main h1,
.mailbox-section-heading h2 {
  color: var(--ink);
  font-family: "Playfair Display", Georgia, serif;
  font-weight: 500;
}

.mailbox-main h1 {
  max-width: 14ch;
  margin: 8px 0 14px;
  font-size: 3.1rem;
  line-height: 1.08;
}

.mailbox-lede {
  max-width: 58ch;
  margin: 0;
  color: var(--muted, #68736e);
  font-size: 1rem;
  line-height: 1.8;
}

.mailbox-sketch {
  width: 100%;
  max-width: 210px;
  margin: 16px 0 0 auto;
  color: var(--ink);
  transform: rotate(-2deg);
}

.mailbox-open-illustration {
  position: relative;
  display: block;
  width: 100%;
  border: 0;
  padding: 0;
  color: inherit;
  background: transparent;
  cursor: pointer;
}

.mailbox-open-illustration:focus-visible {
  outline: 2px solid var(--accent, #98485d);
  outline-offset: 5px;
}

.mailbox-open-illustration:disabled {
  cursor: not-allowed;
  opacity: 0.72;
}

.mailbox-open-illustration:not(:disabled):hover svg {
  transform: translateY(-2px);
}

.mailbox-open-illustration svg {
  display: block;
  width: 100%;
  overflow: visible;
  transition: transform 160ms ease;
}

.mailbox-open-label {
  position: absolute;
  top: 40%;
  left: 48%;
  color: var(--ink);
  font-family: "DM Sans", sans-serif;
  font-size: 0.58rem;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.mailbox-sketch figcaption {
  margin-top: 2px;
  color: var(--muted, #68736e);
  font-family: "Playfair Display", Georgia, serif;
  font-size: 0.88rem;
  font-style: italic;
  text-align: center;
}

.sketch-outline {
  stroke-width: 3.2;
}

.sketch-body-fill {
  fill: #fbf8f0;
  stroke: none;
}

.sketch-offset {
  opacity: 0.3;
  transform: translate(1px, 2px);
}

.sketch-fine {
  stroke-width: 1.8;
  opacity: 0.65;
}

.sketch-flag {
  color: var(--accent, #98485d);
  stroke: currentColor;
  stroke-width: 3;
}

.sketch-stamp {
  fill: rgba(152, 72, 93, 0.12);
  stroke: var(--accent, #98485d);
  stroke-width: 1.5;
}

.sketch-stamp-line {
  fill: none;
  stroke: var(--accent, #98485d);
  stroke-linecap: round;
  stroke-width: 1.2;
}

.mailbox-controls,
.mailbox-form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 24px;
  margin-top: 30px;
}

.mailbox-controls [hidden],
.mailbox-page [hidden] {
  display: none !important;
}

.mailbox-text-button {
  border: 0;
  padding: 10px 0;
  color: var(--ink);
  background: transparent;
  font: inherit;
  text-decoration: underline;
  text-decoration-color: rgba(29, 48, 42, 0.35);
  text-underline-offset: 4px;
  cursor: pointer;
}

.mailbox-text-button:hover,
.mailbox-text-button:focus-visible {
  text-decoration-color: currentColor;
}

.mailbox-status {
  min-height: 1.5em;
  margin: 18px 0 0;
  color: var(--muted, #68736e);
  line-height: 1.6;
}

.mailbox-section-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 24px;
  margin: 64px 0 24px;
  border-bottom: 1px solid rgba(29, 48, 42, 0.2);
  padding-bottom: 18px;
}

.mailbox-section-heading h2 {
  margin: 4px 0 0;
  font-size: clamp(1.8rem, 5vw, 2.6rem);
  line-height: 1.2;
}

.mailbox-section-heading .eyebrow {
  margin: 0;
}

.mailbox-letter {
  border-bottom: 1px solid rgba(29, 48, 42, 0.16);
  padding: 24px 0 32px;
}

.mailbox-letter h3,
.mailbox-draft-button {
  margin: 0;
  color: var(--ink);
  font-family: "Playfair Display", Georgia, serif;
  font-size: 1.5rem;
  font-weight: 500;
}

.mailbox-letter-date,
.mailbox-field-hint {
  color: var(--muted, #68736e);
  font-size: 0.9rem;
  line-height: 1.6;
}

.mailbox-existing-attachments ul {
  display: grid;
  gap: 6px;
  margin: 8px 0 18px;
  padding: 0;
  list-style: none;
}

.mailbox-existing-attachments li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  border-bottom: 1px solid rgba(29, 48, 42, 0.12);
  padding: 6px 0;
  color: var(--muted, #68736e);
  font-size: 0.9rem;
}

.mailbox-letter-body {
  margin: 20px 0 0;
  color: var(--ink);
  font-family: "Playfair Display", Georgia, serif;
  font-size: 1.1rem;
  line-height: 1.9;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.mailbox-attachment {
  display: block;
  width: min(100%, 520px);
  max-height: 620px;
  margin: 18px 0;
  border: 1px solid rgba(29, 48, 42, 0.16);
  background: #eee7dc;
  object-fit: contain;
}

.mailbox-report-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  margin-top: 20px;
}

.mailbox-report-form select {
  min-height: 38px;
  border: 1px solid rgba(29, 48, 42, 0.25);
  border-radius: 2px;
  padding: 0 10px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.46);
  font: inherit;
}

.mailbox-empty {
  margin: 0;
  padding: 22px 0;
  color: var(--muted, #68736e);
  line-height: 1.7;
}

.mailbox-compose form {
  max-width: 680px;
}

.mailbox-envelope-stage {
  max-width: 720px;
}

.mailbox-envelope {
  position: relative;
  width: min(100%, 560px);
  aspect-ratio: 1.72 / 1;
  margin: 32px auto 18px;
  overflow: hidden;
  border: 1px solid rgba(29, 48, 42, 0.38);
  background: #eee7dc;
  box-shadow: 0 12px 26px rgba(29, 48, 42, 0.09);
  perspective: 700px;
}

.mailbox-envelope-letter {
  position: absolute;
  z-index: 1;
  top: 7%;
  left: 11%;
  width: 78%;
  height: 84%;
  border: 1px solid rgba(29, 48, 42, 0.14);
  background: #fffdf8;
  transition: transform 430ms ease;
}

.mailbox-envelope-letter::before,
.mailbox-envelope-letter::after {
  position: absolute;
  left: 12%;
  height: 1px;
  background: rgba(29, 48, 42, 0.2);
  content: "";
}

.mailbox-envelope-letter::before {
  top: 27%;
  width: 68%;
}

.mailbox-envelope-letter::after {
  top: 35%;
  width: 52%;
}

.mailbox-envelope-flap {
  position: absolute;
  z-index: 3;
  top: -1px;
  left: 0;
  width: 100%;
  height: 64%;
  background: #f6f0e6;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform: rotateX(180deg);
  transform-origin: 50% 0;
  backface-visibility: hidden;
  transition: transform 430ms cubic-bezier(0.22, 0.7, 0.25, 1);
}

.mailbox-envelope::after {
  position: absolute;
  z-index: 4;
  inset: 0;
  background: #f2eadf;
  clip-path: polygon(0 0, 50% 55%, 100% 0, 100% 100%, 0 100%);
  content: "";
}

.mailbox-envelope.is-closing .mailbox-envelope-flap,
.mailbox-envelope.is-closed .mailbox-envelope-flap,
.mailbox-envelope.is-sealing .mailbox-envelope-flap,
.mailbox-envelope.is-sealed .mailbox-envelope-flap {
  transform: rotateX(0deg);
}

.mailbox-envelope.is-closing .mailbox-envelope-letter,
.mailbox-envelope.is-closed .mailbox-envelope-letter,
.mailbox-envelope.is-sealing .mailbox-envelope-letter,
.mailbox-envelope.is-sealed .mailbox-envelope-letter {
  transform: translateY(-9%);
}

.mailbox-envelope-addresses {
  position: absolute;
  z-index: 5;
  top: 42%;
  left: 12%;
  display: grid;
  gap: 7px;
  max-width: 76%;
  color: var(--ink);
}

.mailbox-envelope-addresses p {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 8px;
  margin: 0;
  font-size: 0.78rem;
}

.mailbox-envelope-addresses span {
  color: var(--muted, #68736e);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.mailbox-envelope-addresses strong {
  overflow: hidden;
  font-family: "Playfair Display", Georgia, serif;
  font-size: clamp(0.84rem, 2.4vw, 1.1rem);
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mailbox-wax-seal {
  position: absolute;
  z-index: 6;
  top: 53%;
  left: 50%;
  display: grid;
  width: clamp(38px, 9vw, 54px);
  aspect-ratio: 1;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.46);
  border-radius: 50%;
  color: #fffaf3;
  background: var(--accent, #98485d);
  box-shadow: 0 2px 5px rgba(58, 33, 35, 0.22);
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.25) rotate(-18deg);
  pointer-events: none;
}

.mailbox-wax-seal span {
  font-family: "Playfair Display", Georgia, serif;
  font-size: 1.3rem;
  font-style: italic;
}

.mailbox-envelope.is-sealing .mailbox-wax-seal {
  animation: vera-seal-stamp 520ms cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

.mailbox-envelope.is-sealed .mailbox-wax-seal {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1) rotate(-8deg);
}

@keyframes vera-seal-stamp {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(2.1) rotate(-28deg); }
  72% { opacity: 1; transform: translate(-50%, -50%) scale(0.88) rotate(-5deg); }
  100% { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(-8deg); }
}

.mailbox-envelope-note {
  margin: 0;
  color: var(--muted, #68736e);
  font-family: "Playfair Display", Georgia, serif;
  font-style: italic;
  line-height: 1.6;
  text-align: center;
}

.mailbox-envelope-actions {
  justify-content: center;
}

.mailbox-field {
  display: block;
  margin: 20px 0;
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 600;
}

.mailbox-input-hint {
  display: block;
  margin-top: 6px;
  color: var(--muted, #68736e);
  font-size: 0.82rem;
  font-weight: 400;
  line-height: 1.55;
}

.mailbox-field input,
.mailbox-field textarea {
  display: block;
  width: 100%;
  margin-top: 8px;
  border: 1px solid rgba(29, 48, 42, 0.25);
  border-radius: 2px;
  padding: 12px 14px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.46);
  font: inherit;
  font-weight: 400;
}

.mailbox-field input:focus,
.mailbox-field textarea:focus {
  outline: 2px solid var(--accent, #98485d);
  outline-offset: 2px;
}

.mailbox-field textarea {
  min-height: 280px;
  resize: vertical;
  font-family: "Playfair Display", Georgia, serif;
  font-size: 1.08rem;
  line-height: 1.85;
}

.mailbox-field-hint {
  margin: -10px 0 0;
}

.mailbox-draft-list {
  display: grid;
  gap: 0;
}

.mailbox-draft-button {
  display: block;
  width: 100%;
  border: 0;
  border-bottom: 1px solid rgba(29, 48, 42, 0.16);
  padding: 20px 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.mailbox-draft-button span {
  display: block;
  margin-top: 5px;
  color: var(--muted, #68736e);
  font-family: "DM Sans", sans-serif;
  font-size: 0.88rem;
}

@media (max-width: 600px) {
  .mailbox-main {
    padding-top: 68px;
    padding-bottom: 56px;
  }

  .mailbox-main h1 {
    font-size: 2.35rem;
  }

  .mailbox-intro {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }

  .mailbox-sketch {
    width: min(100%, 165px);
    margin: 6px 0 0 auto;
  }

  .mailbox-section-heading {
    align-items: start;
    flex-direction: column;
    gap: 8px;
    margin-top: 48px;
  }

  .mailbox-field textarea {
    min-height: 240px;
  }

  .mailbox-envelope {
    margin-top: 24px;
  }

  .mailbox-envelope-addresses {
    top: 40%;
    left: 8%;
    gap: 4px;
    max-width: 82%;
  }

  .mailbox-envelope-addresses p {
    grid-template-columns: 36px minmax(0, 1fr);
    gap: 4px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .mailbox-envelope-letter,
  .mailbox-envelope-flap,
  .mailbox-open-illustration svg {
    transition-duration: 0.01ms;
  }

  .mailbox-envelope.is-sealing .mailbox-wax-seal {
    animation-duration: 0.01ms;
    animation-delay: 0ms;
  }
}