Tangle theory