rustango-cms 0.3.0

A page-tree content management system for Rust, built on rustango
Documentation
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
/* rustango-cms admin chrome — Material 3 design system.
 *
 * Single source of truth for every /cms-admin/* screen + the
 * stand-alone auth flow (login / password-reset).
 *
 * Token tier (`--md-sys-*`): direct port of the Tailwind config in
 * the project-root `./design` reference. Component tier reads through
 * the alias layer (`--accent`, `--fg`, `--bg`, ...) so the existing
 * 77 class names in this file keep working without per-template
 * rewrites. Tenant-theme overrides emitted by `theme::emit_css()`
 * cascade ABOVE this file (loaded inline in `_base.html`), so the
 * resolution order is: built-in MD3 defaults → tenant theme overrides
 * → @media (prefers-color-scheme: dark).
 *
 * Host apps override by dropping `static/cms_admin/cms.css` in their
 * project root — the admin's static handler returns it instead of
 * this bundled file.
 *
 * Namespacing convention (#314):
 *   - The admin shell carries `.rcms-admin` on <body> (both _base.html
 *     and _auth_layout.html). It is the single scope anchor for the
 *     framework's chrome.
 *   - New component classes use the `rcms-` prefix. The legacy `cms-`
 *     classes are fully folded into `rcms-`; folding the remaining
 *     unprefixed/generic names (`.rcms-btn`, `.rcms-card`, `.rcms-field`, …) into the
 *     prefix is the #293-coordinated rewrite, in progress. Avoid bare
 *     generic names in new markup.
 *   - Bare element rules (typography, form controls) that would restyle
 *     user-authored HTML rendered INLINE in the admin (rich-text /
 *     stream / block previews) must be `@scope`d to `.rcms-admin` with a
 *     lower boundary at the user-content wrappers (`.rcms-block-*`,
 *     `.rcms-stream-block`, `.rcms-block-picker-tile-preview`, `.rcms-display-chip-value`)
 *     so admin chrome never leaks into stored content. The page-preview
 *     pane is already iframe-isolated and needs no scoping.
 */

/* ============================================================
 * 1. MD3 design tokens
 * ============================================================ */

:root {
    /* Color roles — light mode. A white-and-black chrome: neutral cool
       surfaces, hairline borders, and nothing saturated competing with
       the content.

       `primary` stays a *legible* muted blue rather than a pale tint,
       because it is read as TEXT in 8 rules and as a BORDER in 25 —
       a pale value there would leave button labels and links unreadable
       on white. The pale tone the chrome actually shows comes from the
       `-fixed` tier below, which is what fills buttons and chips. Keep
       that split: lightening `primary` itself is the tempting one-line
       change that quietly fails contrast everywhere it is text. */
    --md-sys-color-primary: #4a6d9e;
    --md-sys-color-on-primary: #ffffff;
    --md-sys-color-primary-container: #dbe7f6;
    --md-sys-color-on-primary-container: #1e3a5f;
    /* The pale fill + its dark ink + the hairline that edges it. */
    --md-sys-color-primary-fixed: #e0e9f8;
    --md-sys-color-primary-fixed-dim: #b6cdec;
    --md-sys-color-on-primary-fixed: #1e3a5f;
    --md-sys-color-on-primary-fixed-variant: #2f5480;

    --md-sys-color-secondary: #64748b;
    --md-sys-color-on-secondary: #ffffff;
    --md-sys-color-secondary-container: #f1f5f9;
    --md-sys-color-on-secondary-container: #334155;

    --md-sys-color-tertiary: #8a5a44;
    --md-sys-color-on-tertiary: #ffffff;
    --md-sys-color-tertiary-container: #f0e2db;
    --md-sys-color-on-tertiary-container: #5c3625;
    --md-sys-color-tertiary-fixed: #ffdbcf;
    --md-sys-color-tertiary-fixed-dim: #ffb59c;

    --md-sys-color-error: #b42318;
    --md-sys-color-on-error: #ffffff;
    --md-sys-color-error-container: #fee4e2;
    --md-sys-color-on-error-container: #912018;

    --md-sys-color-success: #157f5f;
    --md-sys-color-on-success: #ffffff;
    --md-sys-color-success-container: #dcfce7;
    --md-sys-color-on-success-container: #065f46;

    --md-sys-color-warning: #b45309;
    --md-sys-color-on-warning: #ffffff;
    --md-sys-color-warning-container: #fef3c7;
    --md-sys-color-on-warning-container: #92400e;

    --md-sys-color-surface: #ffffff;
    --md-sys-color-surface-dim: #e2e8f0;
    --md-sys-color-surface-bright: #ffffff;
    --md-sys-color-surface-container-lowest: #ffffff;
    --md-sys-color-surface-container-low: #f8fafc;
    --md-sys-color-surface-container: #f1f5f9;
    --md-sys-color-surface-container-high: #e9eef4;
    --md-sys-color-surface-container-highest: #e2e8f0;
    --md-sys-color-surface-variant: #eef2f6;
    --md-sys-color-on-surface: #0f172a;
    --md-sys-color-on-surface-variant: #475569;
    --md-sys-color-surface-tint: #4a6d9e;

    --md-sys-color-outline: #94a3b8;
    --md-sys-color-outline-variant: #e2e8f0;

    --md-sys-color-inverse-surface: #1e293b;
    --md-sys-color-inverse-on-surface: #f1f5f9;
    --md-sys-color-inverse-primary: #b6cdec;

    /* Shape — corner radii. */
    --md-sys-radius-sm: 2px;
    --md-sys-radius-md: 4px;
    --md-sys-radius-lg: 8px;
    --md-sys-radius-xl: 12px;
    --md-sys-radius-full: 9999px;

    /* Elevation — three tiers using paired shadows (one tight + one
       diffuse) so depth reads on light surfaces without becoming
       muddy. Tuned warmer + slightly stronger than the design's raw
       0.03-alpha — under hands-on review the chrome wanted more
       definition between surface tiers. */
    --md-sys-elevation-1: 0px 1px 2px rgba(15, 23, 42, 0.05);
    --md-sys-elevation-2: 0px 2px 6px rgba(15, 23, 42, 0.06),
                          0px 1px 2px rgba(15, 23, 42, 0.04);
    --md-sys-elevation-3: 0px 8px 20px rgba(15, 23, 42, 0.08),
                          0px 2px 6px rgba(15, 23, 42, 0.05);
    /* Tinted shadow for the primary filled button — a soft halo of
       the primary hue lifts it off the surface without using a
       darker grey shadow (which always reads heavy on filled M3). */

    /* Type — Hanken Grotesk for UI, Literata for editorial body. */
    --md-sys-font-ui: 'Hanken Grotesk', 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    --md-sys-font-editor: 'Literata', Georgia, 'Times New Roman', serif;

    --md-sys-typescale-display-lg: 700 48px/60px var(--md-sys-font-ui);
    --md-sys-typescale-ui-header: 600 18px/24px var(--md-sys-font-ui);
    --md-sys-typescale-ui-body: 400 14px/20px var(--md-sys-font-ui);
    --md-sys-typescale-ui-button: 500 14px/20px var(--md-sys-font-ui);
    --md-sys-typescale-ui-label: 600 12px/16px var(--md-sys-font-ui);
    --md-sys-typescale-editor-text: 400 16px/1.7 var(--md-sys-font-editor);

    /* ----------------------------------------------------------
     * 1a. Alias layer — existing chrome variables map onto MD3
     *     tokens. The 77 existing class names below this block
     *     keep working without per-template rewrites.
     * ---------------------------------------------------------- */
    --fg: var(--md-sys-color-on-surface);
    --muted: var(--md-sys-color-on-surface-variant);
    --muted-2: var(--md-sys-color-outline);
    --accent: var(--md-sys-color-primary);
    --accent-hover: var(--md-sys-color-primary-container);
    --accent-soft: var(--md-sys-color-primary-fixed);
    --accent-soft-2: var(--md-sys-color-primary-fixed-dim);
    /* #293 phase 1 — the `--violet*` alias trio was an early
       shorthand that no template or stylesheet ever read; removed.
       Templates that need the tertiary swatch reference
       `--md-sys-color-tertiary*` directly (the styleguide + the
       brand-image card both already do). */
    --border: var(--md-sys-color-outline-variant);
    /* Link colour, one hop from the accent so a tenant theme still drives
       it. Indirected through its own token because the theme bridge emits
       `--md-sys-color-primary` from a single `color_link` field with no
       dark counterpart, so in dark mode a theme re-asserts its LIGHT accent
       over this stylesheet. The dark blocks below lift this toward white
       instead of inheriting that. */
    --rcms-link: var(--md-sys-color-primary);
    --rcms-link-hover: var(--md-sys-color-on-primary-fixed);
    --border-strong: var(--md-sys-color-outline);
    --bg: var(--md-sys-color-surface);
    --bg-elevated: var(--md-sys-color-surface-container-lowest);
    --danger: var(--md-sys-color-error);
    --danger-soft: var(--md-sys-color-error-container);
    --danger-hover: var(--md-sys-color-on-error-container);
    --success: var(--md-sys-color-success);
    --success-soft: var(--md-sys-color-success-container);
    --success-hover: var(--md-sys-color-on-success-container);
    --warning: var(--md-sys-color-warning);
    --warning-soft: var(--md-sys-color-warning-container);
    --warning-hover: var(--md-sys-color-on-warning-container);

    /* Sidebar palette — M3 nav rail. Light surface with on-surface
       text; primary becomes the *active* color, not the background.
       Matches the design file's `bg-surface-container-low` aside. */
    --sidebar-bg: var(--md-sys-color-surface);
    --sidebar-fg: var(--md-sys-color-on-surface);
    --sidebar-fg-muted: var(--md-sys-color-on-surface-variant);
    --sidebar-active: var(--md-sys-color-primary);
    --sidebar-active-bg: var(--md-sys-color-primary-fixed);
    --sidebar-hover-bg: var(--md-sys-color-surface-container);
    --sidebar-border: var(--md-sys-color-outline-variant);

    --font-body: var(--md-sys-font-ui);
    --font-heading: var(--md-sys-font-ui);
    --radius-md: var(--md-sys-radius-md);
}

/* Dark token block applies in TWO contexts:
 *   1. OS dark mode (`@media (prefers-color-scheme: dark)`), unless
 *      the user explicitly chose Light via the toggle (`[data-theme="light"]`).
 *   2. Explicit Dark choice via the toggle (`[data-theme="dark"]`),
 *      regardless of OS pref.
 * CSS can't combine an `@media` query with another selector via comma,
 * so the body is duplicated below. Keep them in sync. */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        /* Dark mode mirrors the light chrome's restraint rather than
           asserting its own identity: neutral charcoal surfaces with
           no hue cast, and the same muted blue accent family. The
           button tier stays subdued-fill + light ink, so a control
           reads the same way in either mode. */

        /* Primary — violet-400 family. */
        --md-sys-color-primary: #9db8dc;
        --md-sys-color-on-primary: #10243b;
        --md-sys-color-primary-container: #2f4c72;
        --md-sys-color-on-primary-container: #dce8f7;
        --md-sys-color-primary-fixed: #223449;
        --md-sys-color-primary-fixed-dim: #33506f;
        --md-sys-color-on-primary-fixed: #dce8f7;
        --md-sys-color-on-primary-fixed-variant: #9db8dc;

        /* Tertiary becomes the emerald accent — used for success
           states + focus highlights + the "right rail" cues. */
        --md-sys-color-tertiary: #34d399;
        --md-sys-color-on-tertiary: #064e3b;
        --md-sys-color-tertiary-container: #047857;
        --md-sys-color-on-tertiary-container: #d1fae5;
        --md-sys-color-tertiary-fixed: #064e3b;
        --md-sys-color-tertiary-fixed-dim: #065f46;

        /* Success — emerald, matching the tertiary accent so the two
           reinforce each other in dark mode. */
        --md-sys-color-success: #34d399;
        --md-sys-color-on-success: #064e3b;
        --md-sys-color-success-container: #047857;
        --md-sys-color-on-success-container: #d1fae5;

        /* Surface containers — charcoal with a faint violet tint
           so the chrome reads warm against the violet primary. */
        --md-sys-color-surface: #0f1115;
        --md-sys-color-surface-dim: #0a0c0f;
        --md-sys-color-surface-bright: #2a2f39;
        --md-sys-color-surface-container-lowest: #070809;
        --md-sys-color-surface-container-low: #161920;
        --md-sys-color-surface-container: #1b1f27;
        --md-sys-color-surface-container-high: #222731;
        --md-sys-color-surface-container-highest: #2a2f39;
        --md-sys-color-surface-variant: #222731;
        /* The theme cannot tell us a dark link colour (no `color_link_dark`
           on the model), and its light accent is too dark on charcoal —
           #4a6d9e on #0f1117 is roughly 3.5:1. Lift whatever it chose
           toward white so any theme stays readable here. */
        --rcms-link: color-mix(in srgb, var(--md-sys-color-primary) 55%, white);
        --rcms-link-hover: color-mix(in srgb, var(--md-sys-color-primary) 25%, white);
        --md-sys-color-on-surface: #e6e9ef;
        --md-sys-color-on-surface-variant: #aab3c2;

        --md-sys-color-outline: #7c8598;
        --md-sys-color-outline-variant: #2a303c;

        --md-sys-color-error: #ffb4ab;
        --md-sys-color-on-error: #690005;
        --md-sys-color-error-container: #93000a;
        --md-sys-color-on-error-container: #ffdad6;

        /* Re-tune the sidebar palette for dark mode so the active
           pill picks up violet against the violet-tinted charcoal. */
        --sidebar-bg: var(--md-sys-color-surface);
        --sidebar-fg: var(--md-sys-color-on-surface);
        --sidebar-fg-muted: var(--md-sys-color-on-surface-variant);
        --sidebar-active: var(--md-sys-color-primary);
        --sidebar-active-bg: var(--md-sys-color-primary-fixed-dim);
        --sidebar-hover-bg: var(--md-sys-color-surface-container);
        --sidebar-border: var(--md-sys-color-outline-variant);
    }
}

/* Explicit dark — mirrors the @media block above. Both bodies must
 * stay in sync (CSS can't deduplicate across an @media boundary). */
:root[data-theme="dark"] {
    color-scheme: dark;

    /* Primary — violet-400 family. */
    --md-sys-color-primary: #9db8dc;
    --md-sys-color-on-primary: #10243b;
    --md-sys-color-primary-container: #2f4c72;
    --md-sys-color-on-primary-container: #dce8f7;
    --md-sys-color-primary-fixed: #223449;
    --md-sys-color-primary-fixed-dim: #33506f;
    --md-sys-color-on-primary-fixed: #dce8f7;
    --md-sys-color-on-primary-fixed-variant: #9db8dc;

    /* Tertiary becomes the emerald accent. */
    --md-sys-color-tertiary: #34d399;
    --md-sys-color-on-tertiary: #064e3b;
    --md-sys-color-tertiary-container: #047857;
    --md-sys-color-on-tertiary-container: #d1fae5;
    --md-sys-color-tertiary-fixed: #064e3b;
    --md-sys-color-tertiary-fixed-dim: #065f46;

    /* Success — emerald, matching the tertiary accent. */
    --md-sys-color-success: #34d399;
    --md-sys-color-on-success: #064e3b;
    --md-sys-color-success-container: #047857;
    --md-sys-color-on-success-container: #d1fae5;

    /* Surface containers — charcoal with a faint violet tint. */
    --md-sys-color-surface: #0f1115;
    --md-sys-color-surface-dim: #0a0c0f;
    --md-sys-color-surface-bright: #2a2f39;
    --md-sys-color-surface-container-lowest: #070809;
    --md-sys-color-surface-container-low: #161920;
    --md-sys-color-surface-container: #1b1f27;
    --md-sys-color-surface-container-high: #222731;
    --md-sys-color-surface-container-highest: #2a2f39;
    --md-sys-color-surface-variant: #222731;
        /* The theme cannot tell us a dark link colour (no `color_link_dark`
           on the model), and its light accent is too dark on charcoal —
           #4a6d9e on #0f1117 is roughly 3.5:1. Lift whatever it chose
           toward white so any theme stays readable here. */
        --rcms-link: color-mix(in srgb, var(--md-sys-color-primary) 55%, white);
        --rcms-link-hover: color-mix(in srgb, var(--md-sys-color-primary) 25%, white);
    --md-sys-color-on-surface: #e6e9ef;
    --md-sys-color-on-surface-variant: #aab3c2;

    --md-sys-color-outline: #7c8598;
    --md-sys-color-outline-variant: #2a303c;

    --md-sys-color-error: #ffb4ab;
    --md-sys-color-on-error: #690005;
    --md-sys-color-error-container: #93000a;
    --md-sys-color-on-error-container: #ffdad6;

    --sidebar-bg: var(--md-sys-color-surface);
    --sidebar-fg: var(--md-sys-color-on-surface);
    --sidebar-fg-muted: var(--md-sys-color-on-surface-variant);
    --sidebar-active: var(--md-sys-color-primary);
    --sidebar-active-bg: var(--md-sys-color-primary-fixed-dim);
    --sidebar-hover-bg: var(--md-sys-color-surface-container);
    --sidebar-border: var(--md-sys-color-outline-variant);
}

/* ============================================================
 * 1b. Accessibility prefs (#14) — driven by `[data-text-scale]`
 *     and `[data-high-contrast]` on <html>. Toggle UI lives in the
 *     sidebar footer; preferences persist in localStorage.
 * ============================================================ */

/* Text scale — applied as root font-size %, which `em`-based units
   in cms.css and `rem`-based units in editor templates both pick up.
   Default (M) is omitted: it's 100%. */
:root[data-text-scale="s"]  { font-size: 87.5%; }
:root[data-text-scale="l"]  { font-size: 112.5%; }
:root[data-text-scale="xl"] { font-size: 125%; }

/* High-contrast — bumps border weight + opacity, swaps the focus
   ring color to maximum contrast, darkens muted text. */
:root[data-high-contrast] {
    --md-sys-color-outline: #000000;
    --md-sys-color-outline-variant: #4a4a4a;
    --md-sys-color-on-surface-variant: #1a1a1a;
}
:root[data-high-contrast] .rcms-card,
:root[data-high-contrast] table.rcms-data,
:root[data-high-contrast] .rcms-field input,
:root[data-high-contrast] .rcms-field select,
:root[data-high-contrast] .rcms-field textarea,
:root[data-high-contrast] .rcms-btn-outlined,
:root[data-high-contrast] .rcms-sidebar-logout,
:root[data-high-contrast] .rcms-mode-toggle,
:root[data-high-contrast] .rcms-search-input,
:root[data-high-contrast] select:not(.rcms-field select) {
    border-width: 2px;
}
:root[data-high-contrast] :focus,
:root[data-high-contrast] :focus-visible {
    /* #336 — dual-ring focus that reads on ANY background. Outer ring is
       the forced max-contrast neutral (--md-sys-color-outline = #000 in
       light / #fff in dark) instead of `primary`, which blended into
       filled / active primary surfaces. The inner --md-sys-color-surface
       band (≈white in light / dark in dark — the inverse tone) fills the
       outline-offset gap, so on the dark sidebar (where the black outline
       has little contrast) the light band still reads, and vice-versa.
       `!important` keeps a control's decorative elevation shadow from
       suppressing the ring. */
    outline: 3px solid var(--md-sys-color-outline);
    outline-offset: 2px;
    box-shadow: 0 0 0 2px var(--md-sys-color-surface) !important;
}
:root[data-high-contrast][data-theme="dark"] {
    --md-sys-color-outline: #ffffff;
    --md-sys-color-outline-variant: #c4b5d9;
    --md-sys-color-on-surface-variant: #f5f3ff;
}
/* Sidebar links are stacked ~2px apart, so an *outset* focus ring (offset +
   the high-contrast dual ring) spills onto the items above/below and reads as
   overlapping menu rows. Inset the ring so it stays inside each link. */
.rcms-sidebar-link:focus-visible {
    outline-offset: -2px;
}
:root[data-high-contrast] .rcms-sidebar-link:focus,
:root[data-high-contrast] .rcms-sidebar-link:focus-visible {
    outline-offset: -3px;
    box-shadow: none !important;
}

/* ============================================================
 * 2. Reset + global type
 * ============================================================ */

/* #314 — the universal box-sizing reset and the body chrome are
   qualified on the admin root class so cms.css can never restyle a
   host page that happens to load it. */
body.rcms-admin, .rcms-admin * { box-sizing: border-box; }
/* `[hidden]` actually hides things.
   The UA rule is `[hidden] { display: none }` at the lowest possible
   specificity, so ANY author `display` on the element wins and a
   "hidden" node stays on screen. This repo had hit that trap in
   seventeen separate places, each patched with its own
   `.some-class[hidden]` guard; the preview pane hit it again and
   rendered the HTML stage and the JSON body stacked on top of each
   other. One rule, scoped to the admin root so it can never touch a
   host page, ends the whole class of bug — `!important` because it has
   to outrank whatever `display` the component sets. */
.rcms-admin [hidden] { display: none !important; }
html:has(> body.rcms-admin), body.rcms-admin { height: 100%; }
/* Links.
 *
 * The admin had no rule for `<a>` at all. Every link either carried a
 * component class that painted it (`.rcms-btn`, `.rcms-sidebar-link`, …)
 * or fell through to the browser default — bright blue, thickly
 * underlined — which is what showed up in the "Referenced by" table and a
 * dozen other cells. Not a regression; there was simply never a link
 * identity to inherit.
 *
 * `:where()` is doing real work here: it contributes **zero** specificity,
 * so this reads as plain `a` (0,0,1) while still being scoped to the admin
 * document. Written as `.rcms-admin a` it would score (0,1,1) and outrank
 * every single-class component — recolouring the text of every `<a
 * class="rcms-btn">` on the site. The scope is worth keeping: cms.css is
 * also loaded by host apps that render public markup nearby.
 *
 * A component that paints its own colour still wins, so this only reaches
 * links nothing else claimed. */
:where(.rcms-admin) a {
    color: var(--rcms-link);
    /* Underline present but quiet — the affordance without the shout,
       matching the hairline-border chrome. It firms up on hover. */
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
    text-decoration-color: color-mix(in srgb, currentColor 30%, transparent);
    transition: color 0.12s, text-decoration-color 0.12s;
}
:where(.rcms-admin) a:hover {
    color: var(--rcms-link-hover);
    text-decoration-color: currentColor;
}

body.rcms-admin {
    font: var(--md-sys-typescale-ui-body);
    /* Override the shorthand's literal 14px with rem so the
       per-user text-scale toggle (#14) can scale body content via
       :root[data-text-scale]'s font-size %. Components that use the
       typescale shorthand directly (buttons, chips) intentionally
       stay at fixed px so the chrome density doesn't drift. */
    font-size: 0.875rem;
    line-height: 1.43;
    color: var(--fg);
    margin: 0;
    background: var(--bg);
    display: flex;
    height: 100vh;
    /* Lock body height so the sidebar can be a fixed-height flex
       column. Scrolling happens inside `.rcms-app-main` (the right-hand
       column), which keeps the sidebar perfectly stationary even on
       long edit pages. */
    overflow: hidden;
}
/* #314 — scope the heading font to the admin shell, stopping at inline
   user-content wrappers so a user's stored <h2> in a rich-text / stream /
   block preview keeps its own (public/UA) font instead of admin chrome. */
@scope (.rcms-admin) to (.rcms-block-paragraph, .rcms-block-rich-text, .rcms-block-raw-html, .rcms-block-snippet-chooser, .rcms-block-picker-tile-preview, .rcms-stream-block, .rcms-display-chip-value) {
    h1, h2, h3, h4, h5, h6 { font-family: var(--font-heading); }
}

/* ============================================================
 * 3. Material Symbols icons
 * ============================================================ */

.material-symbols-rounded {
    font-family: 'Material Symbols Rounded';
    font-weight: normal;
    font-style: normal;
    font-size: 20px;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    display: inline-block;
    white-space: nowrap;
    word-wrap: normal;
    direction: ltr;
    -webkit-font-feature-settings: 'liga';
    -webkit-font-smoothing: antialiased;
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
    vertical-align: -4px;
}
.material-symbols-rounded.filled {
    font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 24;
}
.material-symbols-rounded.sm { font-size: 18px; vertical-align: -3px; }
.material-symbols-rounded.lg { font-size: 24px; vertical-align: -6px; }

/* ============================================================
 * 4. Sidebar
 * ============================================================ */

.rcms-sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    color: var(--sidebar-fg);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    flex-shrink: 0;
    /* No edge shadow or divider: the rail shares the page's surface, so
       the shell reads as one canvas with the cards raised on top of it.
       An elevation here would re-introduce the "separate panel" look. */
    z-index: 1;
    /* #271 — smooth width transition for the collapse toggle. */
    transition: width 0.18s ease;
}

/* #272 — Collapsible sidebar group (e.g. Reports). Native
   `<details>` powers the open/closed toggle so the chevron click,
   keyboard activation, and accessibility tree all work without
   custom JS. `.rcms-sidebar-group-summary` is the parent row;
   `.rcms-sidebar-group-items` wraps the nested links and animates
   expand/collapse via a grid-template-rows trick (rows track
   interpolates from 0fr to 1fr, so the wrapper's height tweens
   with the content). */
