## 2 Materials and Methods
### Detection Mechanism and Experimental Setup  
As indicated in Figure 1e, as the incident wavelength varies from 500 to 700 nm, the MICP varies from the 2073 th pixel to the 2361 th pixel, which indicates a one-to-one correspondence between the wavelength and MICP; that is, for each incident wavelength, one corresponding MICP exists on the CCD. A transmission efficiency matrix \(T\) can be obtained from Figure 1e and used to represent this correlation. The variable \(T_{ij}\) can be used to represent the elements in \(T\). This variable indicates the transmission efficiency at the MICP \(i\) for the incident wavelength \(j\). For example, \(T_{5,100}\) represents the transmission efficiency for the 100 th wavelength at the fifth MICP. In this study, both \(i\) and \(j\) ranged from 1 to 200. An incident spectrum can be digitized and represented by a single-column matrix, where the elements are denoted by \(I_{j}\), which indicates the intensity of the \(j\)th wavelength, where \(j\) ranges from 1 to 200 and represents wavelengths of 500-700 nm in 1-nm increments. The intensity measured on the CCD can then be calculated using the formula \(C=Tl\), where \(C\) is a column vector of size 200 and each element represents the intensity at each MICP on the CCD. For the incident spectrum presented as a blue curve in Figure 2a, which is obtained for assays such as a fluorescence emission or colorimetric assay, the CCD intensity distribution illustrated as a blue curve in Figure 2b can be obtained using a simple matrix multiplication. The MICP in Figure 2b corresponds to the peak wavelength based on the calibration diagram presented in Figure 1c. When the intensity of the incident spectrum is reduced without changing its center wavelength, as indicated by the blue dashed line in Figure 2a, the corresponding intensity distribution in the CCD is also reduced, as illustrated by the  
Figure 1: (**a**) Illustration of a three-layer gradient grating period guided-mode resonance (GGP-GMR) device on top of a charge-coupled device (CCD). The large blue arrow indicates an incident light with a specific wavelength, and the orange arrow indicates the light reflected at a specific grating period. The reflected light indicated by the orange arrow results in the minimum intensity in the underneath CCD pixel (represented in dark gray). Intensity distribution on the CCD for incident wavelengths of (**b**) 520, (**c**) 600, and (**d**) 680 nm. (**e**) Calibration diagram of the transmission efficiency at each pixel for each wavelength. blue dashed curve in Figure 2b, without changing the MICP. If both the incident wavelength and intensity are varied, as indicated by the red curve in Figure 2a, the intensity and location of the MICP change accordingly. In summary, the peak wavelength and intensity of the incident illumination are correlated with the location and intensity of the MICP in the GGP-GMR/CCD system that does not contain a bulky spectrometer. The experimental setup presented in Figure 2c was used to demonstrate that the proposed GGP-GMR device and CCD can be used as a compact platform for fluorescence and colorimetric assay detection. A customized sample chamber was used to hold the cuvette and connect the light source and optical fiber. For fluorescence measurement, the excitation light was set perpendicular to the detection optics to minimize the interference. By contrast, for colorimetric detection, the light source was placed in line with the detection optics to measure the transmission. To evaluate the performance of the proposed GGP-GMR/CCD detection platform, the light emitted from the fluorophores or transmitted through the samples was collected by a ball lens and coupled to a \(2\times 1\) fiber, whose one end was connected to a commercial spectrometer (2000+VIS-NIR-ES, Ocean Inside, Orlando, FL, USA) and other end was connected to the GGP-GMR/CCD system. Depending on the assays and the excitation light source, a filter might need to be used before the light is coupled to the \(2\times 1\) fiber.