The recent detection of the binary neutron star merger GW170817 by LIGO and Virgo was followed by a firework of electromagnetic counterparts across the entire electromagnetic spectrum. In particular, the ultraviolet, optical, and near-infrared emission is consistent with a kilonova that provided strong evidence for the formation of heavy elements in the merger ejecta by the rapid neutron capture process (r-process). In this talk, I will discuss the state of the art in modeling neutron star mergers from first principles, which represents a multi-physics challenge involving all four fundamental forces and petascale computing. I will present recent results from general-relativistic magnetohydrodynamic simulations and discuss possible scenarios and mass ejection mechanisms that can give rise to the observed kilonova features. In particular, I will argue that massive winds from neutrino-cooled post-merger accretion disks most likely synthesized the heavy r-process elements in GW170817. I will show how this finding (at least partially) concludes the quest for the cosmic origin of the heavy elements, which has been an enduring mystery for more than 70 years.