First off, congratulations! While your black toenail might be causing you some anxiety, don't fret. Having a black toenail is somewhat of a rite of passage among runners. In fact, lots of professionals and elites show off their black toenails with pride!
Black toenails are nothing to fear, though as you are aware, they can be pretty painful. A black toenail is essentially just a bruised toe nail - or rather, bruised skin under the toenail. They can happen because you hit your toe against something really hard (as in your case and in the case of most runners) or because of repeated rubbing of moist, sweat drenched skin against the inside of your shoe when you repeatedly pound the ground during runs. In this way, a blood blister can form under the nail and because of the protective nature of the hard nail alongside repeated use, they can take a while to fully heal. They also might indicate that you have a toe fungus growing there, like athlete's foot. A simple antibiotic or topical cream can get rid of these.
In your case, I think time is what will heal your black toenail. If the pain gets too intense, and over the counter pain killer should help. And don't worry if your toenail falls off. It can be alarming, but it means your body needs a stronger toenail to take its place. To avoid future black toenails, there are a number of precautions you can take. There's not much you can do as far as hitting it hard on hard surfaces - things happen, and you might be running on a new-to-you trail which you do not know each bump and turn as well. But keep these tips in mind: buy your running shoes a half size bigger than your street shoe size for some (literal) wiggle room between the end of your toe and the inside of your shoe so that you can avoid constant banging. And where the right kind of socks. Thick socks that wick sweat well are your best option because they will stop moisture from building up and causing blisters.
Sources:
https://www.verywell.com/how-to-prevent-and-treat-black-toenails-from-running-2911044
https://www.runnersworld.com/black-toenails/5-causes-of-black-toenails-and-how-to-id-the-harmless-from-the-harmful/slide/3