Don't discount acid reflux as the culprit, or underlying problem. I have acid reflux and if it goes untreated, or gets out of control, I have allot coughing and cough up phlegm. It's usually milky, to yellow in color and it can be thick. It wouldn't hurt to try an over the counter drug, like . You don't have to have heartburn symptoms, to be suffering from acid reflux. Good luck and hope all is going well.
Vitamin D supplements, as Red_Star suggested, are a good idea. You might want to get your D3 levels checked. The test is relatively inexpensive. You should be using an expectorant such as Guaifenesen (Brand names Albatussin EX, Allfen Jr., Altorant...) to assist in breaking up the mucus. Drink plenty of fluids with this medication. You don't want to rupture blood vessels from the coughing. You might also try an electric nebulizer filled with a little sterile normal saline. It sounds like you may be regurgitating a bit of stomach acid because of a relaxed Lower esophageal sphincter. This can be exacerbated with chemicals called methylxanthines, which are found in coffee and chocolate. Try sleeping with your upper body at a 20-30 degree angle.
I get plenty of phlegm when i forget to take my vitamin D supplement. I'm borderline deficient, but was severely deficient, so this symptom shows up quick smart. I am SO glad i know what the problem is. If i am clearing my throat i get a "take your vitamin D" comment lol!