File size: 75,264 Bytes
e839280
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80f3341
e839280
80f3341
 
 
 
 
 
e839280
80f3341
 
 
 
 
 
 
e839280
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5557c4a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e839280
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5557c4a
 
 
e839280
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5557c4a
 
 
e839280
 
 
5557c4a
 
 
e839280
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3a3d875
e839280
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5557c4a
3a3d875
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e839280
 
5557c4a
 
 
e839280
 
 
 
 
 
3a3d875
e839280
 
 
 
 
 
 
3a3d875
e839280
3a3d875
 
 
 
 
 
 
 
 
 
e839280
 
 
 
 
 
 
 
 
 
 
 
3a3d875
 
 
 
 
 
 
 
 
 
 
 
 
 
e839280
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3a3d875
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e839280
 
 
 
 
 
 
 
 
 
5557c4a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e839280
 
 
 
 
5557c4a
 
 
 
 
 
e839280
 
 
 
 
 
 
 
 
3a3d875
e839280
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5557c4a
 
e839280
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5557c4a
 
 
e839280
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3a3d875
 
 
 
 
 
 
 
e839280
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3a3d875
 
 
 
 
 
 
 
 
 
 
 
 
e839280
 
 
 
5557c4a
 
 
 
 
 
 
 
e839280
 
 
5557c4a
 
 
 
e839280
 
5557c4a
e839280
 
5557c4a
e839280
 
 
5557c4a
e839280
 
 
 
3a3d875
e839280
3a3d875
5557c4a
 
 
 
e839280
 
5557c4a
 
e839280
5557c4a
 
e839280
5557c4a
 
 
e839280
 
5557c4a
 
 
 
 
 
 
 
e839280
 
5557c4a
 
 
 
 
 
 
e839280
 
 
 
 
 
 
 
 
 
 
 
5557c4a
 
 
 
 
 
 
 
e839280
5557c4a
 
 
3a3d875
5557c4a
 
 
e839280
 
 
 
 
5557c4a
e839280
 
 
5557c4a
e839280
5557c4a
3a3d875
5557c4a
 
e839280
 
 
 
 
 
 
5557c4a
e839280
5557c4a
 
 
e839280
5557c4a
e839280
5557c4a
e839280
 
 
 
 
 
 
 
3a3d875
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e839280
 
 
 
 
 
 
 
 
 
 
 
 
3a3d875
e839280
 
 
 
3a3d875
e839280
 
 
 
 
3a3d875
e839280
 
3a3d875
e839280
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5557c4a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e839280
5557c4a
 
 
 
 
e839280
 
 
5557c4a
e839280
5557c4a
e839280
 
5557c4a
e839280
 
 
5557c4a
e839280
 
 
 
 
 
 
 
 
 
 
 
5557c4a
e839280
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3a3d875
e839280
3a3d875
e839280
 
3a3d875
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e839280
 
 
 
 
 
 
 
3a3d875
e839280
 
 
 
 
 
 
 
 
3a3d875
e839280
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3a3d875
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e839280
3a3d875
e839280
 
 
 
 
 
 
 
 
 
 
 
3a3d875
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e839280
 
 
 
 
 
 
 
 
 
 
3a3d875
 
 
 
 
 
e839280
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3a3d875
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e839280
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3a3d875
 
 
 
 
 
 
 
 
e839280
 
 
 
 
3a3d875
e839280
 
 
 
3a3d875
e839280
 
 
 
 
 
3a3d875
e839280
 
 
 
3a3d875
 
 
 
 
e839280
 
 
 
 
 
 
 
 
 
 
 
