:root {
  --ink: #1f2328;
  --muted: #5d6572;
  --line: #cfd6df;
  --panel: #ffffff;
  --page: #ffffff;
  --bg: #eef2f6;
  --accent: #bd1f2d;
  --accent-dark: #8f1721;
  --focus: #246bfe;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Calibri, Arial, Helvetica, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(340px, 460px) minmax(560px, 1fr);
  min-height: 100vh;
}

.form-panel {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  padding: 24px;
  background: var(--panel);
  border-right: 1px solid var(--line);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.15;
}

.primary-action {
  min-height: 42px;
  padding: 0 16px;
  border: 0;
  border-radius: 6px;
  color: #fff;
  background: var(--accent);
  cursor: pointer;
  white-space: nowrap;
}

.primary-action:hover {
  background: var(--accent-dark);
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.span-2 {
  grid-column: span 2;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 11px;
  color: var(--ink);
  background: #fff;
  font-size: 14px;
  font-weight: 400;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
  border-color: transparent;
}

.preview-panel {
  padding: 30px;
  overflow: auto;
}

.letter-page {
  width: 210mm;
  height: 297mm;
  margin: 0 auto;
  padding: 22mm 25.4mm 18mm;
  background: var(--page);
  box-shadow: 0 20px 50px rgba(24, 33, 45, 0.15);
  font-family: Calibri, Arial, sans-serif;
  font-size: 11pt;
  font-weight: 400;
  line-height: 1.22;
  overflow: hidden;
}

.letter-page p {
  margin: 0 0 12px;
}

.recipient-block {
  margin: 0 0 18px;
}

.recipient-block p {
  margin-bottom: 0;
  white-space: pre-line;
}

.strong,
.subject {
  font-weight: 700;
}

.subject {
  margin: 18px 0 20px;
  text-align: center;
  text-decoration: underline;
}

.contact-block {
  margin: 2px 0 24px;
}

.contact-block p {
  margin-bottom: 4px;
}

.signature-block {
  margin-top: 28px;
}

.signature-block p {
  margin-bottom: 4px;
}

.signature-space {
  width: 54mm;
  height: 20mm;
  margin-top: 6mm;
  border-bottom: 1px solid #1f2328;
}

.signature-name {
  margin-top: 4px;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .form-panel {
    position: relative;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 18px;
  }

  .preview-panel {
    padding: 18px;
    overflow: auto;
  }

  .letter-page {
    width: 210mm;
    height: 297mm;
  }
}

@media (max-width: 620px) {
  .panel-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  h1 {
    font-size: 22px;
  }

  .primary-action {
    width: 100%;
  }

  .field-grid {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: span 1;
  }
}

@media print {
  html,
  body {
    width: 210mm;
    height: 297mm;
    overflow: hidden;
    background: #fff;
  }

  .form-panel {
    display: none;
  }

  .app-shell {
    display: block;
    min-height: 0;
  }

  .preview-panel {
    padding: 0;
    overflow: hidden;
  }

  .letter-page {
    width: 210mm;
    height: 297mm;
    margin: 0;
    padding: 20mm 25.4mm 16mm;
    box-shadow: none;
    font-size: 10.5pt;
    line-height: 1.18;
    break-after: avoid;
    page-break-after: avoid;
    page-break-inside: avoid;
  }

  .letter-page p {
    margin-bottom: 10px;
  }

  .signature-block {
    margin-top: 22px;
  }

  .signature-space {
    height: 18mm;
    margin-top: 5mm;
  }

  .signature-name {
    margin-top: 4px;
  }

  @page {
    size: A4;
    margin: 0;
  }
}
