Solution (source code)

= Solution

Before diagonalizing quark masses, the charged weak current couples fields in the same weak doublet:
$$
\mathcal L_W=\frac g{\sqrt2}\bar u'_L\gamma^\mu d'_L W_\mu^++\text{h.c.}
$$
The Higgs <Yukawa matrices> produce mass matrices $M_u$ and $M_d$. Biunitary transformations diagonalize them, with $u'_L=U_{uL}u_L$ and $d'_L=U_{dL}d_L$. The charged current therefore contains the <Cabibbo-Kobayashi-Maskawa matrix>
$$
\boxed{V_{\rm CKM}=U_{uL}^\dagger U_{dL}}.
$$
Neutral gauge currents remain flavor diagonal because the same unitary matrix occurs on both sides, and neutral Higgs couplings are diagonal together with each mass matrix.

For $N$ generations, rephasing the quark fields leaves $N(N-1)/2$ mixing angles and $(N-1)(N-2)/2$ irreducible phases, a total of $(N-1)^2$ parameters. Three generations are the minimum needed for a physical phase; the observed $3\times3$ matrix has
$$
\boxed{3\text{ angles}+1\text{ phase}=4\text{ physical parameters}}.
$$