Limit the rotation of a Bone

I am attempting to create an arm that will follow the mouse cursor, I have a basic script that allows for it to follow the mouse cursor but it doesn’t limit rotation. In general I would like to be able to limit the chain’s rotation either through components or a script.

public class BoneLookAt : MonoBehaviour
{
    public Transform target;
    public float speed = 5f;
    public float minRotation = -45f;
    public float maxRotation = 45f;
    // Update is called once per frame
    void Update()
    {
        
            try
            {
                // Get the direction to the target
                Vector3 direction = target.position - transform.position;
                direction.z = 0f;
          
                // Smoothly rotate the bone towards the target
                Quaternion rotation = Quaternion.LookRotation(Vector3.forward, direction);
            rotation *= Quaternion.Euler(0, 0, 90);
            
            rotation.z = Mathf.Clamp(rotation.z, minRotation, maxRotation);
            transform.rotation = Quaternion.Lerp(transform.rotation, rotation, Time.deltaTime * speed);
            

        }
            catch (System.NullReferenceException e)
            {
                // Log the error
                Debug.LogError($"Error: {e.Message}");
            }
        
    }
}