Hearts returned to the top of the Scottish Premiership but dropped what could be crucial points in the title race at bottom side Livingston.