  We extend the parametric geometry of numbers (initiated by Schmidt and
Summerer, and deepened by Roy) to Diophantine approximation for systems of $m$
linear forms in $n$ variables, and establish a new connection to the metric
theory via a variational principle that computes fractal dimensions of a
variety of sets of number-theoretic interest. The proof relies on two novel
ingredients: a variant of Schmidt's game capable of computing the Hausdorff and
packing dimensions of any set, and the notion of templates, which generalize
Roy's rigid systems. In particular, we compute the Hausdorff and packing
dimensions of the set of singular systems of linear forms and show they are
equal, resolving a conjecture of Kadyrov, Kleinbock, Lindenstrauss and
Margulis, as well as a question of Bugeaud, Cheung and Chevallier. As a
corollary of Dani's correspondence principle, the divergent trajectories of a
one-parameter diagonal action on the space of unimodular lattices with exactly
two Lyapunov exponents with opposite signs has equal Hausdorff and packing
dimensions. Other applications include quantitative strengthenings of theorems
due to Cheung and Moshchevitin, which originally resolved conjectures due to
Starkov and Schmidt respectively; as well as dimension formulas with respect to
the uniform exponent of irrationality for simultaneous and dual approximation
in two dimensions, completing partial results due to Baker, Bugeaud, Cheung,
Chevallier, Dodson, Laurent and Rynne.
