  The cosmic microwave background (CMB) places strong constraints on models of
dark matter (DM) that deviate from standard cold DM (CDM), and on initial
conditions beyond the scalar adiabatic mode. Here, the full \textit{Planck}
data set (including temperature, $E$-mode polarisation, and lensing deflection)
is used to test the possibility that some fraction of the DM is composed of
ultralight axions (ULAs). This represents the first use of CMB lensing to test
the ULA model. We find no evidence for a ULA component in the mass range
$10^{-33}\leq m_a\leq 10^{-24}\text{ eV}$. We put percent-level constraints on
the ULA contribution to the DM, improving by up to a factor of two compared to
the case with temperature anisotropies alone. Axion DM also provides a
low-energy window onto the high-energy physics of inflation through the
interplay between the vacuum misalignment production of axions and isocurvature
perturbations. We perform the first systematic investigation into the parameter
space of ULA isocurvature, using an accurate isocurvature transfer function at
all $m_{a}$ values. We precisely identify a "window of co-existence" for
$10^{-25}\text{ eV}\leq m_a\leq10^{-24}\text{ eV}$ where the data allow,
simultaneously, a $\sim10\%$ contribution of ULAs to the DM, and $\sim 1\%$
contributions of isocurvature and tensors to the CMB power. ULAs in this window
(and \textit{all} lighter ULAs) are shown to be consistent with a large
inflationary Hubble parameter, $H_I\sim 10^{14}\text{ GeV}$. The window of
co-existence will be fully probed by proposed CMB-S4 observations with
increased accuracy in the high-$\ell$ lensing power and low-$\ell$ $E$ and
$B$-mode polarisation. If ULAs in the window exist, this could allow for two
independent measurements of $H_I$ in the CMB using the axion DM content and
isocurvature, and the tensor contribution to $B$-modes.
