Power loss detection

Writing to flash can take a fair amount of current and the required capacitor will probably be surprisingly large.

I’d look at just using a battery powered Arduino/smd card and be done with it - as capacitors are lousy energy storage devices.