.rcms-sidebar-group {
    display: block;
}
.rcms-sidebar-group-summary {
    /* Hide the native disclosure triangle — we draw our own chevron. */
    list-style: none;
    cursor: pointer;
    user-select: none;
}
.rcms-sidebar-group-summary::-webkit-details-marker { display: none; }
.rcms-sidebar-group-label {
    /* Push the chevron to the far right of the summary row. */
    flex: 1;
}
.rcms-sidebar-group-chevron {
    font-size: 18px !important;
    transition: transform 0.18s ease;
    opacity: 0.7;
}
.rcms-sidebar-group[open] > .rcms-sidebar-group-summary .rcms-sidebar-group-chevron {
    transform: rotate(180deg);
}
.rcms-sidebar-group.active > .rcms-sidebar-group-summary {
    /* Subtle tint on the parent row when any child is the current
       page — reinforces "you are here, inside this group". Lighter
       than the full `.active` treatment so the actual current item
       still reads as the primary highlight. */
    color: var(--md-sys-color-on-surface);
}
/* Nested links sit a touch deeper than top-level entries so the
   group reads as nested in scan. */
.rcms-sidebar-group-items .rcms-sidebar-link {
    padding-left: 36px;
    font-size: 13px;
}
.rcms-sidebar-group-items .rcms-sidebar-link .material-symbols-rounded {
    font-size: 18px;
}
/* Smooth expand/collapse. Override the user-agent stylesheet that
   slot-hides <details>'s non-summary children so they stay in
   layout for the JS-driven height animation in cms-ux.js. CSS
   alone can't transition between `0` and `auto`, so the JS
   intercepts the <summary> click, sets inline `height: <px>` to
   the measured scrollHeight, lets the transition run, then
   clears the inline style at transitionend so the [open] rule's
   `height: auto` takes back over (and the group grows naturally
   if items are added/removed dynamically). */
.rcms-sidebar-group > *:not(summary) {
    display: block;
}
.rcms-sidebar-group-items {
    overflow: hidden;
    height: 0;
    opacity: 0;
    transition: height 0.22s cubic-bezier(0.2, 0, 0, 1),
                opacity 0.16s ease;
}
.rcms-sidebar-group[open] > .rcms-sidebar-group-items {
    height: auto;
    opacity: 1;
}

/* Collapsed-rail tweaks: drop the chevron + label so the group's
   summary looks like a regular icon entry; force the items rail
   open so nested icons stay visible without requiring a click. */
html[data-sidebar-collapsed] .rcms-sidebar-group > .rcms-sidebar-group-items {
    height: auto;
    opacity: 1;
}
html[data-sidebar-collapsed] .rcms-sidebar-group-chevron,
html[data-sidebar-collapsed] .rcms-sidebar-group-label {
    display: none;
}
html[data-sidebar-collapsed] .rcms-sidebar-group-items .rcms-sidebar-link {
    padding-left: 0;
}

.rcms-sidebar-brand {
    padding: 24px 24px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.rcms-sidebar-brand::before {
    content: "";
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    border-radius: var(--md-sys-radius-lg);
    background:
        linear-gradient(135deg, var(--md-sys-color-primary), var(--md-sys-color-primary-container));
    box-shadow: 0 4px 12px color-mix(in srgb, var(--md-sys-color-primary) 30%, transparent);
}
/* An uploaded logo IS the brand mark — drop the decorative gradient square. */
.rcms-sidebar-brand.has-logo::before {
    display: none;
}
/* The Rustango CMS icon, when the tenant has no logo. */
.rcms-sidebar-brand-mark {
    display: block;
    flex: 0 0 36px;
    line-height: 0;
}
.rcms-sidebar-brand-mark img {
    width: 36px;
    height: 36px;
}
.rcms-sidebar-brand h1 {
    font: var(--md-sys-typescale-ui-header);
    font-size: 15px;
    margin: 0 0 2px;
    color: var(--md-sys-color-on-surface);
}
.rcms-sidebar-brand .rcms-tenant {
    font: var(--md-sys-typescale-ui-label);
    text-transform: none;
    letter-spacing: 0;
    color: var(--sidebar-fg-muted);
}
/* #77 — global search, sidebar edition. Search is navigation, so it
   sits with the nav rather than in the topbar, where a three-child
   `space-between` row left it stranded in the middle. */
.rcms-sidebar-search {
    padding: 0 12px 10px;
    flex: 0 0 auto;
}
/* Anchored inside the sidebar deliberately: `.rcms-sidebar` is
   `overflow-y: auto`, so a dropdown positioned outside its box gets
   clipped. It spans the rail and scrolls itself instead. */
.rcms-sidebar-search-dropdown {
    position: absolute;
    left: 12px;
    right: 12px;
    top: calc(100% - 4px);
    background: var(--md-sys-color-surface-container-lowest);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-radius-md);
    box-shadow: var(--md-sys-elevation-2);
    max-height: 60vh;
    overflow-y: auto;
    z-index: 100;
}

/* Collapsed rail — the input has nowhere to go, so the capsule becomes
   a centred icon button. It doesn't submit: a form with no submit button
   and a hidden input has nothing to trigger, which is why the icon used
   to be inert. cms-ux.js widens the sidebar and focuses the input
   instead, and the `/` shortcut takes the same path. */
html[data-sidebar-collapsed] .rcms-sidebar-search {
    padding: 0 8px 10px;
}
html[data-sidebar-collapsed] .rcms-search-input--sidebar {
    justify-content: center;
    padding: 0;
    cursor: pointer;
}
html[data-sidebar-collapsed] .rcms-search-input--sidebar input {
    display: none;
}

.rcms-sidebar-nav {
    flex: 1;
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.rcms-sidebar-section {
    font: var(--md-sys-typescale-ui-label);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--sidebar-fg-muted);
    padding: 18px 12px 6px;
}
.rcms-sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    color: var(--sidebar-fg-muted);
    text-decoration: none;
    font: var(--md-sys-typescale-ui-button);
    /* `lg`, not the pill radius. A pill reads well on a capsule-shaped
       control — an icon button, a chip, the 32px collapse toggle —
       where height and width are close. On a 236x40 nav row it turns
       into a lozenge with 20px semicircular ends, which fights the 8px
       language every button and menu uses. Compact capsules keep their
       pill; full-width rows use `lg`. */
    border-radius: var(--md-sys-radius-lg);
    transition: background 0.12s, color 0.12s;
}
.rcms-sidebar-link .material-symbols-rounded {
    font-size: 20px;
    color: var(--sidebar-fg-muted);
    transition: color 0.12s;
}
.rcms-sidebar-link:hover {
    background: var(--sidebar-hover-bg);
    color: var(--md-sys-color-on-surface);
}
.rcms-sidebar-link:hover .material-symbols-rounded {
    color: var(--md-sys-color-on-surface);
}
.rcms-sidebar-link.active {
    background: var(--sidebar-active-bg);
    color: var(--md-sys-color-on-primary-fixed);
    font-weight: 600;
}
.rcms-sidebar-link.active .material-symbols-rounded {
    color: var(--md-sys-color-on-primary-fixed);
}
.rcms-sidebar-link .rcms-icon {
    display: inline-block;
    width: 16px;
    font-size: 14px;
    text-align: center;
}
.rcms-sidebar-footer {
    padding: 16px 16px 20px;
    border-top: 1px solid var(--sidebar-border);
    font: var(--md-sys-typescale-ui-label);
    text-transform: none;
    letter-spacing: 0;
    color: var(--sidebar-fg-muted);
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.rcms-sidebar-footer a {
    color: var(--sidebar-fg-muted);
    text-decoration: none;
}
.rcms-sidebar-footer a:hover { color: var(--md-sys-color-primary); }
/* Light / Dark / System segmented toggle — three Material-symbol
   icons in a single pill, with the active mode highlighted.
   `.rcms-text-scale-toggle` (#14) shares the same shape; the only
   difference is the button glyph (A at progressively larger sizes). */
.rcms-mode-toggle,
.rcms-text-scale-toggle {
    display: inline-flex;
    background: var(--md-sys-color-surface-container);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-radius-full);
    padding: 2px;
    gap: 2px;
    /* Let the bar size to its contents so the pills inside get
       breathing room. `align-self: stretch` previously pinned each
       segment to equal-share which cramped the longer labels. */
    flex-wrap: wrap;
}
.rcms-mode-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 32px;
    padding: 0 14px;
    background: transparent;
    color: var(--md-sys-color-on-surface-variant);
    border: 0;
    border-radius: var(--md-sys-radius-full);
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
    white-space: nowrap;
    font: var(--md-sys-typescale-ui-button);
}
.rcms-mode-toggle-btn:hover {
    color: var(--md-sys-color-on-surface);
}
.rcms-mode-toggle-btn.active,
.rcms-mode-toggle-btn[aria-checked="true"] {
    background: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
}
.rcms-mode-toggle-btn .material-symbols-rounded {
    font-size: 16px;
    vertical-align: 0;
}

.rcms-sidebar-logout {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    /* Padding-driven height put this at 38px next to a 40px `.rcms-btn`.
       It is a link styled as a button, so it takes the button height. */
    height: 40px;
    padding: 0 14px;
    background: transparent;
    color: var(--md-sys-color-on-surface-variant);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-radius-full);
    font: var(--md-sys-typescale-ui-button);
    text-transform: none;
    letter-spacing: 0;
    cursor: pointer;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.rcms-sidebar-logout:hover {
    background: var(--md-sys-color-error-container);
    color: var(--md-sys-color-on-error-container);
    border-color: var(--md-sys-color-error);
}
.rcms-sidebar-logout .material-symbols-rounded { font-size: 16px; }
/* #337 — equalize the stacked footer buttons. "Sign out" is a <button>
   inside a <form>, so it shrinks to content width while "Preferences"
   (a bare <a>) stretches to the footer — they read as misaligned. In the
   expanded sidebar, stretch both to full width and left-align icon+label
   so they line up as a stack. Scoped with :not([data-sidebar-collapsed])
   so the collapsed icon-rail (centered, icon-only) is left untouched. */
html:not([data-sidebar-collapsed]) .rcms-sidebar-footer .rcms-sidebar-logout {
    width: 100%;
    justify-content: flex-start;
}

/* #271 — sidebar collapse / icons-only rail. Driven by the
   `data-sidebar-collapsed` attribute on <html> (set BEFORE first
   paint by the no-flash <script> in _base.html, then toggled by
   the top-of-sidebar button via cms-ux.js). Native `title`
   tooltips on each link surface the label on hover in collapsed
   mode. The button sits inside `.rcms-sidebar-brand` and is pushed to
   the right edge via `margin-left: auto` so the brand name +
   tenant pill stay anchored to the left. */
.rcms-sidebar-collapse-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 32px;
    width: 32px;
    height: 32px;
    margin-left: auto;
    background: transparent;
    color: var(--sidebar-fg-muted);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-radius-full);
    cursor: pointer;
    transition: background 0.12s, color 0.12s, transform 0.18s ease;
}
.rcms-sidebar-collapse-toggle:hover {
    background: var(--sidebar-hover-bg);
    color: var(--md-sys-color-on-surface);
}
.rcms-sidebar-collapse-toggle .material-symbols-rounded { font-size: 20px; }
html[data-sidebar-collapsed] .rcms-sidebar-collapse-toggle .material-symbols-rounded {
    transform: rotate(180deg);
}

html[data-sidebar-collapsed] .rcms-sidebar {
    width: 64px;
}
/* Hide text content on the icon rail. `font-size: 0` collapses the
   label text-node next to each icon; the icon itself restores its
   own font-size so it stays visible. */
html[data-sidebar-collapsed] .rcms-sidebar-link,
html[data-sidebar-collapsed] .rcms-sidebar-logout {
    font-size: 0;
    gap: 0;
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
}
html[data-sidebar-collapsed] .rcms-sidebar-link .material-symbols-rounded {
    font-size: 20px;
}
html[data-sidebar-collapsed] .rcms-sidebar-link .material-symbols-rounded.sm,
html[data-sidebar-collapsed] .rcms-sidebar-logout .material-symbols-rounded {
    font-size: 18px;
}
/* On the rail these are icon buttons, not labelled pills. Zeroing the
   horizontal padding alone left the pill wrapped tight around an 18px
   glyph — 20px wide against its own 38px height, a squashed lozenge.
   A square gives the icon its border back as a circle and matches the
   40px size the rest of the chrome uses for icon-only buttons. */
html[data-sidebar-collapsed] .rcms-sidebar-footer .rcms-sidebar-logout {
    width: 40px;
    height: 40px;
    padding: 0;
    flex: 0 0 auto;
}
/* Section headings + brand text + footer text-only items all hide
   in collapsed mode — the rail is icons-only. */
html[data-sidebar-collapsed] .rcms-sidebar-section,
html[data-sidebar-collapsed] .rcms-sidebar-brand h1,
html[data-sidebar-collapsed] .rcms-sidebar-brand .rcms-tenant,
html[data-sidebar-collapsed] .rcms-sidebar-footer > a[href^="/admin/"],
html[data-sidebar-collapsed] .rcms-sidebar-footer [data-user-tz],
/* The switcher is gone from the bundled sidebar, but host apps that
   override `_base.html` still render it — and it never had a collapsed
   rule, so its open menu became a column of one-glyph-per-line labels
   in the 64px rail. Hiding it here fixes those sidebars too. */
html[data-sidebar-collapsed] .rcms-lang-switcher {
    display: none;
}
html[data-sidebar-collapsed] .rcms-sidebar-brand {
    justify-content: center;
    padding: 16px 0;
}
html[data-sidebar-collapsed] .rcms-sidebar-brand-logo img {
    max-height: 32px;
}
/* Hide the brand gradient square (`::before`) and any logo
   image in collapsed mode — the toggle button is the only thing
   that fits in the 64 px rail, and its rotated chevron doubles
   as the "expand me" affordance. */
html[data-sidebar-collapsed] .rcms-sidebar-brand::before,
html[data-sidebar-collapsed] .rcms-sidebar-brand-logo,
html[data-sidebar-collapsed] .rcms-sidebar-brand-mark {
    display: none;
}
html[data-sidebar-collapsed] .rcms-sidebar-collapse-toggle {
    margin-left: 0;
}
html[data-sidebar-collapsed] .rcms-sidebar-footer {
    padding: 12px 8px 16px;
    align-items: center;
}
html[data-sidebar-collapsed] .rcms-sidebar-profile {
    /* Drop the username text — keep the avatar only. */
    gap: 0 !important;
}
html[data-sidebar-collapsed] .rcms-sidebar-profile > span:not([style*="border-radius"]) {
    display: none;
}
/* Drop the "logout" form wrapper's margin so its button stays
   centered in the rail. */
html[data-sidebar-collapsed] .rcms-sidebar-footer form {
    width: 100%;
    display: flex;
    justify-content: center;
}

/* ============================================================
 * 5. Top chrome — topbar, action bar, breadcrumbs, chips
 * ============================================================ */

.rcms-app-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    /* The only scroll container — body is height-locked above,
       sidebar is its sibling at 100vh, so the user scrolls *here*.
       Sticky `.rcms-app-topbar` / `.rcms-action-bar` stay pinned at the top. */
    overflow-y: auto;
    height: 100vh;
}
.rcms-app-topbar {
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 6px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    min-height: 48px;
    position: sticky;
    top: 0;
    z-index: 12;
}
.rcms-app-topbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
    /* `0 1 auto`, not `1 1 auto`: this block must take only the width its
       title needs. Growing it stretched an invisible heading box across
       the row (901px for the word "Pages"), which shoved the search into
       the middle of the bar and made it look stranded. It still shrinks,
       so a long title truncates rather than pushing the search off. */
    flex: 0 1 auto;
    min-width: 0;
}
.rcms-app-topbar-heading {
    font: var(--md-sys-typescale-ui-header);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    /* Shrink-only, matching `.rcms-app-topbar-left` above. */
    flex: 0 1 auto;
    /* Stay on one line — a long page title must truncate, not wrap and spill
       down over the tab bar (the top bar is pinned at a fixed 48px height). */
    white-space: nowrap;
    overflow: hidden;
}
.rcms-app-topbar-heading > .rcms-crumb {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.rcms-app-topbar h1 {
    font: var(--md-sys-typescale-ui-header);
    margin: 0;
}
.rcms-app-topbar-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex: 0 0 auto;
}

/* Mobile — the top bar is a single nowrap row (breadcrumbs · search ·
   actions). In the page editor the action cluster (locale, preview,
   three saves, kebab) is `flex: 0 0 auto` so it overflows off-screen
   while the breadcrumb collapses to width 0. The second toolbar
   (`.rcms-action-bar`) is a sibling sticky bar pinned at `top: 48px` — i.e.
   coupled to a 48px-tall top bar — so simply letting the top bar grow
   makes the two collide.

   Below 768px: un-stick both bars (a multi-row sticky toolbar would eat
   the small viewport), let the top bar wrap into stacked rows, drop the
   global search (list views carry their own), let the actions wrap, and
   let the overflowing tab strip scroll horizontally. Everything stays
   on-screen and tappable, and the two bars stack instead of overlap. */
@media (max-width: 768px) {
    .rcms-app-topbar {
        position: static;
        /* `.rcms-app-main` is a 100vh flex column; without this the column
           shrinks the bar back to its 48px min-height and the wrapped
           rows spill out and overlap the next bar. */
        flex: none;
        flex-wrap: wrap;
        height: auto;
        row-gap: 8px;
        padding: 8px 12px;
    }
    .rcms-app-topbar-left { flex: 1 1 100%; }
    .rcms-app-topbar-actions {
        flex: 1 1 100%;
        flex-wrap: wrap;
        justify-content: flex-start;
    }
    .rcms-action-bar {
        position: static;
        flex: none;
        flex-wrap: wrap;
        height: auto;
        row-gap: 6px;
    }
    /* 8 section tabs can't fit a phone row — let them swipe instead of
       overflowing under the preview controls. */
    .rcms-tab-strip {
        flex-wrap: nowrap;
        max-width: 100%;
        overflow-x: auto;
    }
    .rcms-preview-controls { flex-wrap: wrap; }
}

/* Secondary "action bar" sticky row — page-editor mounts the tab
   strip + preview controls here. List pages leave the `action_bar`
   block empty so the row never renders. */
.rcms-action-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 16px;
    min-height: 40px;
    /* Don't shrink inside the scrollable main column — grow to fit the
       wrapped tab strip instead of clipping it. */
    flex-shrink: 0;
    /* No fill and no rules: the action bar sits on the page canvas like
       the topbar and sidebar. Its own background made a third horizontal
       band under the header, and the divider drew a second line right
       below the topbar's. The tabs and controls carry their own shape,
       so the bar needs none.
       It stays sticky, so it needs the canvas colour rather than
       transparency — content must not scroll visibly beneath it. */
    background: var(--bg);
    position: sticky;
    top: 48px;
    z-index: 11;
}

.rcms-topbar-crumbs {
    display: flex; align-items: center; gap: 6px;
    min-width: 0; flex: 0 1 auto;
}
/* Crumb items are shared by the topbar and the page-editor trail
   (#532) — one rule set; each context keeps only its own deltas. */
.rcms-topbar-crumbs .rcms-crumb,
.rcms-page-editor-crumbs .rcms-crumb {
    display: inline-flex; align-items: center; gap: 4px;
    color: var(--muted); text-decoration: none;
    font-size: 13px; font-weight: 500;
    white-space: nowrap;
}
.rcms-topbar-crumbs .rcms-crumb:hover,
.rcms-page-editor-crumbs .rcms-crumb:hover { color: var(--accent); }
.rcms-topbar-crumbs .rcms-crumb.here,
.rcms-page-editor-crumbs .rcms-crumb.here { color: var(--fg); font-weight: 600; }
/* Only the topbar shrinks its current-page crumb — the editor trail
   scrolls sideways instead, so no min-width/ellipsis there. */
.rcms-topbar-crumbs .rcms-crumb.here {
    min-width: 0;
    overflow: hidden; text-overflow: ellipsis;
}
.rcms-topbar-crumbs .rcms-crumb-sep,
.rcms-page-editor-crumbs .rcms-crumb-sep { color: var(--muted-2); }
.rcms-topbar-crumbs .rcms-crumb-sep { font-size: 14px; }
.rcms-topbar-crumbs .rcms-crumb .material-symbols-rounded,
.rcms-page-editor-crumbs .rcms-crumb .material-symbols-rounded { font-size: 16px; }

