I hope you're not thinking that you're the first person to whom this has ever happened.
First step is to try unformatting your card. This can be completely trivial with standard PC data recovery tools. Easeus and Testdisk are popular.
But if you want to start over,
https://3ds.guide/restoring-updating-cfw .
If your 3DS isn't booting because you didn't follow
https://3ds.guide when you installed CFW, then be sure not to skip the step where Luma is installed to the NAND.