More than 20 years ago, the international community agreed that teenagers should only be jailed as a last resort—and never placed in solitary confinement.