/* #525 — admin UI language switcher in the sidebar footer. */
.rcms-lang-switcher { width: 100%; }
/* Summary reset comes from the shared <details> menu rule below. */
.rcms-lang-switcher > summary { display: flex; align-items: center; gap: 8px; }
.rcms-lang-switcher .rcms-lang-menu { display: flex; flex-direction: column; padding: 4px 0 4px 28px; gap: 2px; }
.rcms-lang-switcher .rcms-lang-opt { text-decoration: none; color: inherit; font-size: 0.85rem; padding: 3px 6px; border-radius: 6px; opacity: 0.8; }
.rcms-lang-switcher .rcms-lang-opt:hover { background: var(--md-sys-color-surface-container-high, #ececf2); opacity: 1; }
.rcms-lang-switcher .rcms-lang-opt.active { font-weight: 700; opacity: 1; }

/* #532 — page-editor breadcrumb row: dedicated slim row below the topbar
   with a back-to-parent control + the full ancestor trail (scrolls when long
   instead of re-cramming). */
.rcms-page-editor-crumbs {
    display: flex; align-items: center; gap: 12px;
    padding: 8px 16px; min-width: 0;
    /* Same as the action bar: no fill, no rule. It already sat on
       `--md-sys-color-surface`, which is now the page canvas, so the
       explicit background is redundant and the border added a third
       horizontal line under the header. */
    font-size: 13px;
}
.rcms-page-editor-crumbs .rcms-crumb-back {
    display: inline-flex; align-items: center; gap: 4px; flex: 0 0 auto;
    color: var(--accent); text-decoration: none; font-weight: 600;
    padding: 4px 8px; border: 1px solid var(--border); border-radius: 6px;
}
.rcms-page-editor-crumbs .rcms-crumb-back:hover { background: var(--md-sys-color-surface-container-high); }
.rcms-page-editor-crumbs .rcms-crumb-back .material-symbols-rounded { font-size: 16px; }
.rcms-page-editor-crumbs .rcms-crumb-trail {
    display: flex; align-items: center; gap: 6px; min-width: 0;
    overflow-x: auto; white-space: nowrap; scrollbar-width: thin;
}
/* Crumb items themselves are styled with the topbar crumbs above. */
@media (max-width: 640px) {
    .rcms-page-editor-crumbs .rcms-crumb-back-label { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
.rcms-locale-badge {
    background: var(--md-sys-color-tertiary-container);
    color: var(--md-sys-color-on-tertiary-container);
    padding: 1px 8px; border-radius: var(--md-sys-radius-full);
    font: var(--md-sys-typescale-ui-label);
    margin-left: 4px; text-transform: uppercase;
}

.rcms-chip-cluster {
    display: flex; align-items: center; gap: 6px;
    flex: 1 1 auto; min-width: 0;
    overflow-x: auto; overflow-y: hidden;
    scrollbar-width: thin;
    padding: 2px 0;
}
.rcms-chip-cluster::-webkit-scrollbar { height: 4px; }
.rcms-chip-cluster::-webkit-scrollbar-thumb {
    background: var(--md-sys-color-outline-variant); border-radius: 2px;
}
/* #i18n — the locale list's "Core support" cell: wrap its status pills and
   stay visible at every width (unlike the scrolling, mobile-hidden
   .rcms-chip-cluster). */
.rcms-locale-support { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
/* #324 — `.status-chip` (the icon-bearing status pill) duplicated `.rcms-tag`
   with identical status colors; it folded into the canonical `.rcms-tag` API
   (see the `.rcms-tag` section). The page-form topbar now uses `.rcms-tag.<status>`
   with a leading icon; the scoped `.rcms-chip-cluster .rcms-tag` rule there restores
   the no-shrink / nowrap layout this variant needed. */
.rcms-display-chip {
    display: inline-flex; align-items: baseline; gap: 6px;
    padding: 4px 10px; border-radius: var(--md-sys-radius-md);
    background: var(--md-sys-color-surface-container-low);
    border: 1px solid var(--md-sys-color-outline-variant);
    font-size: 12px; white-space: nowrap; flex: 0 0 auto;
}
.rcms-display-chip .material-symbols-rounded {
    font-size: 14px; color: var(--accent); align-self: center;
}
.rcms-display-chip-label {
    color: var(--muted); text-transform: uppercase;
    font: var(--md-sys-typescale-ui-label);
    letter-spacing: 0.04em;
}
.rcms-display-chip-value { color: var(--fg); font-weight: 500; }
.rcms-display-chip-value strong { font-weight: 600; }

/* Kebab + locale menus — native <details>/<summary> disclosures.
   The summary reset (no marker, pointer cursor) is shared by every
   <details>-based menu in the admin — one rule set here. */
.rcms-kebab-menu, .rcms-locale-menu { position: relative; }
.rcms-kebab-menu > summary,
.rcms-locale-menu > summary,
.rcms-lang-switcher > summary,
.rcms-col-picker > summary,
.rcms-fb-translate-menu > summary {
    list-style: none; cursor: pointer;
}
.rcms-kebab-menu > summary::-webkit-details-marker,
.rcms-locale-menu > summary::-webkit-details-marker,
.rcms-lang-switcher > summary::-webkit-details-marker,
.rcms-col-picker > summary::-webkit-details-marker,
.rcms-fb-translate-menu > summary::-webkit-details-marker { display: none; }
.rcms-kebab-panel, .rcms-locale-menu-panel {
    position: absolute; right: 0; top: calc(100% + 6px);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--md-sys-radius-lg);
    box-shadow: var(--md-sys-elevation-3);
    min-width: 220px; z-index: 20;
    padding: 6px;
    display: flex; flex-direction: column;
}
.rcms-kebab-panel > a,
.rcms-kebab-panel > form > button,
.rcms-kebab-panel > button[role="menuitem"],
.rcms-locale-menu-panel > a {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 12px; border-radius: var(--md-sys-radius-md);
    color: var(--fg); text-decoration: none;
    font-size: 13px;
    background: transparent; border: 0;
    width: 100%;
    text-align: left;
    cursor: pointer;
    font: inherit;
}
.rcms-kebab-panel > form { margin: 0; display: block; }
.rcms-kebab-panel > a:hover,
.rcms-kebab-panel > form > button:hover,
.rcms-kebab-panel > button[role="menuitem"]:hover,
.rcms-locale-menu-panel > a:hover {
    background: var(--md-sys-color-surface-container-low);
    color: var(--accent);
}
.rcms-kebab-panel .rcms-kebab-divider { border-top: 1px solid var(--md-sys-color-outline-variant); margin-top: 4px; padding-top: 4px; }
.rcms-kebab-panel .rcms-kebab-danger { color: var(--md-sys-color-error); }
/* Danger/logout hover fill lives in the shared semantic fills (tag section). */

/* #156 — list-row actions: wrap gracefully on narrow viewports so
   the row layout doesn't collapse. Plus #157 — Edit + drill-down
   always visible, everything else in the row kebab. */
.rcms-row-actions { flex-wrap: wrap; justify-content: flex-end; }
.rcms-row-actions .rcms-row-actions-children { margin-right: 4px; }
.rcms-row-kebab .rcms-kebab-panel { min-width: 200px; }
/* `.rcms-kebab-logout` is a `.rcms-kebab-panel > form > button` — the shared
   menu-item rule above already styles it; its error hover fill lives
   in the shared semantic fills (tag section). */
.rcms-locale-menu-panel .rcms-canonical-tag {
    margin-left: auto;
    background: var(--md-sys-color-primary-fixed);
    color: var(--md-sys-color-on-primary-fixed);
    font: var(--md-sys-typescale-ui-label);
    padding: 1px 8px; border-radius: var(--md-sys-radius-full);
    text-transform: uppercase; letter-spacing: 0.05em;
}

/* Narrow-viewport collapses. */
@media (max-width: 760px) {
    .rcms-chip-cluster { display: none; }
    .rcms-topbar-crumbs .rcms-crumb:not(.here) .rcms-crumb-label { display: none; }
    .rcms-topbar-crumbs .rcms-crumb-sep { display: none; }
}

.rcms-breadcrumbs {
    color: var(--muted);
    font-size: 13px;
    padding: 12px 24px 0;
}
.rcms-breadcrumbs a { color: var(--accent); text-decoration: none; }
.rcms-breadcrumbs a:hover { text-decoration: underline; }
.rcms-breadcrumbs .rcms-sep { margin: 0 6px; color: var(--muted-2); }

/* ============================================================
 * 6. Flash banners
 * ============================================================ */

.rcms-app-flash {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 24px 0;
}
.rcms-flash {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 16px;
    border-radius: var(--md-sys-radius-lg);
    border: 1px solid transparent;
    font-size: 13px;
    line-height: 1.5;
}
.rcms-flash-icon { font-size: 18px; flex-shrink: 0; margin-top: 1px; }
.rcms-flash-body { flex: 1; }
.rcms-flash--success {
    background: var(--success-soft);
    border-color: var(--success);
    color: var(--success-hover);
}
.rcms-flash--info {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--md-sys-color-on-primary-fixed-variant);
}
.rcms-flash--warning {
    background: var(--warning-soft);
    border-color: var(--warning);
    color: var(--warning-hover);
}
.rcms-flash--error,
.rcms-flash--debug {
    background: var(--danger-soft);
    border-color: var(--danger);
    color: var(--danger-hover);
}

/* #324 — `.rcms-alert`: persistent in-page status banner. Distinct from the
   transient `.rcms-flash` message region above (one-shot, hoisted to a toast
   on load) and the `.rcms-toast` corner stack — `.rcms-alert` is a banner that
   stays put (e.g. a page-lock notice). One canonical class + md-sys-token
   variants replaces hand-rolled inline-styled `role="alert"` divs. */
.rcms-alert {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    margin-bottom: 12px;
    border-radius: var(--md-sys-radius-lg);
    box-shadow: var(--md-sys-elevation-1);
}
/* `.rcms-alert--error` / `.rcms-alert--warning` fills live in the shared
   semantic fills (tag section). */
.rcms-alert-body { flex: 1; }

.rcms-app-content {
    flex: 1;
    padding: 24px 28px;
    width: 100%;
    min-width: 0;
}

/* ============================================================
 * 7. M3 button system
 *
 * Five canonical variants:
 *   .rcms-btn          — filled (primary action)
 *   .rcms-btn-tonal    — tonal (secondary emphasis)
 *   .rcms-btn-outlined — outlined (low-emphasis affirmative)
 *   .rcms-btn-text     — text (lowest emphasis, default no padding-x)
 *   .rcms-btn-danger   — filled error
 * Modifiers:
 *   .rcms-btn-small    — compact (32px tall, 16px x-pad)
 *   .rcms-btn-icon     — square icon-only (40x40)
 *
 * Each button picks up an M3 state layer via `::before`:
 * currentColor at opacity 0 → 0.08 hover → 0.12 active.
 *
 * One canonical class API (#293/#324) — the legacy compound aliases
 * (.rcms-btn.ghost/.muted/.small/.danger/.violet) are gone; see the note
 * by the .rcms-btn-small variant rules below.
 * ============================================================ */

/* ── Button size scale ──────────────────────────────────────────────
 * 40px  `.rcms-btn`              primary / default action
 * 32px  `.rcms-btn-small`, segmented controls (`.rcms-viewport-btn`,
 *       `.rcms-picker__viewtoggle button`), editor toolbars
 *       (`.rcms-richtext-tool`, `.rcms-md-btn`), `.rcms-tab-tab`
 * 28px  compact icon buttons (`.rcms-fb-icon-btn`,
 *       `.rcms-stream-block-actions .rcms-btn`)
 * Radii always come from `--md-sys-radius-*`; segmented controls round
 * the shell and square the children, which is why those read 0.
 * ------------------------------------------------------------------ */
.rcms-btn {
    position: relative;
    isolation: isolate;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 40px;
    padding: 0 24px;
    font: var(--md-sys-typescale-ui-button);
    border-radius: var(--md-sys-radius-lg);
    /* Every variant is outlined, so the border belongs to the base: a
       variant that skipped it would sit 1px short of its neighbours on
       the same row, and only `border-box` was hiding that. */
    border: 1px solid var(--md-sys-color-primary-fixed-dim);
    cursor: pointer;
    /* Pale fill, dark ink. Emphasis comes from tone and border weight
       rather than a saturated block of colour, so a row of controls
       reads as one calm family against the white chrome. */
    background: var(--md-sys-color-primary-fixed);
    color: var(--md-sys-color-on-primary-fixed);
    text-decoration: none;
    box-shadow: none;
    transition: border-color 0.14s, background 0.14s, transform 0.08s;
    user-select: none;
    white-space: nowrap;
}
/* Emphasis comes from the border and the `::before` tint below, not a
   drop shadow. The old filled buttons cast one and read as physically
   taller than the outlined ones beside them, though every variant has
   always measured the same 40px. */
.rcms-btn:hover {
    border-color: var(--md-sys-color-primary);
}
.rcms-btn::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: currentColor;
    opacity: 0;
    border-radius: inherit;
    transition: opacity 0.12s;
    pointer-events: none;
}
.rcms-btn:hover::before { opacity: 0.08; }
.rcms-btn:focus-visible::before { opacity: 0.10; }
.rcms-btn:active::before { opacity: 0.12; }
.rcms-btn:active { transform: scale(0.98); }
.rcms-btn:disabled,
.rcms-btn[aria-disabled="true"] {
    opacity: 0.38;
    cursor: not-allowed;
    pointer-events: none;
}
.rcms-btn .material-symbols-rounded { font-size: 18px; vertical-align: -4px; }
/* The icon scales with the tier. `.material-symbols-rounded.sm` is also
   18px, so tagging an icon `sm` inside a button changed nothing — every
   button icon rendered 18px, including on the 32px tier where the label
   is 13px. An icon a third larger than the text it sits beside is what
   made buttons with icons read as bulkier than their text-only
   neighbours, even though both measure exactly 32px. */
.rcms-btn-small .material-symbols-rounded { font-size: 16px; }

/* Variants. */
/* Three weights of the same outline, so a row of buttons reads as one
   family: the primary action states the accent at full strength, tonal
   softens it, outlined drops to the neutral rule. */
.rcms-btn-tonal {
    background: var(--md-sys-color-surface-container);
    color: var(--md-sys-color-on-surface);
    border-color: var(--md-sys-color-outline-variant);
}
/* The quiet tiers stay unfilled: three weights of one family — filled,
   tinted, bare — so a toolbar has exactly one obvious target. */
.rcms-btn-outlined {
    background: var(--md-sys-color-surface-container-lowest);
    color: var(--md-sys-color-on-surface);
    border-color: var(--md-sys-color-outline-variant);
}
.rcms-btn-outlined:hover { border-color: var(--md-sys-color-outline); }
.rcms-btn-text {
    background: transparent;
    color: var(--md-sys-color-on-surface-variant);
    border-color: transparent;
    padding: 0 12px;
}
.rcms-btn-danger {
    background: var(--md-sys-color-error-container);
    border-color: color-mix(in srgb, var(--md-sys-color-error) 30%, transparent);
    color: var(--md-sys-color-on-error-container);
}
.rcms-btn-icon {
    width: 40px;
    padding: 0;
    border-radius: var(--md-sys-radius-full);
}
.rcms-btn-small {
    height: 32px;
    /* One padding for the whole tier. Solid smalls used to sit at 16px
       while outlined smalls used 12px, so the two rendered different
       widths for the same label. */
    padding: 0 12px;
    font-size: 13px;
}
.rcms-btn-small.rcms-btn-icon { width: 32px; padding: 0; }

/* #293 phase 2 — the compound aliases `.rcms-btn.ghost` (byte-identical to
   `.rcms-btn-outlined`) and `.rcms-btn.muted` (≡ `.rcms-btn-text`) were duplicates of
   the canonical BEM variants above. Templates have been swept to
   `.rcms-btn-outlined` / `.rcms-btn-text` and the compound rules removed, so the
   dual API doesn't survive as a maintenance trap — matching the earlier
   `.rcms-btn.small` → `.rcms-btn-small` and `.rcms-btn.danger` → `.rcms-btn-danger`
   consolidations. (`.rcms-btn.violet` was dropped in phase 1: zero consumers;
   tertiary accents go through `.rcms-btn-tonal`.) The small-variant padding
   override that used to live here is gone — `.rcms-btn-small` now sets one
   padding for the whole tier. */

/* ============================================================
 * 8. Cards, empty states, data tables
 * ============================================================ */

/* Shared pagination control row (`rcms_admin/_pagination.html`). One
   component for every list page: range status, page-size selector,
   prev/next and a jump-to-page select. */
.rcms-pagination {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 16px;
}
.rcms-pagination-spacer { flex: 1 1 auto; }
.rcms-pagination-nav {
    display: flex;
    align-items: center;
    gap: 6px;
}
.rcms-pagination-size,
.rcms-pagination-jump {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
/* Bounds are rendered as inert spans rather than omitted, so the row
   doesn't reflow as you page through it. */
.rcms-pagination .rcms-is-disabled {
    opacity: 0.4;
    pointer-events: none;
}

/* ── Elevated surface ───────────────────────────────────────────────
 * The single definition of "content raised above the page canvas".
 * Cards and data tables are the same thing visually, so they share it
 * rather than each carrying a near-copy — the table used to have the
 * border and radius but no shadow, so it sat flat while cards floated.
 * `.rcms-elevated` is the class to reach for in new markup; the two
 * component selectors are listed here so existing templates need no
 * change.
 * ------------------------------------------------------------------ */
.rcms-elevated,
.rcms-card,
.rcms-table-panel,
.rcms-table-toolbar,
.rcms-table-wrap,
table.rcms-data {
    background: var(--md-sys-color-surface-container-lowest);
    border: 1px solid color-mix(in srgb, var(--md-sys-color-outline-variant) 40%, transparent);
    border-radius: var(--md-sys-radius-xl);
    box-shadow: var(--md-sys-elevation-2);
}

.rcms-card {
    padding: 24px;
}
/* Adjacent-sibling card margin is opt-in via `.rcms-card-stack` so grid /
   inline-flex layouts (media library cards, snippet folder grid)
   don't pick up unwanted gaps that misalign with the parent's own
   `gap`. Vertical-stack contexts (settings page, form chrome) opt in
   by wrapping with `<div class="rcms-card-stack">`. The page edit pane
   is the most common vertical-stack container — it opts in too. */
.rcms-card-stack > .rcms-card + .rcms-card,
.rcms-edit-pane > .rcms-card + .rcms-card,
.rcms-edit-pane > section.rcms-card + section.rcms-card,
.rcms-edit-pane > form.rcms-card + .rcms-card,
.rcms-edit-pane > .rcms-card + section.rcms-card,
.rcms-edit-pane > section.rcms-card + .rcms-card,
.rcms-edit-pane > details.rcms-card + .rcms-card,
.rcms-edit-pane > .rcms-card + details.rcms-card,
.rcms-app-main > .rcms-card + .rcms-card,
.rcms-app-main > section.rcms-card + section.rcms-card { margin-top: 16px; }
/* A card's heading must not add to the card's own padding — but the
   unqualified `.rcms-card h2` (0,1,1) also outranked every `rcms-mt-*`
   utility (0,1,0), so a card holding several sections rendered their
   headings flush. Five on the account Preferences page asked for a gap
   and silently got none. Skip the reset where a heading has stated its
   own top margin; everything else behaves exactly as before. */
.rcms-card h2:not([class*="rcms-mt-"]) { margin-top: 0; }

.rcms-empty {
    padding: 48px;
    text-align: center;
    color: var(--muted);
    background: var(--md-sys-color-surface-container-lowest);
    border: 1px dashed var(--border);
    border-radius: var(--md-sys-radius-xl);
}
.rcms-empty p { margin: 0 0 16px; }

/* Responsive-table wrapper. Bare `table.rcms-data` is `width:100%` with no
 * min-width, so a wide table (many columns / nowrap action cells) pushes
 * the whole page into horizontal scroll on phones. Wrap wide tables in
 * `<div class="rcms-table-wrap">` so the TABLE scrolls sideways within the
 * page instead. Mirrors the overflow-x pattern used by `.rcms-chip-cluster`
 * / `.rcms-tab-strip`, and the inline precedent in form_submissions.html. */
.rcms-table-wrap {
    overflow-x: auto;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
}
/* Permission matrix — a `.rcms-data` table with denser cells (one column
 * per action) and centred checkboxes. Previously each of the two
 * templates that render it carried its own copy of the full table CSS in
 * an inline <style>, which had already drifted apart. */
table.rcms-data.rcms-perm-table th,
table.rcms-data.rcms-perm-table td {
    padding: 8px 10px;
    text-align: center;
    font-size: 13px;
}
table.rcms-data.rcms-perm-table th:first-child,
table.rcms-data.rcms-perm-table td:first-child {
    text-align: left;
}
table.rcms-data.rcms-perm-table input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Permission matrices have one column per action — keep them at their
 * natural width and let `.rcms-table-wrap` scroll, rather than cramming. */
.rcms-table-wrap > table.rcms-perm-overview {
    min-width: max-content;
}
/* The role form's matrix: the resource names wrap, the action columns
 * don't, so the table fits its card and scrolls only when it must. */
.rcms-table-wrap > .rcms-perm-table {
    min-width: 100%;
}
table.rcms-data.rcms-perm-table th:not(:first-child),
table.rcms-data.rcms-perm-table td:not(:first-child) {
    white-space: nowrap;
}

/* Key/value pairs in a card (tenant slug, display name, ...). Not
   tabular data, so not a table — a two-column grid keeps the labels and
   values aligned without borders or headers. */
.rcms-kv {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 4px 16px;
    margin: 0;
}
.rcms-kv dt { grid-column: 1; }
.rcms-kv dd { grid-column: 2; margin: 0; }

/* A card's last child should not add its margin to the card's padding —
   otherwise a card whose only content is a paragraph looks bottom-heavy
   (measured 25px above the text, 39px below). */
.rcms-card > :last-child {
    margin-bottom: 0;
}

/* Every list page is `.rcms-card` (the description) followed by the
   table. The gap between them belongs to that relationship, not to a
   per-page utility class — ten pages had no margin at all and the table
   butted straight against the card, while two carried `rcms-mt-4`. */
.rcms-card + .rcms-table-wrap,
.rcms-card + table.rcms-data,
.rcms-card + .rcms-pagination {
    margin-top: 16px;
}

/* `_list_base.html` emits the intro card, so what follows it is whatever
   that page's body opens with — a table wrapper, an empty state, a
   filter form, another card. The gap is the intro's, not a property of
   each possible neighbour, so it applies to all of them. */
.rcms-page-intro + * {
    margin-top: 16px;
}

/* A surface nested in a surface must not redraw the chrome. Ten
   templates put the table wrapper inside a card; once the wrapper became
   an elevated surface itself, each of those rendered a shadowed, bordered
   box inside another one. Rather than move ten templates around, the
   nested case flattens automatically — the card is the surface, the
   wrapper is just a scroll container. */
.rcms-card .rcms-table-wrap,
.rcms-card .rcms-elevated,
.rcms-card table.rcms-data,
.rcms-table-panel .rcms-table-wrap,
.rcms-table-panel .rcms-elevated {
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
}

.rcms-table-wrap > table.rcms-data {
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
}

/* Bulk-action toolbar attached to a list table.

   Three pages hand-rolled this row out of utility classes — one used
   `rcms-flex rcms-gap-2 rcms-mb-2`, another `rcms-flex
   rcms-justify-between rcms-items-center rcms-mt-3 rcms-mb-3 rcms-mx-0
   rcms-gap-2` — so the controls floated loose on the canvas at three
   different heights and alignments while the table below them sat on a
   surface. The toolbar is part of that surface: `.rcms-table-panel`
   draws one box around toolbar + table, and the two read as one panel
   instead of a button strip adrift above a card. */
.rcms-table-panel {
    /* Clips the table's collapsed borders to the panel's radius, the
       way `table.rcms-data` clips its own. The wrapper inside keeps its
       `overflow-x: auto`, so a wide table still scrolls in place. */
    overflow: hidden;
    /* No `margin: 0` here: the panel is usually a <form>, and zeroing
       the margin outright beat `.rcms-page-intro + *` on source order,
       collapsing the gap below the description card. */
    margin-inline: 0;
    margin-bottom: 0;
}
.rcms-table-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    row-gap: 8px;
    padding: 10px 16px;
}
/* Attached to a panel it is the panel's top edge, so it keeps only the
   rule that separates it from the table. On its own — the Library bulk
   bar sits beside the table rather than wrapping it — it stays a
   surface in its own right, so a page can adopt the toolbar without
   restructuring its markup around a panel. */
.rcms-table-panel > .rcms-table-toolbar {
    background: transparent;
    border: 0;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    border-radius: 0;
    box-shadow: none;
}
/* Selection control on the left, actions on the right — the spacer is
   what puts them there, and capping its basis keeps it from claiming a
   whole second row once the bar wraps. */
.rcms-table-toolbar > .rcms-toolbar-spacer {
    flex: 1 1 auto;
    min-width: 0;
}

table.rcms-data {
    width: 100%;
    border-collapse: collapse;
    /* Clips the collapsed cell borders to the rounded corners; the
       surface itself comes from `.rcms-elevated` above. */
    overflow: hidden;
}
table.rcms-data th, table.rcms-data td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    vertical-align: middle;
}
table.rcms-data th {
    background: var(--md-sys-color-surface-container-low);
    font: var(--md-sys-typescale-ui-label);
    color: var(--muted);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
table.rcms-data tr:last-child td { border-bottom: none; }
table.rcms-data tr:hover td {
    background: var(--md-sys-color-surface-container-low);
}
/* Action cells across the admin.
 *
 * The .rcms-actions class is on the <td> ITSELF in the listing templates
 * (locked_pages, library_list, revisions_report, etc.) — buttons +
 * per-row <form>s are direct children. So we must NOT apply
 * `display: flex` to .rcms-actions, since that turns the <td> into a
 * flex container and removes it from the table-row layout — content
 * then renders as a free-floating flex box that overflows the
 * table's clipping region.
 *
 * Keep the cell native (`display: table-cell` by default). Use a
 * tiny `* + *` margin to space children. Forms render inline-block
 * so they baseline-align with <a class="rcms-btn"> siblings.
 *
 * `.rcms-row-actions` (div-based — page list) keeps the flex wrap layout
 * since it isn't constrained by a table column.
 */
table.rcms-data th.rcms-actions,
table.rcms-data td.rcms-actions {
    text-align: right;
    white-space: nowrap;
    vertical-align: middle;
}
table.rcms-data td.rcms-actions > * + * {
    margin-left: 8px;
}
table.rcms-data td.rcms-actions form {
    display: inline-block;
    margin: 0;
}
.rcms-row-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    justify-content: flex-end;
}
.rcms-row-actions form {
    display: inline-flex;
    margin: 0;
}
table.rcms-data .rcms-actions .rcms-btn,
.rcms-row-actions .rcms-btn,
table.rcms-data .rcms-actions .rcms-btn-icon,
.rcms-row-actions .rcms-btn-icon {
    /* Lock to the small-row height so label-only, label+caret, and
     * icon-only buttons share one baseline. */
    height: 32px;
    min-height: 32px;
}
table.rcms-data .rcms-actions .rcms-btn-icon,
.rcms-row-actions .rcms-btn-icon {
    width: 32px;
}
table.rcms-data .rcms-actions .rcms-btn-small,
.rcms-row-actions .rcms-btn-small {
    padding: 0 12px;
}

/* ============================================================
 * 9. Status pills (`.rcms-tag`) — pill-shape with leading dot
 *
 * Pairs an MD3 *-container background with the matching *-on-
 * foreground for AA contrast. The leading colored dot is rendered
 * via `::before` so the markup stays a plain
 * `<span class="rcms-tag published">`.
 * ============================================================ */

.rcms-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: var(--md-sys-radius-full);
    font: var(--md-sys-typescale-ui-label);
    background: var(--md-sys-color-surface-container-high);
    color: var(--md-sys-color-on-surface-variant);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.rcms-tag::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: var(--md-sys-radius-full);
    background: currentColor;
    opacity: 0.85;
}
.rcms-tag.draft {
    background: var(--md-sys-color-surface-container-high);
    color: var(--md-sys-color-on-surface-variant);
}
.rcms-tag.published {
    background: var(--md-sys-color-success-container);
    color: var(--md-sys-color-on-success-container);
}
/* `.rcms-tag.scheduled` / `.rcms-tag.archived` fills live in the shared
   semantic fills just below. */
/* #556 — `expired` (takedown) is a neutral terminal state, distinct
   from the error-red `archived` (preserved-and-served) pill. */
.rcms-tag.expired {
    background: var(--md-sys-color-surface-container-highest);
    color: var(--md-sys-color-on-surface-variant);
    opacity: 0.75;
}
/* #324 — icon-bearing variant (absorbed the former `.status-chip`). A
   leading Material icon replaces the `::before` status dot. */
.rcms-tag .material-symbols-rounded { font-size: 14px; }
.rcms-tag:has(.material-symbols-rounded)::before { display: none; }
/* Page-form action-bar status pill — keep it from shrinking / wrapping
   in the flex `.rcms-chip-cluster` (the layout `.status-chip` used to carry). */
.rcms-chip-cluster .rcms-tag { white-space: nowrap; flex: 0 0 auto; }

/* ------------------------------------------------------------
 * Shared semantic fills (DRY). Every "this element is in an
 * error/warning state" surface uses the same container/on-container
 * token pair — one rule per tone instead of a copy per component.
 * Placed after `.rcms-card` (equal specificity with `.rcms-card--error`) and
 * before every member's own section.
 * ------------------------------------------------------------ */
.rcms-alert--error,
.rcms-tag.archived,
.rcms-card--error,
.rcms-autosave-chip[data-mode="warn"],
.rcms-kebab-panel .rcms-kebab-danger:hover,
.rcms-kebab-panel .rcms-kebab-logout:hover {
    background: var(--md-sys-color-error-container);
    color: var(--md-sys-color-on-error-container);
}
.rcms-alert--warning,
.rcms-tag.scheduled {
    background: var(--md-sys-color-warning-container);
    color: var(--md-sys-color-on-warning-container);
}

/* ============================================================
 * 10. M3 form fields
 * ============================================================ */

.rcms-field { margin-bottom: 18px; }
/* Canonical form label — one look for every labelled control in the
   admin: `.rcms-field`, stream-editor fields/legends, and the auth card.
   Contexts keep only their own margin/padding deltas at their site. */
