Quick answer
pero = but; adds a contrast or a limitation to something you accept.
sino = but rather; corrects a preceding negative and replaces it with the true version.
sino only works after a negative. Before a conjugated verb it becomes sino que.
Side by side
Memory trick
Ask whether the second half <b>replaces</b> the first. Replacement means sino. Anything else, including most sentences with a negative, is pero.
Typical mistakes
No quiero vino, pero cerveza.
No quiero vino, sino cerveza.
Cerveza replaces vino, so this is a correction and needs sino. Pero would only work if the second half went in a different direction.
No trabaja, sino estudia.
No trabaja, sino que estudia.
A conjugated verb after sino requires que. Without it the sentence sounds unfinished to a native ear.
Check yourself
Fill in: "El examen no fue difícil, ___ larguísimo."