  We extend the kinetic theory of $D$ mesons to accommodate thermal and
off-shell effects due to the medium modification of the heavy-meson spectral
functions. From the Kadanoff-Baym approach we derive the off-shell
Fokker-Planck equation which encodes the heavy-flavor transport coefficients.
We analyze the thermal width (damping rate) of $D$ mesons due to their
scattering off light mesons, focusing on new in-medium effects: off-shell
corrections, inelastic channels, and the contribution of the Landau cut. We
obtain that the latter effect (absent for vacuum scattering amplitudes) brings
sizable corrections at moderate temperatures. We discuss how the heavy-flavor
transport coefficients, like the drag and diffusion coefficients, are modified
in matter. We find that the $D$-meson spatial diffusion coefficient matches
smoothly to the latest results of lattice-QCD calculations and Bayesian
analyses at higher temperatures.
