The question is sort of framed as "how much is safe," but in reality it's very individual. One person can easily drink four cups and sleep like a baby, another gets nervous after two and won't sleep a wink all night. So the universal answer of "four cups a day" is more of a guideline for the average person without heart or blood pressure problems, not a direct instruction to follow.
I had a situation like this: for a long time I drank coffee basically all day - a few cups in the morning, then one more at 4pm, 6pm. I noticed my heart rate picked up, and I'd get occasional blood pressure spikes. I tried cutting back to two cups a day - just before noon, so the caffeine would wear off by evening. Things normalized. Maybe it was a coincidence, but now I stick to that schedule and feel better.
The main thing is to listen to your body, not follow the numbers in articles. If you notice insomnia, anxiety, a racing heart after coffee - that's a signal it's too much for you. If you handle it fine - then your body's coping. And yeah, it makes sense to drink coffee in the morning and early afternoon, not all day long.