It looks fine in terms of time spent at each place, although I agree that you don’t need 3 nights in Bern. You could add a night to Luzern to facilitate the suggestion below. And I suggest skipping Lugano, as described below.
I like the suggestion of the Bernina Express instead of the Gotthard Panorama Express to Lugano. The Bernina Pass route— the only train tracks that go over the Alps instead of tunneling under at some point—- is a good way to reach Varenna, so it is easy to work into your itinerary if you drop Lugano. I say that although we have not ever been to Lugano, other than pass through on the train. Every time I try to work it into a Swiss itinerary I get turned off by the lodging prices——Lugano is a popular resort area, with prices to match— not what we are looking for in Switzerland. So I prefer to get our “lake time” in Italy, where the lodging is more reasonably priced (and the food is Italian!). Also, getting to Varenna from Lugano involves either a bus to Mennaggio and short ferry across the lake, or a train from Lugano to Como and long ferry ride, or a train to Milano Centrale and transfer there to the train to Varenna. The train from the Engadine in Switzerland to Varenna is seamless and easy.
Consider something like this: add a day to Luzern and spend part of a day cruising the lake there—-maybe the Rigi roundtrip. Then head to the Engadine area for the Bernina Pass train (could be either the named Bernina Express, or a regular regional train which is cheaper and runs more frequently). You could travel from Luzern to Pontresina, a pretty Engadine village right on the Bernina route, in 4 hours 20 minutes, with 3 changes on the way (make sure Chur is on the route). Or if you prefer fewer train changes, get off in Samedan, the village before Pontresina, smaller but with good train connections to the other Engadine villages. A 2-night stay at a hotel in either of these villages will get you a travel card good for free travel on all the area travel network (including lifts).
After your stay in Pontresina, you can catch the Bernina Espress train or a regional train over the Bernina Pass to Tirano on the Italian border. Change there for an Italian train to Varenna—-the ride is 1.5 hours.
Here is a map of the Swiss rail system so you can see the routes:
https://cdn-doc.myswissalps.com/docs/default-source/rail-network-maps/swisstravelpass.pdf?sfvrsn=7788603a_52