Nearly 200 countries rescue climate deal from jaws of defeat after UN's COP29 summit ran into overtime in Baku.