Optimal tuning of solid-state quantum gates: A universal two-qubit gate