<?php
// ─── AI TEXT FORMATTING ──────────────────────────────────────
function formatAIText($text) {
  // Escape HTML to prevent XSS, preserve line breaks
  $escaped = htmlspecialchars($text, ENT_QUOTES, 'UTF-8');
  // Replace newlines with <br>
  return nl2br($escaped);
}
?>