In a 6-3 ruling, justices uphold decision by state's top court as Republicans tried to do away with judicial input on issues such as congressional districts, voter registration