Server-side multi-stage pipeline
`POST /api/refine` runs an eight-stage server pipeline. Input is validated with Zod, then a deterministic preflight scans for duplicate sentences, long sentences, repeated openings, generic transitions, inflated phrases, and unsupported claims. Diagnosis and fact-lock extraction feed a rewrite plan that drives the actual Gemini call.
- Zod input validation + style controls
- Deterministic preflight (duplicates, long sentences, generic transitions)
- Fact-lock for claims, names, numbers, terms, references
- Rewrite + post-rewrite quality check against the original