Brachiopods have a huge fossil record going back to the Cambrian. They were much reduced by the two main extinction events, the P/Tr and K/T. Bivalve molluscs took over their inshore habitats in the Mesozoic, and since then the brachiopods have been confined to deeper water, except for a handful of species. There are about 100 to 350 species living; the fossil species number 12,000.