12. Given real numbers $x, y$ satisfy
$$
\left\{\begin{array}{l}
x-y \leqslant 0, \\
x+y-5 \geqslant 0, \\
y-3 \leqslant 0 .
\end{array}\right.
$$

If the inequality $a\left(x^{2}+y^{2}\right) \leqslant(x+y)^{2}$ always holds, then the maximum value of the real number $a$ is $\qquad$ .
12. $\frac{25}{13}$.

From the problem, we know that $a \leqslant \frac{(x+y)^{2}}{x^{2}+y^{2}}$.
Let $f(x, y)=\frac{(x+y)^{2}}{x^{2}+y^{2}}$. Then
$$
a \leqslant f(x, y)_{\text {min }} .
$$

And $f(x, y)=1+\frac{2}{\frac{x}{y}+\frac{y}{x}}$, the inequality represents a planar region as shown in Figure 5.

Considering that $\frac{y}{x}$ represents the slope of the line passing through a point $(x, y)$ in the planar region and $(0,0)$, we get $\frac{y}{x} \in\left[1, \frac{3}{2}\right]$.
Thus, $\frac{x}{y}+\frac{y}{x} \in\left[2, \frac{13}{6}\right]$.
Therefore, $f(x, y) \in\left[\frac{25}{13}, 2\right]$.
Hence, the maximum value of $a$ is $\frac{25}{13}$.