Ancient teeth reveal that flexible feeders survived past climate shocks, while habitat specialists rapidly declined.