Worked example
A 200 mg drink at 2:00 PM with a 5-hour half-life has about 132 mg remaining at 5:00 PM (3 hours later) and about 57 mg remaining at 11:00 PM (9 hours later). It reaches 50 mg a little after 11:20 PM. Change the half-life and those times move.
The same math as the iPhone app
Brewlytics Pro applies this half-life model to every logged drink, then adds the remaining amounts. The website calculator is for one drink at a time so you can inspect the assumption. The app keeps the running total from your actual log, widgets, and bedtime setting.
Use it as a planning aid
If the bedtime estimate is higher than you want, the practical levers are an earlier last drink, a smaller serving, or a longer gap before sleep. Individual sensitivity varies, and this page does not diagnose sleep or give medical advice.