  In kilonovae, freshly-synthesized $r$-process elements imprint features on
optical spectra, as observed in AT2017gfo, the counterpart to the GW170817
binary neutron star merger. However, measuring the $r$-process compositions of
the merger ejecta is computationally challenging. Vieira et al. (2023)
introduced Spectroscopic $r$-Process Abundance Retrieval for Kilonovae (SPARK),
a software tool to infer elemental abundance patterns of the ejecta, and
associate spectral features with particular species. Previously, we applied
SPARK to the 1.4 day spectrum of AT2017gfo and inferred its abundance pattern
for the first time, characterized by electron fraction $Y_e=0.31$, a
substantial abundance of strontium, and a dearth of lanthanides and heavier
elements. This ejecta is consistent with wind from a remnant hypermassive
neutron star and/or accretion disk. We now extend our inference to spectra at
2.4 and 3.4 days, and test the need for multicomponent ejecta, where we
stratify the ejecta in composition. The ejecta at 1.4 and 2.4 days is described
by the same single blue component. At 3.4 days, a new redder component with
lower $Y_e=0.16$ and a significant abundance of lanthanides emerges. This new
redder component is consistent with dynamical ejecta and/or neutron-rich ejecta
from a magnetized accretion disk. As expected from photometric modelling, this
component emerges as the ejecta expands, the photosphere recedes, and the
earlier bluer component dims. At 3.4 days, we find an ensemble of lanthanides,
with the presence of cerium most concrete. This presence of lanthanides has
important implications for the contribution of kilonovae to the $r$-process
abundances observed in the Universe.
