Theory of single-molecule NMR detected by real-time ESR