/* Coquille : une page de cahier. Noir sur blanc, une seule couleur (le rouge du correcteur), une colonne.
   Polices du système uniquement : aucune requête vers un autre site. */
:root {
  --page: #ffffff;
  --ink: #141414;
  --muted: #5a5a5a;
  --rule: #d9d9d9;
  --red: #b3121f;            /* stylo du correcteur */
  --focus: #1f4fbf;
  --text: Georgia, Cambria, "Times New Roman", serif;
  --ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --page: #121212; --ink: #ececec; --muted: #a3a3a3; --rule: #333333; --red: #ff6b6b; --focus: #8ab4ff; color-scheme: dark; }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--page); color: var(--ink); font: 16px/1.55 var(--ui); }
a { color: inherit; }
button:focus-visible, textarea:focus-visible, .fix:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.page { max-width: 760px; margin: 0 auto; padding-inline: 16px; padding-block: 40px 48px; display: grid; gap: 32px; }

.masthead { border-bottom: 2px solid var(--ink); padding-bottom: 14px; }
.masthead h1 { margin: 0; font: 700 2rem/1.1 var(--ui); letter-spacing: -0.01em; }
.masthead p { margin: 6px 0 0; color: var(--muted); }

main { display: grid; gap: 32px; }
section h2 { margin: 0 0 8px; font: 700 0.8rem var(--ui); text-transform: uppercase; letter-spacing: 0.08em; }
.head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.hint { font-size: 0.85rem; color: var(--muted); font-variant-numeric: tabular-nums; }

textarea, .output {
  display: block; width: 100%; min-height: 220px; padding: 12px 14px; font: 1.1rem/1.7 var(--text); color: var(--ink);
  background: var(--page); border: 1px solid var(--rule); border-radius: 0; overflow-wrap: anywhere;
}
textarea { resize: vertical; }
textarea:focus { outline: none; border-color: var(--ink); }
.output { white-space: pre-wrap; min-height: 120px; }
.empty { margin: 0; color: var(--muted); font: 0.95rem/1.6 var(--ui); white-space: normal; }

/* une correction, comme sur une copie : l'erreur barrée, la correction en rouge */
.fix { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; display: inline; }
.fix del { color: var(--muted); text-decoration-color: var(--red); margin-right: 0.25em; }
.fix ins { color: var(--red); text-decoration: none; font-weight: 700; }
.fix:hover ins { text-decoration: underline; }
.fix.rejected del { color: inherit; text-decoration: underline dotted var(--muted); margin: 0; }
.fix.rejected ins { display: none; }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-top: 12px; }
button { font: 600 0.95rem var(--ui); padding: 9px 18px; cursor: pointer; border: 1px solid var(--ink); border-radius: 0; background: var(--page); color: var(--ink); }
button:disabled { opacity: 0.4; cursor: default; }
button.primary { background: var(--ink); color: var(--page); }
/* un clic se voit : le bouton s'enfonce */
button:not(:disabled):active { transform: translateY(1px); background: var(--muted); border-color: var(--muted); color: var(--page); }
/* occupé (chargement, correction) : roue qui tourne, bouton désactivé mais lisible */
button.busy:disabled { opacity: 1; cursor: progress; }
button.busy::before {
  content: ""; display: inline-block; width: 0.85em; height: 0.85em; margin-right: 8px; vertical-align: -1px;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.7s linear infinite;
}
/* « Copier » (action principale du résultat) en rouge plein ; « Remplacer mon texte » reste à contour noir */
#copy { background: var(--red); border-color: var(--red); color: var(--page); }
#copy.done { background: var(--ink); border-color: var(--ink); }
@keyframes spin { to { transform: rotate(360deg); } }
.status { font-size: 0.88rem; color: var(--muted); flex: 1 1 260px; }

.progress { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.bar { flex: 1; height: 3px; background: var(--rule); }
.bar span { display: block; height: 100%; width: 0; background: var(--ink); transition: width 0.2s; }

.notes { border-top: 1px solid var(--rule); padding-top: 20px; display: grid; gap: 14px; }
.notes h3 { margin: 0 0 2px; font-size: 0.95rem; }
.notes p { margin: 0; color: var(--muted); font-size: 0.93rem; }
.colophon { color: var(--muted); font-size: 0.8rem; border-top: 1px solid var(--rule); padding-top: 12px; }
.colophon p { margin: 0; }

@media (prefers-reduced-motion: reduce) { .bar span { transition: none; } button.busy::before { animation-duration: 2s; } }
