:root {
  color-scheme: light dark;
  --bg: #fafaf9;
  --fg: #1c1917;
  --muted: #78716c;
  --accent: #2563eb;
  --border: #e7e5e4;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1917;
    --fg: #f5f5f4;
    --muted: #a8a29e;
    --accent: #60a5fa;
    --border: #44403c;
  }
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", sans-serif;
}

main {
  max-width: 44rem;
  margin: 0 auto;
  padding: 3rem 1.25rem;
}

h1 { font-size: 1.6rem; line-height: 1.3; margin: 0 0 .5rem; }

.muted { color: var(--muted); }

#forbidden { text-align: center; }
#forbidden img { max-width: 100%; height: auto; border-radius: 8px; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

textarea {
  width: 100%;
  margin-top: 1rem;
  padding: .75rem;
  font: inherit;
  color: inherit;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  resize: vertical;
}

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .75rem 1rem;
  margin-top: .75rem;
}

button {
  padding: .6rem 1.2rem;
  font: inherit;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

button:disabled { opacity: .5; cursor: progress; }

#message { margin-top: 1.5rem; color: var(--accent); }

#letter {
  margin-top: 2rem;
  white-space: pre-wrap;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.05rem;
}

.stats {
  margin-top: 1rem;
  font: .8rem/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--muted);
}

.lang { color: var(--muted); font-size: .9rem; }

select {
  font: inherit;
  color: var(--fg);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .25rem .4rem;
}

#what { display: block; max-width: 100%; height: auto; margin: 1rem auto 0; border-radius: 8px; }

.count { margin: .25rem 0 0; text-align: right; font-size: .8rem; }
.count.over { color: #dc2626; font-weight: 600; }

button.secondary {
  color: var(--fg);
  background: transparent;
  border: 1px solid var(--border);
  font-weight: 500;
}

@media (max-width: 480px) {
  main { padding: 1.5rem 1rem; }
  h1 { font-size: 1.35rem; }
  #letter { font-size: 1rem; }
}

@page { size: A4; margin: 25mm 22mm; }

@media print {
  :root { --bg: #fff; --fg: #000; }
  body { background: #fff; color: #000; }
  main { max-width: none; padding: 0; }
  main > *:not(#generator), #generator > *:not(#letter) { display: none !important; }
  #letter {
    margin: 0;
    font: 11.5pt/1.55 Georgia, "Times New Roman", serif;
  }
}