3a3d875
 
 
e839280
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5557c4a
e839280
 
 
 
 
 
 
bde154c
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
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>TamilReal • Portrait Prompt Studio</title>
  <script src="https://cdn.tailwindcss.com"></script>
  <!-- Font: Inter for body text -->
  <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap" rel="stylesheet">
  <link href="https://fonts.googleapis.com/css2?family=Playfair+Display:wght@700&family=Poppins:wght@400;500;600&display=swap" rel="stylesheet">
   <style>
     /* Accessibility: focus styles for keyboard navigation */
     :focus-visible {
       outline: none;
       box-shadow: 0 0 0 3px var(--terracotta);
       border-radius: 4px;
     }
     /* General interactive element focus support */
     button.clay-btn:focus, button.clay-btn:focus-visible,
     .clay-tab:focus, .clay-tab:focus-visible,
     .clay-input:focus, .clay-input:focus-visible,
     .clay-select:focus, .clay-select:focus-visible {
       outline: none;
       box-shadow: 0 0 0 3px var(--terracotta);
     }

      /* Task 1: Fluid full-bleed container */
      .main-container {
        width: 100vw;
        margin-left: calc(-50vw + 50%);
        padding-left: 2rem; /* Increased padding */
        padding-right: 2rem;
        box-sizing: border-box;
      }
      /* Content inner width control */
      .content-inner {
        max-width: 1200px;
        margin: 0 auto;
      }
      
      /* Content0 full width styling - no borders */
      #content0 {
        width: 100%;
        padding-left: 2rem;
        padding-right: 2rem;
        padding-top: 1.5rem;
        padding-bottom: 1.5rem;
        box-sizing: border-box;
        border: none;
        border-radius: 10px;
      }
      @media (max-width: 768px) {
        #content0 {
          padding-left: 1rem;
          padding-right: 1rem;
        }
      }
      
      /* Content1 and Content2 - same styling as content0 */
      #content1, #content2 {
        width: 100%;
        padding-left: 2rem;
        padding-right: 2rem;
        padding-top: 1.5rem;
        padding-bottom: 1.5rem;
        box-sizing: border-box;
        border: none;
        border-radius: 10px;
      }
      @media (max-width: 768px) {
        #content1, #content2 {
          padding-left: 1rem;
          padding-right: 1rem;
        }
      }
      
      /* Identity Anchor full width */
      .identity-anchor {
        width: 100%;
        box-sizing: border-box;
      }

     /* Claymorphism Theme (Default) */
     :root, [data-theme="clay"] {
       --bg: #2c221b;
       --clay: #3f2a21;
       --terracotta: #d9775a;
       --terracotta-dark: #b56347;
       --input-bg: #2c221b;
       --input-text: #e8e0d8;
       --tab-bg: rgba(0,0,0,0.25);
       --tab-text: #b8a090;
       --tab-hover: rgba(0,0,0,0.35);
       --title-gradient: linear-gradient(135deg, var(--terracotta), #f4a261);
       --shadow-sm: 5px 5px 12px rgba(0,0,0,0.35), -3px -3px 10px rgba(255,255,255,0.12);
       --shadow-lg: 10px 10px 24px rgba(0,0,0,0.35), -10px -10px 24px rgba(80,60,50,0.2);
       --shadow-inset: inset 4px 4px 10px rgba(0,0,0,0.45), inset -3px -3px 8px rgba(80,60,50,0.2);
       --border-subtle: rgba(255,255,255,0.08);
       --card-radius: 2.75rem;
       --btn-radius: 9999px;
       --focus-ring: 0 0 0 2px var(--terracotta);
       --font-body: Inter, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
       --font-title: "Playfair Display", serif;
     }

     body {
       font-family: var(--font-body);
       background: var(--bg);
       color: var(--input-text);
       transition: background 0.3s ease, color 0.3s ease;
     }

     .clay-title {
       font-family: var(--font-title);
       background: var(--title-gradient);
       -webkit-background-clip: text;
       -webkit-text-fill-color: transparent;
       background-clip: text;
     }

     .clay-card {
       background: var(--clay);
       border-radius: var(--card-radius);
       box-shadow: var(--shadow-lg), inset 0 0 0 1px var(--border-subtle);
       transition: all 0.3s ease;
     }

     .clay-input, .clay-select {
       background: var(--input-bg);
       border: none;
       border-radius: 2rem;
       box-shadow: var(--shadow-inset);
       color: var(--input-text);
       padding: 0.75rem 1.25rem;
       transition: all 0.2s ease;
     }

     .clay-input:focus, .clay-select:focus {
       outline: none;
       box-shadow: var(--shadow-inset), var(--focus-ring);
     }

     /* Claymorphism specific refinements */
     [data-theme="clay"] .clay-card {
       position: relative;
       overflow: hidden;
     }
     [data-theme="clay"] .clay-card::before {
       content: '';
       position: absolute;
       inset: 0;
       background: 
         radial-gradient(circle at 30% 20%, rgba(255,255,255,0.03) 0%, transparent 50%),
         radial-gradient(circle at 70% 80%, rgba(0,0,0,0.05) 0%, transparent 50%);
       pointer-events: none;
     }

    .clay-btn {
      background: linear-gradient(145deg, var(--terracotta), var(--terracotta-dark));
      border: none;
      border-radius: var(--btn-radius);
      color: white;
      padding: 0.75rem 2rem;
      font-weight: 600;
      cursor: pointer;
      transition: all 0.2s ease;
      box-shadow: var(--shadow-sm);
    }

    .clay-btn:hover {
      transform: translateY(-2px) scale(1.02);
      box-shadow: 6px 6px 14px rgba(0,0,0,0.35), -3px -3px 10px rgba(255,255,255,0.12);
    }

    .clay-btn:active {
      transform: translateY(0) scale(0.98);
    }

    .clay-tab {
      background: var(--tab-bg);
      border: none;
      border-radius: 15px;
      color: var(--tab-text);
      padding: 0.6rem 1.5rem;
      font-weight: 500;
      cursor: pointer;
      transition: all 0.2s ease;
    }

    .clay-tab:hover {
      color: var(--input-text);
      background: var(--tab-hover);
    }

    .clay-tab-active {
      background: var(--terracotta);
      color: white;
      transform: scale(1.08);
      box-shadow: 0 4px 12px rgba(217,119,90,0.4);
      border-radius: 15px;
    }

    .clay-modal {
      background: var(--clay);
      border-radius: 1.5rem;
      box-shadow: 0 25px 50px rgba(0,0,0,0.5);
    }

    .identity-warn {
      background: #7f1d1d;
      color: #fecaca;
      padding: 0.25rem 0.75rem;
      border-radius: 9999px;
      font-size: 0.75rem;
      font-weight: 500;
    }

    .enhancer-note {
      color: #fbbf24;
      border: 1px solid #fbbf24;
      padding: 0.25rem 0.5rem;
      border-radius: 0.375rem;
      font-size: 0.7rem;
    }

    .hidden { display: none !important; }

    #toast {
      position: fixed;
      bottom: 2rem;
      left: 50%;
      transform: translateX(-50%);
      background: #1f2937;
      color: white;
      padding: 1rem 2rem;
      border-radius: 0.75rem;
      box-shadow: 0 10px 25px rgba(0,0,0,0.3);
      z-index: 100;
      min-width: 280px;
      text-align: center;
    }

    @keyframes toastPop {
      from { transform: translate(-50%, 30px); opacity: 0; }
      to { transform: translate(-50%, 0); opacity: 1; }
    }

    .toast-animate {
      animation: toastPop 0.3s ease-out;
    }

      /* Theme: Glassmorphism */
      [data-theme="glass"] {
        --bg: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #0f172a 100%);
        --clay: rgba(255,255,255,0.20);
        --input-bg: rgba(255,255,255,0.15);
        --input-text: #e2e8f0;
        --tab-bg: rgba(255,255,255,0.15);
        --tab-text: #cbd5e1;
        --tab-hover: rgba(255,255,255,0.25);
        --terracotta: #818cf8;
        --terracotta-dark: #6366f1;
        --title-gradient: linear-gradient(135deg, #a5b4fc, #818cf8);
        --shadow-sm: 0 8px 20px rgba(99,102,241,0.3);
        --shadow-lg: 0 16px 40px rgba(0,0,0,0.25);
        --shadow-inset: none;
        --border-subtle: rgba(255,255,255,0.2);
        --card-radius: 1.5rem;
        --btn-radius: 9999px;
        --font-body: Inter, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
        --font-title: "Playfair Display", serif;
        --focus-ring: 0 0 0 2px #818cf8;
      }

      [data-theme="glass"] .clay-card {
        background: rgba(255,255,255,0.20);
        backdrop-filter: blur(20px) saturate(180%);
        -webkit-backdrop-filter: blur(20px) saturate(180%);
        border: 1px solid rgba(255,255,255,0.2);
        box-shadow: var(--shadow-lg), 0 0 40px rgba(99,102,241,0.15);
      }

      [data-theme="glass"] .clay-input, [data-theme="glass"] .clay-select {
        background: rgba(255,255,255,0.15);
        border: 1px solid rgba(255,255,255,0.25);
        box-shadow: none;
        color: #e2e8f0;
      }

      [data-theme="glass"] .clay-input::placeholder, [data-theme="glass"] .clay-select option {
        color: rgba(226, 232, 240, 0.6);
      }

      [data-theme="glass"] .clay-input:focus, [data-theme="glass"] .clay-select:focus {
        border-color: rgba(129,140,248,0.6);
        box-shadow: 0 0 0 3px rgba(129,140,248,0.2);
      }

      [data-theme="glass"] .clay-select {
        color: #e2e8f0;
      }

      [data-theme="glass"] .clay-select option {
        background: #1e1b4b;
        color: #e2e8f0;
      }

      [data-theme="glass"] .clay-tab-active {
        background: linear-gradient(145deg, #818cf8, #6366f1);
        box-shadow: 0 6px 20px rgba(99,102,241,0.5);
      }

      [data-theme="glass"] .clay-modal {
        background: rgba(30,27,75,0.85);
        backdrop-filter: blur(30px) saturate(150%);
       -webkit-backdrop-filter: blur(30px) saturate(150%);
       border: 1px solid rgba(255,255,255,0.2);
     }

    [data-theme="glass"] .clay-tab-active {
      background: linear-gradient(145deg, #6366f1, #4f46e5);
      box-shadow: 0 4px 15px rgba(99,102,241,0.4);
    }

    [data-theme="glass"] .clay-modal {
      background: rgba(30,27,75,0.9);
      backdrop-filter: blur(20px);
      border: 1px solid var(--border-subtle);
    }

     /* Theme: Neumorphism */
     [data-theme="neo"] {
       --bg: #e6ded3;
       --clay: #e6ded3;
       --input-bg: #e6ded3;
       --input-text: #4a4039;
       --tab-bg: #e6ded3;
       --tab-text: #6b5e52;
       --tab-hover: rgba(0,0,0,0.05);
       --terracotta: #d9775a;
       --terracotta-dark: #c06848;
       --title-gradient: linear-gradient(135deg, #8b5a3c, #a67c52);
       --shadow-sm: 5px 5px 12px #b8aea3, -5px -5px 12px #ffffff;
       --shadow-lg: 10px 10px 24px #b8aea3, -10px -10px 24px #ffffff;
       --shadow-inset: inset 4px 4px 10px #b8aea3, inset -4px -4px 10px #ffffff;
       --border-subtle: transparent;
       --card-radius: 1.5rem;
       --btn-radius: 1rem;
       --focus-ring: 0 0 0 2px #d9775a;
       --font-body: Inter, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
       --font-title: "Playfair Display", serif;
     }

     [data-theme="neo"] .clay-card {
       box-shadow: var(--shadow-lg), var(--shadow-inset);
     }

     [data-theme="neo"] .clay-tab {
       box-shadow: 4px 4px 8px #b8aea3, -4px -4px 8px #ffffff;
     }

     [data-theme="neo"] .clay-tab-active {
       box-shadow: inset 3px 3px 6px rgba(0,0,0,0.2);
       background: var(--terracotta);
       color: white;
     }

     [data-theme="neo"] .clay-input, [data-theme="neo"] .clay-select {
       border-radius: 1rem;
       box-shadow: var(--shadow-inset);
     }

     [data-theme="neo"] .clay-input:focus, [data-theme="neo"] .clay-select:focus {
       box-shadow: inset 4px 4px 10px #b8aea3, inset -4px -4px 10px #ffffff, 0 0 0 2px rgba(217,119,90,0.3);
     }

     /* Theme: Skeuomorphism */
     [data-theme="skeuo"] {
       --bg: repeating-linear-gradient(45deg, #3d2914 0%, #3d2914 2px, #4a3420 2px, #4a3420 4px);
       --clay: linear-gradient(145deg, #4a3420, #3d2914);
       --input-bg: linear-gradient(145deg, #3d2914, #2a1d10);
       --input-text: #d4c5b0;
       --tab-bg: linear-gradient(145deg, #3d2914, #2a1d10);
       --tab-text: #b8a080;
       --tab-hover: rgba(0,0,0,0.3);
       --terracotta: #e07a5f;
       --terracotta-dark: #b56347;
       --title-gradient: linear-gradient(135deg, #e8a87c, #d4a574);
       --shadow-sm: 0 4px 12px rgba(0,0,0,0.4);
       --shadow-lg: inset 0 1px 0 rgba(255,255,255,0.15), 0 6px 16px rgba(0,0,0,0.5);
       --shadow-inset: inset 2px 2px 6px rgba(0,0,0,0.4), inset -1px -1px 4px rgba(255,255,255,0.08);
       --border-subtle: #2a1d10;
       --card-radius: 0.75rem;
       --btn-radius: 0.5rem;
       --focus-ring: 0 0 0 2px #e07a5f;
     }

     [data-theme="skeuo"] .clay-card {
       border: 1px solid #2a1d10;
       box-shadow: var(--shadow-lg);
     }

     [data-theme="skeuo"] .clay-input, [data-theme="skeuo"] .cllay-select {
       border: 1px solid #1a1208;
       border-radius: 0.5rem;
       box-shadow: var(--shadow-inset);
     }

     [data-theme="skeuo"] .clay-input:focus, [data-theme="skeuo"] .clay-select:focus {
       border-color: #3d2914;
       box-shadow: inset 2px 2px 6px rgba(0,0,0,0.4), inset -1px -1px 4px rgba(255,255,255,0.08), 0 0 0 2px rgba(224,122,95,0.4);
     }

     [data-theme="skeuo"] .clay-btn {
       border-bottom: 3px solid #8b472e;
       box-shadow: 0 4px 10px rgba(0,0,0,0.3);
     }

     [data-theme="skeuo"] .clay-btn:hover {
       border-bottom-color: #a75a3e;
     }

     [data-theme="skeuo"] .clay-tab {
       border: 1px solid #1a1208;
       box-shadow: 2px 2px 5px rgba(0,0,0,0.3), -1px -1px 3px rgba(255,255,255,0.08);
     }

     [data-theme="skeuo"] .clay-tab-active {
       border-bottom-color: #8b472e;
       background: linear-gradient(145deg, #4a3420, #3d2914);
       box-shadow: inset 2px 2px 5px rgba(0,0,0,0.4);
     }

     [data-theme="skeuo"] .clay-modal {
       background: linear-gradient(145deg, #4a3420, #3d2914);
       border: 1px solid #2a1d10;
       box-shadow: var(--shadow-lg);
     }

     /* Theme: Material Design */
     [data-theme="material"] {
       --bg: #121212;
       --clay: #1e1e1e;
       --input-bg: #2d2d2d;
       --input-text: #e0e0e0;
       --tab-bg: transparent;
       --tab-text: #b0b0b0;
       --tab-hover: rgba(255,255,255,0.08);
       --terracotta: #ff8a65;
       --terracotta-dark: #e07a5f;
       --title-gradient: linear-gradient(135deg, #ffab91, #ff8a65);
       --shadow-sm: 0 2px 4px rgba(0,0,0,0.3);
       --shadow-md: 0 4px 8px rgba(0,0,0,0.4);
       --shadow-lg: 0 8px 16px rgba(0,0,0,0.5);
       --shadow-inset: none;
       --border-subtle: #2d2d2d;
       --card-radius: 0.5rem;
       --btn-radius: 0.25rem;
       --focus-ring: 0 0 0 2px #ff8a65;
       --font-body: Inter, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
       --font-title: "Playfair Display", serif;
     }

     [data-theme="material"] .clay-card {
       border: 1px solid #2d2d2d;
       box-shadow: var(--shadow-md);
     }

     [data-theme="material"] .clay-input, [data-theme="material"] .clay-select {
       border-radius: 0.25rem;
       border: 1px solid #404040;
       background: #252525;
     }

     [data-theme="material"] .clay-input:focus, [data-theme="material"] .clay-select:focus {
       border-color: #ff8a65;
       box-shadow: 0 0 0 2px rgba(255,138,101,0.2);
     }

     [data-theme="material"] .clay-btn {
       box-shadow: var(--shadow-sm);
     }

     [data-theme="material"] .clay-btn:hover {
       box-shadow: var(--shadow-md);
     }

     [data-theme="material"] .clay-tab {
       border-radius: 0.25rem;
     }

     [data-theme="material"] .clay-tab-active {
       background: var(--terracotta);
       color: white;
       box-shadow: var(--shadow-sm);
     }

     [data-theme="material"] .clay-modal {
       background: #1e1e1e;
       border: 1px solid #2d2d2d;
       box-shadow: var(--shadow-lg);
     }

    /* Theme-specific hover/focus states */
    [data-theme="glass"] .clay-btn:hover {
      box-shadow: 0 6px 20px rgba(99,102,241,0.5);
    }
    
    [data-theme="glass"] .clay-tab:hover {
      background: rgba(255,255,255,0.15);
    }

    [data-theme="neo"] .clay-btn:hover {
      box-shadow: 6px 6px 14px #bab0a8, -6px -6px 14px #ffffff;
    }

    [data-theme="neo"] .clay-tab:hover {
      background: rgba(0,0,0,0.05);
    }

    [data-theme="skeuo"] .clay-btn:hover {
      background: linear-gradient(145deg, #e8856a, #c06850);
    }

    [data-theme="skeuo"] .clay-tab:hover {
      background: linear-gradient(145deg, #4a3420, #2a1d10);
    }

    [data-theme="material"] .clay-btn:hover {
      background: #e8856a;
      box-shadow: 0 4px 8px rgba(0,0,0,0.4);
    }

    [data-theme="material"] .clay-tab:hover {
      background: rgba(255,255,255,0.08);
    }

    /* Img2Img Tool Cards */
    .tool-grid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
      gap: 1.5rem;
      margin-top: 2rem;
    }

    .tool-card {
      display: flex;
      flex-direction: column;
      height: 100%;
      padding: 1.5rem;
      position: relative;
      transition: transform 0.3s ease, box-shadow 0.3s ease;
    }

    .tool-card:hover {
      transform: translateY(-5px);
    }

    .tool-badge {
      position: absolute;
      top: 1rem;
      right: 1rem;
      padding: 0.25rem 0.75rem;
      border-radius: 9999px;
      font-size: 0.7rem;
      font-weight: 600;
      text-transform: uppercase;
      background: var(--terracotta);
      color: white;
      box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    }

    .tool-link {
      margin-top: auto;
      display: inline-flex;
      align-items: center;
      gap: 0.5rem;
      color: var(--terracotta);
      font-weight: 600;
      transition: gap 0.2s ease;
    }

    .tool-card:hover .tool-link {
      gap: 0.75rem;
    }

     /* Responsive */
     @media (max-width: 768px) {
       .main-container { padding-left: 1rem; padding-right: 1rem; }
       .content-inner { max-width: 100%; }
       .clay-card { border-radius: 1.5rem; padding: 1.25rem; }
       .clay-input, .clay-select { padding: 0.6rem 1rem; }
       .clay-btn { padding: 0.6rem 1.25rem; font-size: 0.9rem; }
       .clay-tab { padding: 0.5rem 1rem; font-size: 0.9rem; }
       .clay-title { font-size: 2rem; }
     }
   </style>
</head>
    <body data-theme="clay" class="min-h-screen">
    <div class="main-container py-6">
      <div class="content-inner">
        <!-- Header -->
        <header class="flex justify-between items-center mb-6">
          <div>
            <h1 class="clay-title text-3xl md:text-4xl">TAMILREAL</h1>
            <p class="text-sm opacity-70 mt-1">Portrait Prompt Studio</p>
          </div>
          <div class="flex gap-2">
            <button onclick="showThemeModal()" class="clay-tab text-sm" aria-label="Change Theme">Change Theme</button>
          </div>
        </header>

        <!-- Tab Navigation -->
        <nav class="flex gap-6 mb-6 overflow-x-auto pb-2 justify-center" role="tablist">
          <button id="tab0" onclick="switchTab(0)" class="clay-tab clay-tab-active" role="tab" aria-controls="content0" aria-selected="true">Creator</button>
          <button id="tab1" onclick="switchTab(1)" class="clay-tab" role="tab" aria-controls="content1" aria-selected="false">Analyzer</button>
          <button id="tab2" onclick="switchTab(2)" class="clay-tab" role="tab" aria-controls="content2" aria-selected="false">Enhancer</button>
        </nav>
      </div>

      <!-- Content Panels -->
      <!-- Creator Panel - Full Width -->
      <section id="content0" class="clay-card mb-6" role="tabpanel" aria-labelledby="tab0">
        <!-- Fixed Identity Block -->
        <div class="bg-black/20 rounded-xl p-4 mb-6 identity-anchor">
          <div class="flex items-center gap-2 mb-2">
            <span class="w-2 h-2 bg-green-500 rounded-full animate-pulse"></span>
            <span class="font-semibold text-sm">Identity Anchor (Applied to Every Prompt)</span>
          </div>
          <p class="text-xs opacity-80 leading-relaxed">
            <strong>EXACT FACE COMPOSITE PROTOCOL (EFCP):</strong> This protocol ensures high-fidelity identity consistency across different scenes and styles by articulating biometric markers with extreme precision.<br><br>
            <strong>STRICT IDENTITY LOCK:</strong> Maintain the exact rounded jawline and lower cheek fullness. Preserve circular eye shape and visible eyelid creases. The nose must retain its broad bridge and wider alar base. Ensure lower lip fullness and soft Cupid's bow are preserved.<br><br>
            <strong>MANDATORY ACCESSORY LOCK:</strong> The subject MUST wear thick-rimmed browline/Wayfarer style glasses. Remove neckband/earphones.
          </p>
        </div>




        <!-- Library Presets -->
        <div class="grid md:grid-cols-3 gap-4 mb-6">
          <div>
            <label class="block text-sm font-medium mb-2">Location Preset</label>
            <select id="locationPreset" class="clay-select w-full" onchange="applyPreset('location')">
              <option value="">Select Location...</option>
            </select>
          </div>
          <div>
            <label class="block text-sm font-medium mb-2">Camera Angle Preset</label>
            <select id="cameraAnglePreset" class="clay-select w-full" onchange="applyPreset('cameraAngle')">
              <option value="">Select Angle...</option>
            </select>
          </div>
          <div>
            <label class="block text-sm font-medium mb-2">Lighting Preset</label>
            <select id="lightingPreset" class="clay-select w-full" onchange="applyPreset('lighting')">
              <option value="">Select Lighting...</option>
            </select>
          </div>
        </div>

        <!-- Manual Input Fields -->
        <div class="grid md:grid-cols-2 gap-4 mb-6">
          <div>
            <label class="block text-sm font-medium mb-2">Scene</label>
            <div class="flex gap-2">
              <input type="text" id="scene" readonly class="clay-input flex-1" placeholder="Select from preset">
              <button id="editScene" onclick="makeEditable('scene')" class="clay-btn text-sm px-3 hidden">Edit</button>
            </div>
          </div>
          <div>
            <label class="block text-sm font-medium mb-2">Pose</label>
            <div class="flex gap-2">
              <input type="text" id="pose" class="clay-input flex-1" placeholder="Natural relaxed standing pose">
              <button onclick="randomPose(event)" class="clay-btn text-sm px-3">Random ⚠️</button>
            </div>
            <span id="poseWarn" class="identity-warn hidden mt-2 inline-block">⚠️ Risky pose - may obscure face</span>
          </div>
          <div>
            <label class="block text-sm font-medium mb-2">Clothing</label>
            <div class="flex gap-2">
              <input type="text" id="clothing" class="clay-input flex-1" placeholder="White linen shirt & dark trousers">
              <button onclick="randomClothing()" class="clay-btn text-sm px-3">Random</button>
            </div>
          </div>
          <div>
            <label class="block text-sm font-medium mb-2">Lighting</label>
            <div class="flex gap-2">
              <input type="text" id="lighting" readonly class="clay-input flex-1" placeholder="Select from preset">
              <button id="editLighting" onclick="makeEditable('lighting')" class="clay-btn text-sm px-3 hidden">Edit</button>
            </div>
          </div>
          <div>
            <label class="block text-sm font-medium mb-2">Camera Angle</label>
            <div class="flex gap-2 flex-col">
              <div class="flex gap-2">
                <input type="text" id="cameraAngle" readonly class="clay-input flex-1" placeholder="Select from preset">
                <button id="editCameraAngle" onclick="makeEditable('cameraAngle')" class="clay-btn text-sm px-3 hidden">Edit</button>
              </div>
              <span id="angleWarn" class="identity-warn hidden">⚠️ Risky angle - may obscure face</span>
            </div>
          </div>
          <div>
            <label class="block text-sm font-medium mb-2">Color Grading</label>
            <div class="flex gap-2">
              <input type="text" id="colorGrading" class="clay-input flex-1" placeholder="Natural Canon / Sony color science">
              <button onclick="randomColorGrading()" class="clay-btn text-sm px-3">Random</button>
            </div>
          </div>
        </div>

        <!-- Camera Settings -->
        <div class="mb-6">
          <label class="block text-sm font-medium mb-2">Camera Settings</label>
          <div class="flex flex-col sm:flex-row gap-3 items-start sm:items-center">
            <select id="cameraMode" class="clay-select" onchange="toggleManualCamera()">
              <option value="default">Default DSLR/Mirrorless</option>
              <option value="manual">Manual</option>
            </select>
            <input type="text" id="manualCamera" class="clay-input flex-1 hidden" placeholder="Shot on Sony A7R IV, 85mm f/1.8">
          </div>
        </div>



        <!-- Live Length Bar -->
        <div class="mb-4">
          <div class="flex justify-between text-xs mb-1">
            <span>Prompt Length</span>
            <span id="liveLengthCount">0 chars</span>
          </div>
          <div class="h-2 bg-black/30 rounded-full overflow-hidden">
            <div id="liveLengthBar" class="h-full bg-green-500 transition-all duration-300" style="width: 0%"></div>
          </div>
        </div>

        <!-- Generate Buttons -->
        <div class="flex flex-wrap gap-2 mb-6">
          <button onclick="generatePortraitPrompt('chatgpt')" class="clay-btn text-lg px-6 py-3 flex-1 min-w-[140px]">ChatGPT Optimized</button>
          <button onclick="generatePortraitPrompt('gemini')" class="clay-btn text-lg px-6 py-3 flex-1 min-w-[140px]">Gemini Optimized</button>
          <button onclick="generatePortraitPrompt('general')" class="clay-btn text-lg px-6 py-3 flex-1 min-w-[140px]">General Optimized</button>
        </div>




        <!-- Result Area -->
        <div id="creatorResult" class="hidden">
          <label class="block text-sm font-medium mb-2">Generated Prompt</label>
          <pre id="creatorOutput" class="bg-black/20 rounded-lg p-4 text-xs overflow-x-auto max-h-80 whitespace-pre-wrap"></pre>
          <div class="flex flex-wrap gap-3 mt-4">
            <button onclick="copyPrompt('creatorOutput')" class="clay-btn">Copy Prompt</button>
            <button onclick="batchExport()" class="clay-btn">Generate 5 Location Variations</button>
            <button onclick="saveCurrentPrompt()" class="clay-btn">Save Prompt</button>
            <button onclick="loadSavedPrompts()" class="clay-tab">Library</button>
          </div>
        </div>

        <!-- Saved Library Panel -->
        <div id="libraryPanel" class="hidden mt-6 pt-6 border-t border-white/10">
          <div class="flex flex-wrap justify-between items-center gap-3 mb-4">
            <h3 class="font-semibold">Saved Prompts</h3>
            <div class="flex gap-2 items-center">
              <select id="tagFilter" class="clay-select text-sm" onchange="loadSavedPrompts()">
                <option value="">All Tags</option>
                <option value="ChatGPT">ChatGPT</option>
                <option value="Gemini">Gemini</option>
                <option value="General">General</option>
                <option value="EFCP-200%">EFCP-200%</option>
              </select>
              <input type="text" id="librarySearch" class="clay-input text-sm" placeholder="Search..." oninput="loadSavedPrompts()">
            </div>
          </div>
          <div id="savedPromptsList" class="space-y-3 max-h-60 overflow-y-auto"></div>
        </div>
      </section>

      <div class="content-inner">
        <!-- Analyzer Panel -->
        <section id="content1" class="clay-card mb-6 hidden" role="tabpanel" aria-labelledby="tab1">
          <h2 class="text-xl font-semibold mb-4">Prompt Analyzer</h2>
          <textarea id="analyzeInput" class="clay-input w-full h-40 mb-4" placeholder="Paste your prompt here to analyze..."></textarea>
          <button onclick="analyzePrompt()" class="clay-btn mb-4">Analyze Prompt</button>
          <div id="analyzeResult" class="hidden">
            <div class="grid md:grid-cols-2 gap-4 mb-4">
              <div>
                <div id="scoreBadge" class="text-3xl font-bold text-center py-4 rounded-xl"></div>
                <p class="text-center text-sm opacity-70 mb-2">SPECIFICITY SCORE / 100</p>
              </div>
              <div>
                <div id="faceFidelityBadge" class="text-3xl font-bold text-center py-4 rounded-xl"></div>
                <p class="text-center text-sm opacity-70 mb-2">FACE FIDELITY SCORE / 100</p>
              </div>
            </div>
            <div id="missingProtections" class="mb-4 p-3 bg-black/20 rounded-lg hidden">
              <h4 class="font-medium mb-2">Missing Protections</h4>
              <div id="missingList" class="space-y-2"></div>
            </div>
            <ul id="issuesList" class="space-y-2"></ul>
            <button onclick="copyPrompt('analyzeOutput')" id="copyAnalyzeBtn" class="clay-btn mt-4 hidden">Copy Result</button>
            <pre id="analyzeOutput" class="hidden"></pre>
          </div>
        </section>

        <!-- Enhancer Panel -->
        <section id="content2" class="clay-card mb-6 hidden" role="tabpanel" aria-labelledby="tab2">
          <h2 class="text-xl font-semibold mb-4">Prompt Enhancer</h2>
          <textarea id="enhanceInput" class="clay-input w-full h-40 mb-4" placeholder="Paste prompt to enhance..."></textarea>
          
          <div class="flex flex-wrap gap-4 mb-4">
            <label class="flex items-center gap-2">
              <input type="checkbox" id="roleChk" checked class="w-4 h-4">
              <span class="text-sm">Expert Role</span>
              <span class="enhancer-note">LLM-only</span>
            </label>
            <label class="flex items-center gap-2">
              <input type="checkbox" id="cot" checked class="w-4 h-4">
              <span class="text-sm">Chain-of-Thought</span>
              <span class="enhancer-note">LLM-only</span>
            </label>
            <label class="flex items-center gap-2">
              <input type="checkbox" id="format" checked class="w-4 h-4">
              <span class="text-sm">Output Format</span>
            </label>
            <label class="flex items-center gap-2">
              <input type="checkbox" id="examples" checked class="w-4 h-4">
              <span class="text-sm">Real Examples</span>
            </label>
            <label class="flex items-center gap-2">
              <input type="checkbox" id="reinforceEFCP" checked class="w-4 h-4">
              <span class="text-sm">Reinforce EFCP 200%</span>
            </label>
            <label class="flex items-center gap-2">
              <input type="checkbox" id="modelTuned" class="w-4 h-4">
              <span class="text-sm">Model-Tuned Booster</span>
            </label>
            <select id="modelBoosterSelect" class="clay-select text-sm">
              <option value="chatgpt">ChatGPT</option>
              <option value="gemini">Gemini</option>
              <option value="general">General</option>
            </select>
            <label class="flex items-center gap-2">
              <input type="checkbox" id="maximizeNegative" class="w-4 h-4">
              <span class="text-sm">Maximize Negative Prompt</span>
            </label>
          </div>

          <button onclick="enhancePrompt()" class="clay-btn mb-4">Enhance Prompt</button>
          
          <div id="enhanceResult" class="hidden">
            <label class="block text-sm font-medium mb-2">Enhanced Prompt</label>
            <pre id="enhanceOutput" class="bg-black/20 rounded-lg p-4 text-xs overflow-x-auto max-h-80 whitespace-pre-wrap"></pre>
            <button onclick="copyPrompt('enhanceOutput')" class="clay-btn mt-4">Copy Enhanced</button>
          </div>
        </section>

        <!-- Resource Section: Verified Img2Img Tools -->
        <section id="resourceSection" class="mt-12 mb-12">
          <div class="text-center mb-8">
            <h2 class="clay-title text-3xl md:text-4xl mb-4">Verified No-Signup Img2Img Tools</h2>
            <p class="max-w-3xl mx-auto text-sm opacity-80 leading-relaxed">
              These platforms are confirmed to work for true <strong>Image-to-Image (img2img)</strong> generation in March 2026. 
              They are 100% free, requiring no signup, no account, and no email. Just upload your photo, type a prompt, and generate instantly.
            </p>
          </div>

          <div class="tool-grid">
            <!-- EaseMate AI -->
            <div class="clay-card tool-card">
              <span class="tool-badge">Top Recommendation</span>
              <h3 class="text-xl font-bold mb-2">EaseMate AI</h3>
              <p class="text-sm opacity-70 mb-6">Upload photo + text prompt. Clean, fast, no watermark, no account. Excellent for style changes and edits.</p>
              <a href="https://www.easemate.ai/image-to-image-ai-generator" target="_blank" class="tool-link">
                Visit EaseMate AI <svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M14 5l7 7m0 0l-7 7m7-7H3" /></svg>
              </a>
            </div>

            <!-- Image2Image.ai -->
            <div class="clay-card tool-card">
              <span class="tool-badge">Best Interface</span>
              <h3 class="text-xl font-bold mb-2">Image2Image.ai</h3>
              <p class="text-sm opacity-70 mb-6">"Start Free. No Registration Required" — literally instant. One of the cleanest interfaces for quick edits.</p>
              <a href="https://www.image2image.ai/" target="_blank" class="tool-link">
                Visit Image2Image.ai <svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M14 5l7 7m0 0l-7 7m7-7H3" /></svg>
              </a>
            </div>

            <!-- Joyfun AI -->
            <div class="clay-card tool-card">
              <h3 class="text-xl font-bold mb-2">Joyfun AI</h3>
              <p class="text-sm opacity-70 mb-6">Claims "free and unlimited" with no signup. Works immediately for transforming existing photos with AI.</p>
              <a href="https://joyfun.ai/ai-image-to-image/" target="_blank" class="tool-link">
                Visit Joyfun AI <svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M14 5l7 7m0 0l-7 7m7-7H3" /></svg>
              </a>
            </div>

            <!-- Krea.ai -->
            <div class="clay-card tool-card">
              <h3 class="text-xl font-bold mb-2">Krea.ai</h3>
              <p class="text-sm opacity-70 mb-6">"No sign up required. Transform any image with AI for free." Powerful tool with high-quality results.</p>
              <a href="https://www.krea.ai/apps/edit/image-to-image" target="_blank" class="tool-link">
                Visit Krea.ai <svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M14 5l7 7m0 0l-7 7m7-7H3" /></svg>
              </a>
            </div>

            <!-- ImageHub.ai -->
            <div class="clay-card tool-card">
              <h3 class="text-xl font-bold mb-2">ImageHub.ai</h3>
              <p class="text-sm opacity-70 mb-6">"100% Free • No Sign-up Required". Great for sketches-to-real or cinematic style transfers.</p>
              <a href="https://imagehub.ai/free-ai-image-to-image-generator/" target="_blank" class="tool-link">
                Visit ImageHub.ai <svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M14 5l7 7m0 0l-7 7m7-7H3" /></svg>
              </a>
            </div>

            <!-- Arena.ai -->
            <div class="clay-card tool-card">
              <span class="tool-badge">Comparison Tool</span>
              <h3 class="text-xl font-bold mb-2">Arena.ai</h3>
              <p class="text-sm opacity-70 mb-6">A powerful platform for comparing different AI models and generating results side-by-side without friction.</p>
              <a href="https://arena.ai/" target="_blank" class="tool-link">
                Visit Arena.ai <svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M14 5l7 7m0 0l-7 7m7-7H3" /></svg>
              </a>
            </div>
          </div>
        </section>
      </div>
    </div>

  <!-- Length Modal -->
  <div id="lengthModal" class="fixed inset-0 bg-black/70 flex items-center justify-center p-4 hidden z-50">
    <div class="clay-modal max-w-lg w-full p-6 relative">
      <button onclick="keepPrompt()" class="absolute top-4 right-4 text-white/50 hover:text-white" aria-label="Close">
        <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
          <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
        </svg>
      </button>
      <h2 class="text-xl font-semibold mb-4">Length Validation</h2>
      <p id="lengthDisplay" class="text-sm mb-2"></p>
      <p id="statusMessage" class="mb-4"></p>
      
      <div class="mb-4">
        <label class="block text-sm font-medium mb-2">Select Model</label>
        <select id="modelSelect" class="clay-select w-full" onchange="checkLength()">
          <option value="chatgpt">ChatGPT (200,000 tokens)</option>
          <option value="gemini">Gemini (1,000,000 tokens)</option>
          <option value="general">General (500,000 tokens)</option>
          <option value="custom">Custom</option>
        </select>
      </div>
      
      <div id="customLimitDiv" class="mb-4 hidden">
        <label class="block text-sm font-medium mb-2">Custom Limit</label>
        <input type="number" id="customLimit" class="clay-input w-full" value="5000">
      </div>

      <div class="flex gap-3">
        <button onclick="shortenPrompt()" id="shortenBtn" class="clay-btn hidden">Shorten</button>
        <button onclick="keepPrompt()" class="clay-tab flex-1">Keep</button>
        <button onclick="copyFromModal()" class="clay-btn flex-1">Copy</button>
      </div>
    </div>
  </div>

  <!-- Theme Modal -->
  <div id="themeModal" class="fixed inset-0 bg-black/70 flex items-center justify-center p-4 hidden z-50">
    <div class="clay-modal max-w-md w-full p-6">
      <h2 class="text-xl font-semibold mb-4">Select Theme</h2>
      <div id="themeOptions" class="space-y-3"></div>
      <button onclick="hideThemeModal()" class="clay-tab w-full mt-4">Cancel</button>
    </div>
  </div>



   <!-- Toast -->
   <div id="toast" class="hidden"></div>

   <script>
     // Apply modal styling based on current theme
     const styleEl = document.createElement('style');
     styleEl.textContent = `
       [data-theme="glass"] #themeModal .clay-modal {
         background: rgba(255,255,255,0.15) !important;
         backdrop-filter: blur(30px) saturate(180%) !important;
         -webkit-backdrop-filter: blur(30px) saturate(180%) !important;
         border: 1px solid rgba(255,255,255,0.25) !important;
       }
       [data-theme="neo"] #themeModal .clay-modal {
         box-shadow: 8px 8px 20px rgba(0,0,0,0.2), -8px -8px 20px rgba(255,255,255,0.9) !important;
       }
       [data-theme="skeuo"] #themeModal .clay-modal {
         background: linear-gradient(145deg, #4a3420, #3d2914) !important;
         border: 1px solid #2a1d10 !important;
         box-shadow: inset 0 1px 0 rgba(255,255,255,0.1), 0 4px 12px rgba(0,0,0,0.4) !important;
       }
       [data-theme="material"] #themeModal .clay-modal {
         background: #1e1e1e !important;
         border: 1px solid #2d2d2d !important;
         box-shadow: 0 8px 32px rgba(0,0,0,0.5) !important;
       }
     `;
      document.head.appendChild(styleEl);
    </script>
    <script>
      // ============ DATA LIBRARIES ============
    // ============ DATA LIBRARIES ============


    const libraries = {
      locations: [
        "Marina Beach Chennai sunrise", "Besant Nagar beach evening walk",
        "T Nagar shopping street Chennai", "Chennai metro station entrance",
        "Chennai tea stall street", "Kapaleeshwarar Temple street Mylapore",
        "Book shop street Chennai", "Ooty tea plantations",
        "Ooty hill road viewpoint", "Hill fog road Ooty",
        "Tea factory road Ooty", "Old railway platform Ooty toy train",
        "Kodaikanal lake walkway", "Coaker's walk Kodaikanal",
        "Sunset hill viewpoint Kodaikanal", "Yelagiri hill viewpoint",
        "Yercaud lake park", "Madurai Meenakshi temple streets",
        "Thanjavur Brihadeeswarar courtyard", "Chidambaram temple corridor",
        "Tirunelveli temple street market", "Velankanni church street",
        "Rameswaram beach", "Pamban bridge",
        "Kanyakumari sunrise beach", "Kanyakumari Vivekananda rock",
        "Courtallam waterfall", "Sunrise fishing harbor Chennai",
        "Pondicherry french quarter", "Pondicherry beach promenade",
        "Coimbatore cafe street", "Coimbatore race course road",
        "Rural paddy field Thanjavur", "Coconut farm Pollachi",
        "Banana plantation Trichy", "Village road Salem",
        "Village temple entrance", "Bus stand portrait",
        "Local market", "Flower market Madurai",
        "Fish market village", "Small roadside tea shop",
        "College campus walkway", "Government office corridor",
        "Auto rickshaw background", "Rainy street Chennai monsoon",
        "Temple chariot festival street", "Night food street Madurai"
      ],
      cameraAngles: [
        "Eye Level Portrait", "Low Angle Shot", "High Angle Shot",
        "Street Candid Angle", "Walking Follow Shot",
        "Wide Environmental Portrait", "Close Portrait", "Medium Portrait",
        "Over the Shoulder Shot", "Side Profile Shot"
      ],
      lightingSetups: [
        "Golden Hour", "Morning Soft Light", "Overcast Day",
        "Temple Lamp Lighting", "Street Night Lighting",
        "Rainy Monsoon Light", "Beach Sunset Lighting",
        "Forest Shade Lighting", "Cafe Window Lighting", "City Neon Reflection"
      ]
    };

    const RISKY_ANGLES = new Set(["Side Profile Shot", "Over the Shoulder Shot"]);
    const RISKY_POSES = new Set([
      "Side profile looking away from camera",
      "Back to camera, walking away",
      "Looking away, face partially hidden",
      "Face turned away from camera",
      "Backlit with face in shadow",
      "Out of focus background pose"
    ]);
    const RISKY_POSE_PATTERNS = /side profile|over shoulder|behind head|looking away|back to camera|turned away|face hidden|partial face|obscured|blurred face|out of focus|backlit|shadow on face/i;

    const poses = [
      "Natural relaxed standing pose, preserve reference expression",
      "Walking casually toward camera, face fully visible",
      "Sitting relaxed on steps, front-facing",
      "Standing with hands in pockets, facing camera",
      "Leaning against wall, front-facing, natural expression",
      "Looking over shoulder, face partially turned",
      "Side profile looking away from camera",
      "Hands behind head, face visible",
      "Back to camera, walking away",
      "Turned away, partial face visible",
      "Crouching low, face obscured",
      "Holding object in front of face"
    ];

    const clothes = [
      "White linen shirt and dark trousers",
      "Traditional white kurta",
      "Casual blue t-shirt and jeans",
      "Black cotton shirt with rolled sleeves",
      "Light blue denim shirt",
      "Beige linen kurta",
      "Gray hoodie and black pants",
      "White polo and khaki shorts"
    ];

    const colorGradings = [
      "Natural Canon / Sony color science",
      "Warm cinematic Kodak tones",
      "Cool Fujifilm tones",
      "Vibrant National Geographic style",
      "Soft pastel film look",
      "High contrast dramatic",
      "Balanced neutral RAW",
      "Golden hour warmth",
      "Cool blue hour tones",
      "Vintage Polaroid feel"
    ];

    const themes = [
      { id: "clay", name: "Claymorphism", desc: "Warm dark cards with terracotta accents" },
      { id: "glass", name: "Glassmorphism", desc: "Frosted glass with blue-purple gradient" },
      { id: "neo", name: "Neumorphism", desc: "Soft beige with extruded shadows" },
      { id: "skeuo", name: "Skeuomorphism", desc: "Dark leather texture with bevels" },
      { id: "material", name: "Material Design", desc: "Dark surface with elevation shadows" }
    ];

    // ============ EFCP ULTRA CONSTANT ============
    const efcpUltra = `EFCP 200% ENFORCEMENT LAYER (NON-NEGOTIABLE):

• Treat reference face as a literal pixel stamp — zero creative interpretation allowed.
• Face crop must include: exact hairline contour, ear shape, glasses frame thickness/position, stubble density map, neck blend line.
• Lighting, color temperature and shadow direction on the pasted face MUST match the new scene exactly (use reference as master).
• Any deviation = instant failure.
FACE STAMP PROTOCOL:
ChatGPT: RAW composite only. Paste reference face 1:1. No inpainting, no refinement.
Gemini: Biometric Lock v2 — disable all face enhancement, use reference as hard mask.
General: Maximum identity consistency mode. Zero facial morphing or aesthetic changes.`;

    // ============ GLOBAL STATE ============
    let currentPrompt = "";



    // ============ UI UTILS ============
    function populateDropdowns() {
      const locSel = document.getElementById('locationPreset');
      const angleSel = document.getElementById('cameraAnglePreset');
      const lightSel = document.getElementById('lightingPreset');
      libraries.locations.forEach(loc => { const opt = document.createElement('option'); opt.value = loc; opt.textContent = loc; locSel.appendChild(opt); });
      libraries.cameraAngles.forEach(angle => { const opt = document.createElement('option'); opt.value = angle; opt.textContent = angle + (RISKY_ANGLES.has(angle) ? " ⚠️" : ""); angleSel.appendChild(opt); });
      libraries.lightingSetups.forEach(light => { const opt = document.createElement('option'); opt.value = light; opt.textContent = light; lightSel.appendChild(opt); });
    }

    function applyPreset(type) {
      const select = document.getElementById(type + 'Preset');
      if (!select.value) return;
      const cleanValue = select.value.replace(/\s*⚠️$/, '').trim();
      const fieldMap = { location: 'scene', cameraAngle: 'cameraAngle', lighting: 'lighting' };
      const field = fieldMap[type];
      const input = document.getElementById(field);
      input.value = cleanValue; input.readOnly = true;
      const editBtn = document.getElementById('edit' + field.charAt(0).toUpperCase() + field.slice(1));
      if (editBtn) editBtn.classList.remove('hidden');
      if (type === 'cameraAngle') checkAngleWarn(cleanValue);
    }

    function makeEditable(field) {
      const input = document.getElementById(field); input.readOnly = false; input.focus();
      const editBtn = document.getElementById('edit' + field.charAt(0).toUpperCase() + field.slice(1));
      if (editBtn) editBtn.classList.add('hidden');
    }

    function randomPose(event) {
      const input = document.getElementById('pose');
      const allowRisky = event && event.shiftKey;
      let pool = allowRisky ? poses : poses.filter(p => !RISKY_POSES.has(p));
      if (pool.length === 0) { showToast("⚠️ Only risky poses available. Hold Shift."); return; }
      const p = pool[Math.floor(Math.random() * pool.length)];
      input.value = p; checkPoseWarn(p);
    }

    function randomClothing() { document.getElementById('clothing').value = clothes[Math.floor(Math.random() * clothes.length)]; }
    function randomColorGrading() { document.getElementById('colorGrading').value = colorGradings[Math.floor(Math.random() * colorGradings.length)]; }

    function checkPoseWarn(val) { document.getElementById('poseWarn').classList.toggle('hidden', !RISKY_POSE_PATTERNS.test(val)); }
    function checkAngleWarn(val) { document.getElementById('angleWarn').classList.toggle('hidden', !RISKY_ANGLES.has(val)); }

    function toggleManualCamera() {
      const mode = document.getElementById('cameraMode').value;
      document.getElementById('manualCamera').classList.toggle('hidden', mode !== 'manual');
    }

    function deduplicatePrompt(text) {
      if (!text) return "";
      let clean = text.replace(/\n\n+/g, '\n').trim();
      return clean.split('\n').map(section => {
        const phrases = section.split(',').map(p => p.trim());
        const seen = new Set();
        return phrases.filter(p => p && !seen.has(p.toLowerCase()) && seen.add(p.toLowerCase())).join(', ');
      }).join('\n\n');
    }

    function validateInputs() {
      const errors = [];
      if (!document.getElementById('scene').value.trim()) errors.push("Scene");
      if (!document.getElementById('pose').value.trim()) errors.push("Pose");
      if (!document.getElementById('clothing').value.trim()) errors.push("Clothing");
      if (errors.length > 0) { showToast(`⚠️ Missing: ${errors.join(', ')}`); return false; }
      return true;
    }

     // ============ TAB SWITCHING ============
     function switchTab(n) {
       // Hide all content sections
       document.querySelectorAll('[id^="content"]').forEach(el => el.classList.add('hidden'));
       // Show the target content panel
       const target = document.getElementById('content' + n);
       if (target) target.classList.remove('hidden');

       // Explicitly update tab active states by known IDs
       const tabIds = ['tab0', 'tab1', 'tab2'];
      tabIds.forEach((id, idx) => {
        const btn = document.getElementById(id);
        if (btn) {
          btn.classList.toggle('clay-tab-active', idx === n);
          btn.setAttribute('aria-selected', (idx === n).toString());
        }
      });
    }

    // ============ GENERATE PROMPT ============
    function generatePortraitPrompt(variant = 'general') {
      if (!validateInputs()) return;
      
      const scene = document.getElementById('scene').value.trim();
      const pose = document.getElementById('pose').value.trim();
      const clothing = document.getElementById('clothing').value.trim();
      const lighting = document.getElementById('lighting').value.trim() || libraries.lightingSetups[0];
      const colorGrading = document.getElementById('colorGrading').value.trim() || colorGradings[0];
      const cameraAngle = document.getElementById('cameraAngle').value.trim() || "Eye Level Portrait";
      
      const cameraMode = document.getElementById('cameraMode').value;
      const camera = cameraMode === 'manual' 
        ? (document.getElementById('manualCamera').value.trim() || "Shot on Sony A7R IV, 85mm f/1.8")
        : "Shot on 85mm f/1.8 prime lens. Shallow depth of field with soft bokeh";

      let styleNote = "Ultra photorealistic portrait photography style, Professional documentary approach, Authentic Tamil Nadu cultural context";

      let rawPrompt = `${efcpUltra}

STRICT IDENTITY LOCK:
Preserve exact rounded jawline, circular eye shape, broad nasal bridge, and lower lip fullness. Thick-rimmed browline/Wayfarer glasses ONLY.

SCENE: ${scene}
CAMERA ANGLE: ${cameraAngle}
POSE: ${pose}
CLOTHING: ${clothing}
CAMERA: ${camera}
LIGHTING: ${lighting}
STYLE: ${styleNote}, High-end editorial photography, Cinematic storytelling
COLOR GRADING: ${colorGrading}
DETAILS: Realistic cloth wrinkles, natural hair strands, subtle glasses reflections
REALISM: Authentic Tamil Nadu skin tone (medium-warm). Visible skin pores, natural facial hair. No digital smoothing.
PHOTOGRAPHIC DEPTH: DSLR-style shallow depth of field, natural bokeh.

NEGATIVE PROMPT: (neckband, headphones, wires), facial slimming, sharpened chin, thin nose, narrowed eyes, plastic skin, AI art style, 3D render, beautification filter, changed identity, distorted face, unnatural smoothing`;

      currentPrompt = deduplicatePrompt(rawPrompt);
      showResult();
      document.getElementById('lengthModal').classList.remove('hidden');
      checkLength();
    }

    function showResult() {
      document.getElementById('creatorOutput').textContent = currentPrompt;
      document.getElementById('creatorResult').classList.remove('hidden');
      updateLiveLengthBar();
    }

    function updateLiveLengthBar() {
      const chars = currentPrompt.length;
      const model = document.getElementById('modelSelect').value;
      const limits = { chatgpt: 200000, gemini: 1000000, general: 500000, custom: 5000 };
      const limit = limits[model] || 5000;
      const percentage = Math.min((chars / limit) * 100, 100);
      
      const bar = document.getElementById('liveLengthBar');
      const countEl = document.getElementById('liveLengthCount');
      
      bar.style.width = percentage + '%';
      countEl.textContent = chars.toLocaleString() + ' chars';
      
      if (percentage < 50) {
        bar.className = 'h-full bg-green-500 transition-all duration-300';
      } else if (percentage < 80) {
        bar.className = 'h-full bg-yellow-500 transition-all duration-300';
      } else {
        bar.className = 'h-full bg-red-500 transition-all duration-300';
      }
    }



    function batchExport() {
      const locations = libraries.locations.slice(0, 5);
      const model = document.getElementById('modelSelect').value;
      let prompts = '';
      
      locations.forEach((loc, i) => {
        prompts += `=== VARIATION ${i + 1}: ${loc} ===\n\n`;
        const tempPrompt = currentPrompt.replace(/SCENE: .+/, `SCENE: ${loc}`);
        prompts += tempPrompt + '\n\n' + '='.repeat(40) + '\n\n';
      });
      
      const blob = new Blob([prompts], { type: 'text/plain' });
      const url = URL.createObjectURL(blob);
      const a = document.createElement('a');
      a.href = url;
      a.download = 'tamilreal_prompts_5_variations.txt';
      a.click();
      URL.revokeObjectURL(url);
      showToast('✅ Downloaded 5 location variations!');
    }

    // ============ LENGTH VALIDATION ============
    function checkLength() {
      const chars = currentPrompt.length;
      const words = currentPrompt.trim().split(/\s+/).length;
      const tokens = Math.round(chars / 4);
      
      const model = document.getElementById('modelSelect').value;
      
      const limits = {
        chatgpt: 200000,
        gemini: 1000000,
        general: 500000,
        custom: parseInt(document.getElementById('customLimit')?.value || 5000)
      };
      
      const limit = limits[model] || 5000;
      const tooLong = tokens > limit;
      
      document.getElementById('lengthDisplay').textContent = `${chars.toLocaleString()} chars (~${words.toLocaleString()} words / ~${tokens.toLocaleString()} tokens)`;
      
      const statusEl = document.getElementById('statusMessage');
      if (tooLong) {
        statusEl.innerHTML = `<span class="text-red-400">⚠️ Token count exceeds ${limit.toLocaleString()} limit for ${model}</span>`;
        document.getElementById('shortenBtn').classList.remove('hidden');
      } else {
        statusEl.innerHTML = `<span class="text-green-400">✅ Within ${limit.toLocaleString()} token limit for ${model}</span>`;
        document.getElementById('shortenBtn').classList.add('hidden');
      }
      
      document.getElementById('customLimitDiv').classList.toggle('hidden', model !== 'custom');
    }

    function keepPrompt() {
      document.getElementById('lengthModal').classList.add('hidden');
    }

    function copyFromModal() {
      copyPrompt('creatorOutput');
      document.getElementById('lengthModal').classList.add('hidden');
    }

    // ============ SHORTEN PROMPT ============
    function shortenPrompt() {
      const originalPrompt = currentPrompt;
      
      if (currentPrompt.length > 5200) {
        const detailsMatch = currentPrompt.match(/^([\s\S]*?DETAILS: )(.*?)([\s\S]*?REALISM RULES)/);
        if (detailsMatch) {
          currentPrompt = detailsMatch[1] + "Realistic cloth wrinkles, natural hair strands, natural depth of field\n\n" + detailsMatch[3];
        }
      }
      
      if (currentPrompt.length > 5200) {
        const realismMatch = currentPrompt.match(/^([\s\S]*?REALISM RULES[\s\S]*?)(.*?)([\s\S]*?NEGATIVE PROMPT)/);
        if (realismMatch) {
          currentPrompt = realismMatch[1] + "Must look like a real RAW photograph by a professional photographer.\n\n" + realismMatch[3];
        }
      }
      
      if (currentPrompt.length > 5200) {
        const styleMatch = currentPrompt.match(/^([\s\S]*?STYLE: )(.*?)([\s\S]*?COLOR GRADING)/);
        if (styleMatch) {
          currentPrompt = styleMatch[1] + "Ultra photorealistic, natural skin texture, no plastic skin\n\n" + styleMatch[3];
        }
      }
      
      if (currentPrompt.length > 5200) {
        currentPrompt = currentPrompt.slice(0, 5200);
        const lastNewline = currentPrompt.lastIndexOf('\n');
        if (lastNewline > 4000) {
          currentPrompt = currentPrompt.slice(0, lastNewline);
        }
      }
      
      if (!currentPrompt.includes("NEGATIVE PROMPT")) {
        currentPrompt = originalPrompt;
        showToast("Could not safely shorten - please edit manually");
        return;
      }
      
      showResult();
      document.getElementById('lengthModal').classList.add('hidden');
      showToast("Prompt shortened successfully");
    }

    // ============ CLIPBOARD ============
    function copyAsJson() {
      const saved = JSON.parse(localStorage.getItem('tamilreal_api_keys') || '{}');
      const model = saved.lastModel || 'unknown_model';
      const img = document.getElementById('generatedImage');
      
      const data = {
        prompt: currentPrompt,
        model: model,
        imageBase64: img ? img.src : null,
        timestamp: new Date().toISOString()
      };
      
      const text = JSON.stringify(data, null, 2);
      if (navigator.clipboard && navigator.clipboard.writeText) {
        navigator.clipboard.writeText(text).then(() => {
          showToast("✅ Copied as JSON");
        }).catch(() => {
          fallbackCopy(text, "✅ Copied as JSON");
        });
      } else {
        fallbackCopy(text, "✅ Copied as JSON");
      }
    }

    function copyPrompt(id) {
      let text = document.getElementById(id).textContent;
      
      // Auto-append upload reminder
      const uploadLine = '↑↑↑ IMPORTANT: FIRST upload your reference photo in the AI tool, then paste this prompt below ↑↑↑\n\n';
      text = uploadLine + text;
      
      if (navigator.clipboard && navigator.clipboard.writeText) {
        navigator.clipboard.writeText(text).then(() => {
          showToast("✅ Copied with upload reminder!");
        }).catch(() => {
          fallbackCopy(text, "✅ Copied with upload reminder!");
        });
      } else {
        fallbackCopy(text, "✅ Copied with upload reminder!");
      }
    }
    
    function fallbackCopy(text, successMsg = "✅ Copied to clipboard") {
      const textarea = document.createElement('textarea');
      textarea.value = text;
      textarea.style.position = 'fixed';
      textarea.style.left = '-9999px';
      textarea.style.top = '-9999px';
      document.body.appendChild(textarea);
      textarea.focus();
      textarea.select();
      
      try {
        const successful = document.execCommand('copy');
        if (successful) {
          showToast(successMsg);
        } else {
          showToast("⚠️ Copy failed - please select manually");
        }
      } catch (err) {
        showToast("⚠️ Copy failed - please select manually");
      }
      
      document.body.removeChild(textarea);
    }

    // ============ TOAST ============
    function showToast(msg) {
      const toast = document.getElementById('toast');
      toast.textContent = msg;
      toast.classList.remove('hidden');
      toast.classList.add('toast-animate');
      
      setTimeout(() => {
        toast.classList.add('hidden');
        toast.classList.remove('toast-animate');
      }, 2800);
    }

    // ============ ANALYZER ============
    function analyzePrompt() {
      const input = document.getElementById('analyzeInput').value.trim();
      if (!input) {
        showToast("Paste a prompt first");
        return;
      }

      setTimeout(() => {
        let score = 100;
        let faceFidelity = 100;
        const issues = [];
        const missingProtections = [];
        const lower = input.toLowerCase();

        // EFCP keywords for face fidelity
        const efcpKeywords = ['efcp', 'face composite', 'cut-and-paste', 'biometric', 'identity lock', 'reference image', 'face stamp'];
        const biometricTerms = ['jawline', 'cheek', 'nose', 'lip', 'eye shape', 'facial structure', 'skin tone', 'glasses'];
        
        efcpKeywords.forEach(kw => {
          if (!lower.includes(kw.toLowerCase())) {
            faceFidelity -= 12;
          }
        });
        
        biometricTerms.forEach(term => {
          if (!lower.includes(term.toLowerCase())) {
            faceFidelity -= 6;
          }
        });

        if (!/(photorealistic|real photograph)/i.test(input)) {
          score -= 20;
          issues.push("Add stronger photorealism keywords");
        }

        if (!/negative prompt/i.test(input)) {
          score -= 20;
          issues.push("Include a Negative Prompt - protects face identity");
          missingProtections.push({ name: 'Negative Prompt', text: 'NEGATIVE PROMPT: (neckband, headphones), facial slimming, V-shaped jaw, sharpened chin, thin nose, narrowed eyes, wire-rimmed glasses, rounded glasses, plastic skin, AI art style, 3D render, beautification filter, changed identity, skinny face, cartoon, CGI, illustration, over sharpened, extra fingers, distorted face' });
        }

        if (input.length < 180) {
          score -= 15;
          issues.push("Prompt is too short - add more scene, lighting and identity detail");
        }

        if (!/(identity|face structure|reference image)/i.test(input)) {
          score -= 20;
          missingProtections.push({ name: 'EFCP 200%', text: efcpUltra });
        }

        if (!/lighting/i.test(input)) {
          score -= 10;
          issues.push("No lighting specification - define lighting for realism");
        }

        if (!/(camera|lens|aperture|dslr|mirrorless)/i.test(input)) {
          score -= 10;
          issues.push("No camera/lens detail - specify for photorealistic output");
        }

        if (!/(distorted face|symmetry|skin smoothing)/i.test(input)) {
          score -= 5;
          issues.push("Add negative face-distortion terms");
        }

        if (!/(body structure|shoulder|posture)/i.test(input)) {
          faceFidelity -= 10;
          missingProtections.push({ name: 'Body Structure', text: 'BODY STRUCTURE CONSISTENCY: Preserve exact body shape, shoulder width, and posture from reference image. Maintain body proportions and muscle tone. Do not slim, elongate, or morph the torso.' });
        }

        if (!/(background|real-world|photographic)/i.test(input)) {
          faceFidelity -= 8;
          missingProtections.push({ name: 'Background Realism', text: 'REAL-WORLD BACKGROUND REALISM: Use photographic real-world environments (not AI-generated backgrounds). Include natural depth, authentic settings.' });
        }

        if (!/(depth of field|bokeh|perspective)/i.test(input)) {
          faceFidelity -= 8;
          missingProtections.push({ name: 'Photographic Depth', text: 'PHOTOGRAPHIC DEPTH: DSLR-style shallow depth of field with natural bokeh. Realistic perspective falloff. Soft out-of-focus background with authentic optical bokeh.' });
        }

        score = Math.max(0, score);
        faceFidelity = Math.max(0, faceFidelity);

        const badge = document.getElementById('scoreBadge');
        badge.textContent = `${score} / 100`;
        
        if (score >= 80) {
          badge.className = "text-3xl font-bold text-center py-4 rounded-xl bg-green-500/20 text-green-400";
        } else if (score >= 50) {
          badge.className = "text-3xl font-bold text-center py-4 rounded-xl bg-yellow-500/20 text-yellow-400";
        } else {
          badge.className = "text-3xl font-bold text-center py-4 rounded-xl bg-red-500/20 text-red-400";
        }

        const faceBadge = document.getElementById('faceFidelityBadge');
        faceBadge.textContent = `${faceFidelity} / 100`;
        
        if (faceFidelity >= 80) {
          faceBadge.className = "text-3xl font-bold text-center py-4 rounded-xl bg-green-500/20 text-green-400";
        } else if (faceFidelity >= 50) {
          faceBadge.className = "text-3xl font-bold text-center py-4 rounded-xl bg-yellow-500/20 text-yellow-400";
        } else {
          faceBadge.className = "text-3xl font-bold text-center py-4 rounded-xl bg-red-500/20 text-red-400";
        }

        // Show missing protections
        const missingDiv = document.getElementById('missingProtections');
        const missingList = document.getElementById('missingList');
        if (missingProtections.length > 0) {
          missingDiv.classList.remove('hidden');
          missingList.innerHTML = missingProtections.map(m => `
            <div class="flex items-center justify-between gap-2">
              <span class="text-sm">${m.name}</span>
              <button onclick="addMissingProtection('${m.text.replace(/'/g, "\\'")}')" class="clay-tab text-xs px-2 py-1">Add</button>
            </div>
          `).join('');
        } else {
          missingDiv.classList.add('hidden');
        }

        const issuesList = document.getElementById('issuesList');
        if (issues.length === 0) {
          issuesList.innerHTML = '<li class="text-green-400">✅ Excellent prompt! All checks passed.</li>';
        } else {
          issuesList.innerHTML = issues.map(i => `<li class="text-red-300 text-sm">• ${i}</li>`).join('');
        }

        document.getElementById('analyzeResult').classList.remove('hidden');
      }, 600);
    }

    function addMissingProtection(text) {
      const input = document.getElementById('analyzeInput');
      input.value += '\n\n' + text;
      showToast('✅ Protection added!');
    }

    // ============ ENHANCER ============
    function enhancePrompt() {
      const input = document.getElementById('enhanceInput').value.trim();
      if (!input) {
        showToast("Paste a prompt to enhance");
        return;
      }

      setTimeout(() => {
        let enhanced = input;

        if (document.getElementById('roleChk').checked && !/\byou are\b|\bact as\b/i.test(enhanced)) {
          enhanced = "You are a professional Tamil Nadu portrait photographer.\n\n" + enhanced;
        }

        if (document.getElementById('cot').checked) {
          enhanced += "\n\nThink step by step about lighting and realism.";
        }

        if (document.getElementById('format').checked) {
          enhanced += "\n\n--style raw --v 6 --q 2";
        }

        if (document.getElementById('examples').checked) {
          enhanced += "\n\nInclude natural skin texture and real lighting.";
        }

        // Reinforce EFCP 200%
        if (document.getElementById('reinforceEFCP').checked) {
          enhanced = efcpUltra + '\n\n' + enhanced;
        }

        // Model-Tuned Booster
        if (document.getElementById('modelTuned').checked) {
          const model = document.getElementById('modelBoosterSelect').value;
          let booster = '';
          if (model === 'chatgpt') {
            booster = '\n\n[CHATGPT OPTIMIZED] RAW composite only. Paste reference face 1:1. No inpainting, no refinement.';
          } else if (model === 'gemini') {
            booster = '\n\n[GEMINI OPTIMIZED] Biometric Lock v2 — disable all face enhancement, use reference as hard mask.';
          } else {
            booster = '\n\n[GENERAL OPTIMIZED] Maximum identity consistency mode. Zero facial morphing.';
          }
          enhanced += booster;
        }

        // Maximize Negative Prompt
        if (document.getElementById('maximizeNegative').checked) {
          const maxNegative = '\n\nMAXIMIZED NEGATIVE PROMPT: (neckband, headphones, wires around neck), facial slimming, V-shaped jaw, sharpened chin, thin nose, narrowed eyes, wire-rimmed glasses, rounded glasses, plastic skin, AI art style, 3D render, beautification filter, lightened skin tone, changed identity, skinny face, cartoon, CGI, illustration, painting, over sharpened, over saturated, HDR effect, fake lighting, unrealistic shadows, extra fingers, distorted face, symmetry errors, unnatural skin smoothing, beauty filter, different person, face swap, AI-generated background, digital blur, gaussian blur, bokeh effect (artificial),过度锐化, 整形, 假皮肤';
          enhanced += maxNegative;
        }

        document.getElementById('enhanceOutput').textContent = enhanced;
        document.getElementById('enhanceResult').classList.remove('hidden');
      }, 600);
    }

    // ============ THEME MODAL ============
    function showThemeModal() {
      const container = document.getElementById('themeOptions');
      container.innerHTML = '';
      
      const style = getComputedStyle(document.body);
      const bgColor = style.getPropertyValue('--clay').trim();
      const textColor = style.getPropertyValue('--input-text').trim();
      const borderColor = style.getPropertyValue('--border-subtle').trim();
      
      themes.forEach(theme => {
        const card = document.createElement('button');
        card.className = 'w-full text-left p-4 rounded-xl transition-all hover:scale-[1.02]';
        card.style.background = 'rgba(255, 255, 255, 0.30)';
        card.style.backdropFilter = 'blur(20px) saturate(180%)';
        card.style.webkitBackdropFilter = 'blur(20px) saturate(180%)';
        card.style.color = textColor;
        card.style.border = '1px solid rgba(255, 255, 255, 0.2)';
        card.style.boxShadow = '0 8px 32px rgba(0, 0, 0, 0.3)';
        card.innerHTML = `
          <div class="font-semibold">${theme.name}</div>
          <div class="text-sm opacity-70">${theme.desc}</div>
        `;
        card.onclick = () => {
          document.body.dataset.theme = theme.id;
          localStorage.setItem('tamilreal_theme', theme.id);
          hideThemeModal();
        };
        container.appendChild(card);
      });
      
      document.getElementById('themeModal').classList.remove('hidden');
    }

    function hideThemeModal() {
      document.getElementById('themeModal').classList.add('hidden');
    }

    // ============ SAVED PROMPTS ============
    function saveCurrentPrompt() {
      const name = prompt("Enter a name for this prompt:");
      if (!name) return;
      
      const prompts = JSON.parse(localStorage.getItem('tamilreal_prompts') || '[]');
      
      if (prompts.length >= 50) {
        prompts.shift();
        showToast("Oldest prompt removed - limit reached");
      }

      // Auto-generate tags
      const model = document.getElementById('modelSelect').value;
      const tags = [model.toUpperCase(), 'EFCP-200%'];
      
      // Add variant tag if used
      if (currentPrompt.includes('[CHATGPT OPTIMIZED]')) tags.push('ChatGPT');
      if (currentPrompt.includes('[GEMINI OPTIMIZED]')) tags.push('Gemini');
      if (currentPrompt.includes('[GENERAL OPTIMIZED]')) tags.push('General');
      
      prompts.push({
        id: Date.now(),
        name: name,
        content: currentPrompt,
        tags: tags.join(', '),
        savedAt: new Date().toISOString()
      });
      
      localStorage.setItem('tamilreal_prompts', JSON.stringify(prompts));
      showToast(`✅ Saved as "${name}" with tags: ${tags.join(', ')}`);
    }

    function loadSavedPrompts() {
      const panel = document.getElementById('libraryPanel');
      const container = document.getElementById('savedPromptsList');
      const search = document.getElementById('librarySearch').value.toLowerCase();
      const tagFilter = document.getElementById('tagFilter').value;
      
      panel.classList.remove('hidden');
      
      const prompts = JSON.parse(localStorage.getItem('tamilreal_prompts') || '[]');
      let filtered = prompts.filter(p => p.name.toLowerCase().includes(search));
      
      if (tagFilter) {
        filtered = filtered.filter(p => p.tags && p.tags.toLowerCase().includes(tagFilter.toLowerCase()));
      }
      
      if (filtered.length === 0) {
        container.innerHTML = '<p class="text-sm opacity-70">No saved prompts yet. Generate a prompt and hit Save.</p>';
        return;
      }
      
      container.innerHTML = filtered.map(p => `
        <div class="bg-black/20 rounded-lg p-3">
          <div class="flex justify-between items-start mb-2">
            <span class="font-medium">${p.name}</span>
            <span class="text-xs opacity-60">${new Date(p.savedAt).toLocaleDateString()}</span>
          </div>
          <div class="flex gap-1 mb-2 flex-wrap">
            ${p.tags ? p.tags.split(', ').map(t => `<span class="text-xs bg-[#d9775a]/30 px-2 py-0.5 rounded">${t}</span>`).join('') : ''}
          </div>
          <p class="text-xs opacity-70 mb-2 line-clamp-2">${p.content.substring(0, 120)}...</p>
          <div class="flex gap-2">
            <button onclick="loadPrompt(${p.id})" class="clay-btn text-xs py-1 px-3">Load</button>
            <button onclick="deletePrompt(${p.id})" class="clay-tab text-xs py-1 px-3">Delete</button>
          </div>
        </div>
      `).join('');
    }

    function loadPrompt(id) {
      const prompts = JSON.parse(localStorage.getItem('tamilreal_prompts') || '[]');
      const prompt = prompts.find(p => p.id === id);
      if (prompt) {
        currentPrompt = prompt.content;
        showResult();
        showToast(`Loaded "${prompt.name}"`);
      }
    }

    function deletePrompt(id) {
      let prompts = JSON.parse(localStorage.getItem('tamilreal_prompts') || '[]');
      prompts = prompts.filter(p => p.id !== id);
      localStorage.setItem('tamilreal_prompts', JSON.stringify(prompts));
      loadSavedPrompts();
      showToast("Prompt deleted");
    }

    // ============ INIT ============
    window.onload = function() {
      populateDropdowns();
      loadApiKeys();
      switchTab(0);
      
      const savedTheme = localStorage.getItem('tamilreal_theme') || 'clay';
      document.body.dataset.theme = savedTheme;
    };
  </script>
</body>
</html>