.rcms-field label,
.rcms-stream-field > label,
.rcms-stream-nested > legend,
.rcms-auth-card label {
    display: block;
    font: var(--md-sys-typescale-ui-label);
    color: var(--md-sys-color-on-surface-variant);
    margin-bottom: 6px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.rcms-field label .rcms-req { color: var(--md-sys-color-error); }
.rcms-field input[type="text"],
.rcms-field input[type="password"],
.rcms-field input[type="email"],
.rcms-field input[type="number"],
.rcms-field input[type="url"],
.rcms-field input[type="search"],
.rcms-field input[type="tel"],
.rcms-field input[type="date"],
.rcms-field input[type="time"],
.rcms-field input[type="datetime-local"],
.rcms-field select,
.rcms-field textarea,
.rcms-auth-card input[type="text"],
.rcms-auth-card input[type="password"],
.rcms-auth-card input[type="email"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-radius-md);
    font: inherit;
    background: var(--md-sys-color-surface-container);
    color: var(--md-sys-color-on-surface);
    transition: border-color 0.12s, box-shadow 0.12s;
}
.rcms-field input:hover,
.rcms-field select:hover,
.rcms-field textarea:hover,
.rcms-auth-card input:hover {
    border-color: var(--md-sys-color-outline);
}
.rcms-field input:focus,
.rcms-field select:focus,
.rcms-field textarea:focus,
.rcms-auth-card input:focus {
    outline: none;
    border-color: var(--md-sys-color-primary);
    box-shadow: 0 0 0 1px var(--md-sys-color-primary);
}
.rcms-field input[aria-invalid="true"],
.rcms-field select[aria-invalid="true"],
.rcms-field textarea[aria-invalid="true"] {
    border-color: var(--md-sys-color-error);
}
.rcms-field input[aria-invalid="true"]:focus,
.rcms-field select[aria-invalid="true"]:focus,
.rcms-field textarea[aria-invalid="true"]:focus {
    box-shadow: 0 0 0 1px var(--md-sys-color-error);
}
.rcms-field textarea { min-height: 96px; resize: vertical; }
/* Editor body surfaces get Literata for content authoring — Hanken
   Grotesk reads well in UI but a literary serif reads better for
   paragraph-length prose. */
.rcms-field textarea[data-widget-mode="markdown"],
.rcms-field textarea[data-widget-mode="richtext"] {
    font: var(--md-sys-typescale-editor-text);
    min-height: 240px;
}

/* #294 — TipTap richtext editor chrome. The `data-widget-mode="richtext"`
   textarea is hidden by richtext-editor.js and replaced by this surface. */
.rcms-richtext {
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-radius-md);
    background: var(--md-sys-color-surface-container);
    overflow: hidden;
}
.rcms-richtext:focus-within { border-color: var(--md-sys-color-primary); }
.rcms-richtext-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px;
    padding: 6px 8px;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    background: var(--md-sys-color-surface-container-high);
}
/* Editor toolbar buttons. The rich-text and markdown toolbars are the
   same control in two editors, so they share one rule — previously the
   markdown copy had drifted to 4px radius / 3px 8px padding / 12px text. */
.rcms-richtext-tool,
.rcms-md-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    /* 32px is the admin's standard control height — same as
       `.rcms-btn-small`, the segmented controls and the tab strip. The
       toolbars sat at 30px, which is invisible alone and obvious when
       one sits beside another control. */
    min-width: 32px;
    height: 32px;
    padding: 0 6px;
    border: 0;
    border-radius: var(--md-sys-radius-sm);
    background: transparent;
    color: var(--md-sys-color-on-surface-variant);
    font: var(--md-sys-typescale-ui-label);
    cursor: pointer;
    transition: background 0.1s, color 0.1s;
}
.rcms-richtext-tool .material-symbols-rounded { font-size: 18px; }
.rcms-richtext-tool:hover { background: var(--md-sys-color-surface-container-highest); }
/* Active fill comes from the shared active-tool rule (minimap section). */
.rcms-richtext-sep {
    width: 1px;
    align-self: stretch;
    margin: 4px 4px;
    background: var(--md-sys-color-outline-variant);
}
.rcms-richtext-surface { padding: 12px 14px; }
.rcms-richtext-surface .ProseMirror {
    min-height: 200px;
    outline: none;
    font: var(--md-sys-typescale-editor-text);
    color: var(--md-sys-color-on-surface);
}
.rcms-richtext-surface .ProseMirror > :first-child { margin-top: 0; }
.rcms-richtext-surface .ProseMirror p { margin: 0 0 10px; }
.rcms-richtext-surface .ProseMirror h2,
.rcms-richtext-surface .ProseMirror h3,
.rcms-richtext-surface .ProseMirror h4 { margin: 16px 0 8px; line-height: 1.25; }
.rcms-richtext-surface .ProseMirror ul,
.rcms-richtext-surface .ProseMirror ol { margin: 0 0 10px; padding-left: 22px; }
.rcms-richtext-surface .ProseMirror blockquote {
    margin: 0 0 10px;
    padding: 2px 12px;
    border-left: 3px solid var(--md-sys-color-outline-variant);
    color: var(--md-sys-color-on-surface-variant);
}
.rcms-richtext-surface .ProseMirror code {
    font-family: var(--md-sys-font-mono, monospace);
    background: var(--md-sys-color-surface-container-highest);
    padding: 1px 4px;
    border-radius: var(--md-sys-radius-sm);
}
.rcms-richtext-surface .ProseMirror a { color: var(--md-sys-color-primary); }
/* Unscoped — hints render inside and outside `.rcms-field` (page-form
   subscribe row, stream editor, pickers); one base look everywhere. */
.rcms-hint {
    font-size: 12px;
    color: var(--muted);
    margin-top: 6px;
}
/* #324 — hint modifiers. Compound `.rcms-hint.hint--*` (specificity 0,2,0,
   declared after `.rcms-field .rcms-hint`) so they win the cascade over the base
   hint by source order, with or without a `.rcms-field` ancestor. These
   replace per-arm inline `style=` hints in _widget.html — including the
   legacy `--danger` / `--warning` token usages — with md-sys tokens. */
.rcms-hint.rcms-hint--sm { font-size: 11px; }
.rcms-hint.rcms-hint--error { color: var(--md-sys-color-error); }
.rcms-hint.rcms-hint--warning { color: var(--md-sys-color-warning); }
/* Horizontal-flex row of fields. Columns align at the TOP
 * (`align-items: flex-start`): with single-line labels the inputs
 * sit level, and a hint below one column's input only grows that
 * column — it can't push a neighbour's input out of line (the old
 * `flex-end` bottom-alignment did exactly that, which is why hints
 * were once absolutely positioned). Hints stay IN FLOW so they
 * reserve their real height — the previous absolute + fixed-22px
 * reservation clipped any hint that wrapped past one line and let
 * the next row render on top of it (redirect form overlap). */
.rcms-field-row {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    /* Wrap to stacked columns on narrow viewports — without this the
     * fixed 2-up rows (Go live / Expire, OG image / Twitter card) run
     * off the edge on small screens instead of stacking. */
    flex-wrap: wrap;
    /* Row-level rhythm replaces the per-field margin zeroed below —
     * matches the base `.rcms-field` spacing so stacked rows read the same
     * as stacked bare fields. */
    margin-bottom: 18px;
}
.rcms-field-row .rcms-field {
    /* `flex-basis` (not 0) so a column that can't keep ~220px wraps to
     * its own full-width line; `min-width:0` lets the control shrink
     * inside its column instead of forcing horizontal overflow. */
    flex: 1 1 220px;
    min-width: 0;
    margin-bottom: 0;
}
/* Keep every label in a row the same height. A label is 16px of line
 * box (`ui-label`) + 6px margin = a 22px block, but an inline
 * `.material-symbols-rounded.sm` (18px, shifted -3px) grows the line
 * box to 19px — so an icon-bearing column's control sat 3px below its
 * plain-label neighbour's. Laying the label out as a flex line pins it
 * back to 16px and gives the action rule below a fixed offset. */
.rcms-field-row > .rcms-field > label {
    display: flex;
    align-items: center;
    gap: 4px;
    min-height: 16px;
}
.rcms-field-row > .rcms-field > label .material-symbols-rounded {
    font-size: 16px;
    line-height: 1;
    vertical-align: 0;
}
/* Buttons dropped straight into a `.rcms-field-row` (the search + Apply /
 * Clear filter bars) carry no label of their own, so the row's
 * `flex-start` parked them level with the LABELS, floating above the
 * inputs. Offset them by the label block so they sit on the control
 * line. Same for a `.rcms-field` wrapper holding nothing but a button. */
.rcms-field-row > .rcms-btn,
.rcms-field-row > button,
.rcms-field-row > .rcms-field > .rcms-btn:only-child,
.rcms-field-row > .rcms-field > button:only-child {
    margin-top: 22px;
}
.rcms-checkbox-field { display: flex; align-items: center; gap: 8px; }
.rcms-checkbox-field input { width: auto; }
.rcms-checkbox-field label {
    margin-bottom: 0;
    letter-spacing: 0;
    text-transform: none;
    font-weight: 500;
    color: var(--fg);
}

/* #324 — remaining HTML input types + multi-value/option wrappers.
   Every widget renders inside `.rcms-field` (see _widget.html `render`), so
   text-shaped inputs and `<select>` (incl. `[multiple]`) already pick up
   the chrome above. These close the gaps: `color` / `range` inputs
   (emitted by widgets but absent from the base type list) and the
   option / group / pair wrappers that otherwise fell back to UA-default
   layout. */

/* Color — a fixed-size swatch chip, not a full-width text field. */
.rcms-field input[type="color"] {
    width: 56px;
    height: 38px;
    padding: 4px;
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-radius-md);
    background: var(--md-sys-color-surface-container);
    cursor: pointer;
}
.rcms-field input[type="color"]:hover { border-color: var(--md-sys-color-outline); }
.rcms-field input[type="color"]::-webkit-color-swatch { border: none; border-radius: 4px; }
.rcms-field input[type="color"]::-moz-color-swatch { border: none; border-radius: 4px; }

/* Range — themed via accent-color (track + thumb tint, cross-browser). */
.rcms-field input[type="range"] {
    width: 100%;
    accent-color: var(--md-sys-color-primary);
    cursor: pointer;
}

/* Radio / checkbox option groups (`radio`, multi-value `checkboxes`).
   Stack options with consistent spacing; each option is an inline
   input + label, mirroring `.rcms-checkbox-field`. */
.rcms-radio-group,
.rcms-checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
/* Scoped under the group so these win over `.rcms-field label` (0,1,1),
   which otherwise forces the option `<label>` back to display:block. */
/* A choice card (a role on the user form) is an option, not a field
   caption: none of `.rcms-field label`'s uppercase styling. */
.rcms-field label.rcms-choice-card {
    margin-bottom: 0;
    letter-spacing: 0;
    text-transform: none;
    font: inherit;
    color: var(--fg);
}
.rcms-radio-group .rcms-radio-option,
.rcms-checkbox-group .rcms-checkbox-option {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    /* An option is a choice, not a field label: no uppercase caption. */
    margin-bottom: 0;
    letter-spacing: 0;
    text-transform: none;
    font-weight: 500;
    color: var(--fg);
}

/* `<select multiple>` group — the select inherits `.rcms-field select` chrome;
   the wrapper just stacks it above its hint. */
.rcms-multiselect-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.rcms-multiselect-group .rcms-hint { margin-top: 0; }

/* Datetime + timezone pair — side by side instead of stacking. */
.rcms-datetimetz-pair {
    display: flex;
    gap: 8px;
}
.rcms-datetimetz-pair input[type="datetime-local"] { flex: 1 1 60%; min-width: 0; }
.rcms-datetimetz-pair select { flex: 1 1 40%; min-width: 0; }

.rcms-form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
}
.rcms-header-actions { display: flex; gap: 8px; }

/* Role-form permission grid (#325) — section spacing + heading chrome.
   The table itself is a plain `.rcms-data.rcms-perm-table`; only the
   surrounding section furniture lives here. */
.rcms-perm-section { margin-bottom: 20px; }
.rcms-perm-section-heading {
    padding: 8px 12px;
    background: var(--md-sys-color-surface-container);
    font: var(--md-sys-typescale-ui-label);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Page comment threads + workflow chrome (role/page editor, #325).
   `.rcms-comment*` and `.rcms-workflow-bar` appear only in page_form. */
.rcms-comment       { padding: 10px 0; }
.rcms-comment-body  { margin-top: 6px; }
.rcms-comment-reply {
    margin-left: 16px;
    padding-left: 12px;
    border-left: 2px solid var(--md-sys-color-outline-variant);
}
.rcms-comment-reply .rcms-hint { margin-top: 2px; }
.rcms-comment-reply-form  { margin-left: 16px; }
.rcms-comment-input {
    height: 32px;
    padding: 0 8px;
    background: var(--md-sys-color-surface-container);
}
.rcms-comment-new { background: var(--md-sys-color-surface-container-low); }
.rcms-chip { padding: 4px 8px; background: var(--md-sys-color-surface-container); }
/* `.rcms-card--error` fill lives in the shared semantic fills (tag section). */
/* Page editor status banners (#325, page_form only). The presence
   banner starts hidden; its JS toggles inline `display` (none/flex),
   which overrides this base rule either way. */
.rcms-page-lock-banner {
    background: var(--md-sys-color-tertiary-container);
    color: var(--md-sys-color-on-tertiary-container);
    border-radius: var(--md-sys-radius-lg);
    box-shadow: var(--md-sys-elevation-1);
}
.rcms-page-presence-banner {
    display: none;
    padding-left: 12px;
    padding-right: 12px;
    background: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
}
/* Upload crop tool (#325, media_upload). The preview is crosshair-
   draggable; the rect overlay is positioned by JS (top/left/size) and
   starts hidden. */
.rcms-upload-crop-preview { max-height: 480px; cursor: crosshair; }
.rcms-upload-crop-rect {
    border: 2px solid var(--md-sys-color-primary);
    background: color-mix(in srgb, var(--md-sys-color-primary) 18%, transparent);
    pointer-events: none;
    display: none;
}
/* Media-card overlays (#325, media_list) — positioned on each card. */
.rcms-media-card-select {
    top: 16px;
    left: 16px;
    z-index: 1;
    background: var(--md-sys-color-surface-container-lowest);
    padding: 2px 4px;
    box-shadow: var(--md-sys-elevation-1);
}
.rcms-media-card-kebab { top: 12px; right: 12px; z-index: 2; }

/* #159 — canonical search-input capsule. Was previously inline in
   page_list.html only; promoted here so every listing (pages,
   media, library, redirects, navigation, locales, topbar) shares
   one look.

   #288 — radius dropped from `--md-sys-radius-full` (pill) to
   `--md-sys-radius-md` so search inputs match the rest of the
   admin's text inputs (the `.rcms-field input[type="text"]` family
   above also uses `radius-md`). Pill-shaped search alongside
   square form inputs read as stitched-together; this aligns them. */
.rcms-search-input {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
    height: 40px;
    flex: 1 1 280px;
    background: var(--md-sys-color-surface-container);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-radius-md);
    transition: border-color 0.12s, box-shadow 0.12s;
    cursor: text;
}

/* Sidebar variant. MUST come after `.rcms-search-input`: same
   specificity, so source order decides — defined earlier, the base
   rule's 40px height and light surface silently won. */
.rcms-search-input--sidebar {
    display: flex;
    width: 100%;
    height: 36px;
    flex: 0 0 auto;
    /* The rail is dark; the shared capsule's light surface would glare.
       Tint from the sidebar's own palette instead. */
    background: color-mix(in srgb, var(--sidebar-fg) 10%, transparent);
    border-color: color-mix(in srgb, var(--sidebar-fg) 18%, transparent);
}
.rcms-search-input--sidebar input,
.rcms-search-input--sidebar .material-symbols-rounded {
    color: var(--sidebar-fg);
}
.rcms-search-input--sidebar input::placeholder {
    color: color-mix(in srgb, var(--sidebar-fg) 55%, transparent);
}
.rcms-search-input--sidebar:focus-within {
    background: color-mix(in srgb, var(--sidebar-fg) 16%, transparent);
    border-color: color-mix(in srgb, var(--sidebar-fg) 40%, transparent);
}
/* Shared listing filter row — a `.rcms-search-input` capsule, inline
   selects and small buttons on one line. Pages / media / redirects
   all wear this; keep new listings on it rather than a labelled
   `.rcms-field-row` card. */
.rcms-list-filter-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}
/* Chrome comes from the canonical `select:not(.rcms-field select)` — only
   the height is set here, so selects line up with the capsule. */
.rcms-list-filter-row select { height: 40px; }

.rcms-search-input:focus-within {
    border-color: var(--md-sys-color-primary);
    box-shadow: 0 0 0 1px var(--md-sys-color-primary);
}
.rcms-search-input > .material-symbols-rounded {
    color: var(--md-sys-color-on-surface-variant);
    flex: 0 0 auto;
}
.rcms-search-input > input[type="search"],
.rcms-search-input > input[type="text"] {
    flex: 1 1 auto;
    min-width: 0;
    height: 100%;
    padding: 0;
    background: transparent;
    border: 0;
    outline: none;
    font: var(--md-sys-typescale-ui-body);
    color: var(--md-sys-color-on-surface);
}
.rcms-search-input > input[type="search"]::-webkit-search-decoration { display: none; }

/* Topbar modifier — tighter height + neutral flex basis since the
   topbar parent caps the overall width. */
/* ============================================================
 * 11. Stream editor + block picker
 * ============================================================ */

/* #273 — StreamField editor. The outer editor is flat —
   no box around the body — so the tree guide line is the only
   structural visual. Individual block cards are also flat (no
   border, no background): the dashed guide line on the left of
   each `.rcms-stream-nested` level + the circular block-type icon at
   the start of each header carry the whole hierarchy. */
.rcms-stream-editor {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 0;
    background: transparent;
}
.rcms-stream-editor .rcms-stream-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.rcms-stream-block {
    /* Flat — no border, no background. Sibling separation comes
       from the gap on `.rcms-stream-list` + the header's dotted
       underline. */
    border: none;
    border-radius: 0;
    background: transparent;
    overflow: visible;
    padding-bottom: 4px;
}
.rcms-stream-block-header {
    /* One tight row: circular type icon + title + circular action
       buttons, anchored by a dotted underline that picks up from
       the tree guide on the left. Border-bottom is 2 px so the
       dotted pattern actually renders as visible dots (1 px
       dotted aliases to a near-solid line in most browsers). */
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 4px;
    background: transparent;
    border-bottom: 2px dotted var(--md-sys-color-outline);
}
.rcms-stream-block-icon {
    /* Circular badge in the brand colour. Acts as the
       block-type indicator that anchors each row to its tree
       lineage at-a-glance. */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    flex: 0 0 24px;
    border-radius: 50%;
    background: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    font-size: 14px;
}
.rcms-stream-block-title {
    flex: 1;
    font-size: 13px;
    font-weight: 500;
    color: var(--md-sys-color-on-surface);
}
.rcms-stream-block-actions {
    display: inline-flex;
    gap: 4px;
    align-items: center;
}
/* Round action buttons — match the type-icon badge so the whole
   row reads as a series of pills aligned along the dotted line. */
.rcms-stream-block-actions .rcms-btn {
    width: 28px;
    height: 28px;
    padding: 0;
    border-radius: 50%;
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.rcms-stream-block-actions .rcms-btn .material-symbols-rounded { font-size: 16px; }
.rcms-stream-block-actions .rcms-btn-icon { width: 28px; }
.rcms-stream-block-body {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
/* `.rcms-stream-field > label` is styled by the canonical form-label rule
   (M3 form fields section). */
/* #273 — tree nesting. Each `.rcms-stream-nested` is a
   level of depth; its DASHED left border becomes a vertical guide
   that visually owns the indented column of nested blocks
   beneath it. Multiple levels stack naturally because
   `.rcms-stream-nested` is recursive — every nested level draws its
   own guide, so 3-deep nesting reads as three indented columns
   side-by-side. The dashed style follows the tree-guide
   convention (vs. solid lines which read as borders). */
.rcms-stream-nested {
    border: none;
    /* 2 px so the dotted pattern actually renders as visible
       dots — 1 px dotted aliases to a near-solid line in most
       browsers. */
    border-left: 2px dotted var(--md-sys-color-outline);
    border-radius: 0;
    padding: 2px 0 4px 18px;
    margin: 6px 0 6px 6px;
}
/* Base look from the canonical form-label rule; legends only need
   their UA padding zeroed. */
.rcms-stream-nested > legend { padding: 0; }
/* Subtle highlight on the guide when a child block is focused —
   reinforces "this is the parent of what you're editing". */
.rcms-stream-nested:has(.rcms-stream-block:focus-within) {
    border-left-color: var(--md-sys-color-primary);
}
.rcms-stream-picker { align-self: flex-start; }
.rcms-stream-drift {
    padding: 12px;
    background: var(--md-sys-color-warning-container);
    border: 1px solid var(--md-sys-color-warning);
    color: var(--md-sys-color-on-warning-container);
    border-radius: var(--md-sys-radius-md);
    font-size: 13px;
}

.rcms-block-picker {
    border: 1px solid var(--border);
    border-radius: var(--md-sys-radius-xl);
    padding: 0;
    min-width: 360px;
    max-width: 90vw;
    background: var(--md-sys-color-surface-container-lowest);
    box-shadow: var(--md-sys-elevation-3);
}
.rcms-block-picker::backdrop { background: rgba(0, 0, 0, 0.3); }
/* min-width capped to the viewport so the dialog never exceeds a phone
 * screen (was a hard 420px, overflowing sub-420px devices). */
.rcms-block-picker { padding: 16px; min-width: min(420px, 90vw); }
.rcms-block-picker header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
/* #411 — block-picker search box. */
.rcms-block-picker-search {
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 12px;
}
/* #411 — group section header inside the picker list. A presentational
   <li> that labels the blocks beneath it; hidden by the editor JS when
   the group has no visible (allowed + search-matching) blocks. */
.rcms-block-picker-group {
    list-style: none;
    margin: 8px 0 2px;
    padding: 0 4px;
    font-size: var(--md-sys-typescale-label-small-size, 0.6875rem);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--md-sys-color-on-surface-variant);
}
.rcms-block-picker-group:first-child { margin-top: 0; }
.rcms-block-picker-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 60vh;
    overflow-y: auto;
}
.rcms-block-picker-tile {
    position: relative;
    isolation: isolate;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-radius-md);
    background: var(--md-sys-color-surface-container-lowest);
    cursor: pointer;
    font: inherit;
    font-size: 13px;
    color: var(--fg);
    width: 100%;
    text-align: left;
    transition: border-color 0.12s, box-shadow 0.12s;
}
.rcms-block-picker-tile::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: var(--md-sys-color-primary);
    opacity: 0;
    border-radius: inherit;
    transition: opacity 0.12s;
}
.rcms-block-picker-tile:hover::before { opacity: 0.06; }
.rcms-block-picker-tile:hover { border-color: var(--md-sys-color-primary); }
.rcms-block-picker-tile .material-symbols-rounded {
    font-size: 22px;
    color: var(--accent);
    margin-left: auto; /* push icon to the right; label sits on the left */
    order: 2;
}

/* ============================================================
 * 12. Auth chrome (login / password-reset) — shared `_auth_layout`
 *
 * All five auth screens render inside a centered `.rcms-auth-card`,
 * styled with the same MD3 tokens as the dashboard. Labels, inputs
 * and their focus/hover states bind into the canonical `.rcms-field`
 * rules (M3 form fields section); submit buttons carry `.rcms-btn`.
 * Only auth-specific deltas live here. (The dead `.login-card`
 * alias — zero templates — was removed in the DRY pass.)
 * ============================================================ */

.rcms-auth-body {
    /* Auth pages have no sidebar — body becomes the centered
       container instead of a flex row. */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: var(--md-sys-color-surface-container-low);
    overflow: auto;
    height: 100vh;
}
.rcms-auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--md-sys-color-surface-container-lowest);
    border: 1px solid color-mix(in srgb, var(--md-sys-color-outline-variant) 40%, transparent);
    border-radius: var(--md-sys-radius-xl);
    padding: 36px;
    box-shadow: var(--md-sys-elevation-2);
}
.rcms-auth-card h1 {
    margin: 0 0 8px;
    font: var(--md-sys-typescale-ui-header);
    font-size: 22px;
    line-height: 28px;
    color: var(--fg);
}
.rcms-auth-card .rcms-lead {
    margin: 0 0 24px;
    font-size: 13px;
    color: var(--muted);
}
.rcms-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}
.rcms-brand-icon {
    width: 44px; height: 44px;
    border-radius: var(--md-sys-radius-lg);
    background: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.rcms-brand-icon .material-symbols-rounded { font-size: 24px; vertical-align: 0; }
/* #199 — when a tenant logo/favicon is set, drop the coloured badge and show
   the image itself (like the sidebar brand logo). */
.rcms-brand-icon--img { background: none; }
.rcms-brand-icon-img { width: 44px; height: 44px; object-fit: contain; display: block; }
/* The Rustango CMS badge (no tenant logo): large, centred above the name. */
.rcms-brand:has(.rcms-brand-badge) {
    flex-direction: column;
    text-align: center;
    gap: 14px;
}
.rcms-brand-badge { line-height: 0; }
.rcms-brand-badge img {
    width: 132px;
    height: 132px;
    filter: drop-shadow(0 6px 16px rgba(0, 0, 0, .12));
}

/* Brand images that come in a light and a dark version. They follow the
   admin's theme: an explicit Light/Dark choice, else the system setting. */
.rcms-brand-for-dark { display: none; }
:root[data-theme="dark"] .rcms-brand-for-light { display: none; }
:root[data-theme="dark"] .rcms-brand-for-dark { display: block; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .rcms-brand-for-light { display: none; }
    :root:not([data-theme="light"]) .rcms-brand-for-dark { display: block; }
}
.rcms-brand-name {
    font: var(--md-sys-typescale-ui-header);
    color: var(--fg);
}
.rcms-brand-sub {
    font-size: 12px;
    color: var(--muted);
    margin-top: 2px;
}
/* Label + input chrome and focus/hover rings come from the canonical
   `.rcms-field` rules — only the auth layout deltas live here. */
.rcms-auth-card label { margin: 14px 0 0; }
/* The members' sign-in pages link back to the site they came from. */
.rcms-auth-back { margin: 20px 0 0; text-align: center; font-size: 14px; }
.rcms-auth-back a { color: var(--muted); text-decoration: none; }
.rcms-auth-back a:hover { color: var(--fg); text-decoration: underline; }
.rcms-auth-card input[type="text"],
.rcms-auth-card input[type="password"],
.rcms-auth-card input[type="email"] {
    margin-top: 6px;
    font-size: 14px;
}
.rcms-auth-card .rcms-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 24px;
    gap: 12px;
}
/* Submit is a canonical `.rcms-btn` in the markup; auth keeps its slightly
   taller full-width shape. */
