Gradient-based Planning with World Models