@gryphter I mean, speaking as an unpublished would-be writer and a cishet white dude...
...and with the important caveat that you're not committing some mortal sin by sticking to your demographics in pretendy funtimes...
The overly pat, often-repeated aphorism that "the trick to writing women is to write them as people" is pretty much entirely correct. The basic sentiment applies more or less across whatever demographic you're talking about.
Like, yes, different people have had different lived experiences and that shapes their outlook and personality. Of course, a cishet white dude who grew up in a rural town and joined the Marines is also going to have a different lived experience than my nerdy suburbanite upbringing, but that never seems to carry the same sort of stigma, or the same perception of an unapproachable divide.
So, sure, consider the character's identity in terms of how they'd act. But if I'm handing out any advice, I'd say to err on the side of underdoing it versus overdoing it if you're in doubt. Like, try to avoid the pitfall of worrying about whether a character's portrayal is sufficiently female/ queer/ ethnic, worry more if you're overdoing what you'd think of as "typical" for the demographic.
And I'm trying to avoid sounding condescending with this next bit, but, like... we all know people outside of our demographics, right? Like, as a cis white guy, I have a mother and a wife, at the very least. I have friends and coworkers who are women, gay, black, various combinations of the above. I figure most people can say something similar! So try to draw from that, instead of basing our portrayals on fictional characters based on other fictional characters based on stereotypes by straight white dude authors. (There's also the option of drawing from fiction or nonfiction by members of the demographics. It's out there!)
I mean, there's nothing wrong with considering things like women's pockets or men's discomfort with physical proximity. But you're probably better off glossing over it than you are getting lost in the weeds about that sort of thing.