A boy raped two teenage girls and sexually assaulted another girl when he was aged 13, a court has heard.
A judge has ordered that the boy, who is now 15, be detained for three years and should be kept under supervision for a further five years.
The 15-year-old girls were raped at a house in a Highland town and the 13-year-old girl was attacked in a nearby wooded area five months later.
Judge Michael O'Grady QC said they were "dreadful sexual attacks".
The boy, who cannot be identified because he is under 18, was ordered to be detained after appearing at the High Court in Edinburgh.
He had denied a number of charges during an earlier trial and was found guilty of three offences, which happened in 2018.
Mr O'Grady said: "The effect upon these girls is inevitably incalculable.
"You were at the time a child yourself. Even now you are only 15. These courts have long recognised the limitations of responsibility and maturity in young offenders.
"Your life to date has not been without difficulties and so far as I can tell most of these are not of your own making."
But Mr O'Grady said the teenager had to understand what he had done was "wrong and unwanted and cruel and hurtful".
The judge said the offences themselves raised "grave concerns for the future" given their nature and number.
The judge said that the youth's present attitude to the offences and victims was also a cause for concern.
Mr O'Grady said he was aware of previous appeal court decisions in such cases.
He said: "The court must have regard to the best interests of the child as a primary consideration and a factor in that will be the child's rehabilitation into society.
"I am bound by that approach and it is indeed the approach I take."
Mr O'Grady said the guidance he took from the appeal court was to the effect that the overarching consideration when sentencing a child was the interests of that child, but he added that it was not the only consideration.
The judge said he was satisfied that only a period of detention could meet the circumstances of the teenager's case.