  Electromagnetic radiation from blazar jets often displays strong variability,
extending from radio to $\gamma$-ray frequencies. In a few cases, this
variability has been characterized using Fourier time lags, such as those
detected in the X-rays from Mrk~421 using BeppoSAX. The lack of a theoretical
framework to interpret the data has motivated us to develop a new model for the
formation of the X-ray spectrum and the time lags in blazar jets based on a
transport equation including terms describing stochastic Fermi acceleration,
synchrotron losses, shock acceleration, adiabatic expansion, and spatial
diffusion. We derive the exact solution for the Fourier transform of the
electron distribution, and use it to compute the Fourier transform of the
synchrotron radiation spectrum and the associated X-ray time lags. The same
theoretical framework is also used to compute the peak flare X-ray spectrum,
assuming that a steady-state electron distribution is achieved during the peak
of the flare. The model parameters are constrained by comparing the theoretical
predictions with the observational data for Mrk~421. The resulting integrated
model yields, for the first time, a complete first-principles physical
explanation for both the formation of the observed time lags and the shape of
the peak flare X-ray spectrum. It also yields direct estimates of the strength
of the shock and the stochastic MHD wave acceleration components in the Mrk~421
jet.