.rcms-auth-card button[type="submit"] {
    flex: 1;
    height: 44px;
}
.rcms-forgot {
    font-size: 13px;
    color: var(--muted);
    text-decoration: none;
}
.rcms-forgot:hover {
    color: var(--accent);
    text-decoration: underline;
}
.rcms-auth-card .rcms-error,
.rcms-auth-card .rcms-notice {
    margin: 16px 0 0;
    padding: 12px 16px;
    border-radius: var(--md-sys-radius-md);
    font-size: 13px;
}
.rcms-auth-card .rcms-error {
    background: var(--md-sys-color-error-container);
    border: 1px solid var(--md-sys-color-error);
    color: var(--md-sys-color-on-error-container);
}
.rcms-auth-card .rcms-notice {
    background: var(--md-sys-color-success-container);
    border: 1px solid var(--md-sys-color-success);
    color: var(--md-sys-color-on-success-container);
}
.rcms-center-cta {
    text-align: center;
    margin-top: 20px;
}
.rcms-center-cta a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}
.rcms-center-cta a:hover { text-decoration: underline; }

/* ============================================================
 * 14. Page editor — extracted from `page_form.html`'s inline
 *     `<style>` block. Two-pane split (editor + live preview),
 *     tab strip, translation rows, viewport buttons, type chip.
 * ============================================================ */

/* Translation editor — side-by-side rows. */
.rcms-tr-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    margin-bottom: 18px;
}
.rcms-tr-row .rcms-canonical {
    background: var(--md-sys-color-surface-container-low);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-radius-md);
    padding: 10px 12px;
    font-size: 14px;
    color: var(--muted);
    word-break: break-word;
}
/* Reject opens a small box asking what should change. */
.rcms-reject-box { position: relative; display: inline-block; }
.rcms-reject-box > summary { list-style: none; cursor: pointer; }
.rcms-reject-box > summary::-webkit-details-marker { display: none; }
.rcms-reject-box > .rcms-reject-form .rcms-field { width: 100%; }
.rcms-reject-box > .rcms-reject-form {
    position: absolute; z-index: 20; top: calc(100% + 6px); left: 0;
    width: min(360px, 80vw); display: grid; grid-template-columns: 1fr; justify-items: start; gap: 10px; padding: 14px;
    background: var(--md-sys-color-surface-container-lowest);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-radius-md);
    box-shadow: var(--md-sys-elevation-2);
}
/* Only the original text keeps its line breaks — not the markup around it. */
.rcms-tr-row .rcms-canonical-text {
    white-space: pre-wrap;
}
/* Rich text is shown formatted; its paragraphs keep a small gap. */
.rcms-tr-row .rcms-canonical-rich > :first-child { margin-top: 0; }
.rcms-tr-row .rcms-canonical-rich > :last-child { margin-bottom: 0; }
.rcms-tr-row .rcms-canonical-rich p { margin: 0 0 8px; }
.rcms-tr-row .rcms-canonical .rcms-lbl,
.rcms-tr-row label.rcms-tr-lbl {
    display: flex; align-items: center; gap: 4px;
    font: var(--md-sys-typescale-ui-label);
    text-transform: uppercase; letter-spacing: 0.05em;
    color: var(--muted-2); margin-bottom: 6px;
}
.rcms-tr-row label.rcms-tr-lbl { color: var(--md-sys-color-tertiary); }
.rcms-tr-row textarea,
.rcms-tr-row input[type="text"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--md-sys-color-tertiary-fixed-dim);
    border-radius: var(--md-sys-radius-md);
    background: var(--md-sys-color-surface-container-lowest);
    font: inherit;
    color: var(--md-sys-color-on-surface);
    transition: border-color 0.12s, box-shadow 0.12s;
}
.rcms-tr-row textarea:focus,
.rcms-tr-row input:focus {
    outline: none;
    border-color: var(--md-sys-color-tertiary);
    box-shadow: 0 0 0 1px var(--md-sys-color-tertiary);
}
.rcms-tr-row .rcms-placeholder { color: var(--muted-2); font-style: italic; }

/* #i18n — per-leaf StreamField translation groups (incl. nested blocks). */
.rcms-tr-stream { margin-bottom: 16px; }
.rcms-tr-stream-field {
    display: flex; align-items: center; gap: 6px;
    font: var(--md-sys-typescale-label-large);
    color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em;
    margin: 10px 0 6px;
}
.rcms-tr-block {
    border-left: 2px solid var(--md-sys-color-outline-variant);
    padding-left: 12px; margin-bottom: 10px;
}
/* Nested-block indent for the stream-translation view — a bounded class
 * set instead of a computed inline style (page_form.html is locked
 * inline-style-free by admin_surface #325). Depth is clamped to 6 in the
 * template; deeper nesting shares the deepest indent. */
.rcms-tr-block--d1 { margin-left: 20px; }
.rcms-tr-block--d2 { margin-left: 40px; }
.rcms-tr-block--d3 { margin-left: 60px; }
.rcms-tr-block--d4 { margin-left: 80px; }
.rcms-tr-block--d5 { margin-left: 100px; }
.rcms-tr-block--d6 { margin-left: 120px; }
.rcms-tr-block-head {
    display: flex; align-items: center; gap: 6px;
    font-weight: 600; font-size: 13px; color: var(--fg);
    margin-bottom: 6px;
}

/* Two-pane edit experience — editor on the left, live preview on
   the right with a draggable splitter. Only mounted in edit mode;
   the "new" form is single-column. */
.rcms-edit-with-preview {
    display: flex; flex-direction: row; align-items: stretch;
    width: 100%; min-height: calc(100vh - 220px);
}
.rcms-edit-pane {
    flex: 1 1 60%; min-width: 320px;
    padding-right: 12px; overflow-x: auto;
}
/* On phones the 320px floor exceeds the content width (~304px at 360px)
 * and pushed the page sideways. Below the drawer breakpoint the pane is
 * already full-width-stacked, so drop the floor. */
@media (max-width: 768px) {
    .rcms-edit-pane { min-width: 0; padding-right: 0; }
}
/* Drop the inline 760px cap on cards inside the edit pane so the
   form expands to fill the available width. */
.rcms-edit-pane > .rcms-card,
.rcms-edit-pane > section.rcms-card,
.rcms-edit-pane > form.rcms-card { max-width: none !important; }

/* #256 — split handle: 6px visual stays narrow but the hit target
   extends ±9px via `::before` so the effective pointer area is
   24px (Material guidance). The handle aligns with the preview
   pane (`align-self: stretch` + sticky `top`) so it visually
   pairs with the right column, not the full editor stack. */
.rcms-split-handle {
    flex: 0 0 6px;
    background: var(--md-sys-color-outline-variant);
    cursor: col-resize; position: relative;
    touch-action: none; user-select: none;
    /* Sticky pairing with the preview column. Same `top` as
       `.rcms-preview-pane` (48px topbar + 40px action bar + 12px). */
    position: sticky;
    top: 100px;
    align-self: flex-start;
    height: calc(100vh - 110px);
    transition: background 0.1s;
}
/* Invisible hit-target overlay — 24px wide, centered on the visible
   handle. The pseudo-element is `pointer-events: auto` so clicks /
   drags here register on the handle even though the visual stays 6px. */
.rcms-split-handle::before {
    content: "";
    position: absolute;
    inset: 0 -9px;
    z-index: 1;
    cursor: col-resize;
}
.rcms-split-handle::after {
    content: ""; position: absolute;
    top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: 2px; height: 56px; border-radius: 1px;
    background: var(--md-sys-color-outline);
    transition: background 0.1s, height 0.1s;
    z-index: 2;
    pointer-events: none;
}
.rcms-split-handle:hover {
    background: var(--md-sys-color-primary-fixed);
}
.rcms-split-handle:hover::after {
    background: var(--md-sys-color-primary);
    height: 80px;
}
.rcms-split-handle.dragging { background: var(--md-sys-color-primary-fixed); }
.rcms-split-handle.dragging::after { background: var(--md-sys-color-primary); }

.rcms-preview-pane {
    flex: 1 1 40%; min-width: 280px;
    display: flex; flex-direction: column;
    padding-left: 12px;
    position: sticky;
    /* 48px topbar + 40px action bar = 88px; +12px breathing */
    top: 100px; align-self: flex-start;
    /* #158 — full sticky-pane height: use `height` instead of
       `max-height` so the iframe inside can fill 100% of the
       available space. */
    height: calc(100vh - 110px);
}
/* API-response surface — the JSON sibling of `.rcms-preview-stage`.
   A sibling, not a child: the stage is `overflow: hidden` on purpose so
   the iframe owns scrolling, and nesting a scrollable <pre> inside it
   would fight that rule. Here the <pre> is the scroll surface, exactly
   as the iframe is in HTML mode. */
.rcms-preview-json {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: var(--md-sys-color-surface-container-lowest);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-radius-lg);
    /* Clips the body's corners to the panel radius. */
    overflow: hidden;
}
.rcms-preview-json-bar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    min-height: 40px;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
}
.rcms-preview-json-meta {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.rcms-preview-json-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    margin: 0;
    padding: 12px;
    line-height: 1.5;
    tab-size: 2;
    /* A long URL or rich-text string should wrap rather than force the
       whole pane into horizontal scroll at 400px wide. */
    overflow-wrap: anywhere;
}
/* In flight: dim rather than blank, so the previous response stays
   readable while the next one lands. */
.rcms-preview-json[data-stale] .rcms-preview-json-body { opacity: 0.55; }
/* The "no HTML representation" stage still centres its notice. */
.rcms-preview-unavailable {
    align-items: center;
    justify-content: center;
}

.rcms-preview-stage {
    flex: 1 1 auto;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    background: var(--md-sys-color-surface-container-low);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-radius-lg);
    padding: 8px;
    /* Clip, don't scroll. The iframe is the single scroll surface (its
       own document scrolls); a scrollable stage let the user pan into
       the centered gutters and fought the iframe's internal scroll
       (stuck scroll). */
    overflow: hidden;
    /* #158 — drop the 480px floor so short viewports don't clip the
       iframe. `min-height: 0` lets the flex child shrink. */
    min-height: 0;
}
/* The decoupled-frontend surface. Same stage box as the HTML one, but
   it stacks a status bar above the frame — cross-origin means the CMS
   cannot live-refresh it, and the bar is where that is said. The frame
   AREA keeps the ordinary stage padding so the viewport maths, which
   measures it, needs no special case. */
.rcms-preview-stage[data-surface="site"] {
    flex-direction: column;
    align-items: stretch;
    padding: 0;
    background: var(--md-sys-color-surface-container-lowest);
}
.rcms-preview-stage[data-surface="site"] .rcms-preview-json-bar {
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
}
.rcms-preview-frame-area {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 8px;
    /* Same reason as the stage: the iframe owns scrolling. */
    overflow: hidden;
}

/* Fit-to-pane preview scaling: the sizer carries the SCALED
 * footprint (so flex layout reserves the right space + the iframe
 * appears centered), while the iframe inside keeps its DOM at the
 * device-pixel width and is `transform: scale()`-d to fit. JS
 * (`page_form.html` viewport handler) sets the inline custom
 * properties + `transform` after computing the right scale factor
 * for the current pane width. The default values fall back to
 * "full" — iframe fills the stage, no scaling. */
.rcms-preview-frame-sizer {
    width: var(--rcms-pv-sizer-w, 100%);
    height: var(--rcms-pv-sizer-h, 100%);
    /* Animate the layout collapse so device-picker clicks aren't
     * jarring. `transition: transform` lives on the iframe. */
    transition: width 0.15s ease, height 0.15s ease;
    flex: 0 0 auto;
    /* Clip the iframe's UNSCALED layout box (transform:scale shrinks
     * paint, not layout) to the scaled footprint, so a down-scaled
     * device (768/1280) doesn't overflow the stage. */
    overflow: hidden;
}
.rcms-preview-frame {
    /* DOM width — set in inline style by the JS viewport handler
     * to the chosen device width (375 / 768 / 1280 / 100%).
     * Media queries inside the iframe fire against THIS dimension,
     * matching the real device. */
    width: var(--rcms-pv-frame-w, 100%);
    height: var(--rcms-pv-frame-h, 100%);
    /* `transform-origin: top left` so the scaled iframe lines up
     * with the sizer's box. */
    transform-origin: top left;
    transform: scale(var(--rcms-pv-scale, 1));
    transition: transform 0.15s ease;
    border: 0;
    border-radius: var(--md-sys-radius-md);
    background: var(--md-sys-color-surface-container-lowest);
    box-shadow: var(--md-sys-elevation-1);
    /* No min-height: with `transform: scale()` a min-height floor
     * inflates the UNSCALED DOM box, so the browser computes a taller
     * scroll extent than is painted — the root of the stuck scroll.
     * The JS viewport handler always sets an explicit
     * `--rcms-pv-frame-h`, so the iframe can't collapse on first render. */
}

/* Viewport buttons in the action bar. */
.rcms-viewport-buttons {
    display: inline-flex; gap: 0;
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-radius-md);
    overflow: hidden;
    margin-right: 4px;
}
.rcms-viewport-btn {
    height: 32px;
    padding: 0 8px !important;
    border-radius: 0 !important;
    border: none !important;
    border-right: 1px solid var(--md-sys-color-outline-variant) !important;
    background: transparent;
    color: var(--muted);
}
.rcms-viewport-btn:last-child { border-right: none !important; }
.rcms-viewport-btn[aria-pressed="true"] {
    background: var(--md-sys-color-primary) !important;
    color: var(--md-sys-color-on-primary) !important;
}
.rcms-viewport-btn[aria-pressed="true"] .material-symbols-rounded {
    color: var(--md-sys-color-on-primary) !important;
}

/* Mobile / narrow — stack and hide the splitter. */
@media (max-width: 1023px) {
    .rcms-edit-with-preview { flex-direction: column; min-height: auto; }
    .rcms-edit-pane { padding-right: 0; }
    .rcms-split-handle { display: none; }
    .rcms-preview-pane {
        padding-left: 0; padding-top: 16px;
        position: static; max-height: none;
        /* #158 — drop the static height on mobile so the pane
           naturally fills the column width. Iframe handles its own
           height below. */
        height: auto;
        flex: 0 0 auto;
        width: 100%;
    }
    .rcms-preview-stage {
        /* Full-width on mobile/tablet — collapse padding so the
           iframe gets the maximum horizontal space. */
        width: 100%;
        padding: 4px;
    }
    /* Force-disable scaling on narrow viewports where the editor
       stacks below the form — preview is for at-a-glance, not
       device-emulation, in that layout. The JS viewport handler
       still runs but its inline `transform` / sizer custom
       properties are overridden here. */
    .rcms-preview-frame-sizer {
        width: 100%;
        height: 60vh;
    }
    .rcms-preview-frame {
        min-height: 60vh;
        height: 60vh;
        width: 100%;
        transform: none !important;
    }
}

/* "Hide preview" state. */
[data-preview-hidden] .rcms-preview-pane,
[data-preview-hidden] .rcms-split-handle { display: none; }
[data-preview-hidden] .rcms-edit-pane { padding-right: 0; flex: 1 1 100%; }

/* Tab strip — lives inside the sticky action bar. */
.rcms-tab-strip {
    display: flex;
    gap: 4px;
    flex: 1 1 auto;
    min-width: 0;
    /* Wrap to a second row rather than scroll-clipping the last tab(s). The
       phone media query switches this back to a horizontal swipe. */
    flex-wrap: wrap;
    row-gap: 4px;
    scrollbar-width: thin;
}
.rcms-tab-strip::-webkit-scrollbar { height: 6px; }
.rcms-tab-strip::-webkit-scrollbar-thumb {
    background: var(--md-sys-color-outline-variant);
    border-radius: 3px;
}
.rcms-tab-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    height: 32px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--md-sys-radius-full);
    cursor: pointer;
    font: var(--md-sys-typescale-ui-button);
    color: var(--muted);
    white-space: nowrap;
    flex: 0 0 auto;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.rcms-tab-tab:hover {
    background: var(--md-sys-color-surface-container);
    color: var(--fg);
}

/* Icon-first tabs: only the selected tab carries its label, so the strip
   stays compact and the current section is unmistakable. Hover and
   keyboard focus reveal a label too, keeping the icons discoverable.
 *
 * The label animates as a GRID TRACK (0fr -> 1fr), not `max-width`.
 * max-width has to guess a target ("20ch"), and whatever you guess is
 * almost never the real text width — so the easing curve maps to the
 * guess rather than to the motion you see, and the label appears to
 * clip open at the wrong rate. A grid track interpolates to the text's
 * intrinsic width, so the curve matches the movement exactly.
 *
 * The label stays in the accessibility tree throughout — it IS the
 * button's accessible name, so it must never be `display: none`. */
.rcms-tab-label {
    display: grid;
    grid-template-columns: 0fr;
    opacity: 0;
    transition: grid-template-columns var(--rcms-tab-ease-dur) var(--rcms-tab-ease),
                opacity 140ms linear;
}
.rcms-tab-label > span {
    overflow: hidden;
    white-space: nowrap;
    min-width: 0;
}
.rcms-tab-tab[aria-selected="true"] .rcms-tab-label,
.rcms-tab-tab:hover .rcms-tab-label,
.rcms-tab-tab:focus-visible .rcms-tab-label {
    grid-template-columns: 1fr;
    opacity: 1;
    /* Hold the text back until there is room for it, so it fades in
       instead of appearing over a still-closing box. Collapsing has no
       delay — the label should leave immediately. */
    transition: grid-template-columns var(--rcms-tab-ease-dur) var(--rcms-tab-ease),
                opacity 140ms linear 80ms;
}
/* Collapsed, the button is a circle around its icon; the 14px side
   padding would stretch it into an oval. These MUST be transitioned
   alongside the label — leaving them out makes the padding snap while
   the label glides, which is what made the motion feel rough. */
.rcms-tab-tab:not([aria-selected="true"]):not(:hover):not(:focus-visible) {
    padding-inline: 8px;
    gap: 0;
}
.rcms-tab-tab {
    /* Material's emphasized-decelerate curve: quick to start, long soft
       landing. `ease` over 180ms read as abrupt. */
    --rcms-tab-ease: cubic-bezier(0.2, 0, 0, 1);
    --rcms-tab-ease-dur: 260ms;
    transition: background 0.12s, color 0.12s, border-color 0.12s,
                padding-inline var(--rcms-tab-ease-dur) var(--rcms-tab-ease),
                gap var(--rcms-tab-ease-dur) var(--rcms-tab-ease);
}
@media (prefers-reduced-motion: reduce) {
    .rcms-tab-tab, .rcms-tab-label { transition-duration: 1ms; }
}
.rcms-tab-tab[aria-selected="true"] {
    background: var(--md-sys-color-primary-fixed);
    color: var(--md-sys-color-on-primary-fixed);
    border-color: var(--md-sys-color-primary-fixed-dim);
}
.rcms-tab-tab .material-symbols-rounded { font-size: 16px; }
.rcms-preview-controls { display: flex; gap: 4px; flex: 0 0 auto; }
[data-preview-hidden] .rcms-preview-controls { display: none; }
.rcms-tab-tab .rcms-tab-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: var(--md-sys-radius-full);
    background: var(--md-sys-color-outline-variant);
    color: var(--muted);
    font-size: 10px;
    font-weight: 600;
    margin-left: 4px;
}
.rcms-tab-tab[aria-selected="true"] .rcms-tab-count {
    background: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
}
.rcms-tab-panel[hidden] { display: none; }

/* #273 — Body content fieldset. Drop the border / padding /
   background — the StreamField inside provides its own tree
   visual; an outer card here just adds noise. Keep the legend
   styled so the section heading still anchors the tab. */
.rcms-content-fieldset {
    border: none;
    padding: 0;
    margin: 20px 0 0;
}
.rcms-content-fieldset > legend {
    padding: 0;
    margin-bottom: 8px;
    font: var(--md-sys-typescale-ui-button);
    color: var(--md-sys-color-primary);
}

/* #269 — page-type breadcrumb strip. Slim, muted, sits above the
   title field so the type reads as page-context
   rather than a same-weight form input. The `title` attr carries
   the machine name + "permanent" note so editors can still see
   the detail on hover without it dominating the layout. */
.rcms-page-type-strip {
    display: inline-flex; align-items: center; gap: 6px;
    margin-bottom: 12px;
    padding: 4px 10px;
    background: var(--md-sys-color-surface-container-low);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-radius-sm);
    font-size: 12px;
    color: var(--md-sys-color-on-surface-variant);
    cursor: help;
}
.rcms-page-type-strip .material-symbols-rounded {
    font-size: 14px;
    color: var(--md-sys-color-on-surface-variant);
}
.rcms-page-type-strip-name {
    font-weight: 500;
    color: var(--md-sys-color-on-surface);
}

/* Page form section banners — the small `.rcms-card` headers that wrap
   over the editor (translation notice, page-edit info). Extracted
   from inline `style="max-width: 760px; margin-bottom: 16px;"`. */
.rcms-page-form-banner {
    max-width: 760px;
    margin-bottom: 16px;
    padding: 10px 14px;
}
.rcms-page-form-banner .rcms-hint { margin: 0; }
.rcms-page-form-section {
    max-width: 760px;
}

/* Page-form notice banner — replaces inline
   `style="background: var(--accent-soft); ..."`. */
.rcms-page-form-notice {
    background: var(--md-sys-color-primary-fixed);
    border: 1px solid var(--md-sys-color-primary-fixed-dim);
    color: var(--md-sys-color-on-primary-fixed-variant);
    padding: 12px 16px;
    border-radius: var(--md-sys-radius-md);
    margin-bottom: 20px;
    font-size: 13px;
}
.rcms-page-form-notice--translation {
    background: var(--md-sys-color-tertiary-container);
    border: 1px solid var(--md-sys-color-tertiary);
    border-left-width: 4px;
    color: var(--md-sys-color-on-tertiary-container);
}

/* Revisions table header. */
.rcms-revisions-card h2 {
    margin: 0 0 12px;
    font: var(--md-sys-typescale-ui-header);
}
.rcms-revisions-card .rcms-data { margin-top: 8px; }
.rcms-revisions-card .rcms-data td.timestamp {
    color: var(--muted);
    font-size: 12px;
}
.rcms-revisions-card .rcms-data .rcms-system-author {
    color: var(--muted-2);
}

/* Page-form group headings (translation editor + custom keys
   subsection). #270 — each heading except the first carries a top
   divider so logical groups on non-Content tabs (Schedule / Tags /
   Social sharing on the Promote tab; equivalent splits elsewhere)
   read as sectioned panels rather than a single jumbled
   block. */
.rcms-page-form-subheading {
    /* h3 is block-level so the border spans the full container
       width — that's what reads as the section divider. */
    display: block;
    margin: 32px 0 14px;
    padding-top: 24px;
    border-top: 2px solid var(--md-sys-color-outline);
    font: var(--md-sys-typescale-ui-label);
    color: var(--muted);
    letter-spacing: 0.05em;
    text-transform: uppercase;
}
.rcms-page-form-subheading:first-of-type {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}
.rcms-page-form-subhint { margin-top: 0; }
.rcms-page-form-subscribe { display: flex; align-items: center; gap: 8px; margin: 8px 0 0; padding: 0; flex-wrap: wrap; }
/* Subscribe hint styling comes from the base `.rcms-hint` rule. */

