Input lines: #foreground #background (6-digit hex). Compute each colour's relative luminance L = 0.2126 R + 0.7152 G + 0.0722 B, where each channel c (0–1) is linearized as c/12.92 if c ≤ 0.04045, else ((c + 0.055)/1.055)^2.4. The contrast ratio is (L_lighter + 0.05)/(L_darker + 0.05).
Print #777777 on #ffffff: 4.48:1 -> text FAIL, large text pass, graphics pass using the thresholds text 4.5, large text 3.0, graphics 3.0 (pass if ratio ≥ threshold, else FAIL).