Peace be upon you and God's mercy and blessings.
Ayatollah Sistani (may God protect him):
The custody and upbringing of the child, along with all related interests concerning their protection and care, is the right of both parents equally during the breastfeeding period, which lasts for two full years. If the father dies during this period or before, the mother has the right to custody until the child reaches maturity, taking precedence over the father's guardian and paternal grandparents, regardless of whether she remarries or not.
However, the authority to manage the child's finances and oversee their interests belongs to the father and paternal grandfather. If both are absent, the guardian appointed by either of them takes over. In the absence of a guardian, the authority falls to the legal ruler. The mother, maternal grandfather, siblings, and other relatives have no guardianship rights over the child. This guardianship ends when the child reaches maturity and is considered rational and not foolish.
Ayatollah Khamenei (may God protect him):
It is the legal guardian's duty to care for the child's educational matters and protect them from ideological and moral corruption, as well as from any harmful or detrimental situations affecting them or others. If the mother has custody, she is legally responsible in this regard. If either parent fails to fulfill their legal duty in raising the child, they are considered sinful.
Custody ends when the child reaches maturity; once they are mature, no one has the right to custody over them, including the parents, as they become the owner of themselves, whether male or female.
Yes, the authority to manage the child's finances and oversee their interests belongs to the father and paternal grandfather. If both are absent, the guardian appointed by either of them takes over. In the absence of a guardian, the legal ruler assumes this role. The mother, maternal grandfather, siblings, and other relatives have no guardianship rights over the child. However, it appears that in the absence of a ruler, this authority may be granted to just and righteous believers as a precaution.
May you be successful in all good.