Dinosaur biodiversity declined well before the asteroid impact, influenced by ecological and environmental pressures