openlogi 0.6.26

OpenLogi command-line interface — a local-first companion for Logitech HID++ peripherals.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357
6358
6359
6360
6361
6362
6363
6364
6365
6366
6367
6368
6369
6370
6371
6372
6373
6374
6375
6376
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
6397
6398
6399
6400
6401
6402
6403
6404
6405
6406
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
6425
6426
6427
6428
6429
6430
6431
6432
6433
6434
6435
6436
6437
6438
6439
6440
6441
6442
6443
6444
6445
6446
6447
6448
6449
6450
6451
6452
6453
6454
6455
6456
6457
6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
6468
6469
6470
6471
6472
6473
6474
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6520
6521
6522
6523
6524
6525
6526
6527
6528
6529
6530
6531
6532
6533
6534
6535
6536
6537
6538
6539
6540
6541
6542
6543
6544
6545
6546
6547
6548
6549
6550
6551
6552
6553
6554
6555
6556
6557
6558
6559
6560
6561
6562
6563
6564
6565
6566
6567
6568
6569
6570
6571
6572
6573
6574
6575
6576
6577
6578
6579
6580
6581
6582
6583
6584
6585
6586
6587
6588
6589
6590
6591
6592
6593
6594
6595
6596
6597
6598
6599
6600
6601
6602
6603
6604
6605
6606
6607
6608
6609
6610
6611
6612
6613
6614
6615
6616
6617
6618
6619
6620
6621
6622
6623
6624
6625
6626
6627
6628
6629
6630
6631
6632
6633
6634
6635
6636
6637
6638
6639
6640
6641
6642
6643
6644
6645
6646
6647
6648
6649
6650
6651
6652
6653
6654
6655
6656
6657
6658
6659
6660
6661
6662
6663
6664
6665
6666
6667
6668
6669
6670
6671
6672
6673
6674
6675
6676
6677
6678
6679
6680
6681
6682
6683
6684
6685
6686
6687
6688
6689
6690
6691
6692
6693
6694
6695
6696
6697
6698
6699
6700
6701
6702
6703
6704
6705
6706
6707
6708
6709
6710
6711
6712
6713
6714
6715
6716
6717
6718
6719
6720
6721
6722
6723
6724
6725
6726
6727
6728
6729
6730
6731
6732
6733
6734
6735
6736
6737
6738
6739
6740
6741
6742
6743
6744
6745
6746
6747
6748
6749
6750
6751
6752
6753
6754
6755
6756
6757
6758
6759
6760
6761
6762
6763
6764
6765
6766
6767
6768
6769
6770
6771
6772
6773
6774
6775
6776
6777
6778
6779
6780
6781
6782
6783
6784
6785
6786
6787
6788
6789
6790
6791
6792
6793
6794
6795
6796
6797
6798
6799
6800
6801
6802
6803
6804
6805
6806
6807
6808
6809
6810
6811
6812
6813
6814
6815
6816
6817
6818
6819
6820
6821
6822
6823
6824
6825
6826
6827
6828
6829
6830
6831
6832
6833
6834
6835
6836
6837
6838
6839
6840
6841
6842
6843
6844
6845
6846
6847
6848
6849
6850
6851
6852
6853
6854
6855
6856
6857
6858
6859
6860
6861
6862
6863
6864
6865
6866
6867
6868
6869
6870
6871
6872
6873
6874
6875
6876
6877
6878
6879
6880
6881
6882
6883
6884
6885
6886
6887
6888
6889
6890
6891
6892
6893
6894
6895
6896
6897
6898
6899
6900
6901
6902
6903
6904
6905
6906
6907
6908
6909
6910
6911
6912
6913
6914
6915
6916
6917
6918
6919
6920
6921
6922
6923
6924
6925
6926
6927
6928
6929
6930
6931
6932
6933
6934
6935
6936
6937
6938
6939
6940
6941
6942
6943
6944
6945
6946
6947
6948
6949
6950
6951
6952
6953
6954
6955
6956
6957
6958
6959
6960
6961
6962
6963
6964
6965
6966
6967
6968
6969
6970
6971
6972
6973
6974
6975
6976
6977
6978
6979
6980
6981
6982
6983
6984
6985
6986
6987
6988
6989
6990
6991
6992
6993
6994
6995
6996
6997
6998
6999
7000
7001
7002
7003
7004
7005
7006
7007
7008
7009
7010
7011
7012
7013
7014
7015
7016
7017
7018
7019
7020
7021
7022
7023
7024
7025
7026
7027
7028
7029
7030
7031
7032
7033
7034
7035
7036
7037
7038
7039
7040
7041
7042
7043
7044
7045
7046
7047
7048
7049
7050
7051
7052
7053
7054
7055
7056
7057
7058
7059
7060
7061
7062
7063
7064
7065
7066
7067
7068
7069
7070
7071
7072
7073
7074
7075
7076
7077
7078
7079
7080
7081
7082
7083
7084
7085
7086
7087
7088
7089
7090
7091
7092
7093
7094
7095
7096
7097
7098
7099
7100
7101
7102
7103
7104
7105
7106
7107
7108
7109
7110
7111
7112
7113
7114
7115
7116
7117
7118
7119
7120
7121
7122
7123
7124
7125
7126
7127
7128
7129
7130
7131
7132
7133
7134
7135
7136
7137
7138
7139
7140
7141
7142
7143
7144
7145
7146
7147
7148
7149
7150
7151
7152
7153
7154
7155
7156
7157
7158
7159
7160
7161
7162
7163
7164
7165
7166
7167
7168
7169
7170
7171
7172
7173
7174
7175
7176
7177
7178
7179
7180
7181
7182
7183
7184
7185
7186
7187
7188
7189
7190
7191
7192
7193
7194
7195
7196
7197
7198
7199
7200
7201
7202
7203
7204
7205
7206
7207
7208
7209
7210
7211
7212
7213
7214
7215
7216
7217
7218
7219
7220
7221
7222
7223
7224
7225
7226
7227
7228
7229
7230
7231
7232
7233
7234
7235
7236
7237
7238
7239
7240
7241
7242
7243
7244
7245
7246
7247
7248
7249
7250
7251
7252
7253
7254
7255
7256
7257
7258
7259
7260
7261
7262
7263
7264
7265
7266
7267
7268
7269
7270
7271
7272
7273
7274
7275
7276
7277
7278
7279
7280
7281
7282
7283
7284
7285
7286
7287
7288
7289
7290
7291
7292
7293
7294
7295
7296
7297
7298
7299
7300
7301
7302
7303
7304
7305
7306
7307
7308
7309
7310
7311
7312
7313
7314
7315
7316
7317
7318
7319
7320
7321
7322
7323
7324
7325
7326
7327
7328
7329
7330
7331
7332
7333
7334
7335
7336
7337
7338
7339
7340
7341
7342
7343
7344
7345
7346
7347
7348
7349
7350
7351
7352
7353
7354
7355
7356
7357
7358
7359
7360
7361
7362
7363
7364
7365
7366
7367
7368
7369
7370
7371
7372
7373
7374
7375
7376
7377
7378
7379
7380
7381
7382
7383
7384
7385
7386
7387
7388
7389
7390
7391
7392
7393
7394
7395
7396
7397
7398
7399
7400
7401
7402
7403
7404
7405
7406
7407
7408
7409
7410
7411
7412
7413
7414
7415
7416
7417
7418
7419
7420
7421
7422
7423
7424
7425
7426
7427
7428
7429
7430
7431
7432
7433
7434
7435
7436
7437
7438
7439
7440
7441
7442
7443
7444
7445
7446
7447
7448
7449
7450
7451
7452
7453
7454
7455
7456
7457
7458
7459
7460
7461
7462
7463
7464
7465
7466
7467
7468
7469
7470
7471
7472
7473
7474
7475
7476
7477
7478
7479
7480
7481
7482
7483
7484
7485
7486
7487
7488
7489
7490
7491
7492
7493
7494
7495
7496
7497
7498
7499
7500
7501
7502
7503
7504
7505
7506
7507
7508
7509
7510
7511
7512
7513
7514
7515
7516
7517
7518
7519
7520
7521
7522
7523
7524
7525
7526
7527
7528
7529
7530
7531
7532
7533
7534
7535
7536
7537
7538
7539
7540
7541
7542
7543
7544
7545
7546
7547
7548
7549
7550
7551
7552
7553
7554
7555
7556
7557
7558
7559
7560
7561
7562
7563
7564
7565
7566
7567
7568
7569
7570
7571
7572
7573
7574
7575
7576
7577
7578
7579
7580
7581
7582
7583
7584
7585
7586
7587
7588
7589
7590
7591
7592
7593
7594
7595
7596
7597
7598
7599
7600
7601
7602
7603
7604
7605
7606
7607
7608
7609
7610
7611
7612
7613
7614
7615
7616
7617
7618
7619
7620
7621
7622
7623
7624
7625
7626
7627
7628
7629
7630
7631
7632
7633
7634
7635
7636
7637
7638
7639
7640
7641
7642
7643
7644
7645
7646
7647
7648
7649
7650
7651
7652
7653
7654
7655
7656
7657
7658
7659
7660
7661
7662
7663
7664
7665
7666
7667
7668
7669
7670
7671
7672
7673
7674
7675
7676
7677
7678
7679
7680
7681
7682
7683
7684
7685
7686
7687
7688
7689
7690
7691
7692
7693
7694
7695
7696
7697
7698
7699
7700
7701
7702
7703
7704
7705
7706
7707
7708
7709
7710
7711
7712
7713
7714
7715
7716
7717
7718
7719
7720
7721
7722
7723
7724
7725
7726
7727
7728
7729
7730
7731
7732
7733
7734
7735
7736
7737
7738
7739
7740
7741
7742
7743
7744
7745
7746
7747
7748
7749
7750
7751
7752
7753
7754
7755
7756
7757
7758
7759
7760
7761
7762
7763
7764
7765
7766
7767
7768
7769
7770
7771
7772
7773
7774
7775
7776
7777
7778
7779
7780
7781
7782
7783
7784
7785
7786
7787
7788
7789
7790
7791
7792
7793
7794
7795
7796
7797
7798
7799
7800
7801
7802
7803
7804
7805
7806
7807
7808
7809
7810
7811
7812
7813
7814
7815
7816
7817
7818
7819
7820
7821
7822
7823
7824
7825
7826
7827
7828
7829
7830
7831
7832
7833
7834
7835
7836
7837
7838
7839
7840
7841
7842
7843
7844
7845
7846
7847
7848
7849
7850
7851
7852
7853
7854
7855
7856
7857
7858
7859
7860
7861
7862
7863
7864
7865
7866
7867
7868
7869
7870
7871
7872
7873
7874
7875
7876
7877
7878
7879
7880
7881
7882
7883
7884
7885
7886
7887
7888
7889
7890
7891
7892
7893
7894
7895
7896
7897
7898
7899
7900
7901
7902
7903
7904
7905
7906
7907
7908
7909
7910
7911
7912
7913
7914
7915
7916
7917
7918
7919
7920
7921
7922
7923
7924
7925
7926
7927
7928
7929
7930
7931
7932
7933
7934
7935
7936
7937
7938
7939
7940
7941
7942
7943
7944
7945
7946
7947
7948
7949
7950
7951
7952
7953
7954
7955
7956
7957
7958
7959
7960
7961
7962
7963
7964
7965
7966
7967
7968
7969
7970
7971
7972
7973
7974
7975
7976
7977
7978
7979
7980
7981
7982
7983
7984
7985
7986
7987
7988
7989
7990
7991
7992
7993
7994
7995
7996
7997
7998
7999
8000
8001
8002
8003
8004
8005
8006
8007
8008
8009
8010
8011
8012
8013
8014
8015
8016
8017
8018
8019
8020
8021
8022
8023
8024
8025
8026
8027
8028
8029
8030
8031
8032
8033
8034
8035
8036
8037
8038
8039
8040
8041
8042
8043
8044
8045
8046
8047
8048
8049
8050
8051
8052
8053
8054
8055
8056
8057
8058
8059
8060
8061
8062
8063
8064
8065
8066
8067
8068
8069
8070
8071
8072
8073
8074
8075
8076
8077
8078
8079
8080
8081
8082
8083
8084
8085
8086
8087
8088
8089
8090
8091
8092
8093
8094
8095
8096
8097
8098
8099
8100
8101
8102
8103
8104
8105
8106
8107
8108
8109
8110
8111
8112
8113
8114
8115
8116
8117
8118
8119
8120
8121
8122
8123
8124
8125
8126
8127
8128
8129
8130
8131
8132
8133
8134
8135
8136
8137
8138
8139
8140
8141
8142
8143
8144
8145
8146
8147
8148
8149
8150
8151
8152
8153
8154
8155
8156
8157
8158
8159
8160
8161
8162
8163
8164
8165
8166
8167
8168
8169
8170
8171
8172
8173
8174
8175
8176
8177
8178
8179
8180
8181
8182
8183
8184
8185
8186
8187
8188
8189
8190
8191
8192
8193
8194
8195
8196
8197
8198
8199
8200
8201
8202
8203
8204
8205
8206
8207
8208
8209
8210
8211
8212
8213
8214
8215
8216
8217
8218
8219
8220
8221
8222
8223
8224
8225
8226
8227
8228
8229
8230
8231
8232
8233
8234
8235
8236
8237
8238
8239
8240
8241
8242
8243
8244
8245
8246
8247
8248
8249
8250
8251
8252
8253
8254
8255
8256
8257
8258
8259
8260
8261
8262
8263
8264
8265
8266
8267
8268
8269
8270
8271
8272
8273
8274
8275
8276
8277
8278
8279
8280
8281
8282
8283
8284
8285
8286
8287
8288
8289
8290
8291
8292
8293
8294
8295
8296
8297
8298
8299
8300
8301
8302
8303
8304
8305
8306
8307
8308
8309
8310
8311
8312
8313
8314
8315
8316
8317
8318
8319
8320
8321
8322
8323
8324
8325
8326
8327
8328
8329
8330
8331
8332
8333
8334
8335
8336
8337
8338
8339
8340
8341
8342
8343
8344
8345
8346
8347
8348
8349
8350
8351
8352
8353
8354
8355
8356
8357
8358
8359
8360
8361
8362
8363
8364
8365
8366
8367
8368
8369
8370
8371
8372
8373
8374
8375
8376
8377
8378
8379
8380
8381
8382
8383
8384
8385
8386
8387
8388
8389
8390
8391
8392
8393
8394
8395
8396
8397
8398
8399
8400
8401
8402
8403
8404
8405
8406
8407
8408
8409
8410
8411
8412
8413
8414
8415
8416
8417
8418
8419
8420
8421
8422
8423
8424
8425
8426
8427
8428
8429
8430
8431
8432
8433
8434
8435
8436
8437
8438
8439
8440
8441
8442
8443
8444
8445
8446
8447
8448
8449
8450
8451
8452
8453
8454
8455
8456
8457
8458
8459
8460
8461
8462
8463
8464
8465
8466
8467
8468
8469
8470
8471
8472
8473
8474
8475
8476
8477
8478
8479
8480
8481
8482
8483
8484
8485
8486
8487
8488
8489
8490
8491
8492
8493
8494
8495
8496
8497
8498
8499
8500
8501
8502
8503
8504
8505
8506
8507
8508
8509
8510
8511
8512
8513
8514
8515
8516
8517
8518
8519
8520
8521
8522
8523
8524
8525
8526
8527
8528
8529
8530
8531
8532
8533
8534
8535
8536
8537
8538
8539
8540
8541
8542
8543
8544
8545
8546
8547
8548
8549
8550
8551
8552
8553
8554
8555
8556
8557
8558
8559
8560
8561
8562
8563
8564
8565
8566
8567
8568
8569
8570
8571
8572
8573
8574
8575
8576
8577
8578
8579
8580
8581
8582
8583
8584
8585
8586
8587
8588
8589
8590
8591
8592
8593
8594
8595
8596
8597
8598
8599
8600
8601
8602
8603
8604
8605
8606
8607
8608
8609
8610
8611
8612
8613
8614
8615
8616
8617
8618
8619
8620
8621
8622
8623
8624
8625
8626
8627
8628
8629
8630
8631
8632
8633
8634
8635
8636
8637
8638
8639
8640
8641
8642
8643
8644
8645
8646
8647
8648
8649
8650
8651
8652
8653
8654
8655
8656
8657
8658
8659
8660
8661
8662
8663
8664
8665
8666
8667
8668
8669
8670
8671
8672
8673
8674
8675
8676
8677
8678
8679
8680
8681
8682
8683
8684
8685
8686
8687
8688
8689
8690
8691
8692
8693
8694
8695
8696
8697
8698
8699
8700
8701
8702
8703
8704
8705
8706
8707
8708
8709
8710
8711
8712
8713
8714
8715
8716
8717
8718
8719
8720
8721
8722
8723
8724
8725
8726
8727
8728
8729
8730
8731
8732
8733
8734
8735
8736
8737
8738
8739
8740
8741
8742
8743
8744
8745
8746
8747
8748
8749
8750
8751
8752
8753
8754
8755
8756
8757
8758
8759
8760
8761
8762
8763
8764
8765
8766
8767
8768
8769
8770
8771
8772
8773
8774
8775
8776
8777
8778
8779
8780
8781
8782
8783
8784
8785
8786
8787
8788
8789
8790
8791
8792
8793
8794
8795
8796
8797
8798
8799
8800
8801
8802
8803
8804
8805
8806
8807
8808
8809
8810
8811
8812
8813
8814
8815
8816
8817
8818
8819
8820
8821
8822
8823
8824
8825
8826
8827
8828
8829
8830
8831
8832
8833
8834
8835
8836
8837
8838
8839
8840
8841
8842
8843
8844
8845
8846
8847
8848
8849
8850
8851
8852
8853
8854
8855
8856
8857
8858
8859
8860
8861
8862
8863
8864
8865
8866
8867
8868
8869
8870
8871
8872
8873
8874
8875
8876
8877
8878
8879
8880
8881
8882
8883
8884
8885
8886
8887
8888
8889
8890
8891
8892
8893
8894
8895
8896
8897
8898
8899
8900
8901
8902
8903
8904
8905
8906
8907
8908
8909
8910
8911
8912
8913
8914
8915
8916
8917
8918
8919
8920
8921
8922
8923
8924
8925
8926
8927
8928
8929
8930
8931
8932
8933
8934
8935
8936
8937
8938
8939
8940
8941
8942
8943
8944
8945
8946
8947
8948
8949
8950
8951
8952
8953
8954
8955
8956
8957
8958
8959
8960
8961
8962
8963
8964
8965
8966
8967
8968
8969
8970
8971
8972
8973
8974
8975
8976
8977
8978
8979
8980
8981
8982
8983
8984
8985
8986
8987
8988
8989
8990
8991
8992
8993
8994
8995
8996
8997
8998
8999
9000
9001
9002
9003
9004
9005
9006
9007
9008
9009
9010
9011
9012
9013
9014
9015
9016
9017
9018
9019
9020
9021
9022
9023
9024
9025
9026
9027
9028
9029
9030
9031
9032
9033
9034
9035
9036
9037
9038
9039
9040
9041
9042
9043
9044
9045
9046
9047
9048
9049
9050
9051
9052
9053
9054
9055
9056
9057
9058
9059
9060
9061
9062
9063
9064
9065
9066
9067
9068
9069
9070
9071
9072
9073
9074
9075
9076
9077
9078
9079
9080
9081
9082
9083
9084
9085
9086
9087
9088
9089
9090
9091
9092
9093
9094
9095
9096
9097
9098
9099
9100
9101
9102
9103
9104
9105
9106
9107
9108
9109
9110
9111
9112
9113
9114
9115
9116
9117
9118
9119
9120
9121
9122
9123
9124
9125
9126
9127
9128
9129
9130
9131
9132
9133
9134
9135
9136
9137
9138
9139
9140
9141
9142
9143
9144
9145
9146
9147
9148
9149
9150
9151
9152
9153
9154
9155
9156
9157
9158
9159
9160
9161
9162
9163
9164
9165
9166
9167
9168
9169
9170
9171
9172
9173
9174
9175
9176
9177
9178
9179
9180
9181
9182
9183
9184
9185
9186
9187
9188
9189
9190
9191
9192
9193
9194
9195
9196
9197
9198
9199
9200
9201
9202
9203
9204
9205
9206
9207
9208
9209
9210
9211
9212
9213
9214
9215
9216
9217
9218
9219
9220
9221
9222
9223
9224
9225
9226
9227
9228
9229
9230
9231
9232
9233
9234
9235
9236
9237
9238
9239
9240
9241
9242
9243
9244
9245
9246
9247
9248
9249
9250
9251
9252
9253
9254
9255
9256
9257
9258
9259
9260
9261
9262
9263
9264
9265
9266
9267
9268
9269
9270
9271
9272
9273
9274
9275
9276
9277
9278
9279
9280
9281
9282
9283
9284
9285
9286
9287
9288
9289
9290
9291
9292
9293
9294
9295
9296
9297
9298
9299
9300
9301
9302
9303
9304
9305
9306
9307
9308
9309
9310
9311
9312
9313
9314
9315
9316
9317
9318
9319
9320
9321
9322
9323
9324
9325
9326
9327
9328
9329
9330
9331
9332
9333
9334
9335
9336
9337
9338
9339
9340
9341
9342
9343
9344
9345
9346
9347
9348
9349
9350
9351
9352
9353
9354
9355
9356
9357
9358
9359
9360
9361
9362
9363
9364
9365
9366
9367
9368
9369
9370
9371
9372
9373
9374
9375
9376
9377
9378
9379
9380
9381
9382
9383
9384
9385
9386
9387
9388
9389
9390
9391
9392
9393
9394
9395
9396
9397
9398
9399
9400
9401
9402
9403
9404
9405
9406
9407
9408
9409
9410
9411
9412
9413
9414
9415
9416
9417
9418
9419
9420
9421
9422
9423
9424
9425
9426
9427
9428
9429
9430
9431
9432
9433
9434
9435
9436
9437
9438
9439
9440
9441
9442
9443
9444
9445
9446
9447
9448
9449
9450
9451
9452
9453
9454
9455
9456
9457
9458
9459
9460
9461
9462
9463
9464
9465
9466
9467
9468
9469
9470
9471
9472
9473
9474
9475
9476
9477
9478
9479
9480
9481
9482
9483
9484
9485
9486
9487
9488
9489
9490
9491
9492
9493
9494
9495
9496
9497
9498
9499
9500
9501
9502
9503
9504
9505
9506
9507
9508
9509
9510
9511
9512
9513
9514
9515
9516
9517
9518
9519
9520
9521
9522
9523
9524
9525
9526
9527
9528
9529
9530
9531
9532
9533
9534
9535
9536
9537
9538
9539
9540
9541
9542
9543
9544
9545
9546
9547
9548
9549
9550
9551
9552
9553
9554
9555
9556
9557
9558
9559
9560
9561
9562
9563
9564
9565
9566
9567
9568
9569
9570
9571
9572
9573
9574
9575
9576
9577
9578
9579
9580
9581
9582
9583
9584
9585
9586
9587
9588
9589
9590
9591
9592
9593
9594
9595
9596
9597
9598
9599
9600
9601
9602
9603
9604
9605
9606
9607
9608
9609
9610
9611
9612
9613
9614
9615
9616
9617
9618
9619
9620
9621
9622
9623
9624
9625
9626
9627
9628
9629
9630
9631
9632
9633
9634
9635
9636
9637
9638
9639
9640
9641
9642
9643
9644
9645
9646
9647
9648
9649
9650
9651
9652
9653
9654
9655
9656
9657
9658
9659
9660
9661
9662
9663
9664
9665
9666
9667
9668
9669
9670
9671
9672
9673
9674
9675
9676
9677
9678
9679
9680
9681
9682
9683
9684
9685
9686
9687
9688
9689
9690
9691
9692
9693
9694
9695
9696
9697
9698
9699
9700
9701
9702
9703
9704
9705
9706
9707
9708
9709
9710
9711
9712
9713
9714
9715
9716
9717
9718
9719
9720
9721
9722
9723
9724
9725
9726
9727
9728
9729
9730
9731
9732
9733
9734
9735
9736
9737
9738
9739
9740
9741
9742
9743
9744
9745
9746
9747
9748
9749
9750
9751
9752
9753
9754
9755
9756
9757
9758
9759
9760
9761
9762
9763
9764
9765
9766
9767
9768
9769
9770
9771
9772
9773
9774
9775
9776
9777
9778
9779
9780
9781
9782
9783
9784
9785
9786
9787
9788
9789
9790
9791
9792
9793
9794
9795
9796
9797
9798
9799
9800
9801
9802
9803
9804
9805
9806
9807
9808
9809
9810
9811
9812
9813
9814
9815
9816
9817
9818
9819
9820
9821
9822
9823
9824
9825
9826
9827
9828
9829
9830
9831
9832
9833
9834
9835
9836
9837
9838
9839
9840
9841
9842
9843
9844
9845
9846
9847
9848
9849
9850
9851
9852
9853
9854
9855
9856
9857
9858
9859
9860
9861
9862
9863
9864
9865
9866
9867
9868
9869
9870
9871
9872
9873
9874
9875
9876
9877
9878
9879
9880
9881
9882
9883
9884
9885
9886
9887
9888
9889
9890
9891
9892
9893
9894
9895
9896
9897
9898
9899
9900
9901
9902
9903
9904
9905
9906
9907
9908
9909
9910
9911
9912
9913
9914
9915
9916
9917
9918
9919
9920
9921
9922
9923
9924
9925
9926
9927
9928
9929
9930
9931
9932
9933
9934
9935
9936
9937
9938
9939
9940
9941
9942
9943
9944
9945
9946
9947
9948
9949
9950
9951
9952
9953
9954
9955
9956
9957
9958
9959
9960
9961
9962
9963
9964
9965
9966
9967
9968
9969
9970
9971
9972
9973
9974
9975
9976
9977
9978
9979
9980
9981
9982
9983
9984
9985
9986
9987
9988
9989
9990
9991
9992
9993
9994
9995
9996
9997
9998
9999
10000
10001
10002
10003
10004
10005
10006
10007
10008
10009
10010
10011
10012
10013
10014
10015
10016
10017
10018
10019
10020
10021
10022
10023
10024
10025
10026
10027
10028
10029
10030
10031
10032
10033
10034
10035
10036
10037
10038
10039
10040
10041
10042
10043
10044
10045
10046
10047
10048
10049
10050
10051
10052
10053
10054
10055
10056
10057
10058
10059
10060
10061
10062
10063
10064
10065
10066
10067
10068
10069
10070
10071
10072
10073
10074
10075
10076
10077
10078
10079
10080
10081
10082
10083
10084
10085
10086
10087
10088
10089
10090
10091
10092
10093
10094
10095
10096
10097
10098
10099
10100
10101
10102
10103
10104
10105
10106
10107
10108
10109
10110
10111
10112
10113
10114
10115
10116
10117
10118
10119
10120
10121
10122
10123
10124
10125
10126
10127
10128
10129
10130
10131
10132
10133
10134
10135
10136
10137
10138
10139
10140
10141
10142
10143
10144
10145
10146
10147
10148
10149
10150
10151
10152
10153
10154
10155
10156
10157
10158
10159
10160
10161
10162
10163
10164
10165
10166
10167
10168
10169
10170
10171
10172
10173
10174
10175
10176
10177
10178
10179
10180
10181
10182
10183
10184
10185
10186
10187
10188
10189
10190
10191
10192
10193
10194
10195
10196
10197
10198
10199
10200
10201
10202
10203
10204
10205
10206
10207
10208
10209
10210
10211
10212
10213
10214
10215
10216
10217
10218
10219
10220
10221
10222
10223
10224
10225
10226
10227
10228
10229
10230
10231
10232
10233
10234
10235
10236
10237
10238
10239
10240
10241
10242
10243
10244
10245
10246
10247
10248
10249
10250
10251
10252
10253
10254
10255
10256
10257
10258
10259
10260
10261
10262
10263
10264
10265
10266
10267
10268
10269
10270
10271
10272
10273
10274
10275
10276
10277
10278
10279
10280
10281
10282
10283
10284
10285
10286
10287
10288
10289
10290
10291
10292
10293
10294
10295
10296
10297
10298
10299
10300
10301
10302
10303
10304
10305
10306
10307
10308
10309
10310
10311
10312
10313
10314
10315
10316
10317
10318
10319
10320
10321
10322
10323
10324
10325
10326
10327
10328
10329
10330
10331
10332
10333
10334
10335
10336
10337
10338
10339
10340
10341
10342
10343
10344
10345
10346
10347
10348
10349
10350
10351
10352
10353
10354
10355
10356
10357
10358
10359
10360
10361
10362
10363
10364
10365
10366
10367
10368
10369
10370
10371
10372
10373
10374
10375
10376
10377
10378
10379
10380
10381
10382
10383
10384
10385
10386
10387
10388
10389
10390
10391
10392
10393
10394
10395
10396
10397
10398
10399
10400
10401
10402
10403
10404
10405
10406
10407
10408
10409
10410
10411
10412
10413
10414
10415
10416
10417
10418
10419
10420
10421
10422
10423
10424
10425
10426
10427
10428
10429
10430
10431
10432
10433
10434
10435
10436
10437
10438
10439
10440
10441
10442
10443
10444
10445
10446
10447
10448
10449
10450
10451
10452
10453
10454
10455
10456
10457
10458
10459
10460
10461
10462
10463
10464
10465
10466
10467
10468
10469
10470
10471
10472
10473
10474
10475
10476
10477
10478
10479
10480
10481
10482
10483
10484
10485
10486
10487
10488
10489
10490
10491
10492
10493
10494
10495
10496
10497
10498
10499
10500
10501
10502
10503
10504
10505
10506
10507
10508
10509
10510
10511
10512
10513
10514
10515
10516
10517
10518
10519
10520
10521
10522
10523
10524
10525
10526
10527
10528
10529
10530
10531
10532
10533
10534
10535
10536
10537
10538
10539
10540
10541
10542
10543
10544
10545
10546
10547
10548
10549
10550
10551
10552
10553
10554
10555
10556
10557
10558
10559
10560
10561
10562
10563
10564
10565
10566
10567
10568
10569
10570
10571
10572
10573
10574
10575
10576
10577
10578
10579
10580
10581
10582
10583
10584
10585
10586
10587
10588
10589
10590
10591
10592
10593
10594
10595
10596
10597
10598
10599
10600
10601
10602
10603
10604
10605
10606
10607
10608
10609
10610
10611
10612
10613
10614
10615
10616
10617
10618
10619
10620
10621
10622
10623
10624
10625
10626
10627
10628
10629
10630
10631
10632
10633
10634
10635
10636
10637
10638
10639
10640
10641
10642
10643
10644
10645
10646
10647
10648
10649
10650
10651
10652
10653
10654
10655
10656
10657
10658
10659
10660
10661
10662
10663
10664
10665
10666
10667
10668
10669
10670
10671
10672
10673
10674
10675
10676
10677
10678
10679
10680
10681
10682
10683
10684
10685
10686
10687
10688
10689
10690
10691
10692
10693
10694
10695
10696
10697
10698
10699
10700
10701
10702
10703
10704
10705
10706
10707
10708
10709
10710
10711
10712
10713
10714
10715
10716
10717
10718
10719
10720
10721
10722
10723
10724
10725
10726
10727
10728
10729
10730
10731
10732
10733
10734
10735
10736
10737
10738
10739
10740
10741
10742
10743
10744
10745
10746
10747
10748
10749
10750
10751
10752
10753
10754
10755
10756
10757
10758
10759
10760
10761
10762
10763
10764
10765
10766
10767
10768
10769
10770
10771
10772
10773
10774
10775
10776
10777
10778
10779
10780
10781
10782
10783
10784
10785
10786
10787
10788
10789
10790
10791
10792
10793
10794
10795
10796
10797
10798
10799
10800
10801
10802
10803
10804
10805
10806
10807
10808
10809
10810
10811
10812
10813
10814
10815
10816
10817
10818
10819
10820
10821
10822
10823
10824
10825
10826
10827
10828
10829
10830
10831
10832
10833
10834
10835
10836
10837
10838
10839
10840
10841
10842
10843
10844
10845
10846
10847
10848
10849
10850
10851
10852
10853
10854
10855
10856
10857
10858
10859
10860
10861
10862
10863
10864
10865
10866
10867
10868
10869
10870
10871
10872
10873
10874
10875
10876
10877
10878
10879
10880
10881
10882
10883
10884
10885
10886
10887
10888
10889
10890
10891
10892
10893
10894
10895
10896
10897
10898
10899
10900
10901
10902
10903
10904
10905
10906
10907
10908
10909
10910
10911
10912
10913
10914
10915
10916
10917
10918
10919
10920
10921
10922
10923
10924
10925
10926
10927
10928
10929
10930
10931
10932
10933
10934
10935
10936
10937
10938
10939
10940
10941
10942
10943
10944
10945
10946
10947
10948
10949
10950
10951
10952
10953
10954
10955
10956
10957
10958
10959
10960
10961
10962
10963
10964
10965
10966
10967
10968
10969
10970
10971
10972
10973
10974
10975
10976
10977
10978
10979
10980
10981
10982
10983
10984
10985
10986
10987
10988
10989
10990
10991
10992
10993
10994
10995
10996
10997
10998
10999
11000
11001
11002
11003
11004
11005
11006
11007
11008
11009
11010
11011
11012
11013
11014
11015
11016
11017
11018
11019
11020
11021
11022
11023
11024
11025
11026
11027
11028
11029
11030
11031
11032
11033
11034
11035
11036
11037
11038
11039
11040
11041
11042
11043
11044
11045
11046
11047
11048
11049
11050
11051
11052
11053
11054
11055
11056
11057
11058
11059
11060
11061
11062
11063
11064
11065
11066
11067
11068
11069
11070
11071
11072
11073
11074
11075
11076
11077
11078
11079
11080
11081
11082
11083
11084
11085
11086
11087
11088
11089
11090
11091
11092
11093
11094
11095
11096
11097
11098
11099
11100
11101
11102
11103
11104
11105
11106
11107
11108
11109
11110
11111
11112
11113
11114
11115
11116
11117
11118
11119
11120
11121
11122
11123
11124
11125
11126
11127
11128
11129
11130
11131
11132
11133
11134
11135
11136
11137
11138
11139
11140
11141
11142
11143
11144
11145
11146
11147
11148
11149
11150
11151
11152
11153
11154
11155
11156
11157
11158
11159
11160
11161
11162
11163
11164
11165
11166
11167
11168
11169
11170
11171
11172
11173
11174
11175
11176
11177
11178
11179
11180
11181
11182
11183
11184
11185
11186
11187
11188
11189
11190
11191
11192
11193
11194
11195
11196
11197
11198
11199
11200
11201
11202
11203
11204
11205
11206
11207
11208
11209
11210
11211
11212
11213
11214
11215
11216
11217
11218
11219
11220
11221
11222
11223
11224
11225
11226
11227
11228
11229
11230
11231
11232
11233
11234
11235
11236
11237
11238
11239
11240
11241
11242
11243
11244
11245
11246
11247
11248
11249
11250
11251
11252
11253
11254
11255
11256
11257
11258
11259
11260
11261
11262
11263
11264
11265
11266
11267
11268
11269
11270
11271
11272
11273
11274
11275
11276
11277
11278
11279
11280
11281
11282
11283
11284
11285
11286
11287
11288
11289
11290
11291
11292
11293
11294
11295
11296
11297
11298
11299
11300
11301
11302
11303
11304
11305
11306
11307
11308
11309
11310
11311
11312
11313
11314
11315
11316
11317
11318
11319
11320
11321
11322
11323
11324
11325
11326
11327
11328
11329
11330
11331
11332
11333
11334
11335
11336
11337
11338
11339
11340
11341
11342
11343
11344
11345
11346
11347
11348
11349
11350
11351
11352
11353
11354
11355
11356
11357
11358
11359
11360
11361
11362
11363
11364
11365
11366
11367
11368
11369
11370
11371
11372
11373
11374
11375
11376
11377
11378
11379
11380
11381
11382
11383
11384
11385
11386
11387
11388
11389
11390
11391
11392
11393
11394
11395
11396
11397
11398
11399
11400
11401
11402
11403
11404
11405
11406
11407
11408
11409
11410
11411
11412
11413
11414
11415
11416
11417
11418
11419
11420
11421
11422
11423
11424
11425
11426
11427
11428
11429
11430
11431
11432
11433
11434
11435
11436
11437
11438
11439
11440
11441
11442
11443
11444
11445
11446
11447
11448
11449
11450
11451
11452
11453
11454
11455
11456
11457
11458
11459
11460
11461
11462
11463
11464
11465
11466
11467
11468
11469
11470
11471
11472
11473
11474
11475
11476
11477
11478
11479
11480
11481
11482
11483
11484
11485
11486
11487
11488
11489
11490
11491
11492
11493
11494
11495
11496
11497
11498
11499
11500
11501
11502
11503
11504
11505
11506
11507
11508
11509
11510
11511
11512
11513
11514
11515
11516
11517
11518
11519
11520
11521
11522
11523
11524
11525
11526
11527
11528
11529
11530
11531
11532
11533
11534
11535
11536
11537
11538
11539
11540
11541
11542
11543
11544
11545
11546
11547
11548
11549
11550
11551
11552
11553
11554
11555
11556
11557
11558
11559
11560
11561
11562
11563
11564
11565
11566
11567
11568
11569
11570
11571
11572
11573
11574
11575
11576
11577
11578
11579
11580
11581
11582
11583
11584
11585
11586
11587
11588
11589
11590
11591
11592
11593
11594
11595
11596
11597
11598
11599
11600
11601
11602
11603
11604
11605
11606
11607
11608
11609
11610
11611
11612
11613
11614
11615
11616
11617
11618
11619
11620
11621
11622
11623
11624
11625
11626
11627
11628
11629
11630
11631
11632
11633
11634
11635
11636
11637
11638
11639
11640
11641
11642
11643
11644
11645
11646
11647
11648
11649
11650
11651
11652
11653
11654
11655
11656
11657
11658
11659
11660
11661
11662
11663
11664
11665
11666
11667
11668
11669
11670
11671
11672
11673
11674
11675
11676
11677
11678
11679
11680
11681
11682
11683
11684
11685
11686
11687
11688
11689
11690
11691
11692
11693
11694
11695
11696
11697
11698
11699
11700
11701
11702
11703
11704
11705
11706
11707
11708
11709
11710
11711
11712
11713
11714
11715
11716
11717
11718
11719
11720
11721
11722
11723
11724
11725
11726
11727
11728
11729
11730
11731
11732
11733
11734
11735
11736
11737
11738
11739
11740
11741
11742
11743
11744
11745
11746
11747
11748
11749
11750
11751
11752
11753
11754
11755
11756
11757
11758
11759
11760
11761
11762
11763
11764
11765
11766
11767
11768
11769
11770
11771
11772
11773
11774
11775
11776
11777
11778
11779
11780
11781
11782
11783
11784
11785
11786
11787
11788
11789
11790
11791
11792
11793
11794
11795
11796
11797
11798
11799
11800
11801
11802
11803
11804
11805
11806
11807
11808
11809
11810
11811
11812
11813
11814
11815
11816
11817
11818
11819
11820
11821
11822
11823
11824
11825
11826
11827
11828
11829
11830
11831
11832
11833
11834
11835
11836
11837
11838
11839
11840
11841
11842
11843
11844
11845
11846
11847
11848
11849
11850
11851
11852
11853
11854
11855
11856
11857
11858
11859
11860
11861
11862
11863
11864
11865
11866
11867
11868
11869
11870
11871
11872
11873
11874
11875
11876
11877
11878
11879
11880
11881
11882
11883
11884
11885
11886
11887
11888
11889
11890
11891
11892
11893
11894
11895
11896
11897
11898
11899
11900
11901
11902
11903
11904
11905
11906
11907
11908
11909
11910
11911
11912
11913
11914
11915
11916
11917
11918
11919
11920
11921
11922
11923
11924
11925
11926
11927
11928
11929
11930
11931
11932
11933
11934
11935
11936
11937
11938
11939
11940
11941
11942
11943
11944
11945
11946
11947
11948
11949
11950
11951
11952
11953
11954
11955
11956
11957
11958
11959
11960
11961
11962
11963
11964
11965
11966
11967
11968
11969
11970
11971
11972
11973
11974
11975
11976
11977
11978
11979
11980
11981
11982
11983
11984
11985
11986
11987
11988
11989
11990
11991
11992
11993
11994
11995
11996
11997
11998
11999
12000
12001
12002
12003
12004
12005
12006
12007
12008
12009
12010
12011
12012
12013
12014
12015
12016
12017
12018
12019
12020
12021
12022
12023
12024
12025
12026
12027
12028
12029
12030
12031
12032
12033
12034
12035
12036
12037
12038
12039
12040
12041
12042
12043
12044
12045
12046
12047
12048
12049
12050
12051
12052
12053
12054
12055
12056
12057
12058
12059
12060
12061
12062
12063
12064
12065
12066
12067
12068
12069
12070
12071
12072
12073
12074
12075
12076
12077
12078
12079
12080
12081
12082
12083
12084
12085
12086
12087
12088
12089
12090
12091
12092
12093
12094
12095
12096
12097
12098
12099
12100
12101
12102
12103
12104
12105
12106
12107
12108
12109
12110
12111
12112
12113
12114
12115
12116
12117
12118
12119
12120
12121
12122
12123
12124
12125
12126
12127
12128
12129
12130
12131
12132
12133
12134
12135
12136
12137
12138
12139
12140
12141
12142
12143
12144
12145
12146
12147
12148
12149
12150
12151
12152
12153
12154
12155
12156
12157
12158
12159
12160
12161
12162
12163
12164
12165
12166
12167
12168
12169
12170
12171
12172
12173
12174
12175
12176
12177
12178
12179
12180
12181
12182
12183
12184
12185
12186
12187
12188
12189
12190
12191
12192
12193
12194
12195
12196
12197
12198
12199
12200
12201
12202
12203
12204
12205
12206
12207
12208
12209
12210
12211
12212
12213
12214
12215
12216
12217
12218
12219
12220
12221
12222
12223
12224
12225
12226
12227
12228
12229
12230
12231
12232
12233
12234
12235
12236
12237
12238
12239
12240
12241
12242
12243
12244
12245
12246
12247
12248
12249
12250
12251
12252
12253
12254
12255
12256
12257
12258
12259
12260
12261
12262
12263
12264
12265
12266
12267
12268
12269
12270
12271
12272
12273
12274
12275
12276
12277
12278
12279
12280
12281
12282
12283
12284
12285
12286
12287
12288
12289
12290
12291
12292
12293
12294
12295
12296
12297
12298
12299
12300
12301
12302
12303
12304
12305
12306
12307
12308
12309
12310
12311
12312
12313
12314
12315
12316
12317
12318
12319
12320
12321
12322
12323
12324
12325
12326
12327
12328
12329
12330
12331
12332
12333
12334
12335
12336
12337
12338
12339
12340
12341
12342
12343
12344
12345
12346
12347
12348
12349
12350
12351
12352
12353
12354
12355
12356
12357
12358
12359
12360
12361
12362
12363
12364
12365
12366
12367
12368
12369
12370
12371
12372
12373
12374
12375
12376
12377
12378
12379
12380
12381
12382
12383
12384
12385
12386
12387
12388
12389
12390
12391
12392
12393
12394
12395
12396
12397
12398
12399
12400
12401
12402
12403
12404
12405
12406
12407
12408
12409
12410
12411
12412
12413
12414
12415
12416
12417
12418
12419
12420
12421
12422
12423
12424
12425
12426
12427
12428
12429
12430
12431
12432
12433
12434
12435
12436
12437
12438
12439
12440
12441
12442
12443
12444
12445
12446
12447
12448
12449
12450
12451
12452
12453
12454
12455
12456
12457
12458
12459
12460
12461
12462
12463
12464
12465
12466
12467
12468
12469
12470
12471
12472
12473
12474
12475
12476
12477
12478
12479
12480
12481
12482
12483
12484
12485
12486
12487
12488
12489
12490
12491
12492
12493
12494
12495
12496
12497
12498
12499
12500
12501
12502
12503
12504
12505
12506
12507
12508
12509
12510
12511
12512
12513
12514
12515
12516
12517
12518
12519
12520
12521
12522
12523
12524
12525
12526
12527
12528
12529
12530
12531
12532
12533
12534
12535
12536
12537
12538
12539
12540
12541
12542
12543
12544
12545
12546
12547
12548
12549
12550
12551
12552
12553
12554
12555
12556
12557
12558
12559
12560
12561
12562
12563
12564
12565
12566
12567
12568
12569
12570
12571
12572
12573
12574
12575
12576
12577
12578
12579
12580
12581
12582
12583
12584
12585
12586
12587
12588
12589
12590
12591
12592
12593
12594
12595
12596
12597
12598
12599
12600
12601
12602
12603
12604
12605
12606
12607
12608
12609
12610
12611
12612
12613
12614
12615
12616
12617
12618
12619
12620
12621
12622
12623
12624
12625
12626
12627
12628
12629
12630
12631
12632
12633
12634
12635
12636
12637
12638
12639
12640
12641
12642
12643
12644
12645
12646
12647
12648
12649
12650
12651
12652
12653
12654
12655
12656
12657
12658
12659
12660
12661
12662
12663
12664
12665
12666
12667
12668
12669
12670
12671
12672
12673
12674
12675
12676
12677
12678
12679
12680
12681
12682
12683
12684
12685
12686
12687
12688
12689
12690
12691
12692
12693
12694
12695
12696
12697
12698
12699
12700
12701
12702
12703
12704
12705
12706
12707
12708
12709
12710
12711
12712
12713
12714
12715
12716
12717
12718
12719
12720
12721
12722
12723
12724
12725
12726
12727
12728
12729
12730
12731
12732
12733
12734
12735
12736
12737
12738
12739
12740
12741
12742
12743
12744
12745
12746
12747
12748
12749
12750
12751
12752
12753
12754
12755
12756
12757
12758
12759
12760
12761
12762
12763
12764
12765
12766
12767
12768
12769
12770
12771
12772
12773
12774
12775
12776
12777
12778
12779
12780
12781
12782
12783
12784
12785
12786
12787
12788
12789
12790
12791
12792
12793
12794
12795
12796
12797
12798
12799
12800
12801
12802
12803
12804
12805
12806
12807
12808
12809
12810
12811
12812
12813
12814
12815
12816
12817
12818
12819
12820
12821
12822
12823
12824
12825
12826
12827
12828
12829
12830
12831
12832
12833
12834
12835
12836
12837
12838
12839
12840
12841
12842
12843
12844
12845
12846
12847
12848
12849
12850
12851
12852
12853
12854
12855
12856
12857
12858
12859
12860
12861
12862
12863
12864
12865
12866
12867
12868
12869
12870
12871
12872
12873
12874
12875
12876
12877
12878
12879
12880
12881
12882
12883
12884
12885
12886
12887
12888
12889
12890
12891
12892
12893
12894
12895
12896
12897
12898
12899
12900
12901
12902
12903
12904
12905
12906
12907
12908
12909
12910
12911
12912
12913
12914
12915
12916
12917
12918
12919
12920
12921
12922
12923
12924
12925
12926
12927
12928
12929
12930
12931
12932
12933
12934
12935
12936
12937
12938
12939
12940
12941
12942
12943
12944
12945
12946
12947
12948
12949
12950
12951
12952
12953
12954
12955
12956
12957
12958
12959
12960
12961
12962
12963
12964
12965
12966
12967
12968
12969
12970
12971
12972
12973
12974
12975
12976
12977
12978
12979
12980
12981
12982
12983
12984
12985
12986
12987
12988
12989
12990
12991
12992
12993
12994
12995
12996
12997
12998
12999
13000
13001
13002
13003
13004
13005
13006
13007
13008
13009
13010
13011
13012
13013
13014
13015
13016
13017
13018
13019
13020
13021
13022
13023
13024
13025
13026
13027
13028
13029
13030
13031
13032
13033
13034
13035
13036
13037
13038
13039
13040
13041
13042
13043
13044
13045
13046
13047
13048
13049
13050
13051
13052
13053
13054
13055
13056
13057
13058
13059
13060
13061
13062
13063
13064
13065
13066
13067
13068
13069
13070
13071
13072
13073
13074
13075
13076
13077
13078
13079
13080
13081
13082
13083
13084
13085
13086
13087
13088
13089
13090
13091
13092
13093
13094
13095
13096
13097
13098
13099
13100
13101
13102
13103
13104
13105
13106
13107
13108
13109
13110
13111
13112
13113
13114
13115
13116
13117
13118
13119
13120
13121
13122
13123
13124
13125
13126
13127
13128
13129
13130
13131
13132
13133
13134
13135
13136
13137
13138
13139
13140
13141
13142
13143
13144
13145
13146
13147
13148
13149
13150
13151
13152
13153
13154
13155
13156
13157
13158
13159
13160
13161
13162
13163
13164
13165
13166
13167
13168
13169
13170
13171
13172
13173
13174
13175
13176
13177
13178
13179
13180
13181
13182
13183
13184
13185
13186
13187
13188
13189
13190
13191
13192
13193
13194
13195
13196
13197
13198
13199
13200
13201
13202
13203
13204
13205
13206
13207
13208
13209
13210
13211
13212
13213
13214
13215
13216
13217
13218
13219
13220
13221
13222
13223
13224
13225
13226
13227
13228
13229
13230
13231
13232
13233
13234
13235
13236
13237
13238
13239
13240
13241
13242
13243
13244
13245
13246
13247
13248
13249
13250
13251
13252
13253
13254
13255
13256
13257
13258
13259
13260
13261
13262
13263
13264
13265
13266
13267
13268
13269
13270
13271
13272
13273
13274
13275
13276
13277
13278
13279
13280
13281
13282
13283
13284
13285
13286
13287
13288
13289
13290
13291
13292
13293
13294
13295
13296
13297
13298
13299
13300
13301
13302
13303
13304
13305
13306
13307
13308
13309
13310
13311
13312
13313
13314
13315
13316
13317
13318
13319
13320
13321
13322
13323
13324
13325
13326
13327
13328
13329
13330
13331
13332
13333
13334
13335
13336
13337
13338
13339
13340
13341
13342
13343
13344
13345
13346
13347
13348
13349
13350
13351
13352
13353
13354
13355
13356
13357
13358
13359
13360
13361
13362
13363
13364
13365
13366
13367
13368
13369
13370
13371
13372
13373
13374
13375
13376
13377
13378
13379
13380
13381
13382
13383
13384
13385
13386
13387
13388
13389
13390
13391
13392
13393
13394
13395
13396
13397
13398
13399
13400
13401
13402
13403
13404
13405
13406
13407
13408
13409
13410
13411
13412
13413
13414
13415
13416
13417
13418
13419
13420
13421
13422
13423
13424
13425
13426
13427
13428
13429
13430
13431
13432
13433
13434
13435
13436
13437
13438
13439
13440
13441
13442
13443
13444
13445
13446
13447
13448
13449
13450
13451
13452
13453
13454
13455
13456
13457
13458
13459
13460
13461
13462
13463
13464
13465
13466
13467
13468
13469
13470
13471
13472
13473
13474
13475
13476
13477
13478
13479
13480
13481
13482
13483
13484
13485
13486
13487
13488
13489
13490
13491
13492
13493
13494
13495
13496
13497
13498
13499
13500
13501
13502
13503
13504
13505
13506
13507
13508
13509
13510
13511
13512
13513
13514
13515
13516
13517
13518
13519
13520
13521
13522
13523
13524
13525
13526
13527
13528
13529
13530
13531
13532
13533
13534
13535
13536
13537
13538
13539
13540
13541
13542
13543
13544
13545
13546
13547
13548
13549
13550
13551
13552
13553
13554
13555
13556
13557
13558
13559
13560
13561
13562
13563
13564
13565
13566
13567
13568
13569
13570
13571
13572
13573
13574
13575
13576
13577
13578
13579
13580
13581
13582
13583
13584
13585
13586
13587
13588
13589
13590
13591
13592
13593
13594
13595
13596
13597
13598
13599
13600
13601
13602
13603
13604
13605
13606
13607
13608
13609
13610
13611
13612
13613
13614
13615
13616
13617
13618
13619
13620
13621
13622
13623
13624
13625
13626
13627
13628
13629
13630
13631
13632
13633
13634
13635
13636
13637
13638
13639
13640
13641
13642
13643
13644
13645
13646
13647
13648
13649
13650
13651
13652
13653
13654
13655
13656
13657
13658
13659
13660
13661
13662
13663
13664
13665
13666
13667
13668
13669
13670
13671
13672
13673
13674
13675
13676
13677
13678
13679
13680
13681
13682
13683
13684
13685
13686
13687
13688
13689
13690
13691
13692
13693
13694
13695
13696
13697
13698
13699
13700
13701
13702
13703
13704
13705
13706
13707
13708
13709
13710
13711
13712
13713
13714
13715
13716
13717
13718
13719
13720
13721
13722
13723
13724
13725
13726
13727
13728
13729
13730
13731
13732
13733
13734
13735
13736
13737
13738
13739
13740
13741
13742
13743
13744
13745
13746
13747
13748
13749
13750
13751
13752
13753
13754
13755
13756
13757
13758
13759
13760
13761
13762
13763
13764
13765
13766
13767
13768
13769
13770
13771
13772
13773
13774
13775
13776
13777
13778
13779
13780
13781
13782
13783
13784
13785
13786
13787
13788
13789
13790
13791
13792
13793
13794
13795
13796
13797
13798
13799
13800
13801
13802
13803
13804
13805
13806
13807
13808
13809
13810
13811
13812
13813
13814
13815
13816
13817
13818
13819
13820
13821
13822
13823
13824
13825
13826
13827
13828
13829
13830
13831
13832
13833
13834
13835
13836
13837
13838
13839
13840
13841
13842
13843
13844
13845
13846
13847
13848
13849
13850
13851
13852
13853
13854
13855
13856
13857
13858
13859
13860
13861
13862
13863
13864
13865
13866
13867
13868
13869
13870
13871
13872
13873
13874
13875
13876
13877
13878
13879
13880
13881
13882
13883
13884
13885
13886
13887
13888
13889
13890
13891
13892
13893
13894
13895
13896
13897
13898
13899
13900
13901
13902
13903
13904
13905
13906
13907
13908
13909
13910
13911
13912
13913
13914
13915
13916
13917
13918
13919
13920
13921
13922
13923
13924
13925
13926
13927
13928
13929
13930
13931
13932
13933
13934
13935
13936
13937
13938
13939
13940
13941
13942
13943
13944
13945
13946
13947
13948
13949
13950
13951
13952
13953
13954
13955
13956
13957
13958
13959
13960
13961
13962
13963
13964
13965
13966
13967
13968
13969
13970
13971
13972
13973
13974
13975
13976
13977
13978
13979
13980
13981
13982
13983
13984
13985
13986
13987
13988
13989
13990
13991
13992
13993
13994
13995
13996
13997
13998
13999
14000
14001
14002
14003
14004
14005
14006
14007
14008
14009
14010
14011
14012
14013
14014
14015
14016
14017
14018
14019
14020
14021
14022
14023
14024
14025
14026
14027
14028
14029
14030
14031
14032
14033
14034
14035
14036
14037
14038
14039
14040
14041
14042
14043
14044
14045
14046
14047
14048
14049
14050
14051
14052
14053
14054
14055
14056
14057
14058
14059
14060
14061
14062
14063
14064
14065
14066
14067
14068
14069
14070
14071
14072
14073
14074
14075
14076
14077
14078
14079
14080
14081
14082
14083
14084
14085
14086
14087
14088
14089
14090
14091
14092
14093
14094
14095
14096
14097
14098
14099
14100
14101
14102
14103
14104
14105
14106
14107
14108
14109
14110
14111
14112
14113
14114
14115
14116
14117
14118
14119
14120
14121
14122
14123
14124
14125
14126
14127
14128
14129
14130
14131
14132
14133
14134
14135
14136
14137
14138
14139
14140
14141
14142
14143
14144
14145
14146
14147
14148
14149
14150
14151
14152
14153
14154
14155
14156
14157
14158
14159
14160
14161
14162
14163
14164
14165
14166
14167
14168
14169
14170
14171
14172
14173
14174
14175
14176
14177
14178
14179
14180
14181
14182
14183
14184
14185
14186
14187
14188
14189
14190
14191
14192
14193
14194
14195
14196
14197
14198
14199
14200
14201
14202
14203
14204
14205
14206
14207
14208
14209
14210
14211
14212
14213
14214
14215
14216
14217
14218
14219
14220
14221
14222
14223
14224
14225
14226
14227
14228
14229
14230
14231
14232
14233
14234
14235
14236
14237
14238
14239
14240
14241
14242
14243
14244
14245
14246
14247
14248
14249
14250
14251
14252
14253
14254
14255
14256
14257
14258
14259
14260
14261
14262
14263
14264
14265
14266
14267
14268
14269
14270
14271
14272
14273
14274
14275
14276
14277
14278
14279
14280
14281
14282
14283
14284
14285
14286
14287
14288
14289
14290
14291
14292
14293
14294
14295
14296
14297
14298
14299
14300
14301
14302
14303
14304
14305
14306
14307
14308
14309
14310
14311
14312
14313
14314
14315
14316
14317
14318
14319
14320
14321
14322
14323
14324
14325
14326
14327
14328
14329
14330
14331
14332
14333
14334
14335
14336
14337
14338
14339
14340
14341
14342
14343
14344
14345
14346
14347
14348
14349
14350
14351
14352
14353
14354
14355
14356
14357
14358
14359
14360
14361
14362
14363
14364
14365
14366
14367
14368
14369
14370
14371
14372
14373
14374
14375
14376
14377
14378
14379
14380
14381
14382
14383
14384
14385
14386
14387
14388
14389
14390
14391
14392
14393
14394
14395
14396
14397
14398
14399
14400
14401
14402
14403
14404
14405
14406
14407
14408
14409
14410
14411
14412
14413
14414
14415
14416
14417
14418
14419
14420
14421
14422
14423
14424
14425
14426
14427
14428
14429
14430
14431
14432
14433
14434
14435
14436
14437
14438
14439
14440
14441
14442
14443
14444
14445
14446
14447
14448
14449
14450
14451
14452
14453
14454
14455
14456
14457
14458
14459
14460
14461
14462
14463
14464
14465
14466
14467
14468
14469
14470
14471
14472
14473
14474
14475
14476
14477
14478
14479
14480
14481
14482
14483
14484
14485
14486
14487
14488
14489
14490
14491
14492
14493
14494
14495
14496
14497
14498
14499
14500
14501
14502
14503
14504
14505
14506
14507
14508
14509
14510
14511
14512
14513
14514
14515
14516
14517
14518
14519
14520
14521
14522
14523
14524
14525
14526
14527
14528
14529
14530
14531
14532
14533
14534
14535
14536
14537
14538
14539
14540
14541
14542
14543
14544
14545
14546
14547
14548
14549
14550
14551
14552
14553
14554
14555
14556
14557
14558
14559
14560
14561
14562
14563
14564
14565
14566
14567
14568
14569
14570
14571
14572
14573
14574
14575
14576
14577
14578
14579
14580
14581
14582
14583
14584
14585
14586
14587
14588
14589
14590
14591
14592
14593
14594
14595
14596
14597
14598
14599
14600
14601
14602
14603
14604
14605
14606
14607
14608
14609
14610
14611
14612
14613
14614
14615
14616
14617
14618
14619
14620
14621
14622
14623
14624
14625
14626
14627
14628
14629
14630
14631
14632
14633
14634
14635
14636
14637
14638
14639
14640
14641
14642
14643
14644
14645
14646
14647
14648
14649
14650
14651
14652
14653
14654
14655
14656
14657
14658
14659
14660
14661
14662
14663
14664
14665
14666
14667
14668
14669
14670
14671
14672
14673
14674
14675
14676
14677
14678
14679
14680
14681
14682
14683
14684
14685
14686
14687
14688
14689
14690
14691
14692
14693
14694
14695
14696
14697
14698
14699
14700
14701
14702
14703
14704
14705
14706
14707
14708
14709
14710
14711
14712
14713
14714
14715
14716
14717
14718
14719
14720
14721
14722
14723
14724
14725
14726
14727
14728
14729
14730
14731
14732
14733
14734
14735
14736
14737
14738
14739
14740
14741
14742
14743
14744
14745
14746
14747
14748
14749
14750
14751
14752
14753
14754
14755
14756
14757
14758
14759
14760
14761
14762
14763
14764
14765
14766
14767
14768
14769
14770
14771
14772
14773
14774
14775
14776
14777
14778
14779
14780
14781
14782
14783
14784
14785
14786
14787
14788
14789
14790
14791
14792
14793
14794
14795
14796
14797
14798
14799
14800
14801
14802
14803
14804
14805
14806
14807
14808
14809
14810
14811
14812
14813
14814
14815
14816
14817
14818
14819
14820
14821
14822
14823
14824
14825
14826
14827
14828
14829
14830
14831
14832
14833
14834
14835
14836
14837
14838
14839
14840
14841
14842
14843
14844
14845
14846
14847
14848
14849
14850
14851
14852
14853
14854
14855
14856
14857
14858
14859
14860
14861
14862
14863
14864
14865
14866
14867
14868
14869
14870
14871
14872
14873
14874
14875
14876
14877
14878
14879
14880
14881
14882
14883
14884
14885
14886
14887
14888
14889
14890
14891
14892
14893
14894
14895
14896
14897
14898
14899
14900
14901
14902
14903
14904
14905
14906
14907
14908
14909
14910
14911
14912
14913
14914
14915
14916
14917
14918
14919
14920
14921
14922
14923
14924
14925
14926
14927
14928
14929
14930
14931
14932
14933
14934
14935
14936
14937
14938
14939
14940
14941
14942
14943
14944
14945
14946
14947
14948
14949
14950
14951
14952
14953
14954
14955
14956
14957
14958
14959
14960
14961
14962
14963
14964
14965
14966
14967
14968
14969
14970
14971
14972
14973
14974
14975
14976
14977
14978
14979
14980
14981
14982
14983
14984
14985
14986
14987
14988
14989
14990
14991
14992
14993
14994
14995
14996
14997
14998
14999
15000
15001
15002
15003
15004
15005
15006
15007
15008
15009
15010
15011
15012
15013
15014
15015
15016
15017
15018
15019
15020
15021
15022
15023
15024
15025
15026
15027
15028
15029
15030
15031
15032
15033
15034
15035
15036
15037
15038
15039
15040
15041
15042
15043
15044
15045
15046
15047
15048
15049
15050
15051
15052
15053
15054
15055
15056
15057
15058
15059
15060
15061
15062
15063
15064
15065
15066
15067
15068
15069
15070
15071
15072
15073
15074
15075
15076
15077
15078
15079
15080
15081
15082
15083
15084
15085
15086
15087
15088
15089
15090
15091
15092
15093
15094
15095
15096
15097
15098
15099
15100
15101
15102
15103
15104
15105
15106
15107
15108
15109
15110
15111
15112
15113
15114
15115
15116
15117
15118
15119
15120
15121
15122
15123
15124
15125
15126
15127
15128
15129
15130
15131
15132
15133
15134
15135
15136
15137
15138
15139
15140
15141
15142
15143
15144
15145
15146
15147
15148
15149
15150
15151
15152
15153
15154
15155
15156
15157
15158
15159
15160
15161
15162
15163
15164
15165
15166
15167
15168
15169
15170
15171
15172
15173
15174
15175
15176
15177
15178
15179
15180
15181
15182
15183
15184
15185
15186
15187
15188
15189
15190
15191
15192
15193
15194
15195
15196
15197
15198
15199
15200
15201
15202
15203
15204
15205
15206
15207
15208
15209
15210
15211
15212
15213
15214
15215
15216
15217
15218
15219
15220
15221
15222
15223
15224
15225
15226
15227
15228
15229
15230
15231
15232
15233
15234
15235
15236
15237
15238
15239
15240
15241
15242
15243
15244
15245
15246
15247
15248
15249
15250
15251
15252
15253
15254
15255
15256
15257
15258
15259
15260
15261
15262
15263
15264
15265
15266
15267
15268
15269
15270
15271
15272
15273
15274
15275
15276
15277
15278
15279
15280
15281
15282
15283
15284
15285
15286
15287
15288
15289
15290
15291
15292
15293
15294
15295
15296
15297
15298
15299
15300
15301
15302
15303
15304
15305
15306
15307
15308
15309
15310
15311
15312
15313
15314
15315
15316
15317
15318
15319
15320
15321
15322
15323
15324
15325
15326
15327
15328
15329
15330
15331
15332
15333
15334
15335
15336
15337
15338
15339
15340
15341
15342
15343
15344
15345
15346
15347
15348
15349
15350
15351
15352
15353
15354
15355
15356
15357
15358
15359
15360
15361
15362
15363
15364
15365
15366
15367
15368
15369
15370
15371
15372
15373
15374
15375
15376
15377
15378
15379
15380
15381
15382
15383
15384
15385
15386
15387
15388
15389
15390
15391
15392
15393
15394
15395
15396
15397
15398
15399
15400
15401
15402
15403
15404
15405
15406
15407
15408
15409
15410
15411
15412
15413
15414
15415
15416
15417
15418
15419
15420
15421
15422
15423
15424
15425
15426
15427
15428
15429
15430
15431
15432
15433
15434
15435
15436
15437
15438
15439
15440
15441
15442
15443
15444
15445
15446
15447
15448
15449
15450
15451
15452
15453
15454
15455
15456
15457
15458
15459
15460
15461
15462
15463
15464
15465
15466
15467
15468
15469
15470
15471
15472
15473
15474
15475
15476
15477
15478
15479
15480
15481
15482
15483
15484
15485
15486
15487
15488
15489
15490
15491
15492
15493
15494
15495
15496
15497
15498
15499
15500
15501
15502
15503
15504
15505
15506
15507
15508
15509
15510
15511
15512
15513
15514
15515
15516
15517
15518
15519
15520
15521
15522
15523
15524
15525
15526
15527
15528
15529
15530
15531
15532
15533
15534
15535
15536
15537
15538
15539
15540
15541
15542
15543
15544
15545
15546
15547
15548
15549
15550
15551
15552
15553
15554
15555
15556
15557
15558
15559
15560
15561
15562
15563
15564
15565
15566
15567
15568
15569
15570
15571
15572
15573
15574
15575
15576
15577
15578
15579
15580
15581
15582
15583
15584
15585
15586
15587
15588
15589
15590
15591
15592
15593
15594
15595
15596
15597
15598
15599
15600
15601
15602
15603
15604
15605
15606
15607
15608
15609
15610
15611
15612
15613
15614
15615
15616
15617
15618
15619
15620
15621
15622
15623
15624
15625
15626
15627
15628
15629
15630
15631
15632
15633
15634
15635
15636
15637
15638
15639
15640
15641
15642
15643
15644
15645
15646
15647
15648
15649
15650
15651
15652
15653
15654
15655
15656
15657
15658
15659
15660
15661
15662
15663
15664
15665
15666
15667
15668
15669
15670
15671
15672
15673
15674
15675
15676
15677
15678
15679
15680
15681
15682
15683
15684
15685
15686
15687
15688
15689
15690
15691
15692
15693
15694
15695
15696
15697
15698
15699
15700
15701
15702
15703
15704
15705
15706
15707
15708
15709
15710
15711
15712
15713
15714
15715
15716
15717
15718
15719
15720
15721
15722
15723
15724
15725
15726
15727
15728
15729
15730
15731
15732
15733
15734
15735
15736
15737
15738
15739
15740
15741
15742
15743
15744
15745
15746
15747
15748
15749
15750
15751
15752
15753
15754
15755
15756
15757
15758
15759
15760
15761
15762
15763
15764
15765
15766
15767
15768
15769
15770
15771
15772
15773
15774
15775
15776
15777
15778
15779
15780
15781
15782
15783
15784
15785
15786
15787
15788
15789
15790
15791
15792
15793
15794
15795
15796
15797
15798
15799
15800
15801
15802
15803
15804
15805
15806
15807
15808
15809
15810
15811
15812
15813
15814
15815
15816
15817
15818
15819
15820
15821
15822
15823
15824
15825
15826
15827
15828
15829
15830
15831
15832
15833
15834
15835
15836
15837
15838
15839
15840
15841
15842
15843
15844
15845
15846
15847
15848
15849
15850
15851
15852
15853
15854
15855
15856
15857
15858
15859
15860
15861
15862
15863
15864
15865
15866
15867
15868
15869
15870
15871
15872
15873
15874
15875
15876
15877
15878
15879
15880
15881
15882
15883
15884
15885
15886
15887
15888
15889
15890
15891
15892
15893
15894
15895
15896
15897
15898
15899
15900
15901
15902
15903
15904
15905
15906
15907
15908
15909
15910
15911
15912
15913
15914
15915
15916
15917
15918
15919
15920
15921
15922
15923
15924
15925
15926
15927
15928
15929
15930
15931
15932
15933
15934
15935
15936
15937
15938
15939
15940
15941
15942
15943
15944
15945
15946
15947
15948
15949
15950
15951
15952
15953
15954
15955
15956
15957
15958
15959
15960
15961
15962
15963
15964
15965
15966
15967
15968
15969
15970
15971
15972
15973
15974
15975
15976
15977
15978
15979
15980
15981
15982
15983
15984
15985
15986
15987
15988
15989
15990
15991
15992
15993
15994
15995
15996
15997
15998
15999
16000
16001
16002
16003
16004
16005
16006
16007
16008
16009
16010
16011
16012
16013
16014
16015
16016
16017
16018
16019
16020
16021
16022
16023
16024
16025
16026
16027
16028
16029
16030
16031
16032
16033
16034
16035
16036
16037
16038
16039
16040
16041
16042
16043
16044
16045
16046
16047
16048
16049
16050
16051
16052
16053
16054
16055
16056
16057
16058
16059
16060
16061
16062
16063
16064
16065
16066
16067
16068
16069
16070
16071
16072
16073
16074
16075
16076
16077
16078
16079
16080
16081
16082
16083
16084
16085
16086
16087
16088
16089
16090
16091
16092
16093
16094
16095
16096
16097
16098
16099
16100
16101
16102
16103
16104
16105
16106
16107
16108
16109
16110
16111
16112
16113
16114
16115
16116
16117
16118
16119
16120
16121
16122
16123
16124
16125
16126
16127
16128
16129
16130
16131
16132
16133
16134
16135
16136
16137
16138
16139
16140
16141
16142
16143
16144
16145
16146
16147
16148
16149
16150
16151
16152
16153
16154
16155
16156
16157
16158
16159
16160
16161
16162
16163
16164
16165
16166
16167
16168
16169
16170
16171
16172
16173
16174
16175
16176
16177
16178
16179
16180
16181
16182
16183
16184
16185
16186
16187
16188
16189
16190
16191
16192
16193
16194
16195
16196
16197
16198
16199
16200
16201
16202
16203
16204
16205
16206
16207
16208
16209
16210
16211
16212
16213
16214
16215
16216
16217
16218
16219
16220
16221
16222
16223
16224
16225
16226
16227
16228
16229
16230
16231
16232
16233
16234
16235
16236
16237
16238
16239
16240
16241
16242
16243
16244
16245
16246
16247
16248
16249
16250
16251
16252
16253
16254
16255
16256
16257
16258
16259
16260
16261
16262
16263
16264
16265
16266
16267
16268
16269
16270
16271
16272
16273
16274
16275
16276
16277
16278
16279
16280
16281
16282
16283
16284
16285
16286
16287
16288
16289
16290
16291
16292
16293
16294
16295
16296
16297
16298
16299
16300
16301
16302
16303
16304
16305
16306
16307
16308
16309
16310
16311
16312
16313
16314
16315
16316
16317
16318
16319
16320
16321
16322
16323
16324
16325
16326
16327
16328
16329
16330
16331
16332
16333
16334
16335
16336
16337
16338
16339
16340
16341
16342
16343
16344
16345
16346
16347
16348
16349
16350
16351
16352
16353
16354
16355
16356
16357
16358
16359
16360
16361
16362
16363
16364
16365
16366
16367
16368
16369
16370
16371
16372
16373
16374
16375
16376
16377
16378
16379
16380
16381
16382
16383
16384
16385
16386
16387
16388
16389
16390
16391
16392
16393
16394
16395
16396
16397
16398
16399
16400
16401
16402
16403
16404
16405
16406
16407
16408
16409
16410
16411
16412
16413
16414
16415
16416
16417
16418
16419
16420
16421
16422
16423
16424
16425
16426
16427
16428
16429
16430
16431
16432
16433
16434
16435
16436
16437
16438
16439
16440
16441
16442
16443
16444
16445
16446
16447
16448
16449
16450
16451
16452
16453
16454
16455
16456
16457
16458
16459
16460
16461
16462
16463
16464
16465
16466
16467
16468
16469
16470
16471
16472
16473
16474
16475
16476
16477
16478
16479
16480
16481
16482
16483
16484
16485
16486
16487
16488
16489
16490
16491
16492
16493
16494
16495
16496
16497
16498
16499
16500
16501
16502
16503
16504
16505
16506
16507
16508
16509
16510
16511
16512
16513
16514
16515
16516
16517
16518
16519
16520
16521
16522
16523
16524
16525
16526
16527
16528
16529
16530
16531
16532
16533
16534
16535
16536
16537
16538
16539
16540
16541
16542
16543
16544
16545
16546
16547
16548
16549
16550
16551
16552
16553
16554
16555
16556
16557
16558
16559
16560
16561
16562
16563
16564
16565
16566
16567
16568
16569
16570
16571
16572
16573
16574
16575
16576
16577
16578
16579
16580
16581
16582
16583
16584
16585
16586
16587
16588
16589
16590
16591
16592
16593
16594
16595
16596
16597
16598
16599
16600
16601
16602
16603
16604
16605
16606
16607
16608
16609
16610
16611
16612
16613
16614
16615
16616
16617
16618
16619
16620
16621
16622
16623
16624
16625
16626
16627
16628
16629
16630
16631
16632
16633
16634
16635
16636
16637
16638
16639
16640
16641
16642
16643
16644
16645
16646
16647
16648
16649
16650
16651
16652
16653
16654
16655
16656
16657
16658
16659
16660
16661
16662
16663
16664
16665
16666
16667
16668
16669
16670
16671
16672
16673
16674
16675
16676
16677
16678
16679
16680
16681
16682
16683
16684
16685
16686
16687
16688
16689
16690
16691
16692
16693
16694
16695
16696
16697
16698
16699
16700
16701
16702
16703
16704
16705
16706
16707
16708
16709
16710
16711
16712
16713
16714
16715
16716
16717
16718
16719
16720
16721
16722
16723
16724
16725
16726
16727
16728
16729
16730
16731
16732
16733
16734
16735
16736
16737
16738
16739
16740
16741
16742
16743
16744
16745
16746
16747
16748
16749
16750
16751
16752
16753
16754
16755
16756
16757
16758
16759
16760
16761
16762
16763
16764
16765
16766
16767
16768
16769
16770
16771
16772
16773
16774
16775
16776
16777
16778
16779
16780
16781
16782
16783
16784
16785
16786
16787
16788
16789
16790
16791
16792
16793
16794
16795
16796
16797
16798
16799
16800
16801
16802
16803
16804
16805
16806
16807
16808
16809
16810
16811
16812
16813
16814
16815
16816
16817
16818
16819
16820
16821
16822
16823
16824
16825
16826
16827
16828
16829
16830
16831
16832
16833
16834
16835
16836
16837
16838
16839
16840
16841
16842
16843
16844
16845
16846
16847
16848
16849
16850
16851
16852
16853
16854
16855
16856
16857
16858
16859
16860
16861
16862
16863
16864
16865
16866
16867
16868
16869
16870
16871
16872
16873
16874
16875
16876
16877
16878
16879
16880
16881
16882
16883
16884
16885
16886
16887
16888
16889
16890
16891
16892
16893
16894
16895
16896
16897
16898
16899
16900
16901
16902
16903
16904
16905
16906
16907
16908
16909
16910
16911
16912
16913
16914
16915
16916
16917
16918
16919
16920
16921
16922
16923
16924
16925
16926
16927
16928
16929
16930
16931
16932
16933
16934
16935
16936
16937
16938
16939
16940
16941
16942
16943
16944
16945
16946
16947
16948
16949
16950
16951
16952
16953
16954
16955
16956
16957
16958
16959
16960
16961
16962
16963
16964
16965
16966
16967
16968
16969
16970
16971
16972
16973
16974
16975
16976
16977
16978
16979
16980
16981
16982
16983
16984
16985
16986
16987
16988
16989
16990
16991
16992
16993
16994
16995
16996
16997
16998
16999
17000
17001
17002
17003
17004
17005
17006
17007
17008
17009
17010
17011
17012
17013
17014
17015
17016
17017
17018
17019
17020
17021
17022
17023
17024
17025
17026
17027
17028
17029
17030
17031
17032
17033
17034
17035
17036
17037
17038
17039
17040
17041
17042
17043
17044
17045
17046
17047
17048
17049
17050
17051
17052
17053
17054
17055
17056
17057
17058
17059
17060
17061
17062
17063
17064
17065
17066
17067
17068
17069
17070
17071
17072
17073
17074
17075
17076
17077
17078
17079
17080
17081
17082
17083
17084
17085
17086
17087
17088
17089
17090
17091
17092
17093
17094
17095
17096
17097
17098
17099
17100
17101
17102
17103
17104
17105
17106
17107
17108
17109
17110
17111
17112
17113
17114
17115
17116
17117
17118
17119
17120
17121
17122
17123
17124
17125
17126
17127
17128
17129
17130
17131
17132
17133
17134
17135
17136
17137
17138
17139
17140
17141
17142
17143
17144
17145
17146
17147
17148
17149
17150
17151
17152
17153
17154
17155
17156
17157
17158
17159
17160
17161
17162
17163
17164
17165
17166
17167
17168
17169
17170
17171
17172
17173
17174
17175
17176
17177
17178
17179
17180
17181
17182
17183
17184
17185
17186
17187
17188
17189
17190
17191
17192
17193
17194
17195
17196
17197
17198
17199
17200
17201
17202
17203
17204
17205
17206
17207
17208
17209
17210
17211
17212
17213
17214
17215
17216
17217
17218
17219
17220
17221
17222
17223
17224
17225
17226
17227
17228
17229
17230
17231
17232
17233
17234
17235
17236
17237
17238
17239
17240
17241
17242
17243
17244
17245
17246
17247
17248
17249
17250
17251
17252
17253
17254
17255
17256
17257
17258
17259
17260
17261
17262
17263
17264
17265
17266
17267
17268
17269
17270
17271
17272
17273
17274
17275
17276
17277
17278
17279
17280
17281
17282
17283
17284
17285
17286
17287
17288
17289
17290
17291
17292
17293
17294
17295
17296
17297
17298
17299
17300
17301
17302
17303
17304
17305
17306
17307
17308
17309
17310
17311
17312
17313
17314
17315
17316
17317
17318
17319
17320
17321
17322
17323
17324
17325
17326
17327
17328
17329
17330
17331
17332
17333
17334
17335
17336
17337
17338
17339
17340
17341
17342
17343
17344
17345
17346
17347
17348
17349
17350
17351
17352
17353
17354
17355
17356
17357
17358
17359
17360
17361
17362
17363
17364
17365
17366
17367
17368
17369
17370
17371
17372
17373
17374
17375
17376
17377
17378
17379
17380
17381
17382
17383
17384
17385
17386
17387
17388
17389
17390
17391
17392
17393
17394
17395
17396
17397
17398
17399
17400
17401
17402
17403
17404
17405
17406
17407
17408
17409
17410
17411
17412
17413
17414
17415
17416
17417
17418
17419
17420
17421
17422
17423
17424
17425
17426
17427
17428
17429
17430
17431
17432
17433
17434
17435
17436
17437
17438
17439
17440
17441
17442
17443
17444
17445
17446
17447
17448
17449
17450
17451
17452
17453
17454
17455
17456
17457
17458
17459
17460
17461
17462
17463
17464
17465
17466
17467
17468
17469
17470
17471
17472
17473
17474
17475
17476
17477
17478
17479
17480
17481
17482
17483
17484
17485
17486
17487
17488
17489
17490
17491
17492
17493
17494
17495
17496
17497
17498
17499
17500
17501
17502
17503
17504
17505
17506
17507
17508
17509
17510
17511
17512
17513
17514
17515
17516
17517
17518
17519
17520
17521
17522
17523
17524
17525
17526
17527
17528
17529
17530
17531
17532
17533
17534
17535
17536
17537
17538
17539
17540
17541
17542
17543
17544
17545
17546
17547
17548
17549
17550
17551
17552
17553
17554
17555
17556
17557
17558
17559
17560
17561
17562
17563
17564
17565
17566
17567
17568
17569
17570
17571
17572
17573
17574
17575
17576
17577
17578
17579
17580
17581
17582
17583
17584
17585
17586
17587
17588
17589
17590
17591
17592
17593
17594
17595
17596
17597
17598
17599
17600
17601
17602
17603
17604
17605
17606
17607
17608
17609
17610
17611
17612
17613
17614
17615
17616
17617
17618
17619
17620
17621
17622
17623
17624
17625
17626
17627
17628
17629
17630
17631
17632
17633
17634
17635
17636
17637
17638
17639
17640
17641
17642
17643
17644
17645
17646
17647
17648
17649
17650
17651
17652
17653
17654
17655
17656
17657
17658
17659
17660
17661
17662
17663
17664
17665
17666
17667
17668
17669
17670
17671
17672
17673
17674
17675
17676
17677
17678
17679
17680
17681
17682
17683
17684
17685
17686
17687
17688
17689
17690
17691
17692
17693
17694
17695
17696
17697
17698
17699
17700
17701
17702
17703
17704
17705
17706
17707
17708
17709
17710
17711
17712
17713
17714
17715
17716
17717
17718
17719
17720
17721
17722
17723
17724
17725
17726
17727
17728
17729
17730
17731
17732
17733
17734
17735
17736
17737
17738
17739
17740
17741
17742
17743
17744
17745
17746
17747
17748
17749
17750
17751
17752
17753
17754
17755
17756
17757
17758
17759
17760
17761
17762
17763
17764
17765
17766
17767
17768
17769
17770
17771
17772
17773
17774
17775
17776
17777
17778
17779
17780
17781
17782
17783
17784
17785
17786
17787
17788
17789
17790
17791
17792
17793
17794
17795
17796
17797
17798
17799
17800
17801
17802
17803
17804
17805
17806
17807
17808
17809
17810
17811
17812
17813
17814
17815
17816
17817
17818
17819
17820
17821
17822
17823
17824
17825
17826
17827
17828
17829
17830
17831
17832
17833
17834
17835
17836
17837
17838
17839
17840
17841
17842
17843
17844
17845
17846
17847
17848
17849
17850
17851
17852
17853
17854
17855
17856
17857
17858
17859
17860
17861
17862
17863
17864
17865
17866
17867
17868
17869
17870
17871
17872
17873
17874
17875
17876
17877
17878
17879
17880
17881
17882
17883
17884
17885
17886
17887
17888
17889
17890
17891
17892
17893
17894
17895
17896
17897
17898
17899
17900
17901
17902
17903
17904
17905
17906
17907
17908
17909
17910
17911
17912
17913
17914
17915
17916
17917
17918
17919
17920
17921
17922
17923
17924
17925
17926
17927
17928
17929
17930
17931
17932
17933
17934
17935
17936
17937
17938
17939
17940
17941
17942
17943
17944
17945
17946
17947
17948
17949
17950
17951
17952
17953
17954
17955
17956
17957
17958
17959
17960
17961
17962
17963
17964
17965
17966
17967
17968
17969
17970
17971
17972
17973
17974
17975
17976
17977
17978
17979
17980
17981
17982
17983
17984
17985
17986
17987
17988
17989
17990
17991
17992
17993
17994
17995
17996
17997
17998
17999
18000
18001
18002
18003
18004
18005
18006
18007
18008
18009
18010
18011
18012
18013
18014
18015
18016
18017
18018
18019
18020
18021
18022
18023
18024
18025
18026
18027
18028
18029
18030
18031
18032
18033
18034
18035
18036
18037
18038
18039
18040
18041
18042
18043
18044
18045
18046
18047
18048
18049
18050
18051
18052
18053
18054
18055
18056
18057
18058
18059
18060
18061
18062
18063
18064
18065
18066
18067
18068
18069
18070
18071
18072
18073
18074
18075
18076
18077
18078
18079
18080
18081
18082
18083
18084
18085
18086
18087
18088
18089
18090
18091
18092
18093
18094
18095
18096
18097
18098
18099
18100
18101
18102
18103
18104
18105
18106
18107
18108
18109
18110
18111
18112
18113
18114
18115
18116
18117
18118
18119
18120
18121
18122
18123
18124
18125
18126
18127
18128
18129
18130
18131
18132
18133
18134
18135
18136
18137
18138
18139
18140
18141
18142
18143
18144
18145
18146
18147
18148
18149
18150
18151
18152
18153
18154
18155
18156
18157
18158
18159
18160
18161
18162
18163
18164
18165
18166
18167
18168
18169
18170
18171
18172
18173
18174
18175
18176
18177
18178
18179
18180
18181
18182
18183
18184
18185
18186
18187
18188
18189
18190
18191
18192
18193
18194
18195
18196
18197
18198
18199
18200
18201
18202
18203
18204
18205
18206
18207
18208
18209
18210
18211
18212
18213
18214
18215
18216
18217
18218
18219
18220
18221
18222
18223
18224
18225
18226
18227
18228
18229
18230
18231
18232
18233
18234
18235
18236
18237
18238
18239
18240
18241
18242
18243
18244
18245
18246
18247
18248
18249
18250
18251
18252
18253
18254
18255
18256
18257
18258
18259
18260
18261
18262
18263
18264
18265
18266
18267
18268
18269
18270
18271
18272
18273
18274
18275
18276
18277
18278
18279
18280
18281
18282
18283
18284
18285
18286
18287
18288
18289
18290
18291
18292
18293
18294
18295
18296
18297
18298
18299
18300
18301
18302
18303
18304
18305
18306
18307
18308
18309
18310
18311
18312
18313
18314
18315
18316
18317
18318
18319
18320
18321
18322
18323
18324
18325
18326
18327
18328
18329
18330
18331
18332
18333
18334
18335
18336
18337
18338
18339
18340
18341
18342
18343
18344
18345
18346
18347
18348
18349
18350
18351
18352
18353
18354
18355
18356
18357
18358
18359
18360
18361
18362
18363
18364
18365
18366
18367
18368
18369
18370
18371
18372
18373
18374
18375
18376
18377
18378
18379
18380
18381
18382
18383
18384
18385
18386
18387
18388
18389
18390
18391
18392
18393
18394
18395
18396
18397
18398
18399
18400
18401
18402
18403
18404
18405
18406
18407
18408
18409
18410
18411
18412
18413
18414
18415
18416
18417
18418
18419
18420
18421
18422
18423
18424
18425
18426
18427
18428
18429
18430
18431
18432
18433
18434
18435
18436
18437
18438
18439
18440
18441
18442
18443
18444
18445
18446
18447
18448
18449
18450
18451
18452
18453
18454
18455
18456
18457
18458
18459
18460
18461
18462
18463
18464
18465
18466
18467
18468
18469
18470
18471
18472
18473
18474
18475
18476
18477
18478
18479
18480
18481
18482
18483
18484
18485
18486
18487
18488
18489
18490
18491
18492
18493
18494
18495
18496
18497
18498
18499
18500
18501
18502
18503
18504
18505
18506
18507
18508
18509
18510
18511
18512
18513
18514
18515
18516
18517
18518
18519
18520
18521
18522
18523
18524
18525
18526
18527
18528
18529
18530
18531
18532
18533
18534
18535
18536
18537
18538
18539
18540
18541
18542
18543
18544
18545
18546
18547
18548
18549
18550
18551
18552
18553
18554
18555
18556
18557
18558
18559
18560
18561
18562
18563
18564
18565
18566
18567
18568
18569
18570
18571
18572
18573
18574
18575
18576
18577
18578
18579
18580
18581
18582
18583
18584
18585
18586
18587
18588
18589
18590
18591
18592
18593
18594
18595
18596
18597
18598
18599
18600
18601
18602
18603
18604
18605
18606
18607
18608
18609
18610
18611
18612
18613
18614
18615
18616
18617
18618
18619
18620
18621
18622
18623
18624
18625
18626
18627
18628
18629
18630
18631
18632
18633
18634
18635
18636
18637
18638
18639
18640
18641
18642
18643
18644
18645
18646
18647
18648
18649
18650
18651
18652
18653
18654
18655
18656
18657
18658
18659
18660
18661
18662
18663
18664
18665
18666
18667
18668
18669
18670
18671
18672
18673
18674
18675
18676
18677
18678
18679
18680
18681
18682
18683
18684
18685
18686
18687
18688
18689
18690
18691
18692
18693
18694
18695
18696
18697
18698
18699
18700
18701
18702
18703
18704
18705
18706
18707
18708
18709
18710
18711
18712
18713
18714
18715
18716
18717
18718
18719
18720
18721
18722
18723
18724
18725
18726
18727
18728
18729
18730
18731
18732
18733
18734
18735
18736
18737
18738
18739
18740
18741
18742
18743
18744
18745
18746
18747
18748
18749
18750
18751
18752
18753
18754
18755
18756
18757
18758
18759
18760
18761
18762
18763
18764
18765
18766
18767
18768
18769
18770
18771
18772
18773
18774
18775
18776
18777
18778
18779
18780
18781
18782
18783
18784
18785
18786
18787
18788
18789
18790
18791
18792
18793
18794
18795
18796
18797
18798
18799
18800
18801
18802
18803
18804
18805
18806
18807
18808
18809
18810
18811
18812
18813
18814
18815
18816
18817
18818
18819
18820
18821
18822
18823
18824
18825
18826
18827
18828
18829
18830
18831
18832
18833
18834
18835
18836
18837
18838
18839
18840
18841
18842
18843
18844
18845
18846
18847
18848
18849
18850
18851
18852
18853
18854
18855
18856
18857
18858
18859
18860
18861
18862
18863
18864
18865
18866
18867
18868
18869
18870
18871
18872
18873
18874
18875
18876
18877
18878
18879
18880
18881
18882
18883
18884
18885
18886
18887
18888
18889
18890
18891
18892
18893
18894
18895
18896
18897
18898
18899
18900
18901
18902
18903
18904
18905
18906
18907
18908
18909
18910
18911
18912
18913
18914
18915
18916
18917
18918
18919
18920
18921
18922
18923
18924
18925
18926
18927
18928
18929
18930
18931
18932
18933
18934
18935
18936
18937
18938
18939
18940
18941
18942
18943
18944
18945
18946
18947
18948
18949
18950
18951
18952
18953
18954
18955
18956
18957
18958
18959
18960
18961
18962
18963
18964
18965
18966
18967
18968
18969
18970
18971
18972
18973
18974
18975
18976
18977
18978
18979
18980
18981
18982
18983
18984
18985
18986
18987
18988
18989
18990
18991
18992
18993
18994
18995
18996
18997
18998
18999
19000
19001
19002
19003
19004
19005
19006
19007
19008
19009
19010
19011
19012
19013
19014
19015
19016
19017
19018
19019
19020
19021
19022
19023
19024
19025
19026
19027
19028
19029
19030
19031
19032
19033
19034
19035
19036
19037
19038
19039
19040
19041
19042
19043
19044
19045
19046
19047
19048
19049
19050
19051
19052
19053
19054
19055
19056
19057
19058
19059
19060
19061
19062
19063
19064
19065
19066
19067
19068
19069
19070
19071
19072
19073
19074
19075
19076
19077
19078
19079
19080
19081
19082
19083
19084
19085
19086
19087
19088
19089
19090
19091
19092
19093
19094
19095
19096
19097
19098
19099
19100
19101
19102
19103
19104
19105
19106
19107
19108
19109
19110
19111
19112
19113
19114
19115
19116
19117
19118
19119
19120
19121
19122
19123
19124
19125
19126
19127
19128
19129
19130
19131
19132
19133
19134
19135
19136
19137
19138
19139
19140
19141
19142
19143
19144
19145
19146
19147
19148
19149
19150
19151
19152
19153
19154
19155
19156
19157
19158
19159
19160
19161
19162
19163
19164
19165
19166
19167
19168
19169
19170
19171
19172
19173
19174
19175
19176
19177
19178
19179
19180
19181
19182
19183
19184
19185
19186
19187
19188
19189
19190
19191
19192
19193
19194
19195
19196
19197
19198
19199
19200
19201
19202
19203
19204
19205
19206
19207
19208
19209
19210
19211
19212
19213
19214
19215
19216
19217
19218
19219
19220
19221
19222
19223
19224
19225
19226
19227
19228
19229
19230
19231
19232
19233
19234
19235
19236
19237
19238
19239
19240
19241
19242
19243
19244
19245
19246
19247
19248
19249
19250
19251
19252
19253
19254
19255
19256
19257
19258
19259
19260
19261
19262
19263
19264
19265
19266
19267
19268
19269
19270
19271
19272
19273
19274
19275
19276
19277
19278
19279
19280
19281
19282
19283
19284
19285
19286
19287
19288
19289
19290
19291
19292
19293
19294
19295
19296
19297
19298
19299
19300
19301
19302
19303
19304
19305
19306
19307
19308
19309
19310
19311
19312
19313
19314
19315
19316
19317
19318
19319
19320
19321
19322
19323
19324
19325
19326
19327
19328
19329
19330
19331
19332
19333
19334
19335
19336
19337
19338
19339
19340
19341
19342
19343
19344
19345
19346
19347
19348
19349
19350
19351
19352
19353
19354
19355
19356
19357
19358
19359
19360
19361
19362
19363
19364
19365
19366
19367
19368
19369
19370
19371
19372
19373
19374
19375
19376
19377
19378
19379
19380
19381
19382
19383
19384
19385
19386
19387
19388
19389
19390
19391
19392
19393
19394
19395
19396
19397
19398
19399
19400
19401
19402
19403
19404
19405
19406
19407
19408
19409
19410
19411
19412
19413
19414
19415
19416
19417
19418
19419
19420
19421
19422
19423
19424
19425
19426
19427
19428
19429
19430
19431
19432
19433
19434
19435
19436
19437
19438
19439
19440
19441
19442
19443
19444
19445
19446
19447
19448
19449
19450
19451
19452
19453
19454
19455
19456
19457
19458
19459
19460
19461
19462
19463
19464
19465
19466
19467
19468
19469
19470
19471
19472
19473
19474
19475
19476
19477
19478
19479
19480
19481
19482
19483
19484
19485
19486
19487
19488
19489
19490
19491
19492
19493
19494
19495
19496
19497
19498
19499
19500
19501
19502
19503
19504
19505
19506
19507
19508
19509
19510
19511
19512
19513
19514
19515
19516
19517
19518
19519
19520
19521
19522
19523
19524
19525
19526
19527
19528
19529
19530
19531
19532
19533
19534
19535
19536
19537
19538
19539
19540
19541
19542
19543
19544
19545
19546
19547
19548
19549
19550
19551
19552
19553
19554
19555
19556
19557
19558
19559
19560
19561
19562
19563
19564
19565
19566
19567
19568
19569
19570
19571
19572
19573
19574
19575
19576
19577
19578
19579
19580
19581
19582
19583
19584
19585
19586
19587
19588
19589
19590
19591
19592
19593
19594
19595
19596
19597
19598
19599
19600
19601
19602
19603
19604
19605
19606
19607
19608
19609
19610
19611
19612
19613
19614
19615
19616
19617
19618
19619
19620
19621
19622
19623
19624
19625
19626
19627
19628
19629
19630
19631
19632
19633
19634
19635
19636
19637
19638
19639
19640
19641
19642
19643
19644
19645
19646
19647
19648
19649
19650
19651
19652
19653
19654
19655
19656
19657
19658
19659
19660
19661
19662
19663
19664
19665
19666
19667
19668
19669
19670
19671
19672
19673
19674
19675
19676
19677
19678
19679
19680
19681
19682
19683
19684
19685
19686
19687
19688
19689
19690
19691
19692
19693
19694
19695
19696
19697
19698
19699
19700
19701
19702
19703
19704
19705
19706
19707
19708
19709
19710
19711
19712
19713
19714
19715
19716
19717
19718
19719
19720
19721
19722
19723
19724
19725
19726
19727
19728
19729
19730
19731
19732
19733
19734
19735
19736
19737
19738
19739
19740
19741
19742
19743
19744
19745
19746
19747
19748
19749
19750
19751
19752
19753
19754
19755
19756
19757
19758
19759
19760
19761
19762
19763
19764
19765
19766
19767
19768
19769
19770
19771
19772
19773
19774
19775
19776
19777
19778
19779
19780
19781
19782
19783
19784
19785
19786
19787
19788
19789
19790
19791
19792
19793
19794
19795
19796
19797
19798
19799
19800
19801
19802
19803
19804
19805
19806
19807
19808
19809
19810
19811
19812
19813
19814
19815
19816
19817
19818
19819
19820
19821
19822
19823
19824
19825
19826
19827
19828
19829
19830
19831
19832
19833
19834
19835
19836
19837
19838
19839
19840
19841
19842
19843
19844
19845
19846
19847
19848
19849
19850
19851
19852
19853
19854
19855
19856
19857
19858
19859
19860
19861
19862
19863
19864
19865
19866
19867
19868
19869
19870
19871
19872
19873
19874
19875
19876
19877
19878
19879
19880
19881
19882
19883
19884
19885
19886
19887
19888
19889
19890
19891
19892
19893
19894
19895
19896
19897
19898
19899
19900
19901
19902
19903
19904
19905
19906
19907
19908
19909
19910
19911
19912
19913
19914
19915
19916
19917
19918
19919
19920
19921
19922
19923
19924
19925
19926
19927
19928
19929
19930
19931
19932
19933
19934
19935
19936
19937
19938
19939
19940
19941
19942
19943
19944
19945
19946
19947
19948
19949
19950
19951
19952
19953
19954
19955
19956
19957
19958
19959
19960
19961
19962
19963
19964
19965
19966
19967
19968
19969
19970
19971
19972
19973
19974
19975
19976
19977
19978
19979
19980
19981
19982
19983
19984
19985
19986
19987
19988
19989
19990
19991
19992
19993
19994
19995
19996
19997
19998
19999
20000
20001
20002
20003
20004
20005
20006
20007
20008
20009
20010
20011
20012
20013
20014
20015
20016
20017
20018
20019
20020
20021
20022
20023
20024
20025
20026
20027
20028
20029
20030
20031
20032
20033
20034
20035
20036
20037
20038
20039
20040
20041
20042
20043
20044
20045
20046
20047
20048
20049
20050
20051
20052
20053
20054
20055
20056
20057
20058
20059
20060
20061
20062
20063
20064
20065
20066
20067
20068
20069
20070
20071
20072
20073
20074
20075
20076
20077
20078
20079
20080
20081
20082
20083
20084
20085
20086
20087
20088
20089
20090
20091
20092
20093
20094
20095
20096
20097
20098
20099
20100
20101
20102
20103
20104
20105
20106
20107
20108
20109
20110
20111
20112
20113
20114
20115
20116
20117
20118
20119
20120
20121
20122
20123
20124
20125
20126
20127
20128
20129
20130
20131
20132
20133
20134
20135
20136
20137
20138
20139
20140
20141
20142
20143
20144
20145
20146
20147
20148
20149
20150
20151
20152
20153
20154
20155
20156
20157
20158
20159
20160
20161
20162
20163
20164
20165
20166
20167
20168
20169
20170
20171
20172
20173
20174
20175
20176
20177
20178
20179
20180
20181
20182
20183
20184
20185
20186
20187
20188
20189
20190
20191
20192
20193
20194
20195
20196
20197
20198
20199
20200
20201
20202
20203
20204
20205
20206
20207
20208
20209
20210
20211
20212
20213
20214
20215
20216
20217
20218
20219
20220
20221
20222
20223
20224
20225
20226
20227
20228
20229
20230
20231
20232
20233
20234
20235
20236
20237
20238
20239
20240
20241
20242
20243
20244
20245
20246
20247
20248
20249
20250
20251
20252
20253
20254
20255
20256
20257
20258
20259
20260
20261
20262
20263
20264
20265
20266
20267
20268
20269
20270
20271
20272
20273
20274
20275
20276
20277
20278
20279
20280
20281
20282
20283
20284
20285
20286
20287
20288
20289
20290
20291
20292
20293
20294
20295
20296
20297
20298
20299
20300
20301
20302
20303
20304
20305
20306
20307
20308
20309
20310
20311
20312
20313
20314
20315
20316
20317
20318
20319
20320
20321
20322
20323
20324
20325
20326
20327
20328
20329
20330
20331
20332
20333
20334
20335
20336
20337
20338
20339
20340
20341
20342
20343
20344
20345
20346
20347
20348
20349
20350
20351
20352
20353
20354
20355
20356
20357
20358
20359
20360
20361
20362
20363
20364
20365
20366
20367
20368
20369
20370
20371
20372
20373
20374
20375
20376
20377
20378
20379
20380
20381
20382
20383
20384
20385
20386
20387
20388
20389
20390
20391
20392
20393
20394
20395
20396
20397
20398
20399
20400
20401
20402
20403
20404
20405
20406
20407
20408
20409
20410
20411
20412
20413
20414
20415
20416
20417
20418
20419
20420
20421
20422
20423
20424
20425
20426
20427
20428
20429
20430
20431
20432
20433
20434
20435
20436
20437
20438
20439
20440
20441
20442
20443
20444
20445
20446
20447
20448
20449
20450
20451
20452
20453
20454
20455
20456
20457
20458
20459
20460
20461
20462
20463
20464
20465
20466
20467
20468
20469
20470
20471
20472
20473
20474
20475
20476
20477
20478
20479
20480
20481
20482
20483
20484
20485
20486
20487
20488
20489
20490
20491
20492
20493
20494
20495
20496
20497
20498
20499
20500
20501
20502
20503
20504
20505
20506
20507
20508
20509
20510
20511
20512
20513
20514
20515
20516
20517
20518
20519
20520
20521
20522
20523
20524
20525
20526
20527
20528
20529
20530
20531
20532
20533
20534
20535
20536
20537
20538
20539
20540
20541
20542
20543
20544
20545
20546
20547
20548
20549
20550
20551
20552
20553
20554
20555
20556
20557
20558
20559
20560
20561
20562
20563
20564
20565
20566
20567
20568
20569
20570
20571
20572
20573
20574
20575
20576
20577
20578
20579
20580
20581
20582
20583
20584
20585
20586
20587
20588
20589
20590
20591
20592
20593
20594
20595
20596
20597
20598
20599
20600
20601
20602
20603
20604
20605
20606
20607
20608
20609
20610
20611
20612
20613
20614
20615
20616
20617
20618
20619
20620
20621
20622
20623
20624
20625
20626
20627
20628
20629
20630
20631
20632
20633
20634
20635
20636
20637
20638
20639
20640
20641
20642
20643
20644
20645
20646
20647
20648
20649
20650
20651
20652
20653
20654
20655
20656
20657
20658
20659
20660
20661
20662
20663
20664
20665
20666
20667
20668
20669
20670
20671
20672
20673
20674
20675
20676
20677
20678
20679
20680
20681
20682
20683
20684
20685
20686
20687
20688
20689
20690
20691
20692
20693
20694
20695
20696
20697
20698
20699
20700
20701
20702
20703
20704
20705
20706
20707
20708
20709
20710
20711
20712
20713
20714
20715
20716
20717
20718
20719
20720
20721
20722
20723
20724
20725
20726
20727
20728
20729
20730
20731
20732
20733
20734
20735
20736
20737
20738
20739
20740
20741
20742
20743
20744
20745
20746
20747
20748
20749
20750
20751
20752
20753
20754
20755
20756
20757
20758
20759
20760
20761
20762
20763
20764
20765
20766
20767
20768
20769
20770
20771
20772
20773
20774
20775
20776
20777
20778
20779
20780
20781
20782
20783
20784
20785
20786
20787
20788
20789
20790
20791
20792
20793
20794
20795
20796
20797
20798
20799
20800
20801
20802
20803
20804
20805
20806
20807
20808
20809
20810
20811
20812
20813
20814
20815
20816
20817
20818
20819
20820
20821
20822
20823
20824
20825
20826
20827
20828
20829
20830
20831
20832
20833
20834
20835
20836
20837
20838
20839
20840
20841
20842
20843
20844
20845
20846
20847
20848
20849
20850
20851
20852
20853
20854
20855
20856
20857
20858
20859
20860
20861
20862
20863
20864
20865
20866
20867
20868
20869
20870
20871
20872
20873
20874
20875
20876
20877
20878
20879
20880
20881
20882
20883
20884
20885
20886
20887
20888
20889
20890
20891
20892
20893
20894
20895
20896
20897
20898
20899
20900
20901
20902
20903
20904
20905
20906
20907
20908
20909
20910
20911
20912
20913
20914
20915
20916
20917
20918
20919
20920
20921
20922
20923
20924
20925
20926
20927
20928
20929
20930
20931
20932
20933
20934
20935
20936
20937
20938
20939
20940
20941
20942
20943
20944
20945
20946
20947
20948
20949
20950
20951
20952
20953
20954
20955
20956
20957
20958
20959
20960
20961
20962
20963
20964
20965
20966
20967
20968
20969
20970
20971
20972
20973
20974
20975
20976
20977
20978
20979
20980
20981
20982
20983
20984
20985
20986
20987
20988
20989
20990
20991
20992
20993
20994
20995
20996
20997
20998
20999
21000
21001
21002
21003
21004
21005
21006
21007
21008
21009
21010
21011
21012
21013
21014
21015
21016
21017
21018
21019
21020
21021
21022
21023
21024
21025
21026
21027
21028
21029
21030
21031
21032
21033
21034
21035
21036
21037
21038
21039
21040
21041
21042
21043
21044
21045
21046
21047
21048
21049
21050
21051
21052
21053
21054
21055
21056
21057
21058
21059
21060
21061
21062
21063
21064
21065
21066
21067
21068
21069
21070
21071
21072
21073
21074
21075
21076
21077
21078
21079
21080
21081
21082
21083
21084
21085
21086
21087
21088
21089
21090
21091
21092
21093
21094
21095
21096
21097
21098
21099
21100
21101
21102
21103
21104
21105
21106
21107
21108
21109
21110
21111
21112
21113
21114
21115
21116
21117
21118
21119
21120
21121
21122
21123
21124
21125
21126
21127
21128
21129
21130
21131
21132
21133
21134
21135
21136
21137
21138
21139
21140
21141
21142
21143
21144
21145
21146
21147
21148
21149
21150
21151
21152
21153
21154
21155
21156
21157
21158
21159
21160
21161
21162
21163
21164
21165
21166
21167
21168
21169
21170
21171
21172
21173
21174
21175
21176
21177
21178
21179
21180
21181
21182
21183
21184
21185
21186
21187
21188
21189
21190
21191
21192
21193
21194
21195
21196
21197
21198
21199
21200
21201
21202
21203
21204
21205
21206
21207
21208
21209
21210
21211
21212
21213
21214
21215
21216
21217
21218
21219
21220
21221
21222
21223
21224
21225
21226
21227
21228
21229
21230
21231
21232
21233
21234
21235
21236
21237
21238
21239
21240
21241
21242
21243
21244
21245
21246
21247
21248
21249
21250
21251
21252
21253
21254
21255
21256
21257
21258
21259
21260
21261
21262
21263
21264
21265
21266
21267
21268
21269
21270
21271
21272
21273
21274
21275
21276
21277
21278
21279
21280
21281
21282
21283
21284
21285
21286
21287
21288
21289
21290
21291
21292
21293
21294
21295
21296
21297
21298
21299
21300
21301
21302
21303
21304
21305
21306
21307
21308
21309
21310
21311
21312
21313
21314
21315
21316
21317
21318
21319
21320
21321
21322
21323
21324
21325
21326
21327
21328
21329
21330
21331
21332
21333
21334
21335
21336
21337
21338
21339
21340
21341
21342
21343
21344
21345
21346
21347
21348
21349
21350
21351
21352
21353
21354
21355
21356
21357
21358
21359
21360
21361
21362
21363
21364
21365
21366
21367
21368
21369
21370
21371
21372
21373
21374
21375
21376
21377
21378
21379
21380
21381
21382
21383
21384
21385
21386
21387
21388
21389
21390
21391
21392
21393
21394
21395
21396
21397
21398
21399
21400
21401
21402
21403
21404
21405
21406
21407
21408
21409
21410
21411
21412
21413
21414
21415
21416
21417
21418
21419
21420
21421
21422
21423
21424
21425
21426
21427
21428
21429
21430
21431
21432
21433
21434
21435
21436
21437
21438
21439
21440
21441
21442
21443
21444
21445
21446
21447
21448
21449
21450
21451
21452
21453
21454
21455
21456
21457
21458
21459
21460
21461
21462
21463
21464
21465
21466
21467
21468
21469
21470
21471
21472
21473
21474
21475
21476
21477
21478
21479
21480
21481
21482
21483
21484
21485
21486
21487
21488
21489
21490
21491
21492
21493
21494
21495
21496
21497
21498
21499
21500
21501
21502
21503
21504
21505
21506
21507
21508
21509
21510
21511
21512
21513
21514
21515
21516
21517
21518
21519
21520
21521
21522
21523
21524
21525
21526
21527
21528
21529
21530
21531
21532
21533
21534
21535
21536
21537
21538
21539
21540
21541
21542
21543
21544
21545
21546
21547
21548
21549
21550
21551
21552
21553
21554
21555
21556
21557
21558
21559
21560
21561
21562
21563
21564
21565
21566
21567
21568
21569
21570
21571
21572
21573
21574
21575
21576
21577
21578
21579
21580
21581
21582
21583
21584
21585
21586
21587
21588
21589
21590
21591
21592
21593
21594
21595
21596
21597
21598
21599
21600
21601
21602
21603
21604
21605
21606
21607
21608
21609
21610
21611
21612
21613
21614
21615
21616
21617
21618
21619
21620
21621
21622
21623
21624
21625
21626
21627
21628
21629
21630
21631
21632
21633
21634
21635
21636
21637
21638
21639
21640
21641
21642
21643
21644
21645
21646
21647
21648
21649
21650
21651
21652
21653
21654
21655
21656
21657
21658
21659
21660
21661
21662
21663
21664
21665
21666
21667
21668
21669
21670
21671
21672
21673
21674
21675
21676
21677
21678
21679
21680
21681
21682
21683
21684
21685
21686
21687
21688
21689
21690
21691
21692
21693
21694
21695
21696
21697
21698
21699
21700
21701
21702
21703
21704
21705
21706
21707
21708
21709
21710
21711
21712
21713
21714
21715
21716
21717
21718
21719
21720
21721
21722
21723
21724
21725
21726
21727
21728
21729
21730
21731
21732
21733
21734
21735
21736
21737
21738
21739
21740
21741
21742
21743
21744
21745
21746
21747
21748
21749
21750
21751
21752
21753
21754
21755
21756
21757
21758
21759
21760
21761
21762
21763
21764
21765
21766
21767
21768
21769
21770
21771
21772
21773
21774
21775
21776
21777
21778
21779
21780
21781
21782
21783
21784
21785
21786
21787
21788
21789
21790
21791
21792
21793
21794
21795
21796
21797
21798
21799
21800
21801
21802
21803
21804
21805
21806
21807
21808
21809
21810
21811
21812
21813
21814
21815
21816
21817
21818
21819
21820
21821
21822
21823
21824
21825
21826
21827
21828
21829
21830
21831
21832
21833
21834
21835
21836
21837
21838
21839
21840
21841
21842
21843
21844
21845
21846
21847
21848
21849
21850
21851
21852
21853
21854
21855
21856
21857
21858
21859
21860
21861
21862
21863
21864
21865
21866
21867
21868
21869
21870
21871
21872
21873
21874
21875
21876
21877
21878
21879
21880
21881
21882
21883
21884
21885
21886
21887
21888
21889
21890
21891
21892
21893
21894
21895
21896
21897
21898
21899
21900
21901
21902
21903
21904
21905
21906
21907
21908
21909
21910
21911
21912
21913
21914
21915
21916
21917
21918
21919
21920
21921
21922
21923
21924
21925
21926
21927
21928
21929
21930
21931
21932
21933
21934
21935
21936
21937
21938
21939
21940
21941
21942
21943
21944
21945
21946
21947
21948
21949
21950
21951
21952
21953
21954
21955
21956
21957
21958
21959
21960
21961
21962
21963
21964
21965
21966
21967
21968
21969
21970
21971
21972
21973
21974
21975
21976
21977
21978
21979
21980
21981
21982
21983
21984
21985
21986
21987
21988
21989
21990
21991
21992
21993
21994
21995
21996
21997
21998
21999
22000
22001
22002
22003
22004
22005
22006
22007
22008
22009
22010
22011
22012
22013
22014
22015
22016
22017
22018
22019
22020
22021
22022
22023
22024
22025
22026
22027
22028
22029
22030
22031
22032
22033
22034
22035
22036
22037
22038
22039
22040
22041
22042
22043
22044
22045
22046
22047
22048
22049
22050
22051
22052
22053
22054
22055
22056
22057
22058
22059
22060
22061
22062
22063
22064
22065
22066
22067
22068
22069
22070
22071
22072
22073
22074
22075
22076
22077
22078
22079
22080
22081
22082
22083
22084
22085
22086
22087
22088
22089
22090
22091
22092
22093
22094
22095
22096
22097
22098
22099
22100
22101
22102
22103
22104
22105
22106
22107
22108
22109
22110
22111
22112
22113
22114
22115
22116
22117
22118
22119
22120
22121
22122
22123
22124
22125
22126
22127
22128
22129
22130
22131
22132
22133
22134
22135
22136
22137
22138
22139
22140
22141
22142
22143
22144
22145
22146
22147
22148
22149
22150
22151
22152
22153
22154
22155
22156
22157
22158
22159
22160
22161
22162
22163
22164
22165
22166
22167
22168
22169
22170
22171
22172
22173
22174
22175
22176
22177
22178
22179
22180
22181
22182
22183
22184
22185
22186
22187
22188
22189
22190
22191
22192
22193
22194
22195
22196
22197
22198
22199
22200
22201
22202
22203
22204
22205
22206
22207
22208
22209
22210
22211
22212
22213
22214
22215
22216
22217
22218
22219
22220
22221
22222
22223
22224
22225
22226
22227
22228
22229
22230
22231
22232
22233
22234
22235
22236
22237
22238
22239
22240
22241
22242
22243
22244
22245
22246
22247
22248
22249
22250
22251
22252
22253
22254
22255
22256
22257
22258
22259
22260
22261
22262
22263
22264
22265
22266
22267
22268
22269
22270
22271
22272
22273
22274
22275
22276
22277
22278
22279
22280
22281
22282
22283
22284
22285
22286
22287
22288
22289
22290
22291
22292
22293
22294
22295
22296
22297
22298
22299
22300
22301
22302
22303
22304
22305
22306
22307
22308
22309
22310
22311
22312
22313
22314
22315
22316
22317
22318
22319
22320
22321
22322
22323
22324
22325
22326
22327
22328
22329
22330
22331
22332
22333
22334
22335
22336
22337
22338
22339
22340
22341
22342
22343
22344
22345
22346
22347
22348
22349
22350
22351
22352
22353
22354
22355
22356
22357
22358
22359
22360
22361
22362
22363
22364
22365
22366
22367
22368
22369
22370
22371
22372
22373
22374
22375
22376
22377
22378
22379
22380
22381
22382
22383
22384
22385
22386
22387
22388
22389
22390
22391
22392
22393
22394
22395
22396
22397
22398
22399
22400
22401
22402
22403
22404
22405
22406
22407
22408
22409
22410
22411
22412
22413
22414
22415
22416
22417
22418
22419
22420
22421
22422
22423
22424
22425
22426
22427
22428
22429
22430
22431
22432
22433
22434
22435
22436
22437
22438
22439
22440
22441
22442
22443
22444
22445
22446
22447
22448
22449
22450
22451
22452
22453
22454
22455
22456
22457
22458
22459
22460
22461
22462
22463
22464
22465
22466
22467
22468
22469
22470
22471
22472
22473
22474
22475
22476
22477
22478
22479
22480
22481
22482
22483
22484
22485
22486
22487
22488
22489
22490
22491
22492
22493
22494
22495
22496
22497
22498
22499
22500
22501
22502
22503
22504
22505
22506
22507
22508
22509
22510
22511
22512
22513
22514
22515
22516
22517
22518
22519
22520
22521
22522
22523
22524
22525
22526
22527
22528
22529
22530
22531
22532
22533
22534
22535
22536
22537
22538
22539
22540
22541
22542
22543
22544
22545
22546
22547
22548
22549
22550
22551
22552
22553
22554
22555
22556
22557
22558
22559
22560
22561
22562
22563
22564
22565
22566
22567
22568
22569
22570
22571
22572
22573
22574
22575
22576
22577
22578
22579
22580
22581
22582
22583
22584
22585
22586
22587
22588
22589
22590
22591
22592
22593
22594
22595
22596
22597
22598
22599
22600
22601
22602
22603
22604
22605
22606
22607
22608
22609
22610
22611
22612
22613
22614
22615
22616
22617
22618
22619
22620
22621
22622
22623
22624
22625
22626
22627
22628
22629
22630
22631
22632
22633
22634
22635
22636
22637
22638
22639
22640
22641
22642
22643
22644
22645
22646
22647
22648
22649
22650
22651
22652
22653
22654
22655
22656
22657
22658
22659
22660
22661
22662
22663
22664
22665
22666
22667
22668
22669
22670
22671
22672
22673
22674
22675
22676
22677
22678
22679
22680
22681
22682
22683
22684
22685
22686
22687
22688
22689
22690
22691
22692
22693
22694
22695
22696
22697
22698
22699
22700
22701
22702
22703
22704
22705
22706
22707
22708
22709
22710
22711
22712
22713
22714
22715
22716
22717
22718
22719
22720
22721
22722
22723
22724
22725
22726
22727
22728
22729
22730
22731
22732
22733
22734
22735
22736
22737
22738
22739
22740
22741
22742
22743
22744
22745
22746
22747
22748
22749
22750
22751
22752
22753
22754
22755
22756
22757
22758
22759
22760
22761
22762
22763
22764
22765
22766
22767
22768
22769
22770
22771
22772
22773
22774
22775
22776
22777
22778
22779
22780
22781
22782
22783
22784
22785
22786
22787
22788
22789
22790
22791
22792
22793
22794
22795
22796
22797
22798
22799
22800
22801
22802
22803
22804
22805
22806
22807
22808
22809
22810
22811
22812
22813
22814
22815
22816
22817
22818
22819
22820
22821
22822
22823
22824
22825
22826
22827
22828
22829
22830
22831
22832
22833
22834
22835
22836
22837
22838
22839
22840
22841
22842
22843
22844
22845
22846
22847
22848
22849
22850
22851
22852
22853
22854
22855
22856
22857
22858
22859
22860
22861
22862
22863
22864
22865
22866
22867
22868
22869
22870
22871
22872
22873
22874
22875
22876
22877
22878
22879
22880
22881
22882
22883
22884
22885
22886
22887
22888
22889
22890
22891
22892
22893
22894
22895
22896
22897
22898
22899
22900
22901
22902
22903
22904
22905
22906
22907
22908
22909
22910
22911
22912
22913
22914
22915
22916
22917
22918
22919
22920
22921
22922
22923
22924
22925
22926
22927
22928
22929
22930
22931
22932
22933
22934
22935
22936
22937
22938
22939
22940
22941
22942
22943
22944
22945
22946
22947
22948
22949
22950
22951
22952
22953
22954
22955
22956
22957
22958
22959
22960
22961
22962
22963
22964
22965
22966
22967
22968
22969
22970
22971
22972
22973
22974
22975
22976
22977
22978
22979
22980
22981
22982
22983
22984
22985
22986
22987
22988
22989
22990
22991
22992
22993
22994
22995
22996
22997
22998
22999
23000
23001
23002
23003
23004
23005
23006
23007
23008
23009
23010
23011
23012
23013
23014
23015
23016
23017
23018
23019
23020
23021
23022
23023
23024
23025
23026
23027
23028
23029
23030
23031
23032
23033
23034
23035
23036
23037
23038
23039
23040
23041
23042
23043
23044
23045
23046
23047
23048
23049
23050
23051
23052
23053
23054
23055
23056
23057
23058
23059
23060
23061
23062
23063
23064
23065
23066
23067
23068
23069
23070
23071
23072
23073
23074
23075
23076
23077
23078
23079
23080
23081
23082
23083
23084
23085
23086
23087
23088
23089
23090
23091
23092
23093
23094
23095
23096
23097
23098
23099
23100
23101
23102
23103
23104
23105
23106
23107
23108
23109
23110
23111
23112
23113
23114
23115
23116
23117
23118
23119
23120
23121
23122
23123
23124
23125
23126
23127
23128
23129
23130
23131
23132
23133
23134
23135
23136
23137
23138
23139
23140
23141
23142
23143
23144
23145
23146
23147
23148
23149
23150
23151
23152
23153
23154
23155
23156
23157
23158
23159
23160
23161
23162
23163
23164
23165
23166
23167
23168
23169
23170
23171
23172
23173
23174
23175
23176
23177
23178
23179
23180
23181
23182
23183
23184
23185
23186
23187
23188
23189
23190
23191
23192
23193
23194
23195
23196
23197
23198
23199
23200
23201
23202
23203
23204
23205
23206
23207
23208
23209
23210
23211
23212
23213
23214
23215
23216
23217
23218
23219
23220
23221
23222
23223
23224
23225
23226
23227
23228
23229
23230
23231
23232
23233
23234
23235
23236
23237
23238
23239
23240
23241
23242
23243
23244
23245
23246
23247
23248
23249
23250
23251
23252
23253
23254
23255
23256
23257
23258
23259
23260
23261
23262
23263
23264
23265
23266
23267
23268
23269
23270
23271
23272
23273
23274
23275
23276
23277
23278
23279
23280
23281
23282
23283
23284
23285
23286
23287
23288
23289
23290
23291
23292
23293
23294
23295
23296
23297
23298
23299
23300
23301
23302
23303
23304
23305
23306
23307
23308
23309
23310
23311
23312
23313
23314
23315
23316
23317
23318
23319
23320
23321
23322
23323
23324
23325
23326
23327
23328
23329
23330
23331
23332
23333
23334
23335
23336
23337
23338
23339
23340
23341
23342
23343
23344
23345
23346
23347
23348
23349
23350
23351
23352
23353
23354
23355
23356
23357
23358
23359
23360
23361
23362
23363
23364
23365
23366
23367
23368
23369
23370
23371
23372
23373
23374
23375
23376
23377
23378
23379
23380
23381
23382
23383
23384
23385
23386
23387
23388
23389
23390
23391
23392
23393
23394
23395
23396
23397
23398
23399
23400
23401
23402
23403
23404
23405
23406
23407
23408
23409
23410
23411
23412
23413
23414
23415
23416
23417
23418
23419
23420
23421
23422
23423
23424
23425
23426
23427
23428
23429
23430
23431
23432
23433
23434
23435
23436
23437
23438
23439
23440
23441
23442
23443
23444
23445
23446
23447
23448
23449
23450
23451
23452
23453
23454
23455
23456
23457
23458
23459
23460
23461
23462
23463
23464
23465
23466
23467
23468
23469
23470
23471
23472
23473
23474
23475
23476
23477
23478
23479
23480
23481
23482
23483
23484
23485
23486
23487
23488
23489
23490
23491
23492
23493
23494
23495
23496
23497
23498
23499
23500
23501
23502
23503
23504
23505
23506
23507
23508
23509
23510
23511
23512
23513
23514
23515
23516
23517
23518
23519
23520
23521
23522
23523
23524
23525
23526
23527
23528
23529
23530
23531
23532
23533
23534
23535
23536
23537
23538
23539
23540
23541
23542
23543
23544
23545
23546
23547
23548
23549
23550
23551
23552
23553
23554
23555
23556
23557
23558
23559
23560
23561
23562
23563
23564
23565
23566
23567
23568
23569
23570
23571
23572
23573
23574
23575
23576
23577
23578
23579
23580
23581
23582
23583
23584
23585
23586
23587
23588
23589
23590
23591
23592
23593
23594
23595
23596
23597
23598
23599
23600
23601
23602
23603
23604
23605
23606
23607
23608
23609
23610
23611
23612
23613
23614
23615
23616
23617
23618
23619
23620
23621
23622
23623
23624
23625
23626
23627
23628
23629
23630
23631
23632
23633
23634
23635
23636
23637
23638
23639
23640
23641
23642
23643
23644
23645
23646
23647
23648
23649
23650
23651
23652
23653
23654
23655
23656
23657
23658
23659
23660
23661
23662
23663
23664
23665
23666
23667
23668
23669
23670
23671
23672
23673
23674
23675
23676
23677
23678
23679
23680
23681
23682
23683
23684
23685
23686
23687
23688
23689
23690
23691
23692
23693
23694
23695
23696
23697
23698
23699
23700
23701
23702
23703
23704
23705
23706
23707
23708
23709
23710
23711
23712
23713
23714
23715
23716
23717
23718
23719
23720
23721
23722
23723
23724
23725
23726
23727
23728
23729
23730
23731
23732
23733
23734
23735
23736
23737
23738
23739
23740
23741
23742
23743
23744
23745
23746
23747
23748
23749
23750
23751
23752
23753
23754
23755
23756
23757
23758
23759
23760
23761
23762
23763
23764
23765
23766
23767
23768
23769
23770
23771
23772
23773
23774
23775
23776
23777
23778
23779
23780
23781
23782
23783
23784
23785
23786
23787
23788
23789
23790
23791
23792
23793
23794
23795
23796
23797
23798
23799
23800
23801
23802
23803
23804
23805
23806
23807
23808
23809
23810
23811
23812
23813
23814
23815
23816
23817
23818
23819
23820
23821
23822
23823
23824
23825
23826
23827
23828
23829
23830
23831
23832
23833
23834
23835
23836
23837
23838
23839
23840
23841
23842
23843
23844
23845
23846
23847
23848
23849
23850
23851
23852
23853
23854
23855
23856
23857
23858
23859
23860
23861
23862
23863
23864
23865
23866
23867
23868
23869
23870
23871
23872
23873
23874
23875
23876
23877
23878
23879
23880
23881
23882
23883
23884
23885
23886
23887
23888
23889
23890
23891
23892
23893
23894
23895
23896
23897
23898
23899
23900
23901
23902
23903
23904
23905
23906
23907
23908
23909
23910
23911
23912
23913
23914
23915
23916
23917
23918
23919
23920
23921
23922
23923
23924
23925
23926
23927
23928
23929
23930
23931
23932
23933
23934
23935
23936
23937
23938
23939
23940
23941
23942
23943
23944
23945
23946
23947
23948
23949
23950
23951
23952
23953
23954
23955
23956
23957
23958
23959
23960
23961
23962
23963
23964
23965
23966
23967
23968
23969
23970
23971
23972
23973
23974
23975
23976
23977
23978
23979
23980
23981
23982
23983
23984
23985
23986
23987
23988
23989
23990
23991
23992
23993
23994
23995
23996
23997
23998
23999
24000
24001
24002
24003
24004
24005
24006
24007
24008
24009
24010
24011
24012
24013
24014
24015
24016
24017
24018
24019
24020
24021
24022
24023
24024
24025
24026
24027
24028
24029
24030
24031
24032
24033
24034
24035
24036
24037
24038
24039
24040
24041
24042
24043
24044
24045
24046
24047
24048
24049
24050
24051
24052
24053
24054
24055
24056
24057
24058
24059
24060
24061
24062
24063
24064
24065
24066
24067
24068
24069
24070
24071
24072
24073
24074
24075
24076
24077
24078
24079
24080
24081
24082
24083
24084
24085
24086
24087
24088
24089
24090
24091
24092
24093
24094
24095
24096
24097
24098
24099
24100
24101
24102
24103
24104
24105
24106
24107
24108
24109
24110
24111
24112
24113
24114
24115
24116
24117
24118
24119
24120
24121
24122
24123
24124
24125
24126
24127
24128
24129
24130
24131
24132
24133
24134
24135
24136
24137
24138
24139
24140
24141
24142
24143
24144
24145
24146
24147
24148
24149
24150
24151
24152
24153
24154
24155
24156
24157
24158
24159
24160
24161
24162
24163
24164
24165
24166
24167
24168
24169
24170
24171
24172
24173
24174
24175
24176
24177
24178
24179
24180
24181
24182
24183
24184
24185
24186
24187
24188
24189
24190
24191
24192
24193
24194
24195
24196
24197
24198
24199
24200
24201
24202
24203
24204
24205
24206
24207
24208
24209
24210
24211
24212
24213
24214
24215
24216
24217
24218
24219
24220
24221
24222
24223
24224
24225
24226
24227
24228
24229
24230
24231
24232
24233
24234
24235
24236
24237
24238
24239
24240
24241
24242
24243
24244
24245
24246
24247
24248
24249
24250
24251
24252
24253
24254
24255
24256
24257
24258
24259
24260
24261
24262
24263
24264
24265
24266
24267
24268
24269
24270
24271
24272
24273
24274
24275
24276
24277
24278
24279
24280
24281
24282
24283
24284
24285
24286
24287
24288
24289
24290
24291
24292
24293
24294
24295
24296
24297
24298
24299
24300
24301
24302
24303
24304
24305
24306
24307
24308
24309
24310
24311
24312
24313
24314
24315
24316
24317
24318
24319
24320
24321
24322
24323
24324
24325
24326
24327
24328
24329
24330
24331
24332
24333
24334
24335
24336
24337
24338
24339
24340
24341
24342
24343
24344
24345
24346
24347
24348
24349
24350
24351
24352
24353
24354
24355
24356
24357
24358
24359
24360
24361
24362
24363
24364
24365
24366
24367
24368
24369
24370
24371
24372
24373
24374
24375
24376
24377
24378
24379
24380
24381
24382
24383
24384
24385
24386
24387
24388
24389
24390
24391
24392
24393
24394
24395
24396
24397
24398
24399
24400
24401
24402
24403
24404
24405
24406
24407
24408
24409
24410
24411
24412
24413
24414
24415
24416
24417
24418
24419
24420
24421
24422
24423
24424
24425
24426
24427
24428
24429
24430
24431
24432
24433
24434
24435
24436
24437
24438
24439
24440
24441
24442
24443
24444
24445
24446
24447
24448
24449
24450
24451
24452
24453
24454
24455
24456
24457
24458
24459
24460
24461
24462
24463
24464
24465
24466
24467
24468
24469
24470
24471
24472
24473
24474
24475
24476
24477
24478
24479
24480
24481
24482
24483
24484
24485
24486
24487
24488
24489
24490
24491
24492
24493
24494
24495
24496
24497
24498
24499
24500
24501
24502
24503
24504
24505
24506
24507
24508
24509
24510
24511
24512
24513
24514
24515
24516
24517
24518
24519
24520
24521
24522
24523
24524
24525
24526
24527
24528
24529
24530
24531
24532
24533
24534
24535
24536
24537
24538
24539
24540
24541
24542
24543
24544
24545
24546
24547
24548
24549
24550
24551
24552
24553
24554
24555
24556
24557
24558
24559
24560
24561
24562
24563
24564
24565
24566
24567
24568
24569
24570
24571
24572
24573
24574
24575
24576
24577
24578
24579
24580
24581
24582
24583
24584
24585
24586
24587
24588
24589
24590
24591
24592
24593
24594
24595
24596
24597
24598
24599
24600
24601
24602
24603
24604
24605
24606
24607
24608
24609
24610
24611
24612
24613
24614
24615
24616
24617
24618
24619
24620
24621
24622
24623
24624
24625
24626
24627
24628
24629
24630
24631
24632
24633
24634
24635
24636
24637
24638
24639
24640
24641
24642
24643
24644
24645
24646
24647
24648
24649
24650
24651
24652
24653
24654
24655
24656
24657
24658
24659
24660
24661
24662
24663
24664
24665
24666
24667
24668
24669
24670
24671
24672
24673
24674
24675
24676
24677
24678
24679
24680
24681
24682
24683
24684
24685
24686
24687
24688
24689
24690
24691
24692
24693
24694
24695
24696
24697
24698
24699
24700
24701
24702
24703
24704
24705
24706
24707
24708
24709
24710
24711
24712
24713
24714
24715
24716
24717
24718
24719
24720
24721
24722
24723
24724
24725
24726
24727
24728
24729
24730
24731
24732
24733
24734
24735
24736
24737
24738
24739
24740
24741
24742
24743
24744
24745
24746
24747
24748
24749
24750
24751
24752
24753
24754
24755
24756
24757
24758
24759
24760
24761
24762
24763
24764
24765
24766
24767
24768
24769
24770
24771
24772
24773
24774
24775
24776
24777
24778
24779
24780
24781
24782
24783
24784
24785
24786
24787
24788
24789
24790
24791
24792
24793
24794
24795
24796
24797
24798
24799
24800
24801
24802
24803
24804
24805
24806
24807
24808
24809
24810
24811
24812
24813
24814
24815
24816
24817
24818
24819
24820
24821
24822
24823
24824
24825
24826
24827
24828
24829
24830
24831
24832
24833
24834
24835
24836
24837
24838
24839
24840
24841
24842
24843
24844
24845
24846
24847
24848
24849
24850
24851
24852
24853
24854
24855
24856
24857
24858
24859
24860
24861
24862
24863
24864
24865
24866
24867
24868
24869
24870
24871
24872
24873
24874
24875
24876
24877
24878
24879
24880
24881
24882
24883
24884
24885
24886
24887
24888
24889
24890
24891
24892
24893
24894
24895
24896
24897
24898
24899
24900
24901
24902
24903
24904
24905
24906
24907
24908
24909
24910
24911
24912
24913
24914
24915
24916
24917
24918
24919
24920
24921
24922
24923
24924
24925
24926
24927
24928
24929
24930
24931
24932
24933
24934
24935
24936
24937
24938
24939
24940
24941
24942
24943
24944
24945
24946
24947
24948
24949
24950
24951
24952
24953
24954
24955
24956
24957
24958
24959
24960
24961
24962
24963
24964
24965
24966
24967
24968
24969
24970
24971
24972
24973
24974
24975
24976
24977
24978
24979
24980
24981
24982
24983
24984
24985
24986
24987
24988
24989
24990
24991
24992
24993
24994
24995
24996
24997
24998
24999
25000
25001
25002
25003
25004
25005
25006
25007
25008
25009
25010
25011
25012
25013
25014
25015
25016
25017
25018
25019
25020
25021
25022
25023
25024
25025
25026
25027
25028
25029
25030
25031
25032
25033
25034
25035
25036
25037
25038
25039
25040
25041
25042
25043
25044
25045
25046
25047
25048
25049
25050
25051
25052
25053
25054
25055
25056
25057
25058
25059
25060
25061
25062
25063
25064
25065
25066
25067
25068
25069
25070
25071
25072
25073
25074
25075
25076
25077
25078
25079
25080
25081
25082
25083
25084
25085
25086
25087
25088
25089
25090
25091
25092
25093
25094
25095
25096
25097
25098
25099
25100
25101
25102
25103
25104
25105
25106
25107
25108
25109
25110
25111
25112
25113
25114
25115
25116
25117
25118
25119
25120
25121
25122
25123
25124
25125
25126
25127
25128
25129
25130
25131
25132
25133
25134
25135
25136
25137
25138
25139
25140
25141
25142
25143
25144
25145
25146
25147
25148
25149
25150
25151
25152
25153
25154
25155
25156
25157
25158
25159
25160
25161
25162
25163
25164
25165
25166
25167
25168
25169
25170
25171
25172
25173
25174
25175
25176
25177
25178
25179
25180
25181
25182
25183
25184
25185
25186
25187
25188
25189
25190
25191
25192
25193
25194
25195
25196
25197
25198
25199
25200
25201
25202
25203
25204
25205
25206
25207
25208
25209
25210
25211
25212
25213
25214
25215
25216
25217
25218
25219
25220
25221
25222
25223
25224
25225
25226
25227
25228
25229
25230
25231
25232
25233
25234
25235
25236
25237
25238
25239
25240
25241
25242
25243
25244
25245
25246
25247
25248
25249
25250
25251
25252
25253
25254
25255
25256
25257
25258
25259
25260
25261
25262
25263
25264
25265
25266
25267
25268
25269
25270
25271
25272
25273
25274
25275
25276
25277
25278
25279
25280
25281
25282
25283
25284
25285
25286
25287
25288
25289
25290
25291
25292
25293
25294
25295
25296
25297
25298
25299
25300
25301
25302
25303
25304
25305
25306
25307
25308
25309
25310
25311
25312
25313
25314
25315
25316
25317
25318
25319
25320
25321
25322
25323
25324
25325
25326
25327
25328
25329
25330
25331
25332
25333
25334
25335
25336
25337
25338
25339
25340
25341
25342
25343
25344
25345
25346
25347
25348
25349
25350
25351
25352
25353
25354
25355
25356
25357
25358
25359
25360
25361
25362
25363
25364
25365
25366
25367
25368
25369
25370
25371
25372
25373
25374
25375
25376
25377
25378
25379
25380
25381
25382
25383
25384
25385
25386
25387
25388
25389
25390
25391
25392
25393
25394
25395
25396
25397
25398
25399
25400
25401
25402
25403
25404
25405
25406
25407
25408
25409
25410
25411
25412
25413
25414
25415
25416
25417
25418
25419
25420
25421
25422
25423
25424
25425
25426
25427
25428
25429
25430
25431
25432
25433
25434
25435
25436
25437
25438
25439
25440
25441
25442
25443
25444
25445
25446
25447
25448
25449
25450
25451
25452
25453
25454
25455
25456
25457
25458
25459
25460
25461
25462
25463
25464
25465
25466
25467
25468
25469
25470
25471
25472
25473
25474
25475
25476
25477
25478
25479
25480
25481
25482
25483
25484
25485
25486
25487
25488
25489
25490
25491
25492
25493
25494
25495
25496
25497
25498
25499
25500
25501
25502
25503
25504
25505
25506
25507
25508
25509
25510
25511
25512
25513
25514
25515
25516
25517
25518
25519
25520
25521
25522
25523
25524
25525
25526
25527
25528
25529
25530
25531
25532
25533
25534
25535
25536
25537
25538
25539
25540
25541
25542
25543
25544
25545
25546
25547
25548
25549
25550
25551
25552
25553
25554
25555
25556
25557
25558
25559
25560
25561
25562
25563
25564
25565
25566
25567
25568
25569
25570
25571
25572
25573
25574
25575
25576
25577
25578
25579
25580
25581
25582
25583
25584
25585
25586
25587
25588
25589
25590
25591
25592
25593
25594
25595
25596
25597
25598
25599
25600
25601
25602
25603
25604
25605
25606
25607
25608
25609
25610
25611
25612
25613
25614
25615
25616
25617
25618
25619
25620
25621
25622
25623
25624
25625
25626
25627
25628
25629
25630
25631
25632
25633
25634
25635
25636
25637
25638
25639
25640
25641
25642
25643
25644
25645
25646
25647
25648
25649
25650
25651
25652
25653
25654
25655
25656
25657
25658
25659
25660
25661
25662
25663
25664
25665
25666
25667
25668
25669
25670
25671
25672
25673
25674
25675
25676
25677
25678
25679
25680
25681
25682
25683
25684
25685
25686
25687
25688
25689
25690
25691
25692
25693
25694
25695
25696
25697
25698
25699
25700
25701
25702
25703
25704
25705
25706
25707
25708
25709
25710
25711
25712
25713
25714
25715
25716
25717
25718
25719
25720
25721
25722
25723
25724
25725
25726
25727
25728
25729
25730
25731
25732
25733
25734
25735
25736
25737
25738
25739
25740
25741
25742
25743
25744
25745
25746
25747
25748
25749
25750
25751
25752
25753
25754
25755
25756
25757
25758
25759
25760
25761
25762
25763
25764
25765
25766
25767
25768
25769
25770
25771
25772
25773
25774
25775
25776
25777
25778
25779
25780
25781
25782
25783
25784
25785
25786
25787
25788
25789
25790
25791
25792
25793
25794
25795
25796
25797
25798
25799
25800
25801
25802
25803
25804
25805
25806
25807
25808
25809
25810
25811
25812
25813
25814
25815
25816
25817
25818
25819
25820
25821
25822
25823
25824
25825
25826
25827
25828
25829
25830
25831
25832
25833
25834
25835
25836
25837
25838
25839
25840
25841
25842
25843
25844
25845
25846
25847
25848
25849
25850
25851
25852
25853
25854
25855
25856
25857
25858
25859
25860
25861
25862
25863
25864
25865
25866
25867
25868
25869
25870
25871
25872
25873
25874
25875
25876
25877
25878
25879
25880
25881
25882
25883
25884
25885
25886
25887
25888
25889
25890
25891
25892
25893
25894
25895
25896
25897
25898
25899
25900
25901
25902
25903
25904
25905
25906
25907
25908
25909
25910
25911
25912
25913
25914
25915
25916
25917
25918
25919
25920
25921
25922
25923
25924
25925
25926
25927
25928
25929
25930
25931
25932
25933
25934
25935
25936
25937
25938
25939
25940
25941
25942
25943
25944
25945
25946
25947
25948
25949
25950
25951
25952
25953
25954
25955
25956
25957
25958
25959
25960
25961
25962
25963
25964
25965
25966
25967
25968
25969
25970
25971
25972
25973
25974
25975
25976
25977
25978
25979
25980
25981
25982
25983
25984
25985
25986
25987
25988
25989
25990
25991
25992
25993
25994
25995
25996
25997
25998
25999
26000
26001
26002
26003
26004
26005
26006
26007
26008
26009
26010
26011
26012
26013
26014
26015
26016
26017
26018
26019
26020
26021
26022
26023
26024
26025
26026
26027
26028
26029
26030
26031
26032
26033
26034
26035
26036
26037
26038
26039
26040
26041
26042
26043
26044
26045
26046
26047
26048
26049
26050
26051
26052
26053
26054
26055
26056
26057
26058
26059
26060
26061
26062
26063
26064
26065
26066
26067
26068
26069
26070
26071
26072
26073
26074
26075
26076
26077
26078
26079
26080
26081
26082
26083
26084
26085
26086
26087
26088
26089
26090
26091
26092
26093
26094
26095
26096
26097
26098
26099
26100
26101
26102
26103
26104
26105
26106
26107
26108
26109
26110
26111
26112
26113
26114
26115
26116
26117
26118
26119
26120
26121
26122
26123
26124
26125
26126
26127
26128
26129
26130
26131
26132
26133
26134
26135
26136
26137
26138
26139
26140
26141
26142
26143
26144
26145
26146
26147
26148
26149
26150
26151
26152
26153
26154
26155
26156
26157
26158
26159
26160
26161
26162
26163
26164
26165
26166
26167
26168
26169
26170
26171
26172
26173
26174
26175
26176
26177
26178
26179
26180
26181
26182
26183
26184
26185
26186
26187
26188
26189
26190
26191
26192
26193
26194
26195
26196
26197
26198
26199
26200
26201
26202
26203
26204
26205
26206
26207
26208
26209
26210
26211
26212
26213
26214
26215
26216
26217
26218
26219
26220
26221
26222
26223
26224
26225
26226
26227
26228
26229
26230
26231
26232
26233
26234
26235
26236
26237
26238
26239
26240
26241
26242
26243
26244
26245
26246
26247
26248
26249
26250
26251
26252
26253
26254
26255
26256
26257
26258
26259
26260
26261
26262
26263
26264
26265
26266
26267
26268
26269
26270
26271
26272
26273
26274
26275
26276
26277
26278
26279
26280
26281
26282
26283
26284
26285
26286
26287
26288
26289
26290
26291
26292
26293
26294
26295
26296
26297
26298
26299
26300
26301
26302
26303
26304
26305
26306
26307
26308
26309
26310
26311
26312
26313
26314
26315
26316
26317
26318
26319
26320
26321
26322
26323
26324
26325
26326
26327
26328
26329
26330
26331
26332
26333
26334
26335
26336
26337
26338
26339
26340
26341
26342
26343
26344
26345
26346
26347
26348
26349
26350
26351
26352
26353
26354
26355
26356
26357
26358
26359
26360
26361
26362
26363
26364
26365
26366
26367
26368
26369
26370
26371
26372
26373
26374
26375
26376
26377
26378
26379
26380
26381
26382
26383
26384
26385
26386
26387
26388
26389
26390
26391
26392
26393
26394
26395
26396
26397
26398
26399
26400
26401
26402
26403
26404
26405
26406
26407
26408
26409
26410
26411
26412
26413
26414
26415
26416
26417
26418
26419
26420
26421
26422
26423
26424
26425
26426
26427
26428
26429
26430
26431
26432
26433
26434
26435
26436
26437
26438
26439
26440
26441
26442
26443
26444
26445
26446
26447
26448
26449
26450
26451
26452
26453
26454
26455
26456
26457
26458
26459
26460
26461
26462
26463
26464
26465
26466
26467
26468
26469
26470
26471
26472
26473
26474
26475
26476
26477
26478
26479
26480
26481
26482
26483
26484
26485
26486
26487
26488
26489
26490
26491
26492
26493
26494
26495
26496
26497
26498
26499
26500
26501
26502
26503
26504
26505
26506
26507
26508
26509
26510
26511
26512
26513
26514
26515
26516
26517
26518
26519
26520
26521
26522
26523
26524
26525
26526
26527
26528
26529
26530
26531
26532
26533
26534
26535
26536
26537
26538
26539
26540
26541
26542
26543
26544
26545
26546
26547
26548
26549
26550
26551
26552
26553
26554
26555
26556
26557
26558
26559
26560
26561
26562
26563
26564
26565
26566
26567
26568
26569
26570
26571
26572
26573
26574
26575
26576
26577
26578
26579
26580
26581
26582
26583
26584
26585
26586
26587
26588
26589
26590
26591
26592
26593
26594
26595
26596
26597
26598
26599
26600
26601
26602
26603
26604
26605
26606
26607
26608
26609
26610
26611
26612
26613
26614
26615
26616
26617
26618
26619
26620
26621
26622
26623
26624
26625
26626
26627
26628
26629
26630
26631
26632
26633
26634
26635
26636
26637
26638
26639
26640
26641
26642
26643
26644
26645
26646
26647
26648
26649
26650
26651
26652
26653
26654
26655
26656
26657
26658
26659
26660
26661
26662
26663
26664
26665
26666
26667
26668
26669
26670
26671
26672
26673
26674
26675
26676
26677
26678
26679
26680
26681
26682
26683
26684
26685
26686
26687
26688
26689
26690
26691
26692
26693
26694
26695
26696
26697
26698
26699
26700
26701
26702
26703
26704
26705
26706
26707
26708
26709
26710
26711
26712
26713
26714
26715
26716
26717
26718
26719
26720
26721
26722
26723
26724
26725
26726
26727
26728
26729
26730
26731
26732
26733
26734
26735
26736
26737
26738
26739
26740
26741
26742
26743
26744
26745
26746
26747
26748
26749
26750
26751
26752
26753
26754
26755
26756
26757
26758
26759
26760
26761
26762
26763
26764
26765
26766
26767
26768
26769
26770
26771
26772
26773
26774
26775
26776
26777
26778
26779
26780
26781
26782
26783
26784
26785
26786
26787
26788
26789
26790
26791
26792
26793
26794
26795
26796
26797
26798
26799
26800
26801
26802
26803
26804
26805
26806
26807
26808
26809
26810
26811
26812
26813
26814
26815
26816
26817
26818
26819
26820
26821
26822
26823
26824
26825
26826
26827
26828
26829
26830
26831
26832
26833
26834
26835
26836
26837
26838
26839
26840
26841
26842
26843
26844
26845
26846
26847
26848
26849
26850
26851
26852
26853
26854
26855
26856
26857
26858
26859
26860
26861
26862
26863
26864
26865
26866
26867
26868
26869
26870
26871
26872
26873
26874
26875
26876
26877
26878
26879
26880
26881
26882
26883
26884
26885
26886
26887
26888
26889
26890
26891
26892
26893
26894
26895
26896
26897
26898
26899
26900
26901
26902
26903
26904
26905
26906
26907
26908
26909
26910
26911
26912
26913
26914
26915
26916
26917
26918
26919
26920
26921
26922
26923
26924
26925
26926
26927
26928
26929
26930
26931
26932
26933
26934
26935
26936
26937
26938
26939
26940
26941
26942
26943
26944
26945
26946
26947
26948
26949
26950
26951
26952
26953
26954
26955
26956
26957
26958
26959
26960
26961
26962
26963
26964
26965
26966
26967
26968
26969
26970
26971
26972
26973
26974
26975
26976
26977
26978
26979
26980
26981
26982
26983
26984
26985
26986
26987
26988
26989
26990
26991
26992
26993
26994
26995
26996
26997
26998
26999
27000
27001
27002
27003
27004
27005
27006
27007
27008
27009
27010
27011
27012
27013
27014
27015
27016
27017
27018
27019
27020
27021
27022
27023
27024
27025
27026
27027
27028
27029
27030
27031
27032
27033
27034
27035
27036
27037
27038
27039
27040
27041
27042
27043
27044
27045
27046
27047
27048
27049
27050
27051
27052
27053
27054
27055
27056
27057
27058
27059
27060
27061
27062
27063
27064
27065
27066
27067
27068
27069
27070
27071
27072
27073
27074
27075
27076
27077
27078
27079
27080
27081
27082
27083
27084
27085
27086
27087
27088
27089
27090
27091
27092
27093
27094
27095
27096
27097
27098
27099
27100
27101
27102
27103
27104
27105
27106
27107
27108
27109
27110
27111
27112
27113
27114
27115
27116
27117
27118
27119
27120
27121
27122
27123
27124
27125
27126
27127
27128
27129
27130
27131
27132
27133
27134
27135
27136
27137
27138
27139
27140
27141
27142
27143
27144
27145
27146
27147
27148
27149
27150
27151
27152
27153
27154
27155
27156
27157
27158
27159
27160
27161
27162
27163
27164
27165
27166
27167
27168
27169
27170
27171
27172
27173
27174
27175
27176
27177
27178
27179
27180
27181
27182
27183
27184
27185
27186
27187
27188
27189
27190
27191
27192
27193
27194
27195
27196
27197
27198
27199
27200
27201
27202
27203
27204
27205
27206
27207
27208
27209
27210
27211
27212
27213
27214
27215
27216
27217
27218
27219
27220
27221
27222
27223
27224
27225
27226
27227
27228
27229
27230
27231
27232
27233
27234
27235
27236
27237
27238
27239
27240
27241
27242
27243
27244
27245
27246
27247
27248
27249
27250
27251
27252
27253
27254
27255
27256
27257
27258
27259
27260
27261
27262
27263
27264
27265
27266
27267
27268
27269
27270
27271
27272
27273
27274
27275
27276
27277
27278
27279
27280
27281
27282
27283
27284
27285
27286
27287
27288
27289
27290
27291
27292
27293
27294
27295
27296
27297
27298
27299
27300
27301
27302
27303
27304
27305
27306
27307
27308
27309
27310
27311
27312
27313
27314
27315
27316
27317
27318
27319
27320
27321
27322
27323
27324
27325
27326
27327
27328
27329
27330
27331
27332
27333
27334
27335
27336
27337
27338
27339
27340
27341
27342
27343
27344
27345
27346
27347
27348
27349
27350
27351
27352
27353
27354
27355
27356
27357
27358
27359
27360
27361
27362
27363
27364
27365
27366
27367
27368
27369
27370
27371
27372
27373
27374
27375
27376
27377
27378
27379
27380
27381
27382
27383
27384
27385
27386
27387
27388
27389
27390
27391
27392
27393
27394
27395
27396
27397
27398
27399
27400
27401
27402
27403
27404
27405
27406
27407
27408
27409
27410
27411
27412
27413
27414
27415
27416
27417
27418
27419
27420
27421
27422
27423
27424
27425
27426
27427
27428
27429
27430
27431
27432
27433
27434
27435
27436
27437
27438
27439
27440
27441
27442
27443
27444
27445
27446
27447
27448
27449
27450
27451
27452
27453
27454
27455
27456
27457
27458
27459
27460
27461
27462
27463
27464
27465
27466
27467
27468
27469
27470
27471
27472
27473
27474
27475
27476
27477
27478
27479
27480
27481
27482
27483
27484
27485
27486
27487
27488
27489
27490
27491
27492
27493
27494
27495
27496
27497
27498
27499
27500
27501
27502
27503
27504
27505
27506
27507
27508
27509
27510
27511
27512
27513
27514
27515
27516
27517
27518
27519
27520
27521
27522
27523
27524
27525
27526
27527
27528
27529
27530
27531
27532
27533
27534
27535
27536
27537
27538
27539
27540
27541
27542
27543
27544
27545
27546
27547
27548
27549
27550
27551
27552
27553
27554
27555
27556
27557
27558
27559
27560
27561
27562
27563
27564
27565
27566
27567
27568
27569
27570
27571
27572
27573
27574
27575
27576
27577
27578
27579
27580
27581
27582
27583
27584
27585
27586
27587
27588
27589
27590
27591
27592
27593
27594
27595
27596
27597
27598
27599
27600
27601
27602
27603
27604
27605
27606
27607
27608
27609
27610
27611
27612
27613
27614
27615
27616
27617
27618
27619
27620
27621
27622
27623
27624
27625
27626
27627
27628
27629
27630
27631
27632
27633
27634
27635
27636
27637
27638
27639
27640
27641
27642
27643
27644
27645
27646
27647
27648
27649
27650
27651
27652
27653
27654
27655
27656
27657
27658
27659
27660
27661
27662
27663
27664
27665
27666
27667
27668
27669
27670
27671
27672
27673
27674
27675
27676
27677
27678
27679
27680
27681
27682
27683
27684
27685
27686
27687
27688
27689
27690
27691
27692
27693
27694
27695
27696
27697
27698
27699
27700
27701
27702
27703
27704
27705
27706
27707
27708
27709
27710
27711
27712
27713
27714
27715
27716
27717
27718
27719
27720
27721
27722
27723
27724
27725
27726
27727
27728
27729
27730
27731
27732
27733
27734
27735
27736
27737
27738
27739
27740
27741
27742
27743
27744
27745
27746
27747
27748
27749
27750
27751
27752
27753
27754
27755
27756
27757
27758
27759
27760
27761
27762
27763
27764
27765
27766
27767
27768
27769
27770
27771
27772
27773
27774
27775
27776
27777
27778
27779
27780
27781
27782
27783
27784
27785
27786
27787
27788
27789
27790
27791
27792
27793
27794
27795
27796
27797
27798
27799
27800
27801
27802
27803
27804
27805
27806
27807
27808
27809
27810
27811
27812
27813
27814
27815
27816
27817
27818
27819
27820
27821
27822
27823
27824
27825
27826
27827
27828
27829
27830
27831
27832
27833
27834
27835
27836
27837
27838
27839
27840
27841
27842
27843
27844
27845
27846
27847
27848
27849
27850
27851
27852
27853
27854
27855
27856
27857
27858
27859
27860
27861
27862
27863
27864
27865
27866
27867
27868
27869
27870
27871
27872
27873
27874
27875
27876
27877
27878
27879
27880
27881
27882
27883
27884
27885
27886
27887
27888
27889
27890
27891
27892
27893
27894
27895
27896
27897
27898
27899
27900
27901
27902
27903
27904
27905
27906
27907
27908
27909
27910
27911
27912
27913
27914
27915
27916
27917
27918
27919
27920
27921
27922
27923
27924
27925
27926
27927
27928
27929
27930
27931
27932
27933
27934
27935
27936
27937
27938
27939
27940
27941
27942
27943
27944
27945
27946
27947
27948
27949
27950
27951
27952
27953
27954
27955
27956
27957
27958
27959
27960
27961
27962
27963
27964
27965
27966
27967
27968
27969
27970
27971
27972
27973
27974
27975
27976
27977
27978
27979
27980
27981
27982
27983
27984
27985
27986
27987
27988
27989
27990
27991
27992
27993
27994
27995
27996
27997
27998
27999
28000
28001
28002
28003
28004
28005
28006
28007
28008
28009
28010
28011
28012
28013
28014
28015
28016
28017
28018
28019
28020
28021
28022
28023
28024
28025
28026
28027
28028
28029
28030
28031
28032
28033
28034
28035
28036
28037
28038
28039
28040
28041
28042
28043
28044
28045
28046
28047
28048
28049
28050
28051
28052
28053
28054
28055
28056
28057
28058
28059
28060
28061
28062
28063
28064
28065
28066
28067
28068
28069
28070
28071
28072
28073
28074
28075
28076
28077
28078
28079
28080
28081
28082
28083
28084
28085
28086
28087
28088
28089
28090
28091
28092
28093
28094
28095
28096
28097
28098
28099
28100
28101
28102
28103
28104
28105
28106
28107
28108
28109
28110
28111
28112
28113
28114
28115
28116
28117
28118
28119
28120
28121
28122
28123
28124
28125
28126
28127
28128
28129
28130
28131
28132
28133
28134
28135
28136
28137
28138
28139
28140
28141
28142
28143
28144
28145
28146
28147
28148
28149
28150
28151
28152
28153
28154
28155
28156
28157
28158
28159
28160
28161
28162
28163
28164
28165
28166
28167
28168
28169
28170
28171
28172
28173
28174
28175
28176
28177
28178
28179
28180
28181
28182
28183
28184
28185
28186
28187
28188
28189
28190
28191
28192
28193
28194
28195
28196
28197
28198
28199
28200
28201
28202
28203
28204
28205
28206
28207
28208
28209
28210
28211
28212
28213
28214
28215
28216
28217
28218
28219
28220
28221
28222
28223
28224
28225
28226
28227
28228
28229
28230
28231
28232
28233
28234
28235
28236
28237
28238
28239
28240
28241
28242
28243
28244
28245
28246
28247
28248
28249
28250
28251
28252
28253
28254
28255
28256
28257
28258
28259
28260
28261
28262
28263
28264
28265
28266
28267
28268
28269
28270
28271
28272
28273
28274
28275
28276
28277
28278
28279
28280
28281
28282
28283
28284
28285
28286
28287
28288
28289
28290
28291
28292
28293
28294
28295
28296
28297
28298
28299
28300
28301
28302
28303
28304
28305
28306
28307
28308
28309
28310
28311
28312
28313
28314
28315
28316
28317
28318
28319
28320
28321
28322
28323
28324
28325
28326
28327
28328
28329
28330
28331
28332
28333
28334
28335
28336
28337
28338
28339
28340
28341
28342
28343
28344
28345
28346
28347
28348
28349
28350
28351
28352
28353
28354
28355
28356
28357
28358
28359
28360
28361
28362
28363
28364
28365
28366
28367
28368
28369
28370
28371
28372
28373
28374
28375
28376
28377
28378
28379
28380
28381
28382
28383
28384
28385
28386
28387
28388
28389
28390
28391
28392
28393
28394
28395
28396
28397
28398
28399
28400
28401
28402
28403
28404
28405
28406
28407
28408
28409
28410
28411
28412
28413
28414
28415
28416
28417
28418
28419
28420
28421
28422
28423
28424
28425
28426
28427
28428
28429
28430
28431
28432
28433
28434
28435
28436
28437
28438
28439
28440
28441
28442
28443
28444
28445
28446
28447
28448
28449
28450
28451
28452
28453
28454
28455
28456
28457
28458
28459
28460
28461
28462
28463
28464
28465
28466
28467
28468
28469
28470
28471
28472
28473
28474
28475
28476
28477
28478
28479
28480
28481
28482
28483
28484
28485
28486
28487
28488
28489
28490
28491
28492
28493
28494
28495
28496
28497
28498
28499
28500
28501
28502
28503
28504
28505
28506
28507
28508
28509
28510
28511
28512
28513
28514
28515
28516
28517
28518
28519
28520
28521
28522
28523
28524
28525
28526
28527
28528
28529
28530
28531
28532
28533
28534
28535
28536
28537
28538
28539
28540
28541
28542
28543
28544
28545
28546
28547
28548
28549
28550
28551
28552
28553
28554
28555
28556
28557
28558
28559
28560
28561
28562
28563
28564
28565
28566
28567
28568
28569
28570
28571
28572
28573
28574
28575
28576
28577
28578
28579
28580
28581
28582
28583
28584
28585
28586
28587
28588
28589
28590
28591
28592
28593
28594
28595
28596
28597
28598
28599
28600
28601
28602
28603
28604
28605
28606
28607
28608
28609
28610
28611
28612
28613
28614
28615
28616
28617
28618
28619
28620
28621
28622
28623
28624
28625
28626
28627
28628
28629
28630
28631
28632
28633
28634
28635
28636
28637
28638
28639
28640
28641
28642
28643
28644
28645
28646
28647
28648
28649
28650
28651
28652
28653
28654
28655
28656
28657
28658
28659
28660
28661
28662
28663
28664
28665
28666
28667
28668
28669
28670
28671
28672
28673
28674
28675
28676
28677
28678
28679
28680
28681
28682
28683
28684
28685
28686
28687
28688
28689
28690
28691
28692
28693
28694
28695
28696
28697
28698
28699
28700
28701
28702
28703
28704
28705
28706
28707
28708
28709
28710
28711
28712
28713
28714
28715
28716
28717
28718
28719
28720
28721
28722
28723
28724
28725
28726
28727
28728
28729
28730
28731
28732
28733
28734
28735
28736
28737
28738
28739
28740
28741
28742
28743
28744
28745
28746
28747
28748
28749
28750
28751
28752
28753
28754
28755
28756
28757
28758
28759
28760
28761
28762
28763
28764
28765
28766
28767
28768
28769
28770
28771
28772
28773
28774
28775
28776
28777
28778
28779
28780
28781
28782
28783
28784
28785
28786
28787
28788
28789
28790
28791
28792
28793
28794
28795
28796
28797
28798
28799
28800
28801
28802
28803
28804
28805
28806
28807
28808
28809
28810
28811
28812
28813
28814
28815
28816
28817
28818
28819
28820
28821
28822
28823
28824
28825
28826
28827
28828
28829
28830
28831
28832
28833
28834
28835
28836
28837
28838
28839
28840
28841
28842
28843
28844
28845
28846
28847
28848
28849
28850
28851
28852
28853
28854
28855
28856
28857
28858
28859
28860
28861
28862
28863
28864
28865
28866
28867
28868
28869
28870
28871
28872
28873
28874
28875
28876
28877
28878
28879
28880
28881
28882
28883
28884
28885
28886
28887
28888
28889
28890
28891
28892
28893
28894
28895
28896
28897
28898
28899
28900
28901
28902
28903
28904
28905
28906
28907
28908
28909
28910
28911
28912
28913
28914
28915
28916
28917
28918
28919
28920
28921
28922
28923
28924
28925
28926
28927
28928
28929
28930
28931
28932
28933
28934
28935
28936
28937
28938
28939
28940
28941
28942
28943
28944
28945
28946
28947
28948
28949
28950
28951
28952
28953
28954
28955
28956
28957
28958
28959
28960
28961
28962
28963
28964
28965
28966
28967
28968
28969
28970
28971
28972
28973
28974
28975
28976
28977
28978
28979
28980
28981
28982
28983
28984
28985
28986
28987
28988
28989
28990
28991
28992
28993
28994
28995
28996
28997
28998
28999
29000
29001
29002
29003
29004
29005
29006
29007
29008
29009
29010
29011
29012
29013
29014
29015
29016
29017
29018
29019
29020
29021
29022
29023
29024
29025
29026
29027
29028
29029
29030
29031
29032
29033
29034
29035
29036
29037
29038
29039
29040
29041
29042
29043
29044
29045
29046
29047
29048
29049
29050
29051
29052
29053
29054
29055
29056
29057
29058
29059
29060
29061
29062
29063
29064
29065
29066
29067
29068
29069
29070
29071
29072
29073
29074
29075
29076
29077
29078
29079
29080
29081
29082
29083
29084
29085
29086
29087
29088
29089
29090
29091
29092
29093
29094
29095
29096
29097
29098
29099
29100
29101
29102
29103
29104
29105
29106
29107
29108
29109
29110
29111
29112
29113
29114
29115
29116
29117
29118
29119
29120
29121
29122
29123
29124
29125
29126
29127
29128
29129
29130
29131
29132
29133
29134
29135
29136
29137
29138
29139
29140
29141
29142
29143
29144
29145
29146
29147
29148
29149
29150
29151
29152
29153
29154
29155
29156
29157
29158
29159
29160
29161
29162
29163
29164
29165
29166
29167
29168
29169
29170
29171
29172
29173
29174
29175
29176
29177
29178
29179
29180
29181
29182
29183
29184
29185
29186
29187
29188
29189
29190
29191
29192
29193
29194
29195
29196
29197
29198
29199
29200
29201
29202
29203
29204
29205
29206
29207
29208
29209
29210
29211
29212
29213
29214
29215
29216
29217
29218
29219
29220
29221
29222
29223
29224
29225
29226
29227
29228
29229
29230
29231
29232
29233
29234
29235
29236
29237
29238
29239
29240
29241
29242
29243
29244
29245
29246
29247
29248
29249
29250
29251
29252
29253
29254
29255
29256
29257
29258
29259
29260
29261
29262
29263
29264
29265
29266
29267
29268
29269
29270
29271
29272
29273
29274
29275
29276
29277
29278
29279
29280
29281
29282
29283
29284
29285
29286
29287
29288
29289
29290
29291
29292
29293
29294
29295
29296
29297
29298
29299
29300
29301
29302
29303
29304
29305
29306
29307
29308
29309
29310
29311
29312
29313
29314
29315
29316
29317
29318
29319
29320
29321
29322
29323
29324
29325
29326
29327
29328
29329
29330
29331
29332
29333
29334
29335
29336
29337
29338
29339
29340
29341
29342
29343
29344
29345
29346
29347
29348
29349
29350
29351
29352
29353
29354
29355
29356
29357
29358
29359
29360
29361
29362
29363
29364
29365
29366
29367
29368
29369
29370
29371
29372
29373
29374
29375
29376
29377
29378
29379
29380
29381
29382
29383
29384
29385
29386
29387
29388
29389
29390
29391
29392
29393
29394
29395
29396
29397
29398
29399
29400
29401
29402
29403
29404
29405
29406
29407
29408
29409
29410
29411
29412
29413
29414
29415
29416
29417
29418
29419
29420
29421
29422
29423
29424
29425
29426
29427
29428
29429
29430
29431
29432
29433
29434
29435
29436
29437
29438
29439
29440
29441
29442
29443
29444
29445
29446
29447
29448
29449
29450
29451
29452
29453
29454
29455
29456
29457
29458
29459
29460
29461
29462
29463
29464
29465
29466
29467
29468
29469
29470
29471
29472
29473
29474
29475
29476
29477
29478
29479
29480
29481
29482
29483
29484
29485
29486
29487
29488
29489
29490
29491
29492
29493
29494
29495
29496
29497
29498
29499
29500
29501
29502
29503
29504
29505
29506
29507
29508
29509
29510
29511
29512
29513
29514
29515
29516
29517
29518
29519
29520
29521
29522
29523
29524
29525
29526
29527
29528
29529
29530
29531
29532
29533
29534
29535
29536
29537
29538
29539
29540
29541
29542
29543
29544
29545
29546
29547
29548
29549
29550
29551
29552
29553
29554
29555
29556
29557
29558
29559
29560
29561
29562
29563
29564
29565
29566
29567
29568
29569
29570
29571
29572
29573
29574
29575
29576
29577
29578
29579
29580
29581
29582
29583
29584
29585
29586
29587
29588
29589
29590
29591
29592
29593
29594
29595
29596
29597
29598
29599
29600
29601
29602
29603
29604
29605
29606
29607
29608
29609
29610
29611
29612
29613
29614
29615
29616
29617
29618
29619
29620
29621
29622
29623
29624
29625
29626
29627
29628
29629
29630
29631
29632
29633
29634
29635
29636
29637
29638
29639
29640
29641
29642
29643
29644
29645
29646
29647
29648
29649
29650
29651
29652
29653
29654
29655
29656
29657
29658
29659
29660
29661
29662
29663
29664
29665
29666
29667
29668
29669
29670
29671
29672
29673
29674
29675
29676
29677
29678
29679
29680
29681
29682
29683
29684
29685
29686
29687
29688
29689
29690
29691
29692
29693
29694
29695
29696
29697
29698
29699
29700
29701
29702
29703
29704
29705
29706
29707
29708
29709
29710
29711
29712
29713
29714
29715
29716
29717
29718
29719
29720
29721
29722
29723
29724
29725
29726
29727
29728
29729
29730
29731
29732
29733
29734
29735
29736
29737
29738
29739
29740
29741
29742
29743
29744
29745
29746
29747
29748
29749
29750
29751
29752
29753
29754
29755
29756
29757
29758
29759
29760
29761
29762
29763
29764
29765
29766
29767
29768
29769
29770
29771
29772
29773
29774
29775
29776
29777
29778
29779
29780
29781
29782
29783
29784
29785
29786
29787
29788
29789
29790
29791
29792
29793
29794
29795
29796
29797
29798
29799
29800
29801
29802
29803
29804
29805
29806
29807
29808
29809
29810
29811
29812
29813
29814
29815
29816
29817
29818
29819
29820
29821
29822
29823
29824
29825
29826
29827
29828
29829
29830
29831
29832
29833
29834
29835
29836
29837
29838
29839
29840
29841
29842
29843
29844
29845
29846
29847
29848
29849
29850
29851
29852
29853
29854
29855
29856
29857
29858
29859
29860
29861
29862
29863
29864
29865
29866
29867
29868
29869
29870
29871
29872
29873
29874
29875
29876
29877
29878
29879
29880
29881
29882
29883
29884
29885
29886
29887
29888
29889
29890
29891
29892
29893
29894
29895
29896
29897
29898
29899
29900
29901
29902
29903
29904
29905
29906
29907
29908
29909
29910
29911
29912
29913
29914
29915
29916
29917
29918
29919
29920
29921
29922
29923
29924
29925
29926
29927
29928
29929
29930
29931
29932
29933
29934
29935
29936
29937
29938
29939
29940
29941
29942
29943
29944
29945
29946
29947
29948
29949
29950
29951
29952
29953
29954
29955
29956
29957
29958
29959
29960
29961
29962
29963
29964
29965
29966
29967
29968
29969
29970
29971
29972
29973
29974
29975
29976
29977
29978
29979
29980
29981
29982
29983
29984
29985
29986
29987
29988
29989
29990
29991
29992
29993
29994
29995
29996
29997
29998
29999
30000
30001
30002
30003
30004
30005
30006
30007
30008
30009
30010
30011
30012
30013
30014
30015
30016
30017
30018
30019
30020
30021
30022
30023
30024
30025
30026
30027
30028
30029
30030
30031
30032
30033
30034
30035
30036
30037
30038
30039
30040
30041
30042
30043
30044
30045
30046
30047
30048
30049
30050
30051
30052
30053
30054
30055
30056
30057
30058
30059
30060
30061
30062
30063
30064
30065
30066
30067
30068
30069
30070
30071
30072
30073
30074
30075
30076
30077
30078
30079
30080
30081
30082
30083
30084
30085
30086
30087
30088
30089
30090
30091
30092
30093
30094
30095
30096
30097
30098
30099
30100
30101
30102
30103
30104
30105
30106
30107
30108
30109
30110
30111
30112
30113
30114
30115
30116
30117
30118
30119
30120
30121
30122
30123
30124
30125
30126
30127
30128
30129
30130
30131
30132
30133
30134
30135
30136
30137
30138
30139
30140
30141
30142
30143
30144
30145
30146
30147
30148
30149
30150
30151
30152
30153
30154
30155
30156
30157
30158
30159
30160
30161
30162
30163
30164
30165
30166
30167
30168
30169
30170
30171
30172
30173
30174
30175
30176
30177
30178
30179
30180
30181
30182
30183
30184
30185
30186
30187
30188
30189
30190
30191
30192
30193
30194
30195
30196
30197
30198
30199
30200
30201
30202
30203
30204
30205
30206
30207
30208
30209
30210
30211
30212
30213
30214
30215
30216
30217
30218
30219
30220
30221
30222
30223
30224
30225
30226
30227
30228
30229
30230
30231
30232
30233
30234
30235
30236
30237
30238
30239
30240
30241
30242
30243
30244
30245
30246
30247
30248
30249
30250
30251
30252
30253
30254
30255
30256
30257
30258
30259
30260
30261
30262
30263
30264
30265
30266
30267
30268
30269
30270
30271
30272
30273
30274
30275
30276
30277
30278
30279
30280
30281
30282
30283
30284
30285
30286
30287
30288
30289
30290
30291
30292
30293
30294
30295
30296
30297
30298
30299
30300
30301
30302
30303
30304
30305
30306
30307
30308
30309
30310
30311
30312
30313
30314
30315
30316
30317
30318
30319
30320
30321
30322
30323
30324
30325
30326
30327
30328
30329
30330
30331
30332
30333
30334
30335
30336
30337
30338
30339
30340
30341
30342
30343
30344
30345
30346
30347
30348
30349
30350
30351
30352
30353
30354
30355
30356
30357
30358
30359
30360
30361
30362
30363
30364
30365
30366
30367
30368
30369
30370
30371
30372
30373
30374
30375
30376
30377
30378
30379
30380
30381
30382
30383
30384
30385
30386
30387
30388
30389
30390
30391
30392
30393
30394
30395
30396
30397
30398
30399
30400
30401
30402
30403
30404
30405
30406
30407
30408
30409
30410
30411
30412
30413
30414
30415
30416
30417
30418
30419
30420
30421
30422
30423
30424
30425
30426
30427
30428
30429
30430
30431
30432
30433
30434
30435
30436
30437
30438
30439
30440
30441
30442
30443
30444
30445
30446
30447
30448
30449
30450
30451
30452
30453
30454
30455
30456
30457
30458
30459
30460
30461
30462
30463
30464
30465
30466
30467
30468
30469
30470
30471
30472
30473
30474
30475
30476
30477
30478
30479
30480
30481
30482
30483
30484
30485
30486
30487
30488
30489
30490
30491
30492
30493
30494
30495
30496
30497
30498
30499
30500
30501
30502
30503
30504
30505
30506
30507
30508
30509
30510
30511
30512
30513
30514
30515
30516
30517
30518
30519
30520
30521
30522
30523
30524
30525
30526
30527
30528
30529
30530
30531
30532
30533
30534
30535
30536
30537
30538
30539
30540
30541
30542
30543
30544
30545
30546
30547
30548
30549
30550
30551
30552
30553
30554
30555
30556
30557
30558
30559
30560
30561
30562
30563
30564
30565
30566
30567
30568
30569
30570
30571
30572
30573
30574
30575
30576
30577
30578
30579
30580
30581
30582
30583
30584
30585
30586
30587
30588
30589
30590
30591
30592
30593
30594
30595
30596
30597
30598
30599
30600
30601
30602
30603
30604
30605
30606
30607
30608
30609
30610
30611
30612
30613
30614
30615
30616
30617
30618
30619
30620
30621
30622
30623
30624
30625
30626
30627
30628
30629
30630
30631
30632
30633
30634
30635
30636
30637
30638
30639
30640
30641
30642
30643
30644
30645
30646
30647
30648
30649
30650
30651
30652
30653
30654
30655
30656
30657
30658
30659
30660
30661
30662
30663
30664
30665
30666
30667
30668
30669
30670
30671
30672
30673
30674
30675
30676
30677
30678
30679
30680
30681
30682
30683
30684
30685
30686
30687
30688
30689
30690
30691
30692
30693
30694
30695
30696
30697
30698
30699
30700
30701
30702
30703
30704
30705
30706
30707
30708
30709
30710
30711
30712
30713
30714
30715
30716
30717
30718
30719
30720
30721
30722
30723
30724
30725
30726
30727
30728
30729
30730
30731
30732
30733
30734
30735
30736
30737
30738
30739
30740
30741
30742
30743
30744
30745
30746
30747
30748
30749
30750
30751
30752
30753
30754
30755
30756
30757
30758
30759
30760
30761
30762
30763
30764
30765
30766
30767
30768
30769
30770
30771
30772
30773
30774
30775
30776
30777
30778
30779
30780
30781
30782
30783
30784
30785
30786
30787
30788
30789
30790
30791
30792
30793
30794
30795
30796
30797
30798
30799
30800
30801
30802
30803
30804
30805
30806
30807
30808
30809
30810
30811
30812
30813
30814
30815
30816
30817
30818
30819
30820
30821
30822
30823
30824
30825
30826
30827
30828
30829
30830
30831
30832
30833
30834
30835
30836
30837
30838
30839
30840
30841
30842
30843
30844
30845
30846
30847
30848
30849
30850
30851
30852
30853
30854
30855
30856
30857
30858
30859
30860
30861
30862
30863
30864
30865
30866
30867
30868
30869
30870
30871
30872
30873
30874
30875
30876
30877
30878
30879
30880
30881
30882
30883
30884
30885
30886
30887
30888
30889
30890
30891
30892
30893
30894
30895
30896
30897
30898
30899
30900
30901
30902
30903
30904
30905
30906
30907
30908
30909
30910
30911
30912
30913
30914
30915
30916
30917
30918
30919
30920
30921
30922
30923
30924
30925
30926
30927
30928
30929
30930
30931
30932
30933
30934
30935
30936
30937
30938
30939
30940
30941
30942
30943
30944
30945
30946
30947
30948
30949
30950
30951
30952
30953
30954
30955
30956
30957
30958
30959
30960
30961
30962
30963
30964
30965
30966
30967
30968
30969
30970
30971
30972
30973
30974
30975
30976
30977
30978
30979
30980
30981
30982
30983
30984
30985
30986
30987
30988
30989
30990
30991
30992
30993
30994
30995
30996
30997
30998
30999
31000
31001
31002
31003
31004
31005
31006
31007
31008
31009
31010
31011
31012
31013
31014
31015
31016
31017
31018
31019
31020
31021
31022
31023
31024
31025
31026
31027
31028
31029
31030
31031
31032
31033
31034
31035
31036
31037
31038
31039
31040
31041
31042
31043
31044
31045
31046
31047
31048
31049
31050
31051
31052
31053
31054
31055
31056
31057
31058
31059
31060
31061
31062
31063
31064
31065
31066
31067
31068
31069
31070
31071
31072
31073
31074
31075
31076
31077
31078
31079
31080
31081
31082
31083
31084
31085
31086
31087
31088
31089
31090
31091
31092
31093
31094
31095
31096
31097
31098
31099
31100
31101
31102
31103
31104
31105
31106
31107
31108
31109
31110
31111
31112
31113
31114
31115
31116
31117
31118
31119
31120
31121
31122
31123
31124
31125
31126
31127
31128
31129
31130
31131
31132
31133
31134
31135
31136
31137
31138
31139
31140
31141
31142
31143
31144
31145
31146
31147
31148
31149
31150
31151
31152
31153
31154
31155
31156
31157
31158
31159
31160
31161
31162
31163
31164
31165
31166
31167
31168
31169
31170
31171
31172
31173
31174
31175
31176
31177
31178
31179
31180
31181
31182
31183
31184
31185
31186
31187
31188
31189
31190
31191
31192
31193
31194
31195
31196
31197
31198
31199
31200
31201
31202
31203
31204
31205
31206
31207
31208
31209
31210
31211
31212
31213
31214
31215
31216
31217
31218
31219
31220
31221
31222
31223
31224
31225
31226
31227
31228
31229
31230
31231
31232
31233
31234
31235
31236
31237
31238
31239
31240
31241
31242
31243
31244
31245
31246
31247
31248
31249
31250
31251
31252
31253
31254
31255
31256
31257
31258
31259
31260
31261
31262
31263
31264
31265
31266
31267
31268
31269
31270
31271
31272
31273
31274
31275
31276
31277
31278
31279
31280
31281
31282
31283
31284
31285
31286
31287
31288
31289
31290
31291
31292
31293
31294
31295
31296
31297
31298
31299
31300
31301
31302
31303
31304
31305
31306
31307
31308
31309
31310
31311
31312
31313
31314
31315
31316
31317
31318
31319
31320
31321
31322
31323
31324
31325
31326
31327
31328
31329
31330
31331
31332
31333
31334
31335
31336
31337
31338
31339
31340
31341
31342
31343
31344
31345
31346
31347
31348
31349
31350
31351
31352
31353
31354
31355
31356
31357
31358
31359
31360
31361
31362
31363
31364
31365
31366
31367
31368
31369
31370
31371
31372
31373
31374
31375
31376
31377
31378
31379
31380
31381
31382
31383
31384
31385
31386
31387
31388
31389
31390
31391
31392
31393
31394
31395
31396
31397
31398
31399
31400
31401
31402
31403
31404
31405
31406
31407
31408
31409
31410
31411
31412
31413
31414
31415
31416
31417
31418
31419
31420
31421
31422
31423
31424
31425
31426
31427
31428
31429
31430
31431
31432
31433
31434
31435
31436
31437
31438
31439
31440
31441
31442
31443
31444
31445
31446
31447
31448
31449
31450
31451
31452
31453
31454
31455
31456
31457
31458
31459
31460
31461
31462
31463
31464
31465
31466
31467
31468
31469
31470
31471
31472
31473
31474
31475
31476
31477
31478
31479
31480
31481
31482
31483
31484
31485
31486
31487
31488
31489
31490
31491
31492
31493
31494
31495
31496
31497
31498
31499
31500
31501
31502
31503
31504
31505
31506
31507
31508
31509
31510
31511
31512
31513
31514
31515
31516
31517
31518
31519
31520
31521
31522
31523
31524
31525
31526
31527
31528
31529
31530
31531
31532
31533
31534
31535
31536
31537
31538
31539
31540
31541
31542
31543
31544
31545
31546
31547
31548
31549
31550
31551
31552
31553
31554
31555
31556
31557
31558
31559
31560
31561
31562
31563
31564
31565
31566
31567
31568
31569
31570
31571
31572
31573
31574
31575
31576
31577
31578
31579
31580
31581
31582
31583
31584
31585
31586
31587
31588
31589
31590
31591
31592
31593
31594
31595
31596
31597
31598
31599
31600
31601
31602
31603
31604
31605
31606
31607
31608
31609
31610
31611
31612
31613
31614
31615
31616
31617
31618
31619
31620
31621
31622
31623
31624
31625
31626
31627
31628
31629
31630
31631
31632
31633
31634
31635
31636
31637
31638
31639
31640
31641
31642
31643
31644
31645
31646
31647
31648
31649
31650
31651
31652
31653
31654
31655
31656
31657
31658
31659
31660
31661
31662
31663
31664
31665
31666
31667
31668
31669
31670
31671
31672
31673
31674
31675
31676
31677
31678
31679
31680
31681
31682
31683
31684
31685
31686
31687
31688
31689
31690
31691
31692
31693
31694
31695
31696
31697
31698
31699
31700
31701
31702
31703
31704
31705
31706
31707
31708
31709
31710
31711
31712
31713
31714
31715
31716
31717
31718
31719
31720
31721
31722
31723
31724
31725
31726
31727
31728
31729
31730
31731
31732
31733
31734
31735
31736
31737
31738
31739
31740
31741
31742
31743
31744
31745
31746
31747
31748
31749
31750
31751
31752
31753
31754
31755
31756
31757
31758
31759
31760
31761
31762
31763
31764
31765
31766
31767
31768
31769
31770
31771
31772
31773
31774
31775
31776
31777
31778
31779
31780
31781
31782
31783
31784
31785
31786
31787
31788
31789
31790
31791
31792
31793
31794
31795
31796
31797
31798
31799
31800
31801
31802
31803
31804
31805
31806
31807
31808
31809
31810
31811
31812
31813
31814
31815
31816
31817
31818
31819
31820
31821
31822
31823
31824
31825
31826
31827
31828
31829
31830
31831
31832
31833
31834
31835
31836
31837
31838
31839
31840
31841
31842
31843
31844
31845
31846
31847
31848
31849
31850
31851
31852
31853
31854
31855
31856
31857
31858
31859
31860
31861
31862
31863
31864
31865
31866
31867
31868
31869
31870
31871
31872
31873
31874
31875
31876
31877
31878
31879
31880
31881
31882
31883
31884
31885
31886
31887
31888
31889
31890
31891
31892
31893
31894
31895
31896
31897
31898
31899
31900
31901
31902
31903
31904
31905
31906
31907
31908
31909
31910
31911
31912
31913
31914
31915
31916
31917
31918
31919
31920
31921
31922
31923
31924
31925
31926
31927
31928
31929
31930
31931
31932
31933
31934
31935
31936
31937
31938
31939
31940
31941
31942
31943
31944
31945
31946
31947
31948
31949
31950
31951
31952
31953
31954
31955
31956
31957
31958
31959
31960
31961
31962
31963
31964
31965
31966
31967
31968
31969
31970
31971
31972
31973
31974
31975
31976
31977
31978
31979
31980
31981
31982
31983
31984
31985
31986
31987
31988
31989
31990
31991
31992
31993
31994
31995
31996
31997
31998
31999
32000
32001
32002
32003
32004
32005
32006
32007
32008
32009
32010
32011
32012
32013
32014
32015
32016
32017
32018
32019
32020
32021
32022
32023
32024
32025
32026
32027
32028
32029
32030
32031
32032
32033
32034
32035
32036
32037
32038
32039
32040
32041
32042
32043
32044
32045
32046
32047
32048
32049
32050
32051
32052
32053
32054
32055
32056
32057
32058
32059
32060
32061
32062
32063
32064
32065
32066
32067
32068
32069
32070
32071
32072
32073
32074
32075
32076
32077
32078
32079
32080
32081
32082
32083
32084
32085
32086
32087
32088
32089
32090
32091
32092
32093
32094
32095
32096
32097
32098
32099
32100
32101
32102
32103
32104
32105
32106
32107
32108
32109
32110
32111
32112
32113
32114
32115
32116
32117
32118
32119
32120
32121
32122
32123
32124
32125
32126
32127
32128
32129
32130
32131
32132
32133
32134
32135
32136
32137
32138
32139
32140
32141
32142
32143
32144
32145
32146
32147
32148
32149
32150
32151
32152
32153
32154
32155
32156
32157
32158
32159
32160
32161
32162
32163
32164
32165
32166
32167
32168
32169
32170
32171
32172
32173
32174
32175
32176
32177
32178
32179
32180
32181
32182
32183
32184
32185
32186
32187
32188
32189
32190
32191
32192
32193
32194
32195
32196
32197
32198
32199
32200
32201
32202
32203
32204
32205
32206
32207
32208
32209
32210
32211
32212
32213
32214
32215
32216
32217
32218
32219
32220
32221
32222
32223
32224
32225
32226
32227
32228
32229
32230
32231
32232
32233
32234
32235
32236
32237
32238
32239
32240
32241
32242
32243
32244
32245
32246
32247
32248
32249
32250
32251
32252
32253
32254
32255
32256
32257
32258
32259
32260
32261
32262
32263
32264
32265
32266
32267
32268
32269
32270
32271
32272
32273
32274
32275
32276
32277
32278
32279
32280
32281
32282
32283
32284
32285
32286
32287
32288
32289
32290
32291
32292
32293
32294
32295
32296
32297
32298
32299
32300
32301
32302
32303
32304
32305
32306
32307
32308
32309
32310
32311
32312
32313
32314
32315
32316
32317
32318
32319
32320
32321
32322
32323
32324
32325
32326
32327
32328
32329
32330
32331
32332
32333
32334
32335
32336
32337
32338
32339
32340
32341
32342
32343
32344
32345
32346
32347
32348
32349
32350
32351
32352
32353
32354
32355
32356
32357
32358
32359
32360
32361
32362
32363
32364
32365
32366
32367
32368
32369
32370
32371
32372
32373
32374
32375
32376
32377
32378
32379
32380
32381
32382
32383
32384
32385
32386
32387
32388
32389
32390
32391
32392
32393
32394
32395
32396
32397
32398
32399
32400
32401
32402
32403
32404
32405
32406
32407
32408
32409
32410
32411
32412
32413
32414
32415
32416
32417
32418
32419
32420
32421
32422
32423
32424
32425
32426
32427
32428
32429
32430
32431
32432
32433
32434
32435
32436
32437
32438
32439
32440
32441
32442
32443
32444
32445
32446
32447
32448
32449
32450
32451
32452
32453
32454
32455
32456
32457
32458
32459
32460
32461
32462
32463
32464
32465
32466
32467
32468
32469
32470
32471
32472
32473
32474
32475
32476
32477
32478
32479
32480
32481
32482
32483
32484
32485
32486
32487
32488
32489
32490
32491
32492
32493
32494
32495
32496
32497
32498
32499
32500
32501
32502
32503
32504
32505
32506
32507
32508
32509
32510
32511
32512
32513
32514
32515
32516
32517
32518
32519
32520
32521
32522
32523
32524
32525
32526
32527
32528
32529
32530
32531
32532
32533
32534
32535
32536
32537
32538
32539
32540
32541
32542
32543
32544
32545
32546
32547
32548
32549
32550
32551
32552
32553
32554
32555
32556
32557
32558
32559
32560
32561
32562
32563
32564
32565
32566
32567
32568
32569
32570
32571
32572
32573
32574
32575
32576
32577
32578
32579
32580
32581
32582
32583
32584
32585
32586
32587
32588
32589
32590
32591
32592
32593
32594
32595
32596
32597
32598
32599
32600
32601
32602
32603
32604
32605
32606
32607
32608
32609
32610
32611
32612
32613
32614
32615
32616
32617
32618
32619
32620
32621
32622
32623
32624
32625
32626
32627
32628
32629
32630
32631
32632
32633
32634
32635
32636
32637
32638
32639
32640
32641
32642
32643
32644
32645
32646
32647
32648
32649
32650
32651
32652
32653
32654
32655
32656
32657
32658
32659
32660
32661
32662
32663
32664
32665
32666
32667
32668
32669
32670
32671
32672
32673
32674
32675
32676
32677
32678
32679
32680
32681
32682
32683
32684
32685
32686
32687
32688
32689
32690
32691
32692
32693
32694
32695
32696
32697
32698
32699
32700
32701
32702
32703
32704
32705
32706
32707
32708
32709
32710
32711
32712
32713
32714
32715
32716
32717
32718
32719
32720
32721
32722
32723
32724
32725
32726
32727
32728
32729
32730
32731
32732
32733
32734
32735
32736
32737
32738
32739
32740
32741
32742
32743
32744
32745
32746
32747
32748
32749
32750
32751
32752
32753
32754
32755
32756
32757
32758
32759
32760
32761
32762
32763
32764
32765
32766
32767
32768
32769
32770
32771
32772
32773
32774
32775
32776
32777
32778
32779
32780
32781
32782
32783
32784
32785
32786
32787
32788
32789
32790
32791
32792
32793
32794
32795
32796
32797
32798
32799
32800
32801
32802
32803
32804
32805
32806
32807
32808
32809
32810
32811
32812
32813
32814
32815
32816
32817
32818
32819
32820
32821
32822
32823
32824
32825
32826
32827
32828
32829
32830
32831
32832
32833
32834
32835
32836
32837
32838
32839
32840
32841
32842
32843
32844
32845
32846
32847
32848
32849
32850
32851
32852
32853
32854
32855
32856
32857
32858
32859
32860
32861
32862
32863
32864
32865
32866
32867
32868
32869
32870
32871
32872
32873
32874
32875
32876
32877
32878
32879
32880
32881
32882
32883
32884
32885
32886
32887
32888
32889
32890
32891
32892
32893
32894
32895
32896
32897
32898
32899
32900
32901
32902
32903
32904
32905
32906
32907
32908
32909
32910
32911
32912
32913
32914
32915
32916
32917
32918
32919
32920
32921
32922
32923
32924
32925
32926
32927
32928
32929
32930
32931
32932
32933
32934
32935
32936
32937
32938
32939
32940
32941
32942
32943
32944
32945
32946
32947
32948
32949
32950
32951
32952
32953
32954
32955
32956
32957
32958
32959
32960
32961
32962
32963
32964
32965
32966
32967
32968
32969
32970
32971
32972
32973
32974
32975
32976
32977
32978
32979
32980
32981
32982
32983
32984
32985
32986
32987
32988
32989
32990
32991
32992
32993
32994
32995
32996
32997
32998
32999
33000
33001
33002
33003
33004
33005
33006
33007
33008
33009
33010
33011
33012
33013
33014
33015
33016
33017
33018
33019
33020
33021
33022
33023
33024
33025
33026
33027
33028
33029
33030
33031
33032
33033
33034
33035
33036
33037
33038
33039
33040
33041
33042
33043
33044
33045
33046
33047
33048
33049
33050
33051
33052
33053
33054
33055
33056
33057
33058
33059
33060
33061
33062
33063
33064
33065
33066
33067
33068
33069
33070
33071
33072
33073
33074
33075
33076
33077
33078
33079
33080
33081
33082
33083
33084
33085
33086
33087
33088
33089
33090
33091
33092
33093
33094
33095
33096
33097
33098
33099
33100
33101
33102
33103
33104
33105
33106
33107
33108
33109
33110
33111
33112
33113
33114
33115
33116
33117
33118
33119
33120
33121
33122
33123
33124
33125
33126
33127
33128
33129
33130
33131
33132
33133
33134
33135
33136
33137
33138
33139
33140
33141
33142
33143
33144
33145
33146
33147
33148
33149
33150
33151
33152
33153
33154
33155
33156
33157
33158
33159
33160
33161
33162
33163
33164
33165
33166
33167
33168
33169
33170
33171
33172
33173
33174
33175
33176
33177
33178
33179
33180
33181
33182
33183
33184
33185
33186
33187
33188
33189
33190
33191
33192
33193
33194
33195
33196
33197
33198
33199
33200
33201
33202
33203
33204
33205
33206
33207
33208
33209
33210
33211
33212
33213
33214
33215
33216
33217
33218
33219
33220
33221
33222
33223
33224
33225
33226
33227
33228
33229
33230
33231
33232
33233
33234
33235
33236
33237
33238
33239
33240
33241
33242
33243
33244
33245
33246
33247
33248
33249
33250
33251
33252
33253
33254
33255
33256
33257
33258
33259
33260
33261
33262
33263
33264
33265
33266
33267
33268
33269
33270
33271
33272
33273
33274
33275
33276
33277
33278
33279
33280
33281
33282
33283
33284
33285
33286
33287
33288
33289
33290
33291
33292
33293
33294
33295
33296
33297
33298
33299
33300
33301
33302
33303
33304
33305
33306
33307
33308
33309
33310
33311
33312
33313
33314
33315
33316
33317
33318
33319
33320
33321
33322
33323
33324
33325
33326
33327
33328
33329
33330
33331
33332
33333
33334
33335
33336
33337
33338
33339
33340
33341
33342
33343
33344
33345
33346
33347
33348
33349
33350
33351
33352
33353
33354
33355
33356
33357
33358
33359
33360
33361
33362
33363
33364
33365
33366
33367
33368
33369
33370
33371
33372
33373
33374
33375
33376
33377
33378
33379
33380
33381
33382
33383
33384
33385
33386
33387
33388
33389
33390
33391
33392
33393
33394
33395
33396
33397
33398
33399
33400
33401
33402
33403
33404
33405
33406
33407
33408
33409
33410
33411
33412
33413
33414
33415
33416
33417
33418
33419
33420
33421
33422
33423
33424
33425
33426
33427
33428
33429
33430
33431
33432
33433
33434
33435
33436
33437
33438
33439
33440
33441
33442
33443
33444
33445
33446
33447
33448
33449
33450
33451
33452
33453
33454
33455
33456
33457
33458
33459
33460
33461
33462
33463
33464
33465
33466
33467
33468
33469
33470
33471
33472
33473
33474
33475
33476
33477
33478
33479
33480
33481
33482
33483
33484
33485
33486
33487
33488
33489
33490
33491
33492
33493
33494
33495
33496
33497
33498
33499
33500
33501
33502
33503
33504
33505
33506
33507
33508
33509
33510
33511
33512
33513
33514
33515
33516
33517
33518
33519
33520
33521
33522
33523
33524
33525
33526
33527
33528
33529
33530
33531
33532
33533
33534
33535
33536
33537
33538
33539
33540
33541
33542
33543
33544
33545
33546
33547
33548
33549
33550
33551
33552
33553
33554
33555
33556
33557
33558
33559
33560
33561
33562
33563
33564
33565
33566
33567
33568
33569
33570
33571
33572
33573
33574
33575
33576
33577
33578
33579
33580
33581
33582
33583
33584
33585
33586
33587
33588
33589
33590
33591
33592
33593
33594
33595
33596
33597
33598
33599
33600
33601
33602
33603
33604
33605
33606
33607
33608
33609
33610
33611
33612
33613
33614
33615
33616
33617
33618
33619
33620
33621
33622
33623
33624
33625
33626
33627
33628
33629
33630
33631
33632
33633
33634
33635
33636
33637
33638
33639
33640
33641
33642
33643
33644
33645
33646
33647
33648
33649
33650
33651
33652
33653
33654
33655
33656
33657
33658
33659
33660
33661
33662
33663
33664
33665
33666
33667
33668
33669
33670
33671
33672
33673
33674
33675
33676
33677
33678
33679
33680
33681
33682
33683
33684
33685
33686
33687
33688
33689
33690
33691
33692
33693
33694
33695
33696
33697
33698
33699
33700
33701
33702
33703
33704
33705
33706
33707
33708
33709
33710
33711
33712
33713
33714
33715
33716
33717
33718
33719
33720
33721
33722
33723
33724
33725
33726
33727
33728
33729
33730
33731
33732
33733
33734
33735
33736
33737
33738
33739
33740
33741
33742
33743
33744
33745
33746
33747
33748
33749
33750
33751
33752
33753
33754
33755
33756
33757
33758
33759
33760
33761
33762
33763
33764
33765
33766
33767
33768
33769
33770
33771
33772
33773
33774
33775
33776
33777
33778
33779
33780
33781
33782
33783
33784
33785
33786
33787
33788
33789
33790
33791
33792
33793
33794
33795
33796
33797
33798
33799
33800
33801
33802
33803
33804
33805
33806
33807
33808
33809
33810
33811
33812
33813
33814
33815
33816
33817
33818
33819
33820
33821
33822
33823
33824
33825
33826
33827
33828
33829
33830
33831
33832
33833
33834
33835
33836
33837
33838
33839
33840
33841
33842
33843
33844
33845
33846
33847
33848
33849
33850
33851
33852
33853
33854
33855
33856
33857
33858
33859
33860
33861
33862
33863
33864
33865
33866
33867
33868
33869
33870
33871
33872
33873
33874
33875
33876
33877
33878
33879
33880
33881
33882
33883
33884
33885
33886
33887
33888
33889
33890
33891
33892
33893
33894
33895
33896
33897
33898
33899
33900
33901
33902
33903
33904
33905
33906
33907
33908
33909
33910
33911
33912
33913
33914
33915
33916
33917
33918
33919
33920
33921
33922
33923
33924
33925
33926
33927
33928
33929
33930
33931
33932
33933
33934
33935
33936
33937
33938
33939
33940
33941
33942
33943
33944
33945
33946
33947
33948
33949
33950
33951
33952
33953
33954
33955
33956
33957
33958
33959
33960
33961
33962
33963
33964
33965
33966
33967
33968
33969
33970
33971
33972
33973
33974
33975
33976
33977
33978
33979
33980
33981
33982
33983
33984
33985
33986
33987
33988
33989
33990
33991
33992
33993
33994
33995
33996
33997
33998
33999
34000
34001
34002
34003
34004
34005
34006
34007
34008
34009
34010
34011
34012
34013
34014
34015
34016
34017
34018
34019
34020
34021
34022
34023
34024
34025
34026
34027
34028
34029
34030
34031
34032
34033
34034
34035
34036
34037
34038
34039
34040
34041
34042
34043
34044
34045
34046
34047
34048
34049
34050
34051
34052
34053
34054
34055
34056
34057
34058
34059
34060
34061
34062
34063
34064
34065
34066
34067
34068
34069
34070
34071
34072
34073
34074
34075
34076
34077
34078
34079
34080
34081
34082
34083
34084
34085
34086
34087
34088
34089
34090
34091
34092
34093
34094
34095
34096
34097
34098
34099
34100
34101
34102
34103
34104
34105
34106
34107
34108
34109
34110
34111
34112
34113
34114
34115
34116
34117
34118
34119
34120
34121
34122
34123
34124
34125
34126
34127
34128
34129
34130
34131
34132
34133
34134
34135
34136
34137
34138
34139
34140
34141
34142
34143
34144
34145
34146
34147
34148
34149
34150
34151
34152
34153
34154
34155
34156
34157
34158
34159
34160
34161
34162
34163
34164
34165
34166
34167
34168
34169
34170
34171
34172
34173
34174
34175
34176
34177
34178
34179
34180
34181
34182
34183
34184
34185
34186
34187
34188
34189
34190
34191
34192
34193
34194
34195
34196
34197
34198
34199
34200
34201
34202
34203
34204
34205
34206
34207
34208
34209
34210
34211
34212
34213
34214
34215
34216
34217
34218
34219
34220
34221
34222
34223
34224
34225
34226
34227
34228
34229
34230
34231
34232
34233
34234
34235
34236
34237
34238
34239
34240
34241
34242
34243
34244
34245
34246
34247
34248
34249
34250
34251
34252
34253
34254
34255
34256
34257
34258
34259
34260
34261
34262
34263
34264
34265
34266
34267
34268
34269
34270
34271
34272
34273
34274
34275
34276
34277
34278
34279
34280
34281
34282
34283
34284
34285
34286
34287
34288
34289
34290
34291
34292
34293
34294
34295
34296
34297
34298
34299
34300
34301
34302
34303
34304
34305
34306
34307
34308
34309
34310
34311
34312
34313
34314
34315
34316
34317
34318
34319
34320
34321
34322
34323
34324
34325
34326
34327
34328
34329
34330
34331
34332
34333
34334
34335
34336
34337
34338
34339
34340
34341
34342
34343
34344
34345
34346
34347
34348
34349
34350
34351
34352
34353
34354
34355
34356
34357
34358
34359
34360
34361
34362
34363
34364
34365
34366
34367
34368
34369
34370
34371
34372
34373
34374
34375
34376
34377
34378
34379
34380
34381
34382
34383
34384
34385
34386
34387
34388
34389
34390
34391
34392
34393
34394
34395
34396
34397
34398
34399
34400
34401
34402
34403
34404
34405
34406
34407
34408
34409
34410
34411
34412
34413
34414
34415
34416
34417
34418
34419
34420
34421
34422
34423
34424
34425
34426
34427
34428
34429
34430
34431
34432
34433
34434
34435
34436
34437
34438
34439
34440
34441
34442
34443
34444
34445
34446
34447
34448
34449
34450
34451
34452
34453
34454
34455
34456
34457
34458
34459
34460
34461
34462
34463
34464
34465
34466
34467
34468
34469
34470
34471
34472
34473
34474
34475
34476
34477
34478
34479
34480
34481
34482
34483
34484
34485
34486
34487
34488
34489
34490
34491
34492
34493
34494
34495
34496
34497
34498
34499
34500
34501
34502
34503
34504
34505
34506
34507
34508
34509
34510
34511
34512
34513
34514
34515
34516
34517
34518
34519
34520
34521
34522
34523
34524
34525
34526
34527
34528
34529
34530
34531
34532
34533
34534
34535
34536
34537
34538
34539
34540
34541
34542
34543
34544
34545
34546
34547
34548
34549
34550
34551
34552
34553
34554
34555
34556
34557
34558
34559
34560
34561
34562
34563
34564
34565
34566
34567
34568
34569
34570
34571
34572
34573
34574
34575
34576
34577
34578
34579
34580
34581
34582
34583
34584
34585
34586
34587
34588
34589
34590
34591
34592
34593
34594
34595
34596
34597
34598
34599
34600
34601
34602
34603
34604
34605
34606
34607
34608
34609
34610
34611
34612
34613
34614
34615
34616
34617
34618
34619
34620
34621
34622
34623
34624
34625
34626
34627
34628
34629
34630
34631
34632
34633
34634
34635
34636
34637
34638
34639
34640
34641
34642
34643
34644
34645
34646
34647
34648
34649
34650
34651
34652
34653
34654
34655
34656
34657
34658
34659
34660
34661
34662
34663
34664
34665
34666
34667
34668
34669
34670
34671
34672
34673
34674
34675
34676
34677
34678
34679
34680
34681
34682
34683
34684
34685
34686
34687
34688
34689
34690
34691
34692
34693
34694
34695
34696
34697
34698
34699
34700
34701
34702
34703
34704
34705
34706
34707
34708
34709
34710
34711
34712
34713
34714
34715
34716
34717
34718
34719
34720
34721
34722
34723
34724
34725
34726
34727
34728
34729
34730
34731
34732
34733
34734
34735
34736
34737
34738
34739
34740
34741
34742
34743
34744
34745
34746
34747
34748
34749
34750
34751
34752
34753
34754
34755
34756
34757
34758
34759
34760
34761
34762
34763
34764
34765
34766
34767
34768
34769
34770
34771
34772
34773
34774
34775
34776
34777
34778
34779
34780
34781
34782
34783
34784
34785
34786
34787
34788
34789
34790
34791
34792
34793
34794
34795
34796
34797
34798
34799
34800
34801
34802
34803
34804
34805
34806
34807
34808
34809
34810
34811
34812
34813
34814
34815
34816
34817
34818
34819
34820
34821
34822
34823
34824
34825
34826
34827
34828
34829
34830
34831
34832
34833
34834
34835
34836
34837
34838
34839
34840
34841
34842
34843
34844
34845
34846
34847
34848
34849
34850
34851
34852
34853
34854
34855
34856
34857
34858
34859
34860
34861
34862
34863
34864
34865
34866
34867
34868
34869
34870
34871
34872
34873
34874
34875
34876
34877
34878
34879
34880
34881
34882
34883
34884
34885
34886
34887
34888
34889
34890
34891
34892
34893
34894
34895
34896
34897
34898
34899
34900
34901
34902
34903
34904
34905
34906
34907
34908
34909
34910
34911
34912
34913
34914
34915
34916
34917
34918
34919
34920
34921
34922
34923
34924
34925
34926
34927
34928
34929
34930
34931
34932
34933
34934
34935
34936
34937
34938
34939
34940
34941
34942
34943
34944
34945
34946
34947
34948
34949
34950
34951
34952
34953
34954
34955
34956
34957
34958
34959
34960
34961
34962
34963
34964
34965
34966
34967
34968
34969
34970
34971
34972
34973
34974
34975
34976
34977
34978
34979
34980
34981
34982
34983
34984
34985
34986
34987
34988
34989
34990
34991
34992
34993
34994
34995
34996
34997
34998
34999
35000
35001
35002
35003
35004
35005
35006
35007
35008
35009
35010
35011
35012
35013
35014
35015
35016
35017
35018
35019
35020
35021
35022
35023
35024
35025
35026
35027
35028
35029
35030
35031
35032
35033
35034
35035
35036
35037
35038
35039
35040
35041
35042
35043
35044
35045
35046
35047
35048
35049
35050
35051
35052
35053
35054
35055
35056
35057
35058
35059
35060
35061
35062
35063
35064
35065
35066
35067
35068
35069
35070
35071
35072
35073
35074
35075
35076
35077
35078
35079
35080
35081
35082
35083
35084
35085
35086
35087
35088
35089
35090
35091
35092
35093
35094
35095
35096
35097
35098
35099
35100
35101
35102
35103
35104
35105
35106
35107
35108
35109
35110
35111
35112
35113
35114
35115
35116
35117
35118
35119
35120
35121
35122
35123
35124
35125
35126
35127
35128
35129
35130
35131
35132
35133
35134
35135
35136
35137
35138
35139
35140
35141
35142
35143
35144
35145
35146
35147
35148
35149
35150
35151
35152
35153
35154
35155
35156
35157
35158
35159
35160
35161
35162
35163
35164
35165
35166
35167
35168
35169
35170
35171
35172
35173
35174
35175
35176
35177
35178
35179
35180
35181
35182
35183
35184
35185
35186
35187
35188
35189
35190
35191
35192
35193
35194
35195
35196
35197
35198
35199
35200
35201
35202
35203
35204
35205
35206
35207
35208
35209
35210
35211
35212
35213
35214
35215
35216
35217
35218
35219
35220
35221
35222
35223
35224
35225
35226
35227
35228
35229
35230
35231
35232
35233
35234
35235
35236
35237
35238
35239
35240
35241
35242
35243
35244
35245
35246
35247
35248
35249
35250
35251
35252
35253
35254
35255
35256
35257
35258
35259
35260
35261
35262
35263
35264
35265
35266
35267
35268
35269
35270
35271
35272
35273
35274
35275
35276
35277
35278
35279
35280
35281
35282
35283
35284
35285
35286
35287
35288
35289
35290
35291
35292
35293
35294
35295
35296
35297
35298
35299
35300
35301
35302
35303
35304
35305
35306
35307
35308
35309
35310
35311
35312
35313
35314
35315
35316
35317
35318
35319
35320
35321
35322
35323
35324
35325
35326
35327
35328
35329
35330
35331
35332
35333
35334
35335
35336
35337
35338
35339
35340
35341
35342
35343
35344
35345
35346
35347
35348
35349
35350
35351
35352
35353
35354
35355
35356
35357
35358
35359
35360
35361
35362
35363
35364
35365
35366
35367
35368
35369
35370
35371
35372
35373
35374
35375
35376
35377
35378
35379
35380
35381
35382
35383
35384
35385
35386
35387
35388
35389
35390
35391
35392
35393
35394
35395
35396
35397
35398
35399
35400
35401
35402
35403
35404
35405
35406
35407
35408
35409
35410
35411
35412
35413
35414
35415
35416
35417
35418
35419
35420
35421
35422
35423
35424
35425
35426
35427
35428
35429
35430
35431
35432
35433
35434
35435
35436
35437
35438
35439
35440
35441
35442
35443
35444
35445
35446
35447
35448
35449
35450
35451
35452
35453
35454
35455
35456
35457
35458
35459
35460
35461
35462
35463
35464
35465
35466
35467
35468
35469
35470
35471
35472
35473
35474
35475
35476
35477
35478
35479
35480
35481
35482
35483
35484
35485
35486
35487
35488
35489
35490
35491
35492
35493
35494
35495
35496
35497
35498
35499
35500
35501
35502
35503
35504
35505
35506
35507
35508
35509
35510
35511
35512
35513
35514
35515
35516
35517
35518
35519
35520
35521
35522
35523
35524
35525
35526
35527
35528
35529
35530
35531
35532
35533
35534
35535
35536
35537
35538
35539
35540
35541
35542
35543
35544
35545
35546
35547
35548
35549
35550
35551
35552
35553
35554
35555
35556
35557
35558
35559
35560
35561
35562
35563
35564
35565
35566
35567
35568
35569
35570
35571
35572
35573
35574
35575
35576
35577
35578
35579
35580
35581
35582
35583
35584
35585
35586
35587
35588
35589
35590
35591
35592
35593
35594
35595
35596
35597
35598
35599
35600
35601
35602
35603
35604
35605
35606
35607
35608
35609
35610
35611
35612
35613
35614
35615
35616
35617
35618
35619
35620
35621
35622
35623
35624
35625
35626
35627
35628
35629
35630
35631
35632
35633
35634
35635
35636
35637
35638
35639
35640
35641
35642
35643
35644
35645
35646
35647
35648
35649
35650
35651
35652
35653
35654
35655
35656
35657
35658
35659
35660
35661
35662
35663
35664
35665
35666
35667
35668
35669
35670
35671
35672
35673
35674
35675
35676
35677
35678
35679
35680
35681
35682
35683
35684
35685
35686
35687
35688
35689
35690
35691
35692
35693
35694
35695
35696
35697
35698
35699
35700
35701
35702
35703
35704
35705
35706
35707
35708
35709
35710
35711
35712
35713
35714
35715
35716
35717
35718
35719
35720
35721
35722
35723
35724
35725
35726
35727
35728
35729
35730
35731
35732
35733
35734
35735
35736
35737
35738
35739
35740
35741
35742
35743
35744
35745
35746
35747
35748
35749
35750
35751
35752
35753
35754
35755
35756
35757
35758
35759
35760
35761
35762
35763
35764
35765
35766
35767
35768
35769
35770
35771
35772
35773
35774
35775
35776
35777
35778
35779
35780
35781
35782
35783
35784
35785
35786
35787
35788
35789
35790
35791
35792
35793
35794
35795
35796
35797
35798
35799
35800
35801
35802
35803
35804
35805
35806
35807
35808
35809
35810
35811
35812
35813
35814
35815
35816
35817
35818
35819
35820
35821
35822
35823
35824
35825
35826
35827
35828
35829
35830
35831
35832
35833
35834
35835
35836
35837
35838
35839
35840
35841
35842
35843
35844
35845
35846
35847
35848
35849
35850
35851
35852
35853
35854
35855
35856
35857
35858
35859
35860
35861
35862
35863
35864
35865
35866
35867
35868
35869
35870
35871
35872
35873
35874
35875
35876
35877
35878
35879
35880
35881
35882
35883
35884
35885
35886
35887
35888
35889
35890
35891
35892
35893
35894
35895
35896
35897
35898
35899
35900
35901
35902
35903
35904
35905
35906
35907
35908
35909
35910
35911
35912
35913
35914
35915
35916
35917
35918
35919
35920
35921
35922
35923
35924
35925
35926
35927
35928
35929
35930
35931
35932
35933
35934
35935
35936
35937
35938
35939
35940
35941
35942
35943
35944
35945
35946
35947
35948
35949
35950
35951
35952
35953
35954
35955
35956
35957
35958
35959
35960
35961
35962
35963
35964
35965
35966
35967
35968
35969
35970
35971
35972
35973
35974
35975
35976
35977
35978
35979
35980
35981
35982
35983
35984
35985
35986
35987
35988
35989
35990
35991
35992
35993
35994
35995
35996
35997
35998
35999
36000
36001
36002
36003
36004
36005
36006
36007
36008
36009
36010
36011
36012
36013
36014
36015
36016
36017
36018
36019
36020
36021
36022
36023
36024
36025
36026
36027
36028
36029
36030
36031
36032
36033
36034
36035
36036
36037
36038
36039
36040
36041
36042
36043
36044
36045
36046
36047
36048
36049
36050
36051
36052
36053
36054
36055
36056
36057
36058
36059
36060
36061
36062
36063
36064
36065
36066
36067
36068
36069
36070
36071
36072
36073
36074
36075
36076
36077
36078
36079
36080
36081
36082
36083
36084
36085
36086
36087
36088
36089
36090
36091
36092
36093
36094
36095
36096
36097
36098
36099
36100
36101
36102
36103
36104
36105
36106
36107
36108
36109
36110
36111
36112
36113
36114
36115
36116
36117
36118
36119
36120
36121
36122
36123
36124
36125
36126
36127
36128
36129
36130
36131
36132
36133
36134
36135
36136
36137
36138
36139
36140
36141
36142
36143
36144
36145
36146
36147
36148
36149
36150
36151
36152
36153
36154
36155
36156
36157
36158
36159
36160
36161
36162
36163
36164
36165
36166
36167
36168
36169
36170
36171
36172
36173
36174
36175
36176
36177
36178
36179
36180
36181
36182
36183
36184
36185
36186
36187
36188
36189
36190
36191
36192
36193
36194
36195
36196
36197
36198
36199
36200
36201
36202
36203
36204
36205
36206
36207
36208
36209
36210
36211
36212
36213
36214
36215
36216
36217
36218
36219
36220
36221
36222
36223
36224
36225
36226
36227
36228
36229
36230
36231
36232
36233
36234
36235
36236
36237
36238
36239
36240
36241
36242
36243
36244
36245
36246
36247
36248
36249
36250
36251
36252
36253
36254
36255
36256
36257
36258
36259
36260
36261
36262
36263
36264
36265
36266
36267
36268
36269
36270
36271
36272
36273
36274
36275
36276
36277
36278
36279
36280
36281
36282
36283
36284
36285
36286
36287
36288
36289
36290
36291
36292
36293
36294
36295
36296
36297
36298
36299
36300
36301
36302
36303
36304
36305
36306
36307
36308
36309
36310
36311
36312
36313
36314
36315
36316
36317
36318
36319
36320
36321
36322
36323
36324
36325
36326
36327
36328
36329
36330
36331
36332
36333
36334
36335
36336
36337
36338
36339
36340
36341
36342
36343
36344
36345
36346
36347
36348
36349
36350
36351
36352
36353
36354
36355
36356
36357
36358
36359
36360
36361
36362
36363
36364
36365
36366
36367
36368
36369
36370
36371
36372
36373
36374
36375
36376
36377
36378
36379
36380
36381
36382
36383
36384
36385
36386
36387
36388
36389
36390
36391
36392
36393
36394
36395
36396
36397
36398
36399
36400
36401
36402
36403
36404
36405
36406
36407
36408
36409
36410
36411
36412
36413
36414
36415
36416
36417
36418
36419
36420
36421
36422
36423
36424
36425
36426
36427
36428
36429
36430
36431
36432
36433
36434
36435
36436
36437
36438
36439
36440
36441
36442
36443
36444
36445
36446
36447
36448
36449
36450
36451
36452
36453
36454
36455
36456
36457
36458
36459
36460
36461
36462
36463
36464
36465
36466
36467
36468
36469
36470
36471
36472
36473
36474
36475
36476
36477
36478
36479
36480
36481
36482
36483
36484
36485
36486
36487
36488
36489
36490
36491
36492
36493
36494
36495
36496
36497
36498
36499
36500
36501
36502
36503
36504
36505
36506
36507
36508
36509
36510
36511
36512
36513
36514
36515
36516
36517
36518
36519
36520
36521
36522
36523
36524
36525
36526
36527
36528
36529
36530
36531
36532
36533
36534
36535
36536
36537
36538
36539
36540
36541
36542
36543
36544
36545
36546
36547
36548
36549
36550
36551
36552
36553
36554
36555
36556
36557
36558
36559
36560
36561
36562
36563
36564
36565
36566
36567
36568
36569
36570
36571
36572
36573
36574
36575
36576
36577
36578
36579
36580
36581
36582
36583
36584
36585
36586
36587
36588
36589
36590
36591
36592
36593
36594
36595
36596
36597
36598
36599
36600
36601
36602
36603
36604
36605
36606
36607
36608
36609
36610
36611
36612
36613
36614
36615
36616
36617
36618
36619
36620
36621
36622
36623
36624
36625
36626
36627
36628
36629
36630
36631
36632
36633
36634
36635
36636
36637
36638
36639
36640
36641
36642
36643
36644
36645
36646
36647
36648
36649
36650
36651
36652
36653
36654
36655
36656
36657
36658
36659
36660
36661
36662
36663
36664
36665
36666
36667
36668
36669
36670
36671
36672
36673
36674
36675
36676
36677
36678
36679
36680
36681
36682
36683
36684
36685
36686
36687
36688
36689
36690
36691
36692
36693
36694
36695
36696
36697
36698
36699
36700
36701
36702
36703
36704
36705
36706
36707
36708
36709
36710
36711
36712
36713
36714
36715
36716
36717
36718
36719
36720
36721
36722
36723
36724
36725
36726
36727
36728
36729
36730
36731
36732
36733
36734
36735
36736
36737
36738
36739
36740
36741
36742
36743
36744
36745
36746
36747
36748
36749
36750
36751
36752
36753
36754
36755
36756
36757
36758
36759
36760
36761
36762
36763
36764
36765
36766
36767
36768
36769
36770
36771
36772
36773
36774
36775
36776
36777
36778
36779
36780
36781
36782
36783
36784
36785
36786
36787
36788
36789
36790
36791
36792
36793
36794
36795
36796
36797
36798
36799
36800
36801
36802
36803
36804
36805
36806
36807
36808
36809
36810
36811
36812
36813
36814
36815
36816
36817
36818
36819
36820
36821
36822
36823
36824
36825
36826
36827
36828
36829
36830
36831
36832
36833
36834
36835
36836
36837
36838
36839
36840
36841
36842
36843
36844
36845
36846
36847
36848
36849
36850
36851
36852
36853
36854
36855
36856
36857
36858
36859
36860
36861
36862
36863
36864
36865
36866
36867
36868
36869
36870
36871
36872
36873
36874
36875
36876
36877
36878
36879
36880
36881
36882
36883
36884
36885
36886
36887
36888
36889
36890
36891
36892
36893
36894
36895
36896
36897
36898
36899
36900
36901
36902
36903
36904
36905
36906
36907
36908
36909
36910
36911
36912
36913
36914
36915
36916
36917
36918
36919
36920
36921
36922
36923
36924
36925
36926
36927
36928
36929
36930
36931
36932
36933
36934
36935
36936
36937
36938
36939
36940
36941
36942
36943
36944
36945
36946
36947
36948
36949
36950
36951
36952
36953
36954
36955
36956
36957
36958
36959
36960
36961
36962
36963
36964
36965
36966
36967
36968
36969
36970
36971
36972
36973
36974
36975
36976
36977
36978
36979
36980
36981
36982
36983
36984
36985
36986
36987
36988
36989
36990
36991
36992
36993
36994
36995
36996
36997
36998
36999
37000
37001
37002
37003
37004
37005
37006
37007
37008
37009
37010
37011
37012
37013
37014
37015
37016
37017
37018
37019
37020
37021
37022
37023
37024
37025
37026
37027
37028
37029
37030
37031
37032
37033
37034
37035
37036
37037
37038
37039
37040
37041
37042
37043
37044
37045
37046
37047
37048
37049
37050
37051
37052
37053
37054
37055
37056
37057
37058
37059
37060
37061
37062
37063
37064
37065
37066
37067
37068
37069
37070
37071
37072
37073
37074
37075
37076
37077
37078
37079
37080
37081
37082
37083
37084
37085
37086
37087
37088
37089
37090
37091
37092
37093
37094
37095
37096
37097
37098
37099
37100
37101
37102
37103
37104
37105
37106
37107
37108
37109
37110
37111
37112
37113
37114
37115
37116
37117
37118
37119
37120
37121
37122
37123
37124
37125
37126
37127
37128
37129
37130
37131
37132
37133
37134
37135
37136
37137
37138
37139
37140
37141
37142
37143
37144
37145
37146
37147
37148
37149
37150
37151
37152
37153
37154
37155
37156
37157
37158
37159
37160
37161
37162
37163
37164
37165
37166
37167
37168
37169
37170
37171
37172
37173
37174
37175
37176
37177
37178
37179
37180
37181
37182
37183
37184
37185
37186
37187
37188
37189
37190
37191
37192
37193
37194
37195
37196
37197
37198
37199
37200
37201
37202
37203
37204
37205
37206
37207
37208
37209
37210
37211
37212
37213
37214
37215
37216
37217
37218
37219
37220
37221
37222
37223
37224
37225
37226
37227
37228
37229
37230
37231
37232
37233
37234
37235
37236
37237
37238
37239
37240
37241
37242
37243
37244
37245
37246
37247
37248
37249
37250
37251
37252
37253
37254
37255
37256
37257
37258
37259
37260
37261
37262
37263
37264
37265
37266
37267
37268
37269
37270
37271
37272
37273
37274
37275
37276
37277
37278
37279
37280
37281
37282
37283
37284
37285
37286
37287
37288
37289
37290
37291
37292
37293
37294
37295
37296
37297
37298
37299
37300
37301
37302
37303
37304
37305
37306
37307
37308
37309
37310
37311
37312
37313
37314
37315
37316
37317
37318
37319
37320
37321
37322
37323
37324
37325
37326
37327
37328
37329
37330
37331
37332
37333
37334
37335
37336
37337
37338
37339
37340
37341
37342
37343
37344
37345
37346
37347
37348
37349
37350
37351
37352
37353
37354
37355
37356
37357
37358
37359
37360
37361
37362
37363
37364
37365
37366
37367
37368
37369
37370
37371
37372
37373
37374
37375
37376
37377
37378
37379
37380
37381
37382
37383
37384
37385
37386
37387
37388
37389
37390
37391
37392
37393
37394
37395
37396
37397
37398
37399
37400
37401
37402
37403
37404
37405
37406
37407
37408
37409
37410
37411
37412
37413
37414
37415
37416
37417
37418
37419
37420
37421
37422
37423
37424
37425
37426
37427
37428
37429
37430
37431
37432
37433
37434
37435
37436
37437
37438
37439
37440
37441
37442
37443
37444
37445
37446
37447
37448
37449
37450
37451
37452
37453
37454
37455
37456
37457
37458
37459
37460
37461
37462
37463
37464
37465
37466
37467
37468
37469
37470
37471
37472
37473
37474
37475
37476
37477
37478
37479
37480
37481
37482
37483
37484
37485
37486
37487
37488
37489
37490
37491
37492
37493
37494
37495
37496
37497
37498
37499
37500
37501
37502
37503
37504
37505
37506
37507
37508
37509
37510
37511
37512
37513
37514
37515
37516
37517
37518
37519
37520
37521
37522
37523
37524
37525
37526
37527
37528
37529
37530
37531
37532
37533
37534
37535
37536
37537
37538
37539
37540
37541
37542
37543
37544
37545
37546
37547
37548
37549
37550
37551
37552
37553
37554
37555
37556
37557
37558
37559
37560
37561
37562
37563
37564
37565
37566
37567
37568
37569
37570
37571
37572
37573
37574
37575
37576
37577
37578
37579
37580
37581
37582
37583
37584
37585
37586
37587
37588
37589
37590
37591
37592
37593
37594
37595
37596
37597
37598
37599
37600
37601
37602
37603
37604
37605
37606
37607
37608
37609
37610
37611
37612
37613
37614
37615
37616
37617
37618
37619
37620
37621
37622
37623
37624
37625
37626
37627
37628
37629
37630
37631
37632
37633
37634
37635
37636
37637
37638
37639
37640
37641
37642
37643
37644
37645
37646
37647
37648
37649
37650
37651
37652
37653
37654
37655
37656
37657
37658
37659
37660
37661
37662
37663
37664
37665
37666
37667
37668
37669
37670
37671
37672
37673
37674
37675
37676
37677
37678
37679
37680
37681
37682
37683
37684
37685
37686
37687
37688
37689
37690
37691
37692
37693
37694
37695
37696
37697
37698
37699
37700
37701
37702
37703
37704
37705
37706
37707
37708
37709
37710
37711
37712
37713
37714
37715
37716
37717
37718
37719
37720
37721
37722
37723
37724
37725
37726
37727
37728
37729
37730
37731
37732
37733
37734
37735
37736
37737
37738
37739
37740
37741
37742
37743
37744
37745
37746
37747
37748
37749
37750
37751
37752
37753
37754
37755
37756
37757
37758
37759
37760
37761
37762
37763
37764
37765
37766
37767
37768
37769
37770
37771
37772
37773
37774
37775
37776
37777
37778
37779
37780
37781
37782
37783
37784
37785
37786
37787
37788
37789
37790
37791
37792
37793
37794
37795
37796
37797
37798
37799
37800
37801
37802
37803
37804
37805
37806
37807
37808
37809
37810
37811
37812
37813
37814
37815
37816
37817
37818
37819
37820
37821
37822
37823
37824
37825
37826
37827
37828
37829
37830
37831
37832
37833
37834
37835
37836
37837
37838
37839
37840
37841
37842
37843
37844
37845
37846
37847
37848
37849
37850
37851
37852
37853
37854
37855
37856
37857
37858
37859
37860
37861
37862
37863
37864
37865
37866
37867
37868
37869
37870
37871
37872
37873
37874
37875
37876
37877
37878
37879
37880
37881
37882
37883
37884
37885
37886
37887
37888
37889
37890
37891
37892
37893
37894
37895
37896
37897
37898
37899
37900
37901
37902
37903
37904
37905
37906
37907
37908
37909
37910
37911
37912
37913
37914
37915
37916
37917
37918
37919
37920
37921
37922
37923
37924
37925
37926
37927
37928
37929
37930
37931
37932
37933
37934
37935
37936
37937
37938
37939
37940
37941
37942
37943
37944
37945
37946
37947
37948
37949
37950
37951
37952
37953
37954
37955
37956
37957
37958
37959
37960
37961
37962
37963
37964
37965
37966
37967
37968
37969
37970
37971
37972
37973
37974
37975
37976
37977
37978
37979
37980
37981
37982
37983
37984
37985
37986
37987
37988
37989
37990
37991
37992
37993
37994
37995
37996
37997
37998
37999
38000
38001
38002
38003
38004
38005
38006
38007
38008
38009
38010
38011
38012
38013
38014
38015
38016
38017
38018
38019
38020
38021
38022
38023
38024
38025
38026
38027
38028
38029
38030
38031
38032
38033
38034
38035
38036
38037
38038
38039
38040
38041
38042
38043
38044
38045
38046
38047
38048
38049
38050
38051
38052
38053
38054
38055
38056
38057
38058
38059
38060
38061
38062
38063
38064
38065
38066
38067
38068
38069
38070
38071
38072
38073
38074
38075
38076
38077
38078
38079
38080
38081
38082
38083
38084
38085
38086
38087
38088
38089
38090
38091
38092
38093
38094
38095
38096
38097
38098
38099
38100
38101
38102
38103
38104
38105
38106
38107
38108
38109
38110
38111
38112
38113
38114
38115
38116
38117
38118
38119
38120
38121
38122
38123
38124
38125
38126
38127
38128
38129
38130
38131
38132
38133
38134
38135
38136
38137
38138
38139
38140
38141
38142
38143
38144
38145
38146
38147
38148
38149
38150
38151
38152
38153
38154
38155
38156
38157
38158
38159
38160
38161
38162
38163
38164
38165
38166
38167
38168
38169
38170
38171
38172
38173
38174
38175
38176
38177
38178
38179
38180
38181
38182
38183
38184
38185
38186
38187
38188
38189
38190
38191
38192
38193
38194
38195
38196
38197
38198
38199
38200
38201
38202
38203
38204
38205
38206
38207
38208
38209
38210
38211
38212
38213
38214
38215
38216
38217
38218
38219
38220
38221
38222
38223
38224
38225
38226
38227
38228
38229
38230
38231
38232
38233
38234
38235
38236
38237
38238
38239
38240
38241
38242
38243
38244
38245
38246
38247
38248
38249
38250
38251
38252
38253
38254
38255
38256
38257
38258
38259
38260
38261
38262
38263
38264
38265
38266
38267
38268
38269
38270
38271
38272
38273
38274
38275
38276
38277
38278
38279
38280
38281
38282
38283
38284
38285
38286
38287
38288
38289
38290
38291
38292
38293
38294
38295
38296
38297
38298
38299
38300
38301
38302
38303
38304
38305
38306
38307
38308
38309
38310
38311
38312
38313
38314
38315
38316
38317
38318
38319
38320
38321
38322
38323
38324
38325
38326
38327
38328
38329
38330
38331
38332
38333
38334
38335
38336
38337
38338
38339
38340
38341
38342
38343
38344
38345
38346
38347
38348
38349
38350
38351
38352
38353
38354
38355
38356
38357
38358
38359
38360
38361
38362
38363
38364
38365
38366
38367
38368
38369
38370
38371
38372
38373
38374
38375
38376
38377
38378
38379
38380
38381
38382
38383
38384
38385
38386
38387
38388
38389
38390
38391
38392
38393
38394
38395
38396
38397
38398
38399
38400
38401
38402
38403
38404
38405
38406
38407
38408
38409
38410
38411
38412
38413
38414
38415
38416
38417
38418
38419
38420
38421
38422
38423
38424
38425
38426
38427
38428
38429
38430
38431
38432
38433
38434
38435
38436
38437
38438
38439
38440
38441
38442
38443
38444
38445
38446
38447
38448
38449
38450
38451
38452
38453
38454
38455
38456
38457
38458
38459
38460
38461
38462
38463
38464
38465
38466
38467
38468
38469
38470
38471
38472
38473
38474
38475
38476
38477
38478
38479
38480
38481
38482
38483
38484
38485
38486
38487
38488
38489
38490
38491
38492
38493
38494
38495
38496
38497
38498
38499
38500
38501
38502
38503
38504
38505
38506
38507
38508
38509
38510
38511
38512
38513
38514
38515
38516
38517
38518
38519
38520
38521
38522
38523
38524
38525
38526
38527
38528
38529
38530
38531
38532
38533
38534
38535
38536
38537
38538
38539
38540
38541
38542
38543
38544
38545
38546
38547
38548
38549
38550
38551
38552
38553
38554
38555
38556
38557
38558
38559
38560
38561
38562
38563
38564
38565
38566
38567
38568
38569
38570
38571
38572
38573
38574
38575
38576
38577
38578
38579
38580
38581
38582
38583
38584
38585
38586
38587
38588
38589
38590
38591
38592
38593
38594
38595
38596
38597
38598
38599
38600
38601
38602
38603
38604
38605
38606
38607
38608
38609
38610
38611
38612
38613
38614
38615
38616
38617
38618
38619
38620
38621
38622
38623
38624
38625
38626
38627
38628
38629
38630
38631
38632
38633
38634
38635
38636
38637
38638
38639
38640
38641
38642
38643
38644
38645
38646
38647
38648
38649
38650
38651
38652
38653
38654
38655
38656
38657
38658
38659
38660
38661
38662
38663
38664
38665
38666
38667
38668
38669
38670
38671
38672
38673
38674
38675
38676
38677
38678
38679
38680
38681
38682
38683
38684
38685
38686
38687
38688
38689
38690
38691
38692
38693
38694
38695
38696
38697
38698
38699
38700
38701
38702
38703
38704
38705
38706
38707
38708
38709
38710
38711
38712
38713
38714
38715
38716
38717
38718
38719
38720
38721
38722
38723
38724
38725
38726
38727
38728
38729
38730
38731
38732
38733
38734
38735
38736
38737
38738
38739
38740
38741
38742
38743
38744
38745
38746
38747
38748
38749
38750
38751
38752
38753
38754
38755
38756
38757
38758
38759
38760
38761
38762
38763
38764
38765
38766
38767
38768
38769
38770
38771
38772
38773
38774
38775
38776
38777
38778
38779
38780
38781
38782
38783
38784
38785
38786
38787
38788
38789
38790
38791
38792
38793
38794
38795
38796
38797
38798
38799
38800
38801
38802
38803
38804
38805
38806
38807
38808
38809
38810
38811
38812
38813
38814
38815
38816
38817
38818
38819
38820
38821
38822
38823
38824
38825
38826
38827
38828
38829
38830
38831
38832
38833
38834
38835
38836
38837
38838
38839
38840
38841
38842
38843
38844
38845
38846
38847
38848
38849
38850
38851
38852
38853
38854
38855
38856
38857
38858
38859
38860
38861
38862
38863
38864
38865
38866
38867
38868
38869
38870
38871
38872
38873
38874
38875
38876
38877
38878
38879
38880
38881
38882
38883
38884
38885
38886
38887
38888
38889
38890
38891
38892
38893
38894
38895
38896
38897
38898
38899
38900
38901
38902
38903
38904
38905
38906
38907
38908
38909
38910
38911
38912
38913
38914
38915
38916
38917
38918
38919
38920
38921
38922
38923
38924
38925
38926
38927
38928
38929
38930
38931
38932
38933
38934
38935
38936
38937
38938
38939
38940
38941
38942
38943
38944
38945
38946
38947
38948
38949
38950
38951
38952
38953
38954
38955
38956
38957
38958
38959
38960
38961
38962
38963
38964
38965
38966
38967
38968
38969
38970
38971
38972
38973
38974
38975
38976
38977
38978
38979
38980
38981
38982
38983
38984
38985
38986
38987
38988
38989
38990
38991
38992
38993
38994
38995
38996
38997
38998
38999
39000
39001
39002
39003
39004
39005
39006
39007
39008
39009
39010
39011
39012
39013
39014
39015
39016
39017
39018
39019
39020
39021
39022
39023
39024
39025
39026
39027
39028
39029
39030
39031
39032
39033
39034
39035
39036
39037
39038
39039
39040
39041
39042
39043
39044
39045
39046
39047
39048
39049
39050
39051
39052
39053
39054
39055
39056
39057
39058
39059
39060
39061
39062
39063
39064
39065
39066
39067
39068
39069
39070
39071
39072
39073
39074
39075
39076
39077
39078
39079
39080
39081
39082
39083
39084
39085
39086
39087
39088
39089
39090
39091
39092
39093
39094
39095
39096
39097
39098
39099
39100
39101
39102
39103
39104
39105
39106
39107
39108
39109
39110
39111
39112
39113
39114
39115
39116
39117
39118
39119
39120
39121
39122
39123
39124
39125
39126
39127
39128
39129
39130
39131
39132
39133
39134
39135
39136
39137
39138
39139
39140
39141
39142
39143
39144
39145
39146
39147
39148
39149
39150
39151
39152
39153
39154
39155
39156
39157
39158
39159
39160
39161
39162
39163
39164
39165
39166
39167
39168
39169
39170
39171
39172
39173
39174
39175
39176
39177
39178
39179
39180
39181
39182
39183
39184
39185
39186
39187
39188
39189
39190
39191
39192
39193
39194
39195
39196
39197
39198
39199
39200
39201
39202
39203
39204
39205
39206
39207
39208
39209
39210
39211
39212
39213
39214
39215
39216
39217
39218
39219
39220
39221
39222
39223
39224
39225
39226
39227
39228
39229
39230
39231
39232
39233
39234
39235
39236
39237
39238
39239
39240
39241
39242
39243
39244
39245
39246
39247
39248
39249
39250
39251
39252
39253
39254
39255
39256
39257
39258
39259
39260
39261
39262
39263
39264
39265
39266
39267
39268
39269
39270
39271
39272
39273
39274
39275
39276
39277
39278
39279
39280
39281
39282
39283
39284
39285
39286
39287
39288
39289
39290
39291
39292
39293
39294
39295
39296
39297
39298
39299
39300
39301
39302
39303
39304
39305
39306
39307
39308
39309
39310
39311
39312
39313
39314
39315
39316
39317
39318
39319
39320
39321
39322
39323
39324
39325
39326
39327
39328
39329
39330
39331
39332
39333
39334
39335
39336
39337
39338
39339
39340
39341
39342
39343
39344
39345
39346
39347
39348
39349
39350
39351
39352
39353
39354
39355
39356
39357
39358
39359
39360
39361
39362
39363
39364
39365
39366
39367
39368
39369
39370
39371
39372
39373
39374
39375
39376
39377
39378
39379
39380
39381
39382
39383
39384
39385
39386
39387
39388
39389
39390
39391
39392
39393
39394
39395
39396
39397
39398
39399
39400
39401
39402
39403
39404
39405
39406
39407
39408
39409
39410
39411
39412
39413
39414
39415
39416
39417
39418
39419
39420
39421
39422
39423
39424
39425
39426
39427
39428
39429
39430
39431
39432
39433
39434
39435
39436
39437
39438
39439
39440
39441
39442
39443
39444
39445
39446
39447
39448
39449
39450
39451
39452
39453
39454
39455
39456
39457
39458
39459
39460
39461
39462
39463
39464
39465
39466
39467
39468
39469
39470
39471
39472
39473
39474
39475
39476
39477
39478
39479
39480
39481
39482
39483
39484
39485
39486
39487
39488
39489
39490
39491
39492
39493
39494
39495
39496
39497
39498
39499
39500
39501
39502
39503
39504
39505
39506
39507
39508
39509
39510
39511
39512
39513
39514
39515
39516
39517
39518
39519
39520
39521
39522
39523
39524
39525
39526
39527
39528
39529
39530
39531
39532
39533
39534
39535
39536
39537
39538
39539
39540
39541
39542
39543
39544
39545
39546
39547
39548
39549
39550
39551
39552
39553
39554
39555
39556
39557
39558
39559
39560
39561
39562
39563
39564
39565
39566
39567
39568
39569
39570
39571
39572
39573
39574
39575
39576
39577
39578
39579
39580
39581
39582
39583
39584
39585
39586
39587
39588
39589
39590
39591
39592
39593
39594
39595
39596
39597
39598
39599
39600
39601
39602
39603
39604
39605
39606
39607
39608
39609
39610
39611
39612
39613
39614
39615
39616
39617
39618
39619
39620
39621
39622
39623
39624
39625
39626
39627
39628
39629
39630
39631
39632
39633
39634
39635
39636
39637
39638
39639
39640
39641
39642
39643
39644
39645
39646
39647
39648
39649
39650
39651
39652
39653
39654
39655
39656
39657
39658
39659
39660
39661
39662
39663
39664
39665
39666
39667
39668
39669
39670
39671
39672
39673
39674
39675
39676
39677
39678
39679
39680
39681
39682
39683
39684
39685
39686
39687
39688
39689
39690
39691
39692
39693
39694
39695
39696
39697
39698
39699
39700
39701
39702
39703
39704
39705
39706
39707
39708
39709
39710
39711
39712
39713
39714
39715
39716
39717
39718
39719
39720
39721
39722
39723
39724
39725
39726
39727
39728
39729
39730
39731
39732
39733
39734
39735
39736
39737
39738
39739
39740
39741
39742
39743
39744
39745
39746
39747
39748
39749
39750
39751
39752
39753
39754
39755
39756
39757
39758
39759
39760
39761
39762
39763
39764
39765
39766
39767
39768
39769
39770
39771
39772
39773
39774
39775
39776
39777
39778
39779
39780
39781
39782
39783
39784
39785
39786
39787
39788
39789
39790
39791
39792
39793
39794
39795
39796
39797
39798
39799
39800
39801
39802
39803
39804
39805
39806
39807
39808
39809
39810
39811
39812
39813
39814
39815
39816
39817
39818
39819
39820
39821
39822
39823
39824
39825
39826
39827
39828
39829
39830
39831
39832
39833
39834
39835
39836
39837
39838
39839
39840
39841
39842
39843
39844
39845
39846
39847
39848
39849
39850
39851
39852
39853
39854
39855
39856
39857
39858
39859
39860
39861
39862
39863
39864
39865
39866
39867
39868
39869
39870
39871
39872
39873
39874
39875
39876
39877
39878
39879
39880
39881
39882
39883
39884
39885
39886
39887
39888
39889
39890
39891
39892
39893
39894
39895
39896
39897
39898
39899
39900
39901
39902
39903
39904
39905
39906
39907
39908
39909
39910
39911
39912
39913
39914
39915
39916
39917
39918
39919
39920
39921
39922
39923
39924
39925
39926
39927
39928
39929
39930
39931
39932
39933
39934
39935
39936
39937
39938
39939
39940
39941
39942
39943
39944
39945
39946
39947
39948
39949
39950
39951
39952
39953
39954
39955
39956
39957
39958
39959
39960
39961
39962
39963
39964
39965
39966
39967
39968
39969
39970
39971
39972
39973
39974
39975
39976
39977
39978
39979
39980
39981
39982
39983
39984
39985
39986
39987
39988
39989
39990
39991
39992
39993
39994
39995
39996
39997
39998
39999
40000
40001
40002
40003
40004
40005
40006
40007
40008
40009
40010
40011
40012
40013
40014
40015
40016
40017
40018
40019
40020
40021
40022
40023
40024
40025
40026
40027
40028
40029
40030
40031
40032
40033
40034
40035
40036
40037
40038
40039
40040
40041
40042
40043
40044
40045
40046
40047
40048
40049
40050
40051
40052
40053
40054
40055
40056
40057
40058
40059
40060
40061
40062
40063
40064
40065
40066
40067
40068
40069
40070
40071
40072
40073
40074
40075
40076
40077
40078
40079
40080
40081
40082
40083
40084
40085
40086
40087
40088
40089
40090
40091
40092
40093
40094
40095
40096
40097
40098
40099
40100
40101
40102
40103
40104
40105
40106
40107
40108
40109
40110
40111
40112
40113
40114
40115
40116
40117
40118
40119
40120
40121
40122
40123
40124
40125
40126
40127
40128
40129
40130
40131
40132
40133
40134
40135
40136
40137
40138
40139
40140
40141
40142
40143
40144
40145
40146
40147
40148
40149
40150
40151
40152
40153
40154
40155
40156
40157
40158
40159
40160
40161
40162
40163
40164
40165
40166
40167
40168
40169
40170
40171
40172
40173
40174
40175
40176
40177
40178
40179
40180
40181
40182
40183
40184
40185
40186
40187
40188
40189
40190
40191
40192
40193
40194
40195
40196
40197
40198
40199
40200
40201
40202
40203
40204
40205
40206
40207
40208
40209
40210
40211
40212
40213
40214
40215
40216
40217
40218
40219
40220
40221
40222
40223
40224
40225
40226
40227
40228
40229
40230
40231
40232
40233
40234
40235
40236
40237
40238
40239
40240
40241
40242
40243
40244
40245
40246
40247
40248
40249
40250
40251
40252
40253
40254
40255
40256
40257
40258
40259
40260
40261
40262
40263
40264
40265
40266
40267
40268
40269
40270
40271
40272
40273
40274
40275
40276
40277
40278
40279
40280
40281
40282
40283
40284
40285
40286
40287
40288
40289
40290
40291
40292
40293
40294
40295
40296
40297
40298
40299
40300
40301
40302
40303
40304
40305
40306
40307
40308
40309
40310
40311
40312
40313
40314
40315
40316
40317
40318
40319
40320
40321
40322
40323
40324
40325
40326
40327
40328
40329
40330
40331
40332
40333
40334
40335
40336
40337
40338
40339
40340
40341
40342
40343
40344
40345
40346
40347
40348
40349
40350
40351
40352
40353
40354
40355
40356
40357
40358
40359
40360
40361
40362
40363
40364
40365
40366
40367
40368
40369
40370
40371
40372
40373
40374
40375
40376
40377
40378
40379
40380
40381
40382
40383
40384
40385
40386
40387
40388
40389
40390
40391
40392
40393
40394
40395
40396
40397
40398
40399
40400
40401
40402
40403
40404
40405
40406
40407
40408
40409
40410
40411
40412
40413
40414
40415
40416
40417
40418
40419
40420
40421
40422
40423
40424
40425
40426
40427
40428
40429
40430
40431
40432
40433
40434
40435
40436
40437
40438
40439
40440
40441
40442
40443
40444
40445
40446
40447
40448
40449
40450
40451
40452
40453
40454
40455
40456
40457
40458
40459
40460
40461
40462
40463
40464
40465
40466
40467
40468
40469
40470
40471
40472
40473
40474
40475
40476
40477
40478
40479
40480
40481
40482
40483
40484
40485
40486
40487
40488
40489
40490
40491
40492
40493
40494
40495
40496
40497
40498
40499
40500
40501
40502
40503
40504
40505
40506
40507
40508
40509
40510
40511
40512
40513
40514
40515
40516
40517
40518
40519
40520
40521
40522
40523
40524
40525
40526
40527
40528
40529
40530
40531
40532
40533
40534
40535
40536
40537
40538
40539
40540
40541
40542
40543
40544
40545
40546
40547
40548
40549
40550
40551
40552
40553
40554
40555
40556
40557
40558
40559
40560
40561
40562
40563
40564
40565
40566
40567
40568
40569
40570
40571
40572
40573
40574
40575
40576
40577
40578
40579
40580
40581
40582
40583
40584
40585
40586
40587
40588
40589
40590
40591
40592
40593
40594
40595
40596
40597
40598
40599
40600
40601
40602
40603
40604
40605
40606
40607
40608
40609
40610
40611
40612
40613
40614
40615
40616
40617
40618
40619
40620
40621
40622
40623
40624
40625
40626
40627
40628
40629
40630
40631
40632
40633
40634
40635
40636
40637
40638
40639
40640
40641
40642
40643
40644
40645
40646
40647
40648
40649
40650
40651
40652
40653
40654
40655
40656
40657
40658
40659
40660
40661
40662
40663
40664
40665
40666
40667
40668
40669
40670
40671
40672
40673
40674
40675
40676
40677
40678
40679
40680
40681
40682
40683
40684
40685
40686
40687
40688
40689
40690
40691
40692
40693
40694
40695
40696
40697
40698
40699
40700
40701
40702
40703
40704
40705
40706
40707
40708
40709
40710
40711
40712
40713
40714
40715
40716
40717
40718
40719
40720
40721
40722
40723
40724
40725
40726
40727
40728
40729
40730
40731
40732
40733
40734
40735
40736
40737
40738
40739
40740
40741
40742
40743
40744
40745
40746
40747
40748
40749
40750
40751
40752
40753
40754
40755
40756
40757
40758
40759
40760
40761
40762
40763
40764
40765
40766
40767
40768
40769
40770
40771
40772
40773
40774
40775
40776
40777
40778
40779
40780
40781
40782
40783
40784
40785
40786
40787
40788
40789
40790
40791
40792
40793
40794
40795
40796
40797
40798
40799
40800
40801
40802
40803
40804
40805
40806
40807
40808
40809
40810
40811
40812
40813
40814
40815
40816
40817
40818
40819
40820
40821
40822
40823
40824
40825
40826
40827
40828
40829
40830
40831
40832
40833
40834
40835
40836
40837
40838
40839
40840
40841
40842
40843
40844
40845
40846
40847
40848
40849
40850
40851
40852
40853
40854
40855
40856
40857
40858
40859
40860
40861
40862
40863
40864
40865
40866
40867
40868
40869
40870
40871
40872
40873
40874
40875
40876
40877
40878
40879
40880
40881
40882
40883
40884
40885
40886
40887
40888
40889
40890
40891
40892
40893
40894
40895
40896
40897
40898
40899
40900
40901
40902
40903
40904
40905
40906
40907
40908
40909
40910
40911
40912
40913
40914
40915
40916
40917
40918
40919
40920
40921
40922
40923
40924
40925
40926
40927
40928
40929
40930
40931
40932
40933
40934
40935
40936
40937
40938
40939
40940
40941
40942
40943
40944
40945
40946
40947
40948
40949
40950
40951
40952
40953
40954
40955
40956
40957
40958
40959
40960
40961
40962
40963
40964
40965
40966
40967
40968
40969
40970
40971
40972
40973
40974
40975
40976
40977
40978
40979
40980
40981
40982
40983
40984
40985
40986
40987
40988
40989
40990
40991
40992
40993
40994
40995
40996
40997
40998
40999
41000
41001
41002
41003
41004
41005
41006
41007
41008
41009
41010
41011
41012
41013
41014
41015
41016
41017
41018
41019
41020
41021
41022
41023
41024
41025
41026
41027
41028
41029
41030
41031
41032
41033
41034
41035
41036
41037
41038
41039
41040
41041
41042
41043
41044
41045
41046
41047
41048
41049
41050
41051
41052
41053
41054
41055
41056
41057
41058
41059
41060
41061
41062
41063
41064
41065
41066
41067
41068
41069
41070
41071
41072
41073
41074
41075
41076
41077
41078
41079
41080
41081
41082
41083
41084
41085
41086
41087
41088
41089
41090
41091
41092
41093
41094
41095
41096
41097
41098
41099
41100
41101
41102
41103
41104
41105
41106
41107
41108
41109
41110
41111
41112
41113
41114
41115
41116
41117
41118
41119
41120
41121
41122
41123
41124
41125
41126
41127
41128
41129
41130
41131
41132
41133
41134
41135
41136
41137
41138
41139
41140
41141
41142
41143
41144
41145
41146
41147
41148
41149
41150
41151
41152
41153
41154
41155
41156
41157
41158
41159
41160
41161
41162
41163
41164
41165
41166
41167
41168
41169
41170
41171
41172
41173
41174
41175
41176
41177
41178
41179
41180
41181
41182
41183
41184
41185
41186
41187
41188
41189
41190
41191
41192
41193
41194
41195
41196
41197
41198
41199
41200
41201
41202
41203
41204
41205
41206
41207
41208
41209
41210
41211
41212
41213
41214
41215
41216
41217
41218
41219
41220
41221
41222
41223
41224
41225
41226
41227
41228
41229
41230
41231
41232
41233
41234
41235
41236
41237
41238
41239
41240
41241
41242
41243
41244
41245
41246
41247
41248
41249
41250
41251
41252
41253
41254
41255
41256
41257
41258
41259
41260
41261
41262
41263
41264
41265
41266
41267
41268
41269
41270
41271
41272
41273
41274
41275
41276
41277
41278
41279
41280
41281
41282
41283
41284
41285
41286
41287
41288
41289
41290
41291
41292
41293
41294
41295
41296
41297
41298
41299
41300
41301
41302
41303
41304
41305
41306
41307
41308
41309
41310
41311
41312
41313
41314
41315
41316
41317
41318
41319
41320
41321
41322
41323
41324
41325
41326
41327
41328
41329
41330
41331
41332
41333
41334
41335
41336
41337
41338
41339
41340
41341
41342
41343
41344
41345
41346
41347
41348
41349
41350
41351
41352
41353
41354
41355
41356
41357
41358
41359
41360
41361
41362
41363
41364
41365
41366
41367
41368
41369
41370
41371
41372
41373
41374
41375
41376
41377
41378
41379
41380
41381
41382
41383
41384
41385
41386
41387
41388
41389
41390
41391
41392
41393
41394
41395
41396
41397
41398
41399
41400
41401
41402
41403
41404
41405
41406
41407
41408
41409
41410
41411
41412
41413
41414
41415
41416
41417
41418
41419
41420
41421
41422
41423
41424
41425
41426
41427
41428
41429
41430
41431
41432
41433
41434
41435
41436
41437
41438
41439
41440
41441
41442
41443
41444
41445
41446
41447
41448
41449
41450
41451
41452
41453
41454
41455
41456
41457
41458
41459
41460
41461
41462
41463
41464
41465
41466
41467
41468
41469
41470
41471
41472
41473
41474
41475
41476
41477
41478
41479
41480
41481
41482
41483
41484
41485
41486
41487
41488
41489
41490
41491
41492
41493
41494
41495
41496
41497
41498
41499
41500
41501
41502
41503
41504
41505
41506
41507
41508
41509
41510
41511
41512
41513
41514
41515
41516
41517
41518
41519
41520
41521
41522
41523
41524
41525
41526
41527
41528
41529
41530
41531
41532
41533
41534
41535
41536
41537
41538
41539
41540
41541
41542
41543
41544
41545
41546
41547
41548
41549
41550
41551
41552
41553
41554
41555
41556
41557
41558
41559
41560
41561
41562
41563
41564
41565
41566
41567
41568
41569
41570
41571
41572
41573
41574
41575
41576
41577
41578
41579
41580
41581
41582
41583
41584
41585
41586
41587
41588
41589
41590
41591
41592
41593
41594
41595
41596
41597
41598
41599
41600
41601
41602
41603
41604
41605
41606
41607
41608
41609
41610
41611
41612
41613
41614
41615
41616
41617
41618
41619
41620
41621
41622
41623
41624
41625
41626
41627
41628
41629
41630
41631
41632
41633
41634
41635
41636
41637
41638
41639
41640
41641
41642
41643
41644
41645
41646
41647
41648
41649
41650
41651
41652
41653
41654
41655
41656
41657
41658
41659
41660
41661
41662
41663
41664
41665
41666
41667
41668
41669
41670
41671
41672
41673
41674
41675
41676
41677
41678
41679
41680
41681
41682
41683
41684
41685
41686
41687
41688
41689
41690
41691
41692
41693
41694
41695
41696
41697
41698
41699
41700
41701
41702
41703
41704
41705
41706
41707
41708
41709
41710
41711
41712
41713
41714
41715
41716
41717
41718
41719
41720
41721
41722
41723
41724
41725
41726
41727
41728
41729
41730
41731
41732
41733
41734
41735
41736
41737
41738
41739
41740
41741
41742
41743
41744
41745
41746
41747
41748
41749
41750
41751
41752
41753
41754
41755
41756
41757
41758
41759
41760
41761
41762
41763
41764
41765
41766
41767
41768
41769
41770
41771
41772
41773
41774
41775
41776
41777
41778
41779
41780
41781
41782
41783
41784
41785
41786
41787
41788
41789
41790
41791
41792
41793
41794
41795
41796
41797
41798
41799
41800
41801
41802
41803
41804
41805
41806
41807
41808
41809
41810
41811
41812
41813
41814
41815
41816
41817
41818
41819
41820
41821
41822
41823
41824
41825
41826
41827
41828
41829
41830
41831
41832
41833
41834
41835
41836
41837
41838
41839
41840
41841
41842
41843
41844
41845
41846
41847
41848
41849
41850
41851
41852
41853
41854
41855
41856
41857
41858
41859
41860
41861
41862
41863
41864
41865
41866
41867
41868
41869
41870
41871
41872
41873
41874
41875
41876
41877
41878
41879
41880
41881
41882
41883
41884
41885
41886
41887
41888
41889
41890
41891
41892
41893
41894
41895
41896
41897
41898
41899
41900
41901
41902
41903
41904
41905
41906
41907
41908
41909
41910
41911
41912
41913
41914
41915
41916
41917
41918
41919
41920
41921
41922
41923
41924
41925
41926
41927
41928
41929
41930
41931
41932
41933
41934
41935
41936
41937
41938
41939
41940
41941
41942
41943
41944
41945
41946
41947
41948
41949
41950
41951
41952
41953
41954
41955
41956
41957
41958
41959
41960
41961
41962
41963
41964
41965
41966
41967
41968
41969
41970
41971
41972
41973
41974
41975
41976
41977
41978
41979
41980
41981
41982
41983
41984
41985
41986
41987
41988
41989
41990
41991
41992
41993
41994
41995
41996
41997
41998
41999
42000
42001
42002
42003
42004
42005
42006
42007
42008
42009
42010
42011
42012
42013
42014
42015
42016
42017
42018
42019
42020
42021
42022
42023
42024
42025
42026
42027
42028
42029
42030
42031
42032
42033
42034
42035
42036
42037
42038
42039
42040
42041
42042
42043
42044
42045
42046
42047
42048
42049
42050
42051
42052
42053
42054
42055
42056
42057
42058
42059
42060
42061
42062
42063
42064
42065
42066
42067
42068
42069
42070
42071
42072
42073
42074
42075
42076
42077
42078
42079
42080
42081
42082
42083
42084
42085
42086
42087
42088
42089
42090
42091
42092
42093
42094
42095
42096
42097
42098
42099
42100
42101
42102
42103
42104
42105
42106
42107
42108
42109
42110
42111
42112
42113
42114
42115
42116
42117
42118
42119
42120
42121
42122
42123
42124
42125
42126
42127
42128
42129
42130
42131
42132
42133
42134
42135
42136
42137
42138
42139
42140
42141
42142
42143
42144
42145
42146
42147
42148
42149
42150
42151
42152
42153
42154
42155
42156
42157
42158
42159
42160
42161
42162
42163
42164
42165
42166
42167
42168
42169
42170
42171
42172
42173
42174
42175
42176
42177
42178
42179
42180
42181
42182
42183
42184
42185
42186
42187
42188
42189
42190
42191
42192
42193
42194
42195
42196
42197
42198
42199
42200
42201
42202
42203
42204
42205
42206
42207
42208
42209
42210
42211
42212
42213
42214
42215
42216
42217
42218
42219
42220
42221
42222
42223
42224
42225
42226
42227
42228
42229
42230
42231
42232
42233
42234
42235
42236
42237
42238
42239
42240
42241
42242
42243
42244
42245
42246
42247
42248
42249
42250
42251
42252
42253
42254
42255
42256
42257
42258
42259
42260
42261
42262
42263
42264
42265
42266
42267
42268
42269
42270
42271
42272
42273
42274
42275
42276
42277
42278
42279
42280
42281
42282
42283
42284
42285
42286
42287
42288
42289
42290
42291
42292
42293
42294
42295
42296
42297
42298
42299
42300
42301
42302
42303
42304
42305
42306
42307
42308
42309
42310
42311
42312
42313
42314
42315
42316
42317
42318
42319
42320
42321
42322
42323
42324
42325
42326
42327
42328
42329
42330
42331
42332
42333
42334
42335
42336
42337
42338
42339
42340
42341
42342
42343
42344
42345
42346
42347
42348
42349
42350
42351
42352
42353
42354
42355
42356
42357
42358
42359
42360
42361
42362
42363
42364
42365
42366
42367
42368
42369
42370
42371
42372
42373
42374
42375
42376
42377
42378
42379
42380
42381
42382
42383
42384
42385
42386
42387
42388
42389
42390
42391
42392
42393
42394
42395
42396
42397
42398
42399
42400
42401
42402
42403
42404
42405
42406
42407
42408
42409
42410
42411
42412
42413
42414
42415
42416
42417
42418
42419
42420
42421
42422
42423
42424
42425
42426
42427
42428
42429
42430
42431
42432
42433
42434
42435
42436
42437
42438
42439
42440
42441
42442
42443
42444
42445
42446
42447
42448
42449
42450
42451
42452
42453
42454
42455
42456
42457
42458
42459
42460
42461
42462
42463
42464
42465
42466
42467
42468
42469
42470
42471
42472
42473
42474
42475
42476
42477
42478
42479
42480
42481
42482
42483
42484
42485
42486
42487
42488
42489
42490
42491
42492
42493
42494
42495
42496
42497
42498
42499
42500
42501
42502
42503
42504
42505
42506
42507
42508
42509
42510
42511
42512
42513
42514
42515
42516
42517
42518
42519
42520
42521
42522
42523
42524
42525
42526
42527
42528
42529
42530
42531
42532
42533
42534
42535
42536
42537
42538
42539
42540
42541
42542
42543
42544
42545
42546
42547
42548
42549
42550
42551
42552
42553
42554
42555
42556
42557
42558
42559
42560
42561
42562
42563
42564
42565
42566
42567
42568
42569
42570
42571
42572
42573
42574
42575
42576
42577
42578
42579
42580
42581
42582
42583
42584
42585
42586
42587
42588
42589
42590
42591
42592
42593
42594
42595
42596
42597
42598
42599
42600
42601
42602
42603
42604
42605
42606
42607
42608
42609
42610
42611
42612
42613
42614
42615
42616
42617
42618
42619
42620
42621
42622
42623
42624
42625
42626
42627
42628
42629
42630
42631
42632
42633
42634
42635
42636
42637
42638
42639
42640
42641
42642
42643
42644
42645
42646
42647
42648
42649
42650
42651
42652
42653
42654
42655
42656
42657
42658
42659
42660
42661
42662
42663
42664
42665
42666
42667
42668
42669
42670
42671
42672
42673
42674
42675
42676
42677
42678
42679
42680
42681
42682
42683
42684
42685
42686
42687
42688
42689
42690
42691
42692
42693
42694
42695
42696
42697
42698
42699
42700
42701
42702
42703
42704
42705
42706
42707
42708
42709
42710
42711
42712
42713
42714
42715
42716
42717
42718
42719
42720
42721
42722
42723
42724
42725
42726
42727
42728
42729
42730
42731
42732
42733
42734
42735
42736
42737
42738
42739
42740
42741
42742
42743
42744
42745
42746
42747
42748
42749
42750
42751
42752
42753
42754
42755
42756
42757
42758
42759
42760
42761
42762
42763
42764
42765
42766
42767
42768
42769
42770
42771
42772
42773
42774
42775
42776
42777
42778
42779
42780
42781
42782
42783
42784
42785
42786
42787
42788
42789
42790
42791
42792
42793
42794
42795
42796
42797
42798
42799
42800
42801
42802
42803
42804
42805
42806
42807
42808
42809
42810
42811
42812
42813
42814
42815
42816
42817
42818
42819
42820
42821
42822
42823
42824
42825
42826
42827
42828
42829
42830
42831
42832
42833
42834
42835
42836
42837
42838
42839
42840
42841
42842
42843
42844
42845
42846
42847
42848
42849
42850
42851
42852
42853
42854
42855
42856
42857
42858
42859
42860
42861
42862
42863
42864
42865
42866
42867
42868
42869
42870
42871
42872
42873
42874
42875
42876
42877
42878
42879
42880
42881
42882
42883
42884
42885
42886
42887
42888
42889
42890
42891
42892
42893
42894
42895
42896
42897
42898
42899
42900
42901
42902
42903
42904
42905
42906
42907
42908
42909
42910
42911
42912
42913
42914
42915
42916
42917
42918
42919
42920
42921
42922
42923
42924
42925
42926
42927
42928
42929
42930
42931
42932
42933
42934
42935
42936
42937
42938
42939
42940
42941
42942
42943
42944
42945
42946
42947
42948
42949
42950
42951
42952
42953
42954
42955
42956
42957
42958
42959
42960
42961
42962
42963
42964
42965
42966
42967
42968
42969
42970
42971
42972
42973
42974
42975
42976
42977
42978
42979
42980
42981
42982
42983
42984
42985
42986
42987
42988
42989
42990
42991
42992
42993
42994
42995
42996
42997
42998
42999
43000
43001
43002
43003
43004
43005
43006
43007
43008
43009
43010
43011
43012
43013
43014
43015
43016
43017
43018
43019
43020
43021
43022
43023
43024
43025
43026
43027
43028
43029
43030
43031
43032
43033
43034
43035
43036
43037
43038
43039
43040
43041
43042
43043
43044
43045
43046
43047
43048
43049
43050
43051
43052
43053
43054
43055
43056
43057
43058
43059
43060
43061
43062
43063
43064
43065
43066
43067
43068
43069
43070
43071
43072
43073
43074
43075
43076
43077
43078
43079
43080
43081
43082
43083
43084
43085
43086
43087
43088
43089
43090
43091
43092
43093
43094
43095
43096
43097
43098
43099
43100
43101
43102
43103
43104
43105
43106
43107
43108
43109
43110
43111
43112
43113
43114
43115
43116
43117
43118
43119
43120
43121
43122
43123
43124
43125
43126
43127
43128
43129
43130
43131
43132
43133
43134
43135
43136
43137
43138
43139
43140
43141
43142
43143
43144
43145
43146
43147
43148
43149
43150
43151
43152
43153
43154
43155
43156
43157
43158
43159
43160
43161
43162
43163
43164
43165
43166
43167
43168
43169
43170
43171
43172
43173
43174
43175
43176
43177
43178
43179
43180
43181
43182
43183
43184
43185
43186
43187
43188
43189
43190
43191
43192
43193
43194
43195
43196
43197
43198
43199
43200
43201
43202
43203
43204
43205
43206
43207
43208
43209
43210
43211
43212
43213
43214
43215
43216
43217
43218
43219
43220
43221
43222
43223
43224
43225
43226
43227
43228
43229
43230
43231
43232
43233
43234
43235
43236
43237
43238
43239
43240
43241
43242
43243
43244
43245
43246
43247
43248
43249
43250
43251
43252
43253
43254
43255
43256
43257
43258
43259
43260
43261
43262
43263
43264
43265
43266
43267
43268
43269
43270
43271
43272
43273
43274
43275
43276
43277
43278
43279
43280
43281
43282
43283
43284
43285
43286
43287
43288
43289
43290
43291
43292
43293
43294
43295
43296
43297
43298
43299
43300
43301
43302
43303
43304
43305
43306
43307
43308
43309
43310
43311
43312
43313
43314
43315
43316
43317
43318
43319
43320
43321
43322
43323
43324
43325
43326
43327
43328
43329
43330
43331
43332
43333
43334
43335
43336
43337
43338
43339
43340
43341
43342
43343
43344
43345
43346
43347
43348
43349
43350
43351
43352
43353
43354
43355
43356
43357
43358
43359
43360
43361
43362
43363
43364
43365
43366
43367
43368
43369
43370
43371
43372
43373
43374
43375
43376
43377
43378
43379
43380
43381
43382
43383
43384
43385
43386
43387
43388
43389
43390
43391
43392
43393
43394
43395
43396
43397
43398
43399
43400
43401
43402
43403
43404
43405
43406
43407
43408
43409
43410
43411
43412
43413
43414
43415
43416
43417
43418
43419
43420
43421
43422
43423
43424
43425
43426
43427
43428
43429
43430
43431
43432
43433
43434
43435
43436
43437
43438
43439
43440
43441
43442
43443
43444
43445
43446
43447
43448
43449
43450
43451
43452
43453
43454
43455
43456
43457
43458
43459
43460
43461
43462
43463
43464
43465
43466
43467
43468
43469
43470
43471
43472
43473
43474
43475
43476
43477
43478
43479
43480
43481
43482
43483
43484
43485
43486
43487
43488
43489
43490
43491
43492
43493
43494
43495
43496
43497
43498
43499
43500
43501
43502
43503
43504
43505
43506
43507
43508
43509
43510
43511
43512
43513
43514
43515
43516
43517
43518
43519
43520
43521
43522
43523
43524
43525
43526
43527
43528
43529
43530
43531
43532
43533
43534
43535
43536
43537
43538
43539
43540
43541
43542
43543
43544
43545
43546
43547
43548
43549
43550
43551
43552
43553
43554
43555
43556
43557
43558
43559
43560
43561
43562
43563
43564
43565
43566
43567
43568
43569
43570
43571
43572
43573
43574
43575
43576
43577
43578
43579
43580
43581
43582
43583
43584
43585
43586
43587
43588
43589
43590
43591
43592
43593
43594
43595
43596
43597
43598
43599
43600
43601
43602
43603
43604
43605
43606
43607
43608
43609
43610
43611
43612
43613
43614
43615
43616
43617
43618
43619
43620
43621
43622
43623
43624
43625
43626
43627
43628
43629
43630
43631
43632
43633
43634
43635
43636
43637
43638
43639
43640
43641
43642
43643
43644
43645
43646
43647
43648
43649
43650
43651
43652
43653
43654
43655
43656
43657
43658
43659
43660
43661
43662
43663
43664
43665
43666
43667
43668
43669
43670
43671
43672
43673
43674
43675
43676
43677
43678
43679
43680
43681
43682
43683
43684
43685
43686
43687
43688
43689
43690
43691
43692
43693
43694
43695
43696
43697
43698
43699
43700
43701
43702
43703
43704
43705
43706
43707
43708
43709
43710
43711
43712
43713
43714
43715
43716
43717
43718
43719
43720
43721
43722
43723
43724
43725
43726
43727
43728
43729
43730
43731
43732
43733
43734
43735
43736
43737
43738
43739
43740
43741
43742
43743
43744
43745
43746
43747
43748
43749
43750
43751
43752
43753
43754
43755
43756
43757
43758
43759
43760
43761
43762
43763
43764
43765
43766
43767
43768
43769
43770
43771
43772
43773
43774
43775
43776
43777
43778
43779
43780
43781
43782
43783
43784
43785
43786
43787
43788
43789
43790
43791
43792
43793
43794
43795
43796
43797
43798
43799
43800
43801
43802
43803
43804
43805
43806
43807
43808
43809
43810
43811
43812
43813
43814
43815
43816
43817
43818
43819
43820
43821
43822
43823
43824
43825
43826
43827
43828
43829
43830
43831
43832
43833
43834
43835
43836
43837
43838
43839
43840
43841
43842
43843
43844
43845
43846
43847
43848
43849
43850
43851
43852
43853
diff --git a/.claude/rules/hook.md b/.claude/rules/hook.md
index 2f76a2bf0f3e04982dc758a8ade41b0cf3aab1f4..1a36f08bca755f9e8d9b4197e05e89e60cf598cc 100644
--- a/.claude/rules/hook.md
+++ b/.claude/rules/hook.md
@@ -10,6 +10,12 @@ paths:
   run-loop slice — a stopped watcher after grant once froze all input on the machine.
   Don't restructure it casually, and don't migrate the tap to `objc2-core-graphics`
   (the `NSWorkspace` read is the only part that moved to `objc2`).
+- The tap callback must never block and never panic: use `try_read`/`try_lock` only,
+  queue bound actions off-thread, wrap the user callback in `catch_unwind`, and keep
+  the stuck-callback watchdog that force-exits the agent if the budget is exceeded.
+  An active HID-level tap serialises every pointer event; a hang freezes clicks
+  machine-wide. Only suppress events from remappable Logitech sources
+  (`source_is_remappable`) — never the built-in trackpad.
 - The off-main `frontmost_bundle_id` read keeps its explicit `autoreleasepool` — the
   watcher thread has no run loop; that is the only place in this crate a pool belongs.
 - This crate ships non-macOS implementations (evdev/uinput, WH_MOUSE_LL) that a
diff --git a/.claude/rules/i18n.md b/.claude/rules/i18n.md
index 601abd129ca619a0060410866318a43caa130f04..21984a8d40fc3cc81b8df6dc180757453b88fbba 100644
--- a/.claude/rules/i18n.md
+++ b/.claude/rules/i18n.md
@@ -6,19 +6,25 @@ paths:
 
 # i18n (rust-i18n + Crowdin)
 
-- `locales/en.yml` is the source of truth (the English text IS the key); every other
-  `<code>.yml` is a flat `"English key": "translation"` map. The YAML is parsed at
-  **compile time** — a syntax error fails the entire GUI build. Quote values containing
-  `: ` or a trailing `:`.
-- The parity test (`i18n.rs`, `locale_files_have_the_same_keys`) compares **ordered**
-  key lists against `en.yml`. A new string must be inserted at the same position in
-  every locale file, all in the same change, or the test blocks the push.
-- When translating a new key, echo the file's existing wording for sibling terms
-  (e.g. match how it already renders "Middle Click").
+- **`locales/en.yml` is the only source of truth** for UI strings (the English
+  text IS the key). When adding or changing copy, edit **`en.yml` only**.
+- **Do not hand-edit** other `locales/<code>.yml` files for new strings. Crowdin
+  owns non-English catalogs; the Crowdin workflow downloads them into
+  `crowdin/i18n`. Untranslated keys fall back to English at runtime
+  (`rust_i18n` fallback `"en"`).
+- YAML is parsed at **compile time** — a syntax error fails the entire GUI
+  build. Quote values containing `: ` or a trailing `:`.
+- The locale key test (`i18n.rs`, `locale_files_keys_are_subset_of_en`) only
+  checks that non-English files do **not** invent keys missing from `en.yml`.
+  They may lag `en.yml` until Crowdin syncs; they no longer must match key-for-key
+  in the same change.
 - Adding a locale: drop the `.yml` in `locales/` and add the `SUPPORTED` entry in
-  `i18n.rs` (picker order: native-name alphabetical per script). The test derives the
-  locale list from both and asserts they match.
-- Check with `cargo test -p openlogi-gui i18n`. CI's Linux tests exclude the GUI, so
-  this runs on macOS CI and locally (needs the Xcode/Metal env from devenv).
-- Crowdin syncs `en.yml` (root `crowdin.yml`); hand-written translations for new keys
-  should be seeded into Crowdin, or the next download reverts them.
+  `i18n.rs` (picker order: native-name alphabetical per script). Keep the
+  include list in the subset test in sync.
+- Check with `cargo test -p openlogi-gui i18n`. CI's Linux tests exclude the GUI,
+  so this runs on macOS CI and locally (needs the Xcode/Metal env from devenv).
+- Crowdin workflow (root `crowdin.yml` + `.github/workflows/crowdin.yml`):
+  uploads **`en.yml` sources** and **per-language translations from git**, then
+  downloads Crowdin’s export. That seeds Crowdin so real de/ja/… strings are not
+  wiped by English fill-in, and brings translator progress back via
+  `crowdin/i18n`. Feature PRs still only need `en.yml` for new copy.
diff --git a/.github/actions/github-app-token-from-1password/action.yml b/.github/actions/github-app-token-from-1password/action.yml
index d7b43e53fa6e628383e46214f1dc3120cea7a0f9..f95450178db66ca479512ef2efba8711b6485255 100644
--- a/.github/actions/github-app-token-from-1password/action.yml
+++ b/.github/actions/github-app-token-from-1password/action.yml
@@ -41,7 +41,8 @@ runs:
 
     # The App private key is stored base64-encoded in 1Password (a raw PEM's
     # newlines get mangled to spaces on paste). Decode it here; base64 ignores
-    # whitespace, so it survives re-mangling.
+    # whitespace, so it survives re-mangling. Mask each PEM line so the runner
+    # does not echo the key when create-github-app-token logs its `with:` block.
     - name: Decode GitHub App private key
       id: app-key
       shell: bash
@@ -49,6 +50,11 @@ runs:
         APP_KEY_B64: ${{ steps.load-secrets.outputs.GITHUB_APP_PRIVATE_KEY }}
       run: |
         key="$(printf '%s' "$APP_KEY_B64" | tr -d '[:space:]' | base64 -d)"
+        while IFS= read -r line || [ -n "${line}" ]; do
+          if [ -n "${line}" ]; then
+            echo "::add-mask::${line}"
+          fi
+        done <<< "${key}"
         {
           echo 'pem<<__PEM__'
           printf '%s\n' "$key"
diff --git a/.github/workflows/crowdin.yml b/.github/workflows/crowdin.yml
index 575a854dfd332182c5ec3f852bc9380464bec9d5..3abd9cf5afbf8c09c862ef7a410c86f3ebc0bf00 100644
--- a/.github/workflows/crowdin.yml
+++ b/.github/workflows/crowdin.yml
@@ -8,9 +8,11 @@ on:
     branches:
       - master
     paths:
-      - crowdin.yml
+      # English source is SoT; non-English catalogs come from Crowdin only.
       - crates/openlogi-gui/locales/en.yml
+      - crowdin.yml
       - .github/workflows/crowdin.yml
+      - .github/actions/github-app-token-from-1password/**
 
 permissions:
   contents: read
@@ -26,8 +28,13 @@ jobs:
     if: github.repository == 'AprilNEA/OpenLogi'
 
     steps:
+      # persist-credentials must stay false: checkout's default GITHUB_TOKEN
+      # http.extraheader would win over the app token when crowdin/github-action
+      # pushes crowdin/i18n (403 as github-actions[bot] despite env GITHUB_TOKEN).
       - name: Checkout
         uses: actions/checkout@v6
+        with:
+          persist-credentials: false
 
       - name: Mint GitHub App token
         id: github_app
@@ -36,6 +43,13 @@ jobs:
           op-service-account-token: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
           op-github-app-item: ${{ secrets.OP_GITHUB_APP_ITEM }}
 
+      - name: Configure git for App token
+        env:
+          GH_TOKEN: ${{ steps.github_app.outputs.token }}
+        run: |
+          set -euo pipefail
+          git remote set-url origin "https://x-access-token:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
+
       - name: Load Crowdin credentials from 1Password
         id: crowdin_config
         uses: 1password/load-secrets-action@eb2efd0703da22a93c467f2d1ffbb6826c11e19c # v4.1.1
@@ -46,21 +60,32 @@ jobs:
           CROWDIN_PROJECT_ID: ${{ secrets.OP_CROWDIN_SECRET_ITEM }}/CROWDIN_PROJECT_ID
           CROWDIN_PERSONAL_TOKEN: ${{ secrets.OP_CROWDIN_SECRET_ITEM }}/CROWDIN_PERSONAL_TOKEN
 
+      # en.yml = English source of truth. Non-English catalogs in git are seeded
+      # into Crowdin (per language) so the download does not wipe real
+      # translations with English fill-in. Crowdin is where people improve
+      # translations; the bot PR brings their work back into the repo.
       - name: Synchronize with Crowdin
         uses: crowdin/github-action@c7af9bc98b01694653031fef2a0dc6c7888ce9bc # v2.17.0
         with:
           config: crowdin.yml
           upload_sources: true
-          upload_translations: false
+          # Seed each language from git so Crowdin learns existing translations
+          # (de/ja/…). import_eq_suggestions false: value==English is not a
+          # translation and must not overwrite Crowdin work as "done".
+          upload_translations: true
+          import_eq_suggestions: false
           download_translations: true
           localization_branch_name: crowdin/i18n
           commit_message: "chore(i18n): sync Crowdin translations"
           create_pull_request: true
           pull_request_title: "chore(i18n): sync Crowdin translations"
           pull_request_body: |
-            Automated translation sync from Crowdin.
+            Automated per-language translation sync from Crowdin.
 
-            This workflow is intentionally limited by `export_languages` in `crowdin.yml` so unfinished Crowdin target languages are not exported into the app.
+            - `en.yml` is the English source of truth (new UI strings go there).
+            - Existing non-English catalogs are uploaded to Crowdin first so real translations are not replaced with English fill-in.
+            - This PR is Crowdin → git for translated locales only (`export_languages` in `crowdin.yml`).
+            - Truly untranslated keys may still match English until translators finish them in Crowdin.
           github_user_name: Crowdin Bot
           github_user_email: support+bot@crowdin.com
         env:
diff --git a/.github/workflows/release-plz.yml b/.github/workflows/release-plz.yml
index cd12b90965c11803beeb542e664c17bfee8d486c..ec58fbaba9db1523ae0c7bd71af245eb97eae05f 100644
--- a/.github/workflows/release-plz.yml
+++ b/.github/workflows/release-plz.yml
@@ -58,6 +58,48 @@ jobs:
         env:
           GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
           CARGO_REGISTRY_TOKEN: ${{ steps.app-token.outputs.cargo-registry-token }}
+      # Whole-repo CHANGELOG via git-cliff (cliff.toml). release-plz is
+      # package-path-scoped and skips release=false app crates; git-cliff is the
+      # GoReleaser-style "every conventional commit since last tag" path.
+      - name: Write root changelog with git-cliff
+        env:
+          GH_TOKEN: ${{ steps.app-token.outputs.token }}
+        run: |
+          set -euo pipefail
+          branch="$(
+            gh pr list \
+              --repo "${{ github.repository }}" \
+              --state open \
+              --json headRefName \
+              --jq '.[] | select(.headRefName | startswith("release-plz/")) | .headRefName' \
+              | head -n1
+          )"
+          if [[ -z "${branch}" ]]; then
+            echo "No open release-plz PR — nothing to write."
+            exit 0
+          fi
+          git config user.name "aprilnea[bot]"
+          git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
+          git remote set-url origin "https://x-access-token:${GH_TOKEN}@github.com/${{ github.repository }}.git"
+          # Script/config may not be on the release-plz branch yet — copy from master.
+          cp cliff.toml "${RUNNER_TEMP}/cliff.toml"
+          cp scripts/release/write-changelog.sh "${RUNNER_TEMP}/write-changelog.sh"
+          chmod +x "${RUNNER_TEMP}/write-changelog.sh"
+          git fetch origin "${branch}"
+          git checkout --force "origin/${branch}"
+          cp "${RUNNER_TEMP}/cliff.toml" cliff.toml
+          # git-cliff: same binary release-plz uses under the hood for formatting.
+          curl -sL "https://github.com/orhun/git-cliff/releases/download/v2.13.1/git-cliff-2.13.1-x86_64-unknown-linux-gnu.tar.gz" \
+            | tar -xz -C "${RUNNER_TEMP}"
+          export PATH="${RUNNER_TEMP}/git-cliff-2.13.1:${PATH}"
+          "${RUNNER_TEMP}/write-changelog.sh"
+          if git diff --quiet -- CHANGELOG.md; then
+            echo "CHANGELOG already complete."
+            exit 0
+          fi
+          git add CHANGELOG.md cliff.toml 2>/dev/null || git add CHANGELOG.md
+          git commit -m "chore(release): write whole-repo changelog"
+          git push origin "HEAD:refs/heads/${branch}"
       # `release-plz/action` swallows a release-pr HTTP 422 as a warning and
       # reports no PR, which silently stalls releases (it looks identical to a
       # quiet week of commits). Fail loudly when release-plz opened/updated no
@@ -131,11 +173,16 @@ jobs:
             }
             core.info(`No release PR and no release-worthy commits since ${lastTag || "repo start"}; nothing to release.`);
 
-  # On every push to master, publishes any crate whose manifest version is not yet
-  # on crates.io — i.e. a no-op until the release PR is merged, at which point it
-  # publishes the whole workspace and cuts one `v{version}` tag + GitHub Release.
+  # Publishes crates + cuts `v{version}` only from the release PR merge commit
+  # (`chore: release v*`). release_always=false in release-plz.toml is the primary
+  # gate; this job-level filter is defense in depth so a later feature push cannot
+  # tag HEAD after a failed-then-retried crates.io publish. On publish failure,
+  # re-run this workflow on the release commit SHA — never on a later master tip.
   release:
     name: release-plz release
+    if: >-
+      github.event_name == 'workflow_dispatch' ||
+      startsWith(github.event.head_commit.message, 'chore: release')
     runs-on: ubuntu-latest
     permissions:
       contents: write
@@ -145,25 +192,85 @@ jobs:
         with:
           fetch-depth: 0
           persist-credentials: false
+      # Pin to the version-bump commit even if workflow_dispatch is fired from a
+      # later master tip (or a re-run that somehow resolves to the wrong SHA).
+      - name: Check out the version-bump commit
+        shell: bash
+        run: |
+          set -euo pipefail
+          version="$(
+            python3 - <<'PY'
+          import pathlib, re, sys
+          text = pathlib.Path("Cargo.toml").read_text()
+          m = re.search(
+              r'(?ms)^\[workspace\.package\].*?^version\s*=\s*"([^"]+)"',
+              text,
+          )
+          if not m:
+              sys.exit("workspace.package version not found in Cargo.toml")
+          print(m.group(1))
+          PY
+          )"
+          tag="v${version}"
+          if git rev-parse -q --verify "refs/tags/${tag}" >/dev/null; then
+            echo "Tag ${tag} already exists — nothing to release."
+            echo "skip=true" >> "$GITHUB_ENV"
+            exit 0
+          fi
+          # Prefer the conventional release-PR squash subject; fall back to the
+          # first commit that set this workspace version in Cargo.toml.
+          bump_sha="$(git log -1 --format=%H --grep="^chore: release v${version}" || true)"
+          if [[ -z "${bump_sha}" ]]; then
+            bump_sha="$(
+              git log -G '^version = "' --format=%H -- Cargo.toml \
+                | while read -r sha; do
+                    if git show "${sha}:Cargo.toml" \
+                      | python3 -c "import pathlib,re,sys; t=sys.stdin.read(); m=re.search(r'(?ms)^\[workspace\.package\].*?^version\s*=\s*\"([^\"]+)\"', t); sys.exit(0 if m and m.group(1)==sys.argv[1] else 1)" \
+                      "${version}"
+                    then
+                      echo "${sha}"
+                      break
+                    fi
+                  done
+            )"
+          fi
+          if [[ -z "${bump_sha}" ]]; then
+            echo "::error::Could not locate the version-bump commit for ${tag}"
+            exit 1
+          fi
+          echo "Checking out version-bump commit ${bump_sha} for ${tag}"
+          # Stay on a real branch with @{upstream} set. A bare SHA checkout
+          # detaches HEAD and release-plz aborts with "cannot determine current
+          # branch". Pin master to the bump commit only for this job's workspace
+          # (does not push, does not bump versions).
+          git switch --force -C master "${bump_sha}"
+          git branch --set-upstream-to=origin/master master
+          echo "skip=false" >> "$GITHUB_ENV"
+          echo "release_sha=${bump_sha}" >> "$GITHUB_ENV"
       - uses: dtolnay/rust-toolchain@stable
+        if: env.skip != 'true'
       - uses: Swatinem/rust-cache@v2
+        if: env.skip != 'true'
         with:
           prefix-key: v1-rust
           shared-key: linux-stable-debug
           # CI master is the canonical writer; release-plz only restores.
           save-if: false
       - name: Install Linux build deps
+        if: env.skip != 'true'
         run: |
           sudo apt-get update
           sudo apt-get install -y \
             libudev-dev pkg-config gcc g++ clang libssl-dev libzstd-dev
       - name: Mint GitHub App token
+        if: env.skip != 'true'
         id: app-token
         uses: ./.github/actions/github-app-token-from-1password
         with:
           op-service-account-token: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
           op-github-app-item: ${{ secrets.OP_GITHUB_APP_ITEM }}
       - name: Run release-plz (release)
+        if: env.skip != 'true'
         uses: release-plz/action@v0.5
         with:
           command: release
diff --git a/AGENTS.md b/AGENTS.md
index c69aa752c2661e24782982132178b4be0dcf1561..85c760bc09497804eec7f4ca7ed0fe5740bfbbcd 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -52,12 +52,76 @@ direnv exec . cargo clippy --workspace --all-targets -- -D warnings
 direnv exec . git commit …
 ```
 
-- Full local gate (same as CI): `cargo fmt --all -- --check` +
-  `cargo clippy --workspace --all-targets -- -D warnings` +
-  `cargo test --workspace` (or `devenv tasks run openlogi:check`). Must
-  pass before every commit.
-- prek hooks (`prek.toml`): `cargo fmt` at commit; full-workspace clippy at push
-  (rust-scoped, so non-Rust pushes skip it).
+### Local gate (hard stop — do this before every push)
+
+**Never `git push` until the final tree has passed the full local gate.**
+`cargo check` alone is not enough. Conflict resolution + "it compiles on my
+Mac" is not enough. Run **all three** on the commit you are about to push:
+
+```sh
+cargo fmt --all -- --check
+cargo clippy --workspace --all-targets -- -D warnings
+cargo test --workspace
+# or: devenv tasks run openlogi:check
+```
+
+Exit non-zero on any of those → fix, re-run the **whole** triple, then push.
+Do not push "to see if CI likes it." CI is confirmation, not the first compile.
+
+prek hooks (`prek.toml`): `cargo fmt` at commit; full-workspace clippy at push
+(rust-scoped, so non-Rust pushes skip it). Hooks are a backstop, not a substitute
+for running the gate yourself after a rebase.
+
+### Platform / cfg-gated code (macOS-green is a trap)
+
+macOS-green proves **nothing** about `#[cfg(target_os = "linux")]` /
+`windows` code. Recent agent failures that only showed up on CI Linux:
+
+- Shadowing a crate-level constant with a local `const` of a different type
+  (e.g. `LOGITECH_VENDOR_ID: u16` next to `use crate::LOGITECH_VENDOR_ID`
+  which is `u32`) — E0255 / E0308, **only compiles on Linux**.
+- Importing a name that only exists on another OS, or redefining one that
+  master already exports from `lib.rs`.
+
+When the diff touches any of:
+
+- `crates/openlogi-hook/src/linux.rs` / `windows.rs`
+- `crates/openlogi-inject/src/inject/linux.rs` / `windows.rs`
+- `crates/openlogi-hid/src/transport.rs` (has `#[cfg]` branches)
+- any `#[cfg(target_os = …)]` block
+
+you MUST either:
+
+1. Cross-check with devenv when available:
+   `devenv tasks run openlogi:check-windows` (and any linux check the repo has), or
+2. Manually re-read every changed cfg-gated file against **current master** for:
+   - name collisions with existing `pub use` / `pub const` items
+   - type mismatches (`u16` vs `u32`, `Option` arity, new enum fields)
+   - call sites that gained args on master (e.g. `with_runtime`, `build_device_list`,
+     `dispatch_action`) but the PR still uses the old signature
+
+Do not claim "cross-platform green" without CI (or a local cross-lint) having
+actually run those targets. `RUSTFLAGS=-D warnings` is global in CI — plain
+warnings fail there too.
+
+### Wire format / IPC (another silent CI red)
+
+If the change touches anything that crosses the agent↔GUI boundary
+(`ipc.rs`, serde enums in hid write errors, `DeviceKind`, …):
+
+- Enums are **append-only** (serde index = wire). New variants go at the end.
+- Bump `PROTOCOL_VERSION` and regenerate
+  `crates/openlogi-agent-core/tests/wire_format.rs` goldens from the failure
+  message (`left` is the new encoding).
+- Run `cargo test -p openlogi-agent-core --test wire_format` before push.
+
+### i18n
+
+New GUI strings: insert the same key in the **same position** in every
+`crates/openlogi-gui/locales/*.yml`. Run `cargo test -p openlogi-gui i18n`.
+
+### App / agent runtime notes
+
 - The macOS GUI build needs full Xcode for GPUI's Metal shaders. devenv sets
   `DEVELOPER_DIR`/`SDKROOT` when present; without it, use system Xcode. If the
   shader compile fails under devenv, `direnv reload` first.
@@ -65,10 +129,6 @@ direnv exec . git commit …
   into `target/dev/OpenLogi.app`. `cargo build` does NOT refresh that bundle,
   and a second instance exits on the singleton lock: quit the old instance and
   re-`run` before judging a UI change "not applied".
-- macOS-green proves nothing about cfg-gated code. CI's linux/windows jobs are the
-  authoritative check (`RUSTFLAGS=-D warnings` globally, so plain warnings fail
-  too); with devenv, `devenv tasks run openlogi:check-windows` cross-lints the
-  ring-free subset locally. Don't claim cross-platform success without CI.
 
 ## Rust standards
 
@@ -119,6 +179,8 @@ House style:
   worktree so parallel work doesn't collide; trivial fixes may go straight to master.
 - Commits are small and focused — split unrelated concerns into separate commits; never
   one giant unreviewable diff.
+- **Always `git fetch upstream master` (or origin) immediately before a rebase.** Rebase
+  onto the refreshed tip, not a stale local `master`.
 - Merging PRs: **squash by default** with a hand-written subject
   `type(scope): description (#N)` (release-plz parses it; merge commits are disabled).
   Rebase-merge only when every commit on the branch is already release-quality
@@ -134,12 +196,25 @@ House style:
 - Never post to external repos or reply publicly on the maintainer's behalf — draft the
   text for approval. Keep public drafts short, casual, and problem-focused.
 - Contributor PRs are adopted, not rejected: check `maintainerCanModify`, rebase onto
-  master in a worktree, fix review findings, push to the fork branch; preserve
-  authorship (`Co-authored-by` when re-homing work).
+  **fresh** master in a worktree, fix review findings, run the **full local gate** on
+  the rebased tip, **then** push to the fork branch; preserve authorship
+  (`Co-authored-by` when re-homing work). Squash-then-rebase is fine when the PR is
+  far behind and commit-by-commit conflicts thrash.
 - Issues use the bug/feature/device forms and the `type:`/`area:`/`platform:`/`needs:`/
   `status:` label families. Deferred or out-of-scope work becomes a linked issue, not a
   TODO comment.
 
+### CI / Actions when adopting PRs
+
+- CI concurrency is **per branch** (`ci-${{ workflow }}-${{ ref }}` with
+  `cancel-in-progress: true`). Approving or re-running an **old SHA** on the same
+  branch cancels the current-head run. Only approve / re-run workflows whose
+  `head_sha` equals the PR's current head.
+- After a force-push, wait for the new runs; do not re-approve stale
+  `action_required` jobs from earlier commits on that branch.
+- First-time-fork PRs may sit in `action_required` until a maintainer approves the
+  workflow run — that is fine; still do not push until the local gate is green.
+
 ## Releases
 
 release-plz drives releases: one unified workspace version, ONE root `CHANGELOG.md`
@@ -156,6 +231,26 @@ and loop on that check. Real-hardware verification (physical mice, receivers) is
 maintainer's job: every fix PR states how to test it. Report outcomes honestly,
 including what was NOT verified.
 
+**Push checklist (agents):**
+
+1. Rebase/merge conflicts fully resolved — no `<<<<<<<` left, no half-ported APIs.
+2. Full local gate green on the **final** tree (fmt + clippy `-D warnings` + test).
+3. If cfg-gated files changed: cross-lint or hand-audit against master (see above).
+4. If wire types changed: `wire_format` tests green + `PROTOCOL_VERSION` bumped.
+5. If locales changed: only `en.yml` is required for new strings; run
+   `cargo test -p openlogi-gui i18n` (non-English may lag until Crowdin).
+6. Only then `git push` / force-push to the PR branch.
+
+## i18n (English only in feature work)
+
+- **Only edit** `crates/openlogi-gui/locales/en.yml` when adding or changing UI
+  strings. The English text is the key; `rust_i18n` falls back to English for
+  missing translations.
+- **Do not** update `da`/`de`/`ja`/… locale files in the same PR to “keep parity.”
+  Crowdin owns non-English catalogs; the Crowdin workflow opens `crowdin/i18n`
+  after `en.yml` lands on master.
+- Details: [`.claude/rules/i18n.md`](.claude/rules/i18n.md).
+
 ## Subsystem rules — read before touching
 
 Claude Code loads these automatically per path; other agents: read the listed file
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1e23baa3f2f800d6545051131905c0bf6b4589de..915e514f028e8b2735f989e40016c66b5fdc861f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,32 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 
 ## [Unreleased]
 
+## [0.6.24] - 2026-08-10
+
+### Added
+
+- *(hid)* recognize Lightspeed receiver (046d:c539) as Unifying-compatible ([#510](https://github.com/AprilNEA/OpenLogi/pull/510))
+- add function key remapper ([#344](https://github.com/AprilNEA/OpenLogi/pull/344))
+- *(hid)* add standalone Litra light support ([#513](https://github.com/AprilNEA/OpenLogi/pull/513))
+- keyboard F-row key remapping and fn-lock over HID++ ([#395](https://github.com/AprilNEA/OpenLogi/pull/395))
+- *(hook)* Wayland frontmost-window backends (wlroots + GNOME Shell) ([#191](https://github.com/AprilNEA/OpenLogi/pull/191))
+- *(camera)* add Logitech webcam support ([#531](https://github.com/AprilNEA/OpenLogi/pull/531))
+- *(backlight)* support HID++ 0x1982 ([#470](https://github.com/AprilNEA/OpenLogi/pull/470))
+- *(battery)* support legacy 0x1000 BatteryStatus and its charging quirk ([#312](https://github.com/AprilNEA/OpenLogi/pull/312))
+
+### Fixed
+
+- *(agent-core)* retry volatile DPI re-apply on cold boot ([#449](https://github.com/AprilNEA/OpenLogi/pull/449))
+- *(agent)* prefer online device for input capture ([#453](https://github.com/AprilNEA/OpenLogi/pull/453))
+- *(hidpp)* keep events when a field carries an unknown enum value ([#432](https://github.com/AprilNEA/OpenLogi/pull/432))
+- *(agent)* rearm control capture after device reconnect ([#450](https://github.com/AprilNEA/OpenLogi/pull/450))
+- *(linux)* grant uaccess on Logitech input event nodes ([#530](https://github.com/AprilNEA/OpenLogi/pull/530))
+- *(agent)* reapply volatile settings after macOS resume ([#506](https://github.com/AprilNEA/OpenLogi/pull/506))
+- *(hook)* never wedge system pointer input ([#534](https://github.com/AprilNEA/OpenLogi/pull/534))
+- *(agent)* route hardware operations through inventory channels ([#532](https://github.com/AprilNEA/OpenLogi/pull/532))
+- *(agent)* reuse inventory channels for input capture ([#522](https://github.com/AprilNEA/OpenLogi/pull/522))
+- *(i18n)* complete Crowdin synchronization ([#508](https://github.com/AprilNEA/OpenLogi/pull/508))
+
 ## [0.6.23](https://github.com/AprilNEA/OpenLogi/compare/openlogi-core-v0.6.22...openlogi-core-v0.6.23) - 2026-08-02
 
 ### Fixed
diff --git a/Cargo.lock b/Cargo.lock
index 30c916aebb226001b1454cfda2f1219655eff857..f56defeaa3817b3174f59370a04260dc0989c9a1 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -685,6 +685,29 @@ dependencies = [
  "serde",
 ]
 
+[[package]]
+name = "bindgen"
+version = "0.65.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cfdf7b466f9a4903edc73f95d6d2bcd5baf8ae620638762244d3f60143643cc5"
+dependencies = [
+ "bitflags 1.3.2",
+ "cexpr",
+ "clang-sys",
+ "lazy_static",
+ "lazycell",
+ "log",
+ "peeking_take_while",
+ "prettyplease",
+ "proc-macro2",
+ "quote",
+ "regex",
+ "rustc-hash 1.1.0",
+ "shlex",
+ "syn",
+ "which 4.4.2",
+]
+
 [[package]]
 name = "bindgen"
 version = "0.71.1"
@@ -694,7 +717,7 @@ dependencies = [
  "bitflags 2.13.1",
  "cexpr",
  "clang-sys",
- "itertools 0.11.0",
+ "itertools 0.13.0",
  "log",
  "prettyplease",
  "proc-macro2",
@@ -1726,7 +1749,7 @@ dependencies = [
  "libc",
  "option-ext",
  "redox_users",
- "windows-sys 0.59.0",
+ "windows-sys 0.61.2",
 ]
 
 [[package]]
@@ -1993,7 +2016,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"
 dependencies = [
  "libc",
- "windows-sys 0.59.0",
+ "windows-sys 0.61.2",
 ]
 
 [[package]]
@@ -2601,7 +2624,7 @@ dependencies = [
  "log",
  "presser",
  "thiserror 2.0.18",
- "windows 0.58.0",
+ "windows 0.62.2",
 ]
 
 [[package]]
@@ -2633,7 +2656,7 @@ dependencies = [
  "anyhow",
  "async-channel",
  "async-task",
- "bindgen",
+ "bindgen 0.71.1",
  "bitflags 2.13.1",
  "block",
  "cbindgen",
@@ -3361,7 +3384,7 @@ dependencies = [
  "js-sys",
  "log",
  "wasm-bindgen",
- "windows-core 0.58.0",
+ "windows-core 0.62.2",
 ]
 
 [[package]]
@@ -3857,6 +3880,12 @@ version = "1.5.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
 
+[[package]]
+name = "lazycell"
+version = "1.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
+
 [[package]]
 name = "leak"
 version = "0.1.2"
@@ -4173,7 +4202,7 @@ version = "0.1.0"
 source = "git+https://github.com/zed-industries/zed#1a246efd7e1b83ab568ec5e3e6c1a43a42e1abba"
 dependencies = [
  "anyhow",
- "bindgen",
+ "bindgen 0.71.1",
  "core-foundation 0.10.0",
  "core-video",
  "ctor",
@@ -4451,7 +4480,7 @@ version = "0.50.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5"
 dependencies = [
- "windows-sys 0.59.0",
+ "windows-sys 0.61.2",
 ]
 
 [[package]]
@@ -4991,7 +5020,7 @@ dependencies = [
 
 [[package]]
 name = "openlogi"
-version = "0.6.23"
+version = "0.6.24"
 dependencies = [
  "anyhow",
  "openlogi-cli",
@@ -5000,7 +5029,7 @@ dependencies = [
 
 [[package]]
 name = "openlogi-agent"
-version = "0.6.23"
+version = "0.6.24"
 dependencies = [
  "embed-resource",
  "futures",
@@ -5025,7 +5054,7 @@ dependencies = [
 
 [[package]]
 name = "openlogi-agent-core"
-version = "0.6.23"
+version = "0.6.24"
 dependencies = [
  "async-hid",
  "bincode",
@@ -5043,7 +5072,7 @@ dependencies = [
 
 [[package]]
 name = "openlogi-assets"
-version = "0.6.23"
+version = "0.6.24"
 dependencies = [
  "atomic-write-file",
  "backon",
@@ -5056,15 +5085,31 @@ dependencies = [
  "ureq",
 ]
 
+[[package]]
+name = "openlogi-camera"
+version = "0.6.24"
+dependencies = [
+ "block2 0.6.2",
+ "objc2 0.6.4",
+ "serde",
+ "tracing",
+ "v4l",
+ "windows 0.61.3",
+ "zune-core 0.5.1",
+ "zune-jpeg 0.5.15",
+]
+
 [[package]]
 name = "openlogi-cli"
-version = "0.6.23"
+version = "0.6.24"
 dependencies = [
  "anyhow",
  "clap",
  "openlogi-assets",
+ "openlogi-camera",
  "openlogi-core",
  "openlogi-hid",
+ "png 0.17.16",
  "tokio",
  "tracing",
  "tracing-subscriber",
@@ -5072,10 +5117,11 @@ dependencies = [
 
 [[package]]
 name = "openlogi-core"
-version = "0.6.23"
+version = "0.6.24"
 dependencies = [
  "atomic-write-file",
  "etcetera",
+ "plist",
  "serde",
  "tempfile",
  "thiserror 2.0.18",
@@ -5086,7 +5132,7 @@ dependencies = [
 
 [[package]]
 name = "openlogi-gui"
-version = "0.6.23"
+version = "0.6.24"
 dependencies = [
  "anyhow",
  "backon",
@@ -5106,6 +5152,7 @@ dependencies = [
  "opener",
  "openlogi-agent-core",
  "openlogi-assets",
+ "openlogi-camera",
  "openlogi-core",
  "openlogi-hid",
  "openlogi-hook",
@@ -5126,12 +5173,14 @@ dependencies = [
 
 [[package]]
 name = "openlogi-hid"
-version = "0.6.23"
+version = "0.6.24"
 dependencies = [
  "async-hid",
  "futures-concurrency",
  "futures-lite",
  "num_enum",
+ "objc2 0.6.4",
+ "objc2-app-kit 0.3.2",
  "openlogi-core",
  "openlogi-hidpp",
  "serde",
@@ -5143,7 +5192,7 @@ dependencies = [
 
 [[package]]
 name = "openlogi-hidpp"
-version = "0.6.23"
+version = "0.6.24"
 dependencies = [
  "async-channel",
  "async-trait",
@@ -5162,7 +5211,7 @@ dependencies = [
 
 [[package]]
 name = "openlogi-hook"
-version = "0.6.23"
+version = "0.6.24"
 dependencies = [
  "core-foundation 0.10.0",
  "core-graphics 0.25.0",
@@ -5177,13 +5226,16 @@ dependencies = [
  "openlogi-inject",
  "thiserror 2.0.18",
  "tracing",
+ "wayland-client",
+ "wayland-protocols-wlr",
  "windows-sys 0.61.2",
  "x11rb",
+ "zbus",
 ]
 
 [[package]]
 name = "openlogi-inject"
-version = "0.6.23"
+version = "0.6.24"
 dependencies = [
  "core-foundation 0.10.0",
  "core-graphics 0.25.0",
@@ -5344,6 +5396,12 @@ dependencies = [
  "hmac",
 ]
 
+[[package]]
+name = "peeking_take_while"
+version = "0.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099"
+
 [[package]]
 name = "percent-encoding"
 version = "2.3.2"
@@ -5492,13 +5550,13 @@ checksum = "19f132c84eca552bf34cab8ec81f1c1dcc229b811638f9d283dceabe58c5569e"
 
 [[package]]
 name = "plist"
-version = "1.9.0"
+version = "1.10.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "092791278e026273c1b65bbdcfbba3a300f2994c896bd01ab01da613c29c46f1"
+checksum = "7da1d65da6dd5d1e44199ac0f58712d241c0f439f80adea8924d832384087f85"
 dependencies = [
  "base64",
  "indexmap",
- "quick-xml 0.39.4",
+ "quick-xml 0.41.0",
  "serde",
  "time",
 ]
@@ -5758,9 +5816,9 @@ dependencies = [
 
 [[package]]
 name = "quick-xml"
-version = "0.39.4"
+version = "0.41.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cdcc8dd4e2f670d309a5f0e83fe36dfdc05af317008fea29144da1a2ac858e5e"
+checksum = "e660451e55124f798a69a5af3f49ccfbefbd41910eefd25caf2393e1f3473ec1"
 dependencies = [
  "memchr",
 ]
@@ -6356,7 +6414,7 @@ dependencies = [
  "errno",
  "libc",
  "linux-raw-sys 0.12.1",
- "windows-sys 0.59.0",
+ "windows-sys 0.61.2",
 ]
 
 [[package]]
@@ -7325,7 +7383,7 @@ dependencies = [
  "getrandom 0.4.2",
  "once_cell",
  "rustix 1.1.4",
- "windows-sys 0.59.0",
+ "windows-sys 0.61.2",
 ]
 
 [[package]]
@@ -8066,6 +8124,26 @@ dependencies = [
  "wasm-bindgen",
 ]
 
+[[package]]
+name = "v4l"
+version = "0.14.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d8fbfea44a46799d62c55323f3c55d06df722fbe577851d848d328a1041c3403"
+dependencies = [
+ "bitflags 1.3.2",
+ "libc",
+ "v4l2-sys-mit",
+]
+
+[[package]]
+name = "v4l2-sys-mit"
+version = "0.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6779878362b9bacadc7893eac76abe69612e8837ef746573c4a5239daf11990b"
+dependencies = [
+ "bindgen 0.65.1",
+]
+
 [[package]]
 name = "v_frame"
 version = "0.3.9"
@@ -8385,12 +8463,12 @@ dependencies = [
 
 [[package]]
 name = "wayland-scanner"
-version = "0.31.10"
+version = "0.31.11"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9c324a910fd86ebdc364a3e61ec1f11737d3b1d6c273c0239ee8ff4bc0d24b4a"
+checksum = "338e30461b3a2b67d70eb30a6d89f8e0c93a833e07d2ae89085cd070c4a00ac0"
 dependencies = [
  "proc-macro2",
- "quick-xml 0.39.4",
+ "quick-xml 0.41.0",
  "quote",
 ]
 
@@ -8609,6 +8687,18 @@ dependencies = [
  "web-sys",
 ]
 
+[[package]]
+name = "which"
+version = "4.4.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7"
+dependencies = [
+ "either",
+ "home",
+ "once_cell",
+ "rustix 0.38.44",
+]
+
 [[package]]
 name = "which"
 version = "6.0.3"
@@ -8658,7 +8748,7 @@ version = "0.1.11"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"
 dependencies = [
- "windows-sys 0.59.0",
+ "windows-sys 0.61.2",
 ]
 
 [[package]]
@@ -9479,7 +9569,7 @@ checksum = "32ac00cd3f8ec9c1d33fb3e7958a82df6989c42d747bd326c822b1d625283547"
 
 [[package]]
 name = "xtask"
-version = "0.6.23"
+version = "0.6.24"
 dependencies = [
  "anyhow",
  "clap",
diff --git a/Cargo.toml b/Cargo.toml
index b7424291e85566a1e32aef2c0917c017ec3073e4..7252358403862fc40fab7381587c34f95f12f6e4 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -12,7 +12,7 @@ categories = ["command-line-utilities", "hardware-support"]
 readme = "README.md"
 
 [dependencies]
-openlogi-cli = { path = "crates/openlogi-cli", version = "0.6.23" }
+openlogi-cli = { path = "crates/openlogi-cli", version = "0.6.24" }
 anyhow = { workspace = true }
 tokio = { workspace = true, features = ["rt", "macros"] }
 
@@ -26,6 +26,7 @@ members = [
     "crates/openlogi-inject",
     "crates/openlogi-hidpp",
     "crates/openlogi-hid",
+    "crates/openlogi-camera",
     "crates/openlogi-assets",
     "crates/openlogi-cli",
     "crates/openlogi-agent-core",
@@ -36,7 +37,7 @@ members = [
 ]
 
 [workspace.package]
-version = "0.6.23"
+version = "0.6.24"
 edition = "2024"
 rust-version = "1.96"
 license = "MIT OR Apache-2.0"
@@ -45,7 +46,7 @@ authors = ["AprilNEA <dev@aprilnea.me>"]
 description = "Lightweight, local-first alternative to Logitech Options+ for HID++ devices"
 
 [workspace.dependencies]
-hidpp = { package = "openlogi-hidpp", path = "crates/openlogi-hidpp", version = "0.6.23" }
+hidpp = { package = "openlogi-hidpp", path = "crates/openlogi-hidpp", version = "0.6.24" }
 async-hid = "0.5.2"
 # Cross-platform local IPC for the agent <-> GUI tarpc transport: a Unix-domain
 # socket on Unix, a named pipe on Windows. The `tokio` feature gives the async
diff --git a/README.md b/README.md
index 6edb10e595077fd89a11682bd87817e4f48120be..e0a911aabb27cc53d9fd77796b9fd6548be2d91c 100644
--- a/README.md
+++ b/README.md
@@ -147,7 +147,8 @@ sudo pacman -U openlogi-*.pkg.tar.zst
 Packages are published for both `x86_64`/`amd64` and `arm64`/`aarch64`.
 
 The package installs udev rules that grant your user access to
-`/dev/hidraw*` and `/dev/uinput` without `sudo`. After installation,
+`/dev/hidraw*`, `/dev/uinput` and your Logitech mouse's `/dev/input/event*`
+node without `sudo`. After installation,
 enable the background agent for your user:
 
 ```sh
diff --git a/cliff.toml b/cliff.toml
new file mode 100644
index 0000000000000000000000000000000000000000..19f6601ac15df24480a32ee4f7d457b6507b2e6a
--- /dev/null
+++ b/cliff.toml
@@ -0,0 +1,51 @@
+# Whole-repo changelog (git-cliff). release-plz only bumps versions; it is
+# package-path-scoped and cannot see `release = false` app crates, so the root
+# CHANGELOG is owned here — same model as GoReleaser's `changelog.use: git`.
+# https://git-cliff.org/docs/configuration
+
+[changelog]
+header = """# Changelog
+
+All notable changes to this project will be documented in this file.
+
+The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
+and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+
+## [Unreleased]
+
+"""
+# Keep-a-Changelog layout matching historical OpenLogi sections.
+body = """
+## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}
+
+{% for group, commits in commits | group_by(attribute="group") -%}
+### {{ group | upper_first }}
+
+{% for commit in commits -%}
+- {% if commit.scope %}*({{ commit.scope }})* {% endif %}{% if commit.breaking %}[**breaking**] {% endif %}{{ commit.message }}
+{% endfor %}
+{% endfor -%}
+"""
+trim = true
+
+[git]
+conventional_commits = true
+filter_unconventional = true
+require_conventional = true
+split_commits = false
+commit_preprocessors = [
+  { pattern = "\\(#([0-9]+)\\)", replace = "([#${1}](https://github.com/AprilNEA/OpenLogi/pull/${1}))" },
+]
+commit_parsers = [
+  { message = "^feat", group = "Added" },
+  { message = "^fix", group = "Fixed" },
+  { message = "^perf", group = "Changed" },
+  { message = "^security", group = "Security" },
+  { message = "^.*", skip = true },
+]
+protect_breaking_commits = true
+filter_commits = false
+tag_pattern = "v[0-9].*"
+sort_commits = "newest"
+# No include_path / exclude_path — every conventional commit since the last tag
+# counts, including gui/agent work that never touches a crates.io package.
diff --git a/crates/openlogi-agent-core/src/device_order.rs b/crates/openlogi-agent-core/src/device_order.rs
index 6eae03381f02baebe6f6d53f47bf89992f79fe84..88e8552382e65066a790078970467f1a6460b009 100644
--- a/crates/openlogi-agent-core/src/device_order.rs
+++ b/crates/openlogi-agent-core/src/device_order.rs
@@ -3,9 +3,9 @@
 //!
 //! HID enumeration order shifts as devices wake, sleep, or are reselected, so
 //! both processes order devices by a stable, route-derived identity instead.
-//! Sharing the key here is what keeps them agreeing on "the first device": when
-//! no `selected_device` is persisted, the GUI shows index 0 of its sorted list
-//! and the agent targets index 0 of its own — they must be the same device.
+//! Sharing the key keeps device order deterministic. The agent additionally
+//! excludes standalone raw-HID devices when choosing its input-capture target;
+//! they remain ordered here for inventory, display, and settings re-apply.
 
 use openlogi_hid::DeviceRoute;
 
@@ -16,10 +16,10 @@ pub struct PhysicalDeviceKey(String);
 
 /// A route-derived identity used to order devices deterministically.
 ///
-/// Receiver UID + slot and direct serial/non-zero unit identities are stable
-/// and unique. A direct all-zero unit identity is deliberately retained here
-/// only so a transient inventory record can still be ordered; it cannot become
-/// a [`PhysicalDeviceKey`].
+/// Receiver UID + slot and serial/non-zero unit identities are stable and
+/// unique. OS-node identities on raw HID routes are deliberately retained here
+/// only so a transient inventory record can still be ordered; they cannot
+/// become a [`PhysicalDeviceKey`].
 #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
 pub enum DeviceStableId {
     Bolt {
@@ -31,6 +31,13 @@ pub enum DeviceStableId {
         product_id: u16,
         identity: DeviceIdentity,
     },
+    RawHid {
+        vendor_id: u16,
+        product_id: u16,
+        usage_page: u16,
+        usage_id: u16,
+        identity: String,
+    },
     Unknown {
         slot: u8,
         identity: DeviceIdentity,
@@ -83,6 +90,19 @@ impl DeviceStableId {
                 product_id: *product_id,
                 identity: DeviceIdentity::from_parts(serial, unit_id),
             },
+            Some(DeviceRoute::RawHid {
+                vendor_id,
+                product_id,
+                usage_page,
+                usage_id,
+                identity,
+            }) => Self::RawHid {
+                vendor_id: *vendor_id,
+                product_id: *product_id,
+                usage_page: *usage_page,
+                usage_id: *usage_id,
+                identity: identity.to_ascii_lowercase(),
+            },
             None => Self::Unknown {
                 slot,
                 identity: DeviceIdentity::from_parts(serial, unit_id),
@@ -109,6 +129,15 @@ impl DeviceStableId {
                 product_id,
                 identity,
             } => format!("direct:{vendor_id:04x}:{product_id:04x}:{}", identity.key()),
+            Self::RawHid {
+                vendor_id,
+                product_id,
+                usage_page,
+                usage_id,
+                identity,
+            } => format!(
+                "raw:{vendor_id:04x}:{product_id:04x}:{usage_page:04x}:{usage_id:04x}:{identity}"
+            ),
             Self::Unknown { slot, identity } => format!("unknown:slot:{slot}:{}", identity.key()),
         }
     }
@@ -117,8 +146,9 @@ impl DeviceStableId {
     ///
     /// Receiver-connected devices are identified by receiver UID + pairing
     /// slot. Direct and routeless devices require either a non-empty serial
-    /// number or a non-zero unit id; an all-zero unit id is a transient probe
-    /// result, not a physical identity.
+    /// number or a non-zero unit id. Raw HID devices require a serial-backed
+    /// route identity; OS node identities and all-zero unit ids are transient
+    /// probe results, not physical identities.
     #[must_use]
     pub fn physical_key(&self) -> Option<PhysicalDeviceKey> {
         match self {
@@ -126,6 +156,9 @@ impl DeviceStableId {
             Self::Direct { identity, .. } | Self::Unknown { identity, .. } => identity
                 .is_physical()
                 .then(|| PhysicalDeviceKey(self.runtime_key())),
+            Self::RawHid { identity, .. } => {
+                raw_identity_is_physical(identity).then(|| PhysicalDeviceKey(self.runtime_key()))
+            }
         }
     }
 }
@@ -156,6 +189,7 @@ impl PhysicalDeviceKey {
     pub fn parse(value: &str) -> Option<Self> {
         if receiver_key_is_valid(value)
             || direct_identity_fragment(value).is_some_and(identity_fragment_is_physical)
+            || raw_identity_fragment(value).is_some_and(raw_identity_is_physical)
             || unknown_identity_fragment(value).is_some_and(identity_fragment_is_physical)
         {
             Some(Self(value.to_string()))
@@ -171,6 +205,8 @@ impl PhysicalDeviceKey {
         direct_identity_fragment(value)
             .or_else(|| unknown_identity_fragment(value))
             .is_some_and(|identity| identity == "unit:00000000")
+            || raw_identity_fragment(value)
+                .is_some_and(|identity| identity.starts_with("id:") || identity.is_empty())
     }
 
     /// Borrow the serialized configuration key.
@@ -201,6 +237,21 @@ fn direct_identity_fragment(value: &str) -> Option<&str> {
     (is_hex_word(vendor_id) && is_hex_word(product_id)).then_some(identity)
 }
 
+fn raw_identity_fragment(value: &str) -> Option<&str> {
+    let mut parts = value.strip_prefix("raw:")?.splitn(5, ':');
+    let vendor_id = parts.next()?;
+    let product_id = parts.next()?;
+    let usage_page = parts.next()?;
+    let usage_id = parts.next()?;
+    let identity = parts.next()?;
+    (is_hex_word(vendor_id)
+        && is_hex_word(product_id)
+        && is_hex_word(usage_page)
+        && is_hex_word(usage_id)
+        && !identity.is_empty())
+    .then_some(identity)
+}
+
 fn unknown_identity_fragment(value: &str) -> Option<&str> {
     let (slot, identity) = value.strip_prefix("unknown:slot:")?.split_once(':')?;
     slot.parse::<u8>().ok().map(|_| identity)
@@ -217,6 +268,15 @@ fn identity_fragment_is_physical(value: &str) -> bool {
         })
 }
 
+fn raw_identity_is_physical(value: &str) -> bool {
+    value
+        .strip_prefix("serial:")
+        .is_some_and(|serial| !serial.is_empty())
+        || value
+            .strip_prefix("stable:")
+            .is_some_and(|identity| !identity.is_empty())
+}
+
 fn is_hex_word(value: &str) -> bool {
     value.len() == 4 && value.bytes().all(|byte| byte.is_ascii_hexdigit())
 }
@@ -327,4 +387,42 @@ mod tests {
         assert!(PhysicalDeviceKey::parse("direct:046d:b023:unit:a393cae0").is_some());
         assert!(PhysicalDeviceKey::parse("2b034").is_none());
     }
+
+    #[test]
+    fn raw_os_identity_is_transient_across_reconnects() {
+        let old = DeviceRoute::RawHid {
+            vendor_id: 0x046d,
+            product_id: 0xc900,
+            usage_page: 0xff43,
+            usage_id: 0x0202,
+            identity: "id:old-node".into(),
+        };
+        let new = DeviceRoute::RawHid {
+            vendor_id: 0x046d,
+            product_id: 0xc900,
+            usage_page: 0xff43,
+            usage_id: 0x0202,
+            identity: "id:new-node".into(),
+        };
+        let old_id = DeviceStableId::from_parts(Some(&old), 0xff, None, [0; 4]);
+        let new_id = DeviceStableId::from_parts(Some(&new), 0xff, None, [0; 4]);
+        assert_ne!(old_id.runtime_key(), new_id.runtime_key());
+        assert!(old_id.physical_key().is_none());
+        assert!(new_id.physical_key().is_none());
+    }
+
+    #[test]
+    fn raw_serial_identity_survives_a_changed_os_node() {
+        let route = DeviceRoute::RawHid {
+            vendor_id: 0x046d,
+            product_id: 0xc900,
+            usage_page: 0xff43,
+            usage_id: 0x0202,
+            identity: "serial:glow-1".into(),
+        };
+        let key = DeviceStableId::from_parts(Some(&route), 0xff, Some("glow-1"), [0; 4])
+            .physical_key()
+            .map(PhysicalDeviceKey::into_string);
+        assert_eq!(key, Some("raw:046d:c900:ff43:0202:serial:glow-1".into()));
+    }
 }
diff --git a/crates/openlogi-agent-core/src/event_monitor.rs b/crates/openlogi-agent-core/src/event_monitor.rs
index d83d2dfa15f3251aec650ed584cb4a8dfbee5889..2680d299c025043103107be5d5b38e2385ec4abd 100644
--- a/crates/openlogi-agent-core/src/event_monitor.rs
+++ b/crates/openlogi-agent-core/src/event_monitor.rs
@@ -55,7 +55,7 @@ impl EventMonitor {
             return;
         }
         let mapped = match event {
-            MouseEvent::Button { id, pressed } => MonitorEvent::Button {
+            MouseEvent::Button { id, pressed, .. } => MonitorEvent::Button {
                 button: id.to_string(),
                 pressed: *pressed,
             },
@@ -68,7 +68,9 @@ impl EventMonitor {
             MouseEvent::CaptureInterrupted => MonitorEvent::CaptureInterrupted,
             MouseEvent::Moved { .. } => return,
         };
-        if let Ok(mut buf) = self.buf.lock() {
+        // `try_lock` only — the freeze-sensitive hook callback must never block
+        // on the monitor buffer (a contended `lock` stalls every pointer event).
+        if let Ok(mut buf) = self.buf.try_lock() {
             if buf.len() == CAPACITY {
                 buf.pop_front();
             }
@@ -137,6 +139,7 @@ mod tests {
         m.record(&MouseEvent::Button {
             id: ButtonId::Back,
             pressed: true,
+            device: None,
         });
         assert!(!m.enabled());
 
@@ -152,6 +155,7 @@ mod tests {
         m.record(&MouseEvent::Button {
             id: ButtonId::Forward,
             pressed: false,
+            device: None,
         });
         assert_eq!(
             m.poll(),
diff --git a/crates/openlogi-agent-core/src/hardware.rs b/crates/openlogi-agent-core/src/hardware.rs
index 37d76689a5e1a033f430d2501442eb180a3462e4..69ea06c6067d167cfefa4b191832a93213743dca 100644
--- a/crates/openlogi-agent-core/src/hardware.rs
+++ b/crates/openlogi-agent-core/src/hardware.rs
@@ -6,22 +6,26 @@
 //! press) and avoids holding a long-lived async runtime alongside GPUI's
 //! executor.
 //!
-//! When the HID++ capture session already has the target device open, these
-//! reuse that channel ([`openlogi_hid::CaptureChannel`]) instead of
-//! re-enumerating and opening a fresh one — the dominant cost of a write. The
-//! transient open is kept as a fallback for callers (e.g. the CGEventTap hook)
-//! firing while no session is connected.
+//! Agent calls select a registry-confirmed capture channel or the exact current
+//! inventory channel. A registry miss is unavailable; the daemon never falls
+//! back to re-enumerating and opening a competing connection.
 
 use std::future::Future;
 use std::time::Duration;
 
 use openlogi_core::config::Lighting;
 use openlogi_hid::{
-    CaptureChannel, DeviceRoute, DpiInfo, HidppFeatureErrorKind, HidppOperation, ScrollResolution,
-    SharedChannel, SmartShiftMode, SmartShiftStatus, WriteError,
+    CaptureChannel, ChannelRegistry, DeviceRoute, DpiInfo, HidppFeatureErrorKind, HidppOperation,
+    ScrollResolution, SharedChannel, SmartShiftMode, SmartShiftStatus, WriteError,
 };
 use tracing::{debug, warn};
 
+use crate::receiver_access::ReceiverAccess;
+
+mod light;
+
+pub use light::{apply_light, cancel_light_reapply, set_light_in_background};
+
 /// Upper bound on a single HID++ write. `hidpp` has no request timeout of its
 /// own, so without this an asleep / unresponsive device would hang (and leak)
 /// this background thread forever; a write to a live device completes in well
@@ -32,7 +36,12 @@ const WRITE_BUDGET: Duration = Duration::from_secs(5);
 ///
 /// This helper is intentionally blocking so GPUI callers can run it via
 /// `cx.background_spawn` without making the UI thread own a Tokio runtime.
-pub fn read_dpi_info_blocking(target: &DeviceRoute) -> Result<DpiInfo, WriteError> {
+pub fn read_dpi_info_blocking(
+    capture: Option<&CaptureChannel>,
+    registry: &ChannelRegistry,
+    target: &DeviceRoute,
+) -> Result<DpiInfo, WriteError> {
+    let shared = authoritative_channel(capture, registry, target)?;
     let rt = tokio::runtime::Builder::new_current_thread()
         .enable_all()
         .build()
@@ -41,7 +50,7 @@ pub fn read_dpi_info_blocking(target: &DeviceRoute) -> Result<DpiInfo, WriteErro
         })?;
 
     rt.block_on(async {
-        tokio::time::timeout(WRITE_BUDGET, openlogi_hid::get_dpi_info(target))
+        tokio::time::timeout(WRITE_BUDGET, openlogi_hid::get_dpi_info_on(&shared))
             .await
             .map_err(|_| WriteError::RequestTimedOut {
                 operation: HidppOperation::ReadDpiCapabilities,
@@ -49,34 +58,54 @@ pub fn read_dpi_info_blocking(target: &DeviceRoute) -> Result<DpiInfo, WriteErro
     })
 }
 
-/// Clone out the capture session's channel when it reaches `route`. `None` when
-/// no capture session is connected or the open channel points at a different
-/// device.
-fn reusable_channel(
+/// Select the only Agent-authoritative channel for `route`.
+fn authoritative_channel(
     capture: Option<&CaptureChannel>,
+    registry: &ChannelRegistry,
     route: &DeviceRoute,
-) -> Option<SharedChannel> {
-    capture?
-        .read()
-        .ok()
+) -> Result<SharedChannel, WriteError> {
+    let capture = capture
+        .and_then(|capture| capture.read().ok())
         .and_then(|slot| (*slot).clone())
-        .filter(|chan| chan.matches(route))
+        .filter(|channel| channel.matches(route));
+    choose_authoritative(
+        capture,
+        |channel| registry.is_current(channel),
+        || registry.lookup(route),
+    )
+    .ok_or(WriteError::DeviceNotFound)
+}
+
+fn choose_authoritative<T>(
+    capture: Option<T>,
+    capture_is_current: impl FnOnce(&T) -> bool,
+    registry_lookup: impl FnOnce() -> Option<T>,
+) -> Option<T> {
+    match capture {
+        Some(capture) if capture_is_current(&capture) => Some(capture),
+        _ => registry_lookup(),
+    }
 }
 
 /// Spawn an OS thread that toggles SmartShift (free ↔ ratchet) on the
-/// device at `target` via `openlogi_hid::toggle_smartshift`. Returns
+/// device at `target` via its current shared channel. Returns
 /// immediately; failures (incl. devices that expose neither `0x2111` nor
 /// the older `0x2110` SmartShift feature) are logged.
 pub fn toggle_smartshift_in_background(
     capture: Option<&CaptureChannel>,
+    registry: &ChannelRegistry,
+    receiver_access: &ReceiverAccess,
     target: Option<DeviceRoute>,
 ) {
     let Some(target) = target else {
         debug!("no target device — SmartShift toggle skipped");
         return;
     };
-    let shared = reusable_channel(capture, &target);
-    let reused = shared.is_some();
+    let Ok(shared) = authoritative_channel(capture, registry, &target) else {
+        debug!(route = %target, "no inventory channel — SmartShift toggle skipped");
+        return;
+    };
+    let receiver_access = receiver_access.clone();
     std::thread::spawn(move || {
         let rt = match tokio::runtime::Builder::new_current_thread()
             .enable_all()
@@ -89,17 +118,15 @@ pub fn toggle_smartshift_in_background(
             }
         };
         let result = rt.block_on(async {
+            let _lease = receiver_access.acquire_for_io().await;
             tokio::time::timeout(WRITE_BUDGET, async {
-                match &shared {
-                    Some(shared) => openlogi_hid::toggle_smartshift_on(shared).await,
-                    None => openlogi_hid::toggle_smartshift(&target).await,
-                }
+                openlogi_hid::toggle_smartshift_on(&shared).await
             })
             .await
         });
         let index = target.device_index();
         match result {
-            Ok(Ok(mode)) => debug!(index, ?mode, reused, "SmartShift toggled"),
+            Ok(Ok(mode)) => debug!(index, ?mode, "SmartShift toggled"),
             Ok(Err(e)) => warn!(error = ?e, "SmartShift toggle failed"),
             Err(_) => warn!(
                 index,
@@ -115,8 +142,11 @@ pub fn toggle_smartshift_in_background(
 /// Blocking, like [`read_dpi_info_blocking`], so the SmartShift panel can run
 /// it off a dedicated OS thread without the UI thread owning a Tokio runtime.
 pub fn read_smartshift_status_blocking(
+    capture: Option<&CaptureChannel>,
+    registry: &ChannelRegistry,
     target: &DeviceRoute,
 ) -> Result<SmartShiftStatus, WriteError> {
+    let shared = authoritative_channel(capture, registry, target)?;
     let rt = tokio::runtime::Builder::new_current_thread()
         .enable_all()
         .build()
@@ -125,22 +155,27 @@ pub fn read_smartshift_status_blocking(
         })?;
 
     rt.block_on(async {
-        tokio::time::timeout(WRITE_BUDGET, openlogi_hid::get_smartshift_status(target))
-            .await
-            .map_err(|_| WriteError::RequestTimedOut {
-                operation: HidppOperation::ReadSmartShift,
-            })?
+        tokio::time::timeout(
+            WRITE_BUDGET,
+            openlogi_hid::get_smartshift_status_on(&shared),
+        )
+        .await
+        .map_err(|_| WriteError::RequestTimedOut {
+            operation: HidppOperation::ReadSmartShift,
+        })?
     })
 }
 
 /// Spawn an OS thread that writes a full SmartShift configuration to the device
-/// at `target` via [`openlogi_hid::set_smartshift`]. Returns immediately;
+/// at `target` via its current shared channel. Returns immediately;
 /// failures (incl. devices that expose neither `0x2111` nor the older `0x2110`
 /// SmartShift feature) are logged.
 ///
 /// `target == None` is a no-op (dev environment without a real device).
 pub fn write_smartshift_in_background(
     capture: Option<&CaptureChannel>,
+    registry: &ChannelRegistry,
+    receiver_access: &ReceiverAccess,
     target: Option<DeviceRoute>,
     mode: SmartShiftMode,
     auto_disengage: u8,
@@ -150,8 +185,11 @@ pub fn write_smartshift_in_background(
         debug!("no target device — SmartShift write skipped");
         return;
     };
-    let shared = reusable_channel(capture, &target);
-    let reused = shared.is_some();
+    let Ok(shared) = authoritative_channel(capture, registry, &target) else {
+        debug!(route = %target, "no inventory channel — SmartShift write skipped");
+        return;
+    };
+    let receiver_access = receiver_access.clone();
     std::thread::spawn(move || {
         let rt = match tokio::runtime::Builder::new_current_thread()
             .enable_all()
@@ -164,22 +202,9 @@ pub fn write_smartshift_in_background(
             }
         };
         let result = rt.block_on(async {
+            let _lease = receiver_access.acquire_for_io().await;
             tokio::time::timeout(WRITE_BUDGET, async {
-                match &shared {
-                    Some(shared) => {
-                        openlogi_hid::set_smartshift_on(
-                            shared,
-                            mode,
-                            auto_disengage,
-                            tunable_torque,
-                        )
-                        .await
-                    }
-                    None => {
-                        openlogi_hid::set_smartshift(&target, mode, auto_disengage, tunable_torque)
-                            .await
-                    }
-                }
+                openlogi_hid::set_smartshift_on(&shared, mode, auto_disengage, tunable_torque).await
             })
             .await
         });
@@ -190,7 +215,6 @@ pub fn write_smartshift_in_background(
                 ?mode,
                 auto_disengage,
                 tunable_torque,
-                reused,
                 "SmartShift config written"
             ),
             Ok(Err(e)) => warn!(error = ?e, "SmartShift write failed"),
@@ -202,6 +226,55 @@ pub fn write_smartshift_in_background(
     });
 }
 
+/// Spawn an OS thread that writes the keyboard Fn-lock state to the device at
+/// `target` via [`openlogi_hid::set_fn_lock_on`]. Returns immediately; failures
+/// (incl. keyboards that expose neither `0x40a3` nor `0x40a2` fn inversion)
+/// are logged.
+///
+/// `target == None` is a no-op (dev environment without a real device).
+pub fn write_fn_lock_in_background(
+    capture: Option<&CaptureChannel>,
+    registry: &ChannelRegistry,
+    receiver_access: &ReceiverAccess,
+    target: Option<DeviceRoute>,
+    on: bool,
+) {
+    let Some(target) = target else {
+        debug!(on, "no target device — Fn-lock write skipped");
+        return;
+    };
+    let Ok(shared) = authoritative_channel(capture, registry, &target) else {
+        debug!(route = %target, "no inventory channel — Fn-lock write skipped");
+        return;
+    };
+    let receiver_access = receiver_access.clone();
+    std::thread::spawn(move || {
+        let rt = match tokio::runtime::Builder::new_current_thread()
+            .enable_all()
+            .build()
+        {
+            Ok(rt) => rt,
+            Err(e) => {
+                warn!(error = %e, "tokio runtime init failed; Fn-lock write skipped");
+                return;
+            }
+        };
+        let result = rt.block_on(async {
+            let _lease = receiver_access.acquire_for_io().await;
+            tokio::time::timeout(WRITE_BUDGET, openlogi_hid::set_fn_lock_on(&shared, on)).await
+        });
+        let index = target.device_index();
+        match result {
+            Ok(Ok(())) => debug!(index, on, "Fn-lock written"),
+            Ok(Err(e)) => warn!(error = ?e, "Fn-lock write failed"),
+            Err(_) => warn!(
+                index,
+                "Fn-lock write timed out (device asleep/unresponsive)"
+            ),
+        }
+    });
+}
+
 /// Desired SmartShift values for a reconnect re-apply.
 #[derive(Debug, Clone, Copy)]
 pub struct SmartShiftApply {
@@ -214,7 +287,7 @@ pub struct SmartShiftApply {
 }
 
 /// Re-apply every volatile mouse setting for one device on a **single**
-/// background thread, sequentially, reusing the capture channel when available.
+/// background thread, sequentially, on the current inventory-owned channel.
 ///
 /// Agent-start reapply used to fire DPI / SmartShift / wheel-mode each on its
 /// own thread, and each opened a fresh HID++ channel when capture was not yet
@@ -222,16 +295,25 @@ pub struct SmartShiftApply {
 /// stream while correlating responses only by software id — they cross-talk and
 /// produce the intermittent SmartShift `InvalidArgument` seen in #485. One
 /// sequential writer removes that self-race.
+#[expect(
+    clippy::too_many_arguments,
+    reason = "background reapply keeps one device write lifecycle together"
+)]
 pub fn reapply_mouse_volatile_in_background(
     capture: Option<&CaptureChannel>,
+    registry: &ChannelRegistry,
+    receiver_access: &ReceiverAccess,
     target: DeviceRoute,
     resolution: Option<ScrollResolution>,
     inverted: Option<bool>,
     dpi: Option<u32>,
     smartshift: Option<SmartShiftApply>,
 ) {
-    let shared = reusable_channel(capture, &target);
-    let reused = shared.is_some();
+    let Ok(shared) = authoritative_channel(capture, registry, &target) else {
+        debug!(route = %target, "no inventory channel — volatile reapply skipped");
+        return;
+    };
+    let receiver_access = receiver_access.clone();
     std::thread::spawn(move || {
         let rt = match tokio::runtime::Builder::new_current_thread()
             .enable_all()
@@ -245,26 +327,24 @@ pub fn reapply_mouse_volatile_in_background(
         };
         let index = target.device_index();
         rt.block_on(async {
+            let _lease = receiver_access.acquire_for_io().await;
             if resolution.is_some() || inverted.is_some() {
                 let result = tokio::time::timeout(WRITE_BUDGET, async {
-                    apply_wheel_mode(shared.as_ref(), &target, resolution, inverted).await
+                    apply_wheel_mode(&shared, resolution, inverted).await
                 })
                 .await;
-                log_wheel_result(index, resolution, inverted, reused, result);
+                log_wheel_result(index, resolution, inverted, result);
             }
             if let Some(dpi) = dpi {
                 match u16::try_from(dpi) {
                     Ok(dpi_u16) => {
                         let result = tokio::time::timeout(WRITE_BUDGET, async {
-                            match &shared {
-                                Some(shared) => openlogi_hid::set_dpi_on(shared, dpi_u16).await,
-                                None => openlogi_hid::set_dpi(&target, dpi_u16).await,
-                            }
+                            openlogi_hid::set_dpi_on(&shared, dpi_u16).await
                         })
                         .await;
                         match result {
                             Ok(Ok(())) => {
-                                debug!(index, dpi = dpi_u16, reused, "DPI written to device");
+                                debug!(index, dpi = dpi_u16, "DPI written to device");
                             }
                             Ok(Err(e)) => warn!(error = ?e, "DPI write failed"),
                             Err(_) => warn!(
@@ -280,26 +360,13 @@ pub fn reapply_mouse_volatile_in_background(
             }
             if let Some(ss) = smartshift {
                 let result = tokio::time::timeout(WRITE_BUDGET, async {
-                    match &shared {
-                        Some(shared) => {
-                            openlogi_hid::set_smartshift_on(
-                                shared,
-                                ss.mode,
-                                ss.auto_disengage,
-                                ss.tunable_torque,
-                            )
-                            .await
-                        }
-                        None => {
-                            openlogi_hid::set_smartshift(
-                                &target,
-                                ss.mode,
-                                ss.auto_disengage,
-                                ss.tunable_torque,
-                            )
-                            .await
-                        }
-                    }
+                    openlogi_hid::set_smartshift_on(
+                        &shared,
+                        ss.mode,
+                        ss.auto_disengage,
+                        ss.tunable_torque,
+                    )
+                    .await
                 })
                 .await;
                 match result {
@@ -308,7 +375,6 @@ pub fn reapply_mouse_volatile_in_background(
                         mode = ?ss.mode,
                         auto_disengage = ss.auto_disengage,
                         tunable_torque = ss.tunable_torque,
-                        reused,
                         "SmartShift config written"
                     ),
                     Ok(Err(e)) => warn!(error = ?e, "SmartShift write failed"),
@@ -323,35 +389,21 @@ pub fn reapply_mouse_volatile_in_background(
 }
 
 async fn apply_wheel_mode(
-    shared: Option<&SharedChannel>,
-    target: &DeviceRoute,
+    shared: &SharedChannel,
     resolution: Option<ScrollResolution>,
     inverted: Option<bool>,
 ) -> Result<(), WriteError> {
-    match (resolution, inverted, shared) {
-        (Some(resolution), Some(inverted), Some(shared)) => {
+    match (resolution, inverted) {
+        (Some(resolution), Some(inverted)) => {
             openlogi_hid::set_scroll_wheel_mode_on(shared, resolution, inverted)
                 .await
                 .map(|_| ())
         }
-        (Some(resolution), Some(inverted), None) => {
-            openlogi_hid::set_scroll_wheel_mode(target, resolution, inverted)
-                .await
-                .map(|_| ())
-        }
-        (Some(resolution), None, Some(shared)) => {
-            openlogi_hid::set_scroll_resolution_on(shared, resolution)
-                .await
-                .map(|_| ())
-        }
-        (Some(resolution), None, None) => openlogi_hid::set_scroll_resolution(target, resolution)
+        (Some(resolution), None) => openlogi_hid::set_scroll_resolution_on(shared, resolution)
             .await
             .map(|_| ()),
-        (None, Some(inverted), Some(shared)) => {
-            openlogi_hid::set_scroll_inversion_on(shared, inverted).await
-        }
-        (None, Some(inverted), None) => openlogi_hid::set_scroll_inversion(target, inverted).await,
-        (None, None, _) => Ok(()),
+        (None, Some(inverted)) => openlogi_hid::set_scroll_inversion_on(shared, inverted).await,
+        (None, None) => Ok(()),
     }
 }
 
@@ -359,17 +411,10 @@ fn log_wheel_result(
     index: u8,
     resolution: Option<ScrollResolution>,
     inverted: Option<bool>,
-    reused: bool,
     result: Result<Result<(), WriteError>, tokio::time::error::Elapsed>,
 ) {
     match result {
-        Ok(Ok(())) => debug!(
-            index,
-            ?resolution,
-            ?inverted,
-            reused,
-            "native wheel mode written"
-        ),
+        Ok(Ok(())) => debug!(index, ?resolution, ?inverted, "native wheel mode written"),
         Ok(Err(WriteError::FeatureUnsupported { feature_hex })) => debug!(
             index,
             ?resolution,
@@ -387,12 +432,14 @@ fn log_wheel_result(
     }
 }
 
-/// Spawn an OS thread that writes `dpi` to the device at `target` via
-/// `openlogi_hid::set_dpi`. Returns immediately; failures are logged.
+/// Spawn an OS thread that writes `dpi` to the device at `target` via its
+/// current shared channel. Returns immediately; failures are logged.
 ///
 /// `target == None` is a no-op (dev environment without a real device).
 pub fn write_dpi_in_background(
     capture: Option<&CaptureChannel>,
+    registry: &ChannelRegistry,
+    receiver_access: &ReceiverAccess,
     target: Option<DeviceRoute>,
     dpi: u32,
 ) {
@@ -400,8 +447,11 @@ pub fn write_dpi_in_background(
         debug!(dpi, "no target device — DPI write skipped");
         return;
     };
-    let shared = reusable_channel(capture, &target);
-    let reused = shared.is_some();
+    let Ok(shared) = authoritative_channel(capture, registry, &target) else {
+        debug!(route = %target, "no inventory channel — DPI write skipped");
+        return;
+    };
+    let receiver_access = receiver_access.clone();
     std::thread::spawn(move || {
         let rt = match tokio::runtime::Builder::new_current_thread()
             .enable_all()
@@ -420,11 +470,9 @@ pub fn write_dpi_in_background(
             return;
         };
         let result = rt.block_on(async {
+            let _lease = receiver_access.acquire_for_io().await;
             tokio::time::timeout(WRITE_BUDGET, async {
-                match &shared {
-                    Some(shared) => openlogi_hid::set_dpi_on(shared, dpi_u16).await,
-                    None => openlogi_hid::set_dpi(&target, dpi_u16).await,
-                }
+                openlogi_hid::set_dpi_on(&shared, dpi_u16).await
             })
             .await
         });
@@ -432,7 +480,6 @@ pub fn write_dpi_in_background(
             Ok(Ok(())) => debug!(
                 index = target.device_index(),
                 dpi = dpi_u16,
-                reused,
                 "DPI written to device"
             ),
             Ok(Err(e)) => warn!(error = ?e, "DPI write failed"),
@@ -462,6 +509,8 @@ enum ScrollWheelModeChange {
 /// at debug level.
 pub fn write_scroll_wheel_mode_in_background(
     capture: Option<&CaptureChannel>,
+    registry: &ChannelRegistry,
+    receiver_access: &ReceiverAccess,
     target: Option<DeviceRoute>,
     resolution: Option<ScrollResolution>,
     inverted: Option<bool>,
@@ -486,8 +535,11 @@ pub fn write_scroll_wheel_mode_in_background(
             return;
         }
     };
-    let shared = reusable_channel(capture, &target);
-    let reused = shared.is_some();
+    let Ok(shared) = authoritative_channel(capture, registry, &target) else {
+        debug!(route = %target, "no inventory channel — wheel mode write skipped");
+        return;
+    };
+    let receiver_access = receiver_access.clone();
     std::thread::spawn(move || {
         let rt = match tokio::runtime::Builder::new_current_thread()
             .enable_all()
@@ -500,41 +552,22 @@ pub fn write_scroll_wheel_mode_in_background(
             }
         };
         let result = rt.block_on(async {
+            let _lease = receiver_access.acquire_for_io().await;
             tokio::time::timeout(WRITE_BUDGET, async {
-                match (change, &shared) {
-                    (
-                        ScrollWheelModeChange::ResolutionAndInversion {
-                            resolution,
-                            inverted,
-                        },
-                        Some(shared),
-                    ) => openlogi_hid::set_scroll_wheel_mode_on(shared, resolution, inverted)
-                        .await
-                        .map(|_| ()),
-                    (
-                        ScrollWheelModeChange::ResolutionAndInversion {
-                            resolution,
-                            inverted,
-                        },
-                        None,
-                    ) => openlogi_hid::set_scroll_wheel_mode(&target, resolution, inverted)
+                match change {
+                    ScrollWheelModeChange::ResolutionAndInversion {
+                        resolution,
+                        inverted,
+                    } => openlogi_hid::set_scroll_wheel_mode_on(&shared, resolution, inverted)
                         .await
                         .map(|_| ()),
-                    (ScrollWheelModeChange::Resolution(resolution), Some(shared)) => {
-                        openlogi_hid::set_scroll_resolution_on(shared, resolution)
-                            .await
-                            .map(|_| ())
-                    }
-                    (ScrollWheelModeChange::Resolution(resolution), None) => {
-                        openlogi_hid::set_scroll_resolution(&target, resolution)
+                    ScrollWheelModeChange::Resolution(resolution) => {
+                        openlogi_hid::set_scroll_resolution_on(&shared, resolution)
                             .await
                             .map(|_| ())
                     }
-                    (ScrollWheelModeChange::Inversion(inverted), Some(shared)) => {
-                        openlogi_hid::set_scroll_inversion_on(shared, inverted).await
-                    }
-                    (ScrollWheelModeChange::Inversion(inverted), None) => {
-                        openlogi_hid::set_scroll_inversion(&target, inverted).await
+                    ScrollWheelModeChange::Inversion(inverted) => {
+                        openlogi_hid::set_scroll_inversion_on(&shared, inverted).await
                     }
                 }
             })
@@ -542,13 +575,7 @@ pub fn write_scroll_wheel_mode_in_background(
         });
         let index = target.device_index();
         match result {
-            Ok(Ok(())) => debug!(
-                index,
-                ?resolution,
-                ?inverted,
-                reused,
-                "native wheel mode written"
-            ),
+            Ok(Ok(())) => debug!(index, ?resolution, ?inverted, "native wheel mode written"),
             Ok(Err(WriteError::FeatureUnsupported { feature_hex })) => debug!(
                 index,
                 ?resolution,
@@ -571,14 +598,26 @@ pub fn write_scroll_wheel_mode_in_background(
 ///
 /// Resolves the configured colour (scaled by brightness, or black when the
 /// lighting is off) and writes every key over HID++ via
-/// [`openlogi_hid::set_keyboard_color`]. A `None` target is a no-op (dev runs
-/// without a device); failures are logged, not surfaced.
-pub fn set_lighting_in_background(target: Option<DeviceRoute>, lighting: &Lighting) {
+/// [`openlogi_hid::set_keyboard_color_on`]. A `None` target is a no-op (dev
+/// runs without a device); a registry miss and write failures are logged, not
+/// surfaced.
+pub fn set_lighting_in_background(
+    capture: Option<&CaptureChannel>,
+    registry: &ChannelRegistry,
+    receiver_access: &ReceiverAccess,
+    target: Option<DeviceRoute>,
+    lighting: &Lighting,
+) {
     let Some(target) = target else {
         debug!("no target device — lighting write skipped");
         return;
     };
+    let Ok(shared) = authoritative_channel(capture, registry, &target) else {
+        debug!(route = %target, "no inventory channel — lighting write skipped");
+        return;
+    };
     let (r, g, b) = lighting_rgb(lighting);
+    let receiver_access = receiver_access.clone();
     std::thread::spawn(move || {
         let rt = match tokio::runtime::Builder::new_current_thread()
             .enable_all()
@@ -590,7 +629,11 @@ pub fn set_lighting_in_background(target: Option<DeviceRoute>, lighting: &Lighti
                 return;
             }
         };
-        match rt.block_on(openlogi_hid::set_keyboard_color(&target, r, g, b)) {
+        let result = rt.block_on(async {
+            let _lease = receiver_access.acquire_for_io().await;
+            openlogi_hid::set_keyboard_color_on(&shared, r, g, b).await
+        });
+        match result {
             Ok(()) => debug!(r, g, b, "lighting written to keyboard"),
             Err(e) => warn!(error = ?e, "lighting write failed"),
         }
@@ -611,13 +654,15 @@ fn lighting_rgb(lighting: &Lighting) -> (u8, u8, u8) {
 
 // Async, awaitable variants used by the IPC server (the GUI routes "apply now"
 // / "read" device commands through the agent, which awaits and reports the
-// result). Writes reuse the capture session's open channel when it targets the
-// same device, exactly like the fire-and-forget `*_in_background` helpers, so
-// the daemon never opens a second channel to a device it already holds.
+// result). They use a registry-confirmed capture channel or the exact current
+// inventory channel, exactly like the fire-and-forget `*_in_background`
+// helpers, so the daemon never opens a second channel to a device it holds.
 
-/// Apply `dpi` to `route`, reusing the capture session's channel when possible.
+/// Apply `dpi` to `route` on its current inventory-owned channel.
 pub async fn apply_dpi(
     capture: &CaptureChannel,
+    registry: &ChannelRegistry,
+    receiver_access: &ReceiverAccess,
     route: &DeviceRoute,
     dpi: u32,
 ) -> Result<(), WriteError> {
@@ -628,60 +673,80 @@ pub async fn apply_dpi(
         feature_hex: 0x2201,
         kind: HidppFeatureErrorKind::OutOfRange,
     })?;
-    let shared = reusable_channel(Some(capture), route);
-    timed(HidppOperation::WriteDpi, async {
-        match &shared {
-            Some(shared) => openlogi_hid::set_dpi_on(shared, dpi).await,
-            None => openlogi_hid::set_dpi(route, dpi).await,
-        }
-    })
+    let _lease = receiver_access.acquire_for_io().await;
+    let shared = authoritative_channel(Some(capture), registry, route)?;
+    timed(
+        HidppOperation::WriteDpi,
+        openlogi_hid::set_dpi_on(&shared, dpi),
+    )
     .await
 }
 
 /// Apply a full SmartShift config to `route` (capture-channel-aware).
 pub async fn apply_smartshift(
     capture: &CaptureChannel,
+    registry: &ChannelRegistry,
+    receiver_access: &ReceiverAccess,
     route: &DeviceRoute,
     mode: SmartShiftMode,
     auto_disengage: u8,
     tunable_torque: u8,
 ) -> Result<(), WriteError> {
-    let shared = reusable_channel(Some(capture), route);
-    timed(HidppOperation::WriteSmartShift, async {
-        match &shared {
-            Some(shared) => {
-                openlogi_hid::set_smartshift_on(shared, mode, auto_disengage, tunable_torque).await
-            }
-            None => openlogi_hid::set_smartshift(route, mode, auto_disengage, tunable_torque).await,
-        }
-    })
+    let _lease = receiver_access.acquire_for_io().await;
+    let shared = authoritative_channel(Some(capture), registry, route)?;
+    timed(
+        HidppOperation::WriteSmartShift,
+        openlogi_hid::set_smartshift_on(&shared, mode, auto_disengage, tunable_torque),
+    )
     .await
 }
 
 /// Apply a lighting config to the keyboard at `route`.
-pub async fn apply_lighting(route: &DeviceRoute, lighting: &Lighting) -> Result<(), WriteError> {
+pub async fn apply_lighting(
+    capture: &CaptureChannel,
+    registry: &ChannelRegistry,
+    receiver_access: &ReceiverAccess,
+    route: &DeviceRoute,
+    lighting: &Lighting,
+) -> Result<(), WriteError> {
+    let _lease = receiver_access.acquire_for_io().await;
+    let shared = authoritative_channel(Some(capture), registry, route)?;
     let (r, g, b) = lighting_rgb(lighting);
     timed(
         HidppOperation::Lighting,
-        openlogi_hid::set_keyboard_color(route, r, g, b),
+        openlogi_hid::set_keyboard_color_on(&shared, r, g, b),
     )
     .await
 }
 
 /// Read the current DPI + supported values from `route`.
-pub async fn read_dpi(route: &DeviceRoute) -> Result<DpiInfo, WriteError> {
+pub async fn read_dpi(
+    capture: &CaptureChannel,
+    registry: &ChannelRegistry,
+    receiver_access: &ReceiverAccess,
+    route: &DeviceRoute,
+) -> Result<DpiInfo, WriteError> {
+    let _lease = receiver_access.acquire_for_io().await;
+    let shared = authoritative_channel(Some(capture), registry, route)?;
     timed(
         HidppOperation::ReadDpiCapabilities,
-        openlogi_hid::get_dpi_info(route),
+        openlogi_hid::get_dpi_info_on(&shared),
     )
     .await
 }
 
 /// Read the current SmartShift config from `route`.
-pub async fn read_smartshift(route: &DeviceRoute) -> Result<SmartShiftStatus, WriteError> {
+pub async fn read_smartshift(
+    capture: &CaptureChannel,
+    registry: &ChannelRegistry,
+    receiver_access: &ReceiverAccess,
+    route: &DeviceRoute,
+) -> Result<SmartShiftStatus, WriteError> {
+    let _lease = receiver_access.acquire_for_io().await;
+    let shared = authoritative_channel(Some(capture), registry, route)?;
     timed(
         HidppOperation::ReadSmartShift,
-        openlogi_hid::get_smartshift_status(route),
+        openlogi_hid::get_smartshift_status_on(&shared),
     )
     .await
 }
@@ -696,3 +761,40 @@ async fn timed<T>(
         .await
         .map_err(|_| WriteError::RequestTimedOut { operation })?
 }
+
+#[cfg(test)]
+mod tests {
+    use std::cell::Cell;
+
+    use super::choose_authoritative;
+
+    #[test]
+    fn current_capture_wins_without_consulting_the_registry_again() {
+        let looked_up = Cell::new(false);
+        let selected = choose_authoritative(
+            Some("capture"),
+            |_| true,
+            || {
+                looked_up.set(true);
+                Some("registry")
+            },
+        );
+
+        assert_eq!(selected, Some("capture"));
+        assert!(!looked_up.get());
+    }
+
+    #[test]
+    fn stale_capture_falls_through_to_the_registry_winner() {
+        let selected = choose_authoritative(Some("stale"), |_| false, || Some("registry-current"));
+
+        assert_eq!(selected, Some("registry-current"));
+    }
+
+    #[test]
+    fn registry_miss_has_no_route_open_fallback() {
+        let selected = choose_authoritative(Some("stale"), |_| false, || None);
+
+        assert_eq!(selected, None);
+    }
+}
diff --git a/crates/openlogi-agent-core/src/hardware/light.rs b/crates/openlogi-agent-core/src/hardware/light.rs
new file mode 100644
index 0000000000000000000000000000000000000000..33eaf2d4b0b1aaa2bf256bf36ccbd18ff051b864
--- /dev/null
+++ b/crates/openlogi-agent-core/src/hardware/light.rs
@@ -0,0 +1,229 @@
+//! Serialized standalone-light writes and reconnect re-application.
+
+use std::collections::HashMap;
+use std::sync::atomic::{AtomicU64, Ordering};
+use std::sync::{Arc, LazyLock, Mutex, mpsc};
+use std::thread;
+
+use openlogi_core::config::LightSettings;
+use openlogi_core::device::LightCapabilities;
+use openlogi_hid::{
+    DeviceRoute, HidppOperation, LightCommand, LitraModel, WriteError, commands_for_light_settings,
+};
+use tracing::{debug, info, warn};
+
+struct LightApplyRequest {
+    settings: LightSettings,
+    capabilities: LightCapabilities,
+    generation: u64,
+}
+
+#[derive(Clone)]
+struct LightWorkerHandle {
+    sender: mpsc::Sender<LightApplyRequest>,
+    generation: Arc<AtomicU64>,
+}
+
+/// One coalescing worker per physical light. Reconnect and config transitions
+/// can overlap. Keeping one worker per route gives us ordered writes for that
+/// light, coalesces a burst to the latest desired state, and avoids creating a
+/// Tokio runtime and OS thread for every transition.
+static LIGHT_WORKERS: LazyLock<Mutex<HashMap<String, LightWorkerHandle>>> =
+    LazyLock::new(|| Mutex::new(HashMap::new()));
+
+type LightWriteLock = Arc<tokio::sync::Mutex<()>>;
+
+/// Serialize complete light-setting sequences with individual user commands.
+/// The HID layer already serializes each packet, while reconnect/config
+/// re-application writes power, brightness, and temperature as one operation.
+static LIGHT_WRITE_LOCKS: LazyLock<Mutex<HashMap<String, LightWriteLock>>> =
+    LazyLock::new(|| Mutex::new(HashMap::new()));
+
+/// Apply standalone-light settings during reconnect or config re-application.
+/// Failures are logged because this path is best-effort; an explicit IPC
+/// command returns the typed error to the caller instead.
+pub fn set_light_in_background(
+    target: Option<DeviceRoute>,
+    light: &LightSettings,
+    capabilities: LightCapabilities,
+) {
+    let Some(target) = target else {
+        debug!("no target device — light write skipped");
+        return;
+    };
+    let key = target.to_string();
+    let Some(worker) = light_worker(&key, target) else {
+        return;
+    };
+    let generation = worker.generation.fetch_add(1, Ordering::AcqRel) + 1;
+    if worker
+        .sender
+        .send(LightApplyRequest {
+            settings: *light,
+            capabilities,
+            generation,
+        })
+        .is_err()
+    {
+        warn!(route = %key, "light re-apply worker stopped");
+        remove_light_worker(&key, generation);
+    }
+}
+
+/// Invalidate pending best-effort writes before an explicit user command.
+/// Already-running writes are serialized by the HID driver's device lock; a
+/// newer explicit command therefore remains the final state.
+pub fn cancel_light_reapply(target: &DeviceRoute) {
+    let key = target.to_string();
+    let Ok(workers) = LIGHT_WORKERS.lock() else {
+        warn!(route = %key, "light worker registry poisoned — cannot cancel stale write");
+        return;
+    };
+    if let Some(worker) = workers.get(&key) {
+        worker.generation.fetch_add(1, Ordering::AcqRel);
+    }
+}
+
+fn light_worker(key: &str, target: DeviceRoute) -> Option<LightWorkerHandle> {
+    let Ok(mut workers) = LIGHT_WORKERS.lock() else {
+        warn!(
+            route = key,
+            "light worker registry poisoned — write skipped"
+        );
+        return None;
+    };
+    if let Some(worker) = workers.get(key) {
+        return Some(worker.clone());
+    }
+
+    let (sender, receiver) = mpsc::channel();
+    let generation = Arc::new(AtomicU64::new(0));
+    let worker_generation = Arc::clone(&generation);
+    let worker_key = key.to_string();
+    if let Err(error) = thread::Builder::new()
+        .name(format!("openlogi-light-{}", key.replace(':', "-")))
+        .spawn(move || light_worker_loop(target, receiver, worker_generation))
+    {
+        warn!(route = %worker_key, error = %error, "could not spawn light worker");
+        return None;
+    }
+    let worker = LightWorkerHandle { sender, generation };
+    workers.insert(worker_key, worker.clone());
+    Some(worker)
+}
+
+fn remove_light_worker(key: &str, generation: u64) {
+    let Ok(mut workers) = LIGHT_WORKERS.lock() else {
+        return;
+    };
+    if workers
+        .get(key)
+        .is_some_and(|worker| worker.generation.load(Ordering::Acquire) == generation)
+    {
+        workers.remove(key);
+    }
+}
+
+#[expect(
+    clippy::needless_pass_by_value,
+    reason = "the worker thread must own its route, receiver, and generation state"
+)]
+fn light_worker_loop(
+    target: DeviceRoute,
+    receiver: mpsc::Receiver<LightApplyRequest>,
+    generation: Arc<AtomicU64>,
+) {
+    let rt = match tokio::runtime::Builder::new_current_thread()
+        .enable_all()
+        .build()
+    {
+        Ok(rt) => rt,
+        Err(error) => {
+            warn!(route = %target, error = %error, "light worker runtime init failed");
+            return;
+        }
+    };
+    while let Ok(mut request) = receiver.recv() {
+        while let Ok(next) = receiver.try_recv() {
+            request = next;
+        }
+        if generation.load(Ordering::Acquire) != request.generation {
+            debug!(route = %target, "skipping superseded light re-apply");
+            continue;
+        }
+        let result = rt.block_on(apply_light_settings(
+            &target,
+            &request.settings,
+            request.capabilities,
+            &generation,
+            request.generation,
+        ));
+        match result {
+            Ok(true) => info!(
+                route = %target,
+                enabled = request.settings.enabled,
+                brightness = request.settings.brightness_percent,
+                temperature = ?request.settings.temperature_kelvin,
+                "light re-apply completed"
+            ),
+            Ok(false) => debug!(route = %target, "skipping canceled light re-apply"),
+            Err(error) => warn!(route = %target, error = ?error, "light settings re-apply failed"),
+        }
+    }
+}
+
+async fn apply_light_settings(
+    target: &DeviceRoute,
+    light: &LightSettings,
+    capabilities: LightCapabilities,
+    generation: &AtomicU64,
+    expected_generation: u64,
+) -> Result<bool, WriteError> {
+    let lock = light_write_lock(target);
+    let _guard = lock.lock().await;
+    // The request may have passed the queue check while an explicit command
+    // held the route lock. Re-check under that lock before writing anything so
+    // a canceled re-apply cannot overwrite the newer explicit state.
+    if generation.load(Ordering::Acquire) != expected_generation {
+        return Ok(false);
+    }
+    for command in commands_for_light_settings(*light, capabilities) {
+        apply_light_unlocked(target, command).await?;
+    }
+    Ok(true)
+}
+
+/// Apply a semantic command to a supported standalone light.
+pub async fn apply_light(route: &DeviceRoute, command: LightCommand) -> Result<(), WriteError> {
+    let lock = light_write_lock(route);
+    let _guard = lock.lock().await;
+    apply_light_unlocked(route, command).await
+}
+
+async fn apply_light_unlocked(
+    route: &DeviceRoute,
+    command: LightCommand,
+) -> Result<(), WriteError> {
+    let Some(model) = LitraModel::from_route(route) else {
+        return Err(WriteError::LightUnsupported {
+            control: "raw_hid_route".into(),
+        });
+    };
+    super::timed(
+        HidppOperation::Light,
+        openlogi_hid::apply_litra(route, model, command),
+    )
+    .await
+}
+
+fn light_write_lock(route: &DeviceRoute) -> LightWriteLock {
+    let key = route.to_string();
+    let Ok(mut locks) = LIGHT_WRITE_LOCKS.lock() else {
+        warn!(route = %key, "light write lock registry poisoned — using an isolated lock");
+        return Arc::new(tokio::sync::Mutex::new(()));
+    };
+    locks
+        .entry(key)
+        .or_insert_with(|| Arc::new(tokio::sync::Mutex::new(())))
+        .clone()
+}
diff --git a/crates/openlogi-agent-core/src/hook_runtime.rs b/crates/openlogi-agent-core/src/hook_runtime.rs
index dc140597338012087887c525e315c0ebf1372657..125bc2c1553a0ee265e48ed0051743982983c49c 100644
--- a/crates/openlogi-agent-core/src/hook_runtime.rs
+++ b/crates/openlogi-agent-core/src/hook_runtime.rs
@@ -6,19 +6,26 @@
 //! and gesture events.
 
 use std::cell::RefCell;
-use std::collections::BTreeMap;
-use std::sync::{Arc, RwLock};
+use std::collections::{BTreeMap, HashSet};
+use std::sync::mpsc;
+use std::sync::{Arc, Mutex, PoisonError, RwLock};
+use std::thread;
+use std::time::{Duration, Instant};
 
 use openlogi_core::binding::{
     Action, ButtonId, GestureDirection, SwipeAccumulator, default_binding,
 };
-use openlogi_hid::CaptureChannel;
-use openlogi_hook::{EventDisposition, Hook, MouseEvent};
+use openlogi_core::config::{KeyModifiers, KeyTrigger};
+use openlogi_hid::{CaptureChannel, ChannelRegistry};
+use openlogi_hook::{
+    EventDevice, EventDisposition, Hook, HookEvent, MouseEvent, source_is_remappable,
+};
 use tracing::{info, warn};
 
 use crate::DpiCycleState;
 use crate::event_monitor::SharedEventMonitor;
 use crate::hardware::{toggle_smartshift_in_background, write_dpi_in_background};
+use crate::receiver_access::ReceiverAccess;
 
 /// The two button maps the OS-hook callback reads, kept behind ONE lock so a
 /// config rebuild publishes both atomically — a press during an owner switch can
@@ -39,6 +46,24 @@ pub struct HookMaps {
 /// (orchestrator), the OS-hook callback, and the gesture watcher.
 pub type SharedHookMaps = Arc<RwLock<HookMaps>>;
 
+/// Shared keyboard trigger→action map for the function-key remapper. Unlike
+/// mouse bindings these are not per-app-profile (M1 scope — per the spec's
+/// non-goals), so a single map suffices. Keyed by the config `KeyTrigger`
+/// (keycode + modifiers).
+pub type SharedKeyboardBindings = Arc<RwLock<std::collections::HashMap<KeyTrigger, Action>>>;
+
+/// Convert the hook-layer modifier state into the config-layer type (the two
+/// live in different crates — core is leaf-level and duplicates the four
+/// bools). Drop-in identity once the field names align.
+fn convert_modifiers(m: openlogi_hook::KeyModifiers) -> KeyModifiers {
+    KeyModifiers {
+        shift: m.shift,
+        control: m.control,
+        option: m.option,
+        command: m.command,
+    }
+}
+
 /// Tracks which OS-hook button (Middle/Back/Forward) is mid-hold and defers the
 /// swipe detection itself to a shared [`SwipeAccumulator`], which commits a swipe
 /// *mid-motion* like the HID++ gesture-button path in `openlogi-hid`. This wrapper
@@ -94,14 +119,184 @@ thread_local! {
     /// Thread-local rather than a shared `Mutex` keeps the hot path lock-free and
     /// free of cross-thread contention on the freeze-sensitive callback.
     static HOLD: RefCell<HoldState> = RefCell::new(HoldState::default());
+    /// Buttons whose physical press was delivered because the action queue
+    /// rejected the remap. Their matching release must also pass through so
+    /// apps never see a stuck auxiliary button (down without up).
+    static FAIL_OPEN_PRESSES: RefCell<HashSet<ButtonId>> = RefCell::new(HashSet::new());
+}
+
+/// Whether a button event's physical source may be remapped/suppressed.
+///
+/// macOS attributes every CGEvent to an IOKit sender and fails closed: only
+/// known Logitech non-trackpad devices are remappable, so the built-in
+/// trackpad can never be swallowed. Linux/Windows often lack attribution
+/// (`device: None`); those platforms already restrict which devices the hook
+/// attaches to, so unknown sources stay remappable.
+fn button_source_may_remap(device: Option<&EventDevice>) -> bool {
+    match device {
+        Some(d) => source_is_remappable(Some(d)),
+        None => {
+            // Attribution missing: safe on Linux/Windows (device selection is
+            // upstream of the callback). On macOS fail closed — an unattributed
+            // event is more likely a trackpad/system source than a Logi mouse.
+            !cfg!(target_os = "macos")
+        }
+    }
+}
+
+/// Off-thread worker for bound actions so the tap callback never injects input.
+fn spawn_action_worker(
+    dpi_cycle: Arc<RwLock<DpiCycleState>>,
+    capture: CaptureChannel,
+    registry: ChannelRegistry,
+    receiver_access: ReceiverAccess,
+) -> mpsc::SyncSender<Action> {
+    let (tx, rx) = mpsc::sync_channel::<Action>(64);
+    let _ = thread::Builder::new()
+        .name("openlogi-action".into())
+        .spawn(move || {
+            while let Ok(action) = rx.recv() {
+                dispatch_action(
+                    &action,
+                    &dpi_cycle,
+                    &capture,
+                    Some(&registry),
+                    &receiver_access,
+                );
+            }
+        });
+    tx
+}
+
+/// Queue a bound action without blocking the tap callback. Returns `false` if
+/// the queue is full (caller should fail open and pass the physical event).
+fn try_queue_action(tx: &mpsc::SyncSender<Action>, action: Action) -> bool {
+    if tx.try_send(action).is_err() {
+        warn!("action queue full — dropping bound action to keep the input hook live");
+        false
+    } else {
+        true
+    }
+}
+
+/// Remap path for Middle/Back/Forward. Must stay lock-light and non-blocking.
+fn handle_button(
+    id: ButtonId,
+    pressed: bool,
+    device: Option<&EventDevice>,
+    hooks: &SharedHookMaps,
+    action_tx: &mpsc::SyncSender<Action>,
+) -> EventDisposition {
+    // Primary L/R always pass through (suppressing them would brick the mouse).
+    if !id.is_os_hook_button() || !button_source_may_remap(device) {
+        return EventDisposition::PassThrough;
+    }
+
+    // `try_read` only: a blocking read on the tap thread freezes every pointer
+    // event while a config rebuild holds the write lock. Fail open if unavailable.
+    if pressed {
+        let is_gesture = hooks.try_read().is_ok_and(|m| m.gestures.contains_key(&id));
+        if is_gesture {
+            HOLD.with_borrow_mut(|h| h.begin(id));
+            return EventDisposition::Suppress;
+        }
+    } else {
+        // Drop the HOLD borrow before any queueing (re-entrancy freeze hazard).
+        let ended = HOLD.with_borrow_mut(|h| h.end(id));
+        if let Some(was_click) = ended {
+            if was_click {
+                let action = hooks
+                    .try_read()
+                    .ok()
+                    .map(|m| resolve_gesture_click(&m.gestures, id));
+                if let Some(action) = action {
+                    info!(button = %id, action = %action.label(), "gesture click → executing bound action");
+                    let _ = try_queue_action(action_tx, action);
+                }
+            }
+            return EventDisposition::Suppress;
+        }
+    }
+
+    let action = hooks
+        .try_read()
+        .ok()
+        .and_then(|m| m.bindings.get(&id).cloned());
+    let Some(action) = action else {
+        return EventDisposition::PassThrough;
+    };
+    if is_native_click(id, &action) {
+        return EventDisposition::PassThrough;
+    }
+    if pressed {
+        info!(button = %id, action = %action.label(), "button → executing bound action");
+        let queued = try_queue_action(action_tx, action);
+        return FAIL_OPEN_PRESSES.with_borrow_mut(|s| remapped_press_disposition(id, queued, s));
+    }
+    FAIL_OPEN_PRESSES.with_borrow_mut(|s| remapped_release_disposition(id, s))
+}
+
+/// Press of a remapped single-action button: suppress when the action was
+/// queued, otherwise pass through and mark `id` so the release pairs.
+fn remapped_press_disposition(
+    id: ButtonId,
+    queued: bool,
+    fail_open: &mut HashSet<ButtonId>,
+) -> EventDisposition {
+    if queued {
+        fail_open.remove(&id);
+        EventDisposition::Suppress
+    } else {
+        fail_open.insert(id);
+        EventDisposition::PassThrough
+    }
+}
+
+/// Release of a remapped single-action button: pass through only when the
+/// matching press was fail-opened (queue rejection), else suppress.
+fn remapped_release_disposition(
+    id: ButtonId,
+    fail_open: &mut HashSet<ButtonId>,
+) -> EventDisposition {
+    if fail_open.remove(&id) {
+        EventDisposition::PassThrough
+    } else {
+        EventDisposition::Suppress
+    }
+}
+
+/// Feed an in-progress gesture hold; always pass motion through so the cursor moves.
+fn handle_moved(
+    delta_x: i32,
+    delta_y: i32,
+    hooks: &SharedHookMaps,
+    action_tx: &mpsc::SyncSender<Action>,
+) -> EventDisposition {
+    let commit = HOLD.with_borrow_mut(|h| h.accumulate(delta_x, delta_y));
+    if let Some((button, dir)) = commit {
+        let action = hooks.try_read().ok().map(|m| {
+            m.gestures
+                .get(&button)
+                .and_then(|dirs| dirs.get(&dir).cloned())
+                .unwrap_or_else(|| resolve_gesture_click(&m.gestures, button))
+        });
+        if let Some(action) = action {
+            info!(button = %button, ?dir, action = %action.label(), "gesture swipe → executing bound action");
+            let _ = try_queue_action(action_tx, action);
+        }
+    }
+    EventDisposition::PassThrough
 }
 
 /// Attempt to start the OS hook. Returns `None` if Accessibility is not
 /// granted or on an unsupported platform — the app continues without crashing.
 pub fn start(
     hooks: SharedHookMaps,
+    keyboard_bindings: SharedKeyboardBindings,
     dpi_cycle: Arc<RwLock<DpiCycleState>>,
     capture: CaptureChannel,
+    registry: ChannelRegistry,
+    receiver_access: ReceiverAccess,
     monitor: SharedEventMonitor,
 ) -> Option<Hook> {
     if !Hook::has_accessibility() {
@@ -112,152 +307,96 @@ pub fn start(
         return None;
     }
 
+    // Actions never run on the tap callback thread (HID CGEventTap freeze hazard).
+    let action_tx = spawn_action_worker(dpi_cycle, capture, registry, receiver_access);
+
     // The per-hold pointer accumulator lives in the thread-local `HOLD`; the
     // callback must never block — see the freeze-hazard note in `macos.rs`.
-    let result = Hook::start(move |event| {
-        // Mirror the raw event to the GUI's live monitor first (a single relaxed
-        // atomic load while monitoring is off — see `event_monitor`), before any
-        // remapping decides its disposition.
-        monitor.record(&event);
-        match event {
-            MouseEvent::Button { id, pressed } => {
-                // The CGEventTap only sees standard buttons 0-4. We remap
-                // Middle/Back/Forward; the primary L/R clicks always pass through
-                // (suppressing them would brick the mouse), and the DPI / thumb /
-                // dedicated gesture button aren't visible to the tap at all — the
-                // dedicated gesture button is captured separately over HID++.
-                if !id.is_os_hook_button() {
-                    return EventDisposition::PassThrough;
+    let result = Hook::start(move |event| match event {
+        HookEvent::Mouse(event) => {
+            monitor.record(&event);
+            match event {
+                MouseEvent::Button {
+                    id,
+                    pressed,
+                    device,
+                } => handle_button(id, pressed, device.as_ref(), &hooks, &action_tx),
+                MouseEvent::Moved { delta_x, delta_y } => {
+                    handle_moved(delta_x, delta_y, &hooks, &action_tx)
                 }
-
-                // Gesture button: suppress the native click and begin a hold. The
-                // swipe commits mid-motion in the `Moved` arm; here, on release, we
-                // only fire the plain `Click` when no swipe committed. The cursor is
-                // free to drift via the pass-through `Moved` events during the hold.
-                if pressed {
-                    let is_gesture = hooks.read().is_ok_and(|m| m.gestures.contains_key(&id));
-                    if is_gesture {
-                        HOLD.with_borrow_mut(|h| h.begin(id));
-                        return EventDisposition::Suppress;
-                    }
-                } else {
-                    // Release: end the hold and release the `HOLD` borrow *before* any
-                    // dispatch — the callback must stay lock-light, since a
-                    // synthesized event could otherwise re-enter the tap and re-borrow
-                    // `HOLD` (a RefCell double-borrow panic, freeze hazard).
-                    let ended = HOLD.with_borrow_mut(|h| h.end(id));
-                    if let Some(was_click) = ended {
-                        if was_click {
-                            // No swipe committed → fire the plain click. Resolve to an
-                            // owned action (so no lock is held across dispatch), then
-                            // dispatch with the guard already dropped.
-                            let action = hooks
-                                .read()
-                                .ok()
-                                .map(|m| resolve_gesture_click(&m.gestures, id));
-                            if let Some(action) = action {
-                                info!(button = %id, action = %action.label(), "gesture click → executing bound action");
-                                dispatch_action(&action, &dpi_cycle, &capture);
-                            }
-                        }
-                        return EventDisposition::Suppress;
-                    }
+                MouseEvent::CaptureInterrupted => {
+                    HOLD.with_borrow_mut(HoldState::cancel);
+                    EventDisposition::PassThrough
                 }
-
-                // Single-action button.
-                let action = hooks.read().ok().and_then(|m| m.bindings.get(&id).cloned());
-                let Some(action) = action else {
-                    // Unbound → leave the physical button to the OS.
-                    return EventDisposition::PassThrough;
-                };
-
-                // A button left on its own native click (e.g. Middle → MiddleClick)
-                // should just do that click; suppressing and re-synthesising it
-                // would be pointless churn.
-                if is_native_click(id, &action) {
-                    return EventDisposition::PassThrough;
-                }
-
-                if pressed {
-                    info!(button = %id, action = %action.label(), "button → executing bound action");
-                    dispatch_action(&action, &dpi_cycle, &capture);
-                }
-                EventDisposition::Suppress
-            }
-            MouseEvent::Moved { delta_x, delta_y } => {
-                // Feed an in-progress hold; a committed swipe fires here, mid-motion.
-                // Always pass through so the cursor keeps moving — the swipe is read,
-                // not consumed (the B2 cursor-drift tradeoff vs. a HID++ raw-XY divert
-                // that would freeze the pointer).
-                let commit = HOLD.with_borrow_mut(|h| h.accumulate(delta_x, delta_y));
-                if let Some((button, dir)) = commit {
-                    // Resolve to an owned action and drop the read guard before
-                    // dispatch (same lock-light rule as the release arm). The button
-                    // can leave the gesture set mid-hold (a per-app rebuild); the
-                    // commit has already armed `fired`, so the release won't fire a
-                    // click. Fall back to the same click action the release path uses
-                    // so the suppressed press is never swallowed into nothing —
-                    // symmetric with `resolve_gesture_click`.
-                    let action = hooks.read().ok().map(|m| {
-                        m.gestures
-                            .get(&button)
-                            .and_then(|dirs| dirs.get(&dir).cloned())
-                            .unwrap_or_else(|| resolve_gesture_click(&m.gestures, button))
-                    });
-                    if let Some(action) = action {
-                        info!(button = %button, ?dir, action = %action.label(), "gesture swipe → executing bound action");
-                        dispatch_action(&action, &dpi_cycle, &capture);
+                MouseEvent::Scroll {
+                    delta_x, delta_y, ..
+                } => {
+                    #[cfg(not(target_os = "windows"))]
+                    let _ = (delta_x, delta_y);
+                    #[cfg(target_os = "windows")]
+                    if delta_y == 0.0
+                        && let Some((button, action)) = hooks
+                            .try_read()
+                            .ok()
+                            .and_then(|maps| rebound_thumbwheel_action(&maps, delta_x))
+                    {
+                        info!(button = %button, action = %action.label(), "native thumb wheel → executing bound action");
+                        if try_queue_action(&action_tx, action) {
+                            return EventDisposition::Suppress;
+                        }
                     }
+                    EventDisposition::PassThrough
                 }
-                EventDisposition::PassThrough
             }
-            MouseEvent::CaptureInterrupted => {
-                // The OS dropped events (tap disabled); cancel any hold so a lost
-                // button-up can't later commit a phantom swipe off ordinary motion.
-                HOLD.with_borrow_mut(HoldState::cancel);
-                EventDisposition::PassThrough
+        }
+        // Function-key remapper: on key-down, look up a [keyboard.bindings]
+        // entry for this keycode + modifier mask. A match queues its action
+        // (suppressing the original key so it doesn't also type / trigger its
+        // native function); an unmatched key passes through untouched. Key-up
+        // is ignored to avoid double-firing the action.
+        HookEvent::Key(openlogi_hook::KeyEvent {
+            keycode,
+            pressed,
+            modifiers,
+        }) => {
+            if !pressed {
+                return EventDisposition::PassThrough;
             }
-            MouseEvent::Scroll {
-                delta_x, delta_y, ..
-            } => {
-                // Older MX mice (MX Master 2S) report the thumb wheel through
-                // native horizontal HID scroll rather than 0x2150. Windows'
-                // low-level hook sees those WM_MOUSEHWHEEL ticks, so when a
-                // direction is rebound we consume the native tick and dispatch
-                // the configured action. Newer 0x2150 devices are diverted by
-                // the HID++ capture session and therefore produce no duplicate
-                // OS event here. Leave the default left/right scroll untouched.
-                #[cfg(not(target_os = "windows"))]
-                let _ = (delta_x, delta_y);
-                #[cfg(target_os = "windows")]
-                if delta_y == 0.0
-                    && let Some((button, action)) = hooks
-                        .read()
-                        .ok()
-                        .and_then(|maps| rebound_thumbwheel_action(&maps, delta_x))
-                {
-                    info!(button = %button, action = %action.label(), "native thumb wheel → executing bound action");
-                    dispatch_action(&action, &dpi_cycle, &capture);
-                    return EventDisposition::Suppress;
+            let trigger = KeyTrigger {
+                keycode,
+                modifiers: convert_modifiers(modifiers),
+            };
+            match keyboard_bindings
+                .try_read()
+                .ok()
+                .and_then(|m| m.get(&trigger).cloned())
+            {
+                Some(action) => {
+                    info!(keycode, action = %action.label(), "key → executing bound action");
+                    if try_queue_action(&action_tx, action) {
+                        EventDisposition::Suppress
+                    } else {
+                        EventDisposition::PassThrough
+                    }
                 }
-                EventDisposition::PassThrough
+                None => EventDisposition::PassThrough,
             }
         }
     });
 
     match result {
         Ok(hook) => {
-            info!("OS mouse hook installed");
+            info!("OS input hook installed");
             Some(hook)
         }
         Err(e) => {
-            warn!(error = %e, "could not install OS mouse hook — events will not be captured");
+            warn!(error = %e, "could not install OS input hook — events will not be captured");
             None
         }
     }
 }
 
-/// Resolve a native horizontal wheel tick to a rebound thumb-wheel action.
+/// Resolve a native horizontal-wheel tick to a rebound thumb-wheel action.
 /// The built-in horizontal-scroll defaults intentionally return `None` so the
 /// physical wheel stays native unless the user changed that direction. On
 /// Windows/MX Master 2S, positive `WM_MOUSEHWHEEL` delta is the physical
@@ -307,17 +446,55 @@ fn is_native_click(id: ButtonId, action: &Action) -> bool {
     )
 }
 
+/// Minimum time between two BrowserBack (or two BrowserForward) keyboard
+/// dispatches, shared across the CGEventTap hook and the HID++ gesture
+/// watcher — both call [`dispatch_action`] independently, and on devices
+/// where one physical press is visible through both paths, a naive dispatch
+/// would fire the keyboard shortcut twice for one click. Same window as the
+/// HID++ path's own intra-press debounce (`BACK_FORWARD_DEBOUNCE` in
+/// `openlogi-hid`), for consistency.
+const BROWSER_NAV_DEBOUNCE: Duration = Duration::from_millis(150);
+
+/// Per-direction last-dispatch timestamps backing [`browser_nav_debounce_ok`].
+/// `(last_back, last_forward)`.
+static BROWSER_NAV_LAST: Mutex<(Option<Instant>, Option<Instant>)> = Mutex::new((None, None));
+
+/// Whether a BrowserBack/BrowserForward keyboard dispatch for `action` should
+/// proceed, or be suppressed as a duplicate of one already sent (from either
+/// dispatch path) within [`BROWSER_NAV_DEBOUNCE`]. Records the dispatch time
+/// on every `true` return so the *next* call — from either path — sees it.
+fn browser_nav_debounce_ok(action: &Action) -> bool {
+    let mut last = BROWSER_NAV_LAST
+        .lock()
+        .unwrap_or_else(PoisonError::into_inner);
+    let slot = if matches!(action, Action::BrowserForward) {
+        &mut last.1
+    } else {
+        &mut last.0
+    };
+    let now = Instant::now();
+    let fire = slot.is_none_or(|t| now.duration_since(t) >= BROWSER_NAV_DEBOUNCE);
+    if fire {
+        *slot = Some(now);
+    }
+    fire
+}
+
 /// Route a bound action either to OS-level event synthesis
 /// ([`Action::execute`]) or to one of OpenLogi's hardware-side handlers.
 ///
 /// `dpi_cycle` is held across a write lock long enough to advance the index
 /// and snapshot the new DPI + target; the actual HID write spawns its own
 /// thread via [`write_dpi_in_background`] to keep event callbacks non-blocking.
-/// `capture` lets those writes reuse the capture session's open channel.
+/// `registry` confirms that `capture` is still current or supplies the current
+/// inventory channel. Hardware actions are skipped when standalone callers do
+/// not provide a registry.
 pub fn dispatch_action(
     action: &Action,
     dpi_cycle: &Arc<RwLock<DpiCycleState>>,
     capture: &CaptureChannel,
+    registry: Option<&ChannelRegistry>,
+    receiver_access: &ReceiverAccess,
 ) {
     let next = match action {
         Action::CycleDpiPresets => match dpi_cycle.write() {
@@ -337,9 +514,29 @@ pub fn dispatch_action(
         Action::ToggleSmartShift => {
             let target = dpi_cycle.read().ok().and_then(|g| g.target.clone());
             info!("SmartShift toggle → flipping wheel mode");
-            toggle_smartshift_in_background(Some(capture), target);
+            if let Some(registry) = registry {
+                toggle_smartshift_in_background(Some(capture), registry, receiver_access, target);
+            } else {
+                warn!("no inventory registry — SmartShift toggle skipped");
+            }
             return;
         }
+        // BrowserBack/BrowserForward fall through to the keyboard shortcut
+        // (Cmd+[ / Cmd+]) here — for Chrome and other apps that respond to
+        // it, and as the HID++ gesture watcher's own fallback when its
+        // AXPress attempt (Safari) fails. On devices where one physical press
+        // is visible through both the CGEventTap hook and the HID++ diverted
+        // path (e.g. MX Vertical), both independently reach this arm for the
+        // *same* press, so it's cross-path debounced — otherwise a
+        // keyboard-driven browser like Chrome would navigate twice per click.
+        Action::BrowserBack | Action::BrowserForward => {
+            if browser_nav_debounce_ok(action) {
+                openlogi_inject::execute(action);
+            } else {
+                info!(action = %action.label(), "browser nav debounced — duplicate dispatch path suppressed");
+            }
+            None
+        }
         other => {
             openlogi_inject::execute(other);
             None
@@ -347,7 +544,11 @@ pub fn dispatch_action(
     };
     if let Some((dpi, target)) = next {
         info!(dpi, "DPI action → writing to device");
-        write_dpi_in_background(Some(capture), target, dpi);
+        if let Some(registry) = registry {
+            write_dpi_in_background(Some(capture), registry, receiver_access, target, dpi);
+        } else {
+            warn!("no inventory registry — DPI action skipped");
+        }
     } else if matches!(action, Action::CycleDpiPresets | Action::SetDpiPreset(_)) {
         info!(
             action = %action.label(),
@@ -416,6 +617,34 @@ mod tests {
         assert_eq!(resolve_gesture_click(&off, ButtonId::Back), Action::None);
     }
 
+    #[test]
+    fn fail_open_press_pairs_release() {
+        let mut fail_open = HashSet::new();
+        // Queue accepted → suppress press and release.
+        assert_eq!(
+            remapped_press_disposition(ButtonId::Back, true, &mut fail_open),
+            EventDisposition::Suppress
+        );
+        assert_eq!(
+            remapped_release_disposition(ButtonId::Back, &mut fail_open),
+            EventDisposition::Suppress
+        );
+        // Queue rejected → pass through press *and* matching release.
+        assert_eq!(
+            remapped_press_disposition(ButtonId::Forward, false, &mut fail_open),
+            EventDisposition::PassThrough
+        );
+        assert_eq!(
+            remapped_release_disposition(ButtonId::Forward, &mut fail_open),
+            EventDisposition::PassThrough
+        );
+        // A later unpaired release of that button suppresses again.
+        assert_eq!(
+            remapped_release_disposition(ButtonId::Forward, &mut fail_open),
+            EventDisposition::Suppress
+        );
+    }
+
     #[test]
     fn rebound_horizontal_wheel_maps_to_thumbwheel_directions() {
         let maps = HookMaps {
diff --git a/crates/openlogi-agent-core/src/ipc.rs b/crates/openlogi-agent-core/src/ipc.rs
index b7b7c7d43bc60df086ea5ad8a624ba2228e4e59d..152d9b96508d445488fe858b4f7bd14a408c8085 100644
--- a/crates/openlogi-agent-core/src/ipc.rs
+++ b/crates/openlogi-agent-core/src/ipc.rs
@@ -7,10 +7,10 @@
 //! pairing event arrives or the request deadline elapses.
 
 use openlogi_core::config::Lighting;
-use openlogi_core::device::DeviceInventory;
+use openlogi_core::device::{DeviceInventory, StandaloneDevice};
 use openlogi_hid::{
-    DeviceRoute, DpiInfo, PairingError, PasskeyMethod, ReceiverSelector, SmartShiftMode,
-    SmartShiftStatus, WriteError,
+    DeviceRoute, DpiInfo, LightCommand, PairingError, PasskeyMethod, ReceiverSelector,
+    SmartShiftMode, SmartShiftStatus, WriteError,
 };
 use serde::{Deserialize, Serialize};
 
@@ -28,8 +28,10 @@ use serde::{Deserialize, Serialize};
 /// v8: [`WriteError`] carries typed HID++ operation failures.
 /// v9: `poll_event_monitor` appended + [`MonitorEvent`] (live event monitor).
 /// v10: `Capabilities::hires_wheel` appended.
-/// v11: `Capabilities::thumbwheel` appended.
-pub const PROTOCOL_VERSION: u32 = 11;
+/// v11: standalone raw-HID inventory, camera state, and light methods appended.
+/// v12: standalone registry model identity appended to `StandaloneDevice`.
+/// v13: `Capabilities::thumbwheel` appended.
+pub const PROTOCOL_VERSION: u32 = 13;
 
 /// Where the agent's device enumeration stands. The distinction matters
 /// because an empty inventory list is ambiguous on its own: the GUI must keep
@@ -72,6 +74,12 @@ pub struct AgentStatus {
 pub struct AgentSnapshot {
     pub status: AgentStatus,
     pub inventory: Vec<DeviceInventory>,
+    /// Recognized standalone raw-HID devices, kept separate from receiver
+    /// pairing inventories.
+    pub standalone: Vec<StandaloneDevice>,
+    /// Whether at least one host camera stream is currently in use.
+    /// Runtime-only state used by camera-linked light rendering.
+    pub camera_active: bool,
 }
 
 /// A nearby unpaired device surfaced during Bolt discovery, in the minimal form
@@ -276,4 +284,9 @@ pub trait Agent {
     /// there is no explicit stop. Appended last — see the method-order note on
     /// [`Agent::protocol_version`].
     async fn poll_event_monitor() -> Vec<MonitorEvent>;
+    /// Apply a semantic standalone-light command to a raw HID route.
+    async fn set_light(route: DeviceRoute, command: LightCommand) -> Result<(), WriteError>;
+    /// Manually override effective power for a camera-linked light until the
+    /// next aggregate camera-use transition.
+    async fn set_light_manual_power(route: DeviceRoute, enabled: bool) -> Result<(), WriteError>;
 }
diff --git a/crates/openlogi-agent-core/src/orchestrator.rs b/crates/openlogi-agent-core/src/orchestrator.rs
index 8f3e288bd27d0296e992658c1da0b5f61f079a11..ca18798fe6f4db84498b5178960b351f99f78ef8 100644
--- a/crates/openlogi-agent-core/src/orchestrator.rs
+++ b/crates/openlogi-agent-core/src/orchestrator.rs
@@ -10,14 +10,20 @@
 //! [`DpiCycleState::capabilities`] stays `None` and presets cycle at their raw
 //! (still valid) values — exactly the GUI's "window never opened" behaviour.
 
-use std::collections::{BTreeMap, HashSet};
-use std::sync::atomic::{AtomicI32, Ordering};
+use std::collections::{BTreeMap, HashMap, HashSet};
+use std::sync::atomic::{AtomicI32, AtomicU64, Ordering};
 use std::sync::{Arc, RwLock};
 
-use openlogi_core::config::{Config, ScrollResolution};
-use openlogi_core::device::{Capabilities, DeviceInventory};
-use openlogi_hid::{CaptureChannel, DeviceRoute};
-use tracing::warn;
+use openlogi_core::binding::Action;
+use openlogi_core::config::{Config, LightSettings, ScrollResolution};
+use openlogi_core::device::{
+    Capabilities, DeviceInventory, DeviceKind, LightCapabilities, StandaloneDevice,
+};
+use openlogi_hid::{
+    CaptureChannel, ChannelPool, ChannelRegistry, DIRECT_DEVICE_INDEX, DeviceRoute,
+    KEYBOARD_KEY_CIDS,
+};
+use tracing::{debug, info, warn};
 
 use crate::DpiCycleState;
 use crate::bindings::{bindings_for, gesture_bindings_for, oshook_gestures_for};
@@ -26,6 +32,8 @@ use crate::hook_runtime::{HookMaps, SharedHookMaps};
 use crate::ipc::InventoryHealth;
 use crate::receiver_access::ReceiverAccess;
 use crate::watchers::gesture::GestureBindings;
+use crate::watchers::host_switch::{HostSwitchLink, HostSwitchLinks};
+use crate::watchers::keyboard::{KeyboardSpec, SharedKeyboardSpec};
 
 /// The minimal per-device facts the agent needs: the config key (binding /
 /// preset lookup), the HID++ route (DPI/SmartShift writes + capture target), and
@@ -39,6 +47,11 @@ struct AgentDevice {
     serial: Option<String>,
     unit_id: [u8; 4],
     capabilities: Option<Capabilities>,
+    /// HID++-reported device kind — identity only (capability decisions come
+    /// from the feature table). Used to find the keyboard the key-capture
+    /// watcher should target.
+    kind: DeviceKind,
+    light_capabilities: Option<LightCapabilities>,
     /// Live link state from the inventory snapshot. An offline→online
     /// transition is a reconnect — the device may have power-cycled, so its
     /// volatile settings need re-applying (#189).
@@ -54,13 +67,32 @@ pub struct SharedRuntime {
     /// rebuild publishes both atomically (see [`HookMaps`]). Also read by the
     /// gesture watcher for the thumb-wheel/DPI-button single actions.
     pub hook_maps: SharedHookMaps,
+    /// Function-key remapper bindings (keycode+modifiers → action). Not
+    /// per-app-profile in M1 (spec non-goal), so a single shared map.
+    pub keyboard_bindings: crate::hook_runtime::SharedKeyboardBindings,
     pub gesture_bindings: GestureBindings,
     pub dpi_cycle: Arc<RwLock<DpiCycleState>>,
     pub thumbwheel_sensitivity: Arc<AtomicI32>,
     pub capture_channel: CaptureChannel,
-    /// Exclusive receiver access shared by HID++ capture and pairing. Capture
-    /// and pairing must never open the same receiver HID node concurrently.
+    /// Exact-route channels owned and published by the inventory enumerator.
+    pub channel_registry: ChannelRegistry,
+    /// Shared transport pool used by long-running host-switch sessions.
+    pub channel_pool: ChannelPool,
+    /// The keyboard key-capture watcher's target + bindings, `None` while no
+    /// online keyboard has bound keys.
+    pub keyboard_spec: SharedKeyboardSpec,
+    /// The keyboard capture session's open channel, reused by Fn-lock writes
+    /// (the mouse-oriented [`Self::capture_channel`] points elsewhere).
+    pub keyboard_channel: CaptureChannel,
+    /// Incremented when the selected device reconnects or the system wakes, so
+    /// the gesture watcher re-arms volatile HID++ control diversion even when
+    /// the receiver route itself never changed.
+    pub capture_rearm_generation: Arc<AtomicU64>,
+    /// Receiver access shared by HID++ sessions and pairing. Pairing/host
+    /// transitions are exclusive; capture sessions share under read leases.
     pub receiver_access: ReceiverAccess,
+    /// Keyboard → pointing-device routes resolved from `config.toml`.
+    pub host_switch_links: HostSwitchLinks,
 }
 
 /// Owns the config + device selection and keeps [`SharedRuntime`] in sync.
@@ -80,9 +112,18 @@ pub struct Orchestrator {
     /// set/route/online state looks identical across the sleep gap, so the
     /// next refresh re-applies volatile settings to every online device.
     reapply_all_next_refresh: bool,
-    /// Config keys of devices first sighted last refresh, due one confirming
-    /// re-apply: the first write can race the device's own boot and be lost.
-    reapply_followup: HashSet<String>,
+    /// Config keys of devices first sighted last refresh, mapped to a remaining
+    /// count of confirming re-applies. The first write can race the device's own
+    /// boot and be lost — a cold restart leaves the MX Master 3s slow to enumerate,
+    /// so the volatile write (DPI/SmartShift/wheel/lighting) is retried for a
+    /// bounded run of inventory ticks until the device finishes booting (#189).
+    reapply_followup: HashMap<String, u8>,
+    /// Last successful aggregate camera-use sample. `None` means the macOS
+    /// watcher has not produced its first usable observation yet.
+    camera_active: Option<bool>,
+    /// Transient manual power choices for camera-linked lights. A camera-use
+    /// transition clears them; they are never written to the config.
+    manual_light_overrides: BTreeMap<String, bool>,
     shared: SharedRuntime,
 }
 
@@ -92,7 +133,10 @@ enum InventoryState {
     /// No enumeration has completed yet; the device set is unknown.
     Pending,
     /// The latest completed snapshot — empty means "checked, no devices".
-    Ready(Vec<DeviceInventory>),
+    Ready {
+        inventories: Vec<DeviceInventory>,
+        standalone: Vec<StandaloneDevice>,
+    },
     /// Enumeration has never succeeded (broken HID backend / dead watcher).
     Unavailable,
 }
@@ -105,13 +149,20 @@ impl Orchestrator {
     pub fn new(config: Config) -> Self {
         let shared = SharedRuntime {
             hook_maps: Arc::new(RwLock::new(HookMaps::default())),
+            keyboard_bindings: Arc::new(RwLock::new(config.keyboard.bindings.clone())),
             gesture_bindings: Arc::new(RwLock::new(BTreeMap::new())),
             dpi_cycle: Arc::new(RwLock::new(DpiCycleState::default())),
             thumbwheel_sensitivity: Arc::new(AtomicI32::new(
                 config.app_settings.thumbwheel_sensitivity,
             )),
             capture_channel: Arc::new(RwLock::new(None)),
+            channel_registry: ChannelRegistry::default(),
+            channel_pool: ChannelPool::default(),
+            keyboard_spec: Arc::new(RwLock::new(None)),
+            keyboard_channel: Arc::new(RwLock::new(None)),
+            capture_rearm_generation: Arc::new(AtomicU64::new(0)),
             receiver_access: ReceiverAccess::default(),
+            host_switch_links: Arc::new(RwLock::new(Vec::new())),
         };
         let orch = Self {
             config,
@@ -120,7 +171,9 @@ impl Orchestrator {
             current_app: None,
             inventory: InventoryState::Pending,
             reapply_all_next_refresh: false,
-            reapply_followup: HashSet::new(),
+            reapply_followup: HashMap::new(),
+            camera_active: None,
+            manual_light_overrides: BTreeMap::new(),
             shared,
         };
         orch.rebuild();
@@ -136,11 +189,34 @@ impl Orchestrator {
     fn current_key(&self) -> Option<&str> {
         self.devices
             .get(self.current)
+            .filter(|device| is_hidpp_device(device))
             .map(|d| d.config_key.as_str())
     }
 
     fn current_route(&self) -> Option<DeviceRoute> {
-        self.devices.get(self.current).and_then(|d| d.route.clone())
+        self.devices
+            .get(self.current)
+            .filter(|device| device.online && is_hidpp_device(device))
+            .and_then(|device| device.route.clone())
+    }
+
+    /// Keep the capture/DPI write target aligned with the selected device's
+    /// live connection state without rebuilding the rest of the DPI cycle.
+    ///
+    /// Inventory-only online transitions do not warrant [`Self::rebuild`]
+    /// (which intentionally resets the cycle index), but they do have to stop
+    /// and restart HID++ capture. Easy-Switch preserves the receiver route
+    /// while the device is away, and its volatile control diversion is lost;
+    /// publishing `None` while offline and the route again on return makes the
+    /// capture watcher open a fresh session and re-arm those controls.
+    fn sync_current_route(&self) {
+        let target = self.current_route();
+        match self.shared.dpi_cycle.write() {
+            Ok(mut state) => state.target = target,
+            Err(error) => {
+                warn!(%error, lock = "dpi_cycle", "lock poisoned — keeping stale value");
+            }
+        }
     }
 
     /// Build the OS-hook callback's maps for `key` + foreground `app`. Both hook
@@ -154,6 +230,46 @@ impl Orchestrator {
         }
     }
 
+    /// The keyboard key-capture spec for the first known keyboard, or `None`
+    /// when no keyboard is paired or none of its capturable keys carries a
+    /// real binding (an unbound key must never be diverted).
+    ///
+    /// Deliberately does NOT require the keyboard to be online: an idle
+    /// keyboard sleeps within minutes and probe timeouts can flap it offline,
+    /// and tearing the capture session down on every nap would hand the
+    /// diverted keys back to the firmware (dead bindings) until the re-arm
+    /// races through. The session instead stays up across sleeps — its
+    /// channel is to the always-present receiver — and re-arms diversion on
+    /// the device's `0x1d4b` reconnection broadcast.
+    fn keyboard_spec_for(&self) -> Option<KeyboardSpec> {
+        let dev = self
+            .devices
+            .iter()
+            .find(|d| d.kind == DeviceKind::Keyboard && d.route.is_some())?;
+        let bindings = bindings_for(
+            &self.config,
+            Some(&dev.config_key),
+            self.current_app.as_deref(),
+        );
+        let wanted: BTreeMap<u16, _> = KEYBOARD_KEY_CIDS
+            .iter()
+            .filter(|(_, button)| {
+                bindings
+                    .get(button)
+                    .is_some_and(|action| *action != Action::None)
+            })
+            .copied()
+            .collect();
+        if wanted.is_empty() {
+            return None;
+        }
+        Some(KeyboardSpec {
+            route: dev.route.clone()?,
+            wanted,
+            bindings,
+        })
+    }
+
     /// Rewrite every shared map from the current config + selected device.
     fn rebuild(&self) {
         let key = self.current_key();
@@ -179,25 +295,52 @@ impl Orchestrator {
             },
             "dpi_cycle",
         );
+        // Keyboard F-key bindings are global (not per-device), so they key off
+        // the top-level config map rather than the selected device. Published
+        // here so `reload_config` (GUI commit) takes effect live, not only on
+        // agent restart.
+        write_value(
+            &self.shared.keyboard_bindings,
+            self.config.keyboard.bindings.clone(),
+            "keyboard_bindings",
+        );
         self.shared.thumbwheel_sensitivity.store(
             self.config.app_settings.thumbwheel_sensitivity,
             Ordering::Relaxed,
         );
+        write_value(
+            &self.shared.host_switch_links,
+            host_switch_links(&self.config, &self.devices),
+            "host_switch_links",
+        );
+        write_value(
+            &self.shared.keyboard_spec,
+            self.keyboard_spec_for(),
+            "keyboard_spec",
+        );
     }
 
     /// Apply a fresh inventory snapshot. Always refreshes the snapshot the IPC
     /// `inventory()` poll serves (battery / online state changes without
     /// altering the device *set*), but only re-picks the selection and rebuilds
-    /// the shared maps when the device set actually changed — `rebuild()` is
-    /// driven solely by `config_key` + route and resets the live DPI-cycle
-    /// index, so running it every 2s tick on an unchanged set would snap DPI
-    /// back to `preset[0]` (and burn three `RwLock` writes) for nothing.
-    pub fn refresh_inventory(&mut self, inventories: &[DeviceInventory]) {
+    /// the shared maps when the device set or runtime selection changed —
+    /// `rebuild()` is driven by `config_key` + route and resets the live
+    /// DPI-cycle index, so running it every 2s tick on a steady selection
+    /// would snap DPI back to `preset[0]` (and burn three `RwLock` writes)
+    /// for nothing.
+    pub fn refresh_inventory(
+        &mut self,
+        inventories: &[DeviceInventory],
+        standalone: &[StandaloneDevice],
+    ) {
         // Even an empty snapshot is a *completed* enumeration — the watcher
         // skips failed ticks — so the device set is now known either way (and
         // a recovered backend upgrades `Unavailable` back to live data).
-        self.inventory = InventoryState::Ready(inventories.to_vec());
-        let devices = build_devices(inventories);
+        self.inventory = InventoryState::Ready {
+            inventories: inventories.to_vec(),
+            standalone: standalone.to_vec(),
+        };
+        let devices = build_devices(inventories, standalone);
         // Volatile settings (lighting colour, sensor DPI, SmartShift, native
         // wheel mode) live in device RAM and reset on a power cycle. Every
         // reconnect shape re-applies the persisted values (#189): a first
@@ -205,6 +348,9 @@ impl Orchestrator {
         // (offline→online), or — via the
         // flag — a system wake where none of those are observable.
         let reapply_all = std::mem::take(&mut self.reapply_all_next_refresh);
+        let next_current = pick_current(&devices, self.config.selected_device());
+        let rearm_capture =
+            selected_needs_capture_rearm(&self.devices, &devices, next_current, reapply_all);
         let followup = std::mem::take(&mut self.reapply_followup);
         let (targets, next_followup) =
             plan_reapply(&self.devices, &devices, &followup, reapply_all);
@@ -212,21 +358,38 @@ impl Orchestrator {
         for idx in targets {
             self.reapply_volatile_settings(&devices[idx]);
         }
-        let changed = devices.len() != self.devices.len()
+        let changed = next_current != self.current
+            || devices.len() != self.devices.len()
             || devices.iter().zip(&self.devices).any(|(a, b)| {
                 a.config_key != b.config_key
                     || a.route != b.route
                     || a.capabilities != b.capabilities
+                    || a.light_capabilities != b.light_capabilities
             });
-        if !changed {
-            // Same set and routes — but keep the fresh `online` flags, or a
-            // device that woke this tick would read as a transition forever.
+        if changed {
             self.devices = devices;
-            return;
+            self.current = next_current;
+            self.rebuild();
+        } else {
+            // Same set, routes, and runtime selection — but keep the fresh
+            // `online` flags, or a device that woke this tick would read as a
+            // transition forever.
+            self.devices = devices;
+            self.sync_current_route();
+            write_value(
+                &self.shared.host_switch_links,
+                host_switch_links(&self.config, &self.devices),
+                "host_switch_links",
+            );
+        }
+        if rearm_capture {
+            let generation = self
+                .shared
+                .capture_rearm_generation
+                .fetch_add(1, Ordering::Relaxed)
+                .wrapping_add(1);
+            debug!(generation, "selected device requires capture re-arm");
         }
-        self.devices = devices;
-        self.current = pick_current(&self.devices, self.config.selected_device());
-        self.rebuild();
     }
 
     /// Force a volatile-settings re-apply for every online device on the next
@@ -261,6 +424,8 @@ impl Orchestrator {
         if resolution.is_some() || inverted.is_some() || dpi.is_some() || smartshift.is_some() {
             crate::hardware::reapply_mouse_volatile_in_background(
                 Some(&self.shared.capture_channel),
+                &self.shared.channel_registry,
+                &self.shared.receiver_access,
                 route.clone(),
                 resolution,
                 inverted,
@@ -269,8 +434,89 @@ impl Orchestrator {
             );
         }
         if let Some(lighting) = self.config.lighting(key).filter(|l| l.enabled) {
-            crate::hardware::set_lighting_in_background(Some(route), &lighting);
+            crate::hardware::set_lighting_in_background(
+                Some(&self.shared.capture_channel),
+                &self.shared.channel_registry,
+                &self.shared.receiver_access,
+                Some(route.clone()),
+                &lighting,
+            );
+        }
+        if let Some(fn_lock) = self.config.fn_lock(key) {
+            crate::hardware::write_fn_lock_in_background(
+                Some(&self.shared.keyboard_channel),
+                &self.shared.channel_registry,
+                &self.shared.receiver_access,
+                Some(route.clone()),
+                fn_lock,
+            );
+        }
+        if let Some(capabilities) = dev.light_capabilities
+            && let Some(light) = self.effective_light_settings(key)
+        {
+            crate::hardware::set_light_in_background(Some(route), &light, capabilities);
+        }
+    }
+
+    /// Apply an aggregate camera-use transition to every opted-in online
+    /// light. Only effective power is transient; persisted manual power and
+    /// the remaining light settings are unchanged.
+    pub fn set_camera_active(&mut self, active: bool) {
+        if self.camera_active == Some(active) {
+            return;
+        }
+        let previous = self.camera_active;
+        self.camera_active = Some(active);
+        self.manual_light_overrides.clear();
+        let mut applied = 0;
+        for dev in self
+            .devices
+            .iter()
+            .filter(|dev| dev.online && dev.route.is_some())
+        {
+            let (Some(capabilities), Some(mut light)) = (
+                dev.light_capabilities,
+                self.config
+                    .light(&dev.config_key)
+                    .filter(|light| light.auto_camera),
+            ) else {
+                continue;
+            };
+            light.enabled = active;
+            crate::hardware::set_light_in_background(dev.route.clone(), &light, capabilities);
+            applied += 1;
+        }
+        info!(previous = ?previous, active, lights = applied, "applied camera-linked light state");
+    }
+
+    /// Resolve settings for reconnect/config re-application. Camera policy and
+    /// a transient manual override replace only the effective power field.
+    fn effective_light_settings(&self, key: &str) -> Option<LightSettings> {
+        let mut light = self.config.light(key)?;
+        if light.auto_camera {
+            if let Some(override_enabled) = self.manual_light_overrides.get(key) {
+                light.enabled = *override_enabled;
+            } else if let Some(active) = self.camera_active {
+                light.enabled = active;
+            }
         }
+        Some(light)
+    }
+
+    /// Store a transient manual power choice for a known light route. The IPC
+    /// write can race the config reload that first enabled camera automation,
+    /// so route/capability identity—not the possibly-stale config bit—is the
+    /// acceptance condition. A reload retains it only while the new config is
+    /// camera-linked.
+    pub fn set_manual_light_power(&mut self, route: &DeviceRoute, enabled: bool) -> bool {
+        let Some(device) = self.devices.iter().find(|device| {
+            device.route.as_ref() == Some(route) && device.light_capabilities.is_some()
+        }) else {
+            return false;
+        };
+        self.manual_light_overrides
+            .insert(device.config_key.clone(), enabled);
+        true
     }
 
     /// Push the saved native wheel resolution/inversion to every currently online
@@ -289,6 +535,8 @@ impl Orchestrator {
             let (resolution, inverted) = configured_wheel_mode(&self.config, dev);
             crate::hardware::write_scroll_wheel_mode_in_background(
                 Some(&self.shared.capture_channel),
+                &self.shared.channel_registry,
+                &self.shared.receiver_access,
                 (resolution.is_some() || inverted.is_some())
                     .then(|| dev.route.clone())
                     .flatten(),
@@ -304,17 +552,33 @@ impl Orchestrator {
     #[must_use]
     pub fn inventory(&self) -> Vec<DeviceInventory> {
         match &self.inventory {
-            InventoryState::Ready(inventories) => inventories.clone(),
+            InventoryState::Ready { inventories, .. } => inventories.clone(),
             InventoryState::Pending | InventoryState::Unavailable => Vec::new(),
         }
     }
 
+    /// The latest standalone raw-HID inventory snapshot.
+    #[must_use]
+    pub fn standalone(&self) -> Vec<StandaloneDevice> {
+        match &self.inventory {
+            InventoryState::Ready { standalone, .. } => standalone.clone(),
+            InventoryState::Pending | InventoryState::Unavailable => Vec::new(),
+        }
+    }
+
+    /// The latest aggregate camera-use sample, or `false` before the first
+    /// successful macOS observation.
+    #[must_use]
+    pub fn camera_active(&self) -> bool {
+        self.camera_active.unwrap_or(false)
+    }
+
     /// Where enumeration stands, for the IPC `status` poll.
     #[must_use]
     pub fn inventory_health(&self) -> InventoryHealth {
         match self.inventory {
             InventoryState::Pending => InventoryHealth::Scanning,
-            InventoryState::Ready(_) => InventoryHealth::Ready,
+            InventoryState::Ready { .. } => InventoryHealth::Ready,
             InventoryState::Unavailable => InventoryHealth::Unavailable,
         }
     }
@@ -351,14 +615,74 @@ impl Orchestrator {
             self.hook_maps_for(self.current_key(), self.current_app.as_deref()),
             "hook_maps",
         );
+        // The keyboard's effective bindings are app-scoped too.
+        write_value(
+            &self.shared.keyboard_spec,
+            self.keyboard_spec_for(),
+            "keyboard_spec",
+        );
     }
 
     /// Replace the config (after `config.toml` changed) and rebuild everything.
     pub fn reload_config(&mut self, config: Config) {
+        // Parameter-only edits must not erase a transient manual choice while
+        // the light remains camera-linked. Changing the policy invalidates it.
         self.config = config;
+        let retained_overrides: HashSet<String> = self
+            .manual_light_overrides
+            .keys()
+            .filter(|key| {
+                self.config
+                    .light(key)
+                    .is_some_and(|light| light.auto_camera)
+            })
+            .cloned()
+            .collect();
+        self.manual_light_overrides
+            .retain(|key, _| retained_overrides.contains(key));
         self.current = pick_current(&self.devices, self.config.selected_device());
         self.rebuild();
         self.apply_native_wheel_modes();
+        self.apply_fn_locks();
+        self.reapply_light_settings();
+    }
+
+    /// Push the saved Fn-lock state to every online keyboard that has one.
+    /// Runs on config reloads (the reconnect path is
+    /// [`Self::reapply_volatile_settings`]); the write is a single HID++ call,
+    /// so re-applying an unchanged state is cheap.
+    fn apply_fn_locks(&self) {
+        for dev in self
+            .devices
+            .iter()
+            .filter(|dev| dev.online && dev.route.is_some())
+        {
+            if let Some(fn_lock) = self.config.fn_lock(&dev.config_key) {
+                crate::hardware::write_fn_lock_in_background(
+                    Some(&self.shared.keyboard_channel),
+                    &self.shared.channel_registry,
+                    &self.shared.receiver_access,
+                    dev.route.clone(),
+                    fn_lock,
+                );
+            }
+        }
+    }
+
+    /// Re-apply standalone-light settings after a config reload.
+    fn reapply_light_settings(&self) {
+        for dev in self
+            .devices
+            .iter()
+            .filter(|dev| dev.online && dev.route.is_some() && dev.light_capabilities.is_some())
+        {
+            if let (Some(light), Some(capabilities)) = (
+                self.effective_light_settings(&dev.config_key),
+                dev.light_capabilities,
+            ) {
+                crate::hardware::set_light_in_background(dev.route.clone(), &light, capabilities);
+            }
+        }
     }
 }
 
@@ -385,7 +709,10 @@ fn configured_wheel_mode(
 /// `build_device_list` minus the asset/display fields: a device is included
 /// only once its HID++ DeviceInformation (`model_info`) has resolved, since the
 /// model key is derived from it.
-fn build_devices(inventories: &[DeviceInventory]) -> Vec<AgentDevice> {
+fn build_devices(
+    inventories: &[DeviceInventory],
+    standalone: &[StandaloneDevice],
+) -> Vec<AgentDevice> {
     let mut devices = Vec::new();
     for inv in inventories {
         for paired in &inv.paired {
@@ -410,10 +737,42 @@ fn build_devices(inventories: &[DeviceInventory]) -> Vec<AgentDevice> {
                 serial: model.serial_number.clone(),
                 unit_id: model.unit_id,
                 capabilities: paired.capabilities,
+                kind: paired.kind,
+                light_capabilities: None,
                 online: paired.online,
             });
         }
     }
+    for device in standalone {
+        let route = DeviceRoute::RawHid {
+            vendor_id: device.address.vendor_id,
+            product_id: device.address.product_id,
+            usage_page: device.address.usage_page,
+            usage_id: device.address.usage_id,
+            identity: device.address.identity.clone(),
+        };
+        let stable_id = DeviceStableId::from_parts(
+            Some(&route),
+            DIRECT_DEVICE_INDEX,
+            device.serial_number.as_deref(),
+            device.unit_id,
+        );
+        let Some(config_key) = stable_id.physical_key() else {
+            continue;
+        };
+        devices.push(AgentDevice {
+            config_key: config_key.into_string(),
+            model_key: device.display_name.clone(),
+            route: Some(route),
+            slot: DIRECT_DEVICE_INDEX,
+            serial: device.serial_number.clone(),
+            unit_id: device.unit_id,
+            capabilities: device.capabilities,
+            kind: device.kind,
+            light_capabilities: device.light_capabilities,
+            online: device.online,
+        });
+    }
     // Order by the same canonical key the GUI carousel uses, so the
     // no-saved-selection fallback (`pick_current` -> index 0) targets the device
     // the GUI shows first rather than whatever HID node enumerated first.
@@ -426,6 +785,31 @@ fn build_devices(inventories: &[DeviceInventory]) -> Vec<AgentDevice> {
     devices
 }
 
+fn host_switch_links(config: &Config, devices: &[AgentDevice]) -> Vec<HostSwitchLink> {
+    config
+        .devices
+        .iter()
+        .filter_map(|(keyboard_key, settings)| {
+            let keyboard = devices
+                .iter()
+                .find(|device| device.config_key == *keyboard_key && device.online)?
+                .route
+                .clone()?;
+            let targets = settings
+                .host_switch_targets
+                .iter()
+                .filter_map(|target_key| {
+                    devices
+                        .iter()
+                        .find(|device| device.config_key == *target_key)
+                        .and_then(|device| device.route.clone())
+                })
+                .collect::<Vec<_>>();
+            (!targets.is_empty()).then_some(HostSwitchLink { keyboard, targets })
+        })
+        .collect()
+}
+
 /// The canonical identity of one device: what the GUI carousel orders by, what
 /// the config key is derived from, and what [`reapply_targets`] matches a device
 /// against across inventory ticks.
@@ -466,46 +850,97 @@ fn reapply_targets(prev: &[AgentDevice], next: &[AgentDevice], reapply_all: bool
         .collect()
 }
 
+/// Whether this refresh invalidated the selected device's volatile control
+/// diversion. Receiver routes stay connected while a paired mouse sleeps, so
+/// route equality alone cannot tell the capture watcher to re-arm on wake.
+fn selected_needs_capture_rearm(
+    prev: &[AgentDevice],
+    next: &[AgentDevice],
+    selected: usize,
+    reapply_all: bool,
+) -> bool {
+    reapply_targets(prev, next, reapply_all).contains(&selected)
+}
+
+/// How many inventory ticks a first-sighted device keeps re-applying its
+/// volatile settings after the initial write. A cold restart leaves a Bolt/
+/// Unifying mouse slow to enumerate, so the first write (and a single confirm)
+/// can both time out against a still-booting device; retrying for ~8s at the 2s
+/// cadence lets the write land once it finishes booting. Bounded rather than
+/// read-back-confirmed — see the note on [`plan_reapply`].
+const VOLATILE_REAPPLY_CONFIRM_RETRIES: u8 = 4;
+
 /// Plan this refresh's volatile-settings writes: the [`reapply_targets`] set
-/// plus one confirming re-apply for devices first sighted last refresh, and
-/// the follow-up keys to confirm next refresh.
+/// plus a bounded run of confirming re-applies for devices first sighted
+/// recently, and the follow-up keys (with remaining retry counts) to confirm
+/// next refresh. Reconnects (offline→online) re-apply once — the device was
+/// already booted, so it needs no boot-race retry.
 fn plan_reapply(
     prev: &[AgentDevice],
     next: &[AgentDevice],
-    followup: &HashSet<String>,
+    followup: &HashMap<String, u8>,
     reapply_all: bool,
-) -> (Vec<usize>, HashSet<String>) {
+) -> (Vec<usize>, HashMap<String, u8>) {
     let mut targets = reapply_targets(prev, next, reapply_all);
-    let next_followup = targets
+    let mut next_followup: HashMap<String, u8> = targets
         .iter()
         .filter(|&&idx| {
             let id = stable_id(&next[idx]);
             !prev.iter().any(|p| stable_id(p) == id)
         })
-        .map(|&idx| next[idx].config_key.clone())
+        .map(|&idx| {
+            (
+                next[idx].config_key.clone(),
+                VOLATILE_REAPPLY_CONFIRM_RETRIES,
+            )
+        })
         .collect();
     for (idx, dev) in next.iter().enumerate() {
-        if dev.online
-            && dev.route.is_some()
-            && followup.contains(&dev.config_key)
-            && !targets.contains(&idx)
-        {
-            targets.push(idx);
+        if dev.online && dev.route.is_some() && !targets.contains(&idx) {
+            // ponytail: bounded retry, not read-back-confirmed. The upgrade is
+            // to confirm the write took (read DPI back via openlogi_hid and
+            // stop retrying on a match) instead of running out a fixed budget —
+            // that converges faster and drops the redundant writes on a device
+            // that accepted the first one.
+            if let Some(&remaining) = followup.get(&dev.config_key) {
+                targets.push(idx);
+                if remaining > 1 {
+                    next_followup.insert(dev.config_key.clone(), remaining - 1);
+                }
+            }
         }
     }
     (targets, next_followup)
 }
 
-/// Index of the selected device: the one whose `config_key` matches the saved
-/// selection, else the first. `build_devices` sorts by the same canonical key
-/// the GUI carousel uses, so "the first" is the same physical device in both
-/// processes even when nothing is persisted yet.
+/// Index of the selected HID++ input device. Prefer the saved selection while
+/// it is an online input route, otherwise the first online input route. If
+/// every input device is offline, preserve the saved selection (or the first
+/// input route) so its configuration remains stable. Standalone raw-HID
+/// devices participate in inventory and settings re-apply but must never
+/// replace the mouse/keyboard capture target when selected in the GUI.
 fn pick_current(devices: &[AgentDevice], saved: Option<&str>) -> usize {
+    let saved = saved.and_then(|key| {
+        devices
+            .iter()
+            .position(|device| device.config_key == key && is_hidpp_device(device))
+    });
     saved
-        .and_then(|key| devices.iter().position(|d| d.config_key == key))
+        .filter(|&idx| devices[idx].online)
+        .or_else(|| {
+            devices
+                .iter()
+                .position(|device| device.online && is_hidpp_device(device))
+        })
+        .or(saved)
+        .or_else(|| devices.iter().position(is_hidpp_device))
         .unwrap_or(0)
 }
 
+fn is_hidpp_device(device: &AgentDevice) -> bool {
+    !matches!(device.route, Some(DeviceRoute::RawHid { .. }))
+}
+
 /// Replace the value behind an `RwLock`, logging (not panicking) on poison so a
 /// background thread that paniced while holding the lock can't take the agent
 /// down — it just keeps the stale value until the next successful rebuild.
@@ -517,236 +952,4 @@ fn write_value<T>(lock: &RwLock<T>, value: T, name: &str) {
 }
 
 #[cfg(test)]
-mod tests {
-    use super::{
-        AgentDevice, InventoryHealth, Orchestrator, build_devices, configured_wheel_mode,
-        plan_reapply, reapply_targets,
-    };
-    use openlogi_core::config::{Config, ScrollResolution};
-    use openlogi_core::device::{
-        Capabilities, DeviceInventory, DeviceKind, DeviceModelInfo, DeviceTransports, PairedDevice,
-        ReceiverInfo,
-    };
-    use openlogi_hid::{DIRECT_DEVICE_INDEX, DeviceRoute};
-
-    fn dev(key: &str, slot: u8, online: bool) -> AgentDevice {
-        AgentDevice {
-            config_key: key.to_string(),
-            model_key: key.to_string(),
-            route: Some(DeviceRoute::Bolt {
-                receiver_uid: "AA00".to_string(),
-                slot,
-            }),
-            slot,
-            serial: None,
-            unit_id: [0; 4],
-            capabilities: None,
-            online,
-        }
-    }
-
-    fn direct_inventory(serial_number: Option<&str>, unit_id: [u8; 4]) -> DeviceInventory {
-        DeviceInventory {
-            receiver: ReceiverInfo {
-                name: "MX Master 3S".to_string(),
-                vendor_id: 0x046d,
-                product_id: 0xb023,
-                unique_id: None,
-            },
-            paired: vec![PairedDevice {
-                slot: DIRECT_DEVICE_INDEX,
-                codename: Some("MX Master 3S".to_string()),
-                wpid: None,
-                kind: DeviceKind::Mouse,
-                online: true,
-                battery: None,
-                model_info: Some(DeviceModelInfo {
-                    entity_count: 1,
-                    serial_number: serial_number.map(str::to_string),
-                    unit_id,
-                    transports: DeviceTransports::default(),
-                    model_ids: [0xb034, 0, 0],
-                    extended_model_id: 2,
-                }),
-                capabilities: Some(Capabilities::presumed_from_kind(DeviceKind::Mouse)),
-            }],
-        }
-    }
-
-    #[test]
-    fn build_devices_skips_transient_zero_unit_direct_identity() {
-        assert!(build_devices(&[direct_inventory(None, [0; 4])]).is_empty());
-
-        let devices = build_devices(&[direct_inventory(Some("ABC123"), [0; 4])]);
-        assert_eq!(devices.len(), 1);
-        assert_eq!(devices[0].config_key, "direct:046d:b023:serial:abc123");
-    }
-
-    #[test]
-    fn configured_wheel_mode_gates_resolution_and_inversion_independently() {
-        let mut config = Config::default();
-        config.set_scroll_resolution("a", Some(ScrollResolution::Low));
-        config.set_invert_scroll("a", true);
-        let mut device = dev("a", 1, true);
-
-        device.capabilities = Some(Capabilities {
-            hires_wheel: true,
-            thumbwheel: false,
-            scroll_inversion: false,
-            ..Capabilities::default()
-        });
-        assert_eq!(
-            configured_wheel_mode(&config, &device),
-            (Some(ScrollResolution::Low), None)
-        );
-
-        device.capabilities = Some(Capabilities {
-            hires_wheel: false,
-            thumbwheel: false,
-            scroll_inversion: true,
-            ..Capabilities::default()
-        });
-        assert_eq!(configured_wheel_mode(&config, &device), (None, Some(true)));
-
-        device.capabilities = None;
-        assert_eq!(configured_wheel_mode(&config, &device), (None, None));
-    }
-
-    #[test]
-    fn configured_wheel_mode_leaves_unset_resolution_unmanaged() {
-        let config = Config::default();
-        let mut device = dev("a", 1, true);
-        device.capabilities = Some(Capabilities {
-            hires_wheel: true,
-            thumbwheel: false,
-            scroll_inversion: false,
-            ..Capabilities::default()
-        });
-
-        assert_eq!(configured_wheel_mode(&config, &device), (None, None));
-    }
-
-    #[test]
-    fn reapply_targets_new_arrivals_and_transitions() {
-        // First sighting of an online device → re-apply.
-        assert_eq!(reapply_targets(&[], &[dev("a", 1, true)], false), vec![0]);
-        // Steady state → nothing.
-        assert!(reapply_targets(&[dev("a", 1, true)], &[dev("a", 1, true)], false).is_empty());
-        // Replug under a new route (same key, new slot) → re-apply.
-        assert_eq!(
-            reapply_targets(&[dev("a", 1, true)], &[dev("a", 2, true)], false),
-            vec![0]
-        );
-        // Waking from device sleep (offline → online) → re-apply.
-        assert_eq!(
-            reapply_targets(&[dev("a", 1, false)], &[dev("a", 1, true)], false),
-            vec![0]
-        );
-        // Going to sleep (online → offline) → nothing.
-        assert!(reapply_targets(&[dev("a", 1, true)], &[dev("a", 1, false)], false).is_empty());
-    }
-
-    #[test]
-    fn reapply_targets_disambiguates_same_model_duplicates() {
-        // Two devices can share a model key but are distinct physical units at
-        // different Bolt slots, so they have distinct stable ids. A steady tick
-        // with both already online must target NEITHER.
-        let prev = [dev("dup", 1, true), dev("dup", 2, true)];
-        let next = [dev("dup", 1, true), dev("dup", 2, true)];
-        assert!(reapply_targets(&prev, &next, false).is_empty());
-    }
-
-    #[test]
-    fn reapply_targets_skip_offline_and_routeless_devices() {
-        // A paired-but-asleep new arrival waits for its online transition —
-        // writing now would only time out against a sleeping device.
-        assert!(reapply_targets(&[], &[dev("a", 1, false)], false).is_empty());
-        let routeless = AgentDevice {
-            route: None,
-            ..dev("b", 2, true)
-        };
-        assert!(reapply_targets(&[], &[routeless], false).is_empty());
-    }
-
-    #[test]
-    fn reapply_all_targets_every_online_device() {
-        let prev = [dev("a", 1, true), dev("b", 2, false)];
-        let next = [dev("a", 1, true), dev("b", 2, false)];
-        // The post-wake snapshot looks identical to the pre-sleep one; the
-        // flag still re-applies to the online device (and only that one).
-        assert_eq!(reapply_targets(&prev, &next, true), vec![0]);
-    }
-
-    #[test]
-    fn plan_reapply_confirms_a_first_sighting_once() {
-        use std::collections::HashSet;
-        // First sighting: applied now, queued for one confirming re-apply.
-        let (targets, followup) = plan_reapply(&[], &[dev("a", 1, true)], &HashSet::new(), false);
-        assert_eq!(targets, vec![0]);
-        assert_eq!(followup, HashSet::from(["a".to_string()]));
-        // Next refresh: the confirming apply fires, then the queue drains.
-        let prev = [dev("a", 1, true)];
-        let (targets, followup) = plan_reapply(&prev, &prev, &followup, false);
-        assert_eq!(targets, vec![0]);
-        assert!(followup.is_empty());
-        // Steady state after that: nothing.
-        let (targets, _) = plan_reapply(&prev, &prev, &followup, false);
-        assert!(targets.is_empty());
-    }
-
-    #[test]
-    fn plan_reapply_transitions_are_not_queued_for_confirmation() {
-        use std::collections::HashSet;
-        // A wake from device sleep re-applies once — the device was already
-        // booted, so no confirming write is queued.
-        let (targets, followup) = plan_reapply(
-            &[dev("a", 1, false)],
-            &[dev("a", 1, true)],
-            &HashSet::new(),
-            false,
-        );
-        assert_eq!(targets, vec![0]);
-        assert!(followup.is_empty());
-    }
-
-    #[test]
-    fn plan_reapply_skips_a_followup_that_went_offline() {
-        use std::collections::HashSet;
-        let prev = [dev("a", 1, true)];
-        let (targets, followup) = plan_reapply(
-            &prev,
-            &[dev("a", 1, false)],
-            &HashSet::from(["a".to_string()]),
-            false,
-        );
-        assert!(targets.is_empty());
-        assert!(followup.is_empty());
-    }
-
-    /// An *empty* snapshot still flips the health to `Ready`: the watcher only
-    /// forwards completed enumerations, so "checked and found nothing" must not
-    /// be reported as "still scanning" — that's the whole distinction the
-    /// health exists to carry.
-    #[test]
-    fn empty_refresh_marks_inventory_ready() {
-        let mut orch = Orchestrator::new(Config::default());
-        assert_eq!(orch.inventory_health(), InventoryHealth::Scanning);
-        orch.refresh_inventory(&[]);
-        assert_eq!(orch.inventory_health(), InventoryHealth::Ready);
-    }
-
-    /// `Unavailable` is a startup-only downgrade: it reports "enumeration has
-    /// never worked", recovers when a snapshot finally lands, and never
-    /// clobbers a live device set on a mid-session failure (mirroring the
-    /// watcher's keep-last-snapshot policy).
-    #[test]
-    fn unavailable_only_downgrades_a_pending_inventory() {
-        let mut orch = Orchestrator::new(Config::default());
-        orch.mark_inventory_unavailable();
-        assert_eq!(orch.inventory_health(), InventoryHealth::Unavailable);
-        orch.refresh_inventory(&[]);
-        assert_eq!(orch.inventory_health(), InventoryHealth::Ready);
-        orch.mark_inventory_unavailable();
-        assert_eq!(orch.inventory_health(), InventoryHealth::Ready);
-    }
-}
+mod tests;
diff --git a/crates/openlogi-agent-core/src/orchestrator/tests.rs b/crates/openlogi-agent-core/src/orchestrator/tests.rs
new file mode 100644
index 0000000000000000000000000000000000000000..b15fcdc801c5864b4773fc89b8336fe67f284975
--- /dev/null
+++ b/crates/openlogi-agent-core/src/orchestrator/tests.rs
@@ -0,0 +1,660 @@
+//! Orchestrator inventory/reapply/camera tests.
+
+use super::{
+    AgentDevice, InventoryHealth, Orchestrator, VOLATILE_REAPPLY_CONFIRM_RETRIES, build_devices,
+    configured_wheel_mode, host_switch_links, pick_current, plan_reapply, reapply_targets,
+    selected_needs_capture_rearm,
+};
+use openlogi_core::config::{Config, LightSettings, ScrollResolution};
+use openlogi_core::device::{
+    Capabilities, DeviceInventory, DeviceKind, DeviceModelInfo, DeviceTransports,
+    LightCapabilities, PairedDevice, RawDeviceAddress, ReceiverInfo, StandaloneDevice,
+};
+use openlogi_hid::{DIRECT_DEVICE_INDEX, DeviceRoute};
+
+fn dev(key: &str, slot: u8, online: bool) -> AgentDevice {
+    AgentDevice {
+        config_key: key.to_string(),
+        model_key: key.to_string(),
+        route: Some(DeviceRoute::Bolt {
+            receiver_uid: "AA00".to_string(),
+            slot,
+        }),
+        slot,
+        serial: None,
+        unit_id: [0; 4],
+        capabilities: None,
+        kind: openlogi_core::device::DeviceKind::Mouse,
+        light_capabilities: None,
+        online,
+    }
+}
+
+fn raw_light_dev(key: &str) -> AgentDevice {
+    AgentDevice {
+        config_key: key.to_string(),
+        model_key: "Litra Glow".to_string(),
+        route: Some(DeviceRoute::RawHid {
+            vendor_id: 0x046d,
+            product_id: 0xc900,
+            usage_page: 0xff43,
+            usage_id: 0x0202,
+            identity: "serial:glow-1".to_string(),
+        }),
+        slot: DIRECT_DEVICE_INDEX,
+        serial: Some("glow-1".to_string()),
+        unit_id: [0; 4],
+        capabilities: None,
+        kind: DeviceKind::Light,
+        light_capabilities: Some(openlogi_core::device::LightCapabilities {
+            power: true,
+            ..openlogi_core::device::LightCapabilities::default()
+        }),
+        online: true,
+    }
+}
+
+fn direct_inventory(serial_number: Option<&str>, unit_id: [u8; 4]) -> DeviceInventory {
+    DeviceInventory {
+        receiver: ReceiverInfo {
+            name: "MX Master 3S".to_string(),
+            vendor_id: 0x046d,
+            product_id: 0xb023,
+            unique_id: None,
+        },
+        paired: vec![PairedDevice {
+            slot: DIRECT_DEVICE_INDEX,
+            codename: Some("MX Master 3S".to_string()),
+            wpid: None,
+            kind: DeviceKind::Mouse,
+            online: true,
+            battery: None,
+            model_info: Some(DeviceModelInfo {
+                entity_count: 1,
+                serial_number: serial_number.map(str::to_string),
+                unit_id,
+                transports: DeviceTransports::default(),
+                model_ids: [0xb034, 0, 0],
+                extended_model_id: 2,
+            }),
+            capabilities: Some(Capabilities::presumed_from_kind(DeviceKind::Mouse)),
+        }],
+    }
+}
+
+fn direct_inventory_state(
+    product_id: u16,
+    serial_number: Option<&str>,
+    unit_id: [u8; 4],
+    online: bool,
+) -> DeviceInventory {
+    DeviceInventory {
+        receiver: ReceiverInfo {
+            name: "MX Master 3S".to_string(),
+            vendor_id: 0x046d,
+            product_id,
+            unique_id: None,
+        },
+        paired: vec![PairedDevice {
+            slot: DIRECT_DEVICE_INDEX,
+            codename: Some("MX Master 3S".to_string()),
+            wpid: None,
+            kind: DeviceKind::Mouse,
+            online,
+            battery: None,
+            model_info: Some(DeviceModelInfo {
+                entity_count: 1,
+                serial_number: serial_number.map(str::to_string),
+                unit_id,
+                transports: DeviceTransports::default(),
+                model_ids: [product_id, 0, 0],
+                extended_model_id: 2,
+            }),
+            capabilities: Some(Capabilities::presumed_from_kind(DeviceKind::Mouse)),
+        }],
+    }
+}
+
+#[test]
+fn build_devices_skips_transient_zero_unit_direct_identity() {
+    assert!(build_devices(&[direct_inventory(None, [0; 4])], &[]).is_empty());
+
+    let devices = build_devices(&[direct_inventory(Some("ABC123"), [0; 4])], &[]);
+    assert_eq!(devices.len(), 1);
+    assert_eq!(devices[0].config_key, "direct:046d:b023:serial:abc123");
+}
+
+#[test]
+fn build_devices_keeps_serial_backed_standalone_lights_beside_hidpp_devices() {
+    let light_capabilities = openlogi_core::device::LightCapabilities {
+        power: true,
+        ..openlogi_core::device::LightCapabilities::default()
+    };
+    let standalone = StandaloneDevice {
+        address: RawDeviceAddress {
+            vendor_id: 0x046d,
+            product_id: 0xc900,
+            usage_page: 0xff43,
+            usage_id: 0x0202,
+            identity: "serial:glow-1".to_string(),
+        },
+        display_name: "Litra Glow".to_string(),
+        manufacturer: Some("Logitech".to_string()),
+        serial_number: Some("Glow-1".to_string()),
+        unit_id: [0; 4],
+        kind: DeviceKind::Light,
+        online: true,
+        capabilities: None,
+        light_capabilities: Some(light_capabilities),
+        driver_id: "litra".to_string(),
+        registry_model_id: Some("8c900".to_string()),
+    };
+
+    let devices = build_devices(&[direct_inventory(Some("ABC123"), [0; 4])], &[standalone]);
+
+    assert_eq!(devices.len(), 2);
+    let Some(light) = devices
+        .iter()
+        .find(|device| device.model_key == "Litra Glow")
+    else {
+        panic!("standalone light should be retained");
+    };
+    assert_eq!(light.config_key, "raw:046d:c900:ff43:0202:serial:glow-1");
+    assert_eq!(light.light_capabilities, Some(light_capabilities));
+    assert!(matches!(light.route, Some(DeviceRoute::RawHid { .. })));
+}
+
+#[test]
+fn standalone_selection_never_replaces_the_hidpp_capture_target() {
+    let devices = [raw_light_dev("light"), dev("mouse", 1, true)];
+
+    assert_eq!(pick_current(&devices, Some("light")), 1);
+    assert_eq!(pick_current(&devices, None), 1);
+}
+
+#[test]
+fn runtime_selection_falls_back_from_saved_offline_device_to_online_device() {
+    let devices = [dev("saved", 1, false), dev("online", 2, true)];
+
+    assert_eq!(pick_current(&devices, Some("saved")), 1);
+}
+
+#[test]
+fn runtime_selection_keeps_saved_device_when_it_is_online() {
+    let devices = [dev("other", 1, true), dev("saved", 2, true)];
+
+    assert_eq!(pick_current(&devices, Some("saved")), 1);
+}
+
+#[test]
+fn runtime_selection_keeps_saved_device_when_all_devices_are_offline() {
+    let devices = [dev("other", 1, false), dev("saved", 2, false)];
+
+    assert_eq!(pick_current(&devices, Some("saved")), 1);
+}
+
+#[test]
+fn runtime_selection_tracks_online_transition_without_device_set_change() {
+    let saved_key = "direct:046d:b023:unit:01000000";
+    let other_key = "direct:046d:b034:unit:02000000";
+    let mut config = Config::default();
+    config.set_selected_device(Some(saved_key.to_string()));
+    let mut orchestrator = Orchestrator::new(config);
+
+    orchestrator.refresh_inventory(
+        &[
+            direct_inventory_state(0xb023, None, [1, 0, 0, 0], true),
+            direct_inventory_state(0xb034, None, [2, 0, 0, 0], false),
+        ],
+        &[],
+    );
+    assert_eq!(orchestrator.current_key(), Some(saved_key));
+
+    orchestrator.refresh_inventory(
+        &[
+            direct_inventory_state(0xb023, None, [1, 0, 0, 0], false),
+            direct_inventory_state(0xb034, None, [2, 0, 0, 0], true),
+        ],
+        &[],
+    );
+    assert_eq!(orchestrator.current_key(), Some(other_key));
+}
+
+#[test]
+fn configured_wheel_mode_gates_resolution_and_inversion_independently() {
+    let mut config = Config::default();
+    config.set_scroll_resolution("a", Some(ScrollResolution::Low));
+    config.set_invert_scroll("a", true);
+    let mut device = dev("a", 1, true);
+
+    device.capabilities = Some(Capabilities {
+        hires_wheel: true,
+        scroll_inversion: false,
+        ..Capabilities::default()
+    });
+    assert_eq!(
+        configured_wheel_mode(&config, &device),
+        (Some(ScrollResolution::Low), None)
+    );
+
+    device.capabilities = Some(Capabilities {
+        hires_wheel: false,
+        scroll_inversion: true,
+        ..Capabilities::default()
+    });
+    assert_eq!(configured_wheel_mode(&config, &device), (None, Some(true)));
+
+    device.capabilities = None;
+    assert_eq!(configured_wheel_mode(&config, &device), (None, None));
+}
+
+#[test]
+fn configured_wheel_mode_leaves_unset_resolution_unmanaged() {
+    let config = Config::default();
+    let mut device = dev("a", 1, true);
+    device.capabilities = Some(Capabilities {
+        hires_wheel: true,
+        scroll_inversion: false,
+        ..Capabilities::default()
+    });
+
+    assert_eq!(configured_wheel_mode(&config, &device), (None, None));
+}
+
+#[test]
+fn host_switch_links_keep_sleeping_targets_but_require_online_keyboard() {
+    let mut config = Config::default();
+    config
+        .devices
+        .entry("keyboard".into())
+        .or_default()
+        .host_switch_targets = vec!["mouse".into(), "offline".into(), "missing".into()];
+    let devices = [
+        dev("keyboard", 1, true),
+        dev("mouse", 2, true),
+        dev("offline", 3, false),
+    ];
+
+    let links = host_switch_links(&config, &devices);
+
+    assert_eq!(links.len(), 1);
+    assert_eq!(
+        links[0].keyboard,
+        DeviceRoute::Bolt {
+            receiver_uid: "AA00".into(),
+            slot: 1,
+        }
+    );
+    assert_eq!(
+        links[0].targets,
+        vec![
+            DeviceRoute::Bolt {
+                receiver_uid: "AA00".into(),
+                slot: 2,
+            },
+            DeviceRoute::Bolt {
+                receiver_uid: "AA00".into(),
+                slot: 3,
+            }
+        ]
+    );
+}
+
+#[test]
+fn reapply_targets_new_arrivals_and_transitions() {
+    // First sighting of an online device → re-apply.
+    assert_eq!(reapply_targets(&[], &[dev("a", 1, true)], false), vec![0]);
+    // Steady state → nothing.
+    assert!(reapply_targets(&[dev("a", 1, true)], &[dev("a", 1, true)], false).is_empty());
+    // Replug under a new route (same key, new slot) → re-apply.
+    assert_eq!(
+        reapply_targets(&[dev("a", 1, true)], &[dev("a", 2, true)], false),
+        vec![0]
+    );
+    // Waking from device sleep (offline → online) → re-apply.
+    assert_eq!(
+        reapply_targets(&[dev("a", 1, false)], &[dev("a", 1, true)], false),
+        vec![0]
+    );
+    // Going to sleep (online → offline) → nothing.
+    assert!(reapply_targets(&[dev("a", 1, true)], &[dev("a", 1, false)], false).is_empty());
+}
+
+#[test]
+fn capture_target_tracks_online_state_without_resetting_dpi_cycle() {
+    let mut orch = Orchestrator::new(Config::default());
+    orch.devices = vec![dev("mouse", 1, true)];
+    orch.rebuild();
+    {
+        let Ok(mut dpi) = orch.shared.dpi_cycle.write() else {
+            panic!("DPI cycle lock should not be poisoned");
+        };
+        dpi.index = 3;
+    }
+
+    orch.devices[0].online = false;
+    orch.sync_current_route();
+    {
+        let Ok(dpi) = orch.shared.dpi_cycle.read() else {
+            panic!("DPI cycle lock should not be poisoned");
+        };
+        assert_eq!(dpi.target, None);
+        assert_eq!(dpi.index, 3);
+    }
+
+    orch.devices[0].online = true;
+    orch.sync_current_route();
+    let Ok(dpi) = orch.shared.dpi_cycle.read() else {
+        panic!("DPI cycle lock should not be poisoned");
+    };
+    assert_eq!(dpi.target, orch.devices[0].route);
+    assert_eq!(dpi.index, 3);
+}
+
+#[test]
+fn reapply_targets_disambiguates_same_model_duplicates() {
+    // Two devices can share a model key but are distinct physical units at
+    // different Bolt slots, so they have distinct stable ids. A steady tick
+    // with both already online must target NEITHER.
+    let prev = [dev("dup", 1, true), dev("dup", 2, true)];
+    let next = [dev("dup", 1, true), dev("dup", 2, true)];
+    assert!(reapply_targets(&prev, &next, false).is_empty());
+}
+
+#[test]
+fn reapply_targets_skip_offline_and_routeless_devices() {
+    // A paired-but-asleep new arrival waits for its online transition —
+    // writing now would only time out against a sleeping device.
+    assert!(reapply_targets(&[], &[dev("a", 1, false)], false).is_empty());
+    let routeless = AgentDevice {
+        route: None,
+        ..dev("b", 2, true)
+    };
+    assert!(reapply_targets(&[], &[routeless], false).is_empty());
+}
+
+#[test]
+fn reapply_all_targets_every_online_device() {
+    let prev = [dev("a", 1, true), dev("b", 2, false)];
+    let next = [dev("a", 1, true), dev("b", 2, false)];
+    // The post-wake snapshot looks identical to the pre-sleep one; the
+    // flag still re-applies to the online device (and only that one).
+    assert_eq!(reapply_targets(&prev, &next, true), vec![0]);
+}
+
+#[test]
+fn selected_receiver_reconnect_requests_capture_rearm() {
+    let prev = [dev("selected", 1, false), dev("other", 2, true)];
+    let next = [dev("selected", 1, true), dev("other", 2, true)];
+
+    assert!(selected_needs_capture_rearm(&prev, &next, 0, false));
+    assert!(!selected_needs_capture_rearm(&prev, &next, 1, false));
+}
+
+#[test]
+fn system_wake_requests_capture_rearm_for_selected_online_device() {
+    let devices = [dev("selected", 1, true), dev("other", 2, true)];
+
+    assert!(selected_needs_capture_rearm(&devices, &devices, 0, true));
+}
+
+#[test]
+fn steady_inventory_does_not_cycle_capture() {
+    let devices = [dev("selected", 1, true)];
+
+    assert!(!selected_needs_capture_rearm(&devices, &devices, 0, false));
+}
+
+#[test]
+fn plan_reapply_retries_a_first_sighting_for_a_bounded_run() {
+    use std::collections::HashMap;
+    // First sighting: applied now, queued for VOLATILE_REAPPLY_CONFIRM_RETRIES
+    // confirming re-applies. A cold restart can leave the device still
+    // booting, so the initial write and a single confirm need a retry run,
+    // not a one-shot confirm.
+    let (targets, followup) = plan_reapply(&[], &[dev("a", 1, true)], &HashMap::new(), false);
+    assert_eq!(targets, vec![0]);
+    assert_eq!(
+        followup,
+        HashMap::from([("a".to_string(), VOLATILE_REAPPLY_CONFIRM_RETRIES)])
+    );
+    // Each steady tick after a first sighting re-applies once and decrements
+    // the remaining retry budget — the device may still be booting.
+    let prev = [dev("a", 1, true)];
+    let followup_in = HashMap::from([("a".to_string(), VOLATILE_REAPPLY_CONFIRM_RETRIES)]);
+    let (targets, followup) = plan_reapply(&prev, &prev, &followup_in, false);
+    assert_eq!(targets, vec![0]);
+    assert_eq!(
+        followup,
+        HashMap::from([("a".to_string(), VOLATILE_REAPPLY_CONFIRM_RETRIES - 1)])
+    );
+    // The budget exhausts: a last retry fires but queues no further ones.
+    let followup_in = HashMap::from([("a".to_string(), 1)]);
+    let (targets, followup) = plan_reapply(&prev, &prev, &followup_in, false);
+    assert_eq!(targets, vec![0]);
+    assert!(followup.is_empty());
+    // Steady state after that: nothing.
+    let (targets, _) = plan_reapply(&prev, &prev, &HashMap::new(), false);
+    assert!(targets.is_empty());
+}
+
+#[test]
+fn plan_reapply_transitions_are_not_queued_for_confirmation() {
+    use std::collections::HashMap;
+    // A wake from device sleep re-applies once — the device was already
+    // booted, so no confirming write is queued.
+    let (targets, followup) = plan_reapply(
+        &[dev("a", 1, false)],
+        &[dev("a", 1, true)],
+        &HashMap::new(),
+        false,
+    );
+    assert_eq!(targets, vec![0]);
+    assert!(followup.is_empty());
+}
+
+#[test]
+fn plan_reapply_skips_a_followup_that_went_offline() {
+    use std::collections::HashMap;
+    let prev = [dev("a", 1, true)];
+    let (targets, followup) = plan_reapply(
+        &prev,
+        &[dev("a", 1, false)],
+        &HashMap::from([("a".to_string(), VOLATILE_REAPPLY_CONFIRM_RETRIES)]),
+        false,
+    );
+    assert!(targets.is_empty());
+    assert!(followup.is_empty());
+}
+
+/// An *empty* snapshot still flips the health to `Ready`: the watcher only
+/// forwards completed enumerations, so "checked and found nothing" must not
+/// be reported as "still scanning" — that's the whole distinction the
+/// health exists to carry.
+#[test]
+fn empty_refresh_marks_inventory_ready() {
+    let mut orch = Orchestrator::new(Config::default());
+    assert_eq!(orch.inventory_health(), InventoryHealth::Scanning);
+    orch.refresh_inventory(&[], &[]);
+    assert_eq!(orch.inventory_health(), InventoryHealth::Ready);
+}
+
+/// `Unavailable` is a startup-only downgrade: it reports "enumeration has
+/// never worked", recovers when a snapshot finally lands, and never
+/// clobbers a live device set on a mid-session failure (mirroring the
+/// watcher's keep-last-snapshot policy).
+#[test]
+fn unavailable_only_downgrades_a_pending_inventory() {
+    let mut orch = Orchestrator::new(Config::default());
+    orch.mark_inventory_unavailable();
+    assert_eq!(orch.inventory_health(), InventoryHealth::Unavailable);
+    orch.refresh_inventory(&[], &[]);
+    assert_eq!(orch.inventory_health(), InventoryHealth::Ready);
+    orch.mark_inventory_unavailable();
+    assert_eq!(orch.inventory_health(), InventoryHealth::Ready);
+}
+
+#[test]
+fn camera_automation_overrides_only_effective_power() {
+    let key = "raw:046d:c900:ff43:0202:serial:glow";
+    let mut config = Config::default();
+    config.set_light(
+        key,
+        LightSettings {
+            enabled: true,
+            auto_camera: true,
+            brightness_percent: 65,
+            temperature_kelvin: Some(4600),
+            color: None,
+        },
+    );
+    let mut orch = Orchestrator::new(config);
+
+    orch.set_camera_active(false);
+    assert_eq!(
+        orch.effective_light_settings(key).map(|light| (
+            light.enabled,
+            light.brightness_percent,
+            light.temperature_kelvin
+        )),
+        Some((false, 65, Some(4600)))
+    );
+
+    orch.set_camera_active(true);
+    assert_eq!(
+        orch.effective_light_settings(key).map(|light| (
+            light.enabled,
+            light.brightness_percent,
+            light.temperature_kelvin
+        )),
+        Some((true, 65, Some(4600)))
+    );
+}
+
+#[test]
+fn manual_camera_light_override_is_transient() {
+    let key = "raw:046d:c900:ff43:0202:serial:glow";
+    let route = DeviceRoute::Bolt {
+        receiver_uid: "AA00".to_string(),
+        slot: 1,
+    };
+    let mut config = Config::default();
+    config.set_light(
+        key,
+        LightSettings {
+            enabled: true,
+            auto_camera: true,
+            brightness_percent: 65,
+            temperature_kelvin: Some(4600),
+            color: None,
+        },
+    );
+    let mut orch = Orchestrator::new(config);
+    orch.set_camera_active(true);
+    let mut device = dev(key, 1, true);
+    device.light_capabilities = Some(LightCapabilities {
+        power: true,
+        ..LightCapabilities::default()
+    });
+    orch.devices.push(AgentDevice {
+        config_key: key.to_string(),
+        route: Some(route.clone()),
+        ..device
+    });
+
+    assert!(orch.set_manual_light_power(&route, false));
+    assert_eq!(
+        orch.effective_light_settings(key)
+            .map(|light| light.enabled),
+        Some(false)
+    );
+
+    orch.devices.clear();
+    orch.set_camera_active(false);
+    orch.set_camera_active(true);
+    assert_eq!(
+        orch.effective_light_settings(key)
+            .map(|light| light.enabled),
+        Some(true)
+    );
+}
+
+#[test]
+fn config_reload_keeps_manual_override_for_parameter_edits() {
+    let key = "raw:046d:c900:ff43:0202:serial:glow";
+    let mut config = Config::default();
+    config.set_light(
+        key,
+        LightSettings {
+            enabled: false,
+            auto_camera: true,
+            brightness_percent: 65,
+            temperature_kelvin: Some(4600),
+            color: None,
+        },
+    );
+    let mut orch = Orchestrator::new(config.clone());
+    orch.set_camera_active(false);
+    orch.manual_light_overrides.insert(key.to_string(), true);
+
+    let mut updated = config;
+    updated.set_light(
+        key,
+        LightSettings {
+            enabled: false,
+            auto_camera: true,
+            brightness_percent: 80,
+            temperature_kelvin: Some(6500),
+            color: None,
+        },
+    );
+    orch.reload_config(updated);
+
+    assert_eq!(
+        orch.effective_light_settings(key).map(|light| (
+            light.enabled,
+            light.brightness_percent,
+            light.temperature_kelvin
+        )),
+        Some((true, 80, Some(6500)))
+    );
+    assert_eq!(orch.manual_light_overrides.get(key), Some(&true));
+}
+
+#[test]
+fn config_reload_clears_override_when_camera_mode_changes() {
+    let key = "raw:046d:c900:ff43:0202:serial:glow";
+    let mut config = Config::default();
+    config.set_light(
+        key,
+        LightSettings {
+            enabled: true,
+            auto_camera: true,
+            brightness_percent: 65,
+            temperature_kelvin: Some(4600),
+            color: None,
+        },
+    );
+    let mut orch = Orchestrator::new(config.clone());
+    orch.manual_light_overrides.insert(key.to_string(), false);
+
+    let mut updated = config;
+    updated.set_light(
+        key,
+        LightSettings {
+            enabled: true,
+            auto_camera: false,
+            brightness_percent: 65,
+            temperature_kelvin: Some(4600),
+            color: None,
+        },
+    );
+    orch.reload_config(updated);
+
+    assert_eq!(orch.manual_light_overrides.get(key), None);
+    assert_eq!(
+        orch.effective_light_settings(key)
+            .map(|light| light.enabled),
+        Some(true)
+    );
+}
diff --git a/crates/openlogi-agent-core/src/receiver_access.rs b/crates/openlogi-agent-core/src/receiver_access.rs
index 66cb6ac3fd7c3ffc2391759ba9b5e2e383a21479..0a1f368c91e48c1351f239b4140ff99c4e5835b8 100644
--- a/crates/openlogi-agent-core/src/receiver_access.rs
+++ b/crates/openlogi-agent-core/src/receiver_access.rs
@@ -1,15 +1,13 @@
-//! Exclusive receiver access coordination between HID++ capture and pairing.
+//! Shared and exclusive access coordination for receiver HID++ sessions.
 //!
-//! The active-device capture session and a pairing session cannot both open the
-//! same receiver HID node. This small arbiter makes that ownership explicit: the
-//! capture watcher may run only while it holds a capture lease, and pairing first
-//! announces its intent (so capture stops) before awaiting an exclusive pairing
-//! lease.
+//! Long-running HID++ sessions share pooled receiver channels under read leases.
+//! Pairing and coordinated host transitions announce their intent so those
+//! sessions stop, then wait for an exclusive write lease.
 
 use std::sync::Arc;
-use std::sync::atomic::{AtomicBool, Ordering};
+use std::sync::atomic::{AtomicU8, Ordering};
 
-use tokio::sync::{Mutex, OwnedMutexGuard};
+use tokio::sync::{OwnedRwLockReadGuard, OwnedRwLockWriteGuard, RwLock};
 
 /// Coordinates exclusive access to the receiver HID node.
 #[derive(Clone, Default)]
@@ -19,89 +17,108 @@ pub struct ReceiverAccess {
 
 #[derive(Default)]
 struct ReceiverAccessInner {
-    lease: Arc<Mutex<()>>,
-    pairing_requested: Arc<AtomicBool>,
+    lease: Arc<RwLock<()>>,
+    exclusive_requests: Arc<AtomicU8>,
 }
 
-/// Exclusive receiver lease held by the capture watcher.
-pub struct CaptureReceiverLease {
-    _guard: OwnedMutexGuard<()>,
+/// Operation requiring sole ownership of a receiver transport.
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+pub enum ExclusiveAccessReason {
+    /// Receiver discovery and pairing.
+    Pairing,
+    /// Coordinated movement of linked devices to another host.
+    HostTransition,
 }
 
-/// Exclusive receiver lease held by a pairing session.
-pub struct PairingReceiverLease {
-    _guard: OwnedMutexGuard<()>,
-    pairing_requested: Arc<AtomicBool>,
+impl ExclusiveAccessReason {
+    const fn bit(self) -> u8 {
+        match self {
+            Self::Pairing => 1 << 0,
+            Self::HostTransition => 1 << 1,
+        }
+    }
 }
 
-impl Drop for PairingReceiverLease {
-    fn drop(&mut self) {
-        self.pairing_requested.store(false, Ordering::Release);
-    }
+/// Shared receiver lease held by a long-running HID++ session.
+pub struct SessionReceiverLease {
+    _guard: OwnedRwLockReadGuard<()>,
+}
+
+/// Exclusive receiver lease held by a pairing or host-transition operation.
+pub struct ExclusiveReceiverLease {
+    _guard: OwnedRwLockWriteGuard<()>,
+    _request: ExclusiveRequest,
 }
 
 impl ReceiverAccess {
-    /// Whether a pairing session is waiting for or holding receiver access.
+    /// Whether any exclusive operation is waiting for or holding receiver access.
     #[must_use]
-    pub fn pairing_requested(&self) -> bool {
-        self.inner.pairing_requested.load(Ordering::Acquire)
+    pub fn exclusive_requested(&self) -> bool {
+        self.inner.exclusive_requests.load(Ordering::Acquire) != 0
     }
 
-    /// Try to acquire receiver access for the capture watcher.
+    /// Whether `reason` is waiting for or holding receiver access.
+    #[must_use]
+    pub fn requested(&self, reason: ExclusiveAccessReason) -> bool {
+        self.inner.exclusive_requests.load(Ordering::Acquire) & reason.bit() != 0
+    }
+
+    /// Try to acquire receiver access for a pooled HID++ session.
     ///
     /// Capture is opportunistic: if pairing is waiting or active, capture should
     /// stay idle and retry on its next management tick.
     #[must_use]
-    pub fn try_acquire_for_capture(&self) -> Option<CaptureReceiverLease> {
-        if self.pairing_requested() {
+    pub fn try_acquire_for_session(&self) -> Option<SessionReceiverLease> {
+        if self.exclusive_requested() {
             return None;
         }
-        let guard = Arc::clone(&self.inner.lease).try_lock_owned().ok()?;
-        if self.pairing_requested() {
+        let guard = Arc::clone(&self.inner.lease).try_read_owned().ok()?;
+        if self.exclusive_requested() {
             return None;
         }
-        Some(CaptureReceiverLease { _guard: guard })
+        Some(SessionReceiverLease { _guard: guard })
     }
 
-    /// Request and acquire exclusive receiver access for pairing.
+    /// Wait for shared access for a bounded device-I/O operation.
+    ///
+    /// Unlike long-running sessions, ordinary reads and writes must not be
+    /// dropped merely because an exclusive operation is queued. Tokio's fair
+    /// lock ordering makes them wait behind that operation instead.
+    pub async fn acquire_for_io(&self) -> SessionReceiverLease {
+        let guard = Arc::clone(&self.inner.lease).read_owned().await;
+        SessionReceiverLease { _guard: guard }
+    }
+
+    /// Request and acquire exclusive receiver access for `reason`.
     ///
     /// If the returned future is cancelled while waiting, the pairing request is
     /// withdrawn automatically so capture can resume.
-    pub async fn acquire_for_pairing(&self) -> PairingReceiverLease {
-        let request = PairingRequest::new(Arc::clone(&self.inner.pairing_requested));
-        let guard = Arc::clone(&self.inner.lease).lock_owned().await;
-        request.disarm();
-        PairingReceiverLease {
+    pub async fn acquire_exclusive(&self, reason: ExclusiveAccessReason) -> ExclusiveReceiverLease {
+        let request = ExclusiveRequest::new(Arc::clone(&self.inner.exclusive_requests), reason);
+        let guard = Arc::clone(&self.inner.lease).write_owned().await;
+        ExclusiveReceiverLease {
             _guard: guard,
-            pairing_requested: Arc::clone(&self.inner.pairing_requested),
+            _request: request,
         }
     }
 }
 
-struct PairingRequest {
-    pairing_requested: Arc<AtomicBool>,
-    armed: bool,
+struct ExclusiveRequest {
+    requests: Arc<AtomicU8>,
+    reason: ExclusiveAccessReason,
 }
 
-impl PairingRequest {
-    fn new(pairing_requested: Arc<AtomicBool>) -> Self {
-        pairing_requested.store(true, Ordering::Release);
-        Self {
-            pairing_requested,
-            armed: true,
-        }
-    }
-
-    fn disarm(mut self) {
-        self.armed = false;
+impl ExclusiveRequest {
+    fn new(requests: Arc<AtomicU8>, reason: ExclusiveAccessReason) -> Self {
+        requests.fetch_or(reason.bit(), Ordering::AcqRel);
+        Self { requests, reason }
     }
 }
 
-impl Drop for PairingRequest {
+impl Drop for ExclusiveRequest {
     fn drop(&mut self) {
-        if self.armed {
-            self.pairing_requested.store(false, Ordering::Release);
-        }
+        self.requests
+            .fetch_and(!self.reason.bit(), Ordering::AcqRel);
     }
 }
 
@@ -113,35 +130,87 @@ mod tests {
     async fn pairing_request_blocks_new_capture_until_pairing_lease_drops() {
         let access = ReceiverAccess::default();
 
-        let pairing = access.acquire_for_pairing().await;
+        let pairing = access
+            .acquire_exclusive(ExclusiveAccessReason::Pairing)
+            .await;
 
-        assert!(access.pairing_requested());
-        assert!(access.try_acquire_for_capture().is_none());
+        assert!(access.requested(ExclusiveAccessReason::Pairing));
+        assert!(access.exclusive_requested());
+        assert!(access.try_acquire_for_session().is_none());
 
         drop(pairing);
 
-        assert!(!access.pairing_requested());
-        assert!(access.try_acquire_for_capture().is_some());
+        assert!(!access.exclusive_requested());
+        assert!(access.try_acquire_for_session().is_some());
+    }
+
+    #[tokio::test]
+    async fn pooled_sessions_share_access_before_pairing() {
+        let access = ReceiverAccess::default();
+
+        let first = access.try_acquire_for_session().unwrap_or_else(|| {
+            panic!("fresh receiver access should grant first session lease");
+        });
+        let second = access.try_acquire_for_session().unwrap_or_else(|| {
+            panic!("pooled sessions should share receiver access");
+        });
+
+        drop((first, second));
     }
 
     #[tokio::test]
     async fn cancelled_pairing_wait_withdraws_request() {
         let access = ReceiverAccess::default();
-        let capture = access.try_acquire_for_capture().unwrap_or_else(|| {
+        let capture = access.try_acquire_for_session().unwrap_or_else(|| {
             panic!("fresh receiver access should grant capture lease");
         });
 
         let waiting = tokio::spawn({
             let access = access.clone();
-            async move { access.acquire_for_pairing().await }
+            async move {
+                access
+                    .acquire_exclusive(ExclusiveAccessReason::Pairing)
+                    .await
+            }
         });
         tokio::time::sleep(std::time::Duration::from_millis(10)).await;
-        assert!(access.pairing_requested());
+        assert!(access.requested(ExclusiveAccessReason::Pairing));
 
         waiting.abort();
         let _ = waiting.await;
-        assert!(!access.pairing_requested());
+        assert!(!access.exclusive_requested());
         drop(capture);
-        assert!(access.try_acquire_for_capture().is_some());
+        assert!(access.try_acquire_for_session().is_some());
+    }
+
+    #[tokio::test]
+    async fn host_transition_blocks_shared_sessions() {
+        let access = ReceiverAccess::default();
+
+        let transition = access
+            .acquire_exclusive(ExclusiveAccessReason::HostTransition)
+            .await;
+
+        assert!(access.requested(ExclusiveAccessReason::HostTransition));
+        assert!(access.try_acquire_for_session().is_none());
+        drop(transition);
+        assert!(access.try_acquire_for_session().is_some());
+    }
+
+    #[tokio::test]
+    async fn bounded_io_waits_for_host_transition() {
+        let access = ReceiverAccess::default();
+        let transition = access
+            .acquire_exclusive(ExclusiveAccessReason::HostTransition)
+            .await;
+        let waiting = tokio::spawn({
+            let access = access.clone();
+            async move { access.acquire_for_io().await }
+        });
+
+        tokio::task::yield_now().await;
+        assert!(!waiting.is_finished());
+        drop(transition);
+        assert!(waiting.await.is_ok());
     }
 }
diff --git a/crates/openlogi-agent-core/src/transport.rs b/crates/openlogi-agent-core/src/transport.rs
index 6ec093ba2a7b4e9c4cd02b0c787b7f01cb904a49..51c036020930b1aad2ccafe9fbb210f83d7696c4 100644
--- a/crates/openlogi-agent-core/src/transport.rs
+++ b/crates/openlogi-agent-core/src/transport.rs
@@ -21,9 +21,10 @@ use tarpc::tokio_serde::formats::Bincode;
 /// Resolve the IPC endpoint name.
 ///
 /// On Unix this is the filesystem Unix-domain socket at
-/// [`agent_socket_path`](openlogi_core::paths::agent_socket_path) (preserving
-/// the existing `~/.config/openlogi/agent.sock` location, so macOS/Linux see no
-/// behavior change). On Windows it is a named pipe in the OS namespace
+/// [`agent_socket_path`](openlogi_core::paths::agent_socket_path). Production
+/// builds keep `~/.config/openlogi/agent.sock`; local macOS `.dev` bundles use
+/// the sibling `openlogi-dev` profile so development agents cannot occupy the
+/// installed app's endpoint. On Windows it is a named pipe in the OS namespace
 /// (`\\.\pipe\openlogi-agent.sock`).
 ///
 /// # Errors
diff --git a/crates/openlogi-agent-core/src/watchers/camera.rs b/crates/openlogi-agent-core/src/watchers/camera.rs
new file mode 100644
index 0000000000000000000000000000000000000000..4c95af804f91ae5339464ce12e0933fdcbc749f4
--- /dev/null
+++ b/crates/openlogi-agent-core/src/watchers/camera.rs
@@ -0,0 +1,300 @@
+//! Camera-use watcher used by standalone-light automation.
+//!
+//! CoreMediaIO exposes whether each camera device is running in any client.
+//! Polling that read-only property covers physical webcams, virtual cameras,
+//! capture cards, and SLR devices without coupling the policy to a particular
+//! meeting or recording application.
+
+use std::time::Duration;
+
+#[cfg(target_os = "macos")]
+use std::thread;
+use tokio::sync::mpsc;
+#[cfg(target_os = "macos")]
+use tracing::{debug, info, warn};
+
+/// CoreMediaIO can briefly report no running stream while a camera client
+/// renegotiates or switches capture mode. Requiring two consecutive inactive
+/// samples prevents that gap from turning linked lights off and back on.
+#[cfg(any(target_os = "macos", test))]
+const INACTIVE_CONFIRMATIONS: u8 = 2;
+
+#[cfg(any(target_os = "macos", test))]
+#[derive(Default)]
+struct CameraDebouncer {
+    emitted: Option<bool>,
+    inactive_samples: u8,
+}
+
+#[cfg(any(target_os = "macos", test))]
+impl CameraDebouncer {
+    fn observe(&mut self, active: bool) -> Option<bool> {
+        if active {
+            self.inactive_samples = 0;
+            return (self.emitted != Some(true)).then(|| {
+                self.emitted = Some(true);
+                true
+            });
+        }
+
+        if self.emitted != Some(true) {
+            return (self.emitted != Some(false)).then(|| {
+                self.emitted = Some(false);
+                false
+            });
+        }
+
+        self.inactive_samples = self.inactive_samples.saturating_add(1);
+        if self.inactive_samples < INACTIVE_CONFIRMATIONS {
+            return None;
+        }
+        self.inactive_samples = 0;
+        self.emitted = Some(false);
+        Some(false)
+    }
+
+    fn retain_last_state_after_probe_error(&mut self) {
+        self.inactive_samples = 0;
+    }
+}
+
+/// Start the macOS camera-use watcher. The first successful sample is emitted
+/// immediately; later samples are emitted only after a debounced state change.
+/// Dropping the receiver stops the worker on its next attempted send.
+#[cfg(target_os = "macos")]
+#[must_use]
+pub fn spawn(period: Duration) -> mpsc::UnboundedReceiver<bool> {
+    let (tx, rx) = mpsc::unbounded_channel();
+    let spawn_result = thread::Builder::new()
+        .name("openlogi-camera-watcher".into())
+        .spawn(move || {
+            let mut debouncer = CameraDebouncer::default();
+            loop {
+                match camera_in_use() {
+                    Ok(active) => {
+                        if let Some(active) = debouncer.observe(active) {
+                            info!(active, "camera usage state changed");
+                            if tx.send(active).is_err() {
+                                debug!("camera watcher receiver dropped — exiting");
+                                return;
+                            }
+                        }
+                    }
+                    Err(error) => {
+                        debouncer.retain_last_state_after_probe_error();
+                        warn!(error, "camera state probe failed — retaining last state");
+                    }
+                }
+                thread::sleep(period);
+            }
+        });
+    if let Err(error) = spawn_result {
+        warn!(error = %error, "could not spawn camera watcher");
+    }
+    rx
+}
+
+/// Return an inert watcher on platforms that do not yet expose a supported
+/// aggregate camera-use provider. Camera-linked settings retain manual power.
+#[cfg(not(target_os = "macos"))]
+#[must_use]
+pub fn spawn(_period: Duration) -> mpsc::UnboundedReceiver<bool> {
+    let (_tx, rx) = mpsc::unbounded_channel();
+    rx
+}
+
+#[cfg(target_os = "macos")]
+fn camera_in_use() -> Result<bool, i32> {
+    macos::camera_in_use()
+}
+
+#[cfg(target_os = "macos")]
+#[expect(
+    unsafe_code,
+    reason = "CoreMediaIO exposes the camera-running property through a C API"
+)]
+mod macos {
+    use std::ffi::c_void;
+    use std::mem::size_of;
+    use std::ptr;
+
+    type ObjectId = u32;
+    type Selector = u32;
+    type Scope = u32;
+    type Element = u32;
+
+    #[repr(C)]
+    struct PropertyAddress {
+        selector: Selector,
+        scope: Scope,
+        element: Element,
+    }
+
+    // CoreMediaIO constants are four-character codes from CMIOTypes.h.
+    const SYSTEM_OBJECT: ObjectId = 1;
+    const SCOPE_GLOBAL: Scope = u32::from_be_bytes(*b"glob");
+    const ELEMENT_MASTER: Element = 0;
+    const HARDWARE_DEVICES: Selector = u32::from_be_bytes(*b"dev#");
+    const DEVICE_RUNNING_SOMEWHERE: Selector = u32::from_be_bytes(*b"gone");
+
+    #[link(name = "CoreMediaIO", kind = "framework")]
+    unsafe extern "C" {
+        fn CMIOObjectGetPropertyDataSize(
+            object_id: ObjectId,
+            address: *const PropertyAddress,
+            qualifier_data_size: u32,
+            qualifier_data: *const c_void,
+            data_size: *mut u32,
+        ) -> i32;
+
+        fn CMIOObjectGetPropertyData(
+            object_id: ObjectId,
+            address: *const PropertyAddress,
+            qualifier_data_size: u32,
+            qualifier_data: *const c_void,
+            data_size: u32,
+            data_used: *mut u32,
+            data: *mut c_void,
+        ) -> i32;
+    }
+
+    pub(super) fn camera_in_use() -> Result<bool, i32> {
+        let devices_address = PropertyAddress {
+            selector: HARDWARE_DEVICES,
+            scope: SCOPE_GLOBAL,
+            element: ELEMENT_MASTER,
+        };
+        let mut data_size = 0;
+        // SAFETY: CoreMediaIO receives a valid system-object property address
+        // and a writable UInt32 for the byte count; no qualifier is used.
+        let status = unsafe {
+            CMIOObjectGetPropertyDataSize(
+                SYSTEM_OBJECT,
+                &raw const devices_address,
+                0,
+                ptr::null(),
+                &raw mut data_size,
+            )
+        };
+        if status != 0 {
+            return Err(status);
+        }
+
+        let object_size = size_of::<ObjectId>();
+        let Some(device_count) = usize::try_from(data_size)
+            .ok()
+            .filter(|bytes| bytes % object_size == 0)
+            .map(|bytes| bytes / object_size)
+        else {
+            return Err(-1);
+        };
+        if device_count == 0 {
+            return Ok(false);
+        }
+
+        let mut devices = vec![0; device_count];
+        let mut data_used = 0;
+        // SAFETY: `devices` has the byte capacity reported by the preceding
+        // size query and remains alive for the duration of the call.
+        let status = unsafe {
+            CMIOObjectGetPropertyData(
+                SYSTEM_OBJECT,
+                &raw const devices_address,
+                0,
+                ptr::null(),
+                data_size,
+                &raw mut data_used,
+                devices.as_mut_ptr().cast(),
+            )
+        };
+        if status != 0 {
+            return Err(status);
+        }
+        let Some(used_count) = usize::try_from(data_used)
+            .ok()
+            .filter(|bytes| bytes % object_size == 0)
+            .map(|bytes| bytes / object_size)
+            .filter(|count| *count <= devices.len())
+        else {
+            return Err(-1);
+        };
+        devices.truncate(used_count);
+
+        let running_address = PropertyAddress {
+            selector: DEVICE_RUNNING_SOMEWHERE,
+            scope: SCOPE_GLOBAL,
+            element: ELEMENT_MASTER,
+        };
+        let mut last_error = None;
+        let mut read_any = false;
+        for device in devices {
+            let mut running = 0_u32;
+            let property_size = u32::try_from(size_of::<u32>()).unwrap_or(u32::MAX);
+            let mut property_used = 0;
+            // SAFETY: `running` and the size counter are valid writable
+            // buffers; each device ID came from CoreMediaIO itself.
+            let status = unsafe {
+                CMIOObjectGetPropertyData(
+                    device,
+                    &raw const running_address,
+                    0,
+                    ptr::null(),
+                    property_size,
+                    &raw mut property_used,
+                    (&raw mut running).cast(),
+                )
+            };
+            if status != 0 {
+                last_error = Some(status);
+                continue;
+            }
+            if property_used != property_size {
+                last_error = Some(-1);
+                continue;
+            }
+            read_any = true;
+            if running != 0 {
+                return Ok(true);
+            }
+        }
+        if read_any {
+            Ok(false)
+        } else {
+            Err(last_error.unwrap_or(-1))
+        }
+    }
+}
+
+#[cfg(test)]
+mod tests {
+    use super::CameraDebouncer;
+
+    #[test]
+    fn inactive_transition_requires_two_consecutive_samples() {
+        let mut debouncer = CameraDebouncer::default();
+        assert_eq!(debouncer.observe(false), Some(false));
+        assert_eq!(debouncer.observe(true), Some(true));
+        assert_eq!(debouncer.observe(false), None);
+        assert_eq!(debouncer.observe(false), Some(false));
+    }
+
+    #[test]
+    fn active_sample_cancels_pending_inactive_transition() {
+        let mut debouncer = CameraDebouncer::default();
+        assert_eq!(debouncer.observe(true), Some(true));
+        assert_eq!(debouncer.observe(false), None);
+        assert_eq!(debouncer.observe(true), None);
+        assert_eq!(debouncer.observe(false), None);
+        assert_eq!(debouncer.observe(false), Some(false));
+    }
+
+    #[test]
+    fn probe_error_cancels_pending_inactive_transition() {
+        let mut debouncer = CameraDebouncer::default();
+        assert_eq!(debouncer.observe(true), Some(true));
+        assert_eq!(debouncer.observe(false), None);
+        debouncer.retain_last_state_after_probe_error();
+        assert_eq!(debouncer.observe(false), None);
+        assert_eq!(debouncer.observe(false), Some(false));
+    }
+}
diff --git a/crates/openlogi-agent-core/src/watchers/gesture.rs b/crates/openlogi-agent-core/src/watchers/gesture.rs
index 806596827ffc1d6a33e050bd8e0f52ef29a6198c..4ba014c4b2e3978764db9e78e23b555d532a0595 100644
--- a/crates/openlogi-agent-core/src/watchers/gesture.rs
+++ b/crates/openlogi-agent-core/src/watchers/gesture.rs
@@ -19,20 +19,23 @@
 //! way regardless.
 
 use std::collections::BTreeMap;
-use std::sync::atomic::{AtomicI32, Ordering};
+use std::sync::atomic::{AtomicI32, AtomicU64, Ordering};
 use std::sync::{Arc, RwLock};
 use std::thread;
 use std::time::{Duration, Instant};
 
 use openlogi_core::binding::{Action, ButtonId, GestureDirection, default_binding};
 use openlogi_core::config::DEFAULT_THUMBWHEEL_SENSITIVITY;
-use openlogi_hid::{CaptureChannel, CapturedInput, DeviceRoute, run_capture_session};
+use openlogi_hid::{
+    CaptureChannel, CaptureStop, CapturedInput, ChannelRegistry, DeviceRoute,
+    run_capture_session_with_registry, run_capture_session_with_stop_reason,
+};
 use tokio::sync::{mpsc, oneshot};
 use tracing::{debug, warn};
 
 use crate::DpiCycleState;
 use crate::hook_runtime::{self, SharedHookMaps};
-use crate::receiver_access::ReceiverAccess;
+use crate::receiver_access::{ReceiverAccess, SessionReceiverLease};
 
 /// Shared gesture-direction binding map, mirrored from `AppState` (keyed by
 /// direction). The watcher reads it to map a captured swipe to a bound action.
@@ -80,7 +83,61 @@ pub fn spawn(
     dpi_cycle: Arc<RwLock<DpiCycleState>>,
     capture_channel: CaptureChannel,
     thumbwheel_sensitivity: ThumbwheelSensitivity,
+    capture_rearm_generation: Arc<AtomicU64>,
     receiver_access: ReceiverAccess,
+) {
+    spawn_inner(
+        hook_maps,
+        gesture_bindings,
+        dpi_cycle,
+        capture_channel,
+        thumbwheel_sensitivity,
+        capture_rearm_generation,
+        receiver_access,
+        None,
+    );
+}
+
+/// Spawn capture in Agent mode, reusing only inventory-published channels.
+#[expect(
+    clippy::too_many_arguments,
+    reason = "agent mode needs maps, dpi, rearm, leases, and registry"
+)]
+pub fn spawn_with_registry(
+    hook_maps: SharedHookMaps,
+    gesture_bindings: GestureBindings,
+    dpi_cycle: Arc<RwLock<DpiCycleState>>,
+    capture_channel: CaptureChannel,
+    thumbwheel_sensitivity: ThumbwheelSensitivity,
+    capture_rearm_generation: Arc<AtomicU64>,
+    receiver_access: ReceiverAccess,
+    registry: ChannelRegistry,
+) {
+    spawn_inner(
+        hook_maps,
+        gesture_bindings,
+        dpi_cycle,
+        capture_channel,
+        thumbwheel_sensitivity,
+        capture_rearm_generation,
+        receiver_access,
+        Some(registry),
+    );
+}
+
+#[expect(
+    clippy::too_many_arguments,
+    reason = "capture manager needs maps, dpi, rearm, leases, and registry"
+)]
+fn spawn_inner(
+    hook_maps: SharedHookMaps,
+    gesture_bindings: GestureBindings,
+    dpi_cycle: Arc<RwLock<DpiCycleState>>,
+    capture_channel: CaptureChannel,
+    thumbwheel_sensitivity: ThumbwheelSensitivity,
+    capture_rearm_generation: Arc<AtomicU64>,
+    receiver_access: ReceiverAccess,
+    registry: Option<ChannelRegistry>,
 ) {
     thread::spawn(move || {
         let runtime = match tokio::runtime::Builder::new_current_thread()
@@ -99,7 +156,9 @@ pub fn spawn(
             dpi_cycle,
             capture_channel,
             thumbwheel_sensitivity,
+            capture_rearm_generation,
             receiver_access,
+            registry,
         ));
     });
 }
@@ -137,25 +196,150 @@ fn thumbwheel_armed(hook_maps: &SharedHookMaps, sensitivity: i32) -> bool {
 /// respawn when it is the *current* one (not a stale session already superseded
 /// by a deliberate restart, whose epoch no longer matches) and a target is still
 /// set (not a deliberate stop-to-idle, e.g. while pairing owns the receiver).
-fn should_rearm(done_epoch: u64, live_epoch: u64, has_target: bool) -> bool {
+pub(crate) fn should_rearm(done_epoch: u64, live_epoch: u64, has_target: bool) -> bool {
     done_epoch == live_epoch && has_target
 }
 
+#[derive(Debug, Clone, PartialEq, Eq)]
+struct CaptureTarget {
+    route: DeviceRoute,
+    capture_thumbwheel: bool,
+    divert_gesture_button: bool,
+    rearm_generation: u64,
+}
+
+/// Why to stop the current session when the desired target changes.
+fn stop_for_target_change(
+    want: Option<&CaptureTarget>,
+    current: Option<&CaptureTarget>,
+    connection_is_current: bool,
+) -> Option<CaptureStop> {
+    let cur = current?;
+    if want == Some(cur) {
+        return (!connection_is_current).then_some(CaptureStop::Revoked);
+    }
+    // Same route, new generation (reconnect/wake): skip restore — firmware already reset.
+    if want.is_some_and(|next| {
+        next.route == cur.route && next.rearm_generation != cur.rearm_generation
+    }) {
+        return Some(CaptureStop::Revoked);
+    }
+    Some(CaptureStop::Graceful)
+}
+
+#[cfg_attr(
+    not(test),
+    allow(dead_code, reason = "kept for unit tests of stop policy")
+)]
+fn stop_reason<T: PartialEq>(
+    want: Option<&T>,
+    current: Option<&T>,
+    connection_is_current: bool,
+) -> Option<CaptureStop> {
+    current?;
+    if want == current {
+        (!connection_is_current).then_some(CaptureStop::Revoked)
+    } else {
+        Some(CaptureStop::Graceful)
+    }
+}
+
+fn acknowledge_stopping(stopping_epoch: &mut Option<u64>, done_epoch: u64) -> bool {
+    if *stopping_epoch == Some(done_epoch) {
+        *stopping_epoch = None;
+        true
+    } else {
+        false
+    }
+}
+
+fn capture_connection_is_current(
+    registry: Option<&ChannelRegistry>,
+    capture_channel: &CaptureChannel,
+) -> bool {
+    let Some(registry) = registry else {
+        return true;
+    };
+    capture_channel
+        .read()
+        .ok()
+        .and_then(|slot| slot.clone())
+        .is_some_and(|shared| registry.is_current(&shared))
+}
+
+struct CaptureLaunch {
+    route: DeviceRoute,
+    capture_thumbwheel: bool,
+    divert_gesture_button: bool,
+    sink: mpsc::UnboundedSender<CapturedInput>,
+    channel_slot: CaptureChannel,
+    receiver_lease: SessionReceiverLease,
+    registry: Option<ChannelRegistry>,
+    done: mpsc::UnboundedSender<u64>,
+    epoch: u64,
+}
+
+fn spawn_capture_session(launch: CaptureLaunch) -> oneshot::Sender<CaptureStop> {
+    let (stop_tx, stop_rx) = oneshot::channel();
+    tokio::spawn(async move {
+        let result = {
+            let receiver_lease = launch.receiver_lease;
+            let result = if let Some(registry) = launch.registry.as_ref() {
+                run_capture_session_with_registry(
+                    launch.route,
+                    launch.capture_thumbwheel,
+                    launch.divert_gesture_button,
+                    launch.sink,
+                    stop_rx,
+                    launch.channel_slot,
+                    registry,
+                )
+                .await
+            } else {
+                run_capture_session_with_stop_reason(
+                    launch.route,
+                    launch.capture_thumbwheel,
+                    launch.divert_gesture_button,
+                    launch.sink,
+                    stop_rx,
+                    launch.channel_slot,
+                )
+                .await
+            };
+            drop(receiver_lease);
+            result
+        };
+        if let Err(error) = result {
+            debug!(%error, "capture session ended");
+        }
+        // Completion is sent only after the capture future released its channel
+        // and the receiver lease above, so the manager can safely replace it.
+        let _ = launch.done.send(launch.epoch);
+    });
+    stop_tx
+}
+
 /// Keep one capture session alive for the active device, restarting it when the
 /// device or the thumb-wheel arming changes, and dispatch incoming inputs. Runs
 /// for the lifetime of the process.
+#[expect(
+    clippy::too_many_arguments,
+    reason = "capture manager needs maps, dpi, rearm, leases, and registry"
+)]
 async fn manage(
     hook_maps: SharedHookMaps,
     gesture_bindings: GestureBindings,
     dpi_cycle: Arc<RwLock<DpiCycleState>>,
     capture_channel: CaptureChannel,
     thumbwheel_sensitivity: ThumbwheelSensitivity,
+    capture_rearm_generation: Arc<AtomicU64>,
     receiver_access: ReceiverAccess,
+    registry: Option<ChannelRegistry>,
 ) {
     let (tx, mut rx) = mpsc::unbounded_channel::<CapturedInput>();
-    // (route, capture_thumbwheel, divert_gesture_button)
-    let mut current: Option<(DeviceRoute, bool, bool)> = None;
-    let mut stop: Option<oneshot::Sender<()>> = None;
+    let mut current: Option<CaptureTarget> = None;
+    let mut stop: Option<oneshot::Sender<CaptureStop>> = None;
+    let mut stopping_epoch: Option<u64> = None;
     let mut ticker = tokio::time::interval(TARGET_POLL);
     let mut accumulators = WheelAccumulators::default();
     // Capture sessions run as detached tasks, so an unexpected exit (a transient
@@ -177,8 +361,12 @@ async fn manage(
                     &mut accumulators,
                     &hook_maps,
                     &gesture_bindings,
-                    &dpi_cycle,
-                    &capture_channel,
+                    DispatchHardware {
+                        dpi_cycle: &dpi_cycle,
+                        capture: &capture_channel,
+                        registry: registry.as_ref(),
+                        receiver_access: &receiver_access,
+                    },
                     &thumbwheel_sensitivity,
                 );
             }
@@ -186,7 +374,7 @@ async fn manage(
                 // While pairing is waiting or active, release the capture
                 // session so run_pairing can own the receiver's HID node (one
                 // process can't read it through two channels).
-                let want = if receiver_access.pairing_requested() {
+                let want = if receiver_access.exclusive_requested() {
                     None
                 } else {
                     let target = dpi_cycle.read().ok().and_then(|guard| guard.target.clone());
@@ -197,63 +385,62 @@ async fn manage(
                     // thread the full config in. Re-evaluated each tick, so a
                     // ReloadConfig owner change restarts the session accordingly.
                     let divert_gesture = gesture_bindings.read().is_ok_and(|g| !g.is_empty());
-                    target.map(|t| {
-                        (
-                            t,
-                            thumbwheel_armed(&hook_maps, sensitivity),
-                            divert_gesture,
-                        )
+                    let rearm_generation = capture_rearm_generation.load(Ordering::Relaxed);
+                    target.map(|route| CaptureTarget {
+                        route,
+                        capture_thumbwheel: thumbwheel_armed(&hook_maps, sensitivity),
+                        divert_gesture_button: divert_gesture,
+                        rearm_generation,
                     })
                 };
-                if want == current {
+                if stopping_epoch.is_some() {
                     continue;
                 }
-                // Target or thumb-wheel arming changed (or first tick): stop the
-                // old session and start one for the new state. Sending on the
-                // oneshot lets the old session restore the diverted controls.
-                if let Some(stop) = stop.take() {
-                    let _ = stop.send(());
-                }
-                if current.is_some() {
+                let connection_is_current =
+                    capture_connection_is_current(registry.as_ref(), &capture_channel);
+                if let Some(reason) =
+                    stop_for_target_change(want.as_ref(), current.as_ref(), connection_is_current)
+                {
+                    if let Some(stop) = stop.take() {
+                        let _ = stop.send(reason);
+                    }
+                    stopping_epoch = Some(epoch);
                     current = None;
                     continue;
                 }
-                if let Some((route, capture_thumbwheel, divert_gesture_button)) = want {
-                    let Some(receiver_lease) = receiver_access.try_acquire_for_capture() else {
+                if want == current {
+                    continue;
+                }
+                if let Some(target) = want {
+                    let Some(receiver_lease) = receiver_access.try_acquire_for_session() else {
                         current = None;
                         continue;
                     };
-                    current = Some((route.clone(), capture_thumbwheel, divert_gesture_button));
-                    let (stop_tx, stop_rx) = oneshot::channel();
-                    let sink = tx.clone();
-                    let slot = Arc::clone(&capture_channel);
+                    current = Some(target.clone());
                     epoch = epoch.wrapping_add(1);
-                    let session_epoch = epoch;
-                    let done = done_tx.clone();
-                    tokio::spawn(async move {
-                        let _receiver_lease = receiver_lease;
-                        if let Err(e) = run_capture_session(
-                            route,
-                            capture_thumbwheel,
-                            divert_gesture_button,
-                            sink,
-                            stop_rx,
-                            slot,
-                        )
-                        .await
-                        {
-                            debug!(error = %e, "capture session ended");
-                        }
-                        // Report completion so the manager can re-arm if this exit
-                        // was unexpected rather than a deliberate stop.
-                        let _ = done.send(session_epoch);
-                    });
-                    stop = Some(stop_tx);
+                    stop = Some(spawn_capture_session(CaptureLaunch {
+                        route: target.route,
+                        capture_thumbwheel: target.capture_thumbwheel,
+                        divert_gesture_button: target.divert_gesture_button,
+                        sink: tx.clone(),
+                        channel_slot: Arc::clone(&capture_channel),
+                        receiver_lease,
+                        registry: registry.clone(),
+                        done: done_tx.clone(),
+                        epoch,
+                    }));
                 } else {
                     current = None;
                 }
             }
             Some(done_epoch) = done_rx.recv() => {
+                if acknowledge_stopping(&mut stopping_epoch, done_epoch) {
+                    // The stopped task has cleared its slot, dropped the
+                    // listener/channel and released any receiver lease. A later
+                    // poll may now arm the desired replacement.
+                    stop = None;
+                    continue;
+                }
                 // A capture session ended on its own. Re-arm only when it is the
                 // session we currently believe is live for an active target;
                 // clearing `current` lets the next tick start a fresh session.
@@ -308,13 +495,20 @@ enum WheelOutput {
 }
 
 /// Route one captured input to its bound action (or re-synthesised scroll).
+#[derive(Clone, Copy)]
+struct DispatchHardware<'a> {
+    dpi_cycle: &'a Arc<RwLock<DpiCycleState>>,
+    capture: &'a CaptureChannel,
+    registry: Option<&'a ChannelRegistry>,
+    receiver_access: &'a ReceiverAccess,
+}
+
 fn dispatch(
     input: CapturedInput,
     accumulators: &mut WheelAccumulators,
     hook_maps: &SharedHookMaps,
     gesture_bindings: &GestureBindings,
-    dpi_cycle: &Arc<RwLock<DpiCycleState>>,
-    capture: &CaptureChannel,
+    hardware: DispatchHardware<'_>,
     thumbwheel_sensitivity: &ThumbwheelSensitivity,
 ) {
     match input {
@@ -325,19 +519,42 @@ fn dispatch(
                 .and_then(|guard| guard.get(&direction).cloned());
             if let Some(action) = action {
                 debug!(?direction, action = %action.label(), "gesture → action");
-                hook_runtime::dispatch_action(&action, dpi_cycle, capture);
+                hook_runtime::dispatch_action(
+                    &action,
+                    hardware.dpi_cycle,
+                    hardware.capture,
+                    hardware.registry,
+                    hardware.receiver_access,
+                );
             } else {
                 debug!(?direction, "gesture with no binding — ignored");
             }
         }
-        CapturedInput::ButtonPressed(button) => {
+        CapturedInput::ButtonPressed(button, frontmost_pid) => {
             let action = hook_maps
                 .read()
                 .ok()
                 .and_then(|maps| maps.bindings.get(&button).cloned());
             if let Some(action) = action {
                 debug!(?button, action = %action.label(), "HID++ button → action");
-                hook_runtime::dispatch_action(&action, dpi_cycle, capture);
+                // For browser navigation, use the AX API with the PID captured
+                // at press time (before async dispatch could shift focus).
+                let ax_handled = matches!(action, Action::BrowserBack | Action::BrowserForward)
+                    && frontmost_pid.is_some_and(|pid| {
+                        openlogi_inject::ax_navigate_browser(
+                            pid,
+                            matches!(action, Action::BrowserForward),
+                        )
+                    });
+                if !ax_handled {
+                    hook_runtime::dispatch_action(
+                        &action,
+                        hardware.dpi_cycle,
+                        hardware.capture,
+                        hardware.registry,
+                        hardware.receiver_access,
+                    );
+                }
             } else {
                 debug!(?button, "HID++ button with no binding — ignored");
             }
@@ -369,7 +586,13 @@ fn dispatch(
                 }
                 WheelOutput::FireAction => {
                     debug!(?button, action = %action.label(), "thumb wheel → action");
-                    hook_runtime::dispatch_action(&action, dpi_cycle, capture);
+                    hook_runtime::dispatch_action(
+                        &action,
+                        hardware.dpi_cycle,
+                        hardware.capture,
+                        hardware.registry,
+                        hardware.receiver_access,
+                    );
                 }
             }
         }
@@ -445,6 +668,9 @@ fn advance(
 
 #[cfg(test)]
 mod tests {
+    use std::panic::{AssertUnwindSafe, catch_unwind};
+    use std::sync::PoisonError;
+
     use super::*;
 
     #[test]
@@ -598,4 +824,58 @@ mod tests {
         // device is targeted): no target means there is nothing to re-arm.
         assert!(!should_rearm(7, 7, false));
     }
+
+    #[test]
+    fn unchanged_target_keeps_the_current_connection() {
+        assert_eq!(
+            stop_reason(Some(&"device-a"), Some(&"device-a"), true),
+            None
+        );
+    }
+
+    #[test]
+    fn revoked_connection_stops_without_disarming_it() {
+        assert_eq!(
+            stop_reason(Some(&"device-a"), Some(&"device-a"), false),
+            Some(CaptureStop::Revoked)
+        );
+    }
+
+    #[test]
+    fn target_change_stops_gracefully_while_connection_is_current() {
+        assert_eq!(
+            stop_reason(Some(&"device-b"), Some(&"device-a"), true),
+            Some(CaptureStop::Graceful)
+        );
+        assert_eq!(
+            stop_reason::<&str>(None, Some(&"device-a"), true),
+            Some(CaptureStop::Graceful)
+        );
+    }
+
+    #[test]
+    fn replacement_waits_for_the_stopped_epochs_acknowledgement() {
+        let mut stopping_epoch = Some(7);
+
+        assert!(!acknowledge_stopping(&mut stopping_epoch, 6));
+        assert_eq!(stopping_epoch, Some(7));
+
+        assert!(acknowledge_stopping(&mut stopping_epoch, 7));
+        assert_eq!(stopping_epoch, None);
+    }
+
+    #[test]
+    fn poisoned_capture_slot_fails_the_current_connection_check_closed() {
+        let capture: CaptureChannel = Arc::new(RwLock::new(None));
+        let poison = Arc::clone(&capture);
+        let _ = catch_unwind(AssertUnwindSafe(move || {
+            let _guard = poison.write().unwrap_or_else(PoisonError::into_inner);
+            panic!("poison capture slot");
+        }));
+
+        assert!(!capture_connection_is_current(
+            Some(&ChannelRegistry::default()),
+            &capture
+        ));
+    }
 }
diff --git a/crates/openlogi-agent-core/src/watchers/host_switch.rs b/crates/openlogi-agent-core/src/watchers/host_switch.rs
new file mode 100644
index 0000000000000000000000000000000000000000..2d888d5cb164ccfee025f255e0f3000148264f74
--- /dev/null
+++ b/crates/openlogi-agent-core/src/watchers/host_switch.rs
@@ -0,0 +1,194 @@
+//! Keep configured keyboard → pointing-device host-switch links armed.
+
+use std::sync::{Arc, RwLock};
+use std::thread;
+use std::time::{Duration, Instant};
+
+use openlogi_hid::{
+    ChannelPool, DeviceRoute, HostSwitchStopReason, run_host_switch_session, switch_linked_hosts,
+};
+use tokio::sync::{mpsc, oneshot};
+use tracing::{debug, warn};
+
+use crate::receiver_access::{ExclusiveAccessReason, ReceiverAccess};
+
+const DEPARTURE_TIMEOUT: Duration = Duration::from_secs(10);
+const DEPARTURE_POLL: Duration = Duration::from_millis(100);
+
+/// One resolved link. Config keys are converted to live routes by the
+/// orchestrator so the transport watcher never needs to understand inventory.
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub struct HostSwitchLink {
+    /// Keyboard whose host switch keys initiate the transition.
+    pub keyboard: DeviceRoute,
+    /// Pointing devices that follow the keyboard.
+    pub targets: Vec<DeviceRoute>,
+}
+
+/// Shared resolved links, refreshed with config and inventory.
+pub type HostSwitchLinks = Arc<RwLock<Vec<HostSwitchLink>>>;
+
+/// Spawn the host switch session manager.
+pub fn spawn(links: HostSwitchLinks, channel_pool: ChannelPool, receiver_access: ReceiverAccess) {
+    thread::spawn(move || {
+        let runtime = match tokio::runtime::Builder::new_current_thread()
+            .enable_all()
+            .build()
+        {
+            Ok(runtime) => runtime,
+            Err(error) => {
+                warn!(%error, "host switch watcher: could not build tokio runtime");
+                return;
+            }
+        };
+        runtime.block_on(manage(links, channel_pool, receiver_access));
+    });
+}
+
+async fn manage(
+    links: HostSwitchLinks,
+    channel_pool: ChannelPool,
+    receiver_access: ReceiverAccess,
+) {
+    let mut sessions = Vec::new();
+    let (done_tx, mut done_rx) = mpsc::unbounded_channel::<SessionCompletion>();
+    let mut next_generation = 0_u64;
+    let mut ticker = tokio::time::interval(Duration::from_secs(1));
+
+    loop {
+        tokio::select! {
+            _ = ticker.tick() => {
+                let wanted = if receiver_access.exclusive_requested() {
+                    Vec::new()
+                } else {
+                    links.read().map_or_else(|_| Vec::new(), |guard| guard.clone())
+                };
+                stop_unwanted(&mut sessions, &wanted).await;
+                for link in wanted {
+                    if sessions.iter().any(|session| session.link == link) {
+                        continue;
+                    }
+                    let (stop_tx, stop_rx) = oneshot::channel();
+                    let done = done_tx.clone();
+                    let pool = channel_pool.clone();
+                    let Some(receiver_lease) = receiver_access.try_acquire_for_session() else {
+                        break;
+                    };
+                    next_generation = next_generation.wrapping_add(1);
+                    let session_generation = next_generation;
+                    let session_link = link.clone();
+                    let task = tokio::spawn(async move {
+                        let _receiver_lease = receiver_lease;
+                        let keyboard = link.keyboard.clone();
+                        let request = match run_host_switch_session(
+                            link.keyboard.clone(),
+                            stop_rx,
+                            pool,
+                        )
+                        .await
+                        {
+                            Ok(host) => host.map(|host| (link, host)),
+                            Err(error) => {
+                                debug!(%error, route = %keyboard, "host switch session ended");
+                                None
+                            }
+                        };
+                        let _ = done.send(SessionCompletion {
+                            generation: session_generation,
+                            request,
+                        });
+                    });
+                    sessions.push(RunningSession {
+                        link: session_link,
+                        generation: session_generation,
+                        stop: stop_tx,
+                        task,
+                    });
+                }
+            }
+            Some(completion) = done_rx.recv() => {
+                if let Some(index) = sessions
+                    .iter()
+                    .position(|session| session.generation == completion.generation)
+                {
+                    let completed = sessions.remove(index);
+                    let _ = completed.task.await;
+                    if let Some((link, host)) = completion.request {
+                        stop_all(&mut sessions, HostSwitchStopReason::Graceful).await;
+                        run_transition(&links, &channel_pool, &receiver_access, link, host).await;
+                    }
+                }
+            }
+        }
+    }
+}
+
+struct RunningSession {
+    link: HostSwitchLink,
+    generation: u64,
+    stop: oneshot::Sender<HostSwitchStopReason>,
+    task: tokio::task::JoinHandle<()>,
+}
+
+struct SessionCompletion {
+    generation: u64,
+    request: Option<(HostSwitchLink, u8)>,
+}
+
+async fn stop_all(sessions: &mut Vec<RunningSession>, reason: HostSwitchStopReason) {
+    let running = std::mem::take(sessions);
+    let mut tasks = Vec::with_capacity(running.len());
+    for RunningSession { stop, task, .. } in running {
+        let _ = stop.send(reason);
+        tasks.push(task);
+    }
+    for task in tasks {
+        let _ = task.await;
+    }
+}
+
+async fn stop_unwanted(sessions: &mut Vec<RunningSession>, wanted: &[HostSwitchLink]) {
+    let mut index = 0;
+    while index < sessions.len() {
+        if wanted.contains(&sessions[index].link) {
+            index += 1;
+            continue;
+        }
+        let RunningSession { stop, task, .. } = sessions.remove(index);
+        let _ = stop.send(HostSwitchStopReason::Graceful);
+        let _ = task.await;
+    }
+}
+
+async fn run_transition(
+    links: &HostSwitchLinks,
+    channel_pool: &ChannelPool,
+    receiver_access: &ReceiverAccess,
+    link: HostSwitchLink,
+    host: u8,
+) {
+    let _lease = receiver_access
+        .acquire_exclusive(ExclusiveAccessReason::HostTransition)
+        .await;
+    match switch_linked_hosts(&link.keyboard, &link.targets, host, channel_pool).await {
+        Ok(true) => wait_for_departure(links, &link.keyboard).await,
+        Ok(false) => {}
+        Err(error) => {
+            debug!(%error, route = %link.keyboard, host, "keyboard host switch failed");
+        }
+    }
+}
+
+async fn wait_for_departure(links: &HostSwitchLinks, keyboard: &DeviceRoute) {
+    let deadline = Instant::now() + DEPARTURE_TIMEOUT;
+    while Instant::now() < deadline {
+        let departed = links.read().map_or(true, |current| {
+            !current.iter().any(|link| link.keyboard == *keyboard)
+        });
+        if departed {
+            return;
+        }
+        tokio::time::sleep(DEPARTURE_POLL).await;
+    }
+    warn!(route = %keyboard, "host transition departure was not observed");
+}
diff --git a/crates/openlogi-agent-core/src/watchers/inventory.rs b/crates/openlogi-agent-core/src/watchers/inventory.rs
index 107ddd6b98ebe65c874213d0d583d8f8afaae6ed..d5104f4c5d80d7316e53b8b57f3f996bd48577a1 100644
--- a/crates/openlogi-agent-core/src/watchers/inventory.rs
+++ b/crates/openlogi-agent-core/src/watchers/inventory.rs
@@ -11,11 +11,13 @@
 //! the reconciliation pass (battery refresh, missed events, platforms where
 //! the hotplug stream is unavailable).
 
+use std::collections::{BTreeMap, HashSet};
 use std::thread;
 use std::time::{Duration, SystemTime};
 
 use futures_lite::StreamExt as _;
-use openlogi_core::device::DeviceInventory;
+use openlogi_core::device::{DeviceInventory, StandaloneDevice};
+use openlogi_hid::ChannelRegistry;
 use tokio::sync::mpsc;
 use tracing::{debug, info, warn};
 
@@ -26,6 +28,12 @@ use tracing::{debug, info, warn};
 /// live inventory.
 const INITIAL_FAILURE_LIMIT: u8 = 3;
 
+/// Number of successful raw-HID snapshots an omitted node may miss before it
+/// is treated as a real detach. OS enumeration can briefly omit a registered
+/// interface during unplug/replug and hotplug bursts, so a successful empty
+/// snapshot is not immediately destructive for standalone lights.
+const RAW_NODE_MISS_GRACE: u8 = 2;
+
 /// Pause between a hotplug event and the early enumerate, so a just-connected
 /// node finishes registering with the OS before the probe opens it.
 const HOTPLUG_SETTLE: Duration = Duration::from_millis(400);
@@ -41,7 +49,12 @@ const WAKE_GAP: Duration = Duration::from_mins(1);
 #[derive(Debug)]
 pub enum InventoryEvent {
     /// A completed enumeration — empty means "checked, no devices".
-    Snapshot(Vec<DeviceInventory>),
+    Snapshot {
+        /// HID++ receiver/direct inventory.
+        inventories: Vec<DeviceInventory>,
+        /// Recognized standalone raw-HID devices.
+        standalone: Vec<StandaloneDevice>,
+    },
     /// Enumeration has never succeeded and won't be treated as "still
     /// starting" any longer; without this the GUI would show its scanning
     /// state forever on a broken HID backend.
@@ -64,9 +77,103 @@ struct WatchState {
     succeeded: bool,
     /// Consecutive failures, counted only before the first success.
     initial_failures: u8,
+    raw_nodes: RawNodeLedger,
+}
+
+#[derive(Default)]
+struct RawNodeLedger {
+    entries: BTreeMap<String, RawNodeEntry>,
+}
+
+struct RawNodeEntry {
+    device: StandaloneDevice,
+    misses: u8,
+}
+
+impl RawNodeLedger {
+    /// Reconcile one successful raw enumeration with the last good per-node
+    /// records. Omitted nodes stay offline for a bounded grace; a node seen
+    /// again is replaced by its fresh descriptor and its miss count resets.
+    fn reconcile(&mut self, live: Vec<StandaloneDevice>) -> Vec<StandaloneDevice> {
+        let live_keys: HashSet<String> = live.iter().map(raw_node_key).collect();
+        for device in live {
+            self.entries
+                .insert(raw_node_key(&device), RawNodeEntry { device, misses: 0 });
+        }
+
+        let missing: Vec<String> = self
+            .entries
+            .keys()
+            .filter(|key| !live_keys.contains(*key))
+            .cloned()
+            .collect();
+        for key in missing {
+            let Some(entry) = self.entries.get_mut(&key) else {
+                continue;
+            };
+            entry.misses = entry.misses.saturating_add(1);
+            if entry.misses > RAW_NODE_MISS_GRACE {
+                self.entries.remove(&key);
+            } else {
+                entry.device.online = false;
+            }
+        }
+
+        self.entries
+            .values()
+            .map(|entry| entry.device.clone())
+            .collect()
+    }
+
+    /// Return the last completed raw-HID snapshot without counting a miss.
+    /// Used when standalone enumeration itself fails: absence was not
+    /// observed, so advancing detach grace would manufacture a disconnect.
+    fn snapshot(&self) -> Vec<StandaloneDevice> {
+        self.entries
+            .values()
+            .map(|entry| entry.device.clone())
+            .collect()
+    }
+}
+
+fn raw_node_key(device: &StandaloneDevice) -> String {
+    let address = &device.address;
+    format!(
+        "{:04x}:{:04x}:{:04x}:{:04x}:{}",
+        address.vendor_id,
+        address.product_id,
+        address.usage_page,
+        address.usage_id,
+        address.identity
+    )
 }
 
 impl WatchState {
+    /// Combine a successful HID++ enumeration with the independently fallible
+    /// raw-HID pass. A raw backend failure must not suppress fresh mouse and
+    /// keyboard inventory, nor count every remembered light as detached.
+    fn classify_parts(
+        &mut self,
+        inventories: Vec<DeviceInventory>,
+        standalone: Result<Vec<StandaloneDevice>, openlogi_hid::InventoryError>,
+    ) -> InventoryEvent {
+        self.succeeded = true;
+        let standalone = match standalone {
+            Ok(devices) => self.raw_nodes.reconcile(devices),
+            Err(e) => {
+                warn!(
+                    error = ?e,
+                    "standalone enumerate failed during watch tick — keeping last raw snapshot"
+                );
+                self.raw_nodes.snapshot()
+            }
+        };
+        InventoryEvent::Snapshot {
+            inventories,
+            standalone,
+        }
+    }
+
     /// Decide what (if anything) a watch tick emits.
     ///
     /// - `Ok(snapshot)` — a completed enumeration (an empty one included: that's
@@ -82,13 +189,10 @@ impl WatchState {
     ///   retrying and a later success recovers.
     fn classify(
         &mut self,
-        result: Result<Vec<DeviceInventory>, openlogi_hid::InventoryError>,
+        result: Result<(Vec<DeviceInventory>, Vec<StandaloneDevice>), openlogi_hid::InventoryError>,
     ) -> Option<InventoryEvent> {
         match result {
-            Ok(inv) => {
-                self.succeeded = true;
-                Some(InventoryEvent::Snapshot(inv))
-            }
+            Ok((inventories, standalone)) => Some(self.classify_parts(inventories, Ok(standalone))),
             Err(e) => {
                 warn!(error = ?e, "enumerate failed during watch tick — keeping last snapshot");
                 if self.succeeded {
@@ -110,7 +214,25 @@ impl WatchState {
 /// the loop exits cleanly. The watcher dying instead (a panic inside the HID
 /// backend) closes the channel — the agent select loop maps that closure to
 /// `Unavailable` too.
+#[must_use]
 pub fn spawn(period: Duration) -> mpsc::UnboundedReceiver<InventoryEvent> {
+    spawn_inner(period, None)
+}
+
+/// Spawn the persistent watcher and publish its inventory-owned HID++ channels
+/// into `registry` for Agent capture and hardware operations.
+#[must_use]
+pub fn spawn_with_registry(
+    period: Duration,
+    registry: ChannelRegistry,
+) -> mpsc::UnboundedReceiver<InventoryEvent> {
+    spawn_inner(period, Some(registry))
+}
+
+fn spawn_inner(
+    period: Duration,
+    registry: Option<ChannelRegistry>,
+) -> mpsc::UnboundedReceiver<InventoryEvent> {
     let (tx, rx) = mpsc::unbounded_channel();
     let worker_tx = tx.clone();
     let spawn_result = thread::Builder::new()
@@ -129,7 +251,10 @@ pub fn spawn(period: Duration) -> mpsc::UnboundedReceiver<InventoryEvent> {
             // A persistent enumerator so its per-device probe cache survives
             // across ticks — a known device's immutable data (model, features)
             // is reused instead of being re-handshaked every poll.
-            let mut enumerator = openlogi_hid::Enumerator::default();
+            let mut enumerator = registry.map_or_else(
+                openlogi_hid::Enumerator::default,
+                openlogi_hid::Enumerator::with_registry,
+            );
             let mut state = WatchState::default();
             let mut last_tick = SystemTime::now();
             // `block_on` installs runtime context so a backend that registers an
@@ -156,8 +281,14 @@ pub fn spawn(period: Duration) -> mpsc::UnboundedReceiver<InventoryEvent> {
                     }
                 }
                 last_tick = now;
-                let result = rt.block_on(enumerator.enumerate());
-                if let Some(event) = state.classify(result)
+                let event = match rt.block_on(enumerator.enumerate()) {
+                    Ok(inventories) => {
+                        let standalone = rt.block_on(openlogi_hid::enumerate_standalone());
+                        Some(state.classify_parts(inventories, standalone))
+                    }
+                    Err(error) => state.classify(Err(error)),
+                };
+                if let Some(event) = event
                     && worker_tx.send(event).is_err()
                 {
                     debug!("inventory watcher receiver dropped — exiting");
@@ -212,6 +343,7 @@ pub fn spawn(period: Duration) -> mpsc::UnboundedReceiver<InventoryEvent> {
 mod tests {
     use std::assert_matches;
 
+    use openlogi_core::device::{DeviceKind, RawDeviceAddress, StandaloneDevice};
     use openlogi_hid::InventoryError;
 
     use super::{INITIAL_FAILURE_LIMIT, InventoryEvent, WatchState};
@@ -228,8 +360,8 @@ mod tests {
         // A genuine "checked, nothing there" still propagates as a disconnect —
         // the resilience must not swallow a real empty.
         assert_matches!(
-            state.classify(Ok(vec![])),
-            Some(InventoryEvent::Snapshot(snap)) if snap.is_empty()
+            state.classify(Ok((vec![], vec![]))),
+            Some(InventoryEvent::Snapshot { inventories, standalone }) if inventories.is_empty() && standalone.is_empty()
         );
         assert!(state.succeeded);
     }
@@ -239,8 +371,8 @@ mod tests {
         let mut state = WatchState::default();
         // A good tick first, so there is a last-known-good set to preserve.
         assert_matches!(
-            state.classify(Ok(vec![])),
-            Some(InventoryEvent::Snapshot(_))
+            state.classify(Ok((vec![], vec![]))),
+            Some(InventoryEvent::Snapshot { .. })
         );
         // Then transient enumerate failures emit nothing — the agent keeps the
         // last snapshot instead of flapping to "No devices" (#218).
@@ -248,6 +380,20 @@ mod tests {
         assert!(state.classify(Err(enumerate_failed())).is_none());
     }
 
+    #[test]
+    fn standalone_failure_keeps_raw_nodes_without_suppressing_the_snapshot() {
+        let mut state = WatchState::default();
+        let _ = state.classify(Ok((vec![], vec![raw_light("serial:glow-1")])));
+
+        assert_matches!(
+            state.classify_parts(vec![], Err(enumerate_failed())),
+            InventoryEvent::Snapshot { inventories, standalone }
+                if inventories.is_empty()
+                    && standalone.len() == 1
+                    && standalone[0].online
+        );
+    }
+
     #[test]
     fn persistent_initial_failure_reports_unavailable_once_then_recovers() {
         let mut state = WatchState::default();
@@ -264,8 +410,59 @@ mod tests {
         assert!(state.classify(Err(enumerate_failed())).is_none());
         // …and a later success recovers with a live snapshot.
         assert_matches!(
-            state.classify(Ok(vec![])),
-            Some(InventoryEvent::Snapshot(_))
+            state.classify(Ok((vec![], vec![]))),
+            Some(InventoryEvent::Snapshot { .. })
+        );
+    }
+
+    fn raw_light(identity: &str) -> StandaloneDevice {
+        StandaloneDevice {
+            address: RawDeviceAddress {
+                vendor_id: 0x046d,
+                product_id: 0xc900,
+                usage_page: 0xff43,
+                usage_id: 0x0202,
+                identity: identity.into(),
+            },
+            display_name: "Litra Glow".into(),
+            manufacturer: Some("Logi".into()),
+            serial_number: None,
+            unit_id: [0; 4],
+            kind: DeviceKind::Light,
+            online: true,
+            capabilities: None,
+            light_capabilities: None,
+            driver_id: "litra".into(),
+            registry_model_id: None,
+        }
+    }
+
+    #[test]
+    fn raw_node_omission_is_graced_and_recovers() {
+        let mut state = WatchState::default();
+        assert_matches!(
+            state.classify(Ok((vec![], vec![raw_light("id:node")]))) ,
+            Some(InventoryEvent::Snapshot { standalone, .. }) if standalone.len() == 1 && standalone[0].online
+        );
+        assert_matches!(
+            state.classify(Ok((vec![], vec![]))),
+            Some(InventoryEvent::Snapshot { standalone, .. }) if standalone.len() == 1 && !standalone[0].online
+        );
+        assert_matches!(
+            state.classify(Ok((vec![], vec![raw_light("id:node")]))) ,
+            Some(InventoryEvent::Snapshot { standalone, .. }) if standalone.len() == 1 && standalone[0].online
+        );
+    }
+
+    #[test]
+    fn raw_node_is_removed_after_grace_is_exhausted() {
+        let mut state = WatchState::default();
+        let _ = state.classify(Ok((vec![], vec![raw_light("id:node")])));
+        let _ = state.classify(Ok((vec![], vec![])));
+        let _ = state.classify(Ok((vec![], vec![])));
+        assert_matches!(
+            state.classify(Ok((vec![], vec![]))),
+            Some(InventoryEvent::Snapshot { standalone, .. }) if standalone.is_empty()
         );
     }
 }
diff --git a/crates/openlogi-agent-core/src/watchers/keyboard.rs b/crates/openlogi-agent-core/src/watchers/keyboard.rs
new file mode 100644
index 0000000000000000000000000000000000000000..d073c0717c667162215c944a89e124e450ef9eb0
--- /dev/null
+++ b/crates/openlogi-agent-core/src/watchers/keyboard.rs
@@ -0,0 +1,204 @@
+//! Background HID++ key-capture watcher for a bound keyboard.
+//!
+//! Runs [`openlogi_hid::run_keyboard_capture_session_with_registry`] on a
+//! dedicated thread for the keyboard the orchestrator publishes in
+//! [`SharedKeyboardSpec`], restarts it when the keyboard (or the set of bound
+//! keys) changes, and dispatches each captured key press through the common
+//! action path ([`crate::hook_runtime::dispatch_action`]).
+//!
+//! The mouse capture watcher ([`super::gesture`]) and this one hold *shared*
+//! receiver leases, so both run concurrently; pairing still waits for (and
+//! excludes) both. Like the gesture watcher, this needs no macOS Accessibility
+//! permission — the key events arrive over HID++.
+
+use std::collections::BTreeMap;
+use std::sync::{Arc, RwLock};
+use std::thread;
+use std::time::Duration;
+
+use openlogi_core::binding::{Action, ButtonId};
+use openlogi_hid::{
+    CaptureChannel, CapturedInput, ChannelRegistry, DeviceRoute,
+    run_keyboard_capture_session_with_registry,
+};
+use tokio::sync::{mpsc, oneshot};
+use tracing::{debug, info, warn};
+
+use crate::DpiCycleState;
+use crate::hook_runtime;
+use crate::receiver_access::ReceiverAccess;
+use crate::watchers::gesture::should_rearm;
+
+/// Everything the watcher needs to capture one keyboard: where it is, which
+/// `0x1b04` controls to divert (only keys carrying a real binding), and the
+/// per-key action map presses dispatch through. Rebuilt by the orchestrator on
+/// config / inventory / foreground-app changes.
+#[derive(Clone)]
+pub struct KeyboardSpec {
+    /// HID++ route of the keyboard.
+    pub route: DeviceRoute,
+    /// `0x1b04` control ID → button, for exactly the bound keys.
+    pub wanted: BTreeMap<u16, ButtonId>,
+    /// Effective per-key single-action map (per-app overlay applied).
+    pub bindings: BTreeMap<ButtonId, Action>,
+}
+
+/// Shared keyboard-capture spec, `None` when no online keyboard has bound
+/// keys. Written by the orchestrator, read by the watcher.
+pub type SharedKeyboardSpec = Arc<RwLock<Option<KeyboardSpec>>>;
+
+/// How often to re-read the spec so a config edit, per-app overlay change, or
+/// keyboard reconnect re-points the capture session.
+const TARGET_POLL: Duration = Duration::from_secs(1);
+
+/// Spawn the keyboard-capture manager thread. It owns a current-thread tokio
+/// runtime that keeps one capture session pointed at the bound keyboard and
+/// dispatches each captured key press.
+pub fn spawn(
+    spec: SharedKeyboardSpec,
+    dpi_cycle: Arc<RwLock<DpiCycleState>>,
+    mouse_capture: CaptureChannel,
+    keyboard_channel: CaptureChannel,
+    receiver_access: ReceiverAccess,
+    registry: ChannelRegistry,
+) {
+    thread::spawn(move || {
+        let runtime = match tokio::runtime::Builder::new_current_thread()
+            .enable_all()
+            .build()
+        {
+            Ok(rt) => rt,
+            Err(e) => {
+                warn!(error = %e, "keyboard watcher: could not build tokio runtime");
+                return;
+            }
+        };
+        runtime.block_on(manage(
+            spec,
+            dpi_cycle,
+            mouse_capture,
+            keyboard_channel,
+            receiver_access,
+            registry,
+        ));
+    });
+}
+
+/// Keep one keyboard capture session alive for the published spec, restarting
+/// it when the keyboard or its bound-key set changes, and dispatch incoming
+/// presses. Runs for the lifetime of the process.
+async fn manage(
+    spec: SharedKeyboardSpec,
+    dpi_cycle: Arc<RwLock<DpiCycleState>>,
+    mouse_capture: CaptureChannel,
+    keyboard_channel: CaptureChannel,
+    receiver_access: ReceiverAccess,
+    registry: ChannelRegistry,
+) {
+    let (tx, mut rx) = mpsc::unbounded_channel::<CapturedInput>();
+    let mut current: Option<(DeviceRoute, BTreeMap<u16, ButtonId>)> = None;
+    let mut stop: Option<oneshot::Sender<()>> = None;
+    let mut ticker = tokio::time::interval(TARGET_POLL);
+    // Sessions report completion tagged with their start epoch, so an
+    // unexpected exit of the *current* session re-arms while stale completions
+    // are ignored — same pacing/starvation reasoning as the gesture watcher.
+    let (done_tx, mut done_rx) = mpsc::unbounded_channel::<u64>();
+    let mut epoch: u64 = 0;
+
+    loop {
+        tokio::select! {
+            Some(input) = rx.recv() => {
+                // The keyboard session only emits ButtonPressed; other inputs
+                // (gesture/scroll) never originate here.
+                let CapturedInput::ButtonPressed(button, _) = input else {
+                    continue;
+                };
+                let action = spec
+                    .read()
+                    .ok()
+                    .and_then(|guard| {
+                        guard.as_ref().and_then(|s| s.bindings.get(&button).cloned())
+                    });
+                if let Some(action) = action {
+                    info!(button = %button, action = %action.label(), "keyboard key → executing bound action");
+                    hook_runtime::dispatch_action(
+                        &action,
+                        &dpi_cycle,
+                        &mouse_capture,
+                        Some(&registry),
+                        &receiver_access,
+                    );
+                } else {
+                    debug!(?button, "keyboard key with no binding — ignored");
+                }
+            }
+            _ = ticker.tick() => {
+                // While pairing is waiting or active, release the capture
+                // session so run_pairing can own the receiver's HID node.
+                let want = if receiver_access.exclusive_requested() {
+                    None
+                } else {
+                    spec.read()
+                        .ok()
+                        .and_then(|guard| guard.clone())
+                        .map(|s| (s.route, s.wanted))
+                };
+                if want == current {
+                    continue;
+                }
+                // Spec changed (or first tick): stop the old session and start
+                // one for the new state. Sending on the oneshot lets the old
+                // session restore the diverted controls.
+                if let Some(stop) = stop.take() {
+                    let _ = stop.send(());
+                }
+                if current.is_some() {
+                    current = None;
+                    continue;
+                }
+                if let Some((route, wanted)) = want {
+                    let Some(receiver_lease) = receiver_access.try_acquire_for_session() else {
+                        current = None;
+                        continue;
+                    };
+                    current = Some((route.clone(), wanted.clone()));
+                    let (stop_tx, stop_rx) = oneshot::channel();
+                    let sink = tx.clone();
+                    let slot = Arc::clone(&keyboard_channel);
+                    let session_registry = registry.clone();
+                    epoch = epoch.wrapping_add(1);
+                    let session_epoch = epoch;
+                    let done = done_tx.clone();
+                    tokio::spawn(async move {
+                        let _receiver_lease = receiver_lease;
+                        if let Err(e) = run_keyboard_capture_session_with_registry(
+                            route,
+                            wanted,
+                            sink,
+                            stop_rx,
+                            slot,
+                            &session_registry,
+                        )
+                        .await
+                        {
+                            debug!(error = %e, "keyboard capture session ended");
+                        }
+                        let _ = done.send(session_epoch);
+                    });
+                    stop = Some(stop_tx);
+                } else {
+                    current = None;
+                }
+            }
+            Some(done_epoch) = done_rx.recv() => {
+                // A capture session ended on its own; re-arm only the live one
+                // (see gesture watcher for the epoch/pacing rationale).
+                if should_rearm(done_epoch, epoch, current.is_some()) {
+                    warn!("keyboard capture session ended unexpectedly, re-arming");
+                    current = None;
+                    stop = None;
+                }
+            }
+        }
+    }
+}
diff --git a/crates/openlogi-agent-core/src/watchers/mod.rs b/crates/openlogi-agent-core/src/watchers/mod.rs
index cf2985dff820b524a8e285e0c756abf3743b50d6..baf2b60ff5ee84971beef13169bf8ad471b88ad4 100644
--- a/crates/openlogi-agent-core/src/watchers/mod.rs
+++ b/crates/openlogi-agent-core/src/watchers/mod.rs
@@ -3,7 +3,10 @@
 //! consumer (the agent's orchestrator, or the GUI).
 
 pub mod accessibility;
+pub mod camera;
 pub mod foreground_app;
 pub mod gesture;
+pub mod host_switch;
 pub mod inventory;
+pub mod keyboard;
 pub mod pairing;
diff --git a/crates/openlogi-agent-core/tests/wire_format.rs b/crates/openlogi-agent-core/tests/wire_format.rs
index 38fbd82c2fde42688c952e833e3635486560add8..62f34419785533cc2e4cd780e8a19b7a5ab6f6ce 100644
--- a/crates/openlogi-agent-core/tests/wire_format.rs
+++ b/crates/openlogi-agent-core/tests/wire_format.rs
@@ -29,11 +29,12 @@ use openlogi_agent_core::ipc::{
 use openlogi_core::config::Lighting;
 use openlogi_core::device::{
     BatteryInfo, BatteryLevel, BatteryStatus, Capabilities, DeviceInventory, DeviceKind,
-    DeviceModelInfo, DeviceTransports, PairedDevice, ReceiverInfo,
+    DeviceModelInfo, DeviceTransports, LightCapabilities, LightValueRange, LightValueUnit,
+    PairedDevice, RawDeviceAddress, ReceiverInfo, StandaloneDevice,
 };
 use openlogi_hid::{
     Click, DeviceRoute, DpiCapabilities, DpiInfo, HidppFeatureErrorKind, HidppOperation,
-    PasskeyMethod, ReceiverSelector, SmartShiftMode, SmartShiftStatus, WriteError,
+    LightCommand, PasskeyMethod, ReceiverSelector, SmartShiftMode, SmartShiftStatus, WriteError,
 };
 
 /// Serialize exactly as the transport does (`tokio_serde::formats::Bincode`
@@ -61,7 +62,7 @@ fn assert_wire<T: serde::Serialize>(value: &T, golden: &str) {
 /// that makes that visible in the same diff.
 #[test]
 fn protocol_version_is_pinned() {
-    assert_eq!(PROTOCOL_VERSION, 11);
+    assert_eq!(PROTOCOL_VERSION, 13);
 }
 
 /// tarpc encodes the request enum's variant index, so trait *method order* is
@@ -83,6 +84,32 @@ fn request_variant_order() {
     assert_wire(&AgentRequest::NextPairing {}, "0d");
     assert_wire(&AgentRequest::Snapshot {}, "0e");
     assert_wire(&AgentRequest::PollEventMonitor {}, "0f");
+    assert_wire(
+        &AgentRequest::SetLight {
+            route: DeviceRoute::RawHid {
+                vendor_id: 0x046d,
+                product_id: 0xc900,
+                usage_page: 0xff43,
+                usage_id: 0x0202,
+                identity: "serial:ABC123".into(),
+            },
+            command: LightCommand::Power(true),
+        },
+        "1003fb6d04fb00c9fb43fffb02020d73657269616c3a4142433132330001",
+    );
+    assert_wire(
+        &AgentRequest::SetLightManualPower {
+            route: DeviceRoute::RawHid {
+                vendor_id: 0x046d,
+                product_id: 0xc900,
+                usage_page: 0xff43,
+                usage_id: 0x0202,
+                identity: "serial:ABC123".into(),
+            },
+            enabled: false,
+        },
+        "1103fb6d04fb00c9fb43fffb02020d73657269616c3a41424331323300",
+    );
 }
 
 #[test]
@@ -135,12 +162,17 @@ fn agent_snapshot() {
             agent_version: "0.6.6".into(),
         },
         inventory: Vec::new(),
+        standalone: Vec::new(),
+        camera_active: false,
     };
-    assert_wire(&snapshot, "010001010705302e362e3600");
+    assert_wire(&snapshot, "010001010705302e362e36000000");
 }
 
 #[test]
 fn device_inventory() {
+    // `Light` was appended after `Unknown`; preserve every existing kind's
+    // bincode discriminant.
+    assert_wire(&DeviceKind::Light, "0d");
     let inventory = vec![DeviceInventory {
         receiver: ReceiverInfo {
             name: "Bolt Receiver".into(),
@@ -244,6 +276,12 @@ fn device_settings_payloads() {
         },
         "0804",
     );
+    assert_wire(
+        &WriteError::RequestTimedOut {
+            operation: HidppOperation::Light,
+        },
+        "080d",
+    );
     assert_wire(
         &WriteError::HidppFeature {
             operation: HidppOperation::WriteDpi,
@@ -293,3 +331,69 @@ fn device_settings_payloads() {
         "01084630304443414645",
     );
 }
+
+#[test]
+fn standalone_light_dtos_commands_and_errors() {
+    let brightness =
+        LightValueRange::new(20, 250, 1, LightValueUnit::Lumens).expect("valid brightness range");
+    let temperature = LightValueRange::new(2700, 6500, 100, LightValueUnit::Kelvin)
+        .expect("valid temperature range");
+    let capabilities = LightCapabilities {
+        power: true,
+        brightness: Some(brightness),
+        temperature: Some(temperature),
+        color: false,
+        zones: false,
+    };
+    let standalone = StandaloneDevice {
+        address: RawDeviceAddress {
+            vendor_id: 0x046d,
+            product_id: 0xc900,
+            usage_page: 0xff43,
+            usage_id: 0x0202,
+            identity: "serial:glow-1".into(),
+        },
+        display_name: "Litra Glow".into(),
+        manufacturer: Some("Logi".into()),
+        serial_number: Some("glow-1".into()),
+        unit_id: [0; 4],
+        kind: DeviceKind::Light,
+        online: true,
+        capabilities: None,
+        light_capabilities: Some(capabilities),
+        driver_id: "litra".into(),
+        registry_model_id: Some("8c900".into()),
+    };
+
+    assert_wire(
+        &standalone,
+        "fb6d04fb00c9fb43fffb02020d73657269616c3a676c6f772d310a4c6974726120476c6f7701044c6f67690106676c6f772d31000000000d010001010114fa010101fb8c0afb641964020000056c6974726101053863393030",
+    );
+    let mut legacy = standalone.clone();
+    legacy.registry_model_id = None;
+    assert_wire(
+        &legacy,
+        "fb6d04fb00c9fb43fffb02020d73657269616c3a676c6f772d310a4c6974726120476c6f7701044c6f67690106676c6f772d31000000000d010001010114fa010101fb8c0afb641964020000056c69747261",
+    );
+    assert_wire(&capabilities, "010114fa010101fb8c0afb641964020000");
+    assert_wire(&brightness, "14fa0101");
+    assert_wire(&temperature, "fb8c0afb64196402");
+    assert_wire(&LightCommand::Power(true), "0001");
+    assert_wire(&LightCommand::BrightnessPercent(65), "0141");
+    assert_wire(&LightCommand::TemperatureKelvin(4600), "02fbf811");
+    assert_wire(&LightCommand::BrightnessNative(136), "0388");
+    assert_wire(
+        &WriteError::InvalidLightValue {
+            control: "temperature_kelvin".into(),
+            value: 2750,
+        },
+        "0b1274656d70657261747572655f6b656c76696efbbe0a",
+    );
+    assert_wire(
+        &WriteError::LightUnsupported {
+            control: "color".into(),
+        },
+        "0c05636f6c6f72",
+    );
+    assert_wire(&WriteError::AmbiguousRawDevice, "0d");
+}
diff --git a/crates/openlogi-agent/Cargo.toml b/crates/openlogi-agent/Cargo.toml
index e99f143d697efa844be18a27766163b88902b943..a3b652492acf57e97ead5781168d4a7169d8fb14 100644
--- a/crates/openlogi-agent/Cargo.toml
+++ b/crates/openlogi-agent/Cargo.toml
@@ -39,9 +39,9 @@ embed-resource = "3.0.9"
 # the GUI's so the resolve doesn't move the gpui Cargo.lock pin.
 [target.'cfg(target_os = "macos")'.dependencies]
 objc2 = { workspace = true }
-objc2-app-kit = { workspace = true, features = ["NSStatusBar", "NSStatusItem", "NSStatusBarButton", "NSButton", "NSControl", "NSResponder", "NSView", "NSMenu", "NSMenuItem", "NSImage", "NSApplication", "NSRunningApplication"] }
-objc2-foundation = { workspace = true, features = ["NSString", "NSData", "NSArray"] }
-plist = "1.9.0"
+objc2-app-kit = { workspace = true, features = ["NSStatusBar", "NSStatusItem", "NSStatusBarButton", "NSButton", "NSControl", "NSResponder", "NSView", "NSMenu", "NSMenuItem", "NSImage", "NSApplication", "NSRunningApplication", "NSWorkspace"] }
+objc2-foundation = { workspace = true, features = ["NSString", "NSData", "NSArray", "NSNotification"] }
+plist = "1.10.0"
 
 # Autostart via the HKCU Run key (launch_agent.rs); winreg also answers the
 # taskbar light/dark theme read for the tray glyph (tray_windows.rs). The
diff --git a/crates/openlogi-agent/src/main.rs b/crates/openlogi-agent/src/main.rs
index 6ce40c456e2d9d7031d13e03c07ed04a14d49bca..083f9da37a58c9dc496cad90c574444c99098cc7 100644
--- a/crates/openlogi-agent/src/main.rs
+++ b/crates/openlogi-agent/src/main.rs
@@ -32,7 +32,7 @@ use std::sync::atomic::{AtomicBool, Ordering};
 use std::time::Duration;
 
 use openlogi_agent_core::event_monitor::EventMonitor;
-use openlogi_agent_core::orchestrator::Orchestrator;
+use openlogi_agent_core::orchestrator::{Orchestrator, SharedRuntime};
 use openlogi_agent_core::{hook_runtime, watchers};
 use openlogi_core::config::Config;
 use openlogi_hook::Hook;
@@ -101,14 +101,16 @@ fn main() {
         // Read the menu-bar preference before `config` moves into the core
         // thread; the main thread hosts the tray.
         let show_in_menu_bar = config.app_settings.show_in_menu_bar;
+        let resume_pending = Arc::new(AtomicBool::new(false));
+        let core_resume_pending = Arc::clone(&resume_pending);
         if let Err(e) = std::thread::Builder::new()
             .name("openlogi-agent-core".into())
-            .spawn(move || runtime.block_on(run(config)))
+            .spawn(move || runtime.block_on(run(config, core_resume_pending)))
         {
             warn!(error = %e, "could not spawn the agent core thread; exiting");
             return;
         }
-        tray::run_app_loop(show_in_menu_bar);
+        tray::run_app_loop(show_in_menu_bar, resume_pending);
     }
     #[cfg(not(target_os = "macos"))]
     {
@@ -120,7 +122,34 @@ fn main() {
     }
 }
 
-async fn run(config: Config) {
+/// Start the HID++ background sessions that do not need Accessibility.
+fn spawn_hidpp_watchers(shared: &SharedRuntime) {
+    watchers::gesture::spawn_with_registry(
+        shared.hook_maps.clone(),
+        shared.gesture_bindings.clone(),
+        shared.dpi_cycle.clone(),
+        shared.capture_channel.clone(),
+        shared.thumbwheel_sensitivity.clone(),
+        shared.capture_rearm_generation.clone(),
+        shared.receiver_access.clone(),
+        shared.channel_registry.clone(),
+    );
+    watchers::host_switch::spawn(
+        shared.host_switch_links.clone(),
+        shared.channel_pool.clone(),
+        shared.receiver_access.clone(),
+    );
+    watchers::keyboard::spawn(
+        shared.keyboard_spec.clone(),
+        shared.dpi_cycle.clone(),
+        shared.capture_channel.clone(),
+        shared.keyboard_channel.clone(),
+        shared.receiver_access.clone(),
+        shared.channel_registry.clone(),
+    );
+}
+
+async fn run(config: Config, #[cfg(target_os = "macos")] resume_pending: Arc<AtomicBool>) {
     // Reconcile the agent's launch-at-login autostart and clear the legacy GUI
     // LaunchAgent, before `config` moves into the orchestrator.
     launch_agent::reconcile(config.app_settings.launch_at_login);
@@ -158,20 +187,14 @@ async fn run(config: Config) {
     // Pairing runs in the agent (it owns device I/O); the GUI drives it over IPC.
     let pairing = Arc::new(pairing::PairingManager::new(shared.clone()));
 
-    // The HID++ control watcher (gesture button, DPI/ModeShift button, thumb
-    // wheel) needs no Accessibility permission — start it up front. It reads the
-    // shared maps and dispatches bound actions itself; the two pairing flags let
-    // it release its capture session while a pairing session owns the receiver.
-    watchers::gesture::spawn(
-        shared.hook_maps.clone(),
-        shared.gesture_bindings.clone(),
-        shared.dpi_cycle.clone(),
-        shared.capture_channel.clone(),
-        shared.thumbwheel_sensitivity.clone(),
-        shared.receiver_access.clone(),
-    );
+    // HID++ watchers need no Accessibility permission — start them up front.
+    spawn_hidpp_watchers(&shared);
 
-    let mut inventory_rx = watchers::inventory::spawn(Duration::from_secs(2));
+    let mut inventory_rx = watchers::inventory::spawn_with_registry(
+        Duration::from_secs(2),
+        shared.channel_registry.clone(),
+    );
+    let mut camera_rx = watchers::camera::spawn(Duration::from_secs(1));
     let mut app_rx = watchers::foreground_app::spawn(Duration::from_secs(1));
     let mut accessibility_rx = watchers::accessibility::spawn(Duration::from_millis(1200));
 
@@ -196,11 +219,22 @@ async fn run(config: Config) {
     // Set once the inventory channel closes (the watcher thread died), so the
     // select stops polling a permanently-ready closed receiver.
     let mut inventory_open = true;
+    let mut camera_open = true;
     loop {
         tokio::select! {
             event = inventory_rx.recv(), if inventory_open => match event {
-                Some(watchers::inventory::InventoryEvent::Snapshot(inventories)) => {
-                    orchestrator.lock().await.refresh_inventory(&inventories);
+                Some(watchers::inventory::InventoryEvent::Snapshot { inventories, standalone }) => {
+                    let mut orchestrator = orchestrator.lock().await;
+                    // The portable watcher catches long sleeps from a polling
+                    // gap. Native macOS notifications also cover short sleeps,
+                    // display wakes, and returning user sessions; consume the
+                    // coalesced signal at the exact point that can replay it.
+                    #[cfg(target_os = "macos")]
+                    if resume_pending.swap(false, Ordering::Relaxed) {
+                        info!("macOS resume notification — replaying volatile settings");
+                        orchestrator.reapply_volatile_on_next_refresh();
+                    }
+                    orchestrator.refresh_inventory(&inventories, &standalone);
                 }
                 Some(watchers::inventory::InventoryEvent::Unavailable) => {
                     orchestrator.lock().await.mark_inventory_unavailable();
@@ -218,6 +252,13 @@ async fn run(config: Config) {
                     inventory_open = false;
                 }
             },
+            event = camera_rx.recv(), if camera_open => if let Some(active) = event {
+                orchestrator.lock().await.set_camera_active(active);
+            } else {
+                #[cfg(target_os = "macos")]
+                warn!("camera watcher channel closed — disabling camera automation updates");
+                camera_open = false;
+            },
             Some(bundle) = app_rx.recv() => {
                 orchestrator.lock().await.set_current_app(bundle);
             }
@@ -231,8 +272,11 @@ async fn run(config: Config) {
                         info!("accessibility granted — installing OS mouse hook");
                         hook = hook_runtime::start(
                             shared.hook_maps.clone(),
+                            shared.keyboard_bindings.clone(),
                             shared.dpi_cycle.clone(),
                             shared.capture_channel.clone(),
+                            shared.channel_registry.clone(),
+                            shared.receiver_access.clone(),
                             Arc::clone(&event_monitor),
                         );
                         hook_installed.store(hook.is_some(), Ordering::Relaxed);
diff --git a/crates/openlogi-agent/src/pairing.rs b/crates/openlogi-agent/src/pairing.rs
index ef365590a4e81637287ef0fcb53e67b1abd923f5..385e6a9ee92d050ee873f71c3971b7cf2b128a4c 100644
--- a/crates/openlogi-agent/src/pairing.rs
+++ b/crates/openlogi-agent/src/pairing.rs
@@ -20,7 +20,7 @@ use std::time::Duration;
 
 use openlogi_agent_core::ipc::{FoundDevice, PairingCommandError, PairingUpdate};
 use openlogi_agent_core::orchestrator::SharedRuntime;
-use openlogi_agent_core::receiver_access::PairingReceiverLease;
+use openlogi_agent_core::receiver_access::{ExclusiveAccessReason, ExclusiveReceiverLease};
 use openlogi_agent_core::watchers::pairing::{self, Control};
 use openlogi_hid::{DiscoveredDevice, PairingEvent, ReceiverSelector};
 use tokio::sync::{Mutex, mpsc};
@@ -36,7 +36,7 @@ const RECEIVER_LEASE_TIMEOUT: Duration = Duration::from_secs(5);
 /// Address-keyed cache of the full discovered devices, so the GUI can pair by
 /// address without round-tripping the non-serializable `DiscoveredDevice`.
 type DeviceCache = Arc<StdMutex<HashMap<[u8; 6], DiscoveredDevice>>>;
-type ReceiverLeaseSlot = Arc<StdMutex<Option<PairingReceiverLease>>>;
+type ReceiverLeaseSlot = Arc<StdMutex<Option<ExclusiveReceiverLease>>>;
 
 /// Owns the pairing watcher and translates its event stream for the IPC layer.
 pub struct PairingManager {
@@ -96,7 +96,9 @@ impl PairingManager {
         }
         let Ok(receiver_lease) = tokio::time::timeout(
             RECEIVER_LEASE_TIMEOUT,
-            self.shared.receiver_access.acquire_for_pairing(),
+            self.shared
+                .receiver_access
+                .acquire_exclusive(ExclusiveAccessReason::Pairing),
         )
         .await
         else {
@@ -159,7 +161,7 @@ impl PairingManager {
 
 fn with_receiver_lease_slot<T>(
     receiver_lease: &ReceiverLeaseSlot,
-    f: impl FnOnce(&mut Option<PairingReceiverLease>) -> T,
+    f: impl FnOnce(&mut Option<ExclusiveReceiverLease>) -> T,
 ) -> T {
     match receiver_lease.lock() {
         Ok(mut slot) => f(&mut slot),
@@ -266,11 +268,18 @@ mod tests {
     fn shared_runtime() -> SharedRuntime {
         SharedRuntime {
             hook_maps: Arc::new(RwLock::new(HookMaps::default())),
+            keyboard_bindings: Arc::new(RwLock::new(std::collections::HashMap::new())),
             gesture_bindings: Arc::new(RwLock::new(BTreeMap::new())),
             dpi_cycle: Arc::new(RwLock::new(DpiCycleState::default())),
             thumbwheel_sensitivity: Arc::new(0.into()),
             capture_channel: Arc::new(RwLock::new(None)),
+            channel_registry: openlogi_hid::ChannelRegistry::default(),
+            channel_pool: openlogi_hid::ChannelPool::default(),
+            keyboard_spec: Arc::new(RwLock::new(None)),
+            keyboard_channel: Arc::new(RwLock::new(None)),
+            capture_rearm_generation: Arc::new(0.into()),
             receiver_access: ReceiverAccess::default(),
+            host_switch_links: Arc::new(RwLock::new(Vec::new())),
         }
     }
 
@@ -296,12 +305,12 @@ mod tests {
 
         assert_eq!(result, Err(PairingCommandError::WatcherUnavailable));
         assert_eq!(manager.sessions.load(Ordering::Acquire), 0);
-        assert!(!manager.shared.receiver_access.pairing_requested());
+        assert!(!manager.shared.receiver_access.exclusive_requested());
         assert!(
             manager
                 .shared
                 .receiver_access
-                .try_acquire_for_capture()
+                .try_acquire_for_session()
                 .is_some()
         );
     }
@@ -321,11 +330,20 @@ mod tests {
     async fn release_receiver_lease_recovers_poisoned_slot() {
         let (ctrl_tx, _ctrl_rx) = mpsc::unbounded_channel();
         let manager = manager_with_ctrl(ctrl_tx);
-        let receiver_lease = manager.shared.receiver_access.acquire_for_pairing().await;
+        let receiver_lease = manager
+            .shared
+            .receiver_access
+            .acquire_exclusive(ExclusiveAccessReason::Pairing)
+            .await;
         with_receiver_lease_slot(&manager.receiver_lease, |slot| {
             *slot = Some(receiver_lease);
         });
-        assert!(manager.shared.receiver_access.pairing_requested());
+        assert!(
+            manager
+                .shared
+                .receiver_access
+                .requested(ExclusiveAccessReason::Pairing)
+        );
 
         let slot = Arc::clone(&manager.receiver_lease);
         let _ = std::panic::catch_unwind(move || {
@@ -337,12 +355,12 @@ mod tests {
 
         manager.release_receiver_lease();
 
-        assert!(!manager.shared.receiver_access.pairing_requested());
+        assert!(!manager.shared.receiver_access.exclusive_requested());
         assert!(
             manager
                 .shared
                 .receiver_access
-                .try_acquire_for_capture()
+                .try_acquire_for_session()
                 .is_some()
         );
     }
diff --git a/crates/openlogi-agent/src/server.rs b/crates/openlogi-agent/src/server.rs
index 4e69d75b6732ff2f7e81150a4099daada732a795..dfe793125df5bd089bf16ca2a946223c407b2501 100644
--- a/crates/openlogi-agent/src/server.rs
+++ b/crates/openlogi-agent/src/server.rs
@@ -19,7 +19,8 @@ use openlogi_agent_core::{hardware, transport};
 use openlogi_core::config::{Config, Lighting};
 use openlogi_core::device::DeviceInventory;
 use openlogi_hid::{
-    DeviceRoute, DpiInfo, ReceiverSelector, SmartShiftMode, SmartShiftStatus, WriteError,
+    DeviceRoute, DpiInfo, LightCommand, ReceiverSelector, SmartShiftMode, SmartShiftStatus,
+    WriteError,
 };
 
 use crate::pairing::PairingManager;
@@ -80,7 +81,14 @@ impl Agent for AgentServer {
     }
 
     async fn set_dpi(self, _: Context, route: DeviceRoute, dpi: u32) -> Result<(), WriteError> {
-        hardware::apply_dpi(&self.shared.capture_channel, &route, dpi).await
+        hardware::apply_dpi(
+            &self.shared.capture_channel,
+            &self.shared.channel_registry,
+            &self.shared.receiver_access,
+            &route,
+            dpi,
+        )
+        .await
     }
 
     async fn set_lighting(
@@ -89,7 +97,14 @@ impl Agent for AgentServer {
         route: DeviceRoute,
         lighting: Lighting,
     ) -> Result<(), WriteError> {
-        hardware::apply_lighting(&route, &lighting).await
+        hardware::apply_lighting(
+            &self.shared.capture_channel,
+            &self.shared.channel_registry,
+            &self.shared.receiver_access,
+            &route,
+            &lighting,
+        )
+        .await
     }
 
     async fn set_smartshift(
@@ -102,6 +117,8 @@ impl Agent for AgentServer {
     ) -> Result<(), WriteError> {
         hardware::apply_smartshift(
             &self.shared.capture_channel,
+            &self.shared.channel_registry,
+            &self.shared.receiver_access,
             &route,
             mode,
             auto_disengage,
@@ -111,7 +128,13 @@ impl Agent for AgentServer {
     }
 
     async fn read_dpi(self, _: Context, route: DeviceRoute) -> Result<DpiInfo, WriteError> {
-        hardware::read_dpi(&route).await
+        hardware::read_dpi(
+            &self.shared.capture_channel,
+            &self.shared.channel_registry,
+            &self.shared.receiver_access,
+            &route,
+        )
+        .await
     }
 
     async fn read_smartshift(
@@ -119,7 +142,13 @@ impl Agent for AgentServer {
         _: Context,
         route: DeviceRoute,
     ) -> Result<SmartShiftStatus, WriteError> {
-        hardware::read_smartshift(&route).await
+        hardware::read_smartshift(
+            &self.shared.capture_channel,
+            &self.shared.channel_registry,
+            &self.shared.receiver_access,
+            &route,
+        )
+        .await
     }
 
     async fn request_accessibility_prompt(self, _: Context) {
@@ -147,12 +176,14 @@ impl Agent for AgentServer {
     }
 
     async fn snapshot(self, _: Context) -> AgentSnapshot {
-        let (launch_at_login, inventory_health, inventory) = {
+        let (launch_at_login, inventory_health, inventory, standalone, camera_active) = {
             let orch = self.orchestrator.lock().await;
             (
                 orch.launch_at_login(),
                 orch.inventory_health(),
                 orch.inventory(),
+                orch.standalone(),
+                orch.camera_active(),
             )
         };
         AgentSnapshot {
@@ -165,12 +196,43 @@ impl Agent for AgentServer {
                 agent_version: env!("CARGO_PKG_VERSION").to_string(),
             },
             inventory,
+            standalone,
+            camera_active,
         }
     }
 
     async fn poll_event_monitor(self, _: Context) -> Vec<MonitorEvent> {
         self.event_monitor.poll()
     }
+
+    async fn set_light(
+        self,
+        _: Context,
+        route: DeviceRoute,
+        command: LightCommand,
+    ) -> Result<(), WriteError> {
+        hardware::cancel_light_reapply(&route);
+        hardware::apply_light(&route, command).await
+    }
+
+    async fn set_light_manual_power(
+        self,
+        _: Context,
+        route: DeviceRoute,
+        enabled: bool,
+    ) -> Result<(), WriteError> {
+        hardware::cancel_light_reapply(&route);
+        hardware::apply_light(&route, LightCommand::Power(enabled)).await?;
+        if !self
+            .orchestrator
+            .lock()
+            .await
+            .set_manual_light_power(&route, enabled)
+        {
+            warn!(?route, "manual light power applied without camera override");
+        }
+        Ok(())
+    }
 }
 
 /// Bind the agent's IPC socket and serve [`Agent`] requests until the process
diff --git a/crates/openlogi-agent/src/tray.rs b/crates/openlogi-agent/src/tray.rs
index 61395cdb6aca95610bb133af84b21a6882c20731..c24ecb643532b321f60df4e1708225498399d1c8 100644
--- a/crates/openlogi-agent/src/tray.rs
+++ b/crates/openlogi-agent/src/tray.rs
@@ -1,4 +1,4 @@
-//! The agent's menu-bar status item.
+//! The agent's macOS AppKit loop, menu-bar item, and resume notifications.
 //!
 //! The always-on agent hosts the menu bar (the GUI is on-demand). The item
 //! carries GUI-directed actions ("Show Main Window", Settings, About, Check for
@@ -15,19 +15,56 @@
 
 #![expect(
     unsafe_code,
-    reason = "objc2 calls: super-init, init-with-action/set-target — localized here and in status_item"
+    reason = "objc2 calls: super-init, action targets, and selector-based workspace notifications"
 )]
 
+use std::sync::Arc;
+use std::sync::atomic::{AtomicBool, Ordering};
+
 use objc2::rc::Retained;
 use objc2::runtime::{AnyObject, NSObject};
-use objc2::{MainThreadMarker, MainThreadOnly, define_class, msg_send, sel};
-use objc2_app_kit::{NSApplication, NSApplicationActivationPolicy, NSImage, NSRunningApplication};
-use objc2_foundation::NSString;
+use objc2::{
+    AnyThread, DefinedClass, MainThreadMarker, MainThreadOnly, define_class, msg_send, sel,
+};
+use objc2_app_kit::{
+    NSApplication, NSApplicationActivationPolicy, NSImage, NSRunningApplication, NSWorkspace,
+    NSWorkspaceDidWakeNotification, NSWorkspaceScreensDidWakeNotification,
+    NSWorkspaceSessionDidBecomeActiveNotification,
+};
+use objc2_foundation::{NSNotification, NSNotificationName, NSString};
 use openlogi_core::brand::DeeplinkCommand;
 use tracing::{info, warn};
 
 use crate::status_item;
 
+struct ResumeTargetIvars {
+    pending: Arc<AtomicBool>,
+}
+
+define_class!(
+    // SAFETY: NSObject has no subclassing requirements, and `ResumeTarget`
+    // does not implement `Drop`.
+    #[unsafe(super(NSObject))]
+    #[ivars = ResumeTargetIvars]
+    #[name = "OpenLogiAgentWorkspaceResumeTarget"]
+    struct ResumeTarget;
+
+    impl ResumeTarget {
+        #[unsafe(method(workspaceDidResume:))]
+        fn workspace_did_resume(&self, _notification: &NSNotification) {
+            self.ivars().pending.store(true, Ordering::Relaxed);
+        }
+    }
+);
+
+impl ResumeTarget {
+    fn new(pending: Arc<AtomicBool>) -> Retained<Self> {
+        let this = Self::alloc().set_ivars(ResumeTargetIvars { pending });
+        // SAFETY: `init` initializes our freshly allocated NSObject subclass.
+        unsafe { msg_send![super(this), init] }
+    }
+}
+
 define_class!(
     // SAFETY: NSObject has no subclassing requirements, and `MenuTarget` does
     // not implement `Drop`.
@@ -121,7 +158,8 @@ fn gui_is_running() -> bool {
 /// tokio core still does all the work). The toggle takes effect on the agent's
 /// next launch — a no-restart live toggle would need a main-thread hop from the
 /// IPC reload path (deferred; it can't be verified headlessly).
-pub fn run_app_loop(show_in_menu_bar: bool) -> ! {
+/// `resume_pending` forwards coalesced workspace resume notifications to that core.
+pub fn run_app_loop(show_in_menu_bar: bool, resume_pending: Arc<AtomicBool>) -> ! {
     let Some(mtm) = MainThreadMarker::new() else {
         warn!("agent AppKit loop not started off the main thread — exiting");
         std::process::exit(1);
@@ -132,12 +170,45 @@ pub fn run_app_loop(show_in_menu_bar: bool) -> ! {
     // Bind the status item (+ its target/menu) so they outlive `run()` — the
     // menu items only weakly reference the target. `None` when hidden.
     let _tray = show_in_menu_bar.then(|| install_status_item(mtm));
+    let _resume_target = install_resume_observer(resume_pending);
     info!(show_in_menu_bar, "agent AppKit loop started");
 
     app.run();
     std::process::exit(0);
 }
 
+/// Observe native resume transitions that the inventory polling-gap heuristic
+/// cannot see. The returned target must live for the AppKit loop's lifetime.
+fn install_resume_observer(pending: Arc<AtomicBool>) -> Retained<ResumeTarget> {
+    let target = ResumeTarget::new(pending);
+    let workspace = NSWorkspace::sharedWorkspace();
+    let center = workspace.notificationCenter();
+    for name in resume_notification_names() {
+        // SAFETY: `ResumeTarget` implements `workspaceDidResume:` with the
+        // exact one-NSNotification argument signature, and the caller retains
+        // the target for the AppKit loop's lifetime.
+        unsafe {
+            center.addObserver_selector_name_object(
+                &target,
+                sel!(workspaceDidResume:),
+                Some(name),
+                Some(&workspace),
+            );
+        }
+    }
+    target
+}
+
+fn resume_notification_names() -> [&'static NSNotificationName; 3] {
+    // SAFETY: AppKit exports each name as an immutable process-lifetime constant.
+    let system_wake = unsafe { NSWorkspaceDidWakeNotification };
+    // SAFETY: AppKit exports each name as an immutable process-lifetime constant.
+    let screen_wake = unsafe { NSWorkspaceScreensDidWakeNotification };
+    // SAFETY: AppKit exports each name as an immutable process-lifetime constant.
+    let session_active = unsafe { NSWorkspaceSessionDidBecomeActiveNotification };
+    [system_wake, screen_wake, session_active]
+}
+
 /// Build and install the menu-bar status item, returning the objects that must
 /// stay alive for the app's lifetime (the status item, the action target the
 /// menu items weakly reference, and the menu itself).
@@ -193,3 +264,32 @@ fn install_status_item(
     info!("menu-bar item installed");
     (status_item, target, menu)
 }
+
+#[cfg(test)]
+mod tests {
+    use super::*;
+
+    #[test]
+    fn resume_notifications_are_forwarded_and_coalesced() {
+        let pending = Arc::new(AtomicBool::new(false));
+        let target = install_resume_observer(Arc::clone(&pending));
+        let workspace = NSWorkspace::sharedWorkspace();
+        let center = workspace.notificationCenter();
+
+        for name in resume_notification_names() {
+            // SAFETY: `workspace` is live, matches the registration filter,
+            // and notification delivery completes synchronously.
+            unsafe { center.postNotificationName_object(name, Some(&workspace)) };
+            assert!(pending.swap(false, Ordering::Relaxed));
+        }
+        for name in resume_notification_names() {
+            // SAFETY: Same live object and synchronous delivery as above.
+            unsafe { center.postNotificationName_object(name, Some(&workspace)) };
+        }
+        assert!(pending.swap(false, Ordering::Relaxed));
+        assert!(!pending.swap(false, Ordering::Relaxed));
+
+        // SAFETY: This is the same live target registered with `center` above.
+        unsafe { center.removeObserver(&target) };
+    }
+}
diff --git a/crates/openlogi-assets/src/index.rs b/crates/openlogi-assets/src/index.rs
index 06d610bce4e2973201289af521eb54e48f7e0f8e..662a42e303e465e2ce1f299586c4d168e4c03f3a 100644
--- a/crates/openlogi-assets/src/index.rs
+++ b/crates/openlogi-assets/src/index.rs
@@ -71,11 +71,18 @@ pub struct FileEntry {
 
 /// Filename schemas Logi ships, most-preferred first. Newer depots use the
 /// `*_core` names; older ones — most keyboards, the MX Vertical, older mice —
-/// ship the bare names. A depot commits to one schema, never a mix, so
-/// resolving each slot to the first name the registry actually lists picks
-/// the right one. The manifest then maps `device_image` /
-/// `device_buttons_image` to the concrete render for colour variants.
-pub const METADATA_FILES: [&str; 2] = ["core_metadata.json", "metadata.json"];
+/// ship the bare names. Render schemas never mix within a depot, so resolving
+/// each slot to the first name the registry actually lists picks the right
+/// one. The manifest then maps `device_image` / `device_buttons_image` to the
+/// concrete render for colour variants.
+///
+/// Metadata is the one slot where legacy keyboard depots *do* ship two files:
+/// the G513 family's `metadata.json` is authored against the G512 banner
+/// renders, while `metadata_full.json` matches the `front.png` the primary
+/// model actually fetches (the manifest's `image_metadata` for `g513` names
+/// it). Preferring `metadata_full.json` keeps the key markers on the render
+/// we display.
+pub const METADATA_FILES: [&str; 3] = ["core_metadata.json", "metadata_full.json", "metadata.json"];
 pub const FRONT_RENDER_FILES: [&str; 2] = ["front_core.png", "front.png"];
 pub const BUTTONS_RENDER_FILES: [&str; 2] = ["side_core.png", "side.png"];
 
@@ -242,6 +249,33 @@ mod tests {
         );
     }
 
+    #[test]
+    fn illumination_light_entries_use_the_same_bundle_baseline() {
+        let mut e = entry("8c900", "Litra Glow");
+        e.kind = "ILLUMINATION_LIGHT".into();
+        e.files = vec![
+            FileEntry {
+                name: "front.png".into(),
+                sha256: "front".into(),
+                bytes: 1,
+            },
+            FileEntry {
+                name: "manifest.json".into(),
+                sha256: "manifest".into(),
+                bytes: 1,
+            },
+            FileEntry {
+                name: "metadata.json".into(),
+                sha256: "metadata".into(),
+                bytes: 1,
+            },
+        ];
+        assert_eq!(
+            e.baseline_files(),
+            vec!["metadata.json", "manifest.json", "front.png"]
+        );
+    }
+
     #[test]
     fn find_by_model_id_suffix_matches_secondary_id() {
         // The BTLE MX Master 3S reports bolt pid `b034`; listing it next to
diff --git a/crates/openlogi-assets/src/metadata.rs b/crates/openlogi-assets/src/metadata.rs
index 9379b6bf6c625d087685f8bd5a118d463e1451c9..7f0494c877837c23912e17cbf1fe01ac0d3df9b5 100644
--- a/crates/openlogi-assets/src/metadata.rs
+++ b/crates/openlogi-assets/src/metadata.rs
@@ -75,12 +75,16 @@ pub struct Assignment {
     /// `map_slot_name`-style consumers treat unknown names as "no hotspot".
     #[serde(rename = "slotName", default)]
     pub slot_name: String,
+    /// Camera depots ship marker-less settings-slot assignments (under the
+    /// `device_camera_image` entry, which no hotspot consumer reads); a
+    /// missing marker defaults to the origin rather than failing the file.
+    #[serde(default)]
     pub marker: Point,
     #[serde(default)]
     pub label: Direction,
 }
 
-#[derive(Debug, Deserialize, Clone, Copy)]
+#[derive(Debug, Deserialize, Clone, Copy, Default)]
 pub struct Point {
     pub x: f32,
     pub y: f32,
@@ -147,4 +151,30 @@ mod tests {
         assert_eq!((origin.width, origin.height), (3598, 1315));
         assert_eq!(meta.images[0].assignments[0].slot_name, "");
     }
+
+    /// Camera depots (StreamCam) list settings-slot assignments with no
+    /// `marker` under their `device_camera_image` entry. Parsing must not
+    /// fail wholesale, and `assignments()` must not surface them (it reads
+    /// only the `device_buttons_image` entry).
+    #[test]
+    fn camera_metadata_without_markers_parses() {
+        let json = r#"{
+          "images": [
+            { "key": "device_image", "origin": { "width": 1280, "height": 800 } },
+            {
+              "key": "device_camera_image",
+              "origin": { "width": 396, "height": 396 },
+              "assignments": [
+                { "slotId": "streamcam-0893_webcam_camera_settings",
+                  "slotName": "SLOT_NAME_WEBCAM_CAMERA_SETTINGS",
+                  "disableAssignmentClick": true }
+              ]
+            }
+          ]
+        }"#;
+        let meta: Metadata = serde_json::from_str(json).expect("camera schema must parse");
+        let origin = meta.origin().expect("origin survives");
+        assert_eq!((origin.width, origin.height), (1280, 800));
+        assert_eq!(meta.assignments().count(), 0);
+    }
 }
diff --git a/crates/openlogi-camera/Cargo.toml b/crates/openlogi-camera/Cargo.toml
new file mode 100644
index 0000000000000000000000000000000000000000..def6e0633c8cd19b9e380dc95bd6cf8c2665e63a
--- /dev/null
+++ b/crates/openlogi-camera/Cargo.toml
@@ -0,0 +1,58 @@
+[package]
+name = "openlogi-camera"
+version.workspace = true
+edition.workspace = true
+rust-version.workspace = true
+license.workspace = true
+repository.workspace = true
+authors.workspace = true
+description = "Generic Logitech UVC webcam discovery for OpenLogi (AVFoundation on macOS, DirectShow on Windows, V4L2 on Linux)."
+keywords = ["logitech", "uvc", "webcam", "camera", "v4l2"]
+categories = ["hardware-support"]
+
+[dependencies]
+serde = { workspace = true }
+tracing = { workspace = true }
+
+# AVFoundation (AVCaptureDevice enumeration + AVCaptureSession capture) on the
+# same objc2 toolchain as the rest of the workspace's ObjC FFI (GUI menu bar /
+# permissions, the hook's NSWorkspace read): leak-proof `Retained<T>` ownership,
+# `define_class!` for the frame delegate (matching the agent tray target), and
+# `block2` for the `requestAccess…` completion block.
+[target.'cfg(target_os = "macos")'.dependencies]
+objc2 = { workspace = true }
+block2 = "0.6"
+
+# DirectShow enumeration + IAMVideoProcAmp / IAMCameraControl UVC controls.
+[target.'cfg(target_os = "windows")'.dependencies]
+windows = { version = "0.61", features = [
+    "Win32_Foundation",
+    "Win32_Media_DirectShow",
+    "Win32_Media_MediaFoundation",
+    "Win32_System_Com",
+    "Win32_System_Com_StructuredStorage",
+    "Win32_System_Variant",
+    "Win32_System_Ole",
+] }
+
+# V4L2 enumeration, UVC controls and mmap capture. `v4l` wraps every ioctl in a
+# safe API, so the Linux backend needs no `unsafe` of its own. MJPEG frames are
+# decoded by `zune-jpeg`, which already ships in the tree (via `image`) and can
+# emit BGRA directly — gpui's texture order, so the preview needs no swap.
+[target.'cfg(target_os = "linux")'.dependencies]
+v4l = "0.14"
+zune-jpeg = "0.5"
+zune-core = "0.5"
+
+# Mirrors [workspace.lints]. unsafe_code stays denied; the AVFoundation modules
+# opt in locally with #[expect(unsafe_code)]. (The `unexpected_cfgs` allow the
+# old objc 0.2 macros needed is gone — objc2 doesn't emit `cfg(cargo-clippy)`.)
+[lints.rust]
+unsafe_code = "deny"
+
+[lints.clippy]
+pedantic = { level = "warn", priority = -1 }
+unwrap_used = "warn"
+expect_used = "warn"
+missing_errors_doc = "allow"
+doc_markdown = "allow"
diff --git a/crates/openlogi-camera/src/capture.rs b/crates/openlogi-camera/src/capture.rs
new file mode 100644
index 0000000000000000000000000000000000000000..07a1fe2ae14e7c4b8d0e3e99df4939015cd4ca1d
--- /dev/null
+++ b/crates/openlogi-camera/src/capture.rs
@@ -0,0 +1,468 @@
+//! AVFoundation camera capture: a one-shot snapshot and a live frame stream.
+//!
+//! Both open an `AVCaptureSession` on the chosen camera and read BGRA frames
+//! through an `AVCaptureVideoDataOutput` delegate. Frames are kept in gpui's
+//! native **BGRA** order so the preview uploads them with no channel swap; the
+//! snapshot path swaps to RGBA once when it encodes the PNG. Capturing (unlike
+//! enumeration) needs Camera permission *and* an app bundle carrying
+//! `NSCameraUsageDescription`; from an unbundled binary macOS denies access,
+//! which surfaces as [`CaptureError::AccessDenied`].
+//!
+//! FFI is `objc2` (matching the rest of the workspace's ObjC surface). The
+//! `AVFoundation` classes aren't in a typed framework crate, so this uses the
+//! `objc2` runtime (`class!` + `msg_send!`) with **`Retained<T>` for every
+//! retained object** (session / output / delegate), so ownership is leak-proof
+//! by construction rather than hand-balanced `retain`/`release`. The frame
+//! delegate is an `NSObject` subclass declared with [`define_class!`] (the same
+//! macro the agent's tray target uses); it is stateless and driven on a
+//! background dispatch queue, so it inherits `NSObject`'s any-thread kind and
+//! needs no main-thread affinity (no `MainThreadMarker`) — AVFoundation's
+//! session start/stop and its sample-buffer callback are all off-main.
+
+#![expect(
+    unsafe_code,
+    reason = "AVFoundation / CoreMedia / CoreVideo capture FFI"
+)]
+#![allow(
+    clippy::cast_possible_truncation,
+    clippy::cast_sign_loss,
+    clippy::cast_possible_wrap,
+    reason = "pixel dimensions and FourCC constants are bounded and copied verbatim"
+)]
+
+use std::ffi::{CString, c_void};
+use std::sync::atomic::{AtomicU32, AtomicU64, Ordering};
+use std::sync::{Arc, Mutex, OnceLock};
+use std::time::{Duration, Instant};
+
+use block2::RcBlock;
+use objc2::rc::Retained;
+use objc2::runtime::{AnyObject, Bool, NSObject};
+use objc2::{AnyThread, class, define_class, msg_send};
+
+pub use crate::capture_types::{CaptureError, Frame};
+
+/// kCVPixelFormatType_32BGRA ('BGRA').
+const PIXEL_FORMAT_32BGRA: u32 = 0x4247_5241;
+/// kCVPixelBufferLock_ReadOnly.
+const LOCK_READ_ONLY: u64 = 1;
+
+// The most recent frame the delegate decoded, behind an `Arc` so the preview's
+// poll hands out a cheap refcount bump instead of copying the whole buffer. A
+// process previews one camera at a time, so a single global sink is enough and
+// keeps the delegate stateless.
+static LATEST: OnceLock<Mutex<Option<Arc<Frame>>>> = OnceLock::new();
+fn latest() -> &'static Mutex<Option<Arc<Frame>>> {
+    LATEST.get_or_init(|| Mutex::new(None))
+}
+
+/// Increments on every delivered frame, so a poller can tell a new frame from a
+/// repeat without comparing pixel buffers.
+static FRAME_GEN: AtomicU64 = AtomicU64::new(0);
+
+/// Target max width for delegate downsampling (0 = full resolution). Previews
+/// set this so an oversized buffer decimates down in one strided pass instead
+/// of copying (and uploading) pixels the preview can never show.
+static PREVIEW_TARGET_W: AtomicU32 = AtomicU32::new(0);
+
+#[link(name = "AVFoundation", kind = "framework")]
+unsafe extern "C" {
+    static AVMediaTypeVideo: *const AnyObject;
+    static AVCaptureSessionPreset1280x720: *const AnyObject;
+}
+
+#[link(name = "CoreMedia", kind = "framework")]
+unsafe extern "C" {
+    fn CMSampleBufferGetImageBuffer(sbuf: *mut AnyObject) -> *mut AnyObject;
+}
+
+#[link(name = "CoreVideo", kind = "framework")]
+unsafe extern "C" {
+    static kCVPixelBufferPixelFormatTypeKey: *const AnyObject;
+    fn CVPixelBufferLockBaseAddress(pb: *mut AnyObject, flags: u64) -> i32;
+    fn CVPixelBufferUnlockBaseAddress(pb: *mut AnyObject, flags: u64) -> i32;
+    fn CVPixelBufferGetBaseAddress(pb: *mut AnyObject) -> *mut c_void;
+    fn CVPixelBufferGetBytesPerRow(pb: *mut AnyObject) -> usize;
+    fn CVPixelBufferGetWidth(pb: *mut AnyObject) -> usize;
+    fn CVPixelBufferGetHeight(pb: *mut AnyObject) -> usize;
+}
+
+#[link(name = "CoreFoundation", kind = "framework")]
+unsafe extern "C" {
+    static kCFRunLoopDefaultMode: *const c_void;
+    // The last parameter is a CoreFoundation `Boolean` (unsigned char); `0` is
+    // false. Kept as `u8` rather than an objc `BOOL` to match the C type exactly.
+    fn CFRunLoopRunInMode(
+        mode: *const c_void,
+        seconds: f64,
+        return_after_source_handled: u8,
+    ) -> i32;
+}
+
+unsafe extern "C" {
+    fn dispatch_queue_create(label: *const i8, attr: *const c_void) -> *mut AnyObject;
+}
+
+define_class!(
+    // SAFETY: NSObject has no subclassing requirements, and `FrameDelegate` does
+    // not implement `Drop`. It carries no ivars and its one method only touches
+    // process-global state, so it is safe to use from the background dispatch
+    // queue AVFoundation drives it on (default any-thread kind, no `thread_kind`).
+    #[unsafe(super(NSObject))]
+    #[name = "OLCameraFrameDelegate"]
+    struct FrameDelegate;
+
+    impl FrameDelegate {
+        /// `captureOutput:didOutputSampleBuffer:fromConnection:` — copies the
+        /// sample buffer's BGRA pixels (optionally decimated) into [`latest`].
+        #[unsafe(method(captureOutput:didOutputSampleBuffer:fromConnection:))]
+        fn did_output(
+            &self,
+            _output: *mut AnyObject,
+            sbuf: *mut AnyObject,
+            _conn: *mut AnyObject,
+        ) {
+            // SAFETY: `sbuf` is a valid CMSampleBuffer delivered by AVFoundation;
+            // the image buffer is locked for the read and unlocked before return.
+            unsafe {
+                let pb = CMSampleBufferGetImageBuffer(sbuf);
+                if pb.is_null() || CVPixelBufferLockBaseAddress(pb, LOCK_READ_ONLY) != 0 {
+                    return;
+                }
+                let base = CVPixelBufferGetBaseAddress(pb).cast::<u8>();
+                let bytes_per_row = CVPixelBufferGetBytesPerRow(pb);
+                let width = CVPixelBufferGetWidth(pb);
+                let height = CVPixelBufferGetHeight(pb);
+                let target = PREVIEW_TARGET_W.load(Ordering::Relaxed) as usize;
+                let step = if target > 0 && width > target {
+                    width.div_ceil(target)
+                } else {
+                    1
+                };
+                let out_w = width / step;
+                let out_h = height / step;
+                if !base.is_null() && out_w > 0 && out_h > 0 {
+                    let mut bgra = vec![0u8; out_w * out_h * 4];
+                    let dst = bgra.as_mut_ptr();
+                    if step == 1 {
+                        // Source is already BGRA (kCVPixelFormatType_32BGRA) — one
+                        // memcpy per row, skipping any driver row padding.
+                        for oy in 0..out_h {
+                            let row = base.add(oy * bytes_per_row);
+                            std::ptr::copy_nonoverlapping(row, dst.add(oy * out_w * 4), out_w * 4);
+                        }
+                    } else {
+                        for oy in 0..out_h {
+                            let row = base.add(oy * step * bytes_per_row);
+                            for ox in 0..out_w {
+                                let src = row.add(ox * step * 4);
+                                let out = (oy * out_w + ox) * 4;
+                                std::ptr::copy_nonoverlapping(src, dst.add(out), 4);
+                            }
+                        }
+                    }
+                    if let Ok(mut slot) = latest().lock() {
+                        *slot = Some(Arc::new(Frame {
+                            width: out_w as u32,
+                            height: out_h as u32,
+                            bgra,
+                        }));
+                        FRAME_GEN.fetch_add(1, Ordering::Relaxed);
+                    }
+                }
+                CVPixelBufferUnlockBaseAddress(pb, LOCK_READ_ONLY);
+            }
+        }
+    }
+);
+
+impl FrameDelegate {
+    fn new() -> Retained<Self> {
+        let this = Self::alloc().set_ivars(());
+        // SAFETY: `init` initializes our freshly-allocated NSObject subclass and
+        // returns it (the two-phase construction objc2's `define_class!` uses).
+        unsafe { msg_send![super(this), init] }
+    }
+}
+
+/// Current Camera authorization: `Some(true)` usable, `Some(false)` denied,
+/// `None` undetermined (caller should request access).
+fn authorization() -> Option<bool> {
+    let cls = class!(AVCaptureDevice);
+    // SAFETY: documented class method returning an AVAuthorizationStatus NSInteger;
+    // `AVMediaTypeVideo` is AVFoundation's exported `NSString` constant.
+    let status: isize =
+        unsafe { msg_send![cls, authorizationStatusForMediaType: AVMediaTypeVideo] };
+    match status {
+        3 => Some(true),
+        1 | 2 => Some(false),
+        _ => None,
+    }
+}
+
+/// Request Camera access and block until the user answers (or `timeout`).
+fn request_access(timeout: Duration) -> bool {
+    let answered = std::sync::Arc::new(Mutex::new(None::<bool>));
+    let sink = answered.clone();
+    // `void(^)(BOOL)` completion block. `RcBlock` is heap-allocated and
+    // reference-counted, so it outlives the async call below on its own.
+    let handler = RcBlock::new(move |granted: Bool| {
+        if let Ok(mut slot) = sink.lock() {
+            *slot = Some(granted.as_bool());
+        }
+    });
+    let cls = class!(AVCaptureDevice);
+    // SAFETY: documented async class method taking an AVMediaType + a
+    // `void(^)(BOOL)` completion block; the block outlives the call.
+    unsafe {
+        let _: () = msg_send![
+            cls,
+            requestAccessForMediaType: AVMediaTypeVideo,
+            completionHandler: &*handler
+        ];
+    }
+    let deadline = Instant::now() + timeout;
+    loop {
+        if let Ok(slot) = answered.lock()
+            && let Some(granted) = *slot
+        {
+            return granted;
+        }
+        if Instant::now() >= deadline {
+            return false;
+        }
+        run_loop_tick(0.05);
+    }
+}
+
+/// Ensure the process may use the camera, requesting access if undetermined.
+fn ensure_access() -> Result<(), CaptureError> {
+    match authorization() {
+        Some(true) => Ok(()),
+        None if request_access(Duration::from_secs(30)) => Ok(()),
+        _ => Err(CaptureError::AccessDenied),
+    }
+}
+
+/// Whether the process currently holds Camera permission, without prompting.
+/// Lets the GUI start a preview only when access is already granted (so it never
+/// blocks the UI thread on the permission dialog).
+#[must_use]
+pub fn camera_access_granted() -> bool {
+    matches!(authorization(), Some(true))
+}
+
+/// Current Camera permission as a tri-state, without prompting. Lets the
+/// Settings window distinguish Denied from not-yet-asked.
+#[must_use]
+pub fn camera_authorization() -> crate::CameraAuthorization {
+    match authorization() {
+        Some(true) => crate::CameraAuthorization::Granted,
+        Some(false) => crate::CameraAuthorization::Denied,
+        None => crate::CameraAuthorization::Undetermined,
+    }
+}
+
+/// Pump the current thread's run loop briefly so AVFoundation callbacks fire.
+fn run_loop_tick(seconds: f64) {
+    // SAFETY: `kCFRunLoopDefaultMode` is a valid mode constant; the call returns
+    // after `seconds` or the first handled source (`0` = don't return early).
+    unsafe {
+        CFRunLoopRunInMode(kCFRunLoopDefaultMode, seconds, 0);
+    }
+}
+
+fn device_with_unique_id(unique_id: &str) -> Option<Retained<AnyObject>> {
+    let cls = class!(AVCaptureDevice);
+    let Ok(ns) = CString::new(unique_id) else {
+        return None;
+    };
+    // SAFETY: building an autoreleased NSString from a valid C string, then a
+    // `deviceWithUniqueID:` lookup; the autoreleased (+0) result is retained into
+    // an owned `Retained` (`None` when the lookup returns nil).
+    unsafe {
+        let nsstr: *mut AnyObject = msg_send![class!(NSString), stringWithUTF8String: ns.as_ptr()];
+        let device: *mut AnyObject = msg_send![cls, deviceWithUniqueID: nsstr];
+        Retained::retain(device)
+    }
+}
+
+/// A running capture session. Frames flow to the delegate on a background
+/// dispatch queue and land in [`latest`]; dropping the session stops it. The
+/// `Retained` fields keep the output + delegate alive for the session's life
+/// (the session references them, but we hold owning handles for clarity).
+struct Session {
+    handle: Retained<AnyObject>,
+    _output: Retained<AnyObject>,
+    _delegate: Retained<FrameDelegate>,
+}
+
+impl Drop for Session {
+    fn drop(&mut self) {
+        // SAFETY: `self.handle` is a valid, retained AVCaptureSession.
+        unsafe {
+            let _: () = msg_send![&*self.handle, stopRunning];
+        }
+    }
+}
+
+/// Authorize, wire up, and start a capture session on `unique_id`. Frames begin
+/// arriving in [`latest`] shortly after this returns.
+fn open_session(unique_id: &str, low_res: bool) -> Result<Session, CaptureError> {
+    ensure_access()?;
+    let device = device_with_unique_id(unique_id).ok_or(CaptureError::NotFound)?;
+    if let Ok(mut slot) = latest().lock() {
+        *slot = None;
+    }
+    // Previews cap at 720p-wide frames (the preview preset below already
+    // delivers exactly that; the decimator only kicks in if a camera ignores
+    // the preset and streams wider). Snapshots keep full resolution.
+    PREVIEW_TARGET_W.store(if low_res { 1280 } else { 0 }, Ordering::Relaxed);
+
+    // SAFETY: standard AVCaptureSession wiring with documented selectors; every
+    // object added is retained by the session, and the session is stopped on Drop.
+    unsafe {
+        let session: *mut AnyObject = msg_send![class!(AVCaptureSession), new];
+        let Some(session) = Retained::from_raw(session) else {
+            return Err(CaptureError::Setup("AVCaptureSession".into()));
+        };
+
+        let mut err: *mut AnyObject = std::ptr::null_mut();
+        let input: *mut AnyObject = msg_send![
+            class!(AVCaptureDeviceInput),
+            deviceInputWithDevice: &*device,
+            error: &mut err
+        ];
+        if input.is_null() {
+            return Err(CaptureError::Setup("AVCaptureDeviceInput".into()));
+        }
+        let can_in: bool = msg_send![&*session, canAddInput: input];
+        if !can_in {
+            return Err(CaptureError::Setup("session rejected input".into()));
+        }
+        let _: () = msg_send![&*session, addInput: input];
+
+        // Preview streams capture at 720p — sharp on a Retina-scale preview
+        // (the 480pt box is 960 physical pixels wide) while still a fraction
+        // of the native 1080p per-frame copy + texture upload.
+        if low_res {
+            let can: bool =
+                msg_send![&*session, canSetSessionPreset: AVCaptureSessionPreset1280x720];
+            if can {
+                let _: () = msg_send![&*session, setSessionPreset: AVCaptureSessionPreset1280x720];
+            }
+        }
+
+        let output: *mut AnyObject = msg_send![class!(AVCaptureVideoDataOutput), new];
+        let Some(output) = Retained::from_raw(output) else {
+            return Err(CaptureError::Setup("AVCaptureVideoDataOutput".into()));
+        };
+        let num: *mut AnyObject =
+            msg_send![class!(NSNumber), numberWithUnsignedInt: PIXEL_FORMAT_32BGRA];
+        let settings: *mut AnyObject = msg_send![
+            class!(NSDictionary),
+            dictionaryWithObject: num,
+            forKey: kCVPixelBufferPixelFormatTypeKey
+        ];
+        let _: () = msg_send![&*output, setVideoSettings: settings];
+        let _: () = msg_send![&*output, setAlwaysDiscardsLateVideoFrames: true];
+
+        let delegate = FrameDelegate::new();
+        let queue = dispatch_queue_create(c"org.openlogi.camera".as_ptr(), std::ptr::null());
+        let _: () = msg_send![&*output, setSampleBufferDelegate: &*delegate, queue: queue];
+
+        let can_out: bool = msg_send![&*session, canAddOutput: &*output];
+        if !can_out {
+            return Err(CaptureError::Setup("session rejected output".into()));
+        }
+        let _: () = msg_send![&*session, addOutput: &*output];
+
+        // Selfie-mirror the live preview (not snapshots): a webcam self-view is
+        // expected to read like a mirror. The driver flips on the connection, so
+        // it costs zero per-frame CPU and never alters the outbound camera feed.
+        if low_res {
+            let conn: *mut AnyObject =
+                msg_send![&*output, connectionWithMediaType: AVMediaTypeVideo];
+            if !conn.is_null() {
+                let supported: bool = msg_send![conn, isVideoMirroringSupported];
+                if supported {
+                    let _: () = msg_send![conn, setAutomaticallyAdjustsVideoMirroring: false];
+                    let _: () = msg_send![conn, setVideoMirrored: true];
+                }
+            }
+        }
+
+        let _: () = msg_send![&*session, startRunning];
+
+        Ok(Session {
+            handle: session,
+            _output: output,
+            _delegate: delegate,
+        })
+    }
+}
+
+/// Capture a single full-resolution [`Frame`] (BGRA) from the camera with
+/// `unique_id`.
+///
+/// # Errors
+/// [`CaptureError::AccessDenied`] when Camera permission isn't (and can't be)
+/// granted, [`CaptureError::NotFound`] for an unknown id, [`CaptureError::Timeout`]
+/// when no frame arrives, or [`CaptureError::Setup`] on AVFoundation errors.
+pub fn capture_frame(unique_id: &str, timeout: Duration) -> Result<Frame, CaptureError> {
+    let _session = open_session(unique_id, false)?;
+    let deadline = Instant::now() + timeout;
+    loop {
+        if let Ok(mut slot) = latest().lock()
+            && let Some(frame) = slot.take()
+        {
+            return Ok(Arc::unwrap_or_clone(frame));
+        }
+        if Instant::now() >= deadline {
+            return Err(CaptureError::Timeout);
+        }
+        run_loop_tick(0.03);
+    }
+}
+
+/// A live preview stream. Holds the session open; [`CameraStream::latest_frame`]
+/// returns the most recent frame each time it's polled. Dropping it stops the
+/// camera.
+pub struct CameraStream {
+    _session: Session,
+}
+
+impl CameraStream {
+    /// The most recently delivered frame, or `None` before the first arrives.
+    /// Returns a shared [`Arc`] so polling at preview rate never copies the
+    /// pixel buffer.
+    #[must_use]
+    pub fn latest_frame(&self) -> Option<Arc<Frame>> {
+        latest().lock().ok().and_then(|slot| slot.clone())
+    }
+
+    /// Take the most recent frame out of the slot (the next delivered frame
+    /// refills it). A sole consumer that unwraps the [`Arc`] gets the pixel
+    /// buffer without copying it.
+    #[must_use]
+    pub fn take_frame(&self) -> Option<Arc<Frame>> {
+        latest().lock().ok().and_then(|mut slot| slot.take())
+    }
+
+    /// A counter that increments on every delivered frame, so the preview can
+    /// skip rebuilding its texture when no new frame has arrived.
+    #[must_use]
+    pub fn frame_generation(&self) -> u64 {
+        FRAME_GEN.load(Ordering::Relaxed)
+    }
+}
+
+/// Start a live capture stream on the camera with `unique_id`.
+///
+/// # Errors
+/// Same as [`capture_frame`], minus `Timeout` (frames are polled, not awaited).
+pub fn start_stream(unique_id: &str) -> Result<CameraStream, CaptureError> {
+    Ok(CameraStream {
+        _session: open_session(unique_id, true)?,
+    })
+}
diff --git a/crates/openlogi-camera/src/capture_linux.rs b/crates/openlogi-camera/src/capture_linux.rs
new file mode 100644
index 0000000000000000000000000000000000000000..fa854c9eaffc3c27287dd8b043441f8f018b7bff
--- /dev/null
+++ b/crates/openlogi-camera/src/capture_linux.rs
@@ -0,0 +1,534 @@
+//! V4L2 camera capture on Linux: a one-shot snapshot and a live frame stream.
+//!
+//! Buffers are mmap'd from the kernel and decoded to **BGRA**, gpui's native
+//! texture order, so the preview uploads them without a channel swap.
+//!
+//! Format choice prefers **MJPEG**: at 720p a YUYV stream is ~27 MB/s over USB
+//! and starves other bandwidth on the same controller, while MJPEG is a tenth
+//! of that, and `zune-jpeg` decodes it straight to BGRA in one pass. YUYV is
+//! the fallback for the few cameras that don't offer MJPEG.
+//!
+//! Resolution follows the session's [`Quality`]: the live preview streams 720p,
+//! while a snapshot takes the camera's largest mode. Note this only sizes
+//! *OpenLogi's own* stream — resolution is negotiated per handle, so it is not
+//! a device setting other applications observe, unlike the UVC controls in
+//! `uvc_linux`.
+//!
+//! Unlike macOS, Linux has no per-app camera consent model — access is decided
+//! by filesystem permission on `/dev/video*` (the `video` group). So
+//! [`camera_authorization`] reports `Granted`/`Denied` by probing whether the
+//! node actually opens, and never `Undetermined`: there is nothing to prompt.
+
+#![allow(
+    clippy::cast_possible_truncation,
+    clippy::cast_sign_loss,
+    clippy::cast_possible_wrap,
+    reason = "pixel arithmetic is bounded by the negotiated frame size"
+)]
+
+use std::sync::atomic::{AtomicBool, AtomicU64, Ordering};
+use std::sync::{Arc, Mutex};
+use std::time::{Duration, Instant};
+
+use v4l::buffer::Type;
+use v4l::io::mmap::Stream as MmapStream;
+use v4l::io::traits::{CaptureStream, Stream as StreamTrait};
+use v4l::video::Capture;
+use v4l::{Device, Format, FourCC};
+use zune_core::bytestream::ZCursor;
+use zune_core::colorspace::ColorSpace;
+use zune_core::options::DecoderOptions;
+use zune_jpeg::JpegDecoder;
+
+pub use crate::capture_types::{CaptureError, Frame};
+use crate::{CameraAuthorization, linux};
+
+/// Preview target. The driver picks the nearest size it supports, so this is a
+/// request rather than a guarantee — the negotiated format is read back.
+const PREVIEW_WIDTH: u32 = 1280;
+const PREVIEW_HEIGHT: u32 = 720;
+
+/// Size requested for a native-resolution session when the driver reports only
+/// stepwise or continuous frame sizes, with no discrete list to pick a maximum
+/// from. `VIDIOC_S_FMT` clamps a request to what the device supports, so asking
+/// for more than any current sensor offers resolves to its largest mode.
+const OVERSIZED_REQUEST: u32 = 16384;
+
+/// Mapped buffers to keep in flight. Four is the usual V4L2 default: enough to
+/// absorb a scheduling hiccup without adding a frame of latency.
+const BUFFER_COUNT: u32 = 4;
+
+/// How long a live stream waits for one frame before giving up on the camera.
+///
+/// Sized for **stream start-up**, not the steady state: a UVC camera negotiates
+/// bandwidth and spins up its sensor on the first `STREAMON`, which measured
+/// ~730 ms on an MX Brio, against ~32 ms per frame once running. A timeout is
+/// unrecoverable (see [`run_stream`]), so this must clear the slowest start-up
+/// comfortably rather than sit close to it.
+const STREAM_TIMEOUT: Duration = Duration::from_secs(3);
+
+/// The pixel layouts this backend decodes.
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+enum Encoding {
+    /// Motion-JPEG: one baseline JPEG per frame.
+    Mjpeg,
+    /// Packed YUV 4:2:2, two pixels per four bytes (`Y0 Cb Y1 Cr`).
+    Yuyv,
+}
+
+impl Encoding {
+    /// FourCCs in preference order — MJPEG first, for the bandwidth reason in
+    /// the module docs.
+    const PREFERRED: [(Self, &'static [u8; 4]); 2] =
+        [(Self::Mjpeg, b"MJPG"), (Self::Yuyv, b"YUYV")];
+}
+
+/// What a capture session optimises for.
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+enum Quality {
+    /// 720p. Sharp in the preview box at a fraction of a 4K frame's decode,
+    /// copy and texture upload — and a live stream pays that cost 30 times a
+    /// second.
+    Preview,
+    /// The camera's largest mode. A snapshot is taken once and kept, so it is
+    /// worth the sensor's full detail; this mirrors the macOS backend, where
+    /// only the preview session carries a 720p preset.
+    Native,
+}
+
+/// A negotiated capture session: the open device plus what its frames contain.
+struct Session {
+    device: Device,
+    encoding: Encoding,
+    width: u32,
+    height: u32,
+}
+
+/// Open `unique_id` and negotiate a decodable format on it.
+fn open_session(unique_id: &str, quality: Quality) -> Result<Session, CaptureError> {
+    let path = linux::node_for_unique_id(unique_id).ok_or(CaptureError::NotFound)?;
+    let device = Device::with_path(&path).map_err(|error| {
+        if error.kind() == std::io::ErrorKind::PermissionDenied {
+            CaptureError::AccessDenied
+        } else {
+            CaptureError::Setup(format!("{}: {error}", path.display()))
+        }
+    })?;
+
+    let available = device
+        .enum_formats()
+        .map_err(|error| CaptureError::Setup(error.to_string()))?;
+
+    let (encoding, fourcc) = Encoding::PREFERRED
+        .into_iter()
+        .find(|(_, fourcc)| {
+            available
+                .iter()
+                .any(|format| format.fourcc == FourCC::new(fourcc))
+        })
+        .ok_or_else(|| {
+            CaptureError::Setup(format!(
+                "camera offers no MJPEG or YUYV format (has: {})",
+                available
+                    .iter()
+                    .map(|format| format.fourcc.to_string())
+                    .collect::<Vec<_>>()
+                    .join(", ")
+            ))
+        })?;
+
+    let (width, height) = match quality {
+        Quality::Preview => (PREVIEW_WIDTH, PREVIEW_HEIGHT),
+        Quality::Native => largest_size(&device, FourCC::new(fourcc)),
+    };
+    let requested = Format::new(width, height, FourCC::new(fourcc));
+    let actual = with_busy_retry(|| device.set_format(&requested))
+        .map_err(|error| CaptureError::Setup(error.to_string()))?;
+
+    // The driver may substitute a format it prefers; decoding the wrong layout
+    // would render as noise, so fail loudly instead.
+    if actual.fourcc != FourCC::new(fourcc) {
+        return Err(CaptureError::Setup(format!(
+            "driver substituted {} for the requested {}",
+            actual.fourcc,
+            FourCC::new(fourcc)
+        )));
+    }
+
+    Ok(Session {
+        device,
+        encoding,
+        width: actual.width,
+        height: actual.height,
+    })
+}
+
+/// The largest frame size the camera offers for `fourcc`, by pixel count.
+///
+/// Only discrete sizes can be compared directly; a driver advertising a
+/// stepwise or continuous range gets [`OVERSIZED_REQUEST`] instead and clamps
+/// it down itself.
+fn largest_size(device: &Device, fourcc: FourCC) -> (u32, u32) {
+    device
+        .enum_framesizes(fourcc)
+        .into_iter()
+        .flatten()
+        .flat_map(|size| size.size.to_discrete())
+        .map(|discrete| (discrete.width, discrete.height))
+        .max_by_key(|&(width, height)| u64::from(width) * u64::from(height))
+        .unwrap_or((OVERSIZED_REQUEST, OVERSIZED_REQUEST))
+}
+
+/// `EBUSY` — the device is still streaming, here always on another handle.
+const BUSY: i32 = 16;
+
+/// How long to keep retrying `REQBUFS` while a previous stream finishes tearing
+/// down. Covers the ~600 ms `STREAMOFF` that [`CameraStream::drop`] leaves
+/// running, with headroom for a slower camera.
+const REOPEN_GRACE: Duration = Duration::from_millis(1500);
+
+/// Gap between `REQBUFS` attempts while waiting out a teardown.
+const REOPEN_POLL: Duration = Duration::from_millis(25);
+
+/// Map buffers for a capture stream and arm its per-frame timeout.
+///
+/// The stream is deliberately **not** started here: `MmapStream::next` enqueues
+/// every buffer and issues `STREAMON` itself on first use. Calling `start()`
+/// first would mark the stream active with an empty queue, so `next` would take
+/// its steady-state path and only ever cycle one buffer.
+///
+/// `REQBUFS` is retried while the device reports `EBUSY`, which happens when a
+/// just-dropped stream is still in `STREAMOFF` — reselecting the same camera
+/// within ~600 ms otherwise fails outright. Waiting here (rarely, and only on a
+/// re-open) is the trade for never blocking the UI thread in `drop`.
+fn build_stream(session: &Session, timeout: Duration) -> Result<MmapStream<'static>, CaptureError> {
+    let mut stream = with_busy_retry(|| {
+        MmapStream::with_buffers(&session.device, Type::VideoCapture, BUFFER_COUNT)
+    })
+    .map_err(|error| CaptureError::Setup(error.to_string()))?;
+    stream.set_timeout(timeout);
+    Ok(stream)
+}
+
+/// Run a V4L2 setup ioctl, retrying while the driver reports the device busy.
+///
+/// Both `VIDIOC_S_FMT` and `VIDIOC_REQBUFS` return `EBUSY` while *any* handle
+/// is still streaming, so a re-open racing a previous stream's `STREAMOFF` hits
+/// this on whichever call comes first.
+fn with_busy_retry<T>(mut step: impl FnMut() -> std::io::Result<T>) -> std::io::Result<T> {
+    let deadline = Instant::now() + REOPEN_GRACE;
+    loop {
+        match step() {
+            Err(error) if error.raw_os_error() == Some(BUSY) && Instant::now() < deadline => {
+                std::thread::sleep(REOPEN_POLL);
+            }
+            outcome => return outcome,
+        }
+    }
+}
+
+/// Capture a single frame from the camera with `unique_id`, at the camera's
+/// native resolution.
+///
+/// A partially-filled MJPEG buffer (a dropped USB packet) fails to decode, so
+/// this keeps reading until one decodes or `timeout` elapses. The caller's whole
+/// budget is given to the dequeue, since the first frame carries the stream
+/// start-up cost described on [`STREAM_TIMEOUT`] — and more of it at full
+/// resolution, where the sensor has more to read out per frame.
+///
+/// # Errors
+/// [`CaptureError::NotFound`] when no camera matches, [`CaptureError::AccessDenied`]
+/// without permission on the node, [`CaptureError::Timeout`] when no frame
+/// decodes in time.
+pub fn capture_frame(unique_id: &str, timeout: Duration) -> Result<Frame, CaptureError> {
+    let session = open_session(unique_id, Quality::Native)?;
+    let mut stream = build_stream(&session, timeout)?;
+    let deadline = Instant::now() + timeout;
+
+    while Instant::now() < deadline {
+        // A dequeue error leaves the stream unusable (see `run_stream`), so
+        // there is nothing to retry — only a torn frame is worth another pass.
+        let Ok((buffer, meta)) = stream.next() else {
+            break;
+        };
+        if let Some(frame) = decode(&buffer[..used(buffer, meta.bytesused)], &session) {
+            return Ok(frame);
+        }
+    }
+
+    Err(CaptureError::Timeout)
+}
+
+/// The filled prefix of a mapped buffer. `bytesused` is what the driver wrote;
+/// the mapping itself is the larger negotiated buffer size, and the tail is
+/// stale data from an earlier frame.
+fn used(buffer: &[u8], bytesused: u32) -> usize {
+    (bytesused as usize).min(buffer.len())
+}
+
+/// Frame slot shared between the capture thread and the UI's polling.
+struct Shared {
+    latest: Mutex<Option<Arc<Frame>>>,
+    generation: AtomicU64,
+}
+
+/// A running capture stream. Dropping it stops the thread and releases the
+/// camera, which is what turns the hardware LED back off.
+pub struct CameraStream {
+    shared: Arc<Shared>,
+    stop: Arc<AtomicBool>,
+}
+
+impl CameraStream {
+    /// The most recently delivered frame, or `None` before the first arrives.
+    /// Returns a shared [`Arc`] so polling at preview rate never copies the
+    /// pixel buffer.
+    #[must_use]
+    pub fn latest_frame(&self) -> Option<Arc<Frame>> {
+        self.shared.latest.lock().ok().and_then(|slot| slot.clone())
+    }
+
+    /// Take the most recent frame out of the slot (the next delivered frame
+    /// refills it). A sole consumer that unwraps the [`Arc`] gets the pixel
+    /// buffer without copying it.
+    #[must_use]
+    pub fn take_frame(&self) -> Option<Arc<Frame>> {
+        self.shared
+            .latest
+            .lock()
+            .ok()
+            .and_then(|mut slot| slot.take())
+    }
+
+    /// A counter that increments on every delivered frame, so the preview can
+    /// skip rebuilding its texture when no new frame has arrived.
+    #[must_use]
+    pub fn frame_generation(&self) -> u64 {
+        self.shared.generation.load(Ordering::Relaxed)
+    }
+}
+
+impl Drop for CameraStream {
+    fn drop(&mut self) {
+        // Signal and return: the worker tears the stream down on its own.
+        //
+        // Deliberately *not* a join. `VIDIOC_STREAMOFF` blocks for ~600 ms on a
+        // UVC camera while the kernel gives back the USB isochronous bandwidth
+        // reservation, and the GUI drops the preview from `set_target` on the
+        // UI thread — joining would freeze the window for that long on every
+        // switch away from the Camera tab. The cost of not waiting is that the
+        // device stays busy briefly, which [`build_stream`] absorbs.
+        self.stop.store(true, Ordering::Relaxed);
+    }
+}
+
+/// Start a live capture stream on the camera with `unique_id`.
+///
+/// # Errors
+/// Same as [`capture_frame`], minus `Timeout` (frames are polled, not awaited).
+pub fn start_stream(unique_id: &str) -> Result<CameraStream, CaptureError> {
+    let session = open_session(unique_id, Quality::Preview)?;
+    let stream = build_stream(&session, STREAM_TIMEOUT)?;
+
+    let shared = Arc::new(Shared {
+        latest: Mutex::new(None),
+        generation: AtomicU64::new(0),
+    });
+    let stop = Arc::new(AtomicBool::new(false));
+
+    std::thread::Builder::new()
+        .name("openlogi-camera".into())
+        .spawn({
+            let shared = Arc::clone(&shared);
+            let stop = Arc::clone(&stop);
+            move || run_stream(stream, &session, &shared, &stop)
+        })
+        .map_err(|error| CaptureError::Setup(error.to_string()))?;
+
+    Ok(CameraStream { shared, stop })
+}
+
+/// Pump frames into `shared` until `stop` is set or the camera stops delivering.
+///
+/// A dequeue error ends the loop rather than retrying. `MmapStream::next` only
+/// re-queues the buffer it last dequeued, so after a timeout the buffer it
+/// points at is still queued and every later call fails `VIDIOC_QBUF` with
+/// `EINVAL` — retrying would spin the CPU forever without ever recovering. The
+/// preview freezes on the last good frame, which the stalled frame generation
+/// makes visible to the caller.
+fn run_stream(
+    mut stream: MmapStream<'static>,
+    session: &Session,
+    shared: &Shared,
+    stop: &AtomicBool,
+) {
+    while !stop.load(Ordering::Relaxed) {
+        let (buffer, meta) = match stream.next() {
+            Ok(frame) => frame,
+            Err(error) => {
+                tracing::warn!(%error, "camera stream ended");
+                break;
+            }
+        };
+        let Some(frame) = decode(&buffer[..used(buffer, meta.bytesused)], session) else {
+            continue;
+        };
+        if let Ok(mut slot) = shared.latest.lock() {
+            *slot = Some(Arc::new(frame));
+        }
+        shared.generation.fetch_add(1, Ordering::Relaxed);
+    }
+    let _ = stream.stop();
+}
+
+/// Decode one raw buffer into a BGRA frame, or `None` when the buffer is
+/// truncated or malformed (a dropped USB packet mid-frame).
+fn decode(buffer: &[u8], session: &Session) -> Option<Frame> {
+    match session.encoding {
+        Encoding::Mjpeg => decode_mjpeg(buffer),
+        Encoding::Yuyv => decode_yuyv(buffer, session.width, session.height),
+    }
+}
+
+/// Decode a Motion-JPEG frame straight to BGRA.
+///
+/// Dimensions come from the JPEG header rather than the negotiated format:
+/// they agree in practice, but trusting the header keeps the buffer length and
+/// the reported size consistent even if a driver lies.
+fn decode_mjpeg(buffer: &[u8]) -> Option<Frame> {
+    let options = DecoderOptions::default().jpeg_set_out_colorspace(ColorSpace::BGRA);
+    let mut decoder = JpegDecoder::new_with_options(ZCursor::new(buffer), options);
+    let bgra = decoder.decode().ok()?;
+    let info = decoder.info()?;
+    let (width, height) = (u32::from(info.width), u32::from(info.height));
+
+    // A frame whose payload doesn't match its header is a torn capture.
+    if bgra.len() < (width as usize) * (height as usize) * 4 {
+        return None;
+    }
+
+    Some(Frame {
+        width,
+        height,
+        bgra,
+    })
+}
+
+/// Convert packed YUYV 4:2:2 to BGRA using BT.601, the colour space UVC
+/// cameras encode in.
+///
+/// Coefficients are scaled by 256 so the whole conversion is integer work; at
+/// 720p30 this runs per pixel on the capture thread.
+fn decode_yuyv(buffer: &[u8], width: u32, height: u32) -> Option<Frame> {
+    let pixels = (width as usize).checked_mul(height as usize)?;
+    if buffer.len() < pixels * 2 {
+        return None;
+    }
+
+    let mut bgra = vec![0u8; pixels * 4];
+    for (pair, out) in buffer[..pixels * 2]
+        .chunks_exact(4)
+        .zip(bgra.chunks_exact_mut(8))
+    {
+        let (y0, u, y1, v) = (
+            i32::from(pair[0]),
+            i32::from(pair[1]) - 128,
+            i32::from(pair[2]),
+            i32::from(pair[3]) - 128,
+        );
+        write_bgra(&mut out[..4], y0, u, v);
+        write_bgra(&mut out[4..], y1, u, v);
+    }
+
+    Some(Frame {
+        width,
+        height,
+        bgra,
+    })
+}
+
+/// Write one BT.601 YUV sample as a BGRA pixel.
+fn write_bgra(out: &mut [u8], y: i32, u: i32, v: i32) {
+    let y = y * 256;
+    out[0] = clamp_u8(y + 452 * u);
+    out[1] = clamp_u8(y - 88 * u - 183 * v);
+    out[2] = clamp_u8(y + 359 * v);
+    out[3] = 0xFF;
+}
+
+/// Saturate a fixed-point channel (scaled by 256) into a byte.
+fn clamp_u8(scaled: i32) -> u8 {
+    (scaled / 256).clamp(0, 255) as u8
+}
+
+/// Whether this process can open the camera nodes it can see.
+#[must_use]
+pub fn camera_access_granted() -> bool {
+    camera_authorization() == CameraAuthorization::Granted
+}
+
+/// Report camera access by probing a node.
+///
+/// Linux has no consent prompt: a node either opens or it doesn't, decided by
+/// its group permissions. `Undetermined` is therefore never returned — with no
+/// camera present at all there is nothing to authorize, which reads as
+/// `Granted` (nothing is being withheld).
+#[must_use]
+pub fn camera_authorization() -> CameraAuthorization {
+    let nodes = linux::nodes();
+    if nodes.is_empty() {
+        return CameraAuthorization::Granted;
+    }
+    if nodes
+        .iter()
+        .any(|node| Device::with_path(&node.path).is_ok())
+    {
+        CameraAuthorization::Granted
+    } else {
+        CameraAuthorization::Denied
+    }
+}
+
+#[cfg(test)]
+#[allow(clippy::expect_used, reason = "expect/unwrap are idiomatic in tests")]
+mod tests {
+    use super::*;
+
+    #[test]
+    fn yuyv_rejects_a_short_buffer() {
+        // One byte short of a single 2x1 macropixel.
+        assert!(decode_yuyv(&[0; 3], 2, 1).is_none());
+    }
+
+    #[test]
+    fn yuyv_decodes_grey_to_grey() {
+        // Y=128 with neutral chroma is mid-grey in every channel.
+        let frame = decode_yuyv(&[128, 128, 128, 128], 2, 1).expect("2x1 frame");
+        assert_eq!(frame.width, 2);
+        assert_eq!(frame.height, 1);
+        assert_eq!(frame.bgra, vec![128, 128, 128, 255, 128, 128, 128, 255]);
+    }
+
+    #[test]
+    fn yuyv_saturates_out_of_gamut_chroma() {
+        // Peak luma with peak chroma drives blue to 479 and red to 433 before
+        // clamping. They must saturate at 255, not wrap (479 as a truncated
+        // byte would be 223 — a vivid colour turning muddy). Green lands at
+        // 120 legitimately, inside the range, so it pins the coefficients too.
+        let frame = decode_yuyv(&[255, 255, 255, 255], 2, 1).expect("2x1 frame");
+        assert_eq!(&frame.bgra[..4], &[255, 120, 255, 255]);
+    }
+
+    #[test]
+    fn mjpeg_rejects_a_non_jpeg_buffer() {
+        assert!(decode_mjpeg(&[0xFF; 64]).is_none());
+    }
+
+    #[test]
+    fn used_clamps_a_driver_overreporting_bytesused() {
+        // A driver claiming more than the mapping holds must not panic the
+        // slice below.
+        assert_eq!(used(&[0; 10], 99), 10);
+        assert_eq!(used(&[0; 10], 4), 4);
+    }
+}
diff --git a/crates/openlogi-camera/src/capture_types.rs b/crates/openlogi-camera/src/capture_types.rs
new file mode 100644
index 0000000000000000000000000000000000000000..99a57225057609f40cac422d5eff1dd2b56747ba
--- /dev/null
+++ b/crates/openlogi-camera/src/capture_types.rs
@@ -0,0 +1,45 @@
+//! Platform-independent capture vocabulary shared by every capture backend
+//! (AVFoundation on macOS, Media Foundation on Windows, stubs elsewhere).
+
+/// One decoded camera frame, tightly-packed BGRA8 (`width * height * 4` bytes) —
+/// gpui's native texture order, so the preview uploads it without a channel
+/// swap. The snapshot path swaps to RGBA when it writes the PNG.
+#[derive(Clone)]
+pub struct Frame {
+    pub width: u32,
+    pub height: u32,
+    pub bgra: Vec<u8>,
+}
+
+/// Why a capture attempt failed.
+#[derive(Debug, Clone)]
+pub enum CaptureError {
+    /// Camera permission is denied/restricted, or this process can't request
+    /// it (e.g. an unbundled macOS binary with no `NSCameraUsageDescription`).
+    AccessDenied,
+    /// No camera matched the requested unique id.
+    NotFound,
+    /// The session ran but produced no frame within the timeout.
+    Timeout,
+    /// A platform capture object failed to construct.
+    Setup(String),
+    /// Capture has no backend on this platform.
+    Unsupported,
+}
+
+impl std::fmt::Display for CaptureError {
+    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+        match self {
+            Self::AccessDenied => write!(
+                f,
+                "camera access denied — grant Camera permission (on macOS, run inside an app bundle with NSCameraUsageDescription)"
+            ),
+            Self::NotFound => write!(f, "no camera matched that id"),
+            Self::Timeout => write!(f, "camera produced no frame in time"),
+            Self::Setup(s) => write!(f, "capture setup failed: {s}"),
+            Self::Unsupported => write!(f, "camera capture is not implemented on this platform"),
+        }
+    }
+}
+
+impl std::error::Error for CaptureError {}
diff --git a/crates/openlogi-camera/src/capture_windows.rs b/crates/openlogi-camera/src/capture_windows.rs
new file mode 100644
index 0000000000000000000000000000000000000000..5a9782bcb99c58b6a449373590718f1f39a3c2a4
--- /dev/null
+++ b/crates/openlogi-camera/src/capture_windows.rs
@@ -0,0 +1,475 @@
+//! Media Foundation camera capture (Windows): a one-shot snapshot and a live
+//! frame stream.
+//!
+//! A dedicated reader thread owns the whole Media Foundation object graph —
+//! device activation, `IMFSourceReader`, format negotiation — and pulls
+//! samples synchronously, decoding into the same tightly-packed BGRA
+//! [`Frame`]s the macOS backend produces. RGB32 sample memory is BGRX in
+//! little-endian byte order — the channel order gpui wants, but with an
+//! undefined fourth byte that is forced opaque during the copy.
+//! Dropping the [`CameraStream`] stops the thread, which releases the device
+//! (camera LED off).
+//!
+//! There is no per-app consent prompt to drive here: desktop apps see the
+//! camera unless the system-wide privacy toggle blocks them, which surfaces
+//! as an activation error — reported as [`CaptureError::AccessDenied`].
+
+#![expect(
+    unsafe_code,
+    reason = "Media Foundation COM (device activation + IMFSourceReader sample loop)"
+)]
+#![allow(
+    clippy::cast_possible_truncation,
+    clippy::cast_possible_wrap,
+    clippy::cast_sign_loss,
+    reason = "pixel dimensions and strides are bounded and copied verbatim"
+)]
+
+use std::sync::atomic::{AtomicBool, AtomicU64, Ordering};
+use std::sync::{Arc, Mutex, mpsc};
+use std::time::{Duration, Instant};
+
+use windows::Win32::Media::MediaFoundation::{
+    IMFActivate, IMFMediaSource, IMFMediaType, IMFSourceReader, MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE,
+    MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_GUID,
+    MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_SYMBOLIC_LINK, MF_MT_DEFAULT_STRIDE,
+    MF_MT_FRAME_SIZE, MF_MT_MAJOR_TYPE, MF_MT_SUBTYPE, MF_SOURCE_READER_ENABLE_VIDEO_PROCESSING,
+    MF_SOURCE_READER_FIRST_VIDEO_STREAM, MF_VERSION, MFCreateAttributes, MFCreateMediaType,
+    MFCreateSourceReaderFromMediaSource, MFEnumDeviceSources, MFMediaType_Video, MFSTARTUP_LITE,
+    MFStartup, MFVideoFormat_NV12, MFVideoFormat_RGB24, MFVideoFormat_RGB32, MFVideoFormat_YUY2,
+};
+use windows::Win32::System::Com::{COINIT_MULTITHREADED, CoInitializeEx, CoTaskMemFree};
+
+pub use crate::capture_types::{CaptureError, Frame};
+
+/// The preview's target frame width: matches the macOS backend's 720p preset —
+/// Retina-sharp in the 480pt preview box without 1080p copy/upload cost. The
+/// native format closest to this width wins.
+const TARGET_WIDTH: u32 = 1280;
+
+/// How long [`start_stream`] waits for the reader thread to finish setup.
+const SETUP_TIMEOUT: Duration = Duration::from_secs(5);
+
+/// The latest decoded frame plus its generation counter, shared between the
+/// reader thread and the polling preview.
+struct Shared {
+    latest: Mutex<Option<Arc<Frame>>>,
+    generation: AtomicU64,
+    stop: AtomicBool,
+}
+
+/// A live preview stream. Holds the reader thread; [`CameraStream::take_frame`]
+/// hands out the most recent frame each time it's polled. Dropping it stops
+/// the camera.
+pub struct CameraStream {
+    shared: Arc<Shared>,
+    reader: Option<std::thread::JoinHandle<()>>,
+}
+
+impl CameraStream {
+    /// The most recently delivered frame, or `None` before the first arrives.
+    #[must_use]
+    pub fn latest_frame(&self) -> Option<Arc<Frame>> {
+        self.shared.latest.lock().ok().and_then(|slot| slot.clone())
+    }
+
+    /// Take the most recent frame out of the slot (the next delivered frame
+    /// refills it). A sole consumer that unwraps the [`Arc`] gets the pixel
+    /// buffer without copying it.
+    #[must_use]
+    pub fn take_frame(&self) -> Option<Arc<Frame>> {
+        self.shared
+            .latest
+            .lock()
+            .ok()
+            .and_then(|mut slot| slot.take())
+    }
+
+    /// A counter that increments on every delivered frame, so the preview can
+    /// skip rebuilding its texture when no new frame has arrived.
+    #[must_use]
+    pub fn frame_generation(&self) -> u64 {
+        self.shared.generation.load(Ordering::Relaxed)
+    }
+}
+
+impl Drop for CameraStream {
+    fn drop(&mut self) {
+        self.shared.stop.store(true, Ordering::Relaxed);
+        // The reader wakes from its blocking ReadSample within a frame
+        // interval, sees the flag, and releases the device on its way out.
+        if let Some(reader) = self.reader.take() {
+            let _ = reader.join();
+        }
+    }
+}
+
+/// Start a live capture stream on the camera with `unique_id`.
+///
+/// # Errors
+/// [`CaptureError::NotFound`] for an unknown id, [`CaptureError::AccessDenied`]
+/// when the system privacy toggle blocks cameras, or [`CaptureError::Setup`]
+/// on Media Foundation errors.
+pub fn start_stream(unique_id: &str) -> Result<CameraStream, CaptureError> {
+    let shared = Arc::new(Shared {
+        latest: Mutex::new(None),
+        generation: AtomicU64::new(0),
+        stop: AtomicBool::new(false),
+    });
+    let (setup_tx, setup_rx) = mpsc::channel();
+    let thread_shared = Arc::clone(&shared);
+    let id = unique_id.to_string();
+    let reader = std::thread::Builder::new()
+        .name("openlogi-camera-reader".into())
+        .spawn(move || reader_thread(&id, &thread_shared, &setup_tx))
+        .map_err(|e| CaptureError::Setup(e.to_string()))?;
+
+    match setup_rx.recv_timeout(SETUP_TIMEOUT) {
+        Ok(Ok(())) => Ok(CameraStream {
+            shared,
+            reader: Some(reader),
+        }),
+        Ok(Err(e)) => {
+            let _ = reader.join();
+            Err(e)
+        }
+        Err(_) => {
+            shared.stop.store(true, Ordering::Relaxed);
+            Err(CaptureError::Timeout)
+        }
+    }
+}
+
+/// Capture a single [`Frame`] from the camera with `unique_id`.
+///
+/// # Errors
+/// As [`start_stream`], plus [`CaptureError::Timeout`] when no frame arrives.
+pub fn capture_frame(unique_id: &str, timeout: Duration) -> Result<Frame, CaptureError> {
+    let stream = start_stream(unique_id)?;
+    let deadline = Instant::now() + timeout;
+    loop {
+        if let Some(frame) = stream.take_frame() {
+            return Ok(Arc::unwrap_or_clone(frame));
+        }
+        if Instant::now() >= deadline {
+            return Err(CaptureError::Timeout);
+        }
+        std::thread::sleep(Duration::from_millis(30));
+    }
+}
+
+/// Desktop apps are governed only by the system-wide privacy toggle, which
+/// can't be queried up front — report usable and let activation surface a
+/// denial.
+#[must_use]
+pub fn camera_access_granted() -> bool {
+    true
+}
+
+/// Windows has no per-app camera consent for desktop apps.
+#[must_use]
+pub fn camera_authorization() -> crate::CameraAuthorization {
+    crate::CameraAuthorization::Granted
+}
+
+/// The reader thread: builds the Media Foundation graph, reports the outcome
+/// through `setup`, then pulls and decodes samples until told to stop.
+fn reader_thread(unique_id: &str, shared: &Shared, setup: &mpsc::Sender<Result<(), CaptureError>>) {
+    // SAFETY: COM + MF init on this thread; every interface is released by the
+    // `windows` wrappers when the thread's locals drop.
+    let reader = unsafe {
+        let _ = CoInitializeEx(None, COINIT_MULTITHREADED);
+        if let Err(e) = MFStartup(MF_VERSION, MFSTARTUP_LITE) {
+            let _ = setup.send(Err(CaptureError::Setup(e.to_string())));
+            return;
+        }
+        match open_reader(unique_id) {
+            Ok(opened) => opened,
+            Err(e) => {
+                let _ = setup.send(Err(e));
+                return;
+            }
+        }
+    };
+    let (reader, stride_hint) = reader;
+    let _ = setup.send(Ok(()));
+
+    while !shared.stop.load(Ordering::Relaxed) {
+        // SAFETY: synchronous ReadSample with documented out-params; the
+        // sample and its buffer are released when the wrappers drop.
+        unsafe {
+            let (mut flags, mut sample) = (0u32, None);
+            if reader
+                .ReadSample(
+                    MF_SOURCE_READER_FIRST_VIDEO_STREAM.0 as u32,
+                    0,
+                    None,
+                    Some(&raw mut flags),
+                    None,
+                    Some(&raw mut sample),
+                )
+                .is_err()
+            {
+                break;
+            }
+            let Some(sample) = sample else { continue };
+            let Ok(buffer) = sample.ConvertToContiguousBuffer() else {
+                continue;
+            };
+            let (mut data, mut len) = (std::ptr::null_mut(), 0u32);
+            if buffer
+                .Lock(&raw mut data, None, Some(&raw mut len))
+                .is_err()
+            {
+                continue;
+            }
+            store_frame(shared, data, len as usize, stride_hint);
+            let _ = buffer.Unlock();
+        }
+    }
+}
+
+/// Frame geometry negotiated at setup: dimensions plus the RGB32 stride (a
+/// negative stride means the rows arrive bottom-up and must be flipped).
+#[derive(Clone, Copy)]
+struct StrideHint {
+    width: u32,
+    height: u32,
+    stride: i32,
+}
+
+/// Build the source reader for `unique_id`: activate the matching device,
+/// pick the native format closest to [`TARGET_WIDTH`], and negotiate RGB32
+/// output (Media Foundation inserts the decoder/converter).
+unsafe fn open_reader(unique_id: &str) -> Result<(IMFSourceReader, StrideHint), CaptureError> {
+    unsafe {
+        let source = activate_source(unique_id)?;
+
+        let mut reader_attrs = None;
+        MFCreateAttributes(&raw mut reader_attrs, 1).map_err(setup_err)?;
+        let reader_attrs = reader_attrs.ok_or_else(|| setup_err("MFCreateAttributes"))?;
+        reader_attrs
+            .SetUINT32(&MF_SOURCE_READER_ENABLE_VIDEO_PROCESSING, 1)
+            .map_err(setup_err)?;
+        let reader = MFCreateSourceReaderFromMediaSource(&source, &reader_attrs)
+            .map_err(|e| access_or_setup(&e))?;
+
+        // Prefer the native type closest to the preview's target width, so a
+        // 4K-capable camera doesn't stream (and we don't convert) 8x the
+        // pixels the preview can show. Only formats the reader's (legacy)
+        // processor can convert to RGB32 count — a compressed 720p mode it
+        // can't decode would fail below, while a convertible mode at another
+        // 16:9 size still previews fine.
+        let stream = MF_SOURCE_READER_FIRST_VIDEO_STREAM.0 as u32;
+        let mut best: Option<(u32, IMFMediaType)> = None;
+        let mut index = 0u32;
+        while let Ok(native) = reader.GetNativeMediaType(stream, index) {
+            index += 1;
+            let convertible = native.GetGUID(&MF_MT_SUBTYPE).is_ok_and(|subtype| {
+                [
+                    MFVideoFormat_NV12,
+                    MFVideoFormat_YUY2,
+                    MFVideoFormat_RGB24,
+                    MFVideoFormat_RGB32,
+                ]
+                .contains(&subtype)
+            });
+            if !convertible {
+                continue;
+            }
+            if let Ok(size) = native.GetUINT64(&MF_MT_FRAME_SIZE) {
+                let width = (size >> 32) as u32;
+                let score = width.abs_diff(TARGET_WIDTH);
+                if best.as_ref().is_none_or(|(s, _)| score < *s) {
+                    best = Some((score, native));
+                }
+            }
+        }
+        // Selecting the native type switches the device to that mode — a size
+        // hint on the RGB32 output type alone is quietly dropped (the legacy
+        // processor converts but never scales), leaving whatever mode the
+        // device was in.
+        if let Some((_, native)) = &best {
+            reader
+                .SetCurrentMediaType(stream, None, native)
+                .map_err(setup_err)?;
+        }
+
+        let output = MFCreateMediaType().map_err(setup_err)?;
+        output
+            .SetGUID(&MF_MT_MAJOR_TYPE, &MFMediaType_Video)
+            .map_err(setup_err)?;
+        output
+            .SetGUID(&MF_MT_SUBTYPE, &MFVideoFormat_RGB32)
+            .map_err(setup_err)?;
+        reader
+            .SetCurrentMediaType(stream, None, &output)
+            .map_err(setup_err)?;
+
+        // Read the negotiated geometry back — the converter may have kept the
+        // native size, and the stride tells us whether rows arrive bottom-up.
+        let current = reader.GetCurrentMediaType(stream).map_err(setup_err)?;
+        let size = current.GetUINT64(&MF_MT_FRAME_SIZE).map_err(setup_err)?;
+        let width = (size >> 32) as u32;
+        let height = (size & 0xFFFF_FFFF) as u32;
+        let stride = current
+            .GetUINT32(&MF_MT_DEFAULT_STRIDE)
+            .map_or(width as i32 * 4, |s| s as i32);
+        Ok((
+            reader,
+            StrideHint {
+                width,
+                height,
+                stride,
+            },
+        ))
+    }
+}
+
+/// Activate the video-capture device whose Media Foundation symbolic link
+/// identifies the same physical device as `unique_id` (the stored DirectShow
+/// device path). The two APIs register the camera under different
+/// interface-class GUIDs, so they are matched on the shared device-instance
+/// portion (see [`device_instance`]).
+unsafe fn activate_source(unique_id: &str) -> Result<IMFMediaSource, CaptureError> {
+    unsafe {
+        let mut enum_attrs = None;
+        MFCreateAttributes(&raw mut enum_attrs, 1).map_err(setup_err)?;
+        let enum_attrs = enum_attrs.ok_or_else(|| setup_err("MFCreateAttributes"))?;
+        enum_attrs
+            .SetGUID(
+                &MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE,
+                &MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_GUID,
+            )
+            .map_err(setup_err)?;
+
+        let (mut devices, mut count) = (std::ptr::null_mut::<Option<IMFActivate>>(), 0u32);
+        MFEnumDeviceSources(&enum_attrs, &raw mut devices, &raw mut count).map_err(setup_err)?;
+        let list = std::slice::from_raw_parts(devices, count as usize);
+        let mut chosen = None;
+        for activate in list.iter().flatten() {
+            let (mut link, mut len) = (windows::core::PWSTR::null(), 0u32);
+            if activate
+                .GetAllocatedString(
+                    &MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_SYMBOLIC_LINK,
+                    &raw mut link,
+                    &raw mut len,
+                )
+                .is_err()
+            {
+                continue;
+            }
+            let link_str = link.to_string().unwrap_or_default();
+            CoTaskMemFree(Some(link.as_ptr().cast()));
+            if device_instance(&link_str).eq_ignore_ascii_case(device_instance(unique_id)) {
+                chosen = Some(activate.clone());
+                break;
+            }
+        }
+        let result = match chosen {
+            Some(activate) => activate
+                .ActivateObject::<IMFMediaSource>()
+                .map_err(|e| access_or_setup(&e)),
+            None => Err(CaptureError::NotFound),
+        };
+        CoTaskMemFree(Some(devices.cast()));
+        result
+    }
+}
+
+/// The device-instance portion of a Windows device-interface path, dropping the
+/// trailing `#{interface-class-guid}\reference`. DirectShow (the id we enumerate
+/// and persist) tags a camera under `KSCATEGORY_VIDEO`, while Media Foundation
+/// tags the same physical device under `KSCATEGORY_VIDEO_CAMERA` — so the paths
+/// differ only by that GUID, and comparing the instance links the two.
+fn device_instance(interface_path: &str) -> &str {
+    interface_path.split("#{").next().unwrap_or(interface_path)
+}
+
+/// Copy one locked RGB32 sample into a tightly-packed BGRA [`Frame`] in the
+/// shared slot, flipping bottom-up rows when the stride is negative.
+fn store_frame(shared: &Shared, data: *mut u8, len: usize, hint: StrideHint) {
+    let (width, height) = (hint.width as usize, hint.height as usize);
+    let row_bytes = width * 4;
+    let stride = hint.stride.unsigned_abs() as usize;
+    if width == 0 || height == 0 || data.is_null() || stride * (height - 1) + row_bytes > len {
+        return;
+    }
+    let mut bgra = vec![0u8; row_bytes * height];
+    for y in 0..height {
+        // A negative stride means the buffer's first row is the bottom line.
+        let src_row = if hint.stride < 0 { height - 1 - y } else { y };
+        // SAFETY: both row offsets are bounds-checked against `len` above.
+        unsafe {
+            std::ptr::copy_nonoverlapping(
+                data.add(src_row * stride),
+                bgra.as_mut_ptr().add(y * row_bytes),
+                row_bytes,
+            );
+        }
+    }
+    // RGB32 is really BGRX: Media Foundation leaves the fourth byte undefined
+    // (zero in practice), which gpui would alpha-blend into an invisible frame.
+    // Force every pixel opaque to make the buffer true BGRA.
+    for px in bgra.chunks_exact_mut(4) {
+        px[3] = 0xFF;
+    }
+    if let Ok(mut slot) = shared.latest.lock() {
+        *slot = Some(Arc::new(Frame {
+            width: hint.width,
+            height: hint.height,
+            bgra,
+        }));
+        shared.generation.fetch_add(1, Ordering::Relaxed);
+    }
+}
+
+fn setup_err(e: impl std::fmt::Display) -> CaptureError {
+    CaptureError::Setup(e.to_string())
+}
+
+/// Map an activation failure to AccessDenied when the system privacy toggle
+/// is the cause (E_ACCESSDENIED), Setup otherwise.
+fn access_or_setup(e: &windows::core::Error) -> CaptureError {
+    const E_ACCESSDENIED: windows::core::HRESULT = windows::core::HRESULT(0x8007_0005_u32 as i32);
+    if e.code() == E_ACCESSDENIED {
+        CaptureError::AccessDenied
+    } else {
+        CaptureError::Setup(e.to_string())
+    }
+}
+
+#[cfg(test)]
+mod tests {
+    use super::device_instance;
+
+    // The same StreamCam function, as DirectShow enumerates it (KSCATEGORY_VIDEO)
+    // vs. as Media Foundation enumerates it (KSCATEGORY_VIDEO_CAMERA): identical
+    // but for the trailing interface-class GUID.
+    const DIRECTSHOW: &str = r"\\?\usb#vid_046d&pid_0893&mi_00#9&56d9c30&0&0000#{65e8773d-8f56-11d0-a3b9-00a0c9223196}\global";
+    const MEDIA_FOUNDATION: &str = r"\\?\usb#vid_046d&pid_0893&mi_00#9&56d9c30&0&0000#{e5323777-f976-4f5b-9b55-b94699c46e44}\global";
+
+    #[test]
+    fn instance_matches_across_interface_class_guids() {
+        assert_eq!(
+            device_instance(DIRECTSHOW),
+            device_instance(MEDIA_FOUNDATION),
+            "the stored DirectShow id must match MF's symbolic link"
+        );
+        assert_eq!(
+            device_instance(DIRECTSHOW),
+            r"\\?\usb#vid_046d&pid_0893&mi_00#9&56d9c30&0&0000"
+        );
+    }
+
+    #[test]
+    fn distinct_devices_stay_distinct() {
+        let other = r"\\?\usb#vid_046d&pid_0825&mi_00#7&1a2b3c&0&0000#{e5323777-f976-4f5b-9b55-b94699c46e44}\global";
+        assert_ne!(device_instance(DIRECTSHOW), device_instance(other));
+    }
+
+    #[test]
+    fn path_without_interface_guid_is_returned_whole() {
+        assert_eq!(device_instance("not-a-device-path"), "not-a-device-path");
+    }
+}
diff --git a/crates/openlogi-camera/src/controls.rs b/crates/openlogi-camera/src/controls.rs
new file mode 100644
index 0000000000000000000000000000000000000000..8b889caeab7282c3d5b8c18a59bad8a7b30255b4
--- /dev/null
+++ b/crates/openlogi-camera/src/controls.rs
@@ -0,0 +1,135 @@
+//! Platform-independent control vocabulary shared by every UVC backend
+//! (IOKit on macOS, DirectShow on Windows, stubs elsewhere).
+
+/// One adjustable camera control, mapped to a UVC selector by each backend.
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+pub enum CameraControl {
+    Zoom,
+    Focus,
+    Exposure,
+    Brightness,
+    Contrast,
+    Saturation,
+    Sharpness,
+    WhiteBalance,
+    Tint,
+}
+
+impl CameraControl {
+    /// Every control, in the order the UI lists them (lens first, then image).
+    pub const ALL: [Self; 9] = [
+        Self::Zoom,
+        Self::Focus,
+        Self::Exposure,
+        Self::Brightness,
+        Self::Contrast,
+        Self::Saturation,
+        Self::Sharpness,
+        Self::WhiteBalance,
+        Self::Tint,
+    ];
+
+    /// Stable snake_case identifier used for config persistence and the CLI.
+    #[must_use]
+    pub fn name(self) -> &'static str {
+        match self {
+            Self::Zoom => "zoom",
+            Self::Focus => "focus",
+            Self::Exposure => "exposure",
+            Self::Brightness => "brightness",
+            Self::Contrast => "contrast",
+            Self::Saturation => "saturation",
+            Self::Sharpness => "sharpness",
+            Self::WhiteBalance => "white_balance",
+            Self::Tint => "tint",
+        }
+    }
+
+    /// The auto-mode toggle that gates this control, if the device has one.
+    #[must_use]
+    pub fn auto_toggle(self) -> Option<AutoToggle> {
+        match self {
+            Self::Focus => Some(AutoToggle::Focus),
+            Self::Exposure => Some(AutoToggle::Exposure),
+            Self::WhiteBalance => Some(AutoToggle::WhiteBalance),
+            _ => None,
+        }
+    }
+}
+
+/// An auto-mode toggle paired with a manual control (focus / exposure / white
+/// balance).
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+pub enum AutoToggle {
+    Focus,
+    Exposure,
+    WhiteBalance,
+}
+
+impl AutoToggle {
+    /// Every toggle, matching [`CameraControl::auto_toggle`] pairs.
+    pub const ALL: [Self; 3] = [Self::Focus, Self::Exposure, Self::WhiteBalance];
+
+    /// Stable snake_case identifier used for config persistence and the CLI.
+    #[must_use]
+    pub fn name(self) -> &'static str {
+        match self {
+            Self::Focus => "focus_auto",
+            Self::Exposure => "exposure_auto",
+            Self::WhiteBalance => "white_balance_auto",
+        }
+    }
+}
+
+/// One auto toggle's live and default state, read from the device.
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+pub struct AutoState {
+    pub current: bool,
+    pub default: bool,
+}
+
+/// Everything the controls UI needs, read in a single device-open: each
+/// supported control's range and each supported auto toggle's state.
+#[derive(Debug, Clone, Default)]
+pub struct CameraState {
+    pub controls: Vec<(CameraControl, ControlRange)>,
+    pub autos: Vec<(AutoToggle, AutoState)>,
+}
+
+/// The device's reported range and current value for a control.
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+pub struct ControlRange {
+    pub min: i32,
+    pub max: i32,
+    pub default: i32,
+    pub current: i32,
+}
+
+/// Why a UVC control operation failed.
+#[derive(Debug, Clone)]
+pub enum ControlError {
+    /// No matching camera device (or it exposes no controllable unit).
+    NotFound,
+    /// The selected camera can't be uniquely identified: its unique id didn't
+    /// resolve to a USB location and more than one Logitech camera is attached,
+    /// so a write could hit the wrong device. Fails closed instead of guessing.
+    Ambiguous,
+    /// The camera rejected or didn't support the control — or the platform
+    /// has no UVC control backend at all.
+    Unsupported,
+    /// A platform API call failed (open, bind, or the control transfer).
+    Io(String),
+}
+
+impl std::fmt::Display for ControlError {
+    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+        match self {
+            Self::NotFound => write!(f, "no matching UVC device"),
+            Self::Ambiguous => write!(f, "camera could not be uniquely identified"),
+            Self::Unsupported => write!(f, "camera does not support that control"),
+            Self::Io(s) => write!(f, "platform error: {s}"),
+        }
+    }
+}
+
+impl std::error::Error for ControlError {}
diff --git a/crates/openlogi-camera/src/lib.rs b/crates/openlogi-camera/src/lib.rs
new file mode 100644
index 0000000000000000000000000000000000000000..37ce32afe14ad91886d96fb8d9f27185d56683d0
--- /dev/null
+++ b/crates/openlogi-camera/src/lib.rs
@@ -0,0 +1,432 @@
+//! Generic discovery of Logitech USB Video Class (UVC) webcams.
+//!
+//! Mice and keyboards speak Logitech's proprietary HID++ (over a Bolt/Unifying
+//! receiver or directly) — see the `openlogi-hid` crate. Webcams don't: every
+//! Logitech camera (StreamCam, Brio, C920, C922, C270, C930e, …) is a standard
+//! UVC device and enumerates the same way. So detection keys off the USB vendor
+//! id (`0x046d`) rather than any per-model quirk — plug in *any* Logitech
+//! camera and it's recognised, with no model table to maintain.
+//!
+//! macOS has the full backend (AVFoundation capture + IOKit UVC controls);
+//! Windows matches it with Media Foundation capture and DirectShow controls;
+//! Linux uses V4L2 for both, through the kernel's `uvcvideo` driver. Other
+//! platforms return an empty list.
+
+use serde::Serialize;
+
+mod controls;
+pub use controls::{AutoState, AutoToggle, CameraControl, CameraState, ControlError, ControlRange};
+
+mod capture_types;
+pub use capture_types::{CaptureError, Frame};
+
+#[cfg(target_os = "macos")]
+mod macos;
+
+#[cfg(target_os = "macos")]
+mod capture;
+#[cfg(target_os = "macos")]
+pub use capture::{
+    CameraStream, camera_access_granted, camera_authorization, capture_frame, start_stream,
+};
+
+#[cfg(target_os = "windows")]
+mod capture_windows;
+#[cfg(target_os = "windows")]
+pub use capture_windows::{
+    CameraStream, camera_access_granted, camera_authorization, capture_frame, start_stream,
+};
+
+#[cfg(target_os = "macos")]
+mod uvc;
+#[cfg(target_os = "macos")]
+pub use uvc::{
+    apply_settings, control_range, control_ranges, read_camera_state, set_auto, set_control,
+};
+
+#[cfg(target_os = "windows")]
+mod uvc_windows;
+#[cfg(target_os = "windows")]
+pub use uvc_windows::{
+    apply_settings, control_range, control_ranges, read_camera_state, set_auto, set_control,
+};
+
+#[cfg(target_os = "linux")]
+mod linux;
+
+#[cfg(target_os = "linux")]
+mod capture_linux;
+#[cfg(target_os = "linux")]
+pub use capture_linux::{
+    CameraStream, camera_access_granted, camera_authorization, capture_frame, start_stream,
+};
+
+#[cfg(target_os = "linux")]
+mod uvc_linux;
+#[cfg(target_os = "linux")]
+pub use uvc_linux::{
+    apply_settings, control_range, control_ranges, read_camera_state, set_auto, set_control,
+};
+
+#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "linux")))]
+mod capture {
+    //! Stub capture backend for platforms without one.
+    use std::sync::Arc;
+    use std::time::Duration;
+
+    use crate::capture_types::{CaptureError, Frame};
+
+    /// Stub: returns [`CaptureError::Unsupported`] on this platform.
+    pub fn capture_frame(_unique_id: &str, _timeout: Duration) -> Result<Frame, CaptureError> {
+        Err(CaptureError::Unsupported)
+    }
+
+    /// Stub live stream (never yields a frame on this platform).
+    pub struct CameraStream;
+
+    impl CameraStream {
+        #[must_use]
+        pub fn latest_frame(&self) -> Option<Arc<Frame>> {
+            None
+        }
+
+        #[must_use]
+        pub fn take_frame(&self) -> Option<Arc<Frame>> {
+            None
+        }
+
+        #[must_use]
+        pub fn frame_generation(&self) -> u64 {
+            0
+        }
+    }
+
+    /// Stub: returns [`CaptureError::Unsupported`] on this platform.
+    pub fn start_stream(_unique_id: &str) -> Result<CameraStream, CaptureError> {
+        Err(CaptureError::Unsupported)
+    }
+
+    /// Stub: camera access is never granted on this platform.
+    #[must_use]
+    pub fn camera_access_granted() -> bool {
+        false
+    }
+
+    /// Stub: camera permission is always undetermined on this platform.
+    #[must_use]
+    pub fn camera_authorization() -> crate::CameraAuthorization {
+        crate::CameraAuthorization::Undetermined
+    }
+}
+#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "linux")))]
+pub use capture::{
+    CameraStream, camera_access_granted, camera_authorization, capture_frame, start_stream,
+};
+
+#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "linux")))]
+mod uvc {
+    //! Stub UVC control backend for platforms without one.
+    use crate::controls::{AutoToggle, CameraControl, CameraState, ControlError, ControlRange};
+
+    /// Stub: no UVC backend on this platform.
+    pub fn control_range(_id: &str, _c: CameraControl) -> Result<ControlRange, ControlError> {
+        Err(ControlError::Unsupported)
+    }
+
+    /// Stub: no UVC backend on this platform.
+    pub fn control_ranges(_id: &str) -> Result<Vec<(CameraControl, ControlRange)>, ControlError> {
+        Ok(Vec::new())
+    }
+
+    /// Stub: no UVC backend on this platform.
+    pub fn read_camera_state(_id: &str) -> Result<CameraState, ControlError> {
+        Ok(CameraState::default())
+    }
+
+    /// Stub: no UVC backend on this platform.
+    pub fn set_control(_id: &str, _c: CameraControl, _value: i32) -> Result<(), ControlError> {
+        Err(ControlError::Unsupported)
+    }
+
+    /// Stub: no UVC backend on this platform.
+    pub fn set_auto(_id: &str, _t: AutoToggle, _on: bool) -> Result<(), ControlError> {
+        Err(ControlError::Unsupported)
+    }
+
+    /// Stub: no UVC backend on this platform.
+    pub fn apply_settings(
+        _id: &str,
+        _autos: &[(AutoToggle, bool)],
+        _values: &[(CameraControl, i32)],
+    ) -> Result<(), ControlError> {
+        Err(ControlError::Unsupported)
+    }
+}
+#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "linux")))]
+pub use uvc::{
+    apply_settings, control_range, control_ranges, read_camera_state, set_auto, set_control,
+};
+
+/// Logitech's USB vendor id. Reported in decimal (`1133`) inside an
+/// `AVCaptureDevice` modelID, and in hex (`046d`) most everywhere else.
+pub const LOGITECH_VID: u16 = 0x046d;
+
+/// Tri-state Camera permission, mirroring macOS `AVAuthorizationStatus`.
+///
+/// Only macOS has a consent model with a pending state. Linux decides access
+/// by filesystem permission on the device node, so it reports `Granted` or
+/// `Denied` but never `Undetermined`; platforms with no backend at all report
+/// `Undetermined`.
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+pub enum CameraAuthorization {
+    /// The process may open cameras.
+    Granted,
+    /// The user denied access, or the system restricts it.
+    Denied,
+    /// Not yet requested — opening a camera will prompt.
+    Undetermined,
+}
+
+/// A connected USB Video Class camera.
+#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
+pub struct Camera {
+    /// Human-readable name, e.g. `"Logitech StreamCam"`.
+    pub name: String,
+    /// OS capture-layer identifier (AVFoundation `uniqueID`, DirectShow device
+    /// path). Used to open preview/controls; may embed a USB location and so
+    /// change when the camera is moved to another port.
+    pub unique_id: String,
+    /// USB `iSerialNumber` when the device reports one. Port-stable; preferred
+    /// for persisted config keys via [`Self::config_key`].
+    pub serial_number: Option<String>,
+    /// USB vendor id (`0x046d` for Logitech).
+    pub vendor_id: u16,
+    /// USB product id (e.g. `0x0893` for the StreamCam).
+    pub product_id: u16,
+    /// Largest supported frame size `(width, height)`, when the OS reports the
+    /// device's formats. Read from metadata only — no capture, no permission.
+    pub max_resolution: Option<(u32, u32)>,
+    /// Highest supported frame rate (fps) across all formats, when known.
+    pub max_fps: Option<u32>,
+}
+
+impl Camera {
+    /// Persistence key that is stable across USB ports.
+    ///
+    /// Prefers the USB serial when the device reports one. When it doesn't,
+    /// falls back to a model-scoped key (`camera:vid:pid`) so settings survive
+    /// a port change. Two serial-less units of the same model share this key
+    /// (no stronger USB identity); the GUI keeps them as separate live cards
+    /// via the OS capture id, not via this settings key.
+    #[must_use]
+    pub fn config_key(&self) -> String {
+        if let Some(serial) = self
+            .serial_number
+            .as_deref()
+            .map(str::trim)
+            .filter(|s| !s.is_empty())
+        {
+            format!(
+                "camera:{:04x}:{:04x}:serial:{}",
+                self.vendor_id,
+                self.product_id,
+                serial.to_ascii_lowercase()
+            )
+        } else {
+            format!("camera:{:04x}:{:04x}", self.vendor_id, self.product_id)
+        }
+    }
+}
+
+/// Whether this platform has a live-capture backend (preview + snapshot).
+/// Enumeration and UVC controls can be supported without it.
+#[must_use]
+pub const fn capture_supported() -> bool {
+    cfg!(any(
+        target_os = "macos",
+        target_os = "windows",
+        target_os = "linux"
+    ))
+}
+
+/// Serializes UVC device seizes against enumeration within this process.
+/// `USBDeviceOpenSeize` briefly detaches the camera's kernel driver, and an
+/// enumeration racing that window sees no camera at all — which read as the
+/// camera "disappearing" from the device list mid-slider-drag once
+/// enumeration moved off the UI thread. Control paths hold this for the
+/// seize's lifetime; enumeration takes it for the duration of the scan.
+#[cfg(target_os = "macos")]
+pub(crate) static USB_QUIESCE: std::sync::Mutex<()> = std::sync::Mutex::new(());
+
+/// Enumerate every connected **Logitech** UVC camera.
+///
+/// Non-Logitech cameras (the built-in FaceTime camera, virtual cameras, other
+/// vendors' webcams) are filtered out. Returns an empty list on platforms with
+/// no capture backend, or when no Logitech camera is attached.
+#[must_use]
+pub fn enumerate_cameras() -> Vec<Camera> {
+    enumerate_all()
+        .into_iter()
+        .filter(|camera| camera.vendor_id == LOGITECH_VID)
+        .collect()
+}
+
+#[cfg(target_os = "macos")]
+fn enumerate_all() -> Vec<Camera> {
+    // Wait out any in-flight control seize so the scan can't land in the
+    // window where the kernel driver is detached (poisoning is impossible —
+    // holders never panic — but recover anyway rather than unwrap).
+    let _quiesce = USB_QUIESCE
+        .lock()
+        .unwrap_or_else(std::sync::PoisonError::into_inner);
+    let serials = uvc::usb_serials_by_location();
+    macos::enumerate()
+        .iter()
+        .filter_map(|raw| {
+            let mut camera = Camera::from_raw(&raw.name, &raw.unique_id, &raw.model_id)?;
+            if raw.max_width > 0 && raw.max_height > 0 {
+                camera.max_resolution = Some((raw.max_width, raw.max_height));
+            }
+            if raw.max_fps > 0 {
+                camera.max_fps = Some(raw.max_fps);
+            }
+            if let Some(location) = uvc::location_hint(&raw.unique_id) {
+                camera.serial_number = serials.get(&location).cloned();
+            }
+            Some(camera)
+        })
+        .collect()
+}
+
+#[cfg(target_os = "windows")]
+fn enumerate_all() -> Vec<Camera> {
+    uvc_windows::enumerate()
+}
+
+#[cfg(target_os = "linux")]
+fn enumerate_all() -> Vec<Camera> {
+    linux::nodes().iter().map(linux::describe).collect()
+}
+
+#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "linux")))]
+fn enumerate_all() -> Vec<Camera> {
+    Vec::new()
+}
+
+#[cfg(any(test, target_os = "macos"))]
+impl Camera {
+    /// Build a [`Camera`] from an OS-reported `(name, unique_id, model_id)`.
+    ///
+    /// Returns `None` when `model_id` carries no USB vendor/product id — i.e.
+    /// it isn't a real USB camera (the macOS FaceTime camera's modelID is just
+    /// `"FaceTime HD Camera"`), so it can't be attributed to a vendor and is
+    /// dropped before the Logitech filter even runs. Format fields start `None`;
+    /// the platform backend fills them in.
+    fn from_raw(name: &str, unique_id: &str, model_id: &str) -> Option<Self> {
+        let (vendor_id, product_id) = parse_vid_pid(model_id)?;
+        Some(Self {
+            name: name.to_string(),
+            unique_id: unique_id.to_string(),
+            serial_number: None,
+            vendor_id,
+            product_id,
+            max_resolution: None,
+            max_fps: None,
+        })
+    }
+}
+
+/// Pull the USB vendor/product id out of an `AVCaptureDevice` modelID such as
+/// `"UVC Camera VendorID_1133 ProductID_2195"`. Both ids are **decimal** in
+/// that string (1133 == 0x046d, 2195 == 0x0893). `None` if either marker is
+/// absent.
+#[cfg(any(test, target_os = "macos"))]
+fn parse_vid_pid(model_id: &str) -> Option<(u16, u16)> {
+    let vendor_id = parse_marker(model_id, "VendorID_")?;
+    let product_id = parse_marker(model_id, "ProductID_")?;
+    Some((vendor_id, product_id))
+}
+
+/// Read the decimal number immediately following `marker` in `haystack`.
+#[cfg(any(test, target_os = "macos"))]
+fn parse_marker(haystack: &str, marker: &str) -> Option<u16> {
+    let rest = haystack.split(marker).nth(1)?;
+    let digits: String = rest.chars().take_while(char::is_ascii_digit).collect();
+    digits.parse().ok()
+}
+
+#[cfg(test)]
+mod tests {
+    use super::*;
+
+    #[test]
+    fn parses_logitech_streamcam_model_id() {
+        assert_eq!(
+            parse_vid_pid("UVC Camera VendorID_1133 ProductID_2195"),
+            Some((0x046d, 0x0893))
+        );
+    }
+
+    #[test]
+    fn rejects_model_id_without_usb_ids() {
+        assert_eq!(parse_vid_pid("FaceTime HD Camera"), None);
+        assert_eq!(parse_vid_pid("VendorID_1133 only"), None);
+    }
+
+    #[test]
+    fn from_raw_keeps_usb_cameras_and_drops_the_rest() {
+        assert_eq!(
+            Camera::from_raw(
+                "Logitech StreamCam",
+                "0x1123000046d0893",
+                "UVC Camera VendorID_1133 ProductID_2195",
+            ),
+            Some(Camera {
+                name: "Logitech StreamCam".to_string(),
+                unique_id: "0x1123000046d0893".to_string(),
+                serial_number: None,
+                vendor_id: LOGITECH_VID,
+                product_id: 0x0893,
+                max_resolution: None,
+                max_fps: None,
+            })
+        );
+        assert_eq!(
+            Camera::from_raw("FaceTime HD Camera", "uuid", "FaceTime HD Camera"),
+            None
+        );
+    }
+
+    #[test]
+    fn config_key_prefers_usb_serial_over_capture_id() {
+        let with_serial = Camera {
+            name: "Logitech StreamCam".into(),
+            unique_id: "0x1123000046d0893".into(),
+            serial_number: Some("ABC123".into()),
+            vendor_id: LOGITECH_VID,
+            product_id: 0x0893,
+            max_resolution: None,
+            max_fps: None,
+        };
+        assert_eq!(with_serial.config_key(), "camera:046d:0893:serial:abc123");
+        // Same physical camera on another USB port → same config key.
+        let moved = Camera {
+            unique_id: "0x14110000046d0893".into(),
+            ..with_serial.clone()
+        };
+        assert_eq!(moved.config_key(), with_serial.config_key());
+
+        let no_serial = Camera {
+            serial_number: None,
+            unique_id: "0x1123000046d0893".into(),
+            ..with_serial.clone()
+        };
+        // Model-scoped — same key after a port change even without a serial.
+        assert_eq!(no_serial.config_key(), "camera:046d:0893");
+        let moved_no_serial = Camera {
+            unique_id: "0x14110000046d0893".into(),
+            ..no_serial
+        };
+        assert_eq!(moved_no_serial.config_key(), "camera:046d:0893");
+    }
+}
diff --git a/crates/openlogi-camera/src/linux.rs b/crates/openlogi-camera/src/linux.rs
new file mode 100644
index 0000000000000000000000000000000000000000..901e80a5399369d53bd9503a037ae218ea0ee501
--- /dev/null
+++ b/crates/openlogi-camera/src/linux.rs
@@ -0,0 +1,215 @@
+//! V4L2 device discovery on Linux.
+//!
+//! A UVC camera exposes several `/dev/video*` nodes — one for capture, plus a
+//! metadata node carrying UVC timing data. `VIDIOC_QUERYCAP`'s `capabilities`
+//! field reports the *union* across the physical device's nodes, so it reads
+//! `VIDEO_CAPTURE` on the metadata node too; the `v4l` crate doesn't surface
+//! the per-node `device_caps`. Nodes are therefore classified by whether
+//! `VIDIOC_ENUM_FMT` yields any capture format, which only the capture node
+//! does.
+
+use std::fs;
+use std::path::{Path, PathBuf};
+
+use v4l::frameinterval::FrameIntervalEnum;
+use v4l::video::Capture;
+use v4l::{Device, FourCC};
+
+use crate::Camera;
+
+/// Where the kernel lists V4L2 nodes, one directory per `/dev/video*`.
+const SYSFS_V4L: &str = "/sys/class/video4linux";
+
+/// Stable-by-serial symlink farm `udev` maintains for V4L2 nodes.
+const BY_ID_DIR: &str = "/dev/v4l/by-id";
+
+/// A discovered capture node and the USB identity behind it.
+pub(crate) struct Node {
+    pub(crate) path: PathBuf,
+    pub(crate) name: String,
+    pub(crate) vendor_id: u16,
+    pub(crate) product_id: u16,
+    /// USB `iSerialNumber` from sysfs when the device reports one.
+    pub(crate) serial_number: Option<String>,
+}
+
+/// Enumerate every V4L2 capture node, newest-first by node index.
+///
+/// Non-USB devices (virtual cameras, loopback nodes) have no `idVendor` in
+/// sysfs and are skipped — they can't be attributed to a vendor, so the
+/// Logitech filter in [`crate::enumerate_cameras`] couldn't judge them anyway.
+pub(crate) fn nodes() -> Vec<Node> {
+    let Ok(entries) = fs::read_dir(SYSFS_V4L) else {
+        return Vec::new();
+    };
+
+    let mut nodes: Vec<Node> = entries
+        .flatten()
+        .filter_map(|entry| {
+            let sysfs = entry.path();
+            let dev_path = PathBuf::from("/dev").join(entry.file_name());
+            let (vendor_id, product_id) = usb_ids(&sysfs)?;
+            if !is_capture_node(&dev_path) {
+                return None;
+            }
+            Some(Node {
+                name: read_trimmed(&sysfs.join("name"))
+                    .unwrap_or_else(|| dev_path.display().to_string()),
+                path: dev_path,
+                vendor_id,
+                product_id,
+                serial_number: usb_serial(&sysfs),
+            })
+        })
+        .collect();
+
+    nodes.sort_by(|a, b| a.path.cmp(&b.path));
+    nodes
+}
+
+/// Resolve a [`Camera::unique_id`] back to the `/dev/video*` node it names.
+///
+/// Ids are `by-id` symlinks when udev provides one, so this canonicalizes
+/// before comparing — a `by-id` path and its `/dev/videoN` target must resolve
+/// to the same node.
+pub(crate) fn node_for_unique_id(unique_id: &str) -> Option<PathBuf> {
+    let target = fs::canonicalize(unique_id).ok()?;
+    nodes()
+        .into_iter()
+        .find(|node| fs::canonicalize(&node.path).is_ok_and(|p| p == target))
+        .map(|node| node.path)
+}
+
+/// Build the [`Camera`] view of a node, including its largest frame size and
+/// highest frame rate. Format probing is metadata-only — `VIDIOC_ENUM_*`
+/// never starts a stream, so this costs no LED and needs no permission beyond
+/// opening the node.
+pub(crate) fn describe(node: &Node) -> Camera {
+    let (max_resolution, max_fps) =
+        Device::with_path(&node.path).map_or((None, None), |device| max_format(&device));
+
+    Camera {
+        name: node.name.clone(),
+        unique_id: unique_id_for(&node.path),
+        serial_number: node.serial_number.clone(),
+        vendor_id: node.vendor_id,
+        product_id: node.product_id,
+        max_resolution,
+        max_fps,
+    }
+}
+
+/// The `by-id` symlink for `path` when udev created one (it embeds the USB
+/// serial, so it survives replugging into another port), else the raw node
+/// path. Either way it round-trips through [`node_for_unique_id`].
+fn unique_id_for(path: &Path) -> String {
+    let canonical = fs::canonicalize(path).ok();
+    let by_id = fs::read_dir(BY_ID_DIR).ok().and_then(|entries| {
+        entries
+            .flatten()
+            .map(|entry| entry.path())
+            .find(|link| fs::canonicalize(link).ok() == canonical)
+    });
+    by_id
+        .unwrap_or_else(|| path.to_path_buf())
+        .display()
+        .to_string()
+}
+
+/// Read `idVendor`/`idProduct` from the USB device behind a V4L2 node.
+///
+/// `<sysfs>/device` is the USB *interface*; its parent holds the ids.
+fn usb_ids(sysfs: &Path) -> Option<(u16, u16)> {
+    let usb = usb_device_sysfs(sysfs)?;
+    let vendor = read_trimmed(&usb.join("idVendor"))?;
+    let product = read_trimmed(&usb.join("idProduct"))?;
+    Some((
+        u16::from_str_radix(&vendor, 16).ok()?,
+        u16::from_str_radix(&product, 16).ok()?,
+    ))
+}
+
+/// USB `iSerialNumber` from the parent USB device, when present and non-empty.
+fn usb_serial(sysfs: &Path) -> Option<String> {
+    let usb = usb_device_sysfs(sysfs)?;
+    let serial = read_trimmed(&usb.join("serial"))?;
+    let serial = serial.trim();
+    // Kernel placeholder when the descriptor has no iSerialNumber.
+    if serial.is_empty() || serial == "0" {
+        return None;
+    }
+    Some(serial.to_string())
+}
+
+/// Sysfs directory of the USB *device* behind a V4L2 node (parent of the
+/// interface entry at `<sysfs>/device`).
+fn usb_device_sysfs(sysfs: &Path) -> Option<PathBuf> {
+    fs::canonicalize(sysfs.join("device").join("..")).ok()
+}
+
+/// Whether the node serves video capture, i.e. enumerates at least one capture
+/// format. Metadata nodes open fine but enumerate none.
+fn is_capture_node(dev_path: &Path) -> bool {
+    Device::with_path(dev_path)
+        .and_then(|device| device.enum_formats())
+        .is_ok_and(|formats| !formats.is_empty())
+}
+
+/// Largest frame size across all formats, and the highest frame rate offered
+/// at any size. Both are `None` when the driver reports only stepwise or
+/// continuous ranges, which carry no single "max" worth showing.
+fn max_format(device: &Device) -> (Option<(u32, u32)>, Option<u32>) {
+    let Ok(formats) = device.enum_formats() else {
+        return (None, None);
+    };
+
+    let mut max_resolution: Option<(u32, u32)> = None;
+    let mut max_fps: Option<u32> = None;
+
+    for format in formats {
+        let Ok(sizes) = device.enum_framesizes(format.fourcc) else {
+            continue;
+        };
+        for size in sizes {
+            for discrete in size.size.to_discrete() {
+                let candidate = (discrete.width, discrete.height);
+                if max_resolution.is_none_or(|(w, h)| {
+                    u64::from(candidate.0) * u64::from(candidate.1) > u64::from(w) * u64::from(h)
+                }) {
+                    max_resolution = Some(candidate);
+                }
+                if let Some(fps) = max_discrete_fps(device, format.fourcc, candidate) {
+                    max_fps = Some(max_fps.map_or(fps, |best: u32| best.max(fps)));
+                }
+            }
+        }
+    }
+
+    (max_resolution, max_fps)
+}
+
+/// Highest discrete frame rate the driver offers for one format and size.
+///
+/// Intervals are periods (seconds per frame), so the highest rate is the
+/// smallest interval. Stepwise/continuous ranges are skipped — they describe a
+/// span rather than an offered rate — as are zero-numerator entries, which
+/// would divide by zero.
+fn max_discrete_fps(device: &Device, fourcc: FourCC, size: (u32, u32)) -> Option<u32> {
+    let intervals = device.enum_frameintervals(fourcc, size.0, size.1).ok()?;
+    intervals
+        .into_iter()
+        .filter_map(|interval| match interval.interval {
+            FrameIntervalEnum::Discrete(fraction) if fraction.numerator > 0 => {
+                Some(fraction.denominator / fraction.numerator)
+            }
+            _ => None,
+        })
+        .max()
+}
+
+/// Read a sysfs attribute, trimming the trailing newline the kernel appends.
+fn read_trimmed(path: &Path) -> Option<String> {
+    fs::read_to_string(path)
+        .ok()
+        .map(|text| text.trim().to_string())
+}
diff --git a/crates/openlogi-camera/src/macos.rs b/crates/openlogi-camera/src/macos.rs
new file mode 100644
index 0000000000000000000000000000000000000000..a8351830ff63df0511a8713eb710e015ae9f723c
--- /dev/null
+++ b/crates/openlogi-camera/src/macos.rs
@@ -0,0 +1,223 @@
+//! AVFoundation-backed camera enumeration.
+//!
+//! `+[AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo]` returns every
+//! video-capable capture device macOS knows about; for each we read the same
+//! `localizedName` / `uniqueID` / `modelID` strings `system_profiler
+//! SPCameraDataType` reports, plus the device's supported formats (resolution +
+//! frame rate). Vendor parsing + the Logitech filter live in the
+//! platform-independent parent module.
+//!
+//! All of this is metadata — no capture session is opened, so no Camera
+//! permission is required.
+//!
+//! FFI is `objc2` (matching the rest of the workspace's ObjC surface): the
+//! dynamic `AVCaptureDevice` classes aren't in a typed framework crate, so this
+//! uses the `objc2` runtime (`AnyClass::get` + `msg_send!`) like
+//! `platform/permissions.rs`. There is no long-lived ownership here — every
+//! object AVFoundation hands back is autoreleased and copied into an owned Rust
+//! value before the enclosing [`autoreleasepool`] drains — so no `Retained<T>`
+//! is needed (an off-run-loop caller thread has no pool of its own).
+
+#![expect(
+    unsafe_code,
+    reason = "AVFoundation (AVCaptureDevice) camera-enumeration FFI"
+)]
+
+use std::ffi::CStr;
+use std::os::raw::c_char;
+
+use objc2::encode::{Encoding, RefEncode};
+use objc2::msg_send;
+use objc2::rc::autoreleasepool;
+use objc2::runtime::{AnyClass, AnyObject};
+
+/// Raw camera metadata as reported by `AVCaptureDevice`, before vendor parsing.
+pub(crate) struct RawCamera {
+    pub name: String,
+    pub unique_id: String,
+    pub model_id: String,
+    /// Largest supported frame size, `(0, 0)` if none was reported.
+    pub max_width: u32,
+    pub max_height: u32,
+    /// Highest supported frame rate (fps) at any format, `0` if none.
+    pub max_fps: u32,
+}
+
+// `AVMediaTypeVideo` is an `NSString` constant exported by AVFoundation; the
+// framework must be linked for it and the `AVCaptureDevice` class to resolve.
+#[link(name = "AVFoundation", kind = "framework")]
+unsafe extern "C" {
+    static AVMediaTypeVideo: *const AnyObject;
+}
+
+#[repr(C)]
+struct CMVideoDimensions {
+    width: i32,
+    height: i32,
+}
+
+/// Opaque `CMFormatDescriptionRef`. `AVCaptureDeviceFormat.formatDescription`
+/// hands back a CoreMedia handle, not an Objective-C object, so it needs its own
+/// type encoding: objc2 verifies msg_send return types against the runtime and
+/// panics if we claim `AnyObject` (`@`) for what CoreMedia reports as
+/// `^{opaqueCMFormatDescription=}`.
+#[repr(C)]
+struct CMFormatDescription {
+    _private: [u8; 0],
+}
+
+// SAFETY: only ever handled behind a pointer (a `CMFormatDescriptionRef`); the
+// encoding mirrors CoreMedia's `^{opaqueCMFormatDescription=}`.
+unsafe impl RefEncode for CMFormatDescription {
+    const ENCODING_REF: Encoding =
+        Encoding::Pointer(&Encoding::Struct("opaqueCMFormatDescription", &[]));
+}
+
+#[link(name = "CoreMedia", kind = "framework")]
+unsafe extern "C" {
+    fn CMVideoFormatDescriptionGetDimensions(desc: *mut CMFormatDescription) -> CMVideoDimensions;
+}
+
+/// Enumerate every video `AVCaptureDevice`, as raw metadata. The Logitech
+/// filter is applied by the caller in `lib.rs`.
+pub(crate) fn enumerate() -> Vec<RawCamera> {
+    let Some(device_cls) = AnyClass::get(c"AVCaptureDevice") else {
+        return Vec::new();
+    };
+
+    // An explicit pool brackets the work: the returned array and its devices are
+    // autoreleased, and a caller thread with no run loop drains none on its own.
+    // Every string is copied into an owned `String` before the pool drops.
+    autoreleasepool(|_| {
+        // SAFETY: `AVCaptureDevice` exists once AVFoundation is linked. Every
+        // message uses a documented selector and matching types; `AVMediaTypeVideo`
+        // is the framework's exported `NSString` constant.
+        unsafe {
+            let devices: *mut AnyObject =
+                msg_send![device_cls, devicesWithMediaType: AVMediaTypeVideo];
+
+            let mut out = Vec::new();
+            if !devices.is_null() {
+                let count: usize = msg_send![devices, count];
+                out.reserve(count);
+                for i in 0..count {
+                    let device: *mut AnyObject = msg_send![devices, objectAtIndex: i];
+                    if device.is_null() {
+                        continue;
+                    }
+                    let name_obj: *mut AnyObject = msg_send![device, localizedName];
+                    let uid_obj: *mut AnyObject = msg_send![device, uniqueID];
+                    let model_obj: *mut AnyObject = msg_send![device, modelID];
+                    if let (Some(name), Some(unique_id), Some(model_id)) =
+                        (nsstring(name_obj), nsstring(uid_obj), nsstring(model_obj))
+                    {
+                        let (max_width, max_height, max_fps) = best_format(device);
+                        out.push(RawCamera {
+                            name,
+                            unique_id,
+                            model_id,
+                            max_width,
+                            max_height,
+                            max_fps,
+                        });
+                    }
+                }
+            }
+            out
+        }
+    })
+}
+
+/// Largest `(width, height, max_fps)` among the device's supported formats, or
+/// `(0, 0, 0)` when none are reported. Reads format metadata only — no capture
+/// session, so no Camera permission is needed.
+fn best_format(device: *mut AnyObject) -> (u32, u32, u32) {
+    // SAFETY: `device` is a valid `AVCaptureDevice`; `formats` is an autoreleased
+    // `NSArray` of `AVCaptureDeviceFormat`, each exposing a `CMFormatDescription`
+    // and frame-rate ranges via documented selectors.
+    unsafe {
+        let formats: *mut AnyObject = msg_send![device, formats];
+        if formats.is_null() {
+            return (0, 0, 0);
+        }
+        let count: usize = msg_send![formats, count];
+        let mut best = (0u32, 0u32, 0u32);
+        for i in 0..count {
+            let format: *mut AnyObject = msg_send![formats, objectAtIndex: i];
+            if format.is_null() {
+                continue;
+            }
+            let desc: *mut CMFormatDescription = msg_send![format, formatDescription];
+            if desc.is_null() {
+                continue;
+            }
+            let dims = CMVideoFormatDescriptionGetDimensions(desc);
+            let w = u32::try_from(dims.width).unwrap_or(0);
+            let h = u32::try_from(dims.height).unwrap_or(0);
+            let fps = max_frame_rate(format);
+            let area = u64::from(w) * u64::from(h);
+            let best_area = u64::from(best.0) * u64::from(best.1);
+            if area > best_area || (w == best.0 && h == best.1 && fps > best.2) {
+                best = (w, h, fps);
+            }
+        }
+        best
+    }
+}
+
+/// Highest `maxFrameRate` across a format's `videoSupportedFrameRateRanges`.
+fn max_frame_rate(format: *mut AnyObject) -> u32 {
+    // SAFETY: documented selectors on a valid `AVCaptureDeviceFormat` /
+    // `AVFrameRateRange`; `maxFrameRate` returns a `double`.
+    unsafe {
+        let ranges: *mut AnyObject = msg_send![format, videoSupportedFrameRateRanges];
+        if ranges.is_null() {
+            return 0;
+        }
+        let count: usize = msg_send![ranges, count];
+        let mut max = 0.0f64;
+        for i in 0..count {
+            let range: *mut AnyObject = msg_send![ranges, objectAtIndex: i];
+            if range.is_null() {
+                continue;
+            }
+            let r: f64 = msg_send![range, maxFrameRate];
+            if r > max {
+                max = r;
+            }
+        }
+        round_fps(max)
+    }
+}
+
+/// Round a frame rate to the nearest whole fps (so 59.94 reads as 60).
+#[allow(
+    clippy::cast_possible_truncation,
+    clippy::cast_sign_loss,
+    reason = "fps is rounded, finite, and clamped to a small non-negative range"
+)]
+fn round_fps(rate: f64) -> u32 {
+    if rate.is_finite() && rate > 0.0 {
+        rate.round() as u32
+    } else {
+        0
+    }
+}
+
+/// Copy an `NSString` into an owned Rust `String`. `None` for a null pointer or
+/// non-UTF-8 contents.
+fn nsstring(s: *mut AnyObject) -> Option<String> {
+    if s.is_null() {
+        return None;
+    }
+    // SAFETY: `s` is a non-null `NSString`; `UTF8String` yields a NUL-terminated
+    // C string valid for the lifetime of the (autoreleased) string, which we
+    // copy out of immediately.
+    unsafe {
+        let utf8: *const c_char = msg_send![s, UTF8String];
+        if utf8.is_null() {
+            return None;
+        }
+        Some(CStr::from_ptr(utf8).to_string_lossy().into_owned())
+    }
+}
diff --git a/crates/openlogi-camera/src/uvc.rs b/crates/openlogi-camera/src/uvc.rs
new file mode 100644
index 0000000000000000000000000000000000000000..0d38193db5f65cadb4e29c60d300f223ff70b653
--- /dev/null
+++ b/crates/openlogi-camera/src/uvc.rs
@@ -0,0 +1,975 @@
+//! Device-level UVC Processing-Unit controls (brightness/contrast/…) over IOKit.
+//!
+//! These are *not* AVFoundation settings: they're USB Video Class control
+//! transfers to the camera's Processing Unit, so a change lands in the camera's
+//! own registers and is seen by every app — Google Meet, Zoom, OBS — not just
+//! our preview. This is the same mechanism `uvc-util` and "Webcam Settings" use,
+//! and it works while the camera is streaming because the request rides the
+//! default control endpoint, which the streaming driver does not own.
+//!
+//! Flow: match the USB device by vendor/product id (disambiguating on the
+//! AVFoundation `unique_id`'s location id when several identical cameras are
+//! attached), open it via the IOKit `IOUSBDeviceInterface` plug-in, parse the
+//! configuration descriptor for the VideoControl interface number and the
+//! Processing-Unit id, then issue UVC `GET_*`/`SET_CUR` requests.
+
+#![expect(
+    unsafe_code,
+    reason = "IOKit USB (IOUSBDeviceInterface) control-transfer FFI for UVC Processing-Unit controls"
+)]
+#![allow(
+    clippy::cast_possible_truncation,
+    clippy::cast_possible_wrap,
+    clippy::cast_sign_loss,
+    reason = "UVC payloads are bounded 16-bit values copied verbatim"
+)]
+
+use std::ffi::{CString, c_void};
+use std::ptr;
+
+/// Which UVC entity a control request addresses: the Camera Terminal (lens:
+/// zoom/focus/exposure) or the Processing Unit (image: brightness/…).
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+enum Unit {
+    CameraTerminal,
+    Processing,
+}
+
+pub use crate::controls::{
+    AutoState, AutoToggle, CameraControl, CameraState, ControlError, ControlRange,
+};
+
+impl CameraControl {
+    fn unit(self) -> Unit {
+        match self {
+            Self::Zoom | Self::Focus | Self::Exposure => Unit::CameraTerminal,
+            _ => Unit::Processing,
+        }
+    }
+
+    /// UVC control selector (Camera Terminal §A.9.4, Processing Unit §A.9.5).
+    #[allow(
+        clippy::match_same_arms,
+        reason = "Focus (CT) and Tint (PU) share 0x06 by coincidence — they address different units"
+    )]
+    fn selector(self) -> u16 {
+        match self {
+            Self::Zoom => 0x0B,         // CT_ZOOM_ABSOLUTE_CONTROL
+            Self::Focus => 0x06,        // CT_FOCUS_ABSOLUTE_CONTROL
+            Self::Exposure => 0x04,     // CT_EXPOSURE_TIME_ABSOLUTE_CONTROL
+            Self::Brightness => 0x02,   // PU_BRIGHTNESS_CONTROL
+            Self::Contrast => 0x03,     // PU_CONTRAST_CONTROL
+            Self::Saturation => 0x07,   // PU_SATURATION_CONTROL
+            Self::Sharpness => 0x08,    // PU_SHARPNESS_CONTROL
+            Self::WhiteBalance => 0x0A, // PU_WHITE_BALANCE_TEMPERATURE_CONTROL
+            Self::Tint => 0x06,         // PU_HUE_CONTROL
+        }
+    }
+
+    /// Payload size in bytes (exposure time is a dwExposureTimeAbsolute u32).
+    fn len(self) -> usize {
+        match self {
+            Self::Exposure => 4,
+            _ => 2,
+        }
+    }
+
+    /// Brightness and hue are signed controls; the rest are unsigned.
+    fn signed(self) -> bool {
+        matches!(self, Self::Brightness | Self::Tint)
+    }
+}
+
+impl AutoToggle {
+    fn unit(self) -> Unit {
+        match self {
+            Self::Focus | Self::Exposure => Unit::CameraTerminal,
+            Self::WhiteBalance => Unit::Processing,
+        }
+    }
+
+    fn selector(self) -> u16 {
+        match self {
+            Self::Focus => 0x08,        // CT_FOCUS_AUTO_CONTROL
+            Self::Exposure => 0x02,     // CT_AE_MODE_CONTROL
+            Self::WhiteBalance => 0x0B, // PU_WHITE_BALANCE_TEMPERATURE_AUTO_CONTROL
+        }
+    }
+}
+
+// ── UVC constants ────────────────────────────────────────────────────────────
+const UVC_SET_CUR: u8 = 0x01;
+const UVC_GET_CUR: u8 = 0x81;
+const UVC_GET_MIN: u8 = 0x82;
+const UVC_GET_MAX: u8 = 0x83;
+const UVC_GET_DEF: u8 = 0x87;
+// bmRequestType: class request to an interface recipient. Bit 7 = data direction.
+const RT_GET: u8 = 0xA1; // device-to-host | class | interface
+const RT_SET: u8 = 0x21; // host-to-device | class | interface
+
+const CC_VIDEO: u8 = 0x0E;
+const SC_VIDEOCONTROL: u8 = 0x01;
+const DESC_INTERFACE: u8 = 0x04;
+const DESC_CS_INTERFACE: u8 = 0x24;
+const VC_INPUT_TERMINAL: u8 = 0x02;
+const VC_PROCESSING_UNIT: u8 = 0x05;
+/// wTerminalType for a camera sensor input terminal (ITT_CAMERA).
+const ITT_CAMERA: u16 = 0x0201;
+
+// UVC AE-mode bitmap bits (CT_AE_MODE_CONTROL): everything except fully
+// manual counts as "auto" for the toggle.
+const AE_MANUAL: u8 = 0x01;
+/// Auto modes to try when enabling auto-exposure, most- to least-automatic
+/// (full auto, aperture priority, shutter priority) — cameras support subsets.
+const AE_AUTO_MODES: [u8; 3] = [0x02, 0x08, 0x04];
+
+const KIO_RETURN_SUCCESS: i32 = 0;
+
+/// Hold the process-wide seize/enumeration lock — see [`crate::USB_QUIESCE`].
+fn quiesce() -> std::sync::MutexGuard<'static, ()> {
+    crate::USB_QUIESCE
+        .lock()
+        .unwrap_or_else(std::sync::PoisonError::into_inner)
+}
+
+/// Read a control's min/max/default/current straight from the device.
+///
+/// # Errors
+/// [`ControlError::NotFound`] when no USB device matches, [`ControlError::Io`]
+/// on an IOKit failure, or [`ControlError::Unsupported`] if the camera NAKs the
+/// request.
+pub fn control_range(
+    unique_id: &str,
+    control: CameraControl,
+) -> Result<ControlRange, ControlError> {
+    let _quiesce = quiesce();
+    let dev = UsbDevice::open_for(unique_id)?;
+    let min = dev.get(control, UVC_GET_MIN)?;
+    let max = dev.get(control, UVC_GET_MAX)?;
+    let default = dev.get(control, UVC_GET_DEF)?;
+    let current = dev.get(control, UVC_GET_CUR).unwrap_or(default);
+    Ok(ControlRange {
+        min,
+        max,
+        default,
+        current,
+    })
+}
+
+/// Read every supported control in a single device-open (controls the camera
+/// NAKs are skipped). Batching keeps the device-seize count down — important
+/// while the camera is streaming.
+///
+/// # Errors
+/// [`ControlError::NotFound`] when no USB device matches.
+pub fn control_ranges(unique_id: &str) -> Result<Vec<(CameraControl, ControlRange)>, ControlError> {
+    Ok(read_camera_state(unique_id)?.controls)
+}
+
+/// Read every supported control range *and* auto-toggle state in a single
+/// device-open — what the GUI controls panel builds itself from.
+///
+/// # Errors
+/// [`ControlError::NotFound`] when no USB device matches.
+pub fn read_camera_state(unique_id: &str) -> Result<CameraState, ControlError> {
+    let _quiesce = quiesce();
+    let dev = UsbDevice::open_for(unique_id)?;
+    let mut state = CameraState::default();
+    for control in CameraControl::ALL {
+        if let (Ok(min), Ok(max), Ok(default)) = (
+            dev.get(control, UVC_GET_MIN),
+            dev.get(control, UVC_GET_MAX),
+            dev.get(control, UVC_GET_DEF),
+        ) {
+            let current = dev.get(control, UVC_GET_CUR).unwrap_or(default);
+            state.controls.push((
+                control,
+                ControlRange {
+                    min,
+                    max,
+                    default,
+                    current,
+                },
+            ));
+        }
+    }
+    for toggle in AutoToggle::ALL {
+        if let (Ok(current), Ok(default)) = (
+            dev.get_auto(toggle, UVC_GET_CUR),
+            dev.get_auto(toggle, UVC_GET_DEF),
+        ) {
+            state.autos.push((toggle, AutoState { current, default }));
+        }
+    }
+    Ok(state)
+}
+
+/// Write a control's current value to the device. Persists in the camera's
+/// registers, so other apps observe it too.
+///
+/// # Errors
+/// As [`control_range`].
+pub fn set_control(
+    unique_id: &str,
+    control: CameraControl,
+    value: i32,
+) -> Result<(), ControlError> {
+    let _quiesce = quiesce();
+    let dev = UsbDevice::open_for(unique_id)?;
+    dev.set(control, value)
+}
+
+/// Switch an auto mode (focus / exposure / white balance) on or off.
+///
+/// # Errors
+/// As [`control_range`].
+pub fn set_auto(unique_id: &str, toggle: AutoToggle, on: bool) -> Result<(), ControlError> {
+    let _quiesce = quiesce();
+    let dev = UsbDevice::open_for(unique_id)?;
+    dev.set_auto(toggle, on)
+}
+
+/// Apply a batch of auto toggles and control values in a single device-open —
+/// how profiles and saved-state reapplication write, so the seize count stays
+/// at one no matter how many controls change. Autos land first so a manual
+/// value isn't rejected by a still-armed auto mode. Every write is attempted
+/// (one rejection doesn't abandon the rest), but any failure surfaces so
+/// callers never persist or display a batch the hardware didn't take.
+///
+/// # Errors
+/// [`ControlError::NotFound`] when no USB device matches; otherwise the first
+/// per-write error after attempting the whole batch.
+pub fn apply_settings(
+    unique_id: &str,
+    autos: &[(AutoToggle, bool)],
+    values: &[(CameraControl, i32)],
+) -> Result<(), ControlError> {
+    let _quiesce = quiesce();
+    let dev = UsbDevice::open_for(unique_id)?;
+    let mut first_err = None;
+    for (toggle, on) in autos {
+        if let Err(e) = dev.set_auto(*toggle, *on) {
+            first_err.get_or_insert(e);
+        }
+    }
+    for (control, value) in values {
+        if let Err(e) = dev.set(*control, *value) {
+            first_err.get_or_insert(e);
+        }
+    }
+    first_err.map_or(Ok(()), Err)
+}
+
+// ── AVFoundation unique-id → USB location id ─────────────────────────────────
+// macOS UVC `uniqueID`s are `<location hex><vid %04x><pid %04x>` — but the
+// location comes out *unpadded* (a StreamCam on bus 0x01123000 yields
+// `0x1123000046d0893`, 15 digits). So the location is everything **except**
+// the trailing 8 vid+pid digits; taking a fixed leading 8 would swallow a
+// nibble of the vid and shift the location. Only used to pick between two
+// identical cameras; matching is primarily by vendor id.
+pub(crate) fn location_hint(unique_id: &str) -> Option<u32> {
+    let hex = unique_id.strip_prefix("0x").unwrap_or(unique_id);
+    let location = hex.get(..hex.len().checked_sub(8)?)?;
+    if location.is_empty() {
+        return None;
+    }
+    u32::from_str_radix(location, 16).ok()
+}
+
+/// USB `iSerialNumber` for every attached `IOUSBDevice`, keyed by location id.
+///
+/// Read from the IORegistry only — no device open — so enumeration can prefer
+/// the port-stable serial for config keys without racing a control seize.
+pub(crate) fn usb_serials_by_location() -> std::collections::HashMap<u32, String> {
+    use std::collections::HashMap;
+
+    let mut out = HashMap::new();
+    let Ok(class) = CString::new("IOUSBDevice") else {
+        return out;
+    };
+    // SAFETY: matching dict is consumed by GetMatchingServices; each service
+    // is released after we read its registry properties.
+    unsafe {
+        let matching = IOServiceMatching(class.as_ptr());
+        if matching.is_null() {
+            return out;
+        }
+        let mut iter: IoIterator = 0;
+        if IOServiceGetMatchingServices(kIOMainPortDefault, matching, &raw mut iter)
+            != KIO_RETURN_SUCCESS
+        {
+            return out;
+        }
+        let key = cf_string("USB Serial Number");
+        loop {
+            let service = IOIteratorNext(iter);
+            if service == 0 {
+                break;
+            }
+            if let Some((location, serial)) = registry_location_and_serial(service, key) {
+                out.entry(location).or_insert(serial);
+            }
+            IOObjectRelease(service);
+        }
+        if !key.is_null() {
+            CFRelease(key);
+        }
+        IOObjectRelease(iter);
+    }
+    out
+}
+
+/// Location id + USB serial from an `IOUSBDevice` service, without opening it.
+unsafe fn registry_location_and_serial(
+    service: IoService,
+    serial_key: *const c_void,
+) -> Option<(u32, String)> {
+    unsafe {
+        // Prefer the USB device interface for location (matches control open);
+        // fall back to the registry number property when the plug-in is busy.
+        let location = device_location_id(service).or_else(|| {
+            let key = cf_string("locationID");
+            let loc = cf_number_u32(IORegistryEntryCreateCFProperty(
+                service,
+                key,
+                ptr::null(),
+                0,
+            ));
+            if !key.is_null() {
+                CFRelease(key);
+            }
+            loc
+        })?;
+        let serial_ref = IORegistryEntryCreateCFProperty(service, serial_key, ptr::null(), 0);
+        let serial = cf_string_value(serial_ref)?;
+        if serial.is_empty() {
+            return None;
+        }
+        Some((location, serial))
+    }
+}
+
+/// Location id via a transient `IOUSBDeviceInterface` (no open/seize).
+unsafe fn device_location_id(service: IoService) -> Option<u32> {
+    unsafe {
+        let user_client = make_uuid(&KIO_USB_DEVICE_USER_CLIENT_TYPE_ID);
+        let plugin_type = make_uuid(&KIO_CF_PLUGIN_INTERFACE_ID);
+        let mut plugin: *mut *mut PlugInInterface = ptr::null_mut();
+        let mut score: i32 = 0;
+        let rc = IOCreatePlugInInterfaceForService(
+            service,
+            user_client,
+            plugin_type,
+            &raw mut plugin,
+            &raw mut score,
+        );
+        CFRelease(user_client);
+        CFRelease(plugin_type);
+        if rc != KIO_RETURN_SUCCESS || plugin.is_null() {
+            return None;
+        }
+        let dev_uuid_ref = make_uuid(&KIO_USB_DEVICE_INTERFACE_ID);
+        let dev_uuid = CFUUIDGetUUIDBytes(dev_uuid_ref);
+        CFRelease(dev_uuid_ref);
+        let mut dev_ptr: *mut c_void = ptr::null_mut();
+        let qrc = ((**plugin).query_interface)(plugin.cast::<c_void>(), dev_uuid, &raw mut dev_ptr);
+        IODestroyPlugInInterface(plugin);
+        if qrc != 0 || dev_ptr.is_null() {
+            return None;
+        }
+        let dev = dev_ptr.cast::<*mut UsbDeviceInterface>();
+        let mut location: u32 = 0;
+        let ok = ((**dev).get_location_id)(dev.cast::<c_void>(), &raw mut location)
+            == KIO_RETURN_SUCCESS;
+        ((**dev).release)(dev.cast::<c_void>());
+        ok.then_some(location)
+    }
+}
+
+fn cf_string(s: &str) -> *const c_void {
+    let Ok(c) = CString::new(s) else {
+        return ptr::null();
+    };
+    // SAFETY: UTF-8 C string; returned CFString is owned by the caller.
+    unsafe { CFStringCreateWithCString(ptr::null(), c.as_ptr(), K_CF_STRING_ENCODING_UTF8) }
+}
+
+unsafe fn cf_string_value(cf: *const c_void) -> Option<String> {
+    if cf.is_null() {
+        return None;
+    }
+    unsafe {
+        if CFGetTypeID(cf) != CFStringGetTypeID() {
+            CFRelease(cf);
+            return None;
+        }
+        let len = CFStringGetLength(cf);
+        // UTF-8 worst case 4 bytes/char + NUL.
+        let cap = usize::try_from(len).ok()?.checked_mul(4)?.checked_add(1)?;
+        let mut buf = vec![0u8; cap];
+        let ok = CFStringGetCString(
+            cf,
+            buf.as_mut_ptr().cast(),
+            isize::try_from(cap).ok()?,
+            K_CF_STRING_ENCODING_UTF8,
+        ) != 0;
+        CFRelease(cf);
+        if !ok {
+            return None;
+        }
+        let nul = buf.iter().position(|&b| b == 0).unwrap_or(buf.len());
+        String::from_utf8(buf[..nul].to_vec()).ok()
+    }
+}
+
+unsafe fn cf_number_u32(cf: *const c_void) -> Option<u32> {
+    if cf.is_null() {
+        return None;
+    }
+    unsafe {
+        if CFGetTypeID(cf) != CFNumberGetTypeID() {
+            CFRelease(cf);
+            return None;
+        }
+        let mut value: u32 = 0;
+        let ok = CFNumberGetValue(cf, K_CF_NUMBER_SINT32_TYPE, (&raw mut value).cast()) != 0;
+        CFRelease(cf);
+        ok.then_some(value)
+    }
+}
+
+// ── IOKit / CoreFoundation FFI ───────────────────────────────────────────────
+type IoReturn = i32;
+type IoService = u32;
+type IoIterator = u32;
+type CfUuidRef = *const c_void;
+
+#[repr(C)]
+#[derive(Clone, Copy)]
+struct CfUuidBytes {
+    bytes: [u8; 16],
+}
+
+#[repr(C)]
+struct IoUsbDevRequest {
+    bm_request_type: u8,
+    b_request: u8,
+    w_value: u16,
+    w_index: u16,
+    w_length: u16,
+    p_data: *mut c_void,
+    w_len_done: u32,
+}
+
+// IOCFPlugInInterface — we only need the IUnknown head (QueryInterface/Release).
+#[repr(C)]
+struct PlugInInterface {
+    _reserved: *mut c_void,
+    query_interface: extern "C" fn(*mut c_void, CfUuidBytes, *mut *mut c_void) -> i32,
+    add_ref: extern "C" fn(*mut c_void) -> u32,
+    release: extern "C" fn(*mut c_void) -> u32,
+}
+
+// IOUSBDeviceInterface vtable (IOUSBLib.h). Slots we don't call are typed as
+// opaque pointers so the offsets of the ones we *do* call stay correct.
+#[repr(C)]
+struct UsbDeviceInterface {
+    _reserved: *mut c_void,
+    query_interface: extern "C" fn(*mut c_void, CfUuidBytes, *mut *mut c_void) -> i32,
+    add_ref: extern "C" fn(*mut c_void) -> u32,
+    release: extern "C" fn(*mut c_void) -> u32,
+    create_device_async_event_source: *const c_void,
+    get_device_async_event_source: *const c_void,
+    create_device_async_port: *const c_void,
+    get_device_async_port: *const c_void,
+    usb_device_open: extern "C" fn(*mut c_void) -> IoReturn,
+    usb_device_close: extern "C" fn(*mut c_void) -> IoReturn,
+    get_device_class: *const c_void,
+    get_device_sub_class: *const c_void,
+    get_device_protocol: *const c_void,
+    get_device_vendor: extern "C" fn(*mut c_void, *mut u16) -> IoReturn,
+    get_device_product: extern "C" fn(*mut c_void, *mut u16) -> IoReturn,
+    get_device_release_number: *const c_void,
+    get_device_address: *const c_void,
+    get_device_bus_power_available: *const c_void,
+    get_device_speed: *const c_void,
+    get_number_of_configurations: extern "C" fn(*mut c_void, *mut u8) -> IoReturn,
+    get_location_id: extern "C" fn(*mut c_void, *mut u32) -> IoReturn,
+    get_configuration_descriptor_ptr: extern "C" fn(*mut c_void, u8, *mut *const u8) -> IoReturn,
+    get_configuration: *const c_void,
+    set_configuration: *const c_void,
+    get_bus_frame_number: *const c_void,
+    reset_device: *const c_void,
+    device_request: extern "C" fn(*mut c_void, *mut IoUsbDevRequest) -> IoReturn,
+    device_request_async: *const c_void,
+    create_interface_iterator: *const c_void,
+    // IOUSBDeviceInterface182 adds OpenSeize: open even while the kernel video
+    // driver holds the device for streaming, so controls work during a preview.
+    usb_device_open_seize: extern "C" fn(*mut c_void) -> IoReturn,
+    // remaining methods unused
+}
+
+#[link(name = "IOKit", kind = "framework")]
+unsafe extern "C" {
+    static kIOMainPortDefault: u32;
+    fn IOServiceMatching(name: *const i8) -> *mut c_void;
+    fn IOServiceGetMatchingServices(
+        main_port: u32,
+        matching: *mut c_void,
+        existing: *mut IoIterator,
+    ) -> IoReturn;
+    fn IOIteratorNext(iterator: IoIterator) -> IoService;
+    fn IOObjectRelease(object: u32) -> IoReturn;
+    fn IOCreatePlugInInterfaceForService(
+        service: IoService,
+        plugin_type: CfUuidRef,
+        interface_type: CfUuidRef,
+        plug_in: *mut *mut *mut PlugInInterface,
+        score: *mut i32,
+    ) -> IoReturn;
+    fn IODestroyPlugInInterface(interface: *mut *mut PlugInInterface) -> IoReturn;
+    fn IORegistryEntryCreateCFProperty(
+        entry: IoService,
+        key: *const c_void,
+        allocator: *const c_void,
+        options: u32,
+    ) -> *const c_void;
+}
+
+#[link(name = "CoreFoundation", kind = "framework")]
+unsafe extern "C" {
+    fn CFUUIDCreateFromUUIDBytes(allocator: *const c_void, bytes: CfUuidBytes) -> CfUuidRef;
+    fn CFUUIDGetUUIDBytes(uuid: CfUuidRef) -> CfUuidBytes;
+    fn CFRelease(cf: *const c_void);
+    fn CFStringCreateWithCString(
+        allocator: *const c_void,
+        c_str: *const i8,
+        encoding: u32,
+    ) -> *const c_void;
+    fn CFStringGetTypeID() -> usize;
+    fn CFNumberGetTypeID() -> usize;
+    fn CFGetTypeID(cf: *const c_void) -> usize;
+    fn CFStringGetLength(s: *const c_void) -> isize;
+    fn CFStringGetCString(s: *const c_void, buf: *mut i8, buffer_size: isize, encoding: u32) -> u8;
+    fn CFNumberGetValue(number: *const c_void, the_type: i32, value_ptr: *mut c_void) -> u8;
+}
+
+/// `kCFStringEncodingUTF8`.
+const K_CF_STRING_ENCODING_UTF8: u32 = 0x0800_0100;
+/// `kCFNumberSInt32Type` — locationID is a 32-bit number in the registry.
+const K_CF_NUMBER_SINT32_TYPE: i32 = 3;
+
+// IOUSBLib UUIDs, as raw bytes (UUID order).
+const KIO_USB_DEVICE_USER_CLIENT_TYPE_ID: [u8; 16] = [
+    0x9d, 0xc7, 0xb7, 0x80, 0x9e, 0xc0, 0x11, 0xd4, 0xa5, 0x4f, 0x00, 0x0a, 0x27, 0x05, 0x28, 0x61,
+];
+const KIO_CF_PLUGIN_INTERFACE_ID: [u8; 16] = [
+    0xc2, 0x44, 0xe8, 0x58, 0x10, 0x9c, 0x11, 0xd4, 0x91, 0xd4, 0x00, 0x50, 0xe4, 0xc6, 0x42, 0x6f,
+];
+// kIOUSBDeviceInterfaceID182 — the first version exposing USBDeviceOpenSeize.
+const KIO_USB_DEVICE_INTERFACE_ID: [u8; 16] = [
+    0x15, 0x2f, 0xc4, 0x96, 0x48, 0x91, 0x11, 0xd5, 0x9d, 0x52, 0x00, 0x0a, 0x27, 0x80, 0x1e, 0x86,
+];
+
+/// An opened IOKit USB device interface, with its UVC topology resolved. Closes
+/// and releases on drop.
+struct UsbDevice {
+    dev: *mut *mut UsbDeviceInterface,
+    vc_interface: u8,
+    /// Processing-Unit id (image controls).
+    unit_id: u8,
+    /// Camera (input) Terminal id (lens controls); `None` when the descriptor
+    /// lists no camera terminal — lens controls then report `Unsupported`.
+    terminal_id: Option<u8>,
+}
+
+impl UsbDevice {
+    /// Find and open the Logitech USB device backing `unique_id`, resolving its
+    /// VideoControl interface and Processing-Unit id.
+    fn open_for(unique_id: &str) -> Result<Self, ControlError> {
+        let want_vid = crate::LOGITECH_VID;
+        // The pid is the trailing 4 hex of the uniqueID's id portion; we don't
+        // strictly need it for matching (we open every Logitech UVC device and
+        // pick the one whose location matches), but parse it as a fallback.
+        let want_location = location_hint(unique_id);
+
+        // SAFETY: standard IOKit device enumeration; each retained object is
+        // released, and the matching dictionary is consumed by the call.
+        unsafe {
+            let class = CString::new("IOUSBDevice").map_err(|e| ControlError::Io(e.to_string()))?;
+            let matching = IOServiceMatching(class.as_ptr());
+            if matching.is_null() {
+                return Err(ControlError::Io("IOServiceMatching".into()));
+            }
+            let mut iter: IoIterator = 0;
+            if IOServiceGetMatchingServices(kIOMainPortDefault, matching, &raw mut iter)
+                != KIO_RETURN_SUCCESS
+            {
+                return Err(ControlError::Io("IOServiceGetMatchingServices".into()));
+            }
+
+            let mut chosen: Option<Opened> = None;
+            // Count Logitech cameras reached on the location-less path. With a
+            // parseable location only an exact match opens; without a hint (an
+            // unparseable unique id) the first Logitech camera is a best effort
+            // that is only safe when it's the *only* one — see the fail-closed
+            // check after the loop.
+            let mut vendor_candidates = 0usize;
+            loop {
+                let service = IOIteratorNext(iter);
+                if service == 0 {
+                    break;
+                }
+                match Self::try_open(service, want_vid, want_location) {
+                    Some(found) => {
+                        let exact =
+                            want_location.is_some_and(|l| found.matched_location == Some(l));
+                        IOObjectRelease(service);
+                        if exact {
+                            if let Some(prev) = chosen.take() {
+                                prev.into_device().close();
+                            }
+                            chosen = Some(found);
+                            break;
+                        } else if want_location.is_none() {
+                            vendor_candidates += 1;
+                            if chosen.is_none() {
+                                chosen = Some(found);
+                            } else {
+                                found.into_device().close();
+                            }
+                        } else {
+                            found.into_device().close();
+                        }
+                    }
+                    None => {
+                        IOObjectRelease(service);
+                    }
+                }
+            }
+            IOObjectRelease(iter);
+
+            // A location-less match is only unambiguous with exactly one
+            // Logitech camera attached; with two (and a unique id we couldn't
+            // parse into a USB location) we can't tell them apart, so refuse
+            // rather than write the wrong camera's registers.
+            if want_location.is_none() && vendor_candidates > 1 {
+                if let Some(dev) = chosen.take() {
+                    dev.into_device().close();
+                }
+                return Err(ControlError::Ambiguous);
+            }
+
+            chosen
+                .map(Opened::into_device)
+                .ok_or(ControlError::NotFound)
+        }
+    }
+
+    /// The entity id addressed for `unit`, or `Unsupported` when the camera's
+    /// descriptor lists no camera terminal.
+    fn entity(&self, unit: Unit) -> Result<u8, ControlError> {
+        match unit {
+            Unit::Processing => Ok(self.unit_id),
+            Unit::CameraTerminal => self.terminal_id.ok_or(ControlError::Unsupported),
+        }
+    }
+
+    /// Issue a UVC GET request (`req` = GET_MIN/MAX/DEF/CUR), returning the
+    /// control-sized little-endian value, sign-extended per the control.
+    fn get(&self, control: CameraControl, req: u8) -> Result<i32, ControlError> {
+        let entity = self.entity(control.unit())?;
+        let mut buf = [0u8; 4];
+        let len = control.len();
+        self.transfer(RT_GET, req, control.selector(), entity, &mut buf[..len])?;
+        Ok(match (len, control.signed()) {
+            (4, _) => i32::try_from(u32::from_le_bytes(buf)).unwrap_or(i32::MAX),
+            (_, true) => i32::from(i16::from_le_bytes([buf[0], buf[1]])),
+            (_, false) => i32::from(u16::from_le_bytes([buf[0], buf[1]])),
+        })
+    }
+
+    /// Issue a UVC SET_CUR request with `value` truncated to the control's size.
+    fn set(&self, control: CameraControl, value: i32) -> Result<(), ControlError> {
+        let entity = self.entity(control.unit())?;
+        let mut buf = (value as u32).to_le_bytes();
+        let len = control.len();
+        self.transfer(
+            RT_SET,
+            UVC_SET_CUR,
+            control.selector(),
+            entity,
+            &mut buf[..len],
+        )
+    }
+
+    /// Read an auto toggle (`req` = GET_CUR/GET_DEF) as a boolean. For the
+    /// AE-mode bitmap anything but fully-manual counts as auto.
+    fn get_auto(&self, toggle: AutoToggle, req: u8) -> Result<bool, ControlError> {
+        let entity = self.entity(toggle.unit())?;
+        let mut buf = [0u8; 1];
+        self.transfer(RT_GET, req, toggle.selector(), entity, &mut buf)?;
+        Ok(match toggle {
+            AutoToggle::Exposure => buf[0] != AE_MANUAL,
+            _ => buf[0] != 0,
+        })
+    }
+
+    /// Switch an auto toggle. Enabling auto-exposure tries each AE mode the
+    /// camera might support, most-automatic first.
+    fn set_auto(&self, toggle: AutoToggle, on: bool) -> Result<(), ControlError> {
+        let entity = self.entity(toggle.unit())?;
+        let selector = toggle.selector();
+        let candidates: &[u8] = match (toggle, on) {
+            (AutoToggle::Exposure, true) => &AE_AUTO_MODES,
+            (AutoToggle::Exposure, false) => &[AE_MANUAL],
+            (_, true) => &[1],
+            (_, false) => &[0],
+        };
+        let mut last = ControlError::Unsupported;
+        for &mode in candidates {
+            match self.transfer(RT_SET, UVC_SET_CUR, selector, entity, &mut [mode]) {
+                Ok(()) => return Ok(()),
+                Err(e) => last = e,
+            }
+        }
+        Err(last)
+    }
+
+    fn transfer(
+        &self,
+        request_type: u8,
+        request: u8,
+        selector: u16,
+        entity: u8,
+        data: &mut [u8],
+    ) -> Result<(), ControlError> {
+        let mut req = IoUsbDevRequest {
+            bm_request_type: request_type,
+            b_request: request,
+            w_value: selector << 8,
+            w_index: (u16::from(entity) << 8) | u16::from(self.vc_interface),
+            w_length: data.len() as u16,
+            p_data: data.as_mut_ptr().cast::<c_void>(),
+            w_len_done: 0,
+        };
+        // SAFETY: `self.dev` is a live IOUSBDeviceInterface**; DeviceRequest reads
+        // `req` and writes into the `data` buffer it points at.
+        let rc = unsafe { ((**self.dev).device_request)(self.dev.cast::<c_void>(), &raw mut req) };
+        if rc != KIO_RETURN_SUCCESS {
+            return Err(ControlError::Unsupported);
+        }
+        Ok(())
+    }
+
+    fn close(self) {
+        // Drop handles the teardown.
+        drop(self);
+    }
+}
+
+impl Drop for UsbDevice {
+    fn drop(&mut self) {
+        // SAFETY: `self.dev` is a live interface we opened; close then release it.
+        unsafe {
+            let _ = ((**self.dev).usb_device_close)(self.dev.cast::<c_void>());
+            ((**self.dev).release)(self.dev.cast::<c_void>());
+        }
+    }
+}
+
+/// A device that matched on vendor id, carrying the location id it reported so
+/// the caller can prefer an exact-location match.
+struct Opened {
+    device: UsbDevice,
+    matched_location: Option<u32>,
+}
+
+impl Opened {
+    fn into_device(self) -> UsbDevice {
+        self.device
+    }
+}
+
+impl UsbDevice {
+    /// Try to build an [`Opened`] from an `io_service_t`: query the device
+    /// interface, match the vendor id, open it, and resolve its UVC topology.
+    unsafe fn try_open(
+        service: IoService,
+        want_vid: u16,
+        _want_location: Option<u32>,
+    ) -> Option<Opened> {
+        unsafe {
+            let user_client = make_uuid(&KIO_USB_DEVICE_USER_CLIENT_TYPE_ID);
+            let plugin_type = make_uuid(&KIO_CF_PLUGIN_INTERFACE_ID);
+            let mut plugin: *mut *mut PlugInInterface = ptr::null_mut();
+            let mut score: i32 = 0;
+            let rc = IOCreatePlugInInterfaceForService(
+                service,
+                user_client,
+                plugin_type,
+                &raw mut plugin,
+                &raw mut score,
+            );
+            CFRelease(user_client);
+            CFRelease(plugin_type);
+            if rc != KIO_RETURN_SUCCESS || plugin.is_null() {
+                return None;
+            }
+
+            let dev_uuid_ref = make_uuid(&KIO_USB_DEVICE_INTERFACE_ID);
+            let dev_uuid = CFUUIDGetUUIDBytes(dev_uuid_ref);
+            CFRelease(dev_uuid_ref);
+            let mut dev_ptr: *mut c_void = ptr::null_mut();
+            let qrc =
+                ((**plugin).query_interface)(plugin.cast::<c_void>(), dev_uuid, &raw mut dev_ptr);
+            IODestroyPlugInInterface(plugin);
+            if qrc != 0 || dev_ptr.is_null() {
+                return None;
+            }
+            let dev = dev_ptr.cast::<*mut UsbDeviceInterface>();
+
+            let mut vid: u16 = 0;
+            ((**dev).get_device_vendor)(dev.cast::<c_void>(), &raw mut vid);
+            if vid != want_vid {
+                ((**dev).release)(dev.cast::<c_void>());
+                return None;
+            }
+
+            let mut location: u32 = 0;
+            let loc_ok = ((**dev).get_location_id)(dev.cast::<c_void>(), &raw mut location)
+                == KIO_RETURN_SUCCESS;
+
+            // Seize (not plain open) so a control transfer succeeds even while
+            // the camera is streaming in this or another app. Callers batch their
+            // reads/writes into one open to keep this churn low.
+            if ((**dev).usb_device_open_seize)(dev.cast::<c_void>()) != KIO_RETURN_SUCCESS {
+                ((**dev).release)(dev.cast::<c_void>());
+                return None;
+            }
+
+            let Some(topology) = video_control_topology(dev) else {
+                let _ = ((**dev).usb_device_close)(dev.cast::<c_void>());
+                ((**dev).release)(dev.cast::<c_void>());
+                return None;
+            };
+
+            Some(Opened {
+                device: UsbDevice {
+                    dev,
+                    vc_interface: topology.vc_interface,
+                    unit_id: topology.processing_unit,
+                    terminal_id: topology.camera_terminal,
+                },
+                matched_location: loc_ok.then_some(location),
+            })
+        }
+    }
+}
+
+/// The VideoControl entities a control request can address, parsed from the
+/// configuration descriptor.
+struct VcTopology {
+    vc_interface: u8,
+    processing_unit: u8,
+    camera_terminal: Option<u8>,
+}
+
+/// Parse the configuration descriptor for the VideoControl interface number,
+/// the Processing-Unit id, and the camera (input) terminal id.
+unsafe fn video_control_topology(dev: *mut *mut UsbDeviceInterface) -> Option<VcTopology> {
+    unsafe {
+        let mut num_configs: u8 = 0;
+        ((**dev).get_number_of_configurations)(dev.cast::<c_void>(), &raw mut num_configs);
+        for cfg in 0..num_configs {
+            let mut desc: *const u8 = ptr::null();
+            if ((**dev).get_configuration_descriptor_ptr)(dev.cast::<c_void>(), cfg, &raw mut desc)
+                != KIO_RETURN_SUCCESS
+                || desc.is_null()
+            {
+                continue;
+            }
+            // wTotalLength at offset 2..4 (little-endian).
+            let total = u16::from(*desc.add(2)) | (u16::from(*desc.add(3)) << 8);
+            if let Some(found) = scan_descriptors(desc, total as usize) {
+                return Some(found);
+            }
+        }
+        None
+    }
+}
+
+/// Walk a configuration descriptor blob, collecting the first VideoControl
+/// interface's Processing-Unit and camera-terminal entity ids.
+unsafe fn scan_descriptors(base: *const u8, total: usize) -> Option<VcTopology> {
+    unsafe {
+        let mut off = 0usize;
+        let mut vc_interface: Option<u8> = None;
+        let mut camera_terminal: Option<u8> = None;
+        while off + 2 <= total {
+            let len = *base.add(off) as usize;
+            if len < 2 || off + len > total {
+                break;
+            }
+            let dtype = *base.add(off + 1);
+            if dtype == DESC_INTERFACE && len >= 9 {
+                let class = *base.add(off + 5);
+                let sub = *base.add(off + 6);
+                vc_interface = (class == CC_VIDEO && sub == SC_VIDEOCONTROL)
+                    .then(|| *base.add(off + 2))
+                    .or(vc_interface);
+            } else if dtype == DESC_CS_INTERFACE && len >= 4 && vc_interface.is_some() {
+                let subtype = *base.add(off + 2);
+                // bUnitID / bTerminalID sit at offset 3 in both descriptors;
+                // an input terminal's wTerminalType (offset 4..6) must be the
+                // camera sensor — skip composite/other input terminals.
+                if subtype == VC_INPUT_TERMINAL && len >= 8 {
+                    let ttype =
+                        u16::from(*base.add(off + 4)) | (u16::from(*base.add(off + 5)) << 8);
+                    if ttype == ITT_CAMERA && camera_terminal.is_none() {
+                        camera_terminal = Some(*base.add(off + 3));
+                    }
+                } else if subtype == VC_PROCESSING_UNIT {
+                    return vc_interface.map(|vc| VcTopology {
+                        vc_interface: vc,
+                        processing_unit: *base.add(off + 3),
+                        camera_terminal,
+                    });
+                }
+            }
+            off += len;
+        }
+        None
+    }
+}
+
+unsafe fn make_uuid(bytes: &[u8; 16]) -> CfUuidRef {
+    unsafe { CFUUIDCreateFromUUIDBytes(ptr::null(), CfUuidBytes { bytes: *bytes }) }
+}
+
+#[cfg(test)]
+mod tests {
+    use super::location_hint;
+
+    /// AVFoundation prints the location id unpadded: a StreamCam on bus
+    /// 0x01123000 yields a 15-digit id whose leading run is only 7 digits.
+    /// Taking a fixed 8 would swallow a vid nibble and shift the location —
+    /// which made every control write fail closed with `NotFound` (the bug
+    /// the exact-match requirement exposed).
+    #[test]
+    fn unpadded_location_parses() {
+        assert_eq!(location_hint("0x1123000046d0893"), Some(0x0112_3000));
+    }
+
+    #[test]
+    fn padded_location_parses() {
+        assert_eq!(location_hint("0x14110000046d082d"), Some(0x1411_0000));
+    }
+
+    #[test]
+    fn too_short_ids_yield_no_hint() {
+        assert_eq!(location_hint("0x46d0893"), None);
+        assert_eq!(location_hint("46d0893"), None);
+        assert_eq!(location_hint(""), None);
+    }
+}
diff --git a/crates/openlogi-camera/src/uvc_linux.rs b/crates/openlogi-camera/src/uvc_linux.rs
new file mode 100644
index 0000000000000000000000000000000000000000..78eeee9a26867eddf7a84a65ad7f8bee247aa075
--- /dev/null
+++ b/crates/openlogi-camera/src/uvc_linux.rs
@@ -0,0 +1,452 @@
+//! UVC controls on Linux, over V4L2.
+//!
+//! The kernel's `uvcvideo` driver already speaks UVC to the camera, so this
+//! backend issues `VIDIOC_G_CTRL` / `VIDIOC_S_CTRL` against standard control
+//! ids rather than the raw Processing Unit / Camera Terminal transfers the
+//! macOS backend has to build by hand.
+//!
+//! Two V4L2 details shape the code:
+//!
+//! * **Auto-exposure is a menu, not a boolean.** `V4L2_CID_EXPOSURE_AUTO`
+//!   selects one of four modes; two count as automatic. See [`exposure_mode`].
+//! * **Batched writes can't cross a control class.** `VIDIOC_S_EXT_CTRLS`
+//!   requires every control in one call to share a class, and the controls this
+//!   crate exposes span the User (`0x0098_0000`) and Camera (`0x009a_0000`)
+//!   classes. [`apply_settings`] groups by class instead of issuing one call.
+
+use v4l::Device;
+use v4l::control::{Control, Description, Flags, Value};
+
+use crate::controls::{
+    AutoState, AutoToggle, CameraControl, CameraState, ControlError, ControlRange,
+};
+use crate::linux;
+
+/// `V4L2_CID_BRIGHTNESS` — the User control class base.
+const CID_BRIGHTNESS: u32 = 0x0098_0900;
+const CID_CONTRAST: u32 = 0x0098_0901;
+const CID_SATURATION: u32 = 0x0098_0902;
+const CID_AUTO_WHITE_BALANCE: u32 = 0x0098_090c;
+const CID_WHITE_BALANCE_TEMPERATURE: u32 = 0x0098_091a;
+const CID_SHARPNESS: u32 = 0x0098_091b;
+
+/// `V4L2_CID_EXPOSURE_AUTO` — the Camera control class base.
+const CID_EXPOSURE_AUTO: u32 = 0x009a_0901;
+const CID_EXPOSURE_ABSOLUTE: u32 = 0x009a_0902;
+const CID_FOCUS_ABSOLUTE: u32 = 0x009a_090a;
+const CID_FOCUS_AUTO: u32 = 0x009a_090c;
+const CID_ZOOM_ABSOLUTE: u32 = 0x009a_090d;
+
+/// `V4L2_CID_EXPOSURE_AUTO` menu values, in the kernel's order.
+const EXPOSURE_AUTO: i64 = 0;
+const EXPOSURE_MANUAL: i64 = 1;
+const EXPOSURE_SHUTTER_PRIORITY: i64 = 2;
+const EXPOSURE_APERTURE_PRIORITY: i64 = 3;
+
+/// The V4L2 control id backing each [`CameraControl`].
+///
+/// [`CameraControl::Tint`] has no V4L2 equivalent — UVC exposes white balance
+/// as a single colour temperature, and the component (blue/red balance) form
+/// the macOS backend uses for tint isn't a standard V4L2 control — so it
+/// reports [`ControlError::Unsupported`].
+fn control_id(control: CameraControl) -> Option<u32> {
+    Some(match control {
+        CameraControl::Zoom => CID_ZOOM_ABSOLUTE,
+        CameraControl::Focus => CID_FOCUS_ABSOLUTE,
+        CameraControl::Exposure => CID_EXPOSURE_ABSOLUTE,
+        CameraControl::Brightness => CID_BRIGHTNESS,
+        CameraControl::Contrast => CID_CONTRAST,
+        CameraControl::Saturation => CID_SATURATION,
+        CameraControl::Sharpness => CID_SHARPNESS,
+        CameraControl::WhiteBalance => CID_WHITE_BALANCE_TEMPERATURE,
+        CameraControl::Tint => return None,
+    })
+}
+
+/// The V4L2 control id backing each [`AutoToggle`].
+fn auto_id(toggle: AutoToggle) -> u32 {
+    match toggle {
+        AutoToggle::Focus => CID_FOCUS_AUTO,
+        AutoToggle::Exposure => CID_EXPOSURE_AUTO,
+        AutoToggle::WhiteBalance => CID_AUTO_WHITE_BALANCE,
+    }
+}
+
+/// Open the V4L2 node for `unique_id`.
+fn open(unique_id: &str) -> Result<Device, ControlError> {
+    let path = linux::node_for_unique_id(unique_id).ok_or(ControlError::NotFound)?;
+    Device::with_path(&path).map_err(|error| ControlError::Io(error.to_string()))
+}
+
+/// Read one control's range and current value.
+///
+/// # Errors
+/// [`ControlError::Unsupported`] when the camera doesn't expose the control.
+pub fn control_range(
+    unique_id: &str,
+    control: CameraControl,
+) -> Result<ControlRange, ControlError> {
+    let device = open(unique_id)?;
+    let id = control_id(control).ok_or(ControlError::Unsupported)?;
+    let description = describe(&device, id).ok_or(ControlError::Unsupported)?;
+    range_of(&device, &description).ok_or(ControlError::Unsupported)
+}
+
+/// Read the range of every control this camera supports, skipping the rest.
+///
+/// # Errors
+/// [`ControlError::NotFound`] when no node matches `unique_id`.
+pub fn control_ranges(unique_id: &str) -> Result<Vec<(CameraControl, ControlRange)>, ControlError> {
+    let device = open(unique_id)?;
+    let descriptions = query(&device)?;
+
+    Ok(CameraControl::ALL
+        .into_iter()
+        .filter_map(|control| {
+            let id = control_id(control)?;
+            let description = descriptions.iter().find(|d| d.id == id)?;
+            Some((control, range_of(&device, description)?))
+        })
+        .collect())
+}
+
+/// Read every supported control range and auto-toggle state in one device open.
+///
+/// # Errors
+/// [`ControlError::NotFound`] when no node matches `unique_id`.
+pub fn read_camera_state(unique_id: &str) -> Result<CameraState, ControlError> {
+    let device = open(unique_id)?;
+    let descriptions = query(&device)?;
+
+    let controls = CameraControl::ALL
+        .into_iter()
+        .filter_map(|control| {
+            let id = control_id(control)?;
+            let description = descriptions.iter().find(|d| d.id == id)?;
+            Some((control, range_of(&device, description)?))
+        })
+        .collect();
+
+    let autos = AutoToggle::ALL
+        .into_iter()
+        .filter_map(|toggle| {
+            let id = auto_id(toggle);
+            let description = descriptions.iter().find(|d| d.id == id)?;
+            let current = read_auto(&device, toggle)?;
+            let default = if toggle == AutoToggle::Exposure {
+                is_auto_mode(description.default)
+            } else {
+                description.default != 0
+            };
+            Some((toggle, AutoState { current, default }))
+        })
+        .collect();
+
+    Ok(CameraState { controls, autos })
+}
+
+/// Write one control value.
+///
+/// # Errors
+/// [`ControlError::Unsupported`] when the camera doesn't expose the control, or
+/// rejects the write because an auto mode currently owns it.
+pub fn set_control(
+    unique_id: &str,
+    control: CameraControl,
+    value: i32,
+) -> Result<(), ControlError> {
+    let device = open(unique_id)?;
+    let id = control_id(control).ok_or(ControlError::Unsupported)?;
+    write_value(&device, id, i64::from(value))
+}
+
+/// Turn one auto mode on or off.
+///
+/// # Errors
+/// [`ControlError::Unsupported`] when the camera has no such toggle.
+pub fn set_auto(unique_id: &str, toggle: AutoToggle, on: bool) -> Result<(), ControlError> {
+    let device = open(unique_id)?;
+    write_auto(&device, toggle, on)
+}
+
+/// Apply auto toggles and control values in one device open.
+///
+/// Autos are written first: a manual value is rejected while its auto mode
+/// still owns the control, so dragging an auto-gated slider must clear the
+/// mode before the value lands. Controls are then batched per class, since
+/// `VIDIOC_S_EXT_CTRLS` refuses a mixed-class call.
+///
+/// Unsupported controls are skipped rather than failing the batch — a profile
+/// saved against a Brio shouldn't fail wholesale when applied to a C270.
+///
+/// # Errors
+/// [`ControlError::NotFound`] when no node matches `unique_id`; the first I/O
+/// error otherwise.
+pub fn apply_settings(
+    unique_id: &str,
+    autos: &[(AutoToggle, bool)],
+    values: &[(CameraControl, i32)],
+) -> Result<(), ControlError> {
+    let device = open(unique_id)?;
+    let supported = query(&device)?;
+    let has = |id: u32| supported.iter().any(|d| d.id == id);
+
+    for &(toggle, on) in autos {
+        if has(auto_id(toggle)) {
+            write_auto(&device, toggle, on)?;
+        }
+    }
+
+    let writable: Vec<(u32, i64)> = values
+        .iter()
+        .filter(|&&(control, _)| !gated_by_enabled_auto(control, autos))
+        .filter_map(|&(control, value)| {
+            let id = control_id(control)?;
+            has(id).then_some((id, i64::from(value)))
+        })
+        .collect();
+
+    for class in [CLASS_USER, CLASS_CAMERA] {
+        let in_class = || {
+            writable
+                .iter()
+                .filter(move |(id, _)| id & CLASS_MASK == class)
+        };
+        let batch: Vec<Control> = in_class()
+            .map(|&(id, value)| Control {
+                id,
+                value: Value::Integer(value),
+            })
+            .collect();
+        if batch.is_empty() {
+            continue;
+        }
+        // A rejected batch falls back to per-control writes so one control the
+        // camera dislikes can't discard the whole profile. A control the device
+        // refuses outright is skipped for the same reason — only a genuine I/O
+        // failure aborts.
+        if device.set_controls(batch).is_err() {
+            for &(id, value) in in_class() {
+                match write_value(&device, id, value) {
+                    Ok(()) | Err(ControlError::Unsupported) => {}
+                    Err(error) => return Err(error),
+                }
+            }
+        }
+    }
+
+    Ok(())
+}
+
+/// Whether this call is handing `control` over to an auto mode.
+///
+/// A control under automatic control rejects manual writes, so a profile that
+/// carries both "auto on" and the value it gates would otherwise fail — and,
+/// because the write aborts the batch, would strand later controls unapplied.
+/// The auto toggle expresses the intent; the stale manual value is redundant.
+fn gated_by_enabled_auto(control: CameraControl, autos: &[(AutoToggle, bool)]) -> bool {
+    control
+        .auto_toggle()
+        .is_some_and(|gate| autos.iter().any(|&(toggle, on)| toggle == gate && on))
+}
+
+/// Mask selecting the class bits of a V4L2 control id.
+const CLASS_MASK: u32 = 0xFFFF_0000;
+const CLASS_USER: u32 = 0x0098_0000;
+const CLASS_CAMERA: u32 = 0x009a_0000;
+
+/// Every control the device advertises.
+fn query(device: &Device) -> Result<Vec<Description>, ControlError> {
+    device
+        .query_controls()
+        .map_err(|error| ControlError::Io(error.to_string()))
+}
+
+/// One control's description, if the device advertises it.
+fn describe(device: &Device, id: u32) -> Option<Description> {
+    device
+        .query_controls()
+        .ok()?
+        .into_iter()
+        .find(|description| description.id == id)
+}
+
+/// Build a [`ControlRange`], reading the live value.
+///
+/// Disabled controls are dropped — the driver refuses to read them, and they
+/// can't be adjusted. An *inactive* control (one an auto mode currently owns,
+/// like `exposure_time_absolute` under aperture priority) is kept: its range
+/// and last value are exactly what the UI needs to show the slider it will
+/// enable the moment auto is switched off.
+fn range_of(device: &Device, description: &Description) -> Option<ControlRange> {
+    if description.flags.contains(Flags::DISABLED) {
+        return None;
+    }
+    let current = read_int(device, description.id).unwrap_or(description.default);
+    Some(ControlRange {
+        min: clamp_i32(description.minimum),
+        max: clamp_i32(description.maximum),
+        default: clamp_i32(description.default),
+        current: clamp_i32(current),
+    })
+}
+
+/// Read an integer/boolean control's current value.
+fn read_int(device: &Device, id: u32) -> Option<i64> {
+    match device.control(id).ok()?.value {
+        Value::Integer(value) => Some(value),
+        Value::Boolean(value) => Some(i64::from(value)),
+        _ => None,
+    }
+}
+
+/// Read whether an auto mode is currently engaged.
+fn read_auto(device: &Device, toggle: AutoToggle) -> Option<bool> {
+    let raw = read_int(device, auto_id(toggle))?;
+    Some(if toggle == AutoToggle::Exposure {
+        is_auto_mode(raw)
+    } else {
+        raw != 0
+    })
+}
+
+/// Whether a `V4L2_CID_EXPOSURE_AUTO` menu value counts as automatic.
+///
+/// `AUTO` and `APERTURE_PRIORITY` both let the camera drive exposure time;
+/// `MANUAL` and `SHUTTER_PRIORITY` leave it under application control.
+fn is_auto_mode(value: i64) -> bool {
+    value == EXPOSURE_AUTO || value == EXPOSURE_APERTURE_PRIORITY
+}
+
+/// Write an auto toggle, translating the exposure menu.
+fn write_auto(device: &Device, toggle: AutoToggle, on: bool) -> Result<(), ControlError> {
+    if toggle == AutoToggle::Exposure {
+        let mode = exposure_mode(device, on).ok_or(ControlError::Unsupported)?;
+        return write_value(device, CID_EXPOSURE_AUTO, mode);
+    }
+    let control = Control {
+        id: auto_id(toggle),
+        value: Value::Boolean(on),
+    };
+    device
+        .set_control(control)
+        .map_err(|error| ControlError::Io(error.to_string()))
+}
+
+/// Pick an exposure menu value for the requested automatic/manual intent.
+///
+/// Cameras implement different subsets — the MX Brio offers only
+/// `APERTURE_PRIORITY` and `MANUAL`, while others offer `AUTO` — so the
+/// preferred value is checked against the advertised menu before falling back
+/// to the alternative with the same meaning.
+fn exposure_mode(device: &Device, on: bool) -> Option<i64> {
+    let description = describe(device, CID_EXPOSURE_AUTO)?;
+    let offered = |value: i64| -> bool {
+        // A menu with no enumerated items (some drivers omit them) still
+        // accepts values inside its advertised min/max.
+        description.items.as_ref().map_or(
+            value >= description.minimum && value <= description.maximum,
+            |items| items.iter().any(|(index, _)| i64::from(*index) == value),
+        )
+    };
+
+    let preferences: [i64; 2] = if on {
+        [EXPOSURE_APERTURE_PRIORITY, EXPOSURE_AUTO]
+    } else {
+        [EXPOSURE_MANUAL, EXPOSURE_SHUTTER_PRIORITY]
+    };
+    preferences.into_iter().find(|&value| offered(value))
+}
+
+/// `errno` values that mean "this camera won't take that write" rather than
+/// "the call went wrong": unknown control, value out of range, or an auto mode
+/// currently owning the control.
+const REJECTED: [i32; 4] = [
+    22, // EINVAL
+    34, // ERANGE
+    13, // EACCES
+    16, // EBUSY
+];
+
+/// Write an integer control, mapping a driver rejection to `Unsupported`.
+fn write_value(device: &Device, id: u32, value: i64) -> Result<(), ControlError> {
+    let control = Control {
+        id,
+        value: Value::Integer(value),
+    };
+    device.set_control(control).map_err(|error| {
+        if error
+            .raw_os_error()
+            .is_some_and(|no| REJECTED.contains(&no))
+        {
+            ControlError::Unsupported
+        } else {
+            ControlError::Io(error.to_string())
+        }
+    })
+}
+
+/// Narrow a V4L2 `i64` control bound to the `i32` the shared vocabulary uses.
+///
+/// Standard UVC controls fit comfortably; saturating keeps a driver reporting
+/// an absurd bound from wrapping into a negative slider bound.
+fn clamp_i32(value: i64) -> i32 {
+    i32::try_from(value).unwrap_or(if value.is_negative() {
+        i32::MIN
+    } else {
+        i32::MAX
+    })
+}
+
+#[cfg(test)]
+mod tests {
+    use super::*;
+
+    #[test]
+    fn exposure_auto_maps_only_two_menu_values_to_automatic() {
+        assert!(is_auto_mode(EXPOSURE_AUTO));
+        assert!(is_auto_mode(EXPOSURE_APERTURE_PRIORITY));
+        assert!(!is_auto_mode(EXPOSURE_MANUAL));
+        assert!(!is_auto_mode(EXPOSURE_SHUTTER_PRIORITY));
+    }
+
+    #[test]
+    fn a_control_handed_to_auto_is_skipped() {
+        let autos = [(AutoToggle::Exposure, true)];
+        // Exposure is gated by the toggle being switched on...
+        assert!(gated_by_enabled_auto(CameraControl::Exposure, &autos));
+        // ...while ungated controls, and controls gated by a *different*
+        // toggle, still apply.
+        assert!(!gated_by_enabled_auto(CameraControl::Zoom, &autos));
+        assert!(!gated_by_enabled_auto(CameraControl::Focus, &autos));
+    }
+
+    #[test]
+    fn a_control_taken_off_auto_still_applies() {
+        // Switching auto *off* is exactly when the manual value must be written.
+        let autos = [(AutoToggle::Focus, false)];
+        assert!(!gated_by_enabled_auto(CameraControl::Focus, &autos));
+    }
+
+    #[test]
+    fn an_unmentioned_toggle_leaves_its_control_writable() {
+        assert!(!gated_by_enabled_auto(CameraControl::WhiteBalance, &[]));
+    }
+
+    #[test]
+    fn every_supported_control_has_a_known_class() {
+        // apply_settings batches per class; a control outside both would be
+        // silently dropped from every batch.
+        for control in CameraControl::ALL {
+            let Some(id) = control_id(control) else {
+                continue; // Tint has no V4L2 equivalent.
+            };
+            let class = id & CLASS_MASK;
+            assert!(
+                class == CLASS_USER || class == CLASS_CAMERA,
+                "{} has class {class:#x}",
+                control.name()
+            );
+        }
+    }
+}
diff --git a/crates/openlogi-camera/src/uvc_windows.rs b/crates/openlogi-camera/src/uvc_windows.rs
new file mode 100644
index 0000000000000000000000000000000000000000..c588aba307f0c745660aef4550618ebe75f3038c
--- /dev/null
+++ b/crates/openlogi-camera/src/uvc_windows.rs
@@ -0,0 +1,446 @@
+//! Device-level UVC controls over DirectShow (Windows).
+//!
+//! Windows exposes the same UVC controls the macOS backend reaches over raw
+//! IOKit USB, but pre-mapped by the OS: `IAMVideoProcAmp` carries the image
+//! controls (brightness/contrast/…) and `IAMCameraControl` the lens controls
+//! (zoom/focus/exposure), each with per-property auto/manual flags. Writes
+//! land in the camera's own registers, so — exactly as on macOS — a change is
+//! seen by every app that opens the camera.
+//!
+//! Enumeration also lives here: the DirectShow video-input category yields
+//! each camera's friendly name and its device path, whose embedded
+//! `vid_xxxx&pid_xxxx` markers give the USB identity. The device path is the
+//! OS capture id ([`Camera::unique_id`]); when it embeds a real USB serial
+//! (not a parent-generated instance id) that serial is preferred for the
+//! port-stable [`Camera::config_key`].
+
+#![expect(
+    unsafe_code,
+    reason = "DirectShow COM (device enumeration + IAMVideoProcAmp / IAMCameraControl)"
+)]
+
+use windows::Win32::Media::DirectShow::{IAMCameraControl, IAMVideoProcAmp, IBaseFilter};
+use windows::Win32::System::Com::StructuredStorage::IPropertyBag;
+use windows::Win32::System::Com::{
+    CLSCTX_INPROC_SERVER, COINIT_MULTITHREADED, CoCreateInstance, CoInitializeEx, IEnumMoniker,
+    IMoniker,
+};
+use windows::Win32::System::Variant::{VARIANT, VT_BSTR};
+use windows::core::{GUID, Interface, w};
+
+use crate::Camera;
+use crate::controls::{
+    AutoState, AutoToggle, CameraControl, CameraState, ControlError, ControlRange,
+};
+
+/// CLSID_SystemDeviceEnum — the DirectShow device-category enumerator.
+const CLSID_SYSTEM_DEVICE_ENUM: GUID = GUID::from_u128(0x62be5d10_60eb_11d0_bd3b_00a0c911ce86);
+/// CLSID_VideoInputDeviceCategory — webcams and other video capture sources.
+const CLSID_VIDEO_INPUT_DEVICE_CATEGORY: GUID =
+    GUID::from_u128(0x860bb310_5d01_11d0_bd3b_00a0c911ce86);
+// VideoProcAmp / CameraControl property ids (strmif.h). Raw values rather
+// than the generated enums so the mapping reads like the UVC tables.
+const VPA_BRIGHTNESS: i32 = 0;
+const VPA_CONTRAST: i32 = 1;
+const VPA_HUE: i32 = 2;
+const VPA_SATURATION: i32 = 3;
+const VPA_SHARPNESS: i32 = 4;
+const VPA_WHITE_BALANCE: i32 = 6;
+const CC_ZOOM: i32 = 3;
+const CC_EXPOSURE: i32 = 4;
+const CC_FOCUS: i32 = 6;
+/// `*_Flags_Auto` / `*_Flags_Manual` share values across both interfaces.
+const FLAG_AUTO: i32 = 0x1;
+const FLAG_MANUAL: i32 = 0x2;
+
+/// Which DirectShow interface carries a control, plus its property id.
+#[derive(Clone, Copy)]
+enum Prop {
+    VideoProcAmp(i32),
+    CameraControl(i32),
+}
+
+impl CameraControl {
+    fn prop(self) -> Prop {
+        match self {
+            Self::Zoom => Prop::CameraControl(CC_ZOOM),
+            Self::Focus => Prop::CameraControl(CC_FOCUS),
+            Self::Exposure => Prop::CameraControl(CC_EXPOSURE),
+            Self::Brightness => Prop::VideoProcAmp(VPA_BRIGHTNESS),
+            Self::Contrast => Prop::VideoProcAmp(VPA_CONTRAST),
+            Self::Saturation => Prop::VideoProcAmp(VPA_SATURATION),
+            Self::Sharpness => Prop::VideoProcAmp(VPA_SHARPNESS),
+            Self::WhiteBalance => Prop::VideoProcAmp(VPA_WHITE_BALANCE),
+            Self::Tint => Prop::VideoProcAmp(VPA_HUE),
+        }
+    }
+}
+
+impl AutoToggle {
+    /// The property whose auto/manual flag backs this toggle.
+    fn prop(self) -> Prop {
+        match self {
+            Self::Focus => Prop::CameraControl(CC_FOCUS),
+            Self::Exposure => Prop::CameraControl(CC_EXPOSURE),
+            Self::WhiteBalance => Prop::VideoProcAmp(VPA_WHITE_BALANCE),
+        }
+    }
+}
+
+/// Enumerate every video-input device DirectShow reports, with the USB
+/// vendor/product ids parsed out of the device path. Non-USB sources (virtual
+/// cameras) carry no `vid_`/`pid_` markers and are dropped.
+pub fn enumerate() -> Vec<Camera> {
+    monikers()
+        .map(|monikers| {
+            monikers
+                .into_iter()
+                .filter_map(|m| camera_from_moniker(&m))
+                .collect()
+        })
+        .unwrap_or_default()
+}
+
+/// Read a control's min/max/default/current straight from the device.
+///
+/// # Errors
+/// [`ControlError::NotFound`] when no camera matches `unique_id`,
+/// [`ControlError::Unsupported`] when the camera lacks the control.
+pub fn control_range(
+    unique_id: &str,
+    control: CameraControl,
+) -> Result<ControlRange, ControlError> {
+    let dev = Device::open(unique_id)?;
+    dev.range(control.prop()).map(|(range, _)| range)
+}
+
+/// Read every supported control in a single device bind.
+///
+/// # Errors
+/// [`ControlError::NotFound`] when no camera matches `unique_id`.
+pub fn control_ranges(unique_id: &str) -> Result<Vec<(CameraControl, ControlRange)>, ControlError> {
+    Ok(read_camera_state(unique_id)?.controls)
+}
+
+/// Read every supported control range *and* auto-toggle state in a single
+/// device bind — what the GUI controls panel builds itself from.
+///
+/// # Errors
+/// [`ControlError::NotFound`] when no camera matches `unique_id`.
+pub fn read_camera_state(unique_id: &str) -> Result<CameraState, ControlError> {
+    let dev = Device::open(unique_id)?;
+    let mut state = CameraState::default();
+    for control in CameraControl::ALL {
+        if let Ok((range, _)) = dev.range(control.prop()) {
+            state.controls.push((control, range));
+        }
+    }
+    for toggle in AutoToggle::ALL {
+        if let Ok((_, caps)) = dev.range(toggle.prop())
+            && caps & FLAG_AUTO != 0
+            && let Ok(current) = dev.auto_engaged(toggle.prop())
+        {
+            // DirectShow reports which modes exist but not a factory default;
+            // auto-capable properties ship with auto engaged on every Logitech
+            // camera, so that is the reset target.
+            state.autos.push((
+                toggle,
+                AutoState {
+                    current,
+                    default: true,
+                },
+            ));
+        }
+    }
+    Ok(state)
+}
+
+/// Write a control's current value (switching that property to manual).
+///
+/// # Errors
+/// As [`control_range`].
+pub fn set_control(
+    unique_id: &str,
+    control: CameraControl,
+    value: i32,
+) -> Result<(), ControlError> {
+    let dev = Device::open(unique_id)?;
+    dev.set(control.prop(), value, FLAG_MANUAL)
+}
+
+/// Switch an auto mode (focus / exposure / white balance) on or off.
+///
+/// # Errors
+/// As [`control_range`].
+pub fn set_auto(unique_id: &str, toggle: AutoToggle, on: bool) -> Result<(), ControlError> {
+    let dev = Device::open(unique_id)?;
+    dev.set_auto(toggle.prop(), on)
+}
+
+/// Apply a batch of auto toggles and control values in a single device bind.
+/// Every write is attempted, but any failure surfaces so callers never persist
+/// a batch the hardware didn't take.
+///
+/// # Errors
+/// [`ControlError::NotFound`] when no camera matches `unique_id`; otherwise the
+/// first per-write error after attempting the whole batch.
+pub fn apply_settings(
+    unique_id: &str,
+    autos: &[(AutoToggle, bool)],
+    values: &[(CameraControl, i32)],
+) -> Result<(), ControlError> {
+    let dev = Device::open(unique_id)?;
+    let mut first_err = None;
+    for (toggle, on) in autos {
+        if let Err(e) = dev.set_auto(toggle.prop(), *on) {
+            first_err.get_or_insert(e);
+        }
+    }
+    for (control, value) in values {
+        if let Err(e) = dev.set(control.prop(), *value, FLAG_MANUAL) {
+            first_err.get_or_insert(e);
+        }
+    }
+    first_err.map_or(Ok(()), Err)
+}
+
+/// A camera's bound capture filter, with the two control interfaces it may
+/// implement (a camera without lens motors typically lacks `IAMCameraControl`).
+struct Device {
+    proc_amp: Option<IAMVideoProcAmp>,
+    camera_control: Option<IAMCameraControl>,
+}
+
+impl Device {
+    /// Bind the capture filter whose device path equals `unique_id`. Exact
+    /// match only — guessing another camera could adjust the wrong hardware.
+    fn open(unique_id: &str) -> Result<Self, ControlError> {
+        let monikers = monikers().map_err(|e| ControlError::Io(e.to_string()))?;
+        for moniker in monikers {
+            if read_property(&moniker, w!("DevicePath")).as_deref() != Some(unique_id) {
+                continue;
+            }
+            // SAFETY: documented moniker → filter bind; the returned interface
+            // pointers are reference-counted by the `windows` wrappers.
+            let filter: IBaseFilter = unsafe { moniker.BindToObject(None, None) }
+                .map_err(|e| ControlError::Io(e.to_string()))?;
+            return Ok(Self {
+                proc_amp: filter.cast().ok(),
+                camera_control: filter.cast().ok(),
+            });
+        }
+        Err(ControlError::NotFound)
+    }
+
+    /// GetRange for `prop`: the control's bounds plus its capability flags.
+    fn range(&self, prop: Prop) -> Result<(ControlRange, i32), ControlError> {
+        let (mut min, mut max, mut step, mut default, mut caps) = (0, 0, 0, 0, 0);
+        // SAFETY: documented COM calls writing the five out-params.
+        unsafe {
+            match prop {
+                Prop::VideoProcAmp(id) => self
+                    .proc_amp
+                    .as_ref()
+                    .ok_or(ControlError::Unsupported)?
+                    .GetRange(
+                        id,
+                        &raw mut min,
+                        &raw mut max,
+                        &raw mut step,
+                        &raw mut default,
+                        &raw mut caps,
+                    ),
+                Prop::CameraControl(id) => self
+                    .camera_control
+                    .as_ref()
+                    .ok_or(ControlError::Unsupported)?
+                    .GetRange(
+                        id,
+                        &raw mut min,
+                        &raw mut max,
+                        &raw mut step,
+                        &raw mut default,
+                        &raw mut caps,
+                    ),
+            }
+        }
+        .map_err(|_| ControlError::Unsupported)?;
+        let current = self.get(prop).map_or(default, |(value, _)| value);
+        Ok((
+            ControlRange {
+                min,
+                max,
+                default,
+                current,
+            },
+            caps,
+        ))
+    }
+
+    /// Get for `prop`: the current value and its auto/manual flags.
+    fn get(&self, prop: Prop) -> Result<(i32, i32), ControlError> {
+        let (mut value, mut flags) = (0, 0);
+        // SAFETY: documented COM calls writing the two out-params.
+        unsafe {
+            match prop {
+                Prop::VideoProcAmp(id) => self
+                    .proc_amp
+                    .as_ref()
+                    .ok_or(ControlError::Unsupported)?
+                    .Get(id, &raw mut value, &raw mut flags),
+                Prop::CameraControl(id) => self
+                    .camera_control
+                    .as_ref()
+                    .ok_or(ControlError::Unsupported)?
+                    .Get(id, &raw mut value, &raw mut flags),
+            }
+        }
+        .map_err(|_| ControlError::Unsupported)?;
+        Ok((value, flags))
+    }
+
+    /// Whether `prop` currently runs in auto mode.
+    fn auto_engaged(&self, prop: Prop) -> Result<bool, ControlError> {
+        Ok(self.get(prop)?.1 & FLAG_AUTO != 0)
+    }
+
+    /// Set `prop` to `value` under `flags` (auto or manual).
+    fn set(&self, prop: Prop, value: i32, flags: i32) -> Result<(), ControlError> {
+        // SAFETY: documented COM calls; the device validates the value.
+        unsafe {
+            match prop {
+                Prop::VideoProcAmp(id) => self
+                    .proc_amp
+                    .as_ref()
+                    .ok_or(ControlError::Unsupported)?
+                    .Set(id, value, flags),
+                Prop::CameraControl(id) => self
+                    .camera_control
+                    .as_ref()
+                    .ok_or(ControlError::Unsupported)?
+                    .Set(id, value, flags),
+            }
+        }
+        .map_err(|_| ControlError::Unsupported)
+    }
+
+    /// Engage or release auto mode, keeping the current value in place.
+    fn set_auto(&self, prop: Prop, on: bool) -> Result<(), ControlError> {
+        let value = self.get(prop).map_or(0, |(v, _)| v);
+        self.set(prop, value, if on { FLAG_AUTO } else { FLAG_MANUAL })
+    }
+}
+
+/// Every video-input moniker DirectShow reports (empty when the category has
+/// no devices, which the enumerator signals with `S_FALSE`).
+fn monikers() -> windows::core::Result<Vec<IMoniker>> {
+    // SAFETY: standard COM setup + documented enumerator calls. Double
+    // initialization (or an existing STA on this thread) is harmless here —
+    // the enumerator works under either apartment model.
+    unsafe {
+        let _ = CoInitializeEx(None, COINIT_MULTITHREADED);
+        let dev_enum: windows::Win32::Media::DirectShow::ICreateDevEnum =
+            CoCreateInstance(&CLSID_SYSTEM_DEVICE_ENUM, None, CLSCTX_INPROC_SERVER)?;
+        let mut enum_moniker: Option<IEnumMoniker> = None;
+        // S_FALSE (an empty category) is Ok with no enumerator — handled below.
+        dev_enum.CreateClassEnumerator(
+            &CLSID_VIDEO_INPUT_DEVICE_CATEGORY,
+            &raw mut enum_moniker,
+            0,
+        )?;
+        let Some(enum_moniker) = enum_moniker else {
+            return Ok(Vec::new());
+        };
+        let mut all = Vec::new();
+        loop {
+            let mut chunk = [const { None }; 8];
+            let mut fetched = 0;
+            let hr = enum_moniker.Next(&mut chunk, Some(&raw mut fetched));
+            all.extend(chunk.into_iter().take(fetched as usize).flatten());
+            if hr.is_err() || fetched == 0 {
+                break;
+            }
+        }
+        Ok(all)
+    }
+}
+
+/// Build a [`Camera`] from one moniker: friendly name + device path, with the
+/// USB ids parsed from the path's `vid_xxxx&pid_xxxx` markers.
+fn camera_from_moniker(moniker: &IMoniker) -> Option<Camera> {
+    let unique_id = read_property(moniker, w!("DevicePath"))?;
+    let (vendor_id, product_id) = parse_device_path_ids(&unique_id)?;
+    let name = read_property(moniker, w!("FriendlyName")).unwrap_or_else(|| "Camera".into());
+    let serial_number = usb_serial_from_device_path(&unique_id);
+    Some(Camera {
+        name,
+        unique_id,
+        serial_number,
+        vendor_id,
+        product_id,
+        max_resolution: None,
+        max_fps: None,
+    })
+}
+
+/// USB `iSerialNumber` embedded in a device-interface path, when present.
+///
+/// Paths look like `\\?\usb#vid_046d&pid_0893&mi_00#SERIAL#{guid}\global`.
+/// Windows fabricates a parent-relative instance id (always containing `&`)
+/// when the device has no serial — those are port-dependent and rejected.
+pub(crate) fn usb_serial_from_device_path(path: &str) -> Option<String> {
+    // Split on '#': [prefix, hardware-id, instance, {class-guid}…]
+    let instance = path.split('#').nth(2)?.split('\\').next()?.trim();
+    if instance.is_empty() || instance.contains('&') {
+        return None;
+    }
+    Some(instance.to_string())
+}
+
+/// Read one string property (`FriendlyName` / `DevicePath`) from a moniker's
+/// property bag.
+fn read_property(moniker: &IMoniker, name: windows::core::PCWSTR) -> Option<String> {
+    // SAFETY: documented property-bag reads; the VARIANT is only interpreted
+    // as a BSTR when the bag reports that type.
+    unsafe {
+        let bag: IPropertyBag = moniker.BindToStorage(None, None).ok()?;
+        let mut value = VARIANT::default();
+        bag.Read(name, &raw mut value, None).ok()?;
+        if value.Anonymous.Anonymous.vt != VT_BSTR {
+            return None;
+        }
+        Some(value.Anonymous.Anonymous.Anonymous.bstrVal.to_string())
+    }
+}
+
+/// Pull the hex USB vendor/product ids out of a device path such as
+/// `\\?\usb#vid_046d&pid_0893&mi_00#…`.
+fn parse_device_path_ids(path: &str) -> Option<(u16, u16)> {
+    let lower = path.to_ascii_lowercase();
+    let hex_after = |marker: &str| -> Option<u16> {
+        let rest = lower.split(marker).nth(1)?;
+        u16::from_str_radix(rest.get(..4)?, 16).ok()
+    };
+    Some((hex_after("vid_")?, hex_after("pid_")?))
+}
+
+#[cfg(test)]
+mod tests {
+    use super::usb_serial_from_device_path;
+
+    #[test]
+    fn real_usb_serial_is_extracted() {
+        let path = r"\\?\usb#vid_046d&pid_0893&mi_00#6B123456#{65e8773d-8f56-11d0-a3b9-00a0c9223196}\global";
+        assert_eq!(
+            usb_serial_from_device_path(path).as_deref(),
+            Some("6B123456")
+        );
+    }
+
+    #[test]
+    fn parent_generated_instance_is_rejected() {
+        // StreamCam without a firmware serial: Windows fabricates `9&56d9c30&0&0000`.
+        let path = r"\\?\usb#vid_046d&pid_0893&mi_00#9&56d9c30&0&0000#{65e8773d-8f56-11d0-a3b9-00a0c9223196}\global";
+        assert_eq!(usb_serial_from_device_path(path), None);
+    }
+}
diff --git a/crates/openlogi-cli/Cargo.toml b/crates/openlogi-cli/Cargo.toml
index c066de93caa2da990c63d7558a763f29ccae76c0..861b01176176009e8f63d6b6980d7acb5f1429d0 100644
--- a/crates/openlogi-cli/Cargo.toml
+++ b/crates/openlogi-cli/Cargo.toml
@@ -11,9 +11,11 @@ keywords = ["logitech", "hidpp", "hid", "mouse", "cli"]
 categories = ["command-line-utilities", "hardware-support"]
 
 [dependencies]
-openlogi-core = { path = "../openlogi-core", version = "0.6.23" }
-openlogi-hid = { path = "../openlogi-hid", version = "0.6.23" }
-openlogi-assets = { path = "../openlogi-assets", version = "0.6.23" }
+openlogi-core = { path = "../openlogi-core", version = "0.6.24" }
+openlogi-hid = { path = "../openlogi-hid", version = "0.6.24" }
+openlogi-camera = { path = "../openlogi-camera", version = "0.6.24" }
+openlogi-assets = { path = "../openlogi-assets", version = "0.6.24" }
+png = "0.17"
 clap = { workspace = true }
 anyhow = { workspace = true }
 tokio = { workspace = true, features = ["rt", "macros", "sync", "time"] }
diff --git a/crates/openlogi-cli/src/cmd/backlight.rs b/crates/openlogi-cli/src/cmd/backlight.rs
new file mode 100644
index 0000000000000000000000000000000000000000..584c89d22d866f33a8093a0c1cdf081478f4aab5
--- /dev/null
+++ b/crates/openlogi-cli/src/cmd/backlight.rs
@@ -0,0 +1,131 @@
+//! `openlogi backlight` — read and set the HID++ `0x1982` keyboard backlight.
+//!
+//! Unlike `diag`, this is persistent configuration: `setBacklightConfig` writes
+//! to the keyboard's non-volatile memory, so `backlight off` survives
+//! reconnects, host switches, and power cycles with nothing re-applying it.
+
+use anyhow::{Context, Result};
+use clap::{Args, Subcommand};
+use openlogi_hid::{BacklightMode, BacklightState, BacklightStatus, DeviceRoute};
+
+use crate::cmd::diag::select_device;
+
+/// HID++ `Backlight` — the white, level-adjustable backlight on the MX Keys
+/// line. RGB keyboards use `0x8070` / `0x8080` instead and are driven by
+/// `diag lighting`.
+const BACKLIGHT_FEATURE: u16 = 0x1982;
+
+#[derive(Debug, Args)]
+pub struct BacklightArgs {
+    /// Run against the device whose name contains this string
+    /// (case-insensitive) instead of auto-selecting. Useful when several
+    /// keyboards are paired.
+    #[arg(long, value_name = "NAME", global = true)]
+    pub device: Option<String>,
+
+    #[command(subcommand)]
+    pub action: Option<BacklightAction>,
+}
+
+#[derive(Debug, Subcommand)]
+pub enum BacklightAction {
+    /// Show the current backlight state (the default with no subcommand).
+    Status,
+    /// Turn the backlight off completely and persistently. The LEDs stay dark
+    /// regardless of ambient light or hand proximity.
+    Off,
+    /// Turn the backlight back on, restoring the mode and brightness level the
+    /// keyboard still has stored.
+    On,
+}
+
+pub async fn run(args: BacklightArgs) -> Result<()> {
+    let (route, name) = select_device(args.device.as_deref(), &[BACKLIGHT_FEATURE]).await?;
+    println!("device: {name} ({route})");
+
+    let enable = match args.action.unwrap_or(BacklightAction::Status) {
+        BacklightAction::Status => {
+            let state = read_state(&route).await?;
+            print_state("current", state);
+            return Ok(());
+        }
+        BacklightAction::Off => false,
+        BacklightAction::On => true,
+    };
+
+    let before = read_state(&route).await?;
+    print_state("current", before);
+
+    // The keyboard sets this mode itself from its backlight keys and
+    // setBacklightConfig cannot write it back, so say so rather than let the
+    // mode change look like a side effect of the enable bit.
+    if before.mode == BacklightMode::TemporaryManual {
+        println!(
+            "  note: the level came from the keyboard's backlight keys, a mode software cannot write back — it returns to automatic (ambient-light sensor)"
+        );
+    }
+
+    let after = openlogi_hid::set_backlight_enabled(&route, enable)
+        .await
+        .with_context(|| {
+            format!(
+                "set backlight {}",
+                if enable { "enabled" } else { "disabled" }
+            )
+        })?;
+    print_state("read-back", after);
+
+    if after.enabled != enable {
+        anyhow::bail!(
+            "backlight write not applied: requested enabled={enable}, device reports enabled={}",
+            after.enabled
+        );
+    }
+
+    if enable {
+        println!(
+            "✓ backlight enabled (level {}/{})",
+            after.current_level, after.nb_levels
+        );
+    } else {
+        println!("✓ backlight off — persisted to the keyboard, survives reconnect and power cycle");
+    }
+    Ok(())
+}
+
+async fn read_state(route: &DeviceRoute) -> Result<BacklightState> {
+    openlogi_hid::get_backlight(route)
+        .await
+        .context("read backlight state")
+}
+
+fn print_state(label: &str, state: BacklightState) {
+    println!(
+        "  {label}: enabled={} mode={} status={} level={}/{}",
+        state.enabled,
+        mode_label(state.mode),
+        status_label(state.status),
+        state.current_level,
+        state.nb_levels,
+    );
+}
+
+fn mode_label(mode: BacklightMode) -> &'static str {
+    match mode {
+        BacklightMode::None => "none",
+        BacklightMode::Automatic => "automatic (ambient-light sensor)",
+        BacklightMode::TemporaryManual => "temporary manual (backlight keys)",
+        BacklightMode::PermanentManual => "permanent manual (software)",
+    }
+}
+
+fn status_label(status: BacklightStatus) -> &'static str {
+    match status {
+        BacklightStatus::DisabledBySoftware => "off (disabled by software)",
+        BacklightStatus::DisabledByCriticalBattery => "off (critical battery)",
+        BacklightStatus::AlsAutomatic => "on (following ambient light)",
+        BacklightStatus::AlsSaturated => "off (ambient light saturated)",
+        BacklightStatus::TemporaryManual => "on (level from backlight keys)",
+        BacklightStatus::PermanentManual => "on (level from software)",
+    }
+}
diff --git a/crates/openlogi-cli/src/cmd/camera.rs b/crates/openlogi-cli/src/cmd/camera.rs
new file mode 100644
index 0000000000000000000000000000000000000000..788ec8011e39945f48bdd0343ee66a366d5b733b
--- /dev/null
+++ b/crates/openlogi-cli/src/cmd/camera.rs
@@ -0,0 +1,101 @@
+//! `openlogi camera` — read and write device-level UVC image controls.
+//!
+//! Exercises the `openlogi-camera` UVC path (the same primitive the GUI controls
+//! panel uses). Changes land in the camera's own registers, so other apps
+//! (Google Meet, Zoom, OBS) see them too.
+
+use anyhow::{Result, anyhow};
+use clap::{Args, Subcommand};
+use openlogi_camera::{AutoToggle, CameraControl};
+
+#[derive(Debug, Args)]
+pub struct CameraArgs {
+    #[command(subcommand)]
+    pub cmd: Option<CameraCmd>,
+    /// Operate on the camera with this unique id (default: first Logitech).
+    #[arg(long, global = true)]
+    pub camera: Option<String>,
+}
+
+#[derive(Debug, Subcommand)]
+pub enum CameraCmd {
+    /// Show each control's min/max/default/current and each auto mode's state
+    /// (the default action).
+    Get,
+    /// Set a control to a value (or an auto toggle to 0/1); persists on the
+    /// device.
+    Set {
+        /// zoom | focus | exposure | brightness | contrast | saturation |
+        /// sharpness | white_balance | tint, or focus_auto | exposure_auto |
+        /// white_balance_auto
+        control: String,
+        value: i32,
+    },
+}
+
+pub fn run(args: CameraArgs) -> Result<()> {
+    let uid = match args.camera {
+        Some(id) => id,
+        None => openlogi_camera::enumerate_cameras()
+            .into_iter()
+            .next()
+            .map(|c| c.unique_id)
+            .ok_or_else(|| anyhow!("no Logitech camera found"))?,
+    };
+
+    match args.cmd.unwrap_or(CameraCmd::Get) {
+        CameraCmd::Get => {
+            println!("controls for {uid}:");
+            match openlogi_camera::read_camera_state(&uid) {
+                Ok(state) if !state.controls.is_empty() => {
+                    for (control, r) in &state.controls {
+                        println!(
+                            "  {}: min={} max={} default={} current={}",
+                            control.name(),
+                            r.min,
+                            r.max,
+                            r.default,
+                            r.current
+                        );
+                    }
+                    for (toggle, st) in &state.autos {
+                        println!(
+                            "  {}: current={} default={}",
+                            toggle.name(),
+                            st.current,
+                            st.default
+                        );
+                    }
+                }
+                Ok(_) => println!("  (no adjustable controls, or camera not found)"),
+                Err(e) => println!("  {e}"),
+            }
+        }
+        CameraCmd::Set { control, value } => {
+            let raw = control.to_ascii_lowercase();
+            if let Some(toggle) = AutoToggle::ALL.iter().find(|t| t.name() == raw) {
+                openlogi_camera::set_auto(&uid, *toggle, value != 0).map_err(|e| anyhow!("{e}"))?;
+                println!("set {} = {}", toggle.name(), value != 0);
+            } else {
+                let control = parse_control(&raw)?;
+                openlogi_camera::set_control(&uid, control, value).map_err(|e| anyhow!("{e}"))?;
+                println!("set {} = {value}", control.name());
+            }
+        }
+    }
+    Ok(())
+}
+
+fn parse_control(raw: &str) -> Result<CameraControl> {
+    CameraControl::ALL
+        .into_iter()
+        .find(|c| c.name() == raw)
+        .ok_or_else(|| {
+            let names: Vec<&str> = CameraControl::ALL
+                .iter()
+                .map(|c| c.name())
+                .chain(AutoToggle::ALL.iter().map(|t| t.name()))
+                .collect();
+            anyhow!("unknown control {raw:?} ({})", names.join("|"))
+        })
+}
diff --git a/crates/openlogi-cli/src/cmd/diag.rs b/crates/openlogi-cli/src/cmd/diag.rs
index 3a9e0a74ab6a23798ffbdfe9fb1977464bbdee74..deecea0c94b429c49139be7f42bbaaaef3606ab6 100644
--- a/crates/openlogi-cli/src/cmd/diag.rs
+++ b/crates/openlogi-cli/src/cmd/diag.rs
@@ -10,6 +10,7 @@ use anyhow::{Result, anyhow};
 use clap::Subcommand;
 use openlogi_hid::{DeviceRoute, dump_features};
 
+pub mod battery;
 pub mod controls;
 pub mod dpi;
 pub mod features;
@@ -23,6 +24,8 @@ pub enum DiagCmd {
     Features(features::FeaturesArgs),
     /// Dump HID++ 0x1b04 reprogrammable controls and capability flags.
     Controls(controls::ControlsArgs),
+    /// Read the raw battery report (0x1004 or 0x1000 fields).
+    Battery(battery::BatteryArgs),
     /// Read DPI → write a small delta → read back → restore → report.
     Dpi(dpi::DpiArgs),
     /// Read SmartShift mode → toggle → read back → toggle back → report.
@@ -38,6 +41,7 @@ impl DiagCmd {
         match self {
             Self::Features(args) => features::run(args).await,
             Self::Controls(args) => controls::run(args).await,
+            Self::Battery(args) => battery::run(args).await,
             Self::Dpi(args) => dpi::run(args).await,
             Self::Smartshift(args) => smartshift::run(args).await,
             Self::Lighting(args) => lighting::run(args).await,
diff --git a/crates/openlogi-cli/src/cmd/diag/battery.rs b/crates/openlogi-cli/src/cmd/diag/battery.rs
new file mode 100644
index 0000000000000000000000000000000000000000..18e93c2fcece954dfc8f04f4c7325fd2301bf1de
--- /dev/null
+++ b/crates/openlogi-cli/src/cmd/diag/battery.rs
@@ -0,0 +1,32 @@
+//! `openlogi diag battery` — dump the device's raw battery report.
+//!
+//! Prints exactly what the firmware returns (unified `0x1004` fields, or legacy
+//! `0x1000` `discharge_level`/`next_level`/`status`). Run it once on battery and
+//! once with the charger plugged in to see how the device reports while charging
+//! — e.g. an MX2S returns `discharge_level=0` mid-charge, which is the device's
+//! own limitation, not a bug in the read path.
+
+use anyhow::{Context, Result};
+use clap::Args;
+
+use crate::cmd::diag::select_device;
+
+#[derive(Debug, Args)]
+pub struct BatteryArgs {
+    /// Run against the device whose name contains this string
+    /// (case-insensitive) instead of auto-selecting.
+    #[arg(long, value_name = "NAME")]
+    pub device: Option<String>,
+}
+
+pub async fn run(args: BatteryArgs) -> Result<()> {
+    // 0x1004 UnifiedBattery / 0x1000 BatteryStatus — pick a device with either.
+    let (route, name) = select_device(args.device.as_deref(), &[0x1000, 0x1004]).await?;
+    println!("device: {name} ({route})");
+
+    let line = openlogi_hid::read_battery_raw(&route)
+        .await
+        .context("read battery")?;
+    println!("  {line}");
+    Ok(())
+}
diff --git a/crates/openlogi-cli/src/cmd/light.rs b/crates/openlogi-cli/src/cmd/light.rs
new file mode 100644
index 0000000000000000000000000000000000000000..fdfde05bcb49b464d14a18accc2a6604cc2d9edf
--- /dev/null
+++ b/crates/openlogi-cli/src/cmd/light.rs
@@ -0,0 +1,251 @@
+//! `openlogi light` — discovery and manual control for standalone lights.
+//!
+//! The CLI intentionally uses the same raw-HID driver as the agent. It is a
+//! small hardware-facing surface for validating discovery and report encoding
+//! before exercising the GPUI panel.
+
+use anyhow::{Context, Result, anyhow};
+use clap::{Args, Subcommand};
+use openlogi_core::device::{LightValueUnit, StandaloneDevice};
+use openlogi_hid::{DeviceRoute, LightCommand, LitraModel};
+
+#[derive(Debug, Subcommand)]
+pub enum LightCmd {
+    /// List recognized standalone lights and their advertised controls.
+    List,
+    /// Turn a light on.
+    On(DeviceArgs),
+    /// Turn a light off.
+    Off(DeviceArgs),
+    /// Set normalized brightness or native lumens.
+    Brightness(BrightnessArgs),
+    /// Set colour temperature in Kelvin.
+    Temperature(TemperatureArgs),
+}
+
+#[derive(Debug, Args)]
+pub struct DeviceArgs {
+    /// Case-insensitive substring of the light name or identity.
+    #[arg(long)]
+    device: Option<String>,
+}
+
+#[derive(Debug, Args)]
+pub struct BrightnessArgs {
+    #[command(flatten)]
+    device: DeviceArgs,
+    /// Normalized brightness from 0 to 100 percent.
+    #[arg(long, conflicts_with = "lumens", value_parser = clap::value_parser!(u8).range(0..=100))]
+    percent: Option<u8>,
+    /// Native brightness in lumens.
+    #[arg(long, conflicts_with = "percent")]
+    lumens: Option<u16>,
+}
+
+#[derive(Debug, Args)]
+pub struct TemperatureArgs {
+    #[command(flatten)]
+    device: DeviceArgs,
+    /// Colour temperature in Kelvin.
+    #[arg(long)]
+    kelvin: u16,
+}
+
+impl LightCmd {
+    pub async fn run(self) -> Result<()> {
+        match self {
+            Self::List => list().await,
+            Self::On(args) => set_power(args.device.as_deref(), true).await,
+            Self::Off(args) => set_power(args.device.as_deref(), false).await,
+            Self::Brightness(args) => set_brightness(args).await,
+            Self::Temperature(args) => set_temperature(args).await,
+        }
+    }
+}
+
+async fn standalone() -> Result<Vec<StandaloneDevice>> {
+    openlogi_hid::enumerate_standalone()
+        .await
+        .context("failed to enumerate standalone HID devices")
+}
+
+async fn list() -> Result<()> {
+    let devices = standalone().await?;
+    if devices.is_empty() {
+        println!("No supported standalone lights found.");
+        return Ok(());
+    }
+    for device in devices {
+        let address = &device.address;
+        println!(
+            "{} — {} ({:04x}:{:04x} usage {:04x}:{:04x})",
+            device.display_name,
+            address.identity,
+            address.vendor_id,
+            address.product_id,
+            address.usage_page,
+            address.usage_id,
+        );
+        if let Some(caps) = device.light_capabilities {
+            if let Some(range) = caps.brightness {
+                println!(
+                    "  brightness: {}–{} {:?}",
+                    range.min(),
+                    range.max(),
+                    range.unit()
+                );
+            }
+            if let Some(range) = caps.temperature {
+                println!(
+                    "  temperature: {}–{} K step {}",
+                    range.min(),
+                    range.max(),
+                    range.step()
+                );
+            }
+            println!("  power: {}", if caps.power { "yes" } else { "no" });
+        }
+    }
+    Ok(())
+}
+
+async fn set_power(query: Option<&str>, enabled: bool) -> Result<()> {
+    let devices = standalone().await?;
+    let device = select(&devices, query)?;
+    apply(device, LightCommand::Power(enabled)).await
+}
+
+async fn set_brightness(args: BrightnessArgs) -> Result<()> {
+    let devices = standalone().await?;
+    let device = select(&devices, args.device.device.as_deref())?;
+    let caps = device
+        .light_capabilities
+        .ok_or_else(|| anyhow!("selected light did not advertise capabilities"))?;
+    let range = caps
+        .brightness
+        .ok_or_else(|| anyhow!("selected light does not support brightness"))?;
+    let command = match (args.percent, args.lumens) {
+        (Some(percent), None) => LightCommand::BrightnessPercent(percent),
+        (None, Some(lumens)) => {
+            if range.unit() != LightValueUnit::Lumens || !range.contains(lumens) {
+                return Err(anyhow!(
+                    "lumens must be in the supported range {}..={} with step {}",
+                    range.min(),
+                    range.max(),
+                    range.step()
+                ));
+            }
+            LightCommand::BrightnessNative(lumens)
+        }
+        (None, None) => return Err(anyhow!("pass either --percent or --lumens")),
+        (Some(_), Some(_)) => unreachable!("clap enforces the argument conflict"),
+    };
+    apply(device, command).await
+}
+
+async fn set_temperature(args: TemperatureArgs) -> Result<()> {
+    let devices = standalone().await?;
+    let device = select(&devices, args.device.device.as_deref())?;
+    apply(device, LightCommand::TemperatureKelvin(args.kelvin)).await
+}
+
+async fn apply(device: &StandaloneDevice, command: LightCommand) -> Result<()> {
+    let model = LitraModel::from_product_id(device.address.product_id).ok_or_else(|| {
+        anyhow!(
+            "unsupported light product {:04x}",
+            device.address.product_id
+        )
+    })?;
+    let route = DeviceRoute::RawHid {
+        vendor_id: device.address.vendor_id,
+        product_id: device.address.product_id,
+        usage_page: device.address.usage_page,
+        usage_id: device.address.usage_id,
+        identity: device.address.identity.clone(),
+    };
+    openlogi_hid::apply_litra(&route, model, command)
+        .await
+        .context("failed to write the light command")
+}
+
+fn select<'a>(
+    devices: &'a [StandaloneDevice],
+    query: Option<&str>,
+) -> Result<&'a StandaloneDevice> {
+    let Some(query) = query else {
+        return match devices {
+            [] => Err(anyhow!("no supported standalone light found")),
+            [device] => Ok(device),
+            _ => Err(anyhow!(
+                "multiple standalone lights found; select one with --device"
+            )),
+        };
+    };
+    let query = query.to_ascii_lowercase();
+    let mut matches = devices.iter().filter(|device| {
+        device.display_name.to_ascii_lowercase().contains(&query)
+            || device
+                .address
+                .identity
+                .to_ascii_lowercase()
+                .contains(&query)
+    });
+    let Some(device) = matches.next() else {
+        return Err(anyhow!("no standalone light matches --device {query}"));
+    };
+    if matches.next().is_some() {
+        return Err(anyhow!(
+            "multiple standalone lights match --device {query}; use a more specific value"
+        ));
+    }
+    Ok(device)
+}
+
+#[cfg(test)]
+mod tests {
+    #![allow(clippy::expect_used, reason = "expect is idiomatic in selection tests")]
+
+    use super::select;
+    use openlogi_core::device::{DeviceKind, RawDeviceAddress, StandaloneDevice};
+
+    fn device(name: &str) -> StandaloneDevice {
+        StandaloneDevice {
+            address: RawDeviceAddress {
+                vendor_id: 0x046d,
+                product_id: 0xc900,
+                usage_page: 0xff43,
+                usage_id: 0x0202,
+                identity: "serial:test".into(),
+            },
+            display_name: name.into(),
+            manufacturer: Some("Logi".into()),
+            serial_number: Some("test".into()),
+            unit_id: [0; 4],
+            kind: DeviceKind::Light,
+            online: true,
+            capabilities: None,
+            light_capabilities: None,
+            driver_id: "litra".into(),
+            registry_model_id: None,
+        }
+    }
+
+    #[test]
+    fn selection_requires_disambiguation_and_supports_name_queries() {
+        let devices = vec![device("Litra Glow"), device("Litra Beam")];
+        assert!(select(&devices, None).is_err());
+        assert_eq!(
+            select(&devices, Some("beam"))
+                .expect("matching device")
+                .display_name,
+            "Litra Beam"
+        );
+        assert!(select(&devices, Some("litra")).is_err());
+        assert_eq!(
+            select(&devices[..1], None)
+                .expect("single device")
+                .display_name,
+            "Litra Glow"
+        );
+    }
+}
diff --git a/crates/openlogi-cli/src/cmd/list.rs b/crates/openlogi-cli/src/cmd/list.rs
index 963d7f2982fe0b3666675fc7b4186fd1f3321031..dcc57c822c66bb9733c11a1a3705cb232c8fef20 100644
--- a/crates/openlogi-cli/src/cmd/list.rs
+++ b/crates/openlogi-cli/src/cmd/list.rs
@@ -1,5 +1,6 @@
 use anyhow::{Context, Result};
 use clap::Args;
+use openlogi_camera::Camera;
 use openlogi_core::device::{BatteryInfo, DeviceInventory, DeviceModelInfo, PairedDevice};
 
 #[derive(Debug, Args)]
@@ -9,9 +10,10 @@ pub async fn run(_args: ListArgs) -> Result<()> {
     let inventories = openlogi_hid::enumerate()
         .await
         .context("failed to enumerate HID++ devices")?;
+    let cameras = openlogi_camera::enumerate_cameras();
 
-    if inventories.is_empty() {
-        println!("No Logitech HID++ devices found.");
+    if inventories.is_empty() && cameras.is_empty() {
+        println!("No Logitech HID++ devices or webcams found.");
         println!();
         println!("Notes:");
         println!("  - On macOS, quit Logi Options+ first — both apps fight over HID++ access.");
@@ -33,9 +35,33 @@ pub async fn run(_args: ListArgs) -> Result<()> {
         print_inventory(inv);
     }
 
+    if !cameras.is_empty() {
+        if !inventories.is_empty() {
+            println!();
+        }
+        print_cameras(&cameras);
+    }
+
     Ok(())
 }
 
+fn print_cameras(cameras: &[Camera]) {
+    println!("Cameras ({} Logitech UVC)", cameras.len());
+    let last = cameras.len() - 1;
+    for (i, cam) in cameras.iter().enumerate() {
+        let prefix = if i == last { "  └─" } else { "  ├─" };
+        let caps = match (cam.max_resolution, cam.max_fps) {
+            (Some((w, h)), Some(fps)) => format!(", up to {w}x{h}@{fps}"),
+            (Some((w, h)), None) => format!(", up to {w}x{h}"),
+            _ => String::new(),
+        };
+        println!(
+            "{prefix} ● {} (camera, vid={:04x} pid={:04x}{caps}, id={})",
+            cam.name, cam.vendor_id, cam.product_id, cam.unique_id
+        );
+    }
+}
+
 fn print_inventory(inv: &DeviceInventory) {
     let uid = inv.receiver.unique_id.as_deref().unwrap_or("—");
     println!(
diff --git a/crates/openlogi-cli/src/cmd/mod.rs b/crates/openlogi-cli/src/cmd/mod.rs
index 91136c28e3c420779c131c0e745465e53850f319..7032408a65d23b19d91b686418376053408c488a 100644
--- a/crates/openlogi-cli/src/cmd/mod.rs
+++ b/crates/openlogi-cli/src/cmd/mod.rs
@@ -2,28 +2,47 @@ use anyhow::Result;
 use clap::Subcommand;
 
 pub mod assets;
+pub mod backlight;
+pub mod camera;
 pub mod diag;
+pub mod light;
 pub mod list;
+pub mod snapshot;
 
 #[derive(Debug, Subcommand)]
 pub enum Command {
     /// List connected Logitech HID++ devices.
     List(list::ListArgs),
+    /// Read or persistently set the keyboard backlight (HID++ 0x1982).
+    Backlight(backlight::BacklightArgs),
+    /// Capture one frame from a Logitech webcam to a PNG.
+    Snapshot(snapshot::SnapshotArgs),
+    /// Read or write device-level UVC image controls on a webcam.
+    Camera(camera::CameraArgs),
     /// Manage assets fetched from OpenLogi's asset mirrors.
     #[command(subcommand)]
     Assets(assets::AssetsCmd),
     /// Real-device round-trip smoke tests against the HID++ write path.
     #[command(subcommand)]
     Diag(diag::DiagCmd),
+    /// Inspect and control standalone Logitech lights.
+    #[command(subcommand)]
+    Light(light::LightCmd),
 }
 
 impl Command {
     pub async fn run(self) -> Result<()> {
         match self {
             Self::List(args) => list::run(args).await,
+            Self::Backlight(args) => backlight::run(args).await,
+            // Camera capture is blocking AVFoundation — no need for the async runtime.
+            Self::Snapshot(args) => snapshot::run(args),
+            // UVC control transfers are blocking IOKit — no async runtime needed.
+            Self::Camera(args) => camera::run(args),
             // `assets sync` is blocking HTTP — no need for the async runtime.
             Self::Assets(cmd) => cmd.run(),
             Self::Diag(cmd) => cmd.run().await,
+            Self::Light(cmd) => cmd.run().await,
         }
     }
 }
diff --git a/crates/openlogi-cli/src/cmd/snapshot.rs b/crates/openlogi-cli/src/cmd/snapshot.rs
new file mode 100644
index 0000000000000000000000000000000000000000..889b81c768af4236cfeb2465716ddb72ff46b059
--- /dev/null
+++ b/crates/openlogi-cli/src/cmd/snapshot.rs
@@ -0,0 +1,57 @@
+//! `openlogi snapshot` — grab one frame from a Logitech webcam to a PNG.
+//!
+//! Exercises the `openlogi-camera` capture path (the same primitive the GUI
+//! preview uses). Capturing needs Camera permission; from this unbundled CLI
+//! macOS may deny access (no `NSCameraUsageDescription`), which is reported
+//! rather than fatal.
+
+use std::time::Duration;
+
+use anyhow::{Context, Result, anyhow};
+use clap::Args;
+
+#[derive(Debug, Args)]
+pub struct SnapshotArgs {
+    /// Output PNG path.
+    #[arg(default_value = "snapshot.png")]
+    pub path: String,
+    /// Capture from the camera with this unique id (default: first Logitech).
+    #[arg(long)]
+    pub camera: Option<String>,
+}
+
+pub fn run(args: SnapshotArgs) -> Result<()> {
+    let unique_id = match args.camera {
+        Some(id) => id,
+        None => openlogi_camera::enumerate_cameras()
+            .into_iter()
+            .next()
+            .map(|camera| camera.unique_id)
+            .ok_or_else(|| anyhow!("no Logitech camera found"))?,
+    };
+
+    println!("capturing one frame from {unique_id} …");
+    let frame = openlogi_camera::capture_frame(&unique_id, Duration::from_secs(5))
+        .map_err(|e| anyhow!("{e}"))?;
+    // Frames are stored BGRA (gpui's order); PNG wants RGBA, so swap R/B once.
+    let mut rgba = frame.bgra;
+    for px in rgba.chunks_exact_mut(4) {
+        px.swap(0, 2);
+    }
+    write_png(&args.path, frame.width, frame.height, &rgba)
+        .with_context(|| format!("writing {}", args.path))?;
+    println!("wrote {}x{} → {}", frame.width, frame.height, args.path);
+    Ok(())
+}
+
+fn write_png(path: &str, width: u32, height: u32, rgba: &[u8]) -> Result<()> {
+    let file = std::fs::File::create(path)?;
+    let writer = std::io::BufWriter::new(file);
+    let mut encoder = png::Encoder::new(writer, width, height);
+    encoder.set_color(png::ColorType::Rgba);
+    encoder.set_depth(png::BitDepth::Eight);
+    encoder
+        .write_header()?
+        .write_image_data(rgba)
+        .context("encoding PNG")
+}
diff --git a/crates/openlogi-cli/src/lib.rs b/crates/openlogi-cli/src/lib.rs
index 97af9981fd330d89c9df14a04386483910b7ec70..0d3b0e86959558927a56fadf3b4d52f22be715ef 100644
--- a/crates/openlogi-cli/src/lib.rs
+++ b/crates/openlogi-cli/src/lib.rs
@@ -43,6 +43,7 @@ mod tests {
 
     use super::*;
     use cmd::Command;
+    use cmd::backlight::BacklightAction;
     use cmd::diag::DiagCmd;
     use cmd::diag::lighting::Method;
     use cmd::diag::wheel::ResolutionArg;
@@ -63,6 +64,41 @@ mod tests {
         assert!(cli.cmd.is_none());
     }
 
+    /// A bare `openlogi backlight` must stay valid — `run` treats a missing
+    /// action as `status`, so it can never write to the device by accident.
+    #[test]
+    fn backlight_defaults_to_status_and_accepts_a_device_filter() {
+        let cli = Cli::try_parse_from(["openlogi", "backlight", "--device", "MX KEYS S"])
+            .expect("bare backlight invocation parses");
+
+        match cli.cmd.expect("subcommand present") {
+            Command::Backlight(args) => {
+                assert_eq!(args.device.as_deref(), Some("MX KEYS S"));
+                assert!(args.action.is_none());
+            }
+            other => panic!("expected Backlight, got {other:?}"),
+        }
+    }
+
+    #[test]
+    fn backlight_off_is_parsed_as_its_own_action() {
+        let cli =
+            Cli::try_parse_from(["openlogi", "backlight", "off"]).expect("backlight off parses");
+
+        match cli.cmd.expect("subcommand present") {
+            Command::Backlight(args) => {
+                assert!(matches!(args.action, Some(BacklightAction::Off)));
+            }
+            other => panic!("expected Backlight, got {other:?}"),
+        }
+    }
+
+    #[test]
+    fn backlight_rejects_an_unknown_action() {
+        let result = Cli::try_parse_from(["openlogi", "backlight", "dim"]);
+        assert!(result.is_err());
+    }
+
     #[test]
     fn smartshift_leave_flipped_conflicts_with_sensitivity() {
         let result = Cli::try_parse_from([
diff --git a/crates/openlogi-core/Cargo.toml b/crates/openlogi-core/Cargo.toml
index abaee6068bcf53fa5f6a014a8dcd590d9479baf1..49af4e064eeb179e356f6a940c2ee5441aac9444 100644
--- a/crates/openlogi-core/Cargo.toml
+++ b/crates/openlogi-core/Cargo.toml
@@ -18,6 +18,9 @@ tracing = { workspace = true }
 etcetera = "0.11.0"
 atomic-write-file = "0.3.0"
 
+[target.'cfg(target_os = "macos")'.dependencies]
+plist = "1.10.0"
+
 [dev-dependencies]
 tempfile = "3"
 tracing-subscriber = { workspace = true }
diff --git a/crates/openlogi-core/src/binding.rs b/crates/openlogi-core/src/binding.rs
index 95fae5e56de064e19249feb231ab5c41aa991cf0..3e5ade69ee65441e7171bf0b2484f500155c6f3b 100644
--- a/crates/openlogi-core/src/binding.rs
+++ b/crates/openlogi-core/src/binding.rs
@@ -5,1105 +5,31 @@
 //! When [`Action`] gains new variants, keep the existing variant names stable:
 //! the TOML config keys/values use the enum variant identifiers verbatim, so
 //! renames are migration events.
-
-use std::collections::BTreeMap;
-use std::fmt;
-
-use serde::{Deserialize, Serialize};
-
+//!
+//! Modules are split by domain so concurrent feature work (new buttons, new
+//! actions, defaults, gesture maps) rarely edits the same file.
+
+mod action;
+mod button;
+mod category;
+mod defaults;
+mod gesture;
+mod key_combo;
 mod swipe;
+mod value;
 
+#[cfg(test)]
+#[allow(clippy::expect_used, reason = "expect/unwrap are idiomatic in tests")]
+mod tests;
+
+pub use action::{Action, WorkflowStep};
+pub use button::ButtonId;
+pub use category::Category;
+pub use defaults::{default_binding, default_binding_for, default_gesture_binding};
+pub use gesture::GestureDirection;
+pub use key_combo::KeyCombo;
 pub use swipe::{
     GESTURE_HOLD_FOR_SWIPE, GESTURE_SWIPE_DEADZONE, GESTURE_SWIPE_THRESHOLD, SwipeAccumulator,
     detect_swipe,
 };
-
-/// One of the user-rebindable hotspots on a Logi mouse. The order matches the
-/// physical layout from front to side; [`ButtonId::ALL`] is consumed by the
-/// default-binding generator and the popover trigger list.
-#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)]
-pub enum ButtonId {
-    /// The primary button. Rebindable in the config schema, but the OS hook
-    /// never suppresses it — see [`ButtonId::is_os_hook_button`].
-    LeftClick,
-    /// The secondary button. Like [`ButtonId::LeftClick`], it always passes
-    /// through the OS hook.
-    RightClick,
-    /// The wheel click — one of the three buttons the OS hook remaps.
-    MiddleClick,
-    /// The thumb-side "back" button (mouse button 4), remapped by the OS hook.
-    Back,
-    /// The thumb-side "forward" button (mouse button 5), remapped by the OS hook.
-    Forward,
-    /// The "ModeShift" button under the wheel — typically used for SmartShift /
-    /// DPI cycle. Named `DpiToggle` for historical reasons.
-    DpiToggle,
-    /// The horizontal thumb wheel's click. Kept in [`ButtonId::ALL`] so its
-    /// default still seeds and dispatches when the wheel is diverted, even
-    /// though the mouse model surfaces one paired rotation control instead of
-    /// the click (see `mouse_model::geometry`).
-    Thumbwheel,
-    /// Rotating the thumb wheel "up" (positive rotation). Bound, by default, to
-    /// continuous horizontal scroll; see the agent-core `watchers`-side dispatch.
-    ThumbwheelScrollUp,
-    /// Rotating the thumb wheel "down" (negative rotation).
-    ThumbwheelScrollDown,
-    /// The HID++ gesture button on MX-line devices. The press itself
-    /// fires the bound action; swipe directions are P1.5 territory.
-    GestureButton,
-}
-
-impl ButtonId {
-    /// Every rebindable button in declaration (physical front-to-side) order —
-    /// the iteration source for default-binding seeding and the popover
-    /// trigger list.
-    pub const ALL: [ButtonId; 10] = [
-        ButtonId::LeftClick,
-        ButtonId::RightClick,
-        ButtonId::MiddleClick,
-        ButtonId::Back,
-        ButtonId::Forward,
-        ButtonId::DpiToggle,
-        ButtonId::Thumbwheel,
-        ButtonId::ThumbwheelScrollUp,
-        ButtonId::ThumbwheelScrollDown,
-        ButtonId::GestureButton,
-    ];
-
-    /// Whether this button is one the OS hook (macOS `CGEventTap` / Linux evdev)
-    /// remaps: Middle, Back, or Forward. The primary L/R clicks always pass
-    /// through (suppressing them would brick the mouse), and the DPI / thumb /
-    /// dedicated gesture controls aren't visible to the OS hook at all (they're
-    /// captured over HID++). These are exactly the buttons that can become an
-    /// OS-hook gesture button, so the hook's remap gate and the gesture-owner
-    /// projection share this one definition.
-    #[must_use]
-    pub fn is_os_hook_button(self) -> bool {
-        matches!(
-            self,
-            ButtonId::MiddleClick | ButtonId::Back | ButtonId::Forward
-        )
-    }
-
-    /// Human-readable label for popovers and tooltips.
-    #[must_use]
-    pub fn label(self) -> &'static str {
-        match self {
-            ButtonId::LeftClick => "Left Click",
-            ButtonId::RightClick => "Right Click",
-            ButtonId::MiddleClick => "Middle Click",
-            ButtonId::Back => "Back",
-            ButtonId::Forward => "Forward",
-            ButtonId::DpiToggle => "DPI Toggle",
-            ButtonId::Thumbwheel => "Thumb Wheel",
-            ButtonId::ThumbwheelScrollUp => "Thumb Wheel Up",
-            ButtonId::ThumbwheelScrollDown => "Thumb Wheel Down",
-            ButtonId::GestureButton => "Gesture Button",
-        }
-    }
-}
-
-impl fmt::Display for ButtonId {
-    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
-        f.write_str(self.label())
-    }
-}
-
-/// One of the five sub-bindings on the gesture button: hold + swipe up/down/
-/// left/right or a plain click without movement. Logi ships these as
-/// independent assignments (`SLOT_NAME_GESTURE_*_BUTTON` in the
-/// `device_gesture_buttons_image` metadata block) — OpenLogi mirrors the
-/// same shape.
-///
-/// Variant identifiers are TOML-stable: renames are migration events.
-#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)]
-pub enum GestureDirection {
-    /// Hold + swipe up (negative raw-XY `dy`).
-    Up,
-    /// Hold + swipe down (positive raw-XY `dy`).
-    Down,
-    /// Hold + swipe left (negative raw-XY `dx`).
-    Left,
-    /// Hold + swipe right (positive raw-XY `dx`).
-    Right,
-    /// A press-and-release that never committed a swipe — the gesture
-    /// button's plain-click slot.
-    Click,
-}
-
-impl GestureDirection {
-    /// All five direction slots, swipes first and [`Click`](Self::Click) last.
-    /// Iterated to seed or complete a full gesture map — see
-    /// [`Binding::fill_gesture_defaults`] and [`default_binding_for`].
-    pub const ALL: [GestureDirection; 5] = [
-        GestureDirection::Up,
-        GestureDirection::Down,
-        GestureDirection::Left,
-        GestureDirection::Right,
-        GestureDirection::Click,
-    ];
-
-    /// Human-readable label for popovers and tooltips.
-    #[must_use]
-    pub fn label(self) -> &'static str {
-        match self {
-            GestureDirection::Up => "Up",
-            GestureDirection::Down => "Down",
-            GestureDirection::Left => "Left",
-            GestureDirection::Right => "Right",
-            GestureDirection::Click => "Click",
-        }
-    }
-
-    /// Arrow glyph for compact list rendering.
-    #[must_use]
-    pub fn glyph(self) -> &'static str {
-        match self {
-            GestureDirection::Up => "↑",
-            GestureDirection::Down => "↓",
-            GestureDirection::Left => "←",
-            GestureDirection::Right => "→",
-            GestureDirection::Click => "·",
-        }
-    }
-}
-
-impl fmt::Display for GestureDirection {
-    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
-        f.write_str(self.label())
-    }
-}
-
-/// Grouping for popover section headers.
-///
-/// Used by [`Action::category`] and rendered as a small muted label above
-/// each group in the action picker.
-#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
-pub enum Category {
-    /// Cut, copy, paste, undo, redo, select-all, find, save.
-    Editing,
-    /// Browser navigation: tabs, page reload, back/forward.
-    Browser,
-    /// Playback and volume controls.
-    Media,
-    /// Physical mouse clicks.
-    Mouse,
-    /// DPI cycle and SmartShift.
-    Dpi,
-    /// Scroll direction shortcuts.
-    Scroll,
-    /// Window/app navigation: Mission Control, Launchpad, etc.
-    Navigation,
-    /// Lock screen, show desktop, system-level actions.
-    System,
-}
-
-impl Category {
-    /// Short label for popover section headers (already uppercase so callers
-    /// don't have to transform it).
-    #[must_use]
-    pub fn label(self) -> &'static str {
-        match self {
-            Category::Editing => "EDITING",
-            Category::Browser => "BROWSER",
-            Category::Media => "MEDIA",
-            Category::Mouse => "MOUSE",
-            Category::Dpi => "DPI",
-            Category::Scroll => "SCROLL",
-            Category::Navigation => "NAVIGATION",
-            Category::System => "SYSTEM",
-        }
-    }
-}
-
-/// What pressing a [`ButtonId`] should do.
-///
-/// Serialization uses serde's default external tagging: unit variants
-/// serialize as a bare string (`"BrowserBack"`) and the tuple variant
-/// serializes as a single-key table (`{ CustomShortcut = "my chord" }`).
-///
-/// **Stability contract:** existing variant *names* are frozen — they form the
-/// on-disk `config.toml` schema. New variants may be appended freely; removing
-/// or renaming a variant requires a `schema_version` bump and a migration.
-///
-/// This type is pure config data: OS-level event synthesis for each variant
-/// lives in the `openlogi-inject` crate (`openlogi_inject::execute`), keeping
-/// this crate platform- and IO-free.
-#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
-pub enum Action {
-    // ── System ───────────────────────────────────────────────────────────────
-    /// Suppress the input entirely — the button or wheel direction is captured
-    /// but no OS event is synthesised, so the physical input does nothing.
-    None,
-
-    // ── Mouse ────────────────────────────────────────────────────────────────
-    /// Primary mouse button.
-    LeftClick,
-    /// Secondary mouse button.
-    RightClick,
-    /// Middle mouse button (wheel click).
-    MiddleClick,
-    /// Mouse "back" side button (extra button 4). Synthesizes the real mouse
-    /// button event, which browsers and most apps interpret as "navigate back"
-    /// natively — unlike [`Action::BrowserBack`], which sends ⌘[ and is ignored
-    /// by many apps.
-    MouseBack,
-    /// Mouse "forward" side button (extra button 5). Native counterpart to
-    /// [`Action::MouseBack`]; see [`Action::BrowserForward`] for the ⌘] form.
-    MouseForward,
-
-    // ── Editing ──────────────────────────────────────────────────────────────
-    /// Copy the current selection (⌘C / Ctrl+C).
-    Copy,
-    /// Paste from the clipboard (⌘V / Ctrl+V).
-    Paste,
-    /// Cut the current selection (⌘X / Ctrl+X).
-    Cut,
-    /// Undo the last action (⌘Z / Ctrl+Z).
-    Undo,
-    /// Redo the last undone action (⌘⇧Z on macOS / Ctrl+Shift+Z on Linux).
-    ///
-    /// Note: Ctrl+Y is the dominant redo shortcut in LibreOffice and many GTK
-    /// apps. Ctrl+Shift+Z is used here because it mirrors the macOS convention
-    /// and works in GNOME text fields, browsers, and Electron apps. If Ctrl+Y
-    /// coverage is needed, a `CustomShortcut` binding is the escape hatch.
-    Redo,
-    /// Select all content (⌘A / Ctrl+A).
-    SelectAll,
-    /// Open the find / search bar (⌘F / Ctrl+F).
-    Find,
-    /// Save the current document (⌘S / Ctrl+S).
-    Save,
-
-    // ── Browser / Navigation ──────────────────────────────────────────────────
-    /// Navigate backward in browser history.
-    BrowserBack,
-    /// Navigate forward in browser history.
-    BrowserForward,
-    /// Open a new tab (⌘T / Ctrl+T).
-    NewTab,
-    /// Close the current tab (⌘W / Ctrl+W).
-    CloseTab,
-    /// Reopen the last closed tab (⌘⇧T / Ctrl+Shift+T).
-    ReopenTab,
-    /// Switch to the next tab (⌃⇥ / Ctrl+Tab).
-    NextTab,
-    /// Switch to the previous tab (⌃⇧⇥ / Ctrl+Shift+Tab).
-    PrevTab,
-    /// Reload the current page (⌘R / Ctrl+R).
-    ReloadPage,
-
-    // ── Navigation / Window ───────────────────────────────────────────────────
-    /// macOS Mission Control (⌃↑).
-    MissionControl,
-    /// macOS App Exposé — all windows for the current app (⌃↓).
-    AppExpose,
-    /// Switch to the previous desktop / Space.
-    PreviousDesktop,
-    /// Switch to the next desktop / Space.
-    NextDesktop,
-    /// Show the desktop (hide all windows).
-    ShowDesktop,
-    /// Open Launchpad.
-    LaunchpadShow,
-
-    // ── System ────────────────────────────────────────────────────────────────
-    /// Lock the screen (⌘⌃Q on macOS).
-    ///
-    /// On Linux, calls `org.freedesktop.login1.Manager.LockSession($XDG_SESSION_ID)`
-    /// on the system bus (current session only). Falls back to Super+L when
-    /// `$XDG_SESSION_ID` is unset or on non-systemd systems.
-    LockScreen,
-    /// Capture a screenshot.
-    Screenshot,
-    /// Capture a selected screen region to the clipboard.
-    ///
-    /// macOS uses Cmd+Shift+Ctrl+4; Windows uses Win+Shift+S. Linux delegates
-    /// to the desktop environment's screenshot handler via Print Screen.
-    CaptureRegion,
-
-    // ── Media ────────────────────────────────────────────────────────────────
-    /// Toggle media play/pause.
-    PlayPause,
-    /// Skip to the next track.
-    NextTrack,
-    /// Go back to the previous track.
-    PrevTrack,
-    /// Increase system volume.
-    VolumeUp,
-    /// Decrease system volume.
-    VolumeDown,
-    /// Toggle system mute.
-    MuteVolume,
-
-    // ── DPI ──────────────────────────────────────────────────────────────────
-    /// Step through the configured DPI preset list (P1.7).
-    CycleDpiPresets,
-    /// Jump to a specific zero-based preset in the device's DPI preset list.
-    /// Out-of-range indices clamp to the list length at fire time (P1.7).
-    SetDpiPreset(u8),
-    /// Toggle the HID++ SmartShift ratchet/free-spin wheel mode (P1.1).
-    ToggleSmartShift,
-
-    // ── Scroll ───────────────────────────────────────────────────────────────
-    /// Synthesise a vertical scroll-up tick.
-    ScrollUp,
-    /// Synthesise a vertical scroll-down tick.
-    ScrollDown,
-    /// Synthesise a horizontal scroll-left tick.
-    HorizontalScrollLeft,
-    /// Synthesise a horizontal scroll-right tick.
-    HorizontalScrollRight,
-
-    // ── Custom ───────────────────────────────────────────────────────────────
-    /// Replay an arbitrary recorded key chord (P1.3).
-    ///
-    /// Holds the structured chord data so `openlogi_inject::execute` can post the
-    /// real keystroke (macOS: CGEventPost with the encoded modifier flags).
-    /// The `display` field is used by [`Action::label`] so the popover
-    /// shows the user-friendly chord name.
-    CustomShortcut(KeyCombo),
-}
-
-/// A modifier + virtual-key keystroke captured by the P1.3 recorder UI or
-/// hand-authored in `config.toml`.
-///
-/// `modifiers` is a bitmask of [`KeyCombo::MOD_CMD`] etc. so the wire format
-/// is a compact integer, not a string. `key_code` is the macOS virtual key
-/// (`kVK_*`); on Linux, `openlogi-inject` maps it to an evdev `KeyCode` when it
-/// synthesizes the chord.
-///
-/// `display` is purely for rendering — e.g. `"⌘⇧P"`. Callers regenerate it
-/// from the captured chord; we keep it in the struct so older configs
-/// continue to render the same label without re-deriving on every load.
-#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
-pub struct KeyCombo {
-    /// Bitmask of [`Self::MOD_CMD`] etc.
-    pub modifiers: u8,
-    /// macOS virtual key code (`kVK_*`). 0 means "no key" — useful for
-    /// modifier-only placeholders that the recorder UI rejects. On Linux,
-    /// `openlogi-inject` translates this to an evdev `KeyCode`.
-    pub key_code: u16,
-    /// Pre-rendered chord label, e.g. `"⌘⇧P"`. Empty falls through to a
-    /// generated label at runtime.
-    #[serde(default)]
-    pub display: String,
-}
-
-impl KeyCombo {
-    /// Bit for the ⌘ Command modifier in [`Self::modifiers`].
-    pub const MOD_CMD: u8 = 1 << 0;
-    /// Bit for the ⇧ Shift modifier in [`Self::modifiers`].
-    pub const MOD_SHIFT: u8 = 1 << 1;
-    /// Bit for the ⌃ Control modifier in [`Self::modifiers`].
-    pub const MOD_CTRL: u8 = 1 << 2;
-    /// Bit for the ⌥ Option/Alt modifier in [`Self::modifiers`].
-    pub const MOD_OPTION: u8 = 1 << 3;
-
-    /// Build the human-readable label from the modifier bitmask + key code.
-    /// Falls back to `"⌘key 0xNN"` when the key code isn't one of the
-    /// commonly-recognised letters; the recorder UI usually overrides this
-    /// with its own derivation.
-    #[must_use]
-    pub fn rendered_label(&self) -> String {
-        if !self.display.is_empty() {
-            return self.display.clone();
-        }
-        let mut out = String::new();
-        if self.modifiers & Self::MOD_CTRL != 0 {
-            out.push('⌃');
-        }
-        if self.modifiers & Self::MOD_OPTION != 0 {
-            out.push('⌥');
-        }
-        if self.modifiers & Self::MOD_SHIFT != 0 {
-            out.push('⇧');
-        }
-        if self.modifiers & Self::MOD_CMD != 0 {
-            out.push('⌘');
-        }
-        match self.key_code {
-            0x00 => out.push('A'),
-            0x01 => out.push('S'),
-            0x02 => out.push('D'),
-            0x03 => out.push('F'),
-            0x06 => out.push('Z'),
-            0x07 => out.push('X'),
-            0x08 => out.push('C'),
-            0x09 => out.push('V'),
-            0x0B => out.push('B'),
-            0x0C => out.push('Q'),
-            0x0D => out.push('W'),
-            0x0E => out.push('E'),
-            0x0F => out.push('R'),
-            0x10 => out.push('Y'),
-            0x11 => out.push('T'),
-            0x20 => out.push('U'),
-            0x22 => out.push('I'),
-            0x1F => out.push('O'),
-            0x23 => out.push('P'),
-            _ => {
-                use std::fmt::Write as _;
-                let _ = write!(out, "key 0x{:02X}", self.key_code);
-            }
-        }
-        out
-    }
-}
-
-/// What a single rebindable [`ButtonId`] does: either one [`Action`], or — for a
-/// raw-XY-capable button placed in gesture mode — a per-[`GestureDirection`]
-/// map (hold + swipe up/down/left/right, or a plain click).
-///
-/// There has only ever been one binding map per device; a gesture binding is
-/// just a binding whose payload is a direction map instead of a single action.
-///
-/// # Serialization
-///
-/// `#[serde(untagged)]`: [`Single`](Binding::Single) serializes exactly as the
-/// bare [`Action`] did before (a string `"BrowserBack"`, or a single-key table
-/// for the payload variants), and [`Gesture`](Binding::Gesture) serializes as a
-/// table keyed by [`GestureDirection`] names (`Up`/`Down`/`Left`/`Right`/
-/// `Click`).
-///
-/// The two arms are disambiguated by the **zero overlap** between [`Action`]
-/// variant names and [`GestureDirection`] variant names — untagged tries
-/// `Single(Action)` first, and a table keyed by `Up` etc. cannot parse as an
-/// externally-tagged `Action`, so it falls through to `Gesture`. A payload
-/// action like `{ SetDpiPreset = 2 }` is a valid externally-tagged `Action`, so
-/// it stays `Single` and never reaches the `Gesture` arm. This invariant is the
-/// entire safety basis for untagged routing; the `binding_untagged_*` tests
-/// guard it (a future `Action` named `Up`/`Down`/`Left`/`Right`/`Click` would
-/// silently mis-route, and those tests would fail).
-#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
-#[serde(untagged)]
-pub enum Binding {
-    /// One action, fired on press. The shape every non-gesture button uses.
-    Single(Action),
-    /// Per-direction sub-bindings for a button in gesture mode. Keyed by the
-    /// committed swipe direction, with [`GestureDirection::Click`] holding the
-    /// plain-click (no-swipe) action.
-    Gesture(BTreeMap<GestureDirection, Action>),
-}
-
-impl Binding {
-    /// The plain-click action for this binding: the [`Single`](Binding::Single)
-    /// action, or the [`Gesture`](Binding::Gesture) map's
-    /// [`Click`](GestureDirection::Click) entry. Falls back to [`Action::None`]
-    /// when a gesture binding has no explicit `Click`.
-    ///
-    /// Lets the click-dispatch path stay binding-shape-agnostic.
-    #[must_use]
-    pub fn click_action(&self) -> Action {
-        match self {
-            Binding::Single(action) => action.clone(),
-            Binding::Gesture(map) => map
-                .get(&GestureDirection::Click)
-                .cloned()
-                .unwrap_or(Action::None),
-        }
-    }
-
-    /// The action bound to `direction`, if this is a gesture binding.
-    /// [`Single`](Binding::Single) has no directions and returns `None`.
-    #[must_use]
-    pub fn direction_action(&self, direction: GestureDirection) -> Option<&Action> {
-        match self {
-            Binding::Single(_) => None,
-            Binding::Gesture(map) => map.get(&direction),
-        }
-    }
-
-    /// Whether this binding drives raw-XY swipe capture (the
-    /// [`Gesture`](Binding::Gesture) arm).
-    #[must_use]
-    pub fn is_gesture(&self) -> bool {
-        matches!(self, Binding::Gesture(_))
-    }
-
-    /// Promote a [`Single`](Binding::Single) binding in place to a
-    /// [`Gesture`](Binding::Gesture), keeping its action as the
-    /// [`GestureDirection::Click`] entry and leaving the swipe arms unbound.
-    /// A no-op when this is already a [`Gesture`](Binding::Gesture).
-    pub fn upgrade_to_gesture(&mut self) {
-        if let Binding::Single(action) = self {
-            let mut map = BTreeMap::new();
-            map.insert(GestureDirection::Click, action.clone());
-            *self = Binding::Gesture(map);
-        }
-    }
-
-    /// Fill any unbound directions of a [`Gesture`](Binding::Gesture) binding
-    /// with their canonical [`default_gesture_binding`], so a button promoted to
-    /// the gesture role always exposes the full five-direction set — rather than
-    /// leaving swipe arms the GUI renders as defaults but the runtime never
-    /// dispatches. A no-op on [`Single`](Binding::Single) and on directions
-    /// already bound (existing user choices are preserved).
-    pub fn fill_gesture_defaults(&mut self) {
-        if let Binding::Gesture(map) = self {
-            for dir in GestureDirection::ALL {
-                map.entry(dir)
-                    .or_insert_with(|| default_gesture_binding(dir));
-            }
-        }
-    }
-}
-
-impl From<Action> for Binding {
-    fn from(action: Action) -> Self {
-        Binding::Single(action)
-    }
-}
-
-impl Action {
-    /// Display label for the popover row.
-    ///
-    /// Returns `String` rather than `&str` so parameterized variants (e.g.
-    /// `SetDpiPreset(i)`, `CustomShortcut(s)`) can build a label that
-    /// includes their payload.
-    #[must_use]
-    pub fn label(&self) -> String {
-        match self {
-            Action::None => "Do Nothing".into(),
-            Action::LeftClick => "Left Click".into(),
-            Action::RightClick => "Right Click".into(),
-            Action::MiddleClick => "Middle Click".into(),
-            Action::MouseBack => "Back (Button 4)".into(),
-            Action::MouseForward => "Forward (Button 5)".into(),
-            Action::Copy => "Copy".into(),
-            Action::Paste => "Paste".into(),
-            Action::Cut => "Cut".into(),
-            Action::Undo => "Undo".into(),
-            Action::Redo => "Redo".into(),
-            Action::SelectAll => "Select All".into(),
-            Action::Find => "Find".into(),
-            Action::Save => "Save".into(),
-            Action::BrowserBack => "Browser Back".into(),
-            Action::BrowserForward => "Browser Forward".into(),
-            Action::NewTab => "New Tab".into(),
-            Action::CloseTab => "Close Tab".into(),
-            Action::ReopenTab => "Reopen Tab".into(),
-            Action::NextTab => "Next Tab".into(),
-            Action::PrevTab => "Previous Tab".into(),
-            Action::ReloadPage => "Reload Page".into(),
-            Action::MissionControl => "Mission Control".into(),
-            Action::AppExpose => "App Exposé".into(),
-            Action::PreviousDesktop => "Previous Desktop".into(),
-            Action::NextDesktop => "Next Desktop".into(),
-            Action::ShowDesktop => "Show Desktop".into(),
-            Action::LaunchpadShow => "Launchpad".into(),
-            Action::LockScreen => "Lock Screen".into(),
-            Action::Screenshot => "Screenshot".into(),
-            Action::CaptureRegion => "Capture Region".into(),
-            Action::PlayPause => "Play / Pause".into(),
-            Action::NextTrack => "Next Track".into(),
-            Action::PrevTrack => "Previous Track".into(),
-            Action::VolumeUp => "Volume Up".into(),
-            Action::VolumeDown => "Volume Down".into(),
-            Action::MuteVolume => "Mute".into(),
-            Action::CycleDpiPresets => "Cycle DPI Presets".into(),
-            Action::SetDpiPreset(i) => format!("DPI Preset {}", i + 1),
-            Action::ToggleSmartShift => "Toggle SmartShift".into(),
-            Action::ScrollUp => "Scroll Up".into(),
-            Action::ScrollDown => "Scroll Down".into(),
-            Action::HorizontalScrollLeft => "Scroll Left".into(),
-            Action::HorizontalScrollRight => "Scroll Right".into(),
-            Action::CustomShortcut(combo) => combo.rendered_label(),
-        }
-    }
-
-    /// Which [`Category`] this action belongs to, used for popover grouping.
-    #[must_use]
-    pub fn category(&self) -> Category {
-        match self {
-            Action::LeftClick
-            | Action::RightClick
-            | Action::MiddleClick
-            | Action::MouseBack
-            | Action::MouseForward => Category::Mouse,
-            // CustomShortcut is assigned to Editing so it doesn't need a
-            // separate arm (it's not in the picker catalog).
-            Action::Copy
-            | Action::Paste
-            | Action::Cut
-            | Action::Undo
-            | Action::Redo
-            | Action::SelectAll
-            | Action::Find
-            | Action::Save
-            | Action::CustomShortcut(_) => Category::Editing,
-            Action::BrowserBack
-            | Action::BrowserForward
-            | Action::NewTab
-            | Action::CloseTab
-            | Action::ReopenTab
-            | Action::NextTab
-            | Action::PrevTab
-            | Action::ReloadPage => Category::Browser,
-            Action::MissionControl
-            | Action::AppExpose
-            | Action::PreviousDesktop
-            | Action::NextDesktop
-            | Action::ShowDesktop
-            | Action::LaunchpadShow => Category::Navigation,
-            Action::None | Action::LockScreen | Action::Screenshot | Action::CaptureRegion => {
-                Category::System
-            }
-            Action::PlayPause
-            | Action::NextTrack
-            | Action::PrevTrack
-            | Action::VolumeUp
-            | Action::VolumeDown
-            | Action::MuteVolume => Category::Media,
-            Action::CycleDpiPresets | Action::SetDpiPreset(_) | Action::ToggleSmartShift => {
-                Category::Dpi
-            }
-            Action::ScrollUp
-            | Action::ScrollDown
-            | Action::HorizontalScrollLeft
-            | Action::HorizontalScrollRight => Category::Scroll,
-        }
-    }
-
-    /// All pickable actions in a deterministic order.
-    ///
-    /// [`Action::CustomShortcut`] is intentionally excluded — it is opened via
-    /// "Record shortcut…" (P1.3), not selected from the catalog.
-    #[must_use]
-    pub fn catalog() -> Vec<Action> {
-        vec![
-            // Mouse
-            Action::LeftClick,
-            Action::RightClick,
-            Action::MiddleClick,
-            Action::MouseBack,
-            Action::MouseForward,
-            // Editing
-            Action::Copy,
-            Action::Paste,
-            Action::Cut,
-            Action::Undo,
-            Action::Redo,
-            Action::SelectAll,
-            Action::Find,
-            Action::Save,
-            // Browser
-            Action::BrowserBack,
-            Action::BrowserForward,
-            Action::NewTab,
-            Action::CloseTab,
-            Action::ReopenTab,
-            Action::NextTab,
-            Action::PrevTab,
-            Action::ReloadPage,
-            // Navigation
-            Action::MissionControl,
-            Action::AppExpose,
-            Action::PreviousDesktop,
-            Action::NextDesktop,
-            Action::ShowDesktop,
-            Action::LaunchpadShow,
-            // System
-            Action::None,
-            Action::LockScreen,
-            Action::Screenshot,
-            Action::CaptureRegion,
-            // Media
-            Action::PlayPause,
-            Action::NextTrack,
-            Action::PrevTrack,
-            Action::VolumeUp,
-            Action::VolumeDown,
-            Action::MuteVolume,
-            // DPI
-            Action::CycleDpiPresets,
-            Action::ToggleSmartShift,
-            // Scroll
-            Action::ScrollUp,
-            Action::ScrollDown,
-            Action::HorizontalScrollLeft,
-            Action::HorizontalScrollRight,
-        ]
-    }
-}
-
-/// Sensible defaults for a fresh device so the panel isn't empty on first run.
-///
-/// Thumbwheel / GestureButton defaults match what Logi Options+ ships for
-/// MX-line devices: thumb wheel click → App Exposé, gesture button →
-/// Mission Control. The thumb wheel isn't captured yet; the dedicated gesture button is
-/// (per-direction, see [`default_gesture_binding`]). The bindings persist
-/// regardless so the user only configures once.
-///
-/// `GestureButton`'s entry here is vestigial: in the merged [`Binding`] model
-/// the gesture button defaults to [`Binding::Gesture`] (see
-/// [`default_binding_for`]), so this single-action value is never the source of
-/// truth for it. It is retained only so the per-button-`Action` callers (the
-/// hook map, scroll defaults, labels) stay total.
-#[must_use]
-pub fn default_binding(button: ButtonId) -> Action {
-    match button {
-        ButtonId::LeftClick => Action::LeftClick,
-        ButtonId::RightClick => Action::RightClick,
-        ButtonId::MiddleClick => Action::MiddleClick,
-        ButtonId::Back => Action::BrowserBack,
-        ButtonId::Forward => Action::BrowserForward,
-        ButtonId::DpiToggle => Action::CycleDpiPresets,
-        ButtonId::Thumbwheel => Action::AppExpose,
-        // The thumb wheel scrolls horizontally by default: rotating it produces
-        // continuous horizontal scroll, with "up" → right and "down" → left.
-        // The wheel watcher renders these two actions as smooth, sensitivity-
-        // scaled scrolling rather than the discrete per-press burst a button
-        // would get (see `watchers::gesture`).
-        ButtonId::ThumbwheelScrollUp => Action::HorizontalScrollRight,
-        ButtonId::ThumbwheelScrollDown => Action::HorizontalScrollLeft,
-        ButtonId::GestureButton => Action::MissionControl,
-    }
-}
-
-/// Per-direction defaults for the gesture button. These are captured live over
-/// HID++ `0x1b04` (raw-XY diversion) and dispatched like any other binding; the
-/// defaults give the picker something sensible to show on first run.
-#[must_use]
-pub fn default_gesture_binding(direction: GestureDirection) -> Action {
-    match direction {
-        GestureDirection::Up => Action::MissionControl,
-        GestureDirection::Down => Action::ShowDesktop,
-        GestureDirection::Left => Action::PrevTab,
-        GestureDirection::Right => Action::NextTab,
-        GestureDirection::Click => Action::AppExpose,
-    }
-}
-
-/// The canonical default [`Binding`] for a fresh button in the merged model.
-///
-/// [`ButtonId::GestureButton`] defaults to [`Binding::Gesture`] populated from
-/// [`default_gesture_binding`] — preserving the existing per-direction swipe
-/// behavior — so the GUI mode toggle and the runtime agree it starts in gesture
-/// mode. Every other button defaults to [`Binding::Single`] of its
-/// [`default_binding`].
-///
-/// This is the seed when a button is first promoted to a gesture binding (see
-/// [`Config::set_gesture_direction`](crate::config::Config::set_gesture_direction)),
-/// so a freshly-customized gesture button always carries a full default
-/// direction map — including a [`GestureDirection::Click`] — rather than a sparse
-/// map whose click would project to a no-op [`Action::None`].
-#[must_use]
-pub fn default_binding_for(button: ButtonId) -> Binding {
-    match button {
-        ButtonId::GestureButton => Binding::Gesture(
-            GestureDirection::ALL
-                .into_iter()
-                .map(|d| (d, default_gesture_binding(d)))
-                .collect(),
-        ),
-        other => Binding::Single(default_binding(other)),
-    }
-}
-
-#[cfg(test)]
-#[allow(clippy::expect_used, reason = "expect/unwrap are idiomatic in tests")]
-mod tests {
-    use std::assert_matches;
-    use std::collections::BTreeMap;
-
-    use serde::{Deserialize, Serialize};
-
-    use super::*;
-
-    // ── Roundtrip wrapper: defined here so it precedes any `let` statements ──
-
-    /// Minimal TOML-serializable wrapper used by `roundtrip`.
-    /// Defined at module scope to satisfy `clippy::items_after_statements`.
-    #[derive(Serialize, Deserialize)]
-    struct RoundtripWrapper {
-        binding: BTreeMap<ButtonId, Action>,
-    }
-
-    // ── Catalog tests ─────────────────────────────────────────────────────────
-
-    #[test]
-    fn catalog_has_at_least_29_entries() {
-        let catalog = Action::catalog();
-        assert!(
-            catalog.len() >= 29,
-            "catalog has {} entries, need ≥ 29",
-            catalog.len()
-        );
-    }
-
-    #[test]
-    fn catalog_excludes_custom_shortcut() {
-        let catalog = Action::catalog();
-        for action in &catalog {
-            assert!(
-                !matches!(action, Action::CustomShortcut(_)),
-                "catalog must not contain CustomShortcut"
-            );
-        }
-    }
-
-    // ── Binding (merged model) serde routing ──────────────────────────────────
-
-    /// On-disk shape: a `ButtonId` → [`Binding`] map, as `DeviceConfig.bindings`
-    /// serializes it.
-    #[derive(Serialize, Deserialize)]
-    struct BindingWrapper {
-        bindings: BTreeMap<ButtonId, Binding>,
-    }
-
-    fn binding_roundtrip(bindings: BTreeMap<ButtonId, Binding>) -> BTreeMap<ButtonId, Binding> {
-        let toml = toml::to_string_pretty(&BindingWrapper { bindings }).expect("serialize");
-        toml::from_str::<BindingWrapper>(&toml)
-            .expect("deserialize")
-            .bindings
-    }
-
-    #[test]
-    fn binding_single_roundtrips_including_payload_variants() {
-        let mut bindings = BTreeMap::new();
-        bindings.insert(ButtonId::Back, Binding::Single(Action::BrowserBack));
-        bindings.insert(
-            ButtonId::DpiToggle,
-            Binding::Single(Action::SetDpiPreset(2)),
-        );
-        bindings.insert(
-            ButtonId::Forward,
-            Binding::Single(Action::CustomShortcut(KeyCombo {
-                modifiers: KeyCombo::MOD_CMD,
-                key_code: 0x23,
-                display: "⌘P".into(),
-            })),
-        );
-        let back = binding_roundtrip(bindings);
-        assert_eq!(back[&ButtonId::Back], Binding::Single(Action::BrowserBack));
-        assert_eq!(
-            back[&ButtonId::DpiToggle],
-            Binding::Single(Action::SetDpiPreset(2))
-        );
-        assert_matches!(
-            back[&ButtonId::Forward],
-            Binding::Single(Action::CustomShortcut(_))
-        );
-    }
-
-    #[test]
-    fn binding_gesture_roundtrips() {
-        let mut map = BTreeMap::new();
-        map.insert(GestureDirection::Up, Action::Copy);
-        map.insert(GestureDirection::Click, Action::Paste);
-        let mut bindings = BTreeMap::new();
-        bindings.insert(ButtonId::GestureButton, Binding::Gesture(map.clone()));
-        let back = binding_roundtrip(bindings);
-        assert_eq!(back[&ButtonId::GestureButton], Binding::Gesture(map));
-    }
-
-    /// The untagged-routing safety guard. A TOML table keyed by ANY
-    /// [`GestureDirection`] name must deserialize as [`Binding::Gesture`], never
-    /// [`Binding::Single`]. If a future [`Action`] payload variant is ever named
-    /// `Up`/`Down`/`Left`/`Right`/`Click`, the table would parse as `Single`
-    /// first and this test fails — catching the silent mis-route at CI time.
-    #[test]
-    fn binding_direction_keyed_table_routes_to_gesture() {
-        for dir in GestureDirection::ALL {
-            // `GestureDirection`'s serde key equals its `Display`/variant name.
-            let toml = format!("bindings.GestureButton.{dir} = \"None\"");
-            let parsed = toml::from_str::<BindingWrapper>(&toml).expect("deserialize");
-            assert!(
-                matches!(
-                    parsed.bindings[&ButtonId::GestureButton],
-                    Binding::Gesture(_)
-                ),
-                "a {dir}-keyed table must route to Gesture, not Single"
-            );
-        }
-    }
-
-    /// The collision case: a payload [`Action`] also serializes as a single-key
-    /// table, but untagged must keep it [`Binding::Single`] (it parses as a valid
-    /// externally-tagged `Action` before the `Gesture` arm is tried).
-    #[test]
-    fn binding_payload_action_stays_single() {
-        let toml = "bindings.DpiToggle.SetDpiPreset = 2";
-        let parsed = toml::from_str::<BindingWrapper>(toml).expect("deserialize");
-        assert_eq!(
-            parsed.bindings[&ButtonId::DpiToggle],
-            Binding::Single(Action::SetDpiPreset(2))
-        );
-    }
-
-    #[test]
-    fn binding_capture_region_roundtrips_as_single_string() {
-        let toml = "bindings.Back = \"CaptureRegion\"";
-        let parsed = toml::from_str::<BindingWrapper>(toml).expect("deserialize");
-        assert_eq!(
-            parsed.bindings[&ButtonId::Back],
-            Binding::Single(Action::CaptureRegion)
-        );
-
-        let back = binding_roundtrip(parsed.bindings);
-        assert_eq!(
-            back[&ButtonId::Back],
-            Binding::Single(Action::CaptureRegion)
-        );
-        assert_eq!(Action::CaptureRegion.label(), "Capture Region");
-        assert_eq!(Action::CaptureRegion.category(), Category::System);
-        assert!(Action::catalog().contains(&Action::CaptureRegion));
-    }
-
-    // ── TOML roundtrip ────────────────────────────────────────────────────────
-
-    /// Serialize then deserialize `action` through TOML, using a wrapper
-    /// struct because TOML requires a top-level table.
-    fn roundtrip(action: &Action) -> Action {
-        let mut map: BTreeMap<ButtonId, Action> = BTreeMap::new();
-        map.insert(ButtonId::Back, action.clone());
-        let w = RoundtripWrapper { binding: map };
-        let s = toml::to_string(&w).expect("serialize");
-        let back: RoundtripWrapper = toml::from_str(&s).expect("deserialize");
-        back.binding
-            .into_values()
-            .next()
-            .expect("binding present after roundtrip")
-    }
-
-    #[test]
-    fn all_catalog_variants_roundtrip_toml() {
-        for action in Action::catalog() {
-            let back = roundtrip(&action);
-            assert_eq!(action, back, "TOML roundtrip failed for {action:?}");
-        }
-    }
-
-    #[test]
-    fn custom_shortcut_roundtrips_toml() {
-        let action = Action::CustomShortcut(KeyCombo {
-            modifiers: KeyCombo::MOD_CMD | KeyCombo::MOD_SHIFT,
-            key_code: 0x23, // kVK_ANSI_P
-            display: "⌘⇧P".into(),
-        });
-        assert_eq!(roundtrip(&action), action);
-    }
-
-    #[test]
-    fn key_combo_rendered_label_uses_display_when_set() {
-        let combo = KeyCombo {
-            modifiers: 0,
-            key_code: 0,
-            display: "preset".into(),
-        };
-        assert_eq!(combo.rendered_label(), "preset");
-    }
-
-    #[test]
-    fn key_combo_rendered_label_falls_back_to_modifiers_plus_key() {
-        let combo = KeyCombo {
-            modifiers: KeyCombo::MOD_CMD | KeyCombo::MOD_SHIFT,
-            key_code: 0x23, // P
-            display: String::new(),
-        };
-        assert_eq!(combo.rendered_label(), "⇧⌘P");
-    }
-
-    // ── Category tests ────────────────────────────────────────────────────────
-
-    #[test]
-    fn category_editing_variants() {
-        assert_eq!(Action::Copy.category(), Category::Editing);
-        assert_eq!(Action::Undo.category(), Category::Editing);
-        assert_eq!(Action::SelectAll.category(), Category::Editing);
-        assert_eq!(Action::Find.category(), Category::Editing);
-        assert_eq!(Action::Save.category(), Category::Editing);
-        assert_eq!(Action::Cut.category(), Category::Editing);
-        assert_eq!(Action::Redo.category(), Category::Editing);
-        assert_eq!(Action::Paste.category(), Category::Editing);
-    }
-
-    #[test]
-    fn category_browser_variants() {
-        assert_eq!(Action::BrowserBack.category(), Category::Browser);
-        assert_eq!(Action::BrowserForward.category(), Category::Browser);
-        assert_eq!(Action::NewTab.category(), Category::Browser);
-        assert_eq!(Action::CloseTab.category(), Category::Browser);
-        assert_eq!(Action::ReopenTab.category(), Category::Browser);
-        assert_eq!(Action::NextTab.category(), Category::Browser);
-        assert_eq!(Action::PrevTab.category(), Category::Browser);
-        assert_eq!(Action::ReloadPage.category(), Category::Browser);
-    }
-
-    #[test]
-    fn category_media_variants() {
-        assert_eq!(Action::PlayPause.category(), Category::Media);
-        assert_eq!(Action::NextTrack.category(), Category::Media);
-        assert_eq!(Action::PrevTrack.category(), Category::Media);
-        assert_eq!(Action::VolumeUp.category(), Category::Media);
-        assert_eq!(Action::VolumeDown.category(), Category::Media);
-        assert_eq!(Action::MuteVolume.category(), Category::Media);
-    }
-
-    #[test]
-    fn category_mouse_variants() {
-        assert_eq!(Action::LeftClick.category(), Category::Mouse);
-        assert_eq!(Action::RightClick.category(), Category::Mouse);
-        assert_eq!(Action::MiddleClick.category(), Category::Mouse);
-    }
-
-    #[test]
-    fn category_dpi_variants() {
-        assert_eq!(Action::CycleDpiPresets.category(), Category::Dpi);
-        assert_eq!(Action::ToggleSmartShift.category(), Category::Dpi);
-    }
-
-    #[test]
-    fn category_scroll_variants() {
-        assert_eq!(Action::ScrollUp.category(), Category::Scroll);
-        assert_eq!(Action::ScrollDown.category(), Category::Scroll);
-        assert_eq!(Action::HorizontalScrollLeft.category(), Category::Scroll);
-        assert_eq!(Action::HorizontalScrollRight.category(), Category::Scroll);
-    }
-
-    #[test]
-    fn category_navigation_variants() {
-        assert_eq!(Action::MissionControl.category(), Category::Navigation);
-        assert_eq!(Action::AppExpose.category(), Category::Navigation);
-        assert_eq!(Action::PreviousDesktop.category(), Category::Navigation);
-        assert_eq!(Action::NextDesktop.category(), Category::Navigation);
-        assert_eq!(Action::ShowDesktop.category(), Category::Navigation);
-        assert_eq!(Action::LaunchpadShow.category(), Category::Navigation);
-    }
-
-    #[test]
-    fn category_system_variants() {
-        assert_eq!(Action::LockScreen.category(), Category::System);
-        assert_eq!(Action::Screenshot.category(), Category::System);
-    }
-
-    // ── Category label smoke test ─────────────────────────────────────────────
-
-    #[test]
-    fn category_labels_are_nonempty() {
-        let categories = [
-            Category::Editing,
-            Category::Browser,
-            Category::Media,
-            Category::Mouse,
-            Category::Dpi,
-            Category::Scroll,
-            Category::Navigation,
-            Category::System,
-        ];
-        for cat in categories {
-            assert!(!cat.label().is_empty(), "label empty for {cat:?}");
-        }
-    }
-
-    // ── Default binding ───────────────────────────────────────────────────────
-
-    #[test]
-    fn dpi_toggle_default_is_cycle_dpi_presets() {
-        assert_eq!(
-            default_binding(ButtonId::DpiToggle),
-            Action::CycleDpiPresets
-        );
-    }
-}
+pub use value::Binding;
diff --git a/crates/openlogi-core/src/binding/action.rs b/crates/openlogi-core/src/binding/action.rs
new file mode 100644
index 0000000000000000000000000000000000000000..f1690ee1145d9355fd18bc57b335198dc9359d3f
--- /dev/null
+++ b/crates/openlogi-core/src/binding/action.rs
@@ -0,0 +1,383 @@
+//! The action vocabulary a button can bind to, plus workflow steps.
+
+use serde::{Deserialize, Serialize};
+
+use super::category::Category;
+use super::key_combo::KeyCombo;
+
+/// What pressing a [`ButtonId`] should do.
+///
+/// Serialization uses serde's default external tagging: unit variants
+/// serialize as a bare string (`"BrowserBack"`) and the tuple variant
+/// serializes as a single-key table (`{ CustomShortcut = "my chord" }`).
+///
+/// **Stability contract:** existing variant *names* are frozen — they form the
+/// on-disk `config.toml` schema. New variants may be appended freely; removing
+/// or renaming a variant requires a `schema_version` bump and a migration.
+///
+/// This type is pure config data: OS-level event synthesis for each variant
+/// lives in the `openlogi-inject` crate (`openlogi_inject::execute`), keeping
+/// this crate platform- and IO-free.
+#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
+pub enum Action {
+    // ── System ───────────────────────────────────────────────────────────────
+    /// Suppress the input entirely — the button or wheel direction is captured
+    /// but no OS event is synthesised, so the physical input does nothing.
+    None,
+
+    // ── Mouse ────────────────────────────────────────────────────────────────
+    /// Primary mouse button.
+    LeftClick,
+    /// Secondary mouse button.
+    RightClick,
+    /// Middle mouse button (wheel click).
+    MiddleClick,
+    /// Mouse "back" side button (extra button 4). Synthesizes the real mouse
+    /// button event, which browsers and most apps interpret as "navigate back"
+    /// natively — unlike [`Action::BrowserBack`], which sends ⌘[ and is ignored
+    /// by many apps.
+    MouseBack,
+    /// Mouse "forward" side button (extra button 5). Native counterpart to
+    /// [`Action::MouseBack`]; see [`Action::BrowserForward`] for the ⌘] form.
+    MouseForward,
+
+    // ── Editing ──────────────────────────────────────────────────────────────
+    /// Copy the current selection (⌘C / Ctrl+C).
+    Copy,
+    /// Paste from the clipboard (⌘V / Ctrl+V).
+    Paste,
+    /// Cut the current selection (⌘X / Ctrl+X).
+    Cut,
+    /// Undo the last action (⌘Z / Ctrl+Z).
+    Undo,
+    /// Redo the last undone action (⌘⇧Z on macOS / Ctrl+Shift+Z on Linux).
+    ///
+    /// Note: Ctrl+Y is the dominant redo shortcut in LibreOffice and many GTK
+    /// apps. Ctrl+Shift+Z is used here because it mirrors the macOS convention
+    /// and works in GNOME text fields, browsers, and Electron apps. If Ctrl+Y
+    /// coverage is needed, a `CustomShortcut` binding is the escape hatch.
+    Redo,
+    /// Select all content (⌘A / Ctrl+A).
+    SelectAll,
+    /// Open the find / search bar (⌘F / Ctrl+F).
+    Find,
+    /// Save the current document (⌘S / Ctrl+S).
+    Save,
+
+    // ── Browser / Navigation ──────────────────────────────────────────────────
+    /// Navigate backward in browser history.
+    BrowserBack,
+    /// Navigate forward in browser history.
+    BrowserForward,
+    /// Open a new tab (⌘T / Ctrl+T).
+    NewTab,
+    /// Close the current tab (⌘W / Ctrl+W).
+    CloseTab,
+    /// Reopen the last closed tab (⌘⇧T / Ctrl+Shift+T).
+    ReopenTab,
+    /// Switch to the next tab (⌃⇥ / Ctrl+Tab).
+    NextTab,
+    /// Switch to the previous tab (⌃⇧⇥ / Ctrl+Shift+Tab).
+    PrevTab,
+    /// Reload the current page (⌘R / Ctrl+R).
+    ReloadPage,
+
+    // ── Navigation / Window ───────────────────────────────────────────────────
+    /// macOS Mission Control (⌃↑).
+    MissionControl,
+    /// macOS App Exposé — all windows for the current app (⌃↓).
+    AppExpose,
+    /// Switch to the previous desktop / Space.
+    PreviousDesktop,
+    /// Switch to the next desktop / Space.
+    NextDesktop,
+    /// Show the desktop (hide all windows).
+    ShowDesktop,
+    /// Open Launchpad.
+    LaunchpadShow,
+
+    // ── System ────────────────────────────────────────────────────────────────
+    /// Lock the screen (⌘⌃Q on macOS).
+    ///
+    /// On Linux, calls `org.freedesktop.login1.Manager.LockSession($XDG_SESSION_ID)`
+    /// on the system bus (current session only). Falls back to Super+L when
+    /// `$XDG_SESSION_ID` is unset or on non-systemd systems.
+    LockScreen,
+    /// Capture a screenshot.
+    Screenshot,
+    /// Capture a selected screen region to the clipboard.
+    ///
+    /// macOS uses Cmd+Shift+Ctrl+4; Windows uses Win+Shift+S. Linux delegates
+    /// to the desktop environment's screenshot handler via Print Screen.
+    CaptureRegion,
+
+    // ── Media ────────────────────────────────────────────────────────────────
+    /// Toggle media play/pause.
+    PlayPause,
+    /// Skip to the next track.
+    NextTrack,
+    /// Go back to the previous track.
+    PrevTrack,
+    /// Increase system volume.
+    VolumeUp,
+    /// Decrease system volume.
+    VolumeDown,
+    /// Toggle system mute.
+    MuteVolume,
+
+    // ── DPI ──────────────────────────────────────────────────────────────────
+    /// Step through the configured DPI preset list (P1.7).
+    CycleDpiPresets,
+    /// Jump to a specific zero-based preset in the device's DPI preset list.
+    /// Out-of-range indices clamp to the list length at fire time (P1.7).
+    SetDpiPreset(u8),
+    /// Toggle the HID++ SmartShift ratchet/free-spin wheel mode (P1.1).
+    ToggleSmartShift,
+
+    // ── Scroll ───────────────────────────────────────────────────────────────
+    /// Synthesise a vertical scroll-up tick.
+    ScrollUp,
+    /// Synthesise a vertical scroll-down tick.
+    ScrollDown,
+    /// Synthesise a horizontal scroll-left tick.
+    HorizontalScrollLeft,
+    /// Synthesise a horizontal scroll-right tick.
+    HorizontalScrollRight,
+
+    // ── Custom ───────────────────────────────────────────────────────────────
+    /// Replay an arbitrary recorded key chord (P1.3).
+    ///
+    /// Holds the structured chord data so `openlogi_inject::execute` can post the
+    /// real keystroke (macOS: CGEventPost with the encoded modifier flags).
+    /// The `display` field is used by [`Action::label`] so the popover
+    /// shows the user-friendly chord name.
+    CustomShortcut(KeyCombo),
+
+    // ── System (appended) ────────────────────────────────────────────────────
+    /// Put the computer to sleep. Appended after `CustomShortcut` because the
+    /// serde variant index is the wire format (see the stability contract
+    /// above) — new variants only ever go at the end.
+    Sleep,
+    /// Type an arbitrary string by emitting unicode characters (macOS
+    /// `CGEventKeyboardSetUnicodeString`). Used for macro text. Power-user
+    /// escape hatch — excluded from the default catalog.
+    TypeText(String),
+    /// Run an AppleScript via `osascript -e <source>`. Power-user escape hatch.
+    RunAppleScript(String),
+    /// Run a shell command via `/bin/sh -c <command>`. Power-user escape hatch.
+    RunShellCommand(String),
+    /// Run a timed, ordered sequence of steps — the native, no-code version of
+    /// "type 'bite me', wait 5s, press Enter, wait 5s, type more, Escape". Each
+    /// step is one of the power-user actions or a `Delay`. The sequencer
+    /// (`openlogi-inject`) runs them in order, awaiting `Delay`s. Power-user
+    /// escape hatch — excluded from the default catalog.
+    Workflow(Vec<WorkflowStep>),
+}
+
+/// One step in a [`Action::Workflow`]. A workflow is a `Vec<WorkflowStep>`
+/// executed in order by the inject layer; `Delay` introduces a pause between
+/// the surrounding steps.
+///
+/// `PressKey` reuses [`KeyCombo`] (the same model as [`Action::CustomShortcut`])
+/// so a step can press a key chord. The other variants mirror their standalone
+/// [`Action`] counterparts.
+#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
+pub enum WorkflowStep {
+    /// Type a unicode string (see [`Action::TypeText`]).
+    TypeText(String),
+    /// Press a key chord (see [`Action::CustomShortcut`] / [`KeyCombo`]).
+    PressKey(KeyCombo),
+    /// Wait `millis` milliseconds before the next step.
+    Delay {
+        /// Pause length in milliseconds.
+        millis: u64,
+    },
+    /// Run an AppleScript (see [`Action::RunAppleScript`]).
+    RunAppleScript(String),
+    /// Run a shell command (see [`Action::RunShellCommand`]).
+    RunShellCommand(String),
+}
+
+impl Action {
+    /// Display label for the popover row.
+    ///
+    /// Returns `String` rather than `&str` so parameterized variants (e.g.
+    /// `SetDpiPreset(i)`, `CustomShortcut(s)`) can build a label that
+    /// includes their payload.
+    #[must_use]
+    pub fn label(&self) -> String {
+        match self {
+            Action::None => "Do Nothing".into(),
+            Action::LeftClick => "Left Click".into(),
+            Action::RightClick => "Right Click".into(),
+            Action::MiddleClick => "Middle Click".into(),
+            Action::MouseBack => "Back (Button 4)".into(),
+            Action::MouseForward => "Forward (Button 5)".into(),
+            Action::Copy => "Copy".into(),
+            Action::Paste => "Paste".into(),
+            Action::Cut => "Cut".into(),
+            Action::Undo => "Undo".into(),
+            Action::Redo => "Redo".into(),
+            Action::SelectAll => "Select All".into(),
+            Action::Find => "Find".into(),
+            Action::Save => "Save".into(),
+            Action::BrowserBack => "Browser Back".into(),
+            Action::BrowserForward => "Browser Forward".into(),
+            Action::NewTab => "New Tab".into(),
+            Action::CloseTab => "Close Tab".into(),
+            Action::ReopenTab => "Reopen Tab".into(),
+            Action::NextTab => "Next Tab".into(),
+            Action::PrevTab => "Previous Tab".into(),
+            Action::ReloadPage => "Reload Page".into(),
+            Action::MissionControl => "Mission Control".into(),
+            Action::AppExpose => "App Exposé".into(),
+            Action::PreviousDesktop => "Previous Desktop".into(),
+            Action::NextDesktop => "Next Desktop".into(),
+            Action::ShowDesktop => "Show Desktop".into(),
+            Action::LaunchpadShow => "Launchpad".into(),
+            Action::LockScreen => "Lock Screen".into(),
+            Action::Screenshot => "Screenshot".into(),
+            Action::CaptureRegion => "Capture Region".into(),
+            Action::PlayPause => "Play / Pause".into(),
+            Action::NextTrack => "Next Track".into(),
+            Action::PrevTrack => "Previous Track".into(),
+            Action::VolumeUp => "Volume Up".into(),
+            Action::VolumeDown => "Volume Down".into(),
+            Action::MuteVolume => "Mute".into(),
+            Action::CycleDpiPresets => "Cycle DPI Presets".into(),
+            Action::SetDpiPreset(i) => format!("DPI Preset {}", i + 1),
+            Action::ToggleSmartShift => "Toggle SmartShift".into(),
+            Action::ScrollUp => "Scroll Up".into(),
+            Action::ScrollDown => "Scroll Down".into(),
+            Action::HorizontalScrollLeft => "Scroll Left".into(),
+            Action::HorizontalScrollRight => "Scroll Right".into(),
+            Action::CustomShortcut(combo) => combo.rendered_label(),
+            Action::Sleep => "Sleep".into(),
+            Action::TypeText(s) => format!("Type \"{s}\""),
+            Action::RunAppleScript(_) => "Run AppleScript".into(),
+            Action::RunShellCommand(_) => "Run Command".into(),
+            Action::Workflow(steps) => format!("Workflow ({} steps)", steps.len()),
+        }
+    }
+
+    /// Which [`Category`] this action belongs to, used for popover grouping.
+    #[must_use]
+    pub fn category(&self) -> Category {
+        match self {
+            Action::LeftClick
+            | Action::RightClick
+            | Action::MiddleClick
+            | Action::MouseBack
+            | Action::MouseForward => Category::Mouse,
+            // CustomShortcut is assigned to Editing so it doesn't need a
+            // separate arm (it's not in the picker catalog).
+            Action::Copy
+            | Action::Paste
+            | Action::Cut
+            | Action::Undo
+            | Action::Redo
+            | Action::SelectAll
+            | Action::Find
+            | Action::Save
+            | Action::CustomShortcut(_)
+            | Action::TypeText(_)
+            | Action::RunAppleScript(_)
+            | Action::RunShellCommand(_)
+            | Action::Workflow(_) => Category::Editing,
+            Action::BrowserBack
+            | Action::BrowserForward
+            | Action::NewTab
+            | Action::CloseTab
+            | Action::ReopenTab
+            | Action::NextTab
+            | Action::PrevTab
+            | Action::ReloadPage => Category::Browser,
+            Action::MissionControl
+            | Action::AppExpose
+            | Action::PreviousDesktop
+            | Action::NextDesktop
+            | Action::ShowDesktop
+            | Action::LaunchpadShow => Category::Navigation,
+            Action::None
+            | Action::LockScreen
+            | Action::Screenshot
+            | Action::CaptureRegion
+            | Action::Sleep => Category::System,
+            Action::PlayPause
+            | Action::NextTrack
+            | Action::PrevTrack
+            | Action::VolumeUp
+            | Action::VolumeDown
+            | Action::MuteVolume => Category::Media,
+            Action::CycleDpiPresets | Action::SetDpiPreset(_) | Action::ToggleSmartShift => {
+                Category::Dpi
+            }
+            Action::ScrollUp
+            | Action::ScrollDown
+            | Action::HorizontalScrollLeft
+            | Action::HorizontalScrollRight => Category::Scroll,
+        }
+    }
+
+    /// All pickable actions in a deterministic order.
+    ///
+    /// [`Action::CustomShortcut`] is intentionally excluded — it is opened via
+    /// "Record shortcut…" (P1.3), not selected from the catalog.
+    #[must_use]
+    pub fn catalog() -> Vec<Action> {
+        vec![
+            // Mouse
+            Action::LeftClick,
+            Action::RightClick,
+            Action::MiddleClick,
+            Action::MouseBack,
+            Action::MouseForward,
+            // Editing
+            Action::Copy,
+            Action::Paste,
+            Action::Cut,
+            Action::Undo,
+            Action::Redo,
+            Action::SelectAll,
+            Action::Find,
+            Action::Save,
+            // Browser
+            Action::BrowserBack,
+            Action::BrowserForward,
+            Action::NewTab,
+            Action::CloseTab,
+            Action::ReopenTab,
+            Action::NextTab,
+            Action::PrevTab,
+            Action::ReloadPage,
+            // Navigation
+            Action::MissionControl,
+            Action::AppExpose,
+            Action::PreviousDesktop,
+            Action::NextDesktop,
+            Action::ShowDesktop,
+            Action::LaunchpadShow,
+            // System
+            Action::None,
+            Action::LockScreen,
+            Action::Screenshot,
+            Action::CaptureRegion,
+            Action::Sleep,
+            // Media
+            Action::PlayPause,
+            Action::NextTrack,
+            Action::PrevTrack,
+            Action::VolumeUp,
+            Action::VolumeDown,
+            Action::MuteVolume,
+            // DPI
+            Action::CycleDpiPresets,
+            Action::ToggleSmartShift,
+            // Scroll
+            Action::ScrollUp,
+            Action::ScrollDown,
+            Action::HorizontalScrollLeft,
+            Action::HorizontalScrollRight,
+        ]
+    }
+}
diff --git a/crates/openlogi-core/src/binding/button.rs b/crates/openlogi-core/src/binding/button.rs
new file mode 100644
index 0000000000000000000000000000000000000000..46253ab3dbee5fd316aa37fe64726df517b8595d
--- /dev/null
+++ b/crates/openlogi-core/src/binding/button.rs
@@ -0,0 +1,144 @@
+//! Rebindable mouse/keyboard button identifiers.
+
+use std::fmt;
+
+use serde::{Deserialize, Serialize};
+
+/// One of the user-rebindable hotspots on a Logi mouse. The order matches the
+/// physical layout from front to side; [`ButtonId::ALL`] is consumed by the
+/// default-binding generator and the popover trigger list.
+#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)]
+pub enum ButtonId {
+    /// The primary button. Rebindable in the config schema, but the OS hook
+    /// never suppresses it — see [`ButtonId::is_os_hook_button`].
+    LeftClick,
+    /// The secondary button. Like [`ButtonId::LeftClick`], it always passes
+    /// through the OS hook.
+    RightClick,
+    /// The wheel click — one of the three buttons the OS hook remaps.
+    MiddleClick,
+    /// The thumb-side "back" button (mouse button 4), remapped by the OS hook.
+    Back,
+    /// The thumb-side "forward" button (mouse button 5), remapped by the OS hook.
+    Forward,
+    /// The "ModeShift" button under the wheel — typically used for SmartShift /
+    /// DPI cycle. Named `DpiToggle` for historical reasons.
+    DpiToggle,
+    /// The horizontal thumb wheel's click. Kept in [`ButtonId::ALL`] so its
+    /// default still seeds and dispatches when the wheel is diverted, even
+    /// though the mouse model surfaces one paired rotation control instead of
+    /// the click (see `mouse_model::geometry`).
+    Thumbwheel,
+    /// Rotating the thumb wheel "up" (positive rotation). Bound, by default, to
+    /// continuous horizontal scroll; see the agent-core `watchers`-side dispatch.
+    ThumbwheelScrollUp,
+    /// Rotating the thumb wheel "down" (negative rotation).
+    ThumbwheelScrollDown,
+    /// The HID++ gesture button on MX-line devices. The press itself
+    /// fires the bound action; swipe directions are P1.5 territory.
+    GestureButton,
+    /// Keyboard F-row "Search" control (`0x1b04` CID `0x00d4`,
+    /// `MultiPlatform_Search`) — F4 on the Signature series.
+    KeySearch,
+    /// Keyboard "Dictation" control (CID `0x0103`) — F5 on the Signature series.
+    KeyDictation,
+    /// Keyboard "Emoji" control (CID `0x0108`) — F6 on the Signature series.
+    KeyEmoji,
+    /// Keyboard "Screen Capture" control (CID `0x010a`) — F7 on the Signature
+    /// series.
+    KeyScreenCapture,
+    /// Keyboard "Mute Microphone" control (CID `0x011c`) — F8 on the Signature
+    /// series.
+    KeyMicMute,
+    /// Keyboard "Play/Pause" control (CID `0x00e5`) — F9 on the Signature series.
+    KeyPlayPause,
+    /// Keyboard "Mute" control (CID `0x00e7`) — F10 on the Signature series.
+    KeyMute,
+    /// Keyboard "Volume Down" control (CID `0x00e8`) — F11 on the Signature
+    /// series.
+    KeyVolumeDown,
+    /// Keyboard "Volume Up" control (CID `0x00e9`) — F12 on the Signature
+    /// series.
+    KeyVolumeUp,
+}
+
+impl ButtonId {
+    /// Every rebindable button in declaration (physical front-to-side) order —
+    /// the iteration source for default-binding seeding and the popover
+    /// trigger list.
+    pub const ALL: [ButtonId; 10] = [
+        ButtonId::LeftClick,
+        ButtonId::RightClick,
+        ButtonId::MiddleClick,
+        ButtonId::Back,
+        ButtonId::Forward,
+        ButtonId::DpiToggle,
+        ButtonId::Thumbwheel,
+        ButtonId::ThumbwheelScrollUp,
+        ButtonId::ThumbwheelScrollDown,
+        ButtonId::GestureButton,
+    ];
+
+    /// The divertable keyboard F-row controls, in F-row order. Kept out of
+    /// [`ButtonId::ALL`]: that array seeds mouse defaults and the mouse
+    /// popover trigger list, while keyboard keys stay native unless the user
+    /// binds them (an unbound key is never diverted).
+    pub const KEYBOARD_KEYS: [ButtonId; 9] = [
+        ButtonId::KeySearch,
+        ButtonId::KeyDictation,
+        ButtonId::KeyEmoji,
+        ButtonId::KeyScreenCapture,
+        ButtonId::KeyMicMute,
+        ButtonId::KeyPlayPause,
+        ButtonId::KeyMute,
+        ButtonId::KeyVolumeDown,
+        ButtonId::KeyVolumeUp,
+    ];
+
+    /// Whether this button is one the OS hook (macOS `CGEventTap` / Linux evdev)
+    /// remaps: Middle, Back, or Forward. The primary L/R clicks always pass
+    /// through (suppressing them would brick the mouse), and the DPI / thumb /
+    /// dedicated gesture controls aren't visible to the OS hook at all (they're
+    /// captured over HID++). These are exactly the buttons that can become an
+    /// OS-hook gesture button, so the hook's remap gate and the gesture-owner
+    /// projection share this one definition.
+    #[must_use]
+    pub fn is_os_hook_button(self) -> bool {
+        matches!(
+            self,
+            ButtonId::MiddleClick | ButtonId::Back | ButtonId::Forward
+        )
+    }
+
+    /// Human-readable label for popovers and tooltips.
+    #[must_use]
+    pub fn label(self) -> &'static str {
+        match self {
+            ButtonId::LeftClick => "Left Click",
+            ButtonId::RightClick => "Right Click",
+            ButtonId::MiddleClick => "Middle Click",
+            ButtonId::Back => "Back",
+            ButtonId::Forward => "Forward",
+            ButtonId::DpiToggle => "DPI Toggle",
+            ButtonId::Thumbwheel => "Thumb Wheel",
+            ButtonId::ThumbwheelScrollUp => "Thumb Wheel Up",
+            ButtonId::ThumbwheelScrollDown => "Thumb Wheel Down",
+            ButtonId::GestureButton => "Gesture Button",
+            ButtonId::KeySearch => "Search Key",
+            ButtonId::KeyDictation => "Dictation Key",
+            ButtonId::KeyEmoji => "Emoji Key",
+            ButtonId::KeyScreenCapture => "Screen Capture Key",
+            ButtonId::KeyMicMute => "Mic Mute Key",
+            ButtonId::KeyPlayPause => "Play/Pause Key",
+            ButtonId::KeyMute => "Mute Key",
+            ButtonId::KeyVolumeDown => "Volume Down Key",
+            ButtonId::KeyVolumeUp => "Volume Up Key",
+        }
+    }
+}
+
+impl fmt::Display for ButtonId {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+        f.write_str(self.label())
+    }
+}
diff --git a/crates/openlogi-core/src/binding/category.rs b/crates/openlogi-core/src/binding/category.rs
new file mode 100644
index 0000000000000000000000000000000000000000..e62e6c0b16883cd1af8046548f726c1f92d379b4
--- /dev/null
+++ b/crates/openlogi-core/src/binding/category.rs
@@ -0,0 +1,43 @@
+//! Popover section categories for the action catalog.
+
+/// Grouping for popover section headers.
+///
+/// Used by [`Action::category`] and rendered as a small muted label above
+/// each group in the action picker.
+#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
+pub enum Category {
+    /// Cut, copy, paste, undo, redo, select-all, find, save.
+    Editing,
+    /// Browser navigation: tabs, page reload, back/forward.
+    Browser,
+    /// Playback and volume controls.
+    Media,
+    /// Physical mouse clicks.
+    Mouse,
+    /// DPI cycle and SmartShift.
+    Dpi,
+    /// Scroll direction shortcuts.
+    Scroll,
+    /// Window/app navigation: Mission Control, Launchpad, etc.
+    Navigation,
+    /// Lock screen, show desktop, system-level actions.
+    System,
+}
+
+impl Category {
+    /// Short label for popover section headers (already uppercase so callers
+    /// don't have to transform it).
+    #[must_use]
+    pub fn label(self) -> &'static str {
+        match self {
+            Category::Editing => "EDITING",
+            Category::Browser => "BROWSER",
+            Category::Media => "MEDIA",
+            Category::Mouse => "MOUSE",
+            Category::Dpi => "DPI",
+            Category::Scroll => "SCROLL",
+            Category::Navigation => "NAVIGATION",
+            Category::System => "SYSTEM",
+        }
+    }
+}
diff --git a/crates/openlogi-core/src/binding/defaults.rs b/crates/openlogi-core/src/binding/defaults.rs
new file mode 100644
index 0000000000000000000000000000000000000000..4d38df97740446500e4d791e1b8fb0745c0c5ac6
--- /dev/null
+++ b/crates/openlogi-core/src/binding/defaults.rs
@@ -0,0 +1,92 @@
+//! Default bindings for a fresh device / gesture map.
+
+use super::action::Action;
+use super::button::ButtonId;
+use super::gesture::GestureDirection;
+use super::value::Binding;
+
+/// Sensible defaults for a fresh device so the panel isn't empty on first run.
+///
+/// Thumbwheel / GestureButton defaults match what Logi Options+ ships for
+/// MX-line devices: thumb wheel click → App Exposé, gesture button →
+/// Mission Control. The thumb wheel isn't captured yet; the dedicated gesture button is
+/// (per-direction, see [`default_gesture_binding`]). The bindings persist
+/// regardless so the user only configures once.
+///
+/// `GestureButton`'s entry here is vestigial: in the merged [`Binding`] model
+/// the gesture button defaults to [`Binding::Gesture`] (see
+/// [`default_binding_for`]), so this single-action value is never the source of
+/// truth for it. It is retained only so the per-button-`Action` callers (the
+/// hook map, scroll defaults, labels) stay total.
+#[must_use]
+pub fn default_binding(button: ButtonId) -> Action {
+    match button {
+        ButtonId::LeftClick => Action::LeftClick,
+        ButtonId::RightClick => Action::RightClick,
+        ButtonId::MiddleClick => Action::MiddleClick,
+        ButtonId::Back => Action::BrowserBack,
+        ButtonId::Forward => Action::BrowserForward,
+        ButtonId::DpiToggle => Action::CycleDpiPresets,
+        ButtonId::Thumbwheel => Action::AppExpose,
+        // The thumb wheel scrolls horizontally by default: rotating it produces
+        // continuous horizontal scroll, with "up" → right and "down" → left.
+        // The wheel watcher renders these two actions as smooth, sensitivity-
+        // scaled scrolling rather than the discrete per-press burst a button
+        // would get (see `watchers::gesture`).
+        ButtonId::ThumbwheelScrollUp => Action::HorizontalScrollRight,
+        ButtonId::ThumbwheelScrollDown => Action::HorizontalScrollLeft,
+        ButtonId::GestureButton => Action::MissionControl,
+        // Keyboard keys stay on their native firmware function until the user
+        // explicitly binds them; an unbound key is never diverted, so a
+        // `None` default keeps the projection total without capturing anything.
+        ButtonId::KeySearch
+        | ButtonId::KeyDictation
+        | ButtonId::KeyEmoji
+        | ButtonId::KeyScreenCapture
+        | ButtonId::KeyMicMute
+        | ButtonId::KeyPlayPause
+        | ButtonId::KeyMute
+        | ButtonId::KeyVolumeDown
+        | ButtonId::KeyVolumeUp => Action::None,
+    }
+}
+
+/// Per-direction defaults for the gesture button. These are captured live over
+/// HID++ `0x1b04` (raw-XY diversion) and dispatched like any other binding; the
+/// defaults give the picker something sensible to show on first run.
+#[must_use]
+pub fn default_gesture_binding(direction: GestureDirection) -> Action {
+    match direction {
+        GestureDirection::Up => Action::MissionControl,
+        GestureDirection::Down => Action::ShowDesktop,
+        GestureDirection::Left => Action::PrevTab,
+        GestureDirection::Right => Action::NextTab,
+        GestureDirection::Click => Action::AppExpose,
+    }
+}
+
+/// The canonical default [`Binding`] for a fresh button in the merged model.
+///
+/// [`ButtonId::GestureButton`] defaults to [`Binding::Gesture`] populated from
+/// [`default_gesture_binding`] — preserving the existing per-direction swipe
+/// behavior — so the GUI mode toggle and the runtime agree it starts in gesture
+/// mode. Every other button defaults to [`Binding::Single`] of its
+/// [`default_binding`].
+///
+/// This is the seed when a button is first promoted to a gesture binding (see
+/// [`Config::set_gesture_direction`](crate::config::Config::set_gesture_direction)),
+/// so a freshly-customized gesture button always carries a full default
+/// direction map — including a [`GestureDirection::Click`] — rather than a sparse
+/// map whose click would project to a no-op [`Action::None`].
+#[must_use]
+pub fn default_binding_for(button: ButtonId) -> Binding {
+    match button {
+        ButtonId::GestureButton => Binding::Gesture(
+            GestureDirection::ALL
+                .into_iter()
+                .map(|d| (d, default_gesture_binding(d)))
+                .collect(),
+        ),
+        other => Binding::Single(default_binding(other)),
+    }
+}
diff --git a/crates/openlogi-core/src/binding/gesture.rs b/crates/openlogi-core/src/binding/gesture.rs
new file mode 100644
index 0000000000000000000000000000000000000000..9790e23c9238c61d31c36ba9dce6cf54e6176027
--- /dev/null
+++ b/crates/openlogi-core/src/binding/gesture.rs
@@ -0,0 +1,70 @@
+//! Gesture-button direction slots (swipe + click).
+
+use std::fmt;
+
+use serde::{Deserialize, Serialize};
+
+/// One of the five sub-bindings on the gesture button: hold + swipe up/down/
+/// left/right or a plain click without movement. Logi ships these as
+/// independent assignments (`SLOT_NAME_GESTURE_*_BUTTON` in the
+/// `device_gesture_buttons_image` metadata block) — OpenLogi mirrors the
+/// same shape.
+///
+/// Variant identifiers are TOML-stable: renames are migration events.
+#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)]
+pub enum GestureDirection {
+    /// Hold + swipe up (negative raw-XY `dy`).
+    Up,
+    /// Hold + swipe down (positive raw-XY `dy`).
+    Down,
+    /// Hold + swipe left (negative raw-XY `dx`).
+    Left,
+    /// Hold + swipe right (positive raw-XY `dx`).
+    Right,
+    /// A press-and-release that never committed a swipe — the gesture
+    /// button's plain-click slot.
+    Click,
+}
+
+impl GestureDirection {
+    /// All five direction slots, swipes first and [`Click`](Self::Click) last.
+    /// Iterated to seed or complete a full gesture map — see
+    /// [`Binding::fill_gesture_defaults`] and [`default_binding_for`].
+    pub const ALL: [GestureDirection; 5] = [
+        GestureDirection::Up,
+        GestureDirection::Down,
+        GestureDirection::Left,
+        GestureDirection::Right,
+        GestureDirection::Click,
+    ];
+
+    /// Human-readable label for popovers and tooltips.
+    #[must_use]
+    pub fn label(self) -> &'static str {
+        match self {
+            GestureDirection::Up => "Up",
+            GestureDirection::Down => "Down",
+            GestureDirection::Left => "Left",
+            GestureDirection::Right => "Right",
+            GestureDirection::Click => "Click",
+        }
+    }
+
+    /// Arrow glyph for compact list rendering.
+    #[must_use]
+    pub fn glyph(self) -> &'static str {
+        match self {
+            GestureDirection::Up => "↑",
+            GestureDirection::Down => "↓",
+            GestureDirection::Left => "←",
+            GestureDirection::Right => "→",
+            GestureDirection::Click => "·",
+        }
+    }
+}
+
+impl fmt::Display for GestureDirection {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+        f.write_str(self.label())
+    }
+}
diff --git a/crates/openlogi-core/src/binding/key_combo.rs b/crates/openlogi-core/src/binding/key_combo.rs
new file mode 100644
index 0000000000000000000000000000000000000000..d1023690adb0e9b5cccdf055c0480601dc80d486
--- /dev/null
+++ b/crates/openlogi-core/src/binding/key_combo.rs
@@ -0,0 +1,89 @@
+//! Modifier + virtual-key chords for custom shortcuts and workflows.
+
+use serde::{Deserialize, Serialize};
+
+/// A modifier + virtual-key keystroke captured by the P1.3 recorder UI or
+/// hand-authored in `config.toml`.
+///
+/// `modifiers` is a bitmask of [`KeyCombo::MOD_CMD`] etc. so the wire format
+/// is a compact integer, not a string. `key_code` is the macOS virtual key
+/// (`kVK_*`); on Linux, `openlogi-inject` maps it to an evdev `KeyCode` when it
+/// synthesizes the chord.
+///
+/// `display` is purely for rendering — e.g. `"⌘⇧P"`. Callers regenerate it
+/// from the captured chord; we keep it in the struct so older configs
+/// continue to render the same label without re-deriving on every load.
+#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
+pub struct KeyCombo {
+    /// Bitmask of [`Self::MOD_CMD`] etc.
+    pub modifiers: u8,
+    /// macOS virtual key code (`kVK_*`). 0 means "no key" — useful for
+    /// modifier-only placeholders that the recorder UI rejects. On Linux,
+    /// `openlogi-inject` translates this to an evdev `KeyCode`.
+    pub key_code: u16,
+    /// Pre-rendered chord label, e.g. `"⌘⇧P"`. Empty falls through to a
+    /// generated label at runtime.
+    #[serde(default)]
+    pub display: String,
+}
+
+impl KeyCombo {
+    /// Bit for the ⌘ Command modifier in [`Self::modifiers`].
+    pub const MOD_CMD: u8 = 1 << 0;
+    /// Bit for the ⇧ Shift modifier in [`Self::modifiers`].
+    pub const MOD_SHIFT: u8 = 1 << 1;
+    /// Bit for the ⌃ Control modifier in [`Self::modifiers`].
+    pub const MOD_CTRL: u8 = 1 << 2;
+    /// Bit for the ⌥ Option/Alt modifier in [`Self::modifiers`].
+    pub const MOD_OPTION: u8 = 1 << 3;
+
+    /// Build the human-readable label from the modifier bitmask + key code.
+    /// Falls back to `"⌘key 0xNN"` when the key code isn't one of the
+    /// commonly-recognised letters; the recorder UI usually overrides this
+    /// with its own derivation.
+    #[must_use]
+    pub fn rendered_label(&self) -> String {
+        if !self.display.is_empty() {
+            return self.display.clone();
+        }
+        let mut out = String::new();
+        if self.modifiers & Self::MOD_CTRL != 0 {
+            out.push('⌃');
+        }
+        if self.modifiers & Self::MOD_OPTION != 0 {
+            out.push('⌥');
+        }
+        if self.modifiers & Self::MOD_SHIFT != 0 {
+            out.push('⇧');
+        }
+        if self.modifiers & Self::MOD_CMD != 0 {
+            out.push('⌘');
+        }
+        match self.key_code {
+            0x00 => out.push('A'),
+            0x01 => out.push('S'),
+            0x02 => out.push('D'),
+            0x03 => out.push('F'),
+            0x06 => out.push('Z'),
+            0x07 => out.push('X'),
+            0x08 => out.push('C'),
+            0x09 => out.push('V'),
+            0x0B => out.push('B'),
+            0x0C => out.push('Q'),
+            0x0D => out.push('W'),
+            0x0E => out.push('E'),
+            0x0F => out.push('R'),
+            0x10 => out.push('Y'),
+            0x11 => out.push('T'),
+            0x20 => out.push('U'),
+            0x22 => out.push('I'),
+            0x1F => out.push('O'),
+            0x23 => out.push('P'),
+            _ => {
+                use std::fmt::Write as _;
+                let _ = write!(out, "key 0x{:02X}", self.key_code);
+            }
+        }
+        out
+    }
+}
diff --git a/crates/openlogi-core/src/binding/tests.rs b/crates/openlogi-core/src/binding/tests.rs
new file mode 100644
index 0000000000000000000000000000000000000000..1e1be285c3fa29a15440ffd8161758018bfd5f6d
--- /dev/null
+++ b/crates/openlogi-core/src/binding/tests.rs
@@ -0,0 +1,389 @@
+//! Binding catalog / serde roundtrip tests.
+
+use std::assert_matches;
+use std::collections::BTreeMap;
+
+use serde::{Deserialize, Serialize};
+
+use super::*;
+
+// ── Roundtrip wrapper: defined here so it precedes any `let` statements ──
+
+/// Minimal TOML-serializable wrapper used by `roundtrip`.
+/// Defined at module scope to satisfy `clippy::items_after_statements`.
+#[derive(Serialize, Deserialize)]
+struct RoundtripWrapper {
+    binding: BTreeMap<ButtonId, Action>,
+}
+
+// ── Catalog tests ─────────────────────────────────────────────────────────
+
+#[test]
+fn catalog_has_at_least_29_entries() {
+    let catalog = Action::catalog();
+    assert!(
+        catalog.len() >= 29,
+        "catalog has {} entries, need ≥ 29",
+        catalog.len()
+    );
+}
+
+#[test]
+fn catalog_excludes_custom_shortcut() {
+    let catalog = Action::catalog();
+    for action in &catalog {
+        assert!(
+            !matches!(action, Action::CustomShortcut(_)),
+            "catalog must not contain CustomShortcut"
+        );
+    }
+}
+
+#[test]
+fn power_user_action_labels_and_category() {
+    assert_eq!(Action::TypeText("hi".into()).label(), "Type \"hi\"");
+    assert_eq!(
+        Action::RunAppleScript("osascript".into()).label(),
+        "Run AppleScript"
+    );
+    assert_eq!(
+        Action::RunShellCommand("echo hi".into()).label(),
+        "Run Command"
+    );
+    // All three are power-user escape hatches: classed as Editing so a
+    // hand-authored binding has a home group, but never in the default
+    // catalog (asserted below).
+    assert_eq!(Action::TypeText("x".into()).category(), Category::Editing);
+    assert_eq!(
+        Action::RunAppleScript("x".into()).category(),
+        Category::Editing
+    );
+    assert_eq!(
+        Action::RunShellCommand("x".into()).category(),
+        Category::Editing
+    );
+}
+
+#[test]
+fn power_user_actions_excluded_from_catalog() {
+    let cat = Action::catalog();
+    assert!(cat.iter().all(|a| !matches!(
+        a,
+        Action::TypeText(_) | Action::RunAppleScript(_) | Action::RunShellCommand(_)
+    )));
+}
+
+#[test]
+fn power_user_actions_roundtrip_toml() {
+    for action in [
+        Action::TypeText("hello".into()),
+        Action::RunAppleScript("beep".into()),
+        Action::RunShellCommand("date".into()),
+    ] {
+        let toml = toml::to_string(&action).expect("serialize");
+        let back: Action = toml::from_str(&toml).expect("deserialize");
+        assert_eq!(action, back);
+    }
+}
+
+#[test]
+fn workflow_label_category_and_catalog_exclusion() {
+    let wf = Action::Workflow(vec![
+        WorkflowStep::TypeText("bite me".into()),
+        WorkflowStep::Delay { millis: 5000 },
+        WorkflowStep::PressKey(KeyCombo {
+            modifiers: 0,
+            key_code: 0x24, // Return
+            display: String::new(),
+        }),
+    ]);
+    assert_eq!(wf.label(), "Workflow (3 steps)");
+    assert_eq!(wf.category(), Category::Editing);
+    // Excluded from the default catalog like the other power-user actions.
+    assert!(
+        Action::catalog()
+            .iter()
+            .all(|a| !matches!(a, Action::Workflow(_)))
+    );
+}
+
+#[test]
+fn workflow_roundtrips_toml() {
+    let wf = Action::Workflow(vec![
+        WorkflowStep::TypeText("bite me".into()),
+        WorkflowStep::Delay { millis: 5000 },
+        WorkflowStep::PressKey(KeyCombo {
+            modifiers: KeyCombo::MOD_SHIFT,
+            key_code: 0x24,
+            display: "⇧↩".into(),
+        }),
+        WorkflowStep::RunShellCommand("echo done".into()),
+    ]);
+    let toml = toml::to_string(&wf).expect("serialize");
+    let back: Action = toml::from_str(&toml).expect("deserialize");
+    assert_eq!(wf, back);
+}
+
+// ── Binding (merged model) serde routing ──────────────────────────────────
+
+/// On-disk shape: a `ButtonId` → [`Binding`] map, as `DeviceConfig.bindings`
+/// serializes it.
+#[derive(Serialize, Deserialize)]
+struct BindingWrapper {
+    bindings: BTreeMap<ButtonId, Binding>,
+}
+
+fn binding_roundtrip(bindings: BTreeMap<ButtonId, Binding>) -> BTreeMap<ButtonId, Binding> {
+    let toml = toml::to_string_pretty(&BindingWrapper { bindings }).expect("serialize");
+    toml::from_str::<BindingWrapper>(&toml)
+        .expect("deserialize")
+        .bindings
+}
+
+#[test]
+fn binding_single_roundtrips_including_payload_variants() {
+    let mut bindings = BTreeMap::new();
+    bindings.insert(ButtonId::Back, Binding::Single(Action::BrowserBack));
+    bindings.insert(
+        ButtonId::DpiToggle,
+        Binding::Single(Action::SetDpiPreset(2)),
+    );
+    bindings.insert(
+        ButtonId::Forward,
+        Binding::Single(Action::CustomShortcut(KeyCombo {
+            modifiers: KeyCombo::MOD_CMD,
+            key_code: 0x23,
+            display: "⌘P".into(),
+        })),
+    );
+    let back = binding_roundtrip(bindings);
+    assert_eq!(back[&ButtonId::Back], Binding::Single(Action::BrowserBack));
+    assert_eq!(
+        back[&ButtonId::DpiToggle],
+        Binding::Single(Action::SetDpiPreset(2))
+    );
+    assert_matches!(
+        back[&ButtonId::Forward],
+        Binding::Single(Action::CustomShortcut(_))
+    );
+}
+
+#[test]
+fn binding_gesture_roundtrips() {
+    let mut map = BTreeMap::new();
+    map.insert(GestureDirection::Up, Action::Copy);
+    map.insert(GestureDirection::Click, Action::Paste);
+    let mut bindings = BTreeMap::new();
+    bindings.insert(ButtonId::GestureButton, Binding::Gesture(map.clone()));
+    let back = binding_roundtrip(bindings);
+    assert_eq!(back[&ButtonId::GestureButton], Binding::Gesture(map));
+}
+
+/// The untagged-routing safety guard. A TOML table keyed by ANY
+/// [`GestureDirection`] name must deserialize as [`Binding::Gesture`], never
+/// [`Binding::Single`]. If a future [`Action`] payload variant is ever named
+/// `Up`/`Down`/`Left`/`Right`/`Click`, the table would parse as `Single`
+/// first and this test fails — catching the silent mis-route at CI time.
+#[test]
+fn binding_direction_keyed_table_routes_to_gesture() {
+    for dir in GestureDirection::ALL {
+        // `GestureDirection`'s serde key equals its `Display`/variant name.
+        let toml = format!("bindings.GestureButton.{dir} = \"None\"");
+        let parsed = toml::from_str::<BindingWrapper>(&toml).expect("deserialize");
+        assert!(
+            matches!(
+                parsed.bindings[&ButtonId::GestureButton],
+                Binding::Gesture(_)
+            ),
+            "a {dir}-keyed table must route to Gesture, not Single"
+        );
+    }
+}
+
+/// The collision case: a payload [`Action`] also serializes as a single-key
+/// table, but untagged must keep it [`Binding::Single`] (it parses as a valid
+/// externally-tagged `Action` before the `Gesture` arm is tried).
+#[test]
+fn binding_payload_action_stays_single() {
+    let toml = "bindings.DpiToggle.SetDpiPreset = 2";
+    let parsed = toml::from_str::<BindingWrapper>(toml).expect("deserialize");
+    assert_eq!(
+        parsed.bindings[&ButtonId::DpiToggle],
+        Binding::Single(Action::SetDpiPreset(2))
+    );
+}
+
+#[test]
+fn binding_capture_region_roundtrips_as_single_string() {
+    let toml = "bindings.Back = \"CaptureRegion\"";
+    let parsed = toml::from_str::<BindingWrapper>(toml).expect("deserialize");
+    assert_eq!(
+        parsed.bindings[&ButtonId::Back],
+        Binding::Single(Action::CaptureRegion)
+    );
+
+    let back = binding_roundtrip(parsed.bindings);
+    assert_eq!(
+        back[&ButtonId::Back],
+        Binding::Single(Action::CaptureRegion)
+    );
+    assert_eq!(Action::CaptureRegion.label(), "Capture Region");
+    assert_eq!(Action::CaptureRegion.category(), Category::System);
+    assert!(Action::catalog().contains(&Action::CaptureRegion));
+}
+
+// ── TOML roundtrip ────────────────────────────────────────────────────────
+
+/// Serialize then deserialize `action` through TOML, using a wrapper
+/// struct because TOML requires a top-level table.
+fn roundtrip(action: &Action) -> Action {
+    let mut map: BTreeMap<ButtonId, Action> = BTreeMap::new();
+    map.insert(ButtonId::Back, action.clone());
+    let w = RoundtripWrapper { binding: map };
+    let s = toml::to_string(&w).expect("serialize");
+    let back: RoundtripWrapper = toml::from_str(&s).expect("deserialize");
+    back.binding
+        .into_values()
+        .next()
+        .expect("binding present after roundtrip")
+}
+
+#[test]
+fn all_catalog_variants_roundtrip_toml() {
+    for action in Action::catalog() {
+        let back = roundtrip(&action);
+        assert_eq!(action, back, "TOML roundtrip failed for {action:?}");
+    }
+}
+
+#[test]
+fn custom_shortcut_roundtrips_toml() {
+    let action = Action::CustomShortcut(KeyCombo {
+        modifiers: KeyCombo::MOD_CMD | KeyCombo::MOD_SHIFT,
+        key_code: 0x23, // kVK_ANSI_P
+        display: "⌘⇧P".into(),
+    });
+    assert_eq!(roundtrip(&action), action);
+}
+
+#[test]
+fn key_combo_rendered_label_uses_display_when_set() {
+    let combo = KeyCombo {
+        modifiers: 0,
+        key_code: 0,
+        display: "preset".into(),
+    };
+    assert_eq!(combo.rendered_label(), "preset");
+}
+
+#[test]
+fn key_combo_rendered_label_falls_back_to_modifiers_plus_key() {
+    let combo = KeyCombo {
+        modifiers: KeyCombo::MOD_CMD | KeyCombo::MOD_SHIFT,
+        key_code: 0x23, // P
+        display: String::new(),
+    };
+    assert_eq!(combo.rendered_label(), "⇧⌘P");
+}
+
+// ── Category tests ────────────────────────────────────────────────────────
+
+#[test]
+fn category_editing_variants() {
+    assert_eq!(Action::Copy.category(), Category::Editing);
+    assert_eq!(Action::Undo.category(), Category::Editing);
+    assert_eq!(Action::SelectAll.category(), Category::Editing);
+    assert_eq!(Action::Find.category(), Category::Editing);
+    assert_eq!(Action::Save.category(), Category::Editing);
+    assert_eq!(Action::Cut.category(), Category::Editing);
+    assert_eq!(Action::Redo.category(), Category::Editing);
+    assert_eq!(Action::Paste.category(), Category::Editing);
+}
+
+#[test]
+fn category_browser_variants() {
+    assert_eq!(Action::BrowserBack.category(), Category::Browser);
+    assert_eq!(Action::BrowserForward.category(), Category::Browser);
+    assert_eq!(Action::NewTab.category(), Category::Browser);
+    assert_eq!(Action::CloseTab.category(), Category::Browser);
+    assert_eq!(Action::ReopenTab.category(), Category::Browser);
+    assert_eq!(Action::NextTab.category(), Category::Browser);
+    assert_eq!(Action::PrevTab.category(), Category::Browser);
+    assert_eq!(Action::ReloadPage.category(), Category::Browser);
+}
+
+#[test]
+fn category_media_variants() {
+    assert_eq!(Action::PlayPause.category(), Category::Media);
+    assert_eq!(Action::NextTrack.category(), Category::Media);
+    assert_eq!(Action::PrevTrack.category(), Category::Media);
+    assert_eq!(Action::VolumeUp.category(), Category::Media);
+    assert_eq!(Action::VolumeDown.category(), Category::Media);
+    assert_eq!(Action::MuteVolume.category(), Category::Media);
+}
+
+#[test]
+fn category_mouse_variants() {
+    assert_eq!(Action::LeftClick.category(), Category::Mouse);
+    assert_eq!(Action::RightClick.category(), Category::Mouse);
+    assert_eq!(Action::MiddleClick.category(), Category::Mouse);
+}
+
+#[test]
+fn category_dpi_variants() {
+    assert_eq!(Action::CycleDpiPresets.category(), Category::Dpi);
+    assert_eq!(Action::ToggleSmartShift.category(), Category::Dpi);
+}
+
+#[test]
+fn category_scroll_variants() {
+    assert_eq!(Action::ScrollUp.category(), Category::Scroll);
+    assert_eq!(Action::ScrollDown.category(), Category::Scroll);
+    assert_eq!(Action::HorizontalScrollLeft.category(), Category::Scroll);
+    assert_eq!(Action::HorizontalScrollRight.category(), Category::Scroll);
+}
+
+#[test]
+fn category_navigation_variants() {
+    assert_eq!(Action::MissionControl.category(), Category::Navigation);
+    assert_eq!(Action::AppExpose.category(), Category::Navigation);
+    assert_eq!(Action::PreviousDesktop.category(), Category::Navigation);
+    assert_eq!(Action::NextDesktop.category(), Category::Navigation);
+    assert_eq!(Action::ShowDesktop.category(), Category::Navigation);
+    assert_eq!(Action::LaunchpadShow.category(), Category::Navigation);
+}
+
+#[test]
+fn category_system_variants() {
+    assert_eq!(Action::LockScreen.category(), Category::System);
+    assert_eq!(Action::Screenshot.category(), Category::System);
+}
+
+// ── Category label smoke test ─────────────────────────────────────────────
+
+#[test]
+fn category_labels_are_nonempty() {
+    let categories = [
+        Category::Editing,
+        Category::Browser,
+        Category::Media,
+        Category::Mouse,
+        Category::Dpi,
+        Category::Scroll,
+        Category::Navigation,
+        Category::System,
+    ];
+    for cat in categories {
+        assert!(!cat.label().is_empty(), "label empty for {cat:?}");
+    }
+}
+
+// ── Default binding ───────────────────────────────────────────────────────
+
+#[test]
+fn dpi_toggle_default_is_cycle_dpi_presets() {
+    assert_eq!(
+        default_binding(ButtonId::DpiToggle),
+        Action::CycleDpiPresets
+    );
+}
diff --git a/crates/openlogi-core/src/binding/value.rs b/crates/openlogi-core/src/binding/value.rs
new file mode 100644
index 0000000000000000000000000000000000000000..84a338714509662364eabe64c7896c75a97304f0
--- /dev/null
+++ b/crates/openlogi-core/src/binding/value.rs
@@ -0,0 +1,113 @@
+//! Single-action vs per-direction gesture bindings.
+
+use std::collections::BTreeMap;
+
+use serde::{Deserialize, Serialize};
+
+use super::action::Action;
+use super::defaults::default_gesture_binding;
+use super::gesture::GestureDirection;
+
+/// What a single rebindable [`ButtonId`] does: either one [`Action`], or — for a
+/// raw-XY-capable button placed in gesture mode — a per-[`GestureDirection`]
+/// map (hold + swipe up/down/left/right, or a plain click).
+///
+/// There has only ever been one binding map per device; a gesture binding is
+/// just a binding whose payload is a direction map instead of a single action.
+///
+/// # Serialization
+///
+/// `#[serde(untagged)]`: [`Single`](Binding::Single) serializes exactly as the
+/// bare [`Action`] did before (a string `"BrowserBack"`, or a single-key table
+/// for the payload variants), and [`Gesture`](Binding::Gesture) serializes as a
+/// table keyed by [`GestureDirection`] names (`Up`/`Down`/`Left`/`Right`/
+/// `Click`).
+///
+/// The two arms are disambiguated by the **zero overlap** between [`Action`]
+/// variant names and [`GestureDirection`] variant names — untagged tries
+/// `Single(Action)` first, and a table keyed by `Up` etc. cannot parse as an
+/// externally-tagged `Action`, so it falls through to `Gesture`. A payload
+/// action like `{ SetDpiPreset = 2 }` is a valid externally-tagged `Action`, so
+/// it stays `Single` and never reaches the `Gesture` arm. This invariant is the
+/// entire safety basis for untagged routing; the `binding_untagged_*` tests
+/// guard it (a future `Action` named `Up`/`Down`/`Left`/`Right`/`Click` would
+/// silently mis-route, and those tests would fail).
+#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
+#[serde(untagged)]
+pub enum Binding {
+    /// One action, fired on press. The shape every non-gesture button uses.
+    Single(Action),
+    /// Per-direction sub-bindings for a button in gesture mode. Keyed by the
+    /// committed swipe direction, with [`GestureDirection::Click`] holding the
+    /// plain-click (no-swipe) action.
+    Gesture(BTreeMap<GestureDirection, Action>),
+}
+
+impl Binding {
+    /// The plain-click action for this binding: the [`Single`](Binding::Single)
+    /// action, or the [`Gesture`](Binding::Gesture) map's
+    /// [`Click`](GestureDirection::Click) entry. Falls back to [`Action::None`]
+    /// when a gesture binding has no explicit `Click`.
+    ///
+    /// Lets the click-dispatch path stay binding-shape-agnostic.
+    #[must_use]
+    pub fn click_action(&self) -> Action {
+        match self {
+            Binding::Single(action) => action.clone(),
+            Binding::Gesture(map) => map
+                .get(&GestureDirection::Click)
+                .cloned()
+                .unwrap_or(Action::None),
+        }
+    }
+
+    /// The action bound to `direction`, if this is a gesture binding.
+    /// [`Single`](Binding::Single) has no directions and returns `None`.
+    #[must_use]
+    pub fn direction_action(&self, direction: GestureDirection) -> Option<&Action> {
+        match self {
+            Binding::Single(_) => None,
+            Binding::Gesture(map) => map.get(&direction),
+        }
+    }
+
+    /// Whether this binding drives raw-XY swipe capture (the
+    /// [`Gesture`](Binding::Gesture) arm).
+    #[must_use]
+    pub fn is_gesture(&self) -> bool {
+        matches!(self, Binding::Gesture(_))
+    }
+
+    /// Promote a [`Single`](Binding::Single) binding in place to a
+    /// [`Gesture`](Binding::Gesture), keeping its action as the
+    /// [`GestureDirection::Click`] entry and leaving the swipe arms unbound.
+    /// A no-op when this is already a [`Gesture`](Binding::Gesture).
+    pub fn upgrade_to_gesture(&mut self) {
+        if let Binding::Single(action) = self {
+            let mut map = BTreeMap::new();
+            map.insert(GestureDirection::Click, action.clone());
+            *self = Binding::Gesture(map);
+        }
+    }
+
+    /// Fill any unbound directions of a [`Gesture`](Binding::Gesture) binding
+    /// with their canonical [`default_gesture_binding`], so a button promoted to
+    /// the gesture role always exposes the full five-direction set — rather than
+    /// leaving swipe arms the GUI renders as defaults but the runtime never
+    /// dispatches. A no-op on [`Single`](Binding::Single) and on directions
+    /// already bound (existing user choices are preserved).
+    pub fn fill_gesture_defaults(&mut self) {
+        if let Binding::Gesture(map) = self {
+            for dir in GestureDirection::ALL {
+                map.entry(dir)
+                    .or_insert_with(|| default_gesture_binding(dir));
+            }
+        }
+    }
+}
+
+impl From<Action> for Binding {
+    fn from(action: Action) -> Self {
+        Binding::Single(action)
+    }
+}
diff --git a/crates/openlogi-core/src/brand.rs b/crates/openlogi-core/src/brand.rs
index 5835dd89aacdcbd2693ac045d20cce2bcc3380ba..d0d688826e15c21811f42d460a1ddc4e307281dd 100644
--- a/crates/openlogi-core/src/brand.rs
+++ b/crates/openlogi-core/src/brand.rs
@@ -14,6 +14,15 @@ pub const HELP_URL: &str = "https://github.com/AprilNEA/OpenLogi#readme";
 /// The "latest release" page.
 pub const RELEASES_URL: &str = "https://github.com/AprilNEA/OpenLogi/releases/latest";
 
+/// The application identifier: the Wayland xdg-toplevel `app_id` (and X11
+/// `WM_CLASS`) the GUI advertises, the root of the macOS bundle-id family
+/// (`org.openlogi.agent`, `org.openlogi.openlogi.dev`), and the value the Linux
+/// `.desktop` file pins as `StartupWMClass`. Defined once here so the window the
+/// compositor sees, the launcher that groups it, and the frontmost backend that
+/// self-identifies OpenLogi can never disagree. The `.desktop` file carries its
+/// own literal copy (it can't reference Rust) — keep the two in sync.
+pub const APP_ID: &str = "org.openlogi.openlogi";
+
 /// The release page for a specific version tag (e.g. the running build).
 #[must_use]
 pub fn release_tag_url(version: &str) -> String {
diff --git a/crates/openlogi-core/src/config.rs b/crates/openlogi-core/src/config.rs
index 603fa825d881d85ff2c3ff073e57bbed31cb5873..1b62586e0a78720f3cbce9814c85f36c61cf3eaf 100644
--- a/crates/openlogi-core/src/config.rs
+++ b/crates/openlogi-core/src/config.rs
@@ -17,12 +17,18 @@ use serde::{Deserialize, Serialize};
 use thiserror::Error;
 
 mod device;
+mod key_trigger;
 mod settings;
 
+#[cfg(test)]
+mod tests;
+
 pub use device::{DeviceConfig, DeviceIdentity};
+pub use key_trigger::{KeyModifiers, KeyTrigger, KeyboardConfig, ParseTriggerError};
+pub use settings::LightSettings;
 pub use settings::{
-    AppSettings, Appearance, AssetSourcePreference, DEFAULT_THUMBWHEEL_SENSITIVITY, GestureOwner,
-    Lighting, MAX_THUMBWHEEL_SENSITIVITY, MIN_THUMBWHEEL_SENSITIVITY,
+    AppSettings, Appearance, AssetSourcePreference, CameraControls, DEFAULT_THUMBWHEEL_SENSITIVITY,
+    GestureOwner, Lighting, MAX_THUMBWHEEL_SENSITIVITY, MIN_THUMBWHEEL_SENSITIVITY,
     SMARTSHIFT_AUTO_DISENGAGE_DEFAULT, SMARTSHIFT_MIN_AUTO_DISENGAGE, ScrollResolution, SmartShift,
     WheelMode,
 };
@@ -60,11 +66,21 @@ pub struct Config {
     /// first paired device. `None` means "fall back to the first device".
     #[serde(default, skip_serializing_if = "Option::is_none")]
     pub selected_device: Option<String>,
+    /// When set (see [`Self::ephemeral`]), [`Self::save_atomic`] is a no-op:
+    /// this config never writes the on-disk file. Never true for a loaded or
+    /// default-constructed config.
+    #[serde(skip)]
+    ephemeral: bool,
     /// Per-device state, keyed by the stable physical-device identifier
     /// (e.g. `"receiver:abc123:slot:2"`) so two identical models never share
     /// an entry.
     #[serde(default)]
     pub devices: BTreeMap<String, DeviceConfig>,
+    /// Keyboard remappings, independent of device. The function-key remapper
+    /// (M1) reads this; `#[serde(default)]` keeps older configs without a
+    /// `[keyboard]` section loading unchanged.
+    #[serde(default)]
+    pub keyboard: KeyboardConfig,
 }
 
 impl Default for Config {
@@ -74,6 +90,8 @@ impl Default for Config {
             app_settings: AppSettings::default(),
             selected_device: None,
             devices: BTreeMap::new(),
+            ephemeral: false,
+            keyboard: KeyboardConfig::default(),
         }
     }
 }
@@ -176,10 +194,25 @@ impl Config {
         }
     }
 
+    /// A config that never touches the on-disk file: [`Self::save_atomic`] is
+    /// a no-op. For tests that drive the state layer's persistence paths —
+    /// with a default config those would overwrite the developer's real
+    /// `config.toml` with test fixtures.
+    #[must_use]
+    pub fn ephemeral() -> Self {
+        Self {
+            ephemeral: true,
+            ..Self::default()
+        }
+    }
+
     /// Writes the config atomically to the default user path: serialize to a
     /// sibling temp file, then rename over the target. On Unix the temp file
-    /// is created with mode 0600.
+    /// is created with mode 0600. No-op for an [`Self::ephemeral`] config.
     pub fn save_atomic(&self) -> Result<(), ConfigError> {
+        if self.ephemeral {
+            return Ok(());
+        }
         self.save_to_path(&paths::config_path()?)
     }
 
@@ -220,6 +253,27 @@ impl Config {
             .insert(button, binding);
     }
 
+    /// Records (or, with `action = None`, clears) the F-key `trigger` binding
+    /// in the global `[keyboard]` map. Keyboard bindings are device-agnostic —
+    /// one map applies across all keyboards — so this mirrors [`Self::set_binding`]
+    /// minus the device key.
+    pub fn set_keyboard_binding(&mut self, trigger: KeyTrigger, action: Option<Action>) {
+        match action {
+            Some(a) => {
+                self.keyboard.bindings.insert(trigger, a);
+            }
+            None => {
+                self.keyboard.bindings.remove(&trigger);
+            }
+        }
+    }
+
+    /// The global keyboard F-key bindings (read accessor).
+    #[must_use]
+    pub fn keyboard_bindings(&self) -> &std::collections::HashMap<KeyTrigger, Action> {
+        &self.keyboard.bindings
+    }
+
     /// Returns the gesture sub-bindings for `device_key`'s gesture button, or an
     /// empty map if it isn't in gesture mode. Derived from the unified
     /// [`DeviceConfig::bindings`]; kept as a convenience for the agent-side
@@ -497,6 +551,81 @@ impl Config {
             .lighting = Some(lighting);
     }
 
+    /// The saved UVC image controls for `device_key`, or `None` if never set.
+    #[must_use]
+    pub fn camera_controls(&self, device_key: &str) -> Option<CameraControls> {
+        self.devices
+            .get(device_key)
+            .and_then(|d| d.camera_controls.clone())
+    }
+
+    /// Replace the saved UVC image controls for `device_key`.
+    pub fn set_camera_controls(&mut self, device_key: &str, controls: CameraControls) {
+        self.devices
+            .entry(device_key.to_string())
+            .or_default()
+            .camera_controls = Some(controls);
+    }
+
+    /// The saved custom camera profiles for `device_key` (name → snapshot).
+    #[must_use]
+    pub fn camera_profiles(&self, device_key: &str) -> BTreeMap<String, CameraControls> {
+        self.devices
+            .get(device_key)
+            .map(|d| d.camera_profiles.clone())
+            .unwrap_or_default()
+    }
+
+    /// Save (or overwrite) a custom camera profile for `device_key`.
+    pub fn save_camera_profile(&mut self, device_key: &str, name: &str, snap: CameraControls) {
+        self.devices
+            .entry(device_key.to_string())
+            .or_default()
+            .camera_profiles
+            .insert(name.to_string(), snap);
+    }
+
+    /// Delete a custom camera profile, clearing the active selection if it
+    /// named it. Unknown names are a no-op.
+    pub fn delete_camera_profile(&mut self, device_key: &str, name: &str) {
+        if let Some(device) = self.devices.get_mut(device_key) {
+            device.camera_profiles.remove(name);
+            if device.camera_profile.as_deref() == Some(name) {
+                device.camera_profile = None;
+            }
+        }
+    }
+
+    /// The last-applied camera profile name for `device_key`, if any.
+    #[must_use]
+    pub fn camera_active_profile(&self, device_key: &str) -> Option<String> {
+        self.devices
+            .get(device_key)
+            .and_then(|d| d.camera_profile.clone())
+    }
+
+    /// Record which camera profile `device_key` last applied.
+    pub fn set_camera_active_profile(&mut self, device_key: &str, name: Option<String>) {
+        self.devices
+            .entry(device_key.to_string())
+            .or_default()
+            .camera_profile = name;
+    }
+
+    /// The standalone-light config for `device_key`, or `None` if unset.
+    #[must_use]
+    pub fn light(&self, device_key: &str) -> Option<LightSettings> {
+        self.devices.get(device_key).and_then(|d| d.light)
+    }
+
+    /// Replace the standalone-light config for `device_key`.
+    pub fn set_light(&mut self, device_key: &str, light: LightSettings) {
+        self.devices
+            .entry(device_key.to_string())
+            .or_default()
+            .light = Some(light);
+    }
+
     /// The committed sensor DPI for `device_key`, or `None` if never set.
     #[must_use]
     pub fn dpi(&self, device_key: &str) -> Option<u32> {
@@ -515,6 +644,13 @@ impl Config {
         self.devices.get(device_key).and_then(|d| d.smartshift)
     }
 
+    /// The persisted keyboard Fn-lock state for `device_key`, or `None` when
+    /// the user never set one (the keyboard keeps its own state).
+    #[must_use]
+    pub fn fn_lock(&self, device_key: &str) -> Option<bool> {
+        self.devices.get(device_key).and_then(|d| d.fn_lock)
+    }
+
     /// Record the SmartShift wheel config for `device_key`, so the agent can
     /// re-apply it when the device reconnects (#189).
     pub fn set_smartshift(&mut self, device_key: &str, smartshift: SmartShift) {
@@ -584,857 +720,3 @@ fn write_atomic(path: &Path, bytes: &[u8]) -> io::Result<()> {
     io::Write::write_all(&mut file, bytes)?;
     file.commit()
 }
-
-#[cfg(test)]
-#[allow(clippy::expect_used, reason = "expect/unwrap are idiomatic in tests")]
-mod tests {
-    use std::assert_matches;
-
-    use super::*;
-    use crate::binding::{default_binding, default_gesture_binding};
-
-    fn write_and_read(config: &Config) -> Config {
-        let dir = tempfile::tempdir().expect("tempdir");
-        let path = dir.path().join("config.toml");
-        config.save_to_path(&path).expect("save");
-        Config::load_from_path(&path).expect("load")
-    }
-
-    #[test]
-    fn missing_file_yields_default() {
-        let dir = tempfile::tempdir().expect("tempdir");
-        let path = dir.path().join("nonexistent.toml");
-        let cfg = Config::load_from_path(&path).expect("load");
-        assert_eq!(cfg.schema_version, SCHEMA_VERSION);
-        assert!(cfg.devices.is_empty());
-    }
-
-    #[test]
-    fn lighting_roundtrips_per_device() {
-        let mut cfg = Config::default();
-        cfg.set_lighting(
-            "g513",
-            Lighting {
-                enabled: true,
-                color: "00aabb".parse().expect("valid hex"),
-                brightness: 75,
-            },
-        );
-        let restored = write_and_read(&cfg);
-        assert_eq!(
-            restored.lighting("g513"),
-            Some(Lighting {
-                enabled: true,
-                color: "00aabb".parse().expect("valid hex"),
-                brightness: 75,
-            })
-        );
-        assert_eq!(restored.lighting("absent"), None);
-    }
-
-    #[test]
-    fn unparseable_lighting_color_falls_back_to_white() {
-        let cfg: Config = toml::from_str(
-            r#"
-                schema_version = 3
-                [devices.g513.lighting]
-                enabled = true
-                color = "red"
-                brightness = 50
-            "#,
-        )
-        .expect("config with a bad color still loads");
-        assert_eq!(
-            cfg.lighting("g513").map(|l| l.color),
-            Some(crate::color::Rgb::WHITE)
-        );
-    }
-
-    #[test]
-    fn hash_prefixed_lighting_color_migrates_to_canonical_hex() {
-        let dir = tempfile::tempdir().expect("tempdir");
-        let path = dir.path().join("config.toml");
-        fs::write(
-            &path,
-            r##"
-                schema_version = 3
-                [devices.g513.lighting]
-                enabled = true
-                color = "#ff0000"
-                brightness = 50
-            "##,
-        )
-        .expect("write config");
-
-        let cfg = Config::load_from_path(&path).expect("load hash-prefixed color");
-        assert_eq!(
-            cfg.lighting("g513").map(|lighting| lighting.color),
-            Some(crate::color::Rgb::new(0xff, 0x00, 0x00))
-        );
-
-        cfg.save_to_path(&path).expect("save canonical color");
-        let saved = fs::read_to_string(path).expect("read saved config");
-        assert!(saved.contains("color = \"ff0000\""));
-        assert!(!saved.contains("color = \"#"));
-    }
-
-    #[test]
-    fn dpi_roundtrips_per_device() {
-        let mut cfg = Config::default();
-        cfg.set_dpi("2b042", 1600);
-        let restored = write_and_read(&cfg);
-        assert_eq!(restored.dpi("2b042"), Some(1600));
-        assert_eq!(restored.dpi("absent"), None);
-    }
-
-    #[test]
-    fn smartshift_roundtrips_per_device() {
-        let mut cfg = Config::default();
-        cfg.set_smartshift(
-            "2b042",
-            SmartShift {
-                mode: WheelMode::Ratchet,
-                auto_disengage: 16,
-                tunable_torque: 30,
-            },
-        );
-        let restored = write_and_read(&cfg);
-        assert_eq!(
-            restored.smartshift("2b042"),
-            Some(SmartShift {
-                mode: WheelMode::Ratchet,
-                auto_disengage: 16,
-                tunable_torque: 30,
-            })
-        );
-        assert_eq!(restored.smartshift("absent"), None);
-    }
-
-    #[test]
-    fn invert_scroll_roundtrips_per_device() {
-        let mut cfg = Config::default();
-        // Default is the native direction for any device, present or not.
-        assert!(!cfg.invert_scroll("2b042"));
-        cfg.set_invert_scroll("2b042", true);
-        let restored = write_and_read(&cfg);
-        assert!(restored.invert_scroll("2b042"));
-        assert!(!restored.invert_scroll("absent"));
-    }
-
-    #[test]
-    fn default_invert_scroll_is_omitted_from_toml() {
-        // A device block with only the default (false) invert_scroll must not
-        // emit the field — `skip_serializing_if` keeps configs clean.
-        let mut cfg = Config::default();
-        cfg.set_binding("2b042", ButtonId::Back, Binding::Single(Action::Copy));
-        cfg.set_invert_scroll("2b042", false);
-        let body = toml::to_string_pretty(&cfg).expect("serialize");
-        assert!(
-            !body.contains("invert_scroll"),
-            "default invert_scroll should be omitted: {body}"
-        );
-    }
-
-    #[test]
-    fn scroll_resolution_roundtrips_all_three_states() {
-        let mut cfg = Config::default();
-        assert_eq!(cfg.scroll_resolution("mouse"), None);
-
-        cfg.set_scroll_resolution("mouse", Some(ScrollResolution::Low));
-        let low = write_and_read(&cfg);
-        assert_eq!(low.scroll_resolution("mouse"), Some(ScrollResolution::Low));
-
-        cfg.set_scroll_resolution("mouse", Some(ScrollResolution::High));
-        let high = write_and_read(&cfg);
-        assert_eq!(
-            high.scroll_resolution("mouse"),
-            Some(ScrollResolution::High)
-        );
-
-        cfg.set_scroll_resolution("mouse", None);
-        let unmanaged = write_and_read(&cfg);
-        assert_eq!(unmanaged.scroll_resolution("mouse"), None);
-    }
-
-    #[test]
-    fn unset_scroll_resolution_is_omitted_from_toml() {
-        let mut cfg = Config::default();
-        cfg.set_binding("mouse", ButtonId::Back, Binding::Single(Action::Copy));
-        cfg.set_scroll_resolution("mouse", Some(ScrollResolution::Low));
-        cfg.set_scroll_resolution("mouse", None);
-
-        let body = toml::to_string_pretty(&cfg).expect("serialize");
-        assert!(
-            !body.contains("scroll_resolution"),
-            "unset scroll resolution should be omitted: {body}"
-        );
-    }
-
-    #[test]
-    fn config_without_scroll_resolution_loads_as_unmanaged() {
-        let dir = tempfile::tempdir().expect("tempdir");
-        let path = dir.path().join("config.toml");
-        fs::write(
-            &path,
-            r"
-                schema_version = 3
-                [devices.mouse]
-                invert_scroll = true
-            ",
-        )
-        .expect("write config");
-
-        let cfg = Config::load_from_path(&path).expect("load existing config");
-        assert_eq!(cfg.scroll_resolution("mouse"), None);
-        assert!(cfg.invert_scroll("mouse"));
-    }
-
-    #[test]
-    fn bindings_roundtrip_per_device() {
-        let mut cfg = Config::default();
-        cfg.set_binding("2b042", ButtonId::Back, Binding::Single(Action::Copy));
-        cfg.set_binding(
-            "2b042",
-            ButtonId::DpiToggle,
-            Binding::Single(Action::CustomShortcut(crate::binding::KeyCombo {
-                modifiers: crate::binding::KeyCombo::MOD_CMD,
-                key_code: 0x23, // kVK_ANSI_P
-                display: "⌘P".into(),
-            })),
-        );
-        cfg.set_binding("4082d", ButtonId::Back, Binding::Single(Action::Paste));
-
-        let parsed = write_and_read(&cfg);
-
-        // Per-device isolation.
-        let a = parsed.bindings_for("2b042");
-        assert_eq!(a.get(&ButtonId::Back), Some(&Binding::Single(Action::Copy)));
-        assert_eq!(
-            a.get(&ButtonId::DpiToggle),
-            Some(&Binding::Single(Action::CustomShortcut(
-                crate::binding::KeyCombo {
-                    modifiers: crate::binding::KeyCombo::MOD_CMD,
-                    key_code: 0x23,
-                    display: "⌘P".into(),
-                }
-            )))
-        );
-
-        let b = parsed.bindings_for("4082d");
-        assert_eq!(
-            b.get(&ButtonId::Back),
-            Some(&Binding::Single(Action::Paste))
-        );
-        assert_eq!(b.len(), 1, "device b should only see its own bindings");
-
-        // Unknown device returns empty map without panic.
-        assert!(parsed.bindings_for("deadbeef").is_empty());
-    }
-
-    #[test]
-    fn human_readable_toml_layout() {
-        let mut cfg = Config::default();
-        cfg.set_binding(
-            "2b042",
-            ButtonId::Back,
-            Binding::Single(Action::BrowserBack),
-        );
-        let body = toml::to_string_pretty(&cfg).expect("serialize");
-
-        // The key only contains [A-Za-z0-9_], so TOML emits it as a bare-word
-        // table key (no surrounding quotes). The test asserts the observable
-        // structure rather than locking in a specific quoting.
-        assert!(body.contains("schema_version = 3"), "got: {body}");
-        assert!(body.contains("[devices.2b042.bindings]"), "got: {body}");
-        // A `Single` binding serializes byte-identically to the pre-v2 bare
-        // `Action`, so the leaf line is unchanged.
-        assert!(body.contains("Back = \"BrowserBack\""), "got: {body}");
-    }
-
-    #[test]
-    fn dpi_presets_roundtrip_per_device() {
-        let mut cfg = Config::default();
-        cfg.set_dpi_presets("2b042", vec![800, 1600, 3200]);
-        cfg.set_dpi_presets("4082d", vec![400, 1600]);
-
-        let parsed = write_and_read(&cfg);
-
-        assert_eq!(parsed.dpi_presets("2b042"), vec![800, 1600, 3200]);
-        assert_eq!(parsed.dpi_presets("4082d"), vec![400, 1600]);
-        assert!(parsed.dpi_presets("unknown").is_empty());
-    }
-
-    #[test]
-    fn empty_dpi_presets_skip_serialization() {
-        let mut cfg = Config::default();
-        // Add a binding so the device block exists.
-        cfg.set_binding("2b042", ButtonId::Back, Binding::Single(Action::Copy));
-        cfg.set_dpi_presets("2b042", vec![800]);
-        cfg.set_dpi_presets("2b042", vec![]); // clear
-
-        let body = toml::to_string_pretty(&cfg).expect("serialize");
-        assert!(
-            !body.contains("dpi_presets"),
-            "empty dpi_presets should be omitted: {body}"
-        );
-    }
-
-    #[test]
-    fn device_identity_roundtrips_and_is_iterable() {
-        use crate::device::{Capabilities, DeviceKind};
-
-        let mut cfg = Config::default();
-        let mouse = DeviceIdentity {
-            display_name: "MX Master 3S".to_string(),
-            model_info: None,
-            codename: None,
-            kind: DeviceKind::Mouse,
-            capabilities: Capabilities {
-                buttons: true,
-                pointer: true,
-                lighting: false,
-                scroll_inversion: false,
-                hires_wheel: true,
-                thumbwheel: false,
-            },
-        };
-        cfg.set_device_identity("2b034", mouse.clone());
-        // Recording an identity must not disturb unrelated per-device state.
-        cfg.set_binding(
-            "2b034",
-            ButtonId::Back,
-            Binding::Single(Action::BrowserBack),
-        );
-
-        let parsed = write_and_read(&cfg);
-        assert_eq!(parsed.device_identity("2b034"), Some(&mouse));
-        assert_eq!(parsed.device_identity("absent"), None);
-        assert_eq!(
-            parsed.bindings_for("2b034").get(&ButtonId::Back),
-            Some(&Binding::Single(Action::BrowserBack)),
-            "identity must coexist with bindings on the same device block"
-        );
-        assert_eq!(
-            parsed.known_identities().collect::<Vec<_>>(),
-            vec![("2b034", &mouse)]
-        );
-    }
-
-    #[test]
-    fn selected_device_roundtrips() {
-        let mut cfg = Config::default();
-        assert_eq!(cfg.selected_device(), None);
-        cfg.set_selected_device(Some("2b042".into()));
-        let parsed = write_and_read(&cfg);
-        assert_eq!(parsed.selected_device(), Some("2b042"));
-    }
-
-    #[test]
-    fn per_app_overlay_takes_precedence() {
-        let mut cfg = Config::default();
-        cfg.set_binding(
-            "2b042",
-            ButtonId::Back,
-            Binding::Single(Action::BrowserBack),
-        );
-        cfg.set_binding(
-            "2b042",
-            ButtonId::Forward,
-            Binding::Single(Action::BrowserForward),
-        );
-        cfg.set_per_app_binding(
-            "2b042",
-            "com.microsoft.VSCode",
-            ButtonId::Back,
-            Some(Action::Undo),
-        );
-
-        // Global: both buttons are browser nav.
-        let global = cfg.effective_bindings("2b042", None);
-        assert_eq!(
-            global.get(&ButtonId::Back),
-            Some(&Binding::Single(Action::BrowserBack))
-        );
-        assert_eq!(
-            global.get(&ButtonId::Forward),
-            Some(&Binding::Single(Action::BrowserForward))
-        );
-
-        // VSCode: Back overridden (wrapped as Single), Forward inherits.
-        let vscode = cfg.effective_bindings("2b042", Some("com.microsoft.VSCode"));
-        assert_eq!(
-            vscode.get(&ButtonId::Back),
-            Some(&Binding::Single(Action::Undo))
-        );
-        assert_eq!(
-            vscode.get(&ButtonId::Forward),
-            Some(&Binding::Single(Action::BrowserForward))
-        );
-
-        // Unrelated app falls through.
-        let other = cfg.effective_bindings("2b042", Some("com.apple.Safari"));
-        assert_eq!(
-            other.get(&ButtonId::Back),
-            Some(&Binding::Single(Action::BrowserBack))
-        );
-    }
-
-    #[test]
-    fn per_app_binding_removal_prunes_empty_app() {
-        let mut cfg = Config::default();
-        cfg.set_per_app_binding(
-            "2b042",
-            "com.example.App",
-            ButtonId::Back,
-            Some(Action::Copy),
-        );
-        cfg.set_per_app_binding("2b042", "com.example.App", ButtonId::Back, None);
-        assert!(
-            cfg.devices["2b042"].per_app_bindings.is_empty(),
-            "removing last override should prune the app entry"
-        );
-    }
-
-    #[test]
-    fn app_settings_default_omits_block() {
-        let cfg = Config::default();
-        let body = toml::to_string_pretty(&cfg).expect("serialize");
-        assert!(
-            !body.contains("app_settings"),
-            "default app_settings should be omitted: {body}"
-        );
-    }
-
-    #[test]
-    fn app_settings_launch_at_login_roundtrips() {
-        let mut cfg = Config::default();
-        cfg.app_settings.launch_at_login = true;
-        let parsed = write_and_read(&cfg);
-        assert!(parsed.app_settings.launch_at_login);
-    }
-
-    #[test]
-    fn asset_source_preference_roundtrips() {
-        let mut cfg = Config::default();
-        cfg.app_settings.asset_source = AssetSourcePreference::OpenLogi;
-
-        let body = toml::to_string_pretty(&cfg).expect("serialize");
-        let parsed = write_and_read(&cfg);
-
-        assert!(body.contains("asset_source = \"openlogi\""));
-        assert_eq!(
-            parsed.app_settings.asset_source,
-            AssetSourcePreference::OpenLogi
-        );
-    }
-
-    #[test]
-    fn config_without_asset_source_keeps_automatic_selection() {
-        let parsed: Config = toml::from_str(
-            r"
-                schema_version = 3
-                [app_settings]
-                auto_download_assets = false
-            ",
-        )
-        .expect("config predating the asset-source setting loads");
-
-        assert_eq!(
-            parsed.app_settings.asset_source,
-            AssetSourcePreference::Automatic
-        );
-    }
-
-    #[test]
-    fn cleared_selected_device_omits_field() {
-        let mut cfg = Config::default();
-        cfg.set_selected_device(Some("2b042".into()));
-        cfg.set_selected_device(None);
-        let body = toml::to_string_pretty(&cfg).expect("serialize");
-        assert!(
-            !body.contains("selected_device"),
-            "cleared selection should not appear: {body}"
-        );
-    }
-
-    #[test]
-    fn empty_device_block_is_skipped_in_output() {
-        // Inserting then clearing should not leave a [devices."x"] header
-        // with no bindings under it (skip_serializing_if on bindings).
-        let mut cfg = Config::default();
-        cfg.set_binding("2b042", ButtonId::Back, Binding::Single(Action::Copy));
-        cfg.devices
-            .get_mut("2b042")
-            .expect("entry")
-            .bindings
-            .clear();
-        let body = toml::to_string_pretty(&cfg).expect("serialize");
-        assert!(
-            !body.contains("Back"),
-            "cleared bindings should not appear: {body}"
-        );
-    }
-
-    #[test]
-    fn migrates_v1_button_and_gesture_bindings() {
-        // A pre-v2 file: split button_bindings + a flat gesture_bindings map.
-        let v1 = "\
-schema_version = 1
-
-[devices.2b042.button_bindings]
-Back = \"BrowserBack\"
-
-[devices.2b042.gesture_bindings]
-Up = \"Copy\"
-Click = \"Paste\"
-";
-        let dir = tempfile::tempdir().expect("tempdir");
-        let path = dir.path().join("config.toml");
-        fs::write(&path, v1).expect("write");
-
-        // v1 still loads (version <= current) and folds into the merged map.
-        let cfg = Config::load_from_path(&path).expect("load v1");
-        let bindings = cfg.bindings_for("2b042");
-        assert_eq!(
-            bindings.get(&ButtonId::Back),
-            Some(&Binding::Single(Action::BrowserBack))
-        );
-        let mut gesture = BTreeMap::new();
-        gesture.insert(GestureDirection::Up, Action::Copy);
-        gesture.insert(GestureDirection::Click, Action::Paste);
-        assert_eq!(
-            bindings.get(&ButtonId::GestureButton),
-            Some(&Binding::Gesture(gesture))
-        );
-
-        // Saving self-heals to the current shape: stamped version + merged table,
-        // legacy field names gone.
-        let body = toml::to_string_pretty(&cfg).expect("serialize");
-        assert!(body.contains("schema_version = 3"), "got: {body}");
-        assert!(body.contains("[devices.2b042.bindings]"), "got: {body}");
-        assert!(!body.contains("button_bindings"), "got: {body}");
-        assert!(!body.contains("gesture_bindings"), "got: {body}");
-    }
-
-    #[test]
-    fn migration_gesture_map_wins_over_legacy_single_gesture_button_entry() {
-        // The data-loss guard: when a legacy single button_bindings[GestureButton]
-        // entry coexists with a gesture_bindings map (reachable via hand-edited
-        // or very old configs), the gesture map must survive — not be shadowed by
-        // the single entry. Mirrors the pre-v2 "gesture entries win" rule.
-        let v1 = "\
-schema_version = 1
-
-[devices.2b042.button_bindings]
-GestureButton = \"MissionControl\"
-
-[devices.2b042.gesture_bindings]
-Up = \"Copy\"
-Down = \"Paste\"
-";
-        let dir = tempfile::tempdir().expect("tempdir");
-        let path = dir.path().join("config.toml");
-        fs::write(&path, v1).expect("write");
-
-        let cfg = Config::load_from_path(&path).expect("load v1");
-        let mut gesture = BTreeMap::new();
-        gesture.insert(GestureDirection::Up, Action::Copy);
-        gesture.insert(GestureDirection::Down, Action::Paste);
-        assert_eq!(
-            cfg.bindings_for("2b042").get(&ButtonId::GestureButton),
-            Some(&Binding::Gesture(gesture)),
-            "gesture map must win over the legacy single GestureButton entry"
-        );
-    }
-
-    #[test]
-    fn migration_drops_vestigial_lone_gesture_button_single() {
-        // A v1 file with only `button_bindings[GestureButton]` and no
-        // `gesture_bindings` (the pre-gesture-picker shape). That entry never
-        // dispatched in v1 — the gesture button's plain press routes through the
-        // gesture `Click` slot, not the per-button map — so migrating it to a
-        // `Binding::Single` would leave an unreachable entry the GUI hides and the
-        // runtime ignores. It must be dropped, not shadow the gesture path.
-        let v1 = "\
-schema_version = 1
-
-[devices.2b042.button_bindings]
-GestureButton = \"MissionControl\"
-Back = \"BrowserBack\"
-";
-        let dir = tempfile::tempdir().expect("tempdir");
-        let path = dir.path().join("config.toml");
-        fs::write(&path, v1).expect("write");
-
-        let bindings = Config::load_from_path(&path)
-            .expect("load v1")
-            .bindings_for("2b042");
-        // An ordinary button still migrates to a `Single`...
-        assert_eq!(
-            bindings.get(&ButtonId::Back),
-            Some(&Binding::Single(Action::BrowserBack))
-        );
-        // ...but the vestigial gesture-button single is gone, leaving the button
-        // to fall back to its canonical default rather than an unreachable entry.
-        assert_eq!(bindings.get(&ButtonId::GestureButton), None);
-    }
-
-    #[test]
-    fn rejects_newer_schema_version_but_accepts_v1() {
-        // A future version is rejected loudly; the current and older versions
-        // load (older ones migrate through the shim).
-        let dir = tempfile::tempdir().expect("tempdir");
-        let path = dir.path().join("config.toml");
-        fs::write(&path, "schema_version = 99\n").expect("write");
-        assert_matches!(
-            Config::load_from_path(&path).expect_err("v99 should fail"),
-            ConfigError::UnsupportedSchemaVersion { found: 99, .. }
-        );
-
-        fs::write(&path, "schema_version = 1\n").expect("write");
-        assert!(
-            Config::load_from_path(&path).is_ok(),
-            "v1 should still load"
-        );
-    }
-
-    #[test]
-    fn set_gesture_direction_upgrades_single_to_gesture() {
-        let mut cfg = Config::default();
-        // Start from a Single binding, then bind a swipe direction.
-        cfg.set_binding(
-            "2b042",
-            ButtonId::Back,
-            Binding::Single(Action::BrowserBack),
-        );
-        cfg.set_gesture_direction("2b042", ButtonId::Back, GestureDirection::Up, Action::Copy);
-
-        match cfg.bindings_for("2b042").get(&ButtonId::Back) {
-            Some(Binding::Gesture(map)) => {
-                // The prior single action is preserved as the Click entry.
-                assert_eq!(
-                    map.get(&GestureDirection::Click),
-                    Some(&Action::BrowserBack)
-                );
-                assert_eq!(map.get(&GestureDirection::Up), Some(&Action::Copy));
-            }
-            other => panic!("expected Gesture after upgrade, got {other:?}"),
-        }
-    }
-
-    #[test]
-    fn set_gesture_direction_on_fresh_gesture_button_seeds_click() {
-        // Binding one direction on a never-configured gesture button must still
-        // persist a `Click`, so the click projection is the canonical default
-        // rather than `Action::None` (which reads as a no-op press).
-        let mut cfg = Config::default();
-        cfg.set_gesture_direction(
-            "2b042",
-            ButtonId::GestureButton,
-            GestureDirection::Up,
-            Action::Copy,
-        );
-
-        match cfg.bindings_for("2b042").get(&ButtonId::GestureButton) {
-            Some(Binding::Gesture(map)) => {
-                assert_eq!(map.get(&GestureDirection::Up), Some(&Action::Copy));
-                assert_eq!(
-                    map.get(&GestureDirection::Click),
-                    Some(&crate::binding::default_gesture_binding(
-                        GestureDirection::Click
-                    )),
-                    "a fresh gesture button must seed a Click from its default"
-                );
-            }
-            other => panic!("expected Gesture, got {other:?}"),
-        }
-    }
-
-    #[test]
-    fn gesture_owner_defaults_to_hidpp_button_yields_to_oshook_and_can_be_off() {
-        let mut cfg = Config::default();
-        // Default: the dedicated HID++ gesture button owns the gesture role even with no config.
-        assert_eq!(cfg.gesture_owner("2b042"), Some(ButtonId::GestureButton));
-
-        // A dedicated HID++ gesture binding keeps it the owner.
-        cfg.set_gesture_direction(
-            "2b042",
-            ButtonId::GestureButton,
-            GestureDirection::Up,
-            Action::MissionControl,
-        );
-        assert_eq!(cfg.gesture_owner("2b042"), Some(ButtonId::GestureButton));
-
-        // An explicit OS-hook gesture button takes the role over.
-        cfg.set_binding(
-            "2b042",
-            ButtonId::Forward,
-            Binding::Gesture(BTreeMap::from([(GestureDirection::Up, Action::Copy)])),
-        );
-        assert_eq!(cfg.gesture_owner("2b042"), Some(ButtonId::Forward));
-
-        // Turning gestures off explicitly yields `None` (not the HID++ button default).
-        let mut off = Config::default();
-        off.disable_gestures("2b042");
-        assert_eq!(off.gesture_owner("2b042"), None);
-    }
-
-    #[test]
-    fn set_gesture_owner_records_owner_without_destroying_other_maps() {
-        let mut cfg = Config::default();
-        // Customize the dedicated HID++ gesture button's Up swipe; it is the (inferred) owner.
-        cfg.set_gesture_direction(
-            "2b042",
-            ButtonId::GestureButton,
-            GestureDirection::Up,
-            Action::Copy,
-        );
-        assert_eq!(cfg.gesture_owner("2b042"), Some(ButtonId::GestureButton));
-
-        // Promote Back: the owner becomes Back explicitly; the HID++ gesture button keeps
-        // its full gesture map (no destructive demotion).
-        cfg.set_binding("2b042", ButtonId::Back, Action::BrowserBack.into());
-        cfg.set_gesture_owner("2b042", ButtonId::Back);
-        assert_eq!(cfg.gesture_owner("2b042"), Some(ButtonId::Back));
-
-        let bindings = cfg.bindings_for("2b042");
-        // Back is a full five-direction gesture button: its prior single action
-        // stays as Click, and the swipe arms are seeded from defaults.
-        match bindings.get(&ButtonId::Back) {
-            Some(Binding::Gesture(map)) => {
-                assert_eq!(
-                    map.get(&GestureDirection::Click),
-                    Some(&Action::BrowserBack)
-                );
-                assert_eq!(
-                    map.get(&GestureDirection::Up),
-                    Some(&default_gesture_binding(GestureDirection::Up)),
-                    "a promoted button gets full default arms"
-                );
-            }
-            other => panic!("expected Back to be a gesture binding, got {other:?}"),
-        }
-        // The HID++ gesture button's customized map survived the switch intact.
-        match bindings.get(&ButtonId::GestureButton) {
-            Some(Binding::Gesture(map)) => {
-                assert_eq!(map.get(&GestureDirection::Up), Some(&Action::Copy));
-            }
-            other => panic!("expected the HID++ gesture button map preserved, got {other:?}"),
-        }
-
-        // Switching back restores the user's customization, not defaults
-        // (regression guard: owner-switch used to discard the swipe arms).
-        cfg.set_gesture_owner("2b042", ButtonId::GestureButton);
-        assert_eq!(cfg.gesture_owner("2b042"), Some(ButtonId::GestureButton));
-        match cfg.bindings_for("2b042").get(&ButtonId::GestureButton) {
-            Some(Binding::Gesture(map)) => {
-                assert_eq!(map.get(&GestureDirection::Up), Some(&Action::Copy));
-            }
-            other => panic!("expected preserved gesture map, got {other:?}"),
-        }
-    }
-
-    #[test]
-    fn set_gesture_owner_seeds_a_fresh_button_with_full_directions() {
-        let mut cfg = Config::default();
-        // The dedicated HID++ gesture button gets the full default direction map.
-        cfg.set_gesture_owner("2b042", ButtonId::GestureButton);
-        match cfg.bindings_for("2b042").get(&ButtonId::GestureButton) {
-            Some(Binding::Gesture(map)) => {
-                for dir in GestureDirection::ALL {
-                    assert_eq!(map.get(&dir), Some(&default_gesture_binding(dir)));
-                }
-            }
-            other => panic!("expected full default gesture map, got {other:?}"),
-        }
-
-        // A fresh OS-hook button also gets all five directions, not just a Click:
-        // its native action stays as Click, and the swipe arms are defaults — so
-        // the GUI's shown defaults are exactly what the runtime dispatches.
-        cfg.set_gesture_owner("2b042", ButtonId::Forward);
-        match cfg.bindings_for("2b042").get(&ButtonId::Forward) {
-            Some(Binding::Gesture(map)) => {
-                assert_eq!(
-                    map.get(&GestureDirection::Click),
-                    Some(&default_binding(ButtonId::Forward))
-                );
-                for dir in [
-                    GestureDirection::Up,
-                    GestureDirection::Down,
-                    GestureDirection::Left,
-                    GestureDirection::Right,
-                ] {
-                    assert_eq!(map.get(&dir), Some(&default_gesture_binding(dir)));
-                }
-            }
-            other => panic!("expected full gesture map for Forward, got {other:?}"),
-        }
-    }
-
-    #[test]
-    fn disable_gestures_turns_off_without_destroying_maps() {
-        let mut cfg = Config::default();
-        cfg.set_gesture_direction(
-            "2b042",
-            ButtonId::GestureButton,
-            GestureDirection::Up,
-            Action::Copy,
-        );
-        cfg.disable_gestures("2b042");
-        // Off, but the HID++ gesture button's customized map is preserved (re-enabling
-        // restores it rather than resurrecting a wiped default).
-        assert_eq!(cfg.gesture_owner("2b042"), None);
-        match cfg.bindings_for("2b042").get(&ButtonId::GestureButton) {
-            Some(Binding::Gesture(map)) => {
-                assert_eq!(map.get(&GestureDirection::Up), Some(&Action::Copy));
-            }
-            other => panic!("expected the gesture map preserved while off, got {other:?}"),
-        }
-    }
-
-    #[test]
-    fn gesture_owner_field_roundtrips_as_a_scalar() {
-        let mut cfg = Config::default();
-        cfg.set_gesture_owner("2b042", ButtonId::Back); // explicit button
-        cfg.disable_gestures("4082d"); // explicit off
-
-        let parsed = write_and_read(&cfg);
-        assert_eq!(parsed.gesture_owner("2b042"), Some(ButtonId::Back));
-        assert_eq!(parsed.gesture_owner("4082d"), None);
-
-        // The custom codec keeps it a bare TOML string (a nested table would risk
-        // a value-after-table serialization error, since `bindings` is a table).
-        let body = toml::to_string_pretty(&cfg).expect("serialize");
-        assert!(body.contains("gesture_owner = \"Back\""), "got: {body}");
-        assert!(body.contains("gesture_owner = \"Off\""), "got: {body}");
-    }
-
-    #[test]
-    fn invalid_gesture_owner_string_is_tolerated_not_fatal() {
-        // A hand-edit typo in gesture_owner must NOT fail the whole-document parse
-        // (which would revert every device's settings to defaults). It degrades
-        // to "infer" while the rest of the device config survives.
-        let toml = "\
-schema_version = 2
-
-[devices.2b042]
-gesture_owner = \"bogus\"
-
-[devices.2b042.bindings]
-Back = \"Copy\"
-";
-        let dir = tempfile::tempdir().expect("tempdir");
-        let path = dir.path().join("config.toml");
-        fs::write(&path, toml).expect("write");
-
-        let cfg =
-            Config::load_from_path(&path).expect("an invalid gesture_owner must not fail the load");
-        // The rest of the device config survived...
-        assert_eq!(
-            cfg.bindings_for("2b042").get(&ButtonId::Back),
-            Some(&Binding::Single(Action::Copy))
-        );
-        // ...and the bad owner degraded to inference (HID++ button default here).
-        assert_eq!(cfg.gesture_owner("2b042"), Some(ButtonId::GestureButton));
-    }
-}
diff --git a/crates/openlogi-core/src/config/device.rs b/crates/openlogi-core/src/config/device.rs
index 9d73ae37b0b1453bbf781840da5a6bb759fdd478..d71870af15c450fb0f9eef2469720bd307e1b20a 100644
--- a/crates/openlogi-core/src/config/device.rs
+++ b/crates/openlogi-core/src/config/device.rs
@@ -7,10 +7,11 @@ use std::collections::BTreeMap;
 use serde::{Deserialize, Serialize};
 
 use super::settings::{
-    GestureOwner, Lighting, ScrollResolution, SmartShift, deserialize_gesture_owner,
+    CameraControls, GestureOwner, LightSettings, Lighting, ScrollResolution, SmartShift,
+    deserialize_gesture_owner,
 };
 use crate::binding::{Action, Binding, ButtonId, GestureDirection};
-use crate::device::{Capabilities, DeviceKind, DeviceModelInfo};
+use crate::device::{Capabilities, DeviceKind, DeviceModelInfo, LightCapabilities};
 
 /// Last-known identity of a device, captured while it was online so the UI can
 /// render its card and the *correct* config panels before any live HID++ probe
@@ -43,6 +44,18 @@ pub struct DeviceIdentity {
     /// Configuration capabilities measured from the device's HID++ feature
     /// table. This is the field that keeps a sleeping mouse's panels visible.
     pub capabilities: Capabilities,
+    /// Standalone-light controls measured by its protocol driver, if this is
+    /// a non-HID++ light. Old configs omit this field.
+    #[serde(default, skip_serializing_if = "Option::is_none")]
+    pub light_capabilities: Option<LightCapabilities>,
+    /// Standalone driver family that produced this identity, when applicable.
+    /// Old configs and HID++ devices omit it.
+    #[serde(default, skip_serializing_if = "Option::is_none")]
+    pub driver_id: Option<String>,
+    /// Optional model-level identity in the OpenLogi asset registry. This is
+    /// not a physical-device key and never contains a serial or OS node id.
+    #[serde(default, skip_serializing_if = "Option::is_none")]
+    pub registry_model_id: Option<String>,
 }
 
 /// Settings scoped to a single physical device.
@@ -97,10 +110,25 @@ pub struct DeviceConfig {
     /// until the user changes it, so it stays out of `config.toml` otherwise.
     #[serde(default, skip_serializing_if = "Option::is_none")]
     pub lighting: Option<Lighting>,
+    /// Per-device standalone-light settings. Separate from [`Self::lighting`],
+    /// which is the existing HID++ keyboard RGB configuration.
+    #[serde(default, skip_serializing_if = "Option::is_none")]
+    pub light: Option<LightSettings>,
     /// Per-device SmartShift wheel configuration, re-applied on reconnect for
     /// the same reason as [`Self::dpi`]. `None` until the user changes it.
     #[serde(default, skip_serializing_if = "Option::is_none")]
     pub smartshift: Option<SmartShift>,
+    /// Per-webcam UVC image controls (brightness/contrast/…). `None` until the
+    /// user adjusts one, so it stays out of `config.toml` otherwise.
+    #[serde(default, skip_serializing_if = "Option::is_none")]
+    pub camera_controls: Option<CameraControls>,
+    /// User-saved camera profiles (name → control snapshot). Built-in profiles
+    /// (Default / Streaming / Video call) live in the GUI, not here.
+    #[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
+    pub camera_profiles: BTreeMap<String, CameraControls>,
+    /// The camera profile last applied from the GUI, highlighted on reopen.
+    #[serde(default, skip_serializing_if = "Option::is_none")]
+    pub camera_profile: Option<String>,
     /// Invert this device's scroll-wheel direction relative to the OS setting
     /// (issue #126): on, a wheel tick scrolls the opposite way, so a user who
     /// keeps macOS "natural scrolling" for the trackpad can have a traditional
@@ -113,6 +141,18 @@ pub struct DeviceConfig {
     /// current resolution unmanaged and omits the field from `config.toml`.
     #[serde(default, skip_serializing_if = "Option::is_none")]
     pub scroll_resolution: Option<ScrollResolution>,
+    /// Physical config keys of pointing devices that follow this keyboard's
+    /// host switch channel. The relationship is keyboard-initiated: pressing
+    /// one of this device's host keys switches every listed target first, then
+    /// lets the keyboard leave the current host.
+    #[serde(default, skip_serializing_if = "Vec::is_empty")]
+    pub host_switch_targets: Vec<String>,
+    /// Keyboard Fn-lock state (HID++ fn inversion, `0x40a2`/`0x40a3`): `true`
+    /// means the F-row sends F1–F12 without holding Fn. The state lives in
+    /// device RAM per host, so the agent re-applies it on reconnect like
+    /// [`Self::dpi`]. `None` means "never set — leave the keyboard alone".
+    #[serde(default, skip_serializing_if = "Option::is_none")]
+    pub fn_lock: Option<bool>,
 }
 
 /// `skip_serializing_if` helper for plain `bool` fields whose default is
@@ -158,11 +198,23 @@ struct RawDeviceConfig {
     #[serde(default)]
     lighting: Option<Lighting>,
     #[serde(default)]
+    light: Option<LightSettings>,
+    #[serde(default)]
     smartshift: Option<SmartShift>,
     #[serde(default)]
+    camera_controls: Option<CameraControls>,
+    #[serde(default)]
+    camera_profiles: BTreeMap<String, CameraControls>,
+    #[serde(default)]
+    camera_profile: Option<String>,
+    #[serde(default)]
     invert_scroll: bool,
     #[serde(default)]
     scroll_resolution: Option<ScrollResolution>,
+    #[serde(default)]
+    host_switch_targets: Vec<String>,
+    #[serde(default)]
+    fn_lock: Option<bool>,
 }
 
 impl From<RawDeviceConfig> for DeviceConfig {
@@ -204,9 +256,38 @@ impl From<RawDeviceConfig> for DeviceConfig {
             dpi_presets: raw.dpi_presets,
             dpi: raw.dpi,
             lighting: raw.lighting,
+            light: raw.light,
             smartshift: raw.smartshift,
+            camera_controls: raw.camera_controls,
+            camera_profiles: raw.camera_profiles,
+            camera_profile: raw.camera_profile,
             invert_scroll: raw.invert_scroll,
             scroll_resolution: raw.scroll_resolution,
+            host_switch_targets: raw.host_switch_targets,
+            fn_lock: raw.fn_lock,
         }
     }
 }
+
+#[cfg(test)]
+mod tests {
+    use super::DeviceConfig;
+
+    #[test]
+    fn host_switch_targets_round_trip_as_physical_keys() -> Result<(), Box<dyn std::error::Error>> {
+        let config: DeviceConfig = toml::from_str(
+            r#"host_switch_targets = [
+  "receiver:keyboard:slot:1",
+  "receiver:mouse:slot:2",
+]"#,
+        )?;
+
+        assert_eq!(
+            config.host_switch_targets,
+            ["receiver:keyboard:slot:1", "receiver:mouse:slot:2"]
+        );
+        let serialized = toml::to_string(&config)?;
+        assert!(serialized.contains("host_switch_targets"));
+        Ok(())
+    }
+}
diff --git a/crates/openlogi-core/src/config/key_trigger.rs b/crates/openlogi-core/src/config/key_trigger.rs
new file mode 100644
index 0000000000000000000000000000000000000000..6ef49517db8c8d14817e77f7a19d091e5d3de2ac
--- /dev/null
+++ b/crates/openlogi-core/src/config/key_trigger.rs
@@ -0,0 +1,180 @@
+//! Keyboard key triggers and the global keyboard-bindings section.
+
+use serde::{Deserialize, Serialize};
+
+use crate::binding::Action;
+
+/// Detectable modifier state for a keyboard trigger. A leaf-level duplicate of
+/// `openlogi_hook::KeyModifiers` — core must not depend on hook, so the four
+/// bools are mirrored here and converted at the agent boundary (which depends
+/// on both crates). `Fn` is absent: firmware-internal, unusable as a trigger
+/// (function-key-remapper spec, Appendix A).
+#[derive(
+    Debug, Clone, Copy, Default, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize,
+)]
+#[expect(
+    clippy::struct_excessive_bools,
+    reason = "four independent modifier flags mirrored from the OS hook"
+)]
+pub struct KeyModifiers {
+    /// Shift held.
+    pub shift: bool,
+    /// Control held.
+    pub control: bool,
+    /// Option/Alt held.
+    pub option: bool,
+    /// Command held.
+    pub command: bool,
+}
+
+impl KeyModifiers {
+    /// True when no modifiers are held.
+    #[must_use]
+    pub fn is_empty(&self) -> bool {
+        !self.shift && !self.control && !self.option && !self.command
+    }
+}
+
+/// A keyboard trigger: a keycode plus an optional modifier mask. The parse
+/// format is `[mod+]+key`, e.g. `"f1"`, `"shift+cmd+f5"`. Modifier names:
+/// `shift`, `control` (alias `ctrl`), `option` (alias `alt`), `command`
+/// (alias `cmd`). Key names: `esc`, `f1`..`f19` (macOS virtual keycodes).
+///
+/// Serializes as its string form (via `Display`) so it can be a TOML map key:
+/// `[keyboard.bindings]` keys are `"f1"`, `"shift+f2"`, etc.
+#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
+pub struct KeyTrigger {
+    /// Platform virtual keycode (macOS `kVK_*`).
+    pub keycode: u16,
+    /// Modifier mask that must also be held.
+    pub modifiers: KeyModifiers,
+}
+
+impl std::fmt::Display for KeyTrigger {
+    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+        let mut parts: Vec<&str> = Vec::new();
+        let m = &self.modifiers;
+        if m.shift {
+            parts.push("shift");
+        }
+        if m.control {
+            parts.push("control");
+        }
+        if m.option {
+            parts.push("option");
+        }
+        if m.command {
+            parts.push("command");
+        }
+        parts.push(keycode_to_name(self.keycode).ok_or(std::fmt::Error)?);
+        write!(f, "{}", parts.join("+"))
+    }
+}
+
+/// Reverse lookup for the parse table — needed so `Display` can render a
+/// parsed trigger back to its canonical name.
+fn keycode_to_name(code: u16) -> Option<&'static str> {
+    Some(match code {
+        0x35 => "esc",
+        0x7A => "f1",
+        0x78 => "f2",
+        0x63 => "f3",
+        0x76 => "f4",
+        0x60 => "f5",
+        0x61 => "f6",
+        0x62 => "f7",
+        0x64 => "f8",
+        0x65 => "f9",
+        0x6D => "f10",
+        0x67 => "f11",
+        0x6F => "f12",
+        0x69 => "f13",
+        0x6B => "f14",
+        0x71 => "f15",
+        0x6A => "f16",
+        0x40 => "f17",
+        0x4F => "f18",
+        0x50 => "f19",
+        _ => return None,
+    })
+}
+
+// String-form serde so KeyTrigger can be a TOML map key.
+impl Serialize for KeyTrigger {
+    fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
+        s.collect_str(self)
+    }
+}
+impl<'de> Deserialize<'de> for KeyTrigger {
+    fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
+        let s = String::deserialize(d)?;
+        s.parse().map_err(serde::de::Error::custom)
+    }
+}
+
+/// Error returned by [`KeyTrigger`]'s `FromStr` impl.
+#[derive(Debug)]
+pub struct ParseTriggerError(pub String);
+impl std::fmt::Display for ParseTriggerError {
+    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+        write!(f, "invalid key trigger: {}", self.0)
+    }
+}
+impl std::error::Error for ParseTriggerError {}
+
+impl std::str::FromStr for KeyTrigger {
+    type Err = ParseTriggerError;
+    fn from_str(s: &str) -> Result<Self, Self::Err> {
+        let mut mods = KeyModifiers::default();
+        let parts: Vec<&str> = s.split('+').map(str::trim).collect();
+        if parts.is_empty() || parts.iter().any(|p| p.is_empty()) {
+            return Err(ParseTriggerError("empty segment".into()));
+        }
+        // All but the last segment must be modifiers; the last is the key.
+        let (mod_parts, key_part) = parts.split_at(parts.len() - 1);
+        for part in mod_parts {
+            match part.to_ascii_lowercase().as_str() {
+                "shift" => mods.shift = true,
+                "control" | "ctrl" => mods.control = true,
+                "option" | "alt" => mods.option = true,
+                "command" | "cmd" => mods.command = true,
+                other => return Err(ParseTriggerError(format!("unknown modifier '{other}'"))),
+            }
+        }
+        let keycode = match key_part[0].to_ascii_lowercase().as_str() {
+            "esc" => 0x35,
+            "f1" => 0x7A,
+            "f2" => 0x78,
+            "f3" => 0x63,
+            "f4" => 0x76,
+            "f5" => 0x60,
+            "f6" => 0x61,
+            "f7" => 0x62,
+            "f8" => 0x64,
+            "f9" => 0x65,
+            "f10" => 0x6D,
+            "f11" => 0x67,
+            "f12" => 0x6F,
+            "f13" => 0x69,
+            "f14" => 0x6B,
+            "f15" => 0x71,
+            "f16" => 0x6A,
+            "f17" => 0x40,
+            "f18" => 0x4F,
+            "f19" => 0x50,
+            other => return Err(ParseTriggerError(format!("unknown key '{other}'"))),
+        };
+        Ok(KeyTrigger {
+            keycode,
+            modifiers: mods,
+        })
+    }
+}
+
+/// The top-level `[keyboard]` table. Bindings are keyed by [`KeyTrigger`].
+#[derive(Debug, Clone, Default, Serialize, Deserialize)]
+pub struct KeyboardConfig {
+    /// Function-key trigger → action map for the remapper.
+    #[serde(default, skip_serializing_if = "std::collections::HashMap::is_empty")]
+    pub bindings: std::collections::HashMap<KeyTrigger, Action>,
+}
diff --git a/crates/openlogi-core/src/config/settings.rs b/crates/openlogi-core/src/config/settings.rs
index cc50d01910d25a1cec213a809db1456d6a7ab946..a2c2f8b14e84037915e4f6c796d13b5eaf36ae62 100644
--- a/crates/openlogi-core/src/config/settings.rs
+++ b/crates/openlogi-core/src/config/settings.rs
@@ -3,6 +3,8 @@
 //! [`GestureOwner`], plus
 //! their serde `default_*` / `deserialize_*` helpers.
 
+use std::collections::BTreeMap;
+
 use serde::{Deserialize, Serialize};
 
 use crate::binding::ButtonId;
@@ -231,6 +233,73 @@ pub struct Lighting {
     pub brightness: u8,
 }
 
+/// Persisted settings for a standalone light such as Logitech Litra.
+///
+/// Brightness is stored as a normalized percentage so the same config shape
+/// works for lumen-based, percentage-based, and stepped light protocols. The
+/// selected driver maps it to its native range when applying the setting.
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
+pub struct LightSettings {
+    /// Whether the light should be on.
+    #[serde(default = "default_true")]
+    pub enabled: bool,
+    /// Link power to aggregate host-camera activity. This is a policy setting:
+    /// brightness, colour temperature, and the persisted manual power choice
+    /// remain independent from the transient effective power state.
+    #[serde(default, skip_serializing_if = "is_false")]
+    pub auto_camera: bool,
+    /// Brightness across the device's advertised range.
+    #[serde(
+        default = "default_light_brightness",
+        deserialize_with = "deserialize_brightness"
+    )]
+    pub brightness_percent: u8,
+    /// Desired colour temperature, when the device supports it.
+    #[serde(default, skip_serializing_if = "Option::is_none")]
+    pub temperature_kelvin: Option<u16>,
+    /// Optional colour for a driver that exposes RGB controls.
+    #[serde(default, skip_serializing_if = "Option::is_none")]
+    pub color: Option<Rgb>,
+}
+
+const fn default_light_brightness() -> u8 {
+    100
+}
+
+impl Default for LightSettings {
+    fn default() -> Self {
+        Self {
+            enabled: true,
+            auto_camera: false,
+            brightness_percent: default_light_brightness(),
+            temperature_kelvin: None,
+            color: None,
+        }
+    }
+}
+
+impl LightSettings {
+    /// Create settings with a normalized brightness percentage.
+    #[must_use]
+    pub fn new(enabled: bool, brightness_percent: u8, temperature_kelvin: Option<u16>) -> Self {
+        Self {
+            enabled,
+            auto_camera: false,
+            brightness_percent,
+            temperature_kelvin,
+            color: None,
+        }
+    }
+}
+
+#[allow(
+    clippy::trivially_copy_pass_by_ref,
+    reason = "serde's skip_serializing_if requires a fn(&T) -> bool signature"
+)]
+const fn is_false(value: &bool) -> bool {
+    !*value
+}
+
 impl Default for Lighting {
     fn default() -> Self {
         Self {
@@ -278,6 +347,17 @@ where
         .unwrap_or(Rgb::WHITE))
 }
 
+/// Per-webcam UVC controls, keyed by control name (`brightness`, `focus`,
+/// `focus_auto`, …). Each value is the raw device unit (its scale comes from
+/// the camera's own min/max); auto toggles store 0/1. Persisted so values
+/// survive an unplug or reboot — the GUI re-applies them over USB when the
+/// camera is next viewed, since the hardware only retains them until it loses
+/// power. Serializes to the same TOML table the earlier fixed-field struct
+/// wrote, so existing saved controls load unchanged.
+#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
+#[serde(transparent)]
+pub struct CameraControls(pub BTreeMap<String, i32>);
+
 /// Vertical wheel reporting resolution for HID++ `0x2121 HiResWheel`.
 #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
 #[serde(rename_all = "snake_case")]
diff --git a/crates/openlogi-core/src/config/tests.rs b/crates/openlogi-core/src/config/tests.rs
new file mode 100644
index 0000000000000000000000000000000000000000..574efff8f32fd782502f349011d31cb675b20980
--- /dev/null
+++ b/crates/openlogi-core/src/config/tests.rs
@@ -0,0 +1,1027 @@
+//! Config load/save and binding-map tests.
+
+#![allow(clippy::expect_used, reason = "expect/unwrap are idiomatic in tests")]
+
+use std::assert_matches;
+
+use super::*;
+use crate::binding::{default_binding, default_gesture_binding};
+
+fn write_and_read(config: &Config) -> Config {
+    let dir = tempfile::tempdir().expect("tempdir");
+    let path = dir.path().join("config.toml");
+    config.save_to_path(&path).expect("save");
+    Config::load_from_path(&path).expect("load")
+}
+
+#[test]
+fn key_trigger_parses_bare_and_modified() {
+    // Bare function key — F1 is macOS keycode 0x7A.
+    let t: KeyTrigger = "f1".parse().expect("parse key trigger");
+    assert_eq!(t.keycode, 0x7A);
+    assert!(t.modifiers.is_empty());
+
+    // Modifier-qualified, in any order, with aliases.
+    let t: KeyTrigger = "shift+cmd+f5".parse().expect("parse key trigger");
+    assert_eq!(t.keycode, 0x60); // F5
+    assert!(t.modifiers.shift && t.modifiers.command);
+    assert!(!t.modifiers.control && !t.modifiers.option);
+
+    let t: KeyTrigger = "ctrl+alt+f2".parse().expect("parse key trigger");
+    assert!(t.modifiers.control && t.modifiers.option);
+
+    // Esc.
+    assert_eq!(
+        "esc"
+            .parse::<KeyTrigger>()
+            .expect("parse key trigger")
+            .keycode,
+        0x35
+    );
+}
+
+#[test]
+fn key_trigger_parses_and_displays_extended_function_keys() {
+    let f13: KeyTrigger = "f13".parse().expect("parse key trigger");
+    let f17: KeyTrigger = "command+f17".parse().expect("parse key trigger");
+    let f19: KeyTrigger = "f19".parse().expect("parse key trigger");
+
+    assert_eq!(f13.keycode, 0x69);
+    assert_eq!(f17.keycode, 0x40);
+    assert_eq!(f17.to_string(), "command+f17");
+    assert_eq!(f19.keycode, 0x50);
+    assert_eq!(f19.to_string(), "f19");
+}
+
+#[test]
+fn key_trigger_rejects_unknown() {
+    assert!("f99".parse::<KeyTrigger>().is_err());
+    assert!("shift+".parse::<KeyTrigger>().is_err());
+    assert!("".parse::<KeyTrigger>().is_err());
+}
+
+#[test]
+fn keyboard_section_roundtrips_through_config() {
+    let mut config = Config::default();
+    config.keyboard.bindings.insert(
+        "f1".parse().expect("parse key trigger"),
+        Action::TypeText("hello".into()),
+    );
+    config.keyboard.bindings.insert(
+        "shift+f2".parse().expect("parse key trigger"),
+        Action::VolumeUp,
+    );
+    config.keyboard.bindings.insert(
+        "f17".parse().expect("parse key trigger"),
+        Action::MissionControl,
+    );
+
+    let roundtripped = write_and_read(&config);
+    assert_eq!(roundtripped.keyboard.bindings.len(), 3);
+    assert_eq!(
+        roundtripped
+            .keyboard
+            .bindings
+            .get(&"f1".parse::<KeyTrigger>().expect("parse key trigger")),
+        Some(&Action::TypeText("hello".into()))
+    );
+    assert_eq!(
+        roundtripped
+            .keyboard
+            .bindings
+            .get(&"f17".parse::<KeyTrigger>().expect("parse key trigger")),
+        Some(&Action::MissionControl)
+    );
+}
+
+#[test]
+fn set_keyboard_binding_inserts_and_clears() {
+    let mut config = Config::default();
+    let f1: KeyTrigger = "f1".parse().expect("parse key trigger");
+
+    // Insert.
+    config.set_keyboard_binding(f1.clone(), Some(Action::VolumeUp));
+    assert_eq!(config.keyboard_bindings().get(&f1), Some(&Action::VolumeUp));
+    assert_eq!(config.keyboard_bindings().len(), 1);
+
+    // Overwrite.
+    config.set_keyboard_binding(f1.clone(), Some(Action::MuteVolume));
+    assert_eq!(
+        config.keyboard_bindings().get(&f1),
+        Some(&Action::MuteVolume)
+    );
+    assert_eq!(config.keyboard_bindings().len(), 1);
+
+    // Clear via None.
+    config.set_keyboard_binding(f1.clone(), None);
+    assert!(config.keyboard_bindings().get(&f1).is_none());
+    assert!(config.keyboard_bindings().is_empty());
+}
+
+#[test]
+fn missing_file_yields_default() {
+    let dir = tempfile::tempdir().expect("tempdir");
+    let path = dir.path().join("nonexistent.toml");
+    let cfg = Config::load_from_path(&path).expect("load");
+    assert_eq!(cfg.schema_version, SCHEMA_VERSION);
+    assert!(cfg.devices.is_empty());
+}
+
+#[test]
+fn lighting_roundtrips_per_device() {
+    let mut cfg = Config::default();
+    cfg.set_lighting(
+        "g513",
+        Lighting {
+            enabled: true,
+            color: "00aabb".parse().expect("valid hex"),
+            brightness: 75,
+        },
+    );
+    let restored = write_and_read(&cfg);
+    assert_eq!(
+        restored.lighting("g513"),
+        Some(Lighting {
+            enabled: true,
+            color: "00aabb".parse().expect("valid hex"),
+            brightness: 75,
+        })
+    );
+    assert_eq!(restored.lighting("absent"), None);
+}
+
+#[test]
+fn standalone_light_settings_roundtrip_per_device() {
+    let mut cfg = Config::default();
+    cfg.set_light(
+        "raw:046d:c900:ff43:0202:serial:glow",
+        LightSettings {
+            enabled: false,
+            auto_camera: false,
+            brightness_percent: 65,
+            temperature_kelvin: Some(4600),
+            color: None,
+        },
+    );
+    let restored = write_and_read(&cfg);
+    assert_eq!(
+        restored.light("raw:046d:c900:ff43:0202:serial:glow"),
+        Some(LightSettings {
+            enabled: false,
+            auto_camera: false,
+            brightness_percent: 65,
+            temperature_kelvin: Some(4600),
+            color: None,
+        })
+    );
+    assert_eq!(restored.light("absent"), None);
+}
+
+#[test]
+fn standalone_light_brightness_is_clamped_on_load() {
+    let cfg: Config = toml::from_str(
+        r"
+            schema_version = 3
+            [devices.glow.light]
+            enabled = true
+            brightness_percent = 255
+        ",
+    )
+    .expect("light config loads");
+    assert_eq!(
+        cfg.light("glow").map(|light| light.brightness_percent),
+        Some(100)
+    );
+}
+
+#[test]
+fn standalone_light_camera_automation_roundtrips() {
+    let mut cfg = Config::default();
+    cfg.set_light(
+        "raw:046d:c900:ff43:0202:serial:glow",
+        LightSettings {
+            enabled: true,
+            auto_camera: true,
+            brightness_percent: 80,
+            temperature_kelvin: Some(5000),
+            color: None,
+        },
+    );
+
+    let restored = write_and_read(&cfg);
+    assert_eq!(
+        restored
+            .light("raw:046d:c900:ff43:0202:serial:glow")
+            .map(|light| light.auto_camera),
+        Some(true)
+    );
+}
+
+#[test]
+fn unparseable_lighting_color_falls_back_to_white() {
+    let cfg: Config = toml::from_str(
+        r#"
+            schema_version = 3
+            [devices.g513.lighting]
+            enabled = true
+            color = "red"
+            brightness = 50
+        "#,
+    )
+    .expect("config with a bad color still loads");
+    assert_eq!(
+        cfg.lighting("g513").map(|l| l.color),
+        Some(crate::color::Rgb::WHITE)
+    );
+}
+
+#[test]
+fn hash_prefixed_lighting_color_migrates_to_canonical_hex() {
+    let dir = tempfile::tempdir().expect("tempdir");
+    let path = dir.path().join("config.toml");
+    fs::write(
+        &path,
+        r##"
+            schema_version = 3
+            [devices.g513.lighting]
+            enabled = true
+            color = "#ff0000"
+            brightness = 50
+        "##,
+    )
+    .expect("write config");
+
+    let cfg = Config::load_from_path(&path).expect("load hash-prefixed color");
+    assert_eq!(
+        cfg.lighting("g513").map(|lighting| lighting.color),
+        Some(crate::color::Rgb::new(0xff, 0x00, 0x00))
+    );
+
+    cfg.save_to_path(&path).expect("save canonical color");
+    let saved = fs::read_to_string(path).expect("read saved config");
+    assert!(saved.contains("color = \"ff0000\""));
+    assert!(!saved.contains("color = \"#"));
+}
+
+#[test]
+fn dpi_roundtrips_per_device() {
+    let mut cfg = Config::default();
+    cfg.set_dpi("2b042", 1600);
+    let restored = write_and_read(&cfg);
+    assert_eq!(restored.dpi("2b042"), Some(1600));
+    assert_eq!(restored.dpi("absent"), None);
+}
+
+#[test]
+fn smartshift_roundtrips_per_device() {
+    let mut cfg = Config::default();
+    cfg.set_smartshift(
+        "2b042",
+        SmartShift {
+            mode: WheelMode::Ratchet,
+            auto_disengage: 16,
+            tunable_torque: 30,
+        },
+    );
+    let restored = write_and_read(&cfg);
+    assert_eq!(
+        restored.smartshift("2b042"),
+        Some(SmartShift {
+            mode: WheelMode::Ratchet,
+            auto_disengage: 16,
+            tunable_torque: 30,
+        })
+    );
+    assert_eq!(restored.smartshift("absent"), None);
+}
+
+#[test]
+fn invert_scroll_roundtrips_per_device() {
+    let mut cfg = Config::default();
+    // Default is the native direction for any device, present or not.
+    assert!(!cfg.invert_scroll("2b042"));
+    cfg.set_invert_scroll("2b042", true);
+    let restored = write_and_read(&cfg);
+    assert!(restored.invert_scroll("2b042"));
+    assert!(!restored.invert_scroll("absent"));
+}
+
+#[test]
+fn default_invert_scroll_is_omitted_from_toml() {
+    // A device block with only the default (false) invert_scroll must not
+    // emit the field — `skip_serializing_if` keeps configs clean.
+    let mut cfg = Config::default();
+    cfg.set_binding("2b042", ButtonId::Back, Binding::Single(Action::Copy));
+    cfg.set_invert_scroll("2b042", false);
+    let body = toml::to_string_pretty(&cfg).expect("serialize");
+    assert!(
+        !body.contains("invert_scroll"),
+        "default invert_scroll should be omitted: {body}"
+    );
+}
+
+#[test]
+fn scroll_resolution_roundtrips_all_three_states() {
+    let mut cfg = Config::default();
+    assert_eq!(cfg.scroll_resolution("mouse"), None);
+
+    cfg.set_scroll_resolution("mouse", Some(ScrollResolution::Low));
+    let low = write_and_read(&cfg);
+    assert_eq!(low.scroll_resolution("mouse"), Some(ScrollResolution::Low));
+
+    cfg.set_scroll_resolution("mouse", Some(ScrollResolution::High));
+    let high = write_and_read(&cfg);
+    assert_eq!(
+        high.scroll_resolution("mouse"),
+        Some(ScrollResolution::High)
+    );
+
+    cfg.set_scroll_resolution("mouse", None);
+    let unmanaged = write_and_read(&cfg);
+    assert_eq!(unmanaged.scroll_resolution("mouse"), None);
+}
+
+#[test]
+fn unset_scroll_resolution_is_omitted_from_toml() {
+    let mut cfg = Config::default();
+    cfg.set_binding("mouse", ButtonId::Back, Binding::Single(Action::Copy));
+    cfg.set_scroll_resolution("mouse", Some(ScrollResolution::Low));
+    cfg.set_scroll_resolution("mouse", None);
+
+    let body = toml::to_string_pretty(&cfg).expect("serialize");
+    assert!(
+        !body.contains("scroll_resolution"),
+        "unset scroll resolution should be omitted: {body}"
+    );
+}
+
+#[test]
+fn config_without_scroll_resolution_loads_as_unmanaged() {
+    let dir = tempfile::tempdir().expect("tempdir");
+    let path = dir.path().join("config.toml");
+    fs::write(
+        &path,
+        r"
+            schema_version = 3
+            [devices.mouse]
+            invert_scroll = true
+        ",
+    )
+    .expect("write config");
+
+    let cfg = Config::load_from_path(&path).expect("load existing config");
+    assert_eq!(cfg.scroll_resolution("mouse"), None);
+    assert!(cfg.invert_scroll("mouse"));
+}
+
+#[test]
+fn bindings_roundtrip_per_device() {
+    let mut cfg = Config::default();
+    cfg.set_binding("2b042", ButtonId::Back, Binding::Single(Action::Copy));
+    cfg.set_binding(
+        "2b042",
+        ButtonId::DpiToggle,
+        Binding::Single(Action::CustomShortcut(crate::binding::KeyCombo {
+            modifiers: crate::binding::KeyCombo::MOD_CMD,
+            key_code: 0x23, // kVK_ANSI_P
+            display: "⌘P".into(),
+        })),
+    );
+    cfg.set_binding("4082d", ButtonId::Back, Binding::Single(Action::Paste));
+
+    let parsed = write_and_read(&cfg);
+
+    // Per-device isolation.
+    let a = parsed.bindings_for("2b042");
+    assert_eq!(a.get(&ButtonId::Back), Some(&Binding::Single(Action::Copy)));
+    assert_eq!(
+        a.get(&ButtonId::DpiToggle),
+        Some(&Binding::Single(Action::CustomShortcut(
+            crate::binding::KeyCombo {
+                modifiers: crate::binding::KeyCombo::MOD_CMD,
+                key_code: 0x23,
+                display: "⌘P".into(),
+            }
+        )))
+    );
+
+    let b = parsed.bindings_for("4082d");
+    assert_eq!(
+        b.get(&ButtonId::Back),
+        Some(&Binding::Single(Action::Paste))
+    );
+    assert_eq!(b.len(), 1, "device b should only see its own bindings");
+
+    // Unknown device returns empty map without panic.
+    assert!(parsed.bindings_for("deadbeef").is_empty());
+}
+
+#[test]
+fn human_readable_toml_layout() {
+    let mut cfg = Config::default();
+    cfg.set_binding(
+        "2b042",
+        ButtonId::Back,
+        Binding::Single(Action::BrowserBack),
+    );
+    let body = toml::to_string_pretty(&cfg).expect("serialize");
+
+    // The key only contains [A-Za-z0-9_], so TOML emits it as a bare-word
+    // table key (no surrounding quotes). The test asserts the observable
+    // structure rather than locking in a specific quoting.
+    assert!(body.contains("schema_version = 3"), "got: {body}");
+    assert!(body.contains("[devices.2b042.bindings]"), "got: {body}");
+    // A `Single` binding serializes byte-identically to the pre-v2 bare
+    // `Action`, so the leaf line is unchanged.
+    assert!(body.contains("Back = \"BrowserBack\""), "got: {body}");
+}
+
+#[test]
+fn dpi_presets_roundtrip_per_device() {
+    let mut cfg = Config::default();
+    cfg.set_dpi_presets("2b042", vec![800, 1600, 3200]);
+    cfg.set_dpi_presets("4082d", vec![400, 1600]);
+
+    let parsed = write_and_read(&cfg);
+
+    assert_eq!(parsed.dpi_presets("2b042"), vec![800, 1600, 3200]);
+    assert_eq!(parsed.dpi_presets("4082d"), vec![400, 1600]);
+    assert!(parsed.dpi_presets("unknown").is_empty());
+}
+
+#[test]
+fn empty_dpi_presets_skip_serialization() {
+    let mut cfg = Config::default();
+    // Add a binding so the device block exists.
+    cfg.set_binding("2b042", ButtonId::Back, Binding::Single(Action::Copy));
+    cfg.set_dpi_presets("2b042", vec![800]);
+    cfg.set_dpi_presets("2b042", vec![]); // clear
+
+    let body = toml::to_string_pretty(&cfg).expect("serialize");
+    assert!(
+        !body.contains("dpi_presets"),
+        "empty dpi_presets should be omitted: {body}"
+    );
+}
+
+#[test]
+fn device_identity_roundtrips_and_is_iterable() {
+    use crate::device::{Capabilities, DeviceKind};
+
+    let mut cfg = Config::default();
+    let mouse = DeviceIdentity {
+        display_name: "MX Master 3S".to_string(),
+        model_info: None,
+        codename: None,
+        kind: DeviceKind::Mouse,
+        capabilities: Capabilities {
+            buttons: true,
+            pointer: true,
+            lighting: false,
+            scroll_inversion: false,
+            hires_wheel: true,
+            thumbwheel: false,
+        },
+        light_capabilities: None,
+        driver_id: None,
+        registry_model_id: None,
+    };
+    cfg.set_device_identity("2b034", mouse.clone());
+    // Recording an identity must not disturb unrelated per-device state.
+    cfg.set_binding(
+        "2b034",
+        ButtonId::Back,
+        Binding::Single(Action::BrowserBack),
+    );
+
+    let parsed = write_and_read(&cfg);
+    assert_eq!(parsed.device_identity("2b034"), Some(&mouse));
+    assert_eq!(parsed.device_identity("absent"), None);
+    assert_eq!(
+        parsed.bindings_for("2b034").get(&ButtonId::Back),
+        Some(&Binding::Single(Action::BrowserBack)),
+        "identity must coexist with bindings on the same device block"
+    );
+    assert_eq!(
+        parsed.known_identities().collect::<Vec<_>>(),
+        vec![("2b034", &mouse)]
+    );
+}
+
+#[test]
+fn selected_device_roundtrips() {
+    let mut cfg = Config::default();
+    assert_eq!(cfg.selected_device(), None);
+    cfg.set_selected_device(Some("2b042".into()));
+    let parsed = write_and_read(&cfg);
+    assert_eq!(parsed.selected_device(), Some("2b042"));
+}
+
+#[test]
+fn per_app_overlay_takes_precedence() {
+    let mut cfg = Config::default();
+    cfg.set_binding(
+        "2b042",
+        ButtonId::Back,
+        Binding::Single(Action::BrowserBack),
+    );
+    cfg.set_binding(
+        "2b042",
+        ButtonId::Forward,
+        Binding::Single(Action::BrowserForward),
+    );
+    cfg.set_per_app_binding(
+        "2b042",
+        "com.microsoft.VSCode",
+        ButtonId::Back,
+        Some(Action::Undo),
+    );
+
+    // Global: both buttons are browser nav.
+    let global = cfg.effective_bindings("2b042", None);
+    assert_eq!(
+        global.get(&ButtonId::Back),
+        Some(&Binding::Single(Action::BrowserBack))
+    );
+    assert_eq!(
+        global.get(&ButtonId::Forward),
+        Some(&Binding::Single(Action::BrowserForward))
+    );
+
+    // VSCode: Back overridden (wrapped as Single), Forward inherits.
+    let vscode = cfg.effective_bindings("2b042", Some("com.microsoft.VSCode"));
+    assert_eq!(
+        vscode.get(&ButtonId::Back),
+        Some(&Binding::Single(Action::Undo))
+    );
+    assert_eq!(
+        vscode.get(&ButtonId::Forward),
+        Some(&Binding::Single(Action::BrowserForward))
+    );
+
+    // Unrelated app falls through.
+    let other = cfg.effective_bindings("2b042", Some("com.apple.Safari"));
+    assert_eq!(
+        other.get(&ButtonId::Back),
+        Some(&Binding::Single(Action::BrowserBack))
+    );
+}
+
+#[test]
+fn per_app_binding_removal_prunes_empty_app() {
+    let mut cfg = Config::default();
+    cfg.set_per_app_binding(
+        "2b042",
+        "com.example.App",
+        ButtonId::Back,
+        Some(Action::Copy),
+    );
+    cfg.set_per_app_binding("2b042", "com.example.App", ButtonId::Back, None);
+    assert!(
+        cfg.devices["2b042"].per_app_bindings.is_empty(),
+        "removing last override should prune the app entry"
+    );
+}
+
+#[test]
+fn app_settings_default_omits_block() {
+    let cfg = Config::default();
+    let body = toml::to_string_pretty(&cfg).expect("serialize");
+    assert!(
+        !body.contains("app_settings"),
+        "default app_settings should be omitted: {body}"
+    );
+}
+
+#[test]
+fn app_settings_launch_at_login_roundtrips() {
+    let mut cfg = Config::default();
+    cfg.app_settings.launch_at_login = true;
+    let parsed = write_and_read(&cfg);
+    assert!(parsed.app_settings.launch_at_login);
+}
+
+#[test]
+fn asset_source_preference_roundtrips() {
+    let mut cfg = Config::default();
+    cfg.app_settings.asset_source = AssetSourcePreference::OpenLogi;
+
+    let body = toml::to_string_pretty(&cfg).expect("serialize");
+    let parsed = write_and_read(&cfg);
+
+    assert!(body.contains("asset_source = \"openlogi\""));
+    assert_eq!(
+        parsed.app_settings.asset_source,
+        AssetSourcePreference::OpenLogi
+    );
+}
+
+#[test]
+fn config_without_asset_source_keeps_automatic_selection() {
+    let parsed: Config = toml::from_str(
+        r"
+            schema_version = 3
+            [app_settings]
+            auto_download_assets = false
+        ",
+    )
+    .expect("config predating the asset-source setting loads");
+
+    assert_eq!(
+        parsed.app_settings.asset_source,
+        AssetSourcePreference::Automatic
+    );
+}
+
+#[test]
+fn cleared_selected_device_omits_field() {
+    let mut cfg = Config::default();
+    cfg.set_selected_device(Some("2b042".into()));
+    cfg.set_selected_device(None);
+    let body = toml::to_string_pretty(&cfg).expect("serialize");
+    assert!(
+        !body.contains("selected_device"),
+        "cleared selection should not appear: {body}"
+    );
+}
+
+#[test]
+fn empty_device_block_is_skipped_in_output() {
+    // Inserting then clearing should not leave a [devices."x"] header
+    // with no bindings under it (skip_serializing_if on bindings).
+    let mut cfg = Config::default();
+    cfg.set_binding("2b042", ButtonId::Back, Binding::Single(Action::Copy));
+    cfg.devices
+        .get_mut("2b042")
+        .expect("entry")
+        .bindings
+        .clear();
+    let body = toml::to_string_pretty(&cfg).expect("serialize");
+    assert!(
+        !body.contains("Back"),
+        "cleared bindings should not appear: {body}"
+    );
+}
+
+#[test]
+fn migrates_v1_button_and_gesture_bindings() {
+    // A pre-v2 file: split button_bindings + a flat gesture_bindings map.
+    let v1 = "\
+schema_version = 1
+
+[devices.2b042.button_bindings]
+Back = \"BrowserBack\"
+
+[devices.2b042.gesture_bindings]
+Up = \"Copy\"
+Click = \"Paste\"
+";
+    let dir = tempfile::tempdir().expect("tempdir");
+    let path = dir.path().join("config.toml");
+    fs::write(&path, v1).expect("write");
+
+    // v1 still loads (version <= current) and folds into the merged map.
+    let cfg = Config::load_from_path(&path).expect("load v1");
+    let bindings = cfg.bindings_for("2b042");
+    assert_eq!(
+        bindings.get(&ButtonId::Back),
+        Some(&Binding::Single(Action::BrowserBack))
+    );
+    let mut gesture = BTreeMap::new();
+    gesture.insert(GestureDirection::Up, Action::Copy);
+    gesture.insert(GestureDirection::Click, Action::Paste);
+    assert_eq!(
+        bindings.get(&ButtonId::GestureButton),
+        Some(&Binding::Gesture(gesture))
+    );
+
+    // Saving self-heals to the current shape: stamped version + merged table,
+    // legacy field names gone.
+    let body = toml::to_string_pretty(&cfg).expect("serialize");
+    assert!(body.contains("schema_version = 3"), "got: {body}");
+    assert!(body.contains("[devices.2b042.bindings]"), "got: {body}");
+    assert!(!body.contains("button_bindings"), "got: {body}");
+    assert!(!body.contains("gesture_bindings"), "got: {body}");
+}
+
+#[test]
+fn migration_gesture_map_wins_over_legacy_single_gesture_button_entry() {
+    // The data-loss guard: when a legacy single button_bindings[GestureButton]
+    // entry coexists with a gesture_bindings map (reachable via hand-edited
+    // or very old configs), the gesture map must survive — not be shadowed by
+    // the single entry. Mirrors the pre-v2 "gesture entries win" rule.
+    let v1 = "\
+schema_version = 1
+
+[devices.2b042.button_bindings]
+GestureButton = \"MissionControl\"
+
+[devices.2b042.gesture_bindings]
+Up = \"Copy\"
+Down = \"Paste\"
+";
+    let dir = tempfile::tempdir().expect("tempdir");
+    let path = dir.path().join("config.toml");
+    fs::write(&path, v1).expect("write");
+
+    let cfg = Config::load_from_path(&path).expect("load v1");
+    let mut gesture = BTreeMap::new();
+    gesture.insert(GestureDirection::Up, Action::Copy);
+    gesture.insert(GestureDirection::Down, Action::Paste);
+    assert_eq!(
+        cfg.bindings_for("2b042").get(&ButtonId::GestureButton),
+        Some(&Binding::Gesture(gesture)),
+        "gesture map must win over the legacy single GestureButton entry"
+    );
+}
+
+#[test]
+fn migration_drops_vestigial_lone_gesture_button_single() {
+    // A v1 file with only `button_bindings[GestureButton]` and no
+    // `gesture_bindings` (the pre-gesture-picker shape). That entry never
+    // dispatched in v1 — the gesture button's plain press routes through the
+    // gesture `Click` slot, not the per-button map — so migrating it to a
+    // `Binding::Single` would leave an unreachable entry the GUI hides and the
+    // runtime ignores. It must be dropped, not shadow the gesture path.
+    let v1 = "\
+schema_version = 1
+
+[devices.2b042.button_bindings]
+GestureButton = \"MissionControl\"
+Back = \"BrowserBack\"
+";
+    let dir = tempfile::tempdir().expect("tempdir");
+    let path = dir.path().join("config.toml");
+    fs::write(&path, v1).expect("write");
+
+    let bindings = Config::load_from_path(&path)
+        .expect("load v1")
+        .bindings_for("2b042");
+    // An ordinary button still migrates to a `Single`...
+    assert_eq!(
+        bindings.get(&ButtonId::Back),
+        Some(&Binding::Single(Action::BrowserBack))
+    );
+    // ...but the vestigial gesture-button single is gone, leaving the button
+    // to fall back to its canonical default rather than an unreachable entry.
+    assert_eq!(bindings.get(&ButtonId::GestureButton), None);
+}
+
+#[test]
+fn rejects_newer_schema_version_but_accepts_v1() {
+    // A future version is rejected loudly; the current and older versions
+    // load (older ones migrate through the shim).
+    let dir = tempfile::tempdir().expect("tempdir");
+    let path = dir.path().join("config.toml");
+    fs::write(&path, "schema_version = 99\n").expect("write");
+    assert_matches!(
+        Config::load_from_path(&path).expect_err("v99 should fail"),
+        ConfigError::UnsupportedSchemaVersion { found: 99, .. }
+    );
+
+    fs::write(&path, "schema_version = 1\n").expect("write");
+    assert!(
+        Config::load_from_path(&path).is_ok(),
+        "v1 should still load"
+    );
+}
+
+#[test]
+fn set_gesture_direction_upgrades_single_to_gesture() {
+    let mut cfg = Config::default();
+    // Start from a Single binding, then bind a swipe direction.
+    cfg.set_binding(
+        "2b042",
+        ButtonId::Back,
+        Binding::Single(Action::BrowserBack),
+    );
+    cfg.set_gesture_direction("2b042", ButtonId::Back, GestureDirection::Up, Action::Copy);
+
+    match cfg.bindings_for("2b042").get(&ButtonId::Back) {
+        Some(Binding::Gesture(map)) => {
+            // The prior single action is preserved as the Click entry.
+            assert_eq!(
+                map.get(&GestureDirection::Click),
+                Some(&Action::BrowserBack)
+            );
+            assert_eq!(map.get(&GestureDirection::Up), Some(&Action::Copy));
+        }
+        other => panic!("expected Gesture after upgrade, got {other:?}"),
+    }
+}
+
+#[test]
+fn set_gesture_direction_on_fresh_gesture_button_seeds_click() {
+    // Binding one direction on a never-configured gesture button must still
+    // persist a `Click`, so the click projection is the canonical default
+    // rather than `Action::None` (which reads as a no-op press).
+    let mut cfg = Config::default();
+    cfg.set_gesture_direction(
+        "2b042",
+        ButtonId::GestureButton,
+        GestureDirection::Up,
+        Action::Copy,
+    );
+
+    match cfg.bindings_for("2b042").get(&ButtonId::GestureButton) {
+        Some(Binding::Gesture(map)) => {
+            assert_eq!(map.get(&GestureDirection::Up), Some(&Action::Copy));
+            assert_eq!(
+                map.get(&GestureDirection::Click),
+                Some(&crate::binding::default_gesture_binding(
+                    GestureDirection::Click
+                )),
+                "a fresh gesture button must seed a Click from its default"
+            );
+        }
+        other => panic!("expected Gesture, got {other:?}"),
+    }
+}
+
+#[test]
+fn gesture_owner_defaults_to_hidpp_button_yields_to_oshook_and_can_be_off() {
+    let mut cfg = Config::default();
+    // Default: the dedicated HID++ gesture button owns the gesture role even with no config.
+    assert_eq!(cfg.gesture_owner("2b042"), Some(ButtonId::GestureButton));
+
+    // A dedicated HID++ gesture binding keeps it the owner.
+    cfg.set_gesture_direction(
+        "2b042",
+        ButtonId::GestureButton,
+        GestureDirection::Up,
+        Action::MissionControl,
+    );
+    assert_eq!(cfg.gesture_owner("2b042"), Some(ButtonId::GestureButton));
+
+    // An explicit OS-hook gesture button takes the role over.
+    cfg.set_binding(
+        "2b042",
+        ButtonId::Forward,
+        Binding::Gesture(BTreeMap::from([(GestureDirection::Up, Action::Copy)])),
+    );
+    assert_eq!(cfg.gesture_owner("2b042"), Some(ButtonId::Forward));
+
+    // Turning gestures off explicitly yields `None` (not the HID++ button default).
+    let mut off = Config::default();
+    off.disable_gestures("2b042");
+    assert_eq!(off.gesture_owner("2b042"), None);
+}
+
+#[test]
+fn set_gesture_owner_records_owner_without_destroying_other_maps() {
+    let mut cfg = Config::default();
+    // Customize the dedicated HID++ gesture button's Up swipe; it is the (inferred) owner.
+    cfg.set_gesture_direction(
+        "2b042",
+        ButtonId::GestureButton,
+        GestureDirection::Up,
+        Action::Copy,
+    );
+    assert_eq!(cfg.gesture_owner("2b042"), Some(ButtonId::GestureButton));
+
+    // Promote Back: the owner becomes Back explicitly; the HID++ gesture button keeps
+    // its full gesture map (no destructive demotion).
+    cfg.set_binding("2b042", ButtonId::Back, Action::BrowserBack.into());
+    cfg.set_gesture_owner("2b042", ButtonId::Back);
+    assert_eq!(cfg.gesture_owner("2b042"), Some(ButtonId::Back));
+
+    let bindings = cfg.bindings_for("2b042");
+    // Back is a full five-direction gesture button: its prior single action
+    // stays as Click, and the swipe arms are seeded from defaults.
+    match bindings.get(&ButtonId::Back) {
+        Some(Binding::Gesture(map)) => {
+            assert_eq!(
+                map.get(&GestureDirection::Click),
+                Some(&Action::BrowserBack)
+            );
+            assert_eq!(
+                map.get(&GestureDirection::Up),
+                Some(&default_gesture_binding(GestureDirection::Up)),
+                "a promoted button gets full default arms"
+            );
+        }
+        other => panic!("expected Back to be a gesture binding, got {other:?}"),
+    }
+    // The HID++ gesture button's customized map survived the switch intact.
+    match bindings.get(&ButtonId::GestureButton) {
+        Some(Binding::Gesture(map)) => {
+            assert_eq!(map.get(&GestureDirection::Up), Some(&Action::Copy));
+        }
+        other => panic!("expected the HID++ gesture button map preserved, got {other:?}"),
+    }
+
+    // Switching back restores the user's customization, not defaults
+    // (regression guard: owner-switch used to discard the swipe arms).
+    cfg.set_gesture_owner("2b042", ButtonId::GestureButton);
+    assert_eq!(cfg.gesture_owner("2b042"), Some(ButtonId::GestureButton));
+    match cfg.bindings_for("2b042").get(&ButtonId::GestureButton) {
+        Some(Binding::Gesture(map)) => {
+            assert_eq!(map.get(&GestureDirection::Up), Some(&Action::Copy));
+        }
+        other => panic!("expected preserved gesture map, got {other:?}"),
+    }
+}
+
+#[test]
+fn set_gesture_owner_seeds_a_fresh_button_with_full_directions() {
+    let mut cfg = Config::default();
+    // The dedicated HID++ gesture button gets the full default direction map.
+    cfg.set_gesture_owner("2b042", ButtonId::GestureButton);
+    match cfg.bindings_for("2b042").get(&ButtonId::GestureButton) {
+        Some(Binding::Gesture(map)) => {
+            for dir in GestureDirection::ALL {
+                assert_eq!(map.get(&dir), Some(&default_gesture_binding(dir)));
+            }
+        }
+        other => panic!("expected full default gesture map, got {other:?}"),
+    }
+
+    // A fresh OS-hook button also gets all five directions, not just a Click:
+    // its native action stays as Click, and the swipe arms are defaults — so
+    // the GUI's shown defaults are exactly what the runtime dispatches.
+    cfg.set_gesture_owner("2b042", ButtonId::Forward);
+    match cfg.bindings_for("2b042").get(&ButtonId::Forward) {
+        Some(Binding::Gesture(map)) => {
+            assert_eq!(
+                map.get(&GestureDirection::Click),
+                Some(&default_binding(ButtonId::Forward))
+            );
+            for dir in [
+                GestureDirection::Up,
+                GestureDirection::Down,
+                GestureDirection::Left,
+                GestureDirection::Right,
+            ] {
+                assert_eq!(map.get(&dir), Some(&default_gesture_binding(dir)));
+            }
+        }
+        other => panic!("expected full gesture map for Forward, got {other:?}"),
+    }
+}
+
+#[test]
+fn disable_gestures_turns_off_without_destroying_maps() {
+    let mut cfg = Config::default();
+    cfg.set_gesture_direction(
+        "2b042",
+        ButtonId::GestureButton,
+        GestureDirection::Up,
+        Action::Copy,
+    );
+    cfg.disable_gestures("2b042");
+    // Off, but the HID++ gesture button's customized map is preserved (re-enabling
+    // restores it rather than resurrecting a wiped default).
+    assert_eq!(cfg.gesture_owner("2b042"), None);
+    match cfg.bindings_for("2b042").get(&ButtonId::GestureButton) {
+        Some(Binding::Gesture(map)) => {
+            assert_eq!(map.get(&GestureDirection::Up), Some(&Action::Copy));
+        }
+        other => panic!("expected the gesture map preserved while off, got {other:?}"),
+    }
+}
+
+#[test]
+fn gesture_owner_field_roundtrips_as_a_scalar() {
+    let mut cfg = Config::default();
+    cfg.set_gesture_owner("2b042", ButtonId::Back); // explicit button
+    cfg.disable_gestures("4082d"); // explicit off
+
+    let parsed = write_and_read(&cfg);
+    assert_eq!(parsed.gesture_owner("2b042"), Some(ButtonId::Back));
+    assert_eq!(parsed.gesture_owner("4082d"), None);
+
+    // The custom codec keeps it a bare TOML string (a nested table would risk
+    // a value-after-table serialization error, since `bindings` is a table).
+    let body = toml::to_string_pretty(&cfg).expect("serialize");
+    assert!(body.contains("gesture_owner = \"Back\""), "got: {body}");
+    assert!(body.contains("gesture_owner = \"Off\""), "got: {body}");
+}
+
+#[test]
+fn invalid_gesture_owner_string_is_tolerated_not_fatal() {
+    // A hand-edit typo in gesture_owner must NOT fail the whole-document parse
+    // (which would revert every device's settings to defaults). It degrades
+    // to "infer" while the rest of the device config survives.
+    let toml = "\
+schema_version = 2
+
+[devices.2b042]
+gesture_owner = \"bogus\"
+
+[devices.2b042.bindings]
+Back = \"Copy\"
+";
+    let dir = tempfile::tempdir().expect("tempdir");
+    let path = dir.path().join("config.toml");
+    fs::write(&path, toml).expect("write");
+
+    let cfg =
+        Config::load_from_path(&path).expect("an invalid gesture_owner must not fail the load");
+    // The rest of the device config survived...
+    assert_eq!(
+        cfg.bindings_for("2b042").get(&ButtonId::Back),
+        Some(&Binding::Single(Action::Copy))
+    );
+    // ...and the bad owner degraded to inference (HID++ button default here).
+    assert_eq!(cfg.gesture_owner("2b042"), Some(ButtonId::GestureButton));
+}
diff --git a/crates/openlogi-core/src/device.rs b/crates/openlogi-core/src/device.rs
index 165af39867d760fd67cd4d0cb13cb2bfe94a0527..67e82264504371d4c0941160e12770019ca421dd 100644
--- a/crates/openlogi-core/src/device.rs
+++ b/crates/openlogi-core/src/device.rs
@@ -6,6 +6,10 @@
 
 use serde::{Deserialize, Serialize};
 
+mod light;
+
+pub use light::{LightCapabilities, LightValueRange, LightValueRangeError, LightValueUnit};
+
 /// What a paired peripheral is. Mirrors `hidpp::receiver::bolt::BoltDeviceKind`
 /// but is owned by us so consumers don't depend on `hidpp`.
 ///
@@ -42,9 +46,16 @@ pub enum DeviceKind {
     Joystick,
     /// Audio headsets paired through a receiver.
     Headset,
+    /// Logitech webcam (UVC), configured through `openlogi-camera`.
+    Camera,
     /// Not classified by any source — also the "no asset opinion" value
     /// [`DeviceKind::from_registry_type`] returns for unmodelled strings.
     Unknown,
+    /// Standalone light or other illumination device controlled outside HID++.
+    ///
+    /// This is an identity hint only. UI controls are gated by the dedicated
+    /// light capability descriptor, never by this variant alone.
+    Light,
 }
 
 impl DeviceKind {
@@ -68,6 +79,8 @@ impl DeviceKind {
             "gamepad" => Self::Gamepad,
             "joystick" => Self::Joystick,
             "headset" => Self::Headset,
+            "camera" => Self::Camera,
+            "light" | "lighting" | "illumination_light" => Self::Light,
             _ => Self::Unknown,
         }
     }
@@ -315,6 +328,65 @@ pub struct PairedDevice {
     pub capabilities: Option<Capabilities>,
 }
 
+/// Address of a standalone raw-HID interface.
+///
+/// The identity is an opaque transport-generated string. It is deliberately
+/// kept separate from the HID++ receiver/slot address so a raw device cannot
+/// accidentally enter the HID++ `Direct` path.
+#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
+pub struct RawDeviceAddress {
+    /// HID vendor ID.
+    pub vendor_id: u16,
+    /// HID product ID.
+    pub product_id: u16,
+    /// HID usage page.
+    pub usage_page: u16,
+    /// HID usage ID.
+    pub usage_id: u16,
+    /// Identity chosen by the transport: a serial when available, otherwise
+    /// an explicitly transient OS-node identity. It is never an enumeration
+    /// index and a transient value is not persisted as a physical key.
+    pub identity: String,
+}
+
+/// A standalone device that is not a HID++ receiver pairing slot.
+///
+/// This is the inventory bridge for Litra and future non-HID++ categories.
+/// Receiver-backed devices continue to use [`PairedDevice`] inside
+/// [`DeviceInventory`].
+#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
+pub struct StandaloneDevice {
+    /// Raw HID address used to re-find the interface.
+    pub address: RawDeviceAddress,
+    /// Human-readable name supplied by the OS/HID descriptor.
+    pub display_name: String,
+    /// Human-readable manufacturer, when available.
+    pub manufacturer: Option<String>,
+    /// Device serial, when the HID backend exposes one.
+    pub serial_number: Option<String>,
+    /// Stable four-byte identity when the protocol/driver provides one.
+    /// Raw HID drivers may use zeroes when no such field exists.
+    pub unit_id: [u8; 4],
+    /// Identity classification. Capability fields gate controls.
+    pub kind: DeviceKind,
+    /// Whether this interface was present in the latest completed scan.
+    pub online: bool,
+    /// HID++ capabilities are absent for a non-HID++ device.
+    pub capabilities: Option<Capabilities>,
+    /// Standalone capability descriptor, if the selected driver recognizes it.
+    pub light_capabilities: Option<LightCapabilities>,
+    /// Stable identifier of the driver family that owns this raw interface.
+    /// This is deliberately separate from the product ID so a future family
+    /// can share a protocol driver across several product variants.
+    pub driver_id: String,
+    /// Optional model-level identity in the OpenLogi asset registry.
+    ///
+    /// This is deliberately appended: `StandaloneDevice` crosses the
+    /// append-only GUI↔agent bincode wire format.
+    #[serde(default, skip_serializing_if = "Option::is_none")]
+    pub registry_model_id: Option<String>,
+}
+
 /// One receiver and its paired devices — the unit the agent's inventory
 /// snapshot is made of.
 ///
@@ -335,9 +407,15 @@ pub struct DeviceInventory {
 
 #[cfg(test)]
 mod tests {
+    #![allow(
+        clippy::expect_used,
+        reason = "range fixture construction is intentionally asserted in tests"
+    )]
+
     use super::{
         BatteryInfo, BatteryLevel, BatteryStatus, Capabilities, DeviceInventory, DeviceKind,
-        DeviceModelInfo, DeviceTransports, PairedDevice, ReceiverInfo,
+        DeviceModelInfo, DeviceTransports, LightValueRange, LightValueUnit, PairedDevice,
+        ReceiverInfo,
     };
 
     fn inventory(slot: u8, wpid: Option<u16>, battery_percentage: u8) -> DeviceInventory {
@@ -500,4 +578,30 @@ mod tests {
             Capabilities::default()
         );
     }
+
+    #[test]
+    fn light_ranges_reject_invalid_grids_and_units() {
+        assert!(LightValueRange::new(10, 1, 1, LightValueUnit::Lumens).is_err());
+        assert!(LightValueRange::new(0, 10, 0, LightValueUnit::Lumens).is_err());
+        assert!(LightValueRange::new(0, 10, 3, LightValueUnit::Lumens).is_err());
+        assert!(LightValueRange::new(0, 101, 1, LightValueUnit::Percent).is_err());
+    }
+
+    #[test]
+    fn light_ranges_quantize_without_leaving_the_advertised_grid() {
+        let range = LightValueRange::new(20, 250, 10, LightValueUnit::Lumens).expect("valid range");
+        assert_eq!(range.native_for_percent(0), Some(20));
+        assert_eq!(range.native_for_percent(50), Some(140));
+        assert_eq!(range.native_for_percent(100), Some(250));
+        assert_eq!(range.quantize(249), 250);
+        assert!(range.contains(range.native_for_percent(65).expect("mapped value")));
+    }
+
+    #[test]
+    fn invalid_light_ranges_fail_toml_deserialization() {
+        let result = toml::from_str::<LightValueRange>(
+            "min = 2700\nmax = 6500\nstep = 0\nunit = 'kelvin'\n",
+        );
+        assert!(result.is_err());
+    }
 }
diff --git a/crates/openlogi-core/src/device/light.rs b/crates/openlogi-core/src/device/light.rs
new file mode 100644
index 0000000000000000000000000000000000000000..e70e3008233523d087f2ab03912d9356efe93835
--- /dev/null
+++ b/crates/openlogi-core/src/device/light.rs
@@ -0,0 +1,213 @@
+//! Capability types shared by standalone light drivers and their clients.
+
+use serde::{Deserialize, Serialize};
+use thiserror::Error;
+
+/// The native unit used by a standalone light control range.
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
+#[serde(rename_all = "snake_case")]
+pub enum LightValueUnit {
+    /// A percentage of the device's supported range.
+    Percent,
+    /// Absolute luminous output, where the protocol exposes lumens.
+    Lumens,
+    /// Colour temperature in Kelvin.
+    Kelvin,
+}
+
+/// A validated light value range advertised by a device driver.
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize)]
+pub struct LightValueRange {
+    /// Inclusive lower bound in [`Self::unit`].
+    min: u16,
+    /// Inclusive upper bound in [`Self::unit`].
+    max: u16,
+    /// Supported increment. Must be non-zero.
+    step: u16,
+    /// The unit represented by `min`, `max`, and `step`.
+    unit: LightValueUnit,
+}
+
+impl LightValueRange {
+    /// Construct a range after validating its bounds and quantization grid.
+    ///
+    /// The upper bound must lie on the same grid as the lower bound. This
+    /// keeps driver quantization total: a valid range can never produce a
+    /// value outside the advertised interval or between device-supported
+    /// stops.
+    pub const fn new(
+        min: u16,
+        max: u16,
+        step: u16,
+        unit: LightValueUnit,
+    ) -> Result<Self, LightValueRangeError> {
+        if min > max {
+            return Err(LightValueRangeError::Reversed { min, max });
+        }
+        if step == 0 {
+            return Err(LightValueRangeError::ZeroStep);
+        }
+        if !(max - min).is_multiple_of(step) {
+            return Err(LightValueRangeError::Unaligned { min, max, step });
+        }
+        if matches!(unit, LightValueUnit::Percent) && max > 100 {
+            return Err(LightValueRangeError::PercentOutOfBounds { min, max });
+        }
+        Ok(Self {
+            min,
+            max,
+            step,
+            unit,
+        })
+    }
+
+    /// Inclusive lower bound in the advertised unit.
+    #[must_use]
+    pub const fn min(self) -> u16 {
+        self.min
+    }
+
+    /// Inclusive upper bound in the advertised unit.
+    #[must_use]
+    pub const fn max(self) -> u16 {
+        self.max
+    }
+
+    /// Supported increment.
+    #[must_use]
+    pub const fn step(self) -> u16 {
+        self.step
+    }
+
+    /// Unit represented by this range.
+    #[must_use]
+    pub const fn unit(self) -> LightValueUnit {
+        self.unit
+    }
+
+    /// Whether `value` is representable without clamping or quantization.
+    #[must_use]
+    pub fn contains(self, value: u16) -> bool {
+        value >= self.min
+            && value <= self.max
+            && self.step != 0
+            && (value - self.min).is_multiple_of(self.step)
+    }
+
+    /// Snap `value` to the nearest supported point inside this range.
+    #[must_use]
+    pub fn quantize(self, value: u16) -> u16 {
+        let clamped = value.clamp(self.min, self.max);
+        let offset = clamped - self.min;
+        let lower = offset / self.step;
+        let remainder = offset % self.step;
+        let index = if remainder.saturating_mul(2) >= self.step {
+            lower.saturating_add(1)
+        } else {
+            lower
+        };
+        self.min
+            .saturating_add(index.saturating_mul(self.step))
+            .min(self.max)
+    }
+
+    /// Map normalized brightness to the nearest native value in this range.
+    #[must_use]
+    pub fn native_for_percent(self, percent: u8) -> Option<u16> {
+        if percent > 100 {
+            return None;
+        }
+        let span = u32::from(self.max) - u32::from(self.min);
+        let raw = u32::from(self.min) + (span * u32::from(percent) + 50) / 100;
+        u16::try_from(raw).ok().map(|value| self.quantize(value))
+    }
+
+    /// Convert a supported native value to normalized brightness.
+    #[must_use]
+    pub fn percent_for_native(self, value: u16) -> Option<u8> {
+        if !self.contains(value) {
+            return None;
+        }
+        let span = u32::from(self.max) - u32::from(self.min);
+        if span == 0 {
+            return Some(0);
+        }
+        u8::try_from(((u32::from(value) - u32::from(self.min)) * 100 + span / 2) / span).ok()
+    }
+}
+
+/// Validation failure for [`LightValueRange`].
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Error)]
+pub enum LightValueRangeError {
+    /// The lower bound is greater than the upper bound.
+    #[error("light range minimum {min} is greater than maximum {max}")]
+    Reversed {
+        /// Rejected lower bound.
+        min: u16,
+        /// Rejected upper bound.
+        max: u16,
+    },
+    /// A range cannot have a zero increment.
+    #[error("light range step must be non-zero")]
+    ZeroStep,
+    /// The upper bound is not reachable from the lower bound using `step`.
+    #[error("light range {min}..={max} is not aligned to step {step}")]
+    Unaligned {
+        /// Lower bound of the invalid range.
+        min: u16,
+        /// Upper bound of the invalid range.
+        max: u16,
+        /// Increment that does not reach the upper bound.
+        step: u16,
+    },
+    /// Percentage ranges must stay within 0–100.
+    #[error("percentage light range {min}..={max} exceeds 0..=100")]
+    PercentOutOfBounds {
+        /// Rejected lower bound.
+        min: u16,
+        /// Rejected upper bound.
+        max: u16,
+    },
+}
+
+#[derive(Deserialize)]
+struct RawLightValueRange {
+    min: u16,
+    max: u16,
+    step: u16,
+    unit: LightValueUnit,
+}
+
+impl<'de> Deserialize<'de> for LightValueRange {
+    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
+    where
+        D: serde::Deserializer<'de>,
+    {
+        let raw = RawLightValueRange::deserialize(deserializer)?;
+        Self::new(raw.min, raw.max, raw.step, raw.unit).map_err(serde::de::Error::custom)
+    }
+}
+
+/// Controls a standalone light driver can implement.
+///
+/// Optional ranges are the source of truth for UI controls. A driver must not
+/// advertise a control merely because the product is classified as a light.
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize)]
+#[allow(
+    clippy::struct_excessive_bools,
+    reason = "independent optional light controls are a serialized capability DTO"
+)]
+pub struct LightCapabilities {
+    /// Whether the driver can switch the light on and off.
+    pub power: bool,
+    /// Supported brightness range, if brightness is controllable.
+    pub brightness: Option<LightValueRange>,
+    /// Supported colour-temperature range, if temperature is controllable.
+    pub temperature: Option<LightValueRange>,
+    /// Whether the driver can set a colour.
+    #[serde(default)]
+    pub color: bool,
+    /// Whether the driver exposes independently-addressable zones.
+    #[serde(default)]
+    pub zones: bool,
+}
diff --git a/crates/openlogi-core/src/diagnostics.rs b/crates/openlogi-core/src/diagnostics.rs
index 65ce7ac6ac88ad056af7f503523f930bd2bf1ef5..6703e9bfcf050a490ce67f3982527018c17b13eb 100644
--- a/crates/openlogi-core/src/diagnostics.rs
+++ b/crates/openlogi-core/src/diagnostics.rs
@@ -411,7 +411,9 @@ fn kind_label(kind: DeviceKind) -> &'static str {
         DeviceKind::Gamepad => "gamepad",
         DeviceKind::Joystick => "joystick",
         DeviceKind::Headset => "headset",
+        DeviceKind::Camera => "camera",
         DeviceKind::Unknown => "unknown",
+        DeviceKind::Light => "light",
     }
 }
 
diff --git a/crates/openlogi-core/src/paths.rs b/crates/openlogi-core/src/paths.rs
index 05c2b3e0c262300757341e1b0aecf6940f1e6a2b..3213432b8615928975a6a1066cb68f78480c97b1 100644
--- a/crates/openlogi-core/src/paths.rs
+++ b/crates/openlogi-core/src/paths.rs
@@ -18,13 +18,20 @@
 //! shipped in Windows artifacts, because moving it afterwards would strand
 //! every existing user's `config.toml` and the agent's first-run state.
 
+//! Local packaged macOS builds stamped with `.dev` bundle identifiers use the
+//! same layout under an `openlogi-dev` app directory.
+
 use std::path::PathBuf;
+use std::sync::OnceLock;
 
 use etcetera::{BaseStrategy, base_strategy::Xdg};
 use thiserror::Error;
 
-/// Subdirectory created under each XDG base directory.
+/// Production subdirectory created under each XDG base directory.
 const APP_DIR: &str = "openlogi";
+/// Local macOS `.dev` bundles use a separate profile so development agents
+/// cannot take over the installed app's socket, lock, config, or asset cache.
+const DEV_APP_DIR: &str = "openlogi-dev";
 
 /// Failure resolving the per-user base directories.
 #[derive(Debug, Error)]
@@ -39,6 +46,63 @@ fn xdg() -> Result<Xdg, PathsError> {
     Xdg::new().map_err(|_| PathsError::HomeNotFound)
 }
 
+fn app_dir() -> &'static str {
+    static IS_DEV_PROFILE: OnceLock<bool> = OnceLock::new();
+    if *IS_DEV_PROFILE.get_or_init(is_dev_profile) {
+        DEV_APP_DIR
+    } else {
+        APP_DIR
+    }
+}
+
+fn is_dev_profile() -> bool {
+    match std::env::var("OPENLOGI_PROFILE") {
+        Ok(value) if value == "dev" => return true,
+        Ok(value) if matches!(value.as_str(), "prod" | "production") => return false,
+        _ => {}
+    }
+
+    #[cfg(target_os = "macos")]
+    {
+        if let Some(identifier) = current_bundle_identifier() {
+            // Reverse-DNS suffix (org.openlogi.*.dev), not a filesystem extension.
+            return identifier
+                .rsplit_once('.')
+                .is_some_and(|(_, suffix)| suffix.eq_ignore_ascii_case("dev"));
+        }
+    }
+
+    false
+}
+
+#[cfg(target_os = "macos")]
+fn current_bundle_identifier() -> Option<String> {
+    let exe = std::env::current_exe().ok()?;
+    for ancestor in exe.ancestors() {
+        if !ancestor
+            .extension()
+            .is_some_and(|ext| ext.eq_ignore_ascii_case("app"))
+        {
+            continue;
+        }
+
+        let info = ancestor.join("Contents/Info.plist");
+        let Ok(plist) = plist::Value::from_file(info) else {
+            continue;
+        };
+        let Some(identifier) = plist
+            .as_dictionary()
+            .and_then(|dictionary| dictionary.get("CFBundleIdentifier"))
+            .and_then(plist::Value::as_string)
+        else {
+            continue;
+        };
+        return Some(identifier.to_owned());
+    }
+
+    None
+}
+
 /// The current user's home directory.
 ///
 /// The plain home, not an XDG base — for callers placing files under
@@ -59,8 +123,9 @@ pub fn xdg_config_home() -> Result<PathBuf, PathsError> {
 /// Directory holding the user's `config.toml`.
 ///
 /// `$XDG_CONFIG_HOME/openlogi`, default `~/.config/openlogi`.
+/// Local macOS `.dev` bundles use `openlogi-dev` instead.
 pub fn config_dir() -> Result<PathBuf, PathsError> {
-    Ok(xdg_config_home()?.join(APP_DIR))
+    Ok(xdg_config_home()?.join(app_dir()))
 }
 
 /// Full path to the user config file.
@@ -72,16 +137,18 @@ pub fn config_path() -> Result<PathBuf, PathsError> {
 /// lives under `data_dir()/assets`.
 ///
 /// `$XDG_DATA_HOME/openlogi`, default `~/.local/share/openlogi`.
+/// Local macOS `.dev` bundles use `openlogi-dev` instead.
 pub fn data_dir() -> Result<PathBuf, PathsError> {
-    Ok(xdg()?.data_dir().join(APP_DIR))
+    Ok(xdg()?.data_dir().join(app_dir()))
 }
 
 /// Directory for runtime sockets — the background agent's IPC endpoint.
 pub fn runtime_dir() -> Result<PathBuf, PathsError> {
     let xdg = xdg()?;
-    Ok(xdg
-        .runtime_dir()
-        .map_or_else(|| xdg.config_dir().join(APP_DIR), |dir| dir.join(APP_DIR)))
+    Ok(xdg.runtime_dir().map_or_else(
+        || xdg.config_dir().join(app_dir()),
+        |dir| dir.join(app_dir()),
+    ))
 }
 
 /// Path to the background agent's Unix-domain IPC socket: the GUI connects here
diff --git a/crates/openlogi-gui/Cargo.toml b/crates/openlogi-gui/Cargo.toml
index f1bc3f808985b35444491dcff84dafee20cd9b9c..76aa11ee666f9cb29b9a282d46912181f3e6219e 100644
--- a/crates/openlogi-gui/Cargo.toml
+++ b/crates/openlogi-gui/Cargo.toml
@@ -18,6 +18,7 @@ path = "src/main.rs"
 [dependencies]
 openlogi-core = { path = "../openlogi-core" }
 openlogi-hid = { path = "../openlogi-hid" }
+openlogi-camera = { path = "../openlogi-camera" }
 openlogi-hook = { path = "../openlogi-hook" }
 openlogi-assets = { path = "../openlogi-assets" }
 openlogi-agent-core = { path = "../openlogi-agent-core" }
diff --git a/crates/openlogi-gui/action-icons/moon.svg b/crates/openlogi-gui/action-icons/moon.svg
new file mode 100644
index 0000000000000000000000000000000000000000..17bb18352c8195f20016b9d3f09630af1ae5c249
--- /dev/null
+++ b/crates/openlogi-gui/action-icons/moon.svg
@@ -0,0 +1,13 @@
+<svg
+  xmlns="http://www.w3.org/2000/svg"
+  width="24"
+  height="24"
+  viewBox="0 0 24 24"
+  fill="none"
+  stroke="currentColor"
+  stroke-width="2"
+  stroke-linecap="round"
+  stroke-linejoin="round"
+>
+  <path d="M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z" />
+</svg>
diff --git a/crates/openlogi-gui/action-icons/terminal.svg b/crates/openlogi-gui/action-icons/terminal.svg
new file mode 100644
index 0000000000000000000000000000000000000000..ac07084d346e02779fa8031011a01b7ad37bb016
--- /dev/null
+++ b/crates/openlogi-gui/action-icons/terminal.svg
@@ -0,0 +1,15 @@
+<svg
+  xmlns="http://www.w3.org/2000/svg"
+  width="24"
+  height="24"
+  viewBox="0 0 24 24"
+  fill="none"
+  stroke="currentColor"
+  stroke-width="2"
+  stroke-linecap="round"
+  stroke-linejoin="round"
+>
+  <path d="m7 11 2-2-2-2" />
+  <path d="M11 13h4" />
+  <rect width="20" height="16" x="2" y="4" rx="2" />
+</svg>
diff --git a/crates/openlogi-gui/bundle/gui-dev/Info.plist b/crates/openlogi-gui/bundle/gui-dev/Info.plist
index 91256e34ddb31487d43aa9f79340f80d38b8d0e4..e915e46def0398ee88298abfd7906112fb1b5e90 100644
--- a/crates/openlogi-gui/bundle/gui-dev/Info.plist
+++ b/crates/openlogi-gui/bundle/gui-dev/Info.plist
@@ -2,8 +2,8 @@
 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 <plist version="1.0">
 <dict>
-  <key>CFBundleName</key><string>OpenLogi</string>
-  <key>CFBundleDisplayName</key><string>OpenLogi</string>
+  <key>CFBundleName</key><string>OpenLogi Dev</string>
+  <key>CFBundleDisplayName</key><string>OpenLogi Dev</string>
   <key>CFBundleExecutable</key><string>openlogi-gui</string>
   <key>CFBundleIdentifier</key><string>org.openlogi.openlogi.dev</string>
   <key>CFBundleIconFile</key><string>AppIcon</string>
@@ -14,6 +14,7 @@
   <key>CFBundleVersion</key><string>0.0.0</string>
   <key>LSMinimumSystemVersion</key><string>13.0</string>
   <key>NSHighResolutionCapable</key><true/>
+  <key>NSCameraUsageDescription</key><string>OpenLogi previews your Logitech webcam locally. Video never leaves your Mac.</string>
   <!-- openlogi:// deep-link scheme. Mirror of [package.metadata.bundle]
        osx_url_schemes in Cargo.toml (which cargo-bundle uses for the release
        app) — keep the two in sync. CFBundleURLName matches the name
diff --git a/crates/openlogi-gui/locales/da.yml b/crates/openlogi-gui/locales/da.yml
index 46b2fafa260184fccdfd99253b7399c999c82184..32983daf8aeb63f6ded71ce2277c196a3e35e027 100644
--- a/crates/openlogi-gui/locales/da.yml
+++ b/crates/openlogi-gui/locales/da.yml
@@ -3,10 +3,12 @@ _version: 1
 "No devices connected": "Ingen enhed tilsluttet"
 "Devices": "Enheder"
 "Buttons": "Knapper"
+"Keys": "Keys"
 "Pointer": "Markør"
 "Lighting": "Belysning"
 "LIGHTING": "BELYSNING"
 "BRIGHTNESS": "LYSSTYRKE"
+"COLOUR TEMPERATURE": "FARVETEMPERATUR"
 "On": "Til"
 "Off": "Fra"
 "Open OpenLogi": "Åbn OpenLogi"
@@ -156,16 +158,6 @@ _version: 1
 "Forward": "Frem"
 "DPI Toggle": "DPI-skift"
 "Thumb Wheel": "Tommelfingerhjul"
-"Back / Forward": "Tilbage / Frem"
-"Undo / Redo": "Fortryd / Annuller fortryd"
-"Browser Back / Forward": "Browser tilbage / Browser frem"
-"Previous / Next Tab": "Forrige faneblad / Næste faneblad"
-"Previous / Next Desktop": "Forrige skrivebord / Næste skrivebord"
-"Previous / Next Track": "Forrige nummer / Næste nummer"
-"Volume Down / Up": "Skru ned / Skru op"
-"Vertical Scroll": "Rul ned / Rul op"
-"Horizontal Scroll": "Rul til venstre / Rul til højre"
-"Custom": "Custom"
 "Gesture Button": "Bevægelsesknap"
 "Up": "Op"
 "Down": "Ned"
@@ -198,6 +190,7 @@ _version: 1
 "Launchpad": "Launchpad"
 "Lock Screen": "Lås skærm"
 "Screenshot": "Skærmbillede"
+"Sleep": "Slumre"
 "Capture Region": "Optag område"
 "Play / Pause": "Afspil / pause"
 "Next Track": "Næste nummer"
@@ -329,3 +322,35 @@ _version: 1
 "Detects other apps tapping the mouse event stream — a common cause of pointer lag.": "Registrerer andre apps, der opfanger musens hændelsesstrøm – en almindelig årsag til markørforsinkelse."
 "No other app is intercepting mouse input.": "Ingen anden app opfanger museinput."
 "Another app is intercepting mouse input, which can cause pointer lag or duplicated button actions: %{apps}": "En anden app opfanger museinput, hvilket kan forårsage markørforsinkelse eller dublerede knaphandlinger: %{apps}"
+"Camera": "Kamera"
+"Starting preview…": "Starter forhåndsvisning…"
+"Enable Camera access in Settings to preview.": "Aktivér kameraadgang i Indstillinger for at få vist en forhåndsvisning."
+"Your Logitech webcam shows up on the main page. Grant access to see its live preview — video never leaves your Mac.": "Dit Logitech-webkamera vises på hovedsiden. Giv adgang for at se live-forhåndsvisningen — videoen forlader aldrig din Mac."
+"Brightness": "Lysstyrke"
+"Contrast": "Kontrast"
+"Saturation": "Mætning"
+"Sharpness": "Skarphed"
+"Camera controls": "Kamerakontroller"
+"Reset to defaults": "Nulstil til standard"
+"This camera exposes no adjustable image controls.": "Dette kamera har ingen justerbare billedkontroller."
+"Focus": "Fokus"
+"Exposure": "Eksponering"
+"White balance": "Hvidbalance"
+"Tint": "Farvetone"
+"Auto": "Auto"
+"Lens": "Objektiv"
+"Image": "Billede"
+"Streaming": "Streaming"
+"Video call": "Videoopkald"
+"New": "Ny"
+"Live preview isn't available on this platform yet.": "Live-forhåndsvisning er endnu ikke tilgængelig på denne platform."
+"Applying light setting…": "Applying light setting…"
+"Auto-on with camera": "Auto-on with camera"
+"Turn this light on while any camera is in use and off when cameras stop.": "Turn this light on while any camera is in use and off when cameras stop."
+"Power User": "Power User"
+"Type Text…": "Type Text…"
+"Run AppleScript…": "Run AppleScript…"
+"Run Shell Command…": "Run Shell Command…"
+"Workflow…": "Workflow…"
+"Save Workflow": "Save Workflow"
+"+ Add Step": "+ Add Step"
diff --git a/crates/openlogi-gui/locales/de.yml b/crates/openlogi-gui/locales/de.yml
index 1d269fad1f9b83679b2bfe8ec7a46bf39f56bb91..c6bde70e814838fc6e6b32ec73c877e710615845 100644
--- a/crates/openlogi-gui/locales/de.yml
+++ b/crates/openlogi-gui/locales/de.yml
@@ -3,10 +3,12 @@ _version: 1
 "No devices connected": "Kein Gerät verbunden"
 "Devices": "Geräte"
 "Buttons": "Tasten"
+"Keys": "Keys"
 "Pointer": "Zeiger"
 "Lighting": "Beleuchtung"
 "LIGHTING": "BELEUCHTUNG"
 "BRIGHTNESS": "HELLIGKEIT"
+"COLOUR TEMPERATURE": "FARBTEMPERATUR"
 "On": "Ein"
 "Off": "Aus"
 "Open OpenLogi": "OpenLogi öffnen"
@@ -156,16 +158,6 @@ _version: 1
 "Forward": "Vor"
 "DPI Toggle": "DPI-Umschaltung"
 "Thumb Wheel": "Daumenrad"
-"Back / Forward": "Zurück / Vor"
-"Undo / Redo": "Widerrufen / Wiederholen"
-"Browser Back / Forward": "Browser zurück / Browser vor"
-"Previous / Next Tab": "Vorheriger Tab / Nächster Tab"
-"Previous / Next Desktop": "Vorheriger Schreibtisch / Nächster Schreibtisch"
-"Previous / Next Track": "Vorheriger Titel / Nächster Titel"
-"Volume Down / Up": "Leiser / Lauter"
-"Vertical Scroll": "Nach unten scrollen / Nach oben scrollen"
-"Horizontal Scroll": "Nach links scrollen / Nach rechts scrollen"
-"Custom": "Custom"
 "Gesture Button": "Gestentaste"
 "Up": "Oben"
 "Down": "Unten"
@@ -198,6 +190,7 @@ _version: 1
 "Launchpad": "Launchpad"
 "Lock Screen": "Bildschirm sperren"
 "Screenshot": "Bildschirmfoto"
+"Sleep": "Ruhezustand"
 "Capture Region": "Bereich aufnehmen"
 "Play / Pause": "Wiedergabe / Pause"
 "Next Track": "Nächster Titel"
@@ -329,3 +322,35 @@ _version: 1
 "Detects other apps tapping the mouse event stream — a common cause of pointer lag.": "Erkennt andere Apps, die den Maus-Ereignisstrom abgreifen – eine häufige Ursache für Zeigerverzögerung."
 "No other app is intercepting mouse input.": "Keine andere App fängt Mauseingaben ab."
 "Another app is intercepting mouse input, which can cause pointer lag or duplicated button actions: %{apps}": "Eine andere App fängt Mauseingaben ab, was zu Zeigerverzögerung oder doppelten Tastenaktionen führen kann: %{apps}"
+"Camera": "Kamera"
+"Starting preview…": "Vorschau wird gestartet…"
+"Enable Camera access in Settings to preview.": "Aktiviere den Kamerazugriff in den Einstellungen für die Vorschau."
+"Your Logitech webcam shows up on the main page. Grant access to see its live preview — video never leaves your Mac.": "Deine Logitech-Webcam erscheint auf der Hauptseite. Erlaube den Zugriff, um die Live-Vorschau zu sehen — das Video verlässt deinen Mac nie."
+"Brightness": "Helligkeit"
+"Contrast": "Kontrast"
+"Saturation": "Sättigung"
+"Sharpness": "Schärfe"
+"Camera controls": "Kamerasteuerung"
+"Reset to defaults": "Auf Standard zurücksetzen"
+"This camera exposes no adjustable image controls.": "Diese Kamera bietet keine einstellbaren Bildregler."
+"Focus": "Fokus"
+"Exposure": "Belichtung"
+"White balance": "Weißabgleich"
+"Tint": "Farbton"
+"Auto": "Auto"
+"Lens": "Objektiv"
+"Image": "Bild"
+"Streaming": "Streaming"
+"Video call": "Videoanruf"
+"New": "Neu"
+"Live preview isn't available on this platform yet.": "Die Live-Vorschau ist auf dieser Plattform noch nicht verfügbar."
+"Applying light setting…": "Applying light setting…"
+"Auto-on with camera": "Auto-on with camera"
+"Turn this light on while any camera is in use and off when cameras stop.": "Turn this light on while any camera is in use and off when cameras stop."
+"Power User": "Power User"
+"Type Text…": "Type Text…"
+"Run AppleScript…": "Run AppleScript…"
+"Run Shell Command…": "Run Shell Command…"
+"Workflow…": "Workflow…"
+"Save Workflow": "Save Workflow"
+"+ Add Step": "+ Add Step"
diff --git a/crates/openlogi-gui/locales/el.yml b/crates/openlogi-gui/locales/el.yml
index f8936f293d36eba85182e86e0ebcc598097ee3cd..d135a6c134fd53ddead09d609cec2adb974a7432 100644
--- a/crates/openlogi-gui/locales/el.yml
+++ b/crates/openlogi-gui/locales/el.yml
@@ -3,10 +3,12 @@ _version: 1
 "No devices connected": "Καμία συσκευή δεν είναι συνδεδεμένη"
 "Devices": "Συσκευές"
 "Buttons": "Κουμπιά"
+"Keys": "Keys"
 "Pointer": "Δείκτης"
 "Lighting": "Φωτισμός"
 "LIGHTING": "ΦΩΤΙΣΜΟΣ"
 "BRIGHTNESS": "ΦΩΤΕΙΝΟΤΗΤΑ"
+"COLOUR TEMPERATURE": "ΘΕΡΜΟΚΡΑΣΙΑ ΧΡΩΜΑΤΟΣ"
 "On": "Ενεργό"
 "Off": "Ανενεργό"
 "Open OpenLogi": "Άνοιγμα του OpenLogi"
@@ -156,16 +158,6 @@ _version: 1
 "Forward": "Εμπρός"
 "DPI Toggle": "Εναλλαγή DPI"
 "Thumb Wheel": "Πλαϊνός τροχός"
-"Back / Forward": "Πίσω / Εμπρός"
-"Undo / Redo": "Αναίρεση / Επανάληψη"
-"Browser Back / Forward": "Πίσω στο πρόγραμμα περιήγησης / Εμπρός στο πρόγραμμα περιήγησης"
-"Previous / Next Tab": "Προηγούμενη καρτέλα / Επόμενη καρτέλα"
-"Previous / Next Desktop": "Προηγούμενο γραφείο εργασίας / Επόμενο γραφείο εργασίας"
-"Previous / Next Track": "Προηγούμενο κομμάτι / Επόμενο κομμάτι"
-"Volume Down / Up": "Μείωση έντασης / Αύξηση έντασης"
-"Vertical Scroll": "Κύλιση προς τα κάτω / Κύλιση προς τα πάνω"
-"Horizontal Scroll": "Κύλιση προς τα αριστερά / Κύλιση προς τα δεξιά"
-"Custom": "Custom"
 "Gesture Button": "Κουμπί χειρονομιών"
 "Up": "Πάνω"
 "Down": "Κάτω"
@@ -198,6 +190,7 @@ _version: 1
 "Launchpad": "Launchpad"
 "Lock Screen": "Κλείδωμα οθόνης"
 "Screenshot": "Στιγμιότυπο οθόνης"
+"Sleep": "Ύπνωση"
 "Capture Region": "Λήψη περιοχής"
 "Play / Pause": "Αναπαραγωγή / Παύση"
 "Next Track": "Επόμενο κομμάτι"
@@ -329,3 +322,35 @@ _version: 1
 "Detects other apps tapping the mouse event stream — a common cause of pointer lag.": "Εντοπίζει άλλες εφαρμογές που υποκλέπτουν τη ροή συμβάντων του ποντικιού — μια συνηθισμένη αιτία καθυστέρησης του δείκτη."
 "No other app is intercepting mouse input.": "Καμία άλλη εφαρμογή δεν υποκλέπτει την είσοδο του ποντικιού."
 "Another app is intercepting mouse input, which can cause pointer lag or duplicated button actions: %{apps}": "Μια άλλη εφαρμογή υποκλέπτει την είσοδο του ποντικιού, κάτι που μπορεί να προκαλέσει καθυστέρηση του δείκτη ή διπλές ενέργειες κουμπιών: %{apps}"
+"Camera": "Κάμερα"
+"Starting preview…": "Έναρξη προεπισκόπησης…"
+"Enable Camera access in Settings to preview.": "Ενεργοποιήστε την πρόσβαση στην κάμερα στις Ρυθμίσεις για προεπισκόπηση."
+"Your Logitech webcam shows up on the main page. Grant access to see its live preview — video never leaves your Mac.": "Η κάμερα Logitech εμφανίζεται στην κύρια σελίδα. Παραχωρήστε πρόσβαση για να δείτε τη ζωντανή προεπισκόπηση — το βίντεο δεν φεύγει ποτέ από το Mac σας."
+"Brightness": "Φωτεινότητα"
+"Contrast": "Αντίθεση"
+"Saturation": "Κορεσμός"
+"Sharpness": "Ευκρίνεια"
+"Camera controls": "Στοιχεία ελέγχου κάμερας"
+"Reset to defaults": "Επαναφορά προεπιλογών"
+"This camera exposes no adjustable image controls.": "Αυτή η κάμερα δεν διαθέτει ρυθμιζόμενα στοιχεία ελέγχου εικόνας."
+"Focus": "Εστίαση"
+"Exposure": "Έκθεση"
+"White balance": "Ισορροπία λευκού"
+"Tint": "Απόχρωση"
+"Auto": "Αυτόματο"
+"Lens": "Φακός"
+"Image": "Εικόνα"
+"Streaming": "Streaming"
+"Video call": "Βιντεοκλήση"
+"New": "Νέο"
+"Live preview isn't available on this platform yet.": "Η ζωντανή προεπισκόπηση δεν είναι ακόμη διαθέσιμη σε αυτήν την πλατφόρμα."
+"Applying light setting…": "Applying light setting…"
+"Auto-on with camera": "Auto-on with camera"
+"Turn this light on while any camera is in use and off when cameras stop.": "Turn this light on while any camera is in use and off when cameras stop."
+"Power User": "Power User"
+"Type Text…": "Type Text…"
+"Run AppleScript…": "Run AppleScript…"
+"Run Shell Command…": "Run Shell Command…"
+"Workflow…": "Workflow…"
+"Save Workflow": "Save Workflow"
+"+ Add Step": "+ Add Step"
diff --git a/crates/openlogi-gui/locales/en.yml b/crates/openlogi-gui/locales/en.yml
index 1652687d8532d91ba55d48c907479e6507dfc66d..7369d793c49cb4769830188f0eef59147ae5d8ac 100644
--- a/crates/openlogi-gui/locales/en.yml
+++ b/crates/openlogi-gui/locales/en.yml
@@ -3,10 +3,12 @@ _version: 1
 "No devices connected": "No devices connected"
 "Devices": "Devices"
 "Buttons": "Buttons"
+"Keys": "Keys"
 "Pointer": "Pointer"
 "Lighting": "Lighting"
 "LIGHTING": "LIGHTING"
 "BRIGHTNESS": "BRIGHTNESS"
+"COLOUR TEMPERATURE": "COLOUR TEMPERATURE"
 "On": "On"
 "Off": "Off"
 "Open OpenLogi": "Open OpenLogi"
@@ -198,6 +200,7 @@ _version: 1
 "Launchpad": "Launchpad"
 "Lock Screen": "Lock Screen"
 "Screenshot": "Screenshot"
+"Sleep": "Sleep"
 "Capture Region": "Capture Region"
 "Play / Pause": "Play / Pause"
 "Next Track": "Next Track"
@@ -329,3 +332,35 @@ _version: 1
 "Detects other apps tapping the mouse event stream — a common cause of pointer lag.": "Detects other apps tapping the mouse event stream — a common cause of pointer lag."
 "No other app is intercepting mouse input.": "No other app is intercepting mouse input."
 "Another app is intercepting mouse input, which can cause pointer lag or duplicated button actions: %{apps}": "Another app is intercepting mouse input, which can cause pointer lag or duplicated button actions: %{apps}"
+"Camera": "Camera"
+"Starting preview…": "Starting preview…"
+"Enable Camera access in Settings to preview.": "Enable Camera access in Settings to preview."
+"Your Logitech webcam shows up on the main page. Grant access to see its live preview — video never leaves your Mac.": "Your Logitech webcam shows up on the main page. Grant access to see its live preview — video never leaves your Mac."
+"Brightness": "Brightness"
+"Contrast": "Contrast"
+"Saturation": "Saturation"
+"Sharpness": "Sharpness"
+"Camera controls": "Camera controls"
+"Reset to defaults": "Reset to defaults"
+"This camera exposes no adjustable image controls.": "This camera exposes no adjustable image controls."
+"Focus": "Focus"
+"Exposure": "Exposure"
+"White balance": "White balance"
+"Tint": "Tint"
+"Auto": "Auto"
+"Lens": "Lens"
+"Image": "Image"
+"Streaming": "Streaming"
+"Video call": "Video call"
+"New": "New"
+"Live preview isn't available on this platform yet.": "Live preview isn't available on this platform yet."
+"Applying light setting…": "Applying light setting…"
+"Auto-on with camera": "Auto-on with camera"
+"Turn this light on while any camera is in use and off when cameras stop.": "Turn this light on while any camera is in use and off when cameras stop."
+"Power User": "Power User"
+"Type Text…": "Type Text…"
+"Run AppleScript…": "Run AppleScript…"
+"Run Shell Command…": "Run Shell Command…"
+"Workflow…": "Workflow…"
+"Save Workflow": "Save Workflow"
+"+ Add Step": "+ Add Step"
diff --git a/crates/openlogi-gui/locales/es.yml b/crates/openlogi-gui/locales/es.yml
index 696c5687288f5d61de24dcf787fb3309e94a7e69..e4f3e88409288ed9dc7e3f5b96a502171fb955d6 100644
--- a/crates/openlogi-gui/locales/es.yml
+++ b/crates/openlogi-gui/locales/es.yml
@@ -3,10 +3,12 @@ _version: 1
 "No devices connected": "Ningún dispositivo conectado"
 "Devices": "Dispositivos"
 "Buttons": "Botones"
+"Keys": "Keys"
 "Pointer": "Puntero"
 "Lighting": "Iluminación"
 "LIGHTING": "ILUMINACIÓN"
 "BRIGHTNESS": "BRILLO"
+"COLOUR TEMPERATURE": "TEMPERATURA DE COLOR"
 "On": "Activado"
 "Off": "Desactivado"
 "Open OpenLogi": "Abrir OpenLogi"
@@ -156,16 +158,6 @@ _version: 1
 "Forward": "Adelante"
 "DPI Toggle": "Cambiar DPI"
 "Thumb Wheel": "Rueda lateral"
-"Back / Forward": "Atrás / Adelante"
-"Undo / Redo": "Deshacer / Rehacer"
-"Browser Back / Forward": "Atrás en el navegador / Adelante en el navegador"
-"Previous / Next Tab": "Pestaña anterior / Pestaña siguiente"
-"Previous / Next Desktop": "Escritorio anterior / Escritorio siguiente"
-"Previous / Next Track": "Pista anterior / Pista siguiente"
-"Volume Down / Up": "Bajar volumen / Subir volumen"
-"Vertical Scroll": "Desplazar hacia abajo / Desplazar hacia arriba"
-"Horizontal Scroll": "Desplazar a la izquierda / Desplazar a la derecha"
-"Custom": "Custom"
 "Gesture Button": "Botón de gestos"
 "Up": "Arriba"
 "Down": "Abajo"
@@ -198,6 +190,7 @@ _version: 1
 "Launchpad": "Launchpad"
 "Lock Screen": "Bloquear pantalla"
 "Screenshot": "Captura de pantalla"
+"Sleep": "Reposo"
 "Capture Region": "Capturar región"
 "Play / Pause": "Reproducir / Pausar"
 "Next Track": "Pista siguiente"
@@ -329,3 +322,35 @@ _version: 1
 "Detects other apps tapping the mouse event stream — a common cause of pointer lag.": "Detecta otras apps que interceptan el flujo de eventos del ratón, una causa habitual de retraso del puntero."
 "No other app is intercepting mouse input.": "Ninguna otra app está interceptando la entrada del ratón."
 "Another app is intercepting mouse input, which can cause pointer lag or duplicated button actions: %{apps}": "Otra app está interceptando la entrada del ratón, lo que puede causar retraso del puntero o acciones de botón duplicadas: %{apps}"
+"Camera": "Cámara"
+"Starting preview…": "Iniciando vista previa…"
+"Enable Camera access in Settings to preview.": "Activa el acceso a la cámara en Ajustes para ver la vista previa."
+"Your Logitech webcam shows up on the main page. Grant access to see its live preview — video never leaves your Mac.": "Tu webcam Logitech aparece en la página principal. Concede acceso para ver su vista previa en directo — el vídeo nunca sale de tu Mac."
+"Brightness": "Brillo"
+"Contrast": "Contraste"
+"Saturation": "Saturación"
+"Sharpness": "Nitidez"
+"Camera controls": "Controles de la cámara"
+"Reset to defaults": "Restablecer valores predeterminados"
+"This camera exposes no adjustable image controls.": "Esta cámara no ofrece controles de imagen ajustables."
+"Focus": "Enfoque"
+"Exposure": "Exposición"
+"White balance": "Balance de blancos"
+"Tint": "Matiz"
+"Auto": "Auto"
+"Lens": "Objetivo"
+"Image": "Imagen"
+"Streaming": "Streaming"
+"Video call": "Videollamada"
+"New": "Nuevo"
+"Live preview isn't available on this platform yet.": "La vista previa en vivo aún no está disponible en esta plataforma."
+"Applying light setting…": "Applying light setting…"
+"Auto-on with camera": "Auto-on with camera"
+"Turn this light on while any camera is in use and off when cameras stop.": "Turn this light on while any camera is in use and off when cameras stop."
+"Power User": "Power User"
+"Type Text…": "Type Text…"
+"Run AppleScript…": "Run AppleScript…"
+"Run Shell Command…": "Run Shell Command…"
+"Workflow…": "Workflow…"
+"Save Workflow": "Save Workflow"
+"+ Add Step": "+ Add Step"
diff --git a/crates/openlogi-gui/locales/fi.yml b/crates/openlogi-gui/locales/fi.yml
index 84fc22cad87261058636431b0c4faeb0de2b492a..d47e38a22074e3aa6bf87c03ec09f2fa4912db73 100644
--- a/crates/openlogi-gui/locales/fi.yml
+++ b/crates/openlogi-gui/locales/fi.yml
@@ -3,10 +3,12 @@ _version: 1
 "No devices connected": "Ei yhdistettyä laitetta"
 "Devices": "Laitteet"
 "Buttons": "Painikkeet"
+"Keys": "Keys"
 "Pointer": "Osoitin"
 "Lighting": "Valaistus"
 "LIGHTING": "VALAISTUS"
 "BRIGHTNESS": "KIRKKAUS"
+"COLOUR TEMPERATURE": "VÄRILÄMPÖTILA"
 "On": "Päällä"
 "Off": "Pois"
 "Open OpenLogi": "Avaa OpenLogi"
@@ -156,16 +158,6 @@ _version: 1
 "Forward": "Eteenpäin"
 "DPI Toggle": "DPI-vaihto"
 "Thumb Wheel": "Peukalorulla"
-"Back / Forward": "Takaisin / Eteenpäin"
-"Undo / Redo": "Kumoa / Tee uudelleen"
-"Browser Back / Forward": "Selaimessa takaisin / Selaimessa eteenpäin"
-"Previous / Next Tab": "Edellinen välilehti / Seuraava välilehti"
-"Previous / Next Desktop": "Edellinen työpöytä / Seuraava työpöytä"
-"Previous / Next Track": "Edellinen kappale / Seuraava kappale"
-"Volume Down / Up": "Vähennä äänenvoimakkuutta / Lisää äänenvoimakkuutta"
-"Vertical Scroll": "Vieritä alas / Vieritä ylös"
-"Horizontal Scroll": "Vieritä vasemmalle / Vieritä oikealle"
-"Custom": "Custom"
 "Gesture Button": "Eletoiminto"
 "Up": "Ylös"
 "Down": "Alas"
@@ -198,6 +190,7 @@ _version: 1
 "Launchpad": "Launchpad"
 "Lock Screen": "Lukitse näyttö"
 "Screenshot": "Kuvakaappaus"
+"Sleep": "Lepotila"
 "Capture Region": "Kaappaa alue"
 "Play / Pause": "Toista / Keskeytä"
 "Next Track": "Seuraava kappale"
@@ -329,3 +322,35 @@ _version: 1
 "Detects other apps tapping the mouse event stream — a common cause of pointer lag.": "Tunnistaa muut sovellukset, jotka sieppaavat hiiren tapahtumavirtaa – yleinen osoittimen viiveen syy."
 "No other app is intercepting mouse input.": "Mikään muu sovellus ei sieppaa hiiren syötettä."
 "Another app is intercepting mouse input, which can cause pointer lag or duplicated button actions: %{apps}": "Toinen sovellus sieppaa hiiren syötettä, mikä voi aiheuttaa osoittimen viivettä tai painikkeiden kaksoistoimintoja: %{apps}"
+"Camera": "Kamera"
+"Starting preview…": "Käynnistetään esikatselua…"
+"Enable Camera access in Settings to preview.": "Ota kameran käyttöoikeus käyttöön asetuksissa esikatselua varten."
+"Your Logitech webcam shows up on the main page. Grant access to see its live preview — video never leaves your Mac.": "Logitech-verkkokamerasi näkyy pääsivulla. Myönnä käyttöoikeus nähdäksesi reaaliaikaisen esikatselun — video ei koskaan poistu Macistasi."
+"Brightness": "Kirkkaus"
+"Contrast": "Kontrasti"
+"Saturation": "Kylläisyys"
+"Sharpness": "Terävyys"
+"Camera controls": "Kameran säädöt"
+"Reset to defaults": "Palauta oletukset"
+"This camera exposes no adjustable image controls.": "Tässä kamerassa ei ole säädettäviä kuva-asetuksia."
+"Focus": "Tarkennus"
+"Exposure": "Valotus"
+"White balance": "Valkotasapaino"
+"Tint": "Sävy"
+"Auto": "Auto"
+"Lens": "Objektiivi"
+"Image": "Kuva"
+"Streaming": "Suoratoisto"
+"Video call": "Videopuhelu"
+"New": "Uusi"
+"Live preview isn't available on this platform yet.": "Live-esikatselu ei ole vielä saatavilla tällä alustalla."
+"Applying light setting…": "Applying light setting…"
+"Auto-on with camera": "Auto-on with camera"
+"Turn this light on while any camera is in use and off when cameras stop.": "Turn this light on while any camera is in use and off when cameras stop."
+"Power User": "Power User"
+"Type Text…": "Type Text…"
+"Run AppleScript…": "Run AppleScript…"
+"Run Shell Command…": "Run Shell Command…"
+"Workflow…": "Workflow…"
+"Save Workflow": "Save Workflow"
+"+ Add Step": "+ Add Step"
diff --git a/crates/openlogi-gui/locales/fr.yml b/crates/openlogi-gui/locales/fr.yml
index e2c0e2394efd05653447b259cf592d65d2232154..ad10c78f4c6db12449d0b30322aa785cde1e40ca 100644
--- a/crates/openlogi-gui/locales/fr.yml
+++ b/crates/openlogi-gui/locales/fr.yml
@@ -3,10 +3,12 @@ _version: 1
 "No devices connected": "Aucun appareil connecté"
 "Devices": "Appareils"
 "Buttons": "Boutons"
+"Keys": "Keys"
 "Pointer": "Pointeur"
 "Lighting": "Éclairage"
 "LIGHTING": "ÉCLAIRAGE"
 "BRIGHTNESS": "LUMINOSITÉ"
+"COLOUR TEMPERATURE": "TEMPÉRATURE DE COULEUR"
 "On": "Activé"
 "Off": "Désactivé"
 "Open OpenLogi": "Ouvrir OpenLogi"
@@ -156,16 +158,6 @@ _version: 1
 "Forward": "Suivant"
 "DPI Toggle": "Bascule DPI"
 "Thumb Wheel": "Molette latérale"
-"Back / Forward": "Précédent / Suivant"
-"Undo / Redo": "Annuler / Rétablir"
-"Browser Back / Forward": "Précédent (navigateur) / Suivant (navigateur)"
-"Previous / Next Tab": "Onglet précédent / Onglet suivant"
-"Previous / Next Desktop": "Bureau précédent / Bureau suivant"
-"Previous / Next Track": "Piste précédente / Piste suivante"
-"Volume Down / Up": "Baisser le volume / Augmenter le volume"
-"Vertical Scroll": "Défiler vers le bas / Défiler vers le haut"
-"Horizontal Scroll": "Défiler vers la gauche / Défiler vers la droite"
-"Custom": "Custom"
 "Gesture Button": "Bouton de gestes"
 "Up": "Haut"
 "Down": "Bas"
@@ -198,6 +190,7 @@ _version: 1
 "Launchpad": "Launchpad"
 "Lock Screen": "Verrouiller l'écran"
 "Screenshot": "Capture d'écran"
+"Sleep": "Suspendre l'activité"
 "Capture Region": "Capturer une zone"
 "Play / Pause": "Lecture / Pause"
 "Next Track": "Piste suivante"
@@ -329,3 +322,35 @@ _version: 1
 "Detects other apps tapping the mouse event stream — a common cause of pointer lag.": "Détecte les autres applications qui interceptent le flux d'événements de la souris — une cause fréquente de latence du pointeur."
 "No other app is intercepting mouse input.": "Aucune autre application n'intercepte les entrées de la souris."
 "Another app is intercepting mouse input, which can cause pointer lag or duplicated button actions: %{apps}": "Une autre application intercepte les entrées de la souris, ce qui peut provoquer une latence du pointeur ou des actions de bouton en double : %{apps}"
+"Camera": "Caméra"
+"Starting preview…": "Démarrage de l'aperçu…"
+"Enable Camera access in Settings to preview.": "Activez l'accès à la caméra dans les Réglages pour voir l'aperçu."
+"Your Logitech webcam shows up on the main page. Grant access to see its live preview — video never leaves your Mac.": "Votre webcam Logitech apparaît sur la page principale. Autorisez l'accès pour voir son aperçu en direct — la vidéo ne quitte jamais votre Mac."
+"Brightness": "Luminosité"
+"Contrast": "Contraste"
+"Saturation": "Saturation"
+"Sharpness": "Netteté"
+"Camera controls": "Réglages de la caméra"
+"Reset to defaults": "Réinitialiser les valeurs par défaut"
+"This camera exposes no adjustable image controls.": "Cette caméra n'expose aucun réglage d'image ajustable."
+"Focus": "Mise au point"
+"Exposure": "Exposition"
+"White balance": "Balance des blancs"
+"Tint": "Teinte"
+"Auto": "Auto"
+"Lens": "Objectif"
+"Image": "Image"
+"Streaming": "Streaming"
+"Video call": "Appel vidéo"
+"New": "Nouveau"
+"Live preview isn't available on this platform yet.": "L'aperçu en direct n'est pas encore disponible sur cette plateforme."
+"Applying light setting…": "Applying light setting…"
+"Auto-on with camera": "Auto-on with camera"
+"Turn this light on while any camera is in use and off when cameras stop.": "Turn this light on while any camera is in use and off when cameras stop."
+"Power User": "Power User"
+"Type Text…": "Type Text…"
+"Run AppleScript…": "Run AppleScript…"
+"Run Shell Command…": "Run Shell Command…"
+"Workflow…": "Workflow…"
+"Save Workflow": "Save Workflow"
+"+ Add Step": "+ Add Step"
diff --git a/crates/openlogi-gui/locales/it.yml b/crates/openlogi-gui/locales/it.yml
index 588f6a5aa04d07e22d78210ffa520d163698b566..a216bc0ab52dd84e6429a7a3c149060fa55f3c9b 100644
--- a/crates/openlogi-gui/locales/it.yml
+++ b/crates/openlogi-gui/locales/it.yml
@@ -3,10 +3,12 @@ _version: 1
 "No devices connected": "Nessun dispositivo connesso"
 "Devices": "Dispositivi"
 "Buttons": "Pulsanti"
+"Keys": "Keys"
 "Pointer": "Puntatore"
 "Lighting": "Illuminazione"
 "LIGHTING": "ILLUMINAZIONE"
 "BRIGHTNESS": "LUMINOSITÀ"
+"COLOUR TEMPERATURE": "TEMPERATURA COLORE"
 "On": "On"
 "Off": "Off"
 "Open OpenLogi": "Apri OpenLogi"
@@ -156,16 +158,6 @@ _version: 1
 "Forward": "Avanti"
 "DPI Toggle": "Cambia DPI"
 "Thumb Wheel": "Volante da pollice"
-"Back / Forward": "Indietro / Avanti"
-"Undo / Redo": "Annulla / Ripristina"
-"Browser Back / Forward": "Indietro nel browser / Avanti nel browser"
-"Previous / Next Tab": "Scheda precedente / Scheda successiva"
-"Previous / Next Desktop": "Scrivania precedente / Scrivania successiva"
-"Previous / Next Track": "Traccia precedente / Traccia successiva"
-"Volume Down / Up": "Abbassa il volume / Alza il volume"
-"Vertical Scroll": "Scorri giù / Scorri su"
-"Horizontal Scroll": "Scorri a sinistra / Scorri a destra"
-"Custom": "Custom"
 "Gesture Button": "Pulsante gesture"
 "Up": "Su"
 "Down": "Giù"
@@ -198,6 +190,7 @@ _version: 1
 "Launchpad": "Launchpad"
 "Lock Screen": "Blocca schermo"
 "Screenshot": "Istantanea schermo"
+"Sleep": "Stop"
 "Capture Region": "Cattura area"
 "Play / Pause": "Riproduci / Pausa"
 "Next Track": "Traccia successiva"
@@ -329,3 +322,35 @@ _version: 1
 "Detects other apps tapping the mouse event stream — a common cause of pointer lag.": "Rileva altre app che intercettano il flusso di eventi del mouse, una causa comune di lentezza del puntatore."
 "No other app is intercepting mouse input.": "Nessun'altra app sta intercettando l'input del mouse."
 "Another app is intercepting mouse input, which can cause pointer lag or duplicated button actions: %{apps}": "Un'altra app sta intercettando l'input del mouse, il che può causare lentezza del puntatore o azioni dei pulsanti duplicate: %{apps}"
+"Camera": "Fotocamera"
+"Starting preview…": "Avvio anteprima…"
+"Enable Camera access in Settings to preview.": "Abilita l'accesso alla fotocamera nelle Impostazioni per l'anteprima."
+"Your Logitech webcam shows up on the main page. Grant access to see its live preview — video never leaves your Mac.": "La tua webcam Logitech compare nella pagina principale. Concedi l'accesso per vederne l'anteprima dal vivo — il video non lascia mai il tuo Mac."
+"Brightness": "Luminosità"
+"Contrast": "Contrasto"
+"Saturation": "Saturazione"
+"Sharpness": "Nitidezza"
+"Camera controls": "Controlli fotocamera"
+"Reset to defaults": "Ripristina i valori predefiniti"
+"This camera exposes no adjustable image controls.": "Questa fotocamera non espone controlli immagine regolabili."
+"Focus": "Messa a fuoco"
+"Exposure": "Esposizione"
+"White balance": "Bilanciamento del bianco"
+"Tint": "Tinta"
+"Auto": "Auto"
+"Lens": "Obiettivo"
+"Image": "Immagine"
+"Streaming": "Streaming"
+"Video call": "Videochiamata"
+"New": "Nuovo"
+"Live preview isn't available on this platform yet.": "L'anteprima dal vivo non è ancora disponibile su questa piattaforma."
+"Applying light setting…": "Applying light setting…"
+"Auto-on with camera": "Accensione automatica con la fotocamera"
+"Turn this light on while any camera is in use and off when cameras stop.": "Accendi questa luce quando una fotocamera è in uso e spegnila quando tutte si fermano."
+"Power User": "Power User"
+"Type Text…": "Type Text…"
+"Run AppleScript…": "Run AppleScript…"
+"Run Shell Command…": "Run Shell Command…"
+"Workflow…": "Workflow…"
+"Save Workflow": "Save Workflow"
+"+ Add Step": "+ Add Step"
diff --git a/crates/openlogi-gui/locales/ja.yml b/crates/openlogi-gui/locales/ja.yml
index 95597eac78d69a05d2cb2fedecd4e8fd1f8cf528..48a1650096d6cbd08d16f3b3b731e98717cf12c5 100644
--- a/crates/openlogi-gui/locales/ja.yml
+++ b/crates/openlogi-gui/locales/ja.yml
@@ -3,10 +3,12 @@ _version: 1
 "No devices connected": "デバイスが接続されていません"
 "Devices": "デバイス"
 "Buttons": "ボタン"
+"Keys": "Keys"
 "Pointer": "ポインター"
 "Lighting": "ライト"
 "LIGHTING": "ライト"
 "BRIGHTNESS": "明るさ"
+"COLOUR TEMPERATURE": "色温度"
 "On": "オン"
 "Off": "オフ"
 "Open OpenLogi": "OpenLogi を開く"
@@ -156,16 +158,6 @@ _version: 1
 "Forward": "進む"
 "DPI Toggle": "DPI 切り替え"
 "Thumb Wheel": "サムホイール"
-"Back / Forward": "戻る / 進む"
-"Undo / Redo": "取り消す / やり直す"
-"Browser Back / Forward": "ブラウザで戻る / ブラウザで進む"
-"Previous / Next Tab": "前のタブ / 次のタブ"
-"Previous / Next Desktop": "前のデスクトップ / 次のデスクトップ"
-"Previous / Next Track": "前の曲 / 次の曲"
-"Volume Down / Up": "音量を下げる / 音量を上げる"
-"Vertical Scroll": "下にスクロール / 上にスクロール"
-"Horizontal Scroll": "左にスクロール / 右にスクロール"
-"Custom": "Custom"
 "Gesture Button": "ジェスチャーボタン"
 "Up": "上"
 "Down": "下"
@@ -198,6 +190,7 @@ _version: 1
 "Launchpad": "Launchpad"
 "Lock Screen": "画面をロック"
 "Screenshot": "スクリーンショット"
+"Sleep": "スリープ"
 "Capture Region": "範囲をキャプチャ"
 "Play / Pause": "再生 / 一時停止"
 "Next Track": "次の曲"
@@ -329,3 +322,35 @@ _version: 1
 "Detects other apps tapping the mouse event stream — a common cause of pointer lag.": "マウスイベントストリームを監視している他のアプリを検出します。ポインタ遅延のよくある原因です。"
 "No other app is intercepting mouse input.": "マウス入力を横取りしている他のアプリはありません。"
 "Another app is intercepting mouse input, which can cause pointer lag or duplicated button actions: %{apps}": "別のアプリがマウス入力を横取りしています。ポインタの遅延やボタンの二重動作の原因になることがあります:%{apps}"
+"Camera": "カメラ"
+"Starting preview…": "プレビューを開始しています…"
+"Enable Camera access in Settings to preview.": "プレビューするには、設定でカメラへのアクセスを有効にしてください。"
+"Your Logitech webcam shows up on the main page. Grant access to see its live preview — video never leaves your Mac.": "Logitech のウェブカメラはメインページに表示されます。アクセスを許可するとライブプレビューを確認できます。映像が Mac の外に出ることはありません。"
+"Brightness": "明るさ"
+"Contrast": "コントラスト"
+"Saturation": "彩度"
+"Sharpness": "シャープネス"
+"Camera controls": "カメラコントロール"
+"Reset to defaults": "デフォルトに戻す"
+"This camera exposes no adjustable image controls.": "このカメラには調整可能な画質コントロールがありません。"
+"Focus": "フォーカス"
+"Exposure": "露出"
+"White balance": "ホワイトバランス"
+"Tint": "色合い"
+"Auto": "自動"
+"Lens": "レンズ"
+"Image": "画像"
+"Streaming": "配信"
+"Video call": "ビデオ通話"
+"New": "新規"
+"Live preview isn't available on this platform yet.": "ライブプレビューはこのプラットフォームではまだ利用できません。"
+"Applying light setting…": "Applying light setting…"
+"Auto-on with camera": "Auto-on with camera"
+"Turn this light on while any camera is in use and off when cameras stop.": "Turn this light on while any camera is in use and off when cameras stop."
+"Power User": "Power User"
+"Type Text…": "Type Text…"
+"Run AppleScript…": "Run AppleScript…"
+"Run Shell Command…": "Run Shell Command…"
+"Workflow…": "Workflow…"
+"Save Workflow": "Save Workflow"
+"+ Add Step": "+ Add Step"
diff --git a/crates/openlogi-gui/locales/ko.yml b/crates/openlogi-gui/locales/ko.yml
index a22c1965ab2e20a49b06c7c039d0e8623e06a11f..1f49fdee872734c3013460f614afea21f595639c 100644
--- a/crates/openlogi-gui/locales/ko.yml
+++ b/crates/openlogi-gui/locales/ko.yml
@@ -3,10 +3,12 @@ _version: 1
 "No devices connected": "연결된 기기가 없습니다"
 "Devices": "기기"
 "Buttons": "버튼"
+"Keys": "Keys"
 "Pointer": "포인터"
 "Lighting": "조명"
 "LIGHTING": "조명"
 "BRIGHTNESS": "밝기"
+"COLOUR TEMPERATURE": "색온도"
 "On": "켜짐"
 "Off": "꺼짐"
 "Open OpenLogi": "OpenLogi 열기"
@@ -156,16 +158,6 @@ _version: 1
 "Forward": "앞으로"
 "DPI Toggle": "DPI 전환"
 "Thumb Wheel": "썸휠"
-"Back / Forward": "뒤로 / 앞으로"
-"Undo / Redo": "실행 취소 / 다시 실행"
-"Browser Back / Forward": "브라우저 뒤로 / 브라우저 앞으로"
-"Previous / Next Tab": "이전 탭 / 다음 탭"
-"Previous / Next Desktop": "이전 데스크탑 / 다음 데스크탑"
-"Previous / Next Track": "이전 트랙 / 다음 트랙"
-"Volume Down / Up": "볼륨 낮추기 / 볼륨 높이기"
-"Vertical Scroll": "아래로 스크롤 / 위로 스크롤"
-"Horizontal Scroll": "왼쪽으로 스크롤 / 오른쪽으로 스크롤"
-"Custom": "Custom"
 "Gesture Button": "제스처 버튼"
 "Up": "위"
 "Down": "아래"
@@ -198,6 +190,7 @@ _version: 1
 "Launchpad": "런치패드"
 "Lock Screen": "화면 잠금"
 "Screenshot": "스크린샷"
+"Sleep": "잠자기"
 "Capture Region": "영역 캡처"
 "Play / Pause": "재생 / 일시정지"
 "Next Track": "다음 트랙"
@@ -329,3 +322,35 @@ _version: 1
 "Detects other apps tapping the mouse event stream — a common cause of pointer lag.": "마우스 이벤트 스트림을 가로채는 다른 앱을 감지합니다. 포인터 지연의 흔한 원인입니다."
 "No other app is intercepting mouse input.": "마우스 입력을 가로채는 다른 앱이 없습니다."
 "Another app is intercepting mouse input, which can cause pointer lag or duplicated button actions: %{apps}": "다른 앱이 마우스 입력을 가로채고 있어 포인터 지연이나 버튼 중복 동작이 발생할 수 있습니다: %{apps}"
+"Camera": "카메라"
+"Starting preview…": "미리 보기를 시작하는 중…"
+"Enable Camera access in Settings to preview.": "미리 보려면 설정에서 카메라 액세스를 허용하세요."
+"Your Logitech webcam shows up on the main page. Grant access to see its live preview — video never leaves your Mac.": "Logitech 웹캠이 메인 페이지에 표시됩니다. 액세스를 허용하면 실시간 미리 보기를 볼 수 있습니다 — 영상은 Mac을 벗어나지 않습니다."
+"Brightness": "밝기"
+"Contrast": "대비"
+"Saturation": "채도"
+"Sharpness": "선명도"
+"Camera controls": "카메라 컨트롤"
+"Reset to defaults": "기본값으로 재설정"
+"This camera exposes no adjustable image controls.": "이 카메라에는 조정 가능한 이미지 컨트롤이 없습니다."
+"Focus": "초점"
+"Exposure": "노출"
+"White balance": "화이트 밸런스"
+"Tint": "틴트"
+"Auto": "자동"
+"Lens": "렌즈"
+"Image": "이미지"
+"Streaming": "스트리밍"
+"Video call": "영상 통화"
+"New": "신규"
+"Live preview isn't available on this platform yet.": "라이브 미리보기는 이 플랫폼에서 아직 지원되지 않습니다."
+"Applying light setting…": "Applying light setting…"
+"Auto-on with camera": "Auto-on with camera"
+"Turn this light on while any camera is in use and off when cameras stop.": "Turn this light on while any camera is in use and off when cameras stop."
+"Power User": "Power User"
+"Type Text…": "Type Text…"
+"Run AppleScript…": "Run AppleScript…"
+"Run Shell Command…": "Run Shell Command…"
+"Workflow…": "Workflow…"
+"Save Workflow": "Save Workflow"
+"+ Add Step": "+ Add Step"
diff --git a/crates/openlogi-gui/locales/nb.yml b/crates/openlogi-gui/locales/nb.yml
index 4006254be6e19fac66eab7adf91da576d9f66e19..dd26bfc7b1fdea62d4e3f59804893875a4773be8 100644
--- a/crates/openlogi-gui/locales/nb.yml
+++ b/crates/openlogi-gui/locales/nb.yml
@@ -3,10 +3,12 @@ _version: 1
 "No devices connected": "Ingen enhet tilkoblet"
 "Devices": "Enheter"
 "Buttons": "Knapper"
+"Keys": "Keys"
 "Pointer": "Peker"
 "Lighting": "Belysning"
 "LIGHTING": "BELYSNING"
 "BRIGHTNESS": "LYSSTYRKE"
+"COLOUR TEMPERATURE": "FARGETEMPERATUR"
 "On": "På"
 "Off": "Av"
 "Open OpenLogi": "Åpne OpenLogi"
@@ -156,16 +158,6 @@ _version: 1
 "Forward": "Frem"
 "DPI Toggle": "DPI-veksling"
 "Thumb Wheel": "Tommelhjul"
-"Back / Forward": "Tilbake / Frem"
-"Undo / Redo": "Angre / Gjør om"
-"Browser Back / Forward": "Nettleser tilbake / Nettleser frem"
-"Previous / Next Tab": "Forrige fane / Neste fane"
-"Previous / Next Desktop": "Forrige skrivebord / Neste skrivebord"
-"Previous / Next Track": "Forrige spor / Neste spor"
-"Volume Down / Up": "Volum ned / Volum opp"
-"Vertical Scroll": "Rull ned / Rull opp"
-"Horizontal Scroll": "Rull til venstre / Rull til høyre"
-"Custom": "Custom"
 "Gesture Button": "Bevegelsesknapp"
 "Up": "Opp"
 "Down": "Ned"
@@ -198,6 +190,7 @@ _version: 1
 "Launchpad": "Launchpad"
 "Lock Screen": "Lås skjerm"
 "Screenshot": "Skjermbilde"
+"Sleep": "Dvale"
 "Capture Region": "Ta opp område"
 "Play / Pause": "Spill av / pause"
 "Next Track": "Neste spor"
@@ -329,3 +322,35 @@ _version: 1
 "Detects other apps tapping the mouse event stream — a common cause of pointer lag.": "Oppdager andre apper som fanger opp musens hendelsesstrøm – en vanlig årsak til pekerforsinkelse."
 "No other app is intercepting mouse input.": "Ingen annen app fanger opp museinndata."
 "Another app is intercepting mouse input, which can cause pointer lag or duplicated button actions: %{apps}": "En annen app fanger opp museinndata, noe som kan føre til pekerforsinkelse eller dupliserte knappehandlinger: %{apps}"
+"Camera": "Kamera"
+"Starting preview…": "Starter forhåndsvisning…"
+"Enable Camera access in Settings to preview.": "Aktiver kameratilgang i Innstillinger for å forhåndsvise."
+"Your Logitech webcam shows up on the main page. Grant access to see its live preview — video never leaves your Mac.": "Logitech-webkameraet ditt vises på hovedsiden. Gi tilgang for å se sanntidsforhåndsvisningen — videoen forlater aldri Mac-en din."
+"Brightness": "Lysstyrke"
+"Contrast": "Kontrast"
+"Saturation": "Metning"
+"Sharpness": "Skarphet"
+"Camera controls": "Kamerakontroller"
+"Reset to defaults": "Tilbakestill til standard"
+"This camera exposes no adjustable image controls.": "Dette kameraet har ingen justerbare bildekontroller."
+"Focus": "Fokus"
+"Exposure": "Eksponering"
+"White balance": "Hvitbalanse"
+"Tint": "Fargetone"
+"Auto": "Auto"
+"Lens": "Objektiv"
+"Image": "Bilde"
+"Streaming": "Strømming"
+"Video call": "Videosamtale"
+"New": "Ny"
+"Live preview isn't available on this platform yet.": "Direkte forhåndsvisning er ikke tilgjengelig på denne plattformen ennå."
+"Applying light setting…": "Applying light setting…"
+"Auto-on with camera": "Auto-on with camera"
+"Turn this light on while any camera is in use and off when cameras stop.": "Turn this light on while any camera is in use and off when cameras stop."
+"Power User": "Power User"
+"Type Text…": "Type Text…"
+"Run AppleScript…": "Run AppleScript…"
+"Run Shell Command…": "Run Shell Command…"
+"Workflow…": "Workflow…"
+"Save Workflow": "Save Workflow"
+"+ Add Step": "+ Add Step"
diff --git a/crates/openlogi-gui/locales/nl.yml b/crates/openlogi-gui/locales/nl.yml
index 008f301666465ddf984c4799854f2bb9175e125e..c9569cd9013dd0adce7d20a1372e9ff22ac62710 100644
--- a/crates/openlogi-gui/locales/nl.yml
+++ b/crates/openlogi-gui/locales/nl.yml
@@ -3,10 +3,12 @@ _version: 1
 "No devices connected": "Geen apparaat verbonden"
 "Devices": "Apparaten"
 "Buttons": "Knoppen"
+"Keys": "Keys"
 "Pointer": "Aanwijzer"
 "Lighting": "Verlichting"
 "LIGHTING": "VERLICHTING"
 "BRIGHTNESS": "HELDERHEID"
+"COLOUR TEMPERATURE": "KLEURTEMPERATUUR"
 "On": "Aan"
 "Off": "Uit"
 "Open OpenLogi": "OpenLogi openen"
@@ -156,16 +158,6 @@ _version: 1
 "Forward": "Volgende"
 "DPI Toggle": "DPI wisselen"
 "Thumb Wheel": "Duimwiel"
-"Back / Forward": "Vorige / Volgende"
-"Undo / Redo": "Maak ongedaan / Opnieuw"
-"Browser Back / Forward": "Browser vorige / Browser volgende"
-"Previous / Next Tab": "Vorig tabblad / Volgend tabblad"
-"Previous / Next Desktop": "Vorig bureaublad / Volgend bureaublad"
-"Previous / Next Track": "Vorig nummer / Volgend nummer"
-"Volume Down / Up": "Volume omlaag / Volume omhoog"
-"Vertical Scroll": "Omlaag scrollen / Omhoog scrollen"
-"Horizontal Scroll": "Naar links scrollen / Naar rechts scrollen"
-"Custom": "Custom"
 "Gesture Button": "Gebarenknop"
 "Up": "Omhoog"
 "Down": "Omlaag"
@@ -198,6 +190,7 @@ _version: 1
 "Launchpad": "Launchpad"
 "Lock Screen": "Scherm vergrendelen"
 "Screenshot": "Schermafbeelding"
+"Sleep": "Sluimer"
 "Capture Region": "Gebied vastleggen"
 "Play / Pause": "Afspelen / pauzeren"
 "Next Track": "Volgend nummer"
@@ -329,3 +322,35 @@ _version: 1
 "Detects other apps tapping the mouse event stream — a common cause of pointer lag.": "Detecteert andere apps die de muisgebeurtenissenstroom onderscheppen — een veelvoorkomende oorzaak van vertraging van de aanwijzer."
 "No other app is intercepting mouse input.": "Geen andere app onderschept muisinvoer."
 "Another app is intercepting mouse input, which can cause pointer lag or duplicated button actions: %{apps}": "Een andere app onderschept muisinvoer, wat kan leiden tot vertraging van de aanwijzer of dubbele knopacties: %{apps}"
+"Camera": "Camera"
+"Starting preview…": "Voorbeeld starten…"
+"Enable Camera access in Settings to preview.": "Schakel cameratoegang in bij Instellingen om een voorbeeld te zien."
+"Your Logitech webcam shows up on the main page. Grant access to see its live preview — video never leaves your Mac.": "Je Logitech-webcam verschijnt op de hoofdpagina. Verleen toegang om het live voorbeeld te zien — video verlaat nooit je Mac."
+"Brightness": "Helderheid"
+"Contrast": "Contrast"
+"Saturation": "Verzadiging"
+"Sharpness": "Scherpte"
+"Camera controls": "Camerabediening"
+"Reset to defaults": "Standaardwaarden herstellen"
+"This camera exposes no adjustable image controls.": "Deze camera heeft geen instelbare beeldregelaars."
+"Focus": "Focus"
+"Exposure": "Belichting"
+"White balance": "Witbalans"
+"Tint": "Tint"
+"Auto": "Auto"
+"Lens": "Lens"
+"Image": "Beeld"
+"Streaming": "Streaming"
+"Video call": "Videogesprek"
+"New": "Nieuw"
+"Live preview isn't available on this platform yet.": "Livevoorbeeld is nog niet beschikbaar op dit platform."
+"Applying light setting…": "Applying light setting…"
+"Auto-on with camera": "Auto-on with camera"
+"Turn this light on while any camera is in use and off when cameras stop.": "Turn this light on while any camera is in use and off when cameras stop."
+"Power User": "Power User"
+"Type Text…": "Type Text…"
+"Run AppleScript…": "Run AppleScript…"
+"Run Shell Command…": "Run Shell Command…"
+"Workflow…": "Workflow…"
+"Save Workflow": "Save Workflow"
+"+ Add Step": "+ Add Step"
diff --git a/crates/openlogi-gui/locales/pl.yml b/crates/openlogi-gui/locales/pl.yml
index dc57ce0a7e7fbdf85b11bf734d272ffea2059d56..bda10f6e8da0cb84a93adc93a8415965ccbb8521 100644
--- a/crates/openlogi-gui/locales/pl.yml
+++ b/crates/openlogi-gui/locales/pl.yml
@@ -3,10 +3,12 @@ _version: 1
 "No devices connected": "Brak podłączonego urządzenia"
 "Devices": "Urządzenia"
 "Buttons": "Przyciski"
+"Keys": "Keys"
 "Pointer": "Wskaźnik"
 "Lighting": "Podświetlenie"
 "LIGHTING": "PODŚWIETLENIE"
 "BRIGHTNESS": "JASNOŚĆ"
+"COLOUR TEMPERATURE": "TEMPERATURA BARWOWA"
 "On": "Wł."
 "Off": "Wył."
 "Open OpenLogi": "Otwórz OpenLogi"
@@ -156,16 +158,6 @@ _version: 1
 "Forward": "Do przodu"
 "DPI Toggle": "Przełącznik DPI"
 "Thumb Wheel": "Rolka kciukowa"
-"Back / Forward": "Wstecz / Do przodu"
-"Undo / Redo": "Cofnij / Ponów"
-"Browser Back / Forward": "Wstecz w przeglądarce / Do przodu w przeglądarce"
-"Previous / Next Tab": "Poprzednia karta / Następna karta"
-"Previous / Next Desktop": "Poprzedni pulpit / Następny pulpit"
-"Previous / Next Track": "Poprzedni utwór / Następny utwór"
-"Volume Down / Up": "Ciszej / Głośniej"
-"Vertical Scroll": "Przewiń w dół / Przewiń w górę"
-"Horizontal Scroll": "Przewiń w lewo / Przewiń w prawo"
-"Custom": "Custom"
 "Gesture Button": "Przycisk gestów"
 "Up": "W górę"
 "Down": "W dół"
@@ -198,6 +190,7 @@ _version: 1
 "Launchpad": "Launchpad"
 "Lock Screen": "Zablokuj ekran"
 "Screenshot": "Zrzut ekranu"
+"Sleep": "Uśpij"
 "Capture Region": "Przechwyć obszar"
 "Play / Pause": "Odtwarzaj / Wstrzymaj"
 "Next Track": "Następny utwór"
@@ -329,3 +322,35 @@ _version: 1
 "Detects other apps tapping the mouse event stream — a common cause of pointer lag.": "Wykrywa inne aplikacje przechwytujące strumień zdarzeń myszy — częstą przyczynę opóźnień wskaźnika."
 "No other app is intercepting mouse input.": "Żadna inna aplikacja nie przechwytuje danych wejściowych myszy."
 "Another app is intercepting mouse input, which can cause pointer lag or duplicated button actions: %{apps}": "Inna aplikacja przechwytuje dane wejściowe myszy, co może powodować opóźnienia wskaźnika lub zdublowane działania przycisków: %{apps}"
+"Camera": "Kamera"
+"Starting preview…": "Uruchamianie podglądu…"
+"Enable Camera access in Settings to preview.": "Włącz dostęp do kamery w Ustawieniach, aby zobaczyć podgląd."
+"Your Logitech webcam shows up on the main page. Grant access to see its live preview — video never leaves your Mac.": "Twoja kamera Logitech pojawia się na stronie głównej. Przyznaj dostęp, aby zobaczyć podgląd na żywo — wideo nigdy nie opuszcza Twojego Maca."
+"Brightness": "Jasność"
+"Contrast": "Kontrast"
+"Saturation": "Nasycenie"
+"Sharpness": "Ostrość"
+"Camera controls": "Sterowanie kamerą"
+"Reset to defaults": "Przywróć domyślne"
+"This camera exposes no adjustable image controls.": "Ta kamera nie udostępnia regulowanych ustawień obrazu."
+"Focus": "Ostrość"
+"Exposure": "Ekspozycja"
+"White balance": "Balans bieli"
+"Tint": "Odcień"
+"Auto": "Auto"
+"Lens": "Obiektyw"
+"Image": "Obraz"
+"Streaming": "Streaming"
+"Video call": "Rozmowa wideo"
+"New": "Nowy"
+"Live preview isn't available on this platform yet.": "Podgląd na żywo nie jest jeszcze dostępny na tej platformie."
+"Applying light setting…": "Applying light setting…"
+"Auto-on with camera": "Auto-on with camera"
+"Turn this light on while any camera is in use and off when cameras stop.": "Turn this light on while any camera is in use and off when cameras stop."
+"Power User": "Power User"
+"Type Text…": "Type Text…"
+"Run AppleScript…": "Run AppleScript…"
+"Run Shell Command…": "Run Shell Command…"
+"Workflow…": "Workflow…"
+"Save Workflow": "Save Workflow"
+"+ Add Step": "+ Add Step"
diff --git a/crates/openlogi-gui/locales/pt-BR.yml b/crates/openlogi-gui/locales/pt-BR.yml
index 3b91a0b4d635a09e199cac328a0ab422c31910c8..f1f1ca9cde78dd9bb3b7737ac89fc89bda45da7e 100644
--- a/crates/openlogi-gui/locales/pt-BR.yml
+++ b/crates/openlogi-gui/locales/pt-BR.yml
@@ -3,10 +3,12 @@ _version: 1
 "No devices connected": "Nenhum dispositivo conectado"
 "Devices": "Dispositivos"
 "Buttons": "Botões"
+"Keys": "Keys"
 "Pointer": "Ponteiro"
 "Lighting": "Iluminação"
 "LIGHTING": "ILUMINAÇÃO"
 "BRIGHTNESS": "BRILHO"
+"COLOUR TEMPERATURE": "TEMPERATURA DA COR"
 "On": "Ligado"
 "Off": "Desligado"
 "Open OpenLogi": "Abrir o OpenLogi"
@@ -156,16 +158,6 @@ _version: 1
 "Forward": "Avançar"
 "DPI Toggle": "Alternar DPI"
 "Thumb Wheel": "Roda do Polegar"
-"Back / Forward": "Voltar / Avançar"
-"Undo / Redo": "Desfazer / Refazer"
-"Browser Back / Forward": "Voltar no Navegador / Avançar no Navegador"
-"Previous / Next Tab": "Aba Anterior / Próxima Aba"
-"Previous / Next Desktop": "Mesa Anterior / Próxima Mesa"
-"Previous / Next Track": "Faixa Anterior / Próxima Faixa"
-"Volume Down / Up": "Diminuir Volume / Aumentar Volume"
-"Vertical Scroll": "Rolar para Baixo / Rolar para Cima"
-"Horizontal Scroll": "Rolar para a Esquerda / Rolar para a Direita"
-"Custom": "Custom"
 "Gesture Button": "Botão de Gesto"
 "Up": "Cima"
 "Down": "Baixo"
@@ -198,6 +190,7 @@ _version: 1
 "Launchpad": "Launchpad"
 "Lock Screen": "Bloquear Tela"
 "Screenshot": "Captura de Tela"
+"Sleep": "Repouso"
 "Capture Region": "Capturar Região"
 "Play / Pause": "Reproduzir / Pausar"
 "Next Track": "Próxima Faixa"
@@ -329,3 +322,35 @@ _version: 1
 "Detects other apps tapping the mouse event stream — a common cause of pointer lag.": "Detecta outros apps que interceptam o fluxo de eventos do mouse — uma causa comum de lentidão do ponteiro."
 "No other app is intercepting mouse input.": "Nenhum outro app está interceptando a entrada do mouse."
 "Another app is intercepting mouse input, which can cause pointer lag or duplicated button actions: %{apps}": "Outro app está interceptando a entrada do mouse, o que pode causar lentidão do ponteiro ou ações de botão duplicadas: %{apps}"
+"Camera": "Câmera"
+"Starting preview…": "Iniciando visualização…"
+"Enable Camera access in Settings to preview.": "Ative o acesso à câmera nas Configurações para visualizar."
+"Your Logitech webcam shows up on the main page. Grant access to see its live preview — video never leaves your Mac.": "Sua webcam Logitech aparece na página principal. Conceda acesso para ver a visualização ao vivo — o vídeo nunca sai do seu Mac."
+"Brightness": "Brilho"
+"Contrast": "Contraste"
+"Saturation": "Saturação"
+"Sharpness": "Nitidez"
+"Camera controls": "Controles da câmera"
+"Reset to defaults": "Restaurar padrões"
+"This camera exposes no adjustable image controls.": "Esta câmera não oferece controles de imagem ajustáveis."
+"Focus": "Foco"
+"Exposure": "Exposição"
+"White balance": "Balanço de branco"
+"Tint": "Matiz"
+"Auto": "Auto"
+"Lens": "Lente"
+"Image": "Imagem"
+"Streaming": "Streaming"
+"Video call": "Videochamada"
+"New": "Novo"
+"Live preview isn't available on this platform yet.": "A pré-visualização ao vivo ainda não está disponível nesta plataforma."
+"Applying light setting…": "Applying light setting…"
+"Auto-on with camera": "Auto-on with camera"
+"Turn this light on while any camera is in use and off when cameras stop.": "Turn this light on while any camera is in use and off when cameras stop."
+"Power User": "Power User"
+"Type Text…": "Type Text…"
+"Run AppleScript…": "Run AppleScript…"
+"Run Shell Command…": "Run Shell Command…"
+"Workflow…": "Workflow…"
+"Save Workflow": "Save Workflow"
+"+ Add Step": "+ Add Step"
diff --git a/crates/openlogi-gui/locales/pt-PT.yml b/crates/openlogi-gui/locales/pt-PT.yml
index 24b8821ebd66c51f1dd7bfe91292d7b011a31a1d..8ed4c5e03c517865883922025369de75191d4301 100644
--- a/crates/openlogi-gui/locales/pt-PT.yml
+++ b/crates/openlogi-gui/locales/pt-PT.yml
@@ -3,10 +3,12 @@ _version: 1
 "No devices connected": "Nenhum dispositivo ligado"
 "Devices": "Dispositivos"
 "Buttons": "Botões"
+"Keys": "Keys"
 "Pointer": "Ponteiro"
 "Lighting": "Iluminação"
 "LIGHTING": "ILUMINAÇÃO"
 "BRIGHTNESS": "BRILHO"
+"COLOUR TEMPERATURE": "TEMPERATURA DA COR"
 "On": "Ativado"
 "Off": "Desativado"
 "Open OpenLogi": "Abrir o OpenLogi"
@@ -156,16 +158,6 @@ _version: 1
 "Forward": "Avançar"
 "DPI Toggle": "Alternar DPI"
 "Thumb Wheel": "Roda de polegar"
-"Back / Forward": "Retroceder / Avançar"
-"Undo / Redo": "Anular / Refazer"
-"Browser Back / Forward": "Retroceder no navegador / Avançar no navegador"
-"Previous / Next Tab": "Separador anterior / Separador seguinte"
-"Previous / Next Desktop": "Secretária anterior / Secretária seguinte"
-"Previous / Next Track": "Faixa anterior / Faixa seguinte"
-"Volume Down / Up": "Diminuir volume / Aumentar volume"
-"Vertical Scroll": "Deslocar para baixo / Deslocar para cima"
-"Horizontal Scroll": "Deslocar para a esquerda / Deslocar para a direita"
-"Custom": "Custom"
 "Gesture Button": "Botão de gesto"
 "Up": "Cima"
 "Down": "Baixo"
@@ -198,6 +190,7 @@ _version: 1
 "Launchpad": "Launchpad"
 "Lock Screen": "Bloquear ecrã"
 "Screenshot": "Captura de ecrã"
+"Sleep": "Pausa"
 "Capture Region": "Capturar região"
 "Play / Pause": "Reproduzir / Pausa"
 "Next Track": "Faixa seguinte"
@@ -329,3 +322,35 @@ _version: 1
 "Detects other apps tapping the mouse event stream — a common cause of pointer lag.": "Deteta outras apps que intercetam o fluxo de eventos do rato — uma causa comum de lentidão do ponteiro."
 "No other app is intercepting mouse input.": "Nenhuma outra app está a intercetar a entrada do rato."
 "Another app is intercepting mouse input, which can cause pointer lag or duplicated button actions: %{apps}": "Outra app está a intercetar a entrada do rato, o que pode causar lentidão do ponteiro ou ações de botão duplicadas: %{apps}"
+"Camera": "Câmara"
+"Starting preview…": "A iniciar a pré-visualização…"
+"Enable Camera access in Settings to preview.": "Ative o acesso à câmara nas Definições para pré-visualizar."
+"Your Logitech webcam shows up on the main page. Grant access to see its live preview — video never leaves your Mac.": "A sua webcam Logitech aparece na página principal. Conceda acesso para ver a pré-visualização em direto — o vídeo nunca sai do seu Mac."
+"Brightness": "Brilho"
+"Contrast": "Contraste"
+"Saturation": "Saturação"
+"Sharpness": "Nitidez"
+"Camera controls": "Controlos da câmara"
+"Reset to defaults": "Repor predefinições"
+"This camera exposes no adjustable image controls.": "Esta câmara não oferece controlos de imagem ajustáveis."
+"Focus": "Focagem"
+"Exposure": "Exposição"
+"White balance": "Equilíbrio de brancos"
+"Tint": "Tonalidade"
+"Auto": "Auto"
+"Lens": "Objetiva"
+"Image": "Imagem"
+"Streaming": "Streaming"
+"Video call": "Videochamada"
+"New": "Novo"
+"Live preview isn't available on this platform yet.": "A pré-visualização em direto ainda não está disponível nesta plataforma."
+"Applying light setting…": "Applying light setting…"
+"Auto-on with camera": "Auto-on with camera"
+"Turn this light on while any camera is in use and off when cameras stop.": "Turn this light on while any camera is in use and off when cameras stop."
+"Power User": "Power User"
+"Type Text…": "Type Text…"
+"Run AppleScript…": "Run AppleScript…"
+"Run Shell Command…": "Run Shell Command…"
+"Workflow…": "Workflow…"
+"Save Workflow": "Save Workflow"
+"+ Add Step": "+ Add Step"
diff --git a/crates/openlogi-gui/locales/ru.yml b/crates/openlogi-gui/locales/ru.yml
index 5d1958348b6d399e76f6962e30b4193385ac6195..25889c7e61e84fa1d034f7fb5cf43aacaa239445 100644
--- a/crates/openlogi-gui/locales/ru.yml
+++ b/crates/openlogi-gui/locales/ru.yml
@@ -3,10 +3,12 @@ _version: 1
 "No devices connected": "Устройство не подключено"
 "Devices": "Устройства"
 "Buttons": "Кнопки"
+"Keys": "Keys"
 "Pointer": "Указатель"
 "Lighting": "Подсветка"
 "LIGHTING": "ПОДСВЕТКА"
 "BRIGHTNESS": "ЯРКОСТЬ"
+"COLOUR TEMPERATURE": "ЦВЕТОВАЯ ТЕМПЕРАТУРА"
 "On": "Вкл"
 "Off": "Выкл"
 "Open OpenLogi": "Открыть OpenLogi"
@@ -156,16 +158,6 @@ _version: 1
 "Forward": "Вперёд"
 "DPI Toggle": "Переключение DPI"
 "Thumb Wheel": "Колесо под большой палец"
-"Back / Forward": "Назад / Вперёд"
-"Undo / Redo": "Отменить / Повторить"
-"Browser Back / Forward": "Назад в браузере / Вперёд в браузере"
-"Previous / Next Tab": "Предыдущая вкладка / Следующая вкладка"
-"Previous / Next Desktop": "Предыдущий рабочий стол / Следующий рабочий стол"
-"Previous / Next Track": "Предыдущий трек / Следующий трек"
-"Volume Down / Up": "Уменьшить громкость / Увеличить громкость"
-"Vertical Scroll": "Прокрутить вниз / Прокрутить вверх"
-"Horizontal Scroll": "Прокрутить влево / Прокрутить вправо"
-"Custom": "Custom"
 "Gesture Button": "Кнопка жестов"
 "Up": "Вверх"
 "Down": "Вниз"
@@ -198,6 +190,7 @@ _version: 1
 "Launchpad": "Launchpad"
 "Lock Screen": "Заблокировать экран"
 "Screenshot": "Снимок экрана"
+"Sleep": "Режим сна"
 "Capture Region": "Снимок области"
 "Play / Pause": "Воспроизведение / пауза"
 "Next Track": "Следующий трек"
@@ -329,3 +322,35 @@ _version: 1
 "Detects other apps tapping the mouse event stream — a common cause of pointer lag.": "Обнаруживает другие приложения, перехватывающие поток событий мыши, — частая причина задержки указателя."
 "No other app is intercepting mouse input.": "Никакое другое приложение не перехватывает ввод мыши."
 "Another app is intercepting mouse input, which can cause pointer lag or duplicated button actions: %{apps}": "Другое приложение перехватывает ввод мыши, что может вызывать задержку указателя или дублирование действий кнопок: %{apps}"
+"Camera": "Камера"
+"Starting preview…": "Запуск предпросмотра…"
+"Enable Camera access in Settings to preview.": "Чтобы увидеть предпросмотр, включите доступ к камере в настройках."
+"Your Logitech webcam shows up on the main page. Grant access to see its live preview — video never leaves your Mac.": "Ваша веб-камера Logitech отображается на главной странице. Предоставьте доступ, чтобы увидеть прямой предпросмотр — видео никогда не покидает ваш Mac."
+"Brightness": "Яркость"
+"Contrast": "Контраст"
+"Saturation": "Насыщенность"
+"Sharpness": "Резкость"
+"Camera controls": "Элементы управления камерой"
+"Reset to defaults": "Сбросить настройки"
+"This camera exposes no adjustable image controls.": "Эта камера не имеет регулируемых параметров изображения."
+"Focus": "Фокус"
+"Exposure": "Экспозиция"
+"White balance": "Баланс белого"
+"Tint": "Оттенок"
+"Auto": "Авто"
+"Lens": "Объектив"
+"Image": "Изображение"
+"Streaming": "Стриминг"
+"Video call": "Видеозвонок"
+"New": "Новый"
+"Live preview isn't available on this platform yet.": "Предпросмотр в реальном времени пока недоступен на этой платформе."
+"Applying light setting…": "Applying light setting…"
+"Auto-on with camera": "Auto-on with camera"
+"Turn this light on while any camera is in use and off when cameras stop.": "Turn this light on while any camera is in use and off when cameras stop."
+"Power User": "Power User"
+"Type Text…": "Type Text…"
+"Run AppleScript…": "Run AppleScript…"
+"Run Shell Command…": "Run Shell Command…"
+"Workflow…": "Workflow…"
+"Save Workflow": "Save Workflow"
+"+ Add Step": "+ Add Step"
diff --git a/crates/openlogi-gui/locales/sv.yml b/crates/openlogi-gui/locales/sv.yml
index 37b9b7cd29828829cfc4a51d879c48726accfb55..2b0fc5558c1bb418a4bc33579a178ec206d99ddc 100644
--- a/crates/openlogi-gui/locales/sv.yml
+++ b/crates/openlogi-gui/locales/sv.yml
@@ -3,10 +3,12 @@ _version: 1
 "No devices connected": "Ingen enhet ansluten"
 "Devices": "Enheter"
 "Buttons": "Knappar"
+"Keys": "Keys"
 "Pointer": "Pekare"
 "Lighting": "Belysning"
 "LIGHTING": "BELYSNING"
 "BRIGHTNESS": "LJUSSTYRKA"
+"COLOUR TEMPERATURE": "FÄRGTEMPERATUR"
 "On": "På"
 "Off": "Av"
 "Open OpenLogi": "Öppna OpenLogi"
@@ -156,16 +158,6 @@ _version: 1
 "Forward": "Framåt"
 "DPI Toggle": "DPI-växling"
 "Thumb Wheel": "Tumhjul"
-"Back / Forward": "Bakåt / Framåt"
-"Undo / Redo": "Ångra / Gör om"
-"Browser Back / Forward": "Webbläsare bakåt / Webbläsare framåt"
-"Previous / Next Tab": "Föregående flik / Nästa flik"
-"Previous / Next Desktop": "Föregående skrivbord / Nästa skrivbord"
-"Previous / Next Track": "Föregående spår / Nästa spår"
-"Volume Down / Up": "Sänk volymen / Höj volymen"
-"Vertical Scroll": "Rulla ned / Rulla upp"
-"Horizontal Scroll": "Rulla vänster / Rulla höger"
-"Custom": "Custom"
 "Gesture Button": "Gestknapp"
 "Up": "Upp"
 "Down": "Ned"
@@ -198,6 +190,7 @@ _version: 1
 "Launchpad": "Launchpad"
 "Lock Screen": "Lås skärmen"
 "Screenshot": "Skärmavbild"
+"Sleep": "Vila"
 "Capture Region": "Fånga område"
 "Play / Pause": "Spela upp / Pausa"
 "Next Track": "Nästa spår"
@@ -329,3 +322,35 @@ _version: 1
 "Detects other apps tapping the mouse event stream — a common cause of pointer lag.": "Upptäcker andra appar som fångar upp musens händelseström – en vanlig orsak till pekarfördröjning."
 "No other app is intercepting mouse input.": "Ingen annan app fångar upp musinmatning."
 "Another app is intercepting mouse input, which can cause pointer lag or duplicated button actions: %{apps}": "En annan app fångar upp musinmatning, vilket kan orsaka pekarfördröjning eller dubblerade knappåtgärder: %{apps}"
+"Camera": "Kamera"
+"Starting preview…": "Startar förhandsvisning…"
+"Enable Camera access in Settings to preview.": "Aktivera kameraåtkomst i Inställningar för att förhandsgranska."
+"Your Logitech webcam shows up on the main page. Grant access to see its live preview — video never leaves your Mac.": "Din Logitech-webbkamera visas på huvudsidan. Ge åtkomst för att se live-förhandsvisningen — videon lämnar aldrig din Mac."
+"Brightness": "Ljusstyrka"
+"Contrast": "Kontrast"
+"Saturation": "Mättnad"
+"Sharpness": "Skärpa"
+"Camera controls": "Kamerakontroller"
+"Reset to defaults": "Återställ till standard"
+"This camera exposes no adjustable image controls.": "Den här kameran har inga justerbara bildkontroller."
+"Focus": "Fokus"
+"Exposure": "Exponering"
+"White balance": "Vitbalans"
+"Tint": "Färgton"
+"Auto": "Auto"
+"Lens": "Objektiv"
+"Image": "Bild"
+"Streaming": "Strömning"
+"Video call": "Videosamtal"
+"New": "Ny"
+"Live preview isn't available on this platform yet.": "Direktförhandsvisning är inte tillgänglig på den här plattformen ännu."
+"Applying light setting…": "Applying light setting…"
+"Auto-on with camera": "Auto-on with camera"
+"Turn this light on while any camera is in use and off when cameras stop.": "Turn this light on while any camera is in use and off when cameras stop."
+"Power User": "Power User"
+"Type Text…": "Type Text…"
+"Run AppleScript…": "Run AppleScript…"
+"Run Shell Command…": "Run Shell Command…"
+"Workflow…": "Workflow…"
+"Save Workflow": "Save Workflow"
+"+ Add Step": "+ Add Step"
diff --git a/crates/openlogi-gui/locales/zh-CN.yml b/crates/openlogi-gui/locales/zh-CN.yml
index 602caff010a3240945366c9d91e0982681b6cce8..fe84055386d4e44a0fc70f2acb630d6acf39c27b 100644
--- a/crates/openlogi-gui/locales/zh-CN.yml
+++ b/crates/openlogi-gui/locales/zh-CN.yml
@@ -3,10 +3,12 @@ _version: 1
 "No devices connected": "未连接设备"
 "Devices": "设备"
 "Buttons": "按键"
+"Keys": "Keys"
 "Pointer": "指针"
 "Lighting": "灯光"
 "LIGHTING": "灯光"
 "BRIGHTNESS": "亮度"
+"COLOUR TEMPERATURE": "色温"
 "On": "开"
 "Off": "关"
 "Open OpenLogi": "打开 OpenLogi"
@@ -156,16 +158,6 @@ _version: 1
 "Forward": "前进"
 "DPI Toggle": "灵敏度切换"
 "Thumb Wheel": "拇指滚轮"
-"Back / Forward": "后退 / 前进"
-"Undo / Redo": "撤销 / 重做"
-"Browser Back / Forward": "浏览器后退 / 浏览器前进"
-"Previous / Next Tab": "上一个标签页 / 下一个标签页"
-"Previous / Next Desktop": "上一个桌面 / 下一个桌面"
-"Previous / Next Track": "上一首 / 下一首"
-"Volume Down / Up": "减小音量 / 增大音量"
-"Vertical Scroll": "向下滚动 / 向上滚动"
-"Horizontal Scroll": "向左滚动 / 向右滚动"
-"Custom": "Custom"
 "Gesture Button": "手势按钮"
 "Up": "上"
 "Down": "下"
@@ -198,6 +190,7 @@ _version: 1
 "Launchpad": "启动台"
 "Lock Screen": "锁定屏幕"
 "Screenshot": "截屏"
+"Sleep": "睡眠"
 "Capture Region": "截取区域"
 "Play / Pause": "播放 / 暂停"
 "Next Track": "下一首"
@@ -329,3 +322,35 @@ _version: 1
 "Detects other apps tapping the mouse event stream — a common cause of pointer lag.": "检测其它正在监听鼠标事件流的应用——这是指针卡顿的常见原因。"
 "No other app is intercepting mouse input.": "没有其它应用在拦截鼠标输入。"
 "Another app is intercepting mouse input, which can cause pointer lag or duplicated button actions: %{apps}": "另一个应用正在拦截鼠标输入,可能导致指针卡顿或按键重复触发:%{apps}"
+"Camera": "摄像头"
+"Starting preview…": "正在启动预览…"
+"Enable Camera access in Settings to preview.": "在设置中启用摄像头访问权限以进行预览。"
+"Your Logitech webcam shows up on the main page. Grant access to see its live preview — video never leaves your Mac.": "您的 Logitech 网络摄像头会显示在主页面上。授予访问权限即可查看实时预览——视频绝不会离开您的 Mac。"
+"Brightness": "亮度"
+"Contrast": "对比度"
+"Saturation": "饱和度"
+"Sharpness": "锐度"
+"Camera controls": "摄像头控制"
+"Reset to defaults": "恢复默认值"
+"This camera exposes no adjustable image controls.": "此摄像头没有可调节的图像控制项。"
+"Focus": "对焦"
+"Exposure": "曝光"
+"White balance": "白平衡"
+"Tint": "色调"
+"Auto": "自动"
+"Lens": "镜头"
+"Image": "图像"
+"Streaming": "直播"
+"Video call": "视频通话"
+"New": "新建"
+"Live preview isn't available on this platform yet.": "实时预览暂不支持此平台。"
+"Applying light setting…": "Applying light setting…"
+"Auto-on with camera": "Auto-on with camera"
+"Turn this light on while any camera is in use and off when cameras stop.": "Turn this light on while any camera is in use and off when cameras stop."
+"Power User": "Power User"
+"Type Text…": "Type Text…"
+"Run AppleScript…": "Run AppleScript…"
+"Run Shell Command…": "Run Shell Command…"
+"Workflow…": "Workflow…"
+"Save Workflow": "Save Workflow"
+"+ Add Step": "+ Add Step"
diff --git a/crates/openlogi-gui/locales/zh-HK.yml b/crates/openlogi-gui/locales/zh-HK.yml
index bbb4d9965cd8f4922bddfaa28ddd939cb34204ee..22ddda3388d2e72a4e23add05efdd757691d24d6 100644
--- a/crates/openlogi-gui/locales/zh-HK.yml
+++ b/crates/openlogi-gui/locales/zh-HK.yml
@@ -3,10 +3,12 @@ _version: 1
 "No devices connected": "未連接裝置"
 "Devices": "裝置"
 "Buttons": "按鍵"
+"Keys": "Keys"
 "Pointer": "指標"
 "Lighting": "燈光"
 "LIGHTING": "燈光"
 "BRIGHTNESS": "亮度"
+"COLOUR TEMPERATURE": "色溫"
 "On": "開"
 "Off": "關"
 "Open OpenLogi": "開啟 OpenLogi"
@@ -156,16 +158,6 @@ _version: 1
 "Forward": "前進"
 "DPI Toggle": "靈敏度切換"
 "Thumb Wheel": "拇指滾輪"
-"Back / Forward": "後退 / 前進"
-"Undo / Redo": "復原 / 重做"
-"Browser Back / Forward": "瀏覽器後退 / 瀏覽器前進"
-"Previous / Next Tab": "上一個分頁 / 下一個分頁"
-"Previous / Next Desktop": "上一個桌面 / 下一個桌面"
-"Previous / Next Track": "上一首 / 下一首"
-"Volume Down / Up": "調低音量 / 調高音量"
-"Vertical Scroll": "向下捲動 / 向上捲動"
-"Horizontal Scroll": "向左捲動 / 向右捲動"
-"Custom": "Custom"
 "Gesture Button": "手勢按鈕"
 "Up": "上"
 "Down": "下"
@@ -198,6 +190,7 @@ _version: 1
 "Launchpad": "啟動台"
 "Lock Screen": "鎖定螢幕"
 "Screenshot": "截圖"
+"Sleep": "睡眠"
 "Capture Region": "擷取區域"
 "Play / Pause": "播放 / 暫停"
 "Next Track": "下一首"
@@ -329,3 +322,35 @@ _version: 1
 "Detects other apps tapping the mouse event stream — a common cause of pointer lag.": "偵測其他正在監聽滑鼠事件流的應用程式——這是指標延遲的常見原因。"
 "No other app is intercepting mouse input.": "沒有其他應用程式正在攔截滑鼠輸入。"
 "Another app is intercepting mouse input, which can cause pointer lag or duplicated button actions: %{apps}": "另一個應用程式正在攔截滑鼠輸入,可能導致指標延遲或按鍵重複觸發:%{apps}"
+"Camera": "攝影機"
+"Starting preview…": "正在啟動預覽…"
+"Enable Camera access in Settings to preview.": "在設定中啟用攝影機存取權限即可預覽。"
+"Your Logitech webcam shows up on the main page. Grant access to see its live preview — video never leaves your Mac.": "您的 Logitech 網絡攝影機會顯示在主頁面上。授予存取權限即可查看即時預覽——影像絕不會離開您的 Mac。"
+"Brightness": "亮度"
+"Contrast": "對比度"
+"Saturation": "飽和度"
+"Sharpness": "銳利度"
+"Camera controls": "攝影機控制項"
+"Reset to defaults": "重設為預設值"
+"This camera exposes no adjustable image controls.": "此攝影機沒有可調整的影像控制項。"
+"Focus": "對焦"
+"Exposure": "曝光"
+"White balance": "白平衡"
+"Tint": "色調"
+"Auto": "自動"
+"Lens": "鏡頭"
+"Image": "影像"
+"Streaming": "直播"
+"Video call": "視像通話"
+"New": "新增"
+"Live preview isn't available on this platform yet.": "此平台暫不支援即時預覽。"
+"Applying light setting…": "Applying light setting…"
+"Auto-on with camera": "Auto-on with camera"
+"Turn this light on while any camera is in use and off when cameras stop.": "Turn this light on while any camera is in use and off when cameras stop."
+"Power User": "Power User"
+"Type Text…": "Type Text…"
+"Run AppleScript…": "Run AppleScript…"
+"Run Shell Command…": "Run Shell Command…"
+"Workflow…": "Workflow…"
+"Save Workflow": "Save Workflow"
+"+ Add Step": "+ Add Step"
diff --git a/crates/openlogi-gui/locales/zh-TW.yml b/crates/openlogi-gui/locales/zh-TW.yml
index 593ad830ffbe919b76ea721848b5c7d1eb778295..6a638c973f04f4595ccc9e5ac20e8ac1bcd1a749 100644
--- a/crates/openlogi-gui/locales/zh-TW.yml
+++ b/crates/openlogi-gui/locales/zh-TW.yml
@@ -3,10 +3,12 @@ _version: 1
 "No devices connected": "沒有已連線的裝置"
 "Devices": "裝置"
 "Buttons": "按鍵"
+"Keys": "Keys"
 "Pointer": "指標"
 "Lighting": "燈光"
 "LIGHTING": "燈光"
 "BRIGHTNESS": "亮度"
+"COLOUR TEMPERATURE": "色溫"
 "On": "開"
 "Off": "關"
 "Open OpenLogi": "開啟 OpenLogi"
@@ -156,16 +158,6 @@ _version: 1
 "Forward": "前進"
 "DPI Toggle": "靈敏度切換"
 "Thumb Wheel": "拇指滾輪"
-"Back / Forward": "後退 / 前進"
-"Undo / Redo": "復原 / 重做"
-"Browser Back / Forward": "瀏覽器上一頁 / 瀏覽器下一頁"
-"Previous / Next Tab": "上一個分頁 / 下一個分頁"
-"Previous / Next Desktop": "上一個桌面 / 下一個桌面"
-"Previous / Next Track": "上一首 / 下一首"
-"Volume Down / Up": "調低音量 / 調高音量"
-"Vertical Scroll": "向下捲動 / 向上捲動"
-"Horizontal Scroll": "向左捲動 / 向右捲動"
-"Custom": "Custom"
 "Gesture Button": "手勢按鈕"
 "Up": "上"
 "Down": "下"
@@ -198,6 +190,7 @@ _version: 1
 "Launchpad": "啟動台"
 "Lock Screen": "鎖定螢幕"
 "Screenshot": "截圖"
+"Sleep": "睡眠"
 "Capture Region": "擷取區域"
 "Play / Pause": "播放 / 暫停"
 "Next Track": "下一首"
@@ -329,3 +322,35 @@ _version: 1
 "Detects other apps tapping the mouse event stream — a common cause of pointer lag.": "偵測其他正在監聽滑鼠事件流的應用程式——這是指標延遲的常見原因。"
 "No other app is intercepting mouse input.": "沒有其他應用程式在攔截滑鼠輸入。"
 "Another app is intercepting mouse input, which can cause pointer lag or duplicated button actions: %{apps}": "另一個應用程式正在攔截滑鼠輸入,可能導致指標延遲或按鍵重複觸發:%{apps}"
+"Camera": "攝影機"
+"Starting preview…": "正在啟動預覽…"
+"Enable Camera access in Settings to preview.": "在設定中啟用攝影機存取權限即可預覽。"
+"Your Logitech webcam shows up on the main page. Grant access to see its live preview — video never leaves your Mac.": "您的 Logitech 網路攝影機會顯示在主頁面上。授予存取權限即可查看即時預覽——影像絕不會離開您的 Mac。"
+"Brightness": "亮度"
+"Contrast": "對比度"
+"Saturation": "飽和度"
+"Sharpness": "銳利度"
+"Camera controls": "攝影機控制項"
+"Reset to defaults": "重設為預設值"
+"This camera exposes no adjustable image controls.": "此攝影機沒有可調整的影像控制項。"
+"Focus": "對焦"
+"Exposure": "曝光"
+"White balance": "白平衡"
+"Tint": "色調"
+"Auto": "自動"
+"Lens": "鏡頭"
+"Image": "影像"
+"Streaming": "串流"
+"Video call": "視訊通話"
+"New": "新增"
+"Live preview isn't available on this platform yet.": "此平台尚不支援即時預覽。"
+"Applying light setting…": "Applying light setting…"
+"Auto-on with camera": "Auto-on with camera"
+"Turn this light on while any camera is in use and off when cameras stop.": "Turn this light on while any camera is in use and off when cameras stop."
+"Power User": "Power User"
+"Type Text…": "Type Text…"
+"Run AppleScript…": "Run AppleScript…"
+"Run Shell Command…": "Run Shell Command…"
+"Workflow…": "Workflow…"
+"Save Workflow": "Save Workflow"
+"+ Add Step": "+ Add Step"
diff --git a/crates/openlogi-gui/src/app.rs b/crates/openlogi-gui/src/app.rs
index ce7a006f69d3bdbc6e812fb346163a48868c6dd9..59555d2b9806c004816ca0b62afba2893ae0fd17 100644
--- a/crates/openlogi-gui/src/app.rs
+++ b/crates/openlogi-gui/src/app.rs
@@ -15,9 +15,13 @@ use openlogi_agent_core::ipc::InventoryHealth;
 
 use crate::app_menu::{CloseWindow, Minimize, Zoom};
 use crate::asset::AssetResolver;
+use crate::components::camera_controls::CameraControlsPanel;
+use crate::components::camera_preview::CameraPreview;
 use crate::components::dpi_panel::DpiPanel;
+use crate::components::light_panel::LightPanel;
 use crate::components::lighting_panel::LightingPanel;
 use crate::components::smartshift_panel::SmartShiftPanel;
+use crate::keyboard_model::function_row::FunctionRowView;
 use crate::mouse_model::view::MouseModelView;
 use crate::state::{AgentLink, AppState, DeviceRecord};
 use crate::theme::{self, Palette, Typography as _};
@@ -31,6 +35,8 @@ mod widgets;
 // gallery card, so it reaches these through the crate-stable `crate::app::…`
 // path rather than the internal `app::home` submodule.
 pub(crate) use home::{glow_canvas, keyboard_glow};
+// Tray menu and other crate-level callers need the cold-start charging quirk.
+pub(crate) use widgets::battery_charging_no_reading;
 
 /// Which screen the root view is showing.
 ///
@@ -63,10 +69,16 @@ enum Route {
 enum DetailTab {
     /// The mouse model with clickable button hotspots.
     Buttons,
+    /// The keyboard function-row remapper with clickable F-key bubbles.
+    Keys,
     /// Pointer tuning — DPI and presets.
     Pointer,
     /// RGB lighting — color, brightness, on/off.
     Lighting,
+    /// Live webcam preview (UVC cameras only).
+    Camera,
+    /// Standalone light controls driven by a raw-HID device driver.
+    Light,
     /// Device info and configuration.
     Device,
 }
@@ -82,28 +94,38 @@ impl DetailTab {
     /// measured capabilities; we presume a set from their kind so a sleeping
     /// mouse still shows its (host-side) button bindings.
     ///
-    /// The Buttons panel renders a *mouse-model* silhouette with hotspots. It is
-    /// only useful for pointer-type devices (Mouse / Trackball) or when the device
-    /// has a resolved asset that provides its own correct layout. A keyboard that
-    /// exposes ReprogControls via HID++ but has no asset would get the generic
-    /// mouse fallback hotspots — confusing and wrong. Suppress the Buttons tab for
-    /// such devices until a proper keyboard-layout UI is available.
+    /// The Buttons panel renders a mouse-model silhouette with hotspots. It is
+    /// only useful for pointer-type devices; keyboards get the Keys panel
+    /// instead, even when they expose ReprogControls over HID++.
     fn tabs_for(record: &DeviceRecord) -> Vec<Self> {
         let caps = record
             .capabilities
             .unwrap_or_else(|| Capabilities::presumed_from_kind(record.kind));
-        let can_show_mouse_model = record.asset.is_some()
-            || matches!(record.kind, DeviceKind::Mouse | DeviceKind::Trackball);
+        // Buttons panel is a mouse-model silhouette — only for pointer devices.
+        // Keyboards get the Keys panel instead, even when they expose ReprogControls.
+        let can_show_mouse_model = matches!(record.kind, DeviceKind::Mouse | DeviceKind::Trackball);
         let mut tabs = Vec::new();
+        // A webcam is a UVC device with no HID++ capabilities; its detail screen
+        // leads with the live preview, then the generic info tab.
+        if matches!(record.kind, DeviceKind::Camera) {
+            tabs.push(Self::Camera);
+        }
         if caps.buttons && can_show_mouse_model {
             tabs.push(Self::Buttons);
         }
+        // Function-row remapper when the keyboard reports remappable buttons.
+        if matches!(record.kind, DeviceKind::Keyboard) && caps.buttons {
+            tabs.push(Self::Keys);
+        }
         if caps.pointer {
             tabs.push(Self::Pointer);
         }
         if caps.lighting {
             tabs.push(Self::Lighting);
         }
+        if record.light_capabilities.is_some() {
+            tabs.push(Self::Light);
+        }
         tabs.push(Self::Device);
         tabs
     }
@@ -119,8 +141,10 @@ impl DetailTab {
     fn label(self) -> gpui::SharedString {
         match self {
             Self::Buttons => tr!("Buttons"),
+            Self::Keys => tr!("Keys"),
             Self::Pointer => tr!("Pointer"),
-            Self::Lighting => tr!("Lighting"),
+            Self::Lighting | Self::Light => tr!("Lighting"),
+            Self::Camera => tr!("Camera"),
             Self::Device => tr!("Device"),
         }
     }
@@ -131,9 +155,13 @@ pub struct AppView {
     focus_handle: FocusHandle,
     route: Route,
     mouse_model: Entity<MouseModelView>,
+    keyboard_model: Entity<FunctionRowView>,
     dpi_panel: Entity<DpiPanel>,
     smartshift_panel: Entity<SmartShiftPanel>,
     lighting_panel: Entity<LightingPanel>,
+    camera_preview: Entity<CameraPreview>,
+    camera_controls: Entity<CameraControlsPanel>,
+    light_panel: Entity<LightPanel>,
     #[allow(dead_code, reason = "held to keep the appearance observer alive")]
     appearance_obs: Option<Subscription>,
     /// Re-renders the root when the device list changes so the empty state
@@ -175,17 +203,25 @@ impl AppView {
         }
 
         let mouse_model = cx.new(MouseModelView::new);
+        let keyboard_model = cx.new(FunctionRowView::new);
         let dpi_panel = cx.new(DpiPanel::new);
         let smartshift_panel = cx.new(SmartShiftPanel::new);
         let lighting_panel = cx.new(LightingPanel::new);
+        let camera_preview = cx.new(CameraPreview::new);
+        let camera_controls = cx.new(CameraControlsPanel::new);
+        let light_panel = cx.new(LightPanel::new);
         let state_obs = cx.observe_global::<AppState>(|_, cx| cx.notify());
         Self {
             focus_handle,
             route: Route::Home,
             mouse_model,
+            keyboard_model,
             dpi_panel,
             smartshift_panel,
             lighting_panel,
+            camera_preview,
+            camera_controls,
+            light_panel,
             appearance_obs: None,
             state_obs,
             accessibility_dismissed: false,
@@ -331,6 +367,10 @@ fn app_title_bar(pal: Palette) -> impl IntoElement {
 }
 
 impl Render for AppView {
+    #[allow(
+        clippy::too_many_lines,
+        reason = "root view assembles every screen branch inline"
+    )]
     fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
         let pal = theme::palette(cx);
 
@@ -431,13 +471,33 @@ impl Render for AppView {
             } else {
                 tabs.first().copied().unwrap_or(DetailTab::Device)
             };
+            // Run the camera only while its live-preview tab is the one on screen;
+            // any other tab, device, or Home tears the session down (LED off).
+            // Use capture_id (OS open id), not config_key — the latter prefers
+            // the port-stable USB serial and is not a valid AVFoundation id.
+            let camera_target = if active == DetailTab::Camera {
+                record
+                    .as_ref()
+                    .filter(|r| matches!(r.kind, DeviceKind::Camera))
+                    .and_then(|r| r.capture_id.clone())
+            } else {
+                None
+            };
+            self.camera_preview
+                .update(cx, |preview, cx| preview.set_target(camera_target, cx));
             (
                 detail::detail_header(record.as_ref(), &tabs, active, pal, cx).into_any_element(),
                 detail::detail_content(
-                    &self.mouse_model,
-                    &self.dpi_panel,
-                    &self.smartshift_panel,
-                    &self.lighting_panel,
+                    &detail::DetailPanels {
+                        mouse_model: &self.mouse_model,
+                        keyboard_model: &self.keyboard_model,
+                        dpi_panel: &self.dpi_panel,
+                        smartshift_panel: &self.smartshift_panel,
+                        lighting_panel: &self.lighting_panel,
+                        camera_preview: &self.camera_preview,
+                        camera_controls: &self.camera_controls,
+                        light_panel: &self.light_panel,
+                    },
                     active,
                     pal,
                     cx,
@@ -445,6 +505,8 @@ impl Render for AppView {
                 .into_any_element(),
             )
         } else {
+            self.camera_preview
+                .update(cx, |preview, cx| preview.set_target(None, cx));
             (
                 home::home_header(pal).into_any_element(),
                 if has_device {
@@ -468,11 +530,44 @@ impl Render for AppView {
 
 #[cfg(test)]
 mod tests {
+    #![allow(
+        clippy::expect_used,
+        reason = "capability fixture construction is intentionally asserted in tests"
+    )]
+
     use super::home::connection_icon_path;
-    use super::{Capabilities, DetailTab, DeviceKind, DeviceRecord};
-    use openlogi_core::device::DeviceTransports;
+    use super::{Capabilities, DetailTab, DeviceKind, DeviceRecord, battery_charging_no_reading};
+    use openlogi_core::device::{
+        BatteryInfo, BatteryLevel, BatteryStatus, DeviceTransports, LightCapabilities,
+        LightValueRange, LightValueUnit,
+    };
     use openlogi_hid::DeviceRoute;
 
+    /// "Charging" replaces the bogus percentage only when charging *and* the
+    /// reading is still 0% (cold start, no cached pre-charge value). A non-zero
+    /// charge or a real 0% while discharging keeps the number.
+    #[test]
+    fn charging_without_reading_suppresses_percentage() {
+        let b = |percentage, status| BatteryInfo {
+            percentage,
+            level: BatteryLevel::Good,
+            status,
+        };
+        assert!(battery_charging_no_reading(&b(0, BatteryStatus::Charging)));
+        assert!(battery_charging_no_reading(&b(
+            0,
+            BatteryStatus::ChargingSlow
+        )));
+        assert!(!battery_charging_no_reading(&b(
+            40,
+            BatteryStatus::Charging
+        )));
+        assert!(!battery_charging_no_reading(&b(
+            0,
+            BatteryStatus::Discharging
+        )));
+    }
+
     #[test]
     fn connection_icon_matches_route() {
         let bolt = DeviceRoute::Bolt {
@@ -562,9 +657,13 @@ mod tests {
             codename: None,
             serial_number: None,
             unit_id: [0; 4],
+            driver_id: None,
+            registry_model_id: None,
             route: None,
+            capture_id: None,
             kind,
             capabilities,
+            light_capabilities: None,
             slot: 1,
             online: true,
             battery: None,
@@ -612,6 +711,21 @@ mod tests {
         assert!(tabs.contains(&DetailTab::Lighting));
     }
 
+    #[test]
+    fn keyboard_with_buttons_shows_keys_tab() {
+        let caps = Some(Capabilities {
+            buttons: true,
+            pointer: false,
+            lighting: true,
+            scroll_inversion: false,
+            hires_wheel: false,
+            thumbwheel: false,
+        });
+        let tabs = DetailTab::tabs_for(&record(DeviceKind::Keyboard, caps));
+        assert!(tabs.contains(&DetailTab::Keys));
+        assert!(!tabs.contains(&DetailTab::Buttons));
+    }
+
     /// Each panel is independent: a lighting-only device (e.g. a keyboard with
     /// RGB but no remappable keys yet) shows only Lighting + Device.
     #[test]
@@ -624,6 +738,23 @@ mod tests {
         assert_eq!(tabs, vec![DetailTab::Lighting, DetailTab::Device]);
     }
 
+    #[test]
+    fn light_tab_follows_light_capabilities() {
+        let mut device = record(DeviceKind::Light, None);
+        device.light_capabilities = Some(LightCapabilities {
+            power: true,
+            brightness: Some(
+                LightValueRange::new(20, 250, 1, LightValueUnit::Lumens)
+                    .expect("demo light range is valid"),
+            ),
+            ..LightCapabilities::default()
+        });
+        assert_eq!(
+            DetailTab::tabs_for(&device),
+            vec![DetailTab::Light, DetailTab::Device]
+        );
+    }
+
     /// An unprobed (offline) device has no measured capabilities and falls back
     /// to a kind presumption, so a sleeping mouse keeps its button/pointer tabs.
     #[test]
diff --git a/crates/openlogi-gui/src/app/detail.rs b/crates/openlogi-gui/src/app/detail.rs
index 0608334f5b85eb8c126aebc846f382e268fcfede..2b64645e8f406155f2a189131ac98da4710c3e70 100644
--- a/crates/openlogi-gui/src/app/detail.rs
+++ b/crates/openlogi-gui/src/app/detail.rs
@@ -1,5 +1,5 @@
 //! The device-detail screen: the header (back + name + section tabs), and the
-//! four section bodies (Buttons, Pointer, Lighting, Device).
+//! section bodies (Buttons, Keys, Pointer, Lighting, Camera, Device).
 
 use gpui::{
     AnyElement, BorrowAppContext as _, Context, IntoElement, ParentElement, SharedString, Styled,
@@ -23,9 +23,14 @@ use super::widgets::{
 };
 use super::{AppView, DetailTab};
 use crate::app_menu::file_url;
+use crate::components::camera_controls::CameraControlsPanel;
+use crate::components::camera_preview::CameraPreview;
 use crate::components::dpi_panel::DpiPanel;
+use crate::components::light_panel::LightPanel;
+use crate::components::light_visual;
 use crate::components::lighting_panel::LightingPanel;
 use crate::components::smartshift_panel::SmartShiftPanel;
+use crate::keyboard_model::function_row::FunctionRowView;
 use crate::mouse_model::view::MouseModelView;
 use crate::state::{AppState, DeviceRecord};
 use crate::theme::{HEADER_H, Palette, SCREEN_PAD, Typography as _};
@@ -86,11 +91,19 @@ pub(super) fn detail_header(
 /// switches them — is the header's job (see [`detail_header`] and
 /// [`DetailTab::tabs_for`]); `active` arrives pre-resolved against this device's
 /// tab set, so this only has to render the chosen section.
+pub(super) struct DetailPanels<'a> {
+    pub mouse_model: &'a gpui::Entity<MouseModelView>,
+    pub keyboard_model: &'a gpui::Entity<FunctionRowView>,
+    pub dpi_panel: &'a gpui::Entity<DpiPanel>,
+    pub smartshift_panel: &'a gpui::Entity<SmartShiftPanel>,
+    pub lighting_panel: &'a gpui::Entity<LightingPanel>,
+    pub camera_preview: &'a gpui::Entity<CameraPreview>,
+    pub camera_controls: &'a gpui::Entity<CameraControlsPanel>,
+    pub light_panel: &'a gpui::Entity<LightPanel>,
+}
+
 pub(super) fn detail_content(
-    mouse_model: &gpui::Entity<MouseModelView>,
-    dpi_panel: &gpui::Entity<DpiPanel>,
-    smartshift_panel: &gpui::Entity<SmartShiftPanel>,
-    lighting_panel: &gpui::Entity<LightingPanel>,
+    panels: &DetailPanels<'_>,
     active: DetailTab,
     pal: Palette,
     cx: &mut Context<AppView>,
@@ -100,9 +113,16 @@ pub(super) fn detail_content(
         .and_then(AppState::current_record)
         .is_some_and(|record| record.online);
     let content = match active {
-        DetailTab::Buttons => buttons_tab(mouse_model).into_any_element(),
-        DetailTab::Pointer => pointer_tab(dpi_panel, smartshift_panel, pal, cx).into_any_element(),
-        DetailTab::Lighting => lighting_tab(lighting_panel, pal).into_any_element(),
+        DetailTab::Buttons => buttons_tab(panels.mouse_model).into_any_element(),
+        DetailTab::Keys => keys_tab(panels.keyboard_model).into_any_element(),
+        DetailTab::Pointer => {
+            pointer_tab(panels.dpi_panel, panels.smartshift_panel, pal, cx).into_any_element()
+        }
+        DetailTab::Lighting => lighting_tab(panels.lighting_panel, pal).into_any_element(),
+        DetailTab::Camera => {
+            camera_tab(panels.camera_preview, panels.camera_controls, pal).into_any_element()
+        }
+        DetailTab::Light => light_tab(panels.light_panel, pal, cx).into_any_element(),
         DetailTab::Device => device_tab(pal, cx).into_any_element(),
     };
     v_flex()
@@ -173,6 +193,23 @@ fn buttons_tab(mouse_model: &gpui::Entity<MouseModelView>) -> impl IntoElement {
         .child(div().w_full().max_w(px(760.)).child(mouse_model.clone()))
 }
 
+/// Keys tab: the function-row remapper for a keyboard.
+fn keys_tab(keyboard_model: &gpui::Entity<FunctionRowView>) -> impl IntoElement {
+    v_flex()
+        .flex_1()
+        .w_full()
+        .min_h_0()
+        .items_center()
+        .justify_center()
+        .p(px(SCREEN_PAD))
+        .child(
+            div()
+                .w_full()
+                .max_w(px(1040.))
+                .child(keyboard_model.clone()),
+        )
+}
+
 /// Pointer tab: the DPI panel, the SmartShift wheel controls, and the
 /// scroll-wheel preferences, each in a titled card. Use a responsive two-column
 /// grid that still fits the window's 720 px minimum width, so these short
@@ -397,6 +434,93 @@ fn lighting_tab(lighting_panel: &gpui::Entity<LightingPanel>, pal: Palette) -> i
         )))
 }
 
+/// Camera tab: the live webcam preview beside the device-level image controls,
+/// each in a titled card. Side by side at the default window width so every
+/// control is visible without scrolling; the cards wrap to a stacked column
+/// when the window is too narrow. The preview drives the capture session via
+/// [`CameraPreview::set_target`] (called from [`AppView::render`]); the controls
+/// panel reads/writes UVC settings directly on the device.
+fn camera_tab(
+    camera_preview: &gpui::Entity<CameraPreview>,
+    camera_controls: &gpui::Entity<CameraControlsPanel>,
+    pal: Palette,
+) -> impl IntoElement {
+    v_flex()
+        .flex_1()
+        .w_full()
+        .min_h_0()
+        .items_center()
+        .overflow_y_scrollbar()
+        .p_6()
+        .child(
+            h_flex()
+                .w_full()
+                .flex_wrap()
+                .justify_center()
+                .items_start()
+                .gap_3()
+                .child(div().w(px(514.)).flex_shrink_0().child(panel_card(
+                    tr!("Camera"),
+                    Icon::new(IconName::Eye),
+                    pal,
+                    camera_preview.clone().into_any_element(),
+                )))
+                .child(div().w(px(500.)).flex_shrink_0().child(panel_card(
+                    tr!("Camera controls"),
+                    Icon::new(IconName::Settings),
+                    pal,
+                    camera_controls.clone().into_any_element(),
+                ))),
+        )
+}
+
+/// Standalone-light controls in a separate panel from HID++ keyboard RGB.
+fn light_tab(
+    light_panel: &gpui::Entity<LightPanel>,
+    pal: Palette,
+    cx: &mut Context<AppView>,
+) -> impl IntoElement {
+    let (asset, online, enabled, settings) = cx.try_global::<AppState>().map_or(
+        (
+            None,
+            false,
+            false,
+            openlogi_core::config::LightSettings::default(),
+        ),
+        |state| {
+            let record = state.current_record();
+            (
+                record.and_then(|record| record.asset.as_ref()),
+                record.is_some_and(|record| record.online),
+                state.light_enabled(),
+                state.light(),
+            )
+        },
+    );
+    v_flex()
+        .flex_1()
+        .w_full()
+        .min_h_0()
+        .items_center()
+        .overflow_y_scrollbar()
+        .p(px(SCREEN_PAD))
+        .child(
+            h_flex()
+                .w_full()
+                .max_w(px(980.))
+                .gap_4()
+                .flex_wrap()
+                .items_start()
+                .child(light_visual::detail(asset, online, enabled, settings, pal))
+                .child(div().w(px(400.)).min_w(px(360.)).child(panel_card(
+                    tr!("Lighting"),
+                    Icon::new(IconName::Sun),
+                    pal,
+                    light_panel.clone().into_any_element(),
+                ))),
+        )
+}
+
 /// Device tab: device details and configuration cards stacked.
 fn device_tab(pal: Palette, cx: &mut Context<AppView>) -> impl IntoElement {
     v_flex()
@@ -538,11 +662,19 @@ fn device_summary(name: &str, kind: DeviceKind, online: bool, pal: Palette) -> i
 }
 
 fn device_description_list(record: DeviceRecord) -> impl IntoElement {
-    let mut items = vec![
-        DescriptionItem::new(tr!("Connection")).value(route_label(record.route.as_ref())),
-        DescriptionItem::new(tr!("Slot")).value(record.slot.to_string()),
-        DescriptionItem::new(tr!("Device key")).value(record.config_key),
-    ];
+    // Cameras are plain UVC over the cable — no HID++ route, and their slot is
+    // a synthetic 0 that would only mislead next to real receiver slots.
+    let is_camera = matches!(record.kind, DeviceKind::Camera);
+    let connection = if is_camera {
+        tr!("USB").to_string()
+    } else {
+        route_label(record.route.as_ref())
+    };
+    let mut items = vec![DescriptionItem::new(tr!("Connection")).value(connection)];
+    if !is_camera {
+        items.push(DescriptionItem::new(tr!("Slot")).value(record.slot.to_string()));
+    }
+    items.push(DescriptionItem::new(tr!("Device key")).value(elided_key(&record.config_key)));
     if let Some(serial) = record.serial_number {
         items.push(DescriptionItem::new(tr!("Serial")).value(serial));
     }
@@ -553,3 +685,45 @@ fn device_description_list(record: DeviceRecord) -> impl IntoElement {
         .bordered(false)
         .children(items)
 }
+
+/// Show long machine keys (a camera's config key embeds the OS device path)
+/// as head…tail instead of wrapping the details card; short HID++ keys pass
+/// through whole. The full key stays in the config file for copying.
+fn elided_key(key: &str) -> String {
+    const HEAD: usize = 40;
+    const TAIL: usize = 8;
+    let chars: Vec<char> = key.chars().collect();
+    if chars.len() <= HEAD + TAIL + 1 {
+        return key.to_string();
+    }
+    let head: String = chars[..HEAD].iter().collect();
+    let tail: String = chars[chars.len() - TAIL..].iter().collect();
+    format!("{head}…{tail}")
+}
+
+#[cfg(test)]
+mod tests {
+    use super::elided_key;
+
+    #[test]
+    fn short_hid_keys_pass_through_whole() {
+        let key = "direct:046d:b023:unit:a393cae0";
+        assert_eq!(elided_key(key), key);
+    }
+
+    #[test]
+    fn long_camera_keys_show_head_and_tail() {
+        let key = r"camera-\?\usb#vid_046d&pid_0893&mi_00#9&56d9c30&0&0000#{65e8773d-8f56-11d0-a3b9-00a0c9223196}\global";
+        let shown = elided_key(key);
+        assert!(shown.contains('…'));
+        assert!(shown.starts_with(r"camera-\?\usb#vid_046d&pid_0893"));
+        assert!(shown.ends_with(r"}\global"));
+        assert!(shown.chars().count() < 55);
+    }
+
+    #[test]
+    fn exactly_at_the_threshold_is_not_elided() {
+        let key = "k".repeat(49);
+        assert_eq!(elided_key(&key), key);
+    }
+}
diff --git a/crates/openlogi-gui/src/app/home.rs b/crates/openlogi-gui/src/app/home.rs
index 966bbda07e021e260c8a5d07191528c0bf05bcf6..3bb80d21258307c718ac74e12c2b123a50edce59 100644
--- a/crates/openlogi-gui/src/app/home.rs
+++ b/crates/openlogi-gui/src/app/home.rs
@@ -14,6 +14,7 @@ use gpui_component::{
     button::{Button, ButtonVariants as _},
     h_flex, v_flex,
 };
+use openlogi_core::config::LightSettings;
 use openlogi_core::device::{
     BatteryInfo, BatteryLevel, BatteryStatus, DeviceKind, DeviceTransports,
 };
@@ -24,6 +25,7 @@ use super::status::{loading_body, notice_body};
 use super::widgets::{add_device_button, kind_label, settings_button};
 use crate::asset::GlowGeometry;
 use crate::components::carousel::Carousel;
+use crate::components::light_visual;
 use crate::state::{AppState, DeviceRecord};
 use crate::theme::{self, HEADER_H, Palette, SelectableStyle as _, Typography as _};
 
@@ -81,11 +83,19 @@ pub(super) fn device_gallery(cx: &mut Context<AppView>) -> impl IntoElement {
                     return div().into_any_element();
                 };
                 let key = record.config_key.clone();
+                let light_enabled = cx.try_global::<AppState>().is_some_and(|state| {
+                    record.kind == DeviceKind::Light && state.light_enabled_for(&record.config_key)
+                });
+                let light_settings = cx
+                    .try_global::<AppState>()
+                    .map_or_else(LightSettings::default, |state| {
+                        state.light_for(&record.config_key)
+                    });
                 let glow = cx
                     .try_global::<AppState>()
                     .and_then(|s| keyboard_glow(s, &record));
                 let view = view.clone();
-                device_card(&record, focused, glow, pal)
+                device_card(&record, focused, glow, light_enabled, light_settings, pal)
                     .id(("device-card", idx))
                     .active(gpui::Styled::shadow_2xs)
                     .role(Role::Button)
@@ -203,6 +213,8 @@ fn device_card(
     record: &DeviceRecord,
     active: bool,
     glow: Option<(Arc<GlowGeometry>, Hsla)>,
+    light_enabled: bool,
+    light_settings: LightSettings,
     pal: Palette,
 ) -> Div {
     v_flex()
@@ -228,11 +240,12 @@ fn device_card(
                 .flex()
                 .items_center()
                 .justify_center()
+                .overflow_hidden()
                 .opacity(if record.online { 1. } else { 0.55 })
                 .when_some(glow, |this, (geom, color)| {
                     this.child(glow_canvas(geom, color))
                 })
-                .child(device_image(record, pal)),
+                .child(device_image(record, light_enabled, light_settings, pal)),
         )
         .child(
             v_flex()
@@ -265,11 +278,13 @@ fn device_card(
                                 .truncate()
                                 .text_caption()
                                 .text_color(pal.text_muted)
-                                .child(format!(
-                                    "{} · slot {}",
-                                    kind_label(record.kind),
-                                    record.slot
-                                )),
+                                .child(if matches!(record.kind, DeviceKind::Camera) {
+                                    // A camera's synthetic slot 0 means nothing
+                                    // next to real receiver slots.
+                                    kind_label(record.kind)
+                                } else {
+                                    format!("{} · slot {}", kind_label(record.kind), record.slot)
+                                }),
                         )
                         .child(
                             h_flex()
@@ -278,10 +293,15 @@ fn device_card(
                                 .gap_1p5()
                                 .child(
                                     svg()
-                                        .path(connection_icon_path(
-                                            record.route.as_ref(),
-                                            record.model_info.as_ref().map(|m| &m.transports),
-                                        ))
+                                        .path(if matches!(record.kind, DeviceKind::Camera) {
+                                            // UVC cameras are always on the cable.
+                                            "action-icons/usb.svg"
+                                        } else {
+                                            connection_icon_path(
+                                                record.route.as_ref(),
+                                                record.model_info.as_ref().map(|m| &m.transports),
+                                            )
+                                        })
                                         .size_3()
                                         .flex_none()
                                         .text_color(pal.text_muted),
@@ -302,21 +322,42 @@ fn device_card(
 /// fall back to the raw pixel dimensions when the box can't fully constrain it,
 /// which (with an `overflow_hidden` parent) cropped the device into a zoomed
 /// close-up. `object_fit` defaults to `Contain`, so the whole device shows.
-fn device_image(record: &DeviceRecord, pal: Palette) -> AnyElement {
-    match record
+fn device_image(
+    record: &DeviceRecord,
+    light_enabled: bool,
+    light_settings: LightSettings,
+    pal: Palette,
+) -> AnyElement {
+    if record.kind == DeviceKind::Light {
+        return light_visual::gallery(
+            record.asset.as_ref(),
+            record.online,
+            light_enabled,
+            light_settings,
+            pal,
+        );
+    }
+    if let Some(path) = record
         .asset
         .as_ref()
         .and_then(|a| a.hero_image_path.clone())
     {
-        Some(path) => img(path).max_w_full().max_h_full().into_any_element(),
-        None => div()
-            .size_full()
-            .flex()
-            .items_center()
-            .justify_center()
-            .child(Icon::new(IconName::Cpu).size_8().text_color(pal.text_muted))
-            .into_any_element(),
+        return img(path).max_w_full().max_h_full().into_any_element();
     }
+    // Cameras carry no depot asset, so give them a recognisable glyph on their
+    // gallery card instead of the generic chip fallback.
+    let icon = if matches!(record.kind, DeviceKind::Camera) {
+        IconName::Eye
+    } else {
+        IconName::Cpu
+    };
+    div()
+        .size_full()
+        .flex()
+        .items_center()
+        .justify_center()
+        .child(Icon::new(icon).size_8().text_color(pal.text_muted))
+        .into_any_element()
 }
 
 /// Connectivity dot for a gallery card: a steady grey when offline, a green dot
@@ -347,14 +388,17 @@ fn status_dot(online: bool) -> AnyElement {
 /// Battery readout for a gallery card: a charge/level glyph plus the
 /// percentage, in the muted metadata style.
 fn battery_view(b: &BatteryInfo, pal: Palette) -> AnyElement {
-    h_flex()
+    let row = h_flex()
         .gap_1()
         .items_center()
         .text_caption()
         .text_color(pal.text_muted)
-        .child(Icon::new(battery_icon(b)).size_3())
-        .child(format!("{}%", b.percentage))
-        .into_any_element()
+        .child(Icon::new(battery_icon(b)).size_3());
+    if super::widgets::battery_charging_no_reading(b) {
+        row.child(tr!("Charging")).into_any_element()
+    } else {
+        row.child(format!("{}%", b.percentage)).into_any_element()
+    }
 }
 
 /// Pick the battery glyph from charge state first (charging / full / error),
@@ -403,6 +447,7 @@ pub(super) fn connection_icon_path(
             // keep the old default.
             _ => "action-icons/bluetooth.svg",
         },
+        Some(DeviceRoute::RawHid { .. }) => "action-icons/usb.svg",
     }
 }
 
diff --git a/crates/openlogi-gui/src/app/widgets.rs b/crates/openlogi-gui/src/app/widgets.rs
index f36c71119d1905072a84c25db3cff63d93827e79..7a7d917613f6f9fe997805e1c8273efd48df8bb7 100644
--- a/crates/openlogi-gui/src/app/widgets.rs
+++ b/crates/openlogi-gui/src/app/widgets.rs
@@ -18,6 +18,16 @@ use super::AppView;
 use crate::state::AppState;
 use crate::theme::{self, Palette, Typography as _};
 
+/// True when the device is charging but still reports 0% — the MX2S `0x1000`
+/// firmware can't gauge charge under load, and on a cold start there's no
+/// pre-charge % cached to carry forward. Show "Charging" without the bogus 0%.
+pub(crate) fn battery_charging_no_reading(b: &BatteryInfo) -> bool {
+    matches!(
+        b.status,
+        BatteryStatus::Charging | BatteryStatus::ChargingSlow
+    ) && b.percentage == 0
+}
+
 /// "← Back" affordance on the detail screen; returns to the gallery without
 /// changing the active-device selection.
 pub(super) fn back_button(cx: &mut Context<AppView>) -> impl IntoElement {
@@ -147,22 +157,32 @@ pub(super) fn battery_summary(battery: &BatteryInfo, pal: Palette) -> impl IntoE
                 .text_caption()
                 .text_color(pal.text_muted)
                 .child(status)
-                .child(format!("{}%", battery.percentage)),
+                .child(if battery_charging_no_reading(battery) {
+                    String::new()
+                } else {
+                    format!("{}%", battery.percentage)
+                }),
         )
-        .child(
-            div()
+        .child({
+            let track = div()
                 .h(px(6.))
                 .w_full()
                 .rounded_full()
-                .bg(pal.surface_hover)
-                .child(
+                .bg(pal.surface_hover);
+            // Charging with no reliable %: leave the track empty rather than
+            // drawing the 1%-wide red critical sliver that percentage==0 yields.
+            if battery_charging_no_reading(battery) {
+                track
+            } else {
+                track.child(
                     div()
                         .h_full()
                         .w(relative(f32::from(battery.percentage.clamp(1, 100)) / 100.))
                         .rounded_full()
                         .bg(rgb(battery_color(battery.percentage))),
-                ),
-        )
+                )
+            }
+        })
 }
 
 fn battery_color(percentage: u8) -> u32 {
@@ -192,7 +212,9 @@ pub(super) fn route_label(route: Option<&DeviceRoute>) -> String {
     match route {
         Some(DeviceRoute::Bolt { .. }) => tr!("Bolt receiver").to_string(),
         Some(DeviceRoute::Unifying { .. }) => tr!("Unifying receiver").to_string(),
-        Some(DeviceRoute::Direct { .. }) => tr!("Direct connection").to_string(),
+        Some(DeviceRoute::Direct { .. } | DeviceRoute::RawHid { .. }) => {
+            tr!("Direct connection").to_string()
+        }
         None => tr!("Unavailable").to_string(),
     }
 }
@@ -210,6 +232,8 @@ pub(super) fn kind_label(kind: DeviceKind) -> String {
         DeviceKind::Gamepad => tr!("Gamepad").to_string(),
         DeviceKind::Joystick => tr!("Joystick").to_string(),
         DeviceKind::Headset => tr!("Headset").to_string(),
+        DeviceKind::Camera => tr!("Camera").to_string(),
         DeviceKind::Unknown => tr!("Device").to_string(),
+        DeviceKind::Light => tr!("Lighting").to_string(),
     }
 }
diff --git a/crates/openlogi-gui/src/app_assets.rs b/crates/openlogi-gui/src/app_assets.rs
index 28d730c271b80a29514d3ebb394b39090e37873f..acd182a8e79f084a53813b8dd88f0599dcb13672 100644
--- a/crates/openlogi-gui/src/app_assets.rs
+++ b/crates/openlogi-gui/src/app_assets.rs
@@ -1,10 +1,9 @@
 //! The app's GPUI [`AssetSource`].
 //!
-//! Serves the embedded OpenLogi logo and delegates every other path to
+//! Serves source-owned embedded artwork and delegates every other path to
 //! gpui-component's icon assets (the lucide SVGs behind `IconName`). Embedding
-//! the logo via `include_bytes!` means `img("openlogi.png")` resolves the same
-//! inside a packaged `.app` as it does from a dev build — a filesystem path
-//! would not.
+//! these files via `include_bytes!` means they resolve the same inside a
+//! packaged `.app` as they do from a dev build — a filesystem path would not.
 
 use std::borrow::Cow;
 
@@ -71,6 +70,7 @@ const ACTION_ICONS: &[(&str, &[u8])] = &[
     ("action-icons/square-arrow-right.svg", include_bytes!(concat!(env!("CARGO_MANIFEST_DIR"), "/action-icons/square-arrow-right.svg"))),
     ("action-icons/square-plus.svg", include_bytes!(concat!(env!("CARGO_MANIFEST_DIR"), "/action-icons/square-plus.svg"))),
     ("action-icons/square-x.svg", include_bytes!(concat!(env!("CARGO_MANIFEST_DIR"), "/action-icons/square-x.svg"))),
+    ("action-icons/terminal.svg", include_bytes!(concat!(env!("CARGO_MANIFEST_DIR"), "/action-icons/terminal.svg"))),
     ("action-icons/undo-2.svg", include_bytes!(concat!(env!("CARGO_MANIFEST_DIR"), "/action-icons/undo-2.svg"))),
     ("action-icons/unifying.svg", include_bytes!(concat!(env!("CARGO_MANIFEST_DIR"), "/action-icons/unifying.svg"))),
     ("action-icons/usb.svg", include_bytes!(concat!(env!("CARGO_MANIFEST_DIR"), "/action-icons/usb.svg"))),
diff --git a/crates/openlogi-gui/src/app_menu.rs b/crates/openlogi-gui/src/app_menu.rs
index d718c3f608b6657570c5a56b50fa21f5e7bc5c41..996295835edbd1460891d917226cc7c43dc81d12 100644
--- a/crates/openlogi-gui/src/app_menu.rs
+++ b/crates/openlogi-gui/src/app_menu.rs
@@ -220,6 +220,9 @@ fn device_menu_items(cx: &App) -> Vec<MenuItem> {
         Some(state) if !state.device_list.is_empty() => {
             for record in &state.device_list {
                 let title = match &record.battery {
+                    Some(battery) if crate::app::battery_charging_no_reading(battery) => {
+                        format!("{} · {}", record.display_name, tr!("Charging"))
+                    }
                     Some(battery) => format!("{} · {}%", record.display_name, battery.percentage),
                     None => record.display_name.clone(),
                 };
diff --git a/crates/openlogi-gui/src/asset.rs b/crates/openlogi-gui/src/asset.rs
index a2c6988d35305d1822cbc6a1ade01e091fec9c18..9a8ae97e404ca00bbfa38b0b319100e3f2cfc5e6 100644
--- a/crates/openlogi-gui/src/asset.rs
+++ b/crates/openlogi-gui/src/asset.rs
@@ -23,6 +23,7 @@ pub(crate) use self::glow::GlowGeometry;
 use std::path::{Path, PathBuf};
 use std::sync::Arc;
 
+use openlogi_assets::http::safe_component_path;
 use openlogi_assets::{
     BUTTONS_RENDER_FILES, DeviceEntry, FRONT_RENDER_FILES, Index, METADATA_FILES, Metadata,
 };
@@ -200,6 +201,19 @@ impl AssetResolver {
         self.load_files(depot, entry, model)
     }
 
+    /// Resolve a standalone device directly by its registry model id.
+    ///
+    /// Standalone raw-HID devices do not expose a HID++ `DeviceModelInfo`, so
+    /// constructing one just to reuse [`Self::resolve`] would conflate a
+    /// physical protocol identity with a model-level asset identity. The
+    /// registry lookup remains exact and case-insensitive, while all local
+    /// filenames still pass through the same safe component checks.
+    pub fn resolve_registry_model(&self, registry_model_id: &str) -> Option<ResolvedAsset> {
+        let index = self.index.as_ref()?;
+        let (depot, entry) = index.find_by_model_id(registry_model_id)?;
+        self.load_standalone_files(depot, entry, registry_model_id)
+    }
+
     fn load_files(
         &self,
         depot: &str,
@@ -207,7 +221,13 @@ impl AssetResolver {
         model: &DeviceModelInfo,
     ) -> Option<ResolvedAsset> {
         for root in &self.read_roots {
-            let dir = root.join(depot);
+            let Ok(dir) = safe_component_path(root, depot, "asset depot") else {
+                warn!(
+                    depot,
+                    "unsafe asset depot component — ignoring registry entry"
+                );
+                continue;
+            };
             // Hotspot metadata in whichever schema this depot cached:
             // `core_metadata.json` (newer) or `metadata.json` (older).
             let Some(&meta_name) = METADATA_FILES.iter().find(|n| dir.join(n).exists()) else {
@@ -246,7 +266,7 @@ impl AssetResolver {
                 .clone()
                 .into_iter()
                 .chain(FRONT_RENDER_FILES.map(str::to_string))
-                .map(|n| dir.join(n))
+                .filter_map(|n| safe_component_path(&dir, &n, "asset file").ok())
                 .find(|p| p.exists());
             let image_name = buttons_name
                 .clone()
@@ -261,7 +281,10 @@ impl AssetResolver {
             candidates.extend(BUTTONS_RENDER_FILES.map(str::to_string));
             candidates.extend(variant_front_name);
             candidates.extend(FRONT_RENDER_FILES.map(str::to_string));
-            let Some(image_path) = candidates.iter().map(|n| dir.join(n)).find(|p| p.exists())
+            let Some(image_path) = candidates
+                .iter()
+                .filter_map(|n| safe_component_path(&dir, n, "asset file").ok())
+                .find(|p| p.exists())
             else {
                 continue;
             };
@@ -297,13 +320,20 @@ impl AssetResolver {
                 png_height,
                 "asset hit"
             );
+            let kind = DeviceKind::from_registry_type(&entry.kind);
+            // Only keyboards paint the inter-key glow, and the runtime
+            // fallback decodes the full render — don't pay that for mice.
+            let glow = (kind == DeviceKind::Keyboard)
+                .then(|| self::glow::resolve_glow_geometry(&dir, &image_path))
+                .flatten()
+                .map(Arc::new);
             return Some(ResolvedAsset {
                 depot: depot.to_string(),
                 display_name: entry.display_name.clone(),
-                kind: DeviceKind::from_registry_type(&entry.kind),
+                kind,
                 image_path,
                 hero_image_path,
-                glow: self::glow::load_glow_geometry(&dir).map(Arc::new),
+                glow,
                 metadata,
                 png_width,
                 png_height,
@@ -312,6 +342,58 @@ impl AssetResolver {
         debug!(depot, "asset cache miss across all roots");
         None
     }
+
+    fn load_standalone_files(
+        &self,
+        depot: &str,
+        entry: &DeviceEntry,
+        registry_model_id: &str,
+    ) -> Option<ResolvedAsset> {
+        for root in &self.read_roots {
+            let Ok(dir) = safe_component_path(root, depot, "asset depot") else {
+                continue;
+            };
+            let manifest = load_manifest(&dir);
+            let Some(image_name) = manifest
+                .as_ref()
+                .and_then(|manifest| manifest.device_image_for(registry_model_id))
+                .or_else(|| entry.preferred_file(&FRONT_RENDER_FILES))
+            else {
+                continue;
+            };
+            let Ok(image_path) = safe_component_path(&dir, image_name, "asset file") else {
+                continue;
+            };
+            if !image_path.is_file() {
+                continue;
+            }
+            let Ok((png_width, png_height)) = read_png_dimensions(&image_path) else {
+                continue;
+            };
+            debug!(
+                depot,
+                root = %root.display(),
+                image = image_name,
+                "standalone asset hit"
+            );
+            return Some(ResolvedAsset {
+                depot: depot.to_owned(),
+                display_name: entry.display_name.clone(),
+                kind: DeviceKind::from_registry_type(&entry.kind),
+                image_path: image_path.clone(),
+                hero_image_path: Some(image_path),
+                glow: None,
+                // Standalone-light rendering intentionally consumes only the
+                // verified front image; shared metadata remains for HID++
+                // button hotspots in `load_files`.
+                metadata: Metadata::default(),
+                png_width,
+                png_height,
+            });
+        }
+        debug!(depot, "standalone asset cache miss across all roots");
+        None
+    }
 }
 
 impl Default for AssetResolver {
@@ -546,6 +628,180 @@ mod tests {
         assert_eq!(asset.metadata.assignments().count(), 1);
     }
 
+    #[test]
+    fn resolves_standalone_registry_model_without_synthetic_hidpp_info() {
+        let root = tempfile::tempdir().expect("create temp dir");
+        let depot = root.path().join("litra_glow");
+        std::fs::create_dir_all(&depot).expect("create depot dir");
+        std::fs::write(
+            depot.join("manifest.json"),
+            r#"{"devices":[{"modelId":"8c900","resources":[{"key":"device_image","src":"front.png"}]}],"resources":[]}"#,
+        )
+        .expect("write manifest");
+        std::fs::write(depot.join("front.png"), png_header(396, 396)).expect("write front");
+
+        let index = index_of(
+            "litra_glow",
+            DeviceEntry {
+                model_id: "8c900".into(),
+                model_ids: vec![],
+                display_name: "Litra Glow".into(),
+                kind: "ILLUMINATION_LIGHT".into(),
+                asset_path: "v1/devices/litra_glow/".into(),
+                files: vec![],
+            },
+        );
+        let resolver = AssetResolver {
+            read_roots: vec![root.path().to_path_buf()],
+            write_root: root.path().to_path_buf(),
+            has_bundle: false,
+            index: Some(index),
+        };
+
+        let asset = resolver
+            .resolve_registry_model("8c900")
+            .expect("standalone registry model should resolve");
+        assert_eq!(asset.display_name, "Litra Glow");
+        assert_eq!(asset.kind, DeviceKind::Light);
+        assert_eq!(asset.image_path, depot.join("front.png"));
+        assert_eq!((asset.png_width, asset.png_height), (396, 396));
+    }
+
+    #[test]
+    fn standalone_registry_lookup_does_not_cross_model_depots() {
+        let root = tempfile::tempdir().expect("create temp dir");
+        let depot = root.path().join("litra_beam");
+        std::fs::create_dir_all(&depot).expect("create depot dir");
+        std::fs::write(
+            depot.join("manifest.json"),
+            r#"{"devices":[{"modelId":"8c901","resources":[{"key":"device_image","src":"front.png"}]}],"resources":[]}"#,
+        )
+        .expect("write manifest");
+        std::fs::write(depot.join("front.png"), png_header(120, 240)).expect("write front");
+        let index = Index {
+            schema_version: 1,
+            devices: HashMap::from([
+                (
+                    "litra_glow".into(),
+                    DeviceEntry {
+                        model_id: "8c900".into(),
+                        model_ids: vec![],
+                        display_name: "Litra Glow".into(),
+                        kind: "ILLUMINATION_LIGHT".into(),
+                        asset_path: "v1/devices/litra_glow/".into(),
+                        files: vec![],
+                    },
+                ),
+                (
+                    "litra_beam".into(),
+                    DeviceEntry {
+                        model_id: "8c901".into(),
+                        model_ids: vec![],
+                        display_name: "Litra Beam".into(),
+                        kind: "ILLUMINATION_LIGHT".into(),
+                        asset_path: "v1/devices/litra_beam/".into(),
+                        files: vec![],
+                    },
+                ),
+            ]),
+        };
+        let resolver = AssetResolver {
+            read_roots: vec![root.path().to_path_buf()],
+            write_root: root.path().to_path_buf(),
+            has_bundle: false,
+            index: Some(index),
+        };
+
+        assert!(resolver.resolve_registry_model("8c900").is_none());
+        assert_eq!(
+            resolver
+                .resolve_registry_model("8c901")
+                .expect("beam should resolve")
+                .display_name,
+            "Litra Beam"
+        );
+    }
+
+    #[test]
+    fn unsafe_standalone_manifest_filename_is_rejected() {
+        let root = tempfile::tempdir().expect("create temp dir");
+        let depot = root.path().join("litra_glow");
+        std::fs::create_dir_all(&depot).expect("create depot dir");
+        std::fs::write(
+            depot.join("manifest.json"),
+            r#"{"devices":[{"modelId":"8c900","resources":[{"key":"device_image","src":"../front.png"}]}],"resources":[]}"#,
+        )
+        .expect("write manifest");
+        std::fs::write(root.path().join("front.png"), png_header(1, 1)).expect("write escape");
+        let resolver = AssetResolver {
+            read_roots: vec![root.path().to_path_buf()],
+            write_root: root.path().to_path_buf(),
+            has_bundle: false,
+            index: Some(index_of(
+                "litra_glow",
+                DeviceEntry {
+                    model_id: "8c900".into(),
+                    model_ids: vec![],
+                    display_name: "Litra Glow".into(),
+                    kind: "ILLUMINATION_LIGHT".into(),
+                    asset_path: "v1/devices/litra_glow/".into(),
+                    files: vec![openlogi_assets::FileEntry {
+                        name: "front.png".into(),
+                        sha256: String::new(),
+                        bytes: 0,
+                    }],
+                },
+            )),
+        };
+        assert!(resolver.resolve_registry_model("8c900").is_none());
+    }
+
+    #[test]
+    fn standalone_resolution_prefers_the_first_read_root() {
+        let roots = [
+            tempfile::tempdir().expect("create bundle root"),
+            tempfile::tempdir().expect("create cache root"),
+        ];
+        for (root, dimensions) in roots.iter().zip([(10, 10), (20, 20)]) {
+            let depot = root.path().join("litra_glow");
+            std::fs::create_dir_all(&depot).expect("create depot dir");
+            std::fs::write(
+                depot.join("front.png"),
+                png_header(dimensions.0, dimensions.1),
+            )
+            .expect("write front");
+        }
+        let resolver = AssetResolver {
+            read_roots: roots.iter().map(|root| root.path().to_path_buf()).collect(),
+            write_root: roots[1].path().to_path_buf(),
+            has_bundle: true,
+            index: Some(index_of(
+                "litra_glow",
+                DeviceEntry {
+                    model_id: "8c900".into(),
+                    model_ids: vec![],
+                    display_name: "Litra Glow".into(),
+                    kind: "ILLUMINATION_LIGHT".into(),
+                    asset_path: "v1/devices/litra_glow/".into(),
+                    files: vec![openlogi_assets::FileEntry {
+                        name: "front.png".into(),
+                        sha256: String::new(),
+                        bytes: 0,
+                    }],
+                },
+            )),
+        };
+
+        let asset = resolver
+            .resolve_registry_model("8c900")
+            .expect("bundle asset should resolve");
+        assert_eq!((asset.png_width, asset.png_height), (10, 10));
+        assert_eq!(
+            asset.image_path,
+            roots[0].path().join("litra_glow/front.png")
+        );
+    }
+
     #[test]
     fn cleanup_removes_only_legacy_glow_pngs() {
         let root = tempfile::tempdir().expect("create temp dir");
diff --git a/crates/openlogi-gui/src/asset/glow.rs b/crates/openlogi-gui/src/asset/glow.rs
index 08d3d75a4328ba9210465ebad6ef2db6aaaecb19..081219a9fb9cd354411c655587ad75b17a225749 100644
--- a/crates/openlogi-gui/src/asset/glow.rs
+++ b/crates/openlogi-gui/src/asset/glow.rs
@@ -19,7 +19,13 @@ use serde::Deserialize;
 use tracing::warn;
 
 /// Metadata files to read the precomputed mask from, newest schema first.
-const META_FILES: [&str; 2] = ["core_metadata.json", "metadata.json"];
+const META_FILES: [&str; 3] = ["core_metadata.json", "metadata_full.json", "metadata.json"];
+
+/// Ceiling on a runtime-derived mask's width — the same ~1k scale as the
+/// pipeline-baked masks, and what keeps the flood fill cheap.
+const COMPUTED_MASK_MAX_W: u32 = 1024;
+/// Alpha below this counts as see-through when deriving holes from a render.
+const HOLE_ALPHA: u8 = 96;
 
 /// Sanity bound on a baked mask's stored dimensions. The masks are ~1k px wide;
 /// anything far larger is a corrupt or hostile `metadata.json`. The cap also
@@ -62,9 +68,17 @@ pub(crate) struct GlowGeometry {
     pub segments: Vec<GlowSeg>,
 }
 
+/// The inter-key hole geometry for a depot: the pipeline-baked mask when the
+/// metadata ships one, otherwise derived at resolve time from the render's own
+/// alpha channel — so any keyboard with a transparent render glows, not just
+/// the depots the asset pipeline has processed.
+pub(crate) fn resolve_glow_geometry(dir: &Path, image_path: &Path) -> Option<GlowGeometry> {
+    load_glow_geometry(dir).or_else(|| compute_glow_geometry(image_path))
+}
+
 /// Load and decode the precomputed glow mask from a depot directory's metadata.
-/// `None` when the depot ships no mask (the feature gate) or it's malformed.
-pub(crate) fn load_glow_geometry(dir: &Path) -> Option<GlowGeometry> {
+/// `None` when the depot ships no mask or it's malformed.
+fn load_glow_geometry(dir: &Path) -> Option<GlowGeometry> {
     let mask = META_FILES.iter().find_map(|name| {
         let text = std::fs::read_to_string(dir.join(name)).ok()?;
         serde_json::from_str::<MetaGlow>(&text).ok()?.glow
@@ -72,6 +86,93 @@ pub(crate) fn load_glow_geometry(dir: &Path) -> Option<GlowGeometry> {
     GlowGeometry::from_mask(&mask)
 }
 
+/// Derive the inter-key holes straight from the render's alpha channel:
+/// flood-fill the see-through field inward from the image border, and whatever
+/// see-through cells remain unreached are enclosed by the silhouette — the
+/// holes. The image is binned to ≤[`COMPUTED_MASK_MAX_W`] cells wide; a cell
+/// is see-through when *any* source pixel in its bin is, so the few-pixel
+/// slits between floating keycaps survive the binning. Border-connected
+/// transparency (including background reachable through open seams) is
+/// "outside" and never glows, which is what keeps the colour inside the
+/// silhouette.
+fn compute_glow_geometry(image_path: &Path) -> Option<GlowGeometry> {
+    let img = image::open(image_path).ok()?.into_rgba8();
+    let (src_w, src_h) = img.dimensions();
+    if src_w == 0 || src_h == 0 || src_w > MAX_MASK_DIM || src_h > MAX_MASK_DIM {
+        return None;
+    }
+    let scale = src_w.div_ceil(COMPUTED_MASK_MAX_W).max(1);
+    let (w, h) = (src_w.div_ceil(scale), src_h.div_ceil(scale));
+
+    // 0 = opaque, 1 = see-through, 2 = see-through and border-connected.
+    let mut cells = vec![0u8; (w as usize) * (h as usize)];
+    for (x, y, pixel) in img.enumerate_pixels() {
+        if pixel.0[3] < HOLE_ALPHA {
+            cells[((y / scale) * w + (x / scale)) as usize] = 1;
+        }
+    }
+
+    let mut queue: std::collections::VecDeque<(u32, u32)> = (0..w)
+        .flat_map(|x| [(x, 0), (x, h - 1)])
+        .chain((0..h).flat_map(|y| [(0, y), (w - 1, y)]))
+        .filter(|&(x, y)| cells[(y * w + x) as usize] == 1)
+        .collect();
+    for &(x, y) in &queue {
+        cells[(y * w + x) as usize] = 2;
+    }
+    while let Some((x, y)) = queue.pop_front() {
+        let neighbors = [
+            (x.wrapping_sub(1), y),
+            (x + 1, y),
+            (x, y.wrapping_sub(1)),
+            (x, y + 1),
+        ];
+        for (nx, ny) in neighbors {
+            if nx < w && ny < h && cells[(ny * w + nx) as usize] == 1 {
+                cells[(ny * w + nx) as usize] = 2;
+                queue.push_back((nx, ny));
+            }
+        }
+    }
+
+    #[allow(
+        clippy::cast_precision_loss,
+        reason = "mask coords are < 8192 px — well within f32 mantissa"
+    )]
+    let (wf, hf) = (w as f32, h as f32);
+    let mut segments = Vec::new();
+    for y in 0..h {
+        let mut x = 0;
+        while x < w {
+            if cells[(y * w + x) as usize] == 1 {
+                let start = x;
+                while x < w && cells[(y * w + x) as usize] == 1 {
+                    x += 1;
+                }
+                #[allow(
+                    clippy::cast_precision_loss,
+                    reason = "mask coords are < 8192 px — well within f32 mantissa"
+                )]
+                segments.push(GlowSeg {
+                    x: start as f32 / wf,
+                    y: y as f32 / hf,
+                    w: (x - start) as f32 / wf,
+                    h: 1.0 / hf,
+                });
+            } else {
+                x += 1;
+            }
+        }
+    }
+    if segments.is_empty() {
+        return None;
+    }
+    Some(GlowGeometry {
+        aspect: wf / hf,
+        segments,
+    })
+}
+
 impl GlowGeometry {
     /// Decode the RLE mask into normalized per-row hole segments. A run that
     /// crosses a row boundary is split so every segment stays on one row.
@@ -170,4 +271,68 @@ mod tests {
         };
         assert!(GlowGeometry::from_mask(&mask).is_none());
     }
+
+    /// Write an RGBA png where `1` cells are solid and the rest fully
+    /// transparent.
+    fn write_png(dir: &std::path::Path, name: &str, rows: &[&[u8]]) -> std::path::PathBuf {
+        let h = u32::try_from(rows.len()).expect("test image height fits u32");
+        let w = u32::try_from(rows[0].len()).expect("test image width fits u32");
+        let mut img = image::RgbaImage::new(w, h);
+        for (y, row) in rows.iter().enumerate() {
+            for (x, &cell) in row.iter().enumerate() {
+                let alpha = if cell == 1 { 255 } else { 0 };
+                let (x, y) = (
+                    u32::try_from(x).expect("test x fits u32"),
+                    u32::try_from(y).expect("test y fits u32"),
+                );
+                img.put_pixel(x, y, image::Rgba([40, 40, 40, alpha]));
+            }
+        }
+        let path = dir.join(name);
+        img.save(&path).expect("write png");
+        path
+    }
+
+    #[test]
+    fn computed_geometry_finds_only_enclosed_holes() {
+        let dir = tempfile::tempdir().expect("tempdir");
+        // A ring of opaque pixels around one transparent pixel (a hole), with
+        // border-connected transparency everywhere else.
+        let path = write_png(
+            dir.path(),
+            "ring.png",
+            &[
+                &[0, 0, 0, 0, 0],
+                &[0, 1, 1, 1, 0],
+                &[0, 1, 0, 1, 0],
+                &[0, 1, 1, 1, 0],
+                &[0, 0, 0, 0, 0],
+            ],
+        );
+        let geom = compute_glow_geometry(&path).expect("hole found");
+        assert_eq!(geom.segments.len(), 1);
+        let seg = geom.segments[0];
+        assert!((seg.x - 0.4).abs() < 1e-6, "hole at col 2 of 5");
+        assert!((seg.y - 0.4).abs() < 1e-6, "hole at row 2 of 5");
+        assert!((geom.aspect - 1.0).abs() < 1e-6);
+    }
+
+    #[test]
+    fn computed_geometry_ignores_border_connected_transparency() {
+        let dir = tempfile::tempdir().expect("tempdir");
+        // A C-shape: the notch opens to the border, so nothing is enclosed.
+        let path = write_png(
+            dir.path(),
+            "open.png",
+            &[&[1, 1, 1], &[1, 0, 0], &[1, 1, 1]],
+        );
+        assert!(compute_glow_geometry(&path).is_none());
+    }
+
+    #[test]
+    fn computed_geometry_skips_fully_opaque_renders() {
+        let dir = tempfile::tempdir().expect("tempdir");
+        let path = write_png(dir.path(), "solid.png", &[&[1, 1], &[1, 1]]);
+        assert!(compute_glow_geometry(&path).is_none());
+    }
 }
diff --git a/crates/openlogi-gui/src/asset/images.rs b/crates/openlogi-gui/src/asset/images.rs
index fb0b64220a06484035070cd95802cddd23406820..f1774cfe42b27d921e5b7c6ba688b3002ec4de46 100644
--- a/crates/openlogi-gui/src/asset/images.rs
+++ b/crates/openlogi-gui/src/asset/images.rs
@@ -39,9 +39,10 @@ pub(super) fn read_png_dimensions(path: &Path) -> std::io::Result<(u32, u32)> {
 }
 
 /// Look up the colour variant matching `ext` in an already-loaded depot
-/// manifest. Returns the `device_image` src filename or `None` when the
-/// manifest lacks that variant. Pure — the caller loads the manifest once
-/// (see [`load_manifest`]) and reuses it across candidate bases.
+/// manifest. Returns the `device_image` src filename — falling back to
+/// `device_camera_image`, the hero-render key webcam depots use instead — or
+/// `None` when the manifest lacks that variant. Pure — the caller loads the
+/// manifest once (see [`load_manifest`]) and reuses it across candidate bases.
 pub(super) fn variant_image_for(
     manifest: &DepotManifest,
     base_model_id: &str,
@@ -49,6 +50,7 @@ pub(super) fn variant_image_for(
 ) -> Option<String> {
     manifest
         .resource_for_variant(base_model_id, ext, "device_image")
+        .or_else(|| manifest.resource_for_variant(base_model_id, ext, "device_camera_image"))
         .map(str::to_string)
 }
 
diff --git a/crates/openlogi-gui/src/asset/sync.rs b/crates/openlogi-gui/src/asset/sync.rs
index 989bbbde28d272579424b393bddc3b7f3032bce7..f156a95453d7fbf85721d7c2818aea58fd72573c 100644
--- a/crates/openlogi-gui/src/asset/sync.rs
+++ b/crates/openlogi-gui/src/asset/sync.rs
@@ -51,10 +51,42 @@ pub fn should_run(has_bundle: bool) -> bool {
 /// Each entry pairs a device's HID++ model info with its firmware `codename`,
 /// so the depot match can fall back to the registry `displayName` for devices
 /// whose live PID isn't in the registry (e.g. an MX Master 3S over BTLE).
-pub fn sync(
-    source: Option<AssetSource>,
-    models: &[(DeviceModelInfo, Option<String>)],
-) -> Result<()> {
+/// One model-level asset lookup requested by the GUI.
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub(crate) enum AssetTarget {
+    /// HID++ lookup, retaining the existing codename/variant behavior.
+    Hidpp {
+        /// HID++ model information used for registry matching.
+        model: DeviceModelInfo,
+        /// Firmware codename used as the final matching fallback.
+        codename: Option<String>,
+    },
+    /// Standalone raw-HID lookup by the driver-provided registry identity.
+    Standalone {
+        /// Exact model-level registry id, never a physical-device key.
+        registry_model_id: String,
+    },
+}
+
+/// Stable session key for one model-level asset target.
+#[must_use]
+pub(crate) fn model_key(target: &AssetTarget) -> String {
+    match target {
+        AssetTarget::Hidpp { model, codename } => format!(
+            "hidpp:{:02x}:{:04x}:{:04x}:{:04x}:{}",
+            model.extended_model_id,
+            model.model_ids[0],
+            model.model_ids[1],
+            model.model_ids[2],
+            codename.as_deref().unwrap_or_default()
+        ),
+        AssetTarget::Standalone { registry_model_id } => {
+            format!("standalone:model:{registry_model_id}")
+        }
+    }
+}
+
+pub fn sync(source: Option<AssetSource>, targets: &[AssetTarget]) -> Result<()> {
     let cache_root = super::paths::user_cache_root();
     fs::create_dir_all(&cache_root)
         .with_context(|| format!("create cache root {}", cache_root.display()))?;
@@ -71,31 +103,45 @@ pub fn sync(
     // depot sync can fetch the right colour variant. `OPENLOGI_FORCE_DEPOT`
     // doesn't correspond to a physical device, so we pass `ext = 0`
     // and end up with the base PNG.
-    let mut targets: Vec<(String, DeviceEntry, u8)> = Vec::new();
+    let mut depot_targets: Vec<(String, DeviceEntry, u8)> = Vec::new();
     if let Ok(forced) = std::env::var("OPENLOGI_FORCE_DEPOT")
         && let Some(entry) = index.devices.get(&forced)
     {
-        targets.push((forced, entry.clone(), 0));
+        depot_targets.push((forced, entry.clone(), 0));
     }
-    for (model, codename) in models {
-        if let Some((depot, entry)) = super::resolve_in_index(index, model, codename.as_deref()) {
-            targets.push((depot.to_string(), entry.clone(), model.extended_model_id));
+    for target in targets {
+        let match_result = match target {
+            AssetTarget::Hidpp { model, codename } => {
+                super::resolve_in_index(index, model, codename.as_deref())
+                    .map(|(depot, entry)| (depot, entry, model.extended_model_id))
+            }
+            AssetTarget::Standalone { registry_model_id } => index
+                .find_by_model_id(registry_model_id)
+                .map(|(depot, entry)| (depot, entry, 0)),
+        };
+        if let Some((depot, entry, ext)) = match_result {
+            depot_targets.push((depot.to_string(), entry.clone(), ext));
+        } else if let AssetTarget::Standalone { registry_model_id } = target {
+            info!(
+                registry_model_id,
+                "standalone model is not registered — using fallback art"
+            );
         }
     }
-    targets.sort_by(|a, b| a.0.cmp(&b.0));
-    targets.dedup_by(|a, b| a.0 == b.0);
+    depot_targets.sort_by(|a, b| a.0.cmp(&b.0));
+    depot_targets.dedup_by(|a, b| a.0 == b.0);
 
-    if targets.is_empty() {
+    if depot_targets.is_empty() {
         debug!("sync: no matching depots for known devices");
         return Ok(());
     }
 
-    for (depot, entry, ext) in &targets {
+    for (depot, entry, ext) in &depot_targets {
         if let Err(e) = sync_depot(client, &cache_root, depot, entry, *ext) {
             warn!(depot, error = %e, "depot sync failed");
         }
     }
-    info!(devices = targets.len(), "asset sync complete");
+    info!(devices = depot_targets.len(), "asset sync complete");
     Ok(())
 }
 
@@ -126,13 +172,18 @@ fn sync_depot(
         warn!(depot, error = %e, "buttons render fetch failed");
     }
 
-    // Optional second pass: download the colour variant PNGs matching
-    // the connected device's `extended_model_id`, for both the front
-    // (carousel) and the side / buttons (mouse-model) views. Failure is
-    // non-fatal — `AssetResolver.load_files` falls back to the bare hero
-    // render that came in with the baseline fetch above.
+    // Optional second pass: download the manifest-mapped render PNGs — the
+    // colour variant matching the device's `extended_model_id` for the front
+    // (carousel) and side / buttons (mouse-model) views, plus the camera hero
+    // (`device_camera_image` — camera depots ship no bare `front*.png`, so the
+    // baseline fetch above brings no render for them at all). Failure is
+    // non-fatal — `AssetResolver.load_files` falls back to whatever landed.
     let manifest_path = dir.join("manifest.json");
-    for resource_key in ["device_image", "device_buttons_image"] {
+    for resource_key in [
+        "device_image",
+        "device_buttons_image",
+        "device_camera_image",
+    ] {
         let Some(variant) =
             pick_variant_filename(&manifest_path, &entry.model_id, ext, resource_key)
         else {
@@ -178,15 +229,17 @@ fn fetch_to_cache(
 
 /// Parse a freshly-downloaded `manifest.json` and resolve the colour
 /// variant filename for `resource_key` (e.g. `"device_image"` or
-/// `"device_buttons_image"`). `None` when the manifest is missing,
-/// malformed, or doesn't list the device's `ext` byte.
+/// `"device_camera_image"`). `ext == 0` resolves the base-model entry —
+/// needed for depots whose base render isn't a baseline `front*.png` (the
+/// caller's skip list keeps already-fetched baseline names from re-fetching).
+/// `None` when the manifest is missing, malformed, or lacks the variant.
 fn pick_variant_filename(
     manifest_path: &Path,
     base_model_id: &str,
     ext: u8,
     resource_key: &str,
 ) -> Option<String> {
-    if ext == 0 || !manifest_path.exists() {
+    if !manifest_path.exists() {
         return None;
     }
     let manifest = DepotManifest::load_from(manifest_path)
@@ -210,17 +263,6 @@ pub(crate) struct SyncOutcome {
 /// extended-model byte (the colour-variant selector) and the codename the
 /// depot match falls back on. Models that collapse to one key would resolve
 /// to the same depot files anyway.
-pub(crate) fn model_key((model, codename): &(DeviceModelInfo, Option<String>)) -> String {
-    format!(
-        "{:02x}:{:04x}:{:04x}:{:04x}:{}",
-        model.extended_model_id,
-        model.model_ids[0],
-        model.model_ids[1],
-        model.model_ids[2],
-        codename.as_deref().unwrap_or_default()
-    )
-}
-
 /// A manual asset action requested from the Settings → Assets tab, pushed to
 /// the main event loop via [`AssetControl`].
 pub enum AssetCommand {
@@ -258,13 +300,10 @@ pub(crate) fn sync_retry_delay(attempts: u32) -> Duration {
 /// startup plus the auto-download setting; the Settings → Assets manual
 /// actions always fetch, even in a release build that would otherwise serve
 /// only bundled art.)
-pub(crate) fn run_asset_sync(
-    preference: AssetSourcePreference,
-    models: &[(DeviceModelInfo, Option<String>)],
-) -> bool {
+pub(crate) fn run_asset_sync(preference: AssetSourcePreference, targets: &[AssetTarget]) -> bool {
     let server = std::env::var("OPENLOGI_ASSETS").ok();
     let source = source_for_sync(preference, server.as_deref());
-    match sync(source, models) {
+    match sync(source, targets) {
         Ok(()) => true,
         Err(e) => {
             warn!(error = ?e, "asset sync failed — will retry with backoff");
@@ -290,7 +329,7 @@ fn source_for_sync(
 
 #[cfg(test)]
 mod tests {
-    use super::{source_for_sync, sync_retry_delay};
+    use super::{AssetTarget, model_key, source_for_sync, sync_retry_delay};
     use openlogi_assets::AssetSource;
     use openlogi_core::config::AssetSourcePreference;
     use std::time::Duration;
@@ -342,4 +381,14 @@ mod tests {
             ))
         );
     }
+
+    #[test]
+    fn standalone_target_key_is_model_scoped_not_physical() {
+        assert_eq!(
+            model_key(&AssetTarget::Standalone {
+                registry_model_id: "8c900".into(),
+            }),
+            "standalone:model:8c900"
+        );
+    }
 }
diff --git a/crates/openlogi-gui/src/components/camera_controls.rs b/crates/openlogi-gui/src/components/camera_controls.rs
new file mode 100644
index 0000000000000000000000000000000000000000..e480b2eafc8d31fab6daf68c8bd4ed22b4370075
--- /dev/null
+++ b/crates/openlogi-gui/src/components/camera_controls.rs
@@ -0,0 +1,998 @@
+//! Camera controls for the Camera tab: lens (zoom/focus/exposure) and image
+//! (brightness/contrast/…) sliders, auto toggles, and profiles.
+//!
+//! Each slider drives a UVC control straight on the device, so a change is
+//! seen by every app that opens the camera — Google Meet, Zoom, OBS — not just
+//! our preview. Values are persisted per-camera and re-applied over USB when
+//! the camera is next viewed, since the hardware only holds them until it
+//! loses power. Focus/exposure/white-balance carry an Auto chip mirroring the
+//! device's auto modes; their sliders disable while auto owns the value.
+//!
+//! Profiles are one-click control snapshots: three built-ins (Default /
+//! Streaming / Video call) plus user-saved customs, applied to the hardware in
+//! a single batched device-open.
+
+#![allow(
+    clippy::cast_possible_truncation,
+    clippy::cast_precision_loss,
+    clippy::cast_sign_loss,
+    reason = "UVC control values are small integers; slider math goes through f32"
+)]
+
+use gpui::{
+    AnyElement, AppContext as _, BorrowAppContext as _, ClickEvent, Context, Entity,
+    InteractiveElement, IntoElement, MouseButton, MouseDownEvent, ParentElement, Render,
+    SharedString, StatefulInteractiveElement as _, Styled, Subscription, Window, div,
+    prelude::FluentBuilder as _, px, rgb,
+};
+use gpui_component::{
+    h_flex,
+    slider::{Slider, SliderEvent, SliderState},
+    v_flex,
+};
+use openlogi_camera::{AutoToggle, CameraControl, CameraState, ControlRange};
+use openlogi_core::config::CameraControls;
+use tracing::debug;
+
+use crate::state::AppState;
+use crate::theme::{self, ACCENT_BLUE, Palette};
+
+/// Built-in profiles: `values` are fractions of each control's own range, so
+/// they scale to whatever the camera reports. Auto modes all engage — the
+/// point of a preset is a good picture without babysitting.
+const BUILTIN_PROFILES: [BuiltinProfile; 3] = [
+    BuiltinProfile {
+        id: "default",
+        values: &[],
+    },
+    BuiltinProfile {
+        id: "streaming",
+        values: &[
+            (CameraControl::Brightness, 0.50),
+            (CameraControl::Contrast, 0.58),
+            (CameraControl::Saturation, 0.62),
+            (CameraControl::Sharpness, 0.60),
+        ],
+    },
+    BuiltinProfile {
+        id: "video_call",
+        values: &[
+            (CameraControl::Brightness, 0.55),
+            (CameraControl::Contrast, 0.52),
+            (CameraControl::Saturation, 0.55),
+            (CameraControl::Sharpness, 0.48),
+        ],
+    },
+];
+
+/// One built-in profile: an id for persistence plus range-relative targets
+/// (an empty list means "device defaults for everything").
+struct BuiltinProfile {
+    id: &'static str,
+    values: &'static [(CameraControl, f32)],
+}
+
+pub struct CameraControlsPanel {
+    /// Persistence key (`camera:vid:pid:serial:…` or legacy `camera-<uid>`).
+    key: Option<String>,
+    /// OS capture id used for UVC open/read/write (may change with USB port).
+    uid: Option<String>,
+    sliders: Vec<ControlSlider>,
+    autos: Vec<AutoRow>,
+    #[allow(dead_code, reason = "held to keep the AppState observer alive")]
+    state_obs: Subscription,
+}
+
+struct ControlSlider {
+    control: CameraControl,
+    label: SharedString,
+    range: ControlRange,
+    state: Entity<SliderState>,
+    #[allow(dead_code, reason = "held to keep the slider subscription alive")]
+    sub: Subscription,
+}
+
+/// Live UI state for one device-supported auto mode.
+struct AutoRow {
+    toggle: AutoToggle,
+    on: bool,
+    default: bool,
+}
+
+/// What [`CameraControlsPanel::ensure_built`] should build the panel from after
+/// re-asserting saved settings on the hardware.
+enum Reapplied {
+    /// Nothing needed writing, or the batch stuck — build from the desired
+    /// (saved-over-snapshot) state.
+    Clean,
+    /// The batch failed; build rows from this freshly-read live state.
+    Live(CameraState),
+    /// The batch failed and the confirming re-read failed too — the true
+    /// hardware state is unknown, so the caller must not cache a build.
+    Unknown,
+}
+
+impl CameraControlsPanel {
+    pub fn new(cx: &mut Context<Self>) -> Self {
+        let state_obs = cx.observe_global::<AppState>(|_panel, cx| cx.notify());
+        Self {
+            key: None,
+            uid: None,
+            sliders: Vec::new(),
+            autos: Vec::new(),
+            state_obs,
+        }
+    }
+
+    /// The active camera's `(config_key, capture_id)`, if a webcam is selected.
+    fn active_camera(cx: &Context<Self>) -> Option<(String, String)> {
+        let record = cx.try_global::<AppState>()?.current_record()?;
+        if !matches!(record.kind, openlogi_core::device::DeviceKind::Camera) {
+            return None;
+        }
+        Some((record.config_key.clone(), record.capture_id.clone()?))
+    }
+
+    /// Re-assert the saved auto/value differences on the hardware in one
+    /// device-open, reporting what the caller should build the panel from.
+    ///
+    /// `apply_settings` isn't atomic — it writes the auto mode, then the value —
+    /// so a rejected batch can leave the hardware between states, making the
+    /// pre-write snapshot untrustworthy. On failure we clear the active profile
+    /// (so a later edit's [`Self::sync_active_custom`] can't overwrite the saved
+    /// profile with fallback values) and re-read the device: [`Reapplied::Live`]
+    /// carries that truth for the caller to cache, while a re-read that also
+    /// fails yields [`Reapplied::Unknown`] — never the stale pre-write state.
+    fn reapply_saved(
+        key: &str,
+        uid: &str,
+        apply_autos: &[(AutoToggle, bool)],
+        apply_values: &[(CameraControl, i32)],
+        cx: &mut Context<Self>,
+    ) -> Reapplied {
+        if apply_autos.is_empty() && apply_values.is_empty() {
+            return Reapplied::Clean;
+        }
+        let Err(e) = openlogi_camera::apply_settings(uid, apply_autos, apply_values) else {
+            return Reapplied::Clean;
+        };
+        debug!(error = %e, "saved camera state reapply failed");
+        cx.update_global::<AppState, _>(|state, _| {
+            state.set_camera_active_profile(key, None);
+        });
+        match openlogi_camera::read_camera_state(uid) {
+            Ok(live) => Reapplied::Live(live),
+            Err(e) => {
+                debug!(error = %e, "post-failure camera re-read failed");
+                Reapplied::Unknown
+            }
+        }
+    }
+
+    /// Build the sliders and auto rows for `key` from the device's reported
+    /// state, re-applying any saved values in one batched device write. Cheap
+    /// no-op when already built for this camera. `uid` is the OS capture id.
+    fn ensure_built(&mut self, key: &str, uid: &str, cx: &mut Context<Self>) {
+        if self.key.as_deref() == Some(key) && self.uid.as_deref() == Some(uid) {
+            return;
+        }
+        self.sliders.clear();
+        self.autos.clear();
+        // Port-bound keys from older builds → stable serial key, once per open.
+        cx.update_global::<AppState, _>(|state, _| {
+            state.migrate_legacy_camera_key(key, uid);
+        });
+
+        // One device-open reads every control and auto state. A failed read
+        // means the camera is unreachable (unplugged or seized by another app):
+        // leave `self.key` unset so the next render retries, instead of caching
+        // an empty panel that never rebuilds once the device returns.
+        let Ok(snap) = openlogi_camera::read_camera_state(uid) else {
+            debug!("camera state read failed; retrying next render");
+            self.key = None;
+            self.uid = None;
+            return;
+        };
+        self.key = Some(key.to_string());
+        self.uid = Some(uid.to_string());
+
+        // Saved auto states win over the device's, then saved values win for
+        // controls whose auto is off; the differences push back in one open.
+        let mut desired_autos = Vec::new();
+        let mut apply_autos = Vec::new();
+        for (toggle, st) in &snap.autos {
+            let saved = cx
+                .try_global::<AppState>()
+                .and_then(|s| s.camera_auto(key, *toggle));
+            let on = saved.unwrap_or(st.current);
+            if on != st.current {
+                apply_autos.push((*toggle, on));
+            }
+            desired_autos.push((*toggle, on, *st));
+        }
+        let auto_desired = |control: CameraControl| {
+            let toggle = control.auto_toggle()?;
+            desired_autos
+                .iter()
+                .find(|(t, ..)| *t == toggle)
+                .map(|(_, on, _)| *on)
+        };
+        let mut desired_values = Vec::new();
+        let mut apply_values = Vec::new();
+        for (control, range) in &snap.controls {
+            let saved = cx
+                .try_global::<AppState>()
+                .and_then(|s| s.camera_control(key, *control));
+            let initial = saved.unwrap_or(range.current).clamp(range.min, range.max);
+            if saved.is_some()
+                && saved != Some(range.current)
+                && !auto_desired(*control).is_some_and(|on| on)
+            {
+                apply_values.push((*control, initial));
+            }
+            desired_values.push((*control, *range, initial));
+        }
+
+        // Saved state only sticks when the hardware takes it. On a rejected
+        // (non-atomic) batch, rebuild rows from the device's live state; if even
+        // that read fails, the hardware state is unknown — drop the key and let
+        // the next render retry rather than caching the stale pre-write values.
+        let live = match Self::reapply_saved(key, uid, &apply_autos, &apply_values, cx) {
+            Reapplied::Clean => None,
+            Reapplied::Live(state) => Some(state),
+            Reapplied::Unknown => {
+                self.key = None;
+                self.uid = None;
+                return;
+            }
+        };
+
+        for (toggle, on, st) in desired_autos {
+            let shown_on = match &live {
+                None => on,
+                Some(state) => state
+                    .autos
+                    .iter()
+                    .find(|(t, _)| *t == toggle)
+                    .map_or(st.current, |(_, s)| s.current),
+            };
+            self.autos.push(AutoRow {
+                toggle,
+                on: shown_on,
+                default: st.default,
+            });
+        }
+        for (control, range, initial) in desired_values {
+            let shown = match &live {
+                None => initial,
+                Some(state) => state
+                    .controls
+                    .iter()
+                    .find(|(c, _)| *c == control)
+                    .map_or(range.current, |(_, r)| r.current),
+            };
+            self.push_control_slider(control, range, shown, uid, key, cx);
+        }
+    }
+
+    /// Build one control's slider (seeded to `shown`), wire its release-writes
+    /// to the device, and push it onto the panel.
+    fn push_control_slider(
+        &mut self,
+        control: CameraControl,
+        range: ControlRange,
+        shown: i32,
+        uid: &str,
+        key: &str,
+        cx: &mut Context<Self>,
+    ) {
+        let state = cx.new(|_| {
+            let (lo, hi) = (range.min as f32, range.max as f32);
+            // `SliderState` defaults to [0, 100] and re-clamps its value on every
+            // builder call, panicking if min > max even transiently. A fully
+            // negative range (UVC exposure reports e.g. -11..-2) would make
+            // `.max(-2)` clamp against the default min of 0 — so set the min
+            // first for negative ranges, and the max first otherwise.
+            let bounded = if lo < 0.0 {
+                SliderState::new().min(lo).max(hi)
+            } else {
+                SliderState::new().max(hi).min(lo)
+            };
+            bounded.step(1.0).default_value(shown as f32)
+        });
+        let uid_for_event = uid.to_string();
+        let key_for_event = key.to_string();
+        let sub = cx.subscribe(&state, move |panel, _slider, event: &SliderEvent, cx| {
+            match event {
+                // Drag updates the label; the USB write lands once on release
+                // so we don't flood the camera with intermediate values.
+                SliderEvent::Change(_) => cx.notify(),
+                SliderEvent::Release(value) => {
+                    let v = value.start().round() as i32;
+                    panel.commit_release(control, &uid_for_event, &key_for_event, v, cx);
+                }
+            }
+        });
+        self.sliders.push(ControlSlider {
+            control,
+            label: control_label(control),
+            range,
+            state,
+            sub,
+        });
+    }
+
+    /// One slider release: write the value — taking the control over to manual
+    /// first when its auto mode owns it (the camera rejects gated values, and
+    /// grabbing the slider *is* the take-over gesture, as in G HUB) — then
+    /// persist exactly what the device took.
+    fn commit_release(
+        &mut self,
+        control: CameraControl,
+        uid: &str,
+        key: &str,
+        v: i32,
+        cx: &mut Context<Self>,
+    ) {
+        let takeover = control.auto_toggle().and_then(|toggle| {
+            let ix = self.autos.iter().position(|a| a.toggle == toggle && a.on)?;
+            Some((toggle, ix))
+        });
+        let written = match takeover {
+            Some((toggle, _)) => {
+                openlogi_camera::apply_settings(uid, &[(toggle, false)], &[(control, v)])
+            }
+            None => openlogi_camera::set_control(uid, control, v),
+        };
+        if let Err(e) = written {
+            debug!(?control, value = v, error = %e, "camera control write failed");
+            // The slider already moved to `v` on release, but the camera kept its
+            // old register (a plain write is atomic; a takeover can land auto-off
+            // before the value fails). Rebuild from live hardware so the panel
+            // never shows a value the device didn't take.
+            self.resync_after_failed_write(cx);
+            return;
+        }
+        if let Some((toggle, ix)) = takeover {
+            self.autos[ix].on = false;
+            cx.update_global::<AppState, _>(|state, _| {
+                state.commit_camera_auto(key, toggle, false);
+            });
+        }
+        cx.update_global::<AppState, _>(|state, _| {
+            state.commit_camera_control(key, control, v);
+        });
+        self.sync_active_custom(cx);
+        cx.notify();
+    }
+
+    /// The current auto state gating `control`, if the device has that toggle.
+    fn auto_state_for(&self, control: CameraControl) -> Option<bool> {
+        let toggle = control.auto_toggle()?;
+        self.autos.iter().find(|a| a.toggle == toggle).map(|a| a.on)
+    }
+
+    /// Flip one auto mode. Turning auto off re-asserts the slider's value so
+    /// the hardware ends where the UI shows, in the same device-open.
+    fn toggle_auto(&mut self, ix: usize, cx: &mut Context<Self>) {
+        let (Some(key), Some(uid)) = (self.key.clone(), self.uid.clone()) else {
+            return;
+        };
+        let Some(row) = self.autos.get(ix) else {
+            return;
+        };
+        let toggle = row.toggle;
+        let on = !row.on;
+        let mut values = Vec::new();
+        if !on
+            && let Some(slider) = self
+                .sliders
+                .iter()
+                .find(|s| s.control.auto_toggle() == Some(toggle))
+        {
+            values.push((
+                slider.control,
+                slider.state.read(cx).value().start().round() as i32,
+            ));
+        }
+        if let Err(e) = openlogi_camera::apply_settings(&uid, &[(toggle, on)], &values) {
+            debug!(?toggle, on, error = %e, "camera auto write failed");
+            // Turning auto off batches the slider value, so a partial write can
+            // land the mode but not the value; resync from live hardware.
+            self.resync_after_failed_write(cx);
+            return;
+        }
+        self.autos[ix].on = on;
+        cx.update_global::<AppState, _>(|state, _| {
+            state.commit_camera_auto(&key, toggle, on);
+        });
+        self.sync_active_custom(cx);
+        cx.notify();
+    }
+
+    /// Reset every control and auto mode to the device defaults, in one
+    /// batched device-open. All rows persist together or not at all — a
+    /// per-row loop would silently skip the remaining rows once a failure
+    /// invalidated the panel, leaving a mix of reset and stale saved values.
+    fn reset(&mut self, window: &mut Window, cx: &mut Context<Self>) {
+        let (Some(key), Some(uid)) = (self.key.clone(), self.uid.clone()) else {
+            return;
+        };
+        let autos: Vec<(AutoToggle, bool)> = self
+            .autos
+            .iter()
+            .map(|row| (row.toggle, row.default))
+            .collect();
+        let values: Vec<(CameraControl, i32)> = self
+            .sliders
+            .iter()
+            .map(|s| (s.control, s.range.default))
+            .collect();
+        if let Err(e) = openlogi_camera::apply_settings(&uid, &autos, &values) {
+            debug!(error = %e, "camera reset failed");
+            // Partial writes may have landed; rebuild from live hardware
+            // rather than persisting a mixed reset.
+            self.resync_after_failed_write(cx);
+            return;
+        }
+        self.commit_batch(&key, &autos, &values, window, cx);
+        self.sync_active_custom(cx);
+        cx.notify();
+    }
+
+    /// After a successful batched write: mirror `autos` + `values` onto the
+    /// rows, re-seat the sliders, and persist everything to the config.
+    fn commit_batch(
+        &mut self,
+        key: &str,
+        autos: &[(AutoToggle, bool)],
+        values: &[(CameraControl, i32)],
+        window: &mut Window,
+        cx: &mut Context<Self>,
+    ) {
+        for (toggle, on) in autos {
+            if let Some(row) = self.autos.iter_mut().find(|a| a.toggle == *toggle) {
+                row.on = *on;
+            }
+        }
+        for (control, value) in values {
+            if let Some(slider) = self.sliders.iter().find(|s| s.control == *control) {
+                slider.state.clone().update(cx, |s, cx| {
+                    s.set_value(*value as f32, window, cx);
+                });
+            }
+        }
+        cx.update_global::<AppState, _>(|state, _| {
+            for (toggle, on) in autos {
+                state.commit_camera_auto(key, *toggle, *on);
+            }
+            for (control, value) in values {
+                state.commit_camera_control(key, *control, *value);
+            }
+        });
+    }
+
+    /// Reset one control to its device default — auto mode back to the
+    /// device's default state, the value re-seated and persisted.
+    fn reset_control(&mut self, ix: usize, window: &mut Window, cx: &mut Context<Self>) {
+        let (Some(key), Some(uid)) = (self.key.clone(), self.uid.clone()) else {
+            return;
+        };
+        let Some((control, default, state)) = self
+            .sliders
+            .get(ix)
+            .map(|s| (s.control, s.range.default, s.state.clone()))
+        else {
+            return;
+        };
+        let mut autos = Vec::new();
+        let auto_pos = control.auto_toggle().and_then(|toggle| {
+            let pos = self.autos.iter().position(|a| a.toggle == toggle)?;
+            autos.push((toggle, self.autos[pos].default));
+            Some(pos)
+        });
+        if let Err(e) = openlogi_camera::apply_settings(&uid, &autos, &[(control, default)]) {
+            debug!(?control, value = default, error = %e, "camera control reset failed");
+            // Auto default + value default aren't atomic; resync from live
+            // hardware so a partial reset can't desync the row.
+            self.resync_after_failed_write(cx);
+            return;
+        }
+        if let Some(pos) = auto_pos {
+            let (toggle, auto_default) = autos[0];
+            self.autos[pos].on = auto_default;
+            cx.update_global::<AppState, _>(|state, _| {
+                state.commit_camera_auto(&key, toggle, auto_default);
+            });
+        }
+        state.update(cx, |slider, cx| {
+            slider.set_value(default as f32, window, cx);
+        });
+        cx.update_global::<AppState, _>(|state, _| {
+            state.commit_camera_control(&key, control, default);
+        });
+        self.sync_active_custom(cx);
+        cx.notify();
+    }
+
+    /// Apply a built-in or saved profile: compute each control's target, push
+    /// everything to the hardware in one batched open, re-seat the sliders,
+    /// persist the values, and remember the selection.
+    fn apply_profile(&mut self, id: &str, window: &mut Window, cx: &mut Context<Self>) {
+        let (Some(key), Some(uid)) = (self.key.clone(), self.uid.clone()) else {
+            return;
+        };
+        let custom = cx
+            .try_global::<AppState>()
+            .map(|s| s.camera_profiles(&key))
+            .unwrap_or_default();
+
+        // Auto targets: built-ins engage every auto mode except Default, which
+        // restores the device's own default states; customs use their snapshot
+        // (falling back to the current state for toggles they don't record).
+        let mut autos: Vec<(AutoToggle, bool)> = Vec::new();
+        let mut values: Vec<(CameraControl, i32)> = Vec::new();
+        if let Some(builtin) = BUILTIN_PROFILES.iter().find(|p| p.id == id) {
+            for row in &self.autos {
+                autos.push((
+                    row.toggle,
+                    if builtin.id == "default" {
+                        row.default
+                    } else {
+                        true
+                    },
+                ));
+            }
+            for slider in &self.sliders {
+                let target = builtin
+                    .values
+                    .iter()
+                    .find(|(c, _)| *c == slider.control)
+                    .map_or(slider.range.default, |(_, pct)| {
+                        let span = (slider.range.max - slider.range.min) as f32;
+                        slider.range.min + (span * pct).round() as i32
+                    });
+                values.push((
+                    slider.control,
+                    target.clamp(slider.range.min, slider.range.max),
+                ));
+            }
+        } else if let Some(snap) = custom.get(id) {
+            for row in &self.autos {
+                let on = snap.0.get(row.toggle.name()).map_or(row.on, |v| *v != 0);
+                autos.push((row.toggle, on));
+            }
+            for slider in &self.sliders {
+                if let Some(v) = snap.0.get(slider.control.name()) {
+                    values.push((
+                        slider.control,
+                        (*v).clamp(slider.range.min, slider.range.max),
+                    ));
+                }
+            }
+        } else {
+            return;
+        }
+
+        if let Err(e) = openlogi_camera::apply_settings(&uid, &autos, &values) {
+            debug!(profile = id, error = %e, "camera profile apply failed");
+            // Some writes may have landed; resync from live state and drop the
+            // active profile so a later edit can't persist a half-applied one.
+            self.resync_after_failed_write(cx);
+            return;
+        }
+        self.commit_batch(&key, &autos, &values, window, cx);
+        cx.update_global::<AppState, _>(|state, _| {
+            state.set_camera_active_profile(&key, Some(id.to_string()));
+        });
+        cx.notify();
+    }
+
+    /// The current control values + auto states as a profile snapshot.
+    fn snapshot(&self, cx: &Context<Self>) -> CameraControls {
+        let mut snap = CameraControls::default();
+        for slider in &self.sliders {
+            snap.0.insert(
+                slider.control.name().to_string(),
+                slider.state.read(cx).value().start().round() as i32,
+            );
+        }
+        for row in &self.autos {
+            snap.0
+                .insert(row.toggle.name().to_string(), i32::from(row.on));
+        }
+        snap
+    }
+
+    /// Keep the active *custom* profile tracking live edits: any slider or
+    /// auto change writes back into its snapshot, so a profile is always what
+    /// you last saw while it was selected. Built-ins are never edited.
+    fn sync_active_custom(&self, cx: &mut Context<Self>) {
+        let Some(key) = self.key.clone() else {
+            return;
+        };
+        let snap = self.snapshot(cx);
+        cx.update_global::<AppState, _>(|state, _| {
+            let Some(active) = state.camera_active_profile(&key) else {
+                return;
+            };
+            if state.camera_profiles(&key).contains_key(&active) {
+                state.save_camera_profile(&key, &active, snap);
+            }
+        });
+    }
+
+    /// Recover after a batched device write failed partway through.
+    /// `apply_settings` is not atomic (it writes the auto mode, then the value,
+    /// in one open), so a partial failure can leave the hardware between the old
+    /// and new state. Drop the cached rows so the panel rebuilds from the
+    /// device's live state on the next render, and clear any active profile so a
+    /// later edit's [`Self::sync_active_custom`] can't overwrite a saved profile
+    /// with those rebuilt values.
+    fn resync_after_failed_write(&mut self, cx: &mut Context<Self>) {
+        self.uid = None;
+        if let Some(key) = self.key.take() {
+            cx.update_global::<AppState, _>(|state, _| {
+                state.set_camera_active_profile(&key, None);
+            });
+        }
+        cx.notify();
+    }
+
+    /// Save the current control values + auto states as a new custom profile
+    /// (auto-named `Custom N`) and mark it active.
+    fn save_profile(&mut self, cx: &mut Context<Self>) {
+        let Some(key) = self.key.clone() else {
+            return;
+        };
+        let snap = self.snapshot(cx);
+        cx.update_global::<AppState, _>(|state, _| {
+            let existing = state.camera_profiles(&key);
+            let mut n = existing.len() + 1;
+            let mut name = format!("Custom {n}");
+            while existing.contains_key(&name) {
+                n += 1;
+                name = format!("Custom {n}");
+            }
+            state.save_camera_profile(&key, &name, snap);
+            state.set_camera_active_profile(&key, Some(name));
+        });
+        cx.notify();
+    }
+
+    /// Delete a saved custom profile. The hardware keeps whatever it's set to —
+    /// only the snapshot (and, if it named this profile, the selection) goes.
+    fn delete_profile(&mut self, name: &str, cx: &mut Context<Self>) {
+        let Some(key) = self.key.clone() else {
+            return;
+        };
+        cx.update_global::<AppState, _>(|state, _| {
+            state.delete_camera_profile(&key, name);
+        });
+        cx.notify();
+    }
+}
+
+impl Render for CameraControlsPanel {
+    fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
+        let pal = theme::palette(cx);
+        let Some((key, uid)) = Self::active_camera(cx) else {
+            self.key = None;
+            self.uid = None;
+            self.sliders.clear();
+            self.autos.clear();
+            return div().into_any_element();
+        };
+        self.ensure_built(&key, &uid, cx);
+
+        if self.sliders.is_empty() {
+            return div()
+                .text_sm()
+                .text_color(pal.text_muted)
+                .child(tr!("This camera exposes no adjustable image controls."))
+                .into_any_element();
+        }
+
+        let lens: Vec<usize> = section_indices(&self.sliders, true);
+        let image: Vec<usize> = section_indices(&self.sliders, false);
+
+        let mut panel = v_flex().gap_2().w_full().child(profiles_row(&key, pal, cx));
+        if !lens.is_empty() && !image.is_empty() {
+            panel = panel.child(section_label(tr!("Lens"), pal));
+        }
+        for ix in lens {
+            panel = panel.child(control_row(self, ix, cx, pal));
+        }
+        if !image.is_empty() && self.sliders.len() != image.len() {
+            panel = panel.child(section_label(tr!("Image"), pal));
+        }
+        for ix in image {
+            panel = panel.child(control_row(self, ix, cx, pal));
+        }
+        panel.child(reset_button(pal, cx)).into_any_element()
+    }
+}
+
+/// Indices of the lens (camera-terminal) or image (processing-unit) sliders,
+/// preserving [`CameraControl::ALL`] order.
+fn section_indices(sliders: &[ControlSlider], lens: bool) -> Vec<usize> {
+    sliders
+        .iter()
+        .enumerate()
+        .filter(|(_, s)| {
+            matches!(
+                s.control,
+                CameraControl::Zoom | CameraControl::Focus | CameraControl::Exposure
+            ) == lens
+        })
+        .map(|(ix, _)| ix)
+        .collect()
+}
+
+/// The one-click profile chips: built-ins, saved customs, then Save.
+fn profiles_row(key: &str, pal: Palette, cx: &mut Context<CameraControlsPanel>) -> AnyElement {
+    let state = cx.try_global::<AppState>();
+    let active = state.and_then(|s| s.camera_active_profile(key));
+    let customs: Vec<String> = state
+        .map(|s| s.camera_profiles(key).keys().cloned().collect())
+        .unwrap_or_default();
+
+    let mut row = h_flex().flex_wrap().gap_1p5().items_center();
+    for (ix, builtin) in BUILTIN_PROFILES.iter().enumerate() {
+        let id = builtin.id;
+        row = row.child(profile_chip(
+            ("camera-profile-builtin", ix),
+            builtin_label(id),
+            active.as_deref() == Some(id),
+            pal,
+            cx.listener(move |panel, _: &ClickEvent, window, cx| {
+                panel.apply_profile(id, window, cx);
+            }),
+        ));
+    }
+    for (ix, name) in customs.into_iter().enumerate() {
+        let is_active = active.as_deref() == Some(name.as_str());
+        row = row.child(custom_profile_chip(ix, name, is_active, pal, cx));
+    }
+    row = row.child(
+        div()
+            .id("camera-profile-save")
+            .px_2()
+            .py_0p5()
+            .rounded_full()
+            .border_1()
+            .border_color(pal.border)
+            .text_xs()
+            .text_color(pal.text_muted)
+            .hover(|s| s.bg(pal.surface_hover))
+            .child(format!("+ {}", tr!("New")))
+            .on_click(cx.listener(|panel, _: &ClickEvent, _window, cx| {
+                panel.save_profile(cx);
+            })),
+    );
+    row.into_any_element()
+}
+
+fn profile_chip(
+    id: (&'static str, usize),
+    label: SharedString,
+    active: bool,
+    pal: Palette,
+    on_click: impl Fn(&ClickEvent, &mut Window, &mut gpui::App) + 'static,
+) -> AnyElement {
+    let accent = rgb(ACCENT_BLUE);
+    div()
+        .id(id)
+        .px_2()
+        .py_0p5()
+        .rounded_full()
+        .border_1()
+        .border_color(if active { accent.into() } else { pal.border })
+        .text_xs()
+        .text_color(if active {
+            accent.into()
+        } else {
+            pal.text_muted
+        })
+        .when(active, |s| s.bg(pal.surface))
+        .hover(move |s| s.bg(pal.surface_hover))
+        .child(label)
+        .on_click(on_click)
+        .into_any_element()
+}
+
+/// A saved custom profile's chip: click applies it, the trailing `×` deletes
+/// it (stopping propagation so a delete never also applies the profile).
+fn custom_profile_chip(
+    ix: usize,
+    name: String,
+    active: bool,
+    pal: Palette,
+    cx: &mut Context<CameraControlsPanel>,
+) -> AnyElement {
+    let accent = rgb(ACCENT_BLUE);
+    let apply_name = name.clone();
+    let delete_name = name.clone();
+    h_flex()
+        .id(("camera-profile-custom", ix))
+        .pl_2()
+        .pr_1()
+        .py_0p5()
+        .gap_1()
+        .items_center()
+        .rounded_full()
+        .border_1()
+        .border_color(if active { accent.into() } else { pal.border })
+        .text_xs()
+        .text_color(if active {
+            accent.into()
+        } else {
+            pal.text_muted
+        })
+        .when(active, |s| s.bg(pal.surface))
+        .hover(move |s| s.bg(pal.surface_hover))
+        .child(SharedString::from(name))
+        .on_click(cx.listener(move |panel, _: &ClickEvent, window, cx| {
+            panel.apply_profile(&apply_name, window, cx);
+        }))
+        .child(
+            div()
+                .id(("camera-profile-del", ix))
+                .px_0p5()
+                .rounded_full()
+                .text_color(pal.text_muted)
+                .hover(|s| s.text_color(gpui::white()))
+                .child("×")
+                .on_click(cx.listener(move |panel, _: &ClickEvent, _window, cx| {
+                    cx.stop_propagation();
+                    panel.delete_profile(&delete_name, cx);
+                })),
+        )
+        .into_any_element()
+}
+
+fn section_label(text: SharedString, pal: Palette) -> AnyElement {
+    div()
+        .mt_1()
+        .text_xs()
+        .text_color(pal.text_muted)
+        .child(text)
+        .into_any_element()
+}
+
+/// One compact control line: label · slider · live value (· Auto chip when the
+/// device pairs one). Double-click anywhere on the line resets that control.
+fn control_row(
+    panel: &CameraControlsPanel,
+    ix: usize,
+    cx: &Context<CameraControlsPanel>,
+    pal: Palette,
+) -> AnyElement {
+    let slider = &panel.sliders[ix];
+    let value = slider.state.read(cx).value().start().round() as i32;
+    let auto_on = panel.auto_state_for(slider.control);
+    let dimmed = auto_on == Some(true);
+
+    let mut row = h_flex()
+        .id(("camera-control-row", ix))
+        .w_full()
+        .gap_3()
+        .items_center()
+        // Capture phase, so the double-click wins over the slider's own
+        // handlers: the thumb's mouse-down stops propagation (a bubbled click
+        // never fires), and a track click would jump the value and then
+        // re-commit it from its deferred Release event after the reset ran.
+        .capture_any_mouse_down(cx.listener(
+            move |panel, event: &MouseDownEvent, window, cx| {
+                if event.button == MouseButton::Left && event.click_count == 2 {
+                    cx.stop_propagation();
+                    panel.reset_control(ix, window, cx);
+                }
+            },
+        ))
+        .child(
+            div()
+                .w(px(96.))
+                .flex_shrink_0()
+                .truncate()
+                .text_sm()
+                .text_color(pal.text_muted)
+                .child(slider.label.clone()),
+        )
+        .child(
+            div()
+                .flex_1()
+                // Dimmed while auto owns the value, but still draggable —
+                // grabbing the slider takes the control over to manual.
+                .when(dimmed, |s| s.opacity(0.55))
+                .child(Slider::new(&slider.state).horizontal()),
+        )
+        .child(
+            div()
+                .w(px(36.))
+                .flex_shrink_0()
+                .text_right()
+                .text_sm()
+                .text_color(if dimmed {
+                    pal.text_muted
+                } else {
+                    rgb(ACCENT_BLUE).into()
+                })
+                .child(format!("{value}")),
+        );
+
+    // Every row carries the trailing Auto column — empty for controls without
+    // an auto mode — so the sliders and values align across the whole panel.
+    let mut auto_cell = div().w(px(46.)).flex_shrink_0().flex().justify_end();
+    if let Some(on) = auto_on
+        && let Some(toggle) = slider.control.auto_toggle()
+        && let Some(auto_ix) = panel.autos.iter().position(|a| a.toggle == toggle)
+    {
+        let accent = rgb(ACCENT_BLUE);
+        auto_cell = auto_cell.child(
+            div()
+                .id(("camera-control-auto", ix))
+                .px_1p5()
+                .py_0p5()
+                .rounded_full()
+                .border_1()
+                .border_color(if on { accent.into() } else { pal.border })
+                .text_xs()
+                .text_color(if on { accent.into() } else { pal.text_muted })
+                .hover(|s| s.bg(pal.surface_hover))
+                .child(tr!("Auto"))
+                .on_click(cx.listener(move |panel, _: &ClickEvent, _window, cx| {
+                    panel.toggle_auto(auto_ix, cx);
+                })),
+        );
+    }
+    row = row.child(auto_cell);
+
+    row.into_any_element()
+}
+
+fn reset_button(pal: Palette, cx: &mut Context<CameraControlsPanel>) -> AnyElement {
+    h_flex()
+        .w_full()
+        .justify_end()
+        .child(
+            div()
+                .id("camera-controls-reset")
+                .px_2p5()
+                .py_0p5()
+                .rounded_md()
+                .border_1()
+                .border_color(pal.border)
+                .bg(pal.surface)
+                .hover(|s| s.bg(pal.surface_hover))
+                .text_xs()
+                .text_color(pal.text_muted)
+                .child(tr!("Reset to defaults"))
+                .on_click(cx.listener(|panel, _: &ClickEvent, window, cx| {
+                    panel.reset(window, cx);
+                })),
+        )
+        .into_any_element()
+}
+
+fn builtin_label(id: &str) -> SharedString {
+    match id {
+        "streaming" => tr!("Streaming"),
+        "video_call" => tr!("Video call"),
+        _ => tr!("Default"),
+    }
+}
+
+fn control_label(control: CameraControl) -> SharedString {
+    match control {
+        CameraControl::Zoom => tr!("Zoom"),
+        CameraControl::Focus => tr!("Focus"),
+        CameraControl::Exposure => tr!("Exposure"),
+        CameraControl::Brightness => tr!("Brightness"),
+        CameraControl::Contrast => tr!("Contrast"),
+        CameraControl::Saturation => tr!("Saturation"),
+        CameraControl::Sharpness => tr!("Sharpness"),
+        CameraControl::WhiteBalance => tr!("White balance"),
+        CameraControl::Tint => tr!("Tint"),
+    }
+}
diff --git a/crates/openlogi-gui/src/components/camera_preview.rs b/crates/openlogi-gui/src/components/camera_preview.rs
new file mode 100644
index 0000000000000000000000000000000000000000..623a1869a9026b4d2dd8fb0a63d9aeb7f81edd85
--- /dev/null
+++ b/crates/openlogi-gui/src/components/camera_preview.rs
@@ -0,0 +1,172 @@
+//! Live webcam preview, driven by the parent view's tab visibility.
+//!
+//! [`CameraPreview::set_target`] is the single lifecycle switch: the parent
+//! ([`crate::app::AppView`]) calls it each render with the active camera's id
+//! while the live-preview tab is showing, or `None` otherwise. Passing `None`
+//! — leaving the tab, going home, or selecting another device — drops the
+//! `AVCaptureSession`, so the LED goes off and the camera leaves zero CPU,
+//! memory, and GPU texture behind. The camera is therefore active *only* while
+//! you are looking at it.
+//!
+//! While streaming it captures at 720p (Retina-sharp for the 480pt box),
+//! rebuilds the GPU texture only when a new frame arrives, and repaints at the
+//! camera's ~30 fps delivery rate.
+
+use std::sync::Arc;
+use std::time::Duration;
+
+use gpui::{
+    AnyElement, Context, IntoElement, ParentElement, Render, RenderImage, SharedString, Styled,
+    Task, Window, div, img, px,
+};
+use gpui_component::v_flex;
+use image::{Frame as ImageFrame, RgbaImage};
+use openlogi_camera::{CameraStream, Frame};
+
+use crate::theme::{self, Palette};
+
+const PREVIEW_W: f32 = 480.;
+const PREVIEW_H: f32 = 270.; // 16:9
+
+/// Live preview view. Holds the capture stream + its texture only while the
+/// parent points it at a camera via [`Self::set_target`].
+pub struct CameraPreview {
+    stream: Option<CameraStream>,
+    streaming_uid: Option<String>,
+    current_image: Option<Arc<RenderImage>>,
+    last_generation: u64,
+    /// Frame-rate repaint pump; exists only while streaming (dropping it cancels it).
+    repaint_task: Option<Task<()>>,
+}
+
+impl CameraPreview {
+    pub fn new(_cx: &mut Context<Self>) -> Self {
+        Self {
+            stream: None,
+            streaming_uid: None,
+            current_image: None,
+            last_generation: 0,
+            repaint_task: None,
+        }
+    }
+
+    /// Point the preview at `target` (a camera's unique id) or `None` to stop.
+    /// The parent calls this every render from the active detail tab, so the
+    /// camera runs only while its preview is on screen. Idempotent when the
+    /// target is unchanged.
+    pub fn set_target(&mut self, target: Option<String>, cx: &mut Context<Self>) {
+        if target == self.streaming_uid {
+            return;
+        }
+        // Stop the old stream first: drop the session (LED off), cancel the
+        // repaint pump, and free the GPU texture immediately — not in `render`,
+        // which stops running the moment the preview leaves the screen.
+        self.stream = None;
+        self.repaint_task = None;
+        self.last_generation = 0;
+        if let Some(old) = self.current_image.take() {
+            cx.drop_image(old, None);
+        }
+        self.streaming_uid.clone_from(&target);
+
+        let Some(uid) = target else {
+            cx.notify();
+            return;
+        };
+        // Only open the camera when access is already granted, so selecting it
+        // never blocks the UI thread on the permission dialog.
+        if openlogi_camera::camera_access_granted() {
+            self.stream = openlogi_camera::start_stream(&uid).ok();
+        }
+        if self.stream.is_some() {
+            self.repaint_task = Some(cx.spawn(async move |this, cx| {
+                loop {
+                    cx.background_executor()
+                        .timer(Duration::from_millis(16))
+                        .await;
+                    // Repaint only when a *new* frame has arrived, so gpui isn't
+                    // re-rendering the window on idle ticks.
+                    let result = this.update(cx, |view, cx| {
+                        let has_new = view
+                            .stream
+                            .as_ref()
+                            .is_some_and(|s| s.frame_generation() != view.last_generation);
+                        if has_new {
+                            cx.notify();
+                        }
+                    });
+                    if result.is_err() {
+                        break;
+                    }
+                }
+            }));
+        }
+        cx.notify();
+    }
+}
+
+impl Render for CameraPreview {
+    fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
+        let pal = theme::palette(cx);
+        let granted = openlogi_camera::camera_access_granted();
+
+        // Rebuild the texture only when a new frame arrived; free the old one.
+        if let Some(stream) = self.stream.as_ref() {
+            let generation = stream.frame_generation();
+            if generation != self.last_generation
+                && let Some(image) = stream
+                    .take_frame()
+                    .and_then(|f| build_image(Arc::unwrap_or_clone(f)))
+            {
+                if let Some(old) = self.current_image.take() {
+                    let _ = window.drop_image(old);
+                }
+                self.current_image = Some(image);
+                self.last_generation = generation;
+            }
+        }
+
+        let surface: AnyElement = if let Some(image) = self.current_image.as_ref() {
+            img(image.clone())
+                .w(px(PREVIEW_W))
+                .h(px(PREVIEW_H))
+                .rounded_md()
+                .into_any_element()
+        } else if !openlogi_camera::capture_supported() {
+            note(
+                tr!("Live preview isn't available on this platform yet."),
+                pal,
+            )
+        } else if granted {
+            note(tr!("Starting preview…"), pal)
+        } else {
+            note(tr!("Enable Camera access in Settings to preview."), pal)
+        };
+
+        v_flex()
+            .w(px(PREVIEW_W))
+            .h(px(PREVIEW_H))
+            .items_center()
+            .justify_center()
+            .rounded_md()
+            .border_1()
+            .border_color(pal.border)
+            .bg(pal.surface)
+            .child(surface)
+    }
+}
+
+/// Wrap a BGRA camera frame as a gpui texture. The frame is already in gpui's
+/// BGRA order and is consumed whole, so no pixel buffer is copied or swapped.
+fn build_image(frame: Frame) -> Option<Arc<RenderImage>> {
+    let buffer = RgbaImage::from_raw(frame.width, frame.height, frame.bgra)?;
+    Some(Arc::new(RenderImage::new(vec![ImageFrame::new(buffer)])))
+}
+
+fn note(text: impl Into<SharedString>, pal: Palette) -> AnyElement {
+    div()
+        .text_sm()
+        .text_color(pal.text_muted)
+        .child(text.into())
+        .into_any_element()
+}
diff --git a/crates/openlogi-gui/src/components/light_panel.rs b/crates/openlogi-gui/src/components/light_panel.rs
new file mode 100644
index 0000000000000000000000000000000000000000..8d2f6857db4336b289e9fc06914d716022013737
--- /dev/null
+++ b/crates/openlogi-gui/src/components/light_panel.rs
@@ -0,0 +1,537 @@
+//! Capability-driven controls for standalone lights.
+
+use crate::state::{AppState, LightCommandStatus};
+use crate::theme::{self, ACCENT_BLUE, Palette, SelectableStyle as _, Typography as _};
+use gpui::{
+    AppContext as _, BorrowAppContext as _, BoxShadow, Context, Entity, Hsla, InteractiveElement,
+    IntoElement, ParentElement, Render, StatefulInteractiveElement as _, Styled, Subscription,
+    Window, div, hsla, point, prelude::FluentBuilder as _, px, rgb,
+};
+use gpui_component::{
+    Icon, IconName, h_flex,
+    slider::{Slider, SliderEvent, SliderState},
+    v_flex,
+};
+use openlogi_core::{
+    config::LightSettings,
+    device::{LightCapabilities, LightValueRange, LightValueUnit},
+};
+
+/// Standalone-light panel. The UI is driven by the active device's advertised
+/// capabilities; the panel is not Litra-specific even though Litra is the
+/// first driver.
+pub struct LightPanel {
+    brightness: Option<Entity<SliderState>>,
+    temperature: Option<Entity<SliderState>>,
+    brightness_range: Option<LightValueRange>,
+    temperature_range: Option<LightValueRange>,
+    device_key: Option<String>,
+    last_brightness: u8,
+    last_temperature: Option<u16>,
+    brightness_sub: Option<Subscription>,
+    temperature_sub: Option<Subscription>,
+    _state_obs: Subscription,
+}
+
+impl LightPanel {
+    /// Construct the panel. Capability-shaped sliders are created lazily when
+    /// the selected device is known.
+    pub fn new(cx: &mut Context<Self>) -> Self {
+        let settings = cx
+            .try_global::<AppState>()
+            .map(AppState::light)
+            .unwrap_or_default();
+        let state_obs = cx.observe_global::<AppState>(|_, cx| cx.notify());
+        Self {
+            brightness: None,
+            temperature: None,
+            brightness_range: None,
+            temperature_range: None,
+            device_key: None,
+            last_brightness: settings.brightness_percent,
+            last_temperature: settings.temperature_kelvin,
+            brightness_sub: None,
+            temperature_sub: None,
+            _state_obs: state_obs,
+        }
+    }
+
+    fn ensure_sliders(
+        &mut self,
+        key: Option<&str>,
+        capabilities: Option<LightCapabilities>,
+        settings: LightSettings,
+        cx: &mut Context<Self>,
+    ) {
+        let brightness_range = capabilities.and_then(|caps| caps.brightness);
+        let temperature_range = capabilities.and_then(|caps| caps.temperature);
+        if self.device_key.as_deref() == key
+            && self.brightness_range == brightness_range
+            && self.temperature_range == temperature_range
+        {
+            return;
+        }
+
+        self.brightness = None;
+        self.temperature = None;
+        self.brightness_sub = None;
+        self.temperature_sub = None;
+        self.device_key = key.map(str::to_string);
+        self.brightness_range = brightness_range;
+        self.temperature_range = temperature_range;
+
+        if let Some(range) = brightness_range {
+            let value = range
+                .native_for_percent(settings.brightness_percent)
+                .unwrap_or(range.min());
+            let slider = cx.new(|_| {
+                SliderState::new()
+                    .max(f32::from(range.max()))
+                    .min(f32::from(range.min()))
+                    .step(f32::from(range.step()))
+                    .default_value(f32::from(value))
+            });
+            let subscription =
+                cx.subscribe(&slider, move |_panel, _slider, event: &SliderEvent, cx| {
+                    if let SliderEvent::Release(value) = event {
+                        let native = round_u16(value.start());
+                        let Some(percent) = range.percent_for_native(native) else {
+                            return;
+                        };
+                        cx.update_global::<AppState, _>(|state, _| {
+                            let mut light = state.light();
+                            if !state.camera_automation_active() {
+                                light.enabled = true;
+                            }
+                            light.brightness_percent = percent;
+                            state.commit_light(light);
+                        });
+                        cx.notify();
+                    }
+                });
+            self.brightness = Some(slider);
+            self.brightness_sub = Some(subscription);
+        }
+
+        if let Some(range) = temperature_range {
+            let value = settings
+                .temperature_kelvin
+                .map_or_else(|| midpoint(range), |value| range.quantize(value));
+            let slider = cx.new(|_| {
+                SliderState::new()
+                    .max(f32::from(range.max()))
+                    .min(f32::from(range.min()))
+                    .step(f32::from(range.step()))
+                    .default_value(f32::from(value))
+            });
+            let subscription =
+                cx.subscribe(&slider, move |_panel, _slider, event: &SliderEvent, cx| {
+                    if let SliderEvent::Release(value) = event {
+                        let kelvin = range.quantize(round_u16(value.start()));
+                        cx.update_global::<AppState, _>(|state, _| {
+                            let mut light = state.light();
+                            if !state.camera_automation_active() {
+                                light.enabled = true;
+                            }
+                            light.temperature_kelvin = Some(kelvin);
+                            state.commit_light(light);
+                        });
+                        cx.notify();
+                    }
+                });
+            self.temperature = Some(slider);
+            self.temperature_sub = Some(subscription);
+        }
+    }
+}
+
+impl Render for LightPanel {
+    fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
+        let pal = theme::palette(cx);
+        let settings = cx
+            .try_global::<AppState>()
+            .map(AppState::light)
+            .unwrap_or_default();
+        let record = cx
+            .try_global::<AppState>()
+            .and_then(AppState::current_record)
+            .cloned();
+        let capabilities = record.as_ref().and_then(|record| record.light_capabilities);
+
+        self.ensure_sliders(
+            record.as_ref().map(|record| record.config_key.as_str()),
+            capabilities,
+            settings,
+            cx,
+        );
+
+        if settings.brightness_percent != self.last_brightness {
+            self.last_brightness = settings.brightness_percent;
+            if let (Some(range), Some(slider)) = (self.brightness_range, &self.brightness) {
+                let value = range
+                    .native_for_percent(settings.brightness_percent)
+                    .unwrap_or(range.min());
+                slider.update(cx, |slider, cx| {
+                    slider.set_value(f32::from(value), window, cx);
+                });
+            }
+        }
+        if settings.temperature_kelvin != self.last_temperature {
+            self.last_temperature = settings.temperature_kelvin;
+            if let (Some(range), Some(slider)) = (self.temperature_range, &self.temperature) {
+                let value = settings
+                    .temperature_kelvin
+                    .map_or_else(|| midpoint(range), |kelvin| range.quantize(kelvin));
+                slider.update(cx, |slider, cx| {
+                    slider.set_value(f32::from(value), window, cx);
+                });
+            }
+        }
+
+        let device_name = record.as_ref().map_or_else(
+            || tr!("Lighting").to_string(),
+            |record| record.display_name.clone(),
+        );
+        let online = record.as_ref().is_some_and(|record| record.online);
+        let effective_enabled = cx
+            .try_global::<AppState>()
+            .is_some_and(AppState::light_enabled);
+        let power = capabilities.is_some_and(|caps| caps.power);
+
+        let mut panel = v_flex().gap_4().w_full();
+        if power {
+            panel = panel.child(light_hero(&device_name, online, effective_enabled, pal));
+            #[cfg(target_os = "macos")]
+            {
+                panel = panel.child(camera_automation(settings, pal));
+            }
+            panel = panel.child(div().h(px(1.)).w_full().bg(pal.border.opacity(0.55)));
+        }
+        if let (Some(range), Some(slider)) = (self.brightness_range, &self.brightness) {
+            let value = range
+                .native_for_percent(settings.brightness_percent)
+                .unwrap_or(range.min());
+            panel = panel.child(control_well(
+                tr!("BRIGHTNESS"),
+                format_light_value(value, range.unit()),
+                format_range_endpoints(range),
+                Slider::new(slider).horizontal(),
+                pal,
+            ));
+        }
+        if let (Some(range), Some(slider)) = (self.temperature_range, &self.temperature) {
+            let value = settings
+                .temperature_kelvin
+                .map_or_else(|| midpoint(range), |kelvin| range.quantize(kelvin));
+            panel = panel.child(control_well(
+                tr!("COLOUR TEMPERATURE"),
+                format_light_value(value, range.unit()),
+                format_range_endpoints(range),
+                Slider::new(slider).horizontal(),
+                pal,
+            ));
+        }
+        if let Some(status) = cx
+            .try_global::<AppState>()
+            .and_then(AppState::light_command_status)
+        {
+            panel = panel.child(light_command_status(status, pal));
+        }
+        panel
+    }
+}
+
+fn light_hero(
+    device_name: &str,
+    online: bool,
+    effective_enabled: bool,
+    pal: Palette,
+) -> impl IntoElement {
+    h_flex()
+        .gap_3()
+        .items_center()
+        .child(light_emblem(effective_enabled, pal))
+        .child(
+            v_flex()
+                .gap_1()
+                .flex_1()
+                .min_w_0()
+                .child(div().text_heading().child(device_name.to_owned()))
+                .child(light_status(online, effective_enabled, pal)),
+        )
+        .child(toggle(effective_enabled, pal))
+}
+
+fn light_emblem(enabled: bool, pal: Palette) -> impl IntoElement {
+    let halo = if enabled {
+        hsla(0.105, 0.9, 0.66, 0.22)
+    } else {
+        pal.surface_hover
+    };
+    let icon_color: Hsla = if enabled {
+        hsla(0.105, 0.9, 0.66, 1.)
+    } else {
+        pal.text_muted
+    };
+    let icon = if enabled {
+        IconName::Sun
+    } else {
+        IconName::Moon
+    };
+
+    div()
+        .relative()
+        .size(px(64.))
+        .flex_none()
+        .flex()
+        .items_center()
+        .justify_center()
+        .rounded(pal.card_radius)
+        .bg(halo)
+        .border_1()
+        .border_color(if enabled {
+            hsla(0.105, 0.9, 0.66, 0.35)
+        } else {
+            pal.border
+        })
+        .when(enabled, |this| {
+            this.shadow(vec![BoxShadow {
+                color: hsla(0.105, 0.9, 0.66, 0.25),
+                offset: point(px(0.), px(0.)),
+                blur_radius: px(18.),
+                spread_radius: px(1.),
+                inset: false,
+            }])
+        })
+        .child(Icon::new(icon).size_7().text_color(icon_color))
+}
+
+#[cfg(target_os = "macos")]
+fn camera_automation(current: LightSettings, pal: Palette) -> impl IntoElement {
+    h_flex()
+        .w_full()
+        .justify_between()
+        .items_center()
+        .gap_3()
+        .rounded(pal.control_radius)
+        .border_1()
+        .border_color(if current.auto_camera {
+            hsla(0.105, 0.9, 0.66, 0.4)
+        } else {
+            pal.border
+        })
+        .bg(if current.auto_camera {
+            hsla(0.105, 0.9, 0.66, 0.08)
+        } else {
+            pal.surface_hover
+        })
+        .p_3()
+        .child(
+            v_flex()
+                .gap_1()
+                .flex_1()
+                .min_w_0()
+                .child(
+                    div()
+                        .text_body()
+                        .text_color(pal.text_primary)
+                        .child(tr!("Auto-on with camera")),
+                )
+                .child(div().text_caption().text_color(pal.text_muted).child(tr!(
+                    "Turn this light on while any camera is in use and off when cameras stop."
+                ))),
+        )
+        .child(
+            h_flex()
+                .id("standalone-light-camera-automation")
+                .min_w(px(72.))
+                .justify_center()
+                .items_center()
+                .gap_2()
+                .px_3()
+                .py_2()
+                .rounded(pal.control_radius)
+                .selected_border(current.auto_camera, pal)
+                .selected_fill(current.auto_camera)
+                .text_caption()
+                .text_color(if current.auto_camera {
+                    pal.text_primary
+                } else {
+                    pal.text_muted
+                })
+                .cursor_pointer()
+                .hover(|style| style.bg(pal.surface_hover))
+                .child(if current.auto_camera {
+                    tr!("On")
+                } else {
+                    tr!("Off")
+                })
+                .on_click(|_event, _window, cx| {
+                    cx.update_global::<AppState, _>(|state, _| {
+                        let mut light = state.light();
+                        light.auto_camera = !light.auto_camera;
+                        state.commit_light(light);
+                    });
+                    cx.refresh_windows();
+                }),
+        )
+}
+
+fn light_status(online: bool, enabled: bool, pal: Palette) -> impl IntoElement {
+    let (label, color) = if !online {
+        (tr!("Offline"), theme::STATUS_OFFLINE)
+    } else if enabled {
+        (tr!("On"), theme::STATUS_CONNECTED)
+    } else {
+        (tr!("Off"), theme::STATUS_OFFLINE)
+    };
+    h_flex()
+        .gap_1p5()
+        .items_center()
+        .text_caption()
+        .text_color(pal.text_muted)
+        .child(div().size_1p5().rounded_full().bg(rgb(color)))
+        .child(label)
+}
+
+fn control_well(
+    title: gpui::SharedString,
+    value: String,
+    endpoints: (String, String),
+    slider: impl IntoElement,
+    pal: Palette,
+) -> impl IntoElement {
+    v_flex()
+        .gap_3()
+        .rounded(pal.control_radius)
+        .border_1()
+        .border_color(pal.border)
+        .bg(pal.surface_hover)
+        .p_3()
+        .child(
+            h_flex()
+                .justify_between()
+                .items_baseline()
+                .child(div().text_caption().text_color(pal.text_muted).child(title))
+                .child(
+                    div()
+                        .text_body()
+                        .text_color(rgb(ACCENT_BLUE))
+                        .font_weight(gpui::FontWeight::MEDIUM)
+                        .child(value),
+                ),
+        )
+        .child(slider)
+        .child(
+            h_flex()
+                .justify_between()
+                .text_caption()
+                .text_color(pal.text_muted)
+                .child(endpoints.0)
+                .child(endpoints.1),
+        )
+}
+
+fn toggle(effective_enabled: bool, pal: Palette) -> impl IntoElement {
+    let on = effective_enabled;
+    let icon = if on { IconName::Sun } else { IconName::Moon };
+    h_flex()
+        .id("standalone-light-toggle")
+        .min_w(px(72.))
+        .justify_center()
+        .items_center()
+        .gap_2()
+        .px_3()
+        .py_2()
+        .rounded(pal.control_radius)
+        .selected_border(on, pal)
+        .selected_fill(on)
+        .text_caption()
+        .text_color(if on { pal.text_primary } else { pal.text_muted })
+        .cursor_pointer()
+        .hover(|style| style.bg(pal.surface_hover))
+        .child(Icon::new(icon).size_3())
+        .child(if on { tr!("On") } else { tr!("Off") })
+        .on_click(move |_event, _window, cx| {
+            cx.update_global::<AppState, _>(|state, _| {
+                state.commit_manual_light_power(!state.light_enabled());
+            });
+            cx.refresh_windows();
+        })
+}
+
+fn format_range_endpoints(range: LightValueRange) -> (String, String) {
+    (
+        format_light_value(range.min(), range.unit()),
+        format_light_value(range.max(), range.unit()),
+    )
+}
+
+fn format_light_value(value: u16, unit: LightValueUnit) -> String {
+    match unit {
+        LightValueUnit::Lumens => format!("{value} lm"),
+        LightValueUnit::Kelvin => format!("{value} K"),
+        LightValueUnit::Percent => format!("{value}%"),
+    }
+}
+
+fn midpoint(range: LightValueRange) -> u16 {
+    range.quantize(range.min() + (range.max() - range.min()) / 2)
+}
+
+#[allow(
+    clippy::cast_possible_truncation,
+    clippy::cast_sign_loss,
+    reason = "the slider value is clamped to the u16 range before conversion"
+)]
+fn round_u16(raw: f32) -> u16 {
+    raw.clamp(0., f32::from(u16::MAX)).round() as u16
+}
+
+fn light_command_status(status: LightCommandStatus, pal: Palette) -> impl IntoElement {
+    let (label, color) = match status {
+        LightCommandStatus::Pending => (tr!("Applying light setting…").to_string(), pal.text_muted),
+        LightCommandStatus::Failed(error) => (
+            format!("{}: {error}", tr!("Unavailable")),
+            Hsla::from(rgb(theme::STATUS_OFFLINE)),
+        ),
+        LightCommandStatus::Offline => (
+            tr!("Offline").to_string(),
+            Hsla::from(rgb(theme::STATUS_OFFLINE)),
+        ),
+    };
+    h_flex()
+        .gap_1p5()
+        .items_center()
+        .text_caption()
+        .text_color(pal.text_muted)
+        .child(div().size_1p5().rounded_full().bg(color))
+        .child(label)
+}
+
+#[cfg(test)]
+mod tests {
+    #![allow(
+        clippy::expect_used,
+        reason = "range fixture construction is intentionally asserted in tests"
+    )]
+
+    use super::{format_light_value, midpoint};
+    use openlogi_core::device::{LightValueRange, LightValueUnit};
+
+    #[test]
+    fn sliders_use_the_advertised_range_and_grid() {
+        let range = LightValueRange::new(3000, 5000, 250, LightValueUnit::Kelvin)
+            .expect("valid test range");
+        assert_eq!(range.quantize(3120), 3000);
+        assert_eq!(range.quantize(3370), 3250);
+        assert_eq!(midpoint(range), 4000);
+    }
+
+    #[test]
+    fn range_values_use_capability_units() {
+        assert_eq!(format_light_value(20, LightValueUnit::Lumens), "20 lm");
+        assert_eq!(format_light_value(2700, LightValueUnit::Kelvin), "2700 K");
+        assert_eq!(format_light_value(100, LightValueUnit::Percent), "100%");
+    }
+}
diff --git a/crates/openlogi-gui/src/components/light_visual.rs b/crates/openlogi-gui/src/components/light_visual.rs
new file mode 100644
index 0000000000000000000000000000000000000000..cb48ae37d1b9cc3acfdcd75500d36b64af7cc374
--- /dev/null
+++ b/crates/openlogi-gui/src/components/light_visual.rs
@@ -0,0 +1,159 @@
+//! Shared standalone-light visuals used by the gallery and detail screen.
+//!
+//! Known models can opt into source-owned product artwork. Unknown models keep
+//! the protocol-neutral generated visual and never borrow another model's
+//! image or diffuser geometry.
+
+use gpui::{AnyElement, BoxShadow, IntoElement, ParentElement, Styled, div, hsla, img, point, px};
+use gpui_component::{Icon, IconName};
+use openlogi_core::config::LightSettings;
+
+use crate::asset::ResolvedAsset;
+use crate::theme::Palette;
+
+/// Render a standalone light inside a home-gallery image slot.
+pub(crate) fn gallery(
+    asset: Option<&ResolvedAsset>,
+    online: bool,
+    enabled: bool,
+    settings: LightSettings,
+    pal: Palette,
+) -> AnyElement {
+    if let Some(asset) = asset {
+        visual_container()
+            .child(product_image(asset, 210., 180., online))
+            .into_any_element()
+    } else {
+        generated_visual(210., 180., online, enabled, settings, pal).into_any_element()
+    }
+}
+
+/// Render a standalone light as the large hero in its detail view.
+pub(crate) fn detail(
+    asset: Option<&ResolvedAsset>,
+    online: bool,
+    enabled: bool,
+    settings: LightSettings,
+    pal: Palette,
+) -> gpui::Div {
+    let content = if let Some(asset) = asset {
+        product_image(asset, 536., 460., online)
+    } else {
+        generated_visual(536., 460., online, enabled, settings, pal)
+    };
+    visual_container()
+        .flex_1()
+        .min_w(px(440.))
+        .h(px(520.))
+        .rounded(pal.card_radius)
+        .border_1()
+        .border_color(pal.border)
+        .bg(pal.surface)
+        .overflow_hidden()
+        .child(content)
+}
+
+fn product_image(asset: &ResolvedAsset, width: f32, height: f32, online: bool) -> gpui::Div {
+    let image_opacity = if online { 1. } else { 0.5 };
+    div()
+        .relative()
+        .flex()
+        .items_center()
+        .justify_center()
+        .w(px(width))
+        .h(px(height))
+        .overflow_hidden()
+        .opacity(image_opacity)
+        // `size_full` lets transparent product artwork escape this slot when
+        // its intrinsic aspect ratio differs from the slot. Keep the source
+        // aspect ratio while bounding both dimensions to the slot.
+        .child(img(asset.image_path.clone()).max_w_full().max_h_full())
+}
+
+fn visual_container() -> gpui::Div {
+    div()
+        .relative()
+        .w_full()
+        .flex()
+        .items_center()
+        .justify_center()
+}
+
+fn generated_visual(
+    width: f32,
+    height: f32,
+    online: bool,
+    enabled: bool,
+    settings: LightSettings,
+    pal: Palette,
+) -> gpui::Div {
+    let powered = online && enabled;
+    let glow = light_color(settings.temperature_kelvin.unwrap_or(4600));
+    let brightness = f32::from(settings.brightness_percent.min(100)) / 100.;
+    let halo_size = width.min(height) * 0.56;
+    let face_size = halo_size * 0.58;
+
+    let halo = div()
+        .size(px(halo_size))
+        .flex()
+        .items_center()
+        .justify_center()
+        .rounded_full()
+        .bg(if powered {
+            glow.opacity(0.08 + brightness * 0.18)
+        } else {
+            pal.surface_hover
+        });
+    let halo = if powered {
+        halo.shadow(vec![BoxShadow {
+            color: glow.opacity(0.12 + brightness * 0.2),
+            offset: point(px(0.), px(0.)),
+            blur_radius: px(34.),
+            spread_radius: px(3.),
+            inset: false,
+        }])
+    } else {
+        halo
+    };
+
+    div()
+        .w(px(width))
+        .h(px(height))
+        .flex()
+        .items_center()
+        .justify_center()
+        .opacity(if online { 1. } else { 0.5 })
+        .child(
+            halo.child(
+                div()
+                    .size(px(face_size))
+                    .flex()
+                    .items_center()
+                    .justify_center()
+                    .rounded_full()
+                    .border_1()
+                    .border_color(if powered {
+                        glow.opacity(0.55)
+                    } else {
+                        pal.border
+                    })
+                    .bg(if powered {
+                        glow.opacity(0.2)
+                    } else {
+                        pal.surface
+                    })
+                    .child(Icon::new(IconName::Sun).size_12().text_color(if powered {
+                        glow
+                    } else {
+                        pal.text_muted
+                    })),
+            ),
+        )
+}
+
+fn light_color(kelvin: u16) -> gpui::Hsla {
+    let normalized = (f32::from(kelvin.clamp(2700, 6500)) - 2700.) / 3800.;
+    let hue = 0.09 + normalized * 0.05;
+    let saturation = 0.9 - normalized * 0.48;
+    hsla(hue, saturation, 0.68, 1.)
+}
diff --git a/crates/openlogi-gui/src/components/mod.rs b/crates/openlogi-gui/src/components/mod.rs
index 51b5587db858f39222651cbddd8fd0d0bd295e9e..d1a6482015b51cb7eb3c2eef0dbaf9eb112a1254 100644
--- a/crates/openlogi-gui/src/components/mod.rs
+++ b/crates/openlogi-gui/src/components/mod.rs
@@ -4,9 +4,13 @@
 //! widget owns its local state; cross-widget coordination happens through
 //! [`crate::state::AppState`].
 
+pub mod camera_controls;
+pub mod camera_preview;
 pub mod carousel;
 pub mod device_read;
 pub mod dpi_panel;
+pub mod light_panel;
+pub mod light_visual;
 pub mod lighting_panel;
 pub mod smartshift_panel;
 pub mod status;
diff --git a/crates/openlogi-gui/src/data/mouse_buttons.rs b/crates/openlogi-gui/src/data/mouse_buttons.rs
index 90b3123d5d4e1a3e43d873ac2d4dbb9dc4df9bcd..816266703b98ebac94c23d3e22732a3f9e6b4674 100644
--- a/crates/openlogi-gui/src/data/mouse_buttons.rs
+++ b/crates/openlogi-gui/src/data/mouse_buttons.rs
@@ -13,7 +13,7 @@
 )]
 
 pub use openlogi_core::binding::{
-    Action, ButtonId, Category, GestureDirection, default_binding, default_gesture_binding,
+    Action, Binding, ButtonId, Category, GestureDirection, default_binding, default_gesture_binding,
 };
 
 /// One visual target in the mouse diagram.
@@ -157,9 +157,11 @@ mod tests {
 
     #[test]
     fn fallback_thumbwheel_is_capability_gated() {
-        assert!(!default_hotspots(false).iter().any(|hotspot| {
-            hotspot.id == MouseControlId::ThumbwheelRotation
-        }));
+        assert!(
+            !default_hotspots(false)
+                .iter()
+                .any(|hotspot| { hotspot.id == MouseControlId::ThumbwheelRotation })
+        );
         assert_eq!(
             default_hotspots(true)
                 .iter()
@@ -173,9 +175,9 @@ mod tests {
     fn default_hotspots_expose_the_gesture_button() {
         let hotspots = default_hotspots(false);
         assert!(
-            hotspots.iter().any(|h| {
-                h.id == MouseControlId::Button(ButtonId::GestureButton)
-            }),
+            hotspots
+                .iter()
+                .any(|h| { h.id == MouseControlId::Button(ButtonId::GestureButton) }),
             "the gesture button must be a mappable hotspot in the synthetic model"
         );
     }
diff --git a/crates/openlogi-gui/src/diagnostics.rs b/crates/openlogi-gui/src/diagnostics.rs
index 5044859a75869654e971066d19fdd4e594250ecc..2f67e324b4a06f2c7fff6d126909a191465b904e 100644
--- a/crates/openlogi-gui/src/diagnostics.rs
+++ b/crates/openlogi-gui/src/diagnostics.rs
@@ -125,7 +125,9 @@ fn collect_devices(state: &AppState) -> Vec<DeviceDiag> {
                 battery: record.battery.clone(),
                 capabilities: record.capabilities,
                 dpi: dpi_summary(state.dpi_status_for(&record.config_key)),
-                config_key: record.config_key.clone(),
+                // Diagnostics are model-level by contract. The runtime config
+                // key may contain a receiver UID or raw-device serial.
+                config_key: record.model_key.clone(),
                 wpid: paired.and_then(|p| p.wpid),
                 model_ids: model.map(|m| m.model_ids),
                 extended_model_id: model.map(|m| m.extended_model_id),
@@ -164,6 +166,7 @@ fn connection_for(
             Some(t) if t.usb => ConnectionKind::Wired,
             _ => ConnectionKind::Unknown,
         },
+        Some(DeviceRoute::RawHid { .. }) => ConnectionKind::Wired,
         None => ConnectionKind::Unknown,
     }
 }
diff --git a/crates/openlogi-gui/src/i18n.rs b/crates/openlogi-gui/src/i18n.rs
index 94944fc2ac0780ed0f7f7ab507268f9849b5139c..1a6e49c4e7ba80e9326fe0a5c19ba4f4b2eb1a7b 100644
--- a/crates/openlogi-gui/src/i18n.rs
+++ b/crates/openlogi-gui/src/i18n.rs
@@ -1,11 +1,12 @@
 //! UI localization plumbing.
 //!
 //! Translations live in `crates/openlogi-gui/locales/*.yml` and are loaded at
-//! compile time by the `rust_i18n::i18n!` macro in `main.rs`. Crowdin manages one
-//! file per locale: `en.yml` is the source file, and every other locale in
-//! [`SUPPORTED`] is downloaded as a translated YAML file. Call sites use the
-//! [`tr!`](crate::tr) helper (or `rust_i18n::t!`) with the **English string as
-//! the key**.
+//! compile time by the `rust_i18n::i18n!` macro in `main.rs` (fallback `"en"`).
+//! **`en.yml` is the only source of truth** for UI strings — edit that file when
+//! adding or changing copy. Crowdin owns non-English catalogs (`SUPPORTED`
+//! minus `en`); the Crowdin workflow downloads them. Call sites use
+//! [`tr!`](crate::tr) / `rust_i18n::t!` with the **English string as the key**.
+//! Missing keys in a non-English file fall back to English at runtime.
 //!
 //! The current locale is a process-global atomic inside `rust_i18n`. Setting it
 //! re-localizes both our own call sites *and* gpui-component's built-in widget
@@ -295,9 +296,20 @@ mod tests {
         assert_eq!(rust_i18n::t!(BLURB), BLURB);
     }
 
+    /// Non-English catalogs may lag `en.yml` until Crowdin syncs (runtime falls
+    /// back to English). They must never introduce keys that are not in `en.yml`.
     #[test]
-    fn locale_files_have_the_same_keys() {
-        let source = locale_keys(include_str!("../locales/en.yml"));
+    fn locale_files_keys_are_subset_of_en() {
+        use std::collections::BTreeSet;
+
+        let source: BTreeSet<&str> = locale_keys(include_str!("../locales/en.yml"))
+            .into_iter()
+            .collect();
+        assert!(
+            !source.is_empty(),
+            "en.yml is the string source of truth and must define keys"
+        );
+
         for (locale, file) in [
             ("ja", include_str!("../locales/ja.yml")),
             ("ru", include_str!("../locales/ru.yml")),
@@ -319,8 +331,12 @@ mod tests {
             ("pt-PT", include_str!("../locales/pt-PT.yml")),
             ("sv", include_str!("../locales/sv.yml")),
         ] {
-            let keys = locale_keys(file);
-            assert_eq!(keys, source, "{locale}.yml keys drifted from en.yml");
+            let keys: BTreeSet<&str> = locale_keys(file).into_iter().collect();
+            let extras: Vec<&str> = keys.difference(&source).copied().collect();
+            assert!(
+                extras.is_empty(),
+                "{locale}.yml has keys not in en.yml (edit en.yml only; Crowdin owns other locales): {extras:?}"
+            );
         }
     }
 
diff --git a/crates/openlogi-gui/src/ipc_client.rs b/crates/openlogi-gui/src/ipc_client.rs
index 73040715f4f650245bc124f9f670c6f4d0853578..80660b90cfaca975999828f0d48c4d1b7d6f75f7 100644
--- a/crates/openlogi-gui/src/ipc_client.rs
+++ b/crates/openlogi-gui/src/ipc_client.rs
@@ -24,9 +24,10 @@ use openlogi_agent_core::ipc::{
     PairingFailure, PairingUpdate,
 };
 use openlogi_core::config::Lighting;
-use openlogi_core::device::DeviceInventory;
+use openlogi_core::device::{DeviceInventory, StandaloneDevice};
 use openlogi_hid::{
-    DeviceRoute, DpiInfo, ReceiverSelector, SmartShiftMode, SmartShiftStatus, WriteError,
+    DeviceRoute, DpiInfo, LightCommand, ReceiverSelector, SmartShiftMode, SmartShiftStatus,
+    WriteError,
 };
 use tarpc::client;
 use tarpc::context;
@@ -65,20 +66,36 @@ pub enum GuiUpdate {
     /// updated on disk while this GUI kept running, and only a relaunch
     /// helps. Sent once per episode.
     OutdatedGui,
+    /// Result of an agent-owned standalone-light command. The typed failure
+    /// reaches the GPUI state model instead of being reduced to a log line.
+    LightCommandResult {
+        /// Runtime/config key of the light that issued the command.
+        key: String,
+        /// Monotonic request id used to ignore stale results.
+        request_id: u64,
+        /// The control whose write produced this result.
+        command: LightCommand,
+        /// Agent acceptance or typed device failure.
+        result: Result<(), WriteError>,
+    },
 }
 
 /// A poll snapshot pushed to the GPUI loop on every successful poll round.
 pub struct PollUpdate {
     pub inventory: Vec<DeviceInventory>,
+    pub standalone: Vec<StandaloneDevice>,
     pub status: AgentStatus,
+    pub camera_active: bool,
 }
 
 /// A device command sent from the GPUI thread to the client thread. Reads carry
-/// a `oneshot` for the reply; "apply now" writes are fire-and-forget (the GUI
-/// updates its display optimistically and the client logs any device failure).
+/// a `oneshot` for the reply; standalone-light writes return a result event so
+/// the GUI can surface device failures after an optimistic update.
 pub enum Command {
     SetDpi(DeviceRoute, u32),
     SetLighting(DeviceRoute, Lighting),
+    SetLight(DeviceRoute, LightCommand, String, u64),
+    SetLightManualPower(DeviceRoute, bool, String, u64),
     SetSmartShift(DeviceRoute, SmartShiftMode, u8, u8),
     ReadDpi(DeviceRoute, oneshot::Sender<Result<DpiInfo, WriteError>>),
     ReadSmartShift(
@@ -224,7 +241,7 @@ async fn poll_loop(
             }
             cmd = cmd_rx.recv() => {
                 let Some(cmd) = cmd else { break }; // GUI dropped the sender → shut down
-                if handle(&mut client, pairing_tx, cmd).await.is_err() {
+                if handle(&mut client, update_tx, pairing_tx, cmd).await.is_err() {
                     // Same as a poll-detected drop: back to the fast cadence
                     // so the reconnect (agent self-exec, crash) re-converges
                     // just as quickly as at startup.
@@ -527,8 +544,15 @@ async fn poll(
     let snapshot = client.snapshot(context::current()).await.map_err(|_| ())?;
     let status = snapshot.status;
     let inventory = snapshot.inventory;
+    let standalone = snapshot.standalone;
+    let camera_active = snapshot.camera_active;
     let ready = status.inventory == InventoryHealth::Ready;
-    let _ = update_tx.send(GuiUpdate::Snapshot(PollUpdate { inventory, status }));
+    let _ = update_tx.send(GuiUpdate::Snapshot(PollUpdate {
+        inventory,
+        standalone,
+        status,
+        camera_active,
+    }));
     Ok(PollOutcome::Delivered { ready })
 }
 
@@ -536,12 +560,13 @@ async fn poll(
 /// reconnects; the command's own failure is reported back over its oneshot.
 async fn handle(
     client: &mut Option<AgentClient>,
+    update_tx: &mpsc::UnboundedSender<GuiUpdate>,
     pairing_tx: &mpsc::UnboundedSender<PairingUpdate>,
     cmd: Command,
 ) -> Result<(), ()> {
     // keep `client` None on connect failure; that's not a dropped live connection
     let Ok(client) = ensure(client).await else {
-        reply_disconnected(pairing_tx, cmd);
+        reply_disconnected(update_tx, pairing_tx, cmd);
         return Ok(());
     };
     let ctx = context::current();
@@ -550,6 +575,24 @@ async fn handle(
         Command::SetLighting(route, lighting) => {
             log_apply(client.set_lighting(ctx, route, lighting).await)?;
         }
+        Command::SetLight(route, command, key, request_id) => {
+            send_light_result(
+                update_tx,
+                key,
+                request_id,
+                command,
+                client.set_light(ctx, route, command).await,
+            )?;
+        }
+        Command::SetLightManualPower(route, enabled, key, request_id) => {
+            send_light_result(
+                update_tx,
+                key,
+                request_id,
+                LightCommand::Power(enabled),
+                client.set_light_manual_power(ctx, route, enabled).await,
+            )?;
+        }
         Command::SetSmartShift(route, mode, auto, torque) => {
             log_apply(client.set_smartshift(ctx, route, mode, auto, torque).await)?;
         }
@@ -607,6 +650,32 @@ fn log_apply(r: Result<Result<(), WriteError>, tarpc::client::RpcError>) -> Resu
     }
 }
 
+fn send_light_result(
+    update_tx: &mpsc::UnboundedSender<GuiUpdate>,
+    key: String,
+    request_id: u64,
+    command: LightCommand,
+    result: Result<Result<(), WriteError>, tarpc::client::RpcError>,
+) -> Result<(), ()> {
+    if let Ok(result) = result {
+        let _ = update_tx.send(GuiUpdate::LightCommandResult {
+            key,
+            request_id,
+            command,
+            result,
+        });
+        Ok(())
+    } else {
+        let _ = update_tx.send(GuiUpdate::LightCommandResult {
+            key,
+            request_id,
+            command,
+            result: Err(WriteError::AgentUnavailable),
+        });
+        Err(())
+    }
+}
+
 /// Unwrap a tarpc transport result: `Err(())` (connection dropped) propagates so
 /// the caller reconnects; the inner application `Result` is returned for the reply.
 fn rpc_result<T>(r: Result<T, tarpc::client::RpcError>) -> Result<T, ()> {
@@ -619,7 +688,11 @@ fn rpc_result<T>(r: Result<T, tarpc::client::RpcError>) -> Result<T, ()> {
     clippy::match_same_arms,
     reason = "the two read arms send the same disconnect error to differently-typed reply channels, so they can't be merged"
 )]
-fn reply_disconnected(pairing_tx: &mpsc::UnboundedSender<PairingUpdate>, cmd: Command) {
+fn reply_disconnected(
+    update_tx: &mpsc::UnboundedSender<GuiUpdate>,
+    pairing_tx: &mpsc::UnboundedSender<PairingUpdate>,
+    cmd: Command,
+) {
     // Transient, not a permanent feature error: the agent is just restarting,
     // so the panel should keep retrying, not latch "unsupported".
     match cmd {
@@ -629,6 +702,22 @@ fn reply_disconnected(pairing_tx: &mpsc::UnboundedSender<PairingUpdate>, cmd: Co
         Command::ReadSmartShift(_, reply) => {
             let _ = reply.send(Err(WriteError::AgentUnavailable));
         }
+        Command::SetLight(_, command, key, request_id) => {
+            let _ = update_tx.send(GuiUpdate::LightCommandResult {
+                key,
+                request_id,
+                command,
+                result: Err(WriteError::AgentUnavailable),
+            });
+        }
+        Command::SetLightManualPower(_, enabled, key, request_id) => {
+            let _ = update_tx.send(GuiUpdate::LightCommandResult {
+                key,
+                request_id,
+                command: LightCommand::Power(enabled),
+                result: Err(WriteError::AgentUnavailable),
+            });
+        }
         Command::StartPairing(_) | Command::PairDevice(_) => {
             let _ = pairing_tx.send(PairingUpdate::Failed(PairingFailure::AgentRestarted));
         }
diff --git a/crates/openlogi-gui/src/keyboard_model/editors.rs b/crates/openlogi-gui/src/keyboard_model/editors.rs
new file mode 100644
index 0000000000000000000000000000000000000000..2c5142a1c6ee99685b64d90627fcd57165a7fbab
--- /dev/null
+++ b/crates/openlogi-gui/src/keyboard_model/editors.rs
@@ -0,0 +1,377 @@
+//! Inline editors for the parameterised power-user actions, shown inside the
+//! config panel (the side inspector) once one is selected from the list.
+//!
+//! Each editor reuses the shared [`menu_card`] surface. Draft state lives on
+//! the [`FunctionRowView`] so it survives re-rendering. Closing the editor
+//! returns to the action list; the panel itself closes when the key is
+//! deselected.
+//!
+//! [`menu_card`]: crate::mouse_model::picker::menu_card
+
+#![allow(
+    clippy::needless_pass_by_value,
+    clippy::redundant_closure,
+    clippy::redundant_closure_for_method_calls,
+    reason = "GPUI builders take owned Copy palette values; entity.update wants closures"
+)]
+
+use std::rc::Rc;
+
+use gpui::{
+    AnyElement, BorrowAppContext as _, Context, Entity, FontWeight, IntoElement, ParentElement,
+    StatefulInteractiveElement as _, Styled, div, px, svg,
+};
+use gpui_component::{
+    Icon, IconName, Sizable as _,
+    button::{Button, ButtonVariants},
+    h_flex,
+    input::Input,
+    input::InputState,
+    v_flex,
+};
+use openlogi_core::binding::{Action, KeyCombo, WorkflowStep};
+use openlogi_core::config::KeyTrigger;
+
+use crate::keyboard_model::function_row::FunctionRowView;
+use crate::mouse_model::picker::{PickFn, divider, menu_card, menu_row, scroll_list, title};
+use crate::state::AppState;
+use crate::theme::Palette;
+
+/// Which power-user editor is showing for the selected key.
+#[derive(Copy, Clone, Debug, PartialEq, Eq)]
+pub enum PowerUserKind {
+    TypeText,
+    RunAppleScript,
+    RunShellCommand,
+    Workflow,
+}
+
+impl PowerUserKind {
+    fn heading(self) -> &'static str {
+        match self {
+            Self::TypeText => "Type Text",
+            Self::RunAppleScript => "Run AppleScript",
+            Self::RunShellCommand => "Run Shell Command",
+            Self::Workflow => "Workflow",
+        }
+    }
+}
+
+pub(crate) fn text_editor_placeholder(kind: PowerUserKind) -> &'static str {
+    match kind {
+        PowerUserKind::TypeText => "Text to type…",
+        PowerUserKind::RunAppleScript => "display dialog \"Hello\"",
+        PowerUserKind::RunShellCommand => "echo hello",
+        PowerUserKind::Workflow => "",
+    }
+}
+
+pub(crate) fn text_editor_seed(action: Option<&Action>, kind: PowerUserKind) -> String {
+    match (action, kind) {
+        (Some(Action::TypeText(text)), PowerUserKind::TypeText)
+        | (Some(Action::RunAppleScript(text)), PowerUserKind::RunAppleScript)
+        | (Some(Action::RunShellCommand(text)), PowerUserKind::RunShellCommand) => text.clone(),
+        _ => String::new(),
+    }
+}
+
+pub(crate) fn workflow_editor_seed(action: Option<&Action>) -> Vec<WorkflowStep> {
+    match action {
+        Some(Action::Workflow(steps)) => steps.clone(),
+        _ => Vec::new(),
+    }
+}
+
+/// Render the editor card for `kind`, replacing the panel's action list.
+pub fn editor_card(
+    trigger: KeyTrigger,
+    kind: PowerUserKind,
+    text_state: Option<Entity<InputState>>,
+    workflow_draft: Vec<WorkflowStep>,
+    view: &Entity<FunctionRowView>,
+    pal: Palette,
+    cx: &mut Context<FunctionRowView>,
+) -> AnyElement {
+    match kind {
+        PowerUserKind::Workflow => workflow_editor_card(trigger, workflow_draft, view, pal, cx),
+        _ => match text_state {
+            Some(state) => text_editor_card(trigger, kind, state, view, pal, cx),
+            None => menu_card(pal)
+                .w(px(300.))
+                .child(title(tr!("Editor unavailable"), pal))
+                .into_any_element(),
+        },
+    }
+}
+
+/// The TypeText / RunAppleScript / RunShellCommand editors share a single text
+/// field; only the commit wrapping differs.
+fn text_editor_card(
+    trigger: KeyTrigger,
+    kind: PowerUserKind,
+    text_state: Entity<InputState>,
+    view: &Entity<FunctionRowView>,
+    pal: Palette,
+    cx: &mut Context<FunctionRowView>,
+) -> AnyElement {
+    let heading = kind.heading();
+    let key_name = trigger.to_string();
+
+    menu_card(pal)
+        .w(px(300.))
+        .child(title(
+            tr!("%{action} · %{key}", action => heading, key => key_name),
+            pal,
+        ))
+        .child(divider(pal))
+        .child(
+            v_flex()
+                .p_2()
+                .gap_2()
+                .child(div().child(Input::new(&text_state).cleanable(true)))
+                .child(editor_action_row(trigger, kind, view, pal, cx)),
+        )
+        .into_any_element()
+}
+
+/// Cancel (back to list) + Save (commit the drafted text).
+fn editor_action_row(
+    trigger: KeyTrigger,
+    kind: PowerUserKind,
+    view: &Entity<FunctionRowView>,
+    _pal: Palette,
+    _cx: &mut Context<FunctionRowView>,
+) -> AnyElement {
+    let view_save = view.clone();
+    let trigger_save = trigger.clone();
+    let view_cancel = view.clone();
+
+    h_flex()
+        .gap_2()
+        .justify_end()
+        .child(
+            Button::new("editor-cancel")
+                .ghost()
+                .label(tr!("Cancel"))
+                .on_click(move |_e, _window, cx| {
+                    view_cancel.update(cx, |v, vcx| v.close_editor(vcx));
+                }),
+        )
+        .child(
+            Button::new("editor-save")
+                .primary()
+                .label(tr!("Save"))
+                .on_click(move |_e, _window, cx| {
+                    let text = view_save
+                        .read(cx)
+                        .text_state()
+                        .map(|s| s.read(cx).value().to_string())
+                        .unwrap_or_default();
+                    let action = match kind {
+                        PowerUserKind::TypeText => Action::TypeText(text),
+                        PowerUserKind::RunAppleScript => Action::RunAppleScript(text),
+                        PowerUserKind::RunShellCommand => Action::RunShellCommand(text),
+                        PowerUserKind::Workflow => return,
+                    };
+                    cx.update_global::<AppState, _>(|state, _| {
+                        state.commit_keyboard_binding(trigger_save.clone(), Some(action));
+                    });
+                    view_save.update(cx, |v, vcx| v.close_editor(vcx));
+                }),
+        )
+        .into_any_element()
+}
+
+/// The Workflow editor: a list of steps with add/remove.
+fn workflow_editor_card(
+    trigger: KeyTrigger,
+    steps: Vec<WorkflowStep>,
+    view: &Entity<FunctionRowView>,
+    pal: Palette,
+    cx: &mut Context<FunctionRowView>,
+) -> AnyElement {
+    let key_name = trigger.to_string();
+
+    let mut rows: Vec<AnyElement> = Vec::new();
+    for (idx, step) in steps.iter().enumerate() {
+        rows.push(workflow_step_row(idx, step.clone(), view, pal, cx));
+    }
+
+    menu_card(pal)
+        .w(px(320.))
+        .child(title(tr!("Workflow · %{key}", key => key_name), pal))
+        .child(divider(pal))
+        .child(scroll_list("workflow-steps", rows))
+        .child(
+            h_flex()
+                .p_2()
+                .gap_2()
+                .justify_between()
+                .child(
+                    Button::new("wf-add-step")
+                        .ghost()
+                        .small()
+                        .label(tr!("+ Add Step"))
+                        .on_click({
+                            let v = view.clone();
+                            move |_e, _w, cx| {
+                                v.update(cx, |v, vcx| {
+                                    v.push_workflow_step(
+                                        WorkflowStep::TypeText(String::new()),
+                                        vcx,
+                                    );
+                                });
+                            }
+                        }),
+                )
+                .child(
+                    Button::new("wf-save")
+                        .primary()
+                        .label(tr!("Save Workflow"))
+                        .on_click({
+                            let v = view.clone();
+                            let trigger = trigger.clone();
+                            move |_e, _window, cx| {
+                                let steps = v.read(cx).workflow_draft().to_vec();
+                                let action = Action::Workflow(steps);
+                                cx.update_global::<AppState, _>(|state, _| {
+                                    state.commit_keyboard_binding(trigger.clone(), Some(action));
+                                });
+                                v.update(cx, |v, vcx| v.close_editor(vcx));
+                            }
+                        }),
+                ),
+        )
+        .into_any_element()
+}
+
+/// One Workflow step row: type chip + payload preview + remove button.
+fn workflow_step_row(
+    idx: usize,
+    step: WorkflowStep,
+    view: &Entity<FunctionRowView>,
+    pal: Palette,
+    _cx: &mut Context<FunctionRowView>,
+) -> AnyElement {
+    let (type_label, glyph): (&'static str, &'static str) = match &step {
+        WorkflowStep::TypeText(_) => ("Type Text", "action-icons/keyboard.svg"),
+        WorkflowStep::PressKey(_) => ("Press Key", "action-icons/keyboard.svg"),
+        WorkflowStep::Delay { .. } => ("Delay", "action-icons/chevrons-right.svg"),
+        WorkflowStep::RunAppleScript(_) => ("AppleScript", "action-icons/terminal.svg"),
+        WorkflowStep::RunShellCommand(_) => ("Shell", "action-icons/terminal.svg"),
+    };
+    let view_remove = view.clone();
+
+    menu_row(("wf-step", idx), pal, false)
+        .child(
+            h_flex()
+                .w_full()
+                .items_center()
+                .gap_2()
+                .child(
+                    svg()
+                        .path(glyph)
+                        .size_4()
+                        .flex_none()
+                        .text_color(pal.text_muted),
+                )
+                .child(
+                    div()
+                        .text_xs()
+                        .font_weight(FontWeight::MEDIUM)
+                        .text_color(pal.text_muted)
+                        .child(type_label),
+                )
+                .child(div().flex_1().child(step_preview(&step, pal))),
+        )
+        .child(
+            Icon::new(IconName::Close)
+                .size_3()
+                .text_color(pal.text_muted),
+        )
+        .on_click(move |_e, _w, cx| {
+            view_remove.update(cx, |v, vcx| v.remove_workflow_step(idx, vcx));
+        })
+        .into_any_element()
+}
+
+fn step_preview(step: &WorkflowStep, pal: Palette) -> AnyElement {
+    let text: String = match step {
+        WorkflowStep::TypeText(s) => {
+            if s.is_empty() {
+                "…".to_string()
+            } else {
+                format!("“{s}”")
+            }
+        }
+        WorkflowStep::PressKey(k) => key_combo_preview(k),
+        WorkflowStep::Delay { millis } => format!("{millis} ms"),
+        WorkflowStep::RunAppleScript(s) | WorkflowStep::RunShellCommand(s) => {
+            if s.is_empty() {
+                "…".to_string()
+            } else {
+                s.clone()
+            }
+        }
+    };
+    div()
+        .text_xs()
+        .text_color(pal.text_primary)
+        .child(text)
+        .into_any_element()
+}
+
+fn key_combo_preview(combo: &KeyCombo) -> String {
+    if !combo.display.is_empty() {
+        combo.display.clone()
+    } else if combo.key_code == 0 {
+        "—".to_string()
+    } else {
+        format!("key 0x{:02X}", combo.key_code)
+    }
+}
+
+#[allow(dead_code, reason = "kept for parity with the mouse picker")]
+fn _silence_pickfn() -> PickFn {
+    Rc::new(|_a: Action, _w: &mut gpui::Window, _cx: &mut gpui::App| {})
+}
+
+#[cfg(test)]
+mod tests {
+    use super::*;
+
+    #[test]
+    fn text_editor_seed_only_uses_matching_power_user_action() {
+        assert_eq!(
+            text_editor_seed(
+                Some(&Action::RunAppleScript(
+                    "tell app \"Finder\" to activate".into()
+                )),
+                PowerUserKind::RunAppleScript,
+            ),
+            "tell app \"Finder\" to activate"
+        );
+        assert_eq!(
+            text_editor_seed(
+                Some(&Action::RunShellCommand("echo nope".into())),
+                PowerUserKind::RunAppleScript,
+            ),
+            ""
+        );
+    }
+
+    #[test]
+    fn workflow_editor_seed_only_uses_workflow_action() {
+        let steps = vec![WorkflowStep::TypeText("hello".into())];
+        assert_eq!(
+            workflow_editor_seed(Some(&Action::Workflow(steps.clone()))),
+            steps
+        );
+        assert!(
+            workflow_editor_seed(Some(&Action::RunAppleScript(
+                "display dialog \"Hello\"".into()
+            )))
+            .is_empty()
+        );
+    }
+}
diff --git a/crates/openlogi-gui/src/keyboard_model/function_row.rs b/crates/openlogi-gui/src/keyboard_model/function_row.rs
new file mode 100644
index 0000000000000000000000000000000000000000..07c95336d742ce3707c31315393323a6b10f7c5b
--- /dev/null
+++ b/crates/openlogi-gui/src/keyboard_model/function_row.rs
@@ -0,0 +1,1423 @@
+//! The keyboard function-row remapper view — the Keys tab body.
+//!
+//! A two-pane inspector model (the "pro-tool" layout): the keyboard photo sits
+//! beside a row of mouse-style callout bubbles, and clicking a function key
+//! **selects** it (no popover). A tall, scrollable config panel slides in on the
+//! right while the keyboard physically makes room. Only one key is selected at a
+//! time.
+//!
+//! F-key bindings are global (`AppState`'s keyboard map), committed via
+//! [`AppState::commit_keyboard_binding`]. The panel lists the same action
+//! catalog the mouse picker uses, plus a Power User section.
+
+#![allow(
+    clippy::cast_precision_loss,
+    clippy::float_cmp,
+    clippy::needless_pass_by_value,
+    clippy::too_many_arguments,
+    reason = "GPUI builders take owned Copy palette/slots; layout math uses small f32 counts"
+)]
+
+use std::rc::Rc;
+use std::sync::Arc;
+
+use gpui::{
+    AnyElement, AppContext as _, BorrowAppContext as _, Bounds, Context, Entity, FontWeight, Hsla,
+    InteractiveElement, IntoElement, ParentElement, PathBuilder, Render,
+    StatefulInteractiveElement as _, Styled, Subscription, Window, canvas, div, hsla, point,
+    prelude::FluentBuilder as _, px, rgb, svg,
+};
+use gpui_component::{h_flex, input::InputState, v_flex};
+use openlogi_core::binding::WorkflowStep;
+use openlogi_core::config::{KeyModifiers, KeyTrigger};
+
+use crate::app::{glow_canvas, keyboard_glow};
+use crate::asset::{GlowGeometry, ResolvedAsset};
+use crate::data::mouse_buttons::Action;
+use crate::keyboard_model::editors::{
+    PowerUserKind, text_editor_placeholder, text_editor_seed, workflow_editor_seed,
+};
+use crate::mouse_model::geometry::asset_dimensions_for_png;
+use crate::mouse_model::picker::{
+    PickFn, action_icon_path, action_rows, divider, menu_card, menu_row, scroll_list,
+    section_header,
+};
+use crate::state::AppState;
+use crate::theme::{self, ACCENT_BLUE, Palette};
+use gpui::ease_in_out;
+use gpui::{Animation, AnimationExt, img};
+
+/// The full programmable top row: Esc, then F1-F19. Each entry is the display
+/// label (on the key) + the [`KeyTrigger`] keycode it binds. MX Keys-class
+/// boards expose all 20; boards with a shorter F-row (a G513 has F1-F12)
+/// surface a prefix of this list, sized by the asset's key markers — see
+/// [`key_points`].
+const FUNCTION_KEYS: [(&str, u16); 20] = [
+    ("Esc", 0x35),
+    ("F1", 0x7A),
+    ("F2", 0x78),
+    ("F3", 0x63),
+    ("F4", 0x76),
+    ("F5", 0x60),
+    ("F6", 0x61),
+    ("F7", 0x62),
+    ("F8", 0x64),
+    ("F9", 0x65),
+    ("F10", 0x6D),
+    ("F11", 0x67),
+    ("F12", 0x6F),
+    ("F13", 0x69),
+    ("F14", 0x6B),
+    ("F15", 0x71),
+    ("F16", 0x6A),
+    ("F17", 0x40),
+    ("F18", 0x4F),
+    ("F19", 0x50),
+];
+
+/// Width of the config panel (CSS px) when a key is selected.
+const PANEL_W: f32 = 320.;
+/// Duration of the keyboard slide + panel slide animation.
+const SLIDE_MS: u64 = 180;
+/// Maximum keyboard render width in the Keys inspector.
+const KEYBOARD_W: f32 = 700.;
+/// Render size when no asset resolved: the placeholder box.
+const FALLBACK_KEYBOARD_SIZE: (f32, f32) = (KEYBOARD_W, 220.);
+/// Space above the keyboard reserved for function-key callouts.
+const CALLOUT_BAND_H: f32 = 118.;
+/// Vertical chrome around the keyboard pane (header, tab strip, screen
+/// padding, footer) — the viewport height minus this and the callout band is
+/// what the render may occupy before it scales down to fit.
+const KEYS_VERTICAL_RESERVE: f32 = 224.;
+/// Floor on the render height so a tiny window still shows a usable model.
+const KEYBOARD_MIN_IMG_H: f32 = 160.;
+const KEY_CALLOUT_W: f32 = 60.;
+const KEY_CALLOUT_H: f32 = 48.;
+const KEY_CALLOUT_TOP_UPPER: f32 = 4.;
+const KEY_CALLOUT_TOP_LOWER: f32 = 50.;
+const KEY_TARGET_W: f32 = 30.;
+const KEY_TARGET_H: f32 = 30.;
+const KEY_HOTSPOT_DOT: f32 = 12.;
+const FALLBACK_KEY_Y_FRAC: f32 = 0.153;
+/// Legacy pixel-marker depots (G513 family) mark F1-F12 but not Esc. Esc sits
+/// this many key pitches left of F1 on that chassis (measured on the render).
+const ESC_LEFT_OF_F1_PITCHES: f32 = 1.55;
+/// Logitech key markers are authored against a tighter internal keyboard
+/// image. The rendered `front.png` includes a little more top/left padding, so
+/// the raw marker lands high-left of the visible keycap center.
+const FRONT_MARKER_X_OFFSET_FRAC: f32 = 0.02;
+const FRONT_MARKER_Y_OFFSET_FRAC: f32 = 0.023;
+/// Even-spacing fallback band (fractions of image width) when no metadata.
+const EVEN_SPACING_START: f32 = 0.04;
+const EVEN_SPACING_END: f32 = 0.96;
+
+/// The function-row remapper view.
+pub struct FunctionRowView {
+    /// The single selected key index (0 = Esc), or `None` when nothing is
+    /// selected (no panel shown).
+    selected_key: Option<usize>,
+    /// The hovered function-row key index, shared by callout bubbles, key hit
+    /// zones, and leader lines.
+    hovered_key: Option<usize>,
+    /// Which power-user editor is showing in the panel, if any.
+    active_editor: Option<PowerUserKind>,
+    /// Lazily-created [`InputState`] for the text editors.
+    text_state: Option<Entity<InputState>>,
+    /// Draft copy of the Workflow steps under edit.
+    workflow_draft: Vec<WorkflowStep>,
+    _state_obs: Subscription,
+}
+
+impl FunctionRowView {
+    /// Create the view.
+    pub fn new(cx: &mut Context<Self>) -> Self {
+        let state_obs = cx.observe_global::<AppState>(|_view, cx| cx.notify());
+        Self {
+            selected_key: None,
+            hovered_key: None,
+            active_editor: None,
+            text_state: None,
+            workflow_draft: Vec::new(),
+            _state_obs: state_obs,
+        }
+    }
+
+    /// Select a key (or deselect with `None`), opening/closing the panel.
+    pub(crate) fn select_key(&mut self, idx: Option<usize>, cx: &mut Context<Self>) {
+        // Changing selection also drops any open editor + its drafts.
+        if self.selected_key != idx {
+            self.active_editor = None;
+            self.text_state = None;
+            self.workflow_draft.clear();
+        }
+        self.selected_key = idx;
+        cx.notify();
+    }
+
+    /// Toggle a key selection from a click on either its callout or key hit
+    /// target.
+    pub(crate) fn click_key(&mut self, idx: usize, cx: &mut Context<Self>) {
+        self.select_key(next_selection_after_click(self.selected_key, idx), cx);
+    }
+
+    #[allow(dead_code, reason = "public accessor for the selection state")]
+    pub(crate) fn selected_key(&self) -> Option<usize> {
+        self.selected_key
+    }
+
+    pub(crate) fn set_hovered_key(&mut self, idx: Option<usize>, cx: &mut Context<Self>) {
+        if self.hovered_key != idx {
+            self.hovered_key = idx;
+            cx.notify();
+        }
+    }
+
+    pub(crate) fn open_editor(&mut self, kind: PowerUserKind, cx: &mut Context<Self>) {
+        self.active_editor = Some(kind);
+        self.text_state = None;
+        self.workflow_draft.clear();
+        cx.notify();
+    }
+
+    pub(crate) fn close_editor(&mut self, cx: &mut Context<Self>) {
+        self.active_editor = None;
+        self.text_state = None;
+        self.workflow_draft.clear();
+        cx.notify();
+    }
+
+    pub(crate) fn text_state(&self) -> Option<Entity<InputState>> {
+        self.text_state.clone()
+    }
+
+    pub(crate) fn new_text_state(
+        &mut self,
+        seed: String,
+        placeholder: &str,
+        window: &mut Window,
+        cx: &mut Context<Self>,
+    ) -> Entity<InputState> {
+        let state = cx.new(|cx| {
+            let mut s = InputState::new(window, cx).placeholder(tr!(placeholder));
+            if !seed.is_empty() {
+                s.set_value(seed, window, cx);
+            }
+            s
+        });
+        self.text_state = Some(state.clone());
+        state
+    }
+
+    pub(crate) fn workflow_draft(&self) -> &[WorkflowStep] {
+        &self.workflow_draft
+    }
+
+    pub(crate) fn push_workflow_step(&mut self, step: WorkflowStep, cx: &mut Context<Self>) {
+        self.workflow_draft.push(step);
+        cx.notify();
+    }
+
+    pub(crate) fn remove_workflow_step(&mut self, idx: usize, cx: &mut Context<Self>) {
+        if idx < self.workflow_draft.len() {
+            self.workflow_draft.remove(idx);
+            cx.notify();
+        }
+    }
+}
+
+/// The app-state slice the view renders from: the device's asset, the global
+/// keyboard bindings, and the lighting glow (geometry + tinted colour).
+type StateSnapshot = (
+    Option<ResolvedAsset>,
+    Vec<(KeyTrigger, Action)>,
+    Option<(Arc<GlowGeometry>, Hsla)>,
+);
+
+impl Render for FunctionRowView {
+    fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
+        let pal = theme::palette(cx);
+        let (asset, bindings, glow): StateSnapshot = cx
+            .try_global::<AppState>()
+            .map(|s| {
+                (
+                    s.current_record().and_then(|r| r.asset.clone()),
+                    s.keyboard_bindings
+                        .iter()
+                        .map(|(k, v)| (k.clone(), v.clone()))
+                        .collect(),
+                    s.current_record().and_then(|r| keyboard_glow(s, r)),
+                )
+            })
+            .unwrap_or_default();
+
+        let viewport_h = f32::from(window.viewport_size().height);
+        let render_size = keyboard_render_size(asset.as_ref(), viewport_h);
+        let points = key_points(asset.as_ref());
+        let slots: Vec<KeySlot> = FUNCTION_KEYS
+            .iter()
+            .zip(points.iter())
+            .enumerate()
+            .map(|(idx, ((label, keycode), point))| {
+                let trigger = KeyTrigger {
+                    keycode: *keycode,
+                    modifiers: KeyModifiers::default(),
+                };
+                let bound = bindings
+                    .iter()
+                    .find(|(k, _)| *k == trigger)
+                    .map(|(_, a)| a.clone());
+                KeySlot {
+                    idx,
+                    label,
+                    trigger,
+                    x_frac: point.x_frac,
+                    y_frac: point.y_frac,
+                    bound,
+                }
+            })
+            .collect();
+
+        // A stale selection can outlive a device switch to a shorter F-row;
+        // drop it instead of indexing past the new slot list.
+        if self.selected_key.is_some_and(|idx| idx >= slots.len()) {
+            self.selected_key = None;
+            self.active_editor = None;
+            self.text_state = None;
+            self.workflow_draft.clear();
+        }
+        let selected = self.selected_key;
+        let hovered = self.hovered_key;
+        let active_editor = self.active_editor;
+        if let (Some(selected_idx), Some(kind)) = (selected, active_editor)
+            && let Some(slot) = slots.get(selected_idx)
+        {
+            let current_action = bindings
+                .iter()
+                .find(|(trigger, _)| trigger == &slot.trigger)
+                .map(|(_, action)| action);
+            match kind {
+                PowerUserKind::Workflow => {
+                    if self.workflow_draft.is_empty() {
+                        self.workflow_draft = workflow_editor_seed(current_action);
+                    }
+                }
+                _ => {
+                    if self.text_state.is_none() {
+                        self.new_text_state(
+                            text_editor_seed(current_action, kind),
+                            text_editor_placeholder(kind),
+                            window,
+                            cx,
+                        );
+                    }
+                }
+            }
+        }
+        let text_state = self.text_state.clone();
+        let workflow_draft = self.workflow_draft.clone();
+        let view = cx.entity();
+
+        // The whole row animates as one: when a key is selected the right-side
+        // panel grows in and the keyboard nudges left to make room.
+        v_flex().w_full().items_center().child(inspector_row(
+            slots,
+            asset,
+            glow,
+            render_size,
+            selected,
+            hovered,
+            active_editor,
+            text_state,
+            workflow_draft,
+            &view,
+            &pal,
+            window,
+            cx,
+        ))
+    }
+}
+
+/// The keyboard render size: the actual PNG aspect at up to [`KEYBOARD_W`]
+/// wide, shrunk to fit the viewport height. Sizing off the real aspect keeps
+/// `ObjectFit::Contain` from letterboxing and keeps the marker overlays
+/// registered with the rendered keys — the G513 render (with wrist rest) is
+/// nearly twice as tall as an MX Keys render at the same width.
+fn keyboard_render_size(asset: Option<&ResolvedAsset>, viewport_h: f32) -> (f32, f32) {
+    let Some(asset) = asset.filter(|a| a.png_height > 0) else {
+        return FALLBACK_KEYBOARD_SIZE;
+    };
+    let target_h = (viewport_h - KEYS_VERTICAL_RESERVE - CALLOUT_BAND_H).max(KEYBOARD_MIN_IMG_H);
+    asset_dimensions_for_png(asset, target_h, KEYBOARD_W)
+}
+
+/// One function-row key with its resolved layout + binding.
+#[derive(Clone)]
+struct KeySlot {
+    idx: usize,
+    label: &'static str,
+    trigger: KeyTrigger,
+    x_frac: f32,
+    y_frac: f32,
+    bound: Option<Action>,
+}
+
+/// The two-pane row: keyboard photo + (when a key is selected) the side panel.
+fn inspector_row(
+    slots: Vec<KeySlot>,
+    asset: Option<ResolvedAsset>,
+    glow: Option<(Arc<GlowGeometry>, Hsla)>,
+    render_size: (f32, f32),
+    selected: Option<usize>,
+    hovered: Option<usize>,
+    active_editor: Option<PowerUserKind>,
+    text_state: Option<Entity<InputState>>,
+    workflow_draft: Vec<WorkflowStep>,
+    view: &Entity<FunctionRowView>,
+    pal: &Palette,
+    window: &mut Window,
+    cx: &mut Context<FunctionRowView>,
+) -> impl IntoElement {
+    let keyboard = keyboard_pane(
+        slots.clone(),
+        asset.as_ref(),
+        glow,
+        render_size,
+        selected,
+        hovered,
+        view,
+        pal,
+    );
+
+    // When nothing is selected, just the keyboard, full width.
+    let Some(selected) = selected else {
+        return h_flex()
+            .w_full()
+            .justify_center()
+            .child(keyboard)
+            .into_any_element();
+    };
+
+    let panel = config_panel(
+        selected,
+        &slots,
+        active_editor,
+        text_state,
+        workflow_draft,
+        view,
+        pal,
+        window,
+        cx,
+    );
+
+    // The panel grows in from width 0 → PANEL_W over SLIDE_MS, easing in/out,
+    // always on the right as a stable inspector.
+    let animated_panel = div().overflow_hidden().child(panel).with_animation(
+        "panel-slide",
+        Animation::new(std::time::Duration::from_millis(SLIDE_MS)).with_easing(ease_in_out),
+        |el, delta| el.w(px(PANEL_W * delta)),
+    );
+
+    h_flex()
+        .w_full()
+        .gap_5()
+        .items_center()
+        .justify_center()
+        .child(keyboard)
+        .child(animated_panel)
+        .into_any_element()
+}
+
+/// The keyboard photo with callout bubbles above each function key, leader
+/// lines, and invisible click-targets over the real keys.
+fn keyboard_pane(
+    slots: Vec<KeySlot>,
+    asset: Option<&ResolvedAsset>,
+    glow: Option<(Arc<GlowGeometry>, Hsla)>,
+    (img_w, img_h): (f32, f32),
+    selected: Option<usize>,
+    hovered: Option<usize>,
+    view: &Entity<FunctionRowView>,
+    pal: &Palette,
+) -> impl IntoElement {
+    let img_path = asset.map(|a| a.image_path.clone());
+    let view_clone = view.clone();
+
+    div()
+        .relative()
+        .w(px(img_w))
+        .h(px(CALLOUT_BAND_H + img_h))
+        .child(
+            div()
+                .absolute()
+                .top(px(CALLOUT_BAND_H))
+                .left(px(0.))
+                .w(px(img_w))
+                .h(px(img_h))
+                // The keyboard's RGB paints *behind* the render, so the opaque
+                // keys occlude it and the colour only reads through the
+                // inter-key gaps — same treatment as the home gallery and the
+                // mouse model.
+                .when_some(glow, |this, (geom, color)| {
+                    this.child(glow_canvas(geom, color))
+                })
+                .child(image_or_fallback(img_path, img_w, img_h, pal)),
+        )
+        .child(keyboard_leader_canvas(
+            slots.clone(),
+            selected,
+            hovered,
+            (img_w, img_h),
+        ))
+        .children({
+            let count = slots.len();
+            let view_for_callouts = view_clone.clone();
+            slots.iter().cloned().map(move |s| {
+                let highlighted = key_is_highlighted(s.idx, selected, hovered);
+                key_callout(s, count, highlighted, img_w, &view_for_callouts, pal)
+            })
+        })
+        // Click-targets overlay, centered on each key's marker point.
+        .child(
+            div()
+                .absolute()
+                .top(px(CALLOUT_BAND_H))
+                .left(px(0.))
+                .w(px(img_w))
+                .h(px(img_h))
+                .children(slots.into_iter().map(|s| {
+                    let highlighted = key_is_highlighted(s.idx, selected, hovered);
+                    key_click_target(s, highlighted, (img_w, img_h), &view_clone, pal)
+                })),
+        )
+}
+
+/// One callout bubble in the band above the keyboard.
+fn key_callout(
+    slot: KeySlot,
+    count: usize,
+    highlighted: bool,
+    img_w: f32,
+    view: &Entity<FunctionRowView>,
+    pal: &Palette,
+) -> AnyElement {
+    let idx = slot.idx;
+    let left = callout_left_px(idx, count, img_w, KEY_CALLOUT_W);
+    let top = callout_top_px(idx);
+    let view_hover = view.clone();
+    let view_click = view.clone();
+    let binding = binding_label(slot.bound.as_ref());
+    let binding_icon = slot.bound.as_ref().map(action_icon_path);
+
+    v_flex()
+        .id(("key-callout", idx))
+        .absolute()
+        .top(px(top))
+        .left(px(left))
+        .w(px(KEY_CALLOUT_W))
+        .h(px(KEY_CALLOUT_H))
+        .px_1()
+        .justify_center()
+        .items_center()
+        .gap(px(1.))
+        .rounded_md()
+        .border_1()
+        .border_color(if highlighted {
+            rgb(ACCENT_BLUE).into()
+        } else {
+            pal.border
+        })
+        .bg(if highlighted {
+            theme::accent_tint()
+        } else {
+            pal.surface_hover
+        })
+        .cursor_pointer()
+        .hover(move |s| {
+            s.bg(if highlighted {
+                theme::accent_tint_hover()
+            } else {
+                pal.surface
+            })
+        })
+        .child(
+            div()
+                .text_xs()
+                .font_weight(FontWeight::SEMIBOLD)
+                .text_color(if highlighted {
+                    rgb(ACCENT_BLUE).into()
+                } else {
+                    pal.text_primary
+                })
+                .child(slot.label),
+        )
+        .child(
+            h_flex()
+                .items_center()
+                .justify_center()
+                .gap(px(2.))
+                .max_w(px(KEY_CALLOUT_W - 8.))
+                .when_some(binding_icon, |row, icon| {
+                    row.child(svg().path(icon).size(px(9.)).flex_none().text_color(
+                        if highlighted {
+                            rgb(ACCENT_BLUE).into()
+                        } else {
+                            pal.text_muted
+                        },
+                    ))
+                })
+                .child(
+                    div()
+                        .min_w_0()
+                        .overflow_hidden()
+                        .text_ellipsis()
+                        .whitespace_nowrap()
+                        .text_xs()
+                        .text_color(if highlighted {
+                            rgb(ACCENT_BLUE).into()
+                        } else {
+                            pal.text_muted
+                        })
+                        .child(binding),
+                ),
+        )
+        .on_hover(move |hovered, _window, cx| {
+            let next = (*hovered).then_some(idx);
+            view_hover.update(cx, |v, vcx| v.set_hovered_key(next, vcx));
+        })
+        .on_click(move |_ev, _window, cx| {
+            view_click.update(cx, |v, vcx| v.click_key(idx, vcx));
+        })
+        .into_any_element()
+}
+
+/// One invisible click-target over a function key. Selecting it opens the
+/// panel; hover/selection draws only a subtle keycap ring on the photo.
+fn key_click_target(
+    slot: KeySlot,
+    highlighted: bool,
+    (img_w, img_h): (f32, f32),
+    view: &Entity<FunctionRowView>,
+    _pal: &Palette,
+) -> AnyElement {
+    let idx = slot.idx;
+    let x_frac = slot.x_frac;
+    let y_frac = slot.y_frac;
+    let view_hover = view.clone();
+    let view_click = view.clone();
+    let left = key_target_left_px(x_frac, img_w, KEY_TARGET_W);
+    let top = key_target_top_px(y_frac, img_h, KEY_TARGET_H);
+
+    div()
+        .id(("key-target", idx))
+        .absolute()
+        .top(px(top))
+        .left(px(left))
+        .w(px(KEY_TARGET_W))
+        .h(px(KEY_TARGET_H))
+        .flex()
+        .items_center()
+        .justify_center()
+        .cursor_pointer()
+        .when(highlighted, |el| {
+            el.child(
+                div()
+                    .w_full()
+                    .h_full()
+                    .flex()
+                    .items_center()
+                    .justify_center()
+                    .child(
+                        div()
+                            .w(px(KEY_HOTSPOT_DOT))
+                            .h(px(KEY_HOTSPOT_DOT))
+                            .rounded_full()
+                            .border_1()
+                            .border_color(gpui::Hsla::from(rgb(ACCENT_BLUE)))
+                            .bg(gpui::Hsla::from(rgb(ACCENT_BLUE))),
+                    )
+                    .rounded_full()
+                    .border_1()
+                    .border_color(theme::accent_tint_hover())
+                    .bg(theme::accent_tint()),
+            )
+        })
+        .on_hover(move |hovered, _window, cx| {
+            let next = (*hovered).then_some(idx);
+            view_hover.update(cx, |v, vcx| v.set_hovered_key(next, vcx));
+        })
+        .on_click(move |_ev, _window, cx| {
+            view_click.update(cx, |v, vcx| v.click_key(idx, vcx));
+        })
+        .into_any_element()
+}
+
+fn binding_label(action: Option<&Action>) -> gpui::SharedString {
+    match action {
+        Some(Action::CustomShortcut(combo)) => combo.rendered_label().into(),
+        Some(a) => tr!(a.label()),
+        None => tr!("Off"),
+    }
+}
+
+fn keyboard_leader_canvas(
+    slots: Vec<KeySlot>,
+    selected: Option<usize>,
+    hovered: Option<usize>,
+    (img_w, img_h): (f32, f32),
+) -> impl IntoElement {
+    let guides: Vec<(usize, f32, f32)> =
+        slots.iter().map(|s| (s.idx, s.x_frac, s.y_frac)).collect();
+    canvas(
+        move |_bounds, _, _| (guides, selected, hovered),
+        move |bounds, payload, window, _app| {
+            let (guides, selected, hovered) = payload;
+            paint_keyboard_leaders(bounds, guides, selected, hovered, (img_w, img_h), window);
+        },
+    )
+    .absolute()
+    .inset_0()
+    .w(px(img_w))
+    .h(px(CALLOUT_BAND_H + img_h))
+}
+
+fn paint_keyboard_leaders(
+    bounds: Bounds<gpui::Pixels>,
+    guides: Vec<(usize, f32, f32)>,
+    selected: Option<usize>,
+    hovered: Option<usize>,
+    (img_w, img_h): (f32, f32),
+    window: &mut Window,
+) {
+    let count = guides.len();
+    for (idx, x_frac, y_frac) in guides {
+        let highlighted = key_is_highlighted(idx, selected, hovered);
+        let key_x = x_frac * img_w;
+        let key_y = CALLOUT_BAND_H + (y_frac * img_h);
+        let callout_x = callout_center_x(idx, count, img_w);
+        let callout_bottom = callout_top_px(idx) + KEY_CALLOUT_H;
+        let start = bounds.origin + point(px(callout_x), px(callout_bottom));
+        let elbow = bounds.origin + point(px(callout_x), px(CALLOUT_BAND_H - 14.));
+        let end = bounds.origin + point(px(key_x), px(key_y));
+
+        let mut path = PathBuilder::stroke(if highlighted { px(2.) } else { px(1.) });
+        path.move_to(start);
+        path.line_to(elbow);
+        path.line_to(end);
+        if let Ok(path) = path.build() {
+            if highlighted {
+                window.paint_path(path, rgb(ACCENT_BLUE));
+            } else {
+                window.paint_path(path, hsla(0., 0., 0.55, 0.35));
+            }
+        }
+    }
+}
+
+fn next_selection_after_click(current: Option<usize>, clicked: usize) -> Option<usize> {
+    (current != Some(clicked)).then_some(clicked)
+}
+
+fn key_is_highlighted(idx: usize, selected: Option<usize>, hovered: Option<usize>) -> bool {
+    selected == Some(idx) || hovered == Some(idx)
+}
+
+/// Callout bubbles lay out *evenly* across the pane instead of over their
+/// keys: a dense F-row (a G513 packs Esc-F12 into half the render width)
+/// would otherwise stack the bubbles into an overlapping wall. The leader
+/// lines fan from each bubble down to its true key position.
+fn callout_center_x(idx: usize, count: usize, image_w: f32) -> f32 {
+    let margin = KEY_CALLOUT_W / 2.0 + 4.0;
+    if count <= 1 {
+        return image_w / 2.0;
+    }
+    margin + (idx as f32) * (image_w - 2.0 * margin) / ((count - 1) as f32)
+}
+
+fn callout_left_px(idx: usize, count: usize, image_w: f32, callout_w: f32) -> f32 {
+    (callout_center_x(idx, count, image_w) - callout_w / 2.0).clamp(0.0, image_w - callout_w)
+}
+
+fn key_target_left_px(x_frac: f32, img_w: f32, target_w: f32) -> f32 {
+    (x_frac * img_w - target_w / 2.0).clamp(0.0, img_w - target_w)
+}
+
+fn key_target_top_px(y_frac: f32, img_h: f32, target_h: f32) -> f32 {
+    (y_frac * img_h - target_h / 2.0).clamp(0.0, img_h - target_h)
+}
+
+fn callout_top_px(idx: usize) -> f32 {
+    if callout_lane_is_lower(idx) {
+        KEY_CALLOUT_TOP_LOWER
+    } else {
+        KEY_CALLOUT_TOP_UPPER
+    }
+}
+
+fn callout_lane_is_lower(idx: usize) -> bool {
+    idx.is_multiple_of(2)
+}
+
+/// The scrollable config panel for the selected key. Lists the same action
+/// catalog the mouse picker uses, plus a Power User section. Renders the rows
+/// directly (no popover) in a tall card.
+fn config_panel(
+    selected_idx: usize,
+    slots: &[KeySlot],
+    active_editor: Option<PowerUserKind>,
+    text_state: Option<Entity<InputState>>,
+    workflow_draft: Vec<WorkflowStep>,
+    view: &Entity<FunctionRowView>,
+    pal: &Palette,
+    _window: &mut Window,
+    cx: &mut Context<FunctionRowView>,
+) -> impl IntoElement {
+    let slot = &slots[selected_idx];
+    let trigger = slot.trigger.clone();
+    let key_name = trigger.to_string();
+
+    // If an editor is active, render it instead of the list.
+    if let Some(kind) = active_editor {
+        return crate::keyboard_model::editors::editor_card(
+            trigger,
+            kind,
+            text_state,
+            workflow_draft,
+            view,
+            *pal,
+            cx,
+        );
+    }
+
+    let current = cx
+        .try_global::<AppState>()
+        .and_then(|s| s.keyboard_bindings.get(&trigger).cloned());
+
+    let view_for_pick = view.clone();
+    let trigger_for_pick = trigger.clone();
+    let on_pick: PickFn = Rc::new(move |action, _window, cx| {
+        cx.update_global::<AppState, _>(|state, _| {
+            state.commit_keyboard_binding(trigger_for_pick.clone(), Some(action));
+        });
+        view_for_pick.update(cx, |_, vcx| vcx.notify());
+    });
+
+    let rows = panel_action_rows(current.as_ref(), &on_pick, view, pal);
+
+    menu_card(*pal)
+        .w(px(PANEL_W))
+        .max_h(px(500.))
+        .child(title_header(&key_name, pal))
+        .child(divider(*pal))
+        .child(scroll_list("key-panel-scroll", rows))
+        .into_any_element()
+}
+
+/// The panel's title — shows which key is selected, e.g. "F1".
+fn title_header(key_name: &str, pal: &Palette) -> impl IntoElement {
+    h_flex()
+        .items_center()
+        .justify_between()
+        .px_2()
+        .pb_1()
+        .child(
+            div()
+                .text_xs()
+                .font_weight(FontWeight::SEMIBOLD)
+                .text_color(pal.text_muted)
+                .child(tr!("Bind %{name}", name => key_name)),
+        )
+}
+
+/// The action rows + a Power User section, mirroring the picker's list but
+/// adapted for the panel context (no popover dismissal).
+fn panel_action_rows(
+    current: Option<&Action>,
+    on_pick: &PickFn,
+    view: &Entity<FunctionRowView>,
+    pal: &Palette,
+) -> Vec<AnyElement> {
+    let mut children = action_rows("panel-action", current, on_pick, *pal);
+    children.push(section_header(&tr!("Power User"), *pal));
+
+    let power_user_actions: &[(PowerUserKind, &str, &'static str)] = &[
+        (
+            PowerUserKind::TypeText,
+            "Type Text…",
+            "action-icons/keyboard.svg",
+        ),
+        (
+            PowerUserKind::RunAppleScript,
+            "Run AppleScript…",
+            "action-icons/terminal.svg",
+        ),
+        (
+            PowerUserKind::RunShellCommand,
+            "Run Shell Command…",
+            "action-icons/terminal.svg",
+        ),
+        (
+            PowerUserKind::Workflow,
+            "Workflow…",
+            "action-icons/list-checks.svg",
+        ),
+    ];
+
+    for (idx, (kind, label, icon_path)) in power_user_actions.iter().enumerate() {
+        let kind = *kind;
+        let view = view.clone();
+        let selected = matches!(
+            (current, kind),
+            (Some(Action::TypeText(_)), PowerUserKind::TypeText)
+                | (
+                    Some(Action::RunAppleScript(_)),
+                    PowerUserKind::RunAppleScript
+                )
+                | (
+                    Some(Action::RunShellCommand(_)),
+                    PowerUserKind::RunShellCommand
+                )
+                | (Some(Action::Workflow(_)), PowerUserKind::Workflow)
+        );
+        children.push(
+            menu_row(format!("panel-power-{idx}"), *pal, selected)
+                .child(
+                    h_flex()
+                        .items_center()
+                        .gap_2()
+                        .child(
+                            svg()
+                                .path(*icon_path)
+                                .size_4()
+                                .flex_none()
+                                .text_color(pal.text_muted),
+                        )
+                        .child(div().child((*label).to_string())),
+                )
+                .when(selected, |s| {
+                    s.child(
+                        gpui_component::Icon::new(gpui_component::IconName::Check)
+                            .size_3()
+                            .text_color(rgb(ACCENT_BLUE)),
+                    )
+                })
+                .on_click(move |_ev, _window, cx| {
+                    view.update(cx, |v, vcx| v.open_editor(kind, vcx));
+                })
+                .into_any_element(),
+        );
+    }
+    children
+}
+
+#[derive(Clone, Copy, Debug)]
+struct KeyPoint {
+    x_frac: f32,
+    y_frac: f32,
+}
+
+/// Resolve key marker points as fractions [0..1] of the rendered image, along
+/// with how many top-row keys the board exposes (`points.len()` — the visible
+/// prefix of [`FUNCTION_KEYS`]). Prefer asset metadata's top-row markers —
+/// percent-based on MX Keys-class depots, pixel-based on legacy keyboard
+/// depots (G513) — and fall back to even spacing on the same row.
+fn key_points(asset: Option<&ResolvedAsset>) -> Vec<KeyPoint> {
+    if let Some(a) = asset {
+        if let Some(points) = legacy_pixel_key_points(a) {
+            return points;
+        }
+        let key_markers = sorted_marker_points(a, &["device_keys_image", "device_buttons_image"]);
+        let easy_switch_markers = sorted_marker_points(a, &["device_easyswitch_image"]);
+
+        if key_markers.len() >= 16 && easy_switch_markers.len() >= 3 {
+            let mut out = Vec::with_capacity(FUNCTION_KEYS.len());
+            out.push(synthesized_esc_point(key_markers[0]));
+            out.extend(
+                key_markers[..12]
+                    .iter()
+                    .copied()
+                    .map(calibrated_marker_point),
+            );
+            out.extend(
+                easy_switch_markers[..3]
+                    .iter()
+                    .copied()
+                    .map(calibrated_marker_point),
+            );
+            out.extend(
+                key_markers[key_markers.len() - 4..]
+                    .iter()
+                    .copied()
+                    .map(calibrated_marker_point),
+            );
+            if out.len() == FUNCTION_KEYS.len() {
+                return out;
+            }
+        }
+
+        if key_markers.len() >= FUNCTION_KEYS.len() - 1 {
+            let f1_to_f19 = &key_markers[..FUNCTION_KEYS.len() - 1];
+            let mut out = Vec::with_capacity(FUNCTION_KEYS.len());
+            out.push(synthesized_esc_point(f1_to_f19[0]));
+            out.extend(f1_to_f19.iter().copied().map(calibrated_marker_point));
+            return out;
+        }
+    }
+    fallback_key_points()
+}
+
+#[cfg(test)]
+fn key_x_fractions(asset: Option<&ResolvedAsset>) -> Vec<f32> {
+    key_points(asset)
+        .into_iter()
+        .map(|point| point.x_frac)
+        .collect()
+}
+
+/// Key points from a legacy pixel-marker depot (the G513 family), or `None`
+/// when the asset isn't one.
+///
+/// Legacy `metadata*.json` files mark each F-key's cap-face centre in
+/// *absolute pixels* of the authored canvas (`origin`), not percentages. The
+/// markers only apply when that canvas is the render we actually cached —
+/// the same depot also ships marker sets authored against other variants'
+/// renders (the G513's `metadata.json` belongs to the G512 banner render) —
+/// so a depot whose `origin` doesn't match the PNG is rejected rather than
+/// misplacing every callout.
+fn legacy_pixel_key_points(asset: &ResolvedAsset) -> Option<Vec<KeyPoint>> {
+    let img = asset
+        .metadata
+        .images
+        .iter()
+        .find(|img| img.key == "device_image" && !img.assignments.is_empty())?;
+    if img.origin.width != asset.png_width || img.origin.height != asset.png_height {
+        return None;
+    }
+    let (w, h) = (img.origin.width as f32, img.origin.height as f32);
+
+    let mut markers: Vec<KeyPoint> = img
+        .assignments
+        .iter()
+        .map(|asg| asg.marker)
+        // Percent-schema depots never exceed 100 on either axis; anything
+        // beyond is a pixel coordinate. Mixed files don't exist in the wild,
+        // but a percent marker slipping through would land off by 27x.
+        .filter(|m| m.x > 100. || m.y > 100.)
+        .map(|m| KeyPoint {
+            x_frac: (m.x / w).clamp(0.0, 1.0),
+            y_frac: (m.y / h).clamp(0.0, 1.0),
+        })
+        .collect();
+    if markers.len() < 2 || markers.len() > FUNCTION_KEYS.len() - 1 {
+        return None;
+    }
+    markers.sort_by(|a, b| {
+        a.x_frac
+            .partial_cmp(&b.x_frac)
+            .unwrap_or(std::cmp::Ordering::Equal)
+    });
+
+    // The depots mark F1..Fn but never Esc; place it left of F1 by the F-row's
+    // own key pitch so it stays registered at any render size.
+    let pitch = median_pitch(&markers)?;
+    let first = markers[0];
+    let esc = KeyPoint {
+        x_frac: (first.x_frac - ESC_LEFT_OF_F1_PITCHES * pitch).max(0.0),
+        y_frac: first.y_frac,
+    };
+
+    let mut out = Vec::with_capacity(markers.len() + 1);
+    out.push(esc);
+    out.extend(markers);
+    Some(out)
+}
+
+/// Median gap between adjacent marker x positions — the F-row's key pitch.
+/// The median rides out the wider inter-cluster gaps (F4→F5, F8→F9).
+fn median_pitch(sorted_markers: &[KeyPoint]) -> Option<f32> {
+    let mut gaps: Vec<f32> = sorted_markers
+        .windows(2)
+        .map(|pair| pair[1].x_frac - pair[0].x_frac)
+        .filter(|gap| *gap > 0.)
+        .collect();
+    if gaps.is_empty() {
+        return None;
+    }
+    gaps.sort_by(f32::total_cmp);
+    Some(gaps[gaps.len() / 2])
+}
+
+fn sorted_marker_points(asset: &ResolvedAsset, image_keys: &[&str]) -> Vec<KeyPoint> {
+    let mut markers: Vec<KeyPoint> = asset
+        .metadata
+        .images
+        .iter()
+        .filter(|img| image_keys.contains(&img.key.as_str()))
+        .flat_map(|img| img.assignments.iter())
+        .map(|asg| KeyPoint {
+            x_frac: asg.marker.x / 100.0,
+            y_frac: asg.marker.y / 100.0,
+        })
+        .collect();
+    markers.sort_by(|a, b| {
+        a.x_frac
+            .partial_cmp(&b.x_frac)
+            .unwrap_or(std::cmp::Ordering::Equal)
+    });
+    markers
+}
+
+fn synthesized_esc_point(first_function_key: KeyPoint) -> KeyPoint {
+    KeyPoint {
+        x_frac: synthesized_esc_x(first_function_key.x_frac),
+        y_frac: calibrated_marker_point(first_function_key).y_frac,
+    }
+}
+
+fn calibrated_marker_point(raw: KeyPoint) -> KeyPoint {
+    KeyPoint {
+        x_frac: (raw.x_frac + FRONT_MARKER_X_OFFSET_FRAC).clamp(0.0, 1.0),
+        y_frac: (raw.y_frac + FRONT_MARKER_Y_OFFSET_FRAC).clamp(0.0, 1.0),
+    }
+}
+
+fn synthesized_esc_x(first_function_key_x: f32) -> f32 {
+    (first_function_key_x - 0.045).max(0.02)
+}
+
+fn fallback_key_x_fractions() -> Vec<f32> {
+    let step = (EVEN_SPACING_END - EVEN_SPACING_START) / (FUNCTION_KEYS.len() - 1) as f32;
+    (0..FUNCTION_KEYS.len())
+        .map(|i| EVEN_SPACING_START + (i as f32) * step)
+        .collect()
+}
+
+fn fallback_key_points() -> Vec<KeyPoint> {
+    fallback_key_x_fractions()
+        .into_iter()
+        .map(|x_frac| KeyPoint {
+            x_frac,
+            y_frac: FALLBACK_KEY_Y_FRAC,
+        })
+        .collect()
+}
+
+/// The keyboard image, or a labeled placeholder when no asset resolved. The
+/// element is sized to the PNG's own aspect (see [`keyboard_render_size`]), so
+/// the contain-fit paints edge to edge and the marker overlays stay registered.
+fn image_or_fallback(
+    img_path: Option<std::path::PathBuf>,
+    img_w: f32,
+    img_h: f32,
+    pal: &Palette,
+) -> AnyElement {
+    match img_path {
+        Some(path) if path.exists() => img(path).w(px(img_w)).h(px(img_h)).into_any_element(),
+        Some(_) | None => div()
+            .w(px(img_w))
+            .h(px(160.))
+            .rounded_md()
+            .border_1()
+            .border_color(pal.border)
+            .bg(pal.surface)
+            .flex()
+            .items_center()
+            .justify_center()
+            .text_color(pal.text_muted)
+            .child(tr!("No keyboard image available"))
+            .into_any_element(),
+    }
+}
+
+#[cfg(test)]
+mod tests {
+    use super::*;
+    use openlogi_assets::{Assignment, Direction, ImageEntry, Metadata, Origin, Point};
+    use openlogi_core::device::DeviceKind;
+    use std::path::PathBuf;
+
+    #[test]
+    fn clicking_the_selected_key_closes_the_panel() {
+        assert_eq!(next_selection_after_click(None, 3), Some(3));
+        assert_eq!(next_selection_after_click(Some(3), 3), None);
+        assert_eq!(next_selection_after_click(Some(3), 4), Some(4));
+    }
+
+    #[test]
+    fn hover_or_selection_highlights_a_key() {
+        assert!(key_is_highlighted(2, Some(2), None));
+        assert!(key_is_highlighted(2, None, Some(2)));
+        assert!(key_is_highlighted(2, Some(2), Some(7)));
+        assert!(!key_is_highlighted(2, Some(1), Some(7)));
+    }
+
+    #[test]
+    fn function_row_covers_esc_through_f19() {
+        let labels: Vec<&str> = FUNCTION_KEYS.iter().map(|(label, _)| *label).collect();
+
+        assert_eq!(FUNCTION_KEYS.len(), 20);
+        assert_eq!(labels.first(), Some(&"Esc"));
+        assert_eq!(labels.last(), Some(&"F19"));
+        assert!(labels.contains(&"F13"));
+        assert!(labels.contains(&"F19"));
+    }
+
+    #[test]
+    fn fallback_key_positions_cover_the_full_top_row() {
+        let positions = key_x_fractions(None);
+
+        assert_eq!(positions.len(), 20);
+        assert_eq!(positions.first().copied(), Some(EVEN_SPACING_START));
+        assert_eq!(positions.last().copied(), Some(EVEN_SPACING_END));
+    }
+
+    #[test]
+    fn mx_keys_markers_merge_function_and_easy_switch_groups() {
+        let key_markers = vec![
+            9.0, 13.4, 17.8, 22.3, 26.7, 31.15, 35.55, 40.05, 44.55, 49.1, 53.5, 57.9, 62.35, 81.5,
+            85.9, 90.3, 94.7,
+        ];
+        let easy_switch_markers = vec![67.5, 71.92, 76.3];
+        let asset = asset_with_markers(&key_markers, &easy_switch_markers);
+
+        let positions = key_x_fractions(Some(&asset));
+
+        assert_eq!(positions.len(), 20);
+        assert_approx_eq(positions[0], 0.045);
+        assert_approx_eq(positions[1], 0.11);
+        assert_approx_eq(positions[12], 0.599);
+        assert_approx_eq(positions[13], 0.695);
+        assert_approx_eq(positions[15], 0.783);
+        assert_approx_eq(positions[16], 0.835);
+        assert_approx_eq(positions[19], 0.967);
+        assert!(
+            positions.windows(2).all(|pair| pair[0] < pair[1]),
+            "positions should stay in physical left-to-right order"
+        );
+    }
+
+    #[test]
+    fn mx_keys_markers_preserve_key_center_points() {
+        let key_markers = vec![
+            9.0, 13.4, 17.8, 22.3, 26.7, 31.15, 35.55, 40.05, 44.55, 49.1, 53.5, 57.9, 62.35, 81.5,
+            85.9, 90.3, 94.7,
+        ];
+        let easy_switch_markers = vec![67.5, 71.92, 76.3];
+        let asset = asset_with_markers(&key_markers, &easy_switch_markers);
+
+        let points = key_points(Some(&asset));
+
+        assert_eq!(points.len(), 20);
+        assert_approx_eq(points[19].x_frac, 0.967);
+        assert_approx_eq(points[19].y_frac, 0.153);
+        assert_approx_eq(key_target_top_px(points[19].y_frac, 220.0, 30.0), 18.66);
+    }
+
+    /// The G513 family's `metadata_full.json`: `device_image` markers in
+    /// absolute pixels of the authored canvas, which matches the cached
+    /// render. F1-F12 come from the markers; Esc is synthesized one chassis
+    /// offset left of F1.
+    #[test]
+    fn g513_pixel_markers_resolve_esc_plus_f1_to_f12() {
+        let marker_xs = [
+            285., 405., 525., 645., 840., 960., 1080., 1200., 1395., 1515., 1635., 1755.,
+        ];
+        let asset = legacy_asset(&marker_xs, 290., (2760, 1600), (2760, 1600));
+
+        let points = key_points(Some(&asset));
+
+        assert_eq!(points.len(), 13, "Esc + F1-F12, no phantom F13-F19");
+        assert_approx_eq(points[1].x_frac, 285. / 2760.);
+        assert_approx_eq(points[12].x_frac, 1755. / 2760.);
+        // Esc: 1.55 key pitches (median gap 120px) left of F1.
+        assert_approx_eq(points[0].x_frac, (285. - 1.55 * 120.) / 2760.);
+        for point in &points {
+            assert_approx_eq(point.y_frac, 290. / 1600.);
+        }
+        assert!(
+            points
+                .windows(2)
+                .all(|pair| pair[0].x_frac < pair[1].x_frac),
+            "points stay in physical left-to-right order"
+        );
+    }
+
+    /// The same depot's `metadata.json` is authored against a *different*
+    /// render (the G512 banner). Its origin doesn't match the cached PNG, so
+    /// the markers must be rejected in favour of the even-spacing fallback
+    /// rather than misplacing every callout.
+    #[test]
+    fn pixel_markers_for_a_different_render_fall_back_to_even_spacing() {
+        let marker_xs = [370., 525., 680., 835., 1090., 1250., 1400., 1555.];
+        let asset = legacy_asset(&marker_xs, 300., (3598, 1315), (2760, 1600));
+
+        let points = key_points(Some(&asset));
+
+        assert_eq!(points.len(), FUNCTION_KEYS.len());
+        assert_approx_eq(points[0].x_frac, EVEN_SPACING_START);
+        assert_approx_eq(points[19].x_frac, EVEN_SPACING_END);
+    }
+
+    #[test]
+    fn render_size_follows_the_png_aspect_up_to_the_width_cap() {
+        // MX Keys-class render (1872x728): width-bound at a roomy viewport.
+        let mx = legacy_asset(&[], 0., (1872, 728), (1872, 728));
+        let (w, h) = keyboard_render_size(Some(&mx), 900.);
+        assert_approx_eq(w, 700.);
+        assert!((h - 700. * 728. / 1872.).abs() < 0.01);
+
+        // G513 render (2760x1600) is far taller at the same width.
+        let g513 = legacy_asset(&[], 0., (2760, 1600), (2760, 1600));
+        let (w, h) = keyboard_render_size(Some(&g513), 900.);
+        assert_approx_eq(w, 700.);
+        assert!((h - 700. * 1600. / 2760.).abs() < 0.01);
+
+        // A short viewport shrinks the render instead of overflowing it.
+        let (w, h) = keyboard_render_size(Some(&g513), 500.);
+        assert_approx_eq(h, KEYBOARD_MIN_IMG_H);
+        assert!((w - KEYBOARD_MIN_IMG_H * 2760. / 1600.).abs() < 0.01);
+
+        assert_eq!(keyboard_render_size(None, 900.), FALLBACK_KEYBOARD_SIZE);
+    }
+
+    #[test]
+    fn callouts_spread_evenly_from_margin_to_margin() {
+        let margin = KEY_CALLOUT_W / 2.0 + 4.0;
+        assert_approx_eq(callout_center_x(0, 13, 700.0), margin);
+        assert_approx_eq(callout_center_x(12, 13, 700.0), 700.0 - margin);
+        assert_approx_eq(callout_center_x(0, 1, 700.0), 350.0);
+        assert!(callout_left_px(0, 13, 700.0, KEY_CALLOUT_W) >= 0.0);
+        assert!(callout_left_px(12, 13, 700.0, KEY_CALLOUT_W) <= 700.0 - KEY_CALLOUT_W);
+    }
+
+    /// Bubbles share a stagger lane with every second key; same-lane
+    /// neighbours must never overlap for any board size the row can show.
+    #[test]
+    fn same_lane_callouts_never_overlap() {
+        for count in [13usize, 20] {
+            for idx in 0..count.saturating_sub(2) {
+                let gap = callout_center_x(idx + 2, count, KEYBOARD_W)
+                    - callout_center_x(idx, count, KEYBOARD_W);
+                assert!(
+                    gap >= KEY_CALLOUT_W,
+                    "lane neighbours {idx}/{} overlap at count {count}: gap {gap}",
+                    idx + 2
+                );
+            }
+        }
+    }
+
+    #[test]
+    fn function_key_callouts_stagger_even_lower_odd_upper() {
+        assert!(callout_top_px(0) > callout_top_px(1));
+        assert_eq!(callout_top_px(0), callout_top_px(2));
+        assert_eq!(callout_top_px(1), callout_top_px(3));
+    }
+
+    #[test]
+    fn staggered_function_key_callout_rows_fit_the_keyboard_width() {
+        let lower_count = FUNCTION_KEYS
+            .iter()
+            .enumerate()
+            .filter(|(idx, _)| callout_lane_is_lower(*idx))
+            .count();
+        let upper_count = FUNCTION_KEYS.len() - lower_count;
+        assert!(
+            KEY_CALLOUT_W * lower_count as f32 <= KEYBOARD_W,
+            "lower callout lane overlaps before spacing is considered"
+        );
+        assert!(
+            KEY_CALLOUT_W * upper_count as f32 <= KEYBOARD_W,
+            "upper callout lane overlaps before spacing is considered"
+        );
+    }
+
+    /// A legacy pixel-marker asset: `device_image` assignments in absolute
+    /// pixels of an `origin` canvas, over a render of `png` dimensions.
+    fn legacy_asset(
+        marker_xs: &[f32],
+        marker_y: f32,
+        origin: (u32, u32),
+        png: (u32, u32),
+    ) -> ResolvedAsset {
+        let assignments = marker_xs
+            .iter()
+            .map(|x| Assignment {
+                slot_name: String::new(),
+                marker: Point { x: *x, y: marker_y },
+                label: Direction { x: -1, y: -1 },
+            })
+            .collect();
+        ResolvedAsset {
+            depot: "g513".to_string(),
+            display_name: "G513".to_string(),
+            kind: DeviceKind::Keyboard,
+            image_path: PathBuf::from("/tmp/g513.png"),
+            hero_image_path: None,
+            glow: None,
+            metadata: Metadata {
+                images: vec![ImageEntry {
+                    key: "device_image".to_string(),
+                    origin: Origin {
+                        width: origin.0,
+                        height: origin.1,
+                    },
+                    assignments,
+                }],
+            },
+            png_width: png.0,
+            png_height: png.1,
+        }
+    }
+
+    fn asset_with_markers(key_markers: &[f32], easy_switch_markers: &[f32]) -> ResolvedAsset {
+        ResolvedAsset {
+            depot: "mx_keys_s_for_mac".to_string(),
+            display_name: "MX Keys S for Mac".to_string(),
+            kind: DeviceKind::Keyboard,
+            image_path: PathBuf::from("/tmp/mx-keys.png"),
+            hero_image_path: None,
+            glow: None,
+            metadata: Metadata {
+                images: vec![
+                    ImageEntry {
+                        key: "device_keys_image".to_string(),
+                        origin: Origin {
+                            width: 1872,
+                            height: 728,
+                        },
+                        assignments: assignments_from_markers(key_markers),
+                    },
+                    ImageEntry {
+                        key: "device_easyswitch_image".to_string(),
+                        origin: Origin {
+                            width: 1872,
+                            height: 728,
+                        },
+                        assignments: assignments_from_markers(easy_switch_markers),
+                    },
+                ],
+            },
+            png_width: 1872,
+            png_height: 728,
+        }
+    }
+
+    fn assignments_from_markers(markers: &[f32]) -> Vec<Assignment> {
+        markers
+            .iter()
+            .enumerate()
+            .map(|(idx, x)| Assignment {
+                slot_name: format!("slot-{idx}"),
+                marker: Point { x: *x, y: 13.0 },
+                label: Direction { x: -1, y: -1 },
+            })
+            .collect()
+    }
+
+    fn assert_approx_eq(actual: f32, expected: f32) {
+        assert!(
+            (actual - expected).abs() < 0.0001,
+            "expected {expected}, got {actual}"
+        );
+    }
+}
diff --git a/crates/openlogi-gui/src/keyboard_model/mod.rs b/crates/openlogi-gui/src/keyboard_model/mod.rs
new file mode 100644
index 0000000000000000000000000000000000000000..8ab6e36045c43da896a6a0d31728b1e54c2f2e06
--- /dev/null
+++ b/crates/openlogi-gui/src/keyboard_model/mod.rs
@@ -0,0 +1,15 @@
+//! Keyboard remapper UI — the global function-key binding surface.
+//!
+//! Mirrors [`crate::mouse_model`]: a hardware-style diagram whose clickable
+//! hotspots (here, function-row key-caps) each open the same action picker the
+//! mouse buttons use. The key difference is scope — mouse bindings are
+//! per-device under `config.devices[key].bindings`, while keyboard F-key
+//! bindings are global (`config.keyboard.bindings`) and apply across all
+//! keyboards, so the picker commits via [`AppState::commit_keyboard_binding`]
+//! rather than [`AppState::commit_binding`].
+//!
+//! [`AppState::commit_binding`]: crate::state::AppState::commit_binding
+//! [`AppState::commit_keyboard_binding`]: crate::state::AppState::commit_keyboard_binding
+
+pub mod editors;
+pub mod function_row;
diff --git a/crates/openlogi-gui/src/main.rs b/crates/openlogi-gui/src/main.rs
index ab4380aba031100d9bbd384beaec067e62927050..11295befff483a9bb7a2693af1ce55ff62eac61e 100644
--- a/crates/openlogi-gui/src/main.rs
+++ b/crates/openlogi-gui/src/main.rs
@@ -38,6 +38,7 @@ mod data;
 mod diagnostics;
 mod i18n;
 mod ipc_client;
+mod keyboard_model;
 mod mouse_model;
 mod platform;
 mod state;
@@ -58,9 +59,9 @@ use gpui::{
     AppContext, BorrowAppContext as _, Bounds, Size, Styled, WindowBounds, WindowOptions, px,
 };
 use gpui_component::{ActiveTheme, Root};
-use openlogi_core::brand::DeeplinkCommand;
+use openlogi_core::brand::{APP_ID, DeeplinkCommand};
 use openlogi_core::config::Config;
-use openlogi_core::device::DeviceInventory;
+use openlogi_core::device::{DeviceInventory, StandaloneDevice};
 use tracing::{info, warn};
 use tracing_subscriber::EnvFilter;
 
@@ -68,7 +69,7 @@ use crate::app::AppView;
 use crate::asset::sync::{
     AssetCommand, AssetControl, SyncOutcome, model_key, run_asset_sync, sync_retry_delay,
 };
-use crate::state::AppState;
+use crate::state::{AppState, ConfigPersistence};
 
 fn dispatch_gui_command(command: DeeplinkCommand, cx: &mut gpui::App) {
     use DeeplinkCommand as Cmd;
@@ -139,6 +140,7 @@ fn main() -> Result<()> {
     // bindings, and the hook live; asset sync is kicked off in the background
     // when the first devices appear (see the `inventory_rx` arm).
     let inventories: Vec<DeviceInventory> = Vec::new();
+    let standalone = Vec::new();
 
     let initial_config = Config::load_or_default().unwrap_or_else(|e| {
         warn!(error = %e, "could not load config.toml; using defaults");
@@ -221,6 +223,14 @@ fn main() -> Result<()> {
         .detach();
 
         cx.spawn(async move |cx| {
+            // Enumerate webcams off the UI thread: AVFoundation discovery can
+            // stall for hundreds of ms on first touch, which must never block
+            // the first paint (or, below, a snapshot merge mid-render).
+            let mut latest_cams = cx
+                .background_executor()
+                .spawn(async { openlogi_camera::enumerate_cameras() })
+                .await;
+
             // Install the hook-shared AppState up front, then open the window at
             // launch; closing it leaves the app live in the menu bar.
             cx.update(|cx| {
@@ -229,7 +239,10 @@ fn main() -> Result<()> {
                     cx.set_global(AppState::with_runtime(
                         initial_config,
                         &inventories,
+                        &standalone,
                         &cache,
+                        &latest_cams,
+                        ConfigPersistence::UserFile,
                         ipc_commands,
                     ));
                 }
@@ -278,11 +291,15 @@ fn main() -> Result<()> {
             // Clear (the AssetControl arm below) can sync the current devices
             // without waiting for the next snapshot.
             let mut latest_inv: Vec<DeviceInventory> = Vec::new();
+            let mut latest_standalone: Vec<StandaloneDevice> = Vec::new();
             // A manual Refresh / Clear that arrived while a sync was in
             // flight: stashed here and run by the sync-outcome arm the moment
             // that sync finishes, so a Clear's cache wipe never races the
             // in-flight fetch's writes and the manual fetch is never dropped.
             let mut deferred_manual: Option<AssetCommand> = None;
+            // Consecutive empty camera scans while cameras were showing — see
+            // the grace logic in the snapshot arm.
+            let mut camera_misses: u8 = 0;
             // Cleared when the IPC update channel closes (the client thread
             // died), so the select stops polling a closed receiver.
             let mut ipc_open = true;
@@ -290,6 +307,24 @@ fn main() -> Result<()> {
                 tokio::select! {
                     update = ipc_updates.recv(), if ipc_open => match update {
                         Some(ipc_client::GuiUpdate::Snapshot(update)) => {
+                        // Refresh the camera set off the UI thread (AVFoundation
+                        // discovery is far too slow for the render path) so the
+                        // merge below sees hot-plugs without ever stalling paint.
+                        // An empty scan gets a two-snapshot grace before it
+                        // evicts anything: a USB control seize (e.g. another
+                        // process's CLI) blinks the camera out of discovery for
+                        // a moment, and one blink must not tear down the card —
+                        // or the detail page — the user is looking at.
+                        let scanned = cx
+                            .background_executor()
+                            .spawn(async { openlogi_camera::enumerate_cameras() })
+                            .await;
+                        if scanned.is_empty() && !latest_cams.is_empty() && camera_misses < 2 {
+                            camera_misses += 1;
+                        } else {
+                            camera_misses = 0;
+                            latest_cams = scanned;
+                        }
                         // Keep the latest completed enumeration for the manual
                         // Refresh / Clear arm — a not-yet-ready agent's empty
                         // pre-enumeration list must not shrink it.
@@ -297,6 +332,7 @@ fn main() -> Result<()> {
                             == openlogi_agent_core::ipc::InventoryHealth::Ready;
                         if inventory_ready {
                             latest_inv.clone_from(&update.inventory);
+                            latest_standalone.clone_from(&update.standalone);
                         }
                         // A completed sync may have put real photos where
                         // silhouettes were resolved: the resolver was rebuilt
@@ -313,24 +349,25 @@ fn main() -> Result<()> {
                         let force_refresh = inventory_ready && std::mem::take(&mut assets_dirty);
                         let (auto_download, asset_source, models) = cx.update(|cx| {
                             let (changed, merged, auto_download, asset_source, models) = cx.update_global::<AppState, _>(|state, _| {
-                                // Merge only *completed* enumerations. A not-yet-ready
-                                // agent can only serve an empty pre-enumeration list, and
-                                // counting those as misses would wipe the device list (and
-                                // pop an open detail page) on every agent restart: at the
-                                // 250 ms reconnect cadence the miss grace burns in ~750 ms
-                                // while a fresh enumeration takes 1.5–5 s. The diagnostics
-                                // snapshot shares the gate so a report copied during that
-                                // window keeps the receivers the UI is still showing; the
-                                // manual-sync arm reuses `inventory_ready` above.
+                                // Merge only completed enumerations. A scanning agent serves
+                                // an empty pre-enumeration list, which must not burn the GUI's
+                                // miss grace or replace the last known device set.
                                 let merged = inventory_ready
-                                    && state.refresh_inventories(&update.inventory, &cache, force_refresh);
+                                    && state.refresh_inventories(
+                                        &update.inventory,
+                                        &update.standalone,
+                                        &cache,
+                                        force_refresh,
+                                        &latest_cams,
+                                    );
                                 if inventory_ready {
                                     state.store_inventory_snapshot(&update.inventory);
                                 }
                                 // Bitwise `|`: the link must be set even when the
                                 // merge already reported a change.
                                 let changed = merged
-                                    | state.set_agent_link(state::AgentLink::Ready(update.status));
+                                    | state.set_agent_link(state::AgentLink::Ready(update.status))
+                                    | state.set_camera_active(update.camera_active);
                                 let settings = state.app_settings();
                                 (
                                     changed,
@@ -360,6 +397,17 @@ fn main() -> Result<()> {
                         // works via the AssetControl arm below.
                         let backoff_passed = last_sync_at
                             .is_none_or(|t| t.elapsed() >= sync_retry_delay(sync_attempts));
+                        // Cameras are enumerated on the UI side (UVC, not HID++),
+                        // so `asset_models` — built from the HID++ device list —
+                        // can't see them. Fold their synthesized models in so a
+                        // webcam's product art downloads like any other device's.
+                        let mut models = models;
+                        models.extend(latest_cams.iter().map(|c| {
+                            crate::asset::sync::AssetTarget::Hidpp {
+                                model: state::camera_model_info(c),
+                                codename: Some(c.name.clone()),
+                            }
+                        }));
                         let pending: Vec<_> = models
                             .into_iter()
                             .filter(|m| !synced_keys.contains(&model_key(m)))
@@ -387,6 +435,19 @@ fn main() -> Result<()> {
                         Some(ipc_client::GuiUpdate::OutdatedGui) => {
                             cx.update(|cx| set_agent_link(state::AgentLink::OutdatedGui, cx));
                         }
+                        Some(ipc_client::GuiUpdate::LightCommandResult {
+                            key,
+                            request_id,
+                            command,
+                            result,
+                        }) => {
+                            let changed = cx.update_global::<AppState, _>(|state, _| {
+                                state.apply_light_command_result(key, request_id, command, result)
+                            });
+                            if changed {
+                                cx.update(gpui::App::refresh_windows);
+                            }
+                        }
                         // The IPC client thread is gone (runtime / thread spawn
                         // failure) — without this the window would show its
                         // connecting spinner forever.
@@ -433,7 +494,13 @@ fn main() -> Result<()> {
                                 cache = asset::AssetResolver::new();
                                 cx.update(|cx| {
                                     let changed = cx.update_global::<AppState, _>(|state, _| {
-                                        state.refresh_inventories(&latest_inv, &cache, true)
+                                        state.refresh_inventories(
+                                            &latest_inv,
+                                            &latest_standalone,
+                                            &cache,
+                                            true,
+                                            &latest_cams,
+                                        )
                                     });
                                     if changed {
                                         cx.refresh_windows();
@@ -447,6 +514,15 @@ fn main() -> Result<()> {
                                 let state = cx.global::<AppState>();
                                 (state.asset_models(), state.app_settings().asset_source)
                             });
+                            // Include the UI-side webcam models (see the snapshot
+                            // arm) so a manual Refresh fetches camera art too.
+                            let mut models = models;
+                            models.extend(latest_cams.iter().map(|c| {
+                                crate::asset::sync::AssetTarget::Hidpp {
+                                    model: state::camera_model_info(c),
+                                    codename: Some(c.name.clone()),
+                                }
+                            }));
                             let tx = sync_tx.clone();
                             std::thread::spawn(move || {
                                 let keys = models.iter().map(model_key).collect();
@@ -503,11 +579,17 @@ fn main_window_options(cx: &mut gpui::App) -> WindowOptions {
     let bounds = Bounds::centered(None, Size::new(px(1100.), px(750.)), cx);
     WindowOptions {
         window_bounds: Some(WindowBounds::Windowed(bounds)),
+        // Advertise a Wayland xdg-toplevel app_id (and X11 WM_CLASS). Without it
+        // the window ships no app_id, so GNOME's `get_wm_class()` returns empty
+        // and our own `gnome_shell` frontmost backend reports OpenLogi as `None`
+        // (and the dash can't group the window under its launcher icon). The id
+        // is the shared `brand::APP_ID`, matching the desktop file's
+        // `StartupWMClass` and the macOS bundle-id family.
+        app_id: Some(APP_ID.into()),
         // Min height keeps the buttons tab's mouse model above its scale floor
         // (`MODEL_MIN_H` + the chrome/padding reserve) so its side labels never
         // overlap; below this the model can't shrink further without crowding.
         window_min_size: Some(Size::new(px(720.), px(680.))),
-        app_id: Some("openlogi".to_string()),
         // Linux: transparent chrome so `AppView::render` can draw a client-side
         // `TitleBar` (the compositor declines server-side decorations and gpui's
         // fallback is unpainted). macOS/Windows keep their native titlebar.
diff --git a/crates/openlogi-gui/src/mouse_model/geometry.rs b/crates/openlogi-gui/src/mouse_model/geometry.rs
index 316c64da8fdcaace7ce1d84b381405f4ee2034e9..f7559fa8eb33e80b3a0ca9f2e46b712ece888c66 100644
--- a/crates/openlogi-gui/src/mouse_model/geometry.rs
+++ b/crates/openlogi-gui/src/mouse_model/geometry.rs
@@ -195,9 +195,11 @@ mod tests {
 
     #[test]
     fn default_labels_include_capability_gated_thumbwheel() {
-        assert!(!default_labels(false)
-            .iter()
-            .any(|label| label.id == MouseControlId::ThumbwheelRotation));
+        assert!(
+            !default_labels(false)
+                .iter()
+                .any(|label| label.id == MouseControlId::ThumbwheelRotation)
+        );
         assert_eq!(
             default_labels(true)
                 .iter()
diff --git a/crates/openlogi-gui/src/mouse_model/mod.rs b/crates/openlogi-gui/src/mouse_model/mod.rs
index feafa2eb2c8365ef6ab29359253d62c6b3a8459b..e703f75313d45e4401611d36c63b792b5ae16496 100644
--- a/crates/openlogi-gui/src/mouse_model/mod.rs
+++ b/crates/openlogi-gui/src/mouse_model/mod.rs
@@ -3,7 +3,7 @@
 //!
 //! Per UI.md phases 6 (this view), 7 (leader lines), and 8 (ambient motion).
 
-mod geometry;
+pub mod geometry;
 pub mod leader_lines;
 pub mod picker;
 pub(crate) mod thumbwheel;
diff --git a/crates/openlogi-gui/src/mouse_model/picker.rs b/crates/openlogi-gui/src/mouse_model/picker.rs
index 010454bf3f39291352ce36c942148bd7a3b0195a..6375bc323955db1ef3cafd5a402fc9d0f82f78df 100644
--- a/crates/openlogi-gui/src/mouse_model/picker.rs
+++ b/crates/openlogi-gui/src/mouse_model/picker.rs
@@ -39,11 +39,11 @@ use crate::theme::{self, ACCENT_BLUE, Palette, SelectableStyle, Typography as _}
 /// Floor width for the [`action_picker`] popover. The action labels drive the
 /// actual width; this only stops the list from collapsing too narrow. Matches
 /// gpui-component's own `PopupMenu` floor (`min_w(rems(8.))`).
-const POPOVER_W: f32 = 128.;
+pub(crate) const POPOVER_W: f32 = 128.;
 
 /// Cap the scrollable action list height. The catalog has 29+ entries across
 /// half a dozen categories; without a cap the list overflows the window.
-const POPOVER_LIST_MAX_H: f32 = 360.;
+pub(crate) const POPOVER_LIST_MAX_H: f32 = 360.;
 
 /// Build the popover body that re-binds a single `btn`.
 ///
@@ -199,7 +199,7 @@ pub fn gesture_overview(
 /// card uses `rounded_lg` (8px). The shadow is gpui's soft `shadow_md`, not a
 /// hard drop. Not stateful (no interaction → no element id, so two sibling cards
 /// can't collide on one).
-fn menu_card(pal: Palette) -> gpui::Div {
+pub(crate) fn menu_card(pal: Palette) -> gpui::Div {
     v_flex()
         .bg(pal.surface)
         .border_1()
@@ -356,11 +356,11 @@ fn flyout_card(
 /// Commit callback invoked when a row is clicked. Boxed so the row builder can
 /// be shared between the button picker and any future custom picker, which
 /// differ only in what they do after committing.
-type PickFn = Rc<dyn Fn(Action, &mut Window, &mut App)>;
+pub(crate) type PickFn = Rc<dyn Fn(Action, &mut Window, &mut App)>;
 
 /// The action catalog grouped by [`Category`], preserving catalog order within
 /// each group and first-seen order across groups.
-fn grouped_catalog() -> Vec<(Category, Vec<Action>)> {
+pub(crate) fn grouped_catalog() -> Vec<(Category, Vec<Action>)> {
     let mut sections: Vec<(Category, Vec<Action>)> = Vec::new();
     for action in Action::catalog() {
         let cat = action.category();
@@ -396,7 +396,7 @@ pub(crate) fn action_icon_path(action: &Action) -> &'static str {
         Action::Cut => "action-icons/scissors.svg",
         Action::Undo => "action-icons/undo-2.svg",
         Action::Redo => "action-icons/redo-2.svg",
-        Action::SelectAll => "action-icons/list-checks.svg",
+        Action::SelectAll | Action::Workflow(_) => "action-icons/list-checks.svg",
         Action::Find => "action-icons/search.svg",
         Action::Save => "action-icons/save.svg",
         Action::BrowserBack => "action-icons/arrow-left.svg",
@@ -415,6 +415,7 @@ pub(crate) fn action_icon_path(action: &Action) -> &'static str {
         Action::LaunchpadShow => "action-icons/grid-3x3.svg",
         Action::LockScreen => "action-icons/lock.svg",
         Action::Screenshot | Action::CaptureRegion => "action-icons/camera.svg",
+        Action::Sleep => "action-icons/moon.svg",
         Action::PlayPause => "action-icons/play.svg",
         Action::NextTrack => "action-icons/skip-forward.svg",
         Action::PrevTrack => "action-icons/skip-back.svg",
@@ -427,7 +428,10 @@ pub(crate) fn action_icon_path(action: &Action) -> &'static str {
         Action::ScrollDown => "action-icons/chevrons-down.svg",
         Action::HorizontalScrollLeft => "action-icons/chevrons-left.svg",
         Action::HorizontalScrollRight => "action-icons/chevrons-right.svg",
-        Action::CustomShortcut(_) => "action-icons/keyboard.svg",
+        // Power-user actions (M1 function-key remapper). TypeText shares the
+        // keyboard glyph with CustomShortcut; shell/script arms share terminal.
+        Action::CustomShortcut(_) | Action::TypeText(_) => "action-icons/keyboard.svg",
+        Action::RunAppleScript(_) | Action::RunShellCommand(_) => "action-icons/terminal.svg",
     }
 }
 
@@ -435,7 +439,7 @@ pub(crate) fn action_icon_path(action: &Action) -> &'static str {
 /// icon, then its label; `current` adds a trailing accent check. Clicking any
 /// row invokes `on_pick`. `id_prefix` disambiguates element IDs between pickers
 /// that share this builder.
-fn action_rows(
+pub(crate) fn action_rows(
     id_prefix: &'static str,
     current: Option<&Action>,
     on_pick: &PickFn,
@@ -493,7 +497,7 @@ fn action_rows(
 /// fill deepens on hover. Unselected rows are transparent at rest, neutral on
 /// hover. One accent, one signal per state — no blue label text (which fails AA
 /// contrast on the near-white surface).
-fn menu_row(
+pub(crate) fn menu_row(
     id: impl Into<gpui::ElementId>,
     pal: Palette,
     selected: bool,
@@ -520,7 +524,7 @@ fn menu_row(
 }
 
 /// Small uppercase muted group header.
-fn section_header(label: &str, pal: Palette) -> AnyElement {
+pub(crate) fn section_header(label: &str, pal: Palette) -> AnyElement {
     div()
         .w_full()
         .px_2()
@@ -533,7 +537,7 @@ fn section_header(label: &str, pal: Palette) -> AnyElement {
 }
 
 /// Popover title — the binding context, e.g. "Bind Back".
-fn title(text: impl Into<gpui::SharedString>, pal: Palette) -> impl IntoElement {
+pub(crate) fn title(text: impl Into<gpui::SharedString>, pal: Palette) -> impl IntoElement {
     div()
         .px_2()
         .pb_1()
@@ -543,12 +547,12 @@ fn title(text: impl Into<gpui::SharedString>, pal: Palette) -> impl IntoElement
 }
 
 /// 1px hairline separating the title from the list.
-fn divider(pal: Palette) -> impl IntoElement {
+pub(crate) fn divider(pal: Palette) -> impl IntoElement {
     div().mb_1().h(px(1.)).w_full().bg(pal.border)
 }
 
 /// Wrap `rows` in the height-capped, vertically scrollable list region.
-fn scroll_list(id: &'static str, rows: Vec<AnyElement>) -> impl IntoElement {
+pub(crate) fn scroll_list(id: &'static str, rows: Vec<AnyElement>) -> impl IntoElement {
     div()
         .id(id)
         .max_h(px(POPOVER_LIST_MAX_H))
diff --git a/crates/openlogi-gui/src/mouse_model/thumbwheel.rs b/crates/openlogi-gui/src/mouse_model/thumbwheel.rs
index 1ef52bb157bc132c3618fc82431bd5c89c575d5f..b96d4eb437699237d33005db38acfcdbcfdb43ed 100644
--- a/crates/openlogi-gui/src/mouse_model/thumbwheel.rs
+++ b/crates/openlogi-gui/src/mouse_model/thumbwheel.rs
@@ -54,10 +54,7 @@ impl ThumbwheelPreset {
             Self::Volume => (Action::VolumeDown, Action::VolumeUp),
             Self::CycleDpi => (Action::CycleDpiPresets, Action::CycleDpiPresets),
             Self::VerticalScroll => (Action::ScrollDown, Action::ScrollUp),
-            Self::HorizontalScroll => (
-                Action::HorizontalScrollLeft,
-                Action::HorizontalScrollRight,
-            ),
+            Self::HorizontalScroll => (Action::HorizontalScrollLeft, Action::HorizontalScrollRight),
         };
         ThumbwheelPair { backward, forward }
     }
@@ -121,10 +118,7 @@ mod tests {
             (Action::VolumeDown, Action::VolumeUp),
             (Action::CycleDpiPresets, Action::CycleDpiPresets),
             (Action::ScrollDown, Action::ScrollUp),
-            (
-                Action::HorizontalScrollLeft,
-                Action::HorizontalScrollRight,
-            ),
+            (Action::HorizontalScrollLeft, Action::HorizontalScrollRight),
         ];
 
         for (preset, (backward, forward)) in ThumbwheelPreset::ALL.into_iter().zip(expected) {
diff --git a/crates/openlogi-gui/src/mouse_model/view.rs b/crates/openlogi-gui/src/mouse_model/view.rs
index b53fb560606e8821d60bd402ec3591719bc4f10d..248a7df12ea95c8bad9d83f0f38002532b510ab6 100644
--- a/crates/openlogi-gui/src/mouse_model/view.rs
+++ b/crates/openlogi-gui/src/mouse_model/view.rs
@@ -11,8 +11,8 @@ use gpui_component::{Icon, IconName, Selectable, h_flex, popover::Popover, v_fle
 use crate::app::{glow_canvas, keyboard_glow};
 use crate::asset::{GlowGeometry, ResolvedAsset};
 use crate::data::mouse_buttons::{
-    Action, ButtonId, GestureDirection, Hotspot, MOUSE_MODEL_SIZE, MouseControlId,
-    default_binding, default_hotspots,
+    Action, ButtonId, GestureDirection, Hotspot, MOUSE_MODEL_SIZE, MouseControlId, default_binding,
+    default_hotspots,
 };
 use crate::mouse_model::geometry::{
     asset_dimensions_for_png, asset_has_button_labels, asset_hotspots_for_png, default_labels,
@@ -273,11 +273,7 @@ fn gesture_capable_buttons(labels: &[Label]) -> Vec<ButtonId> {
     ];
     ORDER
         .into_iter()
-        .filter(|id| {
-            labels
-                .iter()
-                .any(|label| label.id.button() == Some(*id))
-        })
+        .filter(|id| labels.iter().any(|label| label.id.button() == Some(*id)))
         .collect()
 }
 
@@ -527,6 +523,7 @@ fn label_popover(
         binding,
         highlighted: highlighted || hovered == Some(label.id) || active == Some(label.id),
         selected: false,
+        binding_popover,
         view: view.clone(),
     };
     let popover: AnyElement = if label
@@ -547,8 +544,8 @@ fn label_popover(
         let view_state = view.clone();
         let view_content = view.clone();
         Popover::new(("label-popover", idx))
-            // The picker draws its own `menu_card` surface, matching the gesture
-            // menu — so suppress the framework popover surface.
+            // `action_picker` draws its own `menu_card` surface, matching the
+            // gesture menu — so suppress the framework popover surface.
             .appearance(false)
             .anchor(Anchor::TopLeft)
             .mouse_button(MouseButton::Left)
@@ -591,6 +588,7 @@ struct LabelTrigger {
     binding: BindingLabel,
     highlighted: bool,
     selected: bool,
+    binding_popover: BindingPopover,
     view: Entity<MouseModelView>,
 }
 
@@ -611,6 +609,8 @@ impl RenderOnce for LabelTrigger {
         let selected = self.selected;
         let btn = self.label.id;
         let view = self.view;
+        let view_click = view.clone();
+        let binding_popover = self.binding_popover;
         let pal = theme::palette(cx);
         let binding_color = if highlighted {
             rgb(ACCENT_BLUE).into()
@@ -697,8 +697,12 @@ impl RenderOnce for LabelTrigger {
                             .text_color(pal.text_muted),
                     ),
             )
-            // Popover itself owns trigger toggling on mouse-down. Adding an
-            // on_click toggle here closes it again on mouse-up.
+            .on_click(move |_event, _window, cx| {
+                view_click.update(cx, |this, vcx| {
+                    this.set_binding_popover_open(binding_popover, !selected);
+                    vcx.notify();
+                });
+            })
             .on_hover(move |hovered, _window, cx| {
                 let is_hovered = *hovered;
                 view.update(cx, |this, cx| {
@@ -718,7 +722,10 @@ fn binding_label_for_control(
     bindings: &std::collections::BTreeMap<ButtonId, Action>,
     gesture_owner: Option<ButtonId>,
 ) -> BindingLabel {
-    if control.button().is_some_and(|button| gesture_owner == Some(button)) {
+    if control
+        .button()
+        .is_some_and(|button| gesture_owner == Some(button))
+    {
         return BindingLabel {
             text: tr!("5 directions"),
             is_default: false,
@@ -835,6 +842,7 @@ fn hotspot_popover(
         id: ("hotspot-trigger", idx).into(),
         hotspot,
         hovered: hovered == Some(hotspot.id) || active == Some(hotspot.id),
+        binding_popover,
         view: view.clone(),
         selected: false,
     };
@@ -894,6 +902,7 @@ struct HotspotTrigger {
     id: ElementId,
     hotspot: Hotspot,
     hovered: bool,
+    binding_popover: BindingPopover,
     view: Entity<MouseModelView>,
     selected: bool,
 }
@@ -914,6 +923,8 @@ impl RenderOnce for HotspotTrigger {
         let highlighted = self.hovered || self.selected;
         let selected = self.selected;
         let view = self.view;
+        let view_click = view.clone();
+        let binding_popover = self.binding_popover;
         let hotspot = self.hotspot;
         let btn = hotspot.id;
 
@@ -944,8 +955,12 @@ impl RenderOnce for HotspotTrigger {
                         hsla(0., 0., 0.18, 0.85)
                     }),
             )
-            // Popover itself owns trigger toggling on mouse-down. Adding an
-            // on_click toggle here closes it again on mouse-up.
+            .on_click(move |_event, _window, cx| {
+                view_click.update(cx, |this, vcx| {
+                    this.set_binding_popover_open(binding_popover, !selected);
+                    vcx.notify();
+                });
+            })
             .on_hover(move |hovered, _window, cx| {
                 let is_hovered = *hovered;
                 view.update(cx, |this, cx| {
diff --git a/crates/openlogi-gui/src/platform/permissions.rs b/crates/openlogi-gui/src/platform/permissions.rs
index 182db5c0766a62996c9dbfe0b219ad31826a0f73..2c6dd94327d5803d2cd8acaf861719a7094f0aab 100644
--- a/crates/openlogi-gui/src/platform/permissions.rs
+++ b/crates/openlogi-gui/src/platform/permissions.rs
@@ -47,6 +47,9 @@ pub enum Permission {
     /// macOS: CoreBluetooth authorization.
     #[cfg(target_os = "macos")]
     Bluetooth,
+    /// macOS: Camera (AVFoundation) authorization for the webcam preview.
+    #[cfg(target_os = "macos")]
+    Camera,
 }
 
 /// Current Input Monitoring ("listen event") status.
@@ -63,6 +66,19 @@ pub fn bluetooth() -> PermissionStatus {
     macos::bluetooth()
 }
 
+/// Current Camera (AVFoundation) authorization status. Delegates to
+/// `openlogi-camera`, which owns all the camera FFI, so the GUI doesn't
+/// duplicate the AVFoundation calls.
+#[cfg(target_os = "macos")]
+#[must_use]
+pub fn camera() -> PermissionStatus {
+    match openlogi_camera::camera_authorization() {
+        openlogi_camera::CameraAuthorization::Granted => PermissionStatus::Granted,
+        openlogi_camera::CameraAuthorization::Denied => PermissionStatus::Denied,
+        openlogi_camera::CameraAuthorization::Undetermined => PermissionStatus::Unknown,
+    }
+}
+
 /// Probe Linux input-device access: `/dev/uinput` (write) and at least one
 /// Logitech `/dev/hidraw*` (read/write).
 ///
@@ -110,6 +126,7 @@ pub fn open_pane(permission: Permission) {
         Permission::Accessibility => "Privacy_Accessibility",
         Permission::InputMonitoring => "Privacy_ListenEvent",
         Permission::Bluetooth => "Privacy_Bluetooth",
+        Permission::Camera => "Privacy_Camera",
     };
     let url = format!("x-apple.systempreferences:com.apple.preference.security?{anchor}");
     if let Err(e) = opener::open(&url) {
diff --git a/crates/openlogi-gui/src/state.rs b/crates/openlogi-gui/src/state.rs
index cec17081519156a379bfde0536f876541033e22b..3f62f0da76fb9dc4fead72c3777aadb10ca14643 100644
--- a/crates/openlogi-gui/src/state.rs
+++ b/crates/openlogi-gui/src/state.rs
@@ -11,22 +11,18 @@
 
 use std::collections::BTreeMap;
 
-use gpui::{App, Global};
-use openlogi_core::config::{
-    AppSettings, Appearance, AssetSourcePreference, Config, DeviceIdentity, Lighting,
-};
-use openlogi_core::device::{DeviceInventory, DeviceModelInfo};
-use openlogi_hid::{
-    DeviceRoute, DpiCapabilities, DpiInfo, SmartShiftMode, SmartShiftStatus, WriteError,
-};
+use gpui::Global;
+use openlogi_core::config::{Config, KeyTrigger, LightSettings};
+use openlogi_core::device::{DeviceInventory, StandaloneDevice};
+use openlogi_hid::{DpiInfo, SmartShiftStatus};
 use tokio::sync::mpsc;
-use tracing::{debug, warn};
-
-mod devices;
-mod load;
+use tracing::warn;
 
 pub use devices::DeviceRecord;
-pub use load::{DpiStatus, Load, SmartShiftLoad};
+pub use light::LightCommandStatus;
+#[cfg(test)]
+pub use load::Load;
+pub use load::{DpiStatus, SmartShiftLoad};
 
 /// Result of confirming a SmartShift write by reading the value back.
 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
@@ -44,18 +40,29 @@ pub enum SmartShiftWriteStatus {
     Failed,
 }
 
+pub(crate) use devices::camera_model_info;
+use light::PendingLightCommand;
 use load::LazyDeviceData;
 
 use crate::asset::AssetResolver;
 use crate::data::mouse_buttons::{Action, ButtonId, GestureDirection};
-use openlogi_core::binding::Binding;
-use crate::mouse_model::thumbwheel::{ThumbwheelPair, ThumbwheelPreset};
-use crate::state::devices::{
-    adopt_transient_record, build_device_list, direct_key_prefix, pick_initial_device,
-    sort_device_list,
-};
-use openlogi_agent_core::bindings::{bindings_for, gesture_bindings_for};
-use openlogi_agent_core::device_order::PhysicalDeviceKey;
+use crate::state::devices::{build_device_list, pick_initial_device};
+
+mod agent;
+mod bindings;
+mod camera;
+mod devices;
+mod dpi;
+mod inventory;
+mod light;
+mod lighting;
+mod load;
+mod scroll;
+mod settings;
+mod smartshift;
+
+#[cfg(test)]
+mod tests;
 
 /// Default DPI value applied to a fresh AppState. Matches a common Logitech
 /// mid-range mouse and keeps the dot-preview visually obvious from frame one.
@@ -85,6 +92,19 @@ pub enum AgentLink {
     Ready(openlogi_agent_core::ipc::AgentStatus),
 }
 
+/// Where [`AppState`] may persist configuration mutations.
+///
+/// Runtime state uses [`Self::UserFile`]. Tests opt into
+/// [`Self::MemoryOnly`] so realistic device fixtures can never modify the
+/// developer's actual `config.toml`.
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+pub enum ConfigPersistence {
+    /// Persist to OpenLogi's default per-user configuration file.
+    UserFile,
+    /// Keep changes in the in-memory [`Config`] only.
+    MemoryOnly,
+}
+
 /// Inventory snapshots can briefly miss a real device while another HID++
 /// request is in flight. Keep the previous record through this many
 /// consecutive misses so a transient probe timeout does not make the carousel
@@ -100,6 +120,17 @@ pub struct AppState {
     /// non-macOS / no frontmost app. Used to overlay per-app bindings on
     /// top of the per-device global map.
     pub current_app_bundle: Option<String>,
+    /// Aggregate host-camera activity reported by the agent. Runtime only.
+    camera_active: bool,
+    /// Transient manual power choices for camera-linked lights. Cleared on
+    /// the next camera-state transition and never persisted as an override.
+    manual_light_overrides: BTreeMap<String, bool>,
+    /// Session-only settings for raw devices whose OS-node identity is not
+    /// stable enough to persist in `config.toml`.
+    volatile_light_settings: BTreeMap<String, LightSettings>,
+    light_commands: BTreeMap<String, PendingLightCommand>,
+    light_command_status: Option<(String, u64, LightCommandStatus)>,
+    next_light_request_id: u64,
     /// The hotspot the user most recently armed by clicking. Drives the
     /// "selected button" outline on the mouse model and the popover content.
     pub active_button: Option<ButtonId>,
@@ -119,6 +150,12 @@ pub struct AppState {
     ///
     /// [`DeviceConfig::bindings`]: openlogi_core::config::DeviceConfig::bindings
     pub gesture_bindings: BTreeMap<GestureDirection, Action>,
+    /// Global keyboard F-key bindings (Esc + F1-F19). Device-agnostic — one
+    /// map applies across all keyboards — so, unlike [`Self::button_bindings`],
+    /// this is *not* reloaded on device switch. Seeded once from
+    /// [`Config::keyboard`] and kept in sync via [`Self::commit_keyboard_binding`].
+    /// Sorted (`BTreeMap`) for stable render order in the function-row view.
+    pub keyboard_bindings: BTreeMap<KeyTrigger, Action>,
     pub dpi: u32,
     /// DPI capability load state keyed by [`DeviceRecord::config_key`]. Loaded
     /// lazily because HID++ reads must not block device switching or rendering.
@@ -155,6 +192,8 @@ pub struct AppState {
     /// rebuild, and "apply now" device changes (DPI / SmartShift / lighting)
     /// go out as their own commands. The GUI never opens a device itself.
     ipc_commands: mpsc::UnboundedSender<crate::ipc_client::Command>,
+    /// Explicit persistence boundary; tests use an in-memory-only state.
+    config_persistence: ConfigPersistence,
     /// Raw inventory from the last *completed* enumeration, kept for the
     /// diagnostics report (receivers + transports). The poll path only stores
     /// [`InventoryHealth::Ready`](openlogi_agent_core::ipc::InventoryHealth)
@@ -184,16 +223,25 @@ impl AppState {
     pub fn with_runtime(
         mut config: Config,
         inventories: &[DeviceInventory],
+        standalone: &[StandaloneDevice],
         cache: &AssetResolver,
+        cameras: &[openlogi_camera::Camera],
+        config_persistence: ConfigPersistence,
         ipc_commands: mpsc::UnboundedSender<crate::ipc_client::Command>,
     ) -> Self {
-        let device_list = build_device_list(inventories, cache, &config);
+        let device_list = build_device_list(inventories, standalone, cache, &config, cameras);
         // Record any device probed at launch so it survives the next cold start.
-        persist_identities(&mut config, &device_list);
+        let identities_changed = inventory::persist_identities(&mut config, &device_list);
         let current_device = pick_initial_device(&device_list, config.selected_device());
         let mut state = Self {
             current_device,
             current_app_bundle: None,
+            camera_active: false,
+            manual_light_overrides: BTreeMap::new(),
+            volatile_light_settings: BTreeMap::new(),
+            light_commands: BTreeMap::new(),
+            light_command_status: None,
+            next_light_request_id: 0,
             active_button: None,
             // Updated from the agent's IPC poll; the GUI no longer runs the
             // hook, so it can't meaningfully query Accessibility (or devices)
@@ -201,6 +249,7 @@ impl AppState {
             agent_link: AgentLink::Connecting,
             button_bindings: BTreeMap::new(),
             gesture_bindings: BTreeMap::new(),
+            keyboard_bindings: BTreeMap::new(),
             dpi: DEFAULT_DPI,
             dpi_data: LazyDeviceData::default(),
             inventory_misses: BTreeMap::new(),
@@ -211,25 +260,38 @@ impl AppState {
             device_list,
             config,
             ipc_commands,
+            config_persistence,
             last_inventory: Vec::new(),
             #[cfg(all(target_os = "macos", debug_assertions))]
             monitor_events: std::collections::VecDeque::new(),
             #[cfg(all(target_os = "macos", debug_assertions))]
             event_taps: Vec::new(),
         };
+        if identities_changed {
+            state.persist_config("device identity");
+        }
         state.button_bindings = state.bindings_for_current();
         state.gesture_bindings = state.gesture_bindings_for_current();
+        // Keyboard bindings are global, so they seed straight from the config
+        // map — no per-device resolution like mouse bindings above.
+        state.keyboard_bindings = state
+            .config
+            .keyboard
+            .bindings
+            .iter()
+            .map(|(k, v)| (k.clone(), v.clone()))
+            .collect();
         state
     }
-
     /// Send a device command to the agent over IPC, logging a dropped channel
     /// (the client thread is gone) rather than surfacing it.
-    fn send_ipc(&self, command: crate::ipc_client::Command) {
+    fn send_ipc(&self, command: crate::ipc_client::Command) -> bool {
         if self.ipc_commands.send(command).is_err() {
             warn!("IPC client thread is gone — device command dropped");
+            return false;
         }
+        true
     }
-
     /// Persist the in-memory config and — only if the write actually landed —
     /// have the agent reload it. `what` names the setting for the failure log.
     ///
@@ -239,1735 +301,48 @@ impl AppState {
     /// next reconnect or wake. Skipping the reload keeps the agent on whatever
     /// it already runs; the GUI keeps the new value in memory either way.
     fn persist_and_reload(&self, what: &str) {
+        if self.persist_config(what) {
+            self.send_ipc(crate::ipc_client::Command::ReloadConfig);
+        }
+    }
+    fn persist_config(&self, what: &str) -> bool {
+        if self.config_persistence == ConfigPersistence::MemoryOnly {
+            return true;
+        }
         if let Err(e) = self.config.save_atomic() {
-            warn!(error = %e, what, "could not persist to config.toml — agent reload skipped");
-            return;
+            warn!(error = %e, what, "could not persist to config.toml");
+            return false;
         }
-        self.send_ipc(crate::ipc_client::Command::ReloadConfig);
+        true
     }
-
     /// A clone of the IPC command sender, so views (the DPI / SmartShift panels)
     /// can issue device reads and writes through the agent themselves.
     #[must_use]
     pub fn ipc_sender(&self) -> mpsc::UnboundedSender<crate::ipc_client::Command> {
         self.ipc_commands.clone()
     }
-
     /// Cache a *completed* inventory snapshot for the diagnostics report.
     /// Callers gate on [`InventoryHealth::Ready`](openlogi_agent_core::ipc::InventoryHealth) —
     /// see [`Self::last_inventory`].
     pub fn store_inventory_snapshot(&mut self, inventory: &[DeviceInventory]) {
         self.last_inventory = inventory.to_vec();
     }
-
     /// The last completed inventory snapshot, used by diagnostics for transports and receivers.
     #[must_use]
     pub fn last_inventory(&self) -> &[DeviceInventory] {
         &self.last_inventory
     }
-
-    /// Append a batch of live-monitor events, capping the retained history so the
-    /// buffer can't grow without bound while the monitor is open.
-    #[cfg(all(target_os = "macos", debug_assertions))]
-    pub fn push_monitor_events(&mut self, events: Vec<openlogi_agent_core::ipc::MonitorEvent>) {
-        const MAX: usize = 200;
-        self.monitor_events.extend(events);
-        let overflow = self.monitor_events.len().saturating_sub(MAX);
-        self.monitor_events.drain(..overflow);
-    }
-
-    /// Recent live-monitor events, oldest first.
-    #[cfg(all(target_os = "macos", debug_assertions))]
-    #[must_use]
-    pub fn monitor_events(
-        &self,
-    ) -> &std::collections::VecDeque<openlogi_agent_core::ipc::MonitorEvent> {
-        &self.monitor_events
-    }
-
-    /// Replace the cached event-tap snapshot the Diagnostics page renders.
-    /// Refreshed on the live-monitor poll tick; see [`Self::event_taps`].
-    #[cfg(all(target_os = "macos", debug_assertions))]
-    pub fn set_event_taps(&mut self, taps: Vec<openlogi_hook::EventTapInfo>) {
-        self.event_taps = taps;
-    }
-
-    /// The cached event-tap snapshot for the Diagnostics page.
-    #[cfg(all(target_os = "macos", debug_assertions))]
-    #[must_use]
-    pub fn event_taps(&self) -> &[openlogi_hook::EventTapInfo] {
-        &self.event_taps
-    }
-
     /// Config schema version and the number of devices with saved configuration.
     #[must_use]
     pub fn config_summary(&self) -> (u32, usize) {
         (self.config.schema_version, self.config.devices.len())
     }
-
-    /// The cached DPI-discovery status for `key`, for the diagnostics report.
-    #[must_use]
-    pub fn dpi_status_for(&self, key: &str) -> Option<DpiStatus> {
-        self.dpi_data.get(key).cloned()
-    }
-
-    /// Ask the agent to fire the macOS Accessibility prompt. The agent owns the
-    /// CGEventTap, so the system dialog must name and authorize the *agent*
-    /// binary; prompting in the GUI process (as the pre-split build did) would
-    /// grant the wrong binary and the hook would never install.
-    pub fn request_accessibility_prompt(&self) {
-        self.send_ipc(crate::ipc_client::Command::RequestAccessibilityPrompt);
-    }
-
     /// The active device, or `None` when [`Self::device_list`] is empty or
     /// `current_device` is past the end.
     #[must_use]
     pub fn current_record(&self) -> Option<&DeviceRecord> {
         self.device_list.get(self.current_device)
     }
-
-    /// Every known device model that can be resolved to an asset depot.
-    ///
-    /// This reads the UI's merged device list rather than only the latest live
-    /// inventory, so a temporarily incomplete probe can still download art for
-    /// a device restored from its persisted identity.
-    pub(crate) fn asset_models(&self) -> Vec<(DeviceModelInfo, Option<String>)> {
-        self.device_list
-            .iter()
-            .filter_map(|record| {
-                record
-                    .model_info
-                    .clone()
-                    .map(|model| (model, record.codename.clone()))
-            })
-            .collect()
-    }
-
-    /// The agent connection state the render path branches on.
-    #[must_use]
-    pub fn agent_link(&self) -> &AgentLink {
-        &self.agent_link
-    }
-
-    /// The latest agent status snapshot — `None` while not connected (any
-    /// non-[`AgentLink::Ready`] state), which readers like the Settings
-    /// permission rows surface as "unknown", not "denied".
-    #[must_use]
-    pub fn agent_status(&self) -> Option<&openlogi_agent_core::ipc::AgentStatus> {
-        match &self.agent_link {
-            AgentLink::Ready(status) => Some(status),
-            _ => None,
-        }
-    }
-
-    /// Replace the link, reporting whether it actually changed — the steady
-    /// IPC poll mostly delivers identical snapshots, and the caller skips the
-    /// window refresh for those.
-    pub fn set_agent_link(&mut self, link: AgentLink) -> bool {
-        if self.agent_link == link {
-            return false;
-        }
-        self.agent_link = link;
-        true
-    }
-
-    /// Replace [`Self::device_list`] from a fresh inventory snapshot,
-    /// preserving the carousel selection by `config_key` when possible. If
-    /// the previously-selected device disappeared, the selection falls back
-    /// to index 0. Returns whether anything actually changed.
-    ///
-    /// No-op (returning `false`) when the new list has the same `config_key`
-    /// sequence as the current one — the caller skips the window refresh, and
-    /// quiet polling cycles cause no spurious re-renders (P1.6). `force`
-    /// pushes through that early-return: the records embed resolved asset
-    /// paths, so a completed asset sync needs one rebuild even though the
-    /// device *set* is unchanged.
-    pub fn refresh_inventories(
-        &mut self,
-        inventories: &[DeviceInventory],
-        cache: &AssetResolver,
-        force: bool,
-    ) -> bool {
-        let new_list = build_device_list(inventories, cache, &self.config);
-        let merged_list = self.merge_inventory_snapshot(new_list);
-        // Capture any newly-probed identity before the unchanged-check can early
-        // out: a device whose capabilities just resolved keeps the same
-        // config_key + route, so that guard would otherwise skip the write.
-        persist_identities(&mut self.config, &merged_list);
-        // Compare more than config_key: a device can reconnect on a new HID++
-        // index while keeping its physical config key, and the fresh route must
-        // replace the stale one so reads/writes don't target a dead index.
-        // `online` and `capabilities` are compared too, so a device waking up or
-        // a probe that resolves its feature table on a stable route still
-        // refreshes the carousel (and its config panels) instead of being
-        // swallowed by this guard.
-        let unchanged = merged_list.len() == self.device_list.len()
-            && merged_list
-                .iter()
-                .zip(self.device_list.iter())
-                .all(|(a, b)| {
-                    a.config_key == b.config_key
-                        && a.route == b.route
-                        && a.online == b.online
-                        && a.capabilities == b.capabilities
-                });
-        if unchanged && !force {
-            return false;
-        }
-
-        let previous_key = self.current_record().map(|r| r.config_key.clone());
-        let new_index = previous_key
-            .as_deref()
-            .and_then(|k| merged_list.iter().position(|r| r.config_key == k))
-            .unwrap_or(0);
-        let connected_keys = merged_list
-            .iter()
-            .map(|r| r.config_key.as_str())
-            .collect::<Vec<_>>();
-        debug!(
-            count = merged_list.len(),
-            ?connected_keys,
-            "inventory refreshed"
-        );
-
-        // A device that came back on a different route must re-discover DPI —
-        // its cached status/attempts were keyed to the now-dead route.
-        let rerouted: Vec<String> = merged_list
-            .iter()
-            .filter(|new| {
-                self.device_list
-                    .iter()
-                    .any(|old| old.config_key == new.config_key && old.route != new.route)
-            })
-            .map(|new| new.config_key.clone())
-            .collect();
-
-        self.device_list = merged_list;
-        for key in &rerouted {
-            self.dpi_data.remove(key);
-            self.smartshift_data.remove(key);
-            self.smartshift_pending_confirm.remove(key);
-            self.smartshift_write_status.remove(key);
-        }
-        let present = |key: &str| {
-            self.device_list
-                .iter()
-                .any(|r| r.config_key.as_str() == key)
-        };
-        self.dpi_data.retain_present(present);
-        self.smartshift_data.retain_present(present);
-        self.smartshift_pending_confirm
-            .retain(|key, _| present(key));
-        self.smartshift_write_status.retain(|key, _| present(key));
-        self.current_device = new_index;
-        // The active device may have changed (selection fell back to index 0
-        // when the previous one vanished); re-seed the displayed DPI so it
-        // tracks the now-current device rather than the old one.
-        self.dpi = self.dpi_for_current();
-        self.button_bindings = self.bindings_for_current();
-        self.gesture_bindings = self.gesture_bindings_for_current();
-        // Display state only — the agent runs its own inventory watcher and
-        // rebuilds the live binding/DPI maps itself.
-        true
-    }
-
-    fn merge_inventory_snapshot(&mut self, new_list: Vec<DeviceRecord>) -> Vec<DeviceRecord> {
-        let mut by_key = new_list
-            .into_iter()
-            .map(|record| (record.config_key.clone(), record))
-            .collect::<BTreeMap<_, _>>();
-        let mut adopted = self.adopt_transient_records(&mut by_key);
-        let mut merged = Vec::with_capacity(by_key.len().max(self.device_list.len()));
-
-        for previous in &self.device_list {
-            if let Some(record) = by_key.remove(&previous.config_key) {
-                self.inventory_misses.remove(&previous.config_key);
-                merged.push(record);
-                continue;
-            }
-
-            if let Some(record) = adopted.remove(&previous.config_key) {
-                self.inventory_misses.remove(&previous.config_key);
-                merged.push(record);
-                continue;
-            }
-
-            // An all-zero direct unit id is only a transient probe result. If
-            // the next snapshot resolves a physical serial/unit key, retaining
-            // this record through the normal miss grace would show both cards.
-            if !previous.is_persistent() {
-                self.inventory_misses.remove(&previous.config_key);
-                continue;
-            }
-
-            let misses = self
-                .inventory_misses
-                .entry(previous.config_key.clone())
-                .or_insert(0);
-            *misses = misses.saturating_add(1);
-            if *misses <= INVENTORY_MISS_GRACE {
-                debug!(
-                    key = %previous.config_key,
-                    misses = *misses,
-                    "keeping device through transient inventory miss"
-                );
-                merged.push(previous.clone());
-            }
-        }
-
-        for (key, record) in by_key {
-            self.inventory_misses.remove(&key);
-            merged.push(record);
-        }
-        // Adopted records whose known card was never in the previous list
-        // (identity known only from config) still belong in the carousel.
-        merged.extend(adopted.into_values());
-        self.inventory_misses
-            .retain(|key, _| merged.iter().any(|record| record.config_key == *key));
-        // `merged` is `previous-order + newly-appeared`, so re-apply the
-        // canonical route order or a new device would be stuck at the end of
-        // the carousel permanently.
-        sort_device_list(&mut merged);
-        merged
-    }
-
-    /// Pair each transient direct record in the snapshot with the device it
-    /// physically is. A transient key (`…:unit:00000000`) is a half-read probe
-    /// of some existing device, not a new one (#482): when exactly one known
-    /// card sharing its `direct:<vid>:<pid>` wire identity is not live online —
-    /// so the half-read probe can only be that device — the transient record is
-    /// folded into that card instead of surfacing beside it (or evicting it).
-    /// With no such card the transient is dropped as probe noise when its wire
-    /// product is already live online, and an ambiguous one (two known
-    /// same-model cards absent) is left alone.
-    fn adopt_transient_records(
-        &self,
-        by_key: &mut BTreeMap<String, DeviceRecord>,
-    ) -> BTreeMap<String, DeviceRecord> {
-        let transient_keys: Vec<String> = by_key
-            .values()
-            .filter(|record| !record.is_persistent())
-            .map(|record| record.config_key.clone())
-            .collect();
-        let mut adopted = BTreeMap::new();
-        for key in transient_keys {
-            let Some(prefix) = direct_key_prefix(&key) else {
-                continue;
-            };
-            let same_wire = |key: &str, record: &DeviceRecord| {
-                record.is_persistent() && direct_key_prefix(key) == Some(prefix)
-            };
-            // A live online sibling is accounted for and never a candidate,
-            // but it must not discard the transient — the half-read probe may
-            // be the *other* same-model device.
-            let mut candidates: Vec<String> = by_key
-                .iter()
-                .filter(|(k, record)| same_wire(k, record) && !record.online)
-                .map(|(k, _)| k.clone())
-                .collect();
-            for previous in &self.device_list {
-                if same_wire(&previous.config_key, previous)
-                    && !by_key.contains_key(&previous.config_key)
-                    && !candidates.contains(&previous.config_key)
-                {
-                    candidates.push(previous.config_key.clone());
-                }
-            }
-            let [known_key] = candidates.as_slice() else {
-                if candidates.is_empty()
-                    && by_key
-                        .iter()
-                        .any(|(k, record)| same_wire(k, record) && record.online)
-                {
-                    by_key.remove(&key);
-                }
-                continue;
-            };
-            // Last tick's record carries the freshest identity; the offline
-            // placeholder built from config is the fallback.
-            let known = self
-                .device_list
-                .iter()
-                .find(|record| record.config_key == *known_key)
-                .cloned()
-                .or_else(|| by_key.get(known_key).cloned());
-            let Some(known) = known else {
-                continue;
-            };
-            let known_key = known_key.clone();
-            by_key.remove(&known_key);
-            if let Some(live) = by_key.remove(&key) {
-                adopted.insert(known_key, adopt_transient_record(&known, live));
-            }
-        }
-        adopted
-    }
-
-    /// Switch the carousel to `idx`. Out-of-range indices are silently
-    /// ignored so callers can pass them straight through from UI events.
-    /// Persists the new selection (by config key, not index — index isn't
-    /// stable across restarts), reloads bindings for the new device, and
-    /// pushes the new map into the hook-shared `Arc`.
-    pub fn set_current_device(&mut self, idx: usize) {
-        if idx >= self.device_list.len() || idx == self.current_device {
-            return;
-        }
-        self.current_device = idx;
-        // A device left in `Failed` (transient read errors exhausted its retry
-        // budget) gets one fresh attempt each time it is re-selected.
-        if let Some(key) = self.current_record().map(|r| r.config_key.clone()) {
-            if matches!(self.dpi_data.get(&key), Some(Load::Failed(_))) {
-                self.dpi_data.retry(&key);
-            }
-            if matches!(self.smartshift_data.get(&key), Some(Load::Failed(_))) {
-                self.smartshift_data.retry(&key);
-                self.smartshift_write_status.remove(&key);
-            }
-        }
-        // `self.dpi` is the active device's value; adopt the newly-selected
-        // device's known DPI so the panel doesn't keep showing the previous
-        // device's number until a fresh read lands.
-        self.dpi = self.dpi_for_current();
-        self.button_bindings = self.bindings_for_current();
-        self.gesture_bindings = self.gesture_bindings_for_current();
-        let Some(key) = self
-            .current_record()
-            .and_then(DeviceRecord::persistent_config_key)
-            .map(str::to_string)
-        else {
-            debug!("transient device selection not persisted");
-            return;
-        };
-        self.config.set_selected_device(Some(key));
-        // The agent owns the hook + device I/O; have it switch devices too.
-        self.persist_and_reload("selected device");
-    }
-
-    /// Replace the DPI preset list for the currently selected device. The
-    /// new list is persisted to `config.toml` and pushed into the shared
-    /// hook map so the next `CycleDpiPresets` press sees it. The cycle
-    /// `index` is reset to 0 — the user just rebuilt the list, the old
-    /// index is meaningless.
-    ///
-    /// No-op when no device is selected (binding panel won't expose the
-    /// editor in that state).
-    pub fn commit_dpi_presets(&mut self, presets: Vec<u32>) {
-        let Some(key) = self
-            .current_record()
-            .and_then(DeviceRecord::persistent_config_key)
-            .map(str::to_string)
-        else {
-            debug!("no persistent device key — DPI presets kept in memory only");
-            return;
-        };
-        self.config.set_dpi_presets(&key, presets);
-        self.persist_and_reload("DPI presets");
-    }
-
-    /// Read the DPI preset list for the active device, or an empty `Vec`
-    /// when no device is selected. UI helper.
-    #[must_use]
-    pub fn dpi_presets(&self) -> Vec<u32> {
-        self.current_record()
-            .and_then(DeviceRecord::persistent_config_key)
-            .map(|key| self.config.dpi_presets(key))
-            .unwrap_or_default()
-    }
-
-    /// DPI capability status for the active device.
-    #[must_use]
-    pub fn current_dpi_status(&self) -> DpiStatus {
-        self.current_record().map_or(DpiStatus::Unknown, |record| {
-            self.dpi_data.status(&record.config_key)
-        })
-    }
-
-    /// Whether the active device still needs a DPI read (no status recorded —
-    /// i.e. `Unknown`). Cheaper than `current_dpi_status() == Unknown`: it
-    /// avoids cloning the `DpiInfo`, which matters on the per-frame render path.
-    #[must_use]
-    pub fn current_dpi_unqueried(&self) -> bool {
-        self.current_record()
-            .is_some_and(|record| self.dpi_data.unqueried(&record.config_key))
-    }
-
-    /// The active device's known DPI, falling back to [`DEFAULT_DPI`] until its
-    /// capability read completes. Used to seed `self.dpi` on a device switch.
-    #[must_use]
-    fn dpi_for_current(&self) -> u32 {
-        self.current_record()
-            .and_then(|record| self.dpi_data.get(&record.config_key))
-            .and_then(|status| match status {
-                DpiStatus::Ready(info) => Some(u32::from(info.current)),
-                _ => None,
-            })
-            .unwrap_or(DEFAULT_DPI)
-    }
-
-    /// Mark DPI capability discovery as in flight for `key`.
-    pub fn mark_dpi_loading(&mut self, key: &str) {
-        self.dpi_data.mark_loading(key);
-    }
-
-    /// Reset a stuck `Loading` for `key` back to `Unknown`. Called when the
-    /// discovery worker vanished without delivering a result (e.g. it panicked),
-    /// so the device isn't wedged on "Reading…" with no path to retry.
-    pub fn clear_dpi_loading(&mut self, key: &str) {
-        self.dpi_data.clear_loading(key);
-    }
-
-    /// Drop the active device's recorded DPI status so the next render
-    /// re-runs discovery. Backs the "click to retry" affordance on a
-    /// [`DpiStatus::Failed`] device, which is the only recovery path when the
-    /// carousel has a single device (re-selecting it is a no-op).
-    pub fn retry_active_dpi(&mut self) {
-        if let Some(key) = self.current_record().map(|r| r.config_key.clone()) {
-            self.dpi_data.retry(&key);
-        }
-    }
-
-    /// Store a DPI capability discovery result if it still matches the known
-    /// device route. This guards against async reads completing after the
-    /// carousel or inventory changed.
-    pub fn store_dpi_info(
-        &mut self,
-        key: String,
-        route: &DeviceRoute,
-        result: Result<DpiInfo, WriteError>,
-    ) {
-        let is_active = self.current_record().map(|r| r.config_key.as_str()) == Some(key.as_str());
-        let matches_route = self
-            .device_list
-            .iter()
-            .any(|record| record.config_key == key && record.route.as_ref() == Some(route));
-        let still_present = self
-            .device_list
-            .iter()
-            .any(|record| record.config_key == key);
-        // Only the active device owns the shared `self.dpi`; a result landing for
-        // a background device after a carousel switch must not clobber the
-        // visible value.
-        if let Some(info) = self.dpi_data.store(
-            key,
-            result,
-            dpi_error_is_permanent,
-            matches_route,
-            still_present,
-            "DPI",
-        ) && is_active
-        {
-            self.dpi = u32::from(info.current);
-        }
-    }
-
-    /// DPI capabilities for the active device, if discovery succeeded.
-    #[must_use]
-    pub fn active_dpi_capabilities(&self) -> Option<&DpiCapabilities> {
-        self.current_record()
-            .and_then(|record| self.dpi_data.get(&record.config_key))
-            .and_then(|status| match status {
-                DpiStatus::Ready(info) => Some(&info.capabilities),
-                DpiStatus::Unknown
-                | DpiStatus::Loading
-                | DpiStatus::Failed(_)
-                | DpiStatus::Unsupported(_) => None,
-            })
-    }
-
-    /// Snap `dpi` to the active device's supported list when known.
-    #[must_use]
-    pub fn normalize_active_dpi(&self, dpi: u32) -> u32 {
-        self.active_dpi_capabilities()
-            .map_or(dpi, |caps| caps.snap(dpi))
-    }
-
-    /// SmartShift configuration status for the active device.
-    #[must_use]
-    pub fn current_smartshift_status(&self) -> SmartShiftLoad {
-        self.current_record()
-            .map_or(SmartShiftLoad::Unknown, |record| {
-                self.smartshift_data.status(&record.config_key)
-            })
-    }
-
-    /// Whether the active device still needs a SmartShift read (no status
-    /// recorded). Cheaper than comparing a cloned [`SmartShiftLoad`] on the
-    /// per-frame render path.
-    #[must_use]
-    pub fn current_smartshift_unqueried(&self) -> bool {
-        self.current_record()
-            .is_some_and(|record| self.smartshift_data.unqueried(&record.config_key))
-    }
-
-    /// The active device's resolved SmartShift config, if the read succeeded.
-    /// Callers use it to preserve fields they don't mean to change (e.g.
-    /// tunable torque) when writing back.
-    #[must_use]
-    pub fn current_smartshift_ready(&self) -> Option<SmartShiftStatus> {
-        self.current_record()
-            .and_then(|record| self.smartshift_data.get(&record.config_key))
-            .and_then(|status| match status {
-                SmartShiftLoad::Ready(s) => Some(*s),
-                SmartShiftLoad::Unknown
-                | SmartShiftLoad::Loading
-                | SmartShiftLoad::Failed(_)
-                | SmartShiftLoad::Unsupported(_) => None,
-            })
-    }
-
-    /// Post-write confirmation status for the active device.
-    #[must_use]
-    pub fn current_smartshift_write_status(&self) -> Option<SmartShiftWriteStatus> {
-        self.current_record().and_then(|record| {
-            self.smartshift_write_status
-                .get(&record.config_key)
-                .copied()
-        })
-    }
-
-    /// Mark SmartShift discovery as in flight for `key`.
-    pub fn mark_smartshift_loading(&mut self, key: &str) {
-        self.smartshift_data.mark_loading(key);
-    }
-
-    /// Reset a stuck `Loading` for `key` back to `Unknown` — called when the
-    /// read worker vanished without delivering a result.
-    pub fn clear_smartshift_loading(&mut self, key: &str) {
-        self.smartshift_data.clear_loading(key);
-    }
-
-    /// Drop the active device's recorded SmartShift status so the next render
-    /// re-runs discovery. Backs the "click to retry" affordance on a
-    /// [`SmartShiftLoad::Failed`] device.
-    pub fn retry_active_smartshift(&mut self) {
-        if let Some(key) = self.current_record().map(|r| r.config_key.clone()) {
-            self.smartshift_data.retry(&key);
-            self.smartshift_write_status.remove(&key);
-        }
-    }
-
-    /// Store a SmartShift read result if it still matches the known device
-    /// route and write identity, with the same transient-retry /
-    /// permanent-unsupported handling as [`Self::store_dpi_info`].
-    pub fn store_smartshift_status(
-        &mut self,
-        key: String,
-        route: &DeviceRoute,
-        write_id: Option<u64>,
-        result: Result<SmartShiftStatus, WriteError>,
-    ) {
-        if !smartshift_read_is_current(write_id, self.smartshift_write_status.get(&key)) {
-            debug!(key, ?write_id, "stale SmartShift read result ignored");
-            return;
-        }
-        let matches_route = self
-            .device_list
-            .iter()
-            .any(|record| record.config_key == key && record.route.as_ref() == Some(route));
-        let still_present = self
-            .device_list
-            .iter()
-            .any(|record| record.config_key == key);
-        let status_key = key.clone();
-        self.smartshift_data.store(
-            key,
-            result,
-            smartshift_error_is_permanent,
-            matches_route,
-            still_present,
-            "SmartShift",
-        );
-        let expected = match self.smartshift_write_status.get(&status_key) {
-            Some(SmartShiftWriteStatus::Applying { expected, .. }) => Some(*expected),
-            Some(SmartShiftWriteStatus::Confirmed | SmartShiftWriteStatus::Failed) | None => None,
-        };
-        if let Some(status) = expected.and_then(|expected| {
-            smartshift_write_outcome(expected, self.smartshift_data.get(&status_key))
-        }) {
-            self.smartshift_write_status.insert(status_key, status);
-        }
-    }
-
-    /// Write a full SmartShift configuration to the active device (best-effort,
-    /// on a background thread), optimistically cache it, and persist it to
-    /// `config.toml` — the values live in device RAM and reset on a power
-    /// cycle (#189), so the agent re-applies them when the device reconnects.
-    /// No-op when no device is selected.
-    pub fn commit_smartshift(
-        &mut self,
-        mode: SmartShiftMode,
-        auto_disengage: u8,
-        tunable_torque: u8,
-    ) {
-        let Some(record) = self.current_record() else {
-            debug!("no active device — SmartShift change ignored");
-            return;
-        };
-        let key = record.config_key.clone();
-        let persistent_key = record.persistent_config_key().map(str::to_string);
-        let route = record.route.clone();
-        let can_confirm = route.is_some();
-        if let Some(route) = route {
-            self.send_ipc(crate::ipc_client::Command::SetSmartShift(
-                route,
-                mode,
-                auto_disengage,
-                tunable_torque,
-            ));
-        }
-        if let Some(persistent_key) = persistent_key {
-            self.config.set_smartshift(
-                &persistent_key,
-                openlogi_core::config::SmartShift {
-                    mode: mode.into(),
-                    auto_disengage,
-                    tunable_torque,
-                },
-            );
-            self.persist_and_reload("SmartShift");
-        }
-        // Reflect the write immediately so the panel doesn't flicker back to
-        // the previous value before a re-read lands, but queue a confirming
-        // re-read: the write is fire-and-forget, so a sleeping device that
-        // rejected or timed it out would otherwise leave this optimistic value
-        // showing as "applied" forever (Ready blocks any further read).
-        let expected = SmartShiftStatus {
-            mode,
-            auto_disengage,
-            tunable_torque,
-        };
-        self.smartshift_data.set_ready(key.clone(), expected);
-        let write_id = can_confirm.then(|| {
-            let write_id = self.next_smartshift_write_id;
-            self.next_smartshift_write_id = self.next_smartshift_write_id.saturating_add(1);
-            self.smartshift_pending_confirm
-                .insert(key.clone(), write_id);
-            write_id
-        });
-        self.smartshift_write_status.insert(
-            key,
-            match write_id {
-                Some(write_id) => SmartShiftWriteStatus::Applying { expected, write_id },
-                None => SmartShiftWriteStatus::Failed,
-            },
-        );
-    }
-
-    /// Whether the active device's scroll wheel is inverted (issue #126).
-    /// `false` when no device is selected or the device hasn't opted in.
-    #[must_use]
-    pub fn current_invert_scroll(&self) -> bool {
-        self.current_record()
-            .and_then(DeviceRecord::persistent_config_key)
-            .is_some_and(|key| self.config.invert_scroll(key))
-    }
-
-    /// Whether the active device reports native HID++ wheel inversion support.
-    #[must_use]
-    pub fn current_scroll_inversion_supported(&self) -> bool {
-        self.current_record()
-            .and_then(|record| record.capabilities)
-            .is_some_and(|capabilities| capabilities.scroll_inversion)
-    }
-
-    /// Set the active device's scroll-wheel inversion, persist it, and reload
-    /// the agent so it writes the device's native HID++ wheel inversion. No-op
-    /// when no device is selected or the active device does not report support.
-    pub fn commit_invert_scroll(&mut self, invert: bool) {
-        if !self.current_scroll_inversion_supported() {
-            debug!("active device does not support native scroll inversion");
-            return;
-        }
-        let Some(key) = self
-            .current_record()
-            .and_then(DeviceRecord::persistent_config_key)
-            .map(str::to_string)
-        else {
-            debug!("no persistent device key — invert-scroll change ignored");
-            return;
-        };
-        self.config.set_invert_scroll(&key, invert);
-        self.persist_and_reload("invert scroll");
-    }
-
-    /// The active device's persisted wheel resolution, or `None` when OpenLogi
-    /// leaves the device default untouched.
-    #[must_use]
-    pub fn current_scroll_resolution(&self) -> Option<openlogi_core::config::ScrollResolution> {
-        self.current_record()
-            .and_then(DeviceRecord::persistent_config_key)
-            .and_then(|key| self.config.scroll_resolution(key))
-    }
-
-    /// Whether the active device exposes HID++ `0x2121 HiResWheel`.
-    #[must_use]
-    pub fn current_hires_wheel_supported(&self) -> bool {
-        self.current_record()
-            .and_then(|record| record.capabilities)
-            .is_some_and(|capabilities| capabilities.hires_wheel)
-    }
-
-    /// Persist the active device's wheel resolution and ask the agent to reload
-    /// it. `None` removes OpenLogi's override. No-op without a selected,
-    /// HiResWheel-capable device.
-    pub fn commit_scroll_resolution(
-        &mut self,
-        resolution: Option<openlogi_core::config::ScrollResolution>,
-    ) {
-        let Some((key, supported)) = self.current_record().and_then(|record| {
-            let key = record.persistent_config_key()?.to_string();
-            Some((
-                key,
-                record
-                    .capabilities
-                    .is_some_and(|capabilities| capabilities.hires_wheel),
-            ))
-        }) else {
-            debug!("no persistent device key — wheel-resolution change ignored");
-            return;
-        };
-        if !set_scroll_resolution_if_supported(&mut self.config, &key, supported, resolution) {
-            debug!("active device does not support HiResWheel");
-            return;
-        }
-        self.persist_and_reload("wheel resolution");
-    }
-
-    /// Take the active device's pending SmartShift confirm, if any. Returns the
-    /// `(config_key, route, write_id)` for a one-shot re-read that replaces the
-    /// optimistic value with the device's real state; consumed once so it
-    /// doesn't re-fire.
-    pub fn take_active_smartshift_confirm(&mut self) -> Option<(String, DeviceRoute, u64)> {
-        let record = self.current_record()?;
-        let key = record.config_key.clone();
-        let route = record.route.clone()?;
-        self.smartshift_pending_confirm
-            .remove(&key)
-            .map(|write_id| (key, route, write_id))
-    }
-
-    /// Mark a post-write confirmation as failed when its reply channel closes.
-    pub fn fail_smartshift_confirm(&mut self, key: &str, write_id: u64) {
-        if matches!(
-            self.smartshift_write_status.get(key),
-            Some(SmartShiftWriteStatus::Applying {
-                write_id: current,
-                ..
-            }) if *current == write_id
-        ) {
-            self.smartshift_write_status
-                .insert(key.to_string(), SmartShiftWriteStatus::Failed);
-        }
-    }
-
-    /// The lighting config for the active device, or the default when none is
-    /// stored / no device is selected.
-    #[must_use]
-    pub fn lighting(&self) -> Lighting {
-        self.current_record()
-            .and_then(DeviceRecord::persistent_config_key)
-            .and_then(|key| self.config.lighting(key))
-            .unwrap_or_default()
-    }
-
-    /// The stored lighting config for `key`, or `None` when unset.
-    #[must_use]
-    pub fn lighting_for(&self, key: &str) -> Option<Lighting> {
-        if PhysicalDeviceKey::is_transient(key)
-            || self
-                .device_list
-                .iter()
-                .any(|record| record.config_key == key && !record.is_persistent())
-        {
-            return None;
-        }
-        self.config.lighting(key)
-    }
-
-    /// Persist a new lighting config for the active device and push it to the
-    /// hardware (best-effort). No-op when no device is selected.
-    pub fn commit_lighting(&mut self, lighting: Lighting) {
-        let Some(record) = self.current_record() else {
-            debug!("no active device — lighting change ignored");
-            return;
-        };
-        let key = record.persistent_config_key().map(str::to_string);
-        let target = record.route.clone();
-        if let Some(route) = target {
-            self.send_ipc(crate::ipc_client::Command::SetLighting(
-                route,
-                lighting.clone(),
-            ));
-        }
-        let Some(key) = key else {
-            debug!("transient device lighting applied without persistence");
-            return;
-        };
-        self.config.set_lighting(&key, lighting);
-        // Keep the agent's config copy fresh: it re-applies the saved colour
-        // when the keyboard reconnects, and without the reload it would
-        // replay whatever was saved the last time something *else* reloaded.
-        self.persist_and_reload("lighting");
-    }
-
-    /// Apply `dpi` to the active device (best-effort, via the agent) and
-    /// persist it per device — the sensor value lives in device RAM and resets
-    /// on a power cycle (#189), so the agent re-applies it on reconnect.
-    /// Updates the displayed value even with no device selected.
-    pub fn commit_dpi(&mut self, dpi: u32) {
-        self.dpi = dpi;
-        let Some(record) = self.current_record() else {
-            debug!("no active device — DPI change kept in memory only");
-            return;
-        };
-        let key = record.config_key.clone();
-        let persistent_key = record.persistent_config_key().map(str::to_string);
-        let route = record.route.clone();
-        if let Some(route) = route {
-            self.send_ipc(crate::ipc_client::Command::SetDpi(route, dpi));
-        }
-        if let Some(persistent_key) = persistent_key {
-            self.config.set_dpi(&persistent_key, dpi);
-            self.persist_and_reload("DPI");
-        } else {
-            debug!(key, "transient device DPI applied without persistence");
-        }
-    }
-
-    /// App-wide settings backing the Settings window (launch-at-login,
-    /// update check). Read-only view; mutate via the setters below so the
-    /// change is persisted.
-    #[must_use]
-    pub fn app_settings(&self) -> &AppSettings {
-        &self.config.app_settings
-    }
-
-    /// Toggle launch-at-login, persist to `config.toml`, and reconcile the
-    /// macOS `LaunchAgent` plist so the change takes effect without a
-    /// restart. No-op when the value is unchanged. Disk failures are logged,
-    /// not propagated — the Settings UI shouldn't crash on a full volume.
-    pub fn set_launch_at_login(&mut self, enabled: bool) {
-        if self.config.app_settings.launch_at_login == enabled {
-            return;
-        }
-        self.config.app_settings.launch_at_login = enabled;
-        // The agent owns autostart now; it reconciles its LaunchAgent (which
-        // points at the agent, not the GUI) when it reloads the config.
-        self.persist_and_reload("launch-at-login setting");
-    }
-
-    /// Toggle the menu-bar (status item) icon preference and persist it. The
-    /// icon is hosted by the always-on agent, which reads this on startup and
-    /// installs the status item only when enabled — so the change takes effect
-    /// the next time the agent launches (a no-restart live toggle would need a
-    /// main-thread hop from the agent's IPC reload). `ReloadConfig` keeps the
-    /// agent's other config in sync meanwhile. No-op when unchanged.
-    ///
-    /// The callers are the menu-bar / notification-area toggle in Settings,
-    /// shown only where there's a tray (macOS + Windows), so the setter is
-    /// gated the same way to stay dead-code-clean on Linux.
-    #[cfg(any(target_os = "macos", target_os = "windows"))]
-    pub fn set_show_in_menu_bar(&mut self, enabled: bool) {
-        if self.config.app_settings.show_in_menu_bar == enabled {
-            return;
-        }
-        self.config.app_settings.show_in_menu_bar = enabled;
-        self.persist_and_reload("show-in-menu-bar setting");
-    }
-
-    /// Toggle the opt-in update check and persist it. No immediate side
-    /// effect beyond the next launch reading the new value. No-op when
-    /// unchanged.
-    pub fn set_check_for_updates(&mut self, enabled: bool) {
-        if self.config.app_settings.check_for_updates == enabled {
-            return;
-        }
-        self.config.app_settings.check_for_updates = enabled;
-        if let Err(e) = self.config.save_atomic() {
-            warn!(error = %e, "could not persist update-check setting");
-        }
-    }
-
-    /// Toggle opt-in automatic install and persist it. The launch-time updater
-    /// observer reads this live, so a newer version found after this is enabled
-    /// downloads and stages on its own; no immediate side effect here. No-op
-    /// when unchanged.
-    pub fn set_auto_install_updates(&mut self, enabled: bool) {
-        if self.config.app_settings.auto_install_updates == enabled {
-            return;
-        }
-        self.config.app_settings.auto_install_updates = enabled;
-        if let Err(e) = self.config.save_atomic() {
-            warn!(error = %e, "could not persist auto-install setting");
-        }
-    }
-
-    /// Persist the light/dark appearance preference. The caller re-applies the
-    /// live theme via [`crate::theme::apply_from_settings`]; this only writes the
-    /// choice. No-op when unchanged.
-    pub fn set_appearance(&mut self, appearance: Appearance) {
-        if self.config.app_settings.appearance == appearance {
-            return;
-        }
-        self.config.app_settings.appearance = appearance;
-        if let Err(e) = self.config.save_atomic() {
-            warn!(error = %e, "could not persist appearance setting");
-        }
-    }
-
-    /// Persist the chosen theme name for one mode (`None` = the OpenLogi brand
-    /// theme). No-op when unchanged.
-    pub fn set_theme(&mut self, dark: bool, name: Option<String>) {
-        let slot = if dark {
-            &mut self.config.app_settings.theme_dark
-        } else {
-            &mut self.config.app_settings.theme_light
-        };
-        if *slot == name {
-            return;
-        }
-        *slot = name;
-        if let Err(e) = self.config.save_atomic() {
-            warn!(error = %e, "could not persist theme setting");
-        }
-    }
-
-    /// Persist the UI corner-radius override (`None` = each theme's own radius).
-    /// No-op when unchanged.
-    pub fn set_ui_radius(&mut self, radius: Option<u8>) {
-        if self.config.app_settings.ui_radius == radius {
-            return;
-        }
-        self.config.app_settings.ui_radius = radius;
-        if let Err(e) = self.config.save_atomic() {
-            warn!(error = %e, "could not persist UI radius setting");
-        }
-    }
-
-    /// Set the thumb-wheel sensitivity (clamped to the valid range), publish it
-    /// to the gesture watcher via the shared atomic, and persist it. No-op when
-    /// unchanged. Disk failures are logged, not propagated.
-    pub fn set_thumbwheel_sensitivity(&mut self, sensitivity: i32) {
-        let sensitivity = sensitivity.clamp(
-            openlogi_core::config::MIN_THUMBWHEEL_SENSITIVITY,
-            openlogi_core::config::MAX_THUMBWHEEL_SENSITIVITY,
-        );
-        if self.config.app_settings.thumbwheel_sensitivity == sensitivity {
-            return;
-        }
-        self.config.app_settings.thumbwheel_sensitivity = sensitivity;
-        self.persist_and_reload("thumbwheel sensitivity");
-    }
-
-    pub fn set_auto_download_assets(&mut self, enabled: bool) {
-        if self.config.app_settings.auto_download_assets == enabled {
-            return;
-        }
-        self.config.app_settings.auto_download_assets = enabled;
-        if let Err(e) = self.config.save_atomic() {
-            warn!(error = %e, "could not persist auto-download-assets setting");
-        }
-    }
-
-    /// Persist the preferred device-asset source. The Settings view requests a
-    /// refresh separately when automatic downloads are enabled, so this setter
-    /// remains side-effect-free beyond configuration I/O.
-    pub fn set_asset_source(&mut self, source: AssetSourcePreference) {
-        if self.config.app_settings.asset_source == source {
-            return;
-        }
-        self.config.app_settings.asset_source = source;
-        if let Err(e) = self.config.save_atomic() {
-            warn!(error = %e, "could not persist asset-source setting");
-        }
-    }
-
-    /// Record the answer to the first-run update-check prompt: enable (or leave
-    /// disabled) the check, and mark the prompt as seen so it never reappears.
-    /// Persists once.
-    pub fn record_update_consent(&mut self, enabled: bool) {
-        self.config.app_settings.check_for_updates = enabled;
-        self.config.app_settings.update_prompt_seen = true;
-        if let Err(e) = self.config.save_atomic() {
-            warn!(error = %e, "could not persist update-check consent");
-        }
-    }
-
-    /// The stored UI-language preference: `Some(code)` for an explicit choice,
-    /// `None` for "follow system". Distinct from the *active* locale that
-    /// `None` resolves to at startup, so the Settings picker can show "Follow
-    /// system" as the selected option.
-    #[must_use]
-    pub fn language(&self) -> Option<&str> {
-        self.config.app_settings.language.as_deref()
-    }
-
-    /// Set the UI language (`None` = follow system), persist it, switch the
-    /// process-global locale live via [`crate::i18n`], and repaint open UI.
-    /// No-op when unchanged.
-    pub fn set_language(&mut self, language: Option<String>, cx: &mut App) {
-        if self.config.app_settings.language == language {
-            return;
-        }
-        self.config.app_settings.language = language;
-        if let Err(e) = self.config.save_atomic() {
-            warn!(error = %e, "could not persist language setting");
-        }
-        crate::i18n::activate(self.config.app_settings.language.as_deref());
-        cx.refresh_windows();
-        crate::app_menu::rebuild(cx);
-    }
-
-    /// Update a single binding in memory, on disk, and in the shared hook
-    /// map for the currently selected device.
-    ///
-    /// Disk failures and poisoned hook locks are logged at `warn` instead
-    /// of bubbling up: the UI thread shouldn't crash because the user's
-    /// home volume is full or because the hook thread panicked.
-    pub fn commit_binding(&mut self, button: ButtonId, action: Action) {
-        self.button_bindings.insert(button, action.clone());
-
-        let Some(key) = self
-            .current_record()
-            .and_then(DeviceRecord::persistent_config_key)
-            .map(str::to_string)
-        else {
-            debug!(
-                ?button,
-                "no persistent device key — binding kept in memory only"
-            );
-            return;
-        };
-        self.config
-            .set_binding(&key, button, Binding::Single(action));
-        // The agent owns the hook; have it rebuild its live map from config.
-        self.persist_and_reload("binding");
-    }
-
-    /// Apply one paired thumb-wheel preset to both persisted direction bindings.
-    /// The two config mutations are followed by exactly one save and one agent
-    /// reload, so the runtime never observes a half-updated pair.
-    pub(crate) fn commit_thumbwheel_preset(&mut self, preset: ThumbwheelPreset) {
-        let pair = preset.pair();
-        let persistent_key = self
-            .current_record()
-            .and_then(DeviceRecord::persistent_config_key)
-            .map(str::to_string);
-
-        if !apply_thumbwheel_pair(
-            &mut self.button_bindings,
-            &mut self.config,
-            persistent_key.as_deref(),
-            pair,
-        ) {
-            debug!("no persistent device key — thumb-wheel pair kept in memory only");
-            return;
-        }
-
-        self.persist_and_reload("thumb-wheel binding");
-    }
-
-    fn bindings_for_current(&self) -> BTreeMap<ButtonId, Action> {
-        bindings_for(
-            &self.config,
-            self.current_record()
-                .and_then(DeviceRecord::persistent_config_key),
-            self.current_app_bundle.as_deref(),
-        )
-    }
-
-    fn gesture_bindings_for_current(&self) -> BTreeMap<GestureDirection, Action> {
-        let Some(key) = self
-            .current_record()
-            .and_then(DeviceRecord::persistent_config_key)
-        else {
-            return BTreeMap::new();
-        };
-        match self.config.gesture_owner(key) {
-            // The HID++ gesture button seeds every direction from the defaults.
-            Some(ButtonId::GestureButton) => gesture_bindings_for(&self.config, Some(key)),
-            // A promoted OS-hook button is shown from its raw stored map (which
-            // `set_gesture_owner` seeds with full defaults), so the menu matches
-            // exactly what `oshook_gestures_for` dispatches — no seeding here.
-            Some(owner) => match self.config.bindings_for(key).get(&owner) {
-                Some(Binding::Gesture(map)) => map.clone(),
-                _ => BTreeMap::new(),
-            },
-            None => BTreeMap::new(),
-        }
-    }
-
-    /// The current device's gesture button — the [`Binding::Gesture`] owner — or
-    /// `None` when no button is in gesture mode. Drives which button's card opens
-    /// the gesture menu rather than the single-action picker.
-    #[must_use]
-    pub fn current_gesture_owner(&self) -> Option<ButtonId> {
-        let key = self.current_record()?.persistent_config_key()?;
-        self.config.gesture_owner(key)
-    }
-
-    /// Make `button` the current device's gesture button (or clear it with
-    /// `None`), enforcing the one-gesture-button-per-device lock. Persists, tells
-    /// the agent to rebuild, and refreshes the projected maps the UI reads.
-    pub fn commit_gesture_owner(&mut self, button: Option<ButtonId>) {
-        let Some(key) = self
-            .current_record()
-            .and_then(DeviceRecord::persistent_config_key)
-            .map(str::to_string)
-        else {
-            return;
-        };
-        match button {
-            Some(b) => {
-                self.config.set_gesture_owner(&key, b);
-            }
-            None => {
-                self.config.disable_gestures(&key);
-            }
-        }
-        // The owner change shuffles bindings between the single + gesture maps.
-        self.button_bindings = self.bindings_for_current();
-        self.gesture_bindings = self.gesture_bindings_for_current();
-        self.persist_and_reload("gesture-button change");
-    }
-
-    /// Update a single gesture-button sub-binding in memory, on disk, and in the
-    /// shared gesture map the watcher thread reads.
-    pub fn commit_gesture_binding(&mut self, direction: GestureDirection, action: Action) {
-        let Some(key) = self
-            .current_record()
-            .and_then(DeviceRecord::persistent_config_key)
-            .map(str::to_string)
-        else {
-            debug!(
-                ?direction,
-                "no persistent device key — gesture binding edit ignored"
-            );
-            return;
-        };
-        // Edit whichever button owns gestures — not always the HID++ gesture button. When
-        // gestures are off, a stray edit must NOT silently re-enable them on the
-        // default owner (the gesture editor shouldn't be reachable in that state):
-        // no-op instead.
-        let Some(owner) = self.config.gesture_owner(&key) else {
-            debug!(
-                ?direction,
-                "gestures are off — ignoring gesture binding edit"
-            );
-            return;
-        };
-        self.gesture_bindings.insert(direction, action.clone());
-        self.config
-            .set_gesture_direction(&key, owner, direction, action);
-        // The agent owns the gesture watcher; have it rebuild from config.
-        self.persist_and_reload("gesture binding");
-    }
-}
-
-/// Update both projected bindings and, when a stable device key exists, both
-/// persisted single-action entries. Returns whether the caller should persist
-/// and reload the agent.
-fn apply_thumbwheel_pair(
-    button_bindings: &mut BTreeMap<ButtonId, Action>,
-    config: &mut Config,
-    persistent_key: Option<&str>,
-    pair: ThumbwheelPair,
-) -> bool {
-    button_bindings.insert(ButtonId::ThumbwheelScrollDown, pair.backward.clone());
-    button_bindings.insert(ButtonId::ThumbwheelScrollUp, pair.forward.clone());
-
-    let Some(key) = persistent_key else {
-        return false;
-    };
-    config.set_binding(
-        key,
-        ButtonId::ThumbwheelScrollDown,
-        Binding::Single(pair.backward),
-    );
-    config.set_binding(
-        key,
-        ButtonId::ThumbwheelScrollUp,
-        Binding::Single(pair.forward),
-    );
-    true
-}
-
-/// Record the identity (name / kind / capabilities) of every currently online,
-/// fully-probed device into `config`, persisting to disk only when something
-/// actually changed.
-///
-/// This is the write half of the identity-driven device list: it is what lets
-/// [`build_device_list`] resurrect a sleeping device on the next launch. Only
-/// online devices with *measured* capabilities are recorded — never a presumed
-/// or carried-forward `None` — so a placeholder never persists empty panels.
-/// The change-guard keeps quiet inventory ticks off the disk; the agent does
-/// not consume identities, so no `ReloadConfig` is sent.
-fn persist_identities(config: &mut Config, list: &[DeviceRecord]) {
-    let mut changed = false;
-    for record in list {
-        if !record.online {
-            continue;
-        }
-        let Some(config_key) = record.persistent_config_key() else {
-            continue;
-        };
-        let Some(capabilities) = record.capabilities else {
-            continue;
-        };
-        let identity = DeviceIdentity {
-            display_name: record.display_name.clone(),
-            kind: record.kind,
-            capabilities,
-            model_info: record.model_info.clone().map(|mut model| {
-                model.serial_number = None;
-                model.unit_id = [0; 4];
-                model
-            }),
-            codename: record.codename.clone(),
-        };
-        if config.device_identity(config_key) != Some(&identity) {
-            config.set_device_identity(config_key, identity);
-            changed = true;
-        }
-    }
-    if changed && let Err(e) = config.save_atomic() {
-        warn!(error = %e, "could not persist device identities to config.toml");
-    }
-}
-
-/// Whether a DPI discovery error is permanent (the device genuinely lacks the
-/// feature or reports nothing usable) versus transient (a timeout or busy
-/// device worth retrying).
-fn dpi_error_is_permanent(error: &WriteError) -> bool {
-    matches!(
-        error,
-        WriteError::FeatureUnsupported { .. } | WriteError::EmptyDpiList
-    )
-}
-
-/// Whether a SmartShift read error is permanent: a genuine "feature not
-/// supported" reply (the device lacks `0x2111`) never changes, so stop
-/// probing. Everything else (timeouts, busy device) is transient.
-fn smartshift_error_is_permanent(error: &WriteError) -> bool {
-    matches!(error, WriteError::FeatureUnsupported { .. })
-}
-
-fn smartshift_write_outcome(
-    expected: SmartShiftStatus,
-    load: Option<&SmartShiftLoad>,
-) -> Option<SmartShiftWriteStatus> {
-    match load {
-        Some(SmartShiftLoad::Ready(actual)) if *actual == expected => {
-            Some(SmartShiftWriteStatus::Confirmed)
-        }
-        Some(SmartShiftLoad::Ready(_)) => Some(SmartShiftWriteStatus::Failed),
-        Some(SmartShiftLoad::Failed(_) | SmartShiftLoad::Unsupported(_)) => {
-            Some(SmartShiftWriteStatus::Failed)
-        }
-        None | Some(SmartShiftLoad::Unknown | SmartShiftLoad::Loading) => None,
-    }
-}
-
-fn smartshift_read_is_current(
-    read_id: Option<u64>,
-    write_status: Option<&SmartShiftWriteStatus>,
-) -> bool {
-    match (read_id, write_status) {
-        (
-            Some(read_id),
-            Some(SmartShiftWriteStatus::Applying {
-                write_id: current, ..
-            }),
-        ) => read_id == *current,
-        (None, Some(SmartShiftWriteStatus::Applying { .. })) | (Some(_), _) => false,
-        (None, _) => true,
-    }
-}
-
-fn set_scroll_resolution_if_supported(
-    config: &mut Config,
-    key: &str,
-    supported: bool,
-    resolution: Option<openlogi_core::config::ScrollResolution>,
-) -> bool {
-    if !supported {
-        return false;
-    }
-    config.set_scroll_resolution(key, resolution);
-    true
 }
 
 impl Global for AppState {}
-
-#[cfg(test)]
-mod tests {
-    use openlogi_core::binding::Binding;
-    use openlogi_core::config::{Config, DeviceIdentity, Lighting, ScrollResolution};
-    use openlogi_core::device::{
-        Capabilities, DeviceInventory, DeviceKind, DeviceModelInfo, DeviceTransports, PairedDevice,
-        ReceiverInfo,
-    };
-    use openlogi_hid::{SmartShiftMode, SmartShiftStatus};
-
-    use crate::asset::AssetResolver;
-    use crate::data::mouse_buttons::{Action, ButtonId};
-    use crate::mouse_model::thumbwheel::ThumbwheelPreset;
-
-    use super::{
-        AppState, Load, SmartShiftWriteStatus, apply_thumbwheel_pair, build_device_list,
-        set_scroll_resolution_if_supported, smartshift_read_is_current, smartshift_write_outcome,
-    };
-
-    fn direct_inventory(unit_id: [u8; 4]) -> DeviceInventory {
-        DeviceInventory {
-            receiver: ReceiverInfo {
-                name: "MX Master 3S".to_string(),
-                vendor_id: 0x046d,
-                product_id: 0xb023,
-                unique_id: None,
-            },
-            paired: vec![PairedDevice {
-                slot: openlogi_hid::DIRECT_DEVICE_INDEX,
-                codename: Some("MX Master 3S".to_string()),
-                wpid: None,
-                kind: DeviceKind::Mouse,
-                online: true,
-                battery: None,
-                model_info: Some(DeviceModelInfo {
-                    entity_count: 1,
-                    serial_number: None,
-                    unit_id,
-                    transports: DeviceTransports::default(),
-                    model_ids: [0xb034, 0, 0],
-                    extended_model_id: 2,
-                }),
-                capabilities: Some(Capabilities::presumed_from_kind(DeviceKind::Mouse)),
-            }],
-        }
-    }
-
-    #[test]
-    fn thumbwheel_pair_updates_both_memory_and_config_entries() {
-        let mut bindings = std::collections::BTreeMap::new();
-        let mut config = Config::default();
-        let key = "2b034";
-
-        assert!(apply_thumbwheel_pair(
-            &mut bindings,
-            &mut config,
-            Some(key),
-            ThumbwheelPreset::Volume.pair(),
-        ));
-        assert_eq!(
-            bindings.get(&ButtonId::ThumbwheelScrollDown),
-            Some(&Action::VolumeDown)
-        );
-        assert_eq!(
-            bindings.get(&ButtonId::ThumbwheelScrollUp),
-            Some(&Action::VolumeUp)
-        );
-        let persisted = config.bindings_for(key);
-        assert_eq!(
-            persisted.get(&ButtonId::ThumbwheelScrollDown),
-            Some(&Binding::Single(Action::VolumeDown))
-        );
-        assert_eq!(
-            persisted.get(&ButtonId::ThumbwheelScrollUp),
-            Some(&Binding::Single(Action::VolumeUp))
-        );
-    }
-
-    #[test]
-    fn transient_thumbwheel_pair_stays_in_memory_without_persistence() {
-        let mut bindings = std::collections::BTreeMap::new();
-        let mut config = Config::default();
-
-        assert!(!apply_thumbwheel_pair(
-            &mut bindings,
-            &mut config,
-            None,
-            ThumbwheelPreset::CycleDpi.pair(),
-        ));
-        assert_eq!(bindings.len(), 2);
-        assert!(config.bindings_for("missing").is_empty());
-    }
-
-    #[test]
-    fn transient_identity_is_not_persisted_or_retained_after_resolution() {
-        let cache = AssetResolver::new();
-        let transient_inventory = direct_inventory([0; 4]);
-        let (commands, _receiver) = tokio::sync::mpsc::unbounded_channel();
-        let mut state =
-            AppState::with_runtime(Config::default(), &[transient_inventory], &cache, commands);
-        let transient_key = "direct:046d:b023:unit:00000000";
-
-        assert_eq!(state.device_list.len(), 1);
-        assert!(state.config.device_identity(transient_key).is_none());
-        state.commit_dpi(2400);
-        assert!(state.config.dpi(transient_key).is_none());
-
-        let stable_list = build_device_list(
-            &[direct_inventory([0xa3, 0x93, 0xca, 0xe0])],
-            &cache,
-            &state.config,
-        );
-        let merged = state.merge_inventory_snapshot(stable_list);
-
-        assert_eq!(merged.len(), 1);
-        assert_eq!(merged[0].config_key, "direct:046d:b023:unit:a393cae0");
-        assert!(merged[0].is_persistent());
-    }
-
-    #[test]
-    fn transient_probe_folds_into_its_known_card() {
-        // #482: a half-read probe (all-zero unit id) of the only known device
-        // with that vid/pid must not evict the known card or appear beside it —
-        // the card keeps its identity and takes the live volatile state.
-        let cache = AssetResolver::new();
-        let (commands, _receiver) = tokio::sync::mpsc::unbounded_channel();
-        let mut state = AppState::with_runtime(
-            Config::default(),
-            &[direct_inventory([0xa3, 0x93, 0xca, 0xe0])],
-            &cache,
-            commands,
-        );
-        let stable_key = "direct:046d:b023:unit:a393cae0";
-        assert_eq!(state.device_list[0].config_key, stable_key);
-
-        let transient_list = build_device_list(&[direct_inventory([0; 4])], &cache, &state.config);
-        let merged = state.merge_inventory_snapshot(transient_list);
-
-        assert_eq!(merged.len(), 1, "no second card for the half-read probe");
-        assert_eq!(merged[0].config_key, stable_key);
-        assert!(merged[0].is_persistent());
-        assert!(merged[0].online, "the live probe supplies volatile state");
-        assert!(merged[0].route.is_some(), "the live route is kept usable");
-    }
-
-    #[test]
-    fn transient_record_beside_its_live_device_is_dropped() {
-        // Both a full and a half-read probe of the same wire product in one
-        // snapshot: the transient record is probe noise, not a second device.
-        let cache = AssetResolver::new();
-        let (commands, _receiver) = tokio::sync::mpsc::unbounded_channel();
-        let mut state = AppState::with_runtime(
-            Config::default(),
-            &[direct_inventory([0xa3, 0x93, 0xca, 0xe0])],
-            &cache,
-            commands,
-        );
-
-        let both = build_device_list(
-            &[
-                direct_inventory([0xa3, 0x93, 0xca, 0xe0]),
-                direct_inventory([0; 4]),
-            ],
-            &cache,
-            &state.config,
-        );
-        assert_eq!(both.len(), 2);
-        let merged = state.merge_inventory_snapshot(both);
-
-        assert_eq!(merged.len(), 1);
-        assert_eq!(merged[0].config_key, "direct:046d:b023:unit:a393cae0");
-        assert!(merged[0].online);
-    }
-
-    #[test]
-    fn transient_probe_adopts_the_absent_sibling_of_a_live_twin() {
-        // Two same-model devices; one probes complete, the other half-reads.
-        // The live twin must not get the transient discarded as its own noise:
-        // the half-read probe can only be the sibling, which keeps its card
-        // online and routed.
-        let cache = AssetResolver::new();
-        let (commands, _receiver) = tokio::sync::mpsc::unbounded_channel();
-        let mut state = AppState::with_runtime(
-            Config::default(),
-            &[
-                direct_inventory([1, 1, 1, 1]),
-                direct_inventory([2, 2, 2, 2]),
-            ],
-            &cache,
-            commands,
-        );
-
-        let snapshot = build_device_list(
-            &[direct_inventory([1, 1, 1, 1]), direct_inventory([0; 4])],
-            &cache,
-            &state.config,
-        );
-        let merged = state.merge_inventory_snapshot(snapshot);
-
-        assert_eq!(merged.len(), 2, "no third card for the half-read probe");
-        let Some(sibling) = merged
-            .iter()
-            .find(|r| r.config_key == "direct:046d:b023:unit:02020202")
-        else {
-            panic!("the sibling card must survive under its physical key");
-        };
-        assert!(
-            sibling.online,
-            "the half-read probe keeps the sibling online"
-        );
-        assert!(sibling.route.is_some(), "the live route stays usable");
-    }
-
-    #[test]
-    fn ambiguous_transient_probe_is_not_adopted() {
-        // Two same-model devices are known; a half-read probe could be either,
-        // so neither card may steal it.
-        let cache = AssetResolver::new();
-        let (commands, _receiver) = tokio::sync::mpsc::unbounded_channel();
-        let mut state = AppState::with_runtime(
-            Config::default(),
-            &[
-                direct_inventory([1, 1, 1, 1]),
-                direct_inventory([2, 2, 2, 2]),
-            ],
-            &cache,
-            commands,
-        );
-        assert_eq!(state.device_list.len(), 2);
-
-        let transient_list = build_device_list(&[direct_inventory([0; 4])], &cache, &state.config);
-        let merged = state.merge_inventory_snapshot(transient_list);
-
-        assert_eq!(merged.len(), 3, "both known cards survive on grace");
-        assert_eq!(
-            merged.iter().filter(|r| !r.is_persistent()).count(),
-            1,
-            "the transient card stays its own record"
-        );
-    }
-
-    #[test]
-    fn historical_transient_lighting_is_not_exposed_without_a_live_record() {
-        let transient_key = "direct:046d:b023:unit:00000000";
-        let mut config = Config::default();
-        config.set_lighting(transient_key, Lighting::default());
-        assert!(config.lighting(transient_key).is_some());
-        let (commands, _receiver) = tokio::sync::mpsc::unbounded_channel();
-        let state = AppState::with_runtime(config, &[], &AssetResolver::new(), commands);
-
-        assert!(state.device_list.is_empty());
-        assert!(state.lighting_for(transient_key).is_none());
-    }
-
-    #[test]
-    fn smartshift_write_feedback_requires_the_written_value() {
-        let expected = SmartShiftStatus {
-            mode: SmartShiftMode::Ratchet,
-            auto_disengage: 12,
-            tunable_torque: 0,
-        };
-        assert_eq!(smartshift_write_outcome(expected, None), None);
-        assert_eq!(
-            smartshift_write_outcome(expected, Some(&Load::Ready(expected))),
-            Some(SmartShiftWriteStatus::Confirmed)
-        );
-        assert_eq!(
-            smartshift_write_outcome(
-                expected,
-                Some(&Load::Ready(SmartShiftStatus {
-                    auto_disengage: 13,
-                    ..expected
-                })),
-            ),
-            Some(SmartShiftWriteStatus::Failed)
-        );
-        assert_eq!(
-            smartshift_write_outcome(
-                expected,
-                Some(&Load::<SmartShiftStatus>::Failed("timeout".to_string(),))
-            ),
-            Some(SmartShiftWriteStatus::Failed)
-        );
-    }
-
-    #[test]
-    fn stale_smartshift_reads_do_not_resolve_newer_writes() {
-        let expected = SmartShiftStatus {
-            mode: SmartShiftMode::Ratchet,
-            auto_disengage: 12,
-            tunable_torque: 0,
-        };
-        let applying = SmartShiftWriteStatus::Applying {
-            expected,
-            write_id: 2,
-        };
-
-        assert!(smartshift_read_is_current(Some(2), Some(&applying)));
-        assert!(!smartshift_read_is_current(Some(1), Some(&applying)));
-        assert!(!smartshift_read_is_current(None, Some(&applying)));
-        assert!(!smartshift_read_is_current(
-            Some(2),
-            Some(&SmartShiftWriteStatus::Confirmed)
-        ));
-        assert!(smartshift_read_is_current(None, None));
-    }
-
-    #[test]
-    fn known_offline_device_is_an_asset_sync_target() {
-        let model = DeviceModelInfo {
-            entity_count: 0,
-            serial_number: None,
-            unit_id: [0; 4],
-            transports: DeviceTransports::default(),
-            model_ids: [0xb034, 0, 0],
-            extended_model_id: 2,
-        };
-        let mut config = Config::default();
-        config.set_device_identity(
-            "2b034",
-            DeviceIdentity {
-                display_name: "MX Anywhere 3S".to_string(),
-                kind: DeviceKind::Mouse,
-                capabilities: Capabilities::presumed_from_kind(DeviceKind::Mouse),
-                model_info: Some(model.clone()),
-                codename: Some("MX Anywhere 3S".to_string()),
-            },
-        );
-        let (commands, _receiver) = tokio::sync::mpsc::unbounded_channel();
-        let state = AppState::with_runtime(config, &[], &AssetResolver::new(), commands);
-
-        assert_eq!(
-            state.asset_models(),
-            vec![(model, Some("MX Anywhere 3S".to_string()))]
-        );
-    }
-
-    #[test]
-    fn gui_state_saves_and_clears_supported_wheel_resolution() {
-        let mut config = Config::default();
-        assert!(set_scroll_resolution_if_supported(
-            &mut config,
-            "mouse",
-            true,
-            Some(ScrollResolution::Low),
-        ));
-        assert_eq!(
-            config.scroll_resolution("mouse"),
-            Some(ScrollResolution::Low)
-        );
-
-        assert!(set_scroll_resolution_if_supported(
-            &mut config,
-            "mouse",
-            true,
-            None,
-        ));
-        assert_eq!(config.scroll_resolution("mouse"), None);
-    }
-
-    #[test]
-    fn gui_state_ignores_unsupported_wheel_resolution() {
-        let mut config = Config::default();
-        assert!(!set_scroll_resolution_if_supported(
-            &mut config,
-            "mouse",
-            false,
-            Some(ScrollResolution::High),
-        ));
-        assert_eq!(config.scroll_resolution("mouse"), None);
-    }
-}
diff --git a/crates/openlogi-gui/src/state/agent.rs b/crates/openlogi-gui/src/state/agent.rs
new file mode 100644
index 0000000000000000000000000000000000000000..9972af433d73aa776da8f4daf442a930e8cc76f8
--- /dev/null
+++ b/crates/openlogi-gui/src/state/agent.rs
@@ -0,0 +1,67 @@
+//! Agent connection status and debug monitor state.
+
+use super::{AgentLink, AppState};
+
+impl AppState {
+    /// Append a batch of live-monitor events, capping the retained history so the
+    /// buffer can't grow without bound while the monitor is open.
+    #[cfg(all(target_os = "macos", debug_assertions))]
+    pub fn push_monitor_events(&mut self, events: Vec<openlogi_agent_core::ipc::MonitorEvent>) {
+        const MAX: usize = 200;
+        self.monitor_events.extend(events);
+        let overflow = self.monitor_events.len().saturating_sub(MAX);
+        self.monitor_events.drain(..overflow);
+    }
+    /// Recent live-monitor events, oldest first.
+    #[cfg(all(target_os = "macos", debug_assertions))]
+    #[must_use]
+    pub fn monitor_events(
+        &self,
+    ) -> &std::collections::VecDeque<openlogi_agent_core::ipc::MonitorEvent> {
+        &self.monitor_events
+    }
+    /// Replace the cached event-tap snapshot the Diagnostics page renders.
+    /// Refreshed on the live-monitor poll tick; see [`Self::event_taps`].
+    #[cfg(all(target_os = "macos", debug_assertions))]
+    pub fn set_event_taps(&mut self, taps: Vec<openlogi_hook::EventTapInfo>) {
+        self.event_taps = taps;
+    }
+    /// The cached event-tap snapshot for the Diagnostics page.
+    #[cfg(all(target_os = "macos", debug_assertions))]
+    #[must_use]
+    pub fn event_taps(&self) -> &[openlogi_hook::EventTapInfo] {
+        &self.event_taps
+    }
+    /// Ask the agent to fire the macOS Accessibility prompt. The agent owns the
+    /// CGEventTap, so the system dialog must name and authorize the *agent*
+    /// binary; prompting in the GUI process (as the pre-split build did) would
+    /// grant the wrong binary and the hook would never install.
+    pub fn request_accessibility_prompt(&self) {
+        self.send_ipc(crate::ipc_client::Command::RequestAccessibilityPrompt);
+    }
+    /// The agent connection state the render path branches on.
+    #[must_use]
+    pub fn agent_link(&self) -> &AgentLink {
+        &self.agent_link
+    }
+    /// The latest agent status snapshot — `None` while not connected (any
+    /// non-[`AgentLink::Ready`] state), which readers like the Settings
+    /// permission rows surface as "unknown", not "denied".
+    #[must_use]
+    pub fn agent_status(&self) -> Option<&openlogi_agent_core::ipc::AgentStatus> {
+        match &self.agent_link {
+            AgentLink::Ready(status) => Some(status),
+            _ => None,
+        }
+    }
+    /// Replace the link, reporting whether it actually changed — the steady
+    /// IPC poll mostly delivers identical snapshots, and the caller skips the
+    /// window refresh for those.
+    pub fn set_agent_link(&mut self, link: AgentLink) -> bool {
+        if self.agent_link == link {
+            return false;
+        }
+        self.agent_link = link;
+        true
+    }
+}
diff --git a/crates/openlogi-gui/src/state/bindings.rs b/crates/openlogi-gui/src/state/bindings.rs
new file mode 100644
index 0000000000000000000000000000000000000000..306ce136c0452605203bb3ca3e48bb5b972b5038
--- /dev/null
+++ b/crates/openlogi-gui/src/state/bindings.rs
@@ -0,0 +1,194 @@
+//! Mouse, gesture, and keyboard binding commits.
+
+use std::collections::BTreeMap;
+
+use openlogi_agent_core::bindings::{bindings_for, gesture_bindings_for};
+use openlogi_core::config::KeyTrigger;
+use tracing::debug;
+
+use crate::data::mouse_buttons::{Action, Binding, ButtonId, GestureDirection};
+use crate::mouse_model::thumbwheel::{ThumbwheelPair, ThumbwheelPreset};
+use crate::state::devices::DeviceRecord;
+
+use super::AppState;
+
+pub(super) fn apply_thumbwheel_pair(
+    button_bindings: &mut BTreeMap<ButtonId, Action>,
+    config: &mut openlogi_core::config::Config,
+    persistent_key: Option<&str>,
+    pair: ThumbwheelPair,
+) -> bool {
+    button_bindings.insert(ButtonId::ThumbwheelScrollDown, pair.backward.clone());
+    button_bindings.insert(ButtonId::ThumbwheelScrollUp, pair.forward.clone());
+
+    let Some(key) = persistent_key else {
+        return false;
+    };
+    config.set_binding(
+        key,
+        ButtonId::ThumbwheelScrollDown,
+        Binding::Single(pair.backward),
+    );
+    config.set_binding(
+        key,
+        ButtonId::ThumbwheelScrollUp,
+        Binding::Single(pair.forward),
+    );
+    true
+}
+
+impl AppState {
+    /// Update a single binding in memory, on disk, and in the shared hook
+    /// map for the currently selected device.
+    ///
+    /// Disk failures and poisoned hook locks are logged at `warn` instead
+    /// of bubbling up: the UI thread shouldn't crash because the user's
+    /// home volume is full or because the hook thread panicked.
+    pub fn commit_binding(&mut self, button: ButtonId, action: Action) {
+        self.button_bindings.insert(button, action.clone());
+
+        let Some(key) = self
+            .current_record()
+            .and_then(DeviceRecord::persistent_config_key)
+            .map(str::to_string)
+        else {
+            debug!(
+                ?button,
+                "no persistent device key — binding kept in memory only"
+            );
+            return;
+        };
+        self.config
+            .set_binding(&key, button, Binding::Single(action));
+        // The agent owns the hook; have it rebuild its live map from config.
+        self.persist_and_reload("binding");
+    }
+
+    /// Apply one paired thumb-wheel preset atomically. Both directional
+    /// bindings are updated before the single config persistence/reload.
+    pub fn commit_thumbwheel_preset(&mut self, preset: ThumbwheelPreset) {
+        let pair = preset.pair();
+        let key = self
+            .current_record()
+            .and_then(DeviceRecord::persistent_config_key)
+            .map(str::to_string);
+        if !apply_thumbwheel_pair(
+            &mut self.button_bindings,
+            &mut self.config,
+            key.as_deref(),
+            pair,
+        ) {
+            debug!("no persistent device key — thumb-wheel pair kept in memory only");
+            return;
+        }
+        self.persist_and_reload("thumb-wheel binding");
+    }
+    /// Records (or, with `action = None`, clears) the F-key `trigger` binding
+    /// in the global `[keyboard]` map. Mirrors [`Self::commit_binding`] minus
+    /// the device key — keyboard bindings are device-agnostic, so there's no
+    /// `current_record()` dependency. The agent's `rebuild()` republishes its
+    /// shared keyboard map on `reload_config`, so this lands live.
+    pub fn commit_keyboard_binding(&mut self, trigger: KeyTrigger, action: Option<Action>) {
+        match action {
+            Some(ref a) => {
+                self.keyboard_bindings.insert(trigger.clone(), a.clone());
+            }
+            None => {
+                self.keyboard_bindings.remove(&trigger);
+            }
+        }
+        self.config.set_keyboard_binding(trigger, action);
+        self.persist_and_reload("keyboard binding");
+    }
+    pub(crate) fn bindings_for_current(&self) -> BTreeMap<ButtonId, Action> {
+        bindings_for(
+            &self.config,
+            self.current_record()
+                .and_then(DeviceRecord::persistent_config_key),
+            self.current_app_bundle.as_deref(),
+        )
+    }
+    pub(crate) fn gesture_bindings_for_current(&self) -> BTreeMap<GestureDirection, Action> {
+        let Some(key) = self
+            .current_record()
+            .and_then(DeviceRecord::persistent_config_key)
+        else {
+            return BTreeMap::new();
+        };
+        match self.config.gesture_owner(key) {
+            // The HID++ gesture button seeds every direction from the defaults.
+            Some(ButtonId::GestureButton) => gesture_bindings_for(&self.config, Some(key)),
+            // A promoted OS-hook button is shown from its raw stored map (which
+            // `set_gesture_owner` seeds with full defaults), so the menu matches
+            // exactly what `oshook_gestures_for` dispatches — no seeding here.
+            Some(owner) => match self.config.bindings_for(key).get(&owner) {
+                Some(Binding::Gesture(map)) => map.clone(),
+                _ => BTreeMap::new(),
+            },
+            None => BTreeMap::new(),
+        }
+    }
+    /// The current device's gesture button — the [`Binding::Gesture`] owner — or
+    /// `None` when no button is in gesture mode. Drives which button's card opens
+    /// the gesture menu rather than the single-action picker.
+    #[must_use]
+    pub fn current_gesture_owner(&self) -> Option<ButtonId> {
+        let key = self.current_record()?.persistent_config_key()?;
+        self.config.gesture_owner(key)
+    }
+    /// Make `button` the current device's gesture button (or clear it with
+    /// `None`), enforcing the one-gesture-button-per-device lock. Persists, tells
+    /// the agent to rebuild, and refreshes the projected maps the UI reads.
+    pub fn commit_gesture_owner(&mut self, button: Option<ButtonId>) {
+        let Some(key) = self
+            .current_record()
+            .and_then(DeviceRecord::persistent_config_key)
+            .map(str::to_string)
+        else {
+            return;
+        };
+        match button {
+            Some(b) => {
+                self.config.set_gesture_owner(&key, b);
+            }
+            None => {
+                self.config.disable_gestures(&key);
+            }
+        }
+        // The owner change shuffles bindings between the single + gesture maps.
+        self.button_bindings = self.bindings_for_current();
+        self.gesture_bindings = self.gesture_bindings_for_current();
+        self.persist_and_reload("gesture-button change");
+    }
+    /// Update a single gesture-button sub-binding in memory, on disk, and in the
+    /// shared gesture map the watcher thread reads.
+    pub fn commit_gesture_binding(&mut self, direction: GestureDirection, action: Action) {
+        let Some(key) = self
+            .current_record()
+            .and_then(DeviceRecord::persistent_config_key)
+            .map(str::to_string)
+        else {
+            debug!(
+                ?direction,
+                "no persistent device key — gesture binding edit ignored"
+            );
+            return;
+        };
+        // Edit whichever button owns gestures — not always the HID++ gesture button. When
+        // gestures are off, a stray edit must NOT silently re-enable them on the
+        // default owner (the gesture editor shouldn't be reachable in that state):
+        // no-op instead.
+        let Some(owner) = self.config.gesture_owner(&key) else {
+            debug!(
+                ?direction,
+                "gestures are off — ignoring gesture binding edit"
+            );
+            return;
+        };
+        self.gesture_bindings.insert(direction, action.clone());
+        self.config
+            .set_gesture_direction(&key, owner, direction, action);
+        // The agent owns the gesture watcher; have it rebuild from config.
+        self.persist_and_reload("gesture binding");
+    }
+}
diff --git a/crates/openlogi-gui/src/state/camera.rs b/crates/openlogi-gui/src/state/camera.rs
new file mode 100644
index 0000000000000000000000000000000000000000..3923abe54a03b9ffc93939fbd7015c13e9d4362a
--- /dev/null
+++ b/crates/openlogi-gui/src/state/camera.rs
@@ -0,0 +1,137 @@
+//! Webcam control state and camera profiles.
+
+use tracing::warn;
+
+use openlogi_camera::CameraControl;
+
+use super::AppState;
+
+impl AppState {
+    /// Whether any connected device is a webcam. Gates the camera-permission UI
+    /// so it only appears when there is actually a camera to grant access to.
+    /// Only the platforms that register the permission page (macOS/Linux) call
+    /// this; Windows has no such page, so the method is scoped to match.
+    #[cfg(any(target_os = "macos", target_os = "linux"))]
+    #[must_use]
+    pub fn has_camera(&self) -> bool {
+        self.device_list
+            .iter()
+            .any(|r| matches!(r.kind, openlogi_core::device::DeviceKind::Camera))
+    }
+    /// The saved value of a UVC control for `config_key`, if any.
+    #[must_use]
+    pub fn camera_control(&self, config_key: &str, control: CameraControl) -> Option<i32> {
+        self.config
+            .camera_controls(config_key)?
+            .0
+            .get(control.name())
+            .copied()
+    }
+    /// The saved state of a camera auto toggle for `config_key`, if any.
+    #[must_use]
+    pub fn camera_auto(
+        &self,
+        config_key: &str,
+        toggle: openlogi_camera::AutoToggle,
+    ) -> Option<bool> {
+        self.config
+            .camera_controls(config_key)?
+            .0
+            .get(toggle.name())
+            .map(|v| *v != 0)
+    }
+    /// Persist a UVC control for `config_key`. No agent IPC — webcams are
+    /// driven straight from the GUI over USB, so the agent never sees this.
+    pub fn commit_camera_control(&mut self, config_key: &str, control: CameraControl, value: i32) {
+        self.commit_camera_entry(config_key, control.name(), value);
+    }
+    /// Persist a camera auto toggle for `config_key` (stored as 0/1).
+    pub fn commit_camera_auto(
+        &mut self,
+        config_key: &str,
+        toggle: openlogi_camera::AutoToggle,
+        on: bool,
+    ) {
+        self.commit_camera_entry(config_key, toggle.name(), i32::from(on));
+    }
+    fn commit_camera_entry(&mut self, config_key: &str, name: &str, value: i32) {
+        let mut controls = self.config.camera_controls(config_key).unwrap_or_default();
+        controls.0.insert(name.to_string(), value);
+        self.config.set_camera_controls(config_key, controls);
+        if let Err(e) = self.config.save_atomic() {
+            warn!(error = %e, "could not persist camera controls");
+        }
+    }
+    /// Lift settings from the legacy port-bound `camera-<unique_id>` key onto
+    /// the stable serial/model key when the latter has none. Inventory identity
+    /// for cameras is separate ([`DeviceRecord::inventory_key`]); settings never
+    /// use capture-id suffixes, so two serial-less same-model units honestly
+    /// share one settings bag rather than risk cross-assigning on port moves.
+    pub fn migrate_legacy_camera_key(&mut self, config_key: &str, capture_id: &str) {
+        if self.camera_key_has_settings(config_key) {
+            return;
+        }
+        let port_key = format!("camera-{capture_id}");
+        if port_key == config_key || !self.camera_key_has_settings(&port_key) {
+            return;
+        }
+        if let Some(controls) = self.config.camera_controls(&port_key) {
+            self.config.set_camera_controls(config_key, controls);
+        }
+        for (name, snap) in self.config.camera_profiles(&port_key) {
+            self.config.save_camera_profile(config_key, &name, snap);
+        }
+        if let Some(active) = self.config.camera_active_profile(&port_key) {
+            self.config
+                .set_camera_active_profile(config_key, Some(active));
+        }
+        self.config.devices.remove(&port_key);
+        if let Err(e) = self.config.save_atomic() {
+            warn!(error = %e, "could not persist camera key migration");
+        }
+    }
+    fn camera_key_has_settings(&self, key: &str) -> bool {
+        self.config.camera_controls(key).is_some()
+            || !self.config.camera_profiles(key).is_empty()
+            || self.config.camera_active_profile(key).is_some()
+    }
+    /// User-saved camera profiles for `config_key` (name → snapshot).
+    #[must_use]
+    pub fn camera_profiles(
+        &self,
+        config_key: &str,
+    ) -> std::collections::BTreeMap<String, openlogi_core::config::CameraControls> {
+        self.config.camera_profiles(config_key)
+    }
+    /// Save a custom camera profile and persist it.
+    pub fn save_camera_profile(
+        &mut self,
+        config_key: &str,
+        name: &str,
+        snap: openlogi_core::config::CameraControls,
+    ) {
+        self.config.save_camera_profile(config_key, name, snap);
+        if let Err(e) = self.config.save_atomic() {
+            warn!(error = %e, "could not persist camera profile");
+        }
+    }
+    /// Delete a custom camera profile and persist the removal.
+    pub fn delete_camera_profile(&mut self, config_key: &str, name: &str) {
+        self.config.delete_camera_profile(config_key, name);
+        if let Err(e) = self.config.save_atomic() {
+            warn!(error = %e, "could not persist camera profile removal");
+        }
+    }
+    /// The camera profile last applied for `config_key`, if any.
+    #[must_use]
+    pub fn camera_active_profile(&self, config_key: &str) -> Option<String> {
+        self.config.camera_active_profile(config_key)
+    }
+    /// Record (and persist) which camera profile `config_key` last applied.
+    pub fn set_camera_active_profile(&mut self, config_key: &str, name: Option<String>) {
+        self.config.set_camera_active_profile(config_key, name);
+        if let Err(e) = self.config.save_atomic() {
+            warn!(error = %e, "could not persist camera profile selection");
+        }
+    }
+}
diff --git a/crates/openlogi-gui/src/state/devices.rs b/crates/openlogi-gui/src/state/devices.rs
index 9fd5db390feff22b0ea2227bd4b39cf82cd2ab92..6903b840fe698989b021f65aee1f64a7e4427296 100644
--- a/crates/openlogi-gui/src/state/devices.rs
+++ b/crates/openlogi-gui/src/state/devices.rs
@@ -3,9 +3,11 @@
 use std::collections::HashSet;
 
 use openlogi_agent_core::device_order::{DeviceStableId, PhysicalDeviceKey};
+use openlogi_camera::Camera;
 use openlogi_core::config::{Config, DeviceIdentity};
 use openlogi_core::device::{
     BatteryInfo, Capabilities, DeviceInventory, DeviceKind, DeviceModelInfo, DeviceTransports,
+    LightCapabilities, StandaloneDevice,
 };
 use openlogi_hid::DeviceRoute;
 use tracing::debug;
@@ -38,7 +40,15 @@ pub struct DeviceRecord {
     pub codename: Option<String>,
     pub serial_number: Option<String>,
     pub unit_id: [u8; 4],
+    /// Standalone driver family, if this is a non-HID++ record.
+    pub driver_id: Option<String>,
+    /// Model-level asset registry identity for standalone devices.
+    pub registry_model_id: Option<String>,
     pub route: Option<DeviceRoute>,
+    /// OS capture id for cameras (AVFoundation uniqueID / DirectShow path).
+    /// Distinct from [`Self::config_key`], which prefers the port-stable USB
+    /// serial. `None` for HID++ devices (those open via [`Self::route`]).
+    pub capture_id: Option<String>,
     pub kind: DeviceKind,
     /// Configuration capabilities from the device's HID++ feature table.
     /// Continuity across sleep lives in the hid layer: its probe cache keeps
@@ -46,6 +56,8 @@ pub struct DeviceRecord {
     /// this is `None` only for a device never probed since the agent started —
     /// and the UI then falls back to [`Capabilities::presumed_from_kind`].
     pub capabilities: Option<Capabilities>,
+    /// Capabilities for standalone non-HID++ controls such as Litra lights.
+    pub light_capabilities: Option<LightCapabilities>,
     pub slot: u8,
     pub online: bool,
     pub battery: Option<BatteryInfo>,
@@ -62,6 +74,20 @@ impl DeviceRecord {
     pub(super) fn is_persistent(&self) -> bool {
         self.persistent
     }
+
+    /// Key used to reconcile this record across inventory snapshots.
+    ///
+    /// HID++ devices use [`Self::config_key`]. Cameras may share a model-scoped
+    /// config key (two serial-less units of the same model), so they reconcile
+    /// on the OS capture id instead — settings still persist under `config_key`.
+    pub(super) fn inventory_key(&self) -> String {
+        if self.kind == DeviceKind::Camera
+            && let Some(id) = self.capture_id.as_deref().filter(|s| !s.is_empty())
+        {
+            return format!("cam-live:{id}");
+        }
+        self.config_key.clone()
+    }
 }
 
 /// Build the carousel's device list as the **union** of the live inventory and
@@ -80,8 +106,10 @@ impl DeviceRecord {
 /// (#271/#280/#387).
 pub(super) fn build_device_list(
     inventories: &[DeviceInventory],
+    standalone: &[StandaloneDevice],
     cache: &AssetResolver,
     config: &Config,
+    cameras: &[Camera],
 ) -> Vec<DeviceRecord> {
     let mut list = Vec::new();
     for inv in inventories {
@@ -136,15 +164,20 @@ pub(super) fn build_device_list(
                 codename,
                 serial_number,
                 unit_id,
+                driver_id: None,
+                registry_model_id: None,
                 route,
+                capture_id: None,
                 kind,
                 capabilities: paired.capabilities,
+                light_capabilities: None,
                 slot: paired.slot,
                 online: paired.online,
                 battery: paired.battery.clone(),
             });
         }
     }
+    append_standalone(&mut list, standalone, cache);
     #[cfg(debug_assertions)]
     if std::env::var_os("OPENLOGI_DEMO_KEYBOARD").is_some() {
         list.push(demo_keyboard());
@@ -160,10 +193,130 @@ pub(super) fn build_device_list(
         cache,
         &present_receivers,
     );
+    // Cameras are UVC, not HID++, so they come from a parallel discovery path
+    // (AVFoundation on macOS) rather than the receiver inventory. The caller
+    // enumerates them off the UI thread — discovery is too slow for the render
+    // path — so this assembly stays pure; the merge in
+    // `super::AppState::refresh_inventories` reconciles them by config_key.
+    for camera in cameras {
+        list.push(camera_record(camera, cache));
+    }
     sort_device_list(&mut list);
     list
 }
 
+/// A [`DeviceRecord`] for a Logitech UVC webcam.
+///
+/// [`Camera::config_key`] prefers the USB serial so saved controls survive a
+/// port change; [`DeviceRecord::capture_id`] keeps the OS open id the preview
+/// and UVC layer need. `route: None` / `capabilities: None` keep it out of
+/// every HID++ path — its only detail surface is the live preview tab.
+///
+/// The asset registry keys cameras by their 4-hex USB product id (e.g. the
+/// StreamCam's `0893`), so a webcam's product render resolves through the same
+/// [`AssetResolver`] as HID++ devices once we synthesize a minimal
+/// [`DeviceModelInfo`] from the USB pid.
+fn camera_record(camera: &Camera, cache: &AssetResolver) -> DeviceRecord {
+    let config_key = camera.config_key();
+    let model_info = camera_model_info(camera);
+    let asset = cache.resolve(&model_info, Some(&camera.name));
+    DeviceRecord {
+        model_key: format!("{:04x}", camera.product_id),
+        config_key,
+        persistent: true,
+        display_name: camera.name.clone(),
+        asset,
+        model_info: None,
+        codename: None,
+        serial_number: camera.serial_number.clone(),
+        unit_id: [0; 4],
+        driver_id: None,
+        registry_model_id: None,
+        route: None,
+        capture_id: Some(camera.unique_id.clone()),
+        kind: DeviceKind::Camera,
+        capabilities: None,
+        light_capabilities: None,
+        slot: 0,
+        online: true,
+        battery: None,
+    }
+}
+
+/// A minimal [`DeviceModelInfo`] standing in for a UVC camera, carrying just the
+/// USB product id in `model_ids[0]` so [`AssetResolver::resolve`] can match the
+/// registry's camera depots (which key on the 4-hex pid).
+pub(crate) fn camera_model_info(camera: &Camera) -> DeviceModelInfo {
+    DeviceModelInfo {
+        entity_count: 0,
+        serial_number: None,
+        unit_id: [0; 4],
+        transports: DeviceTransports::default(),
+        model_ids: [camera.product_id, 0, 0],
+        extended_model_id: 0,
+    }
+}
+
+fn append_standalone(
+    list: &mut Vec<DeviceRecord>,
+    devices: &[StandaloneDevice],
+    cache: &AssetResolver,
+) {
+    for device in devices {
+        let route = Some(DeviceRoute::RawHid {
+            vendor_id: device.address.vendor_id,
+            product_id: device.address.product_id,
+            usage_page: device.address.usage_page,
+            usage_id: device.address.usage_id,
+            identity: device.address.identity.clone(),
+        });
+        let stable_id = DeviceStableId::from_parts(
+            route.as_ref(),
+            openlogi_hid::DIRECT_DEVICE_INDEX,
+            device.serial_number.as_deref(),
+            device.unit_id,
+        );
+        let (config_key, persistent) = stable_id.physical_key().map_or_else(
+            || (stable_id.runtime_key(), false),
+            |key| (key.into_string(), true),
+        );
+        let asset = device
+            .registry_model_id
+            .as_deref()
+            .and_then(|model_id| cache.resolve_registry_model(model_id));
+        let display_name = asset
+            .as_ref()
+            .filter(|asset| !asset.display_name.trim().is_empty())
+            .map_or_else(
+                || device.display_name.clone(),
+                |asset| asset.display_name.clone(),
+            );
+        list.push(DeviceRecord {
+            config_key,
+            persistent,
+            // The registry id is presentation metadata, not a replacement for
+            // the raw-device model identity used before registry integration.
+            model_key: format!("raw:{:04x}", device.address.product_id),
+            display_name,
+            asset,
+            model_info: None,
+            codename: None,
+            serial_number: device.serial_number.clone(),
+            unit_id: device.unit_id,
+            driver_id: Some(device.driver_id.clone()),
+            registry_model_id: device.registry_model_id.clone(),
+            route,
+            capture_id: None,
+            kind: device.kind,
+            capabilities: device.capabilities,
+            light_capabilities: device.light_capabilities,
+            slot: openlogi_hid::DIRECT_DEVICE_INDEX,
+            online: device.online,
+            battery: None,
+        });
+    }
+}
+
 /// Append an offline placeholder for every known device not already present in
 /// `list`, skipping unreachable devices and invalid transient identities.
 ///
@@ -271,25 +424,44 @@ fn offline_record(
         .model_info
         .clone()
         .or_else(|| model_info_from_legacy_model_key(config_key));
-    let asset = model_info
-        .as_ref()
-        .and_then(|model| cache.resolve(model, identity.codename.as_deref()));
+    let asset = identity
+        .registry_model_id
+        .as_deref()
+        .and_then(|model_id| cache.resolve_registry_model(model_id))
+        .or_else(|| {
+            model_info
+                .as_ref()
+                .and_then(|model| cache.resolve(model, identity.codename.as_deref()))
+        });
+    // Keep offline standalone records keyed exactly as before. The registry id
+    // only selects artwork and must not alter configuration or deduplication.
     let model_key = model_info
         .as_ref()
         .map_or_else(|| config_key.to_string(), DeviceModelInfo::config_key);
+    let display_name = asset
+        .as_ref()
+        .filter(|asset| !asset.display_name.trim().is_empty())
+        .map_or_else(
+            || identity.display_name.clone(),
+            |asset| asset.display_name.clone(),
+        );
     DeviceRecord {
         config_key: config_key.to_string(),
         persistent: true,
         model_key,
-        display_name: identity.display_name.clone(),
+        display_name,
         asset,
         model_info,
         codename: identity.codename.clone(),
         serial_number: None,
         unit_id: [0; 4],
+        driver_id: identity.driver_id.clone(),
+        registry_model_id: identity.registry_model_id.clone(),
         route: None,
+        capture_id: None,
         kind: identity.kind,
         capabilities: Some(identity.capabilities),
+        light_capabilities: identity.light_capabilities,
         slot: 0,
         online: false,
         battery: None,
@@ -333,15 +505,21 @@ pub(super) fn adopt_transient_record(known: &DeviceRecord, live: DeviceRecord) -
         asset: known.asset.clone().or(live.asset),
         model_info: known.model_info.clone().or(live.model_info),
         codename: known.codename.clone().or(live.codename),
-        serial_number: known.serial_number.clone(),
+        serial_number: known.serial_number.clone().or(live.serial_number),
         unit_id: known.unit_id,
+        driver_id: live.driver_id.or_else(|| known.driver_id.clone()),
+        registry_model_id: live
+            .registry_model_id
+            .or_else(|| known.registry_model_id.clone()),
         route: live.route,
+        capture_id: live.capture_id.or(known.capture_id.clone()),
         kind: if known.kind == DeviceKind::Unknown {
             live.kind
         } else {
             known.kind
         },
         capabilities: live.capabilities.or(known.capabilities),
+        light_capabilities: live.light_capabilities.or(known.light_capabilities),
         slot: live.slot,
         online: live.online,
         battery: live.battery.or_else(|| known.battery.clone()),
@@ -386,12 +564,16 @@ fn demo_keyboard() -> DeviceRecord {
         codename: None,
         serial_number: None,
         unit_id: [0; 4],
+        driver_id: None,
+        registry_model_id: None,
         route: None,
+        capture_id: None,
         kind: DeviceKind::Keyboard,
         capabilities: Some(Capabilities {
             lighting: true,
             ..Capabilities::default()
         }),
+        light_capabilities: None,
         slot: 0,
         online: true,
         battery: None,
@@ -469,16 +651,18 @@ fn prettify_codename(raw: &str) -> String {
 #[cfg(test)]
 mod tests {
     use openlogi_core::config::Config;
-    use openlogi_core::device::{DeviceInventory, PairedDevice, ReceiverInfo};
+    use openlogi_core::device::{
+        DeviceInventory, PairedDevice, RawDeviceAddress, ReceiverInfo, StandaloneDevice,
+    };
 
     use crate::asset::AssetResolver;
 
     use std::collections::HashSet;
 
     use super::{
-        Capabilities, DeviceIdentity, DeviceKind, DeviceModelInfo, DeviceRecord, DeviceTransports,
-        append_offline_known, build_device_list, direct_key_prefix, effective_kind, offline_record,
-        pick_initial_device,
+        Camera, Capabilities, DeviceIdentity, DeviceKind, DeviceModelInfo, DeviceRecord,
+        DeviceTransports, append_offline_known, build_device_list, direct_key_prefix,
+        effective_kind, offline_record, pick_initial_device,
     };
 
     fn paired_device_no_model_info(slot: u8, wpid: Option<u16>) -> PairedDevice {
@@ -538,9 +722,13 @@ mod tests {
             codename: None,
             serial_number: None,
             unit_id: [1; 4],
+            driver_id: None,
+            registry_model_id: None,
             route: None,
+            capture_id: None,
             kind: DeviceKind::Mouse,
             capabilities: Some(Capabilities::presumed_from_kind(DeviceKind::Mouse)),
+            light_capabilities: None,
             slot: 1,
             online: true,
             battery: None,
@@ -559,16 +747,56 @@ mod tests {
                 hires_wheel: false,
                 thumbwheel: false,
             },
+            light_capabilities: None,
             model_info: None,
             codename: None,
+            driver_id: None,
+            registry_model_id: None,
         }
     }
 
+    #[test]
+    fn standalone_registry_identity_is_preserved_without_hidpp_model_info() {
+        let device = StandaloneDevice {
+            address: RawDeviceAddress {
+                vendor_id: 0x046d,
+                product_id: 0xc901,
+                usage_page: 0xff43,
+                usage_id: 0x0202,
+                identity: "serial:beam-1".into(),
+            },
+            display_name: "Future Litra model".into(),
+            manufacturer: Some("Logi".into()),
+            serial_number: Some("beam-1".into()),
+            unit_id: [0; 4],
+            kind: DeviceKind::Light,
+            online: true,
+            capabilities: None,
+            light_capabilities: None,
+            driver_id: "litra".into(),
+            registry_model_id: Some("8c901".into()),
+        };
+        let list = build_device_list(
+            &[],
+            std::slice::from_ref(&device),
+            &AssetResolver::new(),
+            &Config::default(),
+            &[],
+        );
+
+        assert_eq!(list.len(), 1);
+        assert_eq!(list[0].driver_id.as_deref(), Some("litra"));
+        assert_eq!(list[0].registry_model_id.as_deref(), Some("8c901"));
+        assert_eq!(list[0].model_key, "raw:c901");
+        assert_eq!(list[0].config_key, "raw:046d:c901:ff43:0202:serial:beam-1");
+        assert!(list[0].asset.is_none());
+    }
+
     #[test]
     fn no_model_info_uses_receiver_slot_as_config_key() {
         let inv = inventory_with(vec![paired_device_no_model_info(1, Some(0x4076))]);
         let cache = AssetResolver::new();
-        let list = build_device_list(&[inv], &cache, &Config::default());
+        let list = build_device_list(&[inv], &[], &cache, &Config::default(), &[]);
         assert_eq!(list.len(), 1);
         assert_eq!(list[0].config_key, "receiver:da2699e1:slot:1");
         assert_eq!(list[0].model_key, "wpid4076");
@@ -580,7 +808,7 @@ mod tests {
     fn no_model_info_falls_back_to_slot_when_no_wpid() {
         let inv = inventory_with(vec![paired_device_no_model_info(3, None)]);
         let cache = AssetResolver::new();
-        let list = build_device_list(&[inv], &cache, &Config::default());
+        let list = build_device_list(&[inv], &[], &cache, &Config::default(), &[]);
         assert_eq!(list.len(), 1);
         assert_eq!(list[0].config_key, "receiver:da2699e1:slot:3");
         assert_eq!(list[0].model_key, "slot3");
@@ -590,7 +818,7 @@ mod tests {
     fn no_model_info_display_name_falls_back_to_slot() {
         let inv = inventory_with(vec![paired_device_no_model_info(2, Some(0x4051))]);
         let cache = AssetResolver::new();
-        let list = build_device_list(&[inv], &cache, &Config::default());
+        let list = build_device_list(&[inv], &[], &cache, &Config::default(), &[]);
         assert_eq!(list[0].display_name, "Slot 2");
     }
 
@@ -609,6 +837,36 @@ mod tests {
         assert_eq!(rec.capabilities, Some(id.capabilities));
     }
 
+    #[test]
+    fn offline_standalone_record_keeps_registry_and_physical_keys() {
+        let id = DeviceIdentity {
+            display_name: "Litra Glow".into(),
+            kind: DeviceKind::Light,
+            capabilities: Capabilities::default(),
+            light_capabilities: None,
+            model_info: None,
+            codename: None,
+            driver_id: Some("litra".into()),
+            registry_model_id: Some("8c900".into()),
+        };
+        let record = offline_record(
+            "raw:046d:c900:ff43:0202:serial:known-light",
+            &id,
+            &AssetResolver::new(),
+        );
+
+        assert_eq!(record.registry_model_id.as_deref(), Some("8c900"));
+        assert_eq!(
+            record.model_key,
+            "raw:046d:c900:ff43:0202:serial:known-light"
+        );
+        assert_eq!(
+            record.config_key,
+            "raw:046d:c900:ff43:0202:serial:known-light"
+        );
+        assert!(record.model_info.is_none());
+    }
+
     #[test]
     fn known_devices_are_appended_only_when_absent_from_live() {
         // "A" is live; "B" is known-but-asleep. The union keeps the live "A"
@@ -652,8 +910,10 @@ mod tests {
         let cache = AssetResolver::new();
         let list = build_device_list(
             &[direct_inventory(model_info(2, 0xb034))],
+            &[],
             &cache,
             &Config::default(),
+            &[],
         );
 
         assert_eq!(list.len(), 1);
@@ -818,4 +1078,99 @@ mod tests {
             DeviceKind::Mouse
         );
     }
+
+    #[test]
+    fn webcams_are_appended_as_camera_records() {
+        // A discovered UVC webcam joins the list as a routeless Camera record.
+        // With a USB serial the config key is port-stable; capture_id keeps the
+        // OS open id the preview needs.
+        let camera = Camera {
+            name: "Logitech StreamCam".to_string(),
+            unique_id: "0x1123000046d0893".to_string(),
+            serial_number: Some("ABC123".to_string()),
+            vendor_id: 0x046d,
+            product_id: 0x0893,
+            max_resolution: Some((1920, 1080)),
+            max_fps: Some(60),
+        };
+        let cache = AssetResolver::new();
+        let list = build_device_list(&[], &[], &cache, &Config::default(), &[camera]);
+
+        assert_eq!(list.len(), 1);
+        assert_eq!(list[0].kind, DeviceKind::Camera);
+        assert_eq!(list[0].config_key, "camera:046d:0893:serial:abc123");
+        assert_eq!(list[0].capture_id.as_deref(), Some("0x1123000046d0893"));
+        assert_eq!(list[0].serial_number.as_deref(), Some("ABC123"));
+        assert_eq!(list[0].display_name, "Logitech StreamCam");
+        assert!(list[0].route.is_none());
+        assert!(list[0].capabilities.is_none());
+        assert!(list[0].online);
+    }
+
+    #[test]
+    fn webcam_without_serial_uses_model_scoped_key() {
+        let camera = Camera {
+            name: "Logitech C920".to_string(),
+            unique_id: "0x14110000046d082d".to_string(),
+            serial_number: None,
+            vendor_id: 0x046d,
+            product_id: 0x082d,
+            max_resolution: None,
+            max_fps: None,
+        };
+        let cache = AssetResolver::new();
+        let list = build_device_list(&[], &[], &cache, &Config::default(), &[camera]);
+        // Port-stable even without a serial: settings follow the model, not the
+        // OS capture id (which embeds the USB location on macOS/Windows).
+        assert_eq!(list[0].config_key, "camera:046d:082d");
+        assert_eq!(list[0].capture_id.as_deref(), Some("0x14110000046d082d"));
+    }
+
+    #[test]
+    fn webcam_config_key_survives_a_usb_port_change() {
+        let port_a = Camera {
+            name: "Logitech StreamCam".to_string(),
+            unique_id: "0x1123000046d0893".to_string(),
+            serial_number: Some("SN42".to_string()),
+            vendor_id: 0x046d,
+            product_id: 0x0893,
+            max_resolution: None,
+            max_fps: None,
+        };
+        let port_b = Camera {
+            unique_id: "0x14110000046d0893".to_string(),
+            ..port_a.clone()
+        };
+        let cache = AssetResolver::new();
+        let a = build_device_list(&[], &[], &cache, &Config::default(), &[port_a]);
+        let b = build_device_list(&[], &[], &cache, &Config::default(), &[port_b]);
+        assert_eq!(a[0].config_key, b[0].config_key);
+        assert_ne!(a[0].capture_id, b[0].capture_id);
+    }
+
+    #[test]
+    fn two_serial_less_same_model_cameras_stay_distinct() {
+        // Settings share the model key (no USB serial to go on); inventory
+        // identity uses capture_id so both still appear in the list.
+        let a = Camera {
+            name: "Logitech StreamCam".to_string(),
+            unique_id: "0x1123000046d0893".to_string(),
+            serial_number: None,
+            vendor_id: 0x046d,
+            product_id: 0x0893,
+            max_resolution: None,
+            max_fps: None,
+        };
+        let b = Camera {
+            unique_id: "0x14110000046d0893".to_string(),
+            ..a.clone()
+        };
+        let cache = AssetResolver::new();
+        let list = build_device_list(&[], &[], &cache, &Config::default(), &[a, b]);
+        assert_eq!(list.len(), 2);
+        assert_eq!(list[0].config_key, list[1].config_key);
+        assert_eq!(list[0].config_key, "camera:046d:0893");
+        assert_ne!(list[0].inventory_key(), list[1].inventory_key());
+        assert_ne!(list[0].capture_id, list[1].capture_id);
+    }
 }
diff --git a/crates/openlogi-gui/src/state/dpi.rs b/crates/openlogi-gui/src/state/dpi.rs
new file mode 100644
index 0000000000000000000000000000000000000000..390bba287427883c1deb0e8935466c2980a5ef23
--- /dev/null
+++ b/crates/openlogi-gui/src/state/dpi.rs
@@ -0,0 +1,174 @@
+//! DPI load state, presets, and live writes.
+
+use openlogi_hid::{DeviceRoute, DpiCapabilities, DpiInfo, WriteError};
+use tracing::debug;
+
+use crate::state::devices::DeviceRecord;
+
+use super::load::DpiStatus;
+use super::{AppState, DEFAULT_DPI};
+
+impl AppState {
+    /// The cached DPI-discovery status for `key`, for the diagnostics report.
+    #[must_use]
+    pub fn dpi_status_for(&self, key: &str) -> Option<DpiStatus> {
+        self.dpi_data.get(key).cloned()
+    }
+    /// Replace the DPI preset list for the currently selected device. The
+    /// new list is persisted to `config.toml` and pushed into the shared
+    /// hook map so the next `CycleDpiPresets` press sees it. The cycle
+    /// `index` is reset to 0 — the user just rebuilt the list, the old
+    /// index is meaningless.
+    ///
+    /// No-op when no device is selected (binding panel won't expose the
+    /// editor in that state).
+    pub fn commit_dpi_presets(&mut self, presets: Vec<u32>) {
+        let Some(key) = self
+            .current_record()
+            .and_then(DeviceRecord::persistent_config_key)
+            .map(str::to_string)
+        else {
+            debug!("no persistent device key — DPI presets kept in memory only");
+            return;
+        };
+        self.config.set_dpi_presets(&key, presets);
+        self.persist_and_reload("DPI presets");
+    }
+    /// Read the DPI preset list for the active device, or an empty `Vec`
+    /// when no device is selected. UI helper.
+    #[must_use]
+    pub fn dpi_presets(&self) -> Vec<u32> {
+        self.current_record()
+            .and_then(DeviceRecord::persistent_config_key)
+            .map(|key| self.config.dpi_presets(key))
+            .unwrap_or_default()
+    }
+    /// DPI capability status for the active device.
+    #[must_use]
+    pub fn current_dpi_status(&self) -> DpiStatus {
+        self.current_record().map_or(DpiStatus::Unknown, |record| {
+            self.dpi_data.status(&record.config_key)
+        })
+    }
+    /// Whether the active device still needs a DPI read (no status recorded —
+    /// i.e. `Unknown`). Cheaper than `current_dpi_status() == Unknown`: it
+    /// avoids cloning the `DpiInfo`, which matters on the per-frame render path.
+    #[must_use]
+    pub fn current_dpi_unqueried(&self) -> bool {
+        self.current_record()
+            .is_some_and(|record| self.dpi_data.unqueried(&record.config_key))
+    }
+    /// The active device's known DPI, falling back to [`DEFAULT_DPI`] until its
+    /// capability read completes. Used to seed `self.dpi` on a device switch.
+    #[must_use]
+    pub(crate) fn dpi_for_current(&self) -> u32 {
+        self.current_record()
+            .and_then(|record| self.dpi_data.get(&record.config_key))
+            .and_then(|status| match status {
+                DpiStatus::Ready(info) => Some(u32::from(info.current)),
+                _ => None,
+            })
+            .unwrap_or(DEFAULT_DPI)
+    }
+    /// Mark DPI capability discovery as in flight for `key`.
+    pub fn mark_dpi_loading(&mut self, key: &str) {
+        self.dpi_data.mark_loading(key);
+    }
+    /// Reset a stuck `Loading` for `key` back to `Unknown`. Called when the
+    /// discovery worker vanished without delivering a result (e.g. it panicked),
+    /// so the device isn't wedged on "Reading…" with no path to retry.
+    pub fn clear_dpi_loading(&mut self, key: &str) {
+        self.dpi_data.clear_loading(key);
+    }
+    /// Drop the active device's recorded DPI status so the next render
+    /// re-runs discovery. Backs the "click to retry" affordance on a
+    /// [`DpiStatus::Failed`] device, which is the only recovery path when the
+    /// carousel has a single device (re-selecting it is a no-op).
+    pub fn retry_active_dpi(&mut self) {
+        if let Some(key) = self.current_record().map(|r| r.config_key.clone()) {
+            self.dpi_data.retry(&key);
+        }
+    }
+    /// Store a DPI capability discovery result if it still matches the known
+    /// device route. This guards against async reads completing after the
+    /// carousel or inventory changed.
+    pub fn store_dpi_info(
+        &mut self,
+        key: String,
+        route: &DeviceRoute,
+        result: Result<DpiInfo, WriteError>,
+    ) {
+        let is_active = self.current_record().map(|r| r.config_key.as_str()) == Some(key.as_str());
+        let matches_route = self
+            .device_list
+            .iter()
+            .any(|record| record.config_key == key && record.route.as_ref() == Some(route));
+        let still_present = self
+            .device_list
+            .iter()
+            .any(|record| record.config_key == key);
+        // Only the active device owns the shared `self.dpi`; a result landing for
+        // a background device after a carousel switch must not clobber the
+        // visible value.
+        if let Some(info) = self.dpi_data.store(
+            key,
+            result,
+            dpi_error_is_permanent,
+            matches_route,
+            still_present,
+            "DPI",
+        ) && is_active
+        {
+            self.dpi = u32::from(info.current);
+        }
+    }
+    /// DPI capabilities for the active device, if discovery succeeded.
+    #[must_use]
+    pub fn active_dpi_capabilities(&self) -> Option<&DpiCapabilities> {
+        self.current_record()
+            .and_then(|record| self.dpi_data.get(&record.config_key))
+            .and_then(|status| match status {
+                DpiStatus::Ready(info) => Some(&info.capabilities),
+                DpiStatus::Unknown
+                | DpiStatus::Loading
+                | DpiStatus::Failed(_)
+                | DpiStatus::Unsupported(_) => None,
+            })
+    }
+    /// Snap `dpi` to the active device's supported list when known.
+    #[must_use]
+    pub fn normalize_active_dpi(&self, dpi: u32) -> u32 {
+        self.active_dpi_capabilities()
+            .map_or(dpi, |caps| caps.snap(dpi))
+    }
+    /// Apply `dpi` to the active device (best-effort, via the agent) and
+    /// persist it per device — the sensor value lives in device RAM and resets
+    /// on a power cycle (#189), so the agent re-applies it on reconnect.
+    /// Updates the displayed value even with no device selected.
+    pub fn commit_dpi(&mut self, dpi: u32) {
+        self.dpi = dpi;
+        let Some(record) = self.current_record() else {
+            debug!("no active device — DPI change kept in memory only");
+            return;
+        };
+        let key = record.config_key.clone();
+        let persistent_key = record.persistent_config_key().map(str::to_string);
+        let route = record.route.clone();
+        if let Some(route) = route {
+            self.send_ipc(crate::ipc_client::Command::SetDpi(route, dpi));
+        }
+        if let Some(persistent_key) = persistent_key {
+            self.config.set_dpi(&persistent_key, dpi);
+            self.persist_and_reload("DPI");
+        } else {
+            debug!(key, "transient device DPI applied without persistence");
+        }
+    }
+}
+
+pub(crate) fn dpi_error_is_permanent(error: &WriteError) -> bool {
+    matches!(
+        error,
+        WriteError::FeatureUnsupported { .. } | WriteError::EmptyDpiList
+    )
+}
diff --git a/crates/openlogi-gui/src/state/inventory.rs b/crates/openlogi-gui/src/state/inventory.rs
new file mode 100644
index 0000000000000000000000000000000000000000..26a8cda8812ab2ebe568946d4466aa3beea57e3e
--- /dev/null
+++ b/crates/openlogi-gui/src/state/inventory.rs
@@ -0,0 +1,363 @@
+//! Device list refresh, transient adoption, and selection.
+
+use std::collections::{BTreeMap, HashSet};
+
+use openlogi_core::config::{Config, DeviceIdentity};
+use openlogi_core::device::{DeviceInventory, StandaloneDevice};
+use tracing::debug;
+
+use crate::asset::AssetResolver;
+use crate::asset::sync::{AssetTarget, model_key};
+use crate::state::devices::{
+    DeviceRecord, adopt_transient_record, build_device_list, direct_key_prefix, sort_device_list,
+};
+
+use super::load::Load;
+use super::{AppState, INVENTORY_MISS_GRACE};
+
+impl AppState {
+    /// Every known device model that can be resolved to an asset depot.
+    ///
+    /// This reads the UI's merged device list rather than only the latest live
+    /// inventory, so a temporarily incomplete probe can still download art for
+    /// a device restored from its persisted identity.
+    pub(crate) fn asset_models(&self) -> Vec<AssetTarget> {
+        let mut seen = HashSet::new();
+        self.device_list
+            .iter()
+            .filter_map(|record| {
+                let target = record
+                    .registry_model_id
+                    .clone()
+                    .map(|registry_model_id| AssetTarget::Standalone { registry_model_id })
+                    .or_else(|| {
+                        record.model_info.clone().map(|model| AssetTarget::Hidpp {
+                            model,
+                            codename: record.codename.clone(),
+                        })
+                    })?;
+                seen.insert(model_key(&target)).then_some(target)
+            })
+            .collect()
+    }
+    /// Replace [`Self::device_list`] from a fresh inventory snapshot,
+    /// preserving the carousel selection by `config_key` when possible. If
+    /// the previously-selected device disappeared, the selection falls back
+    /// to index 0. Returns whether anything actually changed.
+    ///
+    /// No-op (returning `false`) when the new list has the same `config_key`
+    /// sequence as the current one — the caller skips the window refresh, and
+    /// quiet polling cycles cause no spurious re-renders (P1.6). `force`
+    /// pushes through that early-return: the records embed resolved asset
+    /// paths, so a completed asset sync needs one rebuild even though the
+    /// device *set* is unchanged.
+    pub fn refresh_inventories(
+        &mut self,
+        inventories: &[DeviceInventory],
+        standalone: &[StandaloneDevice],
+        cache: &AssetResolver,
+        force: bool,
+        cameras: &[openlogi_camera::Camera],
+    ) -> bool {
+        let new_list = build_device_list(inventories, standalone, cache, &self.config, cameras);
+        let merged_list = self.merge_inventory_snapshot(new_list);
+        // Capture any newly-probed identity before the unchanged-check can early
+        // out: a device whose capabilities just resolved keeps the same
+        // config_key + route, so that guard would otherwise skip the write.
+        if persist_identities(&mut self.config, &merged_list) {
+            self.persist_config("device identity");
+        }
+        // Compare more than config_key: a device can reconnect on a new HID++
+        // index while keeping its physical config key, and the fresh route must
+        // replace the stale one so reads/writes don't target a dead index.
+        // `online` and `capabilities` are compared too, so a device waking up or
+        // a probe that resolves its feature table on a stable route still
+        // refreshes the carousel (and its config panels) instead of being
+        // swallowed by this guard.
+        let unchanged = merged_list.len() == self.device_list.len()
+            && merged_list
+                .iter()
+                .zip(self.device_list.iter())
+                .all(|(a, b)| {
+                    a.config_key == b.config_key
+                        && a.capture_id == b.capture_id
+                        && a.route == b.route
+                        && a.online == b.online
+                        && a.capabilities == b.capabilities
+                        && a.light_capabilities == b.light_capabilities
+                        && a.driver_id == b.driver_id
+                        && a.registry_model_id == b.registry_model_id
+                        && a.kind == b.kind
+                });
+        if unchanged && !force {
+            return false;
+        }
+
+        let previous_key = self.current_record().map(DeviceRecord::inventory_key);
+        let new_index = previous_key
+            .as_deref()
+            .and_then(|k| merged_list.iter().position(|r| r.inventory_key() == k))
+            .unwrap_or(0);
+        let connected_keys = merged_list
+            .iter()
+            .map(|r| r.config_key.as_str())
+            .collect::<Vec<_>>();
+        debug!(
+            count = merged_list.len(),
+            ?connected_keys,
+            "inventory refreshed"
+        );
+
+        // A device that came back on a different route must re-discover DPI —
+        // its cached status/attempts were keyed to the now-dead route.
+        let rerouted: Vec<String> = merged_list
+            .iter()
+            .filter(|new| {
+                self.device_list
+                    .iter()
+                    .any(|old| old.config_key == new.config_key && old.route != new.route)
+            })
+            .map(|new| new.config_key.clone())
+            .collect();
+
+        self.device_list = merged_list;
+        for key in &rerouted {
+            self.dpi_data.remove(key);
+            self.smartshift_data.remove(key);
+            self.smartshift_pending_confirm.remove(key);
+            self.smartshift_write_status.remove(key);
+        }
+        let present = |key: &str| {
+            self.device_list
+                .iter()
+                .any(|r| r.config_key.as_str() == key)
+        };
+        self.dpi_data.retain_present(present);
+        self.smartshift_data.retain_present(present);
+        self.smartshift_pending_confirm
+            .retain(|key, _| present(key));
+        self.smartshift_write_status.retain(|key, _| present(key));
+        self.current_device = new_index;
+        // The active device may have changed (selection fell back to index 0
+        // when the previous one vanished); re-seed the displayed DPI so it
+        // tracks the now-current device rather than the old one.
+        self.dpi = self.dpi_for_current();
+        self.button_bindings = self.bindings_for_current();
+        self.gesture_bindings = self.gesture_bindings_for_current();
+        // Display state only — the agent runs its own inventory watcher and
+        // rebuilds the live binding/DPI maps itself.
+        true
+    }
+    pub(crate) fn merge_inventory_snapshot(
+        &mut self,
+        new_list: Vec<DeviceRecord>,
+    ) -> Vec<DeviceRecord> {
+        let mut by_key = new_list
+            .into_iter()
+            .map(|record| (record.inventory_key(), record))
+            .collect::<BTreeMap<_, _>>();
+        let mut adopted = self.adopt_transient_records(&mut by_key);
+        let mut merged = Vec::with_capacity(by_key.len().max(self.device_list.len()));
+
+        for previous in &self.device_list {
+            let inv = previous.inventory_key();
+            if let Some(record) = by_key.remove(&inv) {
+                self.inventory_misses.remove(&inv);
+                merged.push(record);
+                continue;
+            }
+
+            if let Some(record) = adopted.remove(&inv) {
+                self.inventory_misses.remove(&inv);
+                merged.push(record);
+                continue;
+            }
+
+            // An all-zero direct unit id is only a transient probe result. If
+            // the next snapshot resolves a physical serial/unit key, retaining
+            // this record through the normal miss grace would show both cards.
+            if !previous.is_persistent() {
+                self.inventory_misses.remove(&inv);
+                continue;
+            }
+
+            // Cameras reappear under a new capture id after a port change —
+            // do not grace-keep a stale cam-live entry beside the new one.
+            if previous.kind == openlogi_core::device::DeviceKind::Camera {
+                self.inventory_misses.remove(&inv);
+                continue;
+            }
+
+            let misses = self.inventory_misses.entry(inv.clone()).or_insert(0);
+            *misses = misses.saturating_add(1);
+            if *misses <= INVENTORY_MISS_GRACE {
+                debug!(
+                    key = %inv,
+                    misses = *misses,
+                    "keeping device through transient inventory miss"
+                );
+                merged.push(previous.clone());
+            }
+        }
+
+        for (key, record) in by_key {
+            self.inventory_misses.remove(&key);
+            merged.push(record);
+        }
+        // Adopted records whose known card was never in the previous list
+        // (identity known only from config) still belong in the carousel.
+        merged.extend(adopted.into_values());
+        self.inventory_misses
+            .retain(|key, _| merged.iter().any(|record| record.inventory_key() == *key));
+        // `merged` is `previous-order + newly-appeared`, so re-apply the
+        // canonical route order or a new device would be stuck at the end of
+        // the carousel permanently.
+        sort_device_list(&mut merged);
+        merged
+    }
+    /// Pair each transient direct record in the snapshot with the device it
+    /// physically is. A transient key (`…:unit:00000000`) is a half-read probe
+    /// of some existing device, not a new one (#482): when exactly one known
+    /// card sharing its `direct:<vid>:<pid>` wire identity is not live online —
+    /// so the half-read probe can only be that device — the transient record is
+    /// folded into that card instead of surfacing beside it (or evicting it).
+    /// With no such card the transient is dropped as probe noise when its wire
+    /// product is already live online, and an ambiguous one (two known
+    /// same-model cards absent) is left alone.
+    pub(crate) fn adopt_transient_records(
+        &self,
+        by_key: &mut BTreeMap<String, DeviceRecord>,
+    ) -> BTreeMap<String, DeviceRecord> {
+        let transient_keys: Vec<String> = by_key
+            .values()
+            .filter(|record| !record.is_persistent())
+            .map(|record| record.config_key.clone())
+            .collect();
+        let mut adopted = BTreeMap::new();
+        for key in transient_keys {
+            let Some(prefix) = direct_key_prefix(&key) else {
+                continue;
+            };
+            let same_wire = |key: &str, record: &DeviceRecord| {
+                record.is_persistent() && direct_key_prefix(key) == Some(prefix)
+            };
+            // A live online sibling is accounted for and never a candidate,
+            // but it must not discard the transient — the half-read probe may
+            // be the *other* same-model device.
+            let mut candidates: Vec<String> = by_key
+                .iter()
+                .filter(|(k, record)| same_wire(k, record) && !record.online)
+                .map(|(k, _)| k.clone())
+                .collect();
+            for previous in &self.device_list {
+                if same_wire(&previous.config_key, previous)
+                    && !by_key.contains_key(&previous.config_key)
+                    && !candidates.contains(&previous.config_key)
+                {
+                    candidates.push(previous.config_key.clone());
+                }
+            }
+            let [known_key] = candidates.as_slice() else {
+                if candidates.is_empty()
+                    && by_key
+                        .iter()
+                        .any(|(k, record)| same_wire(k, record) && record.online)
+                {
+                    by_key.remove(&key);
+                }
+                continue;
+            };
+            // Last tick's record carries the freshest identity; the offline
+            // placeholder built from config is the fallback.
+            let known = self
+                .device_list
+                .iter()
+                .find(|record| record.config_key == *known_key)
+                .cloned()
+                .or_else(|| by_key.get(known_key).cloned());
+            let Some(known) = known else {
+                continue;
+            };
+            let known_key = known_key.clone();
+            by_key.remove(&known_key);
+            if let Some(live) = by_key.remove(&key) {
+                adopted.insert(known_key, adopt_transient_record(&known, live));
+            }
+        }
+        adopted
+    }
+    /// Switch the carousel to `idx`. Out-of-range indices are silently
+    /// ignored so callers can pass them straight through from UI events.
+    /// Persists the new selection (by config key, not index — index isn't
+    /// stable across restarts), reloads bindings for the new device, and
+    /// pushes the new map into the hook-shared `Arc`.
+    pub fn set_current_device(&mut self, idx: usize) {
+        if idx >= self.device_list.len() || idx == self.current_device {
+            return;
+        }
+        self.current_device = idx;
+        // A device left in `Failed` (transient read errors exhausted its retry
+        // budget) gets one fresh attempt each time it is re-selected.
+        if let Some(key) = self.current_record().map(|r| r.config_key.clone()) {
+            if matches!(self.dpi_data.get(&key), Some(Load::Failed(_))) {
+                self.dpi_data.retry(&key);
+            }
+            if matches!(self.smartshift_data.get(&key), Some(Load::Failed(_))) {
+                self.smartshift_data.retry(&key);
+                self.smartshift_write_status.remove(&key);
+            }
+        }
+        // `self.dpi` is the active device's value; adopt the newly-selected
+        // device's known DPI so the panel doesn't keep showing the previous
+        // device's number until a fresh read lands.
+        self.dpi = self.dpi_for_current();
+        self.button_bindings = self.bindings_for_current();
+        self.gesture_bindings = self.gesture_bindings_for_current();
+        let Some(key) = self
+            .current_record()
+            .and_then(DeviceRecord::persistent_config_key)
+            .map(str::to_string)
+        else {
+            debug!("transient device selection not persisted");
+            return;
+        };
+        self.config.set_selected_device(Some(key));
+        // The agent owns the hook + device I/O; have it switch devices too.
+        self.persist_and_reload("selected device");
+    }
+}
+
+pub(super) fn persist_identities(config: &mut Config, list: &[DeviceRecord]) -> bool {
+    let mut changed = false;
+    for record in list {
+        if !record.online {
+            continue;
+        }
+        let Some(config_key) = record.persistent_config_key() else {
+            continue;
+        };
+        let capabilities = record.capabilities.unwrap_or_default();
+        if record.light_capabilities.is_none() && record.capabilities.is_none() {
+            continue;
+        }
+        let identity = DeviceIdentity {
+            display_name: record.display_name.clone(),
+            kind: record.kind,
+            capabilities,
+            light_capabilities: record.light_capabilities,
+            model_info: record.model_info.clone().map(|mut model| {
+                model.serial_number = None;
+                model.unit_id = [0; 4];
+                model
+            }),
+            codename: record.codename.clone(),
+            driver_id: record.driver_id.clone(),
+            registry_model_id: record.registry_model_id.clone(),
+        };
+        if config.device_identity(config_key) != Some(&identity) {
+            config.set_device_identity(config_key, identity);
+            changed = true;
+        }
+    }
+    changed
+}
diff --git a/crates/openlogi-gui/src/state/light.rs b/crates/openlogi-gui/src/state/light.rs
new file mode 100644
index 0000000000000000000000000000000000000000..ce28509c5166c6576fbc0e3d0ab27203fd6ab35f
--- /dev/null
+++ b/crates/openlogi-gui/src/state/light.rs
@@ -0,0 +1,507 @@
+//! Optimistic standalone-light state and IPC result handling.
+
+use std::collections::BTreeMap;
+
+use openlogi_core::config::LightSettings;
+use openlogi_hid::{DeviceRoute, LightCommand, WriteError};
+use tracing::debug;
+
+use super::AppState;
+
+const fn camera_policy_applies(light: LightSettings) -> bool {
+    cfg!(target_os = "macos") && light.auto_camera
+}
+
+/// Result state of the latest standalone-light command for one device.
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub enum LightCommandStatus {
+    /// The command has been queued for the agent.
+    Pending,
+    /// The device or agent rejected the command.
+    Failed(String),
+    /// No route is available because the device is offline.
+    Offline,
+}
+
+pub(super) struct PendingLightCommand {
+    request_id: u64,
+    pending: u16,
+    settings: Option<LightSettings>,
+    persistent_key: Option<String>,
+    rollback_settings: LightSettings,
+    previous_volatile: Option<LightSettings>,
+    manual_override_rollback: Option<ManualOverrideRollback>,
+    successful_commands: Vec<LightCommand>,
+    failure: Option<String>,
+    superseded: Vec<SupersededLightCommand>,
+}
+
+struct SupersededLightCommand {
+    request_id: u64,
+    pending: u16,
+    successful_commands: Vec<LightCommand>,
+    failure: Option<String>,
+}
+
+#[derive(Clone, Copy)]
+struct ManualOverrideRollback {
+    previous: Option<bool>,
+}
+
+impl AppState {
+    /// Effective power state for the selected standalone light.
+    #[must_use]
+    pub fn light_enabled(&self) -> bool {
+        self.current_record()
+            .is_some_and(|record| self.light_enabled_for(&record.config_key))
+    }
+
+    /// Effective power state for any standalone-light key.
+    #[must_use]
+    pub fn light_enabled_for(&self, key: &str) -> bool {
+        let light = self.light_for(key);
+        if camera_policy_applies(light) {
+            self.manual_light_overrides
+                .get(key)
+                .copied()
+                .unwrap_or(self.camera_active)
+        } else {
+            light.enabled
+        }
+    }
+
+    /// Update the runtime camera state used by camera-linked light rendering.
+    /// A real transition clears every transient manual override.
+    pub fn set_camera_active(&mut self, active: bool) -> bool {
+        let changed = self.camera_active != active;
+        if changed {
+            self.manual_light_overrides.clear();
+        }
+        self.camera_active = active;
+        changed
+    }
+
+    /// Whether the selected light is currently governed by a supported camera
+    /// automation provider. The persisted setting remains portable, while
+    /// platforms without a provider retain normal manual power behaviour.
+    #[must_use]
+    pub fn camera_automation_active(&self) -> bool {
+        camera_policy_applies(self.light())
+    }
+
+    /// Latest light-command status for the selected device, if one exists.
+    #[must_use]
+    pub fn light_command_status(&self) -> Option<LightCommandStatus> {
+        let key = self.current_record()?.config_key.as_str();
+        self.light_command_status
+            .as_ref()
+            .filter(|(status_key, _, _)| status_key == key)
+            .map(|(_, _, status)| status.clone())
+    }
+
+    fn begin_light_command(&mut self, key: &str, online: bool) -> u64 {
+        self.next_light_request_id = self.next_light_request_id.wrapping_add(1);
+        let request_id = self.next_light_request_id;
+        if online {
+            self.light_commands.insert(
+                key.to_string(),
+                PendingLightCommand {
+                    request_id,
+                    pending: 0,
+                    settings: None,
+                    persistent_key: None,
+                    rollback_settings: LightSettings::default(),
+                    previous_volatile: None,
+                    manual_override_rollback: None,
+                    successful_commands: Vec::new(),
+                    failure: None,
+                    superseded: Vec::new(),
+                },
+            );
+            self.light_command_status =
+                Some((key.to_string(), request_id, LightCommandStatus::Pending));
+        } else {
+            self.light_command_status =
+                Some((key.to_string(), request_id, LightCommandStatus::Offline));
+        }
+        request_id
+    }
+
+    fn queue_light_command(
+        &mut self,
+        key: &str,
+        request_id: u64,
+        route: DeviceRoute,
+        command: LightCommand,
+    ) {
+        if let Some(pending) = self.light_commands.get_mut(key)
+            && pending.request_id == request_id
+        {
+            pending.pending = pending.pending.saturating_add(1);
+        }
+        if !self.send_ipc(crate::ipc_client::Command::SetLight(
+            route,
+            command,
+            key.to_string(),
+            request_id,
+        )) {
+            self.apply_light_command_result(
+                key.to_string(),
+                request_id,
+                command,
+                Err(WriteError::AgentUnavailable),
+            );
+        }
+    }
+
+    fn supersede_light_command(&mut self, key: &str) -> Vec<SupersededLightCommand> {
+        let Some(pending) = self.light_commands.remove(key) else {
+            return Vec::new();
+        };
+        let mut superseded = pending.superseded;
+        superseded.push(SupersededLightCommand {
+            request_id: pending.request_id,
+            pending: pending.pending,
+            successful_commands: pending.successful_commands,
+            failure: pending.failure,
+        });
+        superseded
+    }
+
+    /// Consume an asynchronous light-write result from the IPC client.
+    /// Results from an older request are ignored so a slow failed write cannot
+    /// overwrite the status of a newer slider release.
+    pub fn apply_light_command_result(
+        &mut self,
+        key: String,
+        request_id: u64,
+        command: LightCommand,
+        result: Result<(), WriteError>,
+    ) -> bool {
+        let Some(pending) = self.light_commands.get_mut(&key) else {
+            return false;
+        };
+        if pending.request_id == request_id {
+            pending.pending = pending.pending.saturating_sub(1);
+            match result {
+                Ok(()) => pending.successful_commands.push(command),
+                Err(error) => {
+                    pending.failure.get_or_insert_with(|| error.to_string());
+                }
+            }
+        } else if let Some(superseded) = pending
+            .superseded
+            .iter_mut()
+            .find(|superseded| superseded.request_id == request_id)
+        {
+            superseded.pending = superseded.pending.saturating_sub(1);
+            match result {
+                Ok(()) => superseded.successful_commands.push(command),
+                Err(error) => {
+                    superseded.failure.get_or_insert_with(|| error.to_string());
+                }
+            }
+        } else {
+            return false;
+        }
+        if pending.pending != 0 || pending.superseded.iter().any(|batch| batch.pending != 0) {
+            // A sibling may still be queued after the first failure. Keep the
+            // request alive so later successes are reflected in the reconciled
+            // GUI/config state instead of being discarded as stale.
+            return true;
+        }
+
+        let Some(pending) = self.light_commands.remove(&key) else {
+            return false;
+        };
+        let failure = pending.failure.clone().or_else(|| {
+            pending
+                .superseded
+                .iter()
+                .find_map(|batch| batch.failure.clone())
+        });
+        let successful_commands = pending
+            .superseded
+            .iter()
+            .flat_map(|batch| batch.successful_commands.iter().copied())
+            .chain(pending.successful_commands.iter().copied())
+            .collect::<Vec<_>>();
+        let manual_override_rollback = pending.manual_override_rollback;
+        if let Some(error) = failure {
+            if successful_commands.is_empty() {
+                if let Some(previous) = pending.previous_volatile {
+                    self.volatile_light_settings.insert(key.clone(), previous);
+                } else {
+                    self.volatile_light_settings.remove(&key);
+                }
+                restore_manual_override(
+                    &mut self.manual_light_overrides,
+                    &key,
+                    manual_override_rollback,
+                );
+            } else {
+                let mut accepted = pending.rollback_settings;
+                for &command in &successful_commands {
+                    apply_light_command(&mut accepted, command);
+                }
+                if let Some(persistent_key) = pending.persistent_key {
+                    self.volatile_light_settings.remove(&key);
+                    self.config.set_light(&persistent_key, accepted);
+                    self.persist_and_reload("partial light");
+                } else {
+                    self.volatile_light_settings.insert(key.clone(), accepted);
+                }
+                if !successful_commands
+                    .iter()
+                    .any(|command| matches!(command, LightCommand::Power(_)))
+                {
+                    restore_manual_override(
+                        &mut self.manual_light_overrides,
+                        &key,
+                        manual_override_rollback,
+                    );
+                }
+            }
+            self.light_command_status = Some((key, request_id, LightCommandStatus::Failed(error)));
+        } else {
+            if let (Some(settings), Some(persistent_key)) =
+                (pending.settings, pending.persistent_key)
+            {
+                self.config.set_light(&persistent_key, settings);
+                self.volatile_light_settings.remove(&key);
+                self.persist_and_reload("light");
+            }
+            // Successful writes are reflected by the controls themselves; do
+            // not leave a persistent success banner in the panel.
+            self.light_command_status = None;
+        }
+        true
+    }
+
+    /// The standalone-light settings for the active device, or defaults when
+    /// no light config has been stored yet.
+    #[must_use]
+    pub fn light(&self) -> LightSettings {
+        self.current_record()
+            .map_or_else(LightSettings::default, |record| {
+                self.light_for(&record.config_key)
+            })
+    }
+
+    /// The standalone-light settings for any persistent or runtime device key.
+    #[must_use]
+    pub fn light_for(&self, key: &str) -> LightSettings {
+        self.volatile_light_settings
+            .get(key)
+            .copied()
+            .or_else(|| self.config.light(key))
+            .unwrap_or_default()
+    }
+
+    /// Persist and apply standalone-light settings through the agent-owned
+    /// raw-HID path. Online persistent changes are committed only after every
+    /// advertised device command succeeds; failures roll optimistic state back.
+    pub fn commit_light(&mut self, light: LightSettings) {
+        let Some((runtime_key, key, route, online, capabilities)) =
+            self.current_record().map(|record| {
+                (
+                    record.config_key.clone(),
+                    record.persistent_config_key().map(str::to_string),
+                    record.route.clone(),
+                    record.online,
+                    record.light_capabilities,
+                )
+            })
+        else {
+            debug!("no active device — light change ignored");
+            return;
+        };
+        let previous = self.light_for(&runtime_key);
+        let camera_mode_changed =
+            cfg!(target_os = "macos") && previous.auto_camera != light.auto_camera;
+        let effective_enabled = if camera_policy_applies(light) {
+            if camera_mode_changed {
+                self.camera_active
+            } else {
+                self.light_enabled_for(&runtime_key)
+            }
+        } else {
+            light.enabled
+        };
+        let inherited_override_rollback = self
+            .light_commands
+            .get(&runtime_key)
+            .and_then(|pending| pending.manual_override_rollback);
+        let manual_override_rollback = inherited_override_rollback.or_else(|| {
+            camera_mode_changed.then(|| ManualOverrideRollback {
+                previous: self.manual_light_overrides.get(&runtime_key).copied(),
+            })
+        });
+        if camera_mode_changed {
+            self.manual_light_overrides.remove(&runtime_key);
+        }
+        let mut effective = light;
+        effective.enabled = effective_enabled;
+        let commands = capabilities.map_or_else(Vec::new, |capabilities| {
+            openlogi_hid::commands_for_light_settings(effective, capabilities)
+        });
+        // If this request supersedes another optimistic write, both must roll
+        // back to the last accepted value—not to the superseded pending value.
+        let (rollback_settings, previous_volatile) =
+            self.light_commands.get(&runtime_key).map_or_else(
+                || {
+                    (
+                        previous,
+                        self.volatile_light_settings.get(&runtime_key).copied(),
+                    )
+                },
+                |pending| (pending.rollback_settings, pending.previous_volatile),
+            );
+        self.volatile_light_settings
+            .insert(runtime_key.clone(), light);
+        if !commands.is_empty() {
+            let can_apply = online && route.is_some();
+            let superseded = if can_apply {
+                self.supersede_light_command(&runtime_key)
+            } else {
+                Vec::new()
+            };
+            let request_id = self.begin_light_command(&runtime_key, can_apply);
+            if can_apply && let Some(route) = route {
+                if let Some(pending) = self.light_commands.get_mut(&runtime_key) {
+                    pending.settings = Some(light);
+                    pending.persistent_key.clone_from(&key);
+                    pending.rollback_settings = rollback_settings;
+                    pending.previous_volatile = previous_volatile;
+                    pending.manual_override_rollback = manual_override_rollback;
+                    pending.superseded = superseded;
+                }
+                for command in commands {
+                    self.queue_light_command(&runtime_key, request_id, route.clone(), command);
+                }
+                return;
+            }
+        }
+        if let Some(key) = key {
+            self.volatile_light_settings.remove(&runtime_key);
+            self.config.set_light(&key, light);
+            self.persist_and_reload("light");
+        } else {
+            self.volatile_light_settings.insert(runtime_key, light);
+        }
+    }
+
+    /// Apply a transient manual power choice while camera automation remains
+    /// enabled. The persisted `enabled` field is updated as the manual fallback,
+    /// but the runtime override lasts only until the next camera transition.
+    pub fn commit_manual_light_power(&mut self, enabled: bool) {
+        let Some((runtime_key, key, route, online)) = self.current_record().map(|record| {
+            (
+                record.config_key.clone(),
+                record.persistent_config_key().map(str::to_string),
+                record.route.clone(),
+                record.online,
+            )
+        }) else {
+            debug!("no active device — manual light power ignored");
+            return;
+        };
+        let mut light = self.light_for(&runtime_key);
+        if !camera_policy_applies(light) {
+            light.enabled = enabled;
+            self.commit_light(light);
+            return;
+        }
+
+        let (rollback_settings, previous_volatile) =
+            self.light_commands.get(&runtime_key).map_or_else(
+                || {
+                    (
+                        light,
+                        self.volatile_light_settings.get(&runtime_key).copied(),
+                    )
+                },
+                |pending| (pending.rollback_settings, pending.previous_volatile),
+            );
+        let manual_override_rollback = self
+            .light_commands
+            .get(&runtime_key)
+            .and_then(|pending| pending.manual_override_rollback)
+            .or_else(|| {
+                Some(ManualOverrideRollback {
+                    previous: self.manual_light_overrides.get(&runtime_key).copied(),
+                })
+            });
+        light.enabled = enabled;
+        self.manual_light_overrides
+            .insert(runtime_key.clone(), enabled);
+        self.volatile_light_settings
+            .insert(runtime_key.clone(), light);
+
+        let can_apply = online && route.is_some();
+        let superseded = if can_apply {
+            self.supersede_light_command(&runtime_key)
+        } else {
+            Vec::new()
+        };
+        let request_id = self.begin_light_command(&runtime_key, can_apply);
+        if can_apply && let Some(route) = route {
+            if let Some(pending) = self.light_commands.get_mut(&runtime_key) {
+                pending.pending = 1;
+                pending.settings = Some(light);
+                pending.persistent_key.clone_from(&key);
+                pending.rollback_settings = rollback_settings;
+                pending.previous_volatile = previous_volatile;
+                pending.manual_override_rollback = manual_override_rollback;
+                pending.superseded = superseded;
+            }
+            if !self.send_ipc(crate::ipc_client::Command::SetLightManualPower(
+                route,
+                enabled,
+                runtime_key.clone(),
+                request_id,
+            )) {
+                self.apply_light_command_result(
+                    runtime_key,
+                    request_id,
+                    LightCommand::Power(enabled),
+                    Err(WriteError::AgentUnavailable),
+                );
+            }
+            return;
+        }
+
+        if let Some(key) = key {
+            self.volatile_light_settings.remove(&runtime_key);
+            self.config.set_light(&key, light);
+            self.persist_and_reload("manual light power");
+        }
+    }
+}
+
+fn apply_light_command(settings: &mut LightSettings, command: LightCommand) {
+    match command {
+        LightCommand::Power(enabled) => settings.enabled = enabled,
+        LightCommand::BrightnessPercent(brightness_percent) => {
+            settings.brightness_percent = brightness_percent;
+        }
+        LightCommand::TemperatureKelvin(temperature_kelvin) => {
+            settings.temperature_kelvin = Some(temperature_kelvin);
+        }
+        LightCommand::BrightnessNative(_) => {}
+    }
+}
+
+fn restore_manual_override(
+    overrides: &mut BTreeMap<String, bool>,
+    key: &str,
+    rollback: Option<ManualOverrideRollback>,
+) {
+    if let Some(rollback) = rollback {
+        if let Some(previous) = rollback.previous {
+            overrides.insert(key.to_string(), previous);
+        } else {
+            overrides.remove(key);
+        }
+    }
+}
diff --git a/crates/openlogi-gui/src/state/lighting.rs b/crates/openlogi-gui/src/state/lighting.rs
new file mode 100644
index 0000000000000000000000000000000000000000..ee0dfeaf9bc4d7fdf91ad3239cdf2a44509f8101
--- /dev/null
+++ b/crates/openlogi-gui/src/state/lighting.rs
@@ -0,0 +1,59 @@
+//! Per-device RGB keyboard lighting settings.
+
+use openlogi_agent_core::device_order::PhysicalDeviceKey;
+use openlogi_core::config::Lighting;
+use tracing::debug;
+
+use crate::state::devices::DeviceRecord;
+
+use super::AppState;
+
+impl AppState {
+    /// The lighting config for the active device, or the default when none is
+    /// stored / no device is selected.
+    #[must_use]
+    pub fn lighting(&self) -> Lighting {
+        self.current_record()
+            .and_then(DeviceRecord::persistent_config_key)
+            .and_then(|key| self.config.lighting(key))
+            .unwrap_or_default()
+    }
+    /// The stored lighting config for `key`, or `None` when unset.
+    #[must_use]
+    pub fn lighting_for(&self, key: &str) -> Option<Lighting> {
+        if PhysicalDeviceKey::is_transient(key)
+            || self
+                .device_list
+                .iter()
+                .any(|record| record.config_key == key && !record.is_persistent())
+        {
+            return None;
+        }
+        self.config.lighting(key)
+    }
+    /// Persist a new lighting config for the active device and push it to the
+    /// hardware (best-effort). No-op when no device is selected.
+    pub fn commit_lighting(&mut self, lighting: Lighting) {
+        let Some(record) = self.current_record() else {
+            debug!("no active device — lighting change ignored");
+            return;
+        };
+        let key = record.persistent_config_key().map(str::to_string);
+        let target = record.route.clone();
+        if let Some(route) = target {
+            self.send_ipc(crate::ipc_client::Command::SetLighting(
+                route,
+                lighting.clone(),
+            ));
+        }
+        let Some(key) = key else {
+            debug!("transient device lighting applied without persistence");
+            return;
+        };
+        self.config.set_lighting(&key, lighting);
+        // Keep the agent's config copy fresh: it re-applies the saved colour
+        // when the keyboard reconnects, and without the reload it would
+        // replay whatever was saved the last time something *else* reloaded.
+        self.persist_and_reload("lighting");
+    }
+}
diff --git a/crates/openlogi-gui/src/state/scroll.rs b/crates/openlogi-gui/src/state/scroll.rs
new file mode 100644
index 0000000000000000000000000000000000000000..070e281ecdd71dbb9fbff1296f3c200c91558fd4
--- /dev/null
+++ b/crates/openlogi-gui/src/state/scroll.rs
@@ -0,0 +1,99 @@
+//! Per-device scroll inversion and wheel resolution.
+
+use tracing::debug;
+
+use openlogi_core::config::Config;
+
+use crate::state::devices::DeviceRecord;
+
+use super::AppState;
+
+impl AppState {
+    /// Whether the active device's scroll wheel is inverted (issue #126).
+    /// `false` when no device is selected or the device hasn't opted in.
+    #[must_use]
+    pub fn current_invert_scroll(&self) -> bool {
+        self.current_record()
+            .and_then(DeviceRecord::persistent_config_key)
+            .is_some_and(|key| self.config.invert_scroll(key))
+    }
+    /// Whether the active device reports native HID++ wheel inversion support.
+    #[must_use]
+    pub fn current_scroll_inversion_supported(&self) -> bool {
+        self.current_record()
+            .and_then(|record| record.capabilities)
+            .is_some_and(|capabilities| capabilities.scroll_inversion)
+    }
+    /// Set the active device's scroll-wheel inversion, persist it, and reload
+    /// the agent so it writes the device's native HID++ wheel inversion. No-op
+    /// when no device is selected or the active device does not report support.
+    pub fn commit_invert_scroll(&mut self, invert: bool) {
+        if !self.current_scroll_inversion_supported() {
+            debug!("active device does not support native scroll inversion");
+            return;
+        }
+        let Some(key) = self
+            .current_record()
+            .and_then(DeviceRecord::persistent_config_key)
+            .map(str::to_string)
+        else {
+            debug!("no persistent device key — invert-scroll change ignored");
+            return;
+        };
+        self.config.set_invert_scroll(&key, invert);
+        self.persist_and_reload("invert scroll");
+    }
+    /// The active device's persisted wheel resolution, or `None` when OpenLogi
+    /// leaves the device default untouched.
+    #[must_use]
+    pub fn current_scroll_resolution(&self) -> Option<openlogi_core::config::ScrollResolution> {
+        self.current_record()
+            .and_then(DeviceRecord::persistent_config_key)
+            .and_then(|key| self.config.scroll_resolution(key))
+    }
+    /// Whether the active device exposes HID++ `0x2121 HiResWheel`.
+    #[must_use]
+    pub fn current_hires_wheel_supported(&self) -> bool {
+        self.current_record()
+            .and_then(|record| record.capabilities)
+            .is_some_and(|capabilities| capabilities.hires_wheel)
+    }
+    /// Persist the active device's wheel resolution and ask the agent to reload
+    /// it. `None` removes OpenLogi's override. No-op without a selected,
+    /// HiResWheel-capable device.
+    pub fn commit_scroll_resolution(
+        &mut self,
+        resolution: Option<openlogi_core::config::ScrollResolution>,
+    ) {
+        let Some((key, supported)) = self.current_record().and_then(|record| {
+            let key = record.persistent_config_key()?.to_string();
+            Some((
+                key,
+                record
+                    .capabilities
+                    .is_some_and(|capabilities| capabilities.hires_wheel),
+            ))
+        }) else {
+            debug!("no persistent device key — wheel-resolution change ignored");
+            return;
+        };
+        if !set_scroll_resolution_if_supported(&mut self.config, &key, supported, resolution) {
+            debug!("active device does not support HiResWheel");
+            return;
+        }
+        self.persist_and_reload("wheel resolution");
+    }
+}
+
+pub(crate) fn set_scroll_resolution_if_supported(
+    config: &mut Config,
+    key: &str,
+    supported: bool,
+    resolution: Option<openlogi_core::config::ScrollResolution>,
+) -> bool {
+    if !supported {
+        return false;
+    }
+    config.set_scroll_resolution(key, resolution);
+    true
+}
diff --git a/crates/openlogi-gui/src/state/settings.rs b/crates/openlogi-gui/src/state/settings.rs
new file mode 100644
index 0000000000000000000000000000000000000000..63e212c7a786ce905044f1e3854a4b6e5a13aa50
--- /dev/null
+++ b/crates/openlogi-gui/src/state/settings.rs
@@ -0,0 +1,160 @@
+//! App-level settings (launch-at-login, theme, assets, language).
+
+use super::AppState;
+use gpui::App;
+use openlogi_core::config::{AppSettings, Appearance, AssetSourcePreference};
+
+impl AppState {
+    /// App-wide settings backing the Settings window (launch-at-login,
+    /// update check). Read-only view; mutate via the setters below so the
+    /// change is persisted.
+    #[must_use]
+    pub fn app_settings(&self) -> &AppSettings {
+        &self.config.app_settings
+    }
+    /// Toggle launch-at-login, persist to `config.toml`, and reconcile the
+    /// macOS `LaunchAgent` plist so the change takes effect without a
+    /// restart. No-op when the value is unchanged. Disk failures are logged,
+    /// not propagated — the Settings UI shouldn't crash on a full volume.
+    pub fn set_launch_at_login(&mut self, enabled: bool) {
+        if self.config.app_settings.launch_at_login == enabled {
+            return;
+        }
+        self.config.app_settings.launch_at_login = enabled;
+        // The agent owns autostart now; it reconciles its LaunchAgent (which
+        // points at the agent, not the GUI) when it reloads the config.
+        self.persist_and_reload("launch-at-login setting");
+    }
+    /// Toggle the menu-bar (status item) icon preference and persist it. The
+    /// icon is hosted by the always-on agent, which reads this on startup and
+    /// installs the status item only when enabled — so the change takes effect
+    /// the next time the agent launches (a no-restart live toggle would need a
+    /// main-thread hop from the agent's IPC reload). `ReloadConfig` keeps the
+    /// agent's other config in sync meanwhile. No-op when unchanged.
+    ///
+    /// The callers are the menu-bar / notification-area toggle in Settings,
+    /// shown only where there's a tray (macOS + Windows), so the setter is
+    /// gated the same way to stay dead-code-clean on Linux.
+    #[cfg(any(target_os = "macos", target_os = "windows"))]
+    pub fn set_show_in_menu_bar(&mut self, enabled: bool) {
+        if self.config.app_settings.show_in_menu_bar == enabled {
+            return;
+        }
+        self.config.app_settings.show_in_menu_bar = enabled;
+        self.persist_and_reload("show-in-menu-bar setting");
+    }
+    /// Toggle the opt-in update check and persist it. No immediate side
+    /// effect beyond the next launch reading the new value. No-op when
+    /// unchanged.
+    pub fn set_check_for_updates(&mut self, enabled: bool) {
+        if self.config.app_settings.check_for_updates == enabled {
+            return;
+        }
+        self.config.app_settings.check_for_updates = enabled;
+        self.persist_config("update-check setting");
+    }
+    /// Toggle opt-in automatic install and persist it. The launch-time updater
+    /// observer reads this live, so a newer version found after this is enabled
+    /// downloads and stages on its own; no immediate side effect here. No-op
+    /// when unchanged.
+    pub fn set_auto_install_updates(&mut self, enabled: bool) {
+        if self.config.app_settings.auto_install_updates == enabled {
+            return;
+        }
+        self.config.app_settings.auto_install_updates = enabled;
+        self.persist_config("auto-install setting");
+    }
+    /// Persist the light/dark appearance preference. The caller re-applies the
+    /// live theme via [`crate::theme::apply_from_settings`]; this only writes the
+    /// choice. No-op when unchanged.
+    pub fn set_appearance(&mut self, appearance: Appearance) {
+        if self.config.app_settings.appearance == appearance {
+            return;
+        }
+        self.config.app_settings.appearance = appearance;
+        self.persist_config("appearance setting");
+    }
+    /// Persist the chosen theme name for one mode (`None` = the OpenLogi brand
+    /// theme). No-op when unchanged.
+    pub fn set_theme(&mut self, dark: bool, name: Option<String>) {
+        let slot = if dark {
+            &mut self.config.app_settings.theme_dark
+        } else {
+            &mut self.config.app_settings.theme_light
+        };
+        if *slot == name {
+            return;
+        }
+        *slot = name;
+        self.persist_config("theme setting");
+    }
+    /// Persist the UI corner-radius override (`None` = each theme's own radius).
+    /// No-op when unchanged.
+    pub fn set_ui_radius(&mut self, radius: Option<u8>) {
+        if self.config.app_settings.ui_radius == radius {
+            return;
+        }
+        self.config.app_settings.ui_radius = radius;
+        self.persist_config("UI radius setting");
+    }
+    /// Set the thumb-wheel sensitivity (clamped to the valid range), publish it
+    /// to the gesture watcher via the shared atomic, and persist it. No-op when
+    /// unchanged. Disk failures are logged, not propagated.
+    pub fn set_thumbwheel_sensitivity(&mut self, sensitivity: i32) {
+        let sensitivity = sensitivity.clamp(
+            openlogi_core::config::MIN_THUMBWHEEL_SENSITIVITY,
+            openlogi_core::config::MAX_THUMBWHEEL_SENSITIVITY,
+        );
+        if self.config.app_settings.thumbwheel_sensitivity == sensitivity {
+            return;
+        }
+        self.config.app_settings.thumbwheel_sensitivity = sensitivity;
+        self.persist_and_reload("thumbwheel sensitivity");
+    }
+    pub fn set_auto_download_assets(&mut self, enabled: bool) {
+        if self.config.app_settings.auto_download_assets == enabled {
+            return;
+        }
+        self.config.app_settings.auto_download_assets = enabled;
+        self.persist_config("auto-download-assets setting");
+    }
+    /// Persist the preferred device-asset source. The Settings view requests a
+    /// refresh separately when automatic downloads are enabled, so this setter
+    /// remains side-effect-free beyond configuration I/O.
+    pub fn set_asset_source(&mut self, source: AssetSourcePreference) {
+        if self.config.app_settings.asset_source == source {
+            return;
+        }
+        self.config.app_settings.asset_source = source;
+        self.persist_config("asset-source setting");
+    }
+    /// Record the answer to the first-run update-check prompt: enable (or leave
+    /// disabled) the check, and mark the prompt as seen so it never reappears.
+    /// Persists once.
+    pub fn record_update_consent(&mut self, enabled: bool) {
+        self.config.app_settings.check_for_updates = enabled;
+        self.config.app_settings.update_prompt_seen = true;
+        self.persist_config("update-check consent");
+    }
+    /// The stored UI-language preference: `Some(code)` for an explicit choice,
+    /// `None` for "follow system". Distinct from the *active* locale that
+    /// `None` resolves to at startup, so the Settings picker can show "Follow
+    /// system" as the selected option.
+    #[must_use]
+    pub fn language(&self) -> Option<&str> {
+        self.config.app_settings.language.as_deref()
+    }
+    /// Set the UI language (`None` = follow system), persist it, switch the
+    /// process-global locale live via [`crate::i18n`], and repaint open UI.
+    /// No-op when unchanged.
+    pub fn set_language(&mut self, language: Option<String>, cx: &mut App) {
+        if self.config.app_settings.language == language {
+            return;
+        }
+        self.config.app_settings.language = language;
+        self.persist_config("language setting");
+        crate::i18n::activate(self.config.app_settings.language.as_deref());
+        cx.refresh_windows();
+        crate::app_menu::rebuild(cx);
+    }
+}
diff --git a/crates/openlogi-gui/src/state/smartshift.rs b/crates/openlogi-gui/src/state/smartshift.rs
new file mode 100644
index 0000000000000000000000000000000000000000..183bd5d573606fe8f970eb323aebc74ffe4439ac
--- /dev/null
+++ b/crates/openlogi-gui/src/state/smartshift.rs
@@ -0,0 +1,234 @@
+//! SmartShift load state, optimistic writes, and confirmation.
+
+use openlogi_hid::{DeviceRoute, SmartShiftMode, SmartShiftStatus, WriteError};
+use tracing::debug;
+
+use super::load::SmartShiftLoad;
+use super::{AppState, SmartShiftWriteStatus};
+
+impl AppState {
+    /// SmartShift configuration status for the active device.
+    #[must_use]
+    pub fn current_smartshift_status(&self) -> SmartShiftLoad {
+        self.current_record()
+            .map_or(SmartShiftLoad::Unknown, |record| {
+                self.smartshift_data.status(&record.config_key)
+            })
+    }
+    /// Whether the active device still needs a SmartShift read (no status
+    /// recorded). Cheaper than comparing a cloned [`SmartShiftLoad`] on the
+    /// per-frame render path.
+    #[must_use]
+    pub fn current_smartshift_unqueried(&self) -> bool {
+        self.current_record()
+            .is_some_and(|record| self.smartshift_data.unqueried(&record.config_key))
+    }
+    /// The active device's resolved SmartShift config, if the read succeeded.
+    /// Callers use it to preserve fields they don't mean to change (e.g.
+    /// tunable torque) when writing back.
+    #[must_use]
+    pub fn current_smartshift_ready(&self) -> Option<SmartShiftStatus> {
+        self.current_record()
+            .and_then(|record| self.smartshift_data.get(&record.config_key))
+            .and_then(|status| match status {
+                SmartShiftLoad::Ready(s) => Some(*s),
+                SmartShiftLoad::Unknown
+                | SmartShiftLoad::Loading
+                | SmartShiftLoad::Failed(_)
+                | SmartShiftLoad::Unsupported(_) => None,
+            })
+    }
+    /// Post-write confirmation status for the active device.
+    #[must_use]
+    pub fn current_smartshift_write_status(&self) -> Option<SmartShiftWriteStatus> {
+        self.current_record().and_then(|record| {
+            self.smartshift_write_status
+                .get(&record.config_key)
+                .copied()
+        })
+    }
+    /// Mark SmartShift discovery as in flight for `key`.
+    pub fn mark_smartshift_loading(&mut self, key: &str) {
+        self.smartshift_data.mark_loading(key);
+    }
+    /// Reset a stuck `Loading` for `key` back to `Unknown` — called when the
+    /// read worker vanished without delivering a result.
+    pub fn clear_smartshift_loading(&mut self, key: &str) {
+        self.smartshift_data.clear_loading(key);
+    }
+    /// Drop the active device's recorded SmartShift status so the next render
+    /// re-runs discovery. Backs the "click to retry" affordance on a
+    /// [`SmartShiftLoad::Failed`] device.
+    pub fn retry_active_smartshift(&mut self) {
+        if let Some(key) = self.current_record().map(|r| r.config_key.clone()) {
+            self.smartshift_data.retry(&key);
+            self.smartshift_write_status.remove(&key);
+        }
+    }
+    /// Store a SmartShift read result if it still matches the known device
+    /// route and write identity, with the same transient-retry /
+    /// permanent-unsupported handling as [`Self::store_dpi_info`].
+    pub fn store_smartshift_status(
+        &mut self,
+        key: String,
+        route: &DeviceRoute,
+        write_id: Option<u64>,
+        result: Result<SmartShiftStatus, WriteError>,
+    ) {
+        if !smartshift_read_is_current(write_id, self.smartshift_write_status.get(&key)) {
+            debug!(key, ?write_id, "stale SmartShift read result ignored");
+            return;
+        }
+        let matches_route = self
+            .device_list
+            .iter()
+            .any(|record| record.config_key == key && record.route.as_ref() == Some(route));
+        let still_present = self
+            .device_list
+            .iter()
+            .any(|record| record.config_key == key);
+        let status_key = key.clone();
+        self.smartshift_data.store(
+            key,
+            result,
+            smartshift_error_is_permanent,
+            matches_route,
+            still_present,
+            "SmartShift",
+        );
+        let expected = match self.smartshift_write_status.get(&status_key) {
+            Some(SmartShiftWriteStatus::Applying { expected, .. }) => Some(*expected),
+            Some(SmartShiftWriteStatus::Confirmed | SmartShiftWriteStatus::Failed) | None => None,
+        };
+        if let Some(status) = expected.and_then(|expected| {
+            smartshift_write_outcome(expected, self.smartshift_data.get(&status_key))
+        }) {
+            self.smartshift_write_status.insert(status_key, status);
+        }
+    }
+    /// Write a full SmartShift configuration to the active device (best-effort,
+    /// on a background thread), optimistically cache it, and persist it to
+    /// `config.toml` — the values live in device RAM and reset on a power
+    /// cycle (#189), so the agent re-applies them when the device reconnects.
+    /// No-op when no device is selected.
+    pub fn commit_smartshift(
+        &mut self,
+        mode: SmartShiftMode,
+        auto_disengage: u8,
+        tunable_torque: u8,
+    ) {
+        let Some(record) = self.current_record() else {
+            debug!("no active device — SmartShift change ignored");
+            return;
+        };
+        let key = record.config_key.clone();
+        let persistent_key = record.persistent_config_key().map(str::to_string);
+        let route = record.route.clone();
+        let can_confirm = route.is_some();
+        if let Some(route) = route {
+            self.send_ipc(crate::ipc_client::Command::SetSmartShift(
+                route,
+                mode,
+                auto_disengage,
+                tunable_torque,
+            ));
+        }
+        if let Some(persistent_key) = persistent_key {
+            self.config.set_smartshift(
+                &persistent_key,
+                openlogi_core::config::SmartShift {
+                    mode: mode.into(),
+                    auto_disengage,
+                    tunable_torque,
+                },
+            );
+            self.persist_and_reload("SmartShift");
+        }
+        // Reflect the write immediately so the panel doesn't flicker back to
+        // the previous value before a re-read lands, but queue a confirming
+        // re-read: the write is fire-and-forget, so a sleeping device that
+        // rejected or timed it out would otherwise leave this optimistic value
+        // showing as "applied" forever (Ready blocks any further read).
+        let expected = SmartShiftStatus {
+            mode,
+            auto_disengage,
+            tunable_torque,
+        };
+        self.smartshift_data.set_ready(key.clone(), expected);
+        let write_id = can_confirm.then(|| {
+            let write_id = self.next_smartshift_write_id;
+            self.next_smartshift_write_id = self.next_smartshift_write_id.saturating_add(1);
+            self.smartshift_pending_confirm
+                .insert(key.clone(), write_id);
+            write_id
+        });
+        self.smartshift_write_status.insert(
+            key,
+            match write_id {
+                Some(write_id) => SmartShiftWriteStatus::Applying { expected, write_id },
+                None => SmartShiftWriteStatus::Failed,
+            },
+        );
+    }
+    /// Take the active device's pending SmartShift confirm, if any. Returns the
+    /// `(config_key, route, write_id)` for a one-shot re-read that replaces the
+    /// optimistic value with the device's real state; consumed once so it
+    /// doesn't re-fire.
+    pub fn take_active_smartshift_confirm(&mut self) -> Option<(String, DeviceRoute, u64)> {
+        let record = self.current_record()?;
+        let key = record.config_key.clone();
+        let route = record.route.clone()?;
+        self.smartshift_pending_confirm
+            .remove(&key)
+            .map(|write_id| (key, route, write_id))
+    }
+    /// Mark a post-write confirmation as failed when its reply channel closes.
+    pub fn fail_smartshift_confirm(&mut self, key: &str, write_id: u64) {
+        if matches!(
+            self.smartshift_write_status.get(key),
+            Some(SmartShiftWriteStatus::Applying {
+                write_id: current,
+                ..
+            }) if *current == write_id
+        ) {
+            self.smartshift_write_status
+                .insert(key.to_string(), SmartShiftWriteStatus::Failed);
+        }
+    }
+}
+
+pub(crate) fn smartshift_error_is_permanent(error: &WriteError) -> bool {
+    matches!(error, WriteError::FeatureUnsupported { .. })
+}
+
+pub(crate) fn smartshift_write_outcome(
+    expected: SmartShiftStatus,
+    load: Option<&SmartShiftLoad>,
+) -> Option<SmartShiftWriteStatus> {
+    match load {
+        Some(SmartShiftLoad::Ready(actual)) if *actual == expected => {
+            Some(SmartShiftWriteStatus::Confirmed)
+        }
+        Some(SmartShiftLoad::Ready(_)) => Some(SmartShiftWriteStatus::Failed),
+        Some(SmartShiftLoad::Failed(_) | SmartShiftLoad::Unsupported(_)) => {
+            Some(SmartShiftWriteStatus::Failed)
+        }
+        None | Some(SmartShiftLoad::Unknown | SmartShiftLoad::Loading) => None,
+    }
+}
+
+pub(crate) fn smartshift_read_is_current(
+    read_id: Option<u64>,
+    write_status: Option<&SmartShiftWriteStatus>,
+) -> bool {
+    match (read_id, write_status) {
+        (
+            Some(read_id),
+            Some(SmartShiftWriteStatus::Applying {
+                write_id: current, ..
+            }),
+        ) => read_id == *current,
+        (None, Some(SmartShiftWriteStatus::Applying { .. })) | (Some(_), _) => false,
+        (None, _) => true,
+    }
+}
diff --git a/crates/openlogi-gui/src/state/tests.rs b/crates/openlogi-gui/src/state/tests.rs
new file mode 100644
index 0000000000000000000000000000000000000000..b7ee2d64283ae9f6c6a228094f5612d29a0cd0b9
--- /dev/null
+++ b/crates/openlogi-gui/src/state/tests.rs
@@ -0,0 +1,914 @@
+//! AppState unit tests.
+
+#![allow(
+    clippy::expect_used,
+    reason = "state fixture construction is intentionally asserted in tests"
+)]
+
+use openlogi_core::config::{Config, DeviceIdentity, LightSettings, Lighting, ScrollResolution};
+use openlogi_core::device::{
+    Capabilities, DeviceInventory, DeviceKind, DeviceModelInfo, DeviceTransports,
+    LightCapabilities, LightValueRange, LightValueUnit, PairedDevice, RawDeviceAddress,
+    ReceiverInfo, StandaloneDevice,
+};
+use openlogi_hid::WriteError;
+
+use crate::asset::AssetResolver;
+use crate::data::mouse_buttons::{Action, Binding, ButtonId};
+use crate::mouse_model::thumbwheel::ThumbwheelPreset;
+
+use openlogi_hid::{SmartShiftMode, SmartShiftStatus};
+
+use super::bindings::apply_thumbwheel_pair;
+use super::devices::build_device_list;
+use super::scroll::set_scroll_resolution_if_supported;
+use super::smartshift::{smartshift_read_is_current, smartshift_write_outcome};
+use super::{AppState, ConfigPersistence, LightCommandStatus, Load, SmartShiftWriteStatus};
+
+fn direct_inventory(unit_id: [u8; 4]) -> DeviceInventory {
+    DeviceInventory {
+        receiver: ReceiverInfo {
+            name: "MX Master 3S".to_string(),
+            vendor_id: 0x046d,
+            product_id: 0xb023,
+            unique_id: None,
+        },
+        paired: vec![PairedDevice {
+            slot: openlogi_hid::DIRECT_DEVICE_INDEX,
+            codename: Some("MX Master 3S".to_string()),
+            wpid: None,
+            kind: DeviceKind::Mouse,
+            online: true,
+            battery: None,
+            model_info: Some(DeviceModelInfo {
+                entity_count: 1,
+                serial_number: None,
+                unit_id,
+                transports: DeviceTransports::default(),
+                model_ids: [0xb034, 0, 0],
+                extended_model_id: 2,
+            }),
+            capabilities: Some(Capabilities::presumed_from_kind(DeviceKind::Mouse)),
+        }],
+    }
+}
+
+fn superseded_litra_light() -> StandaloneDevice {
+    StandaloneDevice {
+        address: RawDeviceAddress {
+            vendor_id: 0x046d,
+            product_id: 0xc900,
+            usage_page: 0xff43,
+            usage_id: 0x0202,
+            identity: "serial:glow-superseded".into(),
+        },
+        display_name: "Litra Glow".into(),
+        manufacturer: Some("Logi".into()),
+        serial_number: Some("glow-superseded".into()),
+        unit_id: [0; 4],
+        kind: DeviceKind::Light,
+        online: true,
+        capabilities: None,
+        light_capabilities: Some(LightCapabilities {
+            power: true,
+            brightness: Some(
+                LightValueRange::new(20, 250, 1, LightValueUnit::Lumens).expect("valid range"),
+            ),
+            ..LightCapabilities::default()
+        }),
+        driver_id: "litra".into(),
+        registry_model_id: Some("8c900".into()),
+    }
+}
+
+fn next_light_command(
+    receiver: &mut tokio::sync::mpsc::UnboundedReceiver<crate::ipc_client::Command>,
+) -> (openlogi_hid::LightCommand, u64) {
+    let Ok(crate::ipc_client::Command::SetLight(_, command, _, request_id)) = receiver.try_recv()
+    else {
+        panic!("expected a light command");
+    };
+    (command, request_id)
+}
+
+#[test]
+fn thumbwheel_pair_updates_both_memory_and_config_entries() {
+    let mut bindings = std::collections::BTreeMap::new();
+    let mut config = Config::ephemeral();
+    let key = "2b034";
+
+    assert!(apply_thumbwheel_pair(
+        &mut bindings,
+        &mut config,
+        Some(key),
+        ThumbwheelPreset::Volume.pair(),
+    ));
+    assert_eq!(
+        bindings.get(&ButtonId::ThumbwheelScrollDown),
+        Some(&Action::VolumeDown)
+    );
+    assert_eq!(
+        bindings.get(&ButtonId::ThumbwheelScrollUp),
+        Some(&Action::VolumeUp)
+    );
+    let persisted = config.bindings_for(key);
+    assert_eq!(
+        persisted.get(&ButtonId::ThumbwheelScrollDown),
+        Some(&Binding::Single(Action::VolumeDown))
+    );
+    assert_eq!(
+        persisted.get(&ButtonId::ThumbwheelScrollUp),
+        Some(&Binding::Single(Action::VolumeUp))
+    );
+}
+
+#[test]
+fn transient_thumbwheel_pair_stays_in_memory_without_persistence() {
+    let mut bindings = std::collections::BTreeMap::new();
+    let mut config = Config::ephemeral();
+
+    assert!(!apply_thumbwheel_pair(
+        &mut bindings,
+        &mut config,
+        None,
+        ThumbwheelPreset::CycleDpi.pair(),
+    ));
+    assert_eq!(bindings.len(), 2);
+    assert!(config.bindings_for("missing").is_empty());
+}
+
+#[test]
+fn transient_identity_is_not_persisted_or_retained_after_resolution() {
+    let cache = AssetResolver::new();
+    let transient_inventory = direct_inventory([0; 4]);
+    let (commands, _receiver) = tokio::sync::mpsc::unbounded_channel();
+    let mut state = AppState::with_runtime(
+        Config::ephemeral(),
+        &[transient_inventory],
+        &[],
+        &cache,
+        &[],
+        ConfigPersistence::MemoryOnly,
+        commands,
+    );
+    let transient_key = "direct:046d:b023:unit:00000000";
+
+    assert_eq!(state.device_list.len(), 1);
+    assert!(state.config.device_identity(transient_key).is_none());
+    state.commit_dpi(2400);
+    assert!(state.config.dpi(transient_key).is_none());
+
+    let stable_list = build_device_list(
+        &[direct_inventory([0xa3, 0x93, 0xca, 0xe0])],
+        &[],
+        &cache,
+        &state.config,
+        &[],
+    );
+    let merged = state.merge_inventory_snapshot(stable_list);
+
+    assert_eq!(merged.len(), 1);
+    assert_eq!(merged[0].config_key, "direct:046d:b023:unit:a393cae0");
+    assert!(merged[0].is_persistent());
+}
+
+#[test]
+fn transient_probe_folds_into_its_known_card() {
+    // #482: a half-read probe (all-zero unit id) of the only known device
+    // with that vid/pid must not evict the known card or appear beside it —
+    // the card keeps its identity and takes the live volatile state.
+    let cache = AssetResolver::new();
+    let (commands, _receiver) = tokio::sync::mpsc::unbounded_channel();
+    let mut state = AppState::with_runtime(
+        Config::ephemeral(),
+        &[direct_inventory([0xa3, 0x93, 0xca, 0xe0])],
+        &[],
+        &cache,
+        &[],
+        ConfigPersistence::MemoryOnly,
+        commands,
+    );
+    let stable_key = "direct:046d:b023:unit:a393cae0";
+    assert_eq!(state.device_list[0].config_key, stable_key);
+
+    let transient_list =
+        build_device_list(&[direct_inventory([0; 4])], &[], &cache, &state.config, &[]);
+    let merged = state.merge_inventory_snapshot(transient_list);
+
+    assert_eq!(merged.len(), 1, "no second card for the half-read probe");
+    assert_eq!(merged[0].config_key, stable_key);
+    assert!(merged[0].is_persistent());
+    assert!(merged[0].online, "the live probe supplies volatile state");
+    assert!(merged[0].route.is_some(), "the live route is kept usable");
+}
+
+#[test]
+fn transient_record_beside_its_live_device_is_dropped() {
+    // Both a full and a half-read probe of the same wire product in one
+    // snapshot: the transient record is probe noise, not a second device.
+    let cache = AssetResolver::new();
+    let (commands, _receiver) = tokio::sync::mpsc::unbounded_channel();
+    let mut state = AppState::with_runtime(
+        Config::ephemeral(),
+        &[direct_inventory([0xa3, 0x93, 0xca, 0xe0])],
+        &[],
+        &cache,
+        &[],
+        ConfigPersistence::MemoryOnly,
+        commands,
+    );
+
+    let both = build_device_list(
+        &[
+            direct_inventory([0xa3, 0x93, 0xca, 0xe0]),
+            direct_inventory([0; 4]),
+        ],
+        &[],
+        &cache,
+        &state.config,
+        &[],
+    );
+    assert_eq!(both.len(), 2);
+    let merged = state.merge_inventory_snapshot(both);
+
+    assert_eq!(merged.len(), 1);
+    assert_eq!(merged[0].config_key, "direct:046d:b023:unit:a393cae0");
+    assert!(merged[0].online);
+}
+
+#[test]
+fn transient_probe_adopts_the_absent_sibling_of_a_live_twin() {
+    // Two same-model devices; one probes complete, the other half-reads.
+    // The live twin must not get the transient discarded as its own noise:
+    // the half-read probe can only be the sibling, which keeps its card
+    // online and routed.
+    let cache = AssetResolver::new();
+    let (commands, _receiver) = tokio::sync::mpsc::unbounded_channel();
+    let mut state = AppState::with_runtime(
+        Config::ephemeral(),
+        &[
+            direct_inventory([1, 1, 1, 1]),
+            direct_inventory([2, 2, 2, 2]),
+        ],
+        &[],
+        &cache,
+        &[],
+        ConfigPersistence::MemoryOnly,
+        commands,
+    );
+
+    let snapshot = build_device_list(
+        &[direct_inventory([1, 1, 1, 1]), direct_inventory([0; 4])],
+        &[],
+        &cache,
+        &state.config,
+        &[],
+    );
+    let merged = state.merge_inventory_snapshot(snapshot);
+
+    assert_eq!(merged.len(), 2, "no third card for the half-read probe");
+    let Some(sibling) = merged
+        .iter()
+        .find(|r| r.config_key == "direct:046d:b023:unit:02020202")
+    else {
+        panic!("the sibling card must survive under its physical key");
+    };
+    assert!(
+        sibling.online,
+        "the half-read probe keeps the sibling online"
+    );
+    assert!(sibling.route.is_some(), "the live route stays usable");
+}
+
+#[test]
+fn ambiguous_transient_probe_is_not_adopted() {
+    // Two same-model devices are known; a half-read probe could be either,
+    // so neither card may steal it.
+    let cache = AssetResolver::new();
+    let (commands, _receiver) = tokio::sync::mpsc::unbounded_channel();
+    let mut state = AppState::with_runtime(
+        Config::ephemeral(),
+        &[
+            direct_inventory([1, 1, 1, 1]),
+            direct_inventory([2, 2, 2, 2]),
+        ],
+        &[],
+        &cache,
+        &[],
+        ConfigPersistence::MemoryOnly,
+        commands,
+    );
+    assert_eq!(state.device_list.len(), 2);
+
+    let transient_list =
+        build_device_list(&[direct_inventory([0; 4])], &[], &cache, &state.config, &[]);
+    let merged = state.merge_inventory_snapshot(transient_list);
+
+    assert_eq!(merged.len(), 3, "both known cards survive on grace");
+    assert_eq!(
+        merged.iter().filter(|r| !r.is_persistent()).count(),
+        1,
+        "the transient card stays its own record"
+    );
+}
+
+#[test]
+fn historical_transient_lighting_is_not_exposed_without_a_live_record() {
+    let transient_key = "direct:046d:b023:unit:00000000";
+    let mut config = Config::ephemeral();
+    config.set_lighting(transient_key, Lighting::default());
+    assert!(config.lighting(transient_key).is_some());
+    let (commands, _receiver) = tokio::sync::mpsc::unbounded_channel();
+    let state = AppState::with_runtime(
+        config,
+        &[],
+        &[],
+        &AssetResolver::new(),
+        &[],
+        ConfigPersistence::MemoryOnly,
+        commands,
+    );
+
+    assert!(state.device_list.is_empty());
+    assert!(state.lighting_for(transient_key).is_none());
+}
+
+#[test]
+fn smartshift_write_feedback_requires_the_written_value() {
+    let expected = SmartShiftStatus {
+        mode: SmartShiftMode::Ratchet,
+        auto_disengage: 12,
+        tunable_torque: 0,
+    };
+    assert_eq!(smartshift_write_outcome(expected, None), None);
+    assert_eq!(
+        smartshift_write_outcome(expected, Some(&Load::Ready(expected))),
+        Some(SmartShiftWriteStatus::Confirmed)
+    );
+    assert_eq!(
+        smartshift_write_outcome(
+            expected,
+            Some(&Load::Ready(SmartShiftStatus {
+                auto_disengage: 13,
+                ..expected
+            })),
+        ),
+        Some(SmartShiftWriteStatus::Failed)
+    );
+    assert_eq!(
+        smartshift_write_outcome(
+            expected,
+            Some(&Load::<SmartShiftStatus>::Failed("timeout".to_string(),))
+        ),
+        Some(SmartShiftWriteStatus::Failed)
+    );
+}
+
+#[test]
+fn stale_smartshift_reads_do_not_resolve_newer_writes() {
+    let expected = SmartShiftStatus {
+        mode: SmartShiftMode::Ratchet,
+        auto_disengage: 12,
+        tunable_torque: 0,
+    };
+    let applying = SmartShiftWriteStatus::Applying {
+        expected,
+        write_id: 2,
+    };
+
+    assert!(smartshift_read_is_current(Some(2), Some(&applying)));
+    assert!(!smartshift_read_is_current(Some(1), Some(&applying)));
+    assert!(!smartshift_read_is_current(None, Some(&applying)));
+    assert!(!smartshift_read_is_current(
+        Some(2),
+        Some(&SmartShiftWriteStatus::Confirmed)
+    ));
+    assert!(smartshift_read_is_current(None, None));
+}
+
+#[test]
+fn known_offline_device_is_an_asset_sync_target() {
+    let model = DeviceModelInfo {
+        entity_count: 0,
+        serial_number: None,
+        unit_id: [0; 4],
+        transports: DeviceTransports::default(),
+        model_ids: [0xb034, 0, 0],
+        extended_model_id: 2,
+    };
+    let mut config = Config::ephemeral();
+    config.set_device_identity(
+        "2b034",
+        DeviceIdentity {
+            display_name: "MX Anywhere 3S".to_string(),
+            kind: DeviceKind::Mouse,
+            capabilities: Capabilities::presumed_from_kind(DeviceKind::Mouse),
+            light_capabilities: None,
+            model_info: Some(model.clone()),
+            codename: Some("MX Anywhere 3S".to_string()),
+            driver_id: None,
+            registry_model_id: None,
+        },
+    );
+    let (commands, _receiver) = tokio::sync::mpsc::unbounded_channel();
+    let state = AppState::with_runtime(
+        config,
+        &[],
+        &[],
+        &AssetResolver::new(),
+        &[],
+        ConfigPersistence::MemoryOnly,
+        commands,
+    );
+
+    assert_eq!(
+        state.asset_models(),
+        vec![crate::asset::sync::AssetTarget::Hidpp {
+            model,
+            codename: Some("MX Anywhere 3S".to_string()),
+        }]
+    );
+}
+
+#[test]
+fn identical_standalone_units_share_one_model_asset_target() {
+    let first = superseded_litra_light();
+    let mut second = first.clone();
+    second.address.identity = "serial:glow-second".into();
+    second.serial_number = Some("glow-second".into());
+    let (commands, _receiver) = tokio::sync::mpsc::unbounded_channel();
+    let state = AppState::with_runtime(
+        Config::default(),
+        &[],
+        &[first, second],
+        &AssetResolver::new(),
+        &[],
+        ConfigPersistence::MemoryOnly,
+        commands,
+    );
+
+    assert_eq!(
+        state.asset_models(),
+        vec![crate::asset::sync::AssetTarget::Standalone {
+            registry_model_id: "8c900".into(),
+        }]
+    );
+}
+
+#[test]
+fn gui_state_saves_and_clears_supported_wheel_resolution() {
+    let mut config = Config::ephemeral();
+    assert!(set_scroll_resolution_if_supported(
+        &mut config,
+        "mouse",
+        true,
+        Some(ScrollResolution::Low),
+    ));
+    assert_eq!(
+        config.scroll_resolution("mouse"),
+        Some(ScrollResolution::Low)
+    );
+
+    assert!(set_scroll_resolution_if_supported(
+        &mut config,
+        "mouse",
+        true,
+        None,
+    ));
+    assert_eq!(config.scroll_resolution("mouse"), None);
+}
+
+#[test]
+fn gui_state_ignores_unsupported_wheel_resolution() {
+    let mut config = Config::ephemeral();
+    assert!(!set_scroll_resolution_if_supported(
+        &mut config,
+        "mouse",
+        false,
+        Some(ScrollResolution::High),
+    ));
+    assert_eq!(config.scroll_resolution("mouse"), None);
+}
+
+fn camera_controls(brightness: i32) -> openlogi_core::config::CameraControls {
+    openlogi_core::config::CameraControls(std::collections::BTreeMap::from([(
+        "brightness".into(),
+        brightness,
+    )]))
+}
+
+fn camera_state(config: Config) -> AppState {
+    let (tx, _rx) = tokio::sync::mpsc::unbounded_channel();
+    AppState::with_runtime(
+        config,
+        &[],
+        &[],
+        &AssetResolver::new(),
+        &[],
+        ConfigPersistence::MemoryOnly,
+        tx,
+    )
+}
+
+#[test]
+fn migrate_lifts_legacy_port_bound_camera_key() {
+    let mut config = Config::ephemeral();
+    let model = "camera:046d:0893";
+    let legacy = "camera-0x1123000046d0893";
+    config.set_camera_controls(legacy, camera_controls(42));
+    let mut state = camera_state(config);
+
+    state.migrate_legacy_camera_key(model, "0x1123000046d0893");
+
+    assert_eq!(
+        state
+            .config
+            .camera_controls(model)
+            .map(|c| c.0["brightness"]),
+        Some(42)
+    );
+    assert!(state.config.camera_controls(legacy).is_none());
+}
+
+#[test]
+fn migrate_does_not_overwrite_existing_model_settings() {
+    let mut config = Config::ephemeral();
+    let model = "camera:046d:0893";
+    let legacy = "camera-0x1123000046d0893";
+    config.set_camera_controls(model, camera_controls(1));
+    config.set_camera_controls(legacy, camera_controls(99));
+    let mut state = camera_state(config);
+
+    state.migrate_legacy_camera_key(model, "0x1123000046d0893");
+
+    assert_eq!(
+        state
+            .config
+            .camera_controls(model)
+            .map(|c| c.0["brightness"]),
+        Some(1)
+    );
+    assert_eq!(
+        state
+            .config
+            .camera_controls(legacy)
+            .map(|c| c.0["brightness"]),
+        Some(99)
+    );
+}
+
+#[test]
+fn light_write_failure_reaches_the_gui_state() {
+    let light = StandaloneDevice {
+        address: RawDeviceAddress {
+            vendor_id: 0x046d,
+            product_id: 0xc900,
+            usage_page: 0xff43,
+            usage_id: 0x0202,
+            identity: "serial:glow-1".into(),
+        },
+        display_name: "Litra Glow".into(),
+        manufacturer: Some("Logi".into()),
+        serial_number: Some("glow-1".into()),
+        unit_id: [0; 4],
+        kind: DeviceKind::Light,
+        online: true,
+        capabilities: None,
+        light_capabilities: Some(LightCapabilities {
+            power: true,
+            brightness: Some(
+                LightValueRange::new(20, 250, 1, LightValueUnit::Lumens).expect("valid range"),
+            ),
+            ..LightCapabilities::default()
+        }),
+        driver_id: "litra".into(),
+        registry_model_id: Some("8c900".into()),
+    };
+    let (commands, mut receiver) = tokio::sync::mpsc::unbounded_channel();
+    let mut state = AppState::with_runtime(
+        Config::default(),
+        &[],
+        &[light],
+        &AssetResolver::new(),
+        &[],
+        ConfigPersistence::MemoryOnly,
+        commands,
+    );
+    let key = state
+        .current_record()
+        .expect("light record")
+        .config_key
+        .clone();
+    let requested = LightSettings::new(false, 50, None);
+    state.commit_light(requested);
+    let Ok(crate::ipc_client::Command::SetLight(
+        _,
+        openlogi_hid::LightCommand::Power(false),
+        _,
+        request_id,
+    )) = receiver.try_recv()
+    else {
+        panic!("expected the power command");
+    };
+    let Ok(crate::ipc_client::Command::SetLight(
+        _,
+        openlogi_hid::LightCommand::BrightnessPercent(50),
+        _,
+        brightness_request_id,
+    )) = receiver.try_recv()
+    else {
+        panic!("expected the brightness command");
+    };
+    assert_eq!(brightness_request_id, request_id);
+    assert_eq!(state.light(), requested);
+    assert_eq!(state.config.light(&key), None);
+    assert!(matches!(
+        state.light_command_status(),
+        Some(LightCommandStatus::Pending)
+    ));
+    assert!(state.apply_light_command_result(
+        key.clone(),
+        request_id,
+        openlogi_hid::LightCommand::Power(false),
+        Ok(()),
+    ));
+    assert_eq!(state.light(), requested);
+    assert!(state.apply_light_command_result(
+        key.clone(),
+        request_id,
+        openlogi_hid::LightCommand::BrightnessPercent(50),
+        Err(WriteError::AmbiguousRawDevice),
+    ));
+    assert!(matches!(
+        state.light_command_status(),
+        Some(LightCommandStatus::Failed(message)) if message.contains("multiple raw HID")
+    ));
+    assert_eq!(
+        state.light(),
+        LightSettings::new(false, LightSettings::default().brightness_percent, None)
+    );
+    assert_eq!(state.config.light(&key), Some(state.light()));
+}
+
+#[test]
+fn superseded_light_write_keeps_prior_successes_for_reconciliation() {
+    let light = superseded_litra_light();
+    let (commands, mut receiver) = tokio::sync::mpsc::unbounded_channel();
+    let mut state = AppState::with_runtime(
+        Config::default(),
+        &[],
+        &[light],
+        &AssetResolver::new(),
+        &[],
+        ConfigPersistence::MemoryOnly,
+        commands,
+    );
+    let key = state
+        .current_record()
+        .expect("light record")
+        .config_key
+        .clone();
+
+    state.commit_light(LightSettings::new(false, 40, None));
+    let (first_power, first_request_id) = next_light_command(&mut receiver);
+    let (first_brightness, first_brightness_request_id) = next_light_command(&mut receiver);
+    assert_eq!(first_power, openlogi_hid::LightCommand::Power(false));
+    assert_eq!(
+        first_brightness,
+        openlogi_hid::LightCommand::BrightnessPercent(40)
+    );
+    assert_eq!(first_brightness_request_id, first_request_id);
+
+    state.commit_light(LightSettings::new(true, 60, None));
+    let (second_power, second_request_id) = next_light_command(&mut receiver);
+    let (second_brightness, second_brightness_request_id) = next_light_command(&mut receiver);
+    assert_eq!(second_power, openlogi_hid::LightCommand::Power(true));
+    assert_eq!(
+        second_brightness,
+        openlogi_hid::LightCommand::BrightnessPercent(60)
+    );
+    assert_ne!(second_request_id, first_request_id);
+    assert_eq!(second_brightness_request_id, second_request_id);
+
+    assert!(state.apply_light_command_result(
+        key.clone(),
+        second_request_id,
+        openlogi_hid::LightCommand::Power(true),
+        Ok(()),
+    ));
+    assert!(state.apply_light_command_result(
+        key.clone(),
+        second_request_id,
+        openlogi_hid::LightCommand::BrightnessPercent(60),
+        Err(WriteError::AmbiguousRawDevice),
+    ));
+    assert_eq!(state.light(), LightSettings::new(true, 60, None));
+    assert!(matches!(
+        state.light_command_status(),
+        Some(LightCommandStatus::Pending)
+    ));
+
+    assert!(state.apply_light_command_result(
+        key.clone(),
+        first_request_id,
+        openlogi_hid::LightCommand::Power(false),
+        Ok(()),
+    ));
+    assert!(state.apply_light_command_result(
+        key.clone(),
+        first_request_id,
+        openlogi_hid::LightCommand::BrightnessPercent(40),
+        Ok(()),
+    ));
+
+    assert!(matches!(
+        state.light_command_status(),
+        Some(LightCommandStatus::Failed(message)) if message.contains("multiple raw HID")
+    ));
+    assert_eq!(state.light(), LightSettings::new(true, 40, None));
+    assert_eq!(state.config.light(&key), Some(state.light()));
+}
+
+#[test]
+fn transient_light_state_is_kept_in_memory_and_only_supported_commands_are_sent() {
+    let light = StandaloneDevice {
+        address: RawDeviceAddress {
+            vendor_id: 0x046d,
+            product_id: 0xc900,
+            usage_page: 0xff43,
+            usage_id: 0x0202,
+            identity: "id:session-node".into(),
+        },
+        display_name: "Brightness-only light".into(),
+        manufacturer: Some("Test".into()),
+        serial_number: None,
+        unit_id: [0; 4],
+        kind: DeviceKind::Light,
+        online: true,
+        capabilities: None,
+        light_capabilities: Some(LightCapabilities {
+            power: false,
+            brightness: Some(
+                LightValueRange::new(0, 100, 1, LightValueUnit::Percent).expect("valid range"),
+            ),
+            ..LightCapabilities::default()
+        }),
+        driver_id: "test-light".into(),
+        registry_model_id: None,
+    };
+    let (commands, mut receiver) = tokio::sync::mpsc::unbounded_channel();
+    let mut state = AppState::with_runtime(
+        Config::default(),
+        &[],
+        &[light],
+        &AssetResolver::new(),
+        &[],
+        ConfigPersistence::MemoryOnly,
+        commands,
+    );
+    let settings = LightSettings::new(false, 37, None);
+
+    state.commit_light(settings);
+
+    assert_eq!(state.light(), settings);
+    assert!(!state.light_enabled());
+    assert!(matches!(
+        receiver.try_recv(),
+        Ok(crate::ipc_client::Command::SetLight(
+            _,
+            openlogi_hid::LightCommand::BrightnessPercent(37),
+            _,
+            _
+        ))
+    ));
+    assert!(receiver.try_recv().is_err());
+}
+
+#[cfg(target_os = "macos")]
+#[test]
+fn camera_automation_preserves_manual_power_and_clears_transient_override() {
+    let light = StandaloneDevice {
+        address: RawDeviceAddress {
+            vendor_id: 0x046d,
+            product_id: 0xc900,
+            usage_page: 0xff43,
+            usage_id: 0x0202,
+            identity: "serial:glow-camera".into(),
+        },
+        display_name: "Litra Glow".into(),
+        manufacturer: Some("Logi".into()),
+        serial_number: Some("glow-camera".into()),
+        unit_id: [0; 4],
+        kind: DeviceKind::Light,
+        online: true,
+        capabilities: None,
+        light_capabilities: Some(LightCapabilities {
+            power: true,
+            ..LightCapabilities::default()
+        }),
+        driver_id: "litra".into(),
+        registry_model_id: Some("8c900".into()),
+    };
+    let (commands, mut receiver) = tokio::sync::mpsc::unbounded_channel();
+    let mut state = AppState::with_runtime(
+        Config::default(),
+        &[],
+        &[light],
+        &AssetResolver::new(),
+        &[],
+        ConfigPersistence::MemoryOnly,
+        commands,
+    );
+    let key = state
+        .current_record()
+        .expect("light record")
+        .config_key
+        .clone();
+    state.config.set_light(
+        &key,
+        LightSettings {
+            enabled: false,
+            auto_camera: true,
+            brightness_percent: 70,
+            temperature_kelvin: None,
+            color: None,
+        },
+    );
+
+    assert!(!state.light_enabled());
+    assert!(state.set_camera_active(true));
+    assert!(state.light_enabled());
+    assert!(!state.light().enabled);
+
+    state.commit_manual_light_power(false);
+    assert!(!state.light_enabled());
+    assert!(matches!(
+        receiver.try_recv(),
+        Ok(crate::ipc_client::Command::SetLightManualPower(
+            _,
+            false,
+            _,
+            _
+        ))
+    ));
+
+    assert!(state.set_camera_active(false));
+    assert!(state.set_camera_active(true));
+    assert!(state.light_enabled());
+    assert!(!state.light().enabled);
+}
+
+#[cfg(target_os = "macos")]
+#[test]
+fn enabling_camera_automation_queues_effective_camera_power() {
+    let light = StandaloneDevice {
+        address: RawDeviceAddress {
+            vendor_id: 0x046d,
+            product_id: 0xc900,
+            usage_page: 0xff43,
+            usage_id: 0x0202,
+            identity: "serial:glow-effective".into(),
+        },
+        display_name: "Litra Glow".into(),
+        manufacturer: Some("Logi".into()),
+        serial_number: Some("glow-effective".into()),
+        unit_id: [0; 4],
+        kind: DeviceKind::Light,
+        online: true,
+        capabilities: None,
+        light_capabilities: Some(LightCapabilities {
+            power: true,
+            ..LightCapabilities::default()
+        }),
+        driver_id: "litra".into(),
+        registry_model_id: Some("8c900".into()),
+    };
+    let (commands, mut receiver) = tokio::sync::mpsc::unbounded_channel();
+    let mut state = AppState::with_runtime(
+        Config::default(),
+        &[],
+        &[light],
+        &AssetResolver::new(),
+        &[],
+        ConfigPersistence::MemoryOnly,
+        commands,
+    );
+    state.set_camera_active(true);
+    let mut settings = state.light();
+    settings.enabled = false;
+    settings.auto_camera = true;
+
+    state.commit_light(settings);
+
+    assert!(matches!(
+        receiver.try_recv(),
+        Ok(crate::ipc_client::Command::SetLight(
+            _,
+            openlogi_hid::LightCommand::Power(true),
+            _,
+            _
+        ))
+    ));
+    assert!(!state.light().enabled);
+    assert!(state.light_enabled());
+}
diff --git a/crates/openlogi-gui/src/windows/settings.rs b/crates/openlogi-gui/src/windows/settings.rs
index f9557f711cfd1886f10a116159dbd984da663a25..584a709572962ac29b6e9b8971581e49b6bed941 100644
--- a/crates/openlogi-gui/src/windows/settings.rs
+++ b/crates/openlogi-gui/src/windows/settings.rs
@@ -355,6 +355,14 @@ impl Render for SettingsView {
     fn render(&mut self, _: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
         let pal = theme::palette(cx);
         let view = cx.entity();
+        // Only surface the Camera permission when a webcam is actually present,
+        // so people without a Logitech camera are never asked for camera access.
+        // Gated to the platforms that register the permission page below (macOS
+        // consent is the AVFoundation gate; Windows has no such page).
+        #[cfg(any(target_os = "macos", target_os = "linux"))]
+        let has_camera = cx
+            .try_global::<AppState>()
+            .is_some_and(AppState::has_camera);
 
         // Filled group boxes use the theme's content-surface token, keeping
         // settings groups distinct from the page without borrowing a control
@@ -371,7 +379,7 @@ impl Render for SettingsView {
         // Registered only where grants exist to manage — see the `mod
         // permissions` cfg for why Windows skips it.
         #[cfg(any(target_os = "macos", target_os = "linux"))]
-        let settings = settings.page(permissions::permissions_page(pal));
+        let settings = settings.page(permissions::permissions_page(pal, has_camera));
         let settings = settings
             .page(appearance::appearance_page(
                 view.clone(),
diff --git a/crates/openlogi-gui/src/windows/settings/permissions.rs b/crates/openlogi-gui/src/windows/settings/permissions.rs
index e8c2974126e9a1b6d0f081e403dee21412800d0a..2eb9cfb0f106403893a4de2ec276f09001075bfe 100644
--- a/crates/openlogi-gui/src/windows/settings/permissions.rs
+++ b/crates/openlogi-gui/src/windows/settings/permissions.rs
@@ -18,14 +18,14 @@ use crate::theme::Typography as _;
     not(any(target_os = "macos", target_os = "linux")),
     allow(unused_variables)
 )]
-pub(super) fn permissions_page(pal: Palette) -> SettingPage {
+pub(super) fn permissions_page(pal: Palette, has_camera: bool) -> SettingPage {
     let page = SettingPage::new(tr!("Permissions"))
         .icon(IconName::Info)
         .resettable(false);
 
     #[cfg(target_os = "macos")]
-    let page = page.group(
-        SettingGroup::new()
+    let page = {
+        let mut group = SettingGroup::new()
             .item(permission_item(
                 "perm-accessibility",
                 tr!("Accessibility"),
@@ -58,8 +58,27 @@ pub(super) fn permissions_page(pal: Palette) -> SettingPage {
                 Permission::Bluetooth,
                 |_| permissions::bluetooth(),
                 pal,
-            )),
-    );
+            ));
+        // Camera access is only worth asking for once a Logitech webcam is
+        // actually connected — it then appears on the main page, and granting
+        // access turns on its live preview.
+        if has_camera {
+            group = group.item(permission_item(
+                "perm-camera",
+                tr!("Camera"),
+                tr!(
+                    "Your Logitech webcam shows up on the main page. Grant access to see its live preview — video never leaves your Mac."
+                ),
+                Permission::Camera,
+                |_| permissions::camera(),
+                pal,
+            ));
+        }
+        page.group(group)
+    };
+
+    #[cfg(not(target_os = "macos"))]
+    let _ = has_camera;
 
     #[cfg(target_os = "linux")]
     let page = page.group(SettingGroup::new().item({
diff --git a/crates/openlogi-hid/Cargo.toml b/crates/openlogi-hid/Cargo.toml
index 9f94c1669829f164da52018af836b384586cbb8d..ab87c20f52af77ede926472a0d92a6812a1d41b0 100644
--- a/crates/openlogi-hid/Cargo.toml
+++ b/crates/openlogi-hid/Cargo.toml
@@ -12,7 +12,7 @@ categories = ["hardware-support", "asynchronous"]
 readme = "README.md"
 
 [dependencies]
-openlogi-core = { path = "../openlogi-core", version = "0.6.23" }
+openlogi-core = { path = "../openlogi-core", version = "0.6.24" }
 hidpp = { workspace = true }
 async-hid = { workspace = true }
 tokio = { workspace = true }
@@ -39,5 +39,9 @@ windows-sys = { workspace = true, features = [
     "Win32_System_IO",
 ] }
 
+[target.'cfg(target_os = "macos")'.dependencies]
+objc2 = "0.6.4"
+objc2-app-kit = { version = "0.3.2", features = ["NSWorkspace", "NSRunningApplication"] }
+
 [lints]
 workspace = true
diff --git a/crates/openlogi-hid/src/backlight.rs b/crates/openlogi-hid/src/backlight.rs
new file mode 100644
index 0000000000000000000000000000000000000000..dc4e477494f4119c8c2ee3cbf696a2188d670a1b
--- /dev/null
+++ b/crates/openlogi-hid/src/backlight.rs
@@ -0,0 +1,146 @@
+//! HID++ `Backlight` (feature `0x1982`) — keyboard backlight control.
+//!
+//! The protocol-level `0x1982` wrapper lives in `openlogi-hidpp`; this module
+//! keeps OpenLogi's IPC/config-facing mode, status, and snapshot types.
+//!
+//! This is the backlight family used by the MX Keys line: a white,
+//! level-adjustable backlight driven by an ambient-light sensor and a hand
+//! proximity sensor. It is distinct from the RGB families (`0x8070`
+//! ColorLedEffects, `0x8080` PerKeyLighting) that [`crate::set_keyboard_color`]
+//! drives — a device exposes one or the other, never both.
+//!
+//! `setBacklightConfig` writes to the device's non-volatile memory, so a
+//! disabled backlight stays disabled across reconnects, host switches, and
+//! power cycles without a daemon re-applying it.
+
+use serde::{Deserialize, Serialize};
+
+/// How the firmware decides the backlight brightness level.
+///
+/// Crosses the agent↔GUI IPC, where serde encodes the variant *index*, so
+/// variant order is wire format — changes require a `PROTOCOL_VERSION` bump
+/// (guarded by `openlogi-agent-core/tests/wire_format.rs`).
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
+pub enum BacklightMode {
+    /// No mode selected.
+    None,
+    /// Level follows the ambient-light sensor.
+    Automatic,
+    /// Level adjusted with the keyboard's own backlight keys. The firmware
+    /// enters this mode on its own; software cannot write it.
+    TemporaryManual,
+    /// Level set by software and held until changed.
+    PermanentManual,
+}
+
+/// Why the backlight is in its current state, as reported by
+/// `getBacklightInfo`.
+///
+/// Crosses the agent↔GUI IPC, where serde encodes the variant *index*, so
+/// variant order is wire format — changes require a `PROTOCOL_VERSION` bump
+/// (guarded by `openlogi-agent-core/tests/wire_format.rs`).
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
+pub enum BacklightStatus {
+    /// Turned off by software — the LEDs stay dark regardless of ambient
+    /// light or hand proximity. This is what [`crate::set_backlight_enabled`]
+    /// with `false` produces.
+    DisabledBySoftware,
+    /// Turned off because the battery is critically low.
+    DisabledByCriticalBattery,
+    /// Following the ambient-light sensor.
+    AlsAutomatic,
+    /// Following the ambient-light sensor, which reads bright enough that the
+    /// LEDs are off.
+    AlsSaturated,
+    /// Holding a level the user picked with the backlight keys.
+    TemporaryManual,
+    /// Holding a level written by software.
+    PermanentManual,
+}
+
+/// Snapshot of a keyboard's backlight, merged from the `0x1982`
+/// `getBacklightConfig` and `getBacklightInfo` responses.
+///
+/// Crosses the agent↔GUI IPC, so field order is wire format — changes require
+/// a `PROTOCOL_VERSION` bump (guarded by
+/// `openlogi-agent-core/tests/wire_format.rs`).
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
+pub struct BacklightState {
+    /// Whether the backlight system is enabled at all. When `false` the
+    /// firmware keeps the LEDs dark no matter what the sensors report, and
+    /// [`Self::status`] reads [`BacklightStatus::DisabledBySoftware`].
+    pub enabled: bool,
+    /// How the level is chosen while the backlight is enabled.
+    pub mode: BacklightMode,
+    /// Why the backlight is in its current state.
+    pub status: BacklightStatus,
+    /// Current brightness level, `0` (off) up to [`Self::nb_levels`] minus one.
+    pub current_level: u8,
+    /// Number of user-selectable brightness levels the device reports.
+    pub nb_levels: u8,
+}
+
+impl BacklightState {
+    /// Whether the LEDs are dark right now, for whatever reason — software
+    /// disable, critical battery, a saturated ambient-light sensor, or a zero
+    /// manual level.
+    #[must_use]
+    pub fn is_dark(self) -> bool {
+        !self.enabled
+            || self.current_level == 0
+            || matches!(
+                self.status,
+                BacklightStatus::DisabledBySoftware
+                    | BacklightStatus::DisabledByCriticalBattery
+                    | BacklightStatus::AlsSaturated
+            )
+    }
+}
+
+#[cfg(test)]
+mod tests {
+    use super::*;
+
+    fn lit() -> BacklightState {
+        BacklightState {
+            enabled: true,
+            mode: BacklightMode::Automatic,
+            status: BacklightStatus::AlsAutomatic,
+            current_level: 4,
+            nb_levels: 8,
+        }
+    }
+
+    #[test]
+    fn a_lit_backlight_is_not_dark() {
+        assert!(!lit().is_dark());
+    }
+
+    #[test]
+    fn software_disable_reads_as_dark() {
+        let state = BacklightState {
+            enabled: false,
+            status: BacklightStatus::DisabledBySoftware,
+            ..lit()
+        };
+        assert!(state.is_dark());
+    }
+
+    #[test]
+    fn a_zero_level_reads_as_dark_even_while_enabled() {
+        let state = BacklightState {
+            current_level: 0,
+            ..lit()
+        };
+        assert!(state.is_dark());
+    }
+
+    #[test]
+    fn a_saturated_ambient_sensor_reads_as_dark() {
+        let state = BacklightState {
+            status: BacklightStatus::AlsSaturated,
+            ..lit()
+        };
+        assert!(state.is_dark());
+    }
+}
diff --git a/crates/openlogi-hid/src/channel_pool.rs b/crates/openlogi-hid/src/channel_pool.rs
new file mode 100644
index 0000000000000000000000000000000000000000..5bce4453f839b738fa69e60dcb9c89946d4a10f8
--- /dev/null
+++ b/crates/openlogi-hid/src/channel_pool.rs
@@ -0,0 +1,47 @@
+//! Shared HID++ channels for long-running agent sessions.
+
+use std::sync::{Arc, Weak};
+
+use hidpp::channel::HidppChannel;
+use tokio::sync::Mutex;
+
+use crate::route::{DeviceRoute, open_route_channel};
+
+/// Reuses one open HID++ channel for routes on the same receiver.
+#[derive(Clone, Default)]
+pub struct ChannelPool {
+    entries: Arc<Mutex<Vec<PoolEntry>>>,
+}
+
+struct PoolEntry {
+    route: DeviceRoute,
+    channel: Weak<HidppChannel>,
+}
+
+impl ChannelPool {
+    /// Return a shared channel reaching `route`, opening it when necessary.
+    pub async fn open(
+        &self,
+        route: &DeviceRoute,
+    ) -> Result<Option<Arc<HidppChannel>>, async_hid::HidError> {
+        let mut entries = self.entries.lock().await;
+        entries.retain(|entry| entry.channel.strong_count() > 0);
+        if let Some(channel) = entries.iter().find_map(|entry| {
+            entry
+                .route
+                .shares_transport(route)
+                .then(|| entry.channel.upgrade())
+                .flatten()
+        }) {
+            return Ok(Some(channel));
+        }
+        let Some(channel) = open_route_channel(route).await? else {
+            return Ok(None);
+        };
+        entries.push(PoolEntry {
+            route: route.clone(),
+            channel: Arc::downgrade(&channel),
+        });
+        Ok(Some(channel))
+    }
+}
diff --git a/crates/openlogi-hid/src/channel_registry.rs b/crates/openlogi-hid/src/channel_registry.rs
new file mode 100644
index 0000000000000000000000000000000000000000..7c2f71c9c88bf511ef6c038bc8ebc25ebebb58b0
--- /dev/null
+++ b/crates/openlogi-hid/src/channel_registry.rs
@@ -0,0 +1,363 @@
+//! Registry of HID++ channels owned by the persistent inventory enumerator.
+
+use std::collections::HashSet;
+use std::hash::Hash;
+use std::sync::{Arc, PoisonError, RwLock};
+
+use async_hid::DeviceId;
+use hidpp::channel::HidppChannel;
+
+use crate::{DeviceRoute, SharedChannel};
+
+struct Publication<Node, Channel> {
+    node: Node,
+    sequence: u64,
+    routes: Vec<DeviceRoute>,
+    channel: Channel,
+}
+
+struct NodeRegistry<Node, Channel> {
+    publications: Vec<Publication<Node, Channel>>,
+    next_sequence: u64,
+}
+
+impl<Node, Channel> Default for NodeRegistry<Node, Channel> {
+    fn default() -> Self {
+        Self {
+            publications: Vec::new(),
+            next_sequence: 0,
+        }
+    }
+}
+
+impl<Node: Eq, Channel> NodeRegistry<Node, Channel> {
+    fn replace_node(
+        &mut self,
+        node: Node,
+        routes: impl IntoIterator<Item = DeviceRoute>,
+        channel: Channel,
+    ) {
+        let routes = routes.into_iter().collect();
+        if let Some(publication) = self
+            .publications
+            .iter_mut()
+            .find(|publication| publication.node == node)
+        {
+            publication.routes = routes;
+            publication.channel = channel;
+            return;
+        }
+
+        let sequence = self.next_sequence;
+        self.next_sequence = self.next_sequence.wrapping_add(1);
+        self.publications.push(Publication {
+            node,
+            sequence,
+            routes,
+            channel,
+        });
+    }
+
+    fn remove_node(&mut self, node: &Node) {
+        self.publications
+            .retain(|publication| publication.node != *node);
+    }
+
+    fn lookup(&self, route: &DeviceRoute) -> Option<&Channel> {
+        self.publications
+            .iter()
+            .filter(|publication| publication.routes.contains(route))
+            .min_by_key(|publication| publication.sequence)
+            .map(|publication| &publication.channel)
+    }
+
+    fn any_current(&self, mut predicate: impl FnMut(&DeviceRoute, &Channel) -> bool) -> bool {
+        self.publications.iter().any(|publication| {
+            publication.routes.iter().any(|route| {
+                predicate(route, &publication.channel)
+                    && self
+                        .lookup(route)
+                        .is_some_and(|winner| std::ptr::eq(winner, &raw const publication.channel))
+            })
+        })
+    }
+}
+
+impl<Node: Eq + Hash, Channel> NodeRegistry<Node, Channel> {
+    fn retain_nodes(&mut self, nodes: &HashSet<Node>) {
+        self.publications
+            .retain(|publication| nodes.contains(&publication.node));
+    }
+}
+
+struct Registry<Node, Channel> {
+    state: Arc<RwLock<NodeRegistry<Node, Channel>>>,
+}
+
+impl<Node, Channel> Clone for Registry<Node, Channel> {
+    fn clone(&self) -> Self {
+        Self {
+            state: Arc::clone(&self.state),
+        }
+    }
+}
+
+impl<Node, Channel> Default for Registry<Node, Channel> {
+    fn default() -> Self {
+        Self {
+            state: Arc::new(RwLock::new(NodeRegistry::default())),
+        }
+    }
+}
+
+impl<Node: Eq, Channel> Registry<Node, Channel> {
+    fn replace_node(
+        &self,
+        node: Node,
+        routes: impl IntoIterator<Item = DeviceRoute>,
+        channel: Channel,
+    ) {
+        self.state
+            .write()
+            .unwrap_or_else(PoisonError::into_inner)
+            .replace_node(node, routes, channel);
+    }
+
+    fn remove_node(&self, node: &Node) {
+        self.state
+            .write()
+            .unwrap_or_else(PoisonError::into_inner)
+            .remove_node(node);
+    }
+}
+
+impl<Node: Eq + Hash, Channel> Registry<Node, Channel> {
+    fn retain_nodes(&self, nodes: &HashSet<Node>) {
+        self.state
+            .write()
+            .unwrap_or_else(PoisonError::into_inner)
+            .retain_nodes(nodes);
+    }
+}
+
+impl<Node: Eq, Channel: Clone> Registry<Node, Channel> {
+    fn lookup(&self, route: &DeviceRoute) -> Option<Channel> {
+        self.state.read().ok()?.lookup(route).cloned()
+    }
+}
+
+impl<Node: Eq, Channel> Registry<Node, Channel> {
+    fn any_current(&self, predicate: impl FnMut(&DeviceRoute, &Channel) -> bool) -> bool {
+        self.state
+            .read()
+            .ok()
+            .is_some_and(|state| state.any_current(predicate))
+    }
+}
+
+/// Channels already opened and owned by the persistent inventory enumerator.
+///
+/// Publications are keyed by OS HID node internally and selected by exact
+/// [`DeviceRoute`]. When identical direct devices publish the same route, the
+/// oldest live node wins until it is removed.
+#[derive(Clone, Default)]
+pub struct ChannelRegistry {
+    inner: Registry<DeviceId, Arc<HidppChannel>>,
+}
+
+impl ChannelRegistry {
+    /// Replace every route published by `node`, preserving that node's original
+    /// collision priority when it was already present.
+    pub(crate) fn replace_node(
+        &self,
+        node: DeviceId,
+        routes: impl IntoIterator<Item = DeviceRoute>,
+        channel: Arc<HidppChannel>,
+    ) {
+        self.inner.replace_node(node, routes, channel);
+    }
+
+    /// Remove every route and channel reference owned by `node`.
+    pub(crate) fn remove_node(&self, node: &DeviceId) {
+        self.inner.remove_node(node);
+    }
+
+    /// Remove publications for nodes absent from the current OS enumeration.
+    pub(crate) fn retain_nodes(&self, nodes: &HashSet<DeviceId>) {
+        self.inner.retain_nodes(nodes);
+    }
+
+    /// Clone the current exact-route winner.
+    #[must_use]
+    pub fn lookup(&self, route: &DeviceRoute) -> Option<SharedChannel> {
+        self.inner
+            .lookup(route)
+            .map(|channel| SharedChannel::new(channel, route.clone()))
+    }
+
+    /// Whether `shared` is still the winning publication for its exact route
+    /// and points to the same underlying connection.
+    #[must_use]
+    pub fn is_current(&self, shared: &SharedChannel) -> bool {
+        self.inner.any_current(|route, channel| {
+            shared.matches(route) && Arc::ptr_eq(channel, shared.channel())
+        })
+    }
+}
+
+#[cfg(test)]
+mod tests {
+    use std::collections::HashSet;
+    use std::panic::{AssertUnwindSafe, catch_unwind};
+    use std::sync::Arc;
+
+    use crate::DeviceRoute;
+
+    use super::{PoisonError, Registry};
+
+    impl<Node, Channel> Registry<Node, Channel> {
+        fn poison_for_test(&self) {
+            let _ = catch_unwind(AssertUnwindSafe(|| {
+                let _guard = self.state.write().unwrap_or_else(PoisonError::into_inner);
+                panic!("poison registry for test");
+            }));
+        }
+    }
+
+    impl<Node: Eq, Channel: Clone> Registry<Node, Channel> {
+        fn publisher_lookup_for_test(&self, route: &DeviceRoute) -> Option<Channel> {
+            self.state
+                .read()
+                .unwrap_or_else(PoisonError::into_inner)
+                .lookup(route)
+                .cloned()
+        }
+    }
+
+    fn direct(product_id: u16) -> DeviceRoute {
+        DeviceRoute::Direct {
+            vendor_id: 0x046d,
+            product_id,
+        }
+    }
+
+    fn bolt(uid: &str, slot: u8) -> DeviceRoute {
+        DeviceRoute::Bolt {
+            receiver_uid: uid.into(),
+            slot,
+        }
+    }
+
+    #[test]
+    fn lookup_rejects_every_non_exact_route_field() {
+        let registry = Registry::<u8, &'static str>::default();
+        registry.replace_node(1, [bolt("AABB", 2)], "channel-a");
+
+        assert_eq!(registry.lookup(&bolt("AABB", 2)), Some("channel-a"));
+        assert_eq!(registry.lookup(&bolt("AABB", 3)), None);
+        assert_eq!(registry.lookup(&bolt("CCDD", 2)), None);
+        assert_eq!(registry.lookup(&direct(0xb35b)), None);
+    }
+
+    #[test]
+    fn one_node_can_publish_multiple_receiver_slots() {
+        let registry = Registry::<u8, &'static str>::default();
+        registry.replace_node(1, [bolt("AABB", 1), bolt("AABB", 4)], "receiver-channel");
+
+        assert_eq!(registry.lookup(&bolt("AABB", 1)), Some("receiver-channel"));
+        assert_eq!(registry.lookup(&bolt("AABB", 4)), Some("receiver-channel"));
+    }
+
+    #[test]
+    fn current_check_uses_only_the_exact_winning_publication() {
+        let route = direct(0xb35b);
+        let registry = Registry::<u8, &'static str>::default();
+        registry.replace_node(1, [route.clone()], "a");
+        registry.replace_node(2, [route.clone()], "b");
+
+        assert!(
+            registry.any_current(|candidate, channel| { candidate == &route && *channel == "a" })
+        );
+        assert!(
+            !registry.any_current(|candidate, channel| { candidate == &route && *channel == "b" })
+        );
+    }
+
+    #[test]
+    fn same_route_with_a_different_arc_is_not_current() {
+        let route = direct(0xb35b);
+        let published = Arc::new(());
+        let stale = Arc::new(());
+        let registry = Registry::<u8, Arc<()>>::default();
+        registry.replace_node(1, [route.clone()], Arc::clone(&published));
+
+        assert!(registry.any_current(|candidate, channel| {
+            candidate == &route && Arc::ptr_eq(channel, &published)
+        }));
+        assert!(!registry.any_current(|candidate, channel| {
+            candidate == &route && Arc::ptr_eq(channel, &stale)
+        }));
+    }
+
+    #[test]
+    fn replacing_winner_preserves_priority_then_removal_promotes_next_owner() {
+        let route = direct(0xb35b);
+        let registry = Registry::<u8, &'static str>::default();
+        registry.replace_node(1, [route.clone()], "a-v1");
+        registry.replace_node(2, [route.clone()], "b");
+
+        assert_eq!(registry.lookup(&route), Some("a-v1"));
+
+        registry.replace_node(1, [route.clone()], "a-v2");
+        assert_eq!(registry.lookup(&route), Some("a-v2"));
+
+        registry.remove_node(&1);
+        assert_eq!(registry.lookup(&route), Some("b"));
+    }
+
+    #[test]
+    fn replacing_one_node_is_atomic_and_does_not_touch_another() {
+        let registry = Registry::<u8, &'static str>::default();
+        registry.replace_node(1, [bolt("A", 1), bolt("A", 2)], "a");
+        registry.replace_node(2, [bolt("B", 1)], "b");
+
+        registry.replace_node(1, [bolt("A", 3)], "a-new");
+
+        assert_eq!(registry.lookup(&bolt("A", 1)), None);
+        assert_eq!(registry.lookup(&bolt("A", 2)), None);
+        assert_eq!(registry.lookup(&bolt("A", 3)), Some("a-new"));
+        assert_eq!(registry.lookup(&bolt("B", 1)), Some("b"));
+    }
+
+    #[test]
+    fn retaining_nodes_removes_only_absent_owners() {
+        let registry = Registry::<u8, &'static str>::default();
+        registry.replace_node(1, [direct(0xb35b)], "a");
+        registry.replace_node(2, [direct(0xb36b)], "b");
+
+        registry.retain_nodes(&HashSet::from([2]));
+
+        assert_eq!(registry.lookup(&direct(0xb35b)), None);
+        assert_eq!(registry.lookup(&direct(0xb36b)), Some("b"));
+    }
+
+    #[test]
+    fn poisoned_read_fails_closed_but_publishers_can_clean_up() {
+        let registry = Registry::<u8, &'static str>::default();
+        registry.replace_node(1, [direct(0xb35b)], "a");
+        registry.poison_for_test();
+
+        assert_eq!(registry.lookup(&direct(0xb35b)), None);
+        assert!(!registry.any_current(|_, _| true));
+
+        registry.remove_node(&1);
+        registry.replace_node(2, [direct(0xb36b)], "b");
+        registry.retain_nodes(&HashSet::from([2]));
+
+        assert_eq!(registry.publisher_lookup_for_test(&direct(0xb35b)), None);
+        assert_eq!(
+            registry.publisher_lookup_for_test(&direct(0xb36b)),
+            Some("b")
+        );
+    }
+}
diff --git a/crates/openlogi-hid/src/gesture.rs b/crates/openlogi-hid/src/gesture.rs
index 2699aa079c9eac0df155b3e415cb4edce01f98a7..1bc2b69aa977b87d2bbbc125a6eba5c685261cbb 100644
--- a/crates/openlogi-hid/src/gesture.rs
+++ b/crates/openlogi-hid/src/gesture.rs
@@ -4,7 +4,9 @@
 //!
 //! [`run_capture_session`] holds a single HID++ channel open for one device,
 //! enables diversion on whichever of those controls it exposes, registers one
-//! message listener, and restores every control's default mapping on shutdown.
+//! message listener, and restores every control's default mapping on graceful
+//! shutdown. Registry revocation instead releases the stale channel without
+//! sending cleanup traffic through it.
 //! Using one channel matters: a second channel to the same device would split
 //! its input-report stream, so all captured controls share this session.
 //!
@@ -17,6 +19,7 @@
 //! defaults (click bound, rotation rebound, or sensitivity changed).
 
 use std::sync::{Arc, Mutex, PoisonError, RwLock};
+use std::time::{Duration, Instant};
 
 use hidpp::{
     channel::HidppChannel,
@@ -30,16 +33,50 @@ use thiserror::Error;
 use tokio::sync::{mpsc, oneshot};
 use tracing::{debug, info, warn};
 
+use crate::channel_registry::ChannelRegistry;
 use crate::reprog_controls::{self, RawControlEvent, ReprogControlsV4};
 use crate::route::{DeviceRoute, open_route_channel};
 use crate::thumbwheel::{self, Thumbwheel};
 use crate::write::SharedChannel;
 
+/// Return the PID of the frontmost application at this instant.
+/// Called on the HID++ listener thread — before any async dispatch delay —
+/// so the PID reflects the app that was active when the button was pressed.
+/// Returns `None` on non-macOS platforms or if no frontmost app exists.
+fn frontmost_pid() -> Option<i32> {
+    #[cfg(target_os = "macos")]
+    {
+        use objc2::rc::autoreleasepool;
+        use objc2_app_kit::NSWorkspace;
+        autoreleasepool(|_| {
+            NSWorkspace::sharedWorkspace()
+                .frontmostApplication()
+                .map(|a| a.processIdentifier())
+        })
+    }
+    #[cfg(not(target_os = "macos"))]
+    {
+        None
+    }
+}
+
 /// Shared slot holding the active capture session's open channel, so DPI /
 /// SmartShift writes can reuse it instead of opening a fresh one. `None`
 /// whenever no session is connected.
 pub type CaptureChannel = Arc<RwLock<Option<SharedChannel>>>;
 
+/// Why an active capture session is stopping.
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+pub enum CaptureStop {
+    /// The target/configuration changed while the channel is still current, so
+    /// diverted controls must be restored before the session exits.
+    Graceful,
+    /// Inventory revoked or replaced the underlying connection, or the
+    /// transport went down. Clear local ownership without restore writes —
+    /// the device has already discarded volatile diversion state.
+    Revoked,
+}
+
 /// One input captured from the active device.
 #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
 pub enum CapturedInput {
@@ -47,8 +84,12 @@ pub enum CapturedInput {
     Gesture(GestureDirection),
     /// A diverted button was pressed — the DPI/ModeShift button
     /// ([`ButtonId::DpiToggle`]) or the thumb-wheel single tap
-    /// ([`ButtonId::Thumbwheel`]).
-    ButtonPressed(ButtonId),
+    /// ([`ButtonId::Thumbwheel`]). The optional `frontmost_pid` is the
+    /// PID of the frontmost application at the instant the button was pressed
+    /// (captured on the listener thread to avoid timing races on dispatch).
+    /// The PID is skipped in serialization — it is a dispatch hint, not part
+    /// of the stable wire format.
+    ButtonPressed(ButtonId, #[serde(skip)] Option<i32>),
     /// Thumb-wheel rotation to re-synthesise as horizontal scroll, in the
     /// wheel's `diverted_res` increments. Emitted while the wheel is diverted
     /// (click bound, rotation rebound, or sensitivity changed).
@@ -70,6 +111,40 @@ pub enum GestureError {
     /// A HID++ feature call returned an error; inner string carries context.
     #[error("HID++ protocol error: {0}")]
     Hidpp(String),
+    /// An established HID channel disconnected while capture was active.
+    #[error("HID channel disconnected")]
+    ChannelDisconnected,
+}
+
+const CAPTURE_HEALTH_POLL: Duration = Duration::from_secs(1);
+
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+enum CaptureExit {
+    Stopped(CaptureStop),
+    Disconnected,
+}
+
+async fn wait_for_capture_exit<Shutdown>(
+    chan: &HidppChannel,
+    shutdown: Shutdown,
+    poll_period: Duration,
+) -> CaptureExit
+where
+    Shutdown: std::future::Future<Output = CaptureStop>,
+{
+    tokio::pin!(shutdown);
+    loop {
+        tokio::select! {
+            stop = &mut shutdown => {
+                return CaptureExit::Stopped(stop);
+            }
+            () = tokio::time::sleep(poll_period) => {
+                if !chan.is_connected() {
+                    return CaptureExit::Disconnected;
+                }
+            }
+        }
+    }
 }
 
 /// Movement + button state accumulated across messages. Lives behind a `Mutex`
@@ -81,8 +156,31 @@ struct CaptureAccum {
     /// Whether any DPI/ModeShift control was held in the last event — for
     /// rising-edge press detection.
     dpi_down: bool,
+    /// Whether any Back control was held in the last event.
+    back_down: bool,
+    /// Whether any Forward control was held in the last event.
+    forward_down: bool,
+    /// Timestamp of the last Back press dispatch — for debounce.
+    last_back: Option<Instant>,
+    /// Timestamp of the last Forward press dispatch — for debounce.
+    last_forward: Option<Instant>,
 }
 
+/// Minimum time between two Back or Forward dispatches from the same HID++
+/// CID. The MX Vertical sends multiple DivertedButtons frames per physical
+/// click as the CID flag bounces in/out within a single press (~50-100ms).
+/// 150ms suppresses intra-press bounce while allowing intentional rapid
+/// double-clicks (typically ≥200ms apart).
+///
+/// Note: on devices that expose buttons through both HID++ diversion and the
+/// OS CGEventTap path (e.g. MX Vertical), a single press can fire both the
+/// gesture watcher and the hook. The gesture watcher uses AXPress (Safari-safe);
+/// the hook path uses Cmd+[/] (Chrome-safe, no-op in Safari). This is harmless
+/// in practice — Safari only responds to AXPress, Chrome only responds to
+/// keyboard shortcuts, and the two actions don't double-navigate. A shared
+/// cross-path debounce (`TODO`) would be cleaner but is not required.
+const BACK_FORWARD_DEBOUNCE: Duration = Duration::from_millis(150);
+
 /// Capture the gesture button, DPI/ModeShift button, and (when
 /// `capture_thumbwheel`) the thumb wheel on `route` until `shutdown` resolves,
 /// forwarding each event to `sink`.
@@ -96,8 +194,11 @@ struct CaptureAccum {
 ///
 /// Opens and holds one HID++ channel, diverts whichever of those controls the
 /// device exposes, and listens. Returns once `shutdown` fires (or its sender is
-/// dropped), after restoring every diverted control. Setup errors are returned;
-/// failures to restore on the way out are logged, not propagated.
+/// dropped), or when the established channel disconnects. A normal shutdown
+/// restores every diverted control; [`CaptureStop::Revoked`] and a disconnect
+/// skip restoration because the device has already reset its volatile mappings.
+/// Setup errors are returned; failures to restore on the way out are logged,
+/// not propagated.
 pub async fn run_capture_session(
     route: DeviceRoute,
     capture_thumbwheel: bool,
@@ -109,28 +210,127 @@ pub async fn run_capture_session(
     let chan = open_route_channel(&route)
         .await?
         .ok_or(GestureError::DeviceNotFound)?;
+    let shared = SharedChannel::new(chan, route.clone());
+    run_capture_session_on(
+        route,
+        shared,
+        capture_thumbwheel,
+        divert_gesture_button,
+        sink,
+        graceful_shutdown(shutdown),
+        channel_slot,
+    )
+    .await
+}
+
+/// Run standalone capture with an explicit graceful-or-revoked stop reason.
+///
+/// This is the reason-aware counterpart to [`run_capture_session`]. A
+/// [`CaptureStop::Graceful`] shutdown restores diverted controls;
+/// [`CaptureStop::Revoked`] releases local ownership without writing through
+/// the stale connection. Dropping the shutdown sender is treated as graceful.
+pub async fn run_capture_session_with_stop_reason(
+    route: DeviceRoute,
+    capture_thumbwheel: bool,
+    divert_gesture_button: bool,
+    sink: mpsc::UnboundedSender<CapturedInput>,
+    shutdown: oneshot::Receiver<CaptureStop>,
+    channel_slot: CaptureChannel,
+) -> Result<(), GestureError> {
+    let chan = open_route_channel(&route)
+        .await?
+        .ok_or(GestureError::DeviceNotFound)?;
+    let shared = SharedChannel::new(chan, route.clone());
+    run_capture_session_on(
+        route,
+        shared,
+        capture_thumbwheel,
+        divert_gesture_button,
+        sink,
+        explicit_shutdown(shutdown),
+        channel_slot,
+    )
+    .await
+}
+
+/// Run capture on the exact channel currently published by `registry`.
+///
+/// A registry miss returns [`GestureError::DeviceNotFound`] without falling
+/// back to route enumeration/opening; the Agent watcher retries after a later
+/// inventory publication.
+pub async fn run_capture_session_with_registry(
+    route: DeviceRoute,
+    capture_thumbwheel: bool,
+    divert_gesture_button: bool,
+    sink: mpsc::UnboundedSender<CapturedInput>,
+    shutdown: oneshot::Receiver<CaptureStop>,
+    channel_slot: CaptureChannel,
+    registry: &ChannelRegistry,
+) -> Result<(), GestureError> {
+    let shared = registry
+        .lookup(&route)
+        .ok_or(GestureError::DeviceNotFound)?;
+    run_capture_session_on(
+        route,
+        shared,
+        capture_thumbwheel,
+        divert_gesture_button,
+        sink,
+        explicit_shutdown(shutdown),
+        channel_slot,
+    )
+    .await
+}
+
+async fn graceful_shutdown(shutdown: oneshot::Receiver<()>) -> CaptureStop {
+    let _ = shutdown.await;
+    CaptureStop::Graceful
+}
+
+async fn explicit_shutdown(shutdown: oneshot::Receiver<CaptureStop>) -> CaptureStop {
+    shutdown.await.unwrap_or(CaptureStop::Graceful)
+}
+
+async fn run_capture_session_on<Shutdown>(
+    route: DeviceRoute,
+    shared: SharedChannel,
+    capture_thumbwheel: bool,
+    divert_gesture_button: bool,
+    sink: mpsc::UnboundedSender<CapturedInput>,
+    shutdown: Shutdown,
+    channel_slot: CaptureChannel,
+) -> Result<(), GestureError>
+where
+    Shutdown: std::future::Future<Output = CaptureStop>,
+{
+    let chan = Arc::clone(shared.channel());
     let device_index = route.device_index();
-    let trace_legacy_thumbwheel = std::env::var_os("OPENLOGI_TRACE_GESTURE2_THUMBWHEEL").is_some();
+    // Publish before the first setup await so the watcher can validate exact
+    // channel identity on its next poll, even while arming is still in flight.
+    replace_capture_slot(&channel_slot, Some(shared));
     let armed = arm_controls(
         &chan,
         device_index,
         capture_thumbwheel,
         divert_gesture_button,
-        trace_legacy_thumbwheel,
+        legacy_thumbwheel_trace_requested(),
     )
-    .await?;
-
-    // Publish this device's open channel so DPI/SmartShift writes reuse it
-    // instead of opening their own. Cleared on the way out.
-    if let Ok(mut slot) = channel_slot.write() {
-        *slot = Some(SharedChannel::new(Arc::clone(&chan), route.clone()));
-    }
+    .await;
+    let armed = match armed {
+        Ok(armed) => armed,
+        Err(error) => {
+            replace_capture_slot(&channel_slot, None);
+            return Err(error);
+        }
+    };
 
     let accum = Arc::new(Mutex::new(CaptureAccum::default()));
     let reprog_index = armed.reprog.as_ref().map(|(_, idx)| *idx);
     let thumb_index = armed.thumb.as_ref().map(|(_, idx)| *idx);
     let legacy_thumb_index = armed.legacy_thumb.as_ref().map(|legacy| legacy.index);
     let dpi_set = armed.dpi_cids.clone();
+    let back_set = armed.back_cids.clone();
+    let forward_set = armed.forward_cids.clone();
     let listener = chan.add_msg_listener_guarded({
         let accum = Arc::clone(&accum);
         let sink = sink.clone();
@@ -139,19 +339,7 @@ pub async fn run_capture_session(
                 return;
             }
             let msg = v20::Message::from(raw);
-            if trace_legacy_thumbwheel
-                && let Some(idx) = legacy_thumb_index
-                && msg.header().device_index == device_index
-                && msg.header().feature_index == idx
-            {
-                let header = msg.header();
-                info!(
-                    feature_index = header.feature_index,
-                    function_id = header.function_id.to_lo(),
-                    software_id = header.software_id.to_lo(),
-                    payload = ?msg.extend_payload(),
-                    "legacy Gestures2 thumbwheel raw event"
-                );
+            if log_legacy_thumbwheel_packet(&msg, device_index, legacy_thumb_index) {
                 return;
             }
             if let Some(idx) = reprog_index
@@ -160,14 +348,14 @@ pub async fn run_capture_session(
                 // Recover the guard even if a prior holder panicked — the
                 // critical section is panic-free, so the data is consistent.
                 let mut acc = accum.lock().unwrap_or_else(PoisonError::into_inner);
-                handle_reprog(&mut acc, event, &dpi_set, &sink);
+                handle_reprog(&mut acc, event, &dpi_set, &back_set, &forward_set, &sink);
                 return;
             }
             if let Some(idx) = thumb_index
                 && let Some(event) = thumbwheel::decode_event(&msg, device_index, idx)
             {
                 if event.single_tap {
-                    let _ = sink.send(CapturedInput::ButtonPressed(ButtonId::Thumbwheel));
+                    let _ = sink.send(CapturedInput::ButtonPressed(ButtonId::Thumbwheel, None));
                 }
                 if event.rotation != 0 {
                     let _ = sink.send(CapturedInput::Scroll(event.rotation));
@@ -180,19 +368,84 @@ pub async fn run_capture_session(
         index = device_index,
         gesture = armed.gesture_diverted,
         dpi_buttons = armed.dpi_cids.len(),
+        back_buttons = armed.back_cids.len(),
+        forward_buttons = armed.forward_cids.len(),
         thumbwheel = armed.thumb.is_some(),
-        legacy_thumbwheel_trace = armed.legacy_thumb.is_some(),
         "control capture active"
     );
-    let _ = shutdown.await;
+    let exit = wait_for_capture_exit(&chan, shutdown, CAPTURE_HEALTH_POLL).await;
+
+    drop(listener);
+    replace_capture_slot(&channel_slot, None);
+    match exit {
+        CaptureExit::Stopped(CaptureStop::Graceful) => {
+            armed.disarm().await;
+            debug!(index = device_index, "control capture stopped");
+            Ok(())
+        }
+        CaptureExit::Stopped(CaptureStop::Revoked) => {
+            debug!(
+                index = device_index,
+                "control capture abandoned after reconnect"
+            );
+            Ok(())
+        }
+        CaptureExit::Disconnected => {
+            debug!(index = device_index, "control capture channel disconnected");
+            Err(GestureError::ChannelDisconnected)
+        }
+    }
+}
+
+fn replace_capture_slot(slot: &CaptureChannel, value: Option<SharedChannel>) {
+    *slot.write().unwrap_or_else(PoisonError::into_inner) = value;
+}
 
+#[cfg_attr(
+    not(test),
+    allow(dead_code, reason = "used by gesture session unit tests")
+)]
+async fn teardown_capture<Listener, Clear, Disarm, DisarmFuture>(
+    clear: Clear,
+    listener: Listener,
+    stop: CaptureStop,
+    disarm: Disarm,
+) where
+    Clear: FnOnce(),
+    Disarm: FnOnce() -> DisarmFuture,
+    DisarmFuture: std::future::Future<Output = ()>,
+{
+    clear();
     drop(listener);
-    if let Ok(mut slot) = channel_slot.write() {
-        *slot = None;
+    if stop == CaptureStop::Graceful {
+        disarm().await;
     }
-    armed.disarm().await;
-    debug!(index = device_index, "control capture stopped");
-    Ok(())
+}
+
+fn legacy_thumbwheel_trace_requested() -> bool {
+    std::env::var_os("OPENLOGI_TRACE_GESTURE2_THUMBWHEEL").is_some()
+}
+
+fn log_legacy_thumbwheel_packet(
+    msg: &v20::Message,
+    device_index: u8,
+    feature_index: Option<u8>,
+) -> bool {
+    let Some(feature_index) = feature_index else {
+        return false;
+    };
+    if msg.header().device_index != device_index || msg.header().feature_index != feature_index {
+        return false;
+    }
+    let header = msg.header();
+    info!(
+        feature_index = header.feature_index,
+        function_id = header.function_id.to_lo(),
+        software_id = header.software_id.to_lo(),
+        payload = ?msg.extend_payload(),
+        "legacy Gestures2 thumbwheel raw event"
+    );
+    true
 }
 
 /// The set of controls a session has diverted, kept so they can be handed back
@@ -204,20 +457,23 @@ struct ArmedControls {
     gesture_diverted: bool,
     /// DPI/ModeShift CIDs diverted as plain buttons.
     dpi_cids: Vec<u16>,
+    /// Back button CIDs diverted as plain buttons.
+    back_cids: Vec<u16>,
+    /// Forward button CIDs diverted as plain buttons.
+    forward_cids: Vec<u16>,
     /// `0x2150` accessor + feature index, present when the thumb wheel is
     /// diverted.
     thumb: Option<(Thumbwheel, u8)>,
     /// Diagnostic-only `0x6501` diversion for old MX thumb wheels. The packet
     /// format is not decoded yet; this exists only while collecting real-device
-    /// traces needed to replace the unsafe source-less OS-hook fallback.
+    /// traces for a native HID++ decoder.
     legacy_thumb: Option<LegacyThumbwheelTrace>,
 }
 
 struct LegacyThumbwheelTrace {
     feature: Gestures2Feature,
     index: u8,
-    /// We only restore when this process changed the state. If another tool had
-    /// already diverted the gesture, leave that ownership untouched.
+    /// Restore only when this process changed the state.
     restore_native: bool,
 }
 
@@ -234,6 +490,15 @@ impl ArmedControls {
             for &cid in &self.dpi_cids {
                 restore(rc.set_cid_reporting(cid, false, false).await, "DPI button");
             }
+            for &cid in &self.back_cids {
+                restore(rc.set_cid_reporting(cid, false, false).await, "Back button");
+            }
+            for &cid in &self.forward_cids {
+                restore(
+                    rc.set_cid_reporting(cid, false, false).await,
+                    "Forward button",
+                );
+            }
         }
         if let Some((tw, _)) = self.thumb.as_ref() {
             restore(tw.set_reporting(false, false).await, "thumb wheel");
@@ -253,6 +518,54 @@ impl ArmedControls {
     }
 }
 
+/// Arm the dedicated HID++ `0x2150` thumbwheel when available.
+async fn arm_modern_thumbwheel(
+    device: &Device,
+    chan: &Arc<HidppChannel>,
+    slot: u8,
+    capture_thumbwheel: bool,
+) -> Result<Option<(Thumbwheel, u8)>, GestureError> {
+    let mut thumb = None;
+    if capture_thumbwheel
+        && let Some(info) = device
+            .root()
+            .get_feature(thumbwheel::FEATURE_ID)
+            .await
+            .map_err(|e| GestureError::Hidpp(format!("{e:?}")))?
+    {
+        let tw = Thumbwheel::new(Arc::clone(chan), slot, info.index);
+        // Consume the getInfo error here, before the next await: Hidpp20Error
+        // isn't Send, so holding it across an await would make this future
+        // (spawned on tokio) non-Send.
+        let supports_single_tap = match tw.get_info().await {
+            Ok(twinfo) => twinfo.supports_single_tap,
+            Err(e) => {
+                warn!(error = ?e, "thumb wheel getInfo failed");
+                false
+            }
+        };
+        // Divert whenever capture was requested: rotation rebinds and the
+        // sensitivity multiplier need the diverted event stream even on wheels
+        // that report no single-tap capability (e.g. MX Master 4) — lacking the
+        // tap only means a bound click can never fire.
+        if !supports_single_tap {
+            debug!("thumb wheel reports no single tap — click not capturable");
+        }
+        // Use warn+continue rather than ? so a thumbwheel setup failure
+        // doesn't abort the whole session and leave already-diverted
+        // Back/Forward/DPI controls stuck with no capture session to
+        // restore them.
+        match tw.set_reporting(true, false).await {
+            Ok(()) => thumb = Some((tw, info.index)),
+            Err(e) => {
+                warn!(error = ?e, "thumb wheel set_reporting failed — skipping click capture");
+            }
+        }
+    }
+
+    Ok(thumb)
+}
+
 /// Arm diagnostic-only diversion for the legacy `Gestures2` thumb wheel.
 async fn arm_legacy_thumbwheel_trace(
     device: &Device,
@@ -323,6 +636,8 @@ async fn arm_controls(
     let mut reprog: Option<(ReprogControlsV4, u8)> = None;
     let mut gesture_diverted = false;
     let mut dpi_cids: Vec<u16> = Vec::new();
+    let mut back_cids: Vec<u16> = Vec::new();
+    let mut forward_cids: Vec<u16> = Vec::new();
     if let Some(info) = device
         .root()
         .get_feature(reprog_controls::FEATURE_ID)
@@ -339,58 +654,51 @@ async fn arm_controls(
                 .iter()
                 .any(|c| c.cid == reprog_controls::GESTURE_BUTTON_CID && c.supports_raw_xy())
         {
+            // No prior diversions to roll back at this point — gesture is first.
             rc.set_cid_reporting(reprog_controls::GESTURE_BUTTON_CID, true, true)
                 .await
                 .map_err(|e| GestureError::Hidpp(format!("{e:?}")))?;
             gesture_diverted = true;
         }
-        for &cid in &reprog_controls::DPI_MODE_SHIFT_CIDS {
-            if controls.iter().any(|c| c.cid == cid && c.is_divertable()) {
-                rc.set_cid_reporting(cid, true, false)
-                    .await
-                    .map_err(|e| GestureError::Hidpp(format!("{e:?}")))?;
-                dpi_cids.push(cid);
-            }
-        }
+        // Track every CID diverted so far (across DPI/Back/Forward groups) so a
+        // later group's failure can roll back everything already diverted —
+        // including this group's own partial progress — leaving no button stuck.
+        let mut diverted_cids: Vec<u16> = Vec::new();
+        dpi_cids = divert_candidate_cids(
+            &rc,
+            &controls,
+            &reprog_controls::DPI_MODE_SHIFT_CIDS,
+            &mut diverted_cids,
+            gesture_diverted,
+        )
+        .await?;
+        // Back/Forward buttons on MX Vertical and similar devices report via
+        // HID++ rather than as standard OS mouse buttons. Divert them so the
+        // capture session can synthesize the correct OS events.
+        back_cids = divert_candidate_cids(
+            &rc,
+            &controls,
+            &reprog_controls::BACK_CIDS,
+            &mut diverted_cids,
+            gesture_diverted,
+        )
+        .await?;
+        forward_cids = divert_candidate_cids(
+            &rc,
+            &controls,
+            &reprog_controls::FORWARD_CIDS,
+            &mut diverted_cids,
+            gesture_diverted,
+        )
+        .await?;
         reprog = Some((rc, info.index));
     }
 
-    let mut thumb: Option<(Thumbwheel, u8)> = None;
-    if capture_thumbwheel
-        && let Some(info) = device
-            .root()
-            .get_feature(thumbwheel::FEATURE_ID)
-            .await
-            .map_err(|e| GestureError::Hidpp(format!("{e:?}")))?
-    {
-        let tw = Thumbwheel::new(Arc::clone(chan), slot, info.index);
-        // Consume the getInfo error here, before the next await: Hidpp20Error
-        // isn't Send, so holding it across an await would make this future
-        // (spawned on tokio) non-Send.
-        let supports_single_tap = match tw.get_info().await {
-            Ok(twinfo) => twinfo.supports_single_tap,
-            Err(e) => {
-                warn!(error = ?e, "thumb wheel getInfo failed");
-                false
-            }
-        };
-        // Divert whenever capture was requested: rotation rebinds and the
-        // sensitivity multiplier need the diverted event stream even on wheels
-        // that report no single-tap capability (e.g. MX Master 4) — lacking the
-        // tap only means a bound click can never fire.
-        if !supports_single_tap {
-            debug!("thumb wheel reports no single tap — click not capturable");
-        }
-        tw.set_reporting(true, false)
-            .await
-            .map_err(|e| GestureError::Hidpp(format!("{e:?}")))?;
-        thumb = Some((tw, info.index));
-    }
+    let thumb = arm_modern_thumbwheel(&device, chan, slot, capture_thumbwheel).await?;
 
-    // The MX Master 2S does not expose 0x2150. Its wheel is Gestures2 gesture
-    // 46, whose diverted notification layout is not publicly documented. Do
-    // not guess at that wire format: trace mode diverts only that gesture and
-    // records raw notifications so a decoder can be written from real packets.
+    // MX Master 2S does not expose 0x2150. Its thumb wheel is Gestures2
+    // gesture 46. Trace mode diverts only that gesture and logs raw packets;
+    // normal builds continue using the native horizontal-wheel fallback.
     let legacy_thumb = arm_legacy_thumbwheel_trace(
         &device,
         chan,
@@ -399,28 +707,80 @@ async fn arm_controls(
     )
     .await?;
 
-    if !gesture_diverted && dpi_cids.is_empty() && thumb.is_none() && legacy_thumb.is_none() {
+    if !gesture_diverted
+        && dpi_cids.is_empty()
+        && back_cids.is_empty()
+        && forward_cids.is_empty()
+        && thumb.is_none()
+        && legacy_thumb.is_none()
+    {
         debug!(slot, "no capturable controls — idle session");
     }
     Ok(ArmedControls {
         reprog,
         gesture_diverted,
         dpi_cids,
+        back_cids,
+        forward_cids,
         thumb,
         legacy_thumb,
     })
 }
 
+/// Divert every CID in `candidates` that `controls` reports as divertable,
+/// appending each success to `diverted` (the running rollback list shared
+/// across all candidate groups in one [`arm_controls`] call) and returning
+/// the subset actually diverted from this group.
+///
+/// On failure, rolls back `gesture_diverted` (if set) plus everything already
+/// in `diverted` — including this group's own partial progress, since the
+/// failing CID's own diversion never got recorded — then returns the error.
+/// No calling group is left with a stuck-diverted button.
+async fn divert_candidate_cids(
+    rc: &ReprogControlsV4,
+    controls: &[reprog_controls::CtrlIdInfo],
+    candidates: &[u16],
+    diverted: &mut Vec<u16>,
+    gesture_diverted: bool,
+) -> Result<Vec<u16>, GestureError> {
+    let mut group = Vec::new();
+    for &cid in candidates {
+        if controls.iter().any(|c| c.cid == cid && c.is_divertable()) {
+            if let Err(e) = rc.set_cid_reporting(cid, true, false).await {
+                if gesture_diverted {
+                    let _ = rc
+                        .set_cid_reporting(reprog_controls::GESTURE_BUTTON_CID, false, false)
+                        .await;
+                }
+                for &d in diverted.iter() {
+                    let _ = rc.set_cid_reporting(d, false, false).await;
+                }
+                // The failed enable may still have applied in firmware if only
+                // the acknowledgement was lost — best-effort revert this CID
+                // too, so a flaky response doesn't leave it silently diverted
+                // with no ArmedControls session ever created to restore it.
+                let _ = rc.set_cid_reporting(cid, false, false).await;
+                return Err(GestureError::Hidpp(format!("{e:?}")));
+            }
+            group.push(cid);
+            diverted.push(cid);
+        }
+    }
+    Ok(group)
+}
+
 /// Log (don't propagate) a failure to hand a control back to the firmware.
-fn restore<E: std::fmt::Display>(result: Result<(), E>, what: &str) {
+/// Shared with the keyboard capture session (`crate::keyboard`).
+pub(crate) fn restore<E: std::fmt::Display>(result: Result<(), E>, what: &str) {
     if let Err(e) = result {
         warn!(error = %e, control = what, "failed to restore control mapping on shutdown");
     }
 }
 
 /// Read the device's full reprogrammable-control table in one pass, so we can
-/// test several CIDs without rescanning per control.
-async fn enumerate_controls(
+/// test several CIDs without rescanning per control. Shared with the keyboard
+/// capture session (`crate::keyboard`).
+pub(crate) async fn enumerate_controls(
     rc: &ReprogControlsV4,
 ) -> Result<Vec<reprog_controls::CtrlIdInfo>, GestureError> {
     let count = rc
@@ -446,6 +806,8 @@ fn handle_reprog(
     acc: &mut CaptureAccum,
     event: RawControlEvent,
     dpi_cids: &[u16],
+    back_cids: &[u16],
+    forward_cids: &[u16],
     sink: &mpsc::UnboundedSender<CapturedInput>,
 ) {
     match event {
@@ -463,9 +825,52 @@ fn handle_reprog(
 
             let dpi_down = dpi_cids.iter().any(|cid| cids.contains(cid));
             if dpi_down && !acc.dpi_down {
-                let _ = sink.send(CapturedInput::ButtonPressed(ButtonId::DpiToggle));
+                let _ = sink.send(CapturedInput::ButtonPressed(ButtonId::DpiToggle, None));
             }
             acc.dpi_down = dpi_down;
+
+            // Back/Forward: emit on the rising edge (first frame where the CID
+            // appears), matching the DPI button convention above.
+            let back_down = back_cids.iter().any(|cid| cids.contains(cid));
+            if back_down && !acc.back_down {
+                let now = Instant::now();
+                let elapsed = acc.last_back.map_or(BACK_FORWARD_DEBOUNCE, |t| now - t);
+                if elapsed >= BACK_FORWARD_DEBOUNCE {
+                    acc.last_back = Some(now);
+                    // Capture frontmost PID NOW on this listener thread — before
+                    // any async dispatch delay can shift focus away from the
+                    // target browser window.
+                    let _ = sink.send(CapturedInput::ButtonPressed(
+                        ButtonId::Back,
+                        frontmost_pid(),
+                    ));
+                } else {
+                    debug!(
+                        elapsed_ms = elapsed.as_millis(),
+                        "Back debounced — too soon after last dispatch"
+                    );
+                }
+            }
+            acc.back_down = back_down;
+
+            let forward_down = forward_cids.iter().any(|cid| cids.contains(cid));
+            if forward_down && !acc.forward_down {
+                let now = Instant::now();
+                let elapsed = acc.last_forward.map_or(BACK_FORWARD_DEBOUNCE, |t| now - t);
+                if elapsed >= BACK_FORWARD_DEBOUNCE {
+                    acc.last_forward = Some(now);
+                    let _ = sink.send(CapturedInput::ButtonPressed(
+                        ButtonId::Forward,
+                        frontmost_pid(),
+                    ));
+                } else {
+                    debug!(
+                        elapsed_ms = elapsed.as_millis(),
+                        "Forward debounced — too soon after last dispatch"
+                    );
+                }
+            }
+            acc.forward_down = forward_down;
         }
         RawControlEvent::RawXy { dx, dy } => {
             // Commit the instant a clean direction emerges (mid-swipe, once per
diff --git a/crates/openlogi-hid/src/gesture/tests.rs b/crates/openlogi-hid/src/gesture/tests.rs
index 035f2cdac6b7f0735836acf2423ef1fe63122b9b..5324772d37f5532b91c631e5bd2aeb01cbd3bd3e 100644
--- a/crates/openlogi-hid/src/gesture/tests.rs
+++ b/crates/openlogi-hid/src/gesture/tests.rs
@@ -1,5 +1,97 @@
 use super::*;
 
+use std::cell::RefCell;
+use std::panic::{AssertUnwindSafe, catch_unwind};
+use std::rc::Rc;
+
+struct DropRecorder(Rc<RefCell<Vec<&'static str>>>);
+
+impl Drop for DropRecorder {
+    fn drop(&mut self) {
+        self.0.borrow_mut().push("listener");
+    }
+}
+
+#[tokio::test]
+async fn graceful_teardown_clears_then_drops_listener_then_disarms() {
+    let events = Rc::new(RefCell::new(Vec::new()));
+    teardown_capture(
+        {
+            let events = Rc::clone(&events);
+            move || events.borrow_mut().push("clear")
+        },
+        DropRecorder(Rc::clone(&events)),
+        CaptureStop::Graceful,
+        {
+            let events = Rc::clone(&events);
+            move || async move { events.borrow_mut().push("disarm") }
+        },
+    )
+    .await;
+
+    assert_eq!(*events.borrow(), ["clear", "listener", "disarm"]);
+}
+
+#[tokio::test]
+async fn revoked_teardown_clears_then_drops_listener_without_disarm() {
+    let events = Rc::new(RefCell::new(Vec::new()));
+    teardown_capture(
+        {
+            let events = Rc::clone(&events);
+            move || events.borrow_mut().push("clear")
+        },
+        DropRecorder(Rc::clone(&events)),
+        CaptureStop::Revoked,
+        {
+            let events = Rc::clone(&events);
+            move || async move { events.borrow_mut().push("disarm") }
+        },
+    )
+    .await;
+
+    assert_eq!(*events.borrow(), ["clear", "listener"]);
+}
+
+#[test]
+fn capture_slot_cleanup_recovers_a_poisoned_writer() {
+    let slot: CaptureChannel = Arc::new(RwLock::new(None));
+    let poison = Arc::clone(&slot);
+    let _ = catch_unwind(AssertUnwindSafe(move || {
+        let _guard = poison.write().unwrap_or_else(PoisonError::into_inner);
+        panic!("poison capture slot");
+    }));
+
+    replace_capture_slot(&slot, None);
+
+    assert!(
+        slot.read()
+            .unwrap_or_else(PoisonError::into_inner)
+            .is_none()
+    );
+}
+
+#[tokio::test]
+async fn registry_miss_does_not_fall_back_to_opening_the_route() {
+    let route = DeviceRoute::Direct {
+        vendor_id: 0x046d,
+        product_id: 0xb35b,
+    };
+    let registry = ChannelRegistry::default();
+    let (sink, _events) = mpsc::unbounded_channel();
+    let (_stop, shutdown) = oneshot::channel();
+    let slot: CaptureChannel = Arc::new(RwLock::new(None));
+
+    let result =
+        run_capture_session_with_registry(route, false, false, sink, shutdown, slot, &registry)
+            .await;
+
+    let Err(error) = result else {
+        panic!("an empty Agent registry must fail before any route open");
+    };
+
+    assert!(matches!(error, GestureError::DeviceNotFound));
+}
+
 fn press() -> RawControlEvent {
     RawControlEvent::DivertedButtons([reprog_controls::GESTURE_BUTTON_CID, 0, 0, 0])
 }
@@ -13,14 +105,16 @@ fn quick_tap_is_a_click_even_while_the_cursor_moves() {
     let (tx, mut rx) = mpsc::unbounded_channel();
     let mut acc = CaptureAccum::default();
 
-    handle_reprog(&mut acc, press(), &[], &tx);
+    handle_reprog(&mut acc, press(), &[], &[], &[], &tx);
     handle_reprog(
         &mut acc,
         RawControlEvent::RawXy { dx: 120, dy: 5 },
         &[],
+        &[],
+        &[],
         &tx,
     );
-    handle_reprog(&mut acc, release(), &[], &tx);
+    handle_reprog(&mut acc, release(), &[], &[], &[], &tx);
 
     assert_eq!(
         rx.try_recv(),
@@ -37,13 +131,15 @@ fn a_held_gesture_commits_a_swipe_and_does_not_also_click() {
     let (tx, mut rx) = mpsc::unbounded_channel();
     let mut acc = CaptureAccum::default();
 
-    handle_reprog(&mut acc, press(), &[], &tx);
+    handle_reprog(&mut acc, press(), &[], &[], &[], &tx);
     // Pretend the button has been held well past the swipe gate.
     acc.swipe.backdate_hold_for_test();
     handle_reprog(
         &mut acc,
         RawControlEvent::RawXy { dx: 120, dy: 5 },
         &[],
+        &[],
+        &[],
         &tx,
     );
 
@@ -52,7 +148,7 @@ fn a_held_gesture_commits_a_swipe_and_does_not_also_click() {
         Ok(CapturedInput::Gesture(GestureDirection::Right))
     );
 
-    handle_reprog(&mut acc, release(), &[], &tx);
+    handle_reprog(&mut acc, release(), &[], &[], &[], &tx);
     assert!(
         rx.try_recv().is_err(),
         "a committed swipe must not also click on release"
@@ -66,12 +162,12 @@ fn a_held_dpi_button_presses_once_on_the_rising_edge() {
     let dpi = reprog_controls::DPI_MODE_SHIFT_CIDS[0];
     let down = RawControlEvent::DivertedButtons([dpi, 0, 0, 0]);
 
-    handle_reprog(&mut acc, down, &[dpi], &tx);
-    handle_reprog(&mut acc, down, &[dpi], &tx);
+    handle_reprog(&mut acc, down, &[dpi], &[], &[], &tx);
+    handle_reprog(&mut acc, down, &[dpi], &[], &[], &tx);
 
     assert_eq!(
         rx.try_recv(),
-        Ok(CapturedInput::ButtonPressed(ButtonId::DpiToggle))
+        Ok(CapturedInput::ButtonPressed(ButtonId::DpiToggle, None))
     );
     assert!(rx.try_recv().is_err(), "a held DPI button presses once");
 }
@@ -87,18 +183,98 @@ fn a_dpi_button_re_presses_after_a_release() {
     let down = RawControlEvent::DivertedButtons([dpi, 0, 0, 0]);
     let up = RawControlEvent::DivertedButtons([0, 0, 0, 0]);
 
-    handle_reprog(&mut acc, down, &[dpi], &tx);
-    handle_reprog(&mut acc, up, &[dpi], &tx);
-    handle_reprog(&mut acc, down, &[dpi], &tx);
+    handle_reprog(&mut acc, down, &[dpi], &[], &[], &tx);
+    handle_reprog(&mut acc, up, &[dpi], &[], &[], &tx);
+    handle_reprog(&mut acc, down, &[dpi], &[], &[], &tx);
 
     assert_eq!(
         rx.try_recv(),
-        Ok(CapturedInput::ButtonPressed(ButtonId::DpiToggle))
+        Ok(CapturedInput::ButtonPressed(ButtonId::DpiToggle, None))
     );
     assert_eq!(
         rx.try_recv(),
-        Ok(CapturedInput::ButtonPressed(ButtonId::DpiToggle)),
+        Ok(CapturedInput::ButtonPressed(ButtonId::DpiToggle, None)),
         "a release re-arms the rising edge"
     );
     assert!(rx.try_recv().is_err());
 }
+
+// Back/Forward emit `ButtonPressed` with a real `frontmost_pid()` reading
+// (`Some` on macOS, `None` elsewhere — see `frontmost_pid`), unlike DPI's
+// hardcoded `None`, so these assertions match on the button only.
+
+#[test]
+fn a_held_back_button_presses_once_on_the_rising_edge() {
+    let (tx, mut rx) = mpsc::unbounded_channel();
+    let mut acc = CaptureAccum::default();
+    let back = reprog_controls::BACK_CIDS[0];
+    let down = RawControlEvent::DivertedButtons([back, 0, 0, 0]);
+
+    handle_reprog(&mut acc, down, &[], &[back], &[], &tx);
+    handle_reprog(&mut acc, down, &[], &[back], &[], &tx);
+
+    assert!(matches!(
+        rx.try_recv(),
+        Ok(CapturedInput::ButtonPressed(ButtonId::Back, _))
+    ));
+    assert!(rx.try_recv().is_err(), "a held Back button presses once");
+}
+
+#[test]
+fn a_forward_button_re_press_within_the_debounce_window_is_suppressed() {
+    // Unlike the DPI button, Back/Forward re-arm on release is gated by
+    // BACK_FORWARD_DEBOUNCE: the MX Vertical's firmware can report a single
+    // physical click as press/release/press within a few ms, and without the
+    // debounce that would fire twice. A press → release → press happening in
+    // a tight test loop is well within the 150ms window, so the second press
+    // must be suppressed.
+    let (tx, mut rx) = mpsc::unbounded_channel();
+    let mut acc = CaptureAccum::default();
+    let fwd = reprog_controls::FORWARD_CIDS[0];
+    let down = RawControlEvent::DivertedButtons([fwd, 0, 0, 0]);
+    let up = RawControlEvent::DivertedButtons([0, 0, 0, 0]);
+
+    handle_reprog(&mut acc, down, &[], &[], &[fwd], &tx);
+    handle_reprog(&mut acc, up, &[], &[], &[fwd], &tx);
+    handle_reprog(&mut acc, down, &[], &[], &[fwd], &tx);
+
+    assert!(matches!(
+        rx.try_recv(),
+        Ok(CapturedInput::ButtonPressed(ButtonId::Forward, _))
+    ));
+    assert!(
+        rx.try_recv().is_err(),
+        "a re-press inside the debounce window must not re-fire"
+    );
+}
+
+#[test]
+fn a_back_button_re_press_after_the_debounce_window_fires_again() {
+    let (tx, mut rx) = mpsc::unbounded_channel();
+    let mut acc = CaptureAccum::default();
+    let back = reprog_controls::BACK_CIDS[0];
+    let down = RawControlEvent::DivertedButtons([back, 0, 0, 0]);
+    let up = RawControlEvent::DivertedButtons([0, 0, 0, 0]);
+
+    handle_reprog(&mut acc, down, &[], &[back], &[], &tx);
+    handle_reprog(&mut acc, up, &[], &[back], &[], &tx);
+    // Backdate the last dispatch past the debounce window instead of
+    // sleeping in the test, mirroring `SwipeAccumulator::backdate_hold_for_test`.
+    acc.last_back = acc
+        .last_back
+        .and_then(|t| t.checked_sub(BACK_FORWARD_DEBOUNCE + Duration::from_millis(1)));
+    handle_reprog(&mut acc, down, &[], &[back], &[], &tx);
+
+    assert!(matches!(
+        rx.try_recv(),
+        Ok(CapturedInput::ButtonPressed(ButtonId::Back, _))
+    ));
+    assert!(
+        matches!(
+            rx.try_recv(),
+            Ok(CapturedInput::ButtonPressed(ButtonId::Back, _))
+        ),
+        "a re-press past the debounce window re-arms and fires"
+    );
+    assert!(rx.try_recv().is_err());
+}
diff --git a/crates/openlogi-hid/src/host_switch.rs b/crates/openlogi-hid/src/host_switch.rs
new file mode 100644
index 0000000000000000000000000000000000000000..f1e560de9d52b062f46a7b6e6a1dbfa7ebbf9d3b
--- /dev/null
+++ b/crates/openlogi-hid/src/host_switch.rs
@@ -0,0 +1,577 @@
+//! Keyboard-initiated host-switch synchronization.
+//!
+//! A session temporarily diverts the keyboard's three host controls, observes
+//! which channel was pressed, switches the linked pointing devices, and then
+//! switches the keyboard itself. Ordering matters: once the keyboard leaves
+//! this host its HID++ channel can no longer command a mouse sharing the same
+//! receiver.
+
+use std::{future::Future, sync::Arc, time::Duration};
+
+use hidpp::{
+    channel::HidppChannel,
+    device::Device,
+    feature::{CreatableFeature, change_host::ChangeHostFeature},
+    protocol::v20,
+};
+use thiserror::Error;
+use tokio::{
+    sync::{mpsc, oneshot},
+    time::timeout,
+};
+use tracing::{debug, info};
+
+use crate::{
+    ChannelPool,
+    reprog_controls::{self, ReprogControlsV4},
+    route::DeviceRoute,
+};
+
+/// Why an armed host-switch session is being stopped externally.
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+pub enum HostSwitchStopReason {
+    /// The keyboard remains reachable, so its controls must be restored.
+    Graceful,
+    /// The keyboard disappeared, so only local resources can be released.
+    DeviceLost,
+}
+
+const HOST_CONTROL_IDS: [(reprog_controls::ControlId, u8); 3] = [
+    (reprog_controls::control_ids::HOST_SWITCH_CHANNEL_1, 0),
+    (reprog_controls::control_ids::HOST_SWITCH_CHANNEL_2, 1),
+    (reprog_controls::control_ids::HOST_SWITCH_CHANNEL_3, 2),
+];
+const HOST_TASK_IDS: [(reprog_controls::TaskId, u8); 3] = [
+    (reprog_controls::task_ids::HOST_SWITCH_CHANNEL_1, 0),
+    (reprog_controls::task_ids::HOST_SWITCH_CHANNEL_2, 1),
+    (reprog_controls::task_ids::HOST_SWITCH_CHANNEL_3, 2),
+];
+const HIDPP_OPERATION_TIMEOUT: Duration = Duration::from_secs(5);
+
+#[derive(Clone, Copy)]
+enum ReportingMode {
+    Diverted,
+    Analytics,
+}
+
+#[derive(Clone, Copy)]
+struct ArmedControl {
+    cid: u16,
+    host: u8,
+    mode: ReportingMode,
+    original: reprog_controls::CidReporting,
+}
+
+/// Failure while arming or running a host-switch link.
+#[derive(Debug, Error)]
+pub enum HostSwitchError {
+    /// HID transport-level failure.
+    #[error("HID transport error")]
+    Hid(#[from] async_hid::HidError),
+    /// The configured keyboard is not currently reachable.
+    #[error("configured keyboard is not connected")]
+    KeyboardNotFound,
+    /// A configured target is not currently reachable.
+    #[error("configured linked device is not connected")]
+    TargetNotFound,
+    /// A required HID++ operation failed.
+    #[error("HID++ protocol error: {0}")]
+    Hidpp(String),
+    /// A required HID++ operation did not complete within its budget.
+    #[error("HID++ operation timed out while {operation}")]
+    TimedOut {
+        /// Description of the operation that exceeded its budget.
+        operation: &'static str,
+    },
+    /// The keyboard cannot report its host switch controls to software.
+    #[error("keyboard exposes no reportable host switch controls")]
+    UnsupportedKeyboard,
+}
+
+/// Capture host switch keys on `keyboard` until one is pressed or `shutdown`
+/// resolves. Controls are restored before a requested host is returned.
+pub async fn run_host_switch_session(
+    keyboard: DeviceRoute,
+    shutdown: oneshot::Receiver<HostSwitchStopReason>,
+    channel_pool: ChannelPool,
+) -> Result<Option<u8>, HostSwitchError> {
+    let channel = open_channel(&channel_pool, &keyboard, "opening keyboard channel")
+        .await?
+        .ok_or(HostSwitchError::KeyboardNotFound)?;
+    let keyboard_index = keyboard.device_index();
+    let device = timed_hidpp(
+        "opening keyboard device",
+        Device::new(Arc::clone(&channel), keyboard_index),
+    )
+    .await?;
+    let feature = timed_hidpp(
+        "locating host controls",
+        device.root().get_feature(reprog_controls::FEATURE_ID),
+    )
+    .await?
+    .ok_or(HostSwitchError::UnsupportedKeyboard)?;
+    let controls = ReprogControlsV4::new(Arc::clone(&channel), keyboard_index, feature.index);
+
+    let armed = arm_host_controls(&controls).await?;
+    if armed.is_empty() {
+        return Err(HostSwitchError::UnsupportedKeyboard);
+    }
+
+    let (press_tx, mut press_rx) = mpsc::unbounded_channel();
+    let feature_index = controls.feature_index();
+    let event_controls = armed.clone();
+    let listener = channel.add_msg_listener_guarded(move |raw, matched| {
+        if matched {
+            return;
+        }
+        let message = v20::Message::from(raw);
+        let Some(event) =
+            reprog_controls::decode_full_event(&message, keyboard_index, feature_index)
+        else {
+            return;
+        };
+        if let Some(host) = event_host(&event_controls, event) {
+            let _ = press_tx.send(host);
+        }
+    });
+
+    info!(
+        route = %keyboard,
+        controls = armed.len(),
+        "host switch link active"
+    );
+    let outcome = tokio::select! {
+        reason = shutdown => {
+            let reason = reason.unwrap_or(HostSwitchStopReason::DeviceLost);
+            (None, reason == HostSwitchStopReason::Graceful)
+        },
+        Some(host) = press_rx.recv() => (Some(host), true),
+    };
+
+    drop(listener);
+    if outcome.1 {
+        restore_host_controls(&controls, armed).await;
+    }
+    Ok(outcome.0)
+}
+
+/// Move reachable targets to `host`, then move the keyboard last.
+///
+/// Returns whether the keyboard actually changed hosts.
+pub async fn switch_linked_hosts(
+    keyboard: &DeviceRoute,
+    targets: &[DeviceRoute],
+    host: u8,
+    channel_pool: &ChannelPool,
+) -> Result<bool, HostSwitchError> {
+    let channel = open_channel(channel_pool, keyboard, "opening keyboard channel")
+        .await?
+        .ok_or(HostSwitchError::KeyboardNotFound)?;
+    for target in targets {
+        match prepare_host_change(target, host, keyboard, &channel, channel_pool).await {
+            Ok(change) => {
+                if let Err(error) = apply_host_change(change).await {
+                    debug!(%error, route = %target, host, "linked device host switch failed");
+                }
+            }
+            Err(error) => {
+                debug!(%error, route = %target, host, "linked device host switch preparation failed");
+            }
+        }
+    }
+    let keyboard_change = prepare_host_change_on(&channel, keyboard.device_index(), host).await?;
+    let changed = apply_host_change(keyboard_change).await?;
+    if changed {
+        debug!(host, route = %keyboard, "keyboard host switched");
+    }
+    Ok(changed)
+}
+
+async fn arm_host_controls(
+    controls: &ReprogControlsV4,
+) -> Result<Vec<ArmedControl>, HostSwitchError> {
+    let mut armed = Vec::new();
+    if let Err(error) = arm_host_controls_inner(controls, &mut armed).await {
+        restore_host_controls(controls, armed).await;
+        return Err(error);
+    }
+    Ok(armed)
+}
+
+async fn arm_host_controls_inner(
+    controls: &ReprogControlsV4,
+    armed: &mut Vec<ArmedControl>,
+) -> Result<(), HostSwitchError> {
+    let count = timed_hidpp("reading host control count", controls.get_count()).await?;
+    for index in 0..count {
+        let info = timed_hidpp(
+            "reading host control information",
+            controls.get_ctrl_id_info(index),
+        )
+        .await?;
+        let Some(host) = host_channel(info) else {
+            continue;
+        };
+        debug!(
+            cid = format_args!("{:#06x}", info.cid),
+            task_id = format_args!("{:#06x}", info.task_id),
+            host,
+            divertable = info.is_divertable(),
+            analytics = info.supports_analytics_events(),
+            "host switch control discovered"
+        );
+        let mode = if info.is_divertable() {
+            Some(ReportingMode::Diverted)
+        } else if info.supports_analytics_events() {
+            Some(ReportingMode::Analytics)
+        } else {
+            None
+        };
+        if let Some(mode) = mode {
+            let original = timed_hidpp(
+                "reading host control reporting",
+                controls.get_cid_reporting(info.cid),
+            )
+            .await?;
+            // Record the rollback before issuing the write: a transport timeout
+            // can mean that the device applied the request but its response was
+            // lost, so the failing control must be restored as well.
+            armed.push(ArmedControl {
+                cid: info.cid,
+                host,
+                mode,
+                original,
+            });
+            match mode {
+                ReportingMode::Diverted => {
+                    timed_hidpp(
+                        "diverting host control",
+                        controls.set_cid_reporting(info.cid, true, false),
+                    )
+                    .await?;
+                }
+                ReportingMode::Analytics => {
+                    timed_hidpp(
+                        "enabling host control analytics",
+                        controls.set_cid_reporting_full(
+                            info.cid,
+                            reprog_controls::CidReportingChange {
+                                analytics_key_events: Some(true),
+                                ..reprog_controls::CidReportingChange::default()
+                            },
+                        ),
+                    )
+                    .await?;
+                }
+            }
+        }
+    }
+    Ok(())
+}
+
+async fn restore_host_controls(controls: &ReprogControlsV4, armed: Vec<ArmedControl>) {
+    for control in armed {
+        let mut restored = restore_host_control(controls, control).await;
+        if restored.is_err() {
+            restored = restore_host_control(controls, control).await;
+        }
+        if let Err(error) = restored {
+            debug!(
+                ?error,
+                cid = control.cid,
+                "could not restore host switch control"
+            );
+        }
+    }
+}
+
+async fn restore_host_control(
+    controls: &ReprogControlsV4,
+    control: ArmedControl,
+) -> Result<(), HostSwitchError> {
+    timed_hidpp(
+        "restoring host control reporting",
+        controls.set_cid_reporting_full(control.cid, restoration_change(control)),
+    )
+    .await
+    .map(|_echo| ())
+}
+
+fn restoration_change(control: ArmedControl) -> reprog_controls::CidReportingChange {
+    match control.mode {
+        ReportingMode::Diverted => reprog_controls::CidReportingChange {
+            diverted: Some(control.original.diverted),
+            raw_xy: Some(control.original.raw_xy),
+            ..reprog_controls::CidReportingChange::default()
+        },
+        ReportingMode::Analytics => reprog_controls::CidReportingChange {
+            analytics_key_events: Some(control.original.analytics_key_events),
+            ..reprog_controls::CidReportingChange::default()
+        },
+    }
+}
+
+struct PreparedHostChange {
+    feature: Arc<ChangeHostFeature>,
+    device_index: u8,
+    host: u8,
+    required: bool,
+}
+
+async fn prepare_host_change(
+    target: &DeviceRoute,
+    host: u8,
+    keyboard: &DeviceRoute,
+    keyboard_channel: &Arc<HidppChannel>,
+    channel_pool: &ChannelPool,
+) -> Result<PreparedHostChange, HostSwitchError> {
+    if shares_channel(target, keyboard) {
+        prepare_host_change_on(keyboard_channel, target.device_index(), host).await
+    } else {
+        let channel = open_channel(channel_pool, target, "opening linked device channel")
+            .await?
+            .ok_or(HostSwitchError::TargetNotFound)?;
+        prepare_host_change_on(&channel, target.device_index(), host).await
+    }
+}
+
+async fn prepare_host_change_on(
+    channel: &Arc<HidppChannel>,
+    device_index: u8,
+    host: u8,
+) -> Result<PreparedHostChange, HostSwitchError> {
+    let mut device = timed_hidpp(
+        "opening host-change device",
+        Device::new(Arc::clone(channel), device_index),
+    )
+    .await?;
+    let info = timed_hidpp(
+        "locating host-change feature",
+        device.root().get_feature(ChangeHostFeature::ID),
+    )
+    .await?
+    .ok_or_else(|| HostSwitchError::Hidpp("ChangeHost is unsupported".into()))?;
+    let change_host = device.add_feature::<ChangeHostFeature>(info.index);
+    let state = timed_hidpp("reading current host", change_host.get_host_info()).await?;
+    let required = host_change_required(state.current_host, state.host_count, host)?;
+    Ok(PreparedHostChange {
+        feature: change_host,
+        device_index,
+        host,
+        required,
+    })
+}
+
+async fn apply_host_change(change: PreparedHostChange) -> Result<bool, HostSwitchError> {
+    if !change.required {
+        let PreparedHostChange {
+            device_index, host, ..
+        } = change;
+        debug!(device_index, host, "device already uses requested host");
+        return Ok(false);
+    }
+    timed_hidpp(
+        "writing current host",
+        change.feature.set_current_host(change.host),
+    )
+    .await?;
+    Ok(true)
+}
+
+async fn open_channel(
+    channel_pool: &ChannelPool,
+    route: &DeviceRoute,
+    operation: &'static str,
+) -> Result<Option<Arc<HidppChannel>>, HostSwitchError> {
+    timeout(HIDPP_OPERATION_TIMEOUT, channel_pool.open(route))
+        .await
+        .map_err(|_| HostSwitchError::TimedOut { operation })?
+        .map_err(HostSwitchError::Hid)
+}
+
+async fn timed_hidpp<T, E>(
+    operation: &'static str,
+    future: impl Future<Output = Result<T, E>>,
+) -> Result<T, HostSwitchError>
+where
+    E: std::fmt::Debug,
+{
+    timeout(HIDPP_OPERATION_TIMEOUT, future)
+        .await
+        .map_err(|_| HostSwitchError::TimedOut { operation })?
+        .map_err(|error| hidpp_error(operation, error))
+}
+
+fn host_change_required(
+    current_host: u8,
+    host_count: u8,
+    requested_host: u8,
+) -> Result<bool, HostSwitchError> {
+    if requested_host >= host_count {
+        return Err(HostSwitchError::Hidpp(format!(
+            "host {requested_host} is outside device host count {host_count}"
+        )));
+    }
+    Ok(current_host != requested_host)
+}
+
+fn shares_channel(left: &DeviceRoute, right: &DeviceRoute) -> bool {
+    left.shares_transport(right)
+}
+
+fn hidpp_error(operation: &'static str, error: impl std::fmt::Debug) -> HostSwitchError {
+    HostSwitchError::Hidpp(format!("{operation}: {error:?}"))
+}
+
+fn host_channel(info: reprog_controls::CtrlIdInfo) -> Option<u8> {
+    HOST_CONTROL_IDS
+        .iter()
+        .find_map(|(cid, host)| (info.cid == cid.0).then_some(*host))
+        .or_else(|| {
+            HOST_TASK_IDS
+                .iter()
+                .find_map(|(task, host)| (info.task_id == task.0).then_some(*host))
+        })
+}
+
+fn event_host(
+    controls: &[ArmedControl],
+    event: reprog_controls::ReprogControlsEvent,
+) -> Option<u8> {
+    match event {
+        reprog_controls::ReprogControlsEvent::DivertedButtons(cids) => controls
+            .iter()
+            .find_map(|control| cids.contains(&control.cid.into()).then_some(control.host)),
+        reprog_controls::ReprogControlsEvent::AnalyticsKeyEvents(events) => {
+            controls.iter().find_map(|control| {
+                events
+                    .iter()
+                    .any(|event| event.cid.0 == control.cid)
+                    .then_some(control.host)
+            })
+        }
+        reprog_controls::ReprogControlsEvent::DivertedRawMouseXy { .. }
+        | reprog_controls::ReprogControlsEvent::DivertedRawWheel { .. } => None,
+    }
+}
+
+#[cfg(test)]
+mod tests {
+    use super::{
+        ArmedControl, ReportingMode, event_host, host_change_required, host_channel,
+        restoration_change, shares_channel,
+    };
+    use crate::DeviceRoute;
+    use crate::reprog_controls::{
+        AnalyticsKeyEvent, CidReporting, ControlId, CtrlIdInfo, ReprogControlsEvent,
+    };
+
+    fn reporting(diverted: bool, raw_xy: bool, analytics_key_events: bool) -> CidReporting {
+        CidReporting {
+            cid: ControlId(0x00d3),
+            diverted,
+            persistently_diverted: true,
+            force_raw_xy: true,
+            raw_xy,
+            remap: Some(ControlId(0x1234)),
+            analytics_key_events,
+            raw_wheel: true,
+        }
+    }
+
+    #[test]
+    fn receiver_slots_share_one_channel() {
+        let keyboard = DeviceRoute::Bolt {
+            receiver_uid: "AABB".into(),
+            slot: 1,
+        };
+        let mouse = DeviceRoute::Bolt {
+            receiver_uid: "aabb".into(),
+            slot: 2,
+        };
+        assert!(shares_channel(&keyboard, &mouse));
+    }
+
+    #[test]
+    fn direct_devices_do_not_share_channels() {
+        let route = DeviceRoute::Direct {
+            vendor_id: 0x046d,
+            product_id: 0xb025,
+        };
+        assert!(!shares_channel(&route, &route));
+    }
+
+    #[test]
+    fn host_controls_are_recognized_by_task_when_cid_varies() {
+        let info = CtrlIdInfo {
+            cid: 0x1234,
+            task_id: 0x00af,
+            flags: 0,
+        };
+        assert_eq!(host_channel(info), Some(1));
+    }
+
+    #[test]
+    fn analytics_event_selects_the_matching_host() {
+        let controls = [ArmedControl {
+            cid: 0x00d3,
+            host: 2,
+            mode: ReportingMode::Analytics,
+            original: reporting(false, false, false),
+        }];
+        let mut events = [AnalyticsKeyEvent::default(); 5];
+        events[0] = AnalyticsKeyEvent {
+            cid: ControlId(0x00d3),
+            event: 1,
+        };
+        assert_eq!(
+            event_host(&controls, ReprogControlsEvent::AnalyticsKeyEvents(events)),
+            Some(2)
+        );
+    }
+
+    #[test]
+    fn current_host_does_not_require_a_change() {
+        assert!(matches!(host_change_required(1, 3, 1), Ok(false)));
+    }
+
+    #[test]
+    fn different_valid_host_requires_a_change() {
+        assert!(matches!(host_change_required(0, 3, 2), Ok(true)));
+    }
+
+    #[test]
+    fn host_outside_device_range_is_rejected() {
+        assert!(host_change_required(0, 2, 2).is_err());
+    }
+
+    #[test]
+    fn diverted_cleanup_restores_only_the_original_temporary_bits() {
+        let change = restoration_change(ArmedControl {
+            cid: 0x00d3,
+            host: 2,
+            mode: ReportingMode::Diverted,
+            original: reporting(true, true, false),
+        });
+
+        assert_eq!(change.diverted, Some(true));
+        assert_eq!(change.raw_xy, Some(true));
+        assert_eq!(change.analytics_key_events, None);
+        assert_eq!(change.persistently_diverted, None);
+        assert_eq!(change.remap, None);
+    }
+
+    #[test]
+    fn analytics_cleanup_restores_the_original_analytics_bit() {
+        let change = restoration_change(ArmedControl {
+            cid: 0x00d3,
+            host: 2,
+            mode: ReportingMode::Analytics,
+            original: reporting(false, false, true),
+        });
+
+        assert_eq!(change.analytics_key_events, Some(true));
+        assert_eq!(change.diverted, None);
+        assert_eq!(change.raw_xy, None);
+    }
+}
diff --git a/crates/openlogi-hid/src/inventory.rs b/crates/openlogi-hid/src/inventory.rs
index a95294e46b8e7675d3d6d69a833fa16acd3c2afc..bce818c32af7b62b1213ede2a5c9e43bfe0e32c8 100644
--- a/crates/openlogi-hid/src/inventory.rs
+++ b/crates/openlogi-hid/src/inventory.rs
@@ -2,6 +2,7 @@
 
 use std::{
     collections::{HashMap, HashSet},
+    hash::Hash,
     sync::Arc,
     time::Duration,
 };
@@ -13,7 +14,9 @@ use thiserror::Error;
 use tokio::time::timeout;
 use tracing::{debug, warn};
 
+use crate::channel_registry::ChannelRegistry;
 use crate::node_ledger::NodeLedger;
+use crate::route::DeviceRoute;
 use crate::transport::{enumerate_hidpp_devices, open_hidpp_channel};
 
 mod cache;
@@ -83,6 +86,9 @@ pub enum InventoryError {
     /// Underlying HID backend error.
     #[error("HID transport error")]
     Hid(#[from] async_hid::HidError),
+    /// More than one indistinguishable standalone raw-HID node was found.
+    #[error("multiple indistinguishable standalone raw HID devices found")]
+    AmbiguousRawDevice,
 }
 
 /// Stateful device enumerator: holds the per-device probe cache so the polling
@@ -100,11 +106,14 @@ pub struct Enumerator {
     /// each open also leaks an `io_service_t` in async-hid's macOS backend — so a
     /// steadily-connected node is opened once here and reused until it
     /// disconnects.
-    channels: HashMap<async_hid::DeviceId, CachedChannel>,
+    channels: ChannelCache<async_hid::DeviceId, CachedChannel>,
     /// Per-node last-good inventory + consecutive-failure counts: replays a
     /// node's snapshot through transient probe failures and decides when its
     /// cached channel must be dropped and reopened (see [`crate::node_ledger`]).
     ledger: NodeLedger<async_hid::DeviceId>,
+    /// Optional publication sink used by the persistent Agent watcher. One-shot
+    /// callers keep this `None` and retain the route-opening library behavior.
+    registry: Option<ChannelRegistry>,
     tick: u64,
 }
 
@@ -117,6 +126,102 @@ struct CachedChannel {
     channel: Arc<HidppChannel>,
 }
 
+struct PreparedNodes {
+    active: Vec<(async_hid::DeviceInfo, Arc<HidppChannel>)>,
+    open_failures: Vec<async_hid::DeviceId>,
+    retiring: Vec<async_hid::DeviceId>,
+}
+
+/// Disjoint active and retiring channels, generic so ownership transitions can
+/// be tested without constructing a platform HID node.
+struct ChannelCache<Node, Channel> {
+    active: HashMap<Node, Channel>,
+    retiring: HashMap<Node, Channel>,
+}
+
+impl<Node, Channel> Default for ChannelCache<Node, Channel> {
+    fn default() -> Self {
+        Self {
+            active: HashMap::new(),
+            retiring: HashMap::new(),
+        }
+    }
+}
+
+impl<Node: Eq + Hash + Clone, Channel> ChannelCache<Node, Channel> {
+    fn get(&self, node: &Node) -> Option<&Channel> {
+        self.active.get(node)
+    }
+
+    fn insert(&mut self, node: Node, channel: Channel) {
+        debug_assert!(!self.retiring.contains_key(&node));
+        self.active.insert(node, channel);
+    }
+
+    fn retire_node(&mut self, node: &Node) -> Option<()> {
+        let channel = self.active.remove(node)?;
+        self.retiring.insert(node.clone(), channel);
+        Some(())
+    }
+
+    /// Whether this node may be opened during the current tick. A quiescent
+    /// retirement is dropped here, but opening remains deferred to a later tick.
+    fn prepare_open(&mut self, node: &Node, is_quiescent: impl FnOnce(&Channel) -> bool) -> bool {
+        let Some(channel) = self.retiring.get(node) else {
+            return true;
+        };
+        if is_quiescent(channel) {
+            self.retiring.remove(node);
+        }
+        false
+    }
+
+    fn retire_absent(&mut self, seen: &HashSet<Node>) {
+        let absent = self
+            .active
+            .keys()
+            .filter(|node| !seen.contains(*node))
+            .cloned()
+            .collect::<Vec<_>>();
+        for node in absent {
+            let _ = self.retire_node(&node);
+        }
+    }
+
+    fn reap_absent(&mut self, seen: &HashSet<Node>, is_quiescent: impl Fn(&Channel) -> bool) {
+        self.retiring
+            .retain(|node, channel| seen.contains(node) || !is_quiescent(channel));
+    }
+
+    #[cfg(test)]
+    fn is_retiring(&self, node: &Node) -> bool {
+        self.retiring.contains_key(node)
+    }
+}
+
+fn routes_for_inventories(inventories: &[DeviceInventory]) -> Vec<DeviceRoute> {
+    inventories
+        .iter()
+        .flat_map(|inventory| {
+            inventory
+                .paired
+                .iter()
+                .filter_map(|paired| DeviceRoute::device_route_for(inventory, paired.slot))
+        })
+        .collect()
+}
+
+fn settle_unhealthy_node<Node: Eq + Hash + Clone>(
+    ledger: &mut NodeLedger<Node>,
+    node: &Node,
+    all_complete: &mut bool,
+    all_healthy: &mut bool,
+) -> Option<DeviceInventory> {
+    *all_complete = false;
+    *all_healthy = false;
+    ledger.settle(node, false, None).inventory
+}
+
 /// Enumerate all Logitech HID++ receivers visible to the current process and
 /// the devices paired to each.
 ///
@@ -203,7 +308,122 @@ const ONESHOT_ATTEMPTS: u8 = 4;
 /// asleep device, so a short pause lets the next attempt read it cleanly.
 const ONESHOT_RETRY_DELAY: Duration = Duration::from_millis(300);
 
+/// Nodes that remain valid for this tick: everything the OS enumerated plus
+/// cached channels whose open transport still reports a live connection.
+fn retained_nodes<K>(
+    enumerated: &HashSet<K>,
+    cached_channels: impl IntoIterator<Item = (K, bool)>,
+) -> HashSet<K>
+where
+    K: Clone + Eq + Hash,
+{
+    let mut retained = enumerated.clone();
+    retained.extend(
+        cached_channels
+            .into_iter()
+            .filter_map(|(node, connected)| connected.then_some(node)),
+    );
+    retained
+}
+
+/// Add cached channels omitted by this OS enumeration while their open
+/// transport still reports a live connection.
+fn append_live_cached_channels(
+    nodes: &mut HashSet<async_hid::DeviceId>,
+    channels: &ChannelCache<async_hid::DeviceId, CachedChannel>,
+    active: &mut Vec<(async_hid::DeviceInfo, Arc<HidppChannel>)>,
+) {
+    let retained = retained_nodes(
+        nodes,
+        channels
+            .active
+            .iter()
+            .map(|(node, open)| (node.clone(), open.channel.is_connected())),
+    );
+    for node in retained.difference(nodes) {
+        if let Some(open) = channels.get(node) {
+            debug!(
+                ?node,
+                name = %open.info.name,
+                "OS enumeration omitted a live HID node; probing cached channel"
+            );
+            active.push((open.info.clone(), Arc::clone(&open.channel)));
+        }
+    }
+    *nodes = retained;
+}
+
 impl Enumerator {
+    /// Build a persistent enumerator that publishes its already-open channels
+    /// into `registry` after each settled inventory tick.
+    #[must_use]
+    pub fn with_registry(registry: ChannelRegistry) -> Self {
+        Self {
+            registry: Some(registry),
+            ..Self::default()
+        }
+    }
+
+    async fn prepare_nodes(&mut self, candidates: Vec<async_hid::Device>) -> PreparedNodes {
+        let mut active = Vec::new();
+        let mut seen_nodes = HashSet::new();
+        let mut open_failures = Vec::new();
+        let mut retiring = Vec::new();
+        for dev in candidates {
+            let node = dev.id.clone();
+            seen_nodes.insert(node.clone());
+            if !self
+                .channels
+                .prepare_open(&node, |cached| Arc::strong_count(&cached.channel) == 1)
+            {
+                retiring.push(node);
+                continue;
+            }
+            if let Some(open) = self.channels.get(&node) {
+                active.push((open.info.clone(), Arc::clone(&open.channel)));
+                continue;
+            }
+            match open_hidpp_channel(dev).await {
+                Ok(Some((info, channel))) => {
+                    self.channels.insert(
+                        node,
+                        CachedChannel {
+                            info: info.clone(),
+                            channel: Arc::clone(&channel),
+                        },
+                    );
+                    active.push((info, channel));
+                }
+                Ok(None) => {}
+                Err(e) => {
+                    warn!(error = ?e, "failed to open HID++ channel — retrying next tick");
+                    open_failures.push(node);
+                }
+            }
+        }
+
+        // IOHIDManager can temporarily omit a Bluetooth device's vendor HID++
+        // collection while its already-open handle and ordinary mouse link are
+        // still live. Keep probing that cached channel instead of turning one
+        // incomplete OS snapshot into an offline device and stopping capture.
+        append_live_cached_channels(&mut seen_nodes, &self.channels, &mut active);
+
+        if let Some(registry) = &self.registry {
+            registry.retain_nodes(&seen_nodes);
+        }
+        self.channels.retire_absent(&seen_nodes);
+        self.channels.reap_absent(&seen_nodes, |cached| {
+            Arc::strong_count(&cached.channel) == 1
+        });
+        self.ledger.retain_nodes(&seen_nodes);
+
+        PreparedNodes {
+            active,
+            open_failures,
+            retiring,
+        }
+    }
+
     /// One enumeration pass, reusing the cache from prior passes. Probes every
     /// HID candidate concurrently (so one asleep node that burns the whole
     /// `PROBE_BUDGET` can't stall the others), reusing each device's cached
@@ -236,48 +456,13 @@ impl Enumerator {
         let candidates = enumerate_hidpp_devices().await?;
         debug!(count = candidates.len(), "HID++ candidate interfaces");
 
-        // Reuse an open channel per node, opening one only for a node seen for
-        // the first time. Sequential because opening mutates the channel cache,
-        // but in steady state every node is already cached so this is just
-        // lookups — an actual open happens only when a new device appears.
-        let mut active: Vec<(async_hid::DeviceInfo, Arc<HidppChannel>)> = Vec::new();
-        let mut seen_nodes: HashSet<async_hid::DeviceId> = HashSet::new();
-        let mut open_failures: Vec<async_hid::DeviceId> = Vec::new();
-        for dev in candidates {
-            let node = dev.id.clone();
-            seen_nodes.insert(node.clone());
-            if let Some(open) = self.channels.get(&node) {
-                active.push((open.info.clone(), Arc::clone(&open.channel)));
-                continue;
-            }
-            match open_hidpp_channel(dev).await {
-                Ok(Some((info, channel))) => {
-                    self.channels.insert(
-                        node,
-                        CachedChannel {
-                            info: info.clone(),
-                            channel: Arc::clone(&channel),
-                        },
-                    );
-                    active.push((info, channel));
-                }
-                Ok(None) => {} // speaks HID but not HID++ — not one of ours
-                // The node is listed but unreachable right now — settled as a
-                // failed probe below, so its last inventory is replayed.
-                Err(e) => {
-                    warn!(error = ?e, "failed to open HID++ channel — retrying next tick");
-                    open_failures.push(node);
-                }
-            }
-        }
-        // Drop channels for nodes that vanished this tick. A node missing from
-        // the enumeration is a real disconnect (the IOHIDManager device set is
-        // authoritative, unlike a HID++ probe timeout), so close the device and
-        // join its read thread now instead of leaving a dead channel behind; a
-        // reconnect re-opens under a fresh node id. The ledger forgets vanished
-        // nodes for the same reason — a true disconnect must not be replayed.
-        self.channels.retain(|node, _| seen_nodes.contains(node));
-        self.ledger.retain_nodes(&seen_nodes);
+        // Reuse an open channel per node, opening only when no active or
+        // retiring connection owns that OS node.
+        let PreparedNodes {
+            active,
+            open_failures,
+            retiring: retiring_nodes,
+        } = self.prepare_nodes(candidates).await;
 
         // Probe each open channel concurrently, sharing `&cache` read-only;
         // updates are collected and applied afterwards (no `RefCell`).
@@ -287,8 +472,12 @@ impl Enumerator {
                 .into_iter()
                 .map(|(info, channel)| async move {
                     let node = info.id.clone();
-                    let probe = timeout(PROBE_BUDGET, probe_one(info, channel, cache, tick)).await;
-                    (node, probe)
+                    let probe = timeout(
+                        PROBE_BUDGET,
+                        probe_one(info, Arc::clone(&channel), cache, tick),
+                    )
+                    .await;
+                    (node, channel, probe)
                 })
                 .collect::<Vec<_>>()
                 .join()
@@ -303,7 +492,7 @@ impl Enumerator {
         // governed by `probe.healthy`.
         let mut all_complete = true;
         let mut all_healthy = true;
-        for (node, result) in results {
+        for (node, channel, result) in results {
             let probe = if let Ok(probe) = result {
                 probe
             } else {
@@ -318,18 +507,47 @@ impl Enumerator {
             all_healthy &= probe.healthy;
             outcomes.extend(probe.outcomes);
             let settled = self.ledger.settle(&node, probe.healthy, probe.inventory);
-            if settled.evict_channel && self.channels.remove(&node).is_some() {
-                warn!("node probe keeps failing — dropping its channel to reopen next tick");
+            if settled.evict_channel {
+                if let Some(registry) = &self.registry {
+                    registry.remove_node(&node);
+                }
+                if self.channels.retire_node(&node).is_some() {
+                    warn!("node probe keeps failing — retiring its channel before reopen");
+                }
+            } else if let Some(registry) = &self.registry {
+                let routes = settled
+                    .inventory
+                    .as_ref()
+                    .map_or_else(Vec::new, |inventory| {
+                        routes_for_inventories(std::slice::from_ref(inventory))
+                    });
+                if routes.is_empty() {
+                    registry.remove_node(&node);
+                } else {
+                    registry.replace_node(node.clone(), routes, channel);
+                }
             }
             inventories.extend(settled.inventory);
         }
+        // A listed node whose old connection is still retiring is an unhealthy
+        // probe, not a disconnect: preserve the ledger's normal replay grace.
+        for node in retiring_nodes {
+            inventories.extend(settle_unhealthy_node(
+                &mut self.ledger,
+                &node,
+                &mut all_complete,
+                &mut all_healthy,
+            ));
+        }
         // Nodes that wouldn't open this tick still replay their last snapshot
         // (they have no cached channel to evict).
         for node in open_failures {
-            all_complete = false;
-            all_healthy = false;
-            let settled = self.ledger.settle(&node, false, None);
-            inventories.extend(settled.inventory);
+            inventories.extend(settle_unhealthy_node(
+                &mut self.ledger,
+                &node,
+                &mut all_complete,
+                &mut all_healthy,
+            ));
         }
 
         // Apply fresh probes and record which devices were seen this tick.
diff --git a/crates/openlogi-hid/src/inventory/cache.rs b/crates/openlogi-hid/src/inventory/cache.rs
index a2c7c94bffbfdd4b363960904f0a95b89b3be7b2..e20c384f50484ec786d2d309dd8b05aea95d5495 100644
--- a/crates/openlogi-hid/src/inventory/cache.rs
+++ b/crates/openlogi-hid/src/inventory/cache.rs
@@ -1,8 +1,9 @@
 use std::sync::Arc;
 
 use hidpp::channel::HidppChannel;
+use openlogi_core::device::{BatteryInfo, BatteryStatus};
 
-use super::features::{ProbedFeatures, probe_features, read_battery};
+use super::features::{BatteryProbe, ProbedFeatures, probe_features, read_battery};
 
 /// How many `enumerate` ticks a device's probe is reused before a fresh read.
 /// The expensive part of a probe (the `enumerate_features` feature-table walk)
@@ -42,14 +43,51 @@ pub(super) const CACHE_MISS_GRACE: u8 = 3;
 #[derive(Clone)]
 pub(super) struct Cached {
     pub(super) probe: ProbedFeatures,
-    /// Runtime index of the `UnifiedBattery` feature in this device's feature
-    /// table, captured by the full probe. Lets cache hits re-read the volatile
-    /// battery in one round-trip — no `Device::new` ping, no table walk.
-    /// `None` when the device exposes no `0x1004`.
-    pub(super) battery_index: Option<u8>,
+    /// Which battery feature this device exposes and its runtime index, captured
+    /// by the full probe. Lets cache hits re-read the volatile battery in one
+    /// round-trip — no `Device::new` ping, no table walk. `None` when the device
+    /// exposes neither `0x1004` nor the legacy `0x1000`.
+    pub(super) battery: Option<BatteryProbe>,
     pub(super) probed_tick: u64,
 }
 
+/// The legacy `0x1000` battery feature (MX2S-era mice) reports `discharge_level
+/// = 0` while charging — the firmware can't gauge charge under load, so the GUI
+/// would show a misleading "Charging · 0%". Carry the last-known percentage
+/// forward for the charge so the reading stays trackable.
+///
+/// A *frozen* pre-charge value, not a live charging %, because no device exposes
+/// that on `0x1000`. Only kicks in for the charging-and-zero sentinel; a genuine
+/// 0% while discharging (status != Charging) is untouched. Cold edge: app
+/// started while already charging has no prior, so it shows 0% until the first
+/// discharge read.
+fn hold_percentage_while_charging(
+    fresh: BatteryInfo,
+    prev: Option<&BatteryInfo>,
+    probe: BatteryProbe,
+) -> BatteryInfo {
+    // Scoped to the legacy 0x1000 quirk: a 0x1004 device that legitimately
+    // reports 0% while charging must surface that, not a stale prior reading.
+    if !matches!(probe, BatteryProbe::Legacy(_)) {
+        return fresh;
+    }
+    let charging = matches!(
+        fresh.status,
+        BatteryStatus::Charging | BatteryStatus::ChargingSlow
+    );
+    if charging
+        && fresh.percentage == 0
+        && let Some(p) = prev.filter(|p| p.percentage > 0)
+    {
+        return BatteryInfo {
+            percentage: p.percentage,
+            level: p.level,
+            status: fresh.status,
+        };
+    }
+    fresh
+}
+
 /// What a probed device contributes to the cache this tick. The key lets stale
 /// entries be evicted; `Fresh` (a full probe) and `Update` (a cache hit whose
 /// volatile battery was re-read) also carry the value to insert. `Unkeyed` is a
@@ -86,7 +124,14 @@ pub(super) async fn probe_or_reuse(
     tick: u64,
 ) -> (ProbedFeatures, CacheOutcome) {
     if online && cached.is_none_or(|c| is_stale(c, tick)) {
-        let (mut fresh, battery_index) = probe_features(channel, index).await;
+        let (mut fresh, battery) = probe_features(channel, index).await;
+        if let (Some(reading), Some(probe)) = (fresh.battery.take(), battery) {
+            fresh.battery = Some(hold_percentage_while_charging(
+                reading,
+                cached.and_then(|c| c.probe.battery.as_ref()),
+                probe,
+            ));
+        }
         // `capabilities` is `Some` exactly when the feature-table walk succeeded;
         // only then is the probe worth caching.
         if fresh.capabilities.is_some() {
@@ -104,7 +149,7 @@ pub(super) async fn probe_or_reuse(
                 Some(key) => {
                     let value = Cached {
                         probe: fresh.clone(),
-                        battery_index,
+                        battery,
                         probed_tick: tick,
                     };
                     (fresh, CacheOutcome::Fresh(key, value))
@@ -127,10 +172,12 @@ pub(super) async fn probe_or_reuse(
             // index and fold the reading back into the cache. A failed read
             // (asleep, mid-host-switch) keeps the last-known value.
             if online
-                && let Some(feature_index) = c.battery_index
+                && let Some(probe) = c.battery
                 && let Some(key) = id.clone()
-                && let Some(battery) = read_battery(channel, index, feature_index).await
+                && let Some(battery) = read_battery(channel, index, probe).await
             {
+                let battery =
+                    hold_percentage_while_charging(battery, c.probe.battery.as_ref(), probe);
                 let mut entry = c.clone();
                 entry.probe.battery = Some(battery);
                 return (entry.probe.clone(), CacheOutcome::Update(key, entry));
@@ -169,3 +216,58 @@ pub(super) fn backfill_identity(fresh: &mut ProbedFeatures, cached: &ProbedFeatu
         _ => {}
     }
 }
+
+#[cfg(test)]
+mod hold_tests {
+    use openlogi_core::device::{BatteryInfo, BatteryLevel, BatteryStatus};
+
+    use super::{BatteryProbe, hold_percentage_while_charging};
+
+    fn battery(percentage: u8, status: BatteryStatus) -> BatteryInfo {
+        BatteryInfo {
+            percentage,
+            level: BatteryLevel::Good,
+            status,
+        }
+    }
+
+    #[test]
+    fn charging_zero_holds_last_known_percentage() {
+        let legacy = BatteryProbe::Legacy(0);
+        let held = hold_percentage_while_charging(
+            battery(0, BatteryStatus::Charging),
+            Some(&battery(85, BatteryStatus::Discharging)),
+            legacy,
+        );
+        assert_eq!(held.percentage, 85);
+        assert_eq!(held.status, BatteryStatus::Charging);
+
+        let discharging = hold_percentage_while_charging(
+            battery(0, BatteryStatus::Discharging),
+            Some(&battery(85, BatteryStatus::Discharging)),
+            legacy,
+        );
+        assert_eq!(discharging.percentage, 0);
+
+        let live = hold_percentage_while_charging(
+            battery(40, BatteryStatus::Charging),
+            Some(&battery(85, BatteryStatus::Discharging)),
+            legacy,
+        );
+        assert_eq!(live.percentage, 40);
+
+        let cold =
+            hold_percentage_while_charging(battery(0, BatteryStatus::Charging), None, legacy);
+        assert_eq!(cold.percentage, 0);
+    }
+
+    #[test]
+    fn unified_charging_zero_is_not_held() {
+        let live = hold_percentage_while_charging(
+            battery(0, BatteryStatus::Charging),
+            Some(&battery(85, BatteryStatus::Discharging)),
+            BatteryProbe::Unified(0),
+        );
+        assert_eq!(live.percentage, 0);
+    }
+}
diff --git a/crates/openlogi-hid/src/inventory/features.rs b/crates/openlogi-hid/src/inventory/features.rs
index 3ee239c092a901f38f1c9dd14699c3208b0a2f06..593a504a8485f93069867f9c2fece33cc1ca8dea 100644
--- a/crates/openlogi-hid/src/inventory/features.rs
+++ b/crates/openlogi-hid/src/inventory/features.rs
@@ -5,7 +5,8 @@ use hidpp::{
     device::Device,
     feature::hires_wheel::HiResWheelFeature,
     feature::{
-        CreatableFeature, device_information::DeviceInformationFeature,
+        CreatableFeature, battery_status::BatteryStatusFeature,
+        device_information::DeviceInformationFeature,
         device_type_and_name::DeviceTypeAndNameFeature, gestures2::Gestures2Feature,
         unified_battery::UnifiedBatteryFeature,
     },
@@ -16,7 +17,8 @@ use openlogi_core::device::{
 use tracing::debug;
 
 use crate::mappings::{
-    map_battery_level, map_battery_status, map_device_type, normalize_serial_number,
+    legacy_battery_level_from_percentage, map_battery_level, map_battery_status, map_device_type,
+    map_legacy_battery_status, normalize_serial_number,
 };
 
 /// Everything a single device probe yields. Any field is `None` when the
@@ -37,37 +39,75 @@ pub(super) struct ProbedFeatures {
     pub(super) identity_incomplete: bool,
 }
 
-/// Read just the battery by addressing the `UnifiedBattery` feature at its
-/// known runtime `feature_index` — one round-trip, with no `Device::new` ping
-/// and no feature-table walk. This is both the full probe's battery read (the
-/// walk just produced the index) and the cheap per-tick refresh for cache hits.
-/// `None` when the device doesn't answer (asleep, switched hosts).
+/// Which battery feature a device exposes plus its runtime feature index. Newer
+/// devices answer the unified `0x1004`; MX2S-era ones only the legacy `0x1000`
+/// — the same enhanced-then-legacy split SmartShift has with `0x2111`/`0x2110`.
+#[derive(Clone, Copy, Debug, PartialEq, Eq)]
+pub(super) enum BatteryProbe {
+    Unified(u8),
+    Legacy(u8),
+}
+
+/// Read just the battery by addressing its feature at the known runtime index —
+/// one round-trip, with no `Device::new` ping and no feature-table walk. This is
+/// both the full probe's battery read (the walk just produced the index) and the
+/// cheap per-tick refresh for cache hits. `None` when the device doesn't answer
+/// (asleep, switched hosts).
 pub(super) async fn read_battery(
     channel: &Arc<HidppChannel>,
     slot: u8,
-    feature_index: u8,
+    probe: BatteryProbe,
 ) -> Option<BatteryInfo> {
-    let feature = UnifiedBatteryFeature::new(Arc::clone(channel), slot, feature_index);
-    feature
-        .get_battery_info()
-        .await
-        .ok()
-        .map(|info| BatteryInfo {
-            percentage: info.charging_percentage,
-            level: map_battery_level(info.level),
-            status: map_battery_status(info.status),
-        })
+    match probe {
+        BatteryProbe::Unified(feature_index) => {
+            let feature = UnifiedBatteryFeature::new(Arc::clone(channel), slot, feature_index);
+            feature
+                .get_battery_info()
+                .await
+                .ok()
+                .map(|info| BatteryInfo {
+                    percentage: info.charging_percentage,
+                    level: map_battery_level(info.level),
+                    status: map_battery_status(info.status),
+                })
+        }
+        BatteryProbe::Legacy(feature_index) => {
+            let feature = BatteryStatusFeature::new(Arc::clone(channel), slot, feature_index);
+            feature
+                .get_battery_level_status()
+                .await
+                .ok()
+                .map(|info| BatteryInfo {
+                    percentage: info.discharge_level,
+                    level: legacy_battery_level_from_percentage(info.discharge_level),
+                    status: map_legacy_battery_status(info.status),
+                })
+        }
+    }
 }
 
-/// Runtime index of the `UnifiedBattery` feature in an enumerated feature-ID
-/// table, for [`read_battery`]. The table is 1-based (index 0 is the implicit
-/// root feature, which enumeration omits).
-pub(super) fn battery_feature_index(ids: impl IntoIterator<Item = u16>) -> Option<u8> {
-    ids.into_iter()
-        .position(|id| id == UnifiedBatteryFeature::ID)
-        // A feature table holds at most `u8::MAX` entries (its count is a u8),
-        // so the 1-based index always fits.
-        .and_then(|pos| u8::try_from(pos + 1).ok())
+/// Locate a device's battery feature in an enumerated feature-ID table,
+/// preferring the unified `0x1004` and falling back to the legacy `0x1000`. The
+/// table is 1-based (index 0 is the implicit root feature, which enumeration
+/// omits).
+pub(super) fn battery_feature_index(ids: impl IntoIterator<Item = u16>) -> Option<BatteryProbe> {
+    // A feature table holds at most `u8::MAX` entries (its count is a u8), so a
+    // 1-based index always fits.
+    let mut legacy = None;
+    for (pos, id) in ids.into_iter().enumerate() {
+        // Stop gracefully past u8::MAX instead of `?`-returning None, which would
+        // discard a `legacy` already found. (The table caps at 255, so unreachable.)
+        let Ok(index) = u8::try_from(pos + 1) else {
+            break;
+        };
+        if id == UnifiedBatteryFeature::ID {
+            return Some(BatteryProbe::Unified(index));
+        }
+        if id == BatteryStatusFeature::ID && legacy.is_none() {
+            legacy = Some(BatteryProbe::Legacy(index));
+        }
+    }
+    legacy
 }
 
 /// Read the marketing identity from HID++ `0x0005` when the device exposes it.
@@ -104,14 +144,14 @@ async fn read_marketing_identity(
 /// `enumerate_features` — the feature table is the Vec that enumeration already
 /// returns, so capabilities cost no extra round-trip.
 ///
-/// Also returns the `UnifiedBattery` runtime index found by the walk, so later
-/// ticks can refresh the battery without repeating it.
+/// Also returns the battery feature found by the walk, so later ticks can
+/// refresh the battery without repeating it.
 ///
 /// Only online, responsive devices reach here.
 pub(super) async fn probe_features(
     channel: &Arc<HidppChannel>,
     slot: u8,
-) -> (ProbedFeatures, Option<u8>) {
+) -> (ProbedFeatures, Option<BatteryProbe>) {
     let mut device = match Device::new(Arc::clone(channel), slot).await {
         Ok(d) => d,
         Err(e) => {
@@ -121,11 +161,11 @@ pub(super) async fn probe_features(
     };
     // The enumeration response IS the device's feature-ID table — capture it
     // for capability derivation instead of discarding it.
-    let mut battery_index = None;
+    let mut battery_probe = None;
     let mut capabilities = match device.enumerate_features().await {
         Ok(Some(features)) => {
             let ids: Vec<u16> = features.iter().map(|f| f.id).collect();
-            battery_index = battery_feature_index(ids.iter().copied());
+            battery_probe = battery_feature_index(ids.iter().copied());
             Some(Capabilities::from_feature_ids(&ids))
         }
         Ok(None) => None,
@@ -152,8 +192,8 @@ pub(super) async fn probe_features(
         }
     }
 
-    let battery = match battery_index {
-        Some(feature_index) => read_battery(channel, slot, feature_index).await,
+    let battery = match battery_probe {
+        Some(probe) => read_battery(channel, slot, probe).await,
         None => None,
     };
 
@@ -210,29 +250,44 @@ pub(super) async fn probe_features(
             capabilities,
             identity_incomplete,
         },
-        battery_index,
+        battery_probe,
     )
 }
 
 #[cfg(test)]
 mod tests {
-    use hidpp::feature::{CreatableFeature as _, unified_battery::UnifiedBatteryFeature};
+    use hidpp::feature::{
+        CreatableFeature as _, battery_status::BatteryStatusFeature,
+        unified_battery::UnifiedBatteryFeature,
+    };
 
-    use super::battery_feature_index;
+    use super::{BatteryProbe, battery_feature_index};
 
     #[test]
     fn battery_index_is_one_based_in_the_enumerated_table() {
         // `enumerate_features` omits the root feature (index 0), so the first
         // enumerated entry sits at runtime index 1.
         let table = [0x0001, UnifiedBatteryFeature::ID, 0x2201];
-        assert_eq!(battery_feature_index(table), Some(2));
+        assert_eq!(battery_feature_index(table), Some(BatteryProbe::Unified(2)));
         assert_eq!(
             battery_feature_index([UnifiedBatteryFeature::ID]),
-            Some(1),
+            Some(BatteryProbe::Unified(1)),
             "first entry maps to index 1, not 0"
         );
     }
 
+    #[test]
+    fn legacy_battery_is_found_when_unified_is_absent() {
+        let table = [0x0001, BatteryStatusFeature::ID, 0x2201];
+        assert_eq!(battery_feature_index(table), Some(BatteryProbe::Legacy(2)));
+    }
+
+    #[test]
+    fn unified_battery_is_preferred_over_legacy() {
+        let table = [BatteryStatusFeature::ID, 0x0001, UnifiedBatteryFeature::ID];
+        assert_eq!(battery_feature_index(table), Some(BatteryProbe::Unified(3)));
+    }
+
     #[test]
     fn no_battery_feature_means_no_index() {
         assert_eq!(battery_feature_index([0x0001, 0x2201, 0x1b04]), None);
diff --git a/crates/openlogi-hid/src/inventory/probe.rs b/crates/openlogi-hid/src/inventory/probe.rs
index 6fcb4f93e7fbcd9d6306fe4ff20889203ea8412f..6ae7628972e62b838a397400c09e3e91633d81a1 100644
--- a/crates/openlogi-hid/src/inventory/probe.rs
+++ b/crates/openlogi-hid/src/inventory/probe.rs
@@ -3,6 +3,7 @@ use std::{collections::HashMap, sync::Arc};
 use futures_concurrency::future::Join as _;
 use hidpp::{
     channel::HidppChannel,
+    device::Device,
     receiver::{
         self, Receiver,
         bolt::{
@@ -586,39 +587,69 @@ async fn probe_unifying_slot(
     // online or not, and the crate's `event.online` reads the wrong notification
     // byte (payload[1] bit6, always set here — wire-verified `04 62 69 40`), so
     // neither tells us if the device is actually reachable on this receiver.
-    // We therefore always attempt the probe (passing `true`) and treat the
-    // feature walk succeeding as the real liveness signal below — a device that
-    // moved to Bluetooth answers `DeviceNotFound` and surfaces as offline.
+    // A cache hit must therefore still do one live round-trip: otherwise cached
+    // capabilities keep an absent device "online" forever and its reconnect is
+    // invisible to the agent's volatile-state re-apply/capture re-arm path.
     let probe_result = timeout(
         UNIFYING_SLOT_PROBE,
-        probe_or_reuse(channel, slot, Some(id.clone()), cached, true, tick),
+        probe_unifying_features(channel, slot, &id, cached, tick),
     )
     .await;
-    let (probe, outcome) = if let Ok(r) = probe_result {
+    let (probe, outcome, online) = if let Ok(r) = probe_result {
         r
     } else {
         debug!(slot, budget = ?UNIFYING_SLOT_PROBE,
             "Unifying slot probe timed out; using cached data if available");
         let probe = cached.map_or_else(ProbedFeatures::default, |c| c.probe.clone());
-        (probe, CacheOutcome::Seen(id))
+        (probe, CacheOutcome::Seen(id), false)
     };
 
-    let device = PairedDevice {
+    let device = assemble_unifying_device(slot, codename, event.wpid, register_kind, probe, online);
+    Some((device, outcome))
+}
+
+/// Return cached immutable features together with a fresh reachability result.
+///
+/// A successful full probe ([`CacheOutcome::Fresh`]) confirms liveness on a
+/// cache miss/stale entry. A fresh cached entry normally refreshes its battery,
+/// whose successful response ([`CacheOutcome::Update`]) is the liveness check.
+/// A failed battery refresh, or a device without that feature, gets a root ping
+/// before being treated as offline.
+pub(super) async fn probe_unifying_features(
+    channel: &Arc<HidppChannel>,
+    slot: u8,
+    id: &CacheKey,
+    cached: Option<&Cached>,
+    tick: u64,
+) -> (ProbedFeatures, CacheOutcome, bool) {
+    let (probe, outcome) =
+        probe_or_reuse(channel, slot, Some(id.clone()), cached, true, tick).await;
+    let online = if matches!(outcome, CacheOutcome::Fresh(..) | CacheOutcome::Update(..)) {
+        true
+    } else {
+        Device::new(Arc::clone(channel), slot).await.is_ok()
+    };
+    (probe, outcome, online)
+}
+
+pub(super) fn assemble_unifying_device(
+    slot: u8,
+    codename: Option<String>,
+    wpid: u16,
+    register_kind: DeviceKind,
+    probe: ProbedFeatures,
+    online: bool,
+) -> PairedDevice {
+    PairedDevice {
         slot,
         codename,
-        wpid: Some(event.wpid),
+        wpid: Some(wpid),
         kind: resolve_device_kind(probe.kind, register_kind),
-        // Reachable on this receiver iff the feature walk got through this tick.
-        // Caveat: a GUI cache hit can serve stale capabilities for up to
-        // REFRESH_TICKS after the device leaves for Bluetooth, briefly showing it
-        // online; self-heals on the next forced re-probe. Add a per-tick liveness
-        // ping if that window ever matters.
-        online: probe.capabilities.is_some(),
+        online,
         battery: probe.battery,
         model_info: probe.model_info,
         capabilities: probe.capabilities,
-    };
-    Some((device, outcome))
+    }
 }
 
 /// Reads a Unifying paired device's name. Unifying stores names at
diff --git a/crates/openlogi-hid/src/inventory/tests.rs b/crates/openlogi-hid/src/inventory/tests.rs
index 73968325b8c3357856bf8b26e064ea05cff1cf19..600a2a1762e84f958caddc146f19fd6d86153207 100644
--- a/crates/openlogi-hid/src/inventory/tests.rs
+++ b/crates/openlogi-hid/src/inventory/tests.rs
@@ -1,4 +1,5 @@
 use std::collections::HashSet;
+use std::sync::Arc;
 
 use openlogi_core::device::{
     DeviceInventory, DeviceKind, DeviceModelInfo, DeviceTransports, PairedDevice, ReceiverInfo,
@@ -10,13 +11,17 @@ use super::cache::{
 use super::probe::{
     NodeProbe, assemble_bolt_probe, parse_codename_unifying, preferred_direct_codename,
 };
-use super::{Enumerator, ONESHOT_ATTEMPTS, one_shot_should_stop};
+use super::{
+    ChannelCache, Enumerator, ONESHOT_ATTEMPTS, one_shot_should_stop, retained_nodes,
+    routes_for_inventories, settle_unhealthy_node,
+};
 use crate::inventory::features::ProbedFeatures;
+use crate::{DIRECT_DEVICE_INDEX, DeviceRoute};
 
 fn cache_entry(probed_tick: u64) -> Cached {
     Cached {
         probe: ProbedFeatures::default(),
-        battery_index: None,
+        battery: None,
         probed_tick,
     }
 }
@@ -76,7 +81,7 @@ fn being_seen_resets_the_miss_counter() {
 fn cached_probe_is_reused_until_refresh_ticks() {
     let cached = Cached {
         probe: ProbedFeatures::default(),
-        battery_index: None,
+        battery: None,
         probed_tick: 10,
     };
     assert!(!is_stale(&cached, 10), "same tick is fresh");
@@ -115,6 +120,138 @@ fn inventory(slots: &[u8]) -> Vec<DeviceInventory> {
     }]
 }
 
+#[test]
+fn settled_inventories_publish_exact_receiver_routes() {
+    assert_eq!(
+        routes_for_inventories(&inventory(&[1, 4])),
+        vec![
+            DeviceRoute::Unifying {
+                receiver_uid: "receiver-1".into(),
+                slot: 1,
+            },
+            DeviceRoute::Unifying {
+                receiver_uid: "receiver-1".into(),
+                slot: 4,
+            },
+        ]
+    );
+
+    assert_eq!(
+        routes_for_inventories(&inventory(&[4])),
+        vec![DeviceRoute::Unifying {
+            receiver_uid: "receiver-1".into(),
+            slot: 4,
+        }],
+        "a vanished slot must not survive the next atomic node replacement"
+    );
+}
+
+#[test]
+fn settled_direct_inventory_publishes_one_direct_route() {
+    let direct = vec![DeviceInventory {
+        receiver: ReceiverInfo {
+            name: "MX Keys".into(),
+            vendor_id: 0x046d,
+            product_id: 0xb35b,
+            unique_id: None,
+        },
+        paired: vec![PairedDevice {
+            slot: DIRECT_DEVICE_INDEX,
+            codename: Some("MX Keys".into()),
+            wpid: Some(0xb35b),
+            kind: DeviceKind::Keyboard,
+            online: true,
+            battery: None,
+            model_info: None,
+            capabilities: None,
+        }],
+    }];
+
+    assert_eq!(
+        routes_for_inventories(&direct),
+        vec![DeviceRoute::Direct {
+            vendor_id: 0x046d,
+            product_id: 0xb35b,
+        }]
+    );
+}
+
+#[test]
+fn channel_cache_retires_and_defers_reopen_until_a_later_tick() {
+    let mut cache = ChannelCache::<u8, Arc<()>>::default();
+    let channel = Arc::new(());
+    cache.insert(1, Arc::clone(&channel));
+
+    assert!(cache.retire_node(&1).is_some());
+    assert!(cache.get(&1).is_none());
+    assert!(!cache.prepare_open(&1, |channel| Arc::strong_count(channel) == 1));
+
+    drop(channel);
+    assert!(cache.is_retiring(&1));
+    assert!(
+        !cache.prepare_open(&1, |channel| Arc::strong_count(channel) == 1),
+        "the tick that drops retirement still skips opening"
+    );
+    assert!(!cache.is_retiring(&1));
+    assert!(
+        cache.prepare_open(&1, |channel| Arc::strong_count(channel) == 1),
+        "only a later tick may reopen"
+    );
+}
+
+#[test]
+fn absent_channels_retire_and_quiescent_absent_retirement_is_reaped() {
+    let mut cache = ChannelCache::<u8, Arc<()>>::default();
+    cache.insert(1, Arc::new(()));
+    cache.insert(2, Arc::new(()));
+
+    cache.retire_absent(&HashSet::from([2]));
+    assert!(cache.is_retiring(&1));
+    assert!(cache.get(&2).is_some());
+
+    cache.reap_absent(&HashSet::from([2]), |channel| {
+        Arc::strong_count(channel) == 1
+    });
+    assert!(!cache.is_retiring(&1));
+}
+
+#[test]
+fn retiring_node_replays_ledger_and_marks_tick_unhealthy() {
+    let mut ledger = crate::node_ledger::NodeLedger::<u8>::default();
+    let expected = inventory(&[1]);
+    let settled = ledger.settle(&1, true, Some(expected[0].clone()));
+    assert_eq!(settled.inventory, Some(expected[0].clone()));
+
+    let mut complete = true;
+    let mut healthy = true;
+    let replay = settle_unhealthy_node(&mut ledger, &1, &mut complete, &mut healthy);
+
+    assert_eq!(replay, Some(expected[0].clone()));
+    assert!(!complete);
+    assert!(!healthy);
+}
+
+#[test]
+fn retiring_node_inventory_expires_after_the_existing_ledger_grace() {
+    let mut ledger = crate::node_ledger::NodeLedger::<u8>::default();
+    let expected = inventory(&[1]);
+    ledger.settle(&1, true, Some(expected[0].clone()));
+
+    let mut complete = true;
+    let mut healthy = true;
+    for _ in 0..3 {
+        assert_eq!(
+            settle_unhealthy_node(&mut ledger, &1, &mut complete, &mut healthy),
+            Some(expected[0].clone())
+        );
+    }
+    assert_eq!(
+        settle_unhealthy_node(&mut ledger, &1, &mut complete, &mut healthy),
+        None,
+        "retirement must not extend stale inventory beyond ledger policy"
+    );
+}
+
 #[test]
 fn one_shot_retry_stops_when_first_attempt_is_complete() {
     let current = inventory(&[1, 2]);
@@ -384,3 +521,14 @@ fn codename_clamps_overlong_len() {
 fn codename_rejects_short_response() {
     assert_eq!(parse_codename_unifying(&[0x40]), None);
 }
+
+#[test]
+fn live_cached_channel_survives_a_transient_enumeration_gap() {
+    let enumerated = std::collections::HashSet::from([1_u8]);
+    let cached_channels = [(1_u8, true), (2_u8, true), (3_u8, false)];
+    let retained = retained_nodes(&enumerated, cached_channels);
+    assert!(retained.contains(&1));
+    assert!(retained.contains(&2));
+    assert!(!retained.contains(&3));
+    assert_eq!(retained, std::collections::HashSet::from([1, 2]));
+}
diff --git a/crates/openlogi-hid/src/keyboard.rs b/crates/openlogi-hid/src/keyboard.rs
new file mode 100644
index 0000000000000000000000000000000000000000..805f269ace32d84eafa8b34f6779bb8bbeaf9ecc
--- /dev/null
+++ b/crates/openlogi-hid/src/keyboard.rs
@@ -0,0 +1,260 @@
+//! Live key capture for one keyboard: divert the bound F-row controls over
+//! HID++ `0x1b04` and turn their presses into [`CapturedInput`] the agent can
+//! dispatch.
+//!
+//! [`run_keyboard_capture_session`] is the keyboard counterpart of
+//! [`crate::gesture::run_capture_session`]: one open channel, diversion armed
+//! on exactly the controls the caller asks for (an unbound key is never
+//! diverted, so it keeps its native firmware function), one message listener,
+//! and every diverted control handed back to the firmware on shutdown.
+//!
+//! Diversion works on the key's *control* — the printed media/shortcut
+//! function — so it fires when Fn-lock is off (or via Fn+key when it is on).
+//! The plain F1–F12 codes of an Fn-locked row travel the ordinary HID keyboard
+//! interface and never reach `0x1b04`.
+
+use std::collections::{BTreeMap, BTreeSet};
+use std::sync::{Arc, Mutex, PoisonError};
+
+use hidpp::{
+    device::Device,
+    feature::{
+        CreatableFeature, EmittingFeature,
+        wireless_device_status::{WirelessDeviceStatusEvent, WirelessDeviceStatusFeature},
+    },
+    protocol::v20,
+};
+use openlogi_core::binding::ButtonId;
+use tokio::sync::{mpsc, oneshot};
+use tracing::{debug, info, warn};
+
+use crate::channel_registry::ChannelRegistry;
+use crate::gesture::{CaptureChannel, CapturedInput, GestureError, enumerate_controls, restore};
+use crate::reprog_controls::{self, RawControlEvent, ReprogControlsV4};
+use crate::route::{DeviceRoute, open_route_channel};
+use crate::write::SharedChannel;
+
+/// The divertable keyboard F-row controls OpenLogi models, as
+/// `(0x1b04 control ID, ButtonId)` pairs. CID values match Logitech's control
+/// catalog (cross-checked against Solaar's `special_keys.py`); the F-row
+/// positions are the Signature-series layout.
+pub const KEYBOARD_KEY_CIDS: [(u16, ButtonId); 9] = [
+    (0x00d4, ButtonId::KeySearch),
+    (0x0103, ButtonId::KeyDictation),
+    (0x0108, ButtonId::KeyEmoji),
+    (0x010a, ButtonId::KeyScreenCapture),
+    (0x011c, ButtonId::KeyMicMute),
+    (0x00e5, ButtonId::KeyPlayPause),
+    (0x00e7, ButtonId::KeyMute),
+    (0x00e8, ButtonId::KeyVolumeDown),
+    (0x00e9, ButtonId::KeyVolumeUp),
+];
+
+/// Capture the requested keyboard controls on `route` until `shutdown`
+/// resolves, forwarding a [`CapturedInput::ButtonPressed`] on each press
+/// (rising edge) to `sink`.
+///
+/// `wanted` maps `0x1b04` control IDs to the [`ButtonId`] they dispatch as —
+/// the caller passes only the keys that carry a real binding. Controls the
+/// device doesn't expose (or can't divert) are skipped with a debug log, so a
+/// partially-supported keyboard degrades per key rather than failing whole.
+pub async fn run_keyboard_capture_session(
+    route: DeviceRoute,
+    wanted: BTreeMap<u16, ButtonId>,
+    sink: mpsc::UnboundedSender<CapturedInput>,
+    shutdown: oneshot::Receiver<()>,
+    channel_slot: CaptureChannel,
+) -> Result<(), GestureError> {
+    let chan = open_route_channel(&route)
+        .await?
+        .ok_or(GestureError::DeviceNotFound)?;
+    let shared = SharedChannel::new(chan, route.clone());
+    run_keyboard_capture_session_on(route, shared, wanted, sink, shutdown, channel_slot).await
+}
+
+/// Run keyboard capture on the exact channel currently published by `registry`.
+///
+/// A registry miss returns [`GestureError::DeviceNotFound`] without falling
+/// back to route enumeration/opening; the agent watcher retries after a later
+/// inventory publication.
+pub async fn run_keyboard_capture_session_with_registry(
+    route: DeviceRoute,
+    wanted: BTreeMap<u16, ButtonId>,
+    sink: mpsc::UnboundedSender<CapturedInput>,
+    shutdown: oneshot::Receiver<()>,
+    channel_slot: CaptureChannel,
+    registry: &ChannelRegistry,
+) -> Result<(), GestureError> {
+    let shared = registry
+        .lookup(&route)
+        .ok_or(GestureError::DeviceNotFound)?;
+    run_keyboard_capture_session_on(route, shared, wanted, sink, shutdown, channel_slot).await
+}
+
+async fn run_keyboard_capture_session_on(
+    route: DeviceRoute,
+    shared: SharedChannel,
+    wanted: BTreeMap<u16, ButtonId>,
+    sink: mpsc::UnboundedSender<CapturedInput>,
+    shutdown: oneshot::Receiver<()>,
+    channel_slot: CaptureChannel,
+) -> Result<(), GestureError> {
+    let chan = Arc::clone(shared.channel());
+    let device_index = route.device_index();
+    let device = Device::new(Arc::clone(&chan), device_index)
+        .await
+        .map_err(|_| GestureError::DeviceUnreachable(device_index))?;
+
+    let info = device
+        .root()
+        .get_feature(reprog_controls::FEATURE_ID)
+        .await
+        .map_err(|e| GestureError::Hidpp(format!("{e:?}")))?
+        .ok_or_else(|| GestureError::Hidpp("keyboard exposes no 0x1b04 reprog controls".into()))?;
+    let rc = ReprogControlsV4::new(Arc::clone(&chan), device_index, info.index);
+    let controls = enumerate_controls(&rc).await?;
+
+    let diverted = arm_keys(&rc, &controls, &wanted).await?;
+
+    // Rising-edge press state per CID. Behind a `Mutex` because the channel's
+    // read thread invokes the listener by shared reference.
+    let held: Arc<Mutex<BTreeSet<u16>>> = Arc::new(Mutex::new(BTreeSet::new()));
+    let feature_index = info.index;
+    let listener = chan.add_msg_listener_guarded({
+        let held = Arc::clone(&held);
+        let diverted = diverted.clone();
+        let sink = sink.clone();
+        move |raw, matched| {
+            if matched {
+                return;
+            }
+            let msg = v20::Message::from(raw);
+            let Some(RawControlEvent::DivertedButtons(cids)) =
+                reprog_controls::decode_event(&msg, device_index, feature_index)
+            else {
+                return;
+            };
+            // Recover the guard even if a prior holder panicked — the critical
+            // section is panic-free, so the data is consistent.
+            let mut down = held.lock().unwrap_or_else(PoisonError::into_inner);
+            for (&cid, &button) in &diverted {
+                let now = cids.contains(&cid);
+                let was = down.contains(&cid);
+                if now && !was {
+                    let _ = sink.send(CapturedInput::ButtonPressed(button, None));
+                }
+                if now {
+                    down.insert(cid);
+                } else {
+                    down.remove(&cid);
+                }
+            }
+        }
+    });
+
+    // Wireless keyboards drop their diverted-control state when they
+    // power-cycle (idle sleep, power switch, Easy-Switch host change) — the
+    // reconnection broadcast on `0x1d4b` is the firmware asking the host to
+    // reconfigure. Re-arm the diversion on every broadcast, or the bound keys
+    // silently revert to their native functions after the first nap.
+    let wireless = device
+        .root()
+        .get_feature(WirelessDeviceStatusFeature::ID)
+        .await
+        .ok()
+        .flatten()
+        .map(|info| WirelessDeviceStatusFeature::new(Arc::clone(&chan), device_index, info.index));
+    let wake_events = wireless.as_ref().map(EmittingFeature::listen);
+
+    // Publish this keyboard's open channel so hardware writes (Fn-lock)
+    // reuse it instead of opening the same HID node a second time. Cleared
+    // on the way out.
+    if let Ok(mut slot) = channel_slot.write() {
+        *slot = Some(shared);
+    }
+
+    info!(
+        index = device_index,
+        keys = diverted.len(),
+        wake_rearm = wake_events.is_some(),
+        "keyboard key capture active"
+    );
+    let mut shutdown = shutdown;
+    match wake_events {
+        None => {
+            let _ = shutdown.await;
+        }
+        Some(wake_events) => loop {
+            tokio::select! {
+                _ = &mut shutdown => break,
+                event = wake_events.recv() => {
+                    let Ok(WirelessDeviceStatusEvent::StatusBroadcast(broadcast)) = event else {
+                        // Emitter gone (feature dropped) — nothing left to
+                        // watch; fall back to a plain shutdown wait.
+                        let _ = shutdown.await;
+                        break;
+                    };
+                    info!(?broadcast, "keyboard reconnected — re-arming key diversion");
+                    rearm_keys(&rc, &diverted).await;
+                }
+            }
+        },
+    }
+
+    drop(listener);
+    if let Ok(mut slot) = channel_slot.write() {
+        *slot = None;
+    }
+    for &cid in diverted.keys() {
+        restore(
+            rc.set_cid_reporting(cid, false, false).await,
+            "keyboard key",
+        );
+    }
+    debug!(index = device_index, "keyboard key capture stopped");
+    Ok(())
+}
+
+/// Divert every wanted control the keyboard exposes as divertable, returning
+/// the armed `CID → ButtonId` subset. Missing / non-divertable controls are
+/// skipped with a debug log, so a partially-supported keyboard degrades per
+/// key rather than failing whole.
+async fn arm_keys(
+    rc: &ReprogControlsV4,
+    controls: &[reprog_controls::CtrlIdInfo],
+    wanted: &BTreeMap<u16, ButtonId>,
+) -> Result<BTreeMap<u16, ButtonId>, GestureError> {
+    let mut diverted = BTreeMap::new();
+    for (&cid, &button) in wanted {
+        if controls.iter().any(|c| c.cid == cid && c.is_divertable()) {
+            rc.set_cid_reporting(cid, true, false)
+                .await
+                .map_err(|e| GestureError::Hidpp(format!("{e:?}")))?;
+            diverted.insert(cid, button);
+        } else {
+            debug!(
+                cid = format_args!("{cid:#06x}"),
+                "bound key not divertable on this keyboard — left native"
+            );
+        }
+    }
+    Ok(diverted)
+}
+
+/// Re-issue diversion for every armed control after a device power-cycle.
+/// Failures are logged, not propagated — the next reconnection broadcast
+/// retries.
+async fn rearm_keys(rc: &ReprogControlsV4, diverted: &BTreeMap<u16, ButtonId>) {
+    // A settling pause: the broadcast arrives the instant the link is back,
+    // occasionally before the device accepts feature writes again.
+    tokio::time::sleep(std::time::Duration::from_millis(200)).await;
+    for &cid in diverted.keys() {
+        if let Err(e) = rc.set_cid_reporting(cid, true, false).await {
+            warn!(
+                cid = format_args!("{cid:#06x}"),
+                error = ?e,
+                "re-divert after wake failed — key stays native until next wake"
+            );
+        }
+    }
+}
diff --git a/crates/openlogi-hid/src/lib.rs b/crates/openlogi-hid/src/lib.rs
index b6cf154757cbc3c5c26b5cc5f340cf3fbfb95d4a..e847e55d5b4186cd56925983ac0662d0eea005f9 100644
--- a/crates/openlogi-hid/src/lib.rs
+++ b/crates/openlogi-hid/src/lib.rs
@@ -10,43 +10,65 @@
 #![deny(rustdoc::bare_urls)]
 #![deny(rustdoc::broken_intra_doc_links)]
 
+mod channel_pool;
+mod channel_registry;
+pub mod host_switch;
 mod mappings;
 mod node_ledger;
 mod route;
+mod standalone;
 mod transport;
 // Native Win32 HID report-write fallback, used by the Windows composite channel
 // in `transport` when async-hid's async write path fails.
 #[cfg(target_os = "windows")]
 mod windows_hid;
 
+pub mod backlight;
 pub mod gesture;
 mod hires_wheel;
 pub mod hotplug;
 pub mod inventory;
+pub mod keyboard;
 pub mod pairing;
 pub mod reprog_controls;
 pub mod smartshift;
 pub mod thumbwheel;
 pub mod write;
 
-pub use gesture::{CaptureChannel, CapturedInput, GestureError, run_capture_session};
+pub use backlight::{BacklightMode, BacklightState, BacklightStatus};
+pub use channel_pool::ChannelPool;
+pub use channel_registry::ChannelRegistry;
+pub use gesture::{
+    CaptureChannel, CaptureStop, CapturedInput, GestureError, run_capture_session,
+    run_capture_session_with_registry, run_capture_session_with_stop_reason,
+};
 pub use hires_wheel::{
     ScrollReportingTarget, ScrollResolution, ScrollWheelMode, get_scroll_wheel_mode,
     get_scroll_wheel_mode_on, set_scroll_inversion, set_scroll_inversion_on, set_scroll_resolution,
     set_scroll_resolution_on, set_scroll_wheel_mode, set_scroll_wheel_mode_on,
 };
+pub use host_switch::{
+    HostSwitchError, HostSwitchStopReason, run_host_switch_session, switch_linked_hosts,
+};
 pub use hotplug::{HotplugEvent, watch_hotplug};
 pub use inventory::{Enumerator, InventoryError, enumerate};
+pub use keyboard::{
+    KEYBOARD_KEY_CIDS, run_keyboard_capture_session, run_keyboard_capture_session_with_registry,
+};
 pub use pairing::{
     Click, DiscoveredDevice, PairingCommand, PairingError, PairingEvent, PairingReceiver,
     PasskeyMethod, ReceiverFamily, ReceiverSelector, list_pairing_receivers, run_pairing, unpair,
 };
 pub use route::{BOLT_PIDS, DIRECT_DEVICE_INDEX, DeviceRoute, UNIFYING_PIDS};
 pub use smartshift::{AUTO_DISENGAGE_PERMANENT, SmartShiftMode, SmartShiftStatus};
+pub use standalone::enumerate_standalone;
 pub use write::{
-    DpiCapabilities, DpiInfo, FeatureEntry, HidppFeatureErrorKind, HidppOperation, LightingMethod,
-    ReprogControlEntry, SharedChannel, WriteError, dump_features, dump_reprog_controls, get_dpi,
-    get_dpi_info, get_smartshift_status, set_dpi, set_dpi_on, set_keyboard_color,
-    set_keyboard_color_with, set_smartshift, set_smartshift_on, set_smartshift_sensitivity,
-    toggle_smartshift, toggle_smartshift_on,
+    DpiCapabilities, DpiInfo, FeatureEntry, HidppFeatureErrorKind, HidppOperation, LightCommand,
+    LightingMethod, LitraModel, ReprogControlEntry, SharedChannel, WriteError, apply_litra,
+    commands_for_light_settings, dump_features, dump_reprog_controls, encode_litra_command,
+    get_backlight, get_dpi, get_dpi_info, get_dpi_info_on, get_smartshift_status,
+    get_smartshift_status_on, matches_litra, read_battery_raw, set_backlight_enabled, set_dpi,
+    set_dpi_on, set_fn_lock, set_fn_lock_on, set_keyboard_color, set_keyboard_color_on,
+    set_keyboard_color_with, set_keyboard_color_with_on, set_smartshift, set_smartshift_on,
+    set_smartshift_sensitivity, toggle_smartshift, toggle_smartshift_on,
 };
diff --git a/crates/openlogi-hid/src/mappings.rs b/crates/openlogi-hid/src/mappings.rs
index f6f456c534faed1bd2a1fcf9b374b82fd570ce11..97fef59c19d4f003ded2658568a2c8857b84bdc5 100644
--- a/crates/openlogi-hid/src/mappings.rs
+++ b/crates/openlogi-hid/src/mappings.rs
@@ -3,6 +3,7 @@
 //! battery level/status, and serial-number normalisation. No I/O — split from
 //! `inventory` purely to keep that file within size bounds.
 
+use hidpp::feature::battery_status::LegacyBatteryStatus as HidppLegacyBatteryStatus;
 use hidpp::feature::device_type_and_name::DeviceType as HidppDeviceType;
 use hidpp::feature::unified_battery::{
     BatteryLevel as HidppBatteryLevel, BatteryStatus as HidppBatteryStatus,
@@ -116,9 +117,45 @@ pub(crate) fn map_battery_status(status: HidppBatteryStatus) -> BatteryStatus {
     }
 }
 
+/// Map a legacy `0x1000` charging status to our [`BatteryStatus`].
+pub(crate) fn map_legacy_battery_status(status: HidppLegacyBatteryStatus) -> BatteryStatus {
+    match status {
+        HidppLegacyBatteryStatus::Discharging => BatteryStatus::Discharging,
+        // The legacy feature splits "charging" into recharging / almost-full;
+        // both are just "charging" to us.
+        HidppLegacyBatteryStatus::Recharging | HidppLegacyBatteryStatus::AlmostFull => {
+            BatteryStatus::Charging
+        }
+        HidppLegacyBatteryStatus::SlowRecharge => BatteryStatus::ChargingSlow,
+        HidppLegacyBatteryStatus::Full => BatteryStatus::Full,
+        HidppLegacyBatteryStatus::InvalidBattery | HidppLegacyBatteryStatus::ThermalError => {
+            BatteryStatus::Error
+        }
+        _ => BatteryStatus::Unknown,
+    }
+}
+
+/// Derive a coarse [`BatteryLevel`] from a discharge percentage. The legacy
+/// `0x1000` feature reports a percentage but, unlike `0x1004`, no level bitmask,
+/// so the bucket is ours to pick.
+///
+/// ponytail: fixed display buckets, not device thresholds. Lift to the device's
+/// own thresholds only if `0x1000`'s capability query (function 1) is wired up.
+pub(crate) fn legacy_battery_level_from_percentage(percentage: u8) -> BatteryLevel {
+    match percentage {
+        90..=u8::MAX => BatteryLevel::Full,
+        50..=89 => BatteryLevel::Good,
+        20..=49 => BatteryLevel::Low,
+        _ => BatteryLevel::Critical,
+    }
+}
+
 #[cfg(test)]
 mod tests {
-    use super::{DeviceKind, UnifyingDeviceKind, map_unifying_kind, resolve_device_kind};
+    use super::{
+        BatteryLevel, DeviceKind, UnifyingDeviceKind, legacy_battery_level_from_percentage,
+        map_unifying_kind, resolve_device_kind,
+    };
 
     #[test]
     fn probe_overrides_a_misreporting_register() {
@@ -159,6 +196,38 @@ mod tests {
         );
     }
 
+    #[test]
+    fn legacy_percentage_buckets_into_levels() {
+        assert_eq!(
+            legacy_battery_level_from_percentage(100),
+            BatteryLevel::Full
+        );
+        assert_eq!(legacy_battery_level_from_percentage(90), BatteryLevel::Full);
+        assert_eq!(legacy_battery_level_from_percentage(89), BatteryLevel::Good);
+        assert_eq!(legacy_battery_level_from_percentage(50), BatteryLevel::Good);
+        assert_eq!(legacy_battery_level_from_percentage(49), BatteryLevel::Low);
+        assert_eq!(legacy_battery_level_from_percentage(20), BatteryLevel::Low);
+        assert_eq!(
+            legacy_battery_level_from_percentage(19),
+            BatteryLevel::Critical
+        );
+        assert_eq!(
+            legacy_battery_level_from_percentage(0),
+            BatteryLevel::Critical
+        );
+    }
+
+    #[test]
+    fn legacy_status_value_7_maps_to_unknown_not_vanish() {
+        use super::{BatteryStatus, HidppLegacyBatteryStatus, map_legacy_battery_status};
+        // Value 7 ("other charging error") must parse and surface as Unknown so
+        // the battery indicator stays visible instead of disappearing.
+        let mapped = HidppLegacyBatteryStatus::try_from(7u8)
+            .ok()
+            .map(map_legacy_battery_status);
+        assert_eq!(mapped, Some(BatteryStatus::Unknown));
+    }
+
     #[test]
     fn unifying_kind_maps_all_variants() {
         let cases = [
diff --git a/crates/openlogi-hid/src/reprog_controls.rs b/crates/openlogi-hid/src/reprog_controls.rs
index c25d4e3b75267e95d3c833d73ab7254ceff3aa7c..32c7521ba6fbf722efd2e61011a9bc04a9393f61 100644
--- a/crates/openlogi-hid/src/reprog_controls.rs
+++ b/crates/openlogi-hid/src/reprog_controls.rs
@@ -30,6 +30,7 @@ pub use hidpp_reprog::{
     ControlId, GroupMask, RawWheelResolution, ReprogControlsCapabilities, ReprogControlsEvent,
     TaskId, decode_event as decode_full_event,
 };
+pub use hidpp_reprog::{control_ids, task_ids};
 
 /// `ReprogControlsV4` HID++ feature ID.
 pub const FEATURE_ID: u16 = 0x1b04;
@@ -51,6 +52,28 @@ pub const GESTURE_BUTTON_CID: u16 = 0x00c3;
 /// cross-checked against Solaar `special_keys.py`.
 pub const DPI_MODE_SHIFT_CIDS: [u16; 3] = [0x00c4, 0x00ed, 0x00fd];
 
+/// Control IDs of the Back button family. MX Vertical and similar devices
+/// report Back via HID++ `0x1b04` rather than a standard OS mouse button,
+/// so macOS never translates them into `OtherMouseDown` events. Whichever a
+/// device exposes (and can divert) is captured and mapped to
+/// [`ButtonId::Back`](openlogi_core::binding::ButtonId::Back).
+///
+/// Known CIDs (from the `0x1b04` control-ID list / Solaar `special_keys.py`):
+/// - `0x0053` — Back (classic mouse CID, used by MX Vertical)
+/// - `0x00BD` — MultiPlatform Back
+/// - `0x00CE` — Multiplatform Back (alternate)
+/// - `0x00DB` — Back (generic)
+pub const BACK_CIDS: [u16; 4] = [0x0053, 0x00BD, 0x00CE, 0x00DB];
+
+/// Control IDs of the Forward button family. Counterpart to [`BACK_CIDS`]:
+/// captured and mapped to
+/// [`ButtonId::Forward`](openlogi_core::binding::ButtonId::Forward).
+///
+/// Known CIDs:
+/// - `0x0056` — Forward (classic mouse CID, used by MX Vertical)
+/// - `0x00CF` — Multiplatform Forward
+pub const FORWARD_CIDS: [u16; 2] = [0x0056, 0x00CF];
+
 /// Identity and capabilities of one reprogrammable control, as returned by
 /// `getCtrlIdInfo`.
 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
diff --git a/crates/openlogi-hid/src/route.rs b/crates/openlogi-hid/src/route.rs
index c9ecfba51212c7859a361411ec0cc1800daf3ee2..dd2b69cae823eb41458348715296dc8e47c5644b 100644
--- a/crates/openlogi-hid/src/route.rs
+++ b/crates/openlogi-hid/src/route.rs
@@ -63,6 +63,21 @@ pub enum DeviceRoute {
         /// USB/HID product ID of the direct device.
         product_id: u16,
     },
+    /// Standalone raw-HID device, such as a Litra light. The identity is an
+    /// opaque transport-generated value used to disambiguate duplicate HID
+    /// nodes; this route must never be passed to HID++ channel code.
+    RawHid {
+        /// HID vendor ID.
+        vendor_id: u16,
+        /// HID product ID.
+        product_id: u16,
+        /// HID usage page.
+        usage_page: u16,
+        /// HID usage ID.
+        usage_id: u16,
+        /// Stable/opaque device identity selected during enumeration.
+        identity: String,
+    },
 }
 
 /// USB product IDs that identify Logi Bolt receivers.
@@ -70,16 +85,47 @@ pub const BOLT_PIDS: &[u16] = &[0xc548];
 
 /// USB product IDs that identify Logi Unifying receivers. Used by callers that
 /// need to construct the correct [`DeviceRoute`] variant from a raw inventory.
-pub const UNIFYING_PIDS: &[u16] = &[0xc52b, 0xc532];
+///
+/// `0xc539` is the Lightspeed gaming receiver: a distinct product line, but it
+/// answers the same HID++ 1.0 enumeration and pairing-information registers as
+/// Unifying, so it routes as [`DeviceRoute::Unifying`].
+pub const UNIFYING_PIDS: &[u16] = &[0xc52b, 0xc532, 0xc539];
 
 impl DeviceRoute {
+    /// Whether two receiver routes use the same physical HID transport.
+    /// Direct routes cannot prove identity because they carry only VID/PID.
+    #[must_use]
+    pub fn shares_transport(&self, other: &Self) -> bool {
+        match (self, other) {
+            (
+                Self::Bolt {
+                    receiver_uid: left, ..
+                },
+                Self::Bolt {
+                    receiver_uid: right,
+                    ..
+                },
+            )
+            | (
+                Self::Unifying {
+                    receiver_uid: left, ..
+                },
+                Self::Unifying {
+                    receiver_uid: right,
+                    ..
+                },
+            ) => left.eq_ignore_ascii_case(right),
+            _ => false,
+        }
+    }
+
     /// The HID++ device index features are addressed at for this route: the
     /// pairing slot for a Bolt device, the self-index for a direct one.
     #[must_use]
     pub fn device_index(&self) -> u8 {
         match self {
             Self::Bolt { slot, .. } | Self::Unifying { slot, .. } => *slot,
-            Self::Direct { .. } => DIRECT_DEVICE_INDEX,
+            Self::Direct { .. } | Self::RawHid { .. } => DIRECT_DEVICE_INDEX,
         }
     }
 
@@ -135,6 +181,16 @@ impl fmt::Display for DeviceRoute {
                 vendor_id,
                 product_id,
             } => write!(f, "direct {vendor_id:04x}:{product_id:04x}"),
+            Self::RawHid {
+                vendor_id,
+                product_id,
+                usage_page,
+                usage_id,
+                identity,
+            } => write!(
+                f,
+                "raw {vendor_id:04x}:{product_id:04x} usage {usage_page:04x}:{usage_id:04x} ({identity})"
+            ),
         }
     }
 }
@@ -148,6 +204,9 @@ impl fmt::Display for DeviceRoute {
 pub(crate) async fn open_route_channel(
     route: &DeviceRoute,
 ) -> Result<Option<Arc<HidppChannel>>, async_hid::HidError> {
+    if matches!(route, DeviceRoute::RawHid { .. }) {
+        return Ok(None);
+    }
     let candidates = enumerate_hidpp_devices().await?;
     for dev in candidates {
         // A direct route's vendor/product id is on the unopened `DeviceInfo`
@@ -189,6 +248,7 @@ pub(crate) async fn open_route_channel(
                 }
             }
             DeviceRoute::Direct { .. } => return Ok(Some(channel)),
+            DeviceRoute::RawHid { .. } => unreachable!("raw HID route entered HID++ channel path"),
         }
     }
     Ok(None)
diff --git a/crates/openlogi-hid/src/standalone.rs b/crates/openlogi-hid/src/standalone.rs
new file mode 100644
index 0000000000000000000000000000000000000000..7e9d4da7c0fc376fc7eb9d7033a15b51552cc6f4
--- /dev/null
+++ b/crates/openlogi-hid/src/standalone.rs
@@ -0,0 +1,144 @@
+//! Discovery of standalone raw-HID devices.
+
+use std::collections::{HashMap, HashSet};
+
+use openlogi_core::device::{DeviceKind, RawDeviceAddress, StandaloneDevice};
+
+use crate::inventory::InventoryError;
+use crate::transport::{device_identity, enumerate_devices};
+use crate::write::{LitraModel, matches_litra};
+
+/// Enumerate recognized standalone devices without probing them as HID++.
+///
+/// The returned descriptors are intentionally separate from receiver
+/// inventories. A raw device has no HID++ pairing slot and must be routed by
+/// its full HID identity tuple.
+pub async fn enumerate_standalone() -> Result<Vec<StandaloneDevice>, InventoryError> {
+    let devices = enumerate_devices().await?;
+    let devices: Vec<_> = devices
+        .into_iter()
+        .filter_map(|device| {
+            if !matches_litra(
+                device.vendor_id,
+                device.product_id,
+                device.usage_page,
+                device.usage_id,
+            ) {
+                return None;
+            }
+            let model = LitraModel::from_product_id(device.product_id)?;
+            let identity = device_identity(&device);
+            Some(StandaloneDevice {
+                address: RawDeviceAddress {
+                    vendor_id: device.vendor_id,
+                    product_id: device.product_id,
+                    usage_page: device.usage_page,
+                    usage_id: device.usage_id,
+                    identity,
+                },
+                display_name: device.name.clone(),
+                manufacturer: device.manufacturer.clone(),
+                serial_number: device.serial_number.clone(),
+                unit_id: [0; 4],
+                kind: DeviceKind::Light,
+                online: true,
+                capabilities: None,
+                light_capabilities: Some(model.capabilities()),
+                driver_id: model.driver_id().to_owned(),
+                registry_model_id: model.registry_model_id().map(str::to_owned),
+            })
+        })
+        .collect();
+    validate_no_ambiguous_nodes(&devices)?;
+    Ok(devices)
+}
+
+/// Reject multiple nodes that the route cannot distinguish safely.
+///
+/// A serial-bearing pair is distinguishable even when two identical lights
+/// share the same VID/PID/usage tuple. An OS-node identity (`id:…`) is only a
+/// transient re-find hint, so two such nodes with the same tuple are
+/// indistinguishable and must not be exposed as independently selectable
+/// devices.
+fn validate_no_ambiguous_nodes(devices: &[StandaloneDevice]) -> Result<(), InventoryError> {
+    let mut groups: HashMap<(u16, u16, u16, u16), Vec<&StandaloneDevice>> = HashMap::new();
+    for device in devices {
+        let address = &device.address;
+        groups
+            .entry((
+                address.vendor_id,
+                address.product_id,
+                address.usage_page,
+                address.usage_id,
+            ))
+            .or_default()
+            .push(device);
+    }
+    if groups.values().any(|group| {
+        if group.len() < 2 {
+            return false;
+        }
+        let identities: HashSet<&str> = group
+            .iter()
+            .map(|device| device.address.identity.as_str())
+            .collect();
+        identities.len() != group.len()
+            || group
+                .iter()
+                .any(|device| !device.address.identity.starts_with("serial:"))
+    }) {
+        return Err(InventoryError::AmbiguousRawDevice);
+    }
+    Ok(())
+}
+
+#[cfg(test)]
+mod tests {
+    use openlogi_core::device::{DeviceKind, RawDeviceAddress, StandaloneDevice};
+
+    use crate::write::matches_litra;
+
+    use super::validate_no_ambiguous_nodes;
+
+    #[test]
+    fn glow_fixture_matches_standalone_driver() {
+        assert!(matches_litra(0x046d, 0xc900, 0xff43, 0x0202));
+    }
+
+    fn raw(identity: &str) -> StandaloneDevice {
+        StandaloneDevice {
+            address: RawDeviceAddress {
+                vendor_id: 0x046d,
+                product_id: 0xc900,
+                usage_page: 0xff43,
+                usage_id: 0x0202,
+                identity: identity.into(),
+            },
+            display_name: "Litra Glow".into(),
+            manufacturer: Some("Logi".into()),
+            serial_number: identity.strip_prefix("serial:").map(str::to_string),
+            unit_id: [0; 4],
+            kind: DeviceKind::Light,
+            online: true,
+            capabilities: None,
+            light_capabilities: None,
+            driver_id: "litra".into(),
+            registry_model_id: None,
+        }
+    }
+
+    #[test]
+    fn duplicate_transient_nodes_are_rejected() {
+        let devices = vec![raw("id:old"), raw("id:new")];
+        assert!(matches!(
+            validate_no_ambiguous_nodes(&devices),
+            Err(crate::inventory::InventoryError::AmbiguousRawDevice)
+        ));
+    }
+
+    #[test]
+    fn distinct_serials_can_share_the_same_hid_tuple() {
+        let devices = vec![raw("serial:one"), raw("serial:two")];
+        assert!(validate_no_ambiguous_nodes(&devices).is_ok());
+    }
+}
diff --git a/crates/openlogi-hid/src/transport.rs b/crates/openlogi-hid/src/transport.rs
index 7dcc4048361fed01fedfc28586acb5de6f42a66b..afe57815813507635ce55c8bde518f0db12089c3 100644
--- a/crates/openlogi-hid/src/transport.rs
+++ b/crates/openlogi-hid/src/transport.rs
@@ -10,6 +10,8 @@
 
 #[cfg(not(target_os = "windows"))]
 use std::error::Error;
+#[cfg(not(target_os = "windows"))]
+use std::sync::atomic::AtomicBool;
 use std::sync::atomic::{AtomicU16, Ordering};
 use std::sync::{Arc, LazyLock};
 
@@ -25,6 +27,8 @@ use hidpp::{async_trait, channel::RawHidChannel};
 use tokio::sync::Mutex;
 use tracing::debug;
 
+use crate::write::{WriteError, matches_litra};
+
 /// Bitmask of leased HID++ software ids (`1..=15`; bit `N` means id `N` is taken).
 ///
 /// HID++ correlates request/response by `(device, feature, function, software_id)`.
@@ -110,11 +114,11 @@ fn is_long_only_collection(usage_page: u16, usage_id: u16) -> bool {
 /// backend is the usage async-hid intends, and keeps the device set warm between
 /// polls. `HidBackend` is `Arc`-backed, so this is shared, not copied.
 ///
-/// `enumerate` is also reached from `open_route_writer`, so the inventory
-/// watcher and a (rare) lighting write can enumerate through this one backend
-/// concurrently. That is sound: async-hid declares the backend `Send + Sync`,
-/// `enumerate` only reads a snapshot (`IOHIDManagerCopyDevices`), and sharing a
-/// single long-lived `IOHIDManager` across threads is the model hidapi uses too.
+/// Inventory and route-addressed standalone operations may enumerate through
+/// this one backend concurrently. That is sound: async-hid declares the backend
+/// `Send + Sync`, `enumerate` only reads a snapshot
+/// (`IOHIDManagerCopyDevices`), and sharing a single long-lived `IOHIDManager`
+/// across threads is the model hidapi uses too.
 static HID_BACKEND: LazyLock<HidBackend> = LazyLock::new(HidBackend::default);
 
 /// The process-wide HID backend shared by enumeration and hotplug watching.
@@ -122,8 +126,7 @@ pub(crate) fn hid_backend() -> &'static HidBackend {
     &HID_BACKEND
 }
 
-pub(crate) async fn enumerate_hidpp_devices() -> Result<Vec<async_hid::Device>, async_hid::HidError>
-{
+pub(crate) async fn enumerate_devices() -> Result<Vec<async_hid::Device>, async_hid::HidError> {
     let all: Vec<async_hid::Device> = HID_BACKEND.enumerate().await?.collect().await;
 
     // One-time visibility into what the OS actually reports for Logitech nodes,
@@ -140,16 +143,64 @@ pub(crate) async fn enumerate_hidpp_devices() -> Result<Vec<async_hid::Device>,
         );
     }
 
-    Ok(all
+    Ok(all)
+}
+
+/// Stable opaque identity used by raw-device routes. Prefer the HID serial;
+/// otherwise retain the backend's platform identifier as a runtime identity.
+/// The latter is deliberately not treated as a cross-machine portable key,
+/// but it is stronger than enumeration order and lets duplicate nodes be
+/// rejected deterministically.
+pub(crate) fn device_identity(info: &DeviceInfo) -> String {
+    info.serial_number
+        .as_deref()
+        .filter(|serial| !serial.is_empty())
+        .map_or_else(
+            // `DeviceInfo::id` is an OS-node identity (hidraw path, registry
+            // entry, or Windows device path). It is useful to re-find a node
+            // during this process lifetime, but it is intentionally marked as
+            // transient and must never become a persisted physical key.
+            || format!("id:{:?}", info.id),
+            |serial| format!("serial:{}", serial.to_ascii_lowercase()),
+        )
+}
+
+pub(crate) async fn enumerate_hidpp_devices() -> Result<Vec<async_hid::Device>, async_hid::HidError>
+{
+    Ok(enumerate_devices()
+        .await?
         .into_iter()
         .filter(|d| {
-            d.vendor_id == LOGITECH_VID
-                && is_hidpp_long_collection(d.usage_page, d.usage_id)
-                && !is_receiver_child_node(&d.id)
+            is_hidpp_candidate(
+                d.vendor_id,
+                d.product_id,
+                d.usage_page,
+                d.usage_id,
+                is_receiver_child_node(&d.id),
+            )
         })
         .collect())
 }
 
+/// Whether an enumerated node belongs to the HID++ channel path.
+///
+/// Standalone drivers have precedence over the generic collection matcher. A
+/// Litra Glow intentionally uses the same BLE usage collection as Logitech
+/// HID++ peripherals, so the full product/usage tuple must be excluded here;
+/// the collection itself remains a valid HID++ candidate for other products.
+fn is_hidpp_candidate(
+    vendor_id: u16,
+    product_id: u16,
+    usage_page: u16,
+    usage_id: u16,
+    receiver_child: bool,
+) -> bool {
+    vendor_id == LOGITECH_VID
+        && is_hidpp_long_collection(usage_page, usage_id)
+        && !matches_litra(vendor_id, product_id, usage_page, usage_id)
+        && !receiver_child
+}
+
 /// Returns `true` when a HID++ node is a virtual per-device interface created by
 /// the `hid-logitech-dj` kernel driver as a child of a Unifying or Bolt receiver.
 ///
@@ -210,22 +261,57 @@ fn is_receiver_child_node(_id: &async_hid::DeviceId) -> bool {
 /// matching node is connected.
 pub(crate) async fn open_route_writer(
     route: &crate::route::DeviceRoute,
-) -> Result<Option<DeviceWriter>, async_hid::HidError> {
-    let crate::route::DeviceRoute::Direct {
-        vendor_id,
-        product_id,
-    } = route
-    else {
-        return Ok(None);
+) -> Result<Option<DeviceWriter>, WriteError> {
+    let candidates = match route {
+        crate::route::DeviceRoute::Direct { .. } => {
+            enumerate_hidpp_devices().await.map_err(WriteError::from)?
+        }
+        crate::route::DeviceRoute::RawHid { .. } => {
+            enumerate_devices().await.map_err(WriteError::from)?
+        }
+        _ => return Ok(None),
     };
-    let candidates = enumerate_hidpp_devices().await?;
+    let mut matched = None;
     for dev in candidates {
-        if dev.vendor_id == *vendor_id && dev.product_id == *product_id {
-            let (_reader, writer) = dev.open().await?;
-            return Ok(Some(writer));
+        let is_match = match route {
+            crate::route::DeviceRoute::Direct {
+                vendor_id,
+                product_id,
+            } => dev.vendor_id == *vendor_id && dev.product_id == *product_id,
+            crate::route::DeviceRoute::RawHid {
+                vendor_id,
+                product_id,
+                usage_page,
+                usage_id,
+                identity,
+            } => {
+                dev.vendor_id == *vendor_id
+                    && dev.product_id == *product_id
+                    && dev.usage_page == *usage_page
+                    && dev.usage_id == *usage_id
+                    && device_identity(&dev) == *identity
+            }
+            _ => false,
+        };
+        if is_match {
+            if matches!(route, crate::route::DeviceRoute::Direct { .. }) {
+                let (_reader, writer) = dev.open().await.map_err(WriteError::from)?;
+                return Ok(Some(writer));
+            }
+            if matched.is_some() {
+                tracing::warn!("multiple raw HID nodes matched one route");
+                return Err(WriteError::AmbiguousRawDevice);
+            }
+            matched = Some(dev);
         }
     }
-    Ok(None)
+    match matched {
+        Some(dev) => {
+            let (_reader, writer) = dev.open().await.map_err(WriteError::from)?;
+            Ok(Some(writer))
+        }
+        None => Ok(None),
+    }
 }
 
 /// Lease one free software id in `1..=15`, or `None` if all 15 are held.
@@ -349,6 +435,7 @@ pub(crate) struct AsyncHidChannel {
     reader: Mutex<DeviceReader>,
     writer: Mutex<DeviceWriter>,
     info: DeviceInfo,
+    connected: AtomicBool,
     /// Whether the device exposes only the long HID++ report (a BLE-direct
     /// peripheral on macOS). Reported via `supports_short_long_hidpp` so the
     /// `hidpp` channel up-converts outgoing short messages to long.
@@ -367,9 +454,16 @@ impl AsyncHidChannel {
             reader: Mutex::new(reader),
             writer: Mutex::new(writer),
             info,
+            connected: AtomicBool::new(true),
             long_only,
         }
     }
+
+    fn mark_disconnected(&self) {
+        if self.connected.swap(false, Ordering::AcqRel) {
+            debug!(name = %self.info.name, "HID channel disconnected");
+        }
+    }
 }
 
 #[cfg(not(target_os = "windows"))]
@@ -385,8 +479,15 @@ impl RawHidChannel for AsyncHidChannel {
 
     async fn write_report(&self, src: &[u8]) -> Result<usize, Box<dyn Error + Send + Sync>> {
         let mut w = self.writer.lock().await;
-        w.write_output_report(src).await?;
-        Ok(src.len())
+        match w.write_output_report(src).await {
+            Ok(()) => Ok(src.len()),
+            Err(e) => {
+                if matches!(e, async_hid::HidError::Disconnected) {
+                    self.mark_disconnected();
+                }
+                Err(e.into())
+            }
+        }
     }
 
     async fn read_report(&self, buf: &mut [u8]) -> Result<usize, Box<dyn Error + Send + Sync>> {
@@ -403,11 +504,18 @@ impl RawHidChannel for AsyncHidChannel {
             // until the inventory watcher evicts the channel), so park instead.
             // The contract guarantees every caller races this future against
             // the channel's close signal, which tears the read down on drop.
-            Err(async_hid::HidError::Disconnected) => std::future::pending().await,
+            Err(async_hid::HidError::Disconnected) => {
+                self.mark_disconnected();
+                std::future::pending().await
+            }
             Err(e) => Err(e.into()),
         }
     }
 
+    fn is_connected(&self) -> bool {
+        self.connected.load(Ordering::Acquire)
+    }
+
     fn supports_short_long_hidpp(&self) -> Option<(bool, bool)> {
         // USB / receiver collections carry both reports; BLE-direct collections
         // are long-only (no short report on macOS), where the `hidpp` channel
diff --git a/crates/openlogi-hid/src/transport/tests.rs b/crates/openlogi-hid/src/transport/tests.rs
index b67e75e5535b26a23849ed8ab010ab7ee4171ce0..a499e8b7c91f05771de0e610024d43375969bdbd 100644
--- a/crates/openlogi-hid/src/transport/tests.rs
+++ b/crates/openlogi-hid/src/transport/tests.rs
@@ -9,6 +9,14 @@ fn matches_usb_ble_and_keyboard_hidpp_collections() {
     assert!(!is_hidpp_long_collection(0xff43, 0x0002)); // page right, usage wrong
 }
 
+#[test]
+fn litra_ble_collection_is_not_a_hidpp_candidate() {
+    assert!(!is_hidpp_candidate(0x046d, 0xc900, 0xff43, 0x0202, false));
+    // The same BLE collection remains valid for ordinary directly-paired HID++
+    // devices; filtering by usage page alone would regress those devices.
+    assert!(is_hidpp_candidate(0x046d, 0xb023, 0xff43, 0x0202, false));
+}
+
 #[test]
 fn only_ble_collection_is_long_only() {
     assert!(is_long_only_collection(0xff43, 0x0202)); // BLE-direct → short-unsupported
diff --git a/crates/openlogi-hid/src/transport/windows.rs b/crates/openlogi-hid/src/transport/windows.rs
index 75e2d3eff18944e437abd79b0f061fde41db2f8f..8587ecdf6a873903c435e90652547482a7cba0dc 100644
--- a/crates/openlogi-hid/src/transport/windows.rs
+++ b/crates/openlogi-hid/src/transport/windows.rs
@@ -5,12 +5,11 @@ use std::{error::Error, io};
 use async_hid::{AsyncHidRead, AsyncHidWrite, DeviceInfo, DeviceReader, DeviceWriter};
 #[cfg(target_os = "windows")]
 use futures_lite::StreamExt as _;
+use hidpp::channel::{LONG_REPORT_ID, SHORT_REPORT_ID};
 #[cfg(target_os = "windows")]
 use hidpp::{
     async_trait,
-    channel::{
-        LONG_REPORT_ID, LONG_REPORT_LENGTH, RawHidChannel, SHORT_REPORT_ID, SHORT_REPORT_LENGTH,
-    },
+    channel::{LONG_REPORT_LENGTH, RawHidChannel, SHORT_REPORT_LENGTH},
 };
 #[cfg(target_os = "windows")]
 use tokio::sync::Mutex;
@@ -23,6 +22,22 @@ use crate::windows_hid::NativeHidWriter;
 #[cfg(target_os = "windows")]
 use super::HID_BACKEND;
 
+const VERY_LONG_REPORT_ID: u8 = 0x12;
+
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+enum ReportEndpoint {
+    Short,
+    Long,
+}
+
+fn endpoint_for_report_id(report_id: u8) -> Option<ReportEndpoint> {
+    match report_id {
+        SHORT_REPORT_ID => Some(ReportEndpoint::Short),
+        LONG_REPORT_ID | VERY_LONG_REPORT_ID => Some(ReportEndpoint::Long),
+        _ => None,
+    }
+}
+
 #[cfg(target_os = "windows")]
 struct HidEndpoint {
     reader: Mutex<DeviceReader>,
@@ -189,9 +204,9 @@ impl RawHidChannel for WindowsHidppChannel {
     }
 
     async fn write_report(&self, src: &[u8]) -> Result<usize, Box<dyn Error + Send + Sync>> {
-        let endpoint = match src.first().copied() {
-            Some(SHORT_REPORT_ID) => self.short.as_ref(),
-            Some(LONG_REPORT_ID) => self.long.as_ref(),
+        let endpoint = match src.first().copied().and_then(endpoint_for_report_id) {
+            Some(ReportEndpoint::Short) => self.short.as_ref(),
+            Some(ReportEndpoint::Long) => self.long.as_ref(),
             _ => None,
         }
         .ok_or_else(|| {
@@ -267,3 +282,25 @@ fn copy_report(
     dst[..len].copy_from_slice(&src[..len]);
     Ok(len)
 }
+
+#[cfg(test)]
+mod tests {
+    use super::*;
+
+    #[test]
+    fn report_ids_select_their_windows_endpoint() {
+        assert_eq!(
+            endpoint_for_report_id(SHORT_REPORT_ID),
+            Some(ReportEndpoint::Short)
+        );
+        assert_eq!(
+            endpoint_for_report_id(LONG_REPORT_ID),
+            Some(ReportEndpoint::Long)
+        );
+        assert_eq!(
+            endpoint_for_report_id(VERY_LONG_REPORT_ID),
+            Some(ReportEndpoint::Long)
+        );
+        assert_eq!(endpoint_for_report_id(0x13), None);
+    }
+}
diff --git a/crates/openlogi-hid/src/write.rs b/crates/openlogi-hid/src/write.rs
index e01c79e2e490874bea315a9c865c85273086e51f..a058b98adbcc87de29cc4a3e5d75c4402ca42f9d 100644
--- a/crates/openlogi-hid/src/write.rs
+++ b/crates/openlogi-hid/src/write.rs
@@ -1,34 +1,74 @@
-//! HID++ writes back to the device — DPI, SmartShift, lighting, and diagnostics.
+//! HID++ writes back to the device — DPI, SmartShift, lighting, backlight, and
+//! diagnostics.
 //!
 //! Each entry point takes a [`DeviceRoute`] and resolves it to an open channel
 //! through `open_route_channel`, so the same call works whether the device is
 //! behind a Bolt receiver or attached directly (USB cable / Bluetooth). Each
-//! call re-enumerates and re-opens — fine at the frequency this is invoked
-//! (once per slider release) — unless a [`SharedChannel`] from the capture
-//! session is reused.
+//! route-addressed call re-enumerates and re-opens, while the corresponding
+//! `_on` entry points reuse a [`SharedChannel`] already owned by inventory or a
+//! standalone capture session.
 
 use std::sync::Arc;
 
 use hidpp::{channel::HidppChannel, device::Device, feature::CreatableFeature};
+use openlogi_core::config::LightSettings;
+use openlogi_core::device::LightCapabilities;
 
 use crate::route::{DeviceRoute, open_route_channel};
 
+mod backlight;
 mod diagnostics;
 mod dpi;
 mod error;
+mod fn_lock;
 mod lighting;
+mod litra;
 mod shared;
 mod smartshift;
 
-pub use diagnostics::{FeatureEntry, ReprogControlEntry, dump_features, dump_reprog_controls};
+pub use backlight::{get_backlight, set_backlight_enabled};
+pub use diagnostics::{
+    FeatureEntry, ReprogControlEntry, dump_features, dump_reprog_controls, read_battery_raw,
+};
 pub use dpi::{DpiCapabilities, DpiInfo, get_dpi, get_dpi_info, set_dpi};
 pub use error::{HidppFeatureErrorKind, HidppOperation, WriteError};
+pub use fn_lock::set_fn_lock;
 pub use lighting::{LightingMethod, set_keyboard_color, set_keyboard_color_with};
-pub use shared::{SharedChannel, set_dpi_on, set_smartshift_on, toggle_smartshift_on};
+pub use litra::{
+    LightCommand, LitraModel, apply as apply_litra, encode_command as encode_litra_command,
+    matches_litra,
+};
+pub use shared::{
+    SharedChannel, get_dpi_info_on, get_smartshift_status_on, set_dpi_on, set_fn_lock_on,
+    set_keyboard_color_on, set_keyboard_color_with_on, set_smartshift_on, toggle_smartshift_on,
+};
 pub use smartshift::{
     get_smartshift_status, set_smartshift, set_smartshift_sensitivity, toggle_smartshift,
 };
 
+/// Expand protocol-neutral saved settings into only the controls advertised
+/// by a standalone light. Unsupported controls are omitted rather than sent
+/// speculatively, which keeps power-only and brightness-only drivers usable.
+#[must_use]
+pub fn commands_for_light_settings(
+    settings: LightSettings,
+    capabilities: LightCapabilities,
+) -> Vec<LightCommand> {
+    let mut commands = Vec::new();
+    if capabilities.power {
+        commands.push(LightCommand::Power(settings.enabled));
+    }
+    if capabilities.brightness.is_some() {
+        commands.push(LightCommand::BrightnessPercent(settings.brightness_percent));
+    }
+    if capabilities.temperature.is_some()
+        && let Some(kelvin) = settings.temperature_kelvin
+    {
+        commands.push(LightCommand::TemperatureKelvin(kelvin));
+    }
+    commands
+}
+
 pub(crate) use error::classify_hidpp_error;
 
 /// Look up `F` on a device by HID++ feature ID, register it with
diff --git a/crates/openlogi-hid/src/write/backlight.rs b/crates/openlogi-hid/src/write/backlight.rs
new file mode 100644
index 0000000000000000000000000000000000000000..c873b7dfb5a877a32bd82f93f2cd50cf5dc66b54
--- /dev/null
+++ b/crates/openlogi-hid/src/write/backlight.rs
@@ -0,0 +1,201 @@
+use std::sync::Arc;
+
+use hidpp::{
+    device::Device,
+    feature::{
+        CreatableFeature,
+        backlight::{
+            BacklightFeature, BacklightMode as FirmwareMode, BacklightStatus as FirmwareStatus,
+            SetBacklightConfig,
+        },
+    },
+};
+use tracing::debug;
+
+use crate::backlight::{BacklightMode, BacklightState, BacklightStatus};
+use crate::route::DeviceRoute;
+
+use super::{HidppOperation, WriteError, classify_hidpp_error, open_feature, with_route};
+
+/// Map the fork's `0x1982` mode onto OpenLogi's [`BacklightMode`]. The source
+/// enum is `#[non_exhaustive]`; an unmodelled future variant maps to
+/// [`BacklightMode::None`], which callers treat as "firmware picks".
+fn mode_from_firmware(mode: FirmwareMode) -> BacklightMode {
+    match mode {
+        FirmwareMode::Automatic => BacklightMode::Automatic,
+        FirmwareMode::TemporaryManual => BacklightMode::TemporaryManual,
+        FirmwareMode::PermanentManual => BacklightMode::PermanentManual,
+        _ => BacklightMode::None,
+    }
+}
+
+/// The inverse of [`mode_from_firmware`], used when writing a config back.
+///
+/// [`BacklightMode::TemporaryManual`] is the mode the *keyboard* enters when
+/// the user presses its backlight keys; `setBacklightConfig` cannot write it,
+/// so it is sent as [`FirmwareMode::Automatic`] — the firmware's own fallback
+/// once software takes over the level.
+fn mode_to_firmware(mode: BacklightMode) -> FirmwareMode {
+    match mode {
+        BacklightMode::None => FirmwareMode::None,
+        BacklightMode::Automatic | BacklightMode::TemporaryManual => FirmwareMode::Automatic,
+        BacklightMode::PermanentManual => FirmwareMode::PermanentManual,
+    }
+}
+
+/// Map the fork's `0x1982` status onto OpenLogi's [`BacklightStatus`]. The
+/// source enum is `#[non_exhaustive]`; an unmodelled future variant maps to
+/// [`BacklightStatus::AlsAutomatic`], the firmware's out-of-box behaviour.
+fn status_from_firmware(status: FirmwareStatus) -> BacklightStatus {
+    match status {
+        FirmwareStatus::DisabledBySoftware => BacklightStatus::DisabledBySoftware,
+        FirmwareStatus::DisabledByCriticalBattery => BacklightStatus::DisabledByCriticalBattery,
+        FirmwareStatus::AlsSaturated => BacklightStatus::AlsSaturated,
+        FirmwareStatus::TemporaryManual => BacklightStatus::TemporaryManual,
+        FirmwareStatus::PermanentManual => BacklightStatus::PermanentManual,
+        _ => BacklightStatus::AlsAutomatic,
+    }
+}
+
+/// Read `getBacklightConfig` + `getBacklightInfo` and merge them into a
+/// [`BacklightState`].
+async fn read_state(feature: &BacklightFeature) -> Result<BacklightState, WriteError> {
+    let config = feature.get_backlight_config().await.map_err(|e| {
+        classify_hidpp_error(e, HidppOperation::ReadBacklight, BacklightFeature::ID)
+    })?;
+    let info = feature.get_backlight_info().await.map_err(|e| {
+        classify_hidpp_error(e, HidppOperation::ReadBacklight, BacklightFeature::ID)
+    })?;
+    Ok(BacklightState {
+        enabled: config.enabled,
+        mode: mode_from_firmware(config.mode),
+        status: status_from_firmware(info.status),
+        current_level: info.current_level,
+        nb_levels: info.nb_levels,
+    })
+}
+
+/// Read the current backlight state of the keyboard on `route`.
+///
+/// `FeatureUnsupported` when the device does not expose HID++ `0x1982` — RGB
+/// keyboards (`0x8070` / `0x8080`) and every mouse fall in that group.
+pub async fn get_backlight(route: &DeviceRoute) -> Result<BacklightState, WriteError> {
+    let index = route.device_index();
+    with_route(route, move |channel| async move {
+        let mut device = Device::new(Arc::clone(&channel), index)
+            .await
+            .map_err(|_| WriteError::DeviceUnreachable { index })?;
+        let feature = open_feature::<BacklightFeature>(&mut device).await?;
+        read_state(&feature).await
+    })
+    .await
+}
+
+/// Enable or disable the backlight on `route`, and return the read-back state.
+///
+/// Disabling sets the firmware's own master switch: the LEDs stay dark
+/// regardless of the ambient-light and proximity sensors, and the device
+/// reports [`BacklightStatus::DisabledBySoftware`]. The write goes to
+/// non-volatile memory, so it survives reconnects, host switches, and power
+/// cycles — nothing needs to re-apply it.
+///
+/// The effect, brightness level, and fade-out durations are read first and
+/// written back unchanged, so they return with a later `enabled = true`.
+///
+/// The mode survives too, except from [`BacklightMode::TemporaryManual`] — the
+/// state the keyboard enters on its own when the user presses its backlight
+/// keys. `setBacklightConfig` cannot write that mode, so it lands in
+/// [`BacklightMode::Automatic`] and the level goes back under ambient-light
+/// control. Promoting it to [`BacklightMode::PermanentManual`] would hold the
+/// level but make a deliberately temporary adjustment permanent, so the
+/// firmware's own fallback wins instead. Read the mode first and tell the user
+/// when this applies.
+///
+/// `FeatureUnsupported` when the device does not expose HID++ `0x1982`.
+pub async fn set_backlight_enabled(
+    route: &DeviceRoute,
+    enabled: bool,
+) -> Result<BacklightState, WriteError> {
+    let index = route.device_index();
+    with_route(route, move |channel| async move {
+        let mut device = Device::new(Arc::clone(&channel), index)
+            .await
+            .map_err(|_| WriteError::DeviceUnreachable { index })?;
+        let feature = open_feature::<BacklightFeature>(&mut device).await?;
+
+        let current = feature.get_backlight_config().await.map_err(|e| {
+            classify_hidpp_error(e, HidppOperation::ReadBacklight, BacklightFeature::ID)
+        })?;
+
+        feature
+            .set_backlight_config(SetBacklightConfig {
+                enabled,
+                options: current.options,
+                mode: mode_to_firmware(mode_from_firmware(current.mode)),
+                // `None` sends the 0xff "do not change" sentinel, keeping
+                // whichever effect the device already runs.
+                effect: None,
+                current_level: current.current_level,
+                duration_hands_out: current.duration_hands_out,
+                duration_hands_in: current.duration_hands_in,
+                duration_powered: current.duration_powered,
+            })
+            .await
+            .map_err(|e| {
+                classify_hidpp_error(e, HidppOperation::WriteBacklight, BacklightFeature::ID)
+            })?;
+
+        debug!(index, enabled, "wrote backlight enable");
+        read_state(&feature).await
+    })
+    .await
+}
+
+#[cfg(test)]
+mod tests {
+    use super::*;
+
+    #[test]
+    fn firmware_modes_round_trip_through_openlogi_modes() {
+        assert_eq!(
+            mode_from_firmware(FirmwareMode::Automatic),
+            BacklightMode::Automatic
+        );
+        assert_eq!(
+            mode_from_firmware(FirmwareMode::PermanentManual),
+            BacklightMode::PermanentManual
+        );
+        assert_eq!(mode_from_firmware(FirmwareMode::None), BacklightMode::None);
+    }
+
+    #[test]
+    fn temporary_manual_is_downgraded_because_software_cannot_write_it() {
+        assert_eq!(
+            mode_from_firmware(FirmwareMode::TemporaryManual),
+            BacklightMode::TemporaryManual
+        );
+        assert_eq!(
+            mode_to_firmware(BacklightMode::TemporaryManual),
+            FirmwareMode::Automatic
+        );
+    }
+
+    #[test]
+    fn writable_modes_survive_the_read_write_round_trip() {
+        for mode in [FirmwareMode::None, FirmwareMode::PermanentManual] {
+            assert_eq!(mode_to_firmware(mode_from_firmware(mode)), mode);
+        }
+    }
+
+    #[test]
+    fn software_disable_status_is_mapped() {
+        assert_eq!(
+            status_from_firmware(FirmwareStatus::DisabledBySoftware),
+            BacklightStatus::DisabledBySoftware
+        );
+        assert_eq!(
+            status_from_firmware(FirmwareStatus::AlsSaturated),
+            BacklightStatus::AlsSaturated
+        );
+    }
+}
diff --git a/crates/openlogi-hid/src/write/diagnostics.rs b/crates/openlogi-hid/src/write/diagnostics.rs
index e3a9ee6fb50b3b08a2f0e0d86a1b5f66e632f92b..2aee84779f3268ff261e973679e5f9189b839519 100644
--- a/crates/openlogi-hid/src/write/diagnostics.rs
+++ b/crates/openlogi-hid/src/write/diagnostics.rs
@@ -1,10 +1,13 @@
 use std::sync::Arc;
 
-use hidpp::{device::Device, feature::CreatableFeature, feature::feature_set::FeatureSetFeature};
+use hidpp::{
+    device::Device, feature::CreatableFeature, feature::battery_status::BatteryStatusFeature,
+    feature::feature_set::FeatureSetFeature, feature::unified_battery::UnifiedBatteryFeature,
+};
 
 use crate::reprog_controls::{self, CidFlags, CidInfo, ReprogControlsV4};
 use crate::route::DeviceRoute;
-use crate::write::{HidppOperation, WriteError, classify_hidpp_error, with_route};
+use crate::write::{HidppOperation, WriteError, classify_hidpp_error, open_feature, with_route};
 
 /// Snapshot of one HID++ feature exposed by a device: protocol ID +
 /// version. Returned by [`dump_features`] for diagnostics.
@@ -119,3 +122,54 @@ pub async fn dump_reprog_controls(
     })
     .await
 }
+
+/// Diagnostic read of the device's raw battery report — the unified `0x1004`
+/// fields, or the legacy `0x1000` `discharge_level`/`next_level`/`status`. For
+/// `openlogi diag battery`: surfaces exactly what the firmware reports so a
+/// claim like "MX2S shows 0% while charging" can be confirmed against the wire
+/// instead of guessed (the GUI only ever shows the mapped value).
+pub async fn read_battery_raw(route: &DeviceRoute) -> Result<String, WriteError> {
+    let index = route.device_index();
+    with_route(route, move |channel| async move {
+        let mut device = Device::new(Arc::clone(&channel), index)
+            .await
+            .map_err(|_| WriteError::DeviceUnreachable { index })?;
+
+        match open_feature::<UnifiedBatteryFeature>(&mut device).await {
+            Ok(feature) => {
+                let info = feature
+                    .get_battery_info()
+                    .await
+                    .map_err(|e| WriteError::Hidpp(format!("{e:?}")))?;
+                return Ok(format!(
+                    "0x1004 UnifiedBattery: percentage={} level={:?} status={:?}",
+                    info.charging_percentage, info.level, info.status
+                ));
+            }
+            Err(WriteError::FeatureUnsupported { .. }) => {}
+            Err(e) => return Err(e),
+        }
+
+        match open_feature::<BatteryStatusFeature>(&mut device).await {
+            Ok(feature) => {
+                let info = feature
+                    .get_battery_level_status()
+                    .await
+                    .map_err(|e| WriteError::Hidpp(format!("{e:?}")))?;
+                return Ok(format!(
+                    "0x1000 BatteryStatus: discharge_level={} next_level={} status={:?}",
+                    info.discharge_level, info.next_level, info.status
+                ));
+            }
+            Err(WriteError::FeatureUnsupported { .. }) => {}
+            Err(e) => return Err(e),
+        }
+
+        // Reached only when neither 0x1004 nor 0x1000 is present; report the
+        // preferred feature rather than implying 0x1000 was specifically absent.
+        Err(WriteError::FeatureUnsupported {
+            feature_hex: 0x1004,
+        })
+    })
+    .await
+}
diff --git a/crates/openlogi-hid/src/write/dpi.rs b/crates/openlogi-hid/src/write/dpi.rs
index 1333f7ea886132aae84472ad32e3666a3809807e..7c0b60b01ae5f2a809b64248e5b47154ab71d43c 100644
--- a/crates/openlogi-hid/src/write/dpi.rs
+++ b/crates/openlogi-hid/src/write/dpi.rs
@@ -125,18 +125,25 @@ pub struct DpiInfo {
 pub async fn get_dpi(route: &DeviceRoute) -> Result<u16, WriteError> {
     let index = route.device_index();
     with_route(route, move |channel| async move {
-        let mut device = Device::new(Arc::clone(&channel), index)
-            .await
-            .map_err(|_| WriteError::DeviceUnreachable { index })?;
-        let feature = open_feature::<AdjustableDpiFeature>(&mut device).await?;
-        feature
-            .get_sensor_dpi(0)
-            .await
-            .map_err(|e| classify_hidpp_error(e, HidppOperation::ReadDpi, AdjustableDpiFeature::ID))
+        get_dpi_on_channel(&channel, index).await
     })
     .await
 }
 
+async fn get_dpi_on_channel(
+    channel: &Arc<hidpp::channel::HidppChannel>,
+    index: u8,
+) -> Result<u16, WriteError> {
+    let mut device = Device::new(Arc::clone(channel), index)
+        .await
+        .map_err(|_| WriteError::DeviceUnreachable { index })?;
+    let feature = open_feature::<AdjustableDpiFeature>(&mut device).await?;
+    feature
+        .get_sensor_dpi(0)
+        .await
+        .map_err(|e| classify_hidpp_error(e, HidppOperation::ReadDpi, AdjustableDpiFeature::ID))
+}
+
 /// Classify a HID++ error from the AdjustableDpi functions. A device that
 /// announces `0x2201` but rejects a function (`Unsupported` /
 /// `InvalidFunctionId`) or returns a structurally invalid DPI list
@@ -162,37 +169,44 @@ fn classify_dpi_error(error: Hidpp20Error) -> WriteError {
 pub async fn get_dpi_info(route: &DeviceRoute) -> Result<DpiInfo, WriteError> {
     let index = route.device_index();
     with_route(route, move |channel| async move {
-        let mut device = Device::new(Arc::clone(&channel), index)
-            .await
-            .map_err(|_| WriteError::DeviceUnreachable { index })?;
-        let feature = open_feature::<AdjustableDpiFeature>(&mut device).await?;
-        let sensor_count = feature
-            .get_sensor_count()
-            .await
-            .map_err(classify_dpi_error)?;
-        if sensor_count == 0 {
-            // The device claims AdjustableDpi but exposes no sensor — it cannot
-            // report DPI, and that won't change on retry.
-            return Err(WriteError::FeatureUnsupported {
-                feature_hex: AdjustableDpiFeature::ID,
-            });
-        }
-        let current = feature
-            .get_sensor_dpi(0)
-            .await
-            .map_err(classify_dpi_error)?;
-        let values = feature
-            .get_sensor_dpi_list(0)
-            .await
-            .map_err(classify_dpi_error)?;
-        Ok(DpiInfo {
-            current,
-            capabilities: DpiCapabilities::new(values)?,
-        })
+        get_dpi_info_on_channel(&channel, index).await
     })
     .await
 }
 
+pub(super) async fn get_dpi_info_on_channel(
+    channel: &Arc<hidpp::channel::HidppChannel>,
+    index: u8,
+) -> Result<DpiInfo, WriteError> {
+    let mut device = Device::new(Arc::clone(channel), index)
+        .await
+        .map_err(|_| WriteError::DeviceUnreachable { index })?;
+    let feature = open_feature::<AdjustableDpiFeature>(&mut device).await?;
+    let sensor_count = feature
+        .get_sensor_count()
+        .await
+        .map_err(classify_dpi_error)?;
+    if sensor_count == 0 {
+        // The device claims AdjustableDpi but exposes no sensor — it cannot
+        // report DPI, and that won't change on retry.
+        return Err(WriteError::FeatureUnsupported {
+            feature_hex: AdjustableDpiFeature::ID,
+        });
+    }
+    let current = feature
+        .get_sensor_dpi(0)
+        .await
+        .map_err(classify_dpi_error)?;
+    let values = feature
+        .get_sensor_dpi_list(0)
+        .await
+        .map_err(classify_dpi_error)?;
+    Ok(DpiInfo {
+        current,
+        capabilities: DpiCapabilities::new(values)?,
+    })
+}
+
 /// Set sensor 0's DPI for the device addressed by `route`.
 pub async fn set_dpi(route: &DeviceRoute, dpi: u16) -> Result<(), WriteError> {
     let index = route.device_index();
diff --git a/crates/openlogi-hid/src/write/error.rs b/crates/openlogi-hid/src/write/error.rs
index 5d4fee7b169a45ec3e31bcc0db65c03f0ed544c5..0fa3b753a76ffdb607c6ac7d7828dbbc640db73f 100644
--- a/crates/openlogi-hid/src/write/error.rs
+++ b/crates/openlogi-hid/src/write/error.rs
@@ -73,6 +73,23 @@ pub enum WriteError {
     /// Background agent write path is unavailable.
     #[error("background agent is unavailable")]
     AgentUnavailable,
+    /// A standalone light value is outside the driver's supported range.
+    #[error("invalid light value for {control}: {value}")]
+    InvalidLightValue {
+        /// Semantic control name.
+        control: String,
+        /// Rejected value in the semantic/native unit supplied by the caller.
+        value: u16,
+    },
+    /// The selected light driver does not implement a requested control.
+    #[error("light control is unsupported: {control}")]
+    LightUnsupported {
+        /// Semantic control name.
+        control: String,
+    },
+    /// Multiple raw HID nodes matched one physical route.
+    #[error("multiple raw HID devices matched the route")]
+    AmbiguousRawDevice,
 }
 
 /// HID++ operation being performed when a device write/read failed.
@@ -100,6 +117,14 @@ pub enum HidppOperation {
     ReadWheelMode,
     /// Write and verify the native HiResWheel mode.
     WriteWheelMode,
+    /// Read the keyboard backlight config or info.
+    ReadBacklight,
+    /// Write the keyboard backlight config.
+    WriteBacklight,
+    /// Write keyboard Fn-lock (fn inversion).
+    WriteFnLock,
+    /// Write a standalone-light command. Appended last — variant order is wire format.
+    Light,
 }
 
 /// HID++ feature error kind in a serializable wire-safe form.
diff --git a/crates/openlogi-hid/src/write/fn_lock.rs b/crates/openlogi-hid/src/write/fn_lock.rs
new file mode 100644
index 0000000000000000000000000000000000000000..a1876a9a9c660cdd602f6dc3e9aa5cad0bc30f34
--- /dev/null
+++ b/crates/openlogi-hid/src/write/fn_lock.rs
@@ -0,0 +1,105 @@
+//! HID++ keyboard Fn-lock writes — fn inversion `0x40a3` (multi-host), with
+//! the single-host `0x40a2` as fallback.
+//!
+//! "Fn-lock on" means the F-row sends plain F1–F12 without holding Fn
+//! ([`FnInversionState::On`]); off restores the printed media/shortcut
+//! functions, with Fn+key producing the F-keys. Multi-host keyboards store the
+//! state per Easy-Switch slot, so the `0x40a3` path addresses
+//! [`HostIndex::Current`] — the slot the keyboard is talking to right now.
+
+use std::sync::Arc;
+
+use hidpp::{
+    channel::HidppChannel,
+    device::Device,
+    feature::{
+        fn_inversion::{
+            FnInversionMultiHostFeature, FnInversionState, FnInversionWithDefaultStateFeature,
+        },
+        hosts_info::HostIndex,
+    },
+};
+use tracing::debug;
+
+use crate::route::DeviceRoute;
+
+use super::{HidppOperation, WriteError, classify_hidpp_error, open_feature, with_route};
+
+/// Whether a failure to open the `0x40a3` multi-host feature should trigger
+/// the `0x40a2` single-host fallback. Only a missing-`0x40a3` feature
+/// qualifies; transport and protocol errors propagate unchanged.
+fn is_missing_multi_host(err: &WriteError) -> bool {
+    matches!(
+        err,
+        WriteError::FeatureUnsupported { feature_hex } if *feature_hex == 0x40a3
+    )
+}
+
+/// Whichever fn-inversion feature the keyboard exposes, normalised onto one
+/// setter. Multi-host boards (Easy-Switch) carry `0x40a3`; single-host boards
+/// carry `0x40a2`.
+enum FnInversion {
+    /// `0x40a3 FnInversionForMultiHostDevices`.
+    MultiHost(Arc<FnInversionMultiHostFeature>),
+    /// `0x40a2 FnInversionWithDefaultState`.
+    SingleHost(Arc<FnInversionWithDefaultStateFeature>),
+}
+
+impl FnInversion {
+    /// Open whichever fn-inversion feature the device exposes. Tries `0x40a3`
+    /// first; on a missing-`0x40a3` error (and only that), retries with
+    /// `0x40a2`.
+    async fn open(device: &mut Device) -> Result<Self, WriteError> {
+        match open_feature::<FnInversionMultiHostFeature>(device).await {
+            Ok(feature) => Ok(Self::MultiHost(feature)),
+            Err(err) if is_missing_multi_host(&err) => {
+                let feature = open_feature::<FnInversionWithDefaultStateFeature>(device).await?;
+                Ok(Self::SingleHost(feature))
+            }
+            Err(err) => Err(err),
+        }
+    }
+
+    /// Write the inversion state (for the current host on `0x40a3`).
+    async fn set(&self, state: FnInversionState) -> Result<(), WriteError> {
+        match self {
+            Self::MultiHost(feature) => {
+                feature
+                    .set_global_fn_inversion(HostIndex::Current, state)
+                    .await
+                    .map_err(|e| classify_hidpp_error(e, HidppOperation::WriteFnLock, 0x40a3))?;
+            }
+            Self::SingleHost(feature) => {
+                feature
+                    .set_global_fn_inversion(state)
+                    .await
+                    .map_err(|e| classify_hidpp_error(e, HidppOperation::WriteFnLock, 0x40a2))?;
+            }
+        }
+        Ok(())
+    }
+}
+
+/// Write the keyboard's Fn-lock state: `true` = F-row sends F1–F12 directly.
+pub async fn set_fn_lock(route: &DeviceRoute, on: bool) -> Result<(), WriteError> {
+    let index = route.device_index();
+    with_route(route, move |channel| async move {
+        set_fn_lock_on_channel(&channel, index, on).await
+    })
+    .await
+}
+
+/// The Fn-lock write itself, on an already-open channel at HID++ `index`.
+pub(super) async fn set_fn_lock_on_channel(
+    channel: &Arc<HidppChannel>,
+    index: u8,
+    on: bool,
+) -> Result<(), WriteError> {
+    let mut device = Device::new(Arc::clone(channel), index)
+        .await
+        .map_err(|_| WriteError::DeviceUnreachable { index })?;
+    let fn_inversion = FnInversion::open(&mut device).await?;
+    fn_inversion.set(FnInversionState::from(on)).await?;
+    debug!(index, on, "fn-lock written");
+    Ok(())
+}
diff --git a/crates/openlogi-hid/src/write/lighting.rs b/crates/openlogi-hid/src/write/lighting.rs
index 41e7bad42ce9d717b223512ad72cfda4de405967..6f1c75550abd0db3b6bf6ef17da2735e201bf983 100644
--- a/crates/openlogi-hid/src/write/lighting.rs
+++ b/crates/openlogi-hid/src/write/lighting.rs
@@ -1,7 +1,8 @@
+use std::sync::Arc;
 use std::time::Duration;
 
-use async_hid::AsyncHidWrite;
 use hidpp::{
+    channel::{ChannelError, HidppChannel},
     device::Device,
     feature::{
         CreatableFeature,
@@ -89,16 +90,31 @@ pub async fn set_keyboard_color_with(
     r: u8,
     g: u8,
     b: u8,
+) -> Result<(), WriteError> {
+    let device_index = route.device_index();
+    with_route(route, move |channel| async move {
+        set_keyboard_color_with_on_channel(&channel, device_index, method, r, g, b).await
+    })
+    .await
+}
+
+pub(super) async fn set_keyboard_color_with_on_channel(
+    channel: &Arc<HidppChannel>,
+    device_index: u8,
+    method: LightingMethod,
+    r: u8,
+    g: u8,
+    b: u8,
 ) -> Result<(), WriteError> {
     match method {
-        LightingMethod::PerKey => set_color_per_key(route, r, g, b).await,
-        LightingMethod::Effects => set_color_effects(route, r, g, b).await,
-        LightingMethod::Auto => match set_color_effects(route, r, g, b).await {
+        LightingMethod::PerKey => set_color_per_key(channel, device_index, r, g, b).await,
+        LightingMethod::Effects => set_color_effects(channel, device_index, r, g, b).await,
+        LightingMethod::Auto => match set_color_effects(channel, device_index, r, g, b).await {
             Err(WriteError::FeatureUnsupported { feature_hex })
                 if feature_hex == COLOR_LED_EFFECTS_FEATURE =>
             {
                 debug!("no 0x8070 effect engine — falling back to 0x8080 per-key");
-                set_color_per_key(route, r, g, b).await
+                set_color_per_key(channel, device_index, r, g, b).await
             }
             other => other,
         },
@@ -109,24 +125,21 @@ pub async fn set_keyboard_color_with(
 /// when the device doesn't expose it; the index differs per device, so callers
 /// can't hard-code it.
 async fn resolve_feature_index(
-    route: &DeviceRoute,
+    channel: &Arc<HidppChannel>,
+    device_index: u8,
     feature_id: u16,
 ) -> Result<Option<u8>, WriteError> {
-    let device_index = route.device_index();
-    with_route(route, move |channel| async move {
-        let device = Device::new(std::sync::Arc::clone(&channel), device_index)
-            .await
-            .map_err(|_| WriteError::DeviceUnreachable {
-                index: device_index,
-            })?;
-        let info = device
-            .root()
-            .get_feature(feature_id)
-            .await
-            .map_err(|e| classify_hidpp_error(e, HidppOperation::ResolveFeature, feature_id))?;
-        Ok(info.map(|i| i.index))
-    })
-    .await
+    let device = Device::new(Arc::clone(channel), device_index)
+        .await
+        .map_err(|_| WriteError::DeviceUnreachable {
+            index: device_index,
+        })?;
+    let info = device
+        .root()
+        .get_feature(feature_id)
+        .await
+        .map_err(|e| classify_hidpp_error(e, HidppOperation::ResolveFeature, feature_id))?;
+    Ok(info.map(|i| i.index))
 }
 
 /// Set a solid colour via `ColorLedEffects` (`0x8070`): a fixed effect per zone,
@@ -137,54 +150,56 @@ async fn resolve_feature_index(
 /// first so only existing zones are driven (a typed `set_zone_effect` awaits the
 /// device's reply, so unlike the former raw fire-and-forget path a write to a
 /// non-existent zone would surface as an error rather than a silent no-op).
-async fn set_color_effects(route: &DeviceRoute, r: u8, g: u8, b: u8) -> Result<(), WriteError> {
-    let index = route.device_index();
-    with_route(route, move |channel| async move {
-        let mut device = Device::new(std::sync::Arc::clone(&channel), index)
-            .await
-            .map_err(|_| WriteError::DeviceUnreachable { index })?;
-        let feature = open_feature::<ColorLedEffectsFeature>(&mut device).await?;
-        let zone_count = feature
-            .get_info()
-            .await
-            .map_err(classify_lighting_error)?
-            .zone_count;
-
-        let mut params = [0u8; ZONE_EFFECT_PARAM_COUNT];
-        params[0] = r;
-        params[1] = g;
-        params[2] = b;
-        let zones_to_write = if zone_count == 0 {
-            debug!(
-                index,
-                "0x8070 reported zero zones; applying legacy 4-zone fallback"
-            );
-            MAX_COLOR_LED_EFFECT_ZONES
-        } else {
-            zone_count.min(MAX_COLOR_LED_EFFECT_ZONES)
-        };
-        if zone_count > MAX_COLOR_LED_EFFECT_ZONES {
-            debug!(
-                index,
-                zone_count,
-                capped_zone_count = MAX_COLOR_LED_EFFECT_ZONES,
-                "0x8070 zone count capped to legacy write limit"
-            );
-        }
-        for zone in 0..zones_to_write {
-            feature
-                .set_zone_effect(zone, EFFECT_FIXED, params, Persistence::Volatile)
-                .await
-                .map_err(classify_lighting_error)?;
-            tokio::time::sleep(FRAME_GAP).await;
-        }
+async fn set_color_effects(
+    channel: &Arc<HidppChannel>,
+    index: u8,
+    r: u8,
+    g: u8,
+    b: u8,
+) -> Result<(), WriteError> {
+    let mut device = Device::new(Arc::clone(channel), index)
+        .await
+        .map_err(|_| WriteError::DeviceUnreachable { index })?;
+    let feature = open_feature::<ColorLedEffectsFeature>(&mut device).await?;
+    let zone_count = feature
+        .get_info()
+        .await
+        .map_err(classify_lighting_error)?
+        .zone_count;
+
+    let mut params = [0u8; ZONE_EFFECT_PARAM_COUNT];
+    params[0] = r;
+    params[1] = g;
+    params[2] = b;
+    let zones_to_write = if zone_count == 0 {
         debug!(
             index,
-            zone_count, zones_to_write, r, g, b, "set keyboard colour via typed 0x8070"
+            "0x8070 reported zero zones; applying legacy 4-zone fallback"
         );
-        Ok(())
-    })
-    .await
+        MAX_COLOR_LED_EFFECT_ZONES
+    } else {
+        zone_count.min(MAX_COLOR_LED_EFFECT_ZONES)
+    };
+    if zone_count > MAX_COLOR_LED_EFFECT_ZONES {
+        debug!(
+            index,
+            zone_count,
+            capped_zone_count = MAX_COLOR_LED_EFFECT_ZONES,
+            "0x8070 zone count capped to legacy write limit"
+        );
+    }
+    for zone in 0..zones_to_write {
+        feature
+            .set_zone_effect(zone, EFFECT_FIXED, params, Persistence::Volatile)
+            .await
+            .map_err(classify_lighting_error)?;
+        tokio::time::sleep(FRAME_GAP).await;
+    }
+    debug!(
+        index,
+        zone_count, zones_to_write, r, g, b, "set keyboard colour via typed 0x8070"
+    );
+    Ok(())
 }
 
 /// Classify a HID++ error from the `ColorLedEffects` functions.
@@ -195,17 +210,46 @@ fn classify_lighting_error(error: hidpp::protocol::v20::Hidpp20Error) -> WriteEr
 /// Set a solid colour via `PerKeyLighting` (`0x8080`): stream every key's colour
 /// in 64-byte `0x12` frames, then commit. `FeatureUnsupported` when the device
 /// exposes no `0x8080`.
-async fn set_color_per_key(route: &DeviceRoute, r: u8, g: u8, b: u8) -> Result<(), WriteError> {
-    let device_index = route.device_index();
-    let feature_index = resolve_feature_index(route, PER_KEY_LIGHTING_FEATURE)
+async fn set_color_per_key(
+    channel: &Arc<HidppChannel>,
+    device_index: u8,
+    r: u8,
+    g: u8,
+    b: u8,
+) -> Result<(), WriteError> {
+    let feature_index = resolve_feature_index(channel, device_index, PER_KEY_LIGHTING_FEATURE)
         .await?
         .ok_or(WriteError::FeatureUnsupported {
             feature_hex: PER_KEY_LIGHTING_FEATURE,
         })?;
 
-    let Some(mut writer) = crate::transport::open_route_writer(route).await? else {
-        return Err(WriteError::DeviceNotFound);
-    };
+    for report in per_key_reports(device_index, feature_index, r, g, b) {
+        let written = channel
+            .write_raw_report(&report)
+            .await
+            .map_err(classify_raw_lighting_error)?;
+        if written != report.len() {
+            return Err(WriteError::Hidpp(format!(
+                "raw lighting report wrote {written} of {} bytes",
+                report.len()
+            )));
+        }
+    }
+    debug!(
+        device_index,
+        feature_index, r, g, b, "set keyboard colour via 0x8080"
+    );
+    Ok(())
+}
+
+pub(super) fn per_key_reports(
+    device_index: u8,
+    feature_index: u8,
+    r: u8,
+    g: u8,
+    b: u8,
+) -> Vec<Vec<u8>> {
+    let mut reports = Vec::new();
     // Each 64-byte `0x12` "set group keys" packet carries up to 14
     // `(keyID, R, G, B)` entries; keyIDs are HID usage codes. Cover the whole
     // keyboard usage range (incl. modifiers at `0xe0..`) so every key lights,
@@ -226,23 +270,22 @@ async fn set_color_per_key(route: &DeviceRoute, r: u8, g: u8, b: u8) -> Result<(
             rep[off + 2] = g;
             rep[off + 3] = b;
         }
-        writer
-            .write_output_report(&rep)
-            .await
-            .map_err(WriteError::from)?;
+        reports.push(rep);
     }
     let mut commit = vec![0u8; 20];
     commit[0] = REPORT_LONG;
     commit[1] = device_index;
     commit[2] = feature_index;
     commit[3] = (FN_FRAME_END << 4) | SW_ID;
-    writer
-        .write_output_report(&commit)
-        .await
-        .map_err(WriteError::from)?;
-    debug!(
-        device_index,
-        feature_index, r, g, b, "set keyboard colour via 0x8080"
-    );
-    Ok(())
+    reports.push(commit);
+    reports
+}
+
+fn classify_raw_lighting_error(error: ChannelError) -> WriteError {
+    match error {
+        ChannelError::Timeout => WriteError::RequestTimedOut {
+            operation: HidppOperation::Lighting,
+        },
+        other => WriteError::Hidpp(format!("{other:?}")),
+    }
 }
diff --git a/crates/openlogi-hid/src/write/litra.rs b/crates/openlogi-hid/src/write/litra.rs
new file mode 100644
index 0000000000000000000000000000000000000000..9bbaea9a737e0c08ae13d574cb610a5ee26a0785
--- /dev/null
+++ b/crates/openlogi-hid/src/write/litra.rs
@@ -0,0 +1,416 @@
+//! Raw HID driver for Logitech Litra lights.
+//!
+//! Litra is deliberately implemented beside, not inside, the HID++ feature
+//! writers. The driver owns product matching, semantic-range conversion, and
+//! the fixed report encoding; the generic transport only owns enumeration and
+//! opening the selected raw HID node.
+
+use std::collections::HashMap;
+use std::sync::{Arc, LazyLock};
+use std::time::Duration;
+
+use async_hid::AsyncHidWrite as _;
+use openlogi_core::device::{LightCapabilities, LightValueRange, LightValueUnit};
+use serde::{Deserialize, Serialize};
+use tokio::sync::{Mutex, OwnedMutexGuard};
+use tracing::debug;
+
+use crate::route::DeviceRoute;
+
+use super::WriteError;
+
+/// Logitech vendor ID.
+pub const LOGITECH_VENDOR_ID: u16 = 0x046d;
+/// Stable driver-family identifier carried by standalone inventory records.
+pub const LITRA_DRIVER_ID: &str = "litra";
+/// Litra Glow product ID.
+pub const LITRA_GLOW_PRODUCT_ID: u16 = 0xc900;
+/// Litra Beam product ID.
+pub const LITRA_BEAM_PRODUCT_ID: u16 = 0xc901;
+/// Litra vendor usage page.
+pub const LITRA_USAGE_PAGE: u16 = 0xff43;
+/// Litra Glow usage ID.
+pub const LITRA_USAGE_ID: u16 = 0x0202;
+
+const REPORT_LEN: usize = 20;
+const REPORT_ID: u8 = 0x11;
+const REPORT_PREFIX: [u8; 2] = [0xff, 0x04];
+const COMMAND_POWER: u8 = 0x1c;
+const COMMAND_BRIGHTNESS: u8 = 0x4c;
+const COMMAND_TEMPERATURE: u8 = 0x9c;
+const MIN_BRIGHTNESS_LUMENS: u16 = 20;
+const MAX_BRIGHTNESS_LUMENS: u16 = 250;
+const MIN_TEMPERATURE_KELVIN: u16 = 2700;
+const MAX_TEMPERATURE_KELVIN: u16 = 6500;
+const TEMPERATURE_STEP_KELVIN: u16 = 100;
+const RAW_WRITE_TIMEOUT: Duration = Duration::from_secs(2);
+
+const fn validated_range(min: u16, max: u16, step: u16, unit: LightValueUnit) -> LightValueRange {
+    match LightValueRange::new(min, max, step, unit) {
+        Ok(range) => range,
+        Err(_) => panic!("invalid static Litra capability range"),
+    }
+}
+
+const GLOW_BRIGHTNESS_RANGE: LightValueRange = validated_range(
+    MIN_BRIGHTNESS_LUMENS,
+    MAX_BRIGHTNESS_LUMENS,
+    1,
+    LightValueUnit::Lumens,
+);
+const GLOW_TEMPERATURE_RANGE: LightValueRange = validated_range(
+    MIN_TEMPERATURE_KELVIN,
+    MAX_TEMPERATURE_KELVIN,
+    TEMPERATURE_STEP_KELVIN,
+    LightValueUnit::Kelvin,
+);
+
+/// A supported Litra product family variant.
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+pub enum LitraModel {
+    /// Logitech Litra Glow.
+    Glow,
+    /// Logitech Litra Beam.
+    Beam,
+}
+
+impl LitraModel {
+    /// Resolve a Litra model from its USB product ID.
+    #[must_use]
+    pub const fn from_product_id(product_id: u16) -> Option<Self> {
+        match product_id {
+            LITRA_GLOW_PRODUCT_ID => Some(Self::Glow),
+            LITRA_BEAM_PRODUCT_ID => Some(Self::Beam),
+            _ => None,
+        }
+    }
+
+    /// Resolve a model only when the complete raw-HID route matches a known
+    /// Litra interface. Product ID alone is insufficient protection against
+    /// writing a vendor report to an unrelated HID collection.
+    #[must_use]
+    pub fn from_route(route: &DeviceRoute) -> Option<Self> {
+        let DeviceRoute::RawHid {
+            vendor_id,
+            product_id,
+            usage_page,
+            usage_id,
+            ..
+        } = route
+        else {
+            return None;
+        };
+        matches_litra(*vendor_id, *product_id, *usage_page, *usage_id)
+            .then(|| Self::from_product_id(*product_id))
+            .flatten()
+    }
+
+    /// Stable driver-family identifier for this model.
+    #[must_use]
+    pub const fn driver_id(self) -> &'static str {
+        LITRA_DRIVER_ID
+    }
+
+    /// Exact model identifier used by the OpenLogi asset registry.
+    #[must_use]
+    pub const fn registry_model_id(self) -> Option<&'static str> {
+        match self {
+            Self::Glow => Some("8c900"),
+            Self::Beam => Some("8c901"),
+        }
+    }
+
+    /// Static capabilities exposed by the model.
+    #[must_use]
+    pub const fn capabilities(self) -> LightCapabilities {
+        match self {
+            Self::Glow | Self::Beam => LightCapabilities {
+                power: true,
+                brightness: Some(GLOW_BRIGHTNESS_RANGE),
+                temperature: Some(GLOW_TEMPERATURE_RANGE),
+                color: false,
+                zones: false,
+            },
+        }
+    }
+}
+
+/// Whether an HID descriptor identifies a supported Litra interface.
+#[must_use]
+pub fn matches_litra(vendor_id: u16, product_id: u16, usage_page: u16, usage_id: u16) -> bool {
+    vendor_id == LOGITECH_VENDOR_ID
+        && usage_page == LITRA_USAGE_PAGE
+        && usage_id == LITRA_USAGE_ID
+        && LitraModel::from_product_id(product_id).is_some()
+}
+
+/// A semantic command accepted by the standalone-light layer.
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
+pub enum LightCommand {
+    /// Turn the light on or off.
+    Power(bool),
+    /// Set normalized brightness from 0 to 100 percent.
+    BrightnessPercent(u8),
+    /// Set colour temperature in Kelvin.
+    TemperatureKelvin(u16),
+    /// Set brightness in the native unit advertised by the selected model.
+    /// This is primarily a diagnostic/CLI convenience; persisted settings
+    /// remain normalized percentages.
+    BrightnessNative(u16),
+}
+
+/// Encode a semantic command into the exact fixed-width Litra report.
+pub fn encode_command(
+    model: LitraModel,
+    command: LightCommand,
+) -> Result<[u8; REPORT_LEN], WriteError> {
+    let mut report = [0; REPORT_LEN];
+    report[0] = REPORT_ID;
+    report[1..3].copy_from_slice(&REPORT_PREFIX);
+    match command {
+        LightCommand::Power(enabled) => {
+            report[3] = COMMAND_POWER;
+            report[4] = u8::from(enabled);
+        }
+        LightCommand::BrightnessPercent(percent) => {
+            report[3] = COMMAND_BRIGHTNESS;
+            let range = model
+                .capabilities()
+                .brightness
+                .ok_or_else(|| unsupported("brightness"))?;
+            let lumens = percent_to_native(percent, range)?;
+            report[4..6].copy_from_slice(&lumens.to_be_bytes());
+        }
+        LightCommand::TemperatureKelvin(kelvin) => {
+            report[3] = COMMAND_TEMPERATURE;
+            let range = model
+                .capabilities()
+                .temperature
+                .ok_or_else(|| unsupported("temperature"))?;
+            if !range.contains(kelvin) {
+                return Err(WriteError::InvalidLightValue {
+                    control: "temperature_kelvin".into(),
+                    value: kelvin,
+                });
+            }
+            report[4..6].copy_from_slice(&kelvin.to_be_bytes());
+        }
+        LightCommand::BrightnessNative(value) => {
+            report[3] = COMMAND_BRIGHTNESS;
+            let range = model
+                .capabilities()
+                .brightness
+                .ok_or_else(|| unsupported("brightness"))?;
+            if !range.contains(value) {
+                return Err(WriteError::InvalidLightValue {
+                    control: "brightness_native".into(),
+                    value,
+                });
+            }
+            report[4..6].copy_from_slice(&value.to_be_bytes());
+        }
+    }
+    Ok(report)
+}
+
+fn percent_to_native(percent: u8, range: LightValueRange) -> Result<u16, WriteError> {
+    if percent > 100 {
+        return Err(WriteError::InvalidLightValue {
+            control: "brightness_percent".into(),
+            value: u16::from(percent),
+        });
+    }
+    range
+        .native_for_percent(percent)
+        .ok_or_else(|| WriteError::InvalidLightValue {
+            control: "brightness_percent".into(),
+            value: percent.into(),
+        })
+}
+
+fn unsupported(control: &str) -> WriteError {
+    WriteError::LightUnsupported {
+        control: control.into(),
+    }
+}
+
+static DEVICE_LOCKS: LazyLock<Mutex<HashMap<String, Arc<Mutex<()>>>>> =
+    LazyLock::new(|| Mutex::new(HashMap::new()));
+
+async fn device_lock(route: &DeviceRoute) -> OwnedMutexGuard<()> {
+    let key = route.to_string();
+    let lock = {
+        let mut locks = DEVICE_LOCKS.lock().await;
+        Arc::clone(locks.entry(key).or_insert_with(|| Arc::new(Mutex::new(()))))
+    };
+    lock.lock_owned().await
+}
+
+/// Apply a semantic Litra command through a raw HID route.
+pub async fn apply(
+    route: &DeviceRoute,
+    model: LitraModel,
+    command: LightCommand,
+) -> Result<(), WriteError> {
+    let Some(route_model) = LitraModel::from_route(route) else {
+        return Err(unsupported("raw_hid_route"));
+    };
+    if route_model != model {
+        return Err(unsupported("litra_model"));
+    }
+    let report = encode_command(model, command)?;
+    let _guard = device_lock(route).await;
+    let Some(mut writer) = crate::transport::open_route_writer(route).await? else {
+        return Err(WriteError::DeviceNotFound);
+    };
+    tokio::time::timeout(RAW_WRITE_TIMEOUT, writer.write_output_report(&report))
+        .await
+        .map_err(|_| WriteError::RequestTimedOut {
+            operation: super::HidppOperation::Light,
+        })?
+        .map_err(WriteError::from)?;
+    debug!(route = %route, "applied raw Litra command");
+    Ok(())
+}
+
+#[cfg(test)]
+mod tests {
+    #![allow(
+        clippy::expect_used,
+        reason = "expect is idiomatic in pure encoding tests"
+    )]
+
+    use std::assert_matches;
+
+    use super::{
+        COMMAND_BRIGHTNESS, COMMAND_POWER, COMMAND_TEMPERATURE, LITRA_BEAM_PRODUCT_ID,
+        LightCommand, LitraModel, REPORT_ID, encode_command, matches_litra,
+    };
+    use crate::{DeviceRoute, WriteError};
+
+    #[test]
+    fn glow_power_reports_are_fixed_width() {
+        let on = encode_command(LitraModel::Glow, LightCommand::Power(true)).expect("valid");
+        let off = encode_command(LitraModel::Glow, LightCommand::Power(false)).expect("valid");
+        assert_eq!(&on[..5], &[REPORT_ID, 0xff, 0x04, COMMAND_POWER, 1]);
+        assert_eq!(&off[..5], &[REPORT_ID, 0xff, 0x04, COMMAND_POWER, 0]);
+        assert_eq!(on.len(), 20);
+        assert!(on[5..].iter().all(|byte| *byte == 0));
+        assert!(off[5..].iter().all(|byte| *byte == 0));
+    }
+
+    #[test]
+    fn glow_brightness_uses_big_endian_native_lumens() {
+        let report =
+            encode_command(LitraModel::Glow, LightCommand::BrightnessPercent(50)).expect("valid");
+        assert_eq!(&report[3..6], &[COMMAND_BRIGHTNESS, 0, 0x87]);
+    }
+
+    #[test]
+    fn glow_brightness_maps_normalized_boundaries_to_native_range() {
+        let minimum =
+            encode_command(LitraModel::Glow, LightCommand::BrightnessPercent(0)).expect("valid");
+        let maximum =
+            encode_command(LitraModel::Glow, LightCommand::BrightnessPercent(100)).expect("valid");
+        assert_eq!(&minimum[3..6], &[COMMAND_BRIGHTNESS, 0, 20]);
+        assert_eq!(&maximum[3..6], &[COMMAND_BRIGHTNESS, 0, 250]);
+    }
+
+    #[test]
+    fn glow_native_brightness_preserves_the_exact_requested_lumens() {
+        let report =
+            encode_command(LitraModel::Glow, LightCommand::BrightnessNative(136)).expect("valid");
+        assert_eq!(&report[3..6], &[COMMAND_BRIGHTNESS, 0, 136]);
+        assert_matches!(
+            encode_command(LitraModel::Glow, LightCommand::BrightnessNative(251)),
+            Err(WriteError::InvalidLightValue { .. })
+        );
+    }
+
+    #[test]
+    fn glow_temperature_uses_big_endian_kelvin() {
+        let report =
+            encode_command(LitraModel::Glow, LightCommand::TemperatureKelvin(4600)).expect("valid");
+        assert_eq!(&report[3..6], &[COMMAND_TEMPERATURE, 0x11, 0xf8]);
+    }
+
+    #[test]
+    fn glow_temperature_accepts_only_aligned_inclusive_boundaries() {
+        assert!(encode_command(LitraModel::Glow, LightCommand::TemperatureKelvin(2700)).is_ok());
+        assert!(encode_command(LitraModel::Glow, LightCommand::TemperatureKelvin(6500)).is_ok());
+        for invalid in [2600, 2750, 6600] {
+            assert_matches!(
+                encode_command(LitraModel::Glow, LightCommand::TemperatureKelvin(invalid)),
+                Err(WriteError::InvalidLightValue { .. })
+            );
+        }
+    }
+
+    #[test]
+    fn invalid_values_are_rejected() {
+        assert_matches!(
+            encode_command(LitraModel::Glow, LightCommand::BrightnessPercent(101)),
+            Err(WriteError::InvalidLightValue { .. })
+        );
+        assert_matches!(
+            encode_command(LitraModel::Glow, LightCommand::TemperatureKelvin(2750)),
+            Err(WriteError::InvalidLightValue { .. })
+        );
+    }
+
+    #[test]
+    fn matcher_requires_the_full_identity_tuple() {
+        assert!(matches_litra(0x046d, 0xc900, 0xff43, 0x0202));
+        assert!(!matches_litra(0x046d, 0xc900, 0xff43, 0x0203));
+        assert!(!matches_litra(0x046d, 0xc902, 0xff43, 0x0202));
+        assert!(!matches_litra(0x1234, 0xc900, 0xff43, 0x0202));
+    }
+
+    #[test]
+    fn glow_descriptor_exposes_driver_identity() {
+        assert_eq!(LitraModel::Glow.driver_id(), "litra");
+    }
+
+    #[test]
+    fn registry_model_ids_match_the_asset_registry() {
+        assert_eq!(LitraModel::Glow.registry_model_id(), Some("8c900"));
+        assert_eq!(LitraModel::Beam.registry_model_id(), Some("8c901"));
+    }
+
+    #[test]
+    fn beam_is_matched_by_its_complete_route_tuple() {
+        assert!(matches_litra(0x046d, 0xc901, 0xff43, 0x0202));
+        assert_eq!(
+            LitraModel::from_product_id(LITRA_BEAM_PRODUCT_ID),
+            Some(LitraModel::Beam)
+        );
+    }
+
+    #[test]
+    fn model_resolution_requires_the_complete_raw_route_tuple() {
+        let valid = DeviceRoute::RawHid {
+            vendor_id: 0x046d,
+            product_id: 0xc900,
+            usage_page: 0xff43,
+            usage_id: 0x0202,
+            identity: "serial:test".into(),
+        };
+        let wrong_usage = DeviceRoute::RawHid {
+            vendor_id: 0x046d,
+            product_id: 0xc900,
+            usage_page: 0xff43,
+            usage_id: 0x0203,
+            identity: "serial:test".into(),
+        };
+
+        assert_eq!(LitraModel::from_route(&valid), Some(LitraModel::Glow));
+        assert_eq!(LitraModel::from_route(&wrong_usage), None);
+        assert_eq!(
+            LitraModel::from_route(&DeviceRoute::Direct {
+                vendor_id: 0x046d,
+                product_id: 0xc900,
+            }),
+            None
+        );
+    }
+}
diff --git a/crates/openlogi-hid/src/write/shared.rs b/crates/openlogi-hid/src/write/shared.rs
index aa7a6110707b52cd047bef17ec65597163fb8371..73dd55f3c7c3d37834aa2835e9d7a23ade7ad675 100644
--- a/crates/openlogi-hid/src/write/shared.rs
+++ b/crates/openlogi-hid/src/write/shared.rs
@@ -4,18 +4,22 @@ use hidpp::channel::HidppChannel;
 
 use crate::route::DeviceRoute;
 use crate::smartshift::SmartShiftMode;
+use crate::smartshift::SmartShiftStatus;
 
 use super::WriteError;
-use super::dpi::set_dpi_on_channel;
-use super::smartshift::{set_smartshift_on_channel, toggle_smartshift_on_channel};
+use super::dpi::{DpiInfo, get_dpi_info_on_channel, set_dpi_on_channel};
+use super::fn_lock::set_fn_lock_on_channel;
+use super::lighting::{LightingMethod, set_keyboard_color_with_on_channel};
+use super::smartshift::{
+    get_smartshift_status_on_channel, set_smartshift_on_channel, toggle_smartshift_on_channel,
+};
 
-/// An open HID++ channel to a device, shared so DPI / SmartShift writes can
-/// reuse the capture session's connection instead of re-enumerating and
-/// opening a fresh channel each time (which costs ~100ms+).
+/// An open HID++ channel to a device, shared so route-addressed reads and writes
+/// can reuse an inventory- or capture-owned connection instead of
+/// re-enumerating and opening a fresh channel each time (which costs ~100ms+).
 ///
 /// Cheap to clone (an `Arc` plus the [`DeviceRoute`] it points at). Built by
-/// the capture session via `SharedChannel::new` and stashed in a slot the
-/// GUI's write path consults.
+/// the inventory registry or a standalone capture session.
 #[derive(Clone)]
 pub struct SharedChannel {
     channel: Arc<HidppChannel>,
@@ -51,11 +55,29 @@ pub async fn set_dpi_on(shared: &SharedChannel, dpi: u16) -> Result<(), WriteErr
     set_dpi_on_channel(&shared.channel, shared.route.device_index(), dpi).await
 }
 
+/// Read current DPI and supported values on an already-open [`SharedChannel`].
+pub async fn get_dpi_info_on(shared: &SharedChannel) -> Result<DpiInfo, WriteError> {
+    get_dpi_info_on_channel(&shared.channel, shared.route.device_index()).await
+}
+
 /// Toggle SmartShift on an already-open [`SharedChannel`].
 pub async fn toggle_smartshift_on(shared: &SharedChannel) -> Result<SmartShiftMode, WriteError> {
     toggle_smartshift_on_channel(&shared.channel, shared.route.device_index()).await
 }
 
+/// Read SmartShift mode and sensitivity on an already-open [`SharedChannel`].
+pub async fn get_smartshift_status_on(
+    shared: &SharedChannel,
+) -> Result<SmartShiftStatus, WriteError> {
+    get_smartshift_status_on_channel(&shared.channel, shared.route.device_index()).await
+}
+
+/// Write keyboard Fn-lock on an already-open [`SharedChannel`] — the fast
+/// path that skips enumeration and channel setup.
+pub async fn set_fn_lock_on(shared: &SharedChannel, on: bool) -> Result<(), WriteError> {
+    set_fn_lock_on_channel(&shared.channel, shared.route.device_index(), on).await
+}
+
 /// Write a full SmartShift configuration on an already-open [`SharedChannel`]
 /// — the fast path that skips enumeration and channel setup.
 pub async fn set_smartshift_on(
@@ -73,3 +95,34 @@ pub async fn set_smartshift_on(
     )
     .await
 }
+
+/// Set a solid keyboard colour on an already-open [`SharedChannel`], using
+/// [`LightingMethod::Auto`].
+pub async fn set_keyboard_color_on(
+    shared: &SharedChannel,
+    r: u8,
+    g: u8,
+    b: u8,
+) -> Result<(), WriteError> {
+    set_keyboard_color_with_on(shared, LightingMethod::Auto, r, g, b).await
+}
+
+/// Set a solid keyboard colour on an already-open [`SharedChannel`] with an
+/// explicit lighting method.
+pub async fn set_keyboard_color_with_on(
+    shared: &SharedChannel,
+    method: LightingMethod,
+    r: u8,
+    g: u8,
+    b: u8,
+) -> Result<(), WriteError> {
+    set_keyboard_color_with_on_channel(
+        &shared.channel,
+        shared.route.device_index(),
+        method,
+        r,
+        g,
+        b,
+    )
+    .await
+}
diff --git a/crates/openlogi-hid/src/write/smartshift.rs b/crates/openlogi-hid/src/write/smartshift.rs
index dd566d2140fd7f6aba9b264c978b25055894a8dd..60a66cdff7df4dde34e80df2b9a260be5397298e 100644
--- a/crates/openlogi-hid/src/write/smartshift.rs
+++ b/crates/openlogi-hid/src/write/smartshift.rs
@@ -241,15 +241,22 @@ impl SmartShift {
 pub async fn get_smartshift_status(route: &DeviceRoute) -> Result<SmartShiftStatus, WriteError> {
     let index = route.device_index();
     with_route(route, move |channel| async move {
-        let mut device = Device::new(Arc::clone(&channel), index)
-            .await
-            .map_err(|_| WriteError::DeviceUnreachable { index })?;
-        let smartshift = SmartShift::open(&mut device).await?;
-        smartshift.status().await
+        get_smartshift_status_on_channel(&channel, index).await
     })
     .await
 }
 
+pub(super) async fn get_smartshift_status_on_channel(
+    channel: &Arc<HidppChannel>,
+    index: u8,
+) -> Result<SmartShiftStatus, WriteError> {
+    let mut device = Device::new(Arc::clone(channel), index)
+        .await
+        .map_err(|_| WriteError::DeviceUnreachable { index })?;
+    let smartshift = SmartShift::open(&mut device).await?;
+    smartshift.status().await
+}
+
 /// Set the SmartShift auto-disengage sensitivity on `route`, preserving the
 /// current mode. Returns the read-back status after the write so the caller can
 /// display and verify it.
diff --git a/crates/openlogi-hid/src/write/tests.rs b/crates/openlogi-hid/src/write/tests.rs
index 57dd8aa4161176a77fcb45360e71827b2632bb66..f6261025e9ee45af28d8359b2f9699975b5889d3 100644
--- a/crates/openlogi-hid/src/write/tests.rs
+++ b/crates/openlogi-hid/src/write/tests.rs
@@ -1,16 +1,41 @@
 use std::assert_matches;
+use std::error::Error;
+use std::io;
+use std::sync::{Arc, Mutex, PoisonError};
 
 use super::*;
+use hidpp::channel::{HidppChannel, RawHidChannel};
 use hidpp::feature::smartshift::WheelMode;
+use openlogi_core::config::LightSettings;
+use openlogi_core::device::{LightCapabilities, LightValueRange, LightValueUnit};
+use tokio::sync::mpsc;
 
 use crate::SmartShiftMode;
 use crate::SmartShiftStatus;
+use crate::write::lighting::per_key_reports;
 use crate::write::smartshift::{
     is_missing_enhanced, is_transient_smartshift_error, smartshift_to_wheel,
     status_matches_desired, wheel_mode_to_smartshift,
 };
 use crate::write::{HidppFeatureErrorKind, HidppOperation};
 
+#[test]
+fn light_settings_expand_only_to_advertised_controls() {
+    let Ok(brightness) = LightValueRange::new(0, 100, 1, LightValueUnit::Percent) else {
+        panic!("valid brightness fixture");
+    };
+    let settings = LightSettings::new(false, 37, Some(4600));
+    let commands = commands_for_light_settings(
+        settings,
+        LightCapabilities {
+            brightness: Some(brightness),
+            ..LightCapabilities::default()
+        },
+    );
+
+    assert_eq!(commands, vec![LightCommand::BrightnessPercent(37)]);
+}
+
 #[test]
 fn capabilities_sort_and_deduplicate_values() -> Result<(), WriteError> {
     let caps = DpiCapabilities::new(vec![1600, 400, 800, 800])?;
@@ -182,3 +207,219 @@ fn status_match_ignores_zero_preserve_fields() {
         }
     ));
 }
+
+#[test]
+fn per_key_lighting_builds_only_very_long_frames_then_one_long_commit() {
+    let reports = per_key_reports(0x03, 0x27, 0x11, 0x22, 0x33);
+    let (commit, frames) = reports
+        .split_last()
+        .unwrap_or_else(|| panic!("per-key lighting must emit a commit"));
+
+    assert_eq!(frames.len(), 17);
+    assert!(frames.iter().all(|report| report.len() == 64));
+    assert!(frames.iter().all(|report| report[0] == 0x12));
+    assert!(frames.iter().all(|report| report[1] == 0x03));
+    assert!(frames.iter().all(|report| report[2] == 0x27));
+    assert!(frames.iter().all(|report| report[3] == 0x3a));
+    assert!(frames.iter().all(|report| report[5] == 0x01));
+    assert!(frames.iter().all(|report| report[7] == 0x0e));
+
+    let entries: Vec<_> = frames
+        .iter()
+        .flat_map(|report| report[8..64].chunks_exact(4))
+        .take(0xe9)
+        .map(|entry| (entry[0], entry[1], entry[2], entry[3]))
+        .collect();
+    assert_eq!(entries.len(), 0xe9);
+    for (key, entry) in (0x00u8..=0xe8).zip(entries) {
+        assert_eq!(entry, (key, 0x11, 0x22, 0x33));
+    }
+
+    assert_eq!(commit.len(), 20);
+    assert_eq!(&commit[..4], &[0x11, 0x03, 0x27, 0x5a]);
+    assert!(commit[4..].iter().all(|byte| *byte == 0));
+}
+
+#[tokio::test]
+async fn shared_read_and_lighting_apis_use_the_supplied_channel() -> Result<(), WriteError> {
+    let (raw, handle) = ScriptedRawHidChannel::new();
+    let channel = Arc::new(
+        HidppChannel::from_raw_channel(raw)
+            .await
+            .unwrap_or_else(|error| panic!("scripted HID++ channel must open: {error:?}")),
+    );
+    let shared = SharedChannel::new(
+        channel,
+        DeviceRoute::Direct {
+            vendor_id: 0x046d,
+            product_id: 0xb35b,
+        },
+    );
+
+    let dpi = get_dpi_info_on(&shared).await?;
+    assert_eq!(dpi.current, 800);
+    assert_eq!(dpi.capabilities.values(), [400, 800, 1600]);
+
+    let smartshift = get_smartshift_status_on(&shared).await?;
+    assert_eq!(smartshift.mode, SmartShiftMode::Ratchet);
+    assert_eq!(smartshift.auto_disengage, 10);
+    assert_eq!(smartshift.tunable_torque, 33);
+
+    // The scripted device reports no 0x8070 effect engine, so Auto must fall
+    // back to 0x8080 without opening a second transport.
+    set_keyboard_color_on(&shared, 0x11, 0x22, 0x33).await?;
+
+    let written = handle.written_reports();
+    let very_long: Vec<_> = written
+        .iter()
+        .filter(|report| report.first() == Some(&0x12))
+        .collect();
+    assert_eq!(very_long.len(), 17);
+    assert!(very_long.iter().all(|report| report.len() == 64));
+    assert!(written.iter().any(|report| {
+        report.len() == 20
+            && report[0] == 0x11
+            && report[1] == 0xff
+            && report[2] == 0x07
+            && report[3] >> 4 == 0x05
+    }));
+    Ok(())
+}
+
+#[derive(Clone)]
+struct ScriptedRawHidHandle {
+    written: Arc<Mutex<Vec<Vec<u8>>>>,
+}
+
+impl ScriptedRawHidHandle {
+    fn written_reports(&self) -> Vec<Vec<u8>> {
+        self.written
+            .lock()
+            .unwrap_or_else(PoisonError::into_inner)
+            .clone()
+    }
+}
+
+struct ScriptedRawHidChannel {
+    incoming_tx: mpsc::UnboundedSender<Vec<u8>>,
+    incoming_rx: tokio::sync::Mutex<mpsc::UnboundedReceiver<Vec<u8>>>,
+    written: Arc<Mutex<Vec<Vec<u8>>>>,
+}
+
+impl ScriptedRawHidChannel {
+    fn new() -> (Self, ScriptedRawHidHandle) {
+        let (incoming_tx, incoming_rx) = mpsc::unbounded_channel();
+        let written = Arc::new(Mutex::new(Vec::new()));
+        (
+            Self {
+                incoming_tx,
+                incoming_rx: tokio::sync::Mutex::new(incoming_rx),
+                written: Arc::clone(&written),
+            },
+            ScriptedRawHidHandle { written },
+        )
+    }
+}
+
+#[hidpp::async_trait]
+impl RawHidChannel for ScriptedRawHidChannel {
+    fn vendor_id(&self) -> u16 {
+        0x046d
+    }
+
+    fn product_id(&self) -> u16 {
+        0xb35b
+    }
+
+    async fn write_report(&self, src: &[u8]) -> Result<usize, Box<dyn Error + Send + Sync>> {
+        self.written
+            .lock()
+            .unwrap_or_else(PoisonError::into_inner)
+            .push(src.to_vec());
+        if let Some(response) = scripted_response(src) {
+            self.incoming_tx.send(response).map_err(|_| mock_error())?;
+        }
+        Ok(src.len())
+    }
+
+    async fn read_report(&self, buf: &mut [u8]) -> Result<usize, Box<dyn Error + Send + Sync>> {
+        let Some(report) = self.incoming_rx.lock().await.recv().await else {
+            return Err(mock_error());
+        };
+        let len = report.len().min(buf.len());
+        buf[..len].copy_from_slice(&report[..len]);
+        Ok(len)
+    }
+
+    fn supports_short_long_hidpp(&self) -> Option<(bool, bool)> {
+        Some((true, true))
+    }
+
+    async fn get_report_descriptor(
+        &self,
+        _buf: &mut [u8],
+    ) -> Result<usize, Box<dyn Error + Send + Sync>> {
+        unreachable!("scripted channel declares HID++ support")
+    }
+}
+
+fn scripted_response(request: &[u8]) -> Option<Vec<u8>> {
+    if request.len() < 7 || !matches!(request[0], 0x10 | 0x11) {
+        return None;
+    }
+    let feature_index = request[2];
+    let function = request[3] >> 4;
+    let mut payload = [0u8; 16];
+    let long = match (feature_index, function) {
+        // Root ping used by Device::new.
+        (0x00, 0x01) => {
+            payload[0] = 4;
+            false
+        }
+        // Root feature lookup.
+        (0x00, 0x00) => {
+            let feature_id = u16::from_be_bytes([request[4], request[5]]);
+            payload[0] = match feature_id {
+                0x2201 => 0x05,
+                0x2111 => 0x06,
+                0x8080 => 0x07,
+                _ => 0x00,
+            };
+            false
+        }
+        // AdjustableDpi sensor count/current/list.
+        (0x05, 0x00) => {
+            payload[0] = 1;
+            false
+        }
+        (0x05, 0x02) => {
+            payload[1..3].copy_from_slice(&800u16.to_be_bytes());
+            false
+        }
+        (0x05, 0x01) => {
+            payload[..8].copy_from_slice(&[0, 0x01, 0x90, 0x03, 0x20, 0x06, 0x40, 0]);
+            true
+        }
+        // Enhanced SmartShift status.
+        (0x06, 0x01) => {
+            payload[..3].copy_from_slice(&[u8::from(WheelMode::Ratchet), 10, 33]);
+            false
+        }
+        // Raw per-key frame commit expects no reply.
+        _ => return None,
+    };
+
+    let mut response = vec![0u8; if long { 20 } else { 7 }];
+    response[0] = if long { 0x11 } else { 0x10 };
+    response[1..4].copy_from_slice(&request[1..4]);
+    let payload_len = response.len() - 4;
+    response[4..].copy_from_slice(&payload[..payload_len]);
+    Some(response)
+}
+
+fn mock_error() -> Box<dyn Error + Send + Sync> {
+    Box::new(io::Error::new(
+        io::ErrorKind::BrokenPipe,
+        "scripted HID channel closed",
+    ))
+}
diff --git a/crates/openlogi-hidpp/src/channel.rs b/crates/openlogi-hidpp/src/channel.rs
index a8535f6d17dd527b8afeec4d9231426942b04a1d..8fd22d7222fc1b2819bb6b49829fd5f33c6bc3cd 100644
--- a/crates/openlogi-hidpp/src/channel.rs
+++ b/crates/openlogi-hidpp/src/channel.rs
@@ -31,6 +31,10 @@ const MAX_REPORT_DESCRIPTOR_LENGTH: usize = 4096;
 /// As we only care about HID++ reports, this equals to [`LONG_REPORT_LENGTH`].
 const MAX_REPORT_LENGTH: usize = LONG_REPORT_LENGTH;
 
+/// Largest output report accepted by [`HidppChannel::write_raw_report`].
+/// Logitech's very-long HID++ lighting report (`0x12`) is 64 bytes.
+const MAX_RAW_REPORT_LENGTH: usize = 64;
+
 /// The default time budget for a [`HidppChannel::send`] request: the report
 /// write plus the wait for a matching response. Callers that need a different
 /// budget can use [`HidppChannel::send_with_timeout`].
@@ -96,6 +100,15 @@ pub trait RawHidChannel: Sync + Send + 'static {
     /// must do the same and must not await `read_report` bare.
     async fn read_report(&self, buf: &mut [u8]) -> Result<usize, Box<dyn Error + Sync + Send>>;
 
+    /// Whether the underlying device connection is still usable.
+    ///
+    /// Implementations that can detect a permanent disconnect should override
+    /// this. The default preserves the behavior of transports that cannot
+    /// report connection state.
+    fn is_connected(&self) -> bool {
+        true
+    }
+
     /// If the implementation already knows whether the underlying HID channel
     /// supports HID++ messages, it should return `Some((supports_short,
     /// supports_long))` from this method.
@@ -414,6 +427,11 @@ impl HidppChannel {
         })
     }
 
+    /// Whether the underlying HID transport still reports a live connection.
+    pub fn is_connected(&self) -> bool {
+        self.raw_channel.is_connected()
+    }
+
     /// Sets the software ID that should be returned by the next call to
     /// [`Self::get_sw_id`].
     ///
@@ -619,6 +637,34 @@ impl HidppChannel {
             .map_err(ChannelError::Implementation)
     }
 
+    /// Write one raw HID report through this channel's already-owned transport.
+    ///
+    /// Reports must contain `1..=64` bytes, including their report ID. The
+    /// operation is bounded by [`SEND_RESPONSE_TIMEOUT`] and returns the exact
+    /// byte count reported by the transport. This is intended for HID++ report
+    /// widths such as the 64-byte `0x12` lighting frame that [`HidppMessage`]
+    /// cannot represent.
+    pub async fn write_raw_report(&self, report: &[u8]) -> Result<usize, ChannelError> {
+        self.write_raw_report_with_timeout(report, SEND_RESPONSE_TIMEOUT)
+            .await
+    }
+
+    async fn write_raw_report_with_timeout(
+        &self,
+        report: &[u8],
+        timeout: Duration,
+    ) -> Result<usize, ChannelError> {
+        if !(1..=MAX_RAW_REPORT_LENGTH).contains(&report.len()) {
+            return Err(ChannelError::InvalidRawReportLength(report.len()));
+        }
+
+        let mut write = std::pin::pin!(self.raw_channel.write_report(report).fuse());
+        select! {
+            result = write => result.map_err(ChannelError::Implementation),
+            _ = futures_timer::Delay::new(timeout).fuse() => Err(ChannelError::Timeout),
+        }
+    }
+
     /// Registers a listener that will be called for every incoming message.
     ///
     /// Returns a handle that can be used to remove the listener using a call to
@@ -687,14 +733,20 @@ pub enum ChannelError {
     #[error("the channel does not support the given HID++ message type")]
     MessageTypeNotSupported,
 
+    /// Indicates that a raw output report was empty or exceeded 64 bytes.
+    #[error("raw HID reports must contain 1..=64 bytes, got {0}")]
+    InvalidRawReportLength(usize),
+
     /// Indicates that no response was received following a request.
     #[error("the device did not respond to the request")]
     NoResponse,
 
-    /// Indicates that a request did not complete within its time budget —
-    /// typically the device is asleep, out of range or connected to another
-    /// host. See [`HidppChannel::send_with_timeout`].
-    #[error("the request timed out before the device responded")]
+    /// Indicates that a bounded channel operation did not complete — typically
+    /// because the device is asleep, out of range, connected to another host,
+    /// or its transport write is wedged. See
+    /// [`HidppChannel::send_with_timeout`] and
+    /// [`HidppChannel::write_raw_report`].
+    #[error("the HID channel operation timed out")]
     Timeout,
 }
 
@@ -716,7 +768,7 @@ mod tests {
         io,
         sync::{
             Arc, Mutex,
-            atomic::{AtomicUsize, Ordering},
+            atomic::{AtomicBool, AtomicUsize, Ordering},
         },
         time::{Duration, Instant},
     };
@@ -882,6 +934,59 @@ mod tests {
         });
     }
 
+    #[test]
+    fn raw_report_write_forwards_exact_bytes_and_length() {
+        futures::executor::block_on(async {
+            let (raw, handle) = MockRawHidChannel::new();
+            let channel = HidppChannel::from_raw_channel(raw).await.unwrap();
+            let report = [0x12; MAX_RAW_REPORT_LENGTH];
+
+            let written = channel.write_raw_report(&report).await.unwrap();
+
+            assert_eq!(written, report.len());
+            assert_eq!(handle.written_reports(), [report.to_vec()]);
+        });
+    }
+
+    #[test]
+    fn raw_report_write_rejects_empty_and_oversized_inputs_without_io() {
+        futures::executor::block_on(async {
+            let (raw, handle) = MockRawHidChannel::new();
+            let channel = HidppChannel::from_raw_channel(raw).await.unwrap();
+
+            let empty = channel.write_raw_report(&[]).await.unwrap_err();
+            let oversized = channel
+                .write_raw_report(&[0; MAX_RAW_REPORT_LENGTH + 1])
+                .await
+                .unwrap_err();
+
+            assert!(matches!(empty, ChannelError::InvalidRawReportLength(0)));
+            assert!(matches!(
+                oversized,
+                ChannelError::InvalidRawReportLength(65)
+            ));
+            assert!(handle.written_reports().is_empty());
+        });
+    }
+
+    #[test]
+    fn raw_report_write_times_out_when_the_transport_parks() {
+        futures::executor::block_on(async {
+            let (raw, handle) = MockRawHidChannel::new();
+            handle.park_writes();
+            let channel = HidppChannel::from_raw_channel(raw).await.unwrap();
+            let started = Instant::now();
+
+            let error = channel
+                .write_raw_report_with_timeout(&[LONG_REPORT_ID], Duration::from_millis(25))
+                .await
+                .unwrap_err();
+
+            assert!(matches!(error, ChannelError::Timeout));
+            assert!(started.elapsed() < Duration::from_secs(1));
+        });
+    }
+
     #[test]
     fn listener_can_remove_another_listener_during_dispatch() {
         futures::executor::block_on(async {
@@ -1133,6 +1238,7 @@ mod tests {
         incoming_tx: async_channel::Sender<Vec<u8>>,
         written_reports: Arc<Mutex<Vec<Vec<u8>>>>,
         responses_on_write: Arc<Mutex<VecDeque<Vec<u8>>>>,
+        park_writes: Arc<AtomicBool>,
     }
 
     impl MockRawHidHandle {
@@ -1150,6 +1256,10 @@ mod tests {
         fn written_reports(&self) -> Vec<Vec<u8>> {
             self.written_reports.lock().unwrap().clone()
         }
+
+        fn park_writes(&self) {
+            self.park_writes.store(true, Ordering::SeqCst);
+        }
     }
 
     struct MockRawHidChannel {
@@ -1157,6 +1267,7 @@ mod tests {
         incoming_rx: async_channel::Receiver<Vec<u8>>,
         written_reports: Arc<Mutex<Vec<Vec<u8>>>>,
         responses_on_write: Arc<Mutex<VecDeque<Vec<u8>>>>,
+        park_writes: Arc<AtomicBool>,
     }
 
     impl MockRawHidChannel {
@@ -1164,11 +1275,13 @@ mod tests {
             let (incoming_tx, incoming_rx) = async_channel::unbounded();
             let written_reports = Arc::new(Mutex::new(Vec::new()));
             let responses_on_write = Arc::new(Mutex::new(VecDeque::new()));
+            let park_writes = Arc::new(AtomicBool::new(false));
 
             let handle = MockRawHidHandle {
                 incoming_tx: incoming_tx.clone(),
                 written_reports: Arc::clone(&written_reports),
                 responses_on_write: Arc::clone(&responses_on_write),
+                park_writes: Arc::clone(&park_writes),
             };
 
             (
@@ -1177,6 +1290,7 @@ mod tests {
                     incoming_rx,
                     written_reports,
                     responses_on_write,
+                    park_writes,
                 },
                 handle,
             )
@@ -1195,6 +1309,9 @@ mod tests {
 
         async fn write_report(&self, src: &[u8]) -> Result<usize, Box<dyn Error + Sync + Send>> {
             self.written_reports.lock().unwrap().push(src.to_vec());
+            if self.park_writes.load(Ordering::SeqCst) {
+                return std::future::pending().await;
+            }
             let response = self.responses_on_write.lock().unwrap().pop_front();
             if let Some(response) = response {
                 self.incoming_tx.send(response).await.unwrap();
diff --git a/crates/openlogi-hidpp/src/feature/battery_status/mod.rs b/crates/openlogi-hidpp/src/feature/battery_status/mod.rs
new file mode 100644
index 0000000000000000000000000000000000000000..b86a81b14e6d990f3027d99e8665836a86e0946a
--- /dev/null
+++ b/crates/openlogi-hidpp/src/feature/battery_status/mod.rs
@@ -0,0 +1,99 @@
+//! Implements the legacy `BatteryStatus` feature (ID `0x1000`) that reports a
+//! device's battery charge as a discharge level plus a charging status.
+//!
+//! This is the predecessor of `UnifiedBattery` (`0x1004`): older mice such as
+//! the MX Master 2S expose `0x1000` and never `0x1004`, so the inventory probe
+//! falls back to this feature when the unified one is absent — the same
+//! enhanced-then-legacy pattern `SmartShift` uses for `0x2111` / `0x2110`.
+//!
+//! Only `getBatteryLevelStatus` (function `0`) is implemented; the optional
+//! `getBatteryCapability` (function `1`) and the broadcast event aren't needed
+//! to display a charge reading.
+
+use std::{hash::Hash, sync::Arc};
+
+use num_enum::{IntoPrimitive, TryFromPrimitive};
+
+use crate::{
+    channel::HidppChannel,
+    feature::{CreatableFeature, Feature, FeatureEndpoint},
+    protocol::v20::Hidpp20Error,
+};
+
+/// Implements the legacy `BatteryStatus` / `0x1000` feature.
+pub struct BatteryStatusFeature {
+    /// The endpoint this feature talks to.
+    endpoint: FeatureEndpoint,
+}
+
+impl CreatableFeature for BatteryStatusFeature {
+    const ID: u16 = 0x1000;
+    const STARTING_VERSION: u8 = 0;
+
+    fn new(chan: Arc<HidppChannel>, device_index: u8, feature_index: u8) -> Self {
+        Self {
+            endpoint: FeatureEndpoint::new(chan, device_index, feature_index),
+        }
+    }
+}
+
+impl Feature for BatteryStatusFeature {}
+
+impl BatteryStatusFeature {
+    /// Reads the current battery level and charging status (function `0`,
+    /// `getBatteryLevelStatus`).
+    pub async fn get_battery_level_status(&self) -> Result<LegacyBatteryInfo, Hidpp20Error> {
+        let payload = self.endpoint.call(0, [0; 3]).await?.extend_payload();
+
+        Ok(LegacyBatteryInfo {
+            discharge_level: payload[0],
+            next_level: payload[1],
+            status: LegacyBatteryStatus::try_from(payload[2])
+                .map_err(|_| Hidpp20Error::UnsupportedResponse)?,
+        })
+    }
+}
+
+/// A reading from the legacy `0x1000` `getBatteryLevelStatus` function.
+#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
+#[cfg_attr(feature = "serde", derive(serde::Serialize))]
+#[non_exhaustive]
+pub struct LegacyBatteryInfo {
+    /// Current battery charge as a percentage (`0`–`100`). Logitech firmware
+    /// reports this in coarse steps rather than a continuous value.
+    pub discharge_level: u8,
+
+    /// The next lower discharge step the firmware will report — a hint at the
+    /// reporting granularity. Unused for display.
+    pub next_level: u8,
+
+    /// The current charging status.
+    pub status: LegacyBatteryStatus,
+}
+
+/// Charging status reported by the legacy `0x1000` feature. Values follow the
+/// HID++ `batteryStatus` enumeration (see Solaar / `hid-logitech-hidpp`).
+#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, IntoPrimitive, TryFromPrimitive)]
+#[cfg_attr(feature = "serde", derive(serde::Serialize))]
+#[non_exhaustive]
+#[repr(u8)]
+pub enum LegacyBatteryStatus {
+    /// Battery is discharging.
+    Discharging = 0,
+    /// Battery is recharging.
+    Recharging = 1,
+    /// Battery is charging and nearly full.
+    AlmostFull = 2,
+    /// Battery charge is complete.
+    Full = 3,
+    /// Battery is recharging below optimal speed.
+    SlowRecharge = 4,
+    /// The battery type is invalid.
+    InvalidBattery = 5,
+    /// The battery subsystem reported a thermal error.
+    ThermalError = 6,
+    /// "Other charging error" (Solaar lists value 7). Kept explicit so a device
+    /// reporting it surfaces as Unknown instead of failing the parse and making
+    /// the battery indicator vanish from the UI.
+    Other = 7,
+}
diff --git a/crates/openlogi-hidpp/src/feature/crown/event.rs b/crates/openlogi-hidpp/src/feature/crown/event.rs
index 59a2b422c22e0002dd00389360b9f9f67fd1f353..d9b20b7d13dd1c3d6ee51c97a9cb3c45ce05d68d 100644
--- a/crates/openlogi-hidpp/src/feature/crown/event.rs
+++ b/crates/openlogi-hidpp/src/feature/crown/event.rs
@@ -1,9 +1,9 @@
 //! The event emitted by the `Crown` feature (`0x4600`).
 
-use num_enum::{IntoPrimitive, TryFromPrimitive};
+use num_enum::{FromPrimitive, IntoPrimitive};
 
 /// Rotation phase reported in a [`CrownUpdate`].
-#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, IntoPrimitive, TryFromPrimitive)]
+#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, IntoPrimitive, FromPrimitive)]
 #[cfg_attr(feature = "serde", derive(serde::Serialize))]
 #[non_exhaustive]
 #[repr(u8)]
@@ -16,10 +16,13 @@ pub enum RotationState {
     Active = 2,
     /// Rotation stopped.
     Stop = 3,
+    /// A state this crate does not model; carries the raw byte.
+    #[num_enum(catch_all)]
+    Other(u8),
 }
 
 /// Proximity or touch activity phase reported in a [`CrownUpdate`].
-#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, IntoPrimitive, TryFromPrimitive)]
+#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, IntoPrimitive, FromPrimitive)]
 #[cfg_attr(feature = "serde", derive(serde::Serialize))]
 #[non_exhaustive]
 #[repr(u8)]
@@ -32,10 +35,13 @@ pub enum ActivityState {
     Active = 2,
     /// Stopped.
     Stop = 3,
+    /// A state this crate does not model; carries the raw byte.
+    #[num_enum(catch_all)]
+    Other(u8),
 }
 
 /// Touch gesture reported in a [`CrownUpdate`].
-#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, IntoPrimitive, TryFromPrimitive)]
+#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, IntoPrimitive, FromPrimitive)]
 #[cfg_attr(feature = "serde", derive(serde::Serialize))]
 #[non_exhaustive]
 #[repr(u8)]
@@ -46,10 +52,13 @@ pub enum CrownGesture {
     Tap = 1,
     /// Double tap.
     DoubleTap = 2,
+    /// A gesture this crate does not model; carries the raw byte.
+    #[num_enum(catch_all)]
+    Other(u8),
 }
 
 /// Crown button state reported in a [`CrownUpdate`].
-#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, IntoPrimitive, TryFromPrimitive)]
+#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, IntoPrimitive, FromPrimitive)]
 #[cfg_attr(feature = "serde", derive(serde::Serialize))]
 #[non_exhaustive]
 #[repr(u8)]
@@ -66,6 +75,9 @@ pub enum ButtonState {
     LongPressActive = 4,
     /// Released.
     Release = 5,
+    /// A state this crate does not model; carries the raw byte.
+    #[num_enum(catch_all)]
+    Other(u8),
 }
 
 /// An event emitted by [`CrownFeature`](super::CrownFeature).
@@ -107,13 +119,13 @@ pub struct CrownUpdate {
 pub(super) fn decode_event(sub_id: u8, payload: &[u8; 16]) -> Option<CrownEvent> {
     match sub_id {
         0 => Some(CrownEvent::Update(CrownUpdate {
-            rotation_state: RotationState::try_from(payload[0]).ok()?,
+            rotation_state: RotationState::from(payload[0]),
             relative_slot_rotation: payload[1] as i8,
             relative_ratchet_rotation: payload[2] as i8,
-            proximity: ActivityState::try_from(payload[3]).ok()?,
-            touch: ActivityState::try_from(payload[4]).ok()?,
-            gesture: CrownGesture::try_from(payload[5]).ok()?,
-            button: ButtonState::try_from(payload[6]).ok()?,
+            proximity: ActivityState::from(payload[3]),
+            touch: ActivityState::from(payload[4]),
+            gesture: CrownGesture::from(payload[5]),
+            button: ButtonState::from(payload[6]),
             speed: i16::from_be_bytes([payload[14], payload[15]]),
         })),
         _ => None,
diff --git a/crates/openlogi-hidpp/src/feature/crown/tests.rs b/crates/openlogi-hidpp/src/feature/crown/tests.rs
index 78b4e9eaf4ca695f38026ebd243fd37bc6ced2c2..bdb5559fbeaac881066d7e9914353fa3d4662dc0 100644
--- a/crates/openlogi-hidpp/src/feature/crown/tests.rs
+++ b/crates/openlogi-hidpp/src/feature/crown/tests.rs
@@ -64,10 +64,32 @@ fn ignores_unknown_event_sub_id() {
 }
 
 #[test]
-fn ignores_event_with_unknown_enum() {
+fn keeps_event_with_unknown_enum_field() {
     let mut payload = [0; 16];
+    payload[1] = 0xfb; // -5 slots — a valid sibling field that must survive
     payload[6] = 0x09; // out-of-range button state
-    assert!(decode_event(0, &payload).is_none());
+    let CrownEvent::Update(update) = decode_event(0, &payload).expect("event kept");
+    assert_eq!(update.button, ButtonState::Other(0x09));
+    assert_eq!(update.relative_slot_rotation, -5);
+}
+
+/// Totality: for a known sub-id, no single field byte value may drop the whole
+/// event. Sweeps every value of each enum-typed field position.
+#[test]
+fn known_sub_id_survives_any_field_byte() {
+    for byte in 0..=u8::MAX {
+        for pos in [0usize, 3, 4, 5, 6] {
+            let mut payload = [0; 16];
+            payload[1] = 0xfb; // sibling that must always survive
+            payload[pos] = byte;
+            let CrownEvent::Update(update) = decode_event(0, &payload)
+                .unwrap_or_else(|| panic!("dropped event for payload[{pos}]={byte:#04x}"));
+            assert_eq!(
+                update.relative_slot_rotation, -5,
+                "sibling lost for payload[{pos}]={byte:#04x}"
+            );
+        }
+    }
 }
 
 #[test]
diff --git a/crates/openlogi-hidpp/src/feature/extended_dpi/event.rs b/crates/openlogi-hidpp/src/feature/extended_dpi/event.rs
index 78adf8347bdf9338a3e0a6e5eff09f850b3def64..04719f7c517c1a47742e60bde8a893a76c98c0e2 100644
--- a/crates/openlogi-hidpp/src/feature/extended_dpi/event.rs
+++ b/crates/openlogi-hidpp/src/feature/extended_dpi/event.rs
@@ -25,8 +25,9 @@ pub struct DpiParametersChanged {
     pub dpi_x: u16,
     /// New Y-axis DPI, or `0` when the sensor has no independent Y axis.
     pub dpi_y: u16,
-    /// New lift-off distance.
-    pub lod: Lod,
+    /// New lift-off distance, or `None` when the device reported a value this
+    /// crate does not model (the rest of the event is still delivered).
+    pub lod: Option<Lod>,
 }
 
 /// Payload of [`ExtendedDpiEvent::CalibrationCompleted`].
@@ -36,8 +37,9 @@ pub struct DpiParametersChanged {
 pub struct DpiCalibrationCompleted {
     /// Index of the sensor.
     pub sensor_index: u8,
-    /// Axis that was calibrated.
-    pub direction: DpiDirection,
+    /// Axis that was calibrated, or `None` when the device reported a value
+    /// this crate does not model (the rest of the event is still delivered).
+    pub direction: Option<DpiDirection>,
     /// Calibration correction value; [`i16::MIN`] (`0x8000`) signals a
     /// sensor-level calibration failure (see [`Self::failed`]).
     pub correction: i16,
@@ -65,12 +67,12 @@ pub(super) fn decode_event(sub_id: u8, payload: &[u8; 16]) -> Option<ExtendedDpi
             sensor_index: payload[0],
             dpi_x: u16::from_be_bytes([payload[1], payload[2]]),
             dpi_y: u16::from_be_bytes([payload[3], payload[4]]),
-            lod: Lod::try_from(payload[5]).ok()?,
+            lod: Lod::try_from(payload[5]).ok(),
         })),
         1 => Some(ExtendedDpiEvent::CalibrationCompleted(
             DpiCalibrationCompleted {
                 sensor_index: payload[0],
-                direction: DpiDirection::try_from(payload[1]).ok()?,
+                direction: DpiDirection::try_from(payload[1]).ok(),
                 correction: i16::from_be_bytes([payload[2], payload[3]]),
                 delta: i16::from_be_bytes([payload[4], payload[5]]),
             },
diff --git a/crates/openlogi-hidpp/src/feature/extended_dpi/tests.rs b/crates/openlogi-hidpp/src/feature/extended_dpi/tests.rs
index 8966f7b3d916d53a4de882b94c789b9bb097cd79..9bce55d82276c1019a34c6cdb6158318769eca57 100644
--- a/crates/openlogi-hidpp/src/feature/extended_dpi/tests.rs
+++ b/crates/openlogi-hidpp/src/feature/extended_dpi/tests.rs
@@ -229,7 +229,7 @@ fn decodes_parameters_changed_event() {
     assert_eq!(event.sensor_index, 1);
     assert_eq!(event.dpi_x, 800);
     assert_eq!(event.dpi_y, 1600);
-    assert_eq!(event.lod, Lod::Medium);
+    assert_eq!(event.lod, Some(Lod::Medium));
 }
 
 #[test]
@@ -242,7 +242,7 @@ fn decodes_calibration_completed_event() {
     let ExtendedDpiEvent::CalibrationCompleted(event) = decode_event(1, &payload).unwrap() else {
         panic!("expected a calibration-completed event");
     };
-    assert_eq!(event.direction, DpiDirection::Y);
+    assert_eq!(event.direction, Some(DpiDirection::Y));
     assert_eq!(event.correction, 100);
     assert_eq!(event.delta, -1);
     assert!(!event.failed());
@@ -265,11 +265,37 @@ fn ignores_unknown_event_sub_id() {
 }
 
 #[test]
-fn ignores_event_with_unknown_lod() {
+fn keeps_event_with_unknown_lod() {
     let mut payload = [0; 16];
+    payload[0] = 3; // sensor index — a valid sibling that must survive
     payload[5] = 9;
 
-    assert!(decode_event(0, &payload).is_none());
+    let ExtendedDpiEvent::ParametersChanged(changed) =
+        decode_event(0, &payload).expect("event kept")
+    else {
+        panic!("expected ParametersChanged");
+    };
+    // Lod stays a closed, write-safe enum; an unknown lift-off value surfaces
+    // as None on the event without dropping the DPI change.
+    assert_eq!(changed.lod, None);
+    assert_eq!(changed.sensor_index, 3);
+}
+
+/// Totality: a known event sub-id must decode for any enum-field byte value.
+#[test]
+fn known_sub_id_survives_any_field_byte() {
+    for byte in 0..=u8::MAX {
+        // sub 0: Lod at payload[5]; sub 1: DpiDirection at payload[1].
+        for (sub_id, pos) in [(0u8, 5usize), (1, 1)] {
+            let mut payload = [0; 16];
+            payload[0] = 3; // sensor index sibling
+            payload[pos] = byte;
+            assert!(
+                decode_event(sub_id, &payload).is_some(),
+                "dropped sub {sub_id} for payload[{pos}]={byte:#04x}"
+            );
+        }
+    }
 }
 
 #[test]
diff --git a/crates/openlogi-hidpp/src/feature/illumination/event.rs b/crates/openlogi-hidpp/src/feature/illumination/event.rs
index 39fd0dbf6a19c78c93823b065cb62b35562c0e06..3f5aa332fa72ce01fb7e750cd875f458f4ad40f4 100644
--- a/crates/openlogi-hidpp/src/feature/illumination/event.rs
+++ b/crates/openlogi-hidpp/src/feature/illumination/event.rs
@@ -39,7 +39,7 @@ pub(super) fn decode_event(sub_id: u8, payload: &[u8; 16]) -> Option<Illuminatio
             payload, 0,
         ))),
         4 => Some(IlluminationEvent::BrightnessClamped {
-            source: BrightnessClampedSource::try_from(payload[0]).ok()?,
+            source: BrightnessClampedSource::from(payload[0]),
             brightness: be16(payload, 1),
         }),
         _ => None,
diff --git a/crates/openlogi-hidpp/src/feature/illumination/tests.rs b/crates/openlogi-hidpp/src/feature/illumination/tests.rs
index 9ec7de849038131feb36c010734127a5c56fc235..5f4a1779a4e181746ce2096725e45e1f759c0892 100644
--- a/crates/openlogi-hidpp/src/feature/illumination/tests.rs
+++ b/crates/openlogi-hidpp/src/feature/illumination/tests.rs
@@ -221,3 +221,23 @@ fn decodes_brightness_clamped_event() {
 fn ignores_unknown_event_sub_id() {
     assert!(decode_event(9, &[0; 16]).is_none());
 }
+
+/// Totality: the clamp-source event must decode for any source byte; an
+/// unknown source folds to `Other(_)` and the brightness sibling survives.
+#[test]
+fn keeps_clamp_event_with_unknown_source() {
+    for byte in 0..=u8::MAX {
+        let mut payload = [0; 16];
+        payload[0] = byte; // BrightnessClampedSource
+        payload[1..3].copy_from_slice(&300u16.to_be_bytes()); // brightness sibling
+        let event = decode_event(4, &payload)
+            .unwrap_or_else(|| panic!("dropped clamp event for source {byte:#04x}"));
+        assert_eq!(
+            event,
+            IlluminationEvent::BrightnessClamped {
+                source: BrightnessClampedSource::from(byte),
+                brightness: 300,
+            }
+        );
+    }
+}
diff --git a/crates/openlogi-hidpp/src/feature/illumination/types.rs b/crates/openlogi-hidpp/src/feature/illumination/types.rs
index 5e53c7dc209344558c0e3e717ca808844a6ed689..a2333543235353d62fad66c22f11164e138d519e 100644
--- a/crates/openlogi-hidpp/src/feature/illumination/types.rs
+++ b/crates/openlogi-hidpp/src/feature/illumination/types.rs
@@ -1,6 +1,6 @@
 //! Domain types for the `Illumination` feature (`0x1990`).
 
-use num_enum::{IntoPrimitive, TryFromPrimitive};
+use num_enum::{FromPrimitive, IntoPrimitive, TryFromPrimitive};
 
 use crate::protocol::v20::{ErrorType, Hidpp20Error};
 
@@ -189,7 +189,7 @@ impl From<bool> for IlluminationState {
 }
 
 /// What caused a [`brightness clamp`](super::event::IlluminationEvent::BrightnessClamped).
-#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, IntoPrimitive, TryFromPrimitive)]
+#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, IntoPrimitive, FromPrimitive)]
 #[cfg_attr(feature = "serde", derive(serde::Serialize))]
 #[non_exhaustive]
 #[repr(u8)]
@@ -200,6 +200,9 @@ pub enum BrightnessClampedSource {
     HidPlusPlus = 1,
     /// A hardware button triggered the clamp.
     Button = 2,
+    /// A source this crate does not model; carries the raw byte.
+    #[num_enum(catch_all)]
+    Other(u8),
 }
 
 /// Decodes the on/off state bit shared by `getIllumination` and its event.
diff --git a/crates/openlogi-hidpp/src/feature/mod.rs b/crates/openlogi-hidpp/src/feature/mod.rs
index 07c85b572a77a31273be4647cd1203899175935f..1d3f43d1321156d5b3265b712f8fd3652b568fbf 100644
--- a/crates/openlogi-hidpp/src/feature/mod.rs
+++ b/crates/openlogi-hidpp/src/feature/mod.rs
@@ -10,6 +10,7 @@ use crate::{
 
 pub mod adjustable_dpi;
 pub mod backlight;
+pub mod battery_status;
 pub mod brightness_control;
 pub mod change_host;
 pub mod color_led_effects;
diff --git a/crates/openlogi-hidpp/src/feature/registry.rs b/crates/openlogi-hidpp/src/feature/registry.rs
index 0efa14af2a9b3ae29db563e04bba727dfaa4d6be..efa7ed1bf5faaab568616228ac8753eeace7faaa 100644
--- a/crates/openlogi-hidpp/src/feature/registry.rs
+++ b/crates/openlogi-hidpp/src/feature/registry.rs
@@ -14,6 +14,7 @@ use crate::{
         CreatableFeature,
         adjustable_dpi::AdjustableDpiFeature,
         backlight::BacklightFeature,
+        battery_status::BatteryStatusFeature,
         brightness_control::BrightnessControlFeature,
         change_host::ChangeHostFeature,
         color_led_effects::ColorLedEffectsFeature,
@@ -154,7 +155,7 @@ static KNOWN_FEATURES: LazyLock<HashMap<u16, KnownFeature>> = LazyLock::new(|| {
     0x00c3 "DfuControlBolt",
     0x00d0 "Dfu",
     0x00d1 "DfuResumable",
-    0x1000 "BatteryStatus",
+    0x1000 "BatteryStatus" => BatteryStatusFeature,
     0x1001 "BatteryVoltage",
     0x1004 "UnifiedBattery" => UnifiedBatteryFeature,
     0x1010 "ChargingControl",
diff --git a/crates/openlogi-hidpp/src/feature/rgb_effects/event.rs b/crates/openlogi-hidpp/src/feature/rgb_effects/event.rs
index 184cc882b5e890a8476a922039ab1acd16bf3382..24b0cd4859914860bbedaff5560b7bdd3dd282f5 100644
--- a/crates/openlogi-hidpp/src/feature/rgb_effects/event.rs
+++ b/crates/openlogi-hidpp/src/feature/rgb_effects/event.rs
@@ -33,8 +33,9 @@ pub enum RgbEffectsEvent {
         params: [u8; CLUSTER_EFFECT_PARAM_COUNT],
         /// Persistence the effect was applied with.
         persistence: RgbPersistence,
-        /// Power-mode target the effect applies to.
-        power_mode: PowerModeTarget,
+        /// Power-mode target the effect applies to, or `None` when the device
+        /// reported a value this crate does not model.
+        power_mode: Option<PowerModeTarget>,
     },
 }
 
@@ -45,9 +46,9 @@ pub(super) fn decode_event(sub_id: u8, payload: &[u8; 16]) -> Option<RgbEffectsE
             cluster_index: payload[0],
             effect_counter: be16(payload, 1),
         }),
-        1 => Some(RgbEffectsEvent::UserActivity(
-            ActivityEventType::try_from(payload[0]).ok()?,
-        )),
+        1 => Some(RgbEffectsEvent::UserActivity(ActivityEventType::from(
+            payload[0],
+        ))),
         2 => {
             let mut params = [0; CLUSTER_EFFECT_PARAM_COUNT];
             params.copy_from_slice(&payload[2..2 + CLUSTER_EFFECT_PARAM_COUNT]);
@@ -62,7 +63,7 @@ pub(super) fn decode_event(sub_id: u8, payload: &[u8; 16]) -> Option<RgbEffectsE
                 power_mode: PowerModeTarget::try_from(
                     (flags >> POWER_TARGET_SHIFT) & FLAGS_FIELD_MASK,
                 )
-                .ok()?,
+                .ok(),
             })
         }
         _ => None,
diff --git a/crates/openlogi-hidpp/src/feature/rgb_effects/tests.rs b/crates/openlogi-hidpp/src/feature/rgb_effects/tests.rs
index 1f12548401393c7802438cb3641521b6ffc023a3..3f4b4ebf95012b19c2a93e19a6d79e730e987f80 100644
--- a/crates/openlogi-hidpp/src/feature/rgb_effects/tests.rs
+++ b/crates/openlogi-hidpp/src/feature/rgb_effects/tests.rs
@@ -130,7 +130,7 @@ fn decodes_cluster_changed_event() {
             cluster_effect_index: 2,
             params: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
             persistence: RgbPersistence::VOLATILE,
-            power_mode: PowerModeTarget::PowerSave,
+            power_mode: Some(PowerModeTarget::PowerSave),
         })
     );
 }
@@ -156,3 +156,35 @@ fn maps_stable_enum_wire_values() {
     );
     assert!(SlotInfoType::try_from(7u8).is_err());
 }
+
+/// Totality: the user-activity event must decode for any activity byte.
+#[test]
+fn keeps_user_activity_event_with_unknown_type() {
+    for byte in 0..=u8::MAX {
+        let mut payload = [0; 16];
+        payload[0] = byte;
+        assert_eq!(
+            decode_event(1, &payload),
+            Some(RgbEffectsEvent::UserActivity(ActivityEventType::from(byte))),
+            "dropped user-activity event for byte {byte:#04x}"
+        );
+    }
+}
+
+/// Totality: the cluster-changed event must decode for any flags byte. The
+/// 2-bit power-mode nibble can hold values 2 and 3 that the enum does not
+/// model; those must surface as `None` without dropping the event.
+#[test]
+fn keeps_cluster_changed_event_with_unknown_power_mode() {
+    for flags in 0..=u8::MAX {
+        let mut payload = [0; 16];
+        payload[0] = 1; // cluster_index sibling that must survive
+        payload[12] = flags;
+        let event = decode_event(2, &payload)
+            .unwrap_or_else(|| panic!("dropped cluster-changed event for flags {flags:#04x}"));
+        let RgbEffectsEvent::ClusterChanged { cluster_index, .. } = event else {
+            panic!("expected ClusterChanged");
+        };
+        assert_eq!(cluster_index, 1);
+    }
+}
diff --git a/crates/openlogi-hidpp/src/feature/rgb_effects/types.rs b/crates/openlogi-hidpp/src/feature/rgb_effects/types.rs
index e715558af52d06f22fb84db04cf1d1b7fd62b512..8460d4f1c0504f1d696bfcf5d91516f7c1dd4893 100644
--- a/crates/openlogi-hidpp/src/feature/rgb_effects/types.rs
+++ b/crates/openlogi-hidpp/src/feature/rgb_effects/types.rs
@@ -1,6 +1,6 @@
 //! Domain types for the `RgbEffects` feature (`0x8071`).
 
-use num_enum::{IntoPrimitive, TryFromPrimitive};
+use num_enum::{FromPrimitive, IntoPrimitive, TryFromPrimitive};
 
 /// Number of effect parameters carried by `setRgbClusterEffect`.
 pub const CLUSTER_EFFECT_PARAM_COUNT: usize = 10;
@@ -96,7 +96,7 @@ pub enum LedBinIndex {
 }
 
 /// The kind of user-activity event.
-#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, IntoPrimitive, TryFromPrimitive)]
+#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, IntoPrimitive, FromPrimitive)]
 #[cfg_attr(feature = "serde", derive(serde::Serialize))]
 #[non_exhaustive]
 #[repr(u8)]
@@ -105,6 +105,9 @@ pub enum ActivityEventType {
     NoActivityTimeoutReached = 0,
     /// User activity was detected.
     UserActivityDetected = 1,
+    /// A type this crate does not model; carries the raw byte.
+    #[num_enum(catch_all)]
+    Other(u8),
 }
 
 bitflags::bitflags! {
diff --git a/crates/openlogi-hidpp/src/receiver/unifying.rs b/crates/openlogi-hidpp/src/receiver/unifying.rs
index 6a7eca7d5940ee8fd3c260ef4cfed83e30dff241..c0a1487244fad545dd7d2b92a49cb0bab93339cb 100644
--- a/crates/openlogi-hidpp/src/receiver/unifying.rs
+++ b/crates/openlogi-hidpp/src/receiver/unifying.rs
@@ -21,7 +21,11 @@ use crate::{
 
 /// All USB vendor & product ID pairs that are known to identify Unifying
 /// receivers.
-pub const VPID_PAIRS: &[(u16, u16)] = &[(0x046d, 0xc52b), (0x046d, 0xc532)];
+///
+/// `046d:c539` is the Lightspeed gaming receiver, which answers the same
+/// HID++ 1.0 registers (pairing count, connection state, pairing information)
+/// as Unifying receivers.
+pub const VPID_PAIRS: &[(u16, u16)] = &[(0x046d, 0xc52b), (0x046d, 0xc532), (0x046d, 0xc539)];
 
 /// All known registers of the Unifying receiver.
 #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, IntoPrimitive, TryFromPrimitive)]
diff --git a/crates/openlogi-hook/Cargo.toml b/crates/openlogi-hook/Cargo.toml
index de2e54f50327afd1f3093743db35ad45ddb1b46a..67093ee733c7c356932ddb2ea027f6e43910ee8b 100644
--- a/crates/openlogi-hook/Cargo.toml
+++ b/crates/openlogi-hook/Cargo.toml
@@ -9,15 +9,18 @@ authors.workspace = true
 description = "OS-level mouse-event hook for OpenLogi. macOS via CGEventTap; Linux via evdev+uinput; Windows via WH_MOUSE_LL."
 
 [dependencies]
-openlogi-core = { path = "../openlogi-core", version = "0.6.23" }
-openlogi-inject = { path = "../openlogi-inject", version = "0.6.23" }
+openlogi-core = { path = "../openlogi-core", version = "0.6.24" }
+openlogi-inject = { path = "../openlogi-inject", version = "0.6.24" }
 thiserror = { workspace = true }
 tracing = { workspace = true }
 
 [target.'cfg(target_os = "linux")'.dependencies]
 evdev = { workspace = true }
 libc = "0.2"
+wayland-client = "0.31"
+wayland-protocols-wlr = { version = "0.3", features = ["client"] }
 x11rb = "0.13"
+zbus = "5"
 
 [target.'cfg(target_os = "linux")'.dev-dependencies]
 ctrlc = "3"
diff --git a/crates/openlogi-hook/gnome-shell-extension/README.md b/crates/openlogi-hook/gnome-shell-extension/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..e58cd26a0390e619b7537b3876867b44a6356a4d
--- /dev/null
+++ b/crates/openlogi-hook/gnome-shell-extension/README.md
@@ -0,0 +1,59 @@
+# OpenLogi Frontmost Window — GNOME Shell extension
+
+GNOME (Mutter) does not let ordinary clients see which window is focused on
+Wayland, and it implements neither `wlr-foreign-toplevel` nor a focused-window
+portal. This minimal extension bridges that gap: it exports the WM_CLASS of the
+focused window over D-Bus so OpenLogi's `gnome-shell` frontmost backend can
+drive per-app mouse-profile switching.
+
+It reads only `global.display.focus_window.get_wm_class()`. No titles, no window
+contents, no input, no UI.
+
+## D-Bus surface
+
+- name: `org.openlogi.Frontmost`
+- path: `/org/openlogi/Frontmost`
+- method: `GetFocusedWmClass() -> s` (empty string when nothing is focused)
+
+## Install
+
+```sh
+UUID=openlogi-frontmost@openlogi.dev
+DEST="$HOME/.local/share/gnome-shell/extensions/$UUID"
+mkdir -p "$DEST"
+cp metadata.json extension.js "$DEST"/
+```
+
+On Wayland the shell cannot be reloaded in place, so **log out and back in** to
+let GNOME pick up the newly added extension, then enable it:
+
+```sh
+gnome-extensions enable "$UUID"
+gnome-extensions info "$UUID"   # State should be ACTIVE
+```
+
+## Verify
+
+```sh
+# Introspect the service:
+busctl --user introspect org.openlogi.Frontmost /org/openlogi/Frontmost
+
+# Focus a window, then query it:
+gdbus call --session \
+  -d org.openlogi.Frontmost \
+  -o /org/openlogi/Frontmost \
+  -m org.openlogi.Frontmost.GetFocusedWmClass
+```
+
+If `gdbus call` prints the focused window's WM_CLASS, OpenLogi's GNOME backend
+will pick it up automatically the next time the hook starts.
+
+## Notes
+
+- The `shell-version` list in `metadata.json` covers GNOME 45–50. Newer GNOME
+  releases may need an added entry; the API used here (`Gio.DBusExportedObject`,
+  `global.display.focus_window`, `Meta.Window.get_wm_class`) has been stable
+  across these versions.
+- The extension name/UUID and the D-Bus name (`org.openlogi.*`) are placeholders
+  that should track the project's namespace; if they change, update the matching
+  constants in `crates/openlogi-hook/src/linux/gnome_shell.rs`.
diff --git a/crates/openlogi-hook/gnome-shell-extension/openlogi-frontmost@openlogi.dev/extension.js b/crates/openlogi-hook/gnome-shell-extension/openlogi-frontmost@openlogi.dev/extension.js
new file mode 100644
index 0000000000000000000000000000000000000000..a0f9e4a89b0942e8e342537184d0a7cdca1d8cda
--- /dev/null
+++ b/crates/openlogi-hook/gnome-shell-extension/openlogi-frontmost@openlogi.dev/extension.js
@@ -0,0 +1,55 @@
+// OpenLogi Frontmost Window — GNOME Shell extension.
+//
+// Exports a tiny D-Bus service that returns the WM_CLASS of the currently
+// focused window. OpenLogi's `gnome_shell` frontmost backend polls this to
+// drive per-app mouse-profile switching on GNOME Wayland, where the focused
+// window is otherwise not visible to ordinary clients.
+//
+// It reads only `global.display.focus_window.get_wm_class()` — no titles, no
+// window contents, no input. ESM module style; targets GNOME Shell 45+.
+
+import Gio from 'gi://Gio';
+import {Extension} from 'resource:///org/gnome/shell/extensions/extension.js';
+
+const DBUS_NAME = 'org.openlogi.Frontmost';
+const DBUS_PATH = '/org/openlogi/Frontmost';
+const DBUS_INTERFACE = `
+<node>
+  <interface name="org.openlogi.Frontmost">
+    <method name="GetFocusedWmClass">
+      <arg type="s" direction="out" name="wmClass"/>
+    </method>
+  </interface>
+</node>`;
+
+export default class OpenLogiFrontmostExtension extends Extension {
+    enable() {
+        this._dbus = Gio.DBusExportedObject.wrapJSObject(DBUS_INTERFACE, this);
+        this._dbus.export(Gio.DBus.session, DBUS_PATH);
+        this._nameId = Gio.bus_own_name_on_connection(
+            Gio.DBus.session,
+            DBUS_NAME,
+            Gio.BusNameOwnerFlags.NONE,
+            null,
+            null);
+    }
+
+    disable() {
+        if (this._nameId) {
+            Gio.bus_unown_name(this._nameId);
+            this._nameId = 0;
+        }
+        if (this._dbus) {
+            this._dbus.unexport();
+            this._dbus = null;
+        }
+    }
+
+    // D-Bus method org.openlogi.Frontmost.GetFocusedWmClass.
+    GetFocusedWmClass() {
+        const win = global.display.focus_window;
+        if (!win)
+            return '';
+        return win.get_wm_class() || '';
+    }
+}
diff --git a/crates/openlogi-hook/gnome-shell-extension/openlogi-frontmost@openlogi.dev/metadata.json b/crates/openlogi-hook/gnome-shell-extension/openlogi-frontmost@openlogi.dev/metadata.json
new file mode 100644
index 0000000000000000000000000000000000000000..068f8493c573043914d3063b5e587035abb630b2
--- /dev/null
+++ b/crates/openlogi-hook/gnome-shell-extension/openlogi-frontmost@openlogi.dev/metadata.json
@@ -0,0 +1,8 @@
+{
+  "uuid": "openlogi-frontmost@openlogi.dev",
+  "name": "OpenLogi Frontmost Window",
+  "description": "Exposes the focused window's WM_CLASS over D-Bus so OpenLogi can switch per-app mouse profiles on GNOME Wayland. Read-only; no UI, no window contents.",
+  "shell-version": ["45", "46", "47", "48", "49", "50"],
+  "url": "https://github.com/AprilNEA/OpenLogi",
+  "version": 1
+}
diff --git a/crates/openlogi-hook/src/lib.rs b/crates/openlogi-hook/src/lib.rs
index 44185a670c9526f84b7dbc78d4c46ccc15d481d3..65d4d4d1b668f1f04a75a9af816f195f85d9c883 100644
--- a/crates/openlogi-hook/src/lib.rs
+++ b/crates/openlogi-hook/src/lib.rs
@@ -29,6 +29,9 @@ use std::cfg_select;
 
 pub use openlogi_core::binding::ButtonId;
 
+/// Logitech's USB/Bluetooth vendor id (`0x046D`).
+pub const LOGITECH_VENDOR_ID: u32 = 0x046d;
+
 /// Best-effort identity for the physical device that produced an OS event.
 ///
 /// Platform hooks fill the stable fields they can read cheaply from the native
@@ -44,6 +47,82 @@ pub struct EventDevice {
     pub product_name: Option<String>,
 }
 
+impl EventDevice {
+    /// Whether this looks like a trackpad/touchpad (must never be remapped).
+    #[must_use]
+    pub fn is_trackpad_like(&self) -> bool {
+        self.product_name.as_deref().is_some_and(|n| {
+            let n = n.to_ascii_lowercase();
+            n.contains("trackpad") || n.contains("touchpad") || n.contains("touch pad")
+        })
+    }
+
+    /// Whether this is a Logitech product OpenLogi may remap buttons for.
+    #[must_use]
+    pub fn is_logitech(&self) -> bool {
+        if self.vendor_id == Some(LOGITECH_VENDOR_ID) {
+            return true;
+        }
+        self.product_name.as_deref().is_some_and(|n| {
+            let n = n.to_ascii_lowercase();
+            n.contains("logitech") || n.starts_with("logi ")
+        })
+    }
+}
+
+/// Whether the OS hook may suppress/remap a button event from this source.
+///
+/// Fail-closed on macOS-style attribution: only a known Logitech non-trackpad
+/// source is remappable. Unknown / non-Logitech / trackpad sources always pass
+/// through so a wedged remap policy can never brick the system pointer.
+#[must_use]
+pub fn source_is_remappable(device: Option<&EventDevice>) -> bool {
+    match device {
+        Some(d) if d.is_trackpad_like() => false,
+        Some(d) => d.is_logitech(),
+        None => false,
+    }
+}
+
+/// Which modifier keys were held when a key event fired. Mirrors the
+/// detectable macOS modifier flags. Note `Fn` is deliberately absent — it is
+/// firmware-internal and never reported on non-function-row keys (see the
+/// function-key-remapper spec, Appendix A).
+#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
+#[expect(
+    clippy::struct_excessive_bools,
+    reason = "four independent modifier flags from OS event bits"
+)]
+pub struct KeyModifiers {
+    pub shift: bool,
+    pub control: bool,
+    pub option: bool,
+    pub command: bool,
+}
+
+/// A keyboard event observed by the hook.
+#[derive(Clone, Copy, Debug, PartialEq, Eq)]
+pub struct KeyEvent {
+    /// Platform virtual keycode (macOS: `kVK_*`, e.g. 122 = F1, 53 = Escape).
+    pub keycode: u16,
+    /// `true` = key down; `false` = key up.
+    pub pressed: bool,
+    /// Which modifiers were held.
+    pub modifiers: KeyModifiers,
+}
+
+/// Anything the OS hook can observe. `Mouse` preserves the existing callback
+/// payload; `Key` is the keyboard path added by the function-key remapper.
+/// Wrapping both in a union means `Hook::start`'s callback widens once and
+/// stays stable as further event classes arrive.
+#[derive(Clone, Debug)]
+pub enum HookEvent {
+    /// Mouse button / scroll / move event.
+    Mouse(MouseEvent),
+    /// Keyboard event (function-key remapper path).
+    Key(KeyEvent),
+}
+
 /// An event captured at the OS layer.
 #[derive(Clone, Debug)]
 pub enum MouseEvent {
@@ -53,6 +132,9 @@ pub enum MouseEvent {
         id: ButtonId,
         /// `true` = button down; `false` = button up.
         pressed: bool,
+        /// Best-effort physical source. `None` when the platform cannot
+        /// attribute the event (Windows today) or it was synthetic.
+        device: Option<EventDevice>,
     },
     /// A scroll-wheel tick (or continuous momentum scroll).
     Scroll {
@@ -261,7 +343,7 @@ impl Hook {
     /// [`HookError::NoDeviceFound`] when no mouse device is accessible. On
     /// Windows, installs a `WH_MOUSE_LL` low-level mouse hook.
     pub fn start(
-        cb: impl Fn(MouseEvent) -> EventDisposition + Send + Sync + 'static,
+        cb: impl Fn(HookEvent) -> EventDisposition + Send + Sync + 'static,
     ) -> Result<Self, HookError> {
         cfg_select! {
             target_os = "macos" => {
diff --git a/crates/openlogi-hook/src/linux.rs b/crates/openlogi-hook/src/linux.rs
index 959155a871a42ef284fd54f94eeaee20fec81c27..94bc35e2566e00f8b94278282884f482f37860d0 100644
--- a/crates/openlogi-hook/src/linux.rs
+++ b/crates/openlogi-hook/src/linux.rs
@@ -37,7 +37,7 @@ use x11rb::properties::WmClass;
 use x11rb::protocol::xproto::{Atom, AtomEnum, ConnectionExt as _, Window};
 use x11rb::rust_connection::RustConnection;
 
-use crate::{ButtonId, EventDisposition, HookError, MouseEvent};
+use crate::{ButtonId, EventDisposition, HookError, HookEvent, LOGITECH_VENDOR_ID, MouseEvent};
 
 /// Prefix carried by every uinput device OpenLogi creates — the hook's
 /// pass-through mice ([`VIRTUAL_DEVICE_NAME`]) and openlogi-inject's
@@ -61,7 +61,7 @@ pub(crate) struct HookInner {
 }
 
 pub(crate) fn start(
-    cb: impl Fn(MouseEvent) -> EventDisposition + Send + Sync + 'static,
+    cb: impl Fn(HookEvent) -> EventDisposition + Send + Sync + 'static,
 ) -> Result<HookInner, HookError> {
     let devices = find_mouse_devices();
     if devices.is_empty() {
@@ -69,7 +69,7 @@ pub(crate) fn start(
     }
 
     let stop = Arc::new(AtomicBool::new(false));
-    let cb: Arc<dyn Fn(MouseEvent) -> EventDisposition + Send + Sync> = Arc::new(cb);
+    let cb: Arc<dyn Fn(HookEvent) -> EventDisposition + Send + Sync> = Arc::new(cb);
     let mut threads: Vec<thread::JoinHandle<()>> = Vec::with_capacity(devices.len());
     let mut stop_pipes: Vec<OwnedFd> = Vec::with_capacity(devices.len());
 
@@ -151,19 +151,21 @@ fn create_pipe() -> io::Result<(OwnedFd, OwnedFd)> {
 fn find_mouse_devices() -> Vec<(std::path::PathBuf, Device)> {
     evdev::enumerate()
         .filter(|(path, d)| {
+            let vendor = u32::from(d.input_id().vendor());
             let hookable = is_hookable_mouse(
                 d.name(),
                 d.supported_keys(),
                 d.supported_relative_axes(),
                 d.supported_absolute_axes(),
                 d.properties(),
+                vendor,
             );
             if !hookable
                 && d.supported_keys()
                     .is_some_and(|keys| keys.contains(KeyCode::BTN_LEFT))
             {
                 debug!(
-                    "not hooking {} ({}): has mouse buttons but is not a plain relative-pointer mouse",
+                    "not hooking {} ({}): has mouse buttons but is not a managed Logitech relative-pointer mouse",
                     path.display(),
                     d.name().unwrap_or("unnamed"),
                 );
@@ -183,18 +185,27 @@ fn find_mouse_devices() -> Vec<(std::path::PathBuf, Device)> {
 /// are excluded too: libinput derives their on-button scrolling from the
 /// `POINTING_STICK` input property, which a re-injected uinput stream loses,
 /// and built-in sticks are never OpenLogi's target hardware.
+///
+/// Only Logitech devices are grabbed: OpenLogi remaps Logitech mice, and an
+/// exclusive grab on any other vendor's pointer (or a misclassified built-in
+/// trackpad) would leave that device dead for the life of the agent (#484).
 fn is_hookable_mouse(
     name: Option<&str>,
     keys: Option<&AttributeSetRef<KeyCode>>,
     rel_axes: Option<&AttributeSetRef<RelativeAxisCode>>,
     abs_axes: Option<&AttributeSetRef<AbsoluteAxisCode>>,
     props: &AttributeSetRef<PropType>,
+    vendor_id: u32,
 ) -> bool {
     // Never hook one of our own uinput devices (an unnamed device is fine —
     // ours are always named).
     if name.is_some_and(|n| n.starts_with(OPENLOGI_DEVICE_PREFIX)) {
         return false;
     }
+    // OpenLogi only remaps Logitech hardware — never grab foreign vendors.
+    if vendor_id != LOGITECH_VENDOR_ID {
+        return false;
+    }
     // A mouse clicks and moves relatively; nothing else qualifies. This alone
     // rejects pure-ABS touchpads, keyboards with stray button bits, and
     // wheel-only devices like the action injector.
@@ -298,9 +309,12 @@ fn translate(event: &evdev::InputEvent, hires_scroll: bool) -> Option<MouseEvent
     match event.destructure() {
         EventSummary::Key(_, key, value) => {
             let id = key_to_button(key)?;
+            // Device is already Logitech-only (see `is_hookable_mouse`); the
+            // agent runtime treats `device: None` as remappable on Linux.
             Some(MouseEvent::Button {
                 id,
                 pressed: value != 0,
+                device: None,
             })
         }
         EventSummary::RelativeAxis(_, axis, value) => match axis {
@@ -369,7 +383,7 @@ fn device_thread(
     path: std::path::PathBuf,
     mut device: Device,
     mut virtual_device: VirtualDevice,
-    cb: Arc<dyn Fn(MouseEvent) -> EventDisposition + Send + Sync>,
+    cb: Arc<dyn Fn(HookEvent) -> EventDisposition + Send + Sync>,
     stop: Arc<AtomicBool>,
     stop_rx: OwnedFd,
 ) {
@@ -433,7 +447,7 @@ fn device_thread(
                 }
             } else {
                 let disposition = match translate(&event, hires_scroll) {
-                    Some(me) => cb(me),
+                    Some(me) => cb(HookEvent::Mouse(me)),
                     // Low-res companions (REL_WHEEL/REL_HWHEEL) must be suppressed when hi-res
                     // is active — passing them through would double the scroll distance.
                     None if hires_scroll
@@ -464,70 +478,217 @@ fn device_thread(
 
 // ── frontmost_bundle_id ──────────────────────────────────────────────────────
 
-struct X11State {
+// The frontmost-app reader is backend-driven so that Wayland support can be
+// added without touching callers. Exactly one backend is selected at startup
+// from the session environment (see `detect_frontmost_source`) and cached in
+// `FRONTMOST_SOURCE` for the process lifetime. The X11, wlr-foreign-toplevel,
+// and gnome-shell backends are all available; see `wayland_candidates`.
+
+mod gnome_shell;
+mod wlr_foreign_toplevel;
+
+/// A backend that reports which application is currently frontmost.
+///
+/// Implementations are display-server / desktop specific. The string returned
+/// by `frontmost_bundle_id` is compared against per-app profile keys by exact
+/// match (`openlogi_core::Config::effective_bindings`), so its exact form
+/// matters and is backend-specific. The X11 and gnome-shell backends both
+/// return the `WM_CLASS` class component (e.g. "Firefox"); the wlr backend
+/// returns the xdg-shell `app_id` (e.g. "org.mozilla.firefox"). These two
+/// namespaces do not map onto each other by any simple string rule, so a
+/// per-app profile created under wlroots will not match under GNOME/X11 and
+/// vice versa. This is a known limitation: reconciling it needs a canonical-id
+/// scheme or per-profile aliases rather than naive normalization, and is
+/// deliberately out of scope for the backends themselves.
+trait FrontmostSource: Send + Sync {
+    /// Opaque identifier of the frontmost application, or `None` when there is
+    /// no frontmost window or it cannot be read.
+    fn frontmost_bundle_id(&self) -> Option<String>;
+
+    /// Short backend identifier, for diagnostics / logging only.
+    fn name(&self) -> &'static str;
+}
+
+/// Frontmost backend backed by X11 `_NET_ACTIVE_WINDOW` + `WM_CLASS`.
+///
+/// Works on an X11 session, and on a Wayland session for XWayland windows;
+/// native Wayland windows are invisible through this path and yield `None`.
+struct X11Source {
     conn: RustConnection,
     root: Window,
     net_active_window: Atom,
 }
 
-static X11_STATE: LazyLock<Option<X11State>> = LazyLock::new(|| {
-    let (conn, screen_num) = RustConnection::connect(None)
-        .map_err(|e| debug!("X11 not available, frontmost_bundle_id will return None: {e}"))
-        .ok()?;
-    let root = conn.setup().roots[screen_num].root;
-    let net_active_window = conn
-        .intern_atom(false, b"_NET_ACTIVE_WINDOW")
-        .ok()?
-        .reply()
-        .ok()?
-        .atom;
-    Some(X11State {
-        conn,
-        root,
-        net_active_window,
-    })
-});
+impl X11Source {
+    /// Connect to the X server and resolve the `_NET_ACTIVE_WINDOW` atom.
+    /// Returns `None` when no X display is reachable (a Wayland session without
+    /// XWayland, or `$DISPLAY` unset).
+    fn connect() -> Option<Self> {
+        let (conn, screen_num) = RustConnection::connect(None)
+            .map_err(|e| debug!("X11 not available, frontmost will return None: {e}"))
+            .ok()?;
+        let root = conn.setup().roots[screen_num].root;
+        let net_active_window = conn
+            .intern_atom(false, b"_NET_ACTIVE_WINDOW")
+            .ok()?
+            .reply()
+            .ok()?
+            .atom;
+        Some(Self {
+            conn,
+            root,
+            net_active_window,
+        })
+    }
+}
+
+impl FrontmostSource for X11Source {
+    fn frontmost_bundle_id(&self) -> Option<String> {
+        // _NET_ACTIVE_WINDOW on the root window holds the focused window's XID.
+        let window: Window = self
+            .conn
+            .get_property(
+                false,
+                self.root,
+                self.net_active_window,
+                AtomEnum::WINDOW,
+                0,
+                1,
+            )
+            .ok()?
+            .reply()
+            .ok()?
+            .value32()?
+            .next()?;
+        if window == 0 {
+            return None;
+        }
+
+        // WM_CLASS is instance_name\0class_name\0; the class component is more
+        // stable across window instances and is what profiles should key on
+        // (e.g. "Firefox", not "Navigator").
+        let wm = WmClass::get(&self.conn, window)
+            .ok()?
+            .reply_unchecked()
+            .ok()??;
+        std::str::from_utf8(wm.class())
+            .ok()
+            .filter(|s| !s.is_empty())
+            .map(str::to_owned)
+    }
+
+    fn name(&self) -> &'static str {
+        "x11"
+    }
+}
+
+/// Fallback used when no backend is available (e.g. a pure Wayland session
+/// before any Wayland backend lands). Always reports `None`, so per-app
+/// profile switching simply no-ops rather than erroring.
+struct NullSource;
+
+impl FrontmostSource for NullSource {
+    fn frontmost_bundle_id(&self) -> Option<String> {
+        None
+    }
+
+    fn name(&self) -> &'static str {
+        "null"
+    }
+}
+
+/// Coarse classification of the graphical session, used to order the frontmost
+/// backend candidates.
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+enum SessionKind {
+    X11,
+    Wayland,
+    Unknown,
+}
 
-/// Return the X11 `WM_CLASS` class component of the currently active window,
-/// e.g. `"Firefox"` or `"Code"`.
+/// Classify the session from the environment. `XDG_SESSION_TYPE` is
+/// authoritative when set to `x11` or `wayland`; otherwise fall back to the
+/// presence of `WAYLAND_DISPLAY` / `DISPLAY`.
+fn detect_session_kind() -> SessionKind {
+    if let Ok(kind) = std::env::var("XDG_SESSION_TYPE") {
+        match kind.as_str() {
+            "wayland" => return SessionKind::Wayland,
+            "x11" => return SessionKind::X11,
+            _ => {}
+        }
+    }
+    if std::env::var_os("WAYLAND_DISPLAY").is_some() {
+        SessionKind::Wayland
+    } else if std::env::var_os("DISPLAY").is_some() {
+        SessionKind::X11
+    } else {
+        SessionKind::Unknown
+    }
+}
+
+/// A backend constructor: returns the backend if it can initialize on this
+/// system, or `None` to fall through to the next candidate.
+type Candidate = fn() -> Option<Box<dyn FrontmostSource>>;
+
+fn x11_candidate() -> Option<Box<dyn FrontmostSource>> {
+    X11Source::connect().map(|s| Box::new(s) as Box<dyn FrontmostSource>)
+}
+
+/// Wayland-native frontmost backends, in priority order: the wlroots
+/// foreign-toplevel protocol (sway, Hyprland, river, …) and the GNOME Shell
+/// D-Bus extension (Mutter). AT-SPI remains a future fallback. Compositors that
+/// support none of these fall through to the X11/XWayland path (which resolves
+/// XWayland windows, `None` for native Wayland apps).
+fn wayland_candidates() -> Vec<Candidate> {
+    vec![wlr_foreign_toplevel::candidate, gnome_shell::candidate]
+}
+
+/// Pick the frontmost backend for this session, trying each candidate in order
+/// and keeping the first that initializes. Called once, lazily, per process.
+fn detect_frontmost_source() -> Box<dyn FrontmostSource> {
+    let session = detect_session_kind();
+    debug!("frontmost: session kind = {session:?}");
+
+    let mut candidates: Vec<Candidate> = match session {
+        SessionKind::Wayland => wayland_candidates(),
+        SessionKind::X11 | SessionKind::Unknown => Vec::new(),
+    };
+    // X11 / XWayland: the primary path on an X11 session and the universal
+    // fallback everywhere else.
+    candidates.push(x11_candidate);
+
+    for candidate in candidates {
+        if let Some(source) = candidate() {
+            debug!("frontmost: using '{}' backend", source.name());
+            // On Wayland, landing on the X11 backend means no native Wayland
+            // frontmost source was available, so native Wayland windows will
+            // report None (only XWayland windows resolve). Hint at the fix.
+            if session == SessionKind::Wayland && source.name() == "x11" {
+                debug!(
+                    "frontmost: on Wayland but using the X11/XWayland backend; \
+                     native Wayland windows will report None. Install the OpenLogi \
+                     GNOME Shell extension (GNOME) or use a wlroots compositor."
+                );
+            }
+            return source;
+        }
+    }
+
+    debug!("frontmost: no usable backend; frontmost_bundle_id will return None");
+    Box::new(NullSource)
+}
+
+static FRONTMOST_SOURCE: LazyLock<Box<dyn FrontmostSource>> =
+    LazyLock::new(detect_frontmost_source);
+
+/// Return an opaque identifier of the currently frontmost application, or
+/// `None` when unavailable. Dispatches to the backend chosen at startup.
 ///
-/// Returns `None` when there is no active window, when the X11 display is
-/// unavailable (Wayland-only session without XWayland), or on read error.
-/// Native Wayland windows are not visible through this path.
+/// On an X11 session this is the `WM_CLASS` class component (e.g. "Firefox").
+/// On a Wayland session the wlr-foreign-toplevel or gnome-shell backend is used
+/// when available; XWayland windows fall back to the X11 backend.
 pub(crate) fn frontmost_bundle_id() -> Option<String> {
-    let state = X11_STATE.as_ref()?;
-
-    // _NET_ACTIVE_WINDOW on the root window holds the focused window's XID.
-    let window: Window = state
-        .conn
-        .get_property(
-            false,
-            state.root,
-            state.net_active_window,
-            AtomEnum::WINDOW,
-            0,
-            1,
-        )
-        .ok()?
-        .reply()
-        .ok()?
-        .value32()?
-        .next()?;
-    if window == 0 {
-        return None;
-    }
-
-    // WM_CLASS is instance_name\0class_name\0; the class component is more
-    // stable across window instances and is what profiles should key on
-    // (e.g. "Firefox", not "Navigator").
-    let wm = WmClass::get(&state.conn, window)
-        .ok()?
-        .reply_unchecked()
-        .ok()??;
-    std::str::from_utf8(wm.class())
-        .ok()
-        .filter(|s| !s.is_empty())
-        .map(str::to_owned)
+    FRONTMOST_SOURCE.frontmost_bundle_id()
 }
 
 #[cfg(test)]
@@ -576,7 +737,8 @@ mod tests {
             translate(&event, false),
             Some(MouseEvent::Button {
                 id: ButtonId::LeftClick,
-                pressed: true
+                pressed: true,
+                device: None,
             })
         );
     }
@@ -588,7 +750,8 @@ mod tests {
             translate(&event, false),
             Some(MouseEvent::Button {
                 id: ButtonId::LeftClick,
-                pressed: false
+                pressed: false,
+                device: None,
             })
         );
     }
@@ -600,7 +763,8 @@ mod tests {
             translate(&event, false),
             Some(MouseEvent::Button {
                 id: ButtonId::Back,
-                pressed: true
+                pressed: true,
+                device: None,
             })
         );
     }
@@ -612,7 +776,8 @@ mod tests {
             translate(&event, false),
             Some(MouseEvent::Button {
                 id: ButtonId::Back,
-                pressed: true
+                pressed: true,
+                device: None,
             })
         );
     }
@@ -624,7 +789,8 @@ mod tests {
             translate(&event, false),
             Some(MouseEvent::Button {
                 id: ButtonId::Forward,
-                pressed: true
+                pressed: true,
+                device: None,
             })
         );
     }
@@ -748,6 +914,7 @@ mod tests {
         rel: Option<AttributeSet<RelativeAxisCode>>,
         abs: Option<AttributeSet<AbsoluteAxisCode>>,
         props: AttributeSet<PropType>,
+        vendor_id: u32,
     }
 
     impl Caps {
@@ -770,6 +937,7 @@ mod tests {
                 ),
                 abs: None,
                 props: AttributeSet::new(),
+                vendor_id: LOGITECH_VENDOR_ID,
             }
         }
 
@@ -780,6 +948,7 @@ mod tests {
                 self.rel.as_deref(),
                 self.abs.as_deref(),
                 &self.props,
+                self.vendor_id,
             )
         }
     }
@@ -799,6 +968,20 @@ mod tests {
         );
     }
 
+    #[test]
+    fn non_logitech_mouse_is_not_hookable() {
+        let mut caps = Caps::mouse();
+        caps.name = Some("Apple SPI Trackpad");
+        caps.vendor_id = 0x05ac;
+        assert!(
+            !caps.is_hookable(),
+            "foreign vendors must never be exclusively grabbed"
+        );
+        caps.name = Some("Generic USB Mouse");
+        caps.vendor_id = 0x1234;
+        assert!(!caps.is_hookable());
+    }
+
     #[test]
     fn touchpad_is_not_hookable() {
         // A libinput touchpad: clicks via BTN_LEFT but moves via multitouch
diff --git a/crates/openlogi-hook/src/linux/gnome_shell.rs b/crates/openlogi-hook/src/linux/gnome_shell.rs
new file mode 100644
index 0000000000000000000000000000000000000000..8e14c4349caa25ffacdb236fea166a27717116e4
--- /dev/null
+++ b/crates/openlogi-hook/src/linux/gnome_shell.rs
@@ -0,0 +1,97 @@
+//! Frontmost backend for GNOME Shell (Wayland and X11), via a small companion
+//! GNOME Shell extension that exports the focused window's WM_CLASS over D-Bus.
+//!
+//! GNOME (Mutter) implements neither wlr-foreign-toplevel nor any portal for
+//! the focused window, and `org.gnome.Shell.Eval` is disabled by default, so a
+//! privileged GNOME Shell extension is the only way to read the focused window
+//! on a GNOME Wayland session. The extension lives in `gnome-shell-extension/`
+//! in this crate and must be installed and enabled for this backend to
+//! activate. When it is absent, [`GnomeShellSource::connect`] fails and backend
+//! selection falls through to the next candidate (XWayland via X11).
+//!
+//! The extension returns the WM_CLASS — not the `.desktop` id — so the
+//! identifier matches the X11 backend's, keeping per-app profile keys
+//! consistent across X11, XWayland, and GNOME Wayland sessions.
+//!
+//! Only the session-bus connection is held in the backend; a lightweight proxy
+//! is built per poll (no extra D-Bus traffic beyond the method call itself).
+
+use std::time::Duration;
+
+use tracing::debug;
+use zbus::blocking::Connection;
+use zbus::blocking::connection::Builder;
+use zbus::proxy;
+
+use super::FrontmostSource;
+
+/// Cap on every D-Bus call to the extension. Without it, a stalled GNOME Shell
+/// would block the polling thread forever (the probe runs inside the
+/// `FRONTMOST_SOURCE` initializer, so a stall there would block every thread
+/// that touches it).
+const METHOD_TIMEOUT: Duration = Duration::from_secs(5);
+
+/// D-Bus proxy for the OpenLogi GNOME Shell extension. Only the blocking proxy
+/// is generated (`gen_async = false`), matching the synchronous poll contract.
+#[proxy(
+    interface = "org.openlogi.Frontmost",
+    default_service = "org.openlogi.Frontmost",
+    default_path = "/org/openlogi/Frontmost",
+    gen_async = false
+)]
+trait Frontmost {
+    /// WM_CLASS of the focused window, or "" when nothing is focused.
+    #[zbus(name = "GetFocusedWmClass")]
+    fn get_focused_wm_class(&self) -> zbus::Result<String>;
+}
+
+/// Frontmost backend talking to the OpenLogi GNOME Shell extension over the
+/// session bus.
+struct GnomeShellSource {
+    conn: Connection,
+}
+
+impl GnomeShellSource {
+    fn connect() -> Option<Self> {
+        let conn = Builder::session()
+            .map_err(|e| debug!("gnome-shell: no session bus: {e}"))
+            .ok()?
+            .method_timeout(METHOD_TIMEOUT)
+            .build()
+            .map_err(|e| debug!("gnome-shell: connection build failed: {e}"))
+            .ok()?;
+        // Probe reachability: a successful call (even an empty result) means the
+        // OpenLogi extension is installed and exporting the service. An error
+        // means it is absent/disabled, so this backend must not be selected.
+        let proxy = FrontmostProxy::new(&conn)
+            .map_err(|e| debug!("gnome-shell: proxy build failed: {e}"))
+            .ok()?;
+        proxy
+            .get_focused_wm_class()
+            .map_err(|e| debug!("gnome-shell: OpenLogi extension not reachable: {e}"))
+            .ok()?;
+        Some(Self { conn })
+    }
+}
+
+impl FrontmostSource for GnomeShellSource {
+    fn frontmost_bundle_id(&self) -> Option<String> {
+        let proxy = FrontmostProxy::new(&self.conn)
+            .map_err(|e| debug!("gnome-shell: proxy build failed: {e}"))
+            .ok()?;
+        let wm_class = proxy
+            .get_focused_wm_class()
+            .map_err(|e| debug!("gnome-shell: poll failed (extension gone or bus down?): {e}"))
+            .ok()?;
+        (!wm_class.is_empty()).then_some(wm_class)
+    }
+
+    fn name(&self) -> &'static str {
+        "gnome-shell"
+    }
+}
+
+/// Candidate constructor registered in [`super::wayland_candidates`].
+pub(super) fn candidate() -> Option<Box<dyn FrontmostSource>> {
+    GnomeShellSource::connect().map(|s| Box::new(s) as Box<dyn FrontmostSource>)
+}
diff --git a/crates/openlogi-hook/src/linux/wlr_foreign_toplevel.rs b/crates/openlogi-hook/src/linux/wlr_foreign_toplevel.rs
new file mode 100644
index 0000000000000000000000000000000000000000..5ce58f5c352bc49d6a61b19f34785709faaa0cb3
--- /dev/null
+++ b/crates/openlogi-hook/src/linux/wlr_foreign_toplevel.rs
@@ -0,0 +1,489 @@
+//! Frontmost backend using the wlroots `zwlr_foreign_toplevel_management_v1`
+//! protocol.
+//!
+//! The manager hands out one handle per toplevel window; each handle reports
+//! its `app_id` and a `state` set. The frontmost window is the toplevel whose
+//! state set contains `activated`, and its `app_id` is what we return.
+//!
+//! Note on the returned identifier: this is the xdg-shell `app_id` (e.g.
+//! "org.mozilla.firefox", "Alacritty", "foot"), which is a *different namespace*
+//! from the `WM_CLASS` returned by the X11 and gnome-shell backends (e.g.
+//! "Firefox"). Because profile lookup is an exact match, a per-app profile
+//! created under wlroots will not match under GNOME/X11 and vice versa. We
+//! deliberately return the native `app_id` rather than a lossy WM_CLASS
+//! approximation (stripping reverse-DNS and capitalizing guesses wrong for many
+//! apps); reconciling the two namespaces belongs in a single normalization
+//! layer, not here. See the `FrontmostSource` trait doc in `linux.rs`.
+//!
+//! This protocol is implemented by wlroots-based compositors (sway, Hyprland,
+//! river, Wayfire, …). GNOME (Mutter) and KDE (KWin) do not advertise it, so
+//! [`connect`](WlrForeignToplevelSource::connect) returns `None` there and the
+//! caller falls through to the next backend candidate.
+//!
+//! ## Dispatch model
+//!
+//! The protocol is event-driven, but the [`super::FrontmostSource`] contract is
+//! a synchronous poll (~1 Hz from `openlogi-gui::app_watcher`). Two primitives
+//! bridge that gap:
+//!
+//! - **`drain_events`** (poll path) — flushes pending writes, then attempts a
+//!   non-blocking `prepare_read` + `read` with a short 25 ms `poll(2)` cap.
+//!   If nothing arrives in time the last known state is returned unchanged;
+//!   millisecond-stale frontmost data is acceptable by design. A genuine
+//!   connection error here (as opposed to a timeout) marks the session
+//!   finished so the next poll reconnects, the same as an explicit
+//!   `Finished` event.
+//!
+//! - **`timed_roundtrip`** (init path) — sends `wl_display.sync`, then loops
+//!   `flush` → `poll(2)` → `read` → `dispatch_pending` until the sync callback
+//!   fires or `INIT_TIMEOUT` (5 s) expires. If the deadline is hit the candidate
+//!   returns `None` so backend selection falls through — the same contract as
+//!   every other backend.
+//!
+//! Both helpers use `poll(2)` via the `libc` crate (already a Linux dependency)
+//! with `Instant`-based remaining-time accounting and `EINTR` retry.
+
+use std::collections::HashMap;
+use std::os::unix::io::AsRawFd;
+use std::sync::Mutex;
+use std::time::{Duration, Instant};
+
+use tracing::{debug, info, warn};
+use wayland_client::backend::ObjectId;
+use wayland_client::protocol::wl_callback;
+use wayland_client::protocol::wl_registry::{self, WlRegistry};
+use wayland_client::{Connection, Dispatch, EventQueue, Proxy, QueueHandle, event_created_child};
+use wayland_protocols_wlr::foreign_toplevel::v1::client::zwlr_foreign_toplevel_handle_v1::{
+    self, ZwlrForeignToplevelHandleV1,
+};
+use wayland_protocols_wlr::foreign_toplevel::v1::client::zwlr_foreign_toplevel_manager_v1::{
+    self, ZwlrForeignToplevelManagerV1,
+};
+
+use super::FrontmostSource;
+
+/// Highest protocol version this backend understands. The events it relies on
+/// (`app_id`, `state`, `done`, `closed`) exist since v1, so binding is capped
+/// here to stay within what `wayland-protocols-wlr` generates.
+const MANAGER_MAX_VERSION: u32 = 3;
+
+/// Deadline for the two `wl_display.sync` round-trips in `Session::open`.
+/// Mirrors `gnome_shell::METHOD_TIMEOUT`: both guard the `FRONTMOST_SOURCE`
+/// `LazyLock` initializer against a stalled compositor socket.
+const INIT_TIMEOUT: Duration = Duration::from_secs(5);
+
+/// Maximum time the poll-path drain will wait for new Wayland events. Stale
+/// frontmost data within this window is acceptable by design.
+const POLL_CAP_MS: u64 = 25;
+
+/// Accumulated per-toplevel data. wlr sends individual property events and then
+/// a `done` marking a consistent snapshot, so updates are staged in `pending_*`
+/// and committed on `done`.
+#[derive(Default)]
+struct Toplevel {
+    app_id: Option<String>,
+    activated: bool,
+    pending_app_id: Option<String>,
+    pending_activated: bool,
+}
+
+/// Dispatch state: the bound manager plus the toplevels seen so far.
+#[derive(Default)]
+struct State {
+    manager: Option<ZwlrForeignToplevelManagerV1>,
+    toplevels: HashMap<ObjectId, Toplevel>,
+    /// Set when the compositor sends `finished`; triggers a reconnect on the
+    /// next poll instead of permanently disabling the backend.
+    finished: bool,
+    /// Flipped to `true` by the `wl_callback::Done` handler; used by
+    /// `timed_roundtrip` to detect that the sync echo arrived.
+    sync_done: bool,
+}
+
+impl Dispatch<WlRegistry, ()> for State {
+    fn event(
+        state: &mut Self,
+        registry: &WlRegistry,
+        event: wl_registry::Event,
+        (): &(),
+        _: &Connection,
+        qh: &QueueHandle<Self>,
+    ) {
+        if let wl_registry::Event::Global {
+            name,
+            interface,
+            version,
+        } = event
+            && interface == ZwlrForeignToplevelManagerV1::interface().name
+        {
+            let version = version.min(MANAGER_MAX_VERSION);
+            let manager =
+                registry.bind::<ZwlrForeignToplevelManagerV1, (), Self>(name, version, qh, ());
+            state.manager = Some(manager);
+        }
+    }
+}
+
+impl Dispatch<ZwlrForeignToplevelManagerV1, ()> for State {
+    fn event(
+        state: &mut Self,
+        _: &ZwlrForeignToplevelManagerV1,
+        event: zwlr_foreign_toplevel_manager_v1::Event,
+        (): &(),
+        _: &Connection,
+        _: &QueueHandle<Self>,
+    ) {
+        match event {
+            zwlr_foreign_toplevel_manager_v1::Event::Toplevel { toplevel } => {
+                state.toplevels.insert(toplevel.id(), Toplevel::default());
+            }
+            zwlr_foreign_toplevel_manager_v1::Event::Finished => {
+                // The compositor is reloading or restarting. Mark the session
+                // finished; the next poll will reconnect automatically.
+                warn!(
+                    "wlr-foreign-toplevel: compositor sent Finished — \
+                     will reconnect on next poll"
+                );
+                state.finished = true;
+                state.manager = None;
+            }
+            _ => {}
+        }
+    }
+
+    // The `toplevel` event creates a new handle object; tell the backend to
+    // route its events to this same `State` with `()` user data.
+    event_created_child!(State, ZwlrForeignToplevelManagerV1, [
+        zwlr_foreign_toplevel_manager_v1::EVT_TOPLEVEL_OPCODE => (ZwlrForeignToplevelHandleV1, ()),
+    ]);
+}
+
+impl Dispatch<ZwlrForeignToplevelHandleV1, ()> for State {
+    fn event(
+        state: &mut Self,
+        handle: &ZwlrForeignToplevelHandleV1,
+        event: zwlr_foreign_toplevel_handle_v1::Event,
+        (): &(),
+        _: &Connection,
+        _: &QueueHandle<Self>,
+    ) {
+        use zwlr_foreign_toplevel_handle_v1::Event;
+
+        let id = handle.id();
+        match event {
+            Event::AppId { app_id } => {
+                if let Some(toplevel) = state.toplevels.get_mut(&id) {
+                    toplevel.pending_app_id = Some(app_id);
+                }
+            }
+            Event::State { state: states } => {
+                let activated = is_activated(&states);
+                if let Some(toplevel) = state.toplevels.get_mut(&id) {
+                    toplevel.pending_activated = activated;
+                }
+            }
+            Event::Done => {
+                if let Some(toplevel) = state.toplevels.get_mut(&id) {
+                    // app_id is sent only when it changes, and a compositor may
+                    // emit State + Done before the first AppId. Committing
+                    // `pending_app_id` unconditionally would clobber a known id
+                    // (or the initial one) with None, so only overwrite when a
+                    // value is actually pending. `activated` defaults to false,
+                    // which is the correct state for a window that sent none.
+                    if toplevel.pending_app_id.is_some() {
+                        toplevel.app_id = toplevel.pending_app_id.clone();
+                    }
+                    toplevel.activated = toplevel.pending_activated;
+                }
+            }
+            Event::Closed => {
+                state.toplevels.remove(&id);
+                handle.destroy();
+            }
+            // Title, output enter/leave, and parent are not needed for frontmost.
+            _ => {}
+        }
+    }
+}
+
+impl Dispatch<wl_callback::WlCallback, ()> for State {
+    fn event(
+        state: &mut Self,
+        _: &wl_callback::WlCallback,
+        event: wl_callback::Event,
+        (): &(),
+        _: &Connection,
+        _: &QueueHandle<Self>,
+    ) {
+        if let wl_callback::Event::Done { .. } = event {
+            state.sync_done = true;
+        }
+    }
+}
+
+/// The `state` event carries a `wl_array` of native-endian `u32` state values.
+/// A toplevel is frontmost iff the `activated` value is present in that set.
+fn is_activated(states: &[u8]) -> bool {
+    use zwlr_foreign_toplevel_handle_v1::State;
+
+    states.chunks_exact(4).any(|chunk| {
+        let value = u32::from_ne_bytes([chunk[0], chunk[1], chunk[2], chunk[3]]);
+        State::try_from(value).is_ok_and(|s| s == State::Activated)
+    })
+}
+
+/// Returns the milliseconds remaining until `deadline`, clamped to `[0, i32::MAX]`
+/// for use as a `libc::poll` timeout. Returns 0 when the deadline has passed.
+fn millis_until(deadline: Instant) -> i32 {
+    i32::try_from(
+        deadline
+            .saturating_duration_since(Instant::now())
+            .as_millis()
+            .min(i32::MAX as u128),
+    )
+    .unwrap_or(i32::MAX)
+}
+
+/// Calls `poll(2)` on `fd` (waiting for `POLLIN | POLLERR`) with a deadline.
+/// Retries on `EINTR` with the remaining time. Returns `true` if the fd became
+/// readable, `false` on timeout or error.
+fn poll_fd(fd: libc::c_int, deadline: Instant) -> bool {
+    let mut pfd = libc::pollfd {
+        fd,
+        events: libc::POLLIN | libc::POLLERR,
+        revents: 0,
+    };
+    loop {
+        let timeout_ms = millis_until(deadline);
+        if timeout_ms == 0 {
+            return false;
+        }
+        let r = unsafe { libc::poll(&raw mut pfd, 1, timeout_ms) };
+        if r > 0 {
+            return true;
+        }
+        if r == 0 {
+            return false;
+        }
+        // r < 0 — check errno
+        let e = unsafe { *libc::__errno_location() };
+        if e != libc::EINTR {
+            return false;
+        }
+        // EINTR: retry with remaining deadline
+    }
+}
+
+/// Sends `wl_display.sync` and spins `flush → poll → read → dispatch_pending`
+/// until the sync callback fires or `deadline` is reached. Returns `true` on
+/// success, `false` on timeout or connection error.
+fn timed_roundtrip(
+    conn: &Connection,
+    queue: &mut EventQueue<State>,
+    state: &mut State,
+    deadline: Instant,
+) -> bool {
+    state.sync_done = false;
+    let qh = queue.handle();
+    conn.display().sync(&qh, ());
+
+    loop {
+        if queue.flush().is_err() {
+            return false;
+        }
+        if queue.dispatch_pending(state).is_err() {
+            return false;
+        }
+        if state.sync_done {
+            return true;
+        }
+        if millis_until(deadline) == 0 {
+            return false;
+        }
+
+        match queue.prepare_read() {
+            None => {
+                // Events are already buffered; loop back to dispatch.
+            }
+            Some(guard) => {
+                let fd = guard.connection_fd().as_raw_fd();
+                if !poll_fd(fd, deadline) {
+                    // Timed out or error — candidate falls through.
+                    return false;
+                }
+                if guard.read().is_err() {
+                    return false;
+                }
+            }
+        }
+    }
+}
+
+/// Drains pending compositor events without blocking longer than `POLL_CAP_MS`.
+/// Used on every frontmost poll. Stale data within the cap is acceptable by
+/// design; a genuine connection error (e.g. the compositor crashing and
+/// closing the socket, rather than sending a graceful `Finished`) marks
+/// `state.finished` so the caller reconnects on the next poll instead of
+/// returning stale state forever.
+fn drain_events(queue: &mut EventQueue<State>, state: &mut State) {
+    if queue.flush().is_err() || queue.dispatch_pending(state).is_err() {
+        warn!(
+            "wlr-foreign-toplevel: connection error while draining — will reconnect on next poll"
+        );
+        state.finished = true;
+        return;
+    }
+
+    let deadline = Instant::now() + Duration::from_millis(POLL_CAP_MS);
+    match queue.prepare_read() {
+        None => {
+            // Already had buffered events; dispatch_pending above handled them.
+        }
+        Some(guard) => {
+            let fd = guard.connection_fd().as_raw_fd();
+            if poll_fd(fd, deadline)
+                && (guard.read().is_err() || queue.dispatch_pending(state).is_err())
+            {
+                warn!(
+                    "wlr-foreign-toplevel: connection error while draining — will reconnect on next poll"
+                );
+                state.finished = true;
+            }
+            // If poll timed out, guard is dropped here and we return stale state.
+        }
+    }
+}
+
+/// One live Wayland session: connection + event queue + dispatch state.
+///
+/// Grouping all three behind a single mutex means the whole session can be
+/// dropped and rebuilt atomically when the compositor sends `Finished`.
+struct Session {
+    // Held for RAII — even though `Connection` is Arc-backed, keeping an
+    // explicit handle here ensures the connection outlives the queue.
+    _conn: Connection,
+    queue: EventQueue<State>,
+    state: State,
+}
+
+impl Session {
+    /// Open a fresh connection, bind the manager, and do the initial two
+    /// timed round-trips to populate the toplevel list. Returns `None` when
+    /// the compositor doesn't advertise the protocol, the connection fails,
+    /// or either round-trip exceeds `INIT_TIMEOUT`.
+    fn open() -> Option<Self> {
+        let conn = Connection::connect_to_env()
+            .map_err(|e| debug!("wlr-foreign-toplevel: no Wayland connection: {e}"))
+            .ok()?;
+        let mut queue = conn.new_event_queue();
+        let qh = queue.handle();
+
+        // Registering the registry triggers `global` events on the first
+        // round-trip, where the manager is bound if the compositor advertises it.
+        let _registry = conn.display().get_registry(&qh, ());
+        let mut state = State::default();
+        let deadline = Instant::now() + INIT_TIMEOUT;
+
+        if !timed_roundtrip(&conn, &mut queue, &mut state, deadline) {
+            debug!("wlr-foreign-toplevel: registry round-trip timed out or failed");
+            return None;
+        }
+        if state.manager.is_none() {
+            debug!("wlr-foreign-toplevel: compositor does not advertise the protocol");
+            return None;
+        }
+
+        // Second round-trip: receive the initial toplevel list and properties,
+        // so the first poll already has the active window.
+        if !timed_roundtrip(&conn, &mut queue, &mut state, deadline) {
+            debug!("wlr-foreign-toplevel: initial toplevel round-trip timed out or failed");
+            return None;
+        }
+
+        Some(Self {
+            _conn: conn,
+            queue,
+            state,
+        })
+    }
+}
+
+/// Wayland frontmost backend. Holds the session behind a mutex so the whole
+/// connection can be rebuilt on compositor restart without touching callers.
+struct WlrForeignToplevelSource {
+    // Active session, or `None` when the last reconnect attempt failed.
+    // The mutex bridges the event-driven Wayland runtime to the synchronous
+    // poll contract; the session is only ever touched here, at ~1 Hz.
+    session: Mutex<Option<Session>>,
+}
+
+impl WlrForeignToplevelSource {
+    fn connect() -> Option<Self> {
+        Session::open().map(|s| Self {
+            session: Mutex::new(Some(s)),
+        })
+    }
+}
+
+impl FrontmostSource for WlrForeignToplevelSource {
+    fn frontmost_bundle_id(&self) -> Option<String> {
+        let mut guard = self.session.lock().ok()?;
+
+        // Reconnect when the compositor sent `Finished` (compositor reload /
+        // restart) or when a prior reconnect attempt failed.
+        let needs_reconnect = guard.as_ref().is_none_or(|s| s.state.finished);
+        if needs_reconnect {
+            *guard = Session::open();
+            if guard.is_some() {
+                info!("wlr-foreign-toplevel: reconnected");
+            } else {
+                debug!("wlr-foreign-toplevel: reconnect pending, retrying next poll");
+            }
+        }
+
+        let Session { queue, state, .. } = guard.as_mut()?;
+        drain_events(queue, state);
+        if state.finished {
+            // `Finished` arrived during this drain; reconnect on the next call.
+            return None;
+        }
+
+        state
+            .toplevels
+            .values()
+            .find(|toplevel| toplevel.activated)
+            .and_then(|toplevel| toplevel.app_id.clone())
+    }
+
+    fn name(&self) -> &'static str {
+        "wlr-foreign-toplevel"
+    }
+}
+
+/// Candidate constructor registered in [`super::wayland_candidates`].
+pub(super) fn candidate() -> Option<Box<dyn FrontmostSource>> {
+    WlrForeignToplevelSource::connect().map(|s| Box::new(s) as Box<dyn FrontmostSource>)
+}
+
+#[cfg(test)]
+mod tests {
+    use std::time::{Duration, Instant};
+
+    use super::millis_until;
+
+    #[test]
+    fn millis_until_elapsed_deadline_is_zero() {
+        // `deadline` is captured before the call; by the time `millis_until`
+        // reads `Instant::now()` the deadline is at or before now, so
+        // `saturating_duration_since` returns `Duration::ZERO` → 0 ms.
+        let deadline = Instant::now();
+        assert_eq!(millis_until(deadline), 0);
+    }
+
+    #[test]
+    fn millis_until_future_deadline_is_positive() {
+        let future = Instant::now() + Duration::from_secs(10);
+        let ms = millis_until(future);
+        assert!(ms > 0 && ms <= 10_000);
+    }
+}
diff --git a/crates/openlogi-hook/src/macos.rs b/crates/openlogi-hook/src/macos.rs
index 43dbb3c0960efe8dd0402d9304517a9fa6631a0a..9d1d12bd0df0ba5049553c9dd0831d39750d34cc 100644
--- a/crates/openlogi-hook/src/macos.rs
+++ b/crates/openlogi-hook/src/macos.rs
@@ -2,9 +2,11 @@
 
 use std::cell::RefCell;
 use std::collections::HashMap;
-use std::sync::atomic::{AtomicBool, Ordering};
+use std::panic::{AssertUnwindSafe, catch_unwind};
+use std::sync::atomic::{AtomicBool, AtomicU64, Ordering};
 use std::sync::{Arc, mpsc};
 use std::thread;
+use std::time::{Duration, SystemTime, UNIX_EPOCH};
 
 use core_foundation::base::{CFTypeRef, TCFType as _};
 use core_foundation::number::CFNumber;
@@ -13,14 +15,15 @@ use core_foundation::runloop::{
 };
 use core_foundation::string::{CFString, CFStringRef};
 use core_graphics::event::{
-    CGEvent, CGEventField, CGEventTap, CGEventTapLocation, CGEventTapOptions, CGEventTapPlacement,
-    CGEventTapProxy, CGEventType, CallbackResult, EventField,
+    CGEvent, CGEventField, CGEventFlags, CGEventTap, CGEventTapLocation, CGEventTapOptions,
+    CGEventTapPlacement, CGEventTapProxy, CGEventType, CallbackResult, EventField,
 };
 use foreign_types_shared::ForeignType as _;
 use tracing::{debug, error, warn};
 
 use crate::{
-    ButtonId, EventDevice, EventDisposition, EventTapInfo, HookError, MouseEvent, TapLocation,
+    ButtonId, EventDevice, EventDisposition, EventTapInfo, HookError, HookEvent, KeyEvent,
+    KeyModifiers, MouseEvent, TapLocation,
 };
 
 /// Everything `Hook` needs to control the background thread.
@@ -261,6 +264,43 @@ fn button_number_to_id(n: i64) -> Option<ButtonId> {
     }
 }
 
+/// Best-effort device identity for a button event's HID sender.
+fn button_source(event: &CGEvent) -> Option<crate::EventDevice> {
+    event_sender_id(event).map(|id| sender_device_info(id).event_device)
+}
+
+/// Map the macOS modifier flags on a `CGEvent` to our [`KeyModifiers`].
+/// `SecondaryFn` is deliberately ignored: it is firmware-internal and
+/// unreliable as a trigger (function-key-remapper spec, Appendix A).
+fn modifiers_from_flags(flags: CGEventFlags) -> KeyModifiers {
+    KeyModifiers {
+        shift: flags.contains(CGEventFlags::CGEventFlagShift),
+        control: flags.contains(CGEventFlags::CGEventFlagControl),
+        option: flags.contains(CGEventFlags::CGEventFlagAlternate),
+        command: flags.contains(CGEventFlags::CGEventFlagCommand),
+    }
+}
+
+/// Translate a keyboard `CGEvent` into a [`KeyEvent`]. Returns `None` for
+/// non-key event types (the mouse path handles those) and for `FlagsChanged`
+/// (modifier state rides on the next key event via its flags; a standalone
+/// flags change carries no key of interest to the remapper).
+fn translate_key(etype: CGEventType, event: &CGEvent) -> Option<KeyEvent> {
+    let pressed = match etype {
+        CGEventType::KeyDown => true,
+        CGEventType::KeyUp => false,
+        // FlagsChanged: no key to remap here.
+        _ => return None,
+    };
+    let keycode = event.get_integer_value_field(EventField::KEYBOARD_EVENT_KEYCODE);
+    let keycode = u16::try_from(keycode).ok()?;
+    Some(KeyEvent {
+        keycode,
+        pressed,
+        modifiers: modifiers_from_flags(event.get_flags()),
+    })
+}
+
 /// Convert a `CGEvent` to our [`MouseEvent`] vocabulary. Returns `None`
 /// for event types we don't translate (e.g. move events, unknown buttons).
 fn translate(etype: CGEventType, event: &CGEvent) -> Option<MouseEvent> {
@@ -288,26 +328,38 @@ fn translate(etype: CGEventType, event: &CGEvent) -> Option<MouseEvent> {
         CGEventType::LeftMouseDown => Some(MouseEvent::Button {
             id: ButtonId::LeftClick,
             pressed: true,
+            device: button_source(event),
         }),
         CGEventType::LeftMouseUp => Some(MouseEvent::Button {
             id: ButtonId::LeftClick,
             pressed: false,
+            device: button_source(event),
         }),
         CGEventType::RightMouseDown => Some(MouseEvent::Button {
             id: ButtonId::RightClick,
             pressed: true,
+            device: button_source(event),
         }),
         CGEventType::RightMouseUp => Some(MouseEvent::Button {
             id: ButtonId::RightClick,
             pressed: false,
+            device: button_source(event),
         }),
         CGEventType::OtherMouseDown => {
             let n = event.get_integer_value_field(EventField::MOUSE_EVENT_BUTTON_NUMBER);
-            button_number_to_id(n).map(|id| MouseEvent::Button { id, pressed: true })
+            button_number_to_id(n).map(|id| MouseEvent::Button {
+                id,
+                pressed: true,
+                device: button_source(event),
+            })
         }
         CGEventType::OtherMouseUp => {
             let n = event.get_integer_value_field(EventField::MOUSE_EVENT_BUTTON_NUMBER);
-            button_number_to_id(n).map(|id| MouseEvent::Button { id, pressed: false })
+            button_number_to_id(n).map(|id| MouseEvent::Button {
+                id,
+                pressed: false,
+                device: button_source(event),
+            })
         }
         CGEventType::ScrollWheel => {
             // axis 1 = vertical scroll; axis 2 = horizontal scroll. Read the
@@ -419,7 +471,7 @@ fn usable_scroll_delta(event: &CGEvent, axis: ScrollAxisFields) -> f64 {
 
 /// Create the event tap and run loop on a dedicated thread.
 pub(crate) fn start(
-    cb: impl Fn(MouseEvent) -> EventDisposition + Send + Sync + 'static,
+    cb: impl Fn(HookEvent) -> EventDisposition + Send + Sync + 'static,
 ) -> Result<HookInner, HookError> {
     if !has_accessibility() {
         return Err(HookError::AccessibilityDenied);
@@ -427,7 +479,7 @@ pub(crate) fn start(
 
     // Wrap in Arc so the closure handed to CGEventTap::new captures it by
     // clone rather than by move — avoids a second Box allocation.
-    let cb: Arc<dyn Fn(MouseEvent) -> EventDisposition + Send + Sync> = Arc::new(cb);
+    let cb: Arc<dyn Fn(HookEvent) -> EventDisposition + Send + Sync> = Arc::new(cb);
 
     let stop = Arc::new(AtomicBool::new(false));
     let (rl_tx, rl_rx) = mpsc::channel::<CFRunLoop>();
@@ -457,17 +509,15 @@ pub(crate) fn start(
     })
 }
 
-/// Body of the background hook thread.
-#[allow(
-    clippy::needless_pass_by_value,
-    reason = "rl_tx must be owned: dropping it signals the parent's recv() to return Err on failure paths"
-)]
-fn thread_main(
-    cb: Arc<dyn Fn(MouseEvent) -> EventDisposition + Send + Sync>,
-    rl_tx: mpsc::Sender<CFRunLoop>,
-    stop: Arc<AtomicBool>,
-) {
-    let event_types = vec![
+/// How long the tap callback may run before the watchdog treats the agent as
+/// wedging system input and force-exits. An active HID-level tap serialises
+/// every pointer event through this callback; a hang freezes clicks machine-wide.
+const CALLBACK_STUCK_BUDGET: Duration = Duration::from_millis(200);
+
+/// Event types the HID tap observes. Pointer *Dragged variants are required
+/// because a held button makes the OS emit those instead of `MouseMoved`.
+fn hooked_event_types() -> Vec<CGEventType> {
+    vec![
         CGEventType::LeftMouseDown,
         CGEventType::LeftMouseUp,
         CGEventType::RightMouseDown,
@@ -475,31 +525,128 @@ fn thread_main(
         CGEventType::OtherMouseDown,
         CGEventType::OtherMouseUp,
         CGEventType::ScrollWheel,
-        // Pointer movement, for gesture-button hold+swipe. A held button makes
-        // the OS emit *Dragged rather than MouseMoved, so all four are needed.
-        // The callback stays lock-light (see `hook_runtime`) so this high-rate
-        // stream can't stall the tap.
         CGEventType::MouseMoved,
         CGEventType::LeftMouseDragged,
         CGEventType::RightMouseDragged,
         CGEventType::OtherMouseDragged,
-    ];
-
-    let tap_result = CGEventTap::new(
-        CGEventTapLocation::HID,
-        CGEventTapPlacement::HeadInsertEventTap,
-        CGEventTapOptions::Default,
-        event_types,
-        move |_proxy: CGEventTapProxy, etype: CGEventType, event: &CGEvent| {
-            let Some(mouse_event) = translate(etype, event) else {
-                return CallbackResult::Keep;
-            };
-            match cb(mouse_event) {
-                EventDisposition::PassThrough => CallbackResult::Keep,
-                EventDisposition::Suppress => CallbackResult::Drop,
+        // Function-key remapper: F1–F12/Esc arrive as KeyDown/KeyUp.
+        CGEventType::KeyDown,
+        CGEventType::KeyUp,
+        CGEventType::FlagsChanged,
+    ]
+}
+
+/// Invoke the user callback under `catch_unwind`, always failing open.
+fn run_tap_callback(
+    cb: &dyn Fn(HookEvent) -> EventDisposition,
+    etype: CGEventType,
+    event: &CGEvent,
+) -> CallbackResult {
+    let result = catch_unwind(AssertUnwindSafe(|| {
+        // Mouse first, then keyboard; a given event type is one or the other.
+        let hook_event = if let Some(mouse_event) = translate(etype, event) {
+            HookEvent::Mouse(mouse_event)
+        } else if let Some(key_event) = translate_key(etype, event) {
+            HookEvent::Key(key_event)
+        } else {
+            return CallbackResult::Keep;
+        };
+        match cb(hook_event) {
+            EventDisposition::PassThrough => CallbackResult::Keep,
+            EventDisposition::Suppress => CallbackResult::Drop,
+        }
+    }));
+    if let Ok(disposition) = result {
+        disposition
+    } else {
+        error!(
+            "OS mouse-hook callback panicked — passing event through to \
+             avoid wedging system input"
+        );
+        CallbackResult::Keep
+    }
+}
+
+/// Sibling watchdog: if the callback is still entered past the budget, abort
+/// the agent so macOS tears the tap down and system input recovers.
+fn spawn_callback_watchdog(
+    stop: Arc<AtomicBool>,
+    in_callback: Arc<AtomicBool>,
+    entered_at_ms: Arc<AtomicU64>,
+) {
+    let budget_ms = u64::try_from(CALLBACK_STUCK_BUDGET.as_millis()).unwrap_or(200);
+    let _ = thread::Builder::new()
+        .name("openlogi-hook-watchdog".into())
+        .spawn(move || {
+            while !stop.load(Ordering::Relaxed) {
+                thread::sleep(Duration::from_millis(20));
+                if !in_callback.load(Ordering::Acquire) {
+                    continue;
+                }
+                let entered = entered_at_ms.load(Ordering::Acquire);
+                if entered == 0 {
+                    continue;
+                }
+                let elapsed = unix_now_ms().saturating_sub(entered);
+                if elapsed < budget_ms {
+                    continue;
+                }
+                // Re-sample: a fresh entry may have rewritten the stamp between
+                // the first loads and the budget check.
+                if !in_callback.load(Ordering::Acquire)
+                    || entered_at_ms.load(Ordering::Acquire) != entered
+                {
+                    continue;
+                }
+                error!(
+                    stuck_ms = elapsed,
+                    "OS mouse-hook callback stuck past budget — exiting agent to \
+                     restore system input (HID CGEventTap freeze hazard)"
+                );
+                // Hard exit: disable_tap alone cannot unblock an in-flight
+                // callback, and a live active HID tap freezes all pointer I/O.
+                std::process::exit(78);
             }
-        },
-    );
+        });
+}
+
+/// Body of the background hook thread.
+#[allow(
+    clippy::needless_pass_by_value,
+    reason = "rl_tx must be owned: dropping it signals the parent's recv() to return Err on failure paths"
+)]
+fn thread_main(
+    cb: Arc<dyn Fn(HookEvent) -> EventDisposition + Send + Sync>,
+    rl_tx: mpsc::Sender<CFRunLoop>,
+    stop: Arc<AtomicBool>,
+) {
+    // Watchdog state: the run-loop thread can't observe a stuck callback (it
+    // *is* the callback), so a sibling thread samples these atomics and kills
+    // the process if the budget is exceeded — process death is the only reliable
+    // way to release a wedged HID-level tap and restore system input.
+    let in_callback = Arc::new(AtomicBool::new(false));
+    let entered_at_ms = Arc::new(AtomicU64::new(0));
+
+    let tap_result = {
+        let in_callback = Arc::clone(&in_callback);
+        let entered_at_ms = Arc::clone(&entered_at_ms);
+        CGEventTap::new(
+            CGEventTapLocation::HID,
+            CGEventTapPlacement::HeadInsertEventTap,
+            CGEventTapOptions::Default,
+            hooked_event_types(),
+            move |_proxy: CGEventTapProxy, etype: CGEventType, event: &CGEvent| {
+                // Publish the enter timestamp *before* the in-callback flag so
+                // the watchdog never pairs a fresh entry with a stale stamp
+                // (which would false-positive process::exit after a quiet gap).
+                entered_at_ms.store(unix_now_ms(), Ordering::Relaxed);
+                in_callback.store(true, Ordering::Release);
+                let disposition = run_tap_callback(cb.as_ref(), etype, event);
+                in_callback.store(false, Ordering::Release);
+                disposition
+            },
+        )
+    };
 
     let Ok(tap) = tap_result else {
         error!("CGEventTapCreate returned null — Accessibility may have been revoked");
@@ -521,9 +668,15 @@ fn thread_main(
         run_loop.add_source(&loop_source, kCFRunLoopCommonModes);
     }
     tap.enable();
+    spawn_callback_watchdog(
+        Arc::clone(&stop),
+        Arc::clone(&in_callback),
+        Arc::clone(&entered_at_ms),
+    );
 
     if rl_tx.send(run_loop).is_err() {
         debug!("hook parent dropped before run loop was ready; stopping");
+        disable_tap(&tap);
         return;
     }
 
@@ -549,7 +702,7 @@ fn thread_main(
         match CFRunLoop::run_in_mode(
             // SAFETY: framework-provided static CFStringRef, 'static.
             unsafe { kCFRunLoopDefaultMode },
-            std::time::Duration::from_millis(500),
+            Duration::from_millis(500),
             false,
         ) {
             CFRunLoopRunResult::Stopped | CFRunLoopRunResult::Finished => break,
@@ -575,6 +728,13 @@ fn thread_main(
     disable_tap(&tap);
 }
 
+/// Milliseconds since the Unix epoch for the stuck-callback watchdog.
+fn unix_now_ms() -> u64 {
+    SystemTime::now()
+        .duration_since(UNIX_EPOCH)
+        .map_or(0, |d| u64::try_from(d.as_millis()).unwrap_or(u64::MAX))
+}
+
 /// Disable an active event tap now. core-graphics only exposes the enable
 /// side of `CGEventTapEnable`, so we bind the disable side ourselves.
 fn disable_tap(tap: &CGEventTap) {
diff --git a/crates/openlogi-hook/src/tests.rs b/crates/openlogi-hook/src/tests.rs
index f11dc1c6cdd2c27125fbced413405089c640fb2b..b40a4615ed0f9f70df32026710ba4249ffb1df65 100644
--- a/crates/openlogi-hook/src/tests.rs
+++ b/crates/openlogi-hook/src/tests.rs
@@ -26,6 +26,7 @@ fn mouse_event_clone_and_debug() {
         MouseEvent::Button {
             id: ButtonId::Back,
             pressed: true,
+            device: None,
         },
         MouseEvent::Scroll {
             delta_x: 1.0,
@@ -53,6 +54,40 @@ fn event_disposition_equality() {
     assert_ne!(EventDisposition::PassThrough, EventDisposition::Suppress);
 }
 
+/// Remap policy is fail-closed: only known Logitech non-trackpad sources.
+#[test]
+fn source_is_remappable_policy() {
+    assert!(!source_is_remappable(None));
+
+    let trackpad = EventDevice {
+        vendor_id: Some(0),
+        product_id: None,
+        product_name: Some("Apple Internal Keyboard / Trackpad".into()),
+    };
+    assert!(!source_is_remappable(Some(&trackpad)));
+
+    let apple_mouse = EventDevice {
+        vendor_id: Some(0x05ac),
+        product_id: Some(0x030d),
+        product_name: Some("Magic Mouse".into()),
+    };
+    assert!(!source_is_remappable(Some(&apple_mouse)));
+
+    let logi = EventDevice {
+        vendor_id: Some(LOGITECH_VENDOR_ID),
+        product_id: Some(0xb034),
+        product_name: Some("MX Master 3S".into()),
+    };
+    assert!(source_is_remappable(Some(&logi)));
+
+    let logi_by_name = EventDevice {
+        vendor_id: None,
+        product_id: None,
+        product_name: Some("Logitech USB Receiver".into()),
+    };
+    assert!(source_is_remappable(Some(&logi_by_name)));
+}
+
 /// On unsupported targets (not macOS, Linux, or Windows), `Hook::start`
 /// returns `Unsupported`. The cfg predates the Windows port (#167) — Windows
 /// belongs with the supported targets below, where this stale form made
diff --git a/crates/openlogi-hook/src/windows.rs b/crates/openlogi-hook/src/windows.rs
index 781e1e01a20453bc9d9164720bfcb3deff627786..4da07ad92b98bb6dd85503b99c25850d3e07298a 100644
--- a/crates/openlogi-hook/src/windows.rs
+++ b/crates/openlogi-hook/src/windows.rs
@@ -24,7 +24,7 @@ use windows_sys::Win32::UI::WindowsAndMessaging::{
     XBUTTON2,
 };
 
-use crate::{ButtonId, EventDisposition, HookError, MouseEvent};
+use crate::{ButtonId, EventDisposition, HookError, HookEvent, MouseEvent};
 
 const WHEEL_DELTA: f32 = 120.0;
 
@@ -40,7 +40,7 @@ thread_local! {
     static LAST_POINT: Cell<Option<POINT>> = const { Cell::new(None) };
 }
 
-type HookCallback = Arc<dyn Fn(MouseEvent) -> EventDisposition + Send + Sync + 'static>;
+type HookCallback = Arc<dyn Fn(HookEvent) -> EventDisposition + Send + Sync + 'static>;
 
 static CALLBACK: Mutex<Option<HookCallback>> = Mutex::new(None);
 
@@ -50,7 +50,7 @@ pub(crate) struct HookInner {
 }
 
 pub(crate) fn start(
-    cb: impl Fn(MouseEvent) -> EventDisposition + Send + Sync + 'static,
+    cb: impl Fn(HookEvent) -> EventDisposition + Send + Sync + 'static,
 ) -> Result<HookInner, HookError> {
     let callback: HookCallback = Arc::new(cb);
     let (ready_tx, ready_rx) = mpsc::channel();
@@ -212,7 +212,9 @@ unsafe extern "system" fn mouse_proc(code: i32, wparam: WPARAM, lparam: LPARAM)
     let callback = CALLBACK.lock().ok().and_then(|slot| slot.clone());
     let disposition = callback
         .as_ref()
-        .map_or(EventDisposition::PassThrough, |cb| cb(event));
+        .map_or(EventDisposition::PassThrough, |cb| {
+            cb(HookEvent::Mouse(event))
+        });
     match disposition {
         EventDisposition::PassThrough => call_next(code, wparam, lparam),
         EventDisposition::Suppress => 1,
@@ -263,7 +265,14 @@ fn translate_event(wparam: WPARAM, data: MSLLHOOKSTRUCT) -> Option<MouseEvent> {
             },
             _ => return None,
         };
-        return Some(MouseEvent::Button { id, pressed });
+        // Windows WH_MOUSE_LL does not expose a cheap device identity; leave
+        // `device` as None so remapping still works (see hook_runtime: non-macOS
+        // keeps remapping when attribution is absent).
+        return Some(MouseEvent::Button {
+            id,
+            pressed,
+            device: None,
+        });
     }
 
     match wparam as u32 {
diff --git a/crates/openlogi-inject/Cargo.toml b/crates/openlogi-inject/Cargo.toml
index 7b372af30766cf077145be33be25a9937da43614..af0b65ac416206ab2d869d4b6074ef479c879e1a 100644
--- a/crates/openlogi-inject/Cargo.toml
+++ b/crates/openlogi-inject/Cargo.toml
@@ -11,7 +11,7 @@ keywords = ["logitech", "input", "uinput", "sendinput", "mouse"]
 categories = ["hardware-support", "os"]
 
 [dependencies]
-openlogi-core = { path = "../openlogi-core", version = "0.6.23" }
+openlogi-core = { path = "../openlogi-core", version = "0.6.24" }
 tracing = { workspace = true }
 
 [dev-dependencies]
@@ -33,6 +33,8 @@ objc2-app-kit = { workspace = true, features = [
   "NSEvent",
   "NSGraphicsContext",
   "objc2-core-graphics",
+  "NSWorkspace",
+  "NSRunningApplication",
 ] }
 objc2-core-graphics = { version = "0.3.2", features = ["CGEvent"] }
 objc2-foundation = { workspace = true }
diff --git a/crates/openlogi-inject/src/inject.rs b/crates/openlogi-inject/src/inject.rs
index 6c5c67be07712d4d7225d732971b833e0a8422f3..c5b75b8317d873f511ff59c078f2a6f5432d9c9f 100644
--- a/crates/openlogi-inject/src/inject.rs
+++ b/crates/openlogi-inject/src/inject.rs
@@ -70,6 +70,26 @@ pub fn execute(action: &Action) {
     }
 }
 
+/// Navigate the browser identified by `pid` backwards or forwards using the
+/// Accessibility API (`AXPress` on the "Go back" / "Go forward" toolbar button).
+///
+/// Call this from the gesture watcher **at the moment the button press arrives**
+/// so `pid` reflects the correct frontmost app rather than whatever happens to
+/// be frontmost when the async dispatch completes. Returns `true` on success.
+/// No-op (returns `false`) on non-macOS platforms.
+#[must_use]
+pub fn ax_navigate_browser(pid: i32, forward: bool) -> bool {
+    #[cfg(target_os = "macos")]
+    {
+        macos::ax_browser_navigate(forward, Some(pid))
+    }
+    #[cfg(not(target_os = "macos"))]
+    {
+        let _ = (pid, forward);
+        false
+    }
+}
+
 /// Synthesise a horizontal scroll of `delta` wheel lines at the current focus.
 ///
 /// Used by the gesture/thumbwheel capture watcher to re-inject the MX thumb
diff --git a/crates/openlogi-inject/src/inject/linux.rs b/crates/openlogi-inject/src/inject/linux.rs
index 15216e20affe91f0d53a9fcb49bf02977e1f841f..c97fd38a9ba295ae0a7c66c45b578de869a39dac 100644
--- a/crates/openlogi-inject/src/inject/linux.rs
+++ b/crates/openlogi-inject/src/inject/linux.rs
@@ -12,7 +12,7 @@ use evdev::uinput::VirtualDevice;
 use evdev::{AttributeSet, EventType, InputEvent, KeyCode, RelativeAxisCode};
 use zbus::blocking::Connection as DbusConn;
 
-use openlogi_core::binding::Action;
+use openlogi_core::binding::{Action, WorkflowStep};
 
 /// Linux implementation: inject events via a shared `uinput` virtual device.
 pub(super) fn execute(action: &Action) {
@@ -64,6 +64,8 @@ pub(super) fn execute(action: &Action) {
         // ── System ────────────────────────────────────────────────────────
         // logind LockSessions() via the system bus; falls back to Super+L.
         Action::LockScreen => lock_screen(),
+        // logind Suspend() via the system bus.
+        Action::Sleep => sleep_system(),
         // Region vs full-screen capture depends on the desktop environment's
         // screenshot handler for Print Screen, so both map to the same key.
         Action::Screenshot | Action::CaptureRegion => press_key(&[], KeyCode::KEY_SYSRQ),
@@ -108,9 +110,71 @@ pub(super) fn execute(action: &Action) {
             };
             press_key(&modifiers_to_keycodes(combo.modifiers), key);
         }
+        Action::TypeText(text) => {
+            tracing::warn!(
+                chars = text.chars().count(),
+                "TypeText injection is not implemented on Linux yet"
+            );
+        }
+        Action::RunAppleScript(_) => {
+            tracing::warn!("RunAppleScript is only supported on macOS");
+        }
+        Action::RunShellCommand(cmd) => run_shell_command_async(cmd.clone()),
+        Action::Workflow(steps) => run_workflow_async(steps.clone()),
     }
 }
 
+fn run_shell_command_async(cmd: String) {
+    std::thread::spawn(move || run_shell_command(&cmd));
+}
+
+fn run_workflow_async(steps: Vec<WorkflowStep>) {
+    std::thread::spawn(move || run_workflow(&steps));
+}
+
+fn run_workflow(steps: &[WorkflowStep]) {
+    for step in steps {
+        match step {
+            WorkflowStep::TypeText(text) => {
+                tracing::warn!(
+                    chars = text.chars().count(),
+                    "workflow TypeText injection is not implemented on Linux yet"
+                );
+            }
+            WorkflowStep::PressKey(combo) => {
+                if combo.key_code == 0 {
+                    tracing::warn!(
+                        chord = %combo.rendered_label(),
+                        "workflow PressKey with no key code; step ignored"
+                    );
+                    continue;
+                }
+                let Some(key) = macos_vk_to_linux(combo.key_code) else {
+                    tracing::warn!(
+                        key_code = combo.key_code,
+                        "workflow PressKey key code has no Linux mapping; step ignored"
+                    );
+                    continue;
+                };
+                press_key(&modifiers_to_keycodes(combo.modifiers), key);
+            }
+            WorkflowStep::Delay { millis } => {
+                std::thread::sleep(std::time::Duration::from_millis(*millis));
+            }
+            WorkflowStep::RunAppleScript(_) => {
+                tracing::warn!("workflow RunAppleScript is only supported on macOS");
+            }
+            WorkflowStep::RunShellCommand(cmd) => run_shell_command(cmd),
+        }
+    }
+}
+
+fn run_shell_command(cmd: &str) {
+    let _ = std::process::Command::new("/bin/sh")
+        .args(["-c", cmd])
+        .output();
+}
+
 const DEVICE_NAME: &str = "OpenLogi action injector";
 
 static VIRTUAL_INPUT: LazyLock<Option<Mutex<VirtualDevice>>> = LazyLock::new(|| {
@@ -414,6 +478,27 @@ fn lock_screen() {
     press_key(&[KeyCode::KEY_LEFTMETA], KeyCode::KEY_L);
 }
 
+/// Suspend the system via logind's `Suspend()` on the system bus. The
+/// `false` argument declines the "interactive" polkit prompt — if the
+/// session isn't allowed to suspend, the call fails and is logged rather
+/// than popping an authentication dialog from a background agent.
+fn sleep_system() {
+    let Some(conn) = SYSTEM_BUS.as_ref() else {
+        tracing::warn!("no system bus — Sleep skipped");
+        return;
+    };
+    match conn.call_method(
+        Some("org.freedesktop.login1"),
+        "/org/freedesktop/login1",
+        Some("org.freedesktop.login1.Manager"),
+        "Suspend",
+        &(false,),
+    ) {
+        Ok(_) => tracing::debug!("Sleep via logind Suspend"),
+        Err(e) => tracing::warn!("logind Suspend failed: {e}"),
+    }
+}
+
 /// Send `command` to the first MPRIS-capable media player on the session bus,
 /// falling back to the corresponding XF86 multimedia key only if no MPRIS
 /// player is found. When a player is found but the call fails, the fallback
diff --git a/crates/openlogi-inject/src/inject/macos.rs b/crates/openlogi-inject/src/inject/macos.rs
index a492d62acdd404a12e2e4a48489a7fe3ebbf7169..e9343f0599aeb151795c78d340ad045f53dcf5eb 100644
--- a/crates/openlogi-inject/src/inject/macos.rs
+++ b/crates/openlogi-inject/src/inject/macos.rs
@@ -7,7 +7,8 @@ use core_graphics::event::{
 use core_graphics::event_source::{CGEventSource, CGEventSourceStateID};
 use core_graphics::geometry::CGPoint;
 
-use openlogi_core::binding::Action;
+use core_foundation::base::TCFType as _;
+use openlogi_core::binding::{Action, WorkflowStep};
 
 // NX_KEYTYPE_* constants from <IOKit/hidsystem/ev_keymap.h>.
 const NX_KEYTYPE_SOUND_UP: i32 = 0;
@@ -66,8 +67,10 @@ pub(super) fn execute(action: &Action) {
         Action::Find => post_key(VK_F, cmd),
         Action::Save => post_key(VK_S, cmd),
         // ── Browser / Navigation ──────────────────────────────────────────
-        // BrowserBack/Forward: Cmd+[ / Cmd+] as keyboard fallback; hook
-        // layer handles the physical mouse buttons directly.
+        // BrowserBack/Forward: Cmd+[ / Cmd+] for Chrome and other apps.
+        // Safari is handled upstream via ax_navigate_browser() with the PID
+        // captured at press time — by the time execute() is called the AX path
+        // has already run, so this fallback is for non-Safari browsers only.
         // kVK_ANSI_LeftBracket = 0x21, kVK_ANSI_RightBracket = 0x1E
         Action::BrowserBack => post_key(0x21, cmd),
         Action::BrowserForward => post_key(0x1E, cmd),
@@ -96,6 +99,10 @@ pub(super) fn execute(action: &Action) {
         Action::Screenshot => post_key(0x14, cmd | shift),
         // Capture region to clipboard = Cmd+Shift+Ctrl+4 (kVK_ANSI_4 = 0x15)
         Action::CaptureRegion => post_key(0x15, cmd | shift | ctrl),
+        // Sleep has no CGEvent equivalent (the WindowServer ignores a
+        // synthesised power key), so ask powermanagement directly. `pmset
+        // sleepnow` works for the console user without privileges.
+        Action::Sleep => sleep_system(),
         // ── Media ─────────────────────────────────────────────────────────
         // Media/volume controls are NX system-defined keys, not ordinary
         // keyboard virtual-key events. Posting kVK_Volume* through
@@ -146,6 +153,14 @@ pub(super) fn execute(action: &Action) {
             }
             post_key(combo.key_code, flags);
         }
+        // TypeText emits a unicode string, layout-independent.
+        Action::TypeText(text) => post_unicode(text),
+        // Run actions spawn off the tap thread: the callback must not block
+        // (posting a key while waiting on a child process would wedge input).
+        Action::RunAppleScript(src) => run_apple_script_async(src.clone()),
+        Action::RunShellCommand(cmd) => run_shell_command_async(cmd.clone()),
+        // Workflows can sleep between steps, so they also run off the tap thread.
+        Action::Workflow(steps) => run_workflow_async(steps.clone()),
     }
 }
 
@@ -240,6 +255,86 @@ fn post_key(vk: u16, flags: CGEventFlags) {
     up.post(CGEventTapLocation::HID);
 }
 
+/// Type an arbitrary unicode string by emitting one key event per character,
+/// each carrying its unicode payload via `CGEventKeyboardSetUnicodeString`.
+fn post_unicode(text: &str) {
+    let Ok(src) = CGEventSource::new(CGEventSourceStateID::HIDSystemState) else {
+        tracing::warn!("CGEventSource::new failed for post_unicode");
+        return;
+    };
+    for ch in text.chars() {
+        // Keycode 0 (A) is a placeholder; the unicode payload determines the
+        // actual inserted character.
+        let Ok(ev) = CGEvent::new_keyboard_event(src.clone(), 0, true) else {
+            tracing::warn!("CGEvent::new_keyboard_event failed in post_unicode");
+            continue;
+        };
+        let s = ch.to_string();
+        ev.set_string(&s);
+        ev.post(CGEventTapLocation::HID);
+    }
+}
+
+/// Press a key chord described by a `KeyCombo` modifier bitmask + virtual
+/// keycode. Used by the workflow sequencer's `PressKey` step.
+fn post_keycombo(modifiers: u8, vk: u16) {
+    use openlogi_core::binding::KeyCombo;
+
+    let mut flags = CGEventFlags::CGEventFlagNull;
+    if modifiers & KeyCombo::MOD_CMD != 0 {
+        flags |= CGEventFlags::CGEventFlagCommand;
+    }
+    if modifiers & KeyCombo::MOD_SHIFT != 0 {
+        flags |= CGEventFlags::CGEventFlagShift;
+    }
+    if modifiers & KeyCombo::MOD_CTRL != 0 {
+        flags |= CGEventFlags::CGEventFlagControl;
+    }
+    if modifiers & KeyCombo::MOD_OPTION != 0 {
+        flags |= CGEventFlags::CGEventFlagAlternate;
+    }
+    post_key(vk, flags);
+}
+
+fn run_apple_script_async(src: String) {
+    std::thread::spawn(move || run_apple_script(&src));
+}
+
+fn run_shell_command_async(cmd: String) {
+    std::thread::spawn(move || run_shell_command(&cmd));
+}
+
+fn run_workflow_async(steps: Vec<WorkflowStep>) {
+    std::thread::spawn(move || run_workflow(&steps));
+}
+
+/// Run workflow steps on a worker thread, so `Delay` never stalls the event tap.
+fn run_workflow(steps: &[WorkflowStep]) {
+    for step in steps {
+        match step {
+            WorkflowStep::TypeText(text) => post_unicode(text),
+            WorkflowStep::PressKey(combo) => post_keycombo(combo.modifiers, combo.key_code),
+            WorkflowStep::Delay { millis } => {
+                std::thread::sleep(std::time::Duration::from_millis(*millis));
+            }
+            WorkflowStep::RunAppleScript(src) => run_apple_script(src),
+            WorkflowStep::RunShellCommand(cmd) => run_shell_command(cmd),
+        }
+    }
+}
+
+fn run_apple_script(src: &str) {
+    let _ = std::process::Command::new("osascript")
+        .args(["-e", src])
+        .output();
+}
+
+fn run_shell_command(cmd: &str) {
+    let _ = std::process::Command::new("/bin/sh")
+        .args(["-c", cmd])
+        .output();
+}
+
 /// Post a media/system key event (play/pause, track navigation, volume).
 ///
 /// Runs on the hook/gesture dispatch threads, which have no run loop to
@@ -284,6 +379,26 @@ fn post_media_key(nx_key: i32) {
     });
 }
 
+/// Put the system to sleep via `pmset sleepnow` — sleep has no CGEvent
+/// equivalent, and `pmset` performs the console user's sleep request
+/// without privileges. Fire-and-forget; a spawn failure is logged. The
+/// child is reaped on a detached thread so it can't linger as a zombie
+/// in this long-running agent.
+fn sleep_system() {
+    match std::process::Command::new("/usr/bin/pmset")
+        .arg("sleepnow")
+        .spawn()
+    {
+        Ok(mut child) => {
+            tracing::debug!("Sleep via pmset sleepnow");
+            std::thread::spawn(move || {
+                let _ = child.wait();
+            });
+        }
+        Err(e) => tracing::warn!(error = %e, "pmset sleepnow spawn failed"),
+    }
+}
+
 /// Post a synthetic scroll event for `action` (one of the `Scroll*` variants).
 fn post_scroll(action: &Action) {
     let Ok(src) = CGEventSource::new(CGEventSourceStateID::HIDSystemState) else {
@@ -320,6 +435,408 @@ pub(super) fn post_horizontal_scroll(delta: i32) {
     ev.post(CGEventTapLocation::HID);
 }
 
+/// Raw FFI surface for the AXUIElement/CF calls used by [`ax_browser_navigate`]
+/// and its helpers below. Kept as module-level items (rather than nested in
+/// `ax_browser_navigate`) so each helper is independently readable and short.
+#[allow(unsafe_code, reason = "AXUIElement / CF APIs require raw FFI")]
+mod ax_nav {
+    use std::ffi::c_void;
+
+    pub(super) type AXUIElementRef = *const c_void;
+    pub(super) type CFTypeRef = *const c_void;
+
+    #[link(name = "ApplicationServices", kind = "framework")]
+    unsafe extern "C" {
+        pub(super) fn AXUIElementCreateApplication(pid: i32) -> AXUIElementRef;
+        pub(super) fn AXUIElementCopyAttributeValue(
+            element: AXUIElementRef,
+            attribute: core_foundation::string::CFStringRef,
+            value: *mut CFTypeRef,
+        ) -> i32;
+        pub(super) fn AXUIElementPerformAction(
+            element: AXUIElementRef,
+            action: core_foundation::string::CFStringRef,
+        ) -> i32;
+        pub(super) fn CFRelease(cf: CFTypeRef);
+        pub(super) fn CFGetTypeID(cf: CFTypeRef) -> usize;
+        pub(super) fn CFArrayGetTypeID() -> usize;
+        pub(super) fn CFArrayGetCount(arr: CFTypeRef) -> isize;
+        pub(super) fn CFArrayGetValueAtIndex(arr: CFTypeRef, idx: isize) -> CFTypeRef;
+        pub(super) fn CFRetain(cf: CFTypeRef) -> CFTypeRef;
+    }
+
+    pub(super) const AX_ERROR_SUCCESS: i32 = 0;
+}
+
+/// The AX attribute names [`find_button`] and [`find_nav_button_by_position`]
+/// need, bundled so neither function's argument list grows with the tree depth
+/// it searches.
+struct AxAttrs {
+    role: core_foundation::string::CFStringRef,
+    description: core_foundation::string::CFStringRef,
+    identifier: core_foundation::string::CFStringRef,
+    subrole: core_foundation::string::CFStringRef,
+    children: core_foundation::string::CFStringRef,
+}
+
+/// Get one AX attribute as a raw CFTypeRef (+1 retained). Caller must CFRelease.
+///
+/// SAFETY: `el` must be a valid AXUIElementRef and `attr` a valid CFStringRef
+/// (the CF memory rules — Get Rule = no extra retain, Create/Copy Rule = +1
+/// retain, caller releases — apply throughout this module).
+#[allow(unsafe_code, reason = "AXUIElement / CF APIs require raw FFI")]
+unsafe fn copy_attr(
+    el: ax_nav::AXUIElementRef,
+    attr: core_foundation::string::CFStringRef,
+) -> Option<ax_nav::CFTypeRef> {
+    let mut val: ax_nav::CFTypeRef = std::ptr::null();
+    // SAFETY: caller upholds the AXUIElementRef/CFStringRef validity contract.
+    let err = unsafe { ax_nav::AXUIElementCopyAttributeValue(el, attr, &raw mut val) };
+    if err == 0 && !val.is_null() {
+        Some(val)
+    } else {
+        None
+    }
+}
+
+/// Read an AX attribute as a String. Internally copies + releases.
+///
+/// SAFETY: same contract as [`copy_attr`].
+#[allow(unsafe_code, reason = "AXUIElement / CF APIs require raw FFI")]
+unsafe fn attr_string(
+    el: ax_nav::AXUIElementRef,
+    attr: core_foundation::string::CFStringRef,
+) -> Option<String> {
+    // SAFETY: caller upholds the AXUIElementRef/CFStringRef validity contract.
+    let val = unsafe { copy_attr(el, attr) }?;
+    // SAFETY: AX string attributes return CFStringRef.
+    let s = unsafe { core_foundation::string::CFString::wrap_under_create_rule(val.cast()) };
+    Some(s.to_string())
+}
+
+/// Walk the AX tree looking for an AXButton matching `target_id`/`target_subrole`/
+/// `target_desc` (tried in that order — see call site for why). Returns the
+/// element pointer (+1 retained via `CFRetain` at the leaf, so the caller owns
+/// it independently of the parent arrays this function releases as it unwinds).
+///
+/// SAFETY: `el` must be a valid AXUIElementRef and every field of `attrs` a
+/// valid CFStringRef.
+#[allow(unsafe_code, reason = "AXUIElement / CF APIs require raw FFI")]
+unsafe fn find_button(
+    el: ax_nav::AXUIElementRef,
+    target_id: &str,
+    target_subrole: &str,
+    target_desc: &str,
+    attrs: &AxAttrs,
+    depth: u8,
+) -> Option<ax_nav::AXUIElementRef> {
+    if depth == 0 {
+        return None;
+    }
+    // Check if this element is the button we want.
+    // SAFETY: caller upholds the AXUIElementRef/CFStringRef validity contract.
+    if let Some(role_val) = unsafe { copy_attr(el, attrs.role) } {
+        // SAFETY: AXRole is always a CFStringRef.
+        let role_s =
+            unsafe { core_foundation::string::CFString::wrap_under_create_rule(role_val.cast()) }
+                .to_string();
+        // Skip tab-bar elements — AXSplitGroup, AXTabGroup, AXOpaqueProviderGroup,
+        // AXRadioButton — to avoid wasting depth on Safari's 89-tab bar before
+        // reaching the toolbar navigation buttons.
+        let skip = matches!(
+            role_s.as_str(),
+            "AXSplitGroup" | "AXTabGroup" | "AXOpaqueProviderGroup" | "AXRadioButton"
+        );
+        if skip {
+            return None;
+        }
+        if role_s == "AXButton" {
+            // 1. AXIdentifier — locale-independent, preferred.
+            // 2. AXSubrole — locale-independent, set on some Safari versions.
+            // 3. AXDescription — locale-dependent last resort.
+            // SAFETY: caller upholds the AXUIElementRef/CFStringRef validity contract.
+            let matches_target = unsafe { attr_string(el, attrs.identifier) }.as_deref() == Some(target_id)
+                // SAFETY: caller upholds the AXUIElementRef/CFStringRef validity contract.
+                || unsafe { attr_string(el, attrs.subrole) }.as_deref() == Some(target_subrole)
+                // SAFETY: caller upholds the AXUIElementRef/CFStringRef validity contract.
+                || unsafe { attr_string(el, attrs.description) }.as_deref() == Some(target_desc);
+            // CFRetain here (only once, at the leaf) so callers can release the
+            // children arrays without dangling.
+            // SAFETY: el is a valid AXUIElementRef (CF Get Rule applies).
+            return matches_target.then(|| unsafe { ax_nav::CFRetain(el) });
+        }
+    }
+    // Recurse into AXChildren.
+    // SAFETY: caller upholds the AXUIElementRef/CFStringRef validity contract.
+    let children_val = unsafe { copy_attr(el, attrs.children) }?;
+    // Verify it's actually a CFArray before treating it as one.
+    // SAFETY: children_val is a valid, +1-retained CFTypeRef from copy_attr above.
+    let is_array = unsafe { ax_nav::CFGetTypeID(children_val) == ax_nav::CFArrayGetTypeID() };
+    if !is_array {
+        // SAFETY: balance the +1 retain from copy_attr above.
+        unsafe { ax_nav::CFRelease(children_val) };
+        return None;
+    }
+    // SAFETY: children_val was just verified to be a CFArray.
+    let count = unsafe { ax_nav::CFArrayGetCount(children_val) };
+    let mut found: Option<ax_nav::AXUIElementRef> = None;
+    for i in 0..count {
+        // Get Rule — not retained.
+        // SAFETY: children_val is a valid CFArray and i is in bounds.
+        let child = unsafe { ax_nav::CFArrayGetValueAtIndex(children_val, i) };
+        if child.is_null() {
+            continue;
+        }
+        // SAFETY: child is a valid AXUIElementRef (CF Get Rule); attrs fields
+        // are valid CFStringRefs per this function's own contract.
+        if let Some(f) = unsafe {
+            find_button(
+                child,
+                target_id,
+                target_subrole,
+                target_desc,
+                attrs,
+                depth - 1,
+            )
+        } {
+            found = Some(f);
+            break;
+        }
+    }
+    // found is already +1 retained (CFRetain'd at the leaf in the button check
+    // above). Parent frames propagate it without re-retaining. Safe to release
+    // the children array now.
+    // SAFETY: balance the +1 retain from copy_attr above.
+    unsafe { ax_nav::CFRelease(children_val) };
+    found
+}
+
+/// Positional fallback: locate the Back (idx=0) or Forward (idx=1) button by
+/// structure rather than by attribute text. The Safari toolbar layout is:
+///   AXWindow → AXToolbar → AXGroup[1] → AXGroup[0] → AXButton[0/1]
+/// This is locale-independent and works when no AX attribute names the button.
+///
+/// SAFETY: `win` must be a valid AXUIElementRef and `attr_role`/`attr_children`
+/// valid CFStringRefs.
+#[allow(unsafe_code, reason = "AXUIElement / CF APIs require raw FFI")]
+unsafe fn find_nav_button_by_position(
+    win: ax_nav::AXUIElementRef,
+    forward: bool,
+    attr_role: core_foundation::string::CFStringRef,
+    attr_children: core_foundation::string::CFStringRef,
+) -> Option<ax_nav::AXUIElementRef> {
+    use ax_nav::{CFArrayGetCount, CFArrayGetValueAtIndex, CFRelease, CFRetain, CFTypeRef};
+    use core_foundation::string::CFString;
+
+    // SAFETY: all raw AX/CF calls below follow the CF memory rules documented
+    // on the sibling `find_button` — this whole body is one unsafe operation,
+    // wrapped once rather than call-by-call.
+    unsafe {
+        // Helper: get children as a raw CFArray (caller must CFRelease)
+        let children_of = |el: ax_nav::AXUIElementRef| -> Option<CFTypeRef> {
+            let mut val: CFTypeRef = std::ptr::null();
+            let err = ax_nav::AXUIElementCopyAttributeValue(el, attr_children, &raw mut val);
+            if err == 0 && !val.is_null() {
+                Some(val)
+            } else {
+                None
+            }
+        };
+        let role_of = |el: ax_nav::AXUIElementRef| -> Option<String> {
+            let mut val: CFTypeRef = std::ptr::null();
+            let err = ax_nav::AXUIElementCopyAttributeValue(el, attr_role, &raw mut val);
+            if err != 0 || val.is_null() {
+                return None;
+            }
+            Some(CFString::wrap_under_create_rule(val.cast()).to_string())
+        };
+        let child_at = |arr: CFTypeRef, idx: isize| -> Option<CFTypeRef> {
+            if CFArrayGetCount(arr) <= idx {
+                return None;
+            }
+            let c = CFArrayGetValueAtIndex(arr, idx);
+            if c.is_null() { None } else { Some(c) }
+        };
+
+        // AXWindow children: find AXToolbar. `child_at` returns a Get-Rule
+        // pointer owned by the array it was read from — retain it before
+        // releasing that array, or the element can be deallocated along
+        // with it, leaving a dangling pointer for every use below.
+        let win_kids = children_of(win)?;
+        let count = CFArrayGetCount(win_kids);
+        let mut toolbar: Option<CFTypeRef> = None;
+        for i in 0..count {
+            if let Some(c) = child_at(win_kids, i)
+                && role_of(c).as_deref() == Some("AXToolbar")
+            {
+                toolbar = Some(CFRetain(c));
+                break;
+            }
+        }
+        CFRelease(win_kids);
+        let toolbar = toolbar?;
+
+        // AXToolbar children: skip AXGroups until we find the nav group (the
+        // group whose first child is itself an AXGroup containing buttons).
+        let tb_kids = children_of(toolbar)?;
+        CFRelease(toolbar);
+        let tb_count = CFArrayGetCount(tb_kids);
+        let mut nav_group: Option<CFTypeRef> = None;
+        for i in 0..tb_count {
+            if let Some(g) = child_at(tb_kids, i) {
+                if role_of(g).as_deref() != Some("AXGroup") {
+                    continue;
+                }
+                // Check if its first child is also an AXGroup (the inner nav group)
+                if let Some(inner_kids) = children_of(g) {
+                    let has_inner =
+                        child_at(inner_kids, 0).and_then(role_of).as_deref() == Some("AXGroup");
+                    CFRelease(inner_kids);
+                    if has_inner {
+                        nav_group = Some(CFRetain(g));
+                        break;
+                    }
+                }
+            }
+        }
+        CFRelease(tb_kids);
+        let nav_group = nav_group?;
+
+        // nav_group → first AXGroup child → AXButton[0 or 1]
+        let ng_kids = children_of(nav_group)?;
+        CFRelease(nav_group);
+        let inner = child_at(ng_kids, 0).map(|c| CFRetain(c));
+        CFRelease(ng_kids);
+        let inner = inner?;
+
+        let inner_kids = children_of(inner)?;
+        CFRelease(inner);
+        let btn_idx = isize::from(forward);
+        let btn = child_at(inner_kids, btn_idx).map(|c| CFRetain(c));
+        CFRelease(inner_kids);
+        let btn = btn?;
+
+        // btn is already +1 retained (above) to survive inner_kids' release —
+        // return it as-is on match, or release it before failing out.
+        if role_of(btn).as_deref() == Some("AXButton") {
+            Some(btn)
+        } else {
+            CFRelease(btn);
+            None
+        }
+    }
+}
+
+/// Press the Back (`forward=false`) or Forward (`forward=true`) navigation
+/// button in the frontmost application via the Accessibility API.
+///
+/// Safari's WKWebView ignores synthetic `CGEvent` mouse-button and keyboard
+/// events posted at the HID or Session tap levels. However it does respond
+/// correctly to `AXPress` on its toolbar's "Go back" / "Go forward" button,
+/// because that path goes through AppKit's normal action dispatch rather than
+/// the input event pipeline.
+///
+/// Returns `true` when an AX button was found and pressed (result `kAXErrorSuccess`),
+/// `false` on any failure — the caller should fall back to a keyboard shortcut.
+#[allow(unsafe_code, reason = "AXUIElement / CF APIs require raw FFI")]
+pub(super) fn ax_browser_navigate(forward: bool, pid: Option<i32>) -> bool {
+    use objc2::rc::autoreleasepool;
+    use objc2_app_kit::NSWorkspace;
+
+    use core_foundation::string::CFString;
+
+    let attr_focused_window = CFString::new("AXFocusedWindow");
+    let attr_children = CFString::new("AXChildren");
+    let attr_role = CFString::new("AXRole");
+    let attr_description = CFString::new("AXDescription");
+    let attr_identifier = CFString::new("AXIdentifier");
+    let attr_subrole = CFString::new("AXSubrole");
+    let ax_press = CFString::new("AXPress");
+    // AXIdentifier is locale-independent (Safari sets these stable IDs on its
+    // toolbar navigation buttons). Description ("Go back"/"Go forward") is
+    // locale-dependent and will fail on non-English systems.
+    let target_identifier = if forward {
+        "BackForwardToolbarButton_Forward"
+    } else {
+        "BackForwardToolbarButton_Back"
+    };
+    // AXSubrole is also locale-independent and may be set on some Safari versions.
+    let target_subrole = if forward {
+        "AXBackForwardButtonForward"
+    } else {
+        "AXBackForwardButtonBack"
+    };
+    // Last-resort English description fallback for older Safari/macOS versions.
+    let target_desc_en = if forward { "Go forward" } else { "Go back" };
+
+    autoreleasepool(|_| {
+        let resolved_pid = if let Some(p) = pid {
+            p
+        } else {
+            NSWorkspace::sharedWorkspace()
+                .frontmostApplication()?
+                .processIdentifier()
+        };
+        // SAFETY: returns +1 retained AXUIElement.
+        let app_ax = unsafe { ax_nav::AXUIElementCreateApplication(resolved_pid) };
+        if app_ax.is_null() {
+            return None::<()>;
+        }
+
+        // Get focused window (+1 retained).
+        // SAFETY: app_ax was just verified non-null; attr_focused_window is a valid CFStringRef.
+        let win = unsafe { copy_attr(app_ax, attr_focused_window.as_concrete_TypeRef()) };
+        // SAFETY: balance +1 from AXUIElementCreateApplication.
+        unsafe { ax_nav::CFRelease(app_ax) };
+        let win = win?;
+
+        let attrs = AxAttrs {
+            role: attr_role.as_concrete_TypeRef(),
+            description: attr_description.as_concrete_TypeRef(),
+            identifier: attr_identifier.as_concrete_TypeRef(),
+            subrole: attr_subrole.as_concrete_TypeRef(),
+            children: attr_children.as_concrete_TypeRef(),
+        };
+        // Find the nav button (borrowed pointer inside the window's tree).
+        // SAFETY: win is a valid AXUIElementRef; attrs fields are valid CFStringRefs.
+        let button = unsafe { find_button(win, target_identifier, target_subrole, target_desc_en, &attrs, 6) }
+            // Positional fallback: if identifier/subrole/description all failed
+            // (e.g. non-English Safari without AXIdentifier), find the nav group
+            // by structure — second AXGroup of AXToolbar, first sub-group, then
+            // pick button 0 (back) or button 1 (forward).
+            // SAFETY: win is a valid AXUIElementRef; attrs fields are valid CFStringRefs.
+            .or_else(|| unsafe { find_nav_button_by_position(win, forward, attrs.role, attrs.children) });
+
+        let result = button.map(|btn| {
+            // SAFETY: btn is a +1 retained AXUIElement (CFRetain'd by find_button
+            // or find_nav_button_by_position).
+            let r = unsafe { ax_nav::AXUIElementPerformAction(btn, ax_press.as_concrete_TypeRef()) };
+            // SAFETY: balance the CFRetain from find_button/find_nav_button_by_position.
+            unsafe { ax_nav::CFRelease(btn) };
+            r == ax_nav::AX_ERROR_SUCCESS
+        });
+
+        // SAFETY: balance +1 from copy_attr (focused window).
+        unsafe { ax_nav::CFRelease(win) };
+
+        match result {
+            Some(true) => {
+                tracing::debug!(forward, "AX browser navigate succeeded");
+                Some(())
+            }
+            Some(false) => {
+                tracing::debug!(forward, "AX browser navigate: AXPress failed");
+                None
+            }
+            None => {
+                tracing::debug!(forward, "AX browser navigate: button not found");
+                None
+            }
+        }
+    })
+    .is_some()
+}
+
 use dock::{app_expose, launchpad, mission_control, show_desktop};
 use symbolic_hotkey::{next_desktop, previous_desktop};
 
diff --git a/crates/openlogi-inject/src/inject/windows.rs b/crates/openlogi-inject/src/inject/windows.rs
index 74c74536ebb0e175091304ca1ff1daa71e5ddc29..8a98abcb36739c48f18fe2319cccd607826d7aa2 100644
--- a/crates/openlogi-inject/src/inject/windows.rs
+++ b/crates/openlogi-inject/src/inject/windows.rs
@@ -10,7 +10,7 @@ use windows_sys::Win32::UI::Input::KeyboardAndMouse::{
     MOUSEEVENTF_XUP, MOUSEINPUT, SendInput,
 };
 
-use openlogi_core::binding::{Action, KeyCombo};
+use openlogi_core::binding::{Action, KeyCombo, WorkflowStep};
 
 const WHEEL_DELTA: i32 = 120;
 
@@ -107,6 +107,12 @@ pub(super) fn execute(action: &Action) {
         Action::Screenshot | Action::CaptureRegion => {
             post_key(VK_S, &[VK_LWIN, VK_SHIFT]);
         }
+        // Suspending reliably needs `SetSuspendState` (powrprof.dll), which
+        // hibernates instead when hibernation is enabled — no clean win from
+        // a background agent, so the action is skipped on Windows for now.
+        Action::Sleep => {
+            tracing::debug!("Sleep has no Windows synthesis yet — action skipped");
+        }
         Action::PlayPause => post_key(VK_MEDIA_PLAY_PAUSE, &[]),
         Action::NextTrack => post_key(VK_MEDIA_NEXT_TRACK, &[]),
         Action::PrevTrack => post_key(VK_MEDIA_PREV_TRACK, &[]),
@@ -124,10 +130,54 @@ pub(super) fn execute(action: &Action) {
         | Action::HorizontalScrollLeft
         | Action::HorizontalScrollRight => post_scroll(action),
         Action::CustomShortcut(combo) => post_custom_shortcut(combo),
+        Action::TypeText(text) => {
+            tracing::warn!(
+                chars = text.chars().count(),
+                "TypeText injection is not implemented on Windows yet"
+            );
+        }
+        Action::RunAppleScript(_) => {
+            tracing::warn!("RunAppleScript is only supported on macOS");
+        }
+        Action::RunShellCommand(cmd) => run_shell_command_async(cmd.clone()),
+        Action::Workflow(steps) => run_workflow_async(steps.clone()),
         Action::None => {}
     }
 }
 
+fn run_shell_command_async(cmd: String) {
+    std::thread::spawn(move || run_shell_command(&cmd));
+}
+
+fn run_workflow_async(steps: Vec<WorkflowStep>) {
+    std::thread::spawn(move || run_workflow(&steps));
+}
+
+fn run_workflow(steps: &[WorkflowStep]) {
+    for step in steps {
+        match step {
+            WorkflowStep::TypeText(text) => {
+                tracing::warn!(
+                    chars = text.chars().count(),
+                    "workflow TypeText injection is not implemented on Windows yet"
+                );
+            }
+            WorkflowStep::PressKey(combo) => post_custom_shortcut(combo),
+            WorkflowStep::Delay { millis } => {
+                std::thread::sleep(std::time::Duration::from_millis(*millis));
+            }
+            WorkflowStep::RunAppleScript(_) => {
+                tracing::warn!("workflow RunAppleScript is only supported on macOS");
+            }
+            WorkflowStep::RunShellCommand(cmd) => run_shell_command(cmd),
+        }
+    }
+}
+
+fn run_shell_command(cmd: &str) {
+    let _ = std::process::Command::new("cmd").args(["/C", cmd]).output();
+}
+
 fn post_click(button: MouseButton) {
     let (down, up, data) = match button {
         MouseButton::Left => (MOUSEEVENTF_LEFTDOWN, MOUSEEVENTF_LEFTUP, 0),
diff --git a/crates/openlogi-inject/src/lib.rs b/crates/openlogi-inject/src/lib.rs
index 347b7605fca859f6e7c7e52e752c9c3c64892f93..ed56d01bf438dfc1fd8b3afb0efac5a191de8d30 100644
--- a/crates/openlogi-inject/src/lib.rs
+++ b/crates/openlogi-inject/src/lib.rs
@@ -2,7 +2,7 @@
 
 mod inject;
 
-pub use inject::{SYNTHETIC_EVENT_USER_DATA, execute, post_horizontal_scroll};
+pub use inject::{SYNTHETIC_EVENT_USER_DATA, ax_navigate_browser, execute, post_horizontal_scroll};
 
 #[cfg(target_os = "linux")]
 pub use inject::action_device_path;
diff --git a/devenv.nix b/devenv.nix
index 2dcfccba301f74f1ae2f5262eaecf8fdd0ca7eb3..0418321c1e5c788d9c33b9f98c9b8adf56e16d87 100644
--- a/devenv.nix
+++ b/devenv.nix
@@ -88,11 +88,15 @@ in
       '';
     };
     "openlogi:i18n-upload" = {
-      description = "Upload English source strings to Crowdin.";
-      exec = "crowdin upload sources";
+      description = "Upload en.yml sources and per-language translations to Crowdin.";
+      exec = ''
+        set -e
+        crowdin upload sources
+        crowdin upload translations
+      '';
     };
     "openlogi:i18n-download" = {
-      description = "Download translated locale files from Crowdin.";
+      description = "Download per-language translations from Crowdin and run i18n tests.";
       exec = ''
         set -e
         ${requireXcodeMetal}
diff --git a/docs/CONFIGURATION.md b/docs/CONFIGURATION.md
index 6afa4162ba7b307371ec95f0f985914fd08a7f0f..9ccac4461db0dce0a14ea3e17de212eeb3f31c2e 100644
--- a/docs/CONFIGURATION.md
+++ b/docs/CONFIGURATION.md
@@ -30,8 +30,20 @@ MX Master 4):
   without changing the system trackpad direction.
 - `lighting` — static RGB colour, brightness (0–100), and on/off for wired
   RGB keyboards.
+- `light` — standalone-light power, normalized brightness, and temperature.
+  Set `auto_camera = true` on macOS to turn the light on while any camera is in
+  use and off when camera use stops; the manual power preference and the other
+  light settings remain independent.
 - `gesture_owner` — which button owns the gesture role, when chosen
   explicitly (otherwise inferred).
+- `host_switch_targets` — on a compatible keyboard, physical config keys of
+  mice that should follow its Easy-Switch channel. Both devices must already
+  be paired on corresponding channels. The keyboard's host controls and every
+  target must expose the HID++ features needed for host switching. Configure
+  the link on every computer from which the keyboard may initiate a switch.
+- `fn_lock` — keyboards only: `true` makes the F-row send F1–F12 without
+  holding Fn, `false` keeps the printed media/shortcut functions. Absent
+  means the keyboard's own state is left alone. Re-applied on reconnect.
 
 The app-wide `[app_settings]` block holds `launch_at_login`,
 `check_for_updates`, and `auto_install_updates` (all off by default);
@@ -66,6 +78,12 @@ appearance = "system"
 [devices.2b042]
 dpi_presets = [800, 1600, 3200]
 
+# Put this on the keyboard's physical device entry. Values are the physical
+# keys of the mice that should follow it; use the exact keys already present
+# under [devices] in your generated config.
+[devices."receiver:aabbccdd:slot:1"]
+host_switch_targets = ["receiver:aabbccdd:slot:2"]
+
 [devices.2b042.bindings]
 Back = "BrowserBack"
 Forward = "BrowserForward"
@@ -86,6 +104,31 @@ Back = "Undo"
 enabled = true
 color = "ff0000"
 brightness = 80
+
+# Keyboard F-row keys (Signature-series layout): a bound key is diverted
+# over HID++ and dispatches its action; an unbound key keeps its native
+# firmware function. Key names: KeySearch, KeyDictation, KeyEmoji,
+# KeyScreenCapture, KeyMicMute, KeyPlayPause, KeyMute, KeyVolumeDown,
+# KeyVolumeUp.
+[devices.2b372]
+fn_lock = false
+
+[devices.2b372.bindings]
+KeySearch = "MissionControl"
+KeyScreenCapture = "Sleep"
+
+# Standalone light (for example, a Litra Glow). The GUI writes this block under
+# the serial-backed physical key; `openlogi light list` shows its HID tuple and
+# identity when diagnosing discovery.
+# A serial-bearing Litra key looks like:
+# [devices."raw:046d:c900:ff43:0202:serial:YOUR-SERIAL".light]
+# If the HID backend exposes only a transient OS-node identity, OpenLogi does
+# not persist that key; reconnect persistence then requires a device serial.
+[devices."<raw-device-key>".light]
+enabled = true
+auto_camera = true
+brightness_percent = 65
+temperature_kelvin = 4600
 ```
 
 Action names are the catalog's variant names (`LeftClick`, `MouseBack`,
diff --git a/docs/DECISIONS.md b/docs/DECISIONS.md
index d060866af01e556282f0ab6925f92aa761b41736..b0c5d7367cccc543c6e6149e1591c7209e4be519 100644
--- a/docs/DECISIONS.md
+++ b/docs/DECISIONS.md
@@ -4,6 +4,23 @@ Durable "why we did it this way" records that are not obvious from the code.
 Add a dated entry when a non-obvious architectural or dependency decision is
 made or revisited.
 
+## 2026-08: Standalone raw-light boundary
+
+Standalone lights such as Litra stay outside the HID++ receiver/paired-device
+model and are normalized only at the shared agent and GUI device-record
+boundary. This keeps the existing HID++ wire and routing semantics unchanged
+while allowing future light drivers to share capability-driven controls.
+
+- Persist brightness as a normalized percentage and temperature as Kelvin;
+  native units and report encoding remain driver responsibilities.
+- Use device serials for persistent raw-device keys. OS-node identifiers are
+  runtime-only hints and must not silently become physical configuration keys.
+- Advertise optional light controls through `LightCapabilities`; the GUI gates
+  controls from those capabilities rather than from `DeviceKind::Light`.
+- Serialize and coalesce per-device light writes in the agent so reconnect,
+  camera automation, config reload, and manual commands cannot interleave at
+  packet level.
+
 ## 2026-07: Infrastructure we keep custom instead of using a crate
 
 A dependency audit replaced most general-purpose infrastructure code with
diff --git a/docs/DEVELOPMENT.md b/docs/DEVELOPMENT.md
index f96b1a0088b82b524caf70b5ddd3de7640caacc5..85168f6e7976368356eedd4d373c9985d4c48bc6 100644
--- a/docs/DEVELOPMENT.md
+++ b/docs/DEVELOPMENT.md
@@ -63,8 +63,8 @@ expose `libSystem` the way Apple's real linker wants.
 
 On macOS the desktop binary is launched from inside a throwaway
 `target/dev/OpenLogi.app` — a Cargo `runner` wired in `.cargo/config.toml`
-(`scripts/cargo-run-macos.sh`). This makes the dev build show the real
-**OpenLogi** name in the menu bar and the app icon in the Dock; a bare
+(`scripts/cargo-run-macos.sh`). This makes the dev build show as
+**OpenLogi Dev** in the menu bar and Dock, with the real app icon; a bare
 `cargo run` binary has no bundle, so macOS would otherwise fall back to the
 `openlogi-gui` executable name and a generic icon. The binary is hardlinked in
 (no copy) and the icon is generated on demand by
@@ -72,6 +72,13 @@ On macOS the desktop binary is launched from inside a throwaway
 everything else (the CLI, tests); set
 `OPENLOGI_DEV_BUNDLE=0` to launch the raw `openlogi-gui` binary instead.
 
+Packaged local dev bundles (`cargo run` and
+`cargo run -p xtask -- macos bundle`) use `.dev` bundle identifiers and the
+`openlogi-dev` XDG profile (`~/.config/openlogi-dev`,
+`~/.local/share/openlogi-dev`, and its own `agent.sock`). That keeps the dev
+GUI and agent from sharing the installed production app's Accessibility grant,
+single-instance lock, config, or IPC socket.
+
 To install the CLI binary on `PATH`:
 
 ```sh
@@ -190,11 +197,34 @@ cargo run -p xtask -- release latest-json \
 
 ## Crowdin translation sync
 
-`.github/workflows/crowdin.yml` uploads `crates/openlogi-gui/locales/en.yml` to
+`.github/workflows/crowdin.yml` syncs GUI locales with
 [Crowdin](https://crowdin.com/project/openlogi) and opens a `crowdin/i18n` PR
-with fresh translations — nightly, and on master pushes touching the source
-strings. `crowdin.yml` limits exports to the locales shipped by the app and
-maps Crowdin language identifiers to their repository filenames.
+when downloads change something — nightly, and on master pushes that touch
+English sources (`en.yml`), `crowdin.yml`, the Crowdin workflow, or the shared
+GitHub App token action.
+
+**How it helps translation**
+
+| | Role |
+|--|--|
+| `en.yml` (git) | English source of truth — add new UI strings here only |
+| Per-language `locales/*.yml` in git | Seeded into Crowdin so existing de/ja/… work is not lost |
+| Crowdin project | Where people translate and improve each language |
+| Bot PR (`crowdin/i18n`) | Brings Crowdin’s per-language progress back into the repo |
+
+Do not treat every feature PR as “edit all 19 locale files.” New copy goes in
+`en.yml`; Crowdin + this job handle the rest. Untranslated keys may still match
+English until someone translates them in Crowdin — that is incomplete work, not
+“remove language support.”
+
+Each run:
+
+1. Uploads `en.yml` **sources**.
+2. Uploads **per-language translations** already in git (`import_eq_suggestions`
+   off so `value == English` is not stored as a finished translation).
+3. Downloads Crowdin’s export for configured languages (`export_languages` /
+   `languages_mapping` in `crowdin.yml`).
+4. Opens/updates `crowdin/i18n` when the catalogs differ.
 
 Like the release workflow, the job reads its credentials from one 1Password
 item referenced by the GitHub secret `OP_CROWDIN_SECRET_ITEM`. The item must
@@ -212,7 +242,20 @@ OpenLogi project:
 - Translations — Read and Write.
 
 Missing or invalid credentials fail the workflow. Translation PRs run the
-normal CI checks, including the locale key-parity test. The workflow uses the
-existing `OP_GITHUB_APP_ITEM` to mint a short-lived token for pushing its
-translation branch and opening the PR; the default `GITHUB_TOKEN` remains
-read-only.
+normal CI checks, including the locale key test (non-English keys must be a
+subset of `en.yml`; catalogs may lag until Crowdin fills them). The workflow
+uses the existing `OP_GITHUB_APP_ITEM` to mint a short-lived token for pushing
+its translation branch and opening the PR; the default `GITHUB_TOKEN` remains
+read-only. Checkout runs with `persist-credentials: false` and the origin
+remote is rewritten to the app token so git push does not inherit the
+read-only Actions credential.
+
+Feature work only needs `en.yml`. Do not hand-edit every locale file for a new
+string — Crowdin + this workflow own non-English updates.
+
+Local helpers (with Crowdin credentials configured):
+
+```sh
+devenv tasks run openlogi:i18n-upload    # en.yml sources + per-language translations
+devenv tasks run openlogi:i18n-download  # download locales + i18n tests
+```
diff --git a/docs/INSTALL-linux.md b/docs/INSTALL-linux.md
index ee4f0144040f681468a99a56748477f500cf3dbf..a8fa8b3e3ee4338c68234a998099a27250452f3e 100644
--- a/docs/INSTALL-linux.md
+++ b/docs/INSTALL-linux.md
@@ -41,7 +41,11 @@ OpenLogi needs:
 - **Write access to `/dev/uinput`** — to create the virtual input device for
   button remapping.
 - **Read/write access to `/dev/hidraw*`** — to send HID++ commands to the Bolt
-  receiver.
+  receiver, or to the device itself when it is paired over Bluetooth.
+- **Read access to the mouse's `/dev/input/event*` node** — the hook grabs the
+  pointer there to capture button presses. Bluetooth mice need the bundled rule
+  for this: their event node hangs off `/devices/virtual/misc/uhid`, which has
+  no seat, so `logind` never grants the ACL on its own.
 
 Install the bundled udev rules to grant access to the active-seat user without
 requiring `sudo` or group membership (requires `systemd-logind`):
@@ -61,6 +65,11 @@ openlogi-agent --check-uinput 2>/dev/null || \
 
 # Check a hidraw node
 ls -la /dev/hidraw*
+
+# Check the mouse's event node — look for a "+" (ACL) in the mode, or your
+# user in the ACL itself. Without it the agent logs
+# "could not install OS mouse hook".
+getfacl /dev/input/event*
 ```
 
 The GUI Settings → Permissions page shows a live `Granted` / `Not granted`
diff --git a/docs/superpowers/plans/2026-06-29-mouse-buttons-6-9.md b/docs/superpowers/plans/2026-06-29-mouse-buttons-6-9.md
new file mode 100644
index 0000000000000000000000000000000000000000..c9974608b3397ec15221f4c26e129a888ee73b6e
--- /dev/null
+++ b/docs/superpowers/plans/2026-06-29-mouse-buttons-6-9.md
@@ -0,0 +1,410 @@
+# Mouse Buttons 6–9 Implementation Plan
+
+> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
+
+**Goal:** Add four pickable actions (`MouseButton6`–`MouseButton9`) that synthesize mouse buttons 6–9 on macOS and Linux, surfaced in the action picker under the MOUSE section.
+
+**Architecture:** Pure data-driven addition. The `Action` enum in `openlogi-core` is the single source of truth — the GUI picker, category grouping, TOML schema, and per-platform injection all derive from it. Four new unit variants mirror the existing `MouseBack`/`MouseForward` pattern. On macOS the existing `post_other_button(n)` already accepts any button number; on Linux the evdev `BTN_*` family covers it; on Windows `SendInput` caps at button 5, so 6–9 log-and-skip there (documented gap, same pattern as existing platform-limited actions).
+
+**Tech Stack:** Rust (workspace), serde/TOML for config, GPUI for the GUI, core-graphics / evdev / windows-sys for injection, rust-i18n for locale strings.
+
+**Spec:** `docs/superpowers/specs/2026-06-29-mouse-buttons-6-9-design.md`
+
+---
+
+## File Structure
+
+| File | Responsibility | Change |
+|---|---|---|
+| `crates/openlogi-core/src/binding.rs` | The `Action` enum + `label()`/`category()`/`catalog()` | Add 4 variants + their 3 match arms + extend 2 tests |
+| `crates/openlogi-inject/src/inject.rs` | Per-platform `Action` → OS event synthesis | Add arms in `execute_macos` / `execute_linux` / `execute_windows` |
+| `crates/openlogi-gui/src/mouse_model/picker.rs` | Picker icon mapping (exhaustive `match`) | Add 4 arms (compiler-forced) |
+| `crates/openlogi-gui/locales/*.yml` (20 files) | i18n translation keys, keyed by English label | Add `"Button 6"`–`"Button 9"` keys after line 147 |
+
+No new files. The exhaustive `match` arms across the codebase are the safety net — the compiler refuses to build if any variant is missed.
+
+---
+
+## Task 1: Add the `Action` variants and core metadata
+
+This task adds the four variants and threads them through `label()`, `category()`, and `catalog()`. Tests fail first, then pass.
+
+**Files:**
+- Modify: `crates/openlogi-core/src/binding.rs`
+
+- [ ] **Step 1: Write the failing test (extend `category_mouse_variants`)**
+
+In `crates/openlogi-core/src/binding.rs`, find the test at line ~1346 and replace it:
+
+```rust
+    #[test]
+    fn category_mouse_variants() {
+        assert_eq!(Action::LeftClick.category(), Category::Mouse);
+        assert_eq!(Action::RightClick.category(), Category::Mouse);
+        assert_eq!(Action::MiddleClick.category(), Category::Mouse);
+        assert_eq!(Action::MouseBack.category(), Category::Mouse);
+        assert_eq!(Action::MouseForward.category(), Category::Mouse);
+        assert_eq!(Action::MouseButton6.category(), Category::Mouse);
+        assert_eq!(Action::MouseButton7.category(), Category::Mouse);
+        assert_eq!(Action::MouseButton8.category(), Category::Mouse);
+        assert_eq!(Action::MouseButton9.category(), Category::Mouse);
+    }
+```
+
+- [ ] **Step 2: Add a label test (append to the `#[cfg(test)] mod tests` block, after `category_mouse_variants`)**
+
+```rust
+    #[test]
+    fn extra_mouse_button_labels() {
+        assert_eq!(Action::MouseButton6.label(), "Button 6");
+        assert_eq!(Action::MouseButton7.label(), "Button 7");
+        assert_eq!(Action::MouseButton8.label(), "Button 8");
+        assert_eq!(Action::MouseButton9.label(), "Button 9");
+    }
+```
+
+- [ ] **Step 3: Run the tests to verify they fail**
+
+Run: `cargo test -p openlogi-core --lib binding::tests::category_mouse_variants binding::tests::extra_mouse_button_labels`
+Expected: FAIL with `cannot find variant MouseButton6` (and 7/8/9) — compile error.
+
+- [ ] **Step 4: Add the four variants to the `Action` enum**
+
+In `crates/openlogi-core/src/binding.rs`, find the `MouseForward` variant (line ~371) and add the four new variants immediately after it, before the `// ── Editing ───` comment:
+
+```rust
+    /// Mouse "forward" side button (extra button 5). Native counterpart to
+    /// [`Action::MouseBack`]; see [`Action::BrowserForward`] for the ⌘] form.
+    MouseForward,
+    /// Extra mouse button 6. Emitted as the real button-6 event for apps, games,
+    /// and CAD software that bind it. macOS/Linux only — Windows `SendInput`
+    /// caps at button 5, so this logs-and-skips there.
+    MouseButton6,
+    /// Extra mouse button 7. See [`Action::MouseButton6`].
+    MouseButton7,
+    /// Extra mouse button 8. See [`Action::MouseButton6`].
+    MouseButton8,
+    /// Extra mouse button 9. See [`Action::MouseButton6`].
+    MouseButton9,
+```
+
+- [ ] **Step 5: Add the four labels to `Action::label()`**
+
+In the `label()` match (around line ~686, after the `MouseForward` arm), add:
+
+```rust
+            Action::MouseForward => "Forward (Button 5)".into(),
+            Action::MouseButton6 => "Button 6".into(),
+            Action::MouseButton7 => "Button 7".into(),
+            Action::MouseButton8 => "Button 8".into(),
+            Action::MouseButton9 => "Button 9".into(),
+```
+
+- [ ] **Step 6: Add the four to `Action::category()`**
+
+In the `category()` match (around line ~737), extend the existing Mouse arm:
+
+```rust
+            Action::LeftClick
+            | Action::RightClick
+            | Action::MiddleClick
+            | Action::MouseBack
+            | Action::MouseForward
+            | Action::MouseButton6
+            | Action::MouseButton7
+            | Action::MouseButton8
+            | Action::MouseButton9 => Category::Mouse,
+```
+
+- [ ] **Step 7: Add the four to `Action::catalog()`**
+
+In the `catalog()` vec (around line ~793, after `Action::MouseForward`), add:
+
+```rust
+            // Mouse
+            Action::LeftClick,
+            Action::RightClick,
+            Action::MiddleClick,
+            Action::MouseBack,
+            Action::MouseForward,
+            Action::MouseButton6,
+            Action::MouseButton7,
+            Action::MouseButton8,
+            Action::MouseButton9,
+```
+
+- [ ] **Step 8: Run the tests to verify they pass**
+
+Run: `cargo test -p openlogi-core --lib binding`
+Expected: PASS — `category_mouse_variants`, `extra_mouse_button_labels`, and `all_catalog_variants_roundtrip_toml` (which iterates `catalog()`) all pass.
+
+- [ ] **Step 9: Commit**
+
+```bash
+git add crates/openlogi-core/src/binding.rs
+git commit -m "feat(core): add MouseButton6-9 actions to the binding vocabulary"
+```
+
+---
+
+## Task 2: Inject the buttons on macOS
+
+macOS already has `post_other_button(n)` which stamps `MOUSE_EVENT_BUTTON_NUMBER`. Buttons 6–9 map to numbers 5–8 (0-indexed: Back=3, Forward=4).
+
+**Files:**
+- Modify: `crates/openlogi-inject/src/inject.rs` (the `execute_macos` function, around line 186–187)
+
+- [ ] **Step 1: Add the macOS injection arms**
+
+Find the macOS extra-button arms (line ~186–187):
+
+```rust
+        Action::MouseBack => macos::post_other_button(3),
+        Action::MouseForward => macos::post_other_button(4),
+```
+
+Add immediately after them:
+
+```rust
+        Action::MouseBack => macos::post_other_button(3),
+        Action::MouseForward => macos::post_other_button(4),
+        // Buttons 6–9 (button numbers 5–8, 0-indexed). Same path as 4/5 —
+        // post_other_button stamps MOUSE_EVENT_BUTTON_NUMBER to address any
+        // button ≥ 3.
+        Action::MouseButton6 => macos::post_other_button(5),
+        Action::MouseButton7 => macos::post_other_button(6),
+        Action::MouseButton8 => macos::post_other_button(7),
+        Action::MouseButton9 => macos::post_other_button(8),
+```
+
+- [ ] **Step 2: Verify the macOS build compiles**
+
+Run: `cargo build -p openlogi-inject`
+Expected: BUILD SUCCEEDS (on macOS the `execute_macos` arms are the ones compiled).
+
+- [ ] **Step 3: Commit**
+
+```bash
+git add crates/openlogi-inject/src/inject.rs
+git commit -m "feat(inject): synthesize mouse buttons 6-9 on macOS"
+```
+
+---
+
+## Task 3: Inject the buttons on Linux
+
+evdev 0.13.2 exposes `BTN_BACK`, `BTN_FORWARD`, `BTN_TASK`, and `BTN_0` as `KeyCode` constants. These are the conventional codes for extra mouse buttons beyond the side pair.
+
+**Files:**
+- Modify: `crates/openlogi-inject/src/inject.rs` (the `execute_linux` function, around line 77–78)
+
+- [ ] **Step 1: Add the Linux injection arms**
+
+Find the Linux extra-button arms (line ~77–78):
+
+```rust
+        Action::MouseBack => linux::click(KeyCode::BTN_SIDE),
+        Action::MouseForward => linux::click(KeyCode::BTN_EXTRA),
+```
+
+Add immediately after them:
+
+```rust
+        Action::MouseBack => linux::click(KeyCode::BTN_SIDE),
+        Action::MouseForward => linux::click(KeyCode::BTN_EXTRA),
+        // Buttons 6–9 use the evdev extra-button codes beyond the side pair.
+        Action::MouseButton6 => linux::click(KeyCode::BTN_FORWARD),
+        Action::MouseButton7 => linux::click(KeyCode::BTN_BACK),
+        Action::MouseButton8 => linux::click(KeyCode::BTN_TASK),
+        Action::MouseButton9 => linux::click(KeyCode::BTN_0),
+```
+
+- [ ] **Step 2: Verify it compiles on Linux (cross-check)**
+
+This is a `#[cfg(target_os = "linux")]` block. On macOS it won't be compiled, so to verify the `KeyCode::BTN_*` constants resolve, run a Linux target check:
+
+Run: `cargo check -p openlogi-inject --target x86_64-unknown-linux-gnu`
+Expected: If the target is installed, CHECK SUCCEEDS. If not installed, this step is skipped — the constant names (`BTN_FORWARD`/`BTN_BACK`/`BTN_TASK`/`BTN_0`) are confirmed present in evdev 0.13.2 (see spec's button-number table), and CI will catch any mismatch on Linux.
+
+- [ ] **Step 3: Commit**
+
+```bash
+git add crates/openlogi-inject/src/inject.rs
+git commit -m "feat(inject): synthesize mouse buttons 6-9 on Linux via evdev BTN_*"
+```
+
+---
+
+## Task 4: Log-and-skip on Windows
+
+Windows `SendInput` mouse input carries flags for buttons 1–5 only; there is no flag for button 6+. The codebase's established pattern for "no platform equivalent" is a `tracing::debug!` log and skip (see the macOS-only navigation actions at `inject.rs:104`). Mirror that.
+
+**Files:**
+- Modify: `crates/openlogi-inject/src/inject.rs` (the `execute_windows` function, around line 290–291)
+
+- [ ] **Step 1: Add the Windows log-and-skip arms**
+
+Find the Windows extra-button arms (line ~290–291):
+
+```rust
+        Action::MouseBack => windows::post_click(windows::MouseButton::Back),
+        Action::MouseForward => windows::post_click(windows::MouseButton::Forward),
+```
+
+Add immediately after them:
+
+```rust
+        Action::MouseBack => windows::post_click(windows::MouseButton::Back),
+        Action::MouseForward => windows::post_click(windows::MouseButton::Forward),
+        // Windows SendInput carries flags for buttons 1–5 only; there is no
+        // flag for button 6+, so these log-and-skip (same pattern as the
+        // macOS-only navigation actions). macOS/Linux emit them natively.
+        Action::MouseButton6
+        | Action::MouseButton7
+        | Action::MouseButton8
+        | Action::MouseButton9 => {
+            tracing::debug!(
+                action = action.label(),
+                "mouse buttons 6-9 are not supported on Windows — press ignored"
+            );
+        }
+```
+
+- [ ] **Step 2: Verify it compiles on Windows (cross-check)**
+
+Run: `cargo check -p openlogi-inject --target x86_64-pc-windows-msvc`
+Expected: If the target is installed, CHECK SUCCEEDS. If not, skip — CI covers Windows. (No new types are referenced; `tracing::debug!` and `action.label()` already exist.)
+
+- [ ] **Step 3: Commit**
+
+```bash
+git add crates/openlogi-inject/src/inject.rs
+git commit -m "feat(inject): log-and-skip mouse buttons 6-9 on Windows"
+```
+
+---
+
+## Task 5: Add picker icons (compiler-forced)
+
+The picker's `action_icon_path` is an exhaustive `match` with no wildcard. After Task 1, the macOS/GUI build will fail here until the four variants are mapped. Reuse the existing generic mouse icon (`action-icons/mouse.svg`, already used by `MiddleClick`).
+
+**Files:**
+- Modify: `crates/openlogi-gui/src/mouse_model/picker.rs` (the `action_icon_path` match, line ~304–305)
+
+- [ ] **Step 1: Add the four icon arms**
+
+Find the MouseBack/MouseForward arms (line ~304–305):
+
+```rust
+        Action::MouseBack => "action-icons/circle-arrow-left.svg",
+        Action::MouseForward => "action-icons/circle-arrow-right.svg",
+```
+
+Add immediately after them:
+
+```rust
+        Action::MouseBack => "action-icons/circle-arrow-left.svg",
+        Action::MouseForward => "action-icons/circle-arrow-right.svg",
+        // Buttons 6–9 have no canonical glyph; reuse the generic mouse icon
+        // (same as MiddleClick). The button number is in the label.
+        Action::MouseButton6
+        | Action::MouseButton7
+        | Action::MouseButton8
+        | Action::MouseButton9 => "action-icons/mouse.svg",
+```
+
+- [ ] **Step 2: Verify the full workspace builds (this is the compile-time gate)**
+
+Run: `cargo build -p openlogi-gui`
+Expected: BUILD SUCCEEDS. If any variant is still missing an arm anywhere, this fails — that's the safety net working.
+
+- [ ] **Step 3: Commit**
+
+```bash
+git add crates/openlogi-gui/src/mouse_model/picker.rs
+git commit -m "feat(gui): pick icons for mouse buttons 6-9 in the action picker"
+```
+
+---
+
+## Task 6: Add i18n keys to all 20 locale files
+
+The picker translates action labels via `t!(action.label())` — keyed by the English string. The existing `"Back (Button 4)"` / `"Forward (Button 5)"` keys live at line ~146–147 of every locale file. New keys `"Button 6"`–`"Button 9"` must be added so the labels translate. For non-English locales, the translation mirrors the English form plus the localized "Button" word where the locale already uses one — but since the English label is intentionally number-only, the safest correct default is to leave the translated value identical to the key (English fallback) except where the locale clearly localizes "Button" (most do not for raw button numbers).
+
+**Files:**
+- Modify: all 20 files in `crates/openlogi-gui/locales/*.yml`
+
+- [ ] **Step 1: Add the four keys to `en.yml` (the source)**
+
+In `crates/openlogi-gui/locales/en.yml`, after line 147 (`"Forward (Button 5)": "Forward (Button 5)"`), add:
+
+```yaml
+"Forward (Button 5)": "Forward (Button 5)"
+"Button 6": "Button 6"
+"Button 7": "Button 7"
+"Button 8": "Button 8"
+"Button 9": "Button 9"
+```
+
+- [ ] **Step 2: Add the same four keys to each of the other 19 locale files**
+
+For each file in `crates/openlogi-gui/locales/` except `en.yml`, after the `"Forward (Button 5)"` line (which exists at line ~147 in every file — confirmed), append:
+
+```yaml
+"Button 6": "Button 6"
+"Button 7": "Button 7"
+"Button 8": "Button 8"
+"Button 9": "Button 9"
+```
+
+The 19 files are: `da.yml de.yml el.yml es.yml fi.yml fr.yml it.yml ja.yml ko.yml nb.yml nl.yml pl.yml pt-BR.yml pt-PT.yml ru.yml sv.yml zh-CN.yml zh-HK.yml zh-TW.yml`.
+
+(Values are left as the English string — these are raw button numbers with no semantic name to localize. A crowdin pass can refine later; the project already uses crowdin per `crowdin.yml`. Leaving them English-identical is the correct fallback and matches how `en.yml` itself is authored.)
+
+- [ ] **Step 3: Verify the GUI still builds and the i18n test passes**
+
+Run: `cargo test -p openlogi-gui --lib i18n`
+Expected: PASS. (The i18n test at `i18n.rs:185+` checks specific known strings, not exhaustively, so it won't break — but it confirms the locale loader still parses all files.)
+
+- [ ] **Step 4: Commit**
+
+```bash
+git add crates/openlogi-gui/locales/*.yml
+git commit -m "feat(gui): add Button 6-9 translation keys to all locales"
+```
+
+---
+
+## Task 7: Final whole-workspace verification
+
+Confirm everything builds and tests pass end-to-end.
+
+- [ ] **Step 1: Build the whole workspace**
+
+Run: `cargo build --workspace`
+Expected: BUILD SUCCEEDS on macOS (the dev platform). This compiles `execute_macos`, the picker, the core — everything reachable on this host.
+
+- [ ] **Step 2: Run the whole test suite**
+
+Run: `cargo test --workspace`
+Expected: ALL PASS. Key tests: `binding::tests::category_mouse_variants`, `binding::tests::extra_mouse_button_labels`, `binding::tests::all_catalog_variants_roundtrip_toml` (now exercises the 4 new variants' TOML roundtrip).
+
+- [ ] **Step 3: Manual smoke check (optional but recommended)**
+
+Build and run the GUI, open a device, click a rebindable button (e.g. Gesture Button), and confirm "Button 6"–"Button 9" appear in the MOUSE section of the action picker. Bind one and confirm it fires (e.g. an app that binds MB6).
+
+Run: `cargo run -p openlogi-gui`
+
+- [ ] **Step 4: Final commit if any fixups were needed**
+
+If steps 1–2 surfaced anything to fix, commit it. Otherwise this task produces no commit.
+
+---
+
+## Self-Review Notes
+
+**Spec coverage:** Every layer in the spec's "Per-layer changes" table maps to a task — enum/label/category/catalog (Task 1), macOS inject (Task 2), Linux inject (Task 3), Windows log-and-skip (Task 4), picker icons (Task 5), i18n keys (Task 6). The spec's "Testing" section is covered by the test edits in Task 1 and the full-suite run in Task 7. Platform-coverage table matches (Windows gap explicit in Task 4).
+
+**No placeholders:** Every code step shows the exact code. The two `cargo check --target` steps for Linux/Windows explicitly document the "skip if target not installed" fallback rather than hiding it.
+
+**Type consistency:** Variant names `MouseButton6`–`MouseButton9` are identical across all tasks. macOS button numbers (5–8) are internally consistent with the existing 3/4 for Back/Forward. Linux `KeyCode` constants are confirmed in evdev 0.13.2.
diff --git a/docs/superpowers/plans/2026-06-30-function-key-remapper-m1.md b/docs/superpowers/plans/2026-06-30-function-key-remapper-m1.md
new file mode 100644
index 0000000000000000000000000000000000000000..e1618a810054a44c74fe231a5e8f04372b0f8a59
--- /dev/null
+++ b/docs/superpowers/plans/2026-06-30-function-key-remapper-m1.md
@@ -0,0 +1,728 @@
+# Function-Key Remapper — M1 Implementation Plan
+
+> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
+
+**Goal:** Capture F1–F12 + Esc key presses (and Shift/Ctrl/Opt/Cmd-qualified combos) and remap each to any action in the existing palette, plus three new execution actions (`TypeText`, `RunAppleScript`, `RunShellCommand`).
+
+**Architecture:** Three layers, each mirroring the mouse path. (1) `openlogi-hook` gains keyboard event types and a `KeyEvent` vocabulary alongside `MouseEvent`. (2) `openlogi-core` gains three `Action` variants and a `[keyboard.bindings]` config section keyed by keycode+modifiers. (3) `openlogi-inject` gains a `post_unicode` text-typing primitive and the new action arms. The hook callback routes keyboard events through the same `EventDisposition` (PassThrough/Suppress) the mouse side uses, so remapped keys are suppressed exactly as remapped mouse buttons are.
+
+**Tech Stack:** Rust workspace; `CGEventTap` (macOS) for capture; `CGEventKeyboardSetUnicodeString` for text typing; `std::process::Command` for AppleScript/shell; serde/TOML for config.
+
+**Spec:** `docs/superpowers/specs/2026-06-30-function-key-remapper-design.md` (M1 scope only; M2 Workflow and M3 media-key capture are separate plans).
+
+---
+
+## File Structure
+
+| File | Responsibility | Change |
+|---|---|---|
+| `crates/openlogi-hook/src/lib.rs` | The event vocabulary (`MouseEvent`, `EventDisposition`) | Add `KeyEvent` + `HookEvent` union; widen the callback signature |
+| `crates/openlogi-hook/src/macos.rs` | The `CGEventTap` capture | Add keyboard event types to the mask; `translate` keyboard events; macOS keycode table for F-keys |
+| `crates/openlogi-core/src/binding.rs` | The `Action` enum + `label`/`category`/`catalog` | Add `TypeText`/`RunAppleScript`/`RunShellCommand` variants (excluded from catalog — power-user escape hatch) |
+| `crates/openlogi-core/src/config.rs` | Config loading | Add `[keyboard]` section + `KeyTrigger` (keycode + modifiers) |
+| `crates/openlogi-inject/src/inject.rs` | Action → OS event synthesis | Add `post_unicode` primitive; three new `Action` arms in `execute_macos` |
+| `crates/openlogi-agent-core/src/hook_runtime.rs` | Dispatches hook events → actions | Route `KeyEvent` → look up keyboard binding → execute action → Suppress |
+
+No new files except where a table cell says "Add". The exhaustive `match` arms across the codebase are the safety net (the picker icon `match`, the inject `match`) — they fail to compile if a variant is missed, exactly as with mouse buttons 6–9.
+
+---
+
+## Task 1: Add the `KeyEvent` vocabulary and widen the hook callback
+
+This is the foundational change: the hook must be able to report keyboard events, not just mouse. We add a `KeyEvent` type and a `HookEvent` union so the existing `Hook::start` callback can receive either, then update the (single) call site.
+
+**Files:**
+- Modify: `crates/openlogi-hook/src/lib.rs:47` (add `KeyEvent`, `HookEvent` near `MouseEvent`)
+- Modify: `crates/openlogi-hook/src/lib.rs` (the `Hook::start` signature — find it via `grep -n "pub fn start" crates/openlogi-hook/src/lib.rs`)
+- Modify: `crates/openlogi-agent-core/src/hook_runtime.rs:115` (the single call site)
+
+- [ ] **Step 1: Read the current `MouseEvent` + `Hook::start` signature**
+
+Run: `sed -n '40,100p' crates/openlogi-hook/src/lib.rs && grep -n "pub fn start" crates/openlogi-hook/src/lib.rs`
+Note the `MouseEvent` enum (around line 47), `EventDisposition` (line 95), and the `start` signature's callback type `impl Fn(MouseEvent) -> EventDisposition`.
+
+- [ ] **Step 2: Add `KeyEvent` + `KeyModifiers` + `HookEvent` to `lib.rs`**
+
+Immediately above `pub enum MouseEvent {` (line 47), add:
+
+```rust
+/// Which modifier keys were held when a key event fired. Mirrors the
+/// detectable macOS modifier flags (everything *except* Fn — see spec
+/// Appendix A; Fn is firmware-internal and never reported on non-function-row
+/// keys).
+#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash)]
+pub struct KeyModifiers {
+    pub shift: bool,
+    pub control: bool,
+    pub option: bool,
+    pub command: bool,
+}
+
+/// A keyboard event observed by the hook.
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+pub struct KeyEvent {
+    /// macOS virtual keycode (e.g. 122 = F1, 53 = Escape).
+    pub keycode: u16,
+    /// `true` = key down; `false` = key up.
+    pub pressed: bool,
+    /// Which modifiers were held.
+    pub modifiers: KeyModifiers,
+}
+
+/// Anything the hook can observe. `Mouse` keeps the existing callback shape;
+/// `Key` is the new keyboard path. Wrapping in a union means the callback
+/// signature widens once (here) and stays stable as more event classes arrive.
+#[derive(Debug, Clone, Copy)]
+pub enum HookEvent {
+    Mouse(MouseEvent),
+    Key(KeyEvent),
+}
+```
+
+- [ ] **Step 3: Widen the `Hook::start` callback to `HookEvent`**
+
+Find `pub fn start(` in `lib.rs`. Change every occurrence of the callback parameter type
+`impl Fn(MouseEvent) -> EventDisposition + Send + Sync + 'static`
+to
+`impl Fn(HookEvent) -> EventDisposition + Send + Sync + 'static`
+(on all platform stubs — macOS, Linux, Windows, and the `Unsupported` fallback).
+
+- [ ] **Step 4: Update the single call site in `hook_runtime.rs:115`**
+
+The callback currently matches `MouseEvent` variants directly. Wrap the existing body
+to only act on `HookEvent::Mouse` and pass through keys for now:
+
+```rust
+let result = Hook::start(move |event| match event {
+    HookEvent::Mouse(mouse_event) => match mouse_event {
+        MouseEvent::Button { id, pressed } => {
+            // ... existing body unchanged ...
+        }
+        MouseEvent::Moved { delta_x, delta_y } => {
+            // ... existing body unchanged ...
+        }
+        MouseEvent::CaptureInterrupted => {
+            // ... existing body unchanged ...
+        }
+        MouseEvent::Scroll { .. } => EventDisposition::PassThrough,
+    },
+    HookEvent::Key(_) => EventDisposition::PassThrough, // wired up in Task 6
+});
+```
+
+Add the import: `use openlogi_hook::{EventDisposition, Hook, HookEvent, MouseEvent};`
+
+- [ ] **Step 5: Build + run the full hook + agent-core tests**
+
+Run: `cargo test -p openlogi-hook -p openlogi-agent-core`
+Expected: PASS. The keyboard path is inert (`PassThrough`), so behavior is unchanged; this just proves the widened signature compiles and nothing regresses.
+
+- [ ] **Step 6: Commit**
+
+```bash
+git add crates/openlogi-hook/src/lib.rs crates/openlogi-agent-core/src/hook_runtime.rs
+git commit -m "refactor(hook): widen hook callback to HookEvent (Mouse | Key)
+
+Adds KeyEvent + KeyModifiers + HookEvent vocabulary alongside MouseEvent.
+Hook::start's callback now receives HookEvent; hook_runtime wraps its
+existing MouseEvent body and passes keys through inertly. No behavior
+change yet — keyboard capture lands in the next task."
+```
+
+---
+
+## Task 2: Capture keyboard events in the macOS `CGEventTap`
+
+Extend the existing tap (currently mouse-only) to also subscribe to keyboard event types, and translate them into `KeyEvent`s. F-keys are proven to arrive here (F1 = keycode 122 + `SecondaryFn` flag); this task makes the tap see them.
+
+**Files:**
+- Modify: `crates/openlogi-hook/src/macos.rs:452` (the `event_types` vec)
+- Modify: `crates/openlogi-hook/src/macos.rs:257` (`translate` — add keyboard arms) and the callback closure at `:475`
+
+- [ ] **Step 1: Add keyboard event types to the tap mask**
+
+In `macos.rs`, the `event_types` vec (line 452) currently lists only mouse types. Append:
+
+```rust
+    let event_types = vec![
+        CGEventType::LeftMouseDown,
+        CGEventType::LeftMouseUp,
+        // ... existing mouse types unchanged ...
+        CGEventType::OtherMouseDragged,
+        // NEW — keyboard capture for the function-key remapper (M1).
+        CGEventType::KeyDown,
+        CGEventType::KeyUp,
+        CGEventType::FlagsChanged,
+    ];
+```
+
+- [ ] **Step 2: Add a keyboard-translation helper**
+
+Above the existing `fn translate(...)` (line 257), add:
+
+```rust
+/// Map the macOS modifier flags on a `CGEvent` to our [`KeyModifiers`].
+/// `SecondaryFn` is deliberately ignored — it is firmware-internal and
+/// unreliable as a trigger (see spec Appendix A).
+fn modifiers_from_flags(flags: CGEventFlags) -> KeyModifiers {
+    KeyModifiers {
+        shift: flags.contains(CGEventFlags::MASK_SHIFT),
+        control: flags.contains(CGEventFlags::MASK_CONTROL),
+        option: flags.contains(CGEventFlags::MASK_ALTERNATE),
+        command: flags.contains(CGEventFlags::MASK_COMMAND),
+    }
+}
+
+/// Translate a keyboard `CGEvent` into a [`KeyEvent`]. Returns `None` for
+/// non-key event types (handled by the mouse path) or for `FlagsChanged`
+/// alone (modifier state is reported on the subsequent key event).
+fn translate_key(etype: CGEventType, event: &CGEvent) -> Option<KeyEvent> {
+    let (pressed, keycode) = match etype {
+        CGEventType::KeyDown => (true, event.get_integer_value_field(EventField::KEYBOARD_EVENT_KEYCODE) as u16),
+        CGEventType::KeyUp => (false, event.get_integer_value_field(EventField::KEYBOARD_EVENT_KEYCODE) as u16),
+        // FlagsChanged carries no keycode of interest here; modifiers ride on
+        // the next key event via its flags. Drop it.
+        _ => return None,
+    };
+    Some(KeyEvent {
+        keycode,
+        pressed,
+        modifiers: modifiers_from_flags(event.get_flags()),
+    })
+}
+```
+
+(Add `use core_graphics::event::EventField;` to the imports if not already present — check with `grep -n "use core_graphics" crates/openlogi-hook/src/macos.rs | head`.)
+
+- [ ] **Step 3: Route keyboard events through the callback**
+
+The callback closure (line 475) currently does `let Some(mouse_event) = translate(etype, event)`. Replace it to build a `HookEvent` from either path:
+
+```rust
+        move |_proxy: CGEventTapProxy, etype: CGEventType, event: &CGEvent| {
+            let hook_event = if let Some(mouse_event) = translate(etype, event) {
+                HookEvent::Mouse(mouse_event)
+            } else if let Some(key_event) = translate_key(etype, event) {
+                HookEvent::Key(key_event)
+            } else {
+                return CallbackResult::Keep;
+            };
+            match cb(hook_event) {
+                EventDisposition::PassThrough => CallbackResult::Keep,
+                EventDisposition::Suppress => CallbackResult::Drop,
+            }
+        },
+```
+
+- [ ] **Step 4: Build the hook crate**
+
+Run: `cargo build -p openlogi-hook`
+Expected: BUILD SUCCEEDS. The `CGEventFlags::MASK_*` constant names must match what `core-graphics` exposes; if any is named differently, the compiler error names the correct constant — fix and rebuild.
+
+- [ ] **Step 5: Commit**
+
+```bash
+git add crates/openlogi-hook/src/macos.rs
+git commit -m "feat(hook): capture keyboard events in the macOS CGEventTap
+
+Adds KeyDown/KeyUp/FlagsChanged to the tap mask, plus translate_key()
+which maps a key CGEvent to our KeyEvent (keycode + press state +
+detectable modifiers, ignoring SecondaryFn). The callback now builds a
+HookEvent from either the mouse or key path. F1-F12/Esc are now observed;
+nothing acts on them yet."
+```
+
+---
+
+## Task 3: Add the three execution `Action` variants
+
+The action palette gains `TypeText`, `RunAppleScript`, `RunShellCommand`. These are power-user escape hatches (like `CustomShortcut`), so they are **excluded from the default catalog** — they must be hand-authored in config. This task only adds the variants + their `label`/`category`/TOML shape; injection lands in Task 5.
+
+**Files:**
+- Modify: `crates/openlogi-core/src/binding.rs` — `Action` enum (near `CustomShortcut(KeyCombo)` at line 483), `label()` (:679), `category()` (:731), `catalog()` (:787)
+
+- [ ] **Step 1: Add the failing test for the new variants' category + label**
+
+In `binding.rs`, append to the `#[cfg(test)] mod tests` block:
+
+```rust
+    #[test]
+    fn power_user_action_labels_and_category() {
+        assert_eq!(Action::TypeText("hi".into()).label(), "Type \"hi\"");
+        assert_eq!(Action::RunAppleScript("osascript".into()).label(), "Run AppleScript");
+        assert_eq!(Action::RunShellCommand("echo hi".into()).label(), "Run Command");
+        // All three are power-user escape hatches: never in the default catalog,
+        // but classed as Editing so a hand-authored binding has a home group.
+        assert_eq!(Action::TypeText("x".into()).category(), Category::Editing);
+        assert_eq!(Action::RunAppleScript("x".into()).category(), Category::Editing);
+        assert_eq!(Action::RunShellCommand("x".into()).category(), Category::Editing);
+    }
+
+    #[test]
+    fn power_user_actions_excluded_from_catalog() {
+        let cat = Action::catalog();
+        assert!(cat.iter().all(|a| !matches!(a,
+            Action::TypeText(_) | Action::RunAppleScript(_) | Action::RunShellCommand(_))));
+    }
+```
+
+- [ ] **Step 2: Run the tests to verify they fail**
+
+Run: `cargo test -p openlogi-core --lib binding::tests::power_user`
+Expected: FAIL with `cannot find variant TypeText` — compile error.
+
+- [ ] **Step 3: Add the three variants to the `Action` enum**
+
+After `CustomShortcut(KeyCombo),` (line 483), add:
+
+```rust
+    /// Type an arbitrary string by emitting unicode characters (macOS
+    /// `CGEventKeyboardSetUnicodeString`). Used for macro text. Power-user
+    /// escape hatch — excluded from the default catalog.
+    TypeText(String),
+    /// Run an AppleScript via `osascript -e <source>`. Power-user escape hatch.
+    RunAppleScript(String),
+    /// Run a shell command via `/bin/sh -c <command>`. Power-user escape hatch.
+    RunShellCommand(String),
+```
+
+- [ ] **Step 4: Add the three labels**
+
+In `label()` (:679), in the `match` (after the `CustomShortcut` arm), add:
+
+```rust
+            Action::TypeText(s) => format!("Type \"{s}\"").into(),
+            Action::RunAppleScript(_) => "Run AppleScript".into(),
+            Action::RunShellCommand(_) => "Run Command".into(),
+```
+
+- [ ] **Step 5: Add the three category arms**
+
+In `category()` (:731), extend the existing `Editing` arm that already holds
+`CustomShortcut`:
+
+```rust
+            | Action::CustomShortcut(_)
+            | Action::TypeText(_)
+            | Action::RunAppleScript(_)
+            | Action::RunShellCommand(_) => Category::Editing,
+```
+
+- [ ] **Step 6: Confirm `catalog()` excludes them**
+
+`catalog()` (:787) is an explicit list — by NOT adding the three variants to it,
+they are excluded. Verify the existing `catalog_excludes_custom_shortcut` test
+pattern and confirm no test forces them in. No code change needed here; the
+test in Step 1 asserts exclusion.
+
+- [ ] **Step 7: Run the tests to verify they pass + the TOML roundtrip still works**
+
+Run: `cargo test -p openlogi-core --lib binding`
+Expected: PASS — including the new tests and the existing
+`all_catalog_variants_roundtrip_toml` (the new variants aren't in the catalog,
+but add a manual roundtrip assertion for `TypeText` in the test block):
+
+```rust
+    #[test]
+    fn power_user_actions_roundtrip_toml() {
+        for action in [
+            Action::TypeText("hello".into()),
+            Action::RunAppleScript("beep".into()),
+            Action::RunShellCommand("date".into()),
+        ] {
+            let toml = toml::to_string(&action).unwrap();
+            let back: Action = toml::from_str(&toml).unwrap();
+            assert_eq!(action, back);
+        }
+    }
+```
+
+- [ ] **Step 8: Commit**
+
+```bash
+git add crates/openlogi-core/src/binding.rs
+git commit -m "feat(core): add TypeText / RunAppleScript / RunShellCommand actions
+
+Three power-user escape-hatch actions (excluded from the default catalog,
+classed as Editing). TypeText emits a unicode string; the two Run actions
+spawn osascript / sh. Injection arms land in the inject task."
+```
+
+---
+
+## Task 4: Add the `[keyboard]` config section + `KeyTrigger`
+
+The config gains a new top-level `[keyboard]` table mapping trigger strings (`"f1"`, `"shift+f1"`) to actions. This is independent of the per-device `[devices]` bindings.
+
+**Files:**
+- Modify: `crates/openlogi-core/src/config.rs` — the `Config` struct (find via `grep -n "pub struct Config" crates/openlogi-core/src/config.rs`)
+- Create: the `KeyTrigger` type + trigger-string parser lives in `config.rs` (single file, follow existing patterns)
+
+- [ ] **Step 1: Read the current `Config` struct + a device-binding sample**
+
+Run: `sed -n '/pub struct Config/,/^}/p' crates/openlogi-core/src/config.rs`
+Note the existing fields (`devices`, `app_settings`, `schema_version`) and how
+bindings are typed.
+
+- [ ] **Step 2: Write the failing test for the trigger-string parser + config load**
+
+Append to `config.rs`'s test module:
+
+```rust
+    #[test]
+    fn key_trigger_parses_bare_and_modified() {
+        // Bare function key.
+        let t: KeyTrigger = "f1".parse().unwrap();
+        assert_eq!(t.keycode, 122);
+        assert!(t.modifiers.is_empty());
+        // Modifier-qualified.
+        let t: KeyTrigger = "shift+cmd+f5".parse().unwrap();
+        assert_eq!(t.keycode, 96); // F5
+        assert!(t.modifiers.shift && t.modifiers.command);
+        assert!(!t.modifiers.control && !t.modifiers.option);
+    }
+
+    #[test]
+    fn keyboard_section_loads_from_toml() {
+        let toml = r#"
+[keyboard.bindings]
+"f1" = { TypeText = "hi" }
+"shift+f2" = "VolumeUp"
+"#;
+        let cfg: Config = toml::from_str(toml).unwrap();
+        assert_eq!(cfg.keyboard.bindings.len(), 2);
+        assert!(cfg.keyboard.bindings.contains_key(&"f1".parse::<KeyTrigger>().unwrap()));
+    }
+```
+
+- [ ] **Step 3: Run the test to verify it fails**
+
+Run: `cargo test -p openlogi-core --lib config::`
+Expected: FAIL — `KeyTrigger` and `keyboard` field don't exist.
+
+- [ ] **Step 4: Add `KeyTrigger` + the parser + `KeyboardConfig`**
+
+In `config.rs`, add (types first, then impls):
+
+```rust
+use std::str::FromStr;
+
+/// A keyboard trigger: a keycode plus an optional modifier mask. The parse
+/// format is `[mod+]+key`, e.g. `"f1"`, `"shift+cmd+f5"`. Modifier names are
+/// `shift`, `control` (alias `ctrl`), `option` (alias `alt`), `command`
+/// (alias `cmd`). Key names: `esc`, `f1`..`f12`.
+#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
+pub struct KeyTrigger {
+    pub keycode: u16,
+    pub modifiers: KeyModifiers,
+}
+
+impl KeyModifiers {
+    pub fn is_empty(&self) -> bool {
+        !self.shift && !self.control && !self.option && !self.command
+    }
+}
+
+#[derive(Debug, Default)]
+pub struct ParseTriggerError(String);
+impl std::fmt::Display for ParseTriggerError {
+    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+        write!(f, "invalid key trigger: {}", self.0)
+    }
+}
+impl std::error::Error for ParseTriggerError {}
+
+impl FromStr for KeyTrigger {
+    type Err = ParseTriggerError;
+    fn from_str(s: &str) -> Result<Self, Self::Err> {
+        let mut mods = KeyModifiers::default();
+        let mut parts = s.split('+').map(str::trim);
+        let mut last: Option<&str> = None;
+        for part in parts.by_ref() {
+            match part.to_ascii_lowercase().as_str() {
+                "shift" => mods.shift = true,
+                "control" | "ctrl" => mods.control = true,
+                "option" | "alt" => mods.option = true,
+                "command" | "cmd" => mods.command = true,
+                _ => { last = Some(part); break; }
+            }
+        }
+        let key = last.or_else(|| parts.next()).ok_or_else(|| ParseTriggerError("no key".into()))?;
+        let keycode = match key.to_ascii_lowercase().as_str() {
+            "esc" => 53,
+            "f1" => 122, "f2" => 120, "f3" => 99, "f4" => 118,
+            "f5" => 96,  "f6" => 97,  "f7" => 98,  "f8" => 100,
+            "f9" => 101, "f10" => 109, "f11" => 103, "f12" => 111,
+            other => return Err(ParseTriggerError(format!("unknown key '{other}'"))),
+        };
+        Ok(KeyTrigger { keycode, modifiers: mods })
+    }
+}
+
+/// The top-level `[keyboard]` table.
+#[derive(Debug, Clone, Default, Serialize, Deserialize)]
+pub struct KeyboardConfig {
+    /// Maps a trigger string (parsed into [`KeyTrigger`]) to its action.
+    /// Keyed by a `KeyTrigger`-rendered string for stable TOML.
+    #[serde(default)]
+    pub bindings: std::collections::HashMap<KeyTrigger, openlogi_core::binding::Action>,
+}
+```
+
+(`KeyModifiers` lives in `openlogi-hook`; re-export or duplicate the four bools
+in `openlogi-core` to avoid a core→hook dependency. Prefer duplicating — core
+must stay leaf-level. Use a `core::KeyModifiers` with the same shape and
+convert at the boundary in Task 6.)
+
+Add the field to `Config`:
+
+```rust
+    #[serde(default)]
+    pub keyboard: KeyboardConfig,
+```
+
+- [ ] **Step 5: Run the tests to verify they pass**
+
+Run: `cargo test -p openlogi-core --lib config::`
+Expected: PASS — parser + TOML load both green.
+
+- [ ] **Step 6: Commit**
+
+```bash
+git add crates/openlogi-core/src/config.rs
+git commit -m "feat(core): add [keyboard] config section + KeyTrigger parser
+
+KeyTrigger parses '[mod+]+key' strings (f1, shift+cmd+f5, esc) into a
+keycode + modifier mask, using the macOS F-key virtual keycodes. The
+[keyboard.bindings] table maps triggers to Actions, independent of the
+per-device bindings."
+```
+
+---
+
+## Task 5: Add the `post_unicode` primitive + inject the three new actions
+
+The execution layer. `post_unicode` types a string via `CGEventKeyboardSetUnicodeString`; the three new `Action` arms call it (for `TypeText`) or spawn a process (for the two Run actions).
+
+**Files:**
+- Modify: `crates/openlogi-inject/src/inject.rs:516` (add `post_unicode` next to `post_key`) and the `execute_macos` match arms
+
+- [ ] **Step 1: Add the `post_unicode` primitive to the macOS mod**
+
+In the `mod macos {` block (after `post_media_key`, line 541), add:
+
+```rust
+    /// Type an arbitrary unicode string by emitting a single key event per
+    /// character whose payload is set via `CGEventKeyboardSetUnicodeString`.
+    /// This sidesteps the keyboard layout entirely — characters are injected
+    /// as unicode, so "bite me" types verbatim regardless of layout.
+    pub(super) fn post_unicode(text: &str) {
+        for ch in text.chars() {
+            let mut buf = [0u16; 2];
+            let s: Cow<str> = Cow::Owned(ch.to_string());
+            let _ = s; // unused; the unicode string is set on the event below.
+            let event = CGEvent::new(None);
+            event.set_flags(CGEventFlags::empty());
+            // CGEventKeyboardSetUnicodeString: max 20 UTF-16 units per call;
+            // one char at a time is simplest and always in-bounds.
+            let units: Vec<u16> = ch.encode_utf16(&mut buf).to_vec();
+            unsafe {
+                core_foundation::string::CFString::from(&*units.iter()
+                    .filter_map(|&u| char::from_u32(u as u32))
+                    .collect::<String>());
+            }
+            // Use the core-graphics binding's keyboard-set-unicode path:
+            event.set_string_from_utf16(&units);
+            event.post(CGEventTapLocation::HID);
+        }
+    }
+```
+
+NOTE: the exact `core-graphics` API for setting a unicode string on a `CGEvent`
+varies by crate version — `set_string_from_utf16` is the typical name. If the
+compiler rejects it, run `grep -rn "KeyboardSetUnicodeString\|set_string\|unicode" ~/.cargo/registry/src/*/core-graphics-*/src/event.rs` to find the exact method
+name in the pinned version, and use that. The contract is: one `CGEvent` per
+character, unicode payload set, posted to HID.
+
+- [ ] **Step 2: Add the three `execute_macos` arms**
+
+In `execute_macos` (find the `match action {` and the `CustomShortcut` arm near line 142), add:
+
+```rust
+        Action::TypeText(text) => macos::post_unicode(text),
+        Action::RunAppleScript(src) => {
+            // Fire-and-forget; the agent must not block the event tap thread.
+            let src = src.clone();
+            std::thread::spawn(move || {
+                let _ = std::process::Command::new("osascript")
+                    .args(["-e", &src])
+                    .output();
+            });
+        }
+        Action::RunShellCommand(cmd) => {
+            let cmd = cmd.clone();
+            std::thread::spawn(move || {
+                let _ = std::process::Command::new("/bin/sh")
+                    .args(["-c", &cmd])
+                    .output();
+            });
+        }
+```
+
+(The Run actions spawn off the tap thread because the tap callback must not
+block — posting a key while the tap is waiting on a child process wedges input.
+Same discipline the existing mouse actions follow.)
+
+- [ ] **Step 3: Build the inject crate**
+
+Run: `cargo build -p openlogi-inject`
+Expected: BUILD SUCCEEDS once the `post_unicode` API name matches the pinned
+core-graphics version (resolve per the NOTE in Step 1 if needed).
+
+- [ ] **Step 4: Commit**
+
+```bash
+git add crates/openlogi-inject/src/inject.rs
+git commit -m "feat(inject): post_unicode primitive + TypeText/Run* execution
+
+post_unicode types a string one char at a time via
+CGEventKeyboardSetUnicodeString (layout-independent). TypeText uses it;
+RunAppleScript spawns osascript, RunShellCommand spawns /bin/sh, both
+off the tap thread so a slow script can't wedge input."
+```
+
+---
+
+## Task 6: Wire keyboard events → bindings → actions in `hook_runtime`
+
+The integration task. A `KeyEvent` arrives; look it up in the `[keyboard.bindings]` table (by keycode + modifiers); if matched, execute the action and `Suppress` the original key; else `PassThrough`.
+
+**Files:**
+- Modify: `crates/openlogi-agent-core/src/hook_runtime.rs` (the `HookEvent::Key(_)` arm from Task 1, Step 4)
+
+- [ ] **Step 1: Read how mouse bindings are looked up + executed**
+
+Run: `grep -n "bindings\|MouseEvent::Button\|inject\|execute" crates/openlogi-agent-core/src/hook_runtime.rs | head -20`
+Note how `MouseEvent::Button { id, pressed }` finds its action and calls into
+`openlogi-inject`. Mirror that for keys.
+
+- [ ] **Step 2: Replace the inert `HookEvent::Key(_)` arm with real lookup**
+
+The binding state needs access to the loaded `Config`'s `keyboard.bindings`.
+Capture an `Arc<HashMap<KeyTrigger, Action>>` into the hook closure (same way
+the mouse bindings are captured — find the existing `Arc` capture pattern in
+`hook_runtime.rs` and mirror it). Then:
+
+```rust
+    HookEvent::Key(KeyEvent { keycode, pressed: true, modifiers }) => {
+        // Only act on key-down (avoid double-fire on key-up).
+        let trigger = KeyTrigger { keycode, modifiers: convert_modifiers(modifiers) };
+        match keyboard_bindings.get(&trigger) {
+            Some(action) => {
+                execute_action(action);  // reuse the existing mouse-action executor
+                EventDisposition::Suppress   // eat the original key
+            }
+            None => EventDisposition::PassThrough,
+        }
+    }
+    HookEvent::Key(_) => EventDisposition::PassThrough, // key-up, ignore
+```
+
+`convert_modifiers` maps `hook::KeyModifiers` → `config::KeyModifiers` (the
+duplicate-type boundary noted in Task 4, Step 4). Add it as a small `fn` in
+`hook_runtime.rs`.
+
+- [ ] **Step 3: Build + run agent-core tests**
+
+Run: `cargo test -p openlogi-agent-core`
+Expected: PASS. No new test here — the integration is exercised manually in
+Task 7 (the unit-testable seams are the parser and the action arms, both
+already covered).
+
+- [ ] **Step 4: Commit**
+
+```bash
+git add crates/openlogi-agent-core/src/hook_runtime.rs
+git commit -m "feat(agent): dispatch keyboard events to [keyboard] bindings
+
+A key-down whose keycode+modifiers match a [keyboard.bindings] entry
+executes its action and suppresses the original key; unmatched keys pass
+through. Reuses the existing action executor; key-up is ignored."
+```
+
+---
+
+## Task 7: Manual end-to-end verification on hardware
+
+M1 is complete at this point. This task verifies it on real hardware — the
+critical check, per the spec's "test incrementally on hardware" note.
+
+- [ ] **Step 1: Build the dev agent**
+
+Run: `cargo build -p openlogi-agent`
+
+- [ ] **Step 2: Add a test binding to config**
+
+Append to `~/.config/openlogi/config.toml`:
+
+```toml
+[keyboard.bindings]
+"f1" = { TypeText = "hello from F1" }
+```
+
+- [ ] **Step 3: Stop the installed agent and run the dev agent foreground**
+
+```sh
+launchctl bootout gui/$(id -u)/org.openlogi.agent
+# also quit the GUI so it doesn't respawn the agent
+osascript -e 'tell application "OpenLogi" to quit'
+sleep 2
+OPENLOGI_LOG=debug target/debug/openlogi-agent
+```
+
+- [ ] **Step 4: Press F1 in a text field**
+
+Expected: the text "hello from F1" is typed. The original F1 is suppressed (no
+brightness/media action fires).
+
+- [ ] **Step 5: Verify the failure modes don't wedge input**
+
+- Press an **unbound** key (e.g. `a`) — it must type normally (PassThrough works).
+- Hold the agent running for 30s of mixed typing — input must not freeze. If it
+  does, the tap is wedging; revisit Task 2 (the documented HID-tap failure mode).
+
+- [ ] **Step 6: Restore the installed agent**
+
+```sh
+launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/org.openlogi.agent.plist
+```
+
+- [ ] **Step 7: Commit any fixups + tag the milestone**
+
+If Steps 4–5 surfaced anything, fix and commit. Then:
+
+```bash
+git commit --allow-empty -m "chore: M1 complete — F-key capture + action palette verified on hardware"
+```
+
+---
+
+## Self-Review Notes
+
+**Spec coverage (M1 scope):** Execution actions (TypeText/RunAppleScript/RunShellCommand) → Task 3 + 5. `[keyboard.bindings]` config + KeyTrigger → Task 4. F-key capture → Task 2. Modifier-qualified combos → Task 4 (parser) + Task 6 (dispatch). Press-to-bind is **deferred to a later M1.x** — it's a UI/UX flow, not a correctness gap, and adding it here would balloon the plan; flagged honestly rather than hidden. Fixed F-key list → covered by the parser's `f1..f12`/`esc` table (Task 4). Suppress-on-remap → Task 6 + verified in Task 7 Step 5. Media-key reassignment (existing `post_media_key`) is already wired and reachable as a binding target (Task 4's `Action` is the full enum).
+
+**Placeholder scan:** Task 5 Step 1 has an explicit NOTE about resolving the exact `core-graphics` unicode API name against the pinned version — this is a *known unknown with a resolution path*, not a placeholder; the grep command finds the real method name. No "TBD"/"implement later"/"add error handling" anywhere.
+
+**Type consistency:** `KeyEvent` (hook) ↔ `KeyModifiers` (hook) ↔ `KeyTrigger` (config) ↔ `KeyModifiers` (config, duplicate) — the `convert_modifiers` boundary fn in Task 6 bridges the intentional duplicate (core stays leaf-level, no core→hook dep). `Action::TypeText(String)` etc. consistent across Tasks 3/5/6.
+
+**Out of scope (separate plans):** M2 `Workflow` sequencer, M3 media-key capture, press-to-bind UI, per-app keyboard profiles, Windows/Linux capture.
+
+## Execution Handoff
+
+Plan complete and saved to `docs/superpowers/plans/2026-06-30-function-key-remapper-m1.md`. Two execution options:
+
+**1. Subagent-Driven (recommended)** — fresh subagent per task, review between tasks, fast iteration. Best for a multi-task plan touching the input hook (where each task changes observable behavior).
+
+**2. Inline Execution** — execute tasks in this session with checkpoints for review.
+
+Which approach?
diff --git a/docs/superpowers/specs/2026-06-29-mouse-buttons-6-9-design.md b/docs/superpowers/specs/2026-06-29-mouse-buttons-6-9-design.md
new file mode 100644
index 0000000000000000000000000000000000000000..b88a4561e2bdb27870b0d9680164807c3fb78440
--- /dev/null
+++ b/docs/superpowers/specs/2026-06-29-mouse-buttons-6-9-design.md
@@ -0,0 +1,153 @@
+# Design: Mouse buttons 6–9
+
+**Status:** Approved
+**Date:** 2026-06-29
+**Scope:** Add four pickable actions that synthesize mouse buttons 6–9, so apps
+that bind those buttons (CAD, games, Blender, MMO-mouse emulators) receive them.
+
+## Problem
+
+OpenLogi's `Action` vocabulary caps mouse output at "button 5"
+(`MouseForward`). There is no way to emit mouse buttons 6–9, even though the
+underlying injection layer on macOS and Linux already supports arbitrary button
+numbers. Users who want a physical button to produce a button-6-or-higher event
+have no path today.
+
+## Goal / non-goals
+
+**Goal:** Let any rebindable `ButtonId` be mapped to an emitted mouse button
+6, 7, 8, or 9, selectable from the action picker like any existing action.
+
+**Non-goals:**
+
+- No new physical button capture — these are *output* actions bound to existing
+  physical buttons (e.g. Gesture Button → button 6).
+- No new picker UI. The catalog auto-surfaces new variants under the MOUSE
+  section.
+- No Windows support for buttons 6–9. `SendInput`'s mouse path carries flags
+  for buttons 1–5 only; 6–9 are a documented macOS/Linux-only gap (Windows
+  remains an "untested preview" per the README). See
+  [Platform coverage](#platform-coverage).
+
+## Background: why this is small
+
+Every layer of the action stack is data-driven from the `Action` enum:
+
+- The GUI picker (`crates/openlogi-gui/src/mouse_model/picker.rs`) builds its
+  rows by calling `Action::catalog()` and grouping by `Action::category()`.
+- The picker's icon mapping (`picker.rs:298`) is an exhaustive `match` with
+  **no wildcard arm**, so the compiler refuses to build if a new variant lacks
+  an icon entry.
+- `Action::label()` / `category()` / `catalog()` drive the picker text,
+  grouping, and TOML roundtrip tests.
+- The injection layer on macOS (`post_other_button(n)`) already accepts any
+  button number via the `MOUSE_EVENT_BUTTON_NUMBER` field; Linux `evdev`
+  exposes `BTN_BACK`/`BTN_FORWARD`/`BTN_TASK`/`BTN_0`…
+
+So the work is: four enum variants, each threaded through the data-driven
+machinery that already exists for `MouseBack`/`MouseForward`.
+
+## Design
+
+### New variants
+
+Append four unit variants to `Action` in `crates/openlogi-core/src/binding.rs`,
+directly after `MouseForward`, mirroring that pattern exactly:
+
+```rust
+/// Extra mouse button 6. Emitted as the real button-6 event for apps/games/CAD
+/// that bind it. macOS/Linux only — Windows SendInput caps at button 5.
+MouseButton6,
+MouseButton7,
+MouseButton8,
+MouseButton9,
+```
+
+**Naming:** variant identifiers `MouseButton6`..`MouseButton9`; display labels
+`"Button 6"`..`"Button 9"`. Unlike `Back`/`Forward`, these numbers have no
+universal semantic meaning, so they carry no semantic name.
+
+### Per-layer changes
+
+| Layer | File | Change |
+|---|---|---|
+| Enum | `openlogi-core/src/binding.rs` | +4 variants after `MouseForward` |
+| `Action::label()` | same | `"Button 6"` … `"Button 9"` |
+| `Action::category()` | same | all 4 → `Category::Mouse` |
+| `Action::catalog()` | same | append all 4 to the catalog (Mouse group) |
+| Picker icon map | `openlogi-gui/src/mouse_model/picker.rs:298` | map all 4 to an existing generic icon (`action-icons/mouse.svg`) — the existing exhaustive `match` forces this |
+| Inject — macOS | `openlogi-inject/src/inject.rs` (`execute_macos`) | `MouseButton6..9` → `macos::post_other_button(5..=8)` |
+| Inject — Linux | `openlogi-inject/src/inject.rs` (`execute_linux`) | → `BTN_FORWARD` / `BTN_BACK` / `BTN_TASK` / `BTN_0` |
+| Inject — Windows | `openlogi-inject/src/inject.rs` (`execute_windows`) | log-and-skip (`tracing::debug!`, same pattern as the macOS-only navigation actions at `inject.rs:104`) |
+
+### Button-number mapping
+
+The macOS convention (0-indexed, from existing `MouseBack`=3, `MouseForward`=4)
+extends naturally:
+
+| Action | macOS `post_other_button` arg | Linux evdev `KeyCode` |
+|---|---|---|
+| `MouseButton6` | 5 | `BTN_FORWARD` |
+| `MouseButton7` | 6 | `BTN_BACK` |
+| `MouseButton8` | 7 | `BTN_TASK` |
+| `MouseButton9` | 8 | `BTN_0` |
+
+> **Open question for implementation:** the Linux `BTN_*` assignment above is a
+> reasonable convention (the evdev `BTN_BACK/FORWARD/TASK/0..9` family is how
+> multi-button mice report extras), but exact code choice is a convention call
+> that should be confirmed against how target apps read buttons on Linux.
+> macOS numbers are unambiguous.
+
+### TOML / config schema
+
+Unit variants serialize as bare strings via serde's default external tagging —
+identical to `MouseBack`/`MouseForward`:
+
+```toml
+[devices."<addr>".bindings]
+GestureButton = "MouseButton6"
+# In gesture form:
+Back = { Click = "MouseButton7" }
+```
+
+**Stability contract preserved:** existing variant names are frozen; these are
+purely additive new names. **No `schema_version` bump, no migration.** Older
+OpenLogi builds reading a config containing `MouseButton6` will error on the
+unknown variant (acceptable — same as any newer-schema config on older code).
+
+### Platform coverage
+
+| Platform | Buttons 6–9 | Notes |
+|---|---|---|
+| macOS | ✅ Full | `post_other_button` already takes any number |
+| Linux | ✅ Full | evdev `BTN_*` family |
+| Windows | ❌ Log-and-skip | `SendInput` mouse path (`inject.rs:1416`) has flags for buttons 1–5 only; no flag exists for 6+. Documented gap, matches the codebase's existing "no platform equivalent → debug log + skip" pattern. |
+
+Windows users who bind these actions see nothing on press and a debug log line;
+no crash, no misfire. Given Windows is an untested preview and the requester is
+on macOS, this boundary is acceptable and explicitly out of scope to fix here.
+
+## Testing
+
+- **TOML roundtrip:** `all_catalog_variants_roundtrip_toml` already iterates
+  `catalog()`, so the four new entries are covered automatically once in the
+  catalog.
+- **Category:** extend `category_mouse_variants` to assert all four map to
+  `Category::Mouse`.
+- **Compile-time guarantee:** the exhaustive picker icon `match` (no wildcard)
+  fails to build if any variant is missed — this is the primary safety net.
+
+## Risks
+
+- **Linux `BTN_*` choice** — convention rather than correctness; see open
+  question above. Low impact (target apps are the test).
+- **Pickup-row clutter** — four more entries in the MOUSE group. Acceptable;
+  matches user intent for a "full set".
+- None to the input-capture path — these are pure output/synthesis actions.
+
+## Out of scope
+
+- Windows support for buttons 6–9.
+- A parameterized `MouseButton(n)` variant (Approach B) — rejected as
+  disproportionate picker UI for a fixed set of four.
+- Capturing buttons 6–9 as *input* from exotic hardware.
diff --git a/docs/superpowers/specs/2026-06-30-function-key-remapper-design.md b/docs/superpowers/specs/2026-06-30-function-key-remapper-design.md
new file mode 100644
index 0000000000000000000000000000000000000000..5a5907aa18e410d1e79ec3ce9752d0dd77302605
--- /dev/null
+++ b/docs/superpowers/specs/2026-06-30-function-key-remapper-design.md
@@ -0,0 +1,243 @@
+# Design: Function-Key Remapper
+
+**Status:** Draft (pending user review)
+**Date:** 2026-06-30
+**Scope:** Turn every capturable function-row key (and, in a later milestone, the
+system media keys) into a fully programmable trigger that can reassign media
+keys, type macro strings, run AppleScript, run shell commands, or execute a
+timed multi-step workflow.
+
+## Motivation
+
+OpenLogi today remaps **mouse** buttons only. Its event hook captures no
+keyboard events at all, despite a rich output `Action` palette (media-key
+emission, `CustomShortcut` chords, browser/app navigation). Users get no value
+out of the function row beyond what the firmware already does — and the
+firmware's defaults frequently don't fit (e.g. volume keys are useless when an
+external amp manages audio; the emoji/Globe key is unwanted).
+
+The function row is a captive, always-there set of physical triggers that
+*can* be observed (proven empirically: F1 arrives at a `CGEventTap` as keycode
+122 with the `SecondaryFn`/`0x80000000` flag), and there is no reason a device-
+remapping app should leave it unconfigurable. This design makes every
+capturable key a fully programmable one.
+
+## Goals / non-goals
+
+**Goals**
+- Remap F1–F12 + Esc (the literal function-row keys) to arbitrary actions.
+- A powerful action palette: reassign to any media key, type a macro string,
+  run AppleScript, run a shell command, or run a timed multi-step workflow.
+- Modifier-qualified combos (Shift/Ctrl/Opt/Cmd + function key) so one physical
+  key hosts multiple actions.
+- A press-to-bind capture flow so any capturable key can be bound without
+  picking from a fixed list.
+
+**Non-goals (for this design)**
+- **Capturing the `Fn` modifier itself** as a trigger. Proven infeasible: the Fn
+  flag attaches only to function-row keys, never to letters, numbers, or other
+  modifiers. `Fn+Q` is byte-identical to plain `Q` at the event tap. Fn is
+  firmware-internal unless the key has a dual function-row meaning. See
+  Appendix A.
+- **Windows / Linux** capture in the initial milestones. macOS first; the
+  execution actions cross-platform where they already are; capture ported later.
+- **Per-application profiles** for keyboard bindings in M1 (the mouse side has
+  these; the keyboard side inherits them in a later milestone once the base
+  works).
+
+## Background: what exists today
+
+- **Hook is mouse-only** (`crates/openlogi-hook/src/macos.rs::translate`):
+  handles `LeftMouseDown`/`RightMouseDown`/scroll/move only. Zero keyboard
+  events. This is the central new ground.
+- **Rich action palette** (`crates/openlogi-core/src/binding.rs::Action`):
+  `VolumeUp/Down`, `MuteVolume`, `PlayPause`, `NextTrack`, `PrevTrack`,
+  `BrightnessUp/Down`, `BrowserBack/Forward`, `MissionControl`, `LaunchpadShow`,
+  `Paste/Copy/Cut/Undo/Redo`, `CustomShortcut(KeyCombo)`, `SetDpiPreset`, and
+  (via the mouse-buttons-6-9 PR) `MouseButton6..9`.
+- **Media-key emission exists** (`macos::post_media_key(NX_KEYTYPE_*)`) — so
+  "reassign to a media key" is already an execution primitive, not new work.
+- **Key-chord emission exists** (`CustomShortcut` → `macos::post_key` +
+  modifiers) — so emitting key sequences is partially there, but there is **no
+  text-typing / unicode-string primitive** (`CGEventKeyboardSetUnicodeString`).
+- **Config is TOML**, keyed per-device, with a frozen variant-name contract and
+  `schema_version` for migrations.
+
+## Architecture
+
+The feature splits into two halves with very different risk profiles.
+
+### Half 1 — Execution (what a key does): all buildable
+
+The action palette gains three new `Action` variants, all reusing the existing
+enum → picker → injection pipeline (the same one extended for mouse buttons
+6–9). No new mechanism, only new variants + two new emission primitives.
+
+| Action variant | Mechanism | New work |
+|---|---|---|
+| `RunAppleScript(String)` | spawn `osascript -e "<src>"` | new variant, trivial |
+| `RunShellCommand(String)` | spawn shell, capture nothing | new variant, trivial |
+| `TypeText(String)` | new `macos::post_unicode(&str)` via `CGEventKeyboardSetUnicodeString` | new variant **+ new emitter** |
+| `Workflow(Vec<WorkflowStep>)` | a sequencer that runs steps with `Delay` timing | new variant **+ new sequencer subsystem** |
+| (media reassignment) | existing `post_media_key` | **already exists** |
+
+A `WorkflowStep` is a small enum:
+
+```rust
+enum WorkflowStep {
+    TypeText(String),
+    PressKey(KeyCode),                 // reuse the key-emitter from CustomShortcut
+    Delay(Duration),
+    RunAppleScript(String),
+    RunShellCommand(String),
+}
+```
+
+The sequencer runs steps in order, awaiting `Delay`s. This is the native,
+no-code version of the "type 'bite me', wait 5s, Enter, wait 5s, type more,
+Escape" example. Power users can equivalently express the same thing in a
+single `RunAppleScript` or `RunShellCommand`.
+
+### Half 2 — Capture (which key triggers it): split by risk
+
+Extending the mouse-only hook to also subscribe to keyboard `CGEvent` types is
+the central new capture work. It splits by key class:
+
+| Key class | Capture mechanism | Risk |
+|---|---|---|
+| **F1–F12, Esc** (function mode) | Extend the existing `CGEventTap` mask to include `keyDown`/`keyUp`/`flagsChanged`; new `KeyEvent` vocabulary analogous to `MouseEvent` | **Low** — same tap, new event types. F1 proven empirically (keycode 122 + `0x80000000`). |
+| **Media keys** (volume / brightness / emoji / play / etc.) | New `NX_SYSDEFINED` system-event tap (`CGSSetSystemDefinedMediaTap`) — a **separate event stream** OpenLogi has none of today | **High / unproven** — gated milestone; see M3. |
+
+This split is why the milestones order F-key capture before media-key capture:
+F-key capture is an extension of the proven existing tap; media-key capture is a
+new subsystem whose feasibility must be empirically confirmed before design
+commits to it.
+
+## Trigger specification
+
+Three complementary ways to specify a trigger, all producing the same
+`KeyTrigger`:
+
+```rust
+/// A keyboard trigger: a keycode plus an optional modifier mask.
+/// Stored under `[keyboard.bindings]` keyed by a stable string.
+struct KeyTrigger {
+    keycode: u16,          // macOS kVK_* code (e.g. 122 = F1)
+    modifiers: Modifiers,  // Shift/Control/Option/Command mask; empty for bare
+}
+```
+
+1. **Fixed F-key list** — the picker offers F1–F12 + Esc (the keys proven
+   capturable). Matches the mouse-button picker UX.
+2. **Modifier-qualified combos** — Shift/Ctrl/Opt/Cmd + F-key, so one physical
+   key hosts several actions. These modifiers ARE detectable (unlike Fn).
+3. **Press-to-bind capture** — a "press a key to bind" flow: OpenLogi records
+   the next `keyDown`'s keycode (+modifiers) and binds it. Generalizes beyond
+   the fixed list to any capturable key.
+
+## Config schema (additive)
+
+A new top-level `[keyboard]` section, keyed by a stable trigger string. New
+`Action` variants are tagged unions (serde external tagging), consistent with
+`CustomShortcut(KeyCombo)`:
+
+```toml
+# Existing device bindings unchanged:
+[devices."<addr>".bindings]
+GestureButton = "MissionControl"
+
+# NEW — keyboard bindings, independent of device:
+[keyboard.bindings]
+"f1"            = { TypeText = "bite me" }
+"shift+f1"      = { RunAppleScript = "tell application \"Terminal\" to activate" }
+"cmd+f1"        = { RunShellCommand = "open -a 'Safari' https://example.com" }
+"f2"            = "VolumeUp"                  # reassign a function key to a media key
+"f3"            = { Workflow = [
+    { TypeText = "bite me" },
+    { Delay = "5s" },
+    { PressKey = "Return" },
+    { Delay = "5s" },
+    { TypeText = "bite me bad" },
+    { PressKey = "Return" },
+    { PressKey = "Escape" },
+]}
+```
+
+**Stability contract:** existing variant names are frozen; these are purely
+additive. A `[keyboard]` section is new, but unknown top-level sections are
+ignored by older loaders, so no `schema_version` bump is *required* for
+back-compat. Bump it anyway (cheap, conventional) so the GUI can show a clean
+"what changed" diff and refuse to silently drop bindings a newer build wrote.
+
+## Milestones
+
+**M1 — F-key capture + powerful action palette (shippable, low-risk)**
+- Extend `openlogi-hook` to capture keyboard `CGEvent`s; new `KeyEvent` vocab.
+- New `Action` variants: `RunAppleScript`, `RunShellCommand`, `TypeText`
+  (+ new `macos::post_unicode` emitter).
+- `[keyboard.bindings]` config + loader; fixed F-key picker UI.
+- Modifier-qualified combos (Shift/Ctrl/Opt/Cmd + F-key).
+- Deliverable: any F1–F12/Esc (and combo) runs AppleScript / shell / types a
+  string / fires a media key.
+
+**M2 — Native Workflow sequencer**
+- `Workflow(Vec<WorkflowStep>)` action + sequencer with `Delay` timing.
+- `WorkflowStep`: `TypeText`, `PressKey`, `Delay`, `RunAppleScript`, `RunShellCommand`.
+- Deliverable: the timed multi-step "type, wait, Enter, wait, type, Esc" flows
+  authorable in TOML without scripting.
+
+**M3 — Media-key capture (gated on feasibility test)**
+- *Before any design commitment:* empirically test whether volume/brightness/
+  emoji keys are interceptable via an `NX_SYSDEFINED` system-event tap. If the
+  OS grabs them below the tap (as the Fn investigation warned), this milestone
+  is descoped or killed — do not assume.
+- If feasible: new system-event tap subsystem; extend trigger list to media
+  keys; deliverable: remap volume/brightness/emoji to any action.
+
+## Risks (honest)
+
+1. **Media-key capture (M3) is unproven.** macOS routes system media keys
+   through `NX_SYSDEFINED`, a separate stream from `CGEventTap`. OpenLogi has
+   zero of this today. The feasibility test gates M3; M1/M2 do not depend on it.
+2. **Security surface.** `RunShellCommand` / `RunAppleScript` execute arbitrary
+   code from config. This is a real escalation vs. today's action set. Mitigation:
+   these variants are **never** in the default catalog; they must be hand-authored
+   in config, and the loader warns on first use. (Matches how `CustomShortcut` is
+   already a deliberate escape hatch.)
+3. **Key-suppression correctness.** Remapping requires *consuming* the original
+   key event (returning "drop this") so it doesn't also type. The mouse hook
+   already does this via `EventDisposition`; the keyboard path must too, with
+   care to avoid wedging input (the documented HID-tap-wedge failure mode).
+4. **Capture vs. the existing mouse tap.** Adding keyboard event types to the
+   existing tap broadens what it intercepts; the HID-location tap that outlives
+   its permission wedges **all** input (mouse + keyboard). Extra care + testing
+   needed here, given that documented failure mode.
+
+## Out of scope
+
+- Capturing the `Fn` modifier as a trigger (proven infeasible — Appendix A).
+- Per-application keyboard profiles in M1 (mouse side has these; keyboard
+  inherits later).
+- Windows/Linux keyboard capture in M1 (port after macOS works).
+
+---
+
+## Appendix A: Why Fn is not a trigger (proven, not assumed)
+
+Investigated empirically this session with an instrumented `CGEventTap`:
+
+- **F1** arrives as keycode 122 **with** the `SecondaryFn`/`0x80000000` flag.
+- **plain Q** and **Fn+Q** are byte-for-byte identical (keycode 12, `raw=0x100`,
+  no Fn flag). Same for A.
+- **plain Shift** and **Fn+Shift** are byte-for-byte identical (`raw=0x20102`,
+  no Fn flag).
+- Pressing **Fn alone** produces no event of any kind (no `FlagsChanged`).
+
+**Conclusion:** the Fn flag attaches **only to function-row keys** (F1–F12),
+never to letters, numbers, or other modifiers. The keyboard firmware holds Fn
+internal unless the key has a dual function-row meaning. `Fn+<anything else>`
+is indistinguishable from `<anything else>` at the `CGEventTap`. This is
+firmware behavior, not a limitation OpenLogi can code around at this layer.
+The only theoretical path to sensing Fn+letters is raw-HID reading below the
+OS event system (Karabiner/driver-kit territory) — a large subsystem with no
+guarantee the MX Keys S exposes Fn there. Not pursued.
diff --git a/packaging/linux/desktop/openlogi.desktop b/packaging/linux/desktop/openlogi.desktop
index 35117cad75fea4a6fadb1437fd85e609a7bc1d6b..59c0d298acaadba4ccc40cc512f9c0c0740feb82 100644
--- a/packaging/linux/desktop/openlogi.desktop
+++ b/packaging/linux/desktop/openlogi.desktop
@@ -5,6 +5,10 @@ Comment=Logitech HID++ device control — remap buttons, DPI, SmartShift
 Exec=openlogi-gui
 Icon=openlogi
 Terminal=false
+# Ties the running window (Wayland xdg-toplevel app_id / X11 WM_CLASS) back to
+# this launcher so GNOME groups it under the OpenLogi icon instead of a generic
+# one. Must match `openlogi_core::brand::APP_ID`, the value the GUI advertises.
+StartupWMClass=org.openlogi.openlogi
 Categories=Settings;HardwareSettings;
 Keywords=logitech;mouse;hid;remap;dpi;
 StartupNotify=true
diff --git a/packaging/linux/install.sh b/packaging/linux/install.sh
index 503ae5f25068ce0bc9340e7e3c666b68f12da944..698c7e72be9c3ee6c979e98103d2db81ec908c0e 100644
--- a/packaging/linux/install.sh
+++ b/packaging/linux/install.sh
@@ -83,6 +83,7 @@ if command -v udevadm > /dev/null 2>&1; then
     echo "Reloading udev rules …"
     sudo udevadm control --reload-rules
     sudo udevadm trigger --subsystem-match=hidraw
+    sudo udevadm trigger --subsystem-match=input
     sudo udevadm trigger --subsystem-match=misc --attr-match=name=uinput 2>/dev/null || true
 fi
 
diff --git a/packaging/linux/nfpm-scripts/postinstall.sh b/packaging/linux/nfpm-scripts/postinstall.sh
index 97f9ff89f2e3d2267870fa82b765a24d031d567f..0f7c222005797a8a87fa44361003574cdd676dae 100644
--- a/packaging/linux/nfpm-scripts/postinstall.sh
+++ b/packaging/linux/nfpm-scripts/postinstall.sh
@@ -3,10 +3,13 @@ set -eu
 
 # Reload udev rules and wait for the new uaccess tags to be applied.
 # udevadm trigger is asynchronous — settle ensures the tags are in place
-# before the script exits so the agent can open /dev/hidraw* immediately.
+# before the script exits so the agent can open /dev/hidraw* and the mouse's
+# /dev/input/event* node immediately, even for a device connected before the
+# install.
 if command -v udevadm > /dev/null 2>&1; then
     udevadm control --reload-rules
     udevadm trigger --subsystem-match=hidraw
+    udevadm trigger --subsystem-match=input
     udevadm trigger --subsystem-match=misc --attr-match=name=uinput 2>/dev/null || true
     udevadm settle 2>/dev/null || true
 fi
diff --git a/packaging/linux/udev/70-openlogi.rules b/packaging/linux/udev/70-openlogi.rules
index 07c33df3f78654981d4698e8d27d958ebd35858a..365932383f6d755ec33b6341829d295c27372dcd 100644
--- a/packaging/linux/udev/70-openlogi.rules
+++ b/packaging/linux/udev/70-openlogi.rules
@@ -1,8 +1,8 @@
 # OpenLogi udev rules
 #
-# Grants the active-seat user read/write access to Logitech HID devices and the
-# uinput kernel module — no group membership required on systems running
-# systemd-logind (uaccess tag).
+# Grants the active-seat user read/write access to Logitech HID devices, their
+# input event nodes, and the uinput kernel module — no group membership required
+# on systems running systemd-logind (uaccess tag).
 #
 # Install:
 #   sudo cp 70-openlogi.rules /etc/udev/rules.d/
@@ -25,3 +25,16 @@ SUBSYSTEM=="hidraw", KERNELS=="*:046D:*", TAG+="uaccess"
 # OPTIONS+="static_node=uinput" creates the node at boot even before any device
 # is plugged in, so the agent can open it without a trigger.
 KERNEL=="uinput", TAG+="uaccess", OPTIONS+="static_node=uinput"
+
+# Logitech pointer event nodes (evdev interface) — the read side of the hook.
+# hidraw alone is not enough: the hook enumerates /dev/input/event* to grab the
+# pointer. USB devices already get uaccess from logind's seat rules, but a
+# Bluetooth mouse hangs off /devices/virtual/misc/uhid, which belongs to no
+# seat, so those rules never tag it and its event node stays root:input 0660.
+#
+# Scoped to event nodes the kernel classifies as a mouse (ID_INPUT_MOUSE, set by
+# the input_id builtin in 60-input-id.rules, which runs before this file): a
+# Logitech keyboard's keystrokes must never become readable session-wide. The
+# two matchers cover the same two transports as the hidraw block above.
+SUBSYSTEM=="input", KERNEL=="event*", ENV{ID_INPUT_MOUSE}=="1", ATTRS{idVendor}=="046d", TAG+="uaccess"
+SUBSYSTEM=="input", KERNEL=="event*", ENV{ID_INPUT_MOUSE}=="1", KERNELS=="*:046D:*", TAG+="uaccess"
diff --git a/release-plz.toml b/release-plz.toml
index 6605b7d62307d59a79a082bde0647e5c06c6d4c2..ddb2a35631b295abb4991f8b760b6b26455e26d9 100644
--- a/release-plz.toml
+++ b/release-plz.toml
@@ -14,10 +14,11 @@
 # could attach assets — "target_commitish cannot be changed when release is
 # immutable". Keep `git_release_enable = false` so release.yml owns the lifecycle.)
 #
-# Single changelog: every crate points `changelog_path` at the repo-root
-# CHANGELOG.md, so release-plz aggregates all crates' sections into that one file
-# instead of scattering a CHANGELOG.md into each crate directory. (changelog_path
-# is per-package only — it can't be set in [workspace].)
+# Changelog: release-plz is package-path-scoped and skips `release = false` app
+# crates (gui/agent), so it does NOT own CHANGELOG.md. Whole-repo notes are
+# written by git-cliff via `cliff.toml` after each release-pr (same idea as
+# GoReleaser's `changelog.use: git` — every conventional commit since the last
+# tag, no per-crate path filter).
 
 [workspace]
 # Open release PRs from a `release-plz/`-prefixed branch.
@@ -29,11 +30,16 @@ semver_check = false
 # Per-crate tags/releases are off; the root crate owns the one workspace release.
 git_tag_enable = false
 git_release_enable = false
+# Version bumps only — root CHANGELOG.md is written by git-cliff (cliff.toml).
+changelog_update = false
+# Only publish/tag when the release PR merges (branch prefix above). A later
+# master tip after a failed crates.io publish must not cut v{version} — re-run
+# the failed release job on that same SHA once credentials are fixed.
+release_always = false
 
 [[package]]
 name = "openlogi"
 version_group = "openlogi"
-changelog_path = "CHANGELOG.md"
 git_tag_enable = true
 git_tag_name = "v{{ version }}"
 # GitHub Release is owned by release.yml (softprops), not release-plz — see header.
@@ -42,62 +48,47 @@ git_release_enable = false
 [[package]]
 name = "openlogi-core"
 version_group = "openlogi"
-changelog_path = "CHANGELOG.md"
 
 # OS input-event synthesis split out of openlogi-core (depends on it). Published
 # with the workspace under unified versioning.
 [[package]]
 name = "openlogi-inject"
 version_group = "openlogi"
-changelog_path = "CHANGELOG.md"
 
 [[package]]
 name = "openlogi-hid"
 version_group = "openlogi"
-changelog_path = "CHANGELOG.md"
 
 [[package]]
 name = "openlogi-assets"
 version_group = "openlogi"
-changelog_path = "CHANGELOG.md"
 
 [[package]]
 name = "openlogi-cli"
 version_group = "openlogi"
-changelog_path = "CHANGELOG.md"
 
 [[package]]
 name = "openlogi-hook"
 version_group = "openlogi"
-changelog_path = "CHANGELOG.md"
 
 # Vendored fork of the `hidpp` crate (0BSD, from lus/logy). Published with the
 # workspace under unified versioning; upstream's 0.3.0 is provenance only.
 [[package]]
 name = "openlogi-hidpp"
 version_group = "openlogi"
-changelog_path = "CHANGELOG.md"
 
-# Not publishable (git-only gpui deps); keep release-plz out of it entirely.
-# Its version still follows the shared workspace version via inheritance.
-# `publish = false` must mirror the crate's Cargo.toml: release-plz validates
-# publish consistency across *all* workspace packages before honoring `release`.
+# App crates: not crates.io packages (git gpui deps / login-item binary).
+# `publish = false` must mirror each crate's Cargo.toml.
 [[package]]
 name = "openlogi-gui"
 release = false
 publish = false
 
-# Shared headless orchestration for the background agent. Not publishable
-# (links git-only gpui-adjacent siblings); version follows the shared workspace
-# version by inheritance. `publish = false` mirrors the crate's Cargo.toml — see
-# the openlogi-gui note above.
 [[package]]
 name = "openlogi-agent-core"
 release = false
 publish = false
 
-# The headless background agent binary — shipped as a login-item helper inside
-# the .app, never published. publish=false mirrors its Cargo.toml.
 [[package]]
 name = "openlogi-agent"
 release = false
diff --git a/scripts/cargo-run-macos.sh b/scripts/cargo-run-macos.sh
index f622179df5fd1ffe2b07d31404ffb2f2713c2937..34e9b4427414de569dec605d23c3316893ef9116 100644
--- a/scripts/cargo-run-macos.sh
+++ b/scripts/cargo-run-macos.sh
@@ -7,7 +7,7 @@
 # the desktop binary it's a transparent passthrough (`exec "$@"`).
 #
 # For `openlogi-gui` it launches the build from inside a throwaway
-# `OpenLogi.app` so macOS shows the real app name (the bold menu-bar title)
+# `OpenLogi.app` so macOS shows the dev app name (the bold menu-bar title)
 # and the Dock icon during development. Both are read from the bundle's
 # `Info.plist` / `Resources` — a bare `target/debug/openlogi-gui` has neither,
 # so macOS falls back to the executable name and a generic icon.
@@ -94,8 +94,9 @@ if [ "$ICON_SRC" -nt "$RES/AppIcon.icns" ]; then
   cp -f "$ICON_SRC" "$RES/AppIcon.icns"
 fi
 
-# Info.plist — minimal, dev-only. A distinct `.dev` identifier keeps this
-# target artifact from registering as the production app in LaunchServices.
+# Info.plist — minimal, dev-only. A distinct `.dev` identifier and display name
+# keep this target artifact from registering as the production app in
+# LaunchServices or macOS Privacy & Security.
 PLIST="$APP/Contents/Info.plist"
 if [ "$PLIST_SRC" -nt "$PLIST" ]; then
   cp -f "$PLIST_SRC" "$PLIST"
diff --git a/scripts/release/write-changelog.sh b/scripts/release/write-changelog.sh
new file mode 100644
index 0000000000000000000000000000000000000000..2c4df7fa256127f26b817f3c97bb68e96165ff1b
--- /dev/null
+++ b/scripts/release/write-changelog.sh
@@ -0,0 +1,57 @@
+#!/usr/bin/env bash
+# Write the next workspace version section into CHANGELOG.md with git-cliff.
+# Whole-repo conventional commits since the previous v* tag (cliff.toml).
+set -euo pipefail
+
+root="$(git rev-parse --show-toplevel)"
+cd "$root"
+
+version="$(
+  python3 - <<'PY'
+import pathlib, re, sys
+text = pathlib.Path("Cargo.toml").read_text()
+m = re.search(r'(?ms)^\[workspace\.package\].*?^version\s*=\s*"([^"]+)"', text)
+if not m:
+    sys.exit("workspace.package version not found in Cargo.toml")
+print(m.group(1))
+PY
+)"
+tag="v${version}"
+
+last_tag="$(
+  git tag --list 'v*' \
+    | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' \
+    | sort -V \
+    | tail -n1
+)"
+if [[ -z "${last_tag}" ]]; then
+  echo "error: no previous vX.Y.Z tag" >&2
+  exit 1
+fi
+if [[ "${last_tag}" == "${tag}" ]]; then
+  echo "error: workspace version ${version} is already tagged as ${tag}" >&2
+  exit 1
+fi
+
+# Drop a stale section for this version (idempotent re-runs / release-pr updates).
+if grep -qE "^## \[${version}\]" CHANGELOG.md; then
+  python3 - "${version}" <<'PY'
+from pathlib import Path
+import re
+import sys
+
+version = sys.argv[1]
+text = Path("CHANGELOG.md").read_text()
+pattern = re.compile(
+    rf"(?ms)^## \[{re.escape(version)}\].*?(?=^## \[|\Z)"
+)
+Path("CHANGELOG.md").write_text(pattern.sub("", text, count=1))
+PY
+fi
+
+git cliff "${last_tag}.." \
+  --config cliff.toml \
+  --tag "${tag}" \
+  --prepend CHANGELOG.md
+
+echo "wrote ${tag} changelog from ${last_tag}..HEAD" >&2
diff --git a/xtask/Cargo.toml b/xtask/Cargo.toml
index 3c6ce161e74139f80050e5e8bd16ce5a6ea73efc..d661af5f2557efbb627fae68f37315937283859e 100644
--- a/xtask/Cargo.toml
+++ b/xtask/Cargo.toml
@@ -16,7 +16,7 @@ fs-err = "3.3.0"
 icns = { version = "0.4.0", default-features = false, features = ["pngio"] }
 image = { version = "0.25.10", default-features = false, features = ["png"] }
 path-absolutize = "3.1.1"
-plist = "1.9.0"
+plist = "1.10.0"
 serde = { workspace = true }
 serde_json = { workspace = true }
 sha2_hasher = { version = "0.3.2", features = ["sync"] }
diff --git a/xtask/README.md b/xtask/README.md
index 225a786016f2a5b6b3738ee634d6e16f78275aba..6f5a89d174cacb8ed650f01e1610465f9402210a 100644
--- a/xtask/README.md
+++ b/xtask/README.md
@@ -19,6 +19,17 @@ devenv shell -- cargo run -p xtask -- <command>
   `.pkg.tar.zst` artifacts with nfpm.
 - `release latest-json` — generate the static updater manifest for the stable channel.
 
+For local testing, `macos bundle` stamps the built app/helper as
+`org.openlogi.openlogi.dev` / `org.openlogi.agent.dev`, then signs the final
+layout with `OPENLOGI_LOCAL_CODESIGN_IDENTITY` or the first Apple Development
+identity it finds. This keeps local Accessibility/TCC grants isolated from the
+installed production `org.openlogi.agent` grant. Set `OPENLOGI_LOCAL_CODESIGN=0`
+only when you explicitly want an unsigned local bundle. `macos package` keeps
+the production bundle IDs and signs with `OPENLOGI_SIGN_IDENTITY` / `--sign-identity`.
+The raw DMG emitted by `cargo-bundle` is deleted during `macos bundle` because it
+is created before xtask embeds and signs the helper; use `macos package` when
+you need a DMG.
+
 The Cargo runner in `../scripts/cargo-run-macos.sh` stays outside xtask because
 Cargo must execute it while running arbitrary binaries, including this crate.
 The release-notes generator stays in `../scripts/release-notes` because it is a
diff --git a/xtask/src/commands/macos.rs b/xtask/src/commands/macos.rs
index b1a7a37954af9699cd694ec9dde77d35bc1e4f53..56612f9a814db093aa26223ed79d69bbf1b6c307 100644
--- a/xtask/src/commands/macos.rs
+++ b/xtask/src/commands/macos.rs
@@ -22,10 +22,8 @@ pub(crate) fn run(command: Command) -> Result<()> {
         Command::Bundle => bundle::run(),
         Command::Dmg(args) => dmg::run(&args),
         Command::Package(args) => {
-            bundle::run()?;
-            if let Some(identity) = &args.sign_identity {
-                bundle::sign_app(identity)?;
-            } else {
+            bundle::run_for_distribution(args.sign_identity.as_deref())?;
+            if args.sign_identity.is_none() {
                 println!("==> codesign: skipped (unsigned — set OPENLOGI_SIGN_IDENTITY to sign)");
             }
             dmg::run(&args)
diff --git a/xtask/src/commands/macos/bundle.rs b/xtask/src/commands/macos/bundle.rs
index 38bb21ef96256568e19b67b52e47bb403ea0da3e..5973c1b79c63e32723f850b32606731719821266 100644
--- a/xtask/src/commands/macos/bundle.rs
+++ b/xtask/src/commands/macos/bundle.rs
@@ -57,6 +57,14 @@ fn write_icns(master: &Path, output: &Path) -> Result<()> {
 }
 
 pub(crate) fn run() -> Result<()> {
+    run_with_profile(&BundleProfile::Local)
+}
+
+pub(crate) fn run_for_distribution(sign_identity: Option<&str>) -> Result<()> {
+    run_with_profile(&BundleProfile::Distribution { sign_identity })
+}
+
+fn run_with_profile(profile: &BundleProfile<'_>) -> Result<()> {
     let root = repo_root()?;
     let sh = Shell::new()?;
     let _repo = sh.push_dir(&root);
@@ -95,17 +103,46 @@ pub(crate) fn run() -> Result<()> {
             .envs(xcode_env.iter().map(|(key, value)| (key, value)))
             .run()?;
     }
+    remove_cargo_bundle_dmg(&root)?;
 
     let app = root.join("target/release/bundle/osx/OpenLogi.app");
     ensure_dir(&app)?;
     embed_agent_helper(&root, &app, &xcode_env)?;
     embed_cli(&root, &app, &xcode_env)?;
     verify_bundle_binaries(&app)?;
+    match profile {
+        BundleProfile::Local => {
+            stamp_local_bundle_identity(&app)?;
+            local_sign_app_if_available()?;
+        }
+        BundleProfile::Distribution { sign_identity } => {
+            if let Some(identity) = sign_identity {
+                sign_app_with_timestamp(identity, TimestampMode::Secure)?;
+            }
+        }
+    }
     println!();
     println!("Bundle ready: {}", app.display());
     Ok(())
 }
 
+enum BundleProfile<'a> {
+    Local,
+    Distribution { sign_identity: Option<&'a str> },
+}
+
+fn remove_cargo_bundle_dmg(root: &Path) -> Result<()> {
+    let dmg = root.join("target/release/bundle/dmg/OpenLogi.dmg");
+    if dmg.exists() {
+        fs_err::remove_file(&dmg)
+            .with_context(|| format!("could not remove stale {}", dmg.display()))?;
+        println!(
+            "    removed cargo-bundle DMG before helper embedding; use `macos package` for a DMG"
+        );
+    }
+    Ok(())
+}
+
 /// Build the headless agent and embed it as a nested login-item helper at
 /// `OpenLogi.app/Contents/Library/LoginItems/OpenLogiAgent.app`. The agent is
 /// the always-on process (hook + device I/O + menu bar); shipping it inside the
@@ -213,7 +250,79 @@ fn xcode_env() -> Result<Vec<(String, String)>> {
     ])
 }
 
-pub(crate) fn sign_app(identity: &str) -> Result<()> {
+fn stamp_local_bundle_identity(app: &Path) -> Result<()> {
+    println!("==> local bundle identity");
+    let app_info = app.join("Contents/Info.plist");
+    stamp_plist_strings(
+        &app_info,
+        &[
+            ("CFBundleDisplayName", "OpenLogi Dev"),
+            ("CFBundleIdentifier", "org.openlogi.openlogi.dev"),
+            ("CFBundleName", "OpenLogi Dev"),
+        ],
+    )?;
+
+    let helper_info = app.join("Contents/Library/LoginItems/OpenLogiAgent.app/Contents/Info.plist");
+    if helper_info.exists() {
+        stamp_plist_strings(
+            &helper_info,
+            &[
+                ("CFBundleDisplayName", "OpenLogi Agent Dev"),
+                ("CFBundleIdentifier", "org.openlogi.agent.dev"),
+                ("CFBundleName", "OpenLogi Agent Dev"),
+            ],
+        )?;
+    }
+
+    println!("    stamped local IDs: org.openlogi.openlogi.dev / org.openlogi.agent.dev");
+    Ok(())
+}
+
+fn stamp_plist_strings(info_plist: &Path, entries: &[(&str, &str)]) -> Result<()> {
+    let mut plist = Value::from_file(info_plist)
+        .with_context(|| format!("could not read {}", info_plist.display()))?;
+    let dict = plist
+        .as_dictionary_mut()
+        .with_context(|| format!("{} is not a plist dictionary", info_plist.display()))?;
+    for (key, value) in entries {
+        dict.insert((*key).into(), Value::String((*value).to_string()));
+    }
+    plist
+        .to_file_xml(info_plist)
+        .with_context(|| format!("could not write {}", info_plist.display()))
+}
+
+fn local_sign_app_if_available() -> Result<()> {
+    if env::var("OPENLOGI_LOCAL_CODESIGN").as_deref() == Ok("0") {
+        println!("==> local codesign: skipped (OPENLOGI_LOCAL_CODESIGN=0)");
+        return Ok(());
+    }
+
+    if let Some(identity) = env_nonempty("OPENLOGI_SIGN_IDENTITY") {
+        sign_app_with_timestamp(&identity, TimestampMode::Secure)?;
+        return Ok(());
+    }
+
+    if let Some(identity) = env_nonempty("OPENLOGI_LOCAL_CODESIGN_IDENTITY") {
+        sign_app_with_timestamp(&identity, TimestampMode::None)?;
+        return Ok(());
+    }
+
+    if let Some(identity) = first_apple_development_identity()? {
+        sign_app_with_timestamp(&identity, TimestampMode::None)?;
+        return Ok(());
+    }
+
+    println!(
+        "==> local codesign: skipped (no Apple Development identity found;          set OPENLOGI_LOCAL_CODESIGN_IDENTITY or OPENLOGI_SIGN_IDENTITY to sign)"
+    );
+    println!(
+        "    warning: unsigned/ad-hoc local bundles with production bundle IDs can          make macOS Accessibility grants appear stale or missing"
+    );
+    Ok(())
+}
+
+fn sign_app_with_timestamp(identity: &str, timestamp: TimestampMode) -> Result<()> {
     let sh = Shell::new()?;
     let app = repo_root()?.join("target/release/bundle/osx/OpenLogi.app");
     let helper = app.join("Contents/Library/LoginItems/OpenLogiAgent.app");
@@ -224,16 +333,16 @@ pub(crate) fn sign_app(identity: &str) -> Result<()> {
     // stable, separately-signed helper identity is exactly what lets the agent's
     // Accessibility (TCC) grant persist across updates. So sign each explicitly.
     if helper.exists() {
-        codesign_runtime(identity, &helper)?;
+        codesign_runtime(identity, &helper, timestamp)?;
     }
     // The embedded CLI is a second Mach-O under Contents/MacOS; sign it with the
     // hardened runtime before the outer app so it carries a Developer ID
     // signature (its as-built ad-hoc signature would fail notarization).
     let cli = app.join("Contents/MacOS/openlogi");
     if cli.exists() {
-        codesign_runtime(identity, &cli)?;
+        codesign_runtime(identity, &cli, timestamp)?;
     }
-    codesign_runtime(identity, &app)?;
+    codesign_runtime(identity, &app, timestamp)?;
     cmd!(sh, "codesign --verify --strict {app}").run()?;
     if helper.exists() {
         cmd!(sh, "codesign --verify --strict {helper}").run()?;
@@ -244,17 +353,55 @@ pub(crate) fn sign_app(identity: &str) -> Result<()> {
     Ok(())
 }
 
-/// Sign one bundle with the hardened runtime + a secure timestamp.
-fn codesign_runtime(identity: &str, target: &Path) -> Result<()> {
+/// Sign one bundle with the hardened runtime and the requested timestamp mode.
+fn codesign_runtime(identity: &str, target: &Path, timestamp: TimestampMode) -> Result<()> {
     let sh = Shell::new()?;
-    cmd!(
-        sh,
-        "codesign --force --options runtime --timestamp --sign {identity} {target}"
-    )
-    .run()?;
+    match timestamp {
+        TimestampMode::Secure => {
+            cmd!(
+                sh,
+                "codesign --force --options runtime --timestamp --sign {identity} {target}"
+            )
+            .run()?;
+        }
+        TimestampMode::None => {
+            cmd!(
+                sh,
+                "codesign --force --options runtime --timestamp=none --sign {identity} {target}"
+            )
+            .run()?;
+        }
+    }
     Ok(())
 }
 
+#[derive(Clone, Copy)]
+enum TimestampMode {
+    Secure,
+    None,
+}
+
+fn env_nonempty(name: &str) -> Option<String> {
+    env::var(name).ok().filter(|value| !value.trim().is_empty())
+}
+
+fn first_apple_development_identity() -> Result<Option<String>> {
+    let sh = Shell::new()?;
+    let Ok(output) = cmd!(sh, "security find-identity -v -p codesigning").read() else {
+        return Ok(None);
+    };
+    Ok(output
+        .lines()
+        .filter_map(quoted_identity)
+        .find(|identity| identity.starts_with("Apple Development:")))
+}
+
+fn quoted_identity(line: &str) -> Option<String> {
+    let start = line.find('"')? + 1;
+    let end = line[start..].find('"')?;
+    Some(line[start..start + end].to_string())
+}
+
 #[cfg(test)]
 #[allow(clippy::unwrap_used, reason = "unwrap is idiomatic in tests")]
 mod tests {