  Tertiary modes in electrostatic drift-wave turbulence are localized near
extrema of the zonal velocity $U(x)$ with respect to the radial coordinate $x$.
We argue that these modes can be described as quantum harmonic oscillators with
complex frequencies, so their spectrum can be readily calculated. The
corresponding growth rate $\gamma_{\rm TI}$ is derived within the modified
Hasegawa--Wakatani model. We show that $\gamma_{\rm TI}$ equals the
primary-instability growth rate plus a term that depends on the local $U''$;
hence, the instability threshold is shifted compared to that in homogeneous
turbulence. This provides a generic explanation of the well-known yet elusive
Dimits shift, which we find explicitly in the Terry--Horton limit. Linearly
unstable tertiary modes either saturate due to the evolution of the zonal
density or generate radially propagating structures when the shear $|U'|$ is
sufficiently weakened by viscosity. The Dimits regime ends when such structures
are generated continuously.
