12. As shown in Figure 7, $\triangle A B D$ and $\triangle C E D$ are both equilateral triangles, $A C=B C, A C \perp B C$. If $B E$ $=\sqrt{2}$, then $C D=$ $\qquad$
12. $\sqrt{3}-1$.

Extend $DC$ to intersect $AB$ at point $M$.
Since $AD=BD, AC=BC$, line $DC$ is the perpendicular bisector of $AB$. It is easy to prove that $\triangle ADC \cong \triangle BDE$.
Thus, $AC=BE=\sqrt{2}, CM=\frac{\sqrt{2}}{2} AC=1$, $AB=\sqrt{2} AC=2$.
Therefore, $DM=\sqrt{3}, CD=\sqrt{3}-1$.