/* #116 — accessibility checker side panel. */
.rcms-a11y-card { margin-bottom: 16px; padding: 12px 16px; }
.rcms-a11y-summary { cursor: pointer; font-weight: 500; display: flex; align-items: center; gap: 8px; }
.rcms-a11y-list { list-style: none; padding: 0; margin: 12px 0 0; }
.rcms-a11y-row { display: flex; align-items: flex-start; gap: 8px; padding: 8px 0; border-top: 1px solid var(--md-sys-color-outline-variant); font-size: 13px; }
.rcms-a11y-row:first-child { border-top: none; }
.rcms-a11y-row--error .material-symbols-rounded { color: var(--md-sys-color-error); }
.rcms-a11y-row--warning .material-symbols-rounded { color: #b8860b; }
.rcms-a11y-row--info .material-symbols-rounded { color: var(--md-sys-color-on-surface-variant); }
.rcms-a11y-msg { flex: 1; }
.rcms-a11y-field { font-size: 11px; padding: 2px 6px; background: var(--md-sys-color-surface-container); border-radius: var(--md-sys-radius-sm); color: var(--md-sys-color-on-surface-variant); }
.rcms-a11y-footer { margin: 12px 0 0; font-size: 11px; }
.rcms-a11y-tag-error { background: var(--md-sys-color-error-container); color: var(--md-sys-color-on-error-container); font-size: 10px; margin-left: 4px; }
.rcms-a11y-tag-warning { background: #fff4cc; color: #5a4500; font-size: 10px; margin-left: 4px; }
.rcms-a11y-tag-info { background: var(--md-sys-color-surface-container); color: var(--md-sys-color-on-surface-variant); font-size: 10px; margin-left: 4px; }

/* #117 — InlinePanel: 1-N sub-row collections on the page editor. */
.rcms-inline-panel { margin-top: 16px; }
.rcms-inline-panel legend { display: flex; align-items: center; gap: 8px; }
.rcms-inline-panel-cap { font-size: 11px; color: var(--md-sys-color-on-surface-variant); margin-left: 4px; }
.rcms-inline-panel-help { margin: 0 0 8px; font-size: 12px; }
.rcms-inline-panel-rows { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.rcms-inline-panel-row { padding: 12px; background: var(--md-sys-color-surface-container-low); border-radius: var(--md-sys-radius-md); }
.rcms-inline-panel-row-header,
.rcms-inline-panel-list-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.rcms-inline-panel-row-header strong { font-size: 12px; color: var(--md-sys-color-on-surface-variant); }
.rcms-inline-panel-row-header .rcms-inline-panel-remove { margin-left: auto; }

/* Inline-panel list — all panels share one fieldset, each panel is a list item */
.rcms-inline-panel-card { margin-top: 16px; }
/* Shared vertical list-reset stack (also `.rcms-dashboard-list` and
   `.rcms-upload-queue` — their sections keep only their own gap). */
.rcms-inline-panel-list,
.rcms-dashboard-list,
.rcms-upload-queue { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.rcms-inline-panel-list { gap: 16px; }
.rcms-inline-panel-list-item { padding: 12px; background: var(--md-sys-color-surface-container-lowest); border: 1px solid var(--md-sys-color-outline-variant); border-radius: var(--md-sys-radius-md); }
.rcms-inline-panel-list-item + .rcms-inline-panel-list-item { margin-top: 0; }
/* `.rcms-inline-panel-list-head` layout is grouped with `.rcms-inline-panel-row-header`. */
.rcms-inline-panel-list-head strong { font-size: 14px; }

/* #121 — keyboard-shortcuts cheat-sheet modal. */
.rcms-kbd-modal { border: 0; border-radius: var(--md-sys-radius-lg); padding: 0; max-width: 480px; width: 90vw; background: var(--md-sys-color-surface-container-high); color: var(--md-sys-color-on-surface); box-shadow: var(--md-sys-elevation-3); }
.rcms-kbd-modal::backdrop { background: rgba(0, 0, 0, 0.4); }
.rcms-kbd-modal article { padding: 16px 20px; }
.rcms-kbd-modal header { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.rcms-kbd-modal header h2 { flex: 1; margin: 0; font-size: 16px; }
.rcms-kbd-modal h3 { font-size: 12px; color: var(--md-sys-color-on-surface-variant); text-transform: uppercase; letter-spacing: 0.05em; margin: 12px 0 6px; }
.rcms-kbd-modal dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; font-size: 13px; }
.rcms-kbd-modal dt { display: flex; align-items: center; gap: 4px; }
.rcms-kbd-modal kbd { display: inline-block; padding: 2px 6px; border: 1px solid var(--md-sys-color-outline-variant); border-radius: var(--md-sys-radius-sm); background: var(--md-sys-color-surface-container); font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 11px; }

/* #122 — revision storage report prune form. */
.rcms-revisions-prune-form { margin-bottom: 16px; padding: 16px; }
.rcms-revisions-prune-heading { margin: 0 0 12px; font-size: 14px; }

/* #123 — snippet history card. */
.rcms-snippet-history-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid var(--md-sys-color-outline-variant); }
.rcms-snippet-history-row:first-child { border-top: none; }
.rcms-snippet-history-row-text { flex: 1; font-size: 13px; }

/* #128 — plugin-contributed account settings panels. */
.rcms-account-plugin-panel { margin-top: 16px; padding: 16px; }
.rcms-account-plugin-panel-heading { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; font-size: 16px; }

/* #129 — styleguide / component gallery. */
.rcms-styleguide-section { margin: 24px 0 8px; font-size: 16px; }
.rcms-styleguide-card { padding: 16px; }
.rcms-styleguide-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.rcms-styleguide-row:last-child { margin-bottom: 0; }
.rcms-styleguide-tag-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }

/* #133 — per-user column picker. Tables opt in with
   `data-col-picker="<list-name>"`; JS appends a Columns popover
   that toggles `col-hidden` on the matching th + td cells. */
.rcms-col-hidden { display: none !important; }
.rcms-col-picker { display: inline-block; position: relative; margin: 0 0 8px; }
/* Summary reset comes from the shared <details> menu rule (kebab section). */
.rcms-col-picker-panel { display: none; position: absolute; right: 0; top: calc(100% + 4px); min-width: 220px; padding: 8px; background: var(--md-sys-color-surface-container-high); border: 1px solid var(--md-sys-color-outline-variant); border-radius: var(--md-sys-radius-md); box-shadow: var(--md-sys-elevation-2); z-index: 8; }
.rcms-col-picker[open] .rcms-col-picker-panel { display: flex; flex-direction: column; gap: 4px; }
.rcms-col-picker-row { display: flex; align-items: center; gap: 8px; padding: 4px 6px; font-size: 13px; cursor: pointer; border-radius: var(--md-sys-radius-sm); }
.rcms-col-picker-row:hover { background: var(--md-sys-color-surface-container); }
.rcms-col-picker-reset { margin-top: 4px; align-self: flex-start; }
/* The snippet listing is a bare `table.rcms-data` like every other admin
   list — its own outline + radius, no card shadow wrapped around it.
   The toolbar above it just parks the Columns picker on the right;
   it collapses when the picker script hasn't mounted anything. */
.rcms-library-list-toolbar { display: flex; justify-content: flex-end; margin-bottom: 8px; }
.rcms-library-list-toolbar:empty { display: none; }
.rcms-library-list-bulk-th { width: 32px; }

/* #147 — autosave chip. Floats bottom-right; mode-driven palette
   (saving / idle / warn). Polite-live for screen readers. */
.rcms-autosave-chip {
    position: fixed;
    right: 16px; bottom: 16px;
    padding: 6px 12px;
    background: var(--md-sys-color-surface-container-high);
    color: var(--md-sys-color-on-surface-variant);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-radius-full);
    box-shadow: var(--md-sys-elevation-1);
    font: var(--md-sys-typescale-ui-label);
    z-index: 5;
    opacity: 0;
    transition: opacity 0.18s;
    pointer-events: none;
}
.rcms-autosave-chip[data-mode="saving"],
.rcms-autosave-chip[data-mode="idle"],
.rcms-autosave-chip[data-mode="warn"] {
    opacity: 1;
}
/* Warn fill lives in the shared semantic fills (tag section). */

/* #144 — Dashboard home grid. Two-column on desktop, single-column
   below 760px. The .rcms-dashboard-span-2 modifier lets a card claim the
   full grid width (used for the Recent edits feed). */
.rcms-dashboard-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}
.rcms-dashboard-card { padding: 16px 20px; }
.rcms-dashboard-card h2 {
    display: flex; align-items: center; gap: 8px;
    margin: 0 0 12px;
    font-size: 14px;
}
.rcms-dashboard-card h2 .material-symbols-rounded { color: var(--md-sys-color-primary); }
.rcms-dashboard-span-2 { grid-column: 1 / -1; }
.rcms-dashboard-counts {
    list-style: none; padding: 0; margin: 0 0 12px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: 12px;
}
.rcms-dashboard-counts li {
    display: flex; flex-direction: column;
    padding: 12px;
    background: var(--md-sys-color-surface-container);
    border-radius: var(--md-sys-radius-md);
}
.rcms-dashboard-count { font-size: 22px; font-weight: 600; line-height: 1.1; }
.rcms-dashboard-count-label { font-size: 11px; color: var(--md-sys-color-on-surface-variant); text-transform: uppercase; letter-spacing: 0.04em; }
/* `.rcms-dashboard-list` base comes from the shared list-reset stack
   (inline-panel section). */
.rcms-dashboard-list li {
    display: flex; flex-direction: column;
    padding: 8px 0;
    border-top: 1px solid var(--md-sys-color-outline-variant);
}
.rcms-dashboard-list li:first-child { border-top: none; }
.rcms-dashboard-list a { color: var(--md-sys-color-on-surface); text-decoration: none; }
.rcms-dashboard-list a:hover { color: var(--md-sys-color-primary); }
.rcms-dashboard-list code.rcms-hint { font-size: 11px; margin-left: 8px; }
@media (max-width: 760px) {
    .rcms-dashboard-grid { grid-template-columns: 1fr; }
    .rcms-dashboard-span-2 { grid-column: 1; }
}

/* #324 — badge family note. The admin's small count/label indicators —
   `.rcms-tab-count` (inline count inside a tab), `.rcms-locale-badge`
   (breadcrumb locale pill),
   `.rcms-canonical-tag` (locale-menu marker pill), and `.a11y-tag-*` (a11y-panel
   severity tags) — are intentionally SEPARATE, single-use, context-scoped
   elements, NOT one component behind competing class APIs. Each already has
   exactly one canonical class; they were reviewed for the #324 "one API per
   component" pass and deliberately NOT unified under a single `.badge` base —
   doing so would couple unrelated UI (an absolute notification overlay vs an
   inline count vs uppercase label pills) for no real dedup. Add new context
   badges as their own scoped class rather than overloading these. */
.rcms-side-panel-flash { animation: side-panel-flash-keyframes 1.2s ease-out; }
@keyframes side-panel-flash-keyframes {
    0% { box-shadow: 0 0 0 0 var(--md-sys-color-primary); }
    50% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--md-sys-color-primary) 35%, transparent); }
    100% { box-shadow: 0 0 0 0 transparent; }
}
@media (max-width: 1100px) {
}

/* ------------------------------------------------------------
 * Shared active-tool fill (DRY): every "this tool/entry is the
 * active one" state uses the same primary-container pair. Placed
 * AFTER each member's own `:hover` rule (equal specificity) so an
 * active tool keeps its fill while hovered.
 * ------------------------------------------------------------ */
.rcms-richtext-tool.is-active {
    background: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
}

/* ============================================================
 * 13. Mobile drawer
 * ============================================================ */

@media (max-width: 768px) {
    body { flex-direction: column; }
    .rcms-sidebar {
        position: fixed;
        width: 240px;
        z-index: 10;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        box-shadow: var(--md-sys-elevation-3);
    }
    input#__nav_toggle:checked ~ .rcms-sidebar { transform: translateX(0); }
    .rcms-app-main { width: 100%; }
    .rcms-nav-toggle-label {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        border-radius: var(--md-sys-radius-md);
        cursor: pointer;
        color: var(--muted);
    }
    .rcms-nav-toggle-label:hover { background: var(--md-sys-color-surface-container); }
    .rcms-nav-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.4);
        z-index: 9;
    }
    input#__nav_toggle:checked ~ .rcms-nav-backdrop { display: block; }
}
@media (min-width: 769px) {
    .rcms-nav-toggle-label, .rcms-nav-backdrop, #__nav_toggle { display: none; }
}
#__nav_toggle { position: absolute; left: -9999px; }

/* ============================================================
 * #25 — Modal confirm + toast notifications.
 *
 * `<dialog class="rcms-confirm-dialog">` is the native HTML5
 * element promoted to modal via showModal(). Backdrop styling via
 * ::backdrop. Layout: title + message + actions row.
 *
 * `.rcms-toast-stack` sits fixed bottom-right. Each toast is a
 * card with a leading icon, body text, and a dismiss button.
 * In/out transitions via the `--in` / `--out` modifier classes
 * the JS adds. Per-level colors pull from the same MD3 surface
 * palette the rest of the chrome uses.
 * ============================================================ */

.rcms-confirm-dialog {
    border: none;
    border-radius: var(--md-sys-radius-xl);
    background: var(--md-sys-color-surface-container-lowest);
    color: var(--md-sys-color-on-surface);
    box-shadow: var(--md-sys-elevation-3);
    padding: 0;
    max-width: 460px;
    width: calc(100% - 32px);
}
.rcms-confirm-dialog::backdrop {
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
}
.rcms-confirm-form {
    padding: 24px;
}
.rcms-confirm-form h2 {
    margin: 0 0 12px;
    font: var(--md-sys-typescale-ui-header);
    color: var(--md-sys-color-on-surface);
}
.rcms-confirm-form p {
    margin: 0 0 20px;
    font: var(--md-sys-typescale-ui-body);
    color: var(--md-sys-color-on-surface-variant);
}
.rcms-confirm-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    align-items: center;
}

.rcms-toast-stack {
    position: fixed;
    right: 20px;
    bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 1000;
    max-width: min(420px, calc(100vw - 40px));
    pointer-events: none;
}
.rcms-toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    background: var(--md-sys-color-inverse-surface);
    color: var(--md-sys-color-inverse-on-surface);
    border-radius: var(--md-sys-radius-lg);
    box-shadow: var(--md-sys-elevation-3);
    font: var(--md-sys-typescale-ui-body);
    pointer-events: auto;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}
.rcms-toast--in { opacity: 1; transform: translateY(0); }
.rcms-toast--out { opacity: 0; transform: translateY(8px); }
.rcms-toast-icon { font-size: 20px; flex-shrink: 0; }
.rcms-toast-body { flex: 1; line-height: 1.4; }
.rcms-toast-close {
    background: transparent;
    border: 0;
    color: inherit;
    cursor: pointer;
    padding: 4px;
    border-radius: var(--md-sys-radius-sm);
    opacity: 0.7;
}
.rcms-toast-close:hover { opacity: 1; background: rgba(255, 255, 255, 0.08); }
/* #324 — per-level toasts on md-sys tokens (was hardcoded dark hex that
   ignored theming + dark mode — the #293 disconnect for the status surface
   users actually see, since flash messages hoist to toasts on load). Keeps
   the dark toast identity via the inverted container pair: `on-<level>-
   container` (dark) as the surface + `<level>-container` (light) as the
   text/icon — a designed contrast pair, now theme-aware. `--info` keeps the
   neutral inverse-surface base with a primary-tinted icon. */
.rcms-toast--success { background: var(--md-sys-color-on-success-container); color: var(--md-sys-color-success-container); }
.rcms-toast--warning { background: var(--md-sys-color-on-warning-container); color: var(--md-sys-color-warning-container); }
.rcms-toast--error { background: var(--md-sys-color-on-error-container); color: var(--md-sys-color-error-container); }
.rcms-toast--info .rcms-toast-icon { color: var(--md-sys-color-inverse-primary); }

/* ============================================================
 * #28 — MD3 input restyling for checkbox / radio / file / range
 * and the standalone date/time inputs that aren't inside `.rcms-field`.
 *
 * The `.rcms-field input[type=text|date|…]` rule above covers form-row
 * cases. Filter bars (media list, page list) use bare inputs
 * outside `.rcms-field`; this rule gives them the same MD3 chrome.
 *
 * `::-webkit-calendar-picker-indicator` paints the native browser
 * calendar/clock icon; we tint it to match the on-surface palette
 * so it doesn't look glued on.
 * ============================================================ */

/* #314 — scope the standalone bare form-control chrome (date/time/file/
   color/range inputs, the MD3 checkbox+radio, standalone <select>) to the
   admin shell, stopping at inline user-content wrappers, so a user's
   stored <input>/<select> in a rich-text / stream / block preview renders
   with native UA controls instead of admin chrome. Rules are kept at their
   original indentation to keep the diff to the @scope wrapper itself. */
@scope (.rcms-admin) to (.rcms-block-paragraph, .rcms-block-rich-text, .rcms-block-raw-html, .rcms-block-snippet-chooser, .rcms-block-picker-tile-preview, .rcms-stream-block, .rcms-display-chip-value) {
input[type="date"],
input[type="time"],
input[type="datetime-local"],
input[type="month"],
input[type="week"] {
    font: var(--md-sys-typescale-ui-body);
    color: var(--md-sys-color-on-surface);
    background: var(--md-sys-color-surface-container);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-radius-lg);
    padding: 0 12px;
    height: 40px;
    min-height: 40px;
    box-sizing: border-box;
    transition: border-color 0.12s, box-shadow 0.12s;
}
input[type="date"]:hover,
input[type="time"]:hover,
input[type="datetime-local"]:hover,
input[type="month"]:hover,
input[type="week"]:hover,
select:not(.rcms-field select):hover {
    border-color: var(--md-sys-color-outline);
}
input[type="date"]:focus,
input[type="time"]:focus,
input[type="datetime-local"]:focus,
input[type="month"]:focus,
input[type="week"]:focus,
select:not(.rcms-field select):focus {
    outline: none;
    border-color: var(--md-sys-color-primary);
    box-shadow: 0 0 0 1px var(--md-sys-color-primary);
}
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator,
input[type="datetime-local"]::-webkit-calendar-picker-indicator {
    opacity: 0.65;
    cursor: pointer;
    transition: opacity 0.12s;
}
input[type="date"]:hover::-webkit-calendar-picker-indicator,
input[type="time"]:hover::-webkit-calendar-picker-indicator,
input[type="datetime-local"]:hover::-webkit-calendar-picker-indicator {
    opacity: 1;
}

/* MD3 checkbox + radio. The native input is hidden via opacity:0
 * (kept clickable for keyboard a11y) and the ::before / ::after on
 * the parent label render the visible shape. We keep the bare
 * `input[type="checkbox"]` selector unscoped so legacy templates
 * pick up the styling without needing a wrapper class. */
input[type="checkbox"],
input[type="radio"] {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border: 1.5px solid var(--md-sys-color-outline);
    background: transparent;
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
    transition: border-color 0.12s, background-color 0.12s;
    vertical-align: middle;
}
input[type="checkbox"] {
    border-radius: 3px;
}
input[type="radio"] {
    border-radius: 50%;
}
input[type="checkbox"]:hover,
input[type="radio"]:hover {
    border-color: var(--md-sys-color-on-surface);
}
input[type="checkbox"]:focus-visible,
input[type="radio"]:focus-visible {
    outline: 2px solid var(--md-sys-color-primary);
    outline-offset: 2px;
}
input[type="checkbox"]:checked {
    background: var(--md-sys-color-primary);
    border-color: var(--md-sys-color-primary);
}
input[type="checkbox"]:checked::after {
    content: "";
    position: absolute;
    left: 4px;
    top: 0px;
    width: 6px;
    height: 11px;
    border: solid var(--md-sys-color-on-primary);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}
input[type="radio"]:checked {
    border-color: var(--md-sys-color-primary);
}
input[type="radio"]:checked::after {
    content: "";
    position: absolute;
    inset: 3px;
    border-radius: 50%;
    background: var(--md-sys-color-primary);
}
input[type="checkbox"]:disabled,
input[type="radio"]:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* File input. The native button is restyled; the file-name
 * indicator carries inherited text colour. */
input[type="file"] {
    font: var(--md-sys-typescale-ui-body);
    color: var(--md-sys-color-on-surface-variant);
    border: 1px dashed var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-radius-md);
    padding: 10px 12px;
    background: var(--md-sys-color-surface-container-low);
    cursor: pointer;
    max-width: 100%;
}
input[type="file"]:hover {
    border-color: var(--md-sys-color-primary);
}
input[type="file"]::file-selector-button {
    font: var(--md-sys-typescale-ui-button);
    color: var(--md-sys-color-on-primary);
    background: var(--md-sys-color-primary);
    border: none;
    border-radius: var(--md-sys-radius-lg);
    padding: 6px 14px;
    margin-right: 12px;
    cursor: pointer;
    transition: background-color 0.12s;
}
input[type="file"]::file-selector-button:hover {
    background: color-mix(in srgb, var(--md-sys-color-primary) 88%, black);
}

/* Color swatch. Native `input[type=color]` is a small button; we
 * shape it into a 32x32 rounded swatch. */
input[type="color"] {
    appearance: none;
    -webkit-appearance: none;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-radius-md);
    cursor: pointer;
    background: transparent;
}
input[type="color"]::-webkit-color-swatch-wrapper { padding: 2px; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 4px; }

/* Range slider — primary thumb on outline-variant track. */
input[type="range"] {
    appearance: none;
    -webkit-appearance: none;
    width: 100%;
    height: 4px;
    background: var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-radius-full);
    outline: none;
    cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--md-sys-color-primary);
    cursor: pointer;
    border: none;
}
input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--md-sys-color-primary);
    cursor: pointer;
    border: none;
}

/* Standalone <select> outside `.rcms-field` — restyle to match the
 * date-input chrome above so filter bars don't drop into native
 * OS chrome. Native chevron is hidden; we draw our own via a
 * background SVG masked by `--md-sys-color-on-surface-variant`. */
select:not(.rcms-field select) {
    font: var(--md-sys-typescale-ui-body);
    color: var(--md-sys-color-on-surface);
    background-color: var(--md-sys-color-surface-container);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-radius-md);
    padding: 8px 32px 8px 10px;
    min-height: 36px;
    box-sizing: border-box;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23757688'><path d='M7 10l5 5 5-5z'/></svg>");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 18px 18px;
    cursor: pointer;
}
/* Hover/focus rings are grouped with the date-input rules above. */
} /* end @scope .rcms-admin (#314 — standalone form controls) */

/* ============================================================
 * #28 — Media card uniform image presentation.
 *
 * Cards shipped with `background: surface-container` + a fixed
 * 140px height + `object-fit: cover` which forced upscale of
 * tiny images into a beige noise wash. New shape:
 *   - Aspect-ratio: 1 (square) so the grid stays uniform.
 *   - `object-fit: contain` so small images sit centered without
 *     blowing up. Cover only when the source is at least the
 *     thumb's natural size (handled via inline `data-fit`).
 *   - Subtle background checkerboard suggests transparency for
 *     PNG / SVG sources.
 *   - Hover lifts elevation a notch so the gallery reads as
 *     interactive.
 * Templates apply `.rcms-media-card-thumb` to the wrapper div + opt
 * in to `data-fit="cover"` when the source dims fill the thumb.
 * ============================================================ */

.rcms-media-card-thumb {
    aspect-ratio: 1 / 1;
    border-radius: var(--md-sys-radius-lg);
    background:
        linear-gradient(45deg, color-mix(in srgb, var(--md-sys-color-outline-variant) 18%, transparent) 25%, transparent 25%),
        linear-gradient(-45deg, color-mix(in srgb, var(--md-sys-color-outline-variant) 18%, transparent) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, color-mix(in srgb, var(--md-sys-color-outline-variant) 18%, transparent) 75%),
        linear-gradient(-45deg, transparent 75%, color-mix(in srgb, var(--md-sys-color-outline-variant) 18%, transparent) 75%),
        var(--md-sys-color-surface-container-low);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0;
    overflow: hidden;
    position: relative;
    box-shadow: var(--md-sys-elevation-1);
    transition: box-shadow 0.12s;
    margin-bottom: 8px;
}
.rcms-media-card-thumb:hover { box-shadow: var(--md-sys-elevation-2); }
/* Missing-file placeholder. The thumbnail 404s when the row still exists
   but the object is gone from storage; a centred icon says that plainly,
   where the browser's own broken-image glyph sits in the top-left corner
   and reads like a rendering fault. */
.rcms-media-card-missing {
    display: none;
    position: absolute;
    inset: 0;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    color: var(--muted-2);
}
.rcms-media-card-thumb.is-missing img { display: none; }
.rcms-media-card-thumb.is-missing .rcms-media-card-missing { display: flex; }
.rcms-media-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 12px;
    box-sizing: border-box;
    display: block;
}
.rcms-media-card-thumb[data-fit="cover"] img {
    object-fit: cover;
    padding: 0;
}

/* ============================================================
 * #44 — WP-style menu builder. Two-column layout: picker on the
 * left, draggable tree on the right.
 *
 * Tree depth is driven by `--menu-builder-depth` (set per-card by
 * the JS); the card's left padding scales with depth so the
 * indent reads visually without nesting in the DOM.
 * ============================================================ */

.rcms-menu-builder {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 16px;
    align-items: start;
}
@media (max-width: 900px) {
    .rcms-menu-builder { grid-template-columns: 1fr; }
}

.rcms-menu-builder-picker { padding: 16px; }
.rcms-menu-builder-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
}
.rcms-menu-builder-tab {
    background: transparent;
    border: 0;
    padding: 8px 12px;
    cursor: pointer;
    font: var(--md-sys-typescale-ui-button);
    color: var(--md-sys-color-on-surface-variant);
    border-bottom: 2px solid transparent;
}
.rcms-menu-builder-tab.active {
    color: var(--md-sys-color-primary);
    border-bottom-color: var(--md-sys-color-primary);
}
.rcms-menu-builder-page-search {
    width: 100%;
    margin-bottom: 8px;
    height: 40px;
    padding: 0 12px;
    font: inherit;
    color: var(--fg);
    background: var(--md-sys-color-surface-container-low);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-radius-md);
}
.rcms-menu-builder-page-search:focus {
    outline: 2px solid var(--md-sys-color-primary);
    outline-offset: -1px;
}
.rcms-menu-builder-page-list {
    max-height: 60vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.rcms-menu-builder-picker-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: var(--md-sys-color-surface-container-low);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-radius-md);
    cursor: grab;
    font: var(--md-sys-typescale-ui-body);
    color: var(--md-sys-color-on-surface);
    text-align: left;
    transition: background-color 0.12s, border-color 0.12s;
}
.rcms-menu-builder-picker-item:hover {
    background: var(--md-sys-color-surface-container);
    border-color: var(--md-sys-color-primary);
}
.rcms-menu-builder-picker-item:active { cursor: grabbing; }
.rcms-menu-builder-picker-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.rcms-menu-builder-picker-add {
    font-size: 18px;
    line-height: 1;
    color: var(--md-sys-color-primary);
    font-weight: 600;
    opacity: 0;
    transition: opacity 0.12s;
}
.rcms-menu-builder-picker-item:hover .rcms-menu-builder-picker-add { opacity: 1; }

