Good concise advice, and that's certainly a baseline. In my case I am speaking (asking) more about replicating functionality or an idea, which is a lot more difficult to know where to draw a line on.
So one line would be: if the idea isn't patented, or it is, but you don't think the patent is valid, and have the money to back up your claim, or just feel ornery, then go for it.
People replicate functionality all the time. Why should that be unethical? I wouldn't just replicate it for no good reason. A good reason, and one that the spirit of the law is supposed to support, is, does it provide new value to the customer? Coincidentally, that is the same question you should be asking yourself if you plan to take your work to market.