:root {
  --bg: #fff8f3;
  --bg-soft: #f8ebe8;
  --surface: #ffffff;
  --surface-warm: #fffaf7;
  --ink: #2f2a2a;
  --muted: #736866;
  --line: #eadbd5;
  --blush: #d9898b;
  --blush-dark: #9d555f;
  --sage: #6f8f82;
  --sage-dark: #3f665e;
  --focus: #315f8a;
  --shadow: 0 18px 50px rgba(74, 48, 43, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(248, 235, 232, 0.76), rgba(255, 248, 243, 0.9)),
    var(--bg);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  line-height: 1.5;
}

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

.app-shell {
  width: min(100%, 980px);
  margin: 0 auto;
  padding: 28px 16px 48px;
}

.page-header {
  padding: 24px 0 22px;
}

.top-line {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.eyebrow {
  margin: 0;
  color: var(--sage-dark);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.home-link {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--sage-dark);
  background: rgba(255, 255, 255, 0.68);
  font-size: 0.92rem;
  font-weight: 800;
  text-decoration: none;
}

.home-link:hover {
  background: #ffffff;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  max-width: 720px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.6rem, 10vw, 5.4rem);
  line-height: 0.95;
}

.subtitle {
  max-width: 640px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: clamp(1.05rem, 4vw, 1.35rem);
}

.builder,
.output-panel {
  margin-top: 20px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow);
}

.section-heading {
  display: grid;
  gap: 6px;
  margin-bottom: 18px;
}

.section-heading h2 {
  font-size: clamp(1.3rem, 5vw, 1.9rem);
  line-height: 1.15;
}

.section-heading p,
.message,
.openthisnote-note {
  margin: 0;
  color: var(--muted);
}

.field-group {
  display: grid;
  gap: 8px;
}

label {
  color: var(--ink);
  font-weight: 700;
}

select,
textarea,
input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface-warm);
  outline: none;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    background-color 160ms ease;
}

select,
input {
  min-height: 48px;
  padding: 0 14px;
}

textarea {
  min-height: 104px;
  padding: 13px 14px;
  resize: vertical;
}

select:focus,
textarea:focus,
input:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(49, 95, 138, 0.16);
  background: #ffffff;
}

.question-form {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.prompt-card {
  display: grid;
  gap: 8px;
  padding: 2px 0;
}

.prompt-card textarea {
  min-height: 92px;
}

.empty-state {
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 250, 247, 0.64);
}

.actions,
.output-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 18px;
}

button {
  min-height: 46px;
  padding: 0 16px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
  transition:
    transform 140ms ease,
    box-shadow 140ms ease,
    background-color 140ms ease,
    opacity 140ms ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.primary-button {
  color: #ffffff;
  background: var(--blush-dark);
  box-shadow: 0 10px 20px rgba(157, 85, 95, 0.18);
}

.primary-button:hover:not(:disabled) {
  background: #884c56;
}

.secondary-button {
  color: var(--ink);
  background: #f4e7e2;
}

.secondary-button:hover:not(:disabled) {
  background: #ecd9d2;
}

.accent-button {
  color: #ffffff;
  background: var(--sage-dark);
  box-shadow: 0 10px 20px rgba(63, 102, 94, 0.18);
}

.accent-button:hover:not(:disabled) {
  background: #34584f;
}

.message {
  min-height: 1.5em;
  font-size: 0.95rem;
}

.preview-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}

#letterOutput {
  min-height: 360px;
  border: 0;
  border-radius: 0;
  background: #ffffff;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.08rem;
  line-height: 1.7;
}

#letterOutput:disabled {
  color: var(--muted);
}

.openthisnote-note {
  margin-top: 12px;
  font-size: 0.95rem;
}

.print-sheet {
  display: none;
}

@media (min-width: 760px) {
  .app-shell {
    padding: 46px 24px 72px;
  }

  .builder,
  .output-panel {
    padding: 30px;
  }

  .question-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .prompt-card.full-width {
    grid-column: 1 / -1;
  }
}

@media (max-width: 520px) {
  .builder,
  .output-panel {
    padding: 18px;
  }

  .actions,
  .output-actions {
    align-items: stretch;
    flex-direction: column;
  }

  button {
    width: 100%;
  }
}

@media print {
  body {
    background: #ffffff;
  }

  .app-shell {
    display: none;
  }

  .print-sheet {
    display: block;
    padding: 0.55in;
    color: #242020;
    font-family: Georgia, "Times New Roman", serif;
  }

  .print-sheet h1 {
    margin-bottom: 24px;
    font-size: 28pt;
    line-height: 1.1;
  }

  #printLetter {
    white-space: pre-wrap;
    font-size: 13pt;
    line-height: 1.65;
  }
}
