Wow. There are lots of great ideas being offered. I use Carnet on Nextcloud (https://getcarnet.app/) to meet most of my note taking needs. But there is a real tension in two of your requirements. Specifically, private note taking and sharing can be competititve requirements. So here is my question: what kind of "shared notes" capability do you really need? You might be able to use Nextcloud Notes to meet your needs. But like Carnet, such solutions require you to implement your own private cloud (i.e., Owncloud/Nextcloud). Fundamentally, you really need to get shared notes off of someone else's infrastructure. That is the only way to radically improve your security/privacy.