How to Reset Quaternion/Rotation On 3D Object After Dragging Mouse?

Hello, I have an issue with resetting my gameobject’s rotation. The rotation is based off mouse drag with restrictions. I have it to when the mouse is released the object returns to its starting rotation. But when I re-drag the object again the object rotation starts from where it was left off at from the previous drag. When I need it to drag from its starting rotation. I’ve tried many different methods nothing seems to work.

public Camera cam;
public float speed, minEulerX, maxEulerX, minEulerY, maxEulerY;
float eulerX, eulerY, rotateY, rotateX, inputX, inputY;
Quaternion startrot;
bool touch;

void Start()
{
    startrot = transform.rotation;
}

void Update()
{
    if (Input.GetMouseButtonDown(0))
    {
        Ray ray = cam.ScreenPointToRay(Input.mousePosition);
        if (Physics.Raycast(ray, out RaycastHit hit, Mathf.Infinity, Object))
        {
            inputX = Input.mousePosition.x;
            inputY = Input.mousePosition.y;
            touch = true;
        }
    }

    if (Input.GetMouseButton(0))
    {
        if (touch)
        {
            rotateX = -(Input.mousePosition.y - inputY) * speed;
            rotateY = -(Input.mousePosition.x - inputX) * speed;
            eulerX = Mathf.Clamp(eulerX + rotateX, minEulerX, maxEulerX);
            eulerY = Mathf.Clamp(eulerY + rotateY, minEulerY, maxEulerY);
            transform.rotation = Quaternion.Euler(-eulerX, eulerY, 0) * startrot;
            inputX = Input.mousePosition.x;
            inputY = Input.mousePosition.y;
        }
    }

    if (Input.GetMouseButtonUp(0))
    {
        transform.rotation = startrot;
        touch = false;
    }    
}

You have to set your inputX and inputY to zero so to not start the offset at a weird angle.
Insert into your if(Input.GetMouseButtonUp(0)) function: inputX = 0; inputY = 0;

Set zero the eulerX and eulerY values after rotating