I have always thought of gender as being a socio-cultural concept based on how one views themselves within the social and cultural context they live in. For example, for me being a tomboy in a very traditionally gender roled family and religious community was gender non conforming as I didn't follow the gender roles or gender expectations of my social context. I wasn't feminine and I didn't act or dress in the way that was expected of young girls. It had nothing to do with sex at all. However now I rarely see socio-cultural norms and context and gender roles / expectations attached to gender conversations. Gender identity seems to now be more connected to a vague notion of what it means to be a certain sex. I don't know when this changed. I was looking up definitions and came across this one on gender identity. This fits more with my view of it. Curious to get the thoughts of others.
https://emedicine.medscape.com/article/917990-overview