Similar Items: Resource Allocation and AoI-Aware Detection for ISAC with Stacked Intelligent Metasurfaces