Move camera with mouse (2D)

I want to create a map of my 3D scene. So I have placed a camera in the sky looking down. When M is pressed, I’m switching from the character controller camera to this camera. Now I want to move this camera in up, down, left and right directions with mouse’s movement. So that would be the camera’s movement in X and Z axes reading input from mouse’s X and Z axes. Can you help me with the script? Thanks.

This is what I have so far:

	if (Input.GetAxis("Mouse X")>0)
		{
			transform.localPosition = new Vector3 (transform.position.x,transform.position.y,transform.position.z+5);
	
		}

		if (Input.GetAxis("Mouse X")<0)
		{
			transform.localPosition = new Vector3 (transform.position.x,transform.position.y,transform.position.z-5);
			
		}

		if (Input.GetAxis("Mouse Y")<0)
		{
			transform.localPosition = new Vector3 (transform.position.x+5,transform.position.y,transform.position.z);
			
		}

		if (Input.GetAxis("Mouse Y")>0)
		{
			transform.localPosition = new Vector3 (transform.position.x-5,transform.position.y,transform.position.z);
			
		}

But the movement is jagged especially when moved in diagonal directions. So should I consider input from both mouse axes at the same time?

Also how do I set bounds for the camera so it won’t go off the terrain?

float speed = 3f;
transform.position += new Vector3(Input.GetAxisRaw(“Mouse X”) * Time.deltaTime * speed, 0f, Input.GetAxisRaw(“Mouse Y”) * Time.deltaTime * speed);