The only healthy solution is to understand that there is no guarantee in crypto, risk only what you can afford to lose, even after every thing, something can still always go wrong.
Apart from investing only what you can risk to lose, this is why you don't put all your eggs in one basket, hardware wallets should be use for storing our Bitcoin definitely but you shouldn't use the same wallet that you use for hodling for your daily transaction if you're very active in the market and not just a hodler. When you do this you don't risk losing all your Bitcoin if the wallet get compromised with the scenarios you have given. I still fully recommend using a wallets like electrum for your daily transaction irrespective of it been an online wallet while we keep our Bitcoin we allocated for hodling in a hardware wallet to be touch once in a while.
MK4 has hit the nail on the head, no matter what we do we can't be 100% safe so we should always take extra precautions to keep our Bitcoin safe as the constodial of our Bitcoin is in our hands and not that of any centralized body when we use non constodial wallets.