12. Given the function $f(x)=\frac{a}{x}-x$. If for any $x \in(0,1)$, $f(x) f(1-x) \geqslant 1$ always holds, then the range of the real number $a$ is $\qquad$ .
12. $a \in\left(-\infty,-\frac{1}{4}\right] \cup[1,+\infty)$.

Let $y=1-x$. Then $y \in(0,1)$. Therefore,
$$
\begin{array}{l}
f(x) f(1-x)=f(x) f(y) \\
=\left(\frac{a}{x}-x\right)\left(\frac{a}{y}-y\right) \\
=\frac{x^{2} y^{2}-a\left(x^{2}+y^{2}\right)+a^{2}}{x y} \\
=\frac{(x y)^{2}-a\left[(x+y)^{2}-2 x y\right]+a^{2}}{x y} .
\end{array}
$$

Let $x y=t$. Then $t \in\left(0, \frac{1}{4}\right)$.
Let $g(t)=f(x) f(1-x)$. Then
$$
g(t)=\frac{t^{2}-a(1-2 t)+a^{2}}{t} \geqslant 1,
$$

which implies $t^{2}+(2 a-1) t+a^{2}-a \geqslant 0$.
We discuss three cases.
(1) If $\frac{1}{2}-a \leqslant 0$, i.e., $\frac{1}{2} \leqslant a$, then we only need
$$
g(0) \geqslant 0 \Rightarrow a^{2}-a \geqslant 0 \Rightarrow a \geqslant 1 ;
$$
(2) If $0<\frac{1}{2}-a<\frac{1}{4}$, i.e., $\frac{1}{4}<a<\frac{1}{2}$, then we only need
$$
g\left(\frac{1}{4}\right) \geqslant 0 \Rightarrow\left(a-\frac{1}{4}\right)^{2} \geqslant \frac{1}{4} \Rightarrow a \leqslant 0 \text { or } a \geqslant \frac{1}{2} \text { (contradicts } \frac{1}{4}<a<\frac{1}{2} \text{, so no solution in this case) };
$$
(3) If $\frac{1}{2}-a \geqslant \frac{1}{4}$, i.e., $a<\frac{1}{4}$, then we only need
$$
g\left(\frac{1}{4}\right) \geqslant 0 \Rightarrow\left(a-\frac{1}{4}\right)^{2} \geqslant \frac{1}{4} \Rightarrow a \leqslant-\frac{1}{4} \text { or } a \geqslant \frac{1}{2} \text { (contradicts } a<\frac{1}{4} \text{, so } a \leqslant -\frac{1}{4} \text{) }.
$$

In summary, $a \in\left(-\infty,-\frac{1}{4}\right] \cup[1,+\infty)$.