Walks the string one character at a time, tracking the open ( and [ depth as tuple
lengths (Parens / Brackets). Written as a tail-recursive conditional type so TypeScript's
tail-call optimisation can handle long inputs — the longest of the supplied examples is ~357
characters, comfortably under the ~1000-step limit.
Resolves to S itself when S is a structurally-plausible SMILES string, otherwise never.
Mirrors the spirit of the CAS<T> type in cas.d.ts: a literal in, a constrained literal out.
Every character legal in a SMILES string (matches SMILES_CHAR in smiles.ts).