Inhomogeneous continuous-time Markov chains to infer flexible time-varying evolutionary rates