The decline started after Charles V. Maybe Philip II dies early and Ferdinand gets he entire Hapsburg realm?
IMHO the decline started after Philip II.
Doubt he would. The realm was practically ungovernable. There's a reason it was divided. So Maximilian would get the Empire, the Habsburg hereditary lands and possibly the Netherlands, with Ferdinand getting Spain and the Italian territories, with Milan up in the air. Though if the throne gos to Ferdinand's line we might not see a union between Spain and Portugal. Or we could flip it, with Maximilian getting Spain and his brother the Empire. That way Portugal would be claimed by right of Maximilian's wife Maria of Spain.
IOTL Holy Roman Emperor Ferdinand I of Austria had three surviving sons, Maximilian II, Ferdinand II and Charles II. Maximilian II had been partially educated in 'Spain'* (*= Castille & Aragon) and was married to Mary, the eldest daughter of Charles V.
Depending on other butterflies Maximilian II probably is the most likely candidate to succeed in the Spanish Kingdoms, however the Burgundian Lands and Milan could very well switch to the Austrian branch.
The only issue with Maximilian II was that Ferdinand I felt that his son wasn't 'Catholic enough' and might have some 'suspected Protestant tendencies', still if Mary of Spain (the daughter of Charles V) isn't butterflied away, then he would be in best position to inherit the Spanish Kingdoms.
Ferdinand II was the favourite son of Ferdinand, but IOTL he secretly married a (non noble) patrician's daughter (though even if she would have been, she would still have been beneath his station), as ITTL the heir of the main Habsburg possessions in the Holy Roman Empire and Hungary (and thus the Habsburg candidate for the position of Holy Roman Emperor) this secret marriage won't be an option, though she could still remain his official mistress.
IOTL Charles II, the youngest son of Ferdinand I, got the Inner Austrian Lands (Styria, Carinthia and Carniola). Now ITTL he probably ends up with either the Burgundian Lands or Milan. IOTL both Charles V and Ferdinand I were interested in Milan, in part also due to strategic reasons (given the Spanish possessions in Italy and the Burgundian lands; however given how close Milan is to Austria (and thus could also potentially threaten it), it was also interesting for the Austrian branch). In short Milan probably ends up with Maximilian II or with Ferdinand II.
Regarding the Spanish Habsburg branch, what also could have helped was a different division of the Habsburg Lands.
IOTL Charles V and Ferdinand I did have a small dispute with regard to how to settle their inheritance.
At that point that consisted of the Crown of Castille (and the Colonies), the Crown of Aragon (with the Italian Possessions), the Austrian Lands, the Burgundian Lands and the Habsburg candidacy for the position of Holy Roman Emperor; the dispute more specifically considered the Imperial possessions. Initially Charles V was only willing to give Ferdinand a part of the Austrian Lands, IOTL Ferdinand eventually ended up with all the Austrian hereditary lands.
WI Ferdinand would have gained the Austrian Lands, the Burgundian Lands and the nomination as the Habsburg candidate for the Imperial Crown? For this to happen, you probably need some sort of earlier settlement between Ferdinand II of Aragon and Holy Roman Emperor Maximilian I of Austria (maybe Philip the Handsome too).
This way OTL Holy Roman Emperor Charles V, now ITTL only king Charles I of Castille & Aragon (etc.) would be able to spend much more time in the Spanish kingdoms and with his spouse.
The position of the Habsburgs in the Empire, also wouldn't be weaker, since IOTL, even though Ferdinand was acting as a regent in the Empire (later legitimized by his election as king of the Romans), Charles wanted to keep a say in important decisions; also the Empire will have a ruler fully focused on the Empire, just like the Spanish kingdoms will have a ruler now more focused on their needs, probably better for both.