From a local, your long layover is absolutely plenty of time to enjoy the Flagship Lounge, Vizcaya and more.
The museum is indeed about 20 minutes from the airport. And, being a Sunday, there should not be much traffic.
I would allow between two and three hours to tour the museum and grounds.
Following this, you should have plenty of time to take a stroll and perhaps grab lunch in either Coconut Grove (trendy waterfront area) or on Miracle Mile in Coral Gables. Either of these locations have shops, restaurants, bars, and cafés that you can stroll along and check out. And each is a very short Uber ride back to the airport.
The flagship lounge itself is quite nice to hang out at for a few hours - I usually try to arrive at least two hours ahead of my overseas flights to grab a drink and a bite to eat, and relax before getting on the plane. Certainly a much better experience than the adjacent admirals club, which is usually crowded.
enjoy Morocco. It’s a wonderful destination!