.letter-hero {
  padding-bottom: var(--space-6);
}

.letter-hero__grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(300px, 0.9fr);
  gap: var(--space-6);
  align-items: start;
}

.letter-tool-section {
  padding-top: var(--space-7);
}

.letter-tool-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.92fr);
  gap: var(--space-5);
  align-items: start;
}

.letter-form-card,
.letter-preview-card {
  border-color: rgba(0, 87, 168, 0.12);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.99) 0%, rgba(246, 250, 253, 0.98) 100%);
}

.letter-form {
  gap: var(--space-4);
}

.letter-form .field textarea {
  width: 100%;
  min-height: 7rem;
  padding: 0.85rem 0.95rem;
  border: 1px solid var(--color-border);
  border-radius: 0.9rem;
  background: rgba(255, 255, 255, 0.98);
  color: var(--color-text);
  resize: vertical;
  transition: border-color 180ms ease, box-shadow 180ms ease, background-color 180ms ease;
}

.letter-form .field textarea:hover {
  border-color: var(--color-border-strong);
}

.letter-form .field textarea:focus {
  border-color: rgba(0, 87, 168, 0.5);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(120, 191, 232, 0.18);
  outline: none;
}

.letter-form .field input.is-invalid,
.letter-form .field textarea.is-invalid {
  border-color: rgba(163, 59, 44, 0.48);
  box-shadow: 0 0 0 4px rgba(163, 59, 44, 0.08);
}

.letter-form .form-note {
  color: var(--color-text-faint);
  font-size: 0.88rem;
  font-weight: 500;
}

.letter-form .form-feedback {
  min-height: 1.45rem;
  margin: 0;
  font-weight: 700;
}

.letter-form .form-feedback[data-state="error"] {
  color: #a33b2c;
}

.letter-form .form-feedback[data-state="success"] {
  color: #166947;
}

.letter-privacy-note {
  margin: 0;
  padding: 0.9rem 1rem;
  border: 1px solid rgba(0, 87, 168, 0.14);
  border-radius: 0.95rem;
  background: rgba(234, 244, 251, 0.68);
  color: var(--color-primary-dark);
  font-size: 0.92rem;
  font-weight: 700;
}

.letter-preview-column {
  position: sticky;
  top: 6rem;
}

.letter-preview-shell {
  overflow-x: auto;
  padding-bottom: var(--space-2);
}

.letter-preview-sheet {
  width: min(100%, 44rem);
  min-height: 58.1rem;
  margin: 0 auto;
  padding: 2.65rem 2.75rem 2.35rem;
  overflow: hidden;
  border: 1px solid rgba(15, 53, 87, 0.14);
  border-radius: 0.75rem;
  background: #fff;
  color: #1f2d3a;
  box-shadow: 0 18px 45px rgba(15, 53, 87, 0.11);
}

.letter-place-date {
  margin: 0 0 1.75rem;
  color: #405366;
  font-size: 0.98rem;
  font-weight: 700;
  text-align: right;
}

.letter-recipient {
  display: grid;
  gap: 0.2rem;
  margin-bottom: 1.45rem;
  color: #23384a;
  font-weight: 700;
}

.letter-recipient p {
  margin: 0;
}

.letter-preview-sheet h2 {
  margin: 0 0 1.35rem;
  color: #0f3557;
  font-size: 1.5rem;
  letter-spacing: 0;
  text-align: center;
  text-transform: uppercase;
}

.letter-body {
  display: grid;
  gap: 0.85rem;
  color: #2f4356;
  font-size: 1rem;
  line-height: 1.62;
  text-align: justify;
}

.letter-body p,
.letter-closing,
.letter-signature p {
  margin: 0;
}

.letter-closing {
  margin-top: 1.75rem;
  color: #2f4356;
  font-size: 1rem;
}

.letter-signature {
  display: grid;
  gap: 0.28rem;
  width: min(100%, 20rem);
  margin: 3.1rem auto 0;
  color: #24384a;
  font-size: 0.96rem;
  text-align: center;
}

.letter-signature__line {
  width: 100%;
  height: 1px;
  margin-inline: auto;
  margin-bottom: 0.45rem;
  background: #6d7f90;
}

.letter-signature p:first-of-type {
  color: #0f3557;
  font-weight: 800;
}

.letter-signature p[hidden] {
  display: none !important;
}

.letter-pdf-export-host {
  position: fixed;
  left: 0;
  top: 0;
  width: 7.8in;
  background: #fff;
  opacity: 1;
  pointer-events: none;
  z-index: 2147483647;
}

.letter-pdf-export-host .letter-preview-sheet {
  width: 7.8in;
  max-width: 7.8in;
  min-height: 10.3in;
  max-height: 10.3in;
  margin: 0;
  padding: 0.42in 0.45in 0.38in;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.letter-pdf-export-host .letter-place-date {
  margin-bottom: 0.32in;
  font-size: 10.5pt;
}

.letter-pdf-export-host .letter-recipient {
  margin-bottom: 0.26in;
  font-size: 10.5pt;
}

.letter-pdf-export-host .letter-preview-sheet h2 {
  margin-bottom: 0.26in;
  font-size: 14pt;
}

.letter-pdf-export-host .letter-body {
  gap: 0.16in;
  font-size: 10.5pt;
  line-height: 1.48;
}

.letter-pdf-export-host .letter-closing {
  margin-top: 0.32in;
  font-size: 10.5pt;
}

.letter-pdf-export-host .letter-signature {
  margin: 0.55in auto 0;
  font-size: 10pt;
}

.letter-pdf-export-host .letter-signature__line {
  margin-bottom: 0.1in;
}

body[data-page="generador-carta-recomendacion"] .page-heading h1 {
  max-width: 15ch;
}

@media (max-width: 980px) {
  .letter-hero__grid,
  .letter-tool-layout {
    grid-template-columns: 1fr;
  }

  .letter-preview-column {
    position: static;
  }
}

@media (max-width: 720px) {
  .letter-preview-sheet {
    width: min(100%, 39rem);
    min-height: auto;
    padding: 2.35rem 2rem;
  }

  .letter-body {
    font-size: 0.95rem;
    line-height: 1.58;
  }

  .letter-place-date {
    text-align: left;
  }
}

@media print {
  @page {
    size: letter;
    margin: 0.45in;
  }

  body {
    background: #fff;
  }

  body > *:not(main),
  main > *:not(.letter-tool-section),
  .letter-form-card,
  .letter-preview-card > .section-heading {
    display: none !important;
  }

  .section,
  .letter-tool-section {
    padding: 0 !important;
    background: #fff !important;
  }

  .container,
  .letter-tool-layout,
  .letter-preview-column,
  .letter-preview-card,
  .letter-preview-shell {
    display: block !important;
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    box-shadow: none !important;
    background: #fff !important;
  }

  .letter-preview-sheet {
    width: 100% !important;
    min-height: auto;
    padding: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
}
