What advice do you have to keep one’s mental state straight? Recently, I committed a sin that has made me feel guilty and lose focus

1- Remember that Allah gives you a completely new sheet when you repent. Don’t doubt His mercy. Yes be determined to never commit the sin again but don’t doubt his mercy.

2- Compensate for the feeling of guilt that you have by doing more good deeds. It helps

3- Read the 15 Munajat of Imam Zainul Abidin (a), preferably one each night.

4- I recommend seeing this lecture:
https://youtu.be/AD7rkpqotYA