The mechanism, simply
Caffeine works by blocking adenosine, a chemical that builds up during the day and makes you feel sleepy. The longer caffeine stays in your system, the longer that sleep pressure is held back. That is why a cup at 3 pm can still be pushing against your sleep pressure at 10 pm.
Because the half-life is roughly 5-6 hours, an afternoon cup still leaves meaningful caffeine near bedtime. It does not just delay when you fall asleep — it can also shorten deep sleep and increase light sleep, so you wake after a full night still feeling tired.
Dose and time matter together
The effect depends on both how much you drink and when. A small morning coffee is mostly gone by night for most people. A large afternoon coffee is a different story: it can still be at 25-50% strength at bedtime, which is enough to matter.
This is why a simple cutoff works so well: stop caffeine about 8-10 hours before bed, and most of it clears before sleep. Use the calculator to see your own numbers.
Everyone is different
Sensitivity varies with genetics, regular use, weight, and medication. Some people can drink espresso after dinner and sleep fine; others lose sleep over a mid-afternoon tea. If you are the sensitive type, your personal cutoff is earlier than average.
If you want to know your own threshold, test it for a week: cut caffeine after noon, keep everything else the same, and compare your sleep quality. The data will tell you more than any general rule.
Quick answers
Does caffeine reduce deep sleep?
It can. Caffeine can shorten deep sleep and increase light sleep, leaving you tired even after a full night.
How long before bed should I stop caffeine?
About 8-10 hours, so most of it clears before sleep.
Is morning coffee OK for sleep?
Usually. Morning caffeine is mostly gone by night for most people.
Why do I feel tired even after sleeping 8 hours?
Caffeine lingering from the day can lighten sleep. Try an earlier cutoff for a week and compare.
Does decaf before bed matter?
For most people no; very sensitive sleepers may notice its small caffeine amount.