:root {
  color-scheme: light;
  --bg: #e4ddd0;
  --ink: #1c1915;
  --muted: #5e574c;
  --faint: #8a8174;
  --card: #fbf7f1;
  --line: #ddd4c6;
  --line-strong: #cfc4b2;
  --green: #1b4332;
  --green-ink: #132e23;
  --moss: #e5efe8;
  --danger: #8c2f2f;
  --shadow: 0 16px 40px rgba(70, 48, 20, 0.08);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background-color: var(--bg);
  background-image: linear-gradient(180deg, rgba(255, 252, 247, 0.65), rgba(255, 252, 247, 0) 320px);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  padding-bottom: calc(140px + env(safe-area-inset-bottom));
}

main {
  max-width: 40rem;
  margin: 0 auto;
  padding: 28px 20px 8px;
}

.skip {
  position: absolute;
  left: 12px;
  top: 0;
  transform: translateY(-120%);
  background: #fff;
  color: var(--ink);
  padding: 8px 12px;
  z-index: 20;
}

.skip:focus { transform: none; }

.noscript {
  max-width: 40rem;
  margin: 12px auto 0;
  padding: 12px 16px;
  background: #f6e4e0;
  color: #6e2c2c;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 18px;
  font-family: Georgia, "Iowan Old Style", Palatino, serif;
  font-size: 1.2rem;
}

.logo {
  width: 32px;
  height: 32px;
  display: block;
}

h1, h2, .price strong {
  font-family: Georgia, "Iowan Old Style", Palatino, serif;
  font-weight: 500;
  letter-spacing: -0.02em;
}

h1 {
  margin: 0 0 12px;
  font-size: clamp(2rem, 8vw, 2.75rem);
  line-height: 1.12;
}

.lede {
  margin: 0;
  color: var(--muted);
  font-size: 1.05rem;
}

.bands {
  list-style: none;
  margin: 22px 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.bands li {
  margin: 0;
  padding: 12px;
  background: rgba(251, 247, 241, 0.72);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  font-size: 0.92rem;
}

.bands span {
  display: block;
  margin-bottom: 2px;
  color: var(--ink);
  font-weight: 600;
}

form {
  display: grid;
  gap: 16px;
}

.split {
  display: grid;
  gap: 16px;
}

.field { min-width: 0; }

label, legend {
  font-weight: 600;
}

label {
  display: block;
  margin-bottom: 6px;
}

fieldset {
  margin: 0;
  padding: 14px 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  display: grid;
  gap: 14px;
}

legend { padding: 0 4px; }

input {
  width: 100%;
  min-height: 52px;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fffdf9;
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
}

input::placeholder { color: #9a9186; }

input[aria-invalid="true"] {
  border-color: var(--danger);
}

.hint, .fine, .usage, footer, .copy-status {
  color: var(--muted);
}

.hint, .error, .copy-status {
  margin: 6px 0 0;
  font-size: 0.9rem;
}

.copy-status {
  color: var(--green);
  font-weight: 600;
}

.copy-status:empty {
  margin: 0;
  height: 0;
  overflow: hidden;
}

.hint[data-tone="gentle"] { color: var(--green); }
.hint[data-tone="firm"] { color: #6a4a1d; }
.hint[data-tone="final"] { color: #6e2c2c; }

.error { color: var(--danger); }

.form-error:not([hidden]) { margin-top: -4px; }

.button, .text-button {
  font: inherit;
  cursor: pointer;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 52px;
  padding: 0 16px;
  border: 0;
  border-radius: 10px;
  background: var(--green);
  color: #f6f3ec;
  font-weight: 600;
  font-size: 1.05rem;
  text-decoration: none;
  text-align: center;
}

.button:hover { background: var(--green-ink); }

.button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.button.is-copied { background: #245c42; }

.button.secondary {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line-strong);
}

.button.secondary:hover { background: rgba(255, 255, 255, 0.45); }

.text-button {
  width: auto;
  min-height: 44px;
  padding: 8px 0;
  border: 0;
  background: none;
  color: var(--green);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.text-button.light { color: #f3eadb; }

.output { margin-top: 22px; }

.empty, .letter {
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.empty { padding: 18px; }

.empty-title {
  margin: 0 0 6px;
  font-weight: 600;
}

.empty p { margin: 0; color: var(--muted); }

.letter { padding: 18px 16px 16px; }

.tone {
  display: inline-block;
  margin: 0 0 12px;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--moss);
  color: var(--green);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.tone[data-tone="firm"] {
  background: #f3e6d4;
  color: #6a4a1d;
}

.tone[data-tone="final"] {
  background: #f6e4e0;
  color: #6e2c2c;
}

.subject-label {
  margin: 0;
  color: var(--faint);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

#subject {
  margin: 4px 0 14px;
  font-size: 1.35rem;
  line-height: 1.25;
}

.letter pre {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: Georgia, "Iowan Old Style", Palatino, serif;
  font-size: 1.05rem;
  line-height: 1.55;
}

.letter-actions {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.paywall {
  margin-top: 14px;
  padding: 20px 18px 16px;
  border-radius: 14px;
  background: #1c1915;
  color: #f6f1e8;
}

.paywall-kicker {
  margin: 0 0 6px;
  color: #c9bfb1;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.paywall h2 {
  margin: 0 0 8px;
  font-size: 1.7rem;
  line-height: 1.2;
}

.paywall p { margin: 0 0 10px; color: #e4dccf; }

.price { margin: 8px 0 10px; }

.price strong {
  display: block;
  color: #f6f1e8;
  font-size: 2.4rem;
  line-height: 1;
}

.paywall .button {
  margin: 6px 0 4px;
  background: #f3eadb;
  color: #1c1915;
}

.paywall .button:hover { background: #fffaf3; }

.unconfigured {
  padding: 10px 12px;
  border: 1px solid rgba(243, 234, 219, 0.35);
  border-radius: 8px;
}

.fine { font-size: 0.85rem; color: #c9bfb1; }

footer {
  margin-top: 22px;
  font-size: 0.92rem;
}

footer p { margin: 0 0 8px; }

footer a { color: var(--green); }

.dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  padding: 10px 16px calc(12px + env(safe-area-inset-bottom));
  background: rgba(251, 247, 241, 0.94);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.dock-inner {
  max-width: 40rem;
  margin: 0 auto;
  display: grid;
  gap: 6px;
}

.usage {
  margin: 0;
  font-size: 0.85rem;
  text-align: center;
}

input, button, .letter, .paywall, .empty, .letter-actions, .copy-status {
  scroll-margin-bottom: calc(160px + env(safe-area-inset-bottom));
}

:focus-visible {
  outline: 2px solid #1c1915;
  outline-offset: 3px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (min-width: 640px) {
  .split { grid-template-columns: 1.2fr 0.8fr; }
  .bands { grid-template-columns: repeat(3, 1fr); }
  .letter-actions { grid-template-columns: 1fr 1fr; }
  .letter { padding: 22px 22px 18px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
