Separation of variables for the moduli of Higgs bundles and connections