  We investigate the ``partition function'' integrals $\int_{-1/2}^{1/2}
|\zeta(1/2 + it + ih)|^2 dh$ for the critical exponent 2, and the local maxima
$\max_{|h| \leq 1/2} |\zeta(1/2 + it + ih)|$, as $T \leq t \leq 2T$ varies. In
particular, we prove that for $(1+o(1))T$ values of $T \leq t \leq 2T$ we have
$\max_{|h| \leq 1/2} \log|\zeta(1/2+it+ih)| \leq \log\log T - (3/4 +
o(1))\log\log\log T$, matching for the first time with both the leading and
second order terms predicted by a conjecture of Fyodorov, Hiary and Keating.
  The proofs work by approximating the zeta function in mean square by the
product of a Dirichlet polynomial over smooth numbers and one over rough
numbers. They then apply ideas and results from corresponding random model
problems to compute averages of this product, under size restrictions on the
smooth part that hold for most $T \leq t \leq 2T$ (but reduce the size of the
averages). There are connections with the study of critical multiplicative
chaos. Unlike in some previous work, our arguments never shift away from the
critical line by more than a tiny amount $1/\log T$, and they don't require
explicit calculations of Fourier transforms of Dirichlet polynomials.
