Your requirements statement is terribly hard to read, but it seems to be saying "Select the <details> with the given <title>. If there is a <categ>, select all <details> elements with the same <categ>. Otherwise, select all <details> elements with the same <list>."
That is
<xsl:variable name="d" select="/root/details[title=$inputTitle]"/>
then
select="/root/details[($d/categ != '' and $d/categ = categ)
or ($d/categ = '' and $d/list = list]"/>
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer's Reference