Since all trains commute via Salzburg - this is probably the most classic city to visit.
Lots of culture. Probably lots of tourists too. It is a beautiful town - with many options to enjoy a beautiful day. probably enough places to enjoy also during bad weather.
If you like it quiet Linz is also an option. but to be honest Linz is probably worth a day trip without the need to stay overnight - except you want to visit nightlife.
Nevertheless given your preferences to not divert from the main train line - Salzburg is the way to go.