.rcms-menu-builder-tree-wrap { padding: 16px; }
.rcms-menu-builder-tree-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}
.rcms-menu-builder-dirty {
    font-size: 12px;
    color: var(--md-sys-color-tertiary);
    background: var(--md-sys-color-tertiary-container);
    padding: 4px 8px;
    border-radius: var(--md-sys-radius-full);
}
.rcms-menu-builder-tree {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-height: 80px;
}
.rcms-menu-builder-card {
    --depth: var(--menu-builder-depth, 0);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    margin-left: calc(var(--depth) * 28px);
    background: var(--md-sys-color-surface-container-lowest);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-radius-md);
    box-shadow: var(--md-sys-elevation-1);
    transition: box-shadow 0.12s, opacity 0.12s, transform 0.12s;
}
.rcms-menu-builder-card:hover { box-shadow: var(--md-sys-elevation-2); }
.rcms-menu-builder-card--dragging { opacity: 0.4; }
.rcms-menu-builder-drop-target {
    border-color: var(--md-sys-color-primary);
    border-style: dashed;
}
.rcms-menu-builder-handle {
    color: var(--md-sys-color-outline);
    cursor: grab;
    font-size: 20px;
}
.rcms-menu-builder-card-body {
    flex: 1;
    min-width: 0;
}
.rcms-menu-builder-card-label {
    font: var(--md-sys-typescale-ui-button);
    color: var(--md-sys-color-on-surface);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
/* Shared truncated meta line (also `.rcms-upload-queue-meta` and
   `.rcms-picker-row__sub` — deltas live at their sites). */
.rcms-menu-builder-card-target,
.rcms-upload-queue-meta,
.rcms-picker-row__sub {
    font-size: 11px;
    color: var(--md-sys-color-on-surface-variant);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.rcms-menu-builder-card-target { margin-top: 2px; }
.rcms-menu-builder-card-target code {
    background: transparent;
    color: inherit;
    font-size: 11px;
}
.rcms-menu-builder-card-actions {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
}
.rcms-menu-builder-empty {
    border: 2px dashed var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-radius-md);
    padding: 32px;
    text-align: center;
    color: var(--md-sys-color-on-surface-variant);
}

/* #49 — menu-builder inline disclosure. Hidden by default; click
 * the card body to expand. The panel sits BELOW the card-actions
 * row (after the flex children) so the card stays as a tidy strip
 * until opened. */
.rcms-menu-builder-card { flex-wrap: wrap; }
.rcms-menu-builder-card .rcms-menu-builder-card-disclosure {
    flex-basis: 100%;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--md-sys-color-outline-variant);
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.rcms-menu-builder-card .rcms-menu-builder-card-disclosure .rcms-field {
    margin-bottom: 0;
}
.rcms-menu-builder-card .rcms-menu-builder-card-disclosure .rcms-checkbox-field {
    gap: 8px;
    font: var(--md-sys-typescale-ui-body);
    color: var(--md-sys-color-on-surface);
}
.rcms-menu-builder-card.expanded {
    box-shadow: var(--md-sys-elevation-2);
}
.rcms-menu-builder-card [data-toggle-disclosure] { cursor: pointer; }

/* #49b — drag-to-indent preview. While the editor drags a card
 * horizontally past the indent threshold the card slides to its
 * would-be depth via `--menu-builder-depth`. The preview class adds
 * a slight outline tint so the indent decision reads visually
 * before drop. */
.rcms-menu-builder-card--indent-preview {
    outline: 2px dashed var(--md-sys-color-primary);
    outline-offset: -2px;
    transition: margin-left 0.08s ease, outline-color 0.12s;
}

/* #49c — recent-tab picker items carry a relative-time `<time>`
 * chip after the label. Sits between the label and the `+` add
 * indicator, muted so the page title stays the primary text. */
.rcms-menu-builder-picker-meta {
    font-size: 10px;
    color: var(--md-sys-color-on-surface-variant);
    background: var(--md-sys-color-surface-container-high);
    padding: 2px 6px;
    border-radius: var(--md-sys-radius-full);
    margin-left: 4px;
}

/* ============================================================
 * #57 — Bulk media upload — drop zone + per-file queue.
 * The dropzone is a dashed-border drop area that wraps the file
 * input; the queue is a vertical stack of rows (thumb / inputs /
 * status / remove).
 * ============================================================ */

.rcms-upload-dropzone {
    position: relative;
    border: 2px dashed var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-radius-lg);
    background: var(--md-sys-color-surface-container-low);
    padding: 24px;
    text-align: center;
    transition: border-color 0.12s, background-color 0.12s;
}
.rcms-upload-dropzone:hover,
.rcms-upload-dropzone--active {
    border-color: var(--md-sys-color-primary);
    background: color-mix(in srgb, var(--md-sys-color-primary) 4%, var(--md-sys-color-surface-container-low));
}
/* The file input is a hidden, NON-interactive overlay: a bare `<input
   type=file>` only opens the picker when its native "browse" sub-button is
   clicked, so covering the dropzone with it leaves most of the area dead.
   Instead we make it pointer-events:none and let the dropzone's JS click
   handler call `fileInput.click()` — reliable from anywhere in the zone. */
.rcms-upload-dropzone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    pointer-events: none;
    width: 100%;
    height: 100%;
}
.rcms-upload-dropzone { cursor: pointer; }
.rcms-upload-dropzone-hint { pointer-events: none; }

/* `.rcms-upload-queue` base comes from the shared list-reset stack
   (inline-panel section). */
.rcms-upload-queue-row {
    display: grid;
    grid-template-columns: 60px 1fr auto auto;
    gap: 12px;
    align-items: center;
    padding: 10px 12px;
    background: var(--md-sys-color-surface-container-lowest);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-radius-md);
}
.rcms-upload-queue-thumb {
    width: 60px;
    height: 60px;
    border-radius: var(--md-sys-radius-sm);
    background: var(--md-sys-color-surface-container);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--md-sys-color-on-surface-variant);
}
.rcms-upload-queue-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.rcms-upload-queue-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}
.rcms-upload-queue-body input[type="text"] {
    width: 100%;
    padding: 6px 8px;
    font: var(--md-sys-typescale-ui-body);
    background: var(--md-sys-color-surface-container);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-radius-sm);
}
/* `.rcms-upload-queue-meta` comes from the shared truncated-meta rule
   (menu-builder section). */
.rcms-upload-queue-status {
    font-size: 12px;
    color: var(--md-sys-color-on-surface-variant);
    min-width: 80px;
    text-align: right;
}
.rcms-upload-queue-row[data-status="uploading"] .rcms-upload-queue-status {
    color: var(--md-sys-color-primary);
}
.rcms-upload-queue-row[data-status="done"] .rcms-upload-queue-status {
    color: #047857;
}
.rcms-upload-queue-row[data-status="failed"] .rcms-upload-queue-status {
    color: var(--md-sys-color-error);
}

/* ============================================================
 * #58 — Theme picker on /cms-admin/settings. Grid of swatch tiles
 * — one form per tile so the click submits a POST. The active tile
 * outlines in primary; the others outline in the default border.
 * ============================================================ */

.rcms-theme-picker {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}
.rcms-theme-picker-form { margin: 0; }
.rcms-theme-picker-tile {
    width: 100%;
    background: var(--md-sys-color-surface-container-lowest);
    border: 2px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-radius-lg);
    padding: 12px;
    cursor: pointer;
    text-align: left;
    transition: border-color 0.12s, transform 0.06s, box-shadow 0.12s;
}
.rcms-theme-picker-tile:hover {
    border-color: var(--md-sys-color-outline);
    box-shadow: var(--md-sys-elevation-1);
}
.rcms-theme-picker-tile:active { transform: scale(0.98); }
.rcms-theme-picker-tile--active {
    border-color: var(--md-sys-color-primary);
    box-shadow: 0 0 0 1px var(--md-sys-color-primary);
}
.rcms-theme-picker-swatch-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 2px;
    aspect-ratio: 2 / 1;
    border-radius: var(--md-sys-radius-md);
    overflow: hidden;
    margin-bottom: 8px;
    border: 1px solid var(--md-sys-color-outline-variant);
}
.rcms-theme-picker-swatch-grid span {
    display: block;
}
.rcms-theme-picker-name {
    font: var(--md-sys-typescale-ui-button);
    color: var(--md-sys-color-on-surface);
}
.rcms-theme-picker-badge {
    font-size: 11px;
    color: var(--md-sys-color-primary);
    font-weight: 600;
    margin-top: 2px;
}

/* ============================================================
 * #59 — Page editor utility classes. Extracts repeated inline
 * style="…" patterns from `page_form.html` so future theme
 * overrides cascade against named selectors instead of inline
 * (which beats every external rule).
 * ============================================================ */

/* Tertiary-tinted icon — used for translate / palette / locale
 * accents in the page editor's chrome. */
.rcms-icon-tertiary { color: var(--md-sys-color-tertiary); }
/* Primary-tinted icon — used for "history" / accent markers. */
.rcms-icon-primary { color: var(--md-sys-color-primary); }
/* Small material-symbols inline next to text — corrects the
 * baseline so icon + text read level. */
.rcms-icon-bullet { vertical-align: -4px; }
/* Muted meta cell in revision tables. Inherits the muted color
 * and a slightly smaller font-size. */
.rcms-cell-meta {
    color: var(--md-sys-color-on-surface-variant);
    font-size: 12px;
}
/* Smaller status tag used inside dense tables (revision list). */
.rcms-tag--small { font-size: 11px; }
/* Page-form translate card layout — keeps the translate / promote
 * form from stretching across very wide viewports. */
.rcms-page-form-translate { max-width: 920px; }
.rcms-text-muted-soft { color: var(--md-sys-color-outline); }

/* ============================================================
 * #325 / #314 — rcms- atomic utility layer.
 *
 * The admin templates carry ~545 inline `style="…"` declarations,
 * dominated by a small set of atomic patterns (type sizes, flex,
 * spacing, the muted colour). Inline styles beat every external
 * rule, so they silently defeat theming and host overrides.
 *
 * This layer names those patterns behind the single `rcms-` prefix
 * (#314) so the de-inline sweep (#325) has prefixed, collision-free
 * classes to sweep into. Atomic + composable: e.g. `margin:0 0 12px`
 * → `rcms-m-0 rcms-mb-3`. Spacing scale is the 4px base the inline
 * values already use (1=4 2=8 3=12 4=16px); the `margin:0` shorthand
 * is declared before the directional longhands so combining them
 * resolves correctly by source order.
 * ============================================================ */

/* Type scale (raw px, matching the values already inlined). */
.rcms-text-3xs  { font-size: 10px; }
.rcms-text-2xs  { font-size: 11px; }
.rcms-text-xs   { font-size: 12px; }
.rcms-text-sm   { font-size: 13px; }
.rcms-text-base { font-size: 14px; }
.rcms-text-lg   { font-size: 16px; }
.rcms-text-xl   { font-size: 18px; }
.rcms-text-2xl  { font-size: 32px; }
.rcms-fw-medium   { font-weight: 500; }
.rcms-fw-semibold { font-weight: 600; }
.rcms-italic         { font-style: italic; }
.rcms-leading-normal { line-height: 1.5; }
.rcms-font-mono      { font-family: ui-monospace, Menlo, monospace; }

/* Colour helpers (token-backed so theming still applies). `--muted` is
 * `--md-sys-color-on-surface-variant`; `--muted-2` is `--md-sys-color-outline`. */
.rcms-text-muted   { color: var(--md-sys-color-on-surface-variant); }
.rcms-text-muted-2 { color: var(--md-sys-color-outline); }
.rcms-text-primary { color: var(--md-sys-color-primary); }
.rcms-text-on-surface { color: var(--md-sys-color-on-surface); }
.rcms-text-error   { color: var(--md-sys-color-error); }
.rcms-text-tertiary { color: var(--md-sys-color-tertiary); }
.rcms-text-accent  { color: var(--accent); }
.rcms-text-inherit { color: inherit; }
.rcms-bg-surface-container { background: var(--md-sys-color-surface-container); }
.rcms-opacity-55 { opacity: 0.55; }
.rcms-opacity-60 { opacity: 0.6; }
.rcms-opacity-70 { opacity: 0.7; }

