Precise weed detection in complex cotton fields is a critical prerequisite for site-specific weed control and precision management. To address the challenges of small weed targets, high inter-class similarity, occlusion, and illumination variations that affect detection accuracy in cotton fields, this paper proposes CWD-YOLO, an improved model based on YOLO26n. CWD-YOLO reconstructs the original backbone network using GhostNetV3 to enhance low-level visual feature extraction, integrates TSSA into the C2PSA module to strengthen high-level semantic feature representation, and adopts AssemFormer in the C3k2 feature fusion stage to improve multi-scale local–global feature fusion. These designs enhance the detection of small, weak-feature, and occluded weed targets. On the CottonWeedDet12 benchmark dataset, CWD-YOLO achieved Precision, Recall, mAP@0.5, and mAP@0.5:0.95 values of 94.3%, 87.9%, 93.1%, and 87.6%, respectively, outperforming the baseline YOLO26n by 2.9, 2.7, 2.0, and 1.5 percentage points. Furthermore, in multi-dataset adaptability experiments on three external weed datasets, namely 3WDataset, 6WEED, and 3SeasonWeedDet10, CWD-YOLO consistently outperformed the baseline model, indicating its adaptability to different weed detection scenarios. The experimental results demonstrate that CWD-YOLO effectively improves weed detection accuracy in complex cotton fields and provides an effective method for precise field weed identification.