It's both in my humble (and non-medical) opinion. Weightloss is 90% diet and 10% activity in my opinion.
Muscle maintenance is a bit more complex. You need protein to maintain or put on muscle, but I think that being in ketosis tends to spare your protein because logically, I believe the body knows what is more efficient.
"Ok, no carbs for energy, what to do? Burn 1 gram of muscle for 4.5 calories of energy, or burn 1 gram of body fat for 7.5 (burning body fat is less efficient than burning dietary fat) calories of energy?"
Well, 7.5 (from body fat) > 4.5 (from muscle burning). Body is going to say, "of course fat is more efficient, I'll eat that first!"
Yes, you need some glucose for a few body functions that can't use free fatty acids or ketones for energy. But this can easily come from dietary protein intake so that it doesn't have to burn the protein already contained in your muscle.
The only time you have a problem is if you're like this hyper-lean individual with absolutely no body fat on you for your body to burn.
"The cling and a clang is the metal in my head when I walk. I hear a sort of, this tinging noise - cling clang. The cling clang. So many things happen while walking. The metal in my head clangs and clings as I walk - freaks my balance out. So the natural thought is just clogged up. Totally clogged up. So we need to unplug these dams, and make the the natural flow... It sort of freaks me out. We need to unplug the dams. You cannot stop the natural flow of thought with a cling and a clang..."