Bound excitons in time-dependent density-functional theory: optical and energy-loss spectra.