The community has already prayed Maariv and the sun hasn't set yet. Can I still do a hefsek?
Ideally (lechatchila), the hefsek is done before the community davens Maariv. If the community has already prayed and it is still day, the hefsek counts after the fact (bedieved).
If you yourself have already accepted Shabbat or prayed Maariv, it is best to ask a rabbi.
This is one to ask a rabbi.
Sources
- Shulchan Arukh, Yoreh De'ah 196:1
ונוהגין לכתחלה ליזהר ובדיעבד אין לחוש
Levana shows; it does not rule. The decision stays with your rabbi.

