In short: long-term residence is obtained after 5 years of continuous legal residence in Spain; it allows residing and working indefinitely. It is a separate authorisation, not a mere renewal (RD 1155/2024, arts. 175-189).
In person or by representative? The source does not detail this: the application can usually be filed online or through a representative, but fingerprinting and TIE card collection are in person. By default, prepare for personal appearance and check with your Oficina de Extranjería.
Main requirement: 5 years of continuous legal residence (or alternative routes under art. 32.2 LOEX: birth in Spain, prior Spanish nationality, subsidiary protection, among others).
Continuity (allowed absences): up to 6 months in a row and a maximum of 10 months in total over the 5 years; extendable to 12 months where the absence is due to a duly notified work activity.
Other requirements: not being an EU/EEA/Swiss citizen (they have their own regime) and having no criminal record in Spain or in the countries of residence over the last 5 years.
Official source: Immigration Regulation (RD 1155/2024); detail at inclusion.gob.es.
Informational only; exact requirements and documents vary — check the official source and a professional for your case.