/* Display + flex/grid alignment helpers. */
.rcms-flex         { display: flex; }
.rcms-inline-flex  { display: inline-flex; }
.rcms-inline-block { display: inline-block; }
.rcms-inline       { display: inline; }
.rcms-block        { display: block; }
.rcms-grid         { display: grid; }
/* Auto-fill card grids (media / library / role pickers, #325). */
.rcms-autogrid-180 { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.rcms-autogrid-220 { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.rcms-autogrid-280 { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.rcms-items-center { align-items: center; }
.rcms-items-start  { align-items: flex-start; }
.rcms-justify-between { justify-content: space-between; }
.rcms-justify-center  { justify-content: center; }
.rcms-flex-wrap    { flex-wrap: wrap; }
.rcms-flex-1       { flex: 1; }
/* Redirect-list search form — grows but never collapses below a usable
 * width (was an inline style; redirect_list.html is locked style-free). */
.rcms-redirect-search-form { flex: 1 1 260px; }
.rcms-flex-2       { flex: 2; }
.rcms-flex-3       { flex: 3; }
.rcms-flex-none    { flex: none; }
.rcms-text-center  { text-align: center; }
.rcms-gap-1 { gap: 4px; }
.rcms-gap-2 { gap: 8px; }
.rcms-gap-3 { gap: 12px; }
.rcms-gap-4 { gap: 16px; }

/* Spacing scale (4px base: 1=4 2=8 3=12 4=16 6=24px). The `margin`/`padding`
 * shorthands are declared before the directional longhands so combining
 * them (e.g. `rcms-m-0 rcms-mb-3` for `margin:0 0 12px`) resolves by
 * source order. */
.rcms-m-0  { margin: 0; }
.rcms-mx-0 { margin-left: 0; margin-right: 0; }
.rcms-mt-0 { margin-top: 0; }
.rcms-mt-1 { margin-top: 4px; }
.rcms-mt-2 { margin-top: 8px; }
.rcms-mt-3 { margin-top: 12px; }
.rcms-mt-4 { margin-top: 16px; }
.rcms-mt-5 { margin-top: 20px; }
.rcms-mt-6 { margin-top: 24px; }
.rcms-mt-8 { margin-top: 32px; }
.rcms-mb-0 { margin-bottom: 0; }
.rcms-mb-1 { margin-bottom: 4px; }
.rcms-mb-2 { margin-bottom: 8px; }
.rcms-mb-3 { margin-bottom: 12px; }
.rcms-mb-4 { margin-bottom: 16px; }
.rcms-mb-6 { margin-bottom: 24px; }
.rcms-ml-1 { margin-left: 4px; }
.rcms-ml-2 { margin-left: 8px; }
.rcms-ml-3 { margin-left: 12px; }
.rcms-p-0  { padding: 0; }
.rcms-p-3  { padding: 12px; }
.rcms-p-bar { padding: 16px 20px; }
.rcms-px-0 { padding-left: 0; padding-right: 0; }
.rcms-px-4 { padding-left: 16px; padding-right: 16px; }
.rcms-pl-5 { padding-left: 20px; }
.rcms-pl-6 { padding-left: 24px; }
.rcms-py-2 { padding-top: 8px; padding-bottom: 8px; }
.rcms-py-3 { padding-top: 12px; padding-bottom: 12px; }
.rcms-pt-0 { padding-top: 0; }

/* Borders / radii (token-backed). */
/* Shorthands (border / border:0) BEFORE directional longhands so combining
 * them — e.g. `rcms-border-0 rcms-border-top` for `border:0; border-top:1px` —
 * resolves to the longhand by source order. */
.rcms-border        { border: 1px solid var(--md-sys-color-outline-variant); }
.rcms-border-0      { border: 0; }
.rcms-border-top    { border-top: 1px solid var(--md-sys-color-outline-variant); }
.rcms-border-bottom { border-bottom: 1px solid var(--md-sys-color-outline-variant); }
.rcms-rounded        { border-radius: var(--md-sys-radius-md); }
.rcms-rounded-circle { border-radius: 50%; }
.rcms-rounded-0      { border-radius: 0; }

/* Misc one-property helpers. */
.rcms-relative        { position: relative; }
.rcms-absolute        { position: absolute; }
.rcms-w-full          { width: 100%; }
/* Fixed column widths — table <th> sizing swept off inline styles (#325). */
.rcms-w-32            { width: 32px; }
.rcms-w-60            { width: 60px; }
.rcms-w-70            { width: 70px; }
.rcms-w-100           { width: 100px; }
.rcms-w-180           { width: 180px; }
.rcms-w-320           { width: 320px; }
.rcms-maxw-full       { max-width: 100%; }
.rcms-minw-0          { min-width: 0; }
.rcms-minw-160        { min-width: 160px; }
.rcms-minw-180        { min-width: 180px; }
.rcms-minw-200        { min-width: 200px; }
.rcms-minw-220        { min-width: 220px; }
.rcms-minw-280        { min-width: 280px; }
.rcms-maxw-120        { max-width: 120px; }
.rcms-maxw-240        { max-width: 240px; }
.rcms-maxw-600        { max-width: 600px; }
.rcms-maxw-640        { max-width: 640px; }
.rcms-maxw-720        { max-width: 720px; }
.rcms-maxw-760        { max-width: 760px; }
.rcms-maxw-900        { max-width: 900px; }
.rcms-overflow-hidden  { overflow: hidden; }
.rcms-overflow-visible { overflow: visible; }
.rcms-overflow-auto    { overflow: auto; }
.rcms-maxh-260         { max-height: 260px; }
.rcms-truncate        { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rcms-border-collapse { border-collapse: collapse; }
.rcms-pre-wrap        { white-space: pre-wrap; }
.rcms-cursor-pointer  { cursor: pointer; }
.rcms-select-none     { user-select: none; }
.rcms-list-none       { list-style: none; }
.rcms-no-underline    { text-decoration: none; }

/* #325 — avatar: circular user image with an initial/icon fallback.
 * `--sm` is the 28px sidebar size; the bare class is the 80px profile
 * size. `object-fit` only bites on the <img> variant; it's inert on
 * the fallback <div>/<span>. */
.rcms-avatar     { width: 80px; height: 80px; object-fit: cover; }
.rcms-avatar--sm { width: 28px; height: 28px; }
.rcms-avatar-fallback             { background: var(--md-sys-color-surface-container); }
.rcms-avatar--sm.rcms-avatar-fallback { background: var(--md-sys-color-surface-container-high); }

/* #205 — markdown toolbar. Sits directly above the textarea it
 * targets; revealed only after cms-ux.js attaches handlers
 * (defaults to `hidden` in the template). */
.rcms-md-toolbar {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    padding: 4px 6px;
    border: 1px solid var(--md-sys-color-outline-variant);
    border-bottom: none;
    border-top-left-radius: var(--md-sys-radius-md);
    border-top-right-radius: var(--md-sys-radius-md);
    background: var(--md-sys-color-surface-container-low);
}
.rcms-md-toolbar + textarea {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    margin-top: 0;
}
.rcms-md-btn {
    /* Metrics come from the shared editor-toolbar rule above; only the
       markdown toolbar's own border sits here. */
    border: 1px solid transparent;
    line-height: 1.4;
    cursor: pointer;
    font-family: inherit;
}
.rcms-md-btn:hover {
    background: var(--md-sys-color-surface-container-high);
    border-color: var(--md-sys-color-outline-variant);
}
.rcms-md-btn:active {
    background: var(--md-sys-color-secondary-container);
}
.rcms-md-sep {
    width: 1px;
    height: 16px;
    background: var(--md-sys-color-outline-variant);
    margin: 0 2px;
}

/* #205 Phase 2 — block picker tile description. The picker tile
 * now shows the block name + (optional) one-line description. */
.rcms-block-picker-tile-label {
    display: inline-flex;
    flex-direction: column;
    text-align: left;
    gap: 2px;
    order: 1; /* sit before the icon; icon has order:2 + margin-left:auto */
    flex: 1 1 auto;
    min-width: 0;
}
.rcms-block-picker-tile-name {
    font-weight: 500;
}
.rcms-block-picker-tile-desc {
    font-size: 11px;
    color: var(--md-sys-color-on-surface-variant);
}
/* Block preview value — inline mini-render of the
   block with a sample value so editors see "what does this look
   like" before inserting. Scoped down + opacity-muted so it
   doesn't distract from the tile's primary label. */
.rcms-block-picker-tile-preview {
    display: block;
    margin-top: 6px;
    padding: 6px 8px;
    border-radius: var(--md-sys-radius-sm);
    background: var(--md-sys-color-surface-container-low);
    color: var(--md-sys-color-on-surface-variant);
    font-size: 11px;
    line-height: 1.3;
    opacity: 0.85;
    pointer-events: none;
    overflow: hidden;
    max-height: 64px;
}
.rcms-block-picker-tile-preview * { font-size: inherit !important; margin: 0 !important; }
/* #205 Phase 2 — collapsed stream-block hides body, keeps header
 * visible so the editor can still drag / remove / expand. JS toggles
 * the `data-collapsed` attribute via the header click handler. */
.rcms-stream-block[data-collapsed] .rcms-stream-block-body {
    display: none;
}

/* Phases 4–5 — page / snippet / document chooser widgets share a
 * single dialog overlay (`rcms-chooser-dialog`) and the same inline
 * wrapper (`rcms-chooser`). The dialog mounts lazily under
 * document.body once an editor clicks Open. */
.rcms-chooser {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
/* Selected-image preview thumbnail for the media chooser. */
.rcms-media-preview {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--md-sys-color-outline-variant);
    background: var(--md-sys-color-surface-container-high);
    flex: none;
}
.rcms-chooser-dialog {
    border: none;
    padding: 0;
    border-radius: var(--md-sys-radius-lg);
    background: var(--md-sys-color-surface);
    color: var(--md-sys-color-on-surface);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
}
.rcms-chooser-dialog::backdrop {
    background: rgba(0, 0, 0, 0.4);
}
/* Media picker — the chooser dialog's full-experience mode for
 * kind="media": toolbar (search / collection / view toggle / upload),
 * thumbnail grid or list, a detail-preview pane, and drag-drop upload.
 * Non-media kinds share the same shell (header/toolbar/results/footer)
 * with the plain row list. Every displayed element gets a `[hidden]`
 * guard — an author `display` beats the UA `[hidden]` rule otherwise. */
.rcms-chooser-dialog { width: min(720px, 94vw); }
.rcms-chooser-dialog--media { width: min(960px, 94vw); height: min(640px, 84vh); }
.rcms-picker { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.rcms-picker__header {
    display: flex; align-items: center; gap: 8px; padding: 12px 16px;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
}
.rcms-picker__header strong { flex: 1; }
.rcms-picker__toolbar {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    padding: 10px 16px; border-bottom: 1px solid var(--md-sys-color-outline-variant);
}
.rcms-picker__search { flex: 1; min-width: 140px; padding: 6px 10px; }
.rcms-picker__media-tools,
.rcms-picker__multi { display: inline-flex; align-items: center; gap: 8px; }
.rcms-picker__media-tools[hidden] { display: none; }
.rcms-picker__collection { max-width: 220px; padding: 6px 8px; }
/* Segmented control — same pattern as the viewport switcher in the page
   editor: rounded outer shell, `overflow: hidden` so the children need
   no corner radii of their own, 1px dividers between them. */
.rcms-picker__viewtoggle { display: inline-flex; border: 1px solid var(--md-sys-color-outline-variant); border-radius: var(--md-sys-radius-md); overflow: hidden; }
.rcms-picker__viewtoggle button {
    /* 32px / 0 8px matches `.rcms-viewport-btn`, the other segmented
       control, so the two read as one component. That one is a
       `.rcms-btn` and inherits its centring; this is a bare <button>,
       and `display: inline-flex` alone leaves the icon at flex-start —
       so the glyph sat high and left in a 32px box instead of centred. */
    border: 0; background: transparent; height: 32px; padding: 0 8px; cursor: pointer;
    color: var(--md-sys-color-on-surface-variant);
    display: inline-flex; align-items: center; justify-content: center;
}
/* Pressed fill is grouped with the selected-row rule below. */
.rcms-picker__body { position: relative; display: flex; flex: 1; min-height: 0; }
.rcms-picker__results {
    list-style: none; padding: 4px 0; margin: 0; flex: 1;
    max-height: 60vh; overflow-y: auto;
}
.rcms-picker__results[hidden] { display: none; }
.rcms-picker-row {
    display: flex; align-items: center; gap: 12px; width: 100%;
    padding: 8px 16px; cursor: pointer; text-align: left;
    border: 0; border-top: 1px solid var(--md-sys-color-outline-variant);
    background: transparent; color: inherit; font: inherit;
}
.rcms-picker-row:hover { background: var(--md-sys-color-surface-container-high); }
.rcms-picker-row__thumb {
    width: 40px; height: 40px; object-fit: cover; border-radius: 4px; flex: none;
    background: var(--md-sys-color-surface-container-high);
}
.rcms-picker-row__thumb--icon {
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--md-sys-color-on-surface-variant);
}
/* Selected/pressed fill — the list-view selected row and the grid/list
   view toggle share the secondary-container pair. */
.rcms-picker-row--media.rcms-picker-card--selected,
.rcms-picker__viewtoggle button[aria-pressed="true"] {
    background: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
}
.rcms-picker-row__text { flex: 1; min-width: 0; display: block; }
.rcms-picker-row__title { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Base truncated-meta look shared with the menu builder / upload queue. */
.rcms-picker-row__sub { display: block; font-family: ui-monospace, monospace; }
.rcms-picker-row__meta { flex: none; font-size: 11px; color: var(--md-sys-color-on-surface-variant); }
.rcms-picker__empty { padding: 24px; text-align: center; color: var(--md-sys-color-on-surface-variant); font-size: 13px; }
.rcms-picker__error { padding: 16px; color: var(--md-sys-color-error); }
.rcms-picker__media { display: flex; flex: 1; min-height: 0; }
.rcms-picker__media[hidden] { display: none; }
.rcms-picker__grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 10px; align-content: start; padding: 12px 16px; flex: 1; overflow-y: auto;
}
.rcms-picker__list { display: flex; flex-direction: column; padding: 4px 0; flex: 1; overflow-y: auto; }
.rcms-picker-card {
    position: relative; display: flex; flex-direction: column; gap: 4px;
    border: 1px solid var(--md-sys-color-outline-variant); border-radius: 8px;
    padding: 4px; background: transparent; cursor: pointer; font: inherit;
    color: inherit; text-align: left; min-width: 0;
}
.rcms-picker-card:hover { border-color: var(--md-sys-color-primary); }
.rcms-picker-card--selected {
    outline: 2px solid var(--md-sys-color-primary);
    outline-offset: -1px; border-color: var(--md-sys-color-primary);
}
.rcms-picker-card__thumb {
    width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 5px;
    background: var(--md-sys-color-surface-container-high); display: block;
}
.rcms-picker-card__icon {
    width: 100%; aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
    font-size: 32px; color: var(--md-sys-color-on-surface-variant);
    background: var(--md-sys-color-surface-container-high); border-radius: 5px;
}
.rcms-picker-card__name {
    font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    color: var(--md-sys-color-on-surface); padding: 0 2px 2px;
}
.rcms-picker-card__check { position: absolute; top: 8px; left: 8px; z-index: 1; }
.rcms-picker__list .rcms-picker-card__check { position: static; }
.rcms-picker__detail {
    width: 240px; flex: none; border-left: 1px solid var(--md-sys-color-outline-variant);
    padding: 14px; overflow-y: auto;
}
.rcms-picker__detail-img {
    width: 100%; max-height: 180px; object-fit: contain; border-radius: 6px;
    background: var(--md-sys-color-surface-container-high); margin-bottom: 10px;
}
.rcms-picker__detail-name { font-weight: 600; font-size: 13px; margin-bottom: 8px; overflow-wrap: anywhere; }
.rcms-picker__detail-meta { margin: 0; font-size: 12px; }
.rcms-picker__detail-meta dt { color: var(--md-sys-color-on-surface-variant); font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em; margin-top: 8px; }
.rcms-picker__detail-meta dd { margin: 1px 0 0; overflow-wrap: anywhere; }
.rcms-picker__detail-empty {
    color: var(--md-sys-color-on-surface-variant); font-size: 12px;
    text-align: center; padding: 32px 8px;
}
.rcms-picker__dropzone {
    position: absolute; inset: 8px; z-index: 2;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
    border: 2px dashed var(--md-sys-color-primary); border-radius: 10px;
    background: color-mix(in srgb, var(--md-sys-color-surface) 88%, var(--md-sys-color-primary));
    color: var(--md-sys-color-primary); font-weight: 600; pointer-events: none;
}
.rcms-picker__dropzone[hidden] { display: none; }
.rcms-picker__footer {
    display: flex; align-items: center; gap: 8px; justify-content: flex-end;
    padding: 10px 16px; border-top: 1px solid var(--md-sys-color-outline-variant);
}
/* `.rcms-btn` carries its own display, which outranks the UA [hidden] rule —
 * guard every hideable picker control explicitly. */
.rcms-picker [hidden] { display: none !important; }
.rcms-picker__notice { flex: 1; font-size: 12px; color: var(--md-sys-color-on-surface-variant); overflow-wrap: anywhere; }
.rcms-picker__notice--error { color: var(--md-sys-color-error); }
/* Layout comes from the `.rcms-picker__media-tools` group above. */
.rcms-picker__multi [data-pc-multi-count] { font-size: 12px; color: var(--md-sys-color-on-surface-variant); }
@media (max-width: 719px) {
    .rcms-picker__detail { display: none; }
}
@media (max-width: 480px) {
    .rcms-chooser-dialog--media {
        width: 100vw; height: 100dvh; max-height: 100dvh;
        max-width: 100vw; border-radius: 0; margin: 0;
    }
    .rcms-picker__grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
}

/* Phase 6 — grouped-field / field-row /
 * help panels. TabBody::Group + TabBody::Help in the page editor's
 * custom tabs. */
.rcms-panel-group {
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-radius-md);
    padding: 12px 16px 16px;
    margin: 12px 0;
    background: var(--md-sys-color-surface);
}
.rcms-panel-group > legend {
    padding: 0 6px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--md-sys-color-on-surface-variant);
}
.rcms-panel-group-help {
    margin: 0 0 12px;
}
.rcms-panel-group-body {
    display: flex;
    gap: 12px;
}
.rcms-panel-group--column .rcms-panel-group-body {
    flex-direction: column;
}
.rcms-panel-group--row .rcms-panel-group-body {
    flex-direction: row;
    flex-wrap: wrap;
}
.rcms-panel-group--row .rcms-panel-group-body > .rcms-field {
    flex: 1 1 240px;
    min-width: 0;
}
@media (max-width: 640px) {
    .rcms-panel-group--row .rcms-panel-group-body {
        flex-direction: column;
    }
}
.rcms-panel-help {
    margin: 12px 0;
    padding: 12px 16px;
    border-left: 3px solid var(--md-sys-color-primary);
    background: var(--md-sys-color-surface-container-low);
    border-radius: 0 var(--md-sys-radius-md) var(--md-sys-radius-md) 0;
}
.rcms-panel-help :first-child {
    margin-top: 0;
}
.rcms-panel-help :last-child {
    margin-bottom: 0;
}

/* Phase 7 — SwitchInput. iOS-style toggle on
 * `WidgetKind::Boolean` when `variant = "switch"`. The native
 * checkbox stays in the DOM (hidden but accessible to AT) so the
 * form submission shape is identical to the default checkbox. */
.rcms-checkbox-field--switch {
    align-items: center;
    gap: 8px;
}
.rcms-checkbox-field--switch > input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 0;
    height: 0;
}
.rcms-switch-track {
    display: inline-block;
    position: relative;
    width: 36px;
    height: 20px;
    border-radius: 999px;
    background: var(--md-sys-color-surface-container-high);
    border: 1px solid var(--md-sys-color-outline-variant);
    cursor: pointer;
    transition: background 0.18s;
    flex: 0 0 auto;
}
.rcms-switch-knob {
    position: absolute;
    top: 1px;
    left: 1px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--md-sys-color-on-surface-variant);
    transition: transform 0.18s, background 0.18s;
}
.rcms-checkbox-field--switch > input:checked + .rcms-switch-track {
    background: var(--md-sys-color-primary);
    border-color: var(--md-sys-color-primary);
}
.rcms-checkbox-field--switch > input:checked + .rcms-switch-track .rcms-switch-knob {
    transform: translateX(16px);
    background: var(--md-sys-color-on-primary);
}
.rcms-checkbox-field--switch > input:focus-visible + .rcms-switch-track {
    outline: 2px solid var(--md-sys-color-primary);
    outline-offset: 2px;
}
.rcms-checkbox-field--switch > input:disabled + .rcms-switch-track {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ===================================================================
   Visual Form Builder (#533, FB-04..FB-08)
   =================================================================== */
.rcms-form-builder { --fb-border: var(--md-sys-color-outline-variant, #cdcdd5); }
.rcms-fb-topbar {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; flex-wrap: wrap; margin-bottom: 12px;
}
.rcms-fb-topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.rcms-fb-form-title { font-size: 1.2rem; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rcms-fb-topbar-right,
.rcms-fb-page-head { display: flex; align-items: center; gap: 8px; }
.rcms-fb-badge { font-size: 0.72rem; font-weight: 600; padding: 3px 8px; border-radius: 999px; background: var(--md-sys-color-tertiary-container, #ffe08a); color: var(--md-sys-color-on-tertiary-container, #5b4300); }

.rcms-fb-pagetabs { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--fb-border); margin-bottom: 14px; }
.rcms-fb-tab {
    border: 1px solid transparent; border-bottom: none; background: transparent;
    padding: 8px 14px; border-radius: 8px 8px 0 0; cursor: pointer; font: inherit;
    color: var(--md-sys-color-on-surface-variant, #444); margin-bottom: -1px;
}
.rcms-fb-tab.active {
    background: var(--md-sys-color-surface, #fff);
    border-color: var(--fb-border); border-bottom-color: var(--md-sys-color-surface, #fff);
    color: var(--md-sys-color-on-surface, #111); font-weight: 600;
}
.rcms-fb-tab-add { margin-left: 4px; }

.rcms-fb-workspace { display: grid; grid-template-columns: 1fr 320px; gap: 16px; align-items: start; }
/* The Settings/Preview toggles hide the workspace via the `hidden` attribute,
 * but an author `display: grid` overrides the UA `[hidden]{display:none}` —
 * so without this the workspace stayed visible and the settings/preview
 * panels rendered BELOW the canvas instead of replacing it. */
.rcms-fb-workspace[hidden] { display: none; }
@media (max-width: 900px) { .rcms-fb-workspace { grid-template-columns: 1fr; } }

.rcms-fb-canvas { min-width: 0; display: flex; flex-direction: column; gap: 14px; }
/* `.rcms-fb-page-head` layout is grouped with `.rcms-fb-topbar-right` above. */
.rcms-fb-page-name { flex: 1; font-size: 1.05rem; font-weight: 600; padding: 6px 8px; border: 1px solid transparent; border-radius: 6px; background: transparent; }
.rcms-fb-page-name:hover, .rcms-fb-page-name:focus { border-color: var(--fb-border); background: var(--md-sys-color-surface, #fff); }
.rcms-fb-page-tools, .rcms-fb-section-tools, .rcms-fb-row-tools, .rcms-fb-col-tools, .rcms-fb-field-tools { display: flex; gap: 2px; }

.rcms-fb-section { border: 1px solid var(--fb-border); border-radius: 10px; padding: 12px; background: var(--md-sys-color-surface-container-low, #fafafa); }
.rcms-fb-section-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.rcms-fb-section-title { flex: 1; padding: 5px 8px; border: 1px dashed var(--fb-border); border-radius: 6px; background: transparent; font-weight: 600; }

.rcms-fb-row { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 8px; }
.rcms-fb-row-grid { display: flex; gap: 8px; flex: 1; flex-wrap: wrap; }
.rcms-fb-col { min-width: 120px; border: 1px dashed var(--fb-border); border-radius: 8px; padding: 8px; background: var(--md-sys-color-surface, #fff); display: flex; flex-direction: column; gap: 6px; }
.rcms-fb-col-head { display: flex; align-items: center; justify-content: space-between; }
.rcms-fb-width { font-size: 0.75rem; padding: 2px 4px; border: 1px solid var(--fb-border); border-radius: 4px; }

.rcms-fb-field { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; border: 1px solid var(--fb-border); border-radius: 8px; background: var(--md-sys-color-surface-container, #f3f3f7); cursor: pointer; }
.rcms-fb-field.selected { border-color: var(--md-sys-color-primary, #4f46e5); box-shadow: 0 0 0 2px var(--md-sys-color-primary, #4f46e5) inset; }
.rcms-fb-field-main { display: flex; align-items: center; gap: 8px; min-width: 0; }
.rcms-fb-field-label { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rcms-fb-field-meta { font-size: 0.72rem; color: var(--md-sys-color-on-surface-variant, #666); }

.rcms-fb-add-field-wrap { position: relative; }
.rcms-fb-add-field, .rcms-fb-add-row, .rcms-fb-add-section { display: inline-flex; align-items: center; gap: 4px; padding: 6px 10px; border: 1px dashed var(--fb-border); border-radius: 8px; background: transparent; cursor: pointer; font: inherit; color: var(--md-sys-color-primary, #4f46e5); }
.rcms-fb-add-section { align-self: flex-start; }
.rcms-fb-palette { position: absolute; z-index: 30; top: 100%; left: 0; margin-top: 4px; width: 220px; max-height: 320px; overflow: auto; background: var(--md-sys-color-surface-container-lowest); border: 1px solid var(--fb-border); border-radius: 10px; box-shadow: 0 6px 24px rgba(0,0,0,0.16); padding: 6px; }
.rcms-fb-palette-group { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--md-sys-color-on-surface-variant, #888); padding: 6px 8px 2px; }
.rcms-fb-palette-item { display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 8px; border: none; background: transparent; border-radius: var(--md-sys-radius-lg); cursor: pointer; font: inherit; text-align: left; }
.rcms-fb-palette-item:hover { background: var(--md-sys-color-surface-container-high, #ececf2); }

.rcms-fb-icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border: none; background: transparent; border-radius: var(--md-sys-radius-lg); cursor: pointer; color: var(--md-sys-color-on-surface-variant); }
.rcms-fb-icon-btn:hover { background: var(--md-sys-color-surface-container-high, #ececf2); }
.rcms-fb-icon-btn.rcms-fb-danger:hover { background: var(--md-sys-color-error-container, #fcd8d8); color: var(--md-sys-color-error, #b3261e); }

/* Panels take the same tier real cards do. Painting them with
   `--md-sys-color-surface` made them the page ground itself, so in dark
   the panel had no edge and read as empty space with text floating in
   it. */
.rcms-fb-inspector { border: 1px solid var(--fb-border); border-radius: 10px; padding: 14px; background: var(--md-sys-color-surface-container-lowest); position: sticky; top: 12px; }
.rcms-fb-inspector-empty { text-align: center; color: var(--md-sys-color-on-surface-variant); padding: 24px 8px; }
/* Nothing selected → the inspector has nothing to say, so it should not
   hold a third of the editor open for a sentence. The rigid `1fr 320px`
   was fine when the builder had the whole page; beside the preview pane it
   left a tall empty card squeezing the canvas.
   Collapse to a single column and let the hint sit quietly under the
   canvas until a field is actually selected. */
.rcms-fb-workspace:has(.rcms-fb-inspector-empty) { grid-template-columns: 1fr; }
.rcms-fb-workspace:has(.rcms-fb-inspector-empty) .rcms-fb-inspector {
    border: 0;
    background: transparent;
    padding: 0;
    position: static;
}
.rcms-fb-workspace:has(.rcms-fb-inspector-empty) .rcms-fb-inspector-empty {
    padding: 10px 8px;
    font-size: 0.85rem;
}
/* The pointer glyph is decorative; at hint size it is just noise. */
.rcms-fb-workspace:has(.rcms-fb-inspector-empty) .rcms-fb-inspector-empty .material-symbols-rounded {
    display: none;
}
.rcms-fb-inspector-head { display: flex; align-items: center; gap: 8px; font-weight: 700; margin-bottom: 12px; }
.rcms-fb-prop { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.rcms-fb-prop-label { font-size: 0.78rem; font-weight: 600; color: var(--md-sys-color-on-surface-variant, #555); }
.rcms-fb-prop input[type="text"], .rcms-fb-prop input[type="number"], .rcms-fb-prop textarea { width: 100%; padding: 7px 8px; border: 1px solid var(--fb-border); border-radius: 6px; font: inherit; }
.rcms-fb-prop-check { flex-direction: row; align-items: center; gap: 8px; }
.rcms-fb-options { margin-top: 6px; }
.rcms-fb-option { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.rcms-fb-option input { flex: 1; padding: 6px; border: 1px solid var(--fb-border); border-radius: 6px; }
.rcms-fb-option-value { max-width: 90px; }
.rcms-fb-add-option { display: inline-flex; align-items: center; gap: 4px; border: none; background: transparent; color: var(--md-sys-color-primary, #4f46e5); cursor: pointer; padding: 4px; font: inherit; }
.rcms-fb-rules { margin-top: 10px; border-top: 1px solid var(--fb-border); padding-top: 10px; }
.rcms-fb-rule { border: 1px solid var(--fb-border); border-radius: 8px; padding: 8px; margin-bottom: 8px; }
.rcms-fb-rule-head { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; font-size: 0.82rem; }
/* A condition wraps inside the narrow inspector: the field, then the
 * operator with the remove button, then the value — each readable in full. */
.rcms-fb-cond { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-bottom: 8px; }
.rcms-fb-cond select, .rcms-fb-cond input, .rcms-fb-rule-head select { padding: 4px; border: 1px solid var(--fb-border); border-radius: 4px; font-size: 0.82rem; max-width: 100%; }
.rcms-fb-cond > select:first-child { flex: 1 1 100%; }
.rcms-fb-cond > select:nth-child(2) { flex: 1; }
.rcms-fb-cond > :nth-child(3) { flex: 1 1 100%; order: 3; min-width: 60px; }
.rcms-fb-cond > :nth-child(4) { order: 2; }

/* Settings replaces the workspace when toggled — centred so it reads as
 * the page's main panel, not a stray block hugging the left. (Preview is
 * no longer a panel here: it is the shared sidebar pane.) */
.rcms-fb-settings { border: 1px solid var(--fb-border); border-radius: 10px; padding: 24px 28px; background: var(--md-sys-color-surface-container-lowest); margin: 0 auto; }
.rcms-fb-translate-menu { position: relative; display: inline-block; }
/* Summary reset comes from the shared <details> menu rule (kebab section). */
.rcms-fb-translate-list { position: absolute; right: 0; top: 100%; margin-top: 4px; z-index: 30; background: var(--md-sys-color-surface-container-lowest); border: 1px solid var(--fb-border, var(--md-sys-color-outline-variant)); border-radius: 8px; box-shadow: 0 6px 24px rgba(0,0,0,0.16); min-width: 160px; padding: 4px; }
.rcms-fb-translate-list a { display: block; padding: 7px 10px; border-radius: 6px; text-decoration: none; color: inherit; }
.rcms-fb-translate-list a:hover { background: var(--md-sys-color-surface-container-high, #ececf2); }
.rcms-fb-settings { max-width: 560px; }
.rcms-fb-settings h3 { margin-top: 0; margin-bottom: 14px; font-size: 1.05rem; }
.rcms-fb-settings .rcms-fb-prop { margin-bottom: 14px; }
.rcms-fb-settings textarea, .rcms-fb-settings input[type="text"] { width: 100%; padding: 8px; border: 1px solid var(--fb-border); border-radius: 6px; font: inherit; }

/* Submissions table (FB-12) */

/* ---- Block tree (block_tree.js) — sidebar outline of stream blocks ----
 * Activating swaps the main sidebar's nav for a live tree of the page's
 * blocks (incl. nested Stream/Repeat children). Every hideable element is
 * `[hidden]`-guarded: author display rules outrank the UA [hidden] rule. */
.rcms-sidebar--blocktree .rcms-sidebar-nav,
.rcms-sidebar--blocktree .rcms-sidebar-footer { display: none; }
.rcms-sidebar-blocktree {
    display: flex; flex-direction: column; flex: 1; min-height: 0;
    padding: 8px 10px;
}
.rcms-sidebar-blocktree[hidden] { display: none !important; }
.rcms-blocktree-back {
    display: flex; align-items: center; gap: 6px;
    border: 0; background: transparent; cursor: pointer; font: inherit;
    color: var(--md-sys-color-on-surface-variant);
    padding: 6px 8px; border-radius: 8px; text-align: left;
}
.rcms-blocktree-back:hover { background: var(--md-sys-color-surface-container-high); }
.rcms-blocktree-toolbar {
    display: flex; align-items: center; gap: 2px;
    padding: 6px 8px 8px; border-bottom: 1px solid var(--md-sys-color-outline-variant);
    margin-bottom: 6px;
}
.rcms-blocktree-title {
    flex: 1; font-size: 11px; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.05em; color: var(--md-sys-color-on-surface-variant);
}
.rcms-blocktree-body { flex: 1; overflow-y: auto; min-height: 0; }
.rcms-blocktree-node {
    display: flex; align-items: center; gap: 2px;
    padding-left: calc(var(--bt-depth, 0) * 14px);
    border-radius: 8px;
}
.rcms-blocktree-node:hover { background: var(--md-sys-color-surface-container-high); }
.rcms-blocktree-jump {
    flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px;
    border: 0; background: transparent; cursor: pointer; font: inherit;
    font-size: 13px; color: var(--md-sys-color-on-surface);
    padding: 6px 4px 6px 8px; text-align: left; border-radius: 8px;
}
.rcms-blocktree-label {
    flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rcms-blocktree-node.is-collapsed .rcms-blocktree-label { color: var(--md-sys-color-on-surface-variant); }
.rcms-blocktree-fold {
    flex: none; border: 0; background: transparent; cursor: pointer;
    color: var(--md-sys-color-on-surface-variant);
    padding: 4px; border-radius: 6px; display: inline-flex;
}
.rcms-blocktree-fold:hover { background: var(--md-sys-color-surface-container-highest); }
.rcms-blocktree-group {
    padding: 6px 8px 2px calc(var(--bt-depth, 0) * 14px + 8px);
    font-size: 10px; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.06em; color: var(--md-sys-color-on-surface-variant);
}
.rcms-blocktree-empty {
    padding: 18px 8px; font-size: 12px; text-align: center;
    color: var(--md-sys-color-on-surface-variant);
}
/* Validation state — red label + error-count badge. */
.rcms-blocktree-node.is-invalid .rcms-blocktree-jump,
.rcms-blocktree-node.is-invalid .rcms-blocktree-label { color: var(--md-sys-color-error); }
.rcms-blocktree-errors {
    flex: none; min-width: 16px; height: 16px; border-radius: 999px;
    background: var(--md-sys-color-error); color: var(--md-sys-color-on-error);
    font-size: 10px; font-weight: 700; line-height: 16px; text-align: center;
    padding: 0 4px;
}
/* Canvas mirror: a block with invalid fields gets a red dot in its header. */
.rcms-stream-block--invalid > .rcms-stream-block-header .rcms-stream-block-title::after {
    content: ""; display: inline-block; width: 7px; height: 7px;
    border-radius: 999px; background: var(--md-sys-color-error);
    margin-left: 6px; vertical-align: 1px;
}
/* Per-stream-root section header in the block tree (multi-root pages:
 * page-builder zones + repeaters). */
.rcms-blocktree-root {
    padding: 10px 8px 3px;
    font-size: 10px; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.07em; color: var(--md-sys-color-primary);
    border-top: 1px solid var(--md-sys-color-outline-variant);
    margin-top: 6px;
}
.rcms-blocktree-root:first-child { border-top: 0; margin-top: 0; }

/* ---- Template editor (per-tenant template overrides) ---------------- */
/* The textarea before CodeMirror takes over — and the permanent state
   when the vendored bundle is absent. Sized so the fallback is a usable
   editor in its own right, not a cramped comment box. */
.rcms-code-plain,
textarea[data-template-editor] {
    width: 100%;
    min-height: 60vh;
    font: 13px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    tab-size: 2;
    padding: 12px 14px;
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-radius-md);
    background: var(--md-sys-color-surface-container-lowest);
    color: var(--md-sys-color-on-surface);
    resize: vertical;
}
.CodeMirror {
    height: auto;
    min-height: 60vh;
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-radius-md);
    font: 13px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
/* Dark mode: CodeMirror 5 ships only a light default, and pulling a
   theme file in would double the CSS for one palette. These few
   overrides bind it to the admin's own tokens instead. */
.CodeMirror.rcms-cm-dark,
.CodeMirror.rcms-cm-dark .CodeMirror-gutters {
    background: var(--md-sys-color-surface-container-lowest);
    color: var(--md-sys-color-on-surface);
    border-color: var(--md-sys-color-outline-variant);
}
.CodeMirror.rcms-cm-dark .CodeMirror-linenumber { color: var(--md-sys-color-on-surface-variant); }
.CodeMirror.rcms-cm-dark .CodeMirror-cursor { border-left-color: var(--md-sys-color-on-surface); }
.CodeMirror.rcms-cm-dark .CodeMirror-activeline-background { background: rgba(255, 255, 255, .04); }
.CodeMirror.rcms-cm-dark .CodeMirror-selected { background: rgba(255, 255, 255, .13); }
/* Breathing room under the editor surface.
   `.rcms-form-actions` already carries `margin-top: 24px`, and adjacent
   siblings collapse to the larger of the two — so anything at or below
   24px here is silently a no-op. 36px is a real increase; the buttons
   then sit 36px + their own 18px padding clear of the editor's border,
   which a big bordered box needs and a plain field does not. */
.CodeMirror,
textarea[data-template-editor] {
    margin-bottom: 36px;
}
.rcms-validate-result {
    margin: 0 0 4px;
    padding: 10px 12px;
    border-radius: var(--md-sys-radius-md);
    font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    white-space: pre-wrap;
    border: 1px solid var(--md-sys-color-outline-variant);
}
.rcms-validate-result.is-ok {
    border-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-primary);
}
.rcms-validate-result.is-bad {
    border-color: var(--md-sys-color-error);
    color: var(--md-sys-color-error);
}
.rcms-inline-form { display: flex; gap: 8px; align-items: center; margin: 12px 0 18px; }
.rcms-inline-form input { flex: 0 1 320px; }
.rcms-row-actions { display: flex; gap: 8px; align-items: center; justify-content: flex-end; }
.rcms-row-actions form { margin: 0; }