Consider ideal MHD: infinite conductivity, frozen-in magnetic field lines etc. Clearly total energy of the system is conserved (magnetic field energy + plasma internal energy + kinetic energy = const). This suggests that the energy can be redistributed between these components, for example kinetic energy can be converted into magnetic.
But I don't understand how is it going on the microscopic level. Lorentz force does not do work and because of perfect conductivity E = -v$\times$B, electric field is perpendicular to velocity so again zero work. Naively it looks like magnetic energy should be conserved separately. Where am I wrong?