How caffeine actually keeps you awake
Throughout the day, a chemical called adenosine builds up in your brain. Adenosine binds to receptors that make you feel sleepy. Caffeine has a near-identical shape and blocks those receptors — your brain still produces adenosine, but it can't bind, so you don't feel the accumulated sleep pressure. The moment the caffeine clears, all that adenosine binds at once and you crash.
The 5-hour half-life
Caffeine has an average half-life of about 5 hours in healthy adults. That means if you drink a 100 mg coffee at 3pm, around 50 mg is still in you at 8pm and 25 mg at 1am. The calculator uses this exponential decay to find the latest time you can drink without leaving too much caffeine in your system at bedtime.
Why slow metabolisers should be especially careful
Caffeine metabolism varies enormously between people, mostly because of a liver enzyme called CYP1A2. Slow metabolisers — about half the population — can hold caffeine for 7+ hours. Pregnant women metabolise it even more slowly. People who quit smoking suddenly find their tolerance crashes because nicotine sped up their metabolism. If caffeine routinely wrecks your sleep, set your personal cutoff at least a few hours earlier than the generic recommendation.
The 50 mg threshold
Studies find that even modest amounts of caffeine at bedtime — around 50 mg — measurably reduce sleep efficiency, delay sleep onset and cut deep sleep. That's why the calculator targets keeping you under 50 mg of caffeine remaining when you go to bed, not zero. If you're particularly sensitive, treat the recommended cutoff as a ceiling and aim earlier.