Probing hidden sectors with early universe cosmology