Spaces:
Running
Running
File size: 126,463 Bytes
e907501 d5bbe89 e907501 d5bbe89 e0cd34e e907501 aee5f84 e907501 105015c d5bbe89 105015c e907501 edeb4db 105015c aee5f84 a5ac3fa d5bbe89 e907501 105015c d5bbe89 e907501 aee5f84 d5bbe89 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa d5bbe89 aee5f84 a5ac3fa aee5f84 d5bbe89 a5ac3fa d5bbe89 aee5f84 edeb4db e907501 105015c edeb4db a5ac3fa e907501 a5ac3fa aee5f84 105015c a5ac3fa e907501 aee5f84 a5ac3fa aee5f84 d5bbe89 a5ac3fa d5bbe89 7a1ea71 e907501 aee5f84 a5ac3fa e907501 d5bbe89 7a1ea71 aee5f84 a5ac3fa aee5f84 7a1ea71 d5bbe89 edeb4db a5ac3fa e907501 a5ac3fa edeb4db d5bbe89 a5ac3fa d5bbe89 aee5f84 edeb4db a5ac3fa edeb4db a5ac3fa edeb4db 7a1ea71 aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 d5bbe89 aee5f84 edeb4db a5ac3fa e907501 edeb4db d5bbe89 edeb4db d5bbe89 7a1ea71 aee5f84 a5ac3fa aee5f84 d5bbe89 7a1ea71 d5bbe89 a5ac3fa d5bbe89 a5ac3fa aee5f84 a5ac3fa d5bbe89 aee5f84 a5ac3fa aee5f84 a5ac3fa d5bbe89 a5ac3fa d5bbe89 7a1ea71 a5ac3fa bf4cd90 edeb4db aee5f84 a5ac3fa aee5f84 edeb4db a5ac3fa e907501 a5ac3fa aee5f84 bf4cd90 aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 edeb4db e907501 edeb4db d5bbe89 7a1ea71 aee5f84 a5ac3fa aee5f84 bf4cd90 44a7073 a5ac3fa aee5f84 a5ac3fa bf4cd90 aee5f84 bf4cd90 aee5f84 bf4cd90 aee5f84 bf4cd90 aee5f84 d9f53ae a5ac3fa aee5f84 bf4cd90 aee5f84 a5ac3fa bf4cd90 aee5f84 a5ac3fa aee5f84 bf4cd90 aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 d5bbe89 aee5f84 bf4cd90 a5ac3fa aee5f84 a5ac3fa aee5f84 bf4cd90 d5bbe89 bf4cd90 aee5f84 bf4cd90 aee5f84 d5bbe89 aee5f84 d5bbe89 a5ac3fa bf4cd90 a5ac3fa bf4cd90 a5ac3fa bf4cd90 a5ac3fa bf4cd90 a5ac3fa bf4cd90 a5ac3fa bf4cd90 a5ac3fa bf4cd90 a5ac3fa bf4cd90 a5ac3fa 7a1ea71 d5bbe89 aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa d5bbe89 a5ac3fa aee5f84 a5ac3fa d5bbe89 aee5f84 d5bbe89 a5ac3fa aee5f84 a5ac3fa aee5f84 d5bbe89 7a1ea71 aee5f84 a5ac3fa aee5f84 d5bbe89 aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 d5bbe89 aee5f84 d5bbe89 a5ac3fa aee5f84 d5bbe89 aee5f84 a5ac3fa aee5f84 d5bbe89 a5ac3fa d5bbe89 aee5f84 a5ac3fa aee5f84 d5bbe89 7a1ea71 aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa bf4cd90 aee5f84 bf4cd90 aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 edeb4db aee5f84 bf4cd90 aee5f84 a5ac3fa aee5f84 7a1ea71 aee5f84 a5ac3fa aee5f84 d5bbe89 edeb4db 7a1ea71 aee5f84 a5ac3fa aee5f84 d5bbe89 7a1ea71 aee5f84 a5ac3fa aee5f84 d5bbe89 7a1ea71 aee5f84 a5ac3fa bf4cd90 aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 edeb4db a5ac3fa d5bbe89 aee5f84 d5bbe89 aee5f84 a5ac3fa d5bbe89 aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 d5bbe89 aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 d5bbe89 aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 d5bbe89 aee5f84 a5ac3fa aee5f84 d5bbe89 aee5f84 a5ac3fa aee5f84 edeb4db aee5f84 7a1ea71 aee5f84 a5ac3fa edeb4db aee5f84 d5bbe89 edeb4db 7a1ea71 d5bbe89 aee5f84 a5ac3fa aee5f84 d5bbe89 aee5f84 a5ac3fa aee5f84 7a1ea71 a5ac3fa aee5f84 a5ac3fa aee5f84 d5bbe89 aee5f84 edeb4db 7a1ea71 aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa bf4cd90 aee5f84 bf4cd90 aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa d5bbe89 7a1ea71 aee5f84 a5ac3fa aee5f84 d5bbe89 edeb4db a5ac3fa aee5f84 a5ac3fa aee5f84 7a1ea71 aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 d5bbe89 aee5f84 a5ac3fa aee5f84 d5bbe89 a5ac3fa aee5f84 a5ac3fa aee5f84 d5bbe89 aee5f84 a5ac3fa aee5f84 d5bbe89 aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 d5bbe89 aee5f84 a5ac3fa aee5f84 d5bbe89 aee5f84 a5ac3fa aee5f84 d5bbe89 aee5f84 a5ac3fa aee5f84 d5bbe89 aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 d5bbe89 edeb4db aee5f84 edeb4db d5bbe89 aee5f84 e907501 d5bbe89 aee5f84 a5ac3fa aee5f84 d5bbe89 e907501 d5bbe89 aee5f84 e907501 d5bbe89 e907501 e0cd34e e907501 edeb4db e907501 d5bbe89 aee5f84 edeb4db d5bbe89 aee5f84 edeb4db d5bbe89 aee5f84 d5bbe89 aee5f84 d5bbe89 aee5f84 d5bbe89 105015c d5bbe89 edeb4db aee5f84 d5bbe89 a5ac3fa aee5f84 e907501 d5bbe89 545bc85 e907501 aee5f84 d5bbe89 e907501 d5bbe89 7a1ea71 105015c d5bbe89 e907501 d5bbe89 e907501 d5bbe89 aee5f84 e907501 d5bbe89 e907501 d5bbe89 e907501 d5bbe89 aee5f84 d5bbe89 aee5f84 d5bbe89 aee5f84 d5bbe89 e907501 aee5f84 d5bbe89 e907501 7a1ea71 aee5f84 e907501 d5bbe89 aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa bf4cd90 aee5f84 bf4cd90 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 edeb4db aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 bf4cd90 aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 bf4cd90 aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa bf4cd90 a5ac3fa bf4cd90 a5ac3fa bf4cd90 a5ac3fa bf4cd90 a5ac3fa bf4cd90 a5ac3fa bf4cd90 a5ac3fa bf4cd90 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 e907501 aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 105015c aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 e907501 aee5f84 bf4cd90 aee5f84 a5ac3fa bf4cd90 e6b729c bf4cd90 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa d5bbe89 aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa bf4cd90 a5ac3fa bf4cd90 e907501 aee5f84 bf4cd90 aee5f84 a5ac3fa bf4cd90 aee5f84 bf4cd90 d5bbe89 a5ac3fa bf4cd90 aee5f84 bf4cd90 cf1d8e7 a5ac3fa bf4cd90 a5ac3fa bf4cd90 a5ac3fa bf4cd90 a5ac3fa bf4cd90 a5ac3fa bf4cd90 a5ac3fa bf4cd90 a5ac3fa bf4cd90 a5ac3fa bf4cd90 a5ac3fa bf4cd90 a5ac3fa bf4cd90 a5ac3fa bf4cd90 a5ac3fa bf4cd90 a5ac3fa bf4cd90 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 d5bbe89 aee5f84 bf4cd90 aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa d5bbe89 aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 bf4cd90 aee5f84 a5ac3fa aee5f84 bf4cd90 aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa bf4cd90 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 bf4cd90 a5ac3fa aee5f84 a5ac3fa bf4cd90 d5bbe89 aee5f84 a5ac3fa bf4cd90 aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 bf4cd90 aee5f84 bf4cd90 aee5f84 bf4cd90 aee5f84 a5ac3fa aee5f84 bf4cd90 a5ac3fa bf4cd90 aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa bf4cd90 aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 d9f53ae aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa d9f53ae aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa bf4cd90 aee5f84 a5ac3fa d9f53ae aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 bf4cd90 a5ac3fa bf4cd90 aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa bf4cd90 a5ac3fa bf4cd90 a5ac3fa aee5f84 a5ac3fa bf4cd90 aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 bf4cd90 a5ac3fa bf4cd90 aee5f84 a5ac3fa bf4cd90 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa bf4cd90 aee5f84 a5ac3fa bf4cd90 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa bf4cd90 a5ac3fa bf4cd90 aee5f84 bf4cd90 aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa aee5f84 a5ac3fa bf4cd90 aee5f84 d5bbe89 e907501 bf4cd90 | 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 | <!DOCTYPE html>
<html lang="en" data-density="comfortable">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="theme-color" content="#08101a" />
<link rel="icon" type="image/png" href="/templates/logo.png" />
<title>{{ app_title }}</title>
<style>
/* ββ Design Tokens ββ */
:root {
--bg: #08101a;
--panel: rgba(15, 22, 34, .94);
--panel2: rgba(20, 29, 44, .96);
--border: rgba(148, 163, 184, .14);
--border2: rgba(148, 163, 184, .2);
--text: #eef3f9;
--muted: #a4b3c7;
--accent: #7ca6ff;
--accent2: #4fd1c5;
--good: #2dd4bf;
--bad: #f87171;
--warn: #fbbf24;
--shadow: 0 18px 44px rgba(0,0,0,.34);
--shadow-soft: 0 8px 26px rgba(0,0,0,.2);
--radius-xs: 4px;
--radius-sm: 8px;
--radius-md: 12px;
--radius-lg: 16px;
--radius-xl: 22px;
--radius-pill: 999px;
--space-1: 4px; --space-2: 8px; --space-3: 12px;
--space-4: 16px; --space-6: 24px; --space-8: 32px;
--ease-out: cubic-bezier(.22,.61,.36,1);
--ease-in-out: cubic-bezier(.4,0,.2,1);
--ease-spring: cubic-bezier(.34,1.56,.64,1);
--mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
--font: "Segoe UI Variable Text", "Segoe UI", Aptos, system-ui, -apple-system, sans-serif;
--bubble-padding: 10px 14px;
--turn-gap: 6px;
--font-size-base: 14px;
}
/* ββ Light Mode ββ */
@media (prefers-color-scheme: light) {
:root {
--bg: #f8f9fc; --panel: rgba(255,255,255,.96);
--panel2: rgba(245,247,252,.98);
--border: rgba(30,40,80,.1); --border2: rgba(30,40,80,.16);
--text: #1a1d26; --muted: #5a6374;
--accent: #3b6fd4; --accent2: #0d9488;
--good: #0d9488; --bad: #dc2626; --warn: #d97706;
--shadow: 0 18px 44px rgba(0,0,0,.1);
--shadow-soft: 0 8px 26px rgba(0,0,0,.07);
}
html, body { background: radial-gradient(ellipse at top center, #e8edf8 0%, var(--bg) 50%); }
body::before { opacity: .06; }
#topbar { background: rgba(248,249,252,.88); }
.compose { background: rgba(248,249,252,.92); }
}
/* ββ Density Variants ββ */
[data-density="compact"] { --bubble-padding: 6px 10px; --turn-gap: 3px; --font-size-base: 13px; }
[data-density="spacious"] { --bubble-padding: 14px 18px; --turn-gap: 10px; --font-size-base: 15px; }
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
width: 100%; height: var(--app-height, 100%);
background: radial-gradient(ellipse at top center, #161c2b 0%, var(--bg) 50%);
color: var(--text); font-family: var(--font);
overflow: hidden; -webkit-font-smoothing: antialiased; overscroll-behavior: none;
}
body::before {
content: ""; position: fixed; inset: 0;
background-image:
linear-gradient(rgba(124,166,255,.025) 1px, transparent 1px),
linear-gradient(90deg, rgba(124,166,255,.025) 1px, transparent 1px);
background-size: 56px 56px; pointer-events: none; opacity: .25; will-change: transform;
}
#app {
position: relative; z-index: 1; height: var(--app-height, 100%);
display: flex; flex-direction: column; min-height: 0;
}
.skip-link {
position: absolute; top: -100px; left: var(--space-4);
background: var(--panel); color: var(--text);
padding: var(--space-2) var(--space-4); border-radius: var(--radius-md);
z-index: 300; font-size: 13px; font-weight: 600;
border: 1px solid var(--border2); text-decoration: none;
transition: top 150ms var(--ease-out);
}
.skip-link:focus { top: var(--space-2); }
/* ββ Topbar ββ */
#topbar {
height: 56px; padding: 0 var(--space-4);
display: flex; align-items: center; justify-content: space-between;
border-bottom: 1px solid var(--border);
backdrop-filter: blur(20px) saturate(180%);
background: rgba(11,14,20,.78); flex-shrink: 0; position: relative; z-index: 10;
}
@media (max-height: 500px) { #topbar { height: 42px; } }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo {
width: 30px; height: 30px; border-radius: 10px; display: block; object-fit: cover;
box-shadow: 0 6px 18px rgba(108,131,255,.25); border: 1px solid rgba(255,255,255,.08); flex: 0 0 auto;
}
.brand-title { font-weight: 700; letter-spacing: -.03em; font-size: 15px; }
.brand-sub { color: var(--muted); font-size: 11px; font-family: var(--mono); margin-left: 2px; }
.top-actions { display: flex; align-items: center; gap: var(--space-1); position: relative; }
.top-btn {
border: 1px solid var(--border2); background: rgba(255,255,255,.03); color: var(--muted);
border-radius: var(--radius-md); padding: 6px 12px; font: inherit; font-size: 12px;
cursor: pointer; transition: border-color 180ms var(--ease-out), color 180ms var(--ease-out), background 180ms var(--ease-out), transform 180ms var(--ease-out);
display: flex; align-items: center; gap: 5px; position: relative;
}
.top-btn:hover { border-color: rgba(108,131,255,.35); color: var(--text); background: rgba(108,131,255,.06); }
.top-btn svg { width: 14px; height: 14px; }
.top-btn[aria-label]::after {
content: attr(aria-label); position: absolute; top: calc(100% + 6px); right: 0;
background: var(--panel2); border: 1px solid var(--border2); border-radius: var(--radius-sm);
padding: 4px 8px; font-size: 11px; color: var(--text); white-space: nowrap;
opacity: 0; pointer-events: none; transition: opacity 150ms var(--ease-out); z-index: 50;
}
.top-btn[aria-label]:hover::after { opacity: 1; }
/* ββ Status bar ββ */
#statusbar {
height: 0; overflow: hidden; transition: height 220ms var(--ease-out), opacity 220ms var(--ease-out);
opacity: 0; border-bottom: 1px solid transparent; background: rgba(11,14,20,.6);
display: flex; align-items: center; justify-content: center;
font-size: 12px; font-family: var(--mono); color: var(--muted); flex-shrink: 0;
}
#statusbar.visible { height: 32px; opacity: 1; border-bottom-color: var(--border); }
#statusbar .status-dot {
width: 6px; height: 6px; border-radius: 50%; margin-right: var(--space-2);
display: inline-block; background: var(--accent); animation: pulse-dot 1.2s ease infinite;
}
@keyframes pulse-dot { 0%, 100% { opacity: .4; transform: scale(.85); } 50% { opacity: 1; transform: scale(1.1); } }
#scrollProgress {
position: fixed !important; top: 0; left: 0; height: 3px; width: 0%;
background: linear-gradient(90deg, var(--accent), var(--accent2));
transition: width 100ms ease; z-index: 9999; pointer-events: none; transform-origin: left center;
}
/* ββ Chat area ββ */
#chat {
flex: 1; min-height: 0; overflow-y: auto; padding: 20px 14px 24px;
scroll-behavior: auto; overscroll-behavior-y: contain;
-webkit-overflow-scrolling: touch; overflow-anchor: auto;
scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.1) transparent;
}
#chat::-webkit-scrollbar { width: 5px; }
#chat::-webkit-scrollbar-track { background: transparent; }
#chat::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: var(--radius-pill); }
.wrap { max-width: 760px; margin: 0 auto; }
/* ββ Welcome ββ */
.welcome {
margin: 6vh auto 0; max-width: 480px; text-align: center;
padding: var(--space-6) 20px; border: 1px solid var(--border);
border-radius: var(--radius-xl); background: rgba(255,255,255,.025);
box-shadow: var(--shadow); animation: fadeUp 400ms var(--ease-out) both;
}
@media (max-height: 500px) { .welcome { margin-top: 1vh; padding: var(--space-3); } }
.welcome h1 { font-size: 22px; font-weight: 700; letter-spacing: -.03em; line-height: 1.3; }
.welcome p { color: var(--muted); line-height: 1.6; margin-top: var(--space-2); font-size: 13px; }
.welcome-suggestions { display: flex; flex-wrap: wrap; gap: var(--space-2); justify-content: center; margin-top: var(--space-4); }
.suggestion-chip {
border: 1px solid var(--border2); background: rgba(255,255,255,.03);
border-radius: var(--radius-pill); padding: 6px 14px; font: inherit; font-size: 12px;
color: var(--muted); cursor: pointer;
transition: border-color 160ms var(--ease-out), color 160ms var(--ease-out), background 160ms var(--ease-out);
text-align: left;
}
.suggestion-chip:hover { border-color: rgba(108,131,255,.35); color: var(--text); background: rgba(108,131,255,.05); }
@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
/* ββ Skeleton ββ */
.skeleton-wrap { padding: 20px 0; }
.skeleton {
background: linear-gradient(90deg, rgba(255,255,255,.03) 0%, rgba(255,255,255,.07) 50%, rgba(255,255,255,.03) 100%);
background-size: 200% 100%; animation: skeleton-shimmer 1.5s ease infinite; border-radius: var(--radius-md);
}
@keyframes skeleton-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.skeleton-line { height: 14px; margin-bottom: 8px; }
.skeleton-line.short { width: 40%; } .skeleton-line.medium { width: 70%; } .skeleton-line.long { width: 95%; }
.skeleton-bubble { height: 80px; border-radius: var(--radius-lg); margin-bottom: 12px; }
/* ββ Turns ββ */
.turn { display: flex; gap: 10px; margin-bottom: var(--turn-gap); align-items: flex-start; }
.turn.new-turn { animation: fadeUp 380ms var(--ease-out) both; }
.turn.user { justify-content: flex-end; }
.avatar {
width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
font-size: 12px; flex: 0 0 auto; transition: transform 200ms var(--ease-spring);
}
.avatar:hover { transform: scale(1.1); }
.avatar.user { background: linear-gradient(135deg, #1f2b63, #2d1d58); border: 1px solid rgba(108,131,255,.2); }
.avatar.assistant { background: linear-gradient(135deg, #163d34, #183c54); border: 1px solid rgba(45,212,191,.2); }
.bubble {
max-width: min(620px, calc(100vw - 100px)); border: 1px solid var(--border);
border-radius: var(--radius-lg); padding: var(--bubble-padding);
line-height: 1.6; font-size: var(--font-size-base);
background: rgba(255,255,255,.03);
}
.turn.assistant .bubble { border-radius: var(--radius-xs) var(--radius-lg) var(--radius-lg) var(--radius-lg); }
.turn.user .bubble {
background: linear-gradient(135deg, rgba(108,131,255,.15), rgba(161,110,255,.12));
border-color: rgba(108,131,255,.2);
border-radius: var(--radius-lg) var(--radius-lg) var(--radius-xs) var(--radius-lg);
}
.turn-meta {
margin-top: var(--space-1); font-size: 10px; color: var(--muted);
font-family: var(--mono); display: flex; gap: 6px; align-items: center; flex-wrap: wrap;
}
.chip {
border: 1px solid var(--border); border-radius: var(--radius-pill);
padding: 2px 7px; font-size: 11px; letter-spacing: .03em;
display: inline-flex; align-items: center; gap: 3px;
}
.chip.good { color: var(--good); border-color: rgba(45,212,191,.25); }
.chip.muted { color: var(--muted); }
.chip.warn { color: var(--warn); border-color: rgba(251,191,36,.25); }
.chip.matched { color: var(--accent); border-color: rgba(108,131,255,.25); }
/* ββ Best answer ββ */
.best-answer-bubble {
border: 1px solid rgba(45,212,191,.15);
border-radius: var(--radius-xs) var(--radius-lg) var(--radius-lg) var(--radius-lg);
padding: var(--bubble-padding); background: rgba(45,212,191,.04);
line-height: 1.6; font-size: var(--font-size-base);
outline: none;
}
.best-answer-meta { margin-top: var(--space-1); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
/* ββ Shared Markdown Elements ββ */
.md-body { white-space: normal; word-break: break-word; overflow-wrap: anywhere; }
.md-body p { margin: 3px 0; white-space: normal; }
.md-body h1, .md-body h2, .md-body h3, .md-body h4, .md-body h5, .md-body h6 {
line-height: 1.3; margin: 8px 0 3px; white-space: normal;
}
.md-body h1 { font-size: 1.35em; font-weight: 800; }
.md-body h2 { font-size: 1.2em; font-weight: 700; }
.md-body h3 { font-size: 1.05em; font-weight: 700; color: var(--accent); }
.md-body h4 { font-size: .95em; font-weight: 700; }
.md-body h5, .md-body h6 { font-size: .88em; font-weight: 700; }
.md-body ul, .md-body ol { margin: 3px 0 3px 18px; padding: 0; white-space: normal; }
.md-body li { margin: 1px 0; white-space: normal; }
.task-item { list-style: none; margin-left: -18px; }
.task-item input[type="checkbox"] { accent-color: var(--accent2); margin-right: 6px; pointer-events: none; cursor: default; }
.md-body code {
font-family: var(--mono); font-size: .87em;
background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.1);
border-radius: var(--radius-xs); padding: 1px 5px;
}
.code-block-wrapper { position: relative; margin: 6px 0; }
.md-body pre {
background: rgba(0,0,0,.38); border: 1px solid var(--border);
border-radius: var(--radius-sm); padding: 10px 12px;
overflow-x: auto; white-space: pre; font-family: var(--mono);
font-size: .84em; line-height: 1.5; margin: 0;
}
.md-body pre code {
background: none; border: none; padding: 0; font-size: inherit;
}
.code-lang-label {
position: absolute; top: 5px; left: 6px;
background: rgba(255,255,255,.06);
border-radius: 0 0 var(--radius-xs) var(--radius-xs);
padding: 2px 8px; font-size: 10px; color: var(--muted);
font-family: var(--mono); text-transform: uppercase; letter-spacing: .05em; pointer-events: none;
}
.copy-code-btn {
position: absolute; top: 6px; right: 6px;
border: 1px solid var(--border2); background: rgba(0,0,0,.3); color: var(--muted);
border-radius: var(--radius-xs); padding: 2px 7px;
font: inherit; font-size: 10px; font-family: var(--mono); cursor: pointer;
opacity: 0; transition: opacity 150ms var(--ease-out), color 150ms var(--ease-out), border-color 150ms var(--ease-out);
}
.code-block-wrapper:hover .copy-code-btn { opacity: 1; }
.copy-code-btn:hover { color: var(--text); border-color: rgba(108,131,255,.4); }
.copy-code-btn.copied { color: var(--good); border-color: rgba(45,212,191,.4); opacity: 1; }
.md-body blockquote {
border-left: 3px solid var(--accent); background: rgba(124,166,255,.04);
border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
margin: 6px 0; padding: 6px 12px; color: var(--muted); white-space: normal; font-style: italic;
}
.md-body hr { border: none; border-top: 1px solid var(--border2); margin: 8px 0; }
.md-body a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.md-body a[href^="http"]::after { content: " β"; font-size: .75em; opacity: .5; }
.md-body table { border-collapse: collapse; width: 100%; margin: 8px 0; font-size: 13px; white-space: normal; }
.md-body th, .md-body td { border: 1px solid var(--border2); padding: 6px 10px; text-align: left; }
.md-body th { background: rgba(255,255,255,.05); font-weight: 600; }
sup { font-size: .75em; vertical-align: super; line-height: 0; }
sub { font-size: .75em; vertical-align: sub; line-height: 0; }
.md-figure {
display: inline-flex; flex-direction: column; align-items: flex-start; gap: 6px;
margin: 8px 0; padding: 8px; max-width: min(100%, 520px);
border-radius: var(--radius-lg); border: 1px solid rgba(255,255,255,.08);
background: linear-gradient(180deg, rgba(255,255,255,.05), rgba(255,255,255,.02));
box-shadow: var(--shadow-soft);
}
.md-img {
display: block; max-width: 100%; max-height: 480px;
width: clamp(220px, 38vw, 420px); min-width: 0; height: auto;
border-radius: var(--radius-md); border: 1px solid var(--border);
background: rgba(0,0,0,.18); object-fit: contain; cursor: zoom-in;
transition: transform 180ms var(--ease-out), opacity 150ms ease, border-color 180ms var(--ease-out);
}
.md-img:hover { opacity: .94; transform: translateY(-1px); border-color: rgba(108,131,255,.28); }
.md-figcaption {
font-size: 11px; line-height: 1.45; color: var(--muted);
font-family: var(--mono);
}
p.md-gap { min-height: 0.35em; margin: 0 !important; padding: 0; }
.quality-dots { display: inline-flex; gap: 2px; align-items: center; margin-left: 4px; }
.quality-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--border2); }
.quality-dot.filled { background: var(--accent2); }
/* ββ Thinking Block ββ */
.thinking-dropdown { margin: 8px 0; border-radius: var(--radius-md); overflow: hidden; }
.thinking-summary {
display: flex; align-items: center; gap: 8px; padding: 8px 12px;
background: rgba(255,255,255,.04); border: 1px solid var(--border);
border-radius: var(--radius-md); cursor: pointer; user-select: none;
font-size: 12px; font-family: var(--mono); color: var(--muted);
transition: background 180ms var(--ease-out), border-color 180ms var(--ease-out), color 180ms var(--ease-out);
list-style: none;
}
.thinking-summary .thinking-label { flex: 1; min-width: 0; }
.thinking-summary:hover { background: rgba(255,255,255,.06); border-color: var(--border2); }
.thinking-summary::-webkit-details-marker { display: none; }
.thinking-summary .thinking-arrow {
display: inline-block; transition: transform 200ms var(--ease-out); font-size: 10px;
}
details.thinking-dropdown[open] .thinking-arrow { transform: rotate(90deg); }
.thinking-dropdown.is-live .thinking-summary {
color: var(--text); border-color: rgba(108,131,255,.22); background: rgba(108,131,255,.05);
}
.thinking-summary .thinking-spinner {
width: 12px; height: 12px; border: 2px solid var(--border2);
border-top-color: var(--accent); border-radius: 50%;
animation: spin-thinking .8s linear infinite;
}
@keyframes spin-thinking { to { transform: rotate(360deg); } }
.thinking-body {
display: grid; grid-template-rows: 1fr; overflow: hidden;
transition: grid-template-rows 300ms var(--ease-out), opacity 260ms var(--ease-out);
opacity: 1;
}
.thinking-dropdown:not([open]) .thinking-body {
grid-template-rows: 0fr; opacity: 0;
}
.thinking-content {
min-height: 0; padding: 10px 14px; font-size: 13px; line-height: 1.6;
color: var(--muted); border: 1px solid var(--border); border-top: none;
border-radius: 0 0 var(--radius-md) var(--radius-md);
background: rgba(255,255,255,.02); max-height: min(38vh, 420px);
overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin;
}
.thinking-dropdown.is-live .thinking-content { max-height: min(45vh, 560px); }
.thinking-content p { color: var(--muted); }
/* ββ Vote ββ */
.vote-row { display: flex; gap: var(--space-1); align-items: center; margin-top: 6px; flex-wrap: wrap; }
.vote-btn {
border: 1px solid var(--border2); background: rgba(255,255,255,.02); color: var(--muted);
border-radius: var(--radius-sm); padding: 4px 9px; font: inherit; font-size: 11px;
cursor: pointer; display: inline-flex; align-items: center; gap: 3px;
position: relative; overflow: hidden;
transition: border-color 160ms var(--ease-out), color 160ms var(--ease-out), background 160ms var(--ease-out), transform 160ms var(--ease-spring);
}
.vote-btn:hover { border-color: rgba(108,131,255,.35); color: var(--text); background: rgba(108,131,255,.07); }
.vote-btn.voted-up { border-color: rgba(45,212,191,.5); color: var(--good); background: rgba(45,212,191,.08); }
.vote-btn.voted-down { border-color: rgba(248,113,113,.5); color: var(--bad); background: rgba(248,113,113,.08); }
.vote-btn:active { transform: scale(.92); }
.vote-count { display: inline-block; overflow: hidden; height: 1.2em; position: relative; }
.vote-count-inner { display: block; transition: transform 300ms var(--ease-spring); }
.action-btn {
border: 1px solid var(--border2); background: rgba(255,255,255,.02); color: var(--muted);
border-radius: var(--radius-sm); padding: 4px 9px; font: inherit; font-size: 11px;
cursor: pointer; display: inline-flex; align-items: center; gap: 4px;
transition: border-color 160ms var(--ease-out), color 160ms var(--ease-out), background 160ms var(--ease-out);
}
.action-btn:hover { border-color: rgba(108,131,255,.35); color: var(--text); background: rgba(108,131,255,.05); }
/* ββ Write answer ββ */
.write-answer-btn {
border: 1px solid rgba(45,212,191,.3); background: rgba(45,212,191,.08); color: var(--good);
border-radius: var(--radius-md); padding: var(--space-2) 14px;
font: inherit; font-size: 12px; font-weight: 600; cursor: pointer;
display: inline-flex; align-items: center; gap: 6px; margin-top: var(--space-2);
transition: border-color 180ms var(--ease-out), color 180ms var(--ease-out), background 180ms var(--ease-out), transform 180ms var(--ease-spring);
}
.write-answer-btn:hover { background: rgba(45,212,191,.14); border-color: rgba(45,212,191,.5); }
.write-answer-btn svg { width: 14px; height: 14px; }
.write-panel {
max-height: 0; overflow: hidden; opacity: 0; margin-top: 0;
transition: max-height 300ms var(--ease-out), opacity 250ms var(--ease-out), margin 200ms var(--ease-out);
}
.write-panel.open { max-height: 400px; opacity: 1; margin-top: 10px; }
.write-tabs { display: flex; gap: 2px; margin-bottom: 6px; }
.write-tab {
border: 1px solid var(--border); border-bottom: none; background: transparent; color: var(--muted);
border-radius: var(--radius-sm) var(--radius-sm) 0 0; padding: 4px 12px;
font: inherit; font-size: 11px; cursor: pointer; transition: color 150ms, background 150ms, border-color 150ms;
}
.write-tab.active { border-color: var(--accent); color: var(--accent); background: rgba(108,131,255,.08); }
.write-textarea {
width: 100%; min-height: 80px; max-height: 160px; resize: vertical;
border: 1px solid var(--border2); border-radius: 0 var(--radius-md) var(--radius-md) var(--radius-md);
background: var(--panel); color: var(--text); font: inherit; font-size: 13px; line-height: 1.55;
padding: 10px 12px; outline: none;
transition: border-color 200ms var(--ease-out), height 100ms var(--ease-out);
}
.write-textarea:focus { border-color: rgba(45,212,191,.4); box-shadow: 0 0 0 3px rgba(45,212,191,.07); }
.write-textarea::placeholder { color: #5a6178; }
.write-preview {
min-height: 80px; max-height: 160px; overflow-y: auto;
border: 1px solid var(--border2); border-radius: 0 var(--radius-md) var(--radius-md) var(--radius-md);
background: var(--panel); padding: 10px 12px; font-size: 13px; line-height: 1.6; display: none;
}
.write-preview.active { display: block; }
.char-count { font-size: 10px; font-family: var(--mono); color: var(--muted); text-align: right; margin-top: 2px; }
.char-count.near-limit { color: var(--warn); }
.char-count.over-limit { color: var(--bad); }
.write-actions { display: flex; gap: 6px; margin-top: 6px; align-items: center; }
.write-submit {
border: 1px solid rgba(45,212,191,.4); background: rgba(45,212,191,.12); color: var(--good);
border-radius: var(--radius-sm); padding: 6px 14px; font: inherit; font-size: 12px; font-weight: 600;
cursor: pointer; transition: border-color 160ms, color 160ms, background 160ms;
}
.write-submit:hover { background: rgba(45,212,191,.2); border-color: rgba(45,212,191,.6); }
.write-submit:disabled { opacity: .4; cursor: not-allowed; }
.write-cancel {
border: 1px solid var(--border); background: transparent; color: var(--muted);
border-radius: var(--radius-sm); padding: 6px 12px; font: inherit; font-size: 12px;
cursor: pointer; transition: border-color 160ms, color 160ms;
}
.write-cancel:hover { border-color: var(--border2); color: var(--text); }
/* ββ Other answers ββ */
.other-answers-toggle {
margin-top: var(--space-2); border: 1px solid var(--border); background: rgba(255,255,255,.02);
color: var(--muted); border-radius: var(--radius-md); padding: 6px 12px;
font: inherit; font-size: 11px; cursor: pointer;
display: inline-flex; align-items: center; gap: 5px;
transition: border-color 180ms var(--ease-out), color 180ms var(--ease-out), background 180ms var(--ease-out);
}
.other-answers-toggle:hover { border-color: rgba(108,131,255,.3); color: var(--text); }
.other-answers-toggle .arrow, .related-toggle .arrow {
display: inline-block; transition: transform 200ms var(--ease-out); font-size: 10px;
}
.other-answers-toggle.open .arrow, .related-toggle.open .arrow { transform: rotate(90deg); }
.other-answers-panel, .related-panel, .versions-panel {
max-height: 0; overflow: hidden; opacity: 0;
transition: max-height 300ms var(--ease-out), opacity 200ms var(--ease-out);
}
.other-answers-panel { margin-top: var(--space-1); }
.other-answers-panel.open { max-height: 3000px; opacity: 1; }
.related-panel.open { max-height: 3000px; opacity: 1; margin-top: 6px; }
.versions-panel {
border-left: 2px solid var(--border2); padding-left: 10px; margin-top: var(--space-1);
transition: max-height 280ms var(--ease-out), opacity 180ms var(--ease-out);
}
.versions-panel.open { max-height: 1500px; opacity: 1; }
.other-answer-card {
border: 1px solid var(--border); border-radius: var(--radius-md);
padding: 10px 12px; margin-top: 6px; background: rgba(255,255,255,.02);
animation: fadeUp 260ms var(--ease-out) both; position: relative;
}
.other-answer-card.related {
background: linear-gradient(180deg, rgba(108,131,255,.05), rgba(255,255,255,.02));
border-color: rgba(108,131,255,.16);
}
.other-answer-head {
display: flex; gap: 6px; flex-wrap: wrap; align-items: center;
color: var(--muted); font-family: var(--mono); font-size: 10px; margin-bottom: 6px;
}
.other-answer-text { font-size: 13px; line-height: 1.6; }
/* ββ Preview lines ββ */
.preview-block { display: flex; gap: 8px; align-items: flex-start; margin-top: 6px; }
.preview-label {
flex: 0 0 auto; font-family: var(--mono); font-size: 9px; color: var(--muted);
background: rgba(255,255,255,.04); border: 1px solid var(--border);
border-radius: var(--radius-xs); padding: 2px 6px; line-height: 1.3; letter-spacing: .06em;
}
.preview-text {
flex: 1; min-width: 0; font-size: 12.5px; line-height: 1.5; color: var(--text);
display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3;
-webkit-box-orient: vertical; overflow: hidden; white-space: normal; word-break: break-word;
}
.preview-text.muted-preview { color: var(--muted); }
.preview-actions { display: flex; align-items: center; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.preview-actions .vote-row { margin-top: 0; }
.ask-btn {
border: 1px solid rgba(108,131,255,.35); background: rgba(108,131,255,.1); color: var(--accent);
border-radius: var(--radius-sm); padding: 4px 11px; font: inherit; font-size: 11px; font-weight: 600;
cursor: pointer; display: inline-flex; align-items: center; gap: 4px;
transition: border-color 160ms var(--ease-out), color 160ms var(--ease-out), background 160ms var(--ease-out), transform 160ms var(--ease-spring);
}
.ask-btn:hover { background: rgba(108,131,255,.2); border-color: rgba(108,131,255,.55); }
.ask-btn:active { transform: scale(.95); }
.ask-btn svg { width: 11px; height: 11px; }
/* ββ Versions ββ */
.versions-toggle {
margin-top: var(--space-1); color: var(--muted); font-size: 10px;
cursor: pointer; font-family: var(--mono);
display: inline-flex; align-items: center; gap: 4px;
border: none; background: none; padding: 0; transition: color 150ms var(--ease-out);
}
.versions-toggle:hover { color: var(--text); }
.version-card {
border: 1px solid var(--border); background: rgba(255,255,255,.02);
border-radius: var(--radius-md); padding: 8px 10px; margin-top: var(--space-1);
animation: fadeUp 220ms var(--ease-out) both;
}
.version-head {
font-size: 10px; color: var(--muted); font-family: var(--mono);
display: flex; gap: 5px; flex-wrap: wrap; align-items: center; margin-bottom: var(--space-1);
}
/* ββ Propose version ββ */
.propose-panel {
max-height: 0; overflow: hidden; opacity: 0; margin-top: 6px;
transition: max-height 280ms var(--ease-out), opacity 200ms var(--ease-out);
}
.propose-panel.open { max-height: 400px; opacity: 1; }
.propose-textarea {
width: 100%; min-height: 60px; max-height: 140px; resize: vertical;
border: 1px solid var(--border2); border-radius: var(--radius-md);
background: var(--panel); color: var(--text); font: inherit; font-size: 13px; line-height: 1.55;
padding: 8px 10px; outline: none;
transition: border-color 200ms var(--ease-out), height 100ms var(--ease-out);
}
.propose-textarea:focus { border-color: rgba(108,131,255,.4); box-shadow: 0 0 0 3px rgba(108,131,255,.07); }
.propose-textarea::placeholder { color: #5a6178; }
.propose-actions { display: flex; gap: 6px; margin-top: 6px; }
.propose-submit {
border: 1px solid rgba(108,131,255,.3); background: rgba(108,131,255,.1); color: var(--accent);
border-radius: var(--radius-sm); padding: 5px 12px; font: inherit; font-size: 11px;
cursor: pointer; transition: border-color 160ms, color 160ms, background 160ms;
}
.propose-submit:hover { background: rgba(108,131,255,.18); border-color: rgba(108,131,255,.5); }
.propose-submit:disabled { opacity: .5; cursor: not-allowed; }
.propose-cancel {
border: 1px solid var(--border); background: transparent; color: var(--muted);
border-radius: var(--radius-sm); padding: 5px 10px; font: inherit; font-size: 11px; cursor: pointer;
}
/* ββ Typing indicator ββ */
.typing-indicator {
display: flex; gap: 10px; margin-bottom: 6px; align-items: flex-start;
animation: fadeUp 320ms var(--ease-out) both;
}
.typing-dots {
display: flex; gap: 4px; align-items: center; padding: 12px 16px;
border: 1px solid var(--border);
border-radius: var(--radius-xs) var(--radius-lg) var(--radius-lg) var(--radius-lg);
background: rgba(255,255,255,.03);
}
.typing-dots span {
width: 6px; height: 6px; border-radius: 50%; background: var(--muted);
animation: typingBounce 1.1s ease infinite;
}
.typing-dots span:nth-child(2) { animation-delay: .15s; }
.typing-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes typingBounce { 0%, 60%, 100% { transform: translateY(0); opacity: .35; } 30% { transform: translateY(-5px); opacity: 1; } }
.answer-reveal {
opacity: 0; transform: translateY(4px); filter: blur(1px);
transition: opacity 180ms var(--ease-out), transform 180ms var(--ease-out), filter 180ms var(--ease-out);
}
.answer-reveal.revealed { opacity: 1; transform: translateY(0); filter: blur(0); }
@keyframes glow-in { 0% { box-shadow: 0 0 0 rgba(45,212,191,0); } 40% { box-shadow: 0 0 18px rgba(45,212,191,.3); } 100% { box-shadow: none; } }
.answer-new-glow { animation: glow-in 700ms var(--ease-out) both; }
/* ββ Related ββ */
.related-stack { margin-top: 14px; padding-top: 12px; border-top: 1px solid rgba(255,255,255,.06); }
.related-stack .chip { margin-bottom: 6px; }
.related-toggle {
margin-top: 2px; border: 1px solid var(--border); background: rgba(255,255,255,.02);
color: var(--muted); border-radius: var(--radius-md); padding: 6px 12px;
font: inherit; font-size: 11px; cursor: pointer;
display: inline-flex; align-items: center; gap: 5px;
transition: border-color 180ms var(--ease-out), color 180ms var(--ease-out), background 180ms var(--ease-out);
}
.related-toggle:hover { border-color: rgba(108,131,255,.3); color: var(--text); }
.related-panel { margin-top: 0; transition: max-height 280ms var(--ease-out), opacity 180ms var(--ease-out), margin-top 180ms var(--ease-out); }
.related-score { color: var(--accent); border-color: rgba(108,131,255,.22); }
.related-note { color: var(--muted); font-size: 11px; line-height: 1.5; margin-top: 6px; }
/* ββ Composer ββ */
.compose {
border-top: 1px solid var(--border); background: rgba(11,14,20,.85);
backdrop-filter: blur(16px) saturate(160%);
padding: 10px 14px calc(14px + env(safe-area-inset-bottom)); flex-shrink: 0;
}
@media (max-height: 500px) { .compose { padding: 6px 10px; } }
.compose-inner {
max-width: 760px; margin: 0 auto;
border: 1px solid var(--border2); border-radius: var(--radius-lg);
padding: 8px 10px 6px; background: var(--panel); box-shadow: var(--shadow-soft);
transition: border-color 200ms var(--ease-out), box-shadow 200ms var(--ease-out); position: relative;
}
.compose-inner:focus-within {
border-color: rgba(108,131,255,.4);
box-shadow: 0 0 0 3px rgba(108,131,255,.12), var(--shadow-soft);
}
.autocomplete-dropdown {
position: absolute; bottom: calc(100% + 6px); left: 0; right: 0;
background: var(--panel2); border: 1px solid var(--border2);
border-radius: var(--radius-md); z-index: 20; overflow: hidden;
box-shadow: var(--shadow); display: none;
}
.autocomplete-dropdown.open { display: block; }
.autocomplete-item {
padding: 8px 12px; cursor: pointer;
display: flex; justify-content: space-between; align-items: center; gap: 8px;
transition: background 120ms; border-bottom: 1px solid var(--border);
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover { background: rgba(108,131,255,.07); }
.autocomplete-match { font-size: 13px; color: var(--text); }
.autocomplete-meta { font-size: 10px; color: var(--muted); font-family: var(--mono); white-space: nowrap; }
#prompt {
width: 100%; min-height: 40px; max-height: 180px; resize: none; border: none; outline: none;
background: transparent; color: var(--text); font: inherit; font-size: var(--font-size-base);
line-height: 1.55; padding: 2px 2px 4px; transition: height 100ms var(--ease-out);
}
#prompt::placeholder { color: #5a6178; }
.compose-row {
display: flex; align-items: center; justify-content: space-between;
gap: var(--space-2); border-top: 1px solid var(--border); padding-top: 6px;
}
.hint { color: var(--muted); font-size: 10px; font-family: var(--mono); }
.send-btn {
border: none; border-radius: 10px; padding: 7px 16px; cursor: pointer;
font: inherit; font-size: 13px; font-weight: 600; color: white;
background: linear-gradient(135deg, var(--accent), var(--accent2));
box-shadow: 0 4px 14px rgba(108,131,255,.2);
transition: transform 140ms var(--ease-spring), box-shadow 140ms var(--ease-out), filter 140ms var(--ease-out);
}
.send-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(108,131,255,.3); }
.send-btn:active { transform: scale(.96); }
.send-btn:disabled { opacity: .4; cursor: not-allowed; transform: none; box-shadow: none; }
/* ββ Settings panel ββ */
.settings-backdrop {
position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 99;
opacity: 0; pointer-events: none; transition: opacity 250ms var(--ease-in-out);
}
.settings-backdrop.visible { opacity: 1; pointer-events: auto; }
#settingsPanel {
position: fixed; top: 56px; right: 0; width: 280px;
background: var(--panel); border: 1px solid var(--border2);
border-radius: 0 0 0 var(--radius-lg); box-shadow: var(--shadow); z-index: 100;
transform: translateX(100%); transition: transform 250ms var(--ease-in-out);
padding: 14px 16px; backdrop-filter: blur(24px) saturate(200%);
}
#settingsPanel.open { transform: translateX(0); }
.settings-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.settings-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.settings-close {
border: none; background: none; color: var(--muted); cursor: pointer;
font-size: 16px; line-height: 1; padding: 2px 4px; border-radius: var(--radius-xs); transition: color 150ms;
}
.settings-close:hover { color: var(--text); }
.setting-row {
display: flex; align-items: center; justify-content: space-between;
padding: 6px 0; border-bottom: 1px solid var(--border);
}
.setting-row:last-child { border-bottom: none; }
.setting-label { font-size: 12px; color: var(--text); }
.setting-desc { font-size: 10px; color: var(--muted); margin-top: 1px; }
.anim-segment { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.anim-option {
display: flex; align-items: center; justify-content: space-between;
padding: 6px 10px; border-radius: var(--radius-sm); border: 1px solid var(--border);
cursor: pointer; font-size: 12px; color: var(--muted);
transition: border-color 150ms, background 150ms;
}
.anim-option.active { border-color: rgba(108,131,255,.4); background: rgba(108,131,255,.08); color: var(--accent); }
.anim-preview { width: 24px; height: 8px; border-radius: 4px; background: var(--border2); overflow: hidden; position: relative; }
.anim-preview::after {
content: ""; position: absolute; inset: 0;
background: linear-gradient(90deg, var(--accent), var(--accent2));
opacity: .4;
animation: anim-preview-slide var(--anim-preview-duration, 1000ms) var(--anim-preview-ease, ease) infinite alternate;
}
.anim-option.active .anim-preview::after { opacity: 1; }
.anim-option.anim-static .anim-preview::after {
animation: none; transform: translateX(-38%); opacity: .2;
}
@keyframes anim-preview-slide { from { transform: translateX(-100%); } to { transform: translateX(0); } }
.density-segment { display: flex; gap: 4px; margin-top: 6px; width: 100%; }
.density-option {
flex: 1; padding: 6px; text-align: center; border: 1px solid var(--border);
border-radius: var(--radius-sm); cursor: pointer; font-size: 11px; color: var(--muted);
transition: border-color 150ms, background 150ms, color 150ms;
}
.density-option.active { border-color: rgba(108,131,255,.4); background: rgba(108,131,255,.08); color: var(--accent); }
/* ββ Toast ββ */
#toast {
position: fixed; left: 50%; bottom: 80px;
transform: translateX(-50%) translateY(12px); opacity: 0; pointer-events: none;
transition: opacity 200ms var(--ease-in-out), transform 200ms var(--ease-in-out); z-index: 50;
background: rgba(17,21,29,.95); border: 1px solid var(--border2); border-radius: var(--radius-md);
padding: 8px 14px; color: var(--text); font-family: var(--mono); font-size: 11px;
box-shadow: var(--shadow); white-space: nowrap; backdrop-filter: blur(10px);
display: flex; align-items: center; gap: 8px;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
#toast.good { border-color: rgba(45,212,191,.4); color: var(--good); }
#toast.bad { border-color: rgba(248,113,113,.4); color: var(--bad); }
.toast-retry {
border: 1px solid currentColor; border-radius: var(--radius-xs);
background: transparent; color: inherit; padding: 2px 8px;
font: inherit; font-size: 10px; cursor: pointer; white-space: nowrap;
}
.no-answer-bubble { border-style: dashed !important; color: var(--muted); }
/* ββ Jump to latest ββ */
#jumpLatest {
position: fixed; left: 50%; bottom: 132px;
transform: translateX(-50%) translateY(8px); z-index: 55;
border: 1px solid rgba(124,166,255,.3); background: rgba(14,20,31,.94);
color: var(--text); border-radius: var(--radius-pill);
padding: 8px 14px; font: inherit; font-size: 12px;
box-shadow: var(--shadow-soft); backdrop-filter: blur(10px);
opacity: 0; pointer-events: none; cursor: pointer;
transition: opacity 160ms var(--ease-out), transform 160ms var(--ease-out);
}
#jumpLatest.show { opacity: 1; pointer-events: auto; transform: translateX(-50%) translateY(0); }
/* ββ Lightbox ββ */
#lightbox {
position: fixed; inset: 0; background: rgba(0,0,0,.9); z-index: 400;
display: none; place-items: center; cursor: zoom-out; animation: fadeIn 150ms ease;
}
#lightbox.open { display: grid; }
#lightbox img { max-width: 95vw; max-height: 95vh; border-radius: var(--radius-sm); box-shadow: 0 20px 60px rgba(0,0,0,.5); cursor: default; }
#lightboxClose {
position: absolute; top: 16px; right: 16px;
border: 1px solid rgba(255,255,255,.2); background: rgba(0,0,0,.5); color: white;
border-radius: var(--radius-pill); width: 36px; height: 36px;
display: grid; place-items: center; cursor: pointer; font-size: 18px; line-height: 1;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
/* ββ Command palette ββ */
#cmdBackdrop {
position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 500;
display: none; place-items: flex-start center; padding-top: 18vh;
}
#cmdBackdrop.open { display: grid; }
#cmdPalette {
width: min(480px, 90vw); background: var(--panel2); border: 1px solid var(--border2);
border-radius: var(--radius-xl); box-shadow: var(--shadow); overflow: hidden;
animation: fadeUp 150ms var(--ease-out) both;
}
#cmdInput {
width: 100%; border: none; border-bottom: 1px solid var(--border);
background: transparent; color: var(--text); font: inherit; font-size: 14px;
padding: 14px 16px; outline: none;
}
#cmdInput::placeholder { color: var(--muted); }
.cmd-list { max-height: 280px; overflow-y: auto; padding: 4px 0; }
.cmd-item {
padding: 10px 16px; cursor: pointer; display: flex; align-items: center; gap: 10px;
font-size: 13px; color: var(--text); transition: background 100ms;
}
.cmd-item:hover, .cmd-item.focused { background: rgba(108,131,255,.1); }
.cmd-item-icon { color: var(--muted); font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
.cmd-item-label { flex: 1; }
.cmd-item-shortcut { font-family: var(--mono); font-size: 10px; color: var(--muted); }
.cmd-empty { padding: 16px; text-align: center; color: var(--muted); font-size: 13px; }
/* ββ Confirm modal ββ */
#confirmBackdrop {
position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 600;
display: none; place-items: center;
}
#confirmBackdrop.open { display: grid; }
#confirmModal {
width: min(360px, 90vw); background: var(--panel2); border: 1px solid var(--border2);
border-radius: var(--radius-xl); padding: 24px; box-shadow: var(--shadow);
animation: fadeUp 150ms var(--ease-out) both;
}
.confirm-title { font-size: 15px; font-weight: 700; margin-bottom: 8px; }
.confirm-msg { font-size: 13px; color: var(--muted); line-height: 1.5; margin-bottom: 20px; }
.confirm-actions { display: flex; gap: 8px; justify-content: flex-end; }
.confirm-ok {
border: none; border-radius: var(--radius-sm); padding: 7px 18px;
font: inherit; font-size: 13px; font-weight: 600;
background: var(--bad); color: white; cursor: pointer; transition: filter 150ms;
}
.confirm-ok:hover { filter: brightness(1.1); }
.confirm-cancel {
border: 1px solid var(--border2); background: transparent; color: var(--muted);
border-radius: var(--radius-sm); padding: 7px 14px; font: inherit; font-size: 13px; cursor: pointer;
}
.question-note {
font-size: 11px; color: var(--muted); font-family: var(--mono);
margin-top: 4px; display: flex; align-items: center; gap: 4px;
}
/* ββ Focus styles ββ */
#jumpLatest:focus-visible, .top-btn:focus-visible, .vote-btn:focus-visible,
.action-btn:focus-visible, .ask-btn:focus-visible, .write-answer-btn:focus-visible,
.other-answers-toggle:focus-visible, .related-toggle:focus-visible, .send-btn:focus-visible,
.write-submit:focus-visible, .write-cancel:focus-visible, .propose-submit:focus-visible,
.propose-cancel:focus-visible, .anim-option:focus-visible, .density-option:focus-visible,
.suggestion-chip:focus-visible, .cmd-item:focus-visible, .confirm-ok:focus-visible,
.confirm-cancel:focus-visible, .copy-code-btn:focus-visible {
outline: 2px solid rgba(124,166,255,.7); outline-offset: 2px;
}
/* ββ Responsive ββ */
@media (max-width: 600px) {
#topbar { padding: 0 10px; }
.brand-sub { display: none; }
.bubble { max-width: calc(100vw - 80px); }
.welcome { margin-top: 3vh; padding: 18px 14px; }
.welcome h1 { font-size: 18px; }
#settingsPanel { width: 100%; border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
#jumpLatest { bottom: 120px; max-width: calc(100vw - 24px); white-space: nowrap; }
}
@media (pointer: coarse) {
.vote-btn, .action-btn, .ask-btn, .versions-toggle, .other-answers-toggle,
.related-toggle, .write-answer-btn { min-height: 44px; padding: 8px 14px; }
.vote-btn { min-height: 44px; }
.top-btn { min-height: 40px; }
}
</style>
</head>
<body>
<a href="#prompt" class="skip-link">Skip to chat input</a>
<div id="app">
<header id="topbar" role="banner">
<div class="brand">
<img class="logo" src="/templates/logo.png" alt="Human Intelligence logo" />
<div>
<div class="brand-title">Human Intelligence</div>
<div class="brand-sub">community answers</div>
</div>
</div>
<nav class="top-actions" aria-label="Chat actions">
<button class="top-btn" id="newChatBtn" aria-label="Start a new chat">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg>
New chat
</button>
<button class="top-btn" id="settingsBtn" aria-label="Open appearance settings" aria-expanded="false" aria-controls="settingsPanel">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><circle cx="12" cy="12" r="3"/><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"/></svg>
</button>
</nav>
</header>
<div id="statusbar" role="status" aria-live="assertive">
<span class="status-dot" aria-hidden="true"></span>
<span id="statusText">Thinkingβ¦</span>
</div>
<button id="jumpLatest" type="button" aria-label="Jump to latest content">New content below Β· Jump β</button>
<div class="settings-backdrop" id="settingsBackdrop" aria-hidden="true"></div>
<div id="settingsPanel" role="dialog" aria-label="Appearance settings" aria-modal="false">
<div class="settings-header">
<div class="settings-title">Appearance</div>
<button class="settings-close" id="settingsClose" aria-label="Close settings">Γ</button>
</div>
<div class="setting-row">
<div>
<div class="setting-label">Response animation</div>
<div class="setting-desc">How answers are revealed</div>
</div>
</div>
<div class="anim-segment" id="animSegment" role="radiogroup" aria-label="Animation style">
<div class="anim-option" data-anim="none" role="radio" aria-checked="true" tabindex="0"><span>Instant</span><div class="anim-preview"></div></div>
<div class="anim-option" data-anim="ai" role="radio" aria-checked="false" tabindex="0"><span>Quick fade</span><div class="anim-preview"></div></div>
<div class="anim-option" data-anim="human" role="radio" aria-checked="false" tabindex="0"><span>Gentle fade</span><div class="anim-preview"></div></div>
<div class="anim-option" data-anim="diffusion" role="radio" aria-checked="false" tabindex="0"><span>Soft reveal</span><div class="anim-preview"></div></div>
<div class="anim-option" data-anim="diffusion-v2" role="radio" aria-checked="false" tabindex="0"><span>Slow reveal</span><div class="anim-preview"></div></div>
</div>
<div class="setting-row" style="margin-top:12px;">
<div>
<div class="setting-label">Content density</div>
<div class="setting-desc">Amount of spacing in chat</div>
</div>
</div>
<div class="density-segment" id="densitySegment" role="radiogroup" aria-label="Content density">
<div class="density-option" data-density="compact" role="radio" aria-checked="false" tabindex="0">Compact</div>
<div class="density-option active" data-density="comfortable" role="radio" aria-checked="true" tabindex="0">Default</div>
<div class="density-option" data-density="spacious" role="radio" aria-checked="false" tabindex="0">Spacious</div>
</div>
</div>
<main id="chat" role="main">
<div id="scrollProgress" aria-hidden="true"></div>
<div class="wrap">
<div class="welcome" id="welcome">
<h1 id="welcomeTitle">Ask a question. Get answers from real people.</h1>
<p>Type a question below. If a matching answer exists, it appears instantly. Otherwise, anyone can write the first answer.</p>
<p>Please do not share personal or sensitive information.</p>
<div class="welcome-suggestions" id="welcomeSuggestions" aria-label="Example questions">
<button class="suggestion-chip" data-q="How does the internet work?">π‘ How does the internet work?</button>
<button class="suggestion-chip" data-q="What is the best way to learn programming?">π₯ Best way to learn programming?</button>
<button class="suggestion-chip" data-q="How do I improve my sleep?">π How do I improve my sleep?</button>
</div>
</div>
<div id="transcript" aria-live="polite" aria-atomic="false"></div>
</div>
</main>
<div class="compose">
<form id="composeForm" class="compose-inner" onsubmit="return false;" autocomplete="off">
<div class="autocomplete-dropdown" id="autocompleteDropdown" role="listbox" aria-label="Similar questions"></div>
<textarea id="prompt" rows="1" placeholder="Ask a questionβ¦" aria-label="Your question" autocomplete="off" spellcheck="true"></textarea>
<div class="compose-row">
<div class="hint" id="hint" aria-live="polite">Enter to ask Β· Shift+Enter newline Β· Ctrl+K commands</div>
<button class="send-btn" id="sendBtn" type="submit">Ask</button>
</div>
</form>
</div>
</div>
<div id="toast" role="alert" aria-live="assertive"></div>
<div id="lightbox" aria-modal="true" aria-label="Image viewer" role="dialog">
<button id="lightboxClose" aria-label="Close image viewer">Γ</button>
<img id="lightboxImg" src="" alt="" />
</div>
<div id="cmdBackdrop" role="dialog" aria-modal="true" aria-label="Command palette">
<div id="cmdPalette">
<input id="cmdInput" type="text" placeholder="Type a command or searchβ¦" aria-label="Command search" autocomplete="off" />
<div class="cmd-list" id="cmdList" role="listbox"></div>
</div>
</div>
<div id="confirmBackdrop" role="dialog" aria-modal="true" aria-labelledby="confirmTitle">
<div id="confirmModal">
<div class="confirm-title" id="confirmTitle">Are you sure?</div>
<div class="confirm-msg" id="confirmMsg"></div>
<div class="confirm-actions">
<button class="confirm-cancel" id="confirmCancel">Cancel</button>
<button class="confirm-ok" id="confirmOk">Confirm</button>
</div>
</div>
</div>
<script></script>
<script>
(() => {
'use strict';
/* βββββββββββββββββββββββββββββββββββββββββββ
STATE
βββββββββββββββββββββββββββββββββββββββββββ */
const S = {
clientId: null, conversation: null, currentQuestion: '',
relatedAnswers: [], loading: false, atBottom: true,
animMode: localStorage.getItem('hi_anim') || 'none',
density: localStorage.getItem('hi_density') || 'comfortable',
lastAction: null, originalTitle: document.title,
routeConversationId: '',
renderSessionId: 0,
rendering: false,
};
const MOTION = Object.freeze({
none: { chunkDelay: 0, chunkSize: 6, previewDuration: 0, previewEase: 'linear' },
ai: { chunkDelay: 26, chunkSize: 3, previewDuration: 650, previewEase: 'cubic-bezier(.33,.84,.42,1)' },
human: { chunkDelay: 44, chunkSize: 2, previewDuration: 980, previewEase: 'cubic-bezier(.22,.61,.36,1)' },
diffusion: { chunkDelay: 66, chunkSize: 1, previewDuration: 1320, previewEase: 'cubic-bezier(.25,.46,.45,.94)' },
'diffusion-v2': { chunkDelay: 90, chunkSize: 1, previewDuration: 1760, previewEase: 'cubic-bezier(.16,.84,.27,.99)' },
});
/* βββββββββββββββββββββββββββββββββββββββββββ
UTILITIES
βββββββββββββββββββββββββββββββββββββββββββ */
const $ = id => document.getElementById(id);
const qs = (sel, ctx = document) => ctx.querySelector(sel);
const qsa = (sel, ctx = document) => Array.from(ctx.querySelectorAll(sel));
const sleep = ms => new Promise(r => setTimeout(r, ms));
function updateAppHeight() {
const h = window.visualViewport?.height || window.innerHeight || document.documentElement.clientHeight;
document.documentElement.style.setProperty('--app-height', `${Math.round(h)}px`);
}
function getClientId() {
let id = localStorage.getItem('hi_client_id');
if (!id) {
id = (crypto.randomUUID?.() || Date.now().toString(36) + Math.random().toString(36).slice(2))
.replace(/-/g, '').slice(0, 16);
localStorage.setItem('hi_client_id', id);
}
return id;
}
function debounce(fn, ms) {
let t; return (...a) => { clearTimeout(t); t = setTimeout(() => fn(...a), ms); };
}
function debounceClick(fn, ms = 350) {
let blocked = false;
return async (...a) => {
if (blocked) return;
blocked = true;
try { await fn(...a); } finally { setTimeout(() => { blocked = false; }, ms); }
};
}
function getMotion(mode = S.animMode) { return MOTION[mode] || MOTION.none; }
function shouldAnimateResponses() { return S.animMode !== 'none'; }
function beginRenderSession() { S.renderSessionId += 1; S.rendering = true; return S.renderSessionId; }
function isRenderSessionActive(id) { return id === S.renderSessionId; }
function finishRenderSession(id) { if (isRenderSessionActive(id)) S.rendering = false; }
function cancelActiveRender() { S.renderSessionId += 1; S.rendering = false; removeTyping(); }
function stripEdgeBlankLines(text) {
return String(text || '')
.replace(/^\s*\n+/, '')
.replace(/\n+\s*$/, '')
.trimEnd();
}
function normalizeConversationPath(conversationId = '') {
return conversationId ? `/q/${conversationId}` : '/';
}
function isNearScrollEnd(el, threshold = 28) {
if (!el) return true;
return el.scrollHeight - el.scrollTop - el.clientHeight < threshold;
}
/* βββββββββββββββββββββββββββββββββββββββββββ
TOAST / STATUS
βββββββββββββββββββββββββββββββββββββββββββ */
function toast(msg, kind = '', retryFn = null) {
const t = $('toast');
t.innerHTML = '';
const span = document.createElement('span');
span.textContent = msg;
t.appendChild(span);
if (retryFn) {
const btn = document.createElement('button');
btn.className = 'toast-retry'; btn.textContent = 'Retry';
btn.onclick = () => { hideToast(); retryFn(); };
t.appendChild(btn);
}
t.className = 'show' + (kind ? ' ' + kind : '');
clearTimeout(t._t);
t._t = setTimeout(hideToast, retryFn ? 6000 : 2500);
}
function hideToast() { $('toast').className = ''; }
let statusTimers = [];
function showStatus(text) { $('statusText').textContent = text; $('statusbar').classList.add('visible'); }
function hideStatus() { statusTimers.forEach(clearTimeout); statusTimers = []; $('statusbar').classList.remove('visible'); }
function showStatusWithEscalation() {
showStatus('Searching for answersβ¦');
statusTimers.push(setTimeout(() => showStatus('Still searchingβ¦'), 8000));
statusTimers.push(setTimeout(() => showStatus('Taking longer than usualβ¦'), 20000));
}
/* βββββββββββββββββββββββββββββββββββββββββββ
ESCAPE / TEXT
βββββββββββββββββββββββββββββββββββββββββββ */
function esc(s) {
return String(s).replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"');
}
function nl2br(s) { return esc(s).replace(/\n/g, '<br>'); }
function previewText(s) {
return String(s||'').replace(/```[\s\S]*?```/g,' [code] ')
.replace(/!\[[^\]]*\]\([^)]*\)/g,' [image] ').replace(/\[([^\]]+)\]\([^)]*\)/g,'$1')
.replace(/^[#>\-*+]\s+/gm,'').replace(/[*_~`]+/g,'').replace(/\s+/g,' ').trim();
}
/* βββββββββββββββββββββββββββββββββββββββββββ
INLINE MARKDOWN
βββββββββββββββββββββββββββββββββββββββββββ */
function renderInlineMarkdown(s) {
const tokens = [];
let raw = String(s||'').replace(
/!\[([^\]]*)\]\((https?:\/\/[^\s)]+)\)|\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)/g,
(m, imgAlt, imgSrc, linkText, linkHref) => {
const idx = tokens.length;
if (imgSrc !== undefined) {
const caption = String(imgAlt || '').trim();
tokens.push(
`<figure class="md-figure"><img class="md-img" src="${esc(imgSrc)}" alt="${esc(caption)}" loading="lazy">${caption ? `<figcaption class="md-figcaption">${esc(caption)}</figcaption>` : ''}</figure>`
);
} else {
tokens.push(`<a href="${esc(linkHref)}" target="_blank" rel="noopener noreferrer">${esc(linkText)}</a>`);
}
return `\x00${idx}\x00`;
}
);
raw = raw.replace(/`([^`]+)`/g, (_, c) => {
const idx = tokens.length; tokens.push(`<code>${esc(c)}</code>`); return `\x00${idx}\x00`;
});
let out = esc(raw);
out = out.replace(/\*\*\*([^*]+)\*\*\*/g,'<strong><em>$1</em></strong>');
out = out.replace(/___([^_]+)___/g,'<strong><em>$1</em></strong>');
out = out.replace(/\*\*([^*]+)\*\*/g,'<strong>$1</strong>');
out = out.replace(/__([^_]+)__/g,'<strong>$1</strong>');
out = out.replace(/\*([^*\s][^*]*[^*\s]|\S)\*/g,'<em>$1</em>');
out = out.replace(/_([^_\s][^_]*[^_\s]|\S)_/g,'<em>$1</em>');
out = out.replace(/~~([^~]+)~~/g,'<s>$1</s>');
out = out.replace(/\^([^^]+)\^/g,'<sup>$1</sup>');
out = out.replace(/~([^~]+)~/g,'<sub>$1</sub>');
out = out.replace(/\x00(\d+)\x00/g, (_, i) => tokens[Number(i)]);
return out;
}
/* βββββββββββββββββββββββββββββββββββββββββββ
BLOCK MARKDOWN RENDERER
(with thinking block extraction)
βββββββββββββββββββββββββββββββββββββββββββ */
/**
* Extract <|thinking|>β¦</|thinking|> blocks from raw text.
* Returns { segments: [ {type:'text'|'thinking', content:string} ] }
*/
function extractThinkingBlocks(md) {
const source = String(md || '');
const segments = [];
const openTag = '<|thinking|>';
const closeTag = '</|thinking|>';
let cursor = 0;
while (cursor < source.length) {
const openIdx = source.indexOf(openTag, cursor);
if (openIdx === -1) {
segments.push({ type: 'text', content: source.slice(cursor) });
break;
}
if (openIdx > cursor) {
segments.push({ type: 'text', content: source.slice(cursor, openIdx) });
}
const closeIdx = source.indexOf(closeTag, openIdx + openTag.length);
if (closeIdx === -1) {
// Unclosed thinking block β treat rest as thinking
segments.push({ type: 'thinking', content: source.slice(openIdx + openTag.length) });
cursor = source.length;
break;
}
segments.push({ type: 'thinking', content: source.slice(openIdx + openTag.length, closeIdx) });
cursor = closeIdx + closeTag.length;
}
return segments;
}
function renderMarkdown(md) {
const lines = String(md||'').replace(/\r\n/g,'\n').split('\n');
const out = [];
let inCode = false, codeLang = '', codeBuf = [];
let lastWasBlank = false;
const listStack = [];
function closeListsTo(target) {
while (listStack.length && listStack[listStack.length-1].indent > target)
out.push(`</${listStack.pop().type}>`);
}
function closeLists() { while (listStack.length) out.push(`</${listStack.pop().type}>`); }
let inQuote = false;
function closeQuote() { if (inQuote) { out.push('</blockquote>'); inQuote = false; } }
let inTable = false, tableHeaders = [], tableAligns = [];
function closeTable() {
if (inTable) { out.push('</tbody></table>'); inTable = false; tableHeaders = []; tableAligns = []; }
}
for (let li = 0; li < lines.length; li++) {
const raw = lines[li].trimEnd();
if (inCode) {
if (/^```/.test(raw)) {
const highlighted = esc(codeBuf.join('\n'));
const langLabel = codeLang ? `<span class="code-lang-label">${esc(codeLang)}</span>` : '';
out.push(`<div class="code-block-wrapper">${langLabel}<button class="copy-code-btn" data-copy-code="${encodeURIComponent(codeBuf.join('\n'))}">Copy</button><pre><code>${highlighted}</code></pre></div>`);
codeBuf = []; codeLang = ''; inCode = false;
} else codeBuf.push(raw);
continue;
}
if (/^```/.test(raw)) {
closeLists(); closeQuote(); closeTable();
codeLang = raw.replace(/^```/,'').trim().toLowerCase(); inCode = true; continue;
}
if (!raw.trim()) {
closeLists(); closeQuote(); closeTable();
if (!lastWasBlank) out.push('<p class="md-gap"></p>');
lastWasBlank = true; continue;
}
lastWasBlank = false;
if (/^#{1,6}\s/.test(raw)) {
closeLists(); closeQuote(); closeTable();
const lvl = Math.min(6, raw.match(/^#+/)[0].length);
out.push(`<h${lvl}>${renderInlineMarkdown(raw.replace(/^#+\s+/,''))}</h${lvl}>`); continue;
}
if (/^(-{3,}|\*{3,}|_{3,})$/.test(raw.trim())) {
closeLists(); closeQuote(); closeTable(); out.push('<hr>'); continue;
}
if (/^> ?/.test(raw)) {
closeLists(); closeTable();
if (!inQuote) { out.push('<blockquote>'); inQuote = true; }
out.push(`<p>${renderInlineMarkdown(raw.replace(/^> ?/,''))}</p>`); continue;
}
closeQuote();
if (/^\|.+\|$/.test(raw)) {
const nextLine = lines[li+1] ? lines[li+1].trimEnd() : '';
if (/^\|[\s|:\-]+\|$/.test(nextLine)) {
closeLists();
tableHeaders = raw.split('|').slice(1,-1).map(c=>c.trim());
const sepCells = nextLine.split('|').slice(1,-1).map(c=>c.trim());
tableAligns = sepCells.map(c => /^:-+:$/.test(c)?'center': /^-+:$/.test(c)?'right':'left');
out.push('<table><thead><tr>');
tableHeaders.forEach((h,i)=>out.push(`<th style="text-align:${tableAligns[i]}">${renderInlineMarkdown(h)}</th>`));
out.push('</tr></thead><tbody>'); inTable = true; li++; continue;
} else if (inTable) {
const cells = raw.split('|').slice(1,-1).map(c=>c.trim());
out.push('<tr>');
cells.forEach((c,i)=>out.push(`<td style="text-align:${tableAligns[i]||'left'}">${renderInlineMarkdown(c)}</td>`));
out.push('</tr>'); continue;
}
}
if (inTable && !/^\|/.test(raw)) closeTable();
const ulMatch = raw.match(/^(\s*)[-*]\s+(.*)/);
const olMatch = raw.match(/^(\s*)\d+\.\s+(.*)/);
if (ulMatch || olMatch) {
closeQuote(); closeTable();
const indent = (ulMatch||olMatch)[1].length;
const type = ulMatch ? 'ul' : 'ol';
const text = ulMatch ? ulMatch[2] : olMatch[2];
if (!listStack.length || indent > listStack[listStack.length-1].indent) {
out.push(`<${type}>`); listStack.push({type,indent});
} else if (indent < listStack[listStack.length-1].indent) {
closeListsTo(indent);
if (!listStack.length || listStack[listStack.length-1].indent !== indent) {
out.push(`<${type}>`); listStack.push({type,indent});
}
}
const taskMatch = text.match(/^\[([ xX])\]\s+(.*)/);
if (taskMatch) {
const checked = taskMatch[1] !== ' ';
out.push(`<li class="task-item"><input type="checkbox" ${checked?'checked':''} disabled aria-checked="${checked}">${renderInlineMarkdown(taskMatch[2])}</li>`);
} else out.push(`<li>${renderInlineMarkdown(text)}</li>`);
continue;
}
closeLists(); closeTable();
out.push(`<p>${renderInlineMarkdown(raw)}</p>`);
}
closeLists(); closeQuote(); closeTable();
if (inCode) out.push(`<div class="code-block-wrapper"><pre><code>${esc(codeBuf.join('\n'))}</code></pre></div>`);
return out.join('');
}
/**
* Render markdown that may contain thinking blocks.
* Returns HTML with <details> dropdowns for each thinking block.
* `thinkingDuration` is the number of seconds to display (null = still thinking).
*/
function renderThinkingDropdownHtml(thinkingText, label = 'Thoughts') {
const content = stripEdgeBlankLines(thinkingText);
if (!content) return '';
return `<details class="thinking-dropdown"><summary class="thinking-summary"><span class="thinking-arrow" aria-hidden="true">βΆ</span><span class="thinking-label">${esc(label)}</span></summary><div class="thinking-body"><div class="thinking-content md-body">${renderMarkdown(content)}</div></div></details>`;
}
function renderMarkdownWithThinking(md) {
return extractThinkingBlocks(md).map(seg => {
const cleaned = stripEdgeBlankLines(seg.content);
if (!cleaned) return '';
return seg.type === 'thinking'
? renderThinkingDropdownHtml(cleaned)
: renderMarkdown(cleaned);
}).join('');
}
/* βββββββββββββββββββββββββββββββββββββββββββ
TIME HELPERS
βββββββββββββββββββββββββββββββββββββββββββ */
function relativeTime(iso) {
if (!iso) return '';
try {
const diff = Date.now() - new Date(iso).getTime();
const mins = Math.floor(diff/60000);
if (mins<1) return 'just now';
if (mins<60) return `${mins}m ago`;
const hrs = Math.floor(mins/60);
if (hrs<24) return `${hrs}h ago`;
const days = Math.floor(hrs/24);
if (days<7) return `${days}d ago`;
return new Date(iso).toLocaleString([],{month:'short',day:'numeric',hour:'2-digit',minute:'2-digit'});
} catch { return iso; }
}
/* βββββββββββββββββββββββββββββββββββββββββββ
QUALITY SCORE
βββββββββββββββββββββββββββββββββββββββββββ */
function answerQuality(text) {
let s = 0;
if (text.length>200) s++; if (/```/.test(text)) s++;
if (/https?:\/\//.test(text)) s++; if (/\n[-*] /.test(text)) s++;
return Math.min(s,4);
}
function renderQualityDots(text) {
const q = answerQuality(text);
return `<span class="quality-dots" aria-label="Answer quality">${
Array.from({length:4},(_,i)=>`<span class="quality-dot ${i<q?'filled':''}" aria-hidden="true"></span>`).join('')
}</span>`;
}
/* βββββββββββββββββββββββββββββββββββββββββββ
SCROLL
βββββββββββββββββββββββββββββββββββββββββββ */
function isNearBottom() { const c=$('chat'); return c.scrollHeight-c.scrollTop-c.clientHeight<72; }
function setJumpLatest(v) { $('jumpLatest')?.classList.toggle('show',!!v); }
let scrollRAF = null;
function scrollBottom(force=false) {
if (scrollRAF) return;
scrollRAF = requestAnimationFrame(() => {
scrollRAF = null; const c=$('chat'); if (!c) return;
if (force||S.atBottom||isNearBottom()) {
c.scrollTop = c.scrollHeight; setJumpLatest(false); S.atBottom = true;
} else setJumpLatest(true);
});
}
function updateScrollProgress() {
const c=$('chat'), bar=$('scrollProgress'); if (!c||!bar) return;
const pct = c.scrollHeight<=c.clientHeight ? 0 : (c.scrollTop/(c.scrollHeight-c.clientHeight))*100;
bar.style.width = pct.toFixed(1)+'%';
}
/* βββββββββββββββββββββββββββββββββββββββββββ
DOM HELPERS
βββββββββββββββββββββββββββββββββββββββββββ */
function appendHTML(target, html) {
if (!html) return;
const tpl = document.createElement('template');
tpl.innerHTML = html.trim();
target.appendChild(tpl.content);
}
/* βββββββββββββββββββββββββββββββββββββββββββ
ANIMATE TEXT (chunked autoregressive)
βββββββββββββββββββββββββββββββββββββββββββ */
function setThinkingOpen(details, open) {
details._internalToggle = true;
details.open = open;
requestAnimationFrame(() => { details._internalToggle = false; });
}
async function waitForRenderDelay(ms, renderId) {
if (ms <= 0) return isRenderSessionActive(renderId);
await sleep(ms);
return isRenderSessionActive(renderId);
}
async function animateText(el, text, renderId) {
if (!el) return false;
const motion = getMotion();
if (motion.chunkDelay === 0) {
renderMarkdownInto(el, text, true);
finalizeThinkingBlocks(el);
return true;
}
el.innerHTML = '';
for (const seg of extractThinkingBlocks(text)) {
if (!isRenderSessionActive(renderId)) return false;
const cleaned = stripEdgeBlankLines(seg.content);
if (!cleaned) continue;
if (seg.type === 'thinking') {
const ok = await animateThinkingBlock(el, cleaned, motion, renderId);
if (!ok) return false;
continue;
}
const textContainer = document.createElement('div');
el.appendChild(textContainer);
const ok = await animateMarkdownChunked(textContainer, cleaned, motion, renderId);
if (!ok) return false;
}
finalizeThinkingBlocks(el);
return isRenderSessionActive(renderId);
}
async function animateThinkingBlock(parentEl, thinkingText, motion, renderId) {
if (!thinkingText || !isRenderSessionActive(renderId)) return false;
const details = document.createElement('details');
details.className = 'thinking-dropdown is-live';
details.innerHTML = `<summary class="thinking-summary"><span class="thinking-spinner" aria-hidden="true"></span><span class="thinking-label">Thinkingβ¦</span></summary><div class="thinking-body"><div class="thinking-content md-body"></div></div>`;
parentEl.appendChild(details);
bindRichContent(details);
setThinkingOpen(details, true);
scrollBottom();
const contentDiv = qs('.thinking-content', details);
const startTime = performance.now();
const ok = await animateMarkdownChunked(contentDiv, thinkingText, motion, renderId, () => {
if (details._followContent !== false) contentDiv.scrollTop = contentDiv.scrollHeight;
});
if (!ok || !isRenderSessionActive(renderId)) return false;
const elapsed = ((performance.now() - startTime) / 1000).toFixed(1);
details.classList.remove('is-live');
const summary = qs('.thinking-summary', details);
if (summary) {
summary.innerHTML = `<span class="thinking-arrow" aria-hidden="true">βΆ</span><span class="thinking-label">Thoughts β’ ${elapsed}s</span>`;
}
if (!details._userToggled && details.open) {
const shouldKeepGoing = await waitForRenderDelay(900, renderId);
if (!shouldKeepGoing || !isRenderSessionActive(renderId)) return false;
if (!details._userToggled) setThinkingOpen(details, false);
}
return true;
}
async function animateMarkdownChunked(el, mdText, motion, renderId, afterChunk = null) {
const cleaned = stripEdgeBlankLines(mdText);
if (!cleaned) return true;
const lines = cleaned.replace(/\r\n/g,'\n').split('\n');
let buffer = '';
for (let i = 0; i < lines.length; i += motion.chunkSize) {
if (!isRenderSessionActive(renderId)) return false;
const chunk = lines.slice(i, i + motion.chunkSize).join('\n');
buffer += (buffer ? '\n' : '') + chunk;
renderMarkdownInto(el, buffer, false);
afterChunk?.();
scrollBottom();
if (i + motion.chunkSize < lines.length) {
const stillActive = await waitForRenderDelay(motion.chunkDelay, renderId);
if (!stillActive) return false;
}
}
return true;
}
function finalizeThinkingBlocks(ctx = document) {
bindThinkingDropdowns(ctx);
qsa('.thinking-dropdown', ctx).forEach(details => {
details.classList.remove('is-live');
const label = qs('.thinking-label', details);
if (label && !label.textContent.trim()) label.textContent = 'Thoughts';
});
}
/* βββββββββββββββββββββββββββββββββββββββββββ
TYPING INDICATOR
βββββββββββββββββββββββββββββββββββββββββββ */
function showTyping() {
removeTyping();
$('transcript').insertAdjacentHTML('beforeend', `
<div class="typing-indicator" id="typingInd" aria-label="Loading response" role="status">
<div class="avatar assistant" aria-hidden="true">β¦</div>
<div class="typing-dots" aria-hidden="true"><span></span><span></span><span></span></div>
</div>`);
scrollBottom();
}
function removeTyping() { $('typingInd')?.remove(); }
/* βββββββββββββββββββββββββββββββββββββββββββ
LIGHTBOX
βββββββββββββββββββββββββββββββββββββββββββ */
function openLightbox(src, alt) {
$('lightboxImg').src = src; $('lightboxImg').alt = alt||'';
$('lightbox').classList.add('open'); $('lightboxClose').focus();
document.addEventListener('keydown', closeLightboxOnKey);
}
function closeLightbox() {
$('lightbox').classList.remove('open'); $('lightboxImg').src = '';
document.removeEventListener('keydown', closeLightboxOnKey);
}
function closeLightboxOnKey(e) { if (e.key==='Escape') closeLightbox(); }
/* βββββββββββββββββββββββββββββββββββββββββββ
CODE COPY BUTTONS
βββββββββββββββββββββββββββββββββββββββββββ */
function bindCodeCopyButtons(ctx = document) {
qsa('[data-copy-code]', ctx).forEach(btn => {
if (btn._bound) return; btn._bound = true;
btn.addEventListener('click', async () => {
try {
await navigator.clipboard.writeText(decodeURIComponent(btn.getAttribute('data-copy-code')));
btn.textContent='Copied!'; btn.classList.add('copied');
setTimeout(()=>{btn.textContent='Copy';btn.classList.remove('copied');},2000);
} catch { toast('Could not copy','bad'); }
});
});
}
function bindThinkingDropdowns(ctx = document) {
qsa('.thinking-dropdown', ctx).forEach(details => {
if (details._thinkingBound) return;
details._thinkingBound = true;
details._userToggled = false;
details._followContent = true;
const content = qs('.thinking-content', details);
if (content) {
content.addEventListener('scroll', () => {
details._followContent = isNearScrollEnd(content, 32);
}, { passive: true });
}
details.addEventListener('toggle', () => {
if (details._internalToggle) return;
details._userToggled = true;
});
});
}
function bindImageLightboxes(ctx = document) {
qsa('.md-img', ctx).forEach(img => {
if (img._lightboxBound) return;
img._lightboxBound = true;
img.addEventListener('click', () => openLightbox(img.currentSrc || img.src, img.alt));
});
}
function bindRichContent(ctx = document) {
bindCodeCopyButtons(ctx);
bindImageLightboxes(ctx);
bindThinkingDropdowns(ctx);
}
function renderMarkdownInto(el, text, withThinking = true) {
if (!el) return;
el.innerHTML = withThinking ? renderMarkdownWithThinking(text) : renderMarkdown(text);
bindRichContent(el);
if (withThinking) finalizeThinkingBlocks(el);
}
/* βββββββββββββββββββββββββββββββββββββββββββ
ANSWER HELPERS
βββββββββββββββββββββββββββββββββββββββββββ */
function activeVersion(answer) {
const v = answer?.versions||[];
if (!v.length) return null;
return v.find(x=>x.id===answer.active_version)
|| [...v].sort((a,b)=>(Number(b.votes||0)-Number(a.votes||0)) || String(b.created_at||'').localeCompare(String(a.created_at||'')))[0];
}
function answerScore(a) { const v=activeVersion(a); return v?Number(v.votes||0):0; }
function sortedAnswers(conv) {
return [...(conv?.answers||[])].sort((a,b)=>{
const d=answerScore(b)-answerScore(a);
return d!==0?d:String(b.created_at||'').localeCompare(String(a.created_at||''));
});
}
/* βββββββββββββββββββββββββββββββββββββββββββ
RENDER HELPERS
βββββββββββββββββββββββββββββββββββββββββββ */
const COPY_SVG = `<svg width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>`;
const ASK_SVG = `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><path d="M5 12h14"/><path d="m12 5 7 7-7 7"/></svg>`;
const PENCIL_SVG = `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><path d="M12 20h9"/><path d="M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z"/></svg>`;
function renderVoteRow(answerId, ver) {
const myVote = ver.votes_by_client?.[S.clientId];
const vu = myVote===1, vd = myVote===-1;
const cnt = Number(ver.votes||0);
return `<div class="vote-row">
<button class="vote-btn ${vu?'voted-up':''}" data-vote="${answerId}|${ver.id}|1"
aria-label="Upvote. ${cnt} vote${cnt!==1?'s':''}. ${vu?'You voted.':'Not voted.'}" aria-pressed="${vu}">
β² <span class="vote-count"><span class="vote-count-inner">${cnt}</span></span>
</button>
<button class="vote-btn ${vd?'voted-down':''}" data-vote="${answerId}|${ver.id}|-1"
aria-label="Downvote.${vd?' You voted.':''}" aria-pressed="${vd}">βΌ</button>
<button class="action-btn" data-copy-answer="${answerId}" data-answer-id="${ver.id}">${COPY_SVG} Copy</button>
</div>`;
}
function renderVersions(answer) {
const act = activeVersion(answer);
const others = (answer.versions||[]).filter(v=>v.id!==act?.id);
if (!others.length) return '';
return `
<button class="versions-toggle" type="button" data-toggle-versions="${answer.id}" aria-controls="vp-${answer.id}" aria-expanded="false">
<span class="arrow" aria-hidden="true">βΆ</span> ${others.length} version${others.length>1?'s':''}
</button>
<div class="versions-panel" id="vp-${answer.id}" role="region" aria-label="Other versions">
${others.map(v=>`
<div class="version-card">
<div class="version-head">
<span>${esc(v.author||'Anonymous')}</span><span aria-hidden="true">Β·</span>
<span>${relativeTime(v.created_at)}</span><span aria-hidden="true">Β·</span>
<span>${Number(v.votes||0)} vote${Number(v.votes||0)!==1?'s':''}</span>
</div>
<div class="preview-block">
<span class="preview-label">A</span>
<div class="preview-text">${esc(previewText(v.text||''))}</div>
</div>
<div class="preview-actions">
${renderVoteRow(answer.id, v)}
<button class="ask-btn" type="button" data-ask-current="1" aria-label="Ask this question again">${ASK_SVG} Ask</button>
</div>
</div>`).join('')}
</div>`;
}
function renderPropose(answerId) {
return `
<button class="action-btn" type="button" data-propose="${answerId}" aria-controls="pp-${answerId}" aria-expanded="false" title="Suggest an improved version">β Propose version</button>
<div class="propose-panel" id="pp-${answerId}" role="region" aria-label="Propose version">
<textarea class="propose-textarea" placeholder="Write a better versionβ¦" rows="3" aria-label="Proposed version text"></textarea>
<div class="char-count"><span class="cc-cur">0</span> / 5000</div>
<div class="propose-actions">
<button class="propose-submit" data-submit-proposal="${answerId}">Submit</button>
<button class="propose-cancel" data-cancel-propose="${answerId}">Cancel</button>
</div>
</div>`;
}
function renderWriteAnswer(convId) {
return `
<button class="write-answer-btn" type="button" id="writeAnswerBtn" aria-controls="writePanel" aria-expanded="false">${PENCIL_SVG} Write an answer</button>
<div class="write-panel" id="writePanel" role="region" aria-label="Write your answer">
<div class="write-tabs" role="tablist">
<button class="write-tab active" role="tab" id="writeTabEdit" aria-selected="true" aria-controls="writeEditorPane">Write</button>
<button class="write-tab" role="tab" id="writeTabPreview" aria-selected="false" aria-controls="writePreviewPane">Preview</button>
</div>
<div id="writeEditorPane" role="tabpanel" aria-labelledby="writeTabEdit">
<textarea class="write-textarea" id="writeTextarea" placeholder="Write your answer here⦠Markdown is supported." rows="4" aria-label="Your answer" maxlength="5000"></textarea>
</div>
<div id="writePreviewPane" role="tabpanel" aria-labelledby="writeTabPreview" class="write-preview md-body"></div>
<div class="char-count" id="writeCharCount"><span id="writeCharCur">0</span> / 5000</div>
<div class="write-actions">
<button class="write-submit" id="writeSubmit">Submit answer</button>
<button class="write-cancel" id="writeCancel">Cancel</button>
</div>
</div>`;
}
function renderAnswerBlock(answer, idx, isBest) {
const v = activeVersion(answer); if (!v) return '';
const rawText = v.text||'';
const label = isBest ? `<span class="chip good">β best answer</span>` : `<span class="chip muted">answer ${idx+1}</span>`;
const bubbleId = isBest ? 'id="bestAnswerText"' : '';
const bubbleClass = isBest ? 'best-answer-bubble md-body' : 'bubble md-body';
const glowClass = isBest ? 'answer-new-glow' : '';
return `
<div ${bubbleId} class="${bubbleClass} ${glowClass}" tabindex="-1">${isBest ? '' : renderMarkdownWithThinking(rawText)}</div>
<div class="turn-meta" style="margin-top:var(--space-1);">
${label} ${renderQualityDots(rawText)}
<span>${esc(v.author||'Anonymous')}</span><span aria-hidden="true">Β·</span>
<span>${relativeTime(v.created_at)}</span>
</div>
${renderVoteRow(answer.id, v)}
<div style="display:flex;gap:var(--space-1);flex-wrap:wrap;margin-top:var(--space-1);">
${renderVersions(answer)} ${renderPropose(answer.id)}
</div>`;
}
function renderOtherAnswers(answers) {
if (answers.length<=1) return '';
const others = answers.slice(1);
return `
<button class="other-answers-toggle" type="button" id="otherAnswersToggle" aria-controls="otherAnswersPanel" aria-expanded="false">
<span class="arrow" aria-hidden="true">βΆ</span> ${others.length} other answer${others.length>1?'s':''}
</button>
<div class="other-answers-panel" id="otherAnswersPanel" role="region" aria-label="Other answers">
${others.map((a,i)=>{
const v=activeVersion(a); if(!v) return '';
return `<div class="other-answer-card">
<div class="other-answer-head">
<span class="chip muted">answer ${i+2}</span>
<span>${esc(v.author||'Anonymous')}</span><span aria-hidden="true">Β·</span>
<span>${relativeTime(v.created_at)}</span> ${renderQualityDots(v.text||'')}
</div>
<div class="other-answer-text md-body">${renderMarkdownWithThinking(v.text||'')}</div>
${renderVoteRow(a.id, v)}
<div style="display:flex;gap:var(--space-1);flex-wrap:wrap;margin-top:var(--space-1);">
${renderVersions(a)} ${renderPropose(a.id)}
</div>
</div>`;
}).join('')}
</div>`;
}
function renderRelated(rel) {
if (!rel?.length) return '';
return `
<div class="related-stack">
<div class="chip muted">from similar questions</div>
<button class="related-toggle" type="button" id="relatedToggle" aria-controls="relatedPanel" aria-expanded="false">
<span class="arrow" aria-hidden="true">βΆ</span> ${rel.length} related answer${rel.length>1?'s':''}
</button>
<div class="related-panel" id="relatedPanel" role="region" aria-label="Related answers">
${rel.map(r=>`
<div class="other-answer-card related">
<div class="other-answer-head">
<span class="chip matched">related</span>
<span class="chip related-score">score ${Number(r.score||0).toFixed(2)}</span>
</div>
<div class="preview-block"><span class="preview-label">Q</span>
<div class="preview-text">${esc(previewText(r.question||''))}</div></div>
<div class="preview-block"><span class="preview-label">A</span>
<div class="preview-text muted-preview">${esc(previewText(r.answer||''))}</div></div>
<div class="preview-actions">
<button class="ask-btn" type="button" data-ask-question="${esc(r.question||'')}" aria-label="Ask this question">${ASK_SVG} Ask</button>
</div>
</div>`).join('')}
<p class="related-note">Previews of answers from semantically similar questions. Click Ask to start a fresh conversation.</p>
</div>
</div>`;
}
/* βββββββββββββββββββββββββββββββββββββββββββ
MAIN RENDER
βββββββββββββββββββββββββββββββββββββββββββ */
async function renderConversation(questionText, doAnimate) {
const renderId = beginRenderSession();
const tr=$('transcript'), wl=$('welcome');
const frag = document.createDocumentFragment();
if (!S.conversation) {
wl.style.display=''; tr.replaceChildren();
setJumpLatest(false); document.title=S.originalTitle;
updateWelcomeState(); finishRenderSession(renderId); return;
}
wl.style.display='none';
const q = questionText||S.conversation.question||'';
document.title = q.slice(0,60)+' β '+S.originalTitle;
if (S.conversation.id) history.replaceState({cid:S.conversation.id},'', normalizeConversationPath(S.conversation.id));
const isNew = !S.conversation.created_at || (Date.now()-new Date(S.conversation.created_at).getTime())<10000;
const questionNote = isNew
? `<div class="question-note">π You're the first to ask this!</div>`
: `<div class="question-note">Asked ${relativeTime(S.conversation.created_at)}</div>`;
appendHTML(frag, `
<div class="turn user new-turn"><div>
<div class="bubble">${nl2br(q)}</div>
<div class="turn-meta"><span class="chip muted">question</span><span>${relativeTime(S.conversation.created_at)}</span></div>
${questionNote}
</div><div class="avatar user" aria-hidden="true">U</div></div>`);
const answers = sortedAnswers(S.conversation);
if (!answers.length) {
appendHTML(frag, `
<div class="turn assistant new-turn"><div class="avatar assistant" aria-hidden="true">β¦</div><div>
<div class="bubble no-answer-bubble" role="status">β³ No answer yet. Be the first to write one.</div>
<div class="turn-meta"><span class="chip warn">β³ awaiting answer</span></div>
${renderWriteAnswer(S.conversation.id)}
<div id="relatedMount"></div>
</div></div>`);
} else {
appendHTML(frag, `
<div class="turn assistant new-turn"><div class="avatar assistant" aria-hidden="true">β¦</div>
<div style="min-width:0;flex:1;">
${renderAnswerBlock(answers[0], 0, true)}
${renderWriteAnswer(S.conversation.id)}
${renderOtherAnswers(answers)}
<div id="relatedMount"></div>
</div>
</div>`);
}
tr.replaceChildren(frag);
bindRichContent(tr);
if (answers.length) {
const bestV = activeVersion(answers[0]);
if (bestV) {
const el = $('bestAnswerText');
if (doAnimate && shouldAnimateResponses()) {
const completed = await animateText(el, bestV.text||'', renderId);
if (!completed) return;
} else if (el && isRenderSessionActive(renderId)) {
renderMarkdownInto(el, bestV.text||'', true);
finalizeThinkingBlocks(el);
}
}
}
if (!isRenderSessionActive(renderId)) return;
const rm = $('relatedMount');
if (rm && S.relatedAnswers.length) rm.innerHTML = renderRelated(S.relatedAnswers);
bindRichContent(tr);
bindHandlers(); scrollBottom(); restoreDraft();
finishRenderSession(renderId);
}
/* βββββββββββββββββββββββββββββββββββββββββββ
DRAFTS
βββββββββββββββββββββββββββββββββββββββββββ */
function draftKey() { return S.conversation ? `hi_draft_${S.conversation.id}` : null; }
function saveDraft(text) { const k=draftKey(); if(!k) return; text ? localStorage.setItem(k,text) : localStorage.removeItem(k); }
function clearDraft() { const k=draftKey(); if(k) localStorage.removeItem(k); }
function restoreDraft() {
const k=draftKey(); if(!k) return;
const saved = localStorage.getItem(k);
const ta = $('writeTextarea');
if (saved && ta) {
ta.value = saved; updateCharCount(ta,'writeCharCur',5000);
const panel=$('writePanel'), btn=$('writeAnswerBtn');
if (panel&&btn) { panel.classList.add('open'); btn.setAttribute('aria-expanded','true'); }
}
}
function updateCharCount(ta, spanId, max) {
const span=$(spanId); if(!span) return;
const len=ta.value.length; span.textContent=len;
const row=span.closest('.char-count');
if(row){ row.classList.toggle('near-limit',len>max*.85&&len<=max); row.classList.toggle('over-limit',len>max); }
}
function updateWelcomeState() {
const title=$('welcomeTitle'); if(!title) return;
title.textContent = localStorage.getItem('hi_last_cid')
? 'Welcome back. Ask something new.'
: 'Ask a question. Get answers from real people.';
}
/* βββββββββββββββββββββββββββββββββββββββββββ
EVENT DELEGATION
βββββββββββββββββββββββββββββββββββββββββββ */
function bindHandlers() {
const tr=$('transcript');
if (tr._delegated) return;
tr._delegated = true;
tr.addEventListener('click', async e => {
const voteBtn = e.target.closest('[data-vote]');
if (voteBtn) { await handleVote(voteBtn); return; }
const askQ = e.target.closest('[data-ask-question]');
if (askQ) { handleAskFromCard(askQ.getAttribute('data-ask-question')); return; }
if (e.target.closest('[data-ask-current]')) { handleAskFromCard(S.currentQuestion); return; }
const copyAns = e.target.closest('[data-copy-answer]');
if (copyAns) { await handleCopyAnswer(copyAns); return; }
const toggleVer = e.target.closest('[data-toggle-versions]');
if (toggleVer) { handleToggleVersions(toggleVer); return; }
if (e.target.closest('#otherAnswersToggle')) { handleTogglePanel('otherAnswersToggle','otherAnswersPanel'); return; }
if (e.target.closest('#relatedToggle')) { handleTogglePanel('relatedToggle','relatedPanel'); return; }
const proposeBtn = e.target.closest('[data-propose]');
if (proposeBtn) { handleProposeToggle(proposeBtn); return; }
const cancelProp = e.target.closest('[data-cancel-propose]');
if (cancelProp) { handleProposeCancel(cancelProp); return; }
const submitProp = e.target.closest('[data-submit-proposal]');
if (submitProp) { await handleSubmitProposal(submitProp); return; }
if (e.target.closest('#writeAnswerBtn')) { handleWriteToggle(); return; }
if (e.target.closest('#writeCancel')) { handleWriteCancel(); return; }
if (e.target.closest('#writeSubmit')) { await handleWriteSubmit(); return; }
if (e.target.closest('#writeTabEdit')) { handleWriteTab('edit'); return; }
if (e.target.closest('#writeTabPreview')) { handleWriteTab('preview'); return; }
});
tr.addEventListener('input', e => {
const ta = e.target;
if (ta.tagName!=='TEXTAREA') return;
autoGrow(ta);
if (ta.id==='writeTextarea') {
updateCharCount(ta,'writeCharCur',5000);
saveDraft(ta.value);
const preview=$('writePreviewPane');
if (preview?.classList.contains('write-preview') && !preview.style.display?.includes('none')) {
renderMarkdownInto(preview, ta.value, true);
}
} else {
const panel = ta.closest('.propose-panel');
if (panel) {
const ccSpan=qs('.cc-cur',panel);
if(ccSpan){ ccSpan.textContent=ta.value.length;
const ccRow=qs('.char-count',panel);
if(ccRow){ ccRow.classList.toggle('near-limit',ta.value.length>4250); ccRow.classList.toggle('over-limit',ta.value.length>5000); }
}
}
}
});
}
/* ββ Individual Handlers ββ */
const handleVote = debounceClick(async btn => {
if (!S.conversation) return;
const [aid,vid,d] = btn.getAttribute('data-vote').split('|');
const delta = Number(d);
const answer = (S.conversation.answers||[]).find(a=>a.id===aid);
const ver = answer?.versions?.find(v=>v.id===vid);
const myVote = ver?.votes_by_client?.[S.clientId];
const effectiveDelta = myVote===delta ? 0 : delta;
const countEl = qs('.vote-count-inner',btn.parentElement);
const prevCount = countEl ? Number(countEl.textContent) : 0;
if (countEl) {
const newCount = prevCount + (effectiveDelta===0 ? -delta : delta);
countEl.style.transform = `translateY(${delta>0?'-100%':'100%'})`;
requestAnimationFrame(()=>{ countEl.textContent=newCount; countEl.style.transform=''; });
}
btn.classList.toggle('voted-up', effectiveDelta===1);
btn.classList.toggle('voted-down', effectiveDelta===-1);
if ('vibrate' in navigator) navigator.vibrate(10);
S.lastAction = ()=>handleVote(btn);
const res = await callAPI('vote',{
conversation_id:S.conversation.id, answer_id:aid, version_id:vid, delta:effectiveDelta
});
if (res.ok) {
S.conversation=res.conversation; save();
updateVoteBtn(btn,aid,vid,res.conversation);
} else {
if(countEl) countEl.textContent=prevCount;
btn.classList.toggle('voted-up', myVote===1);
btn.classList.toggle('voted-down', myVote===-1);
toast(res.error||'Vote failed','bad',S.lastAction);
}
});
function updateVoteBtn(btn,aid,vid,conv) {
const answer=(conv.answers||[]).find(a=>a.id===aid);
const ver=answer?.versions?.find(v=>v.id===vid);
if(!ver) return;
const myVote=ver.votes_by_client?.[S.clientId];
const cnt=Number(ver.votes||0);
const countEl=qs('.vote-count-inner',btn.parentElement);
if(countEl) countEl.textContent=cnt;
const vu=myVote===1, vd=myVote===-1;
btn.classList.toggle('voted-up',vu); btn.classList.toggle('voted-down',vd);
if(btn.getAttribute('data-vote').endsWith('|1')){
btn.setAttribute('aria-label',`Upvote. ${cnt} vote${cnt!==1?'s':''}. ${vu?'You voted.':'Not voted.'}`);
btn.setAttribute('aria-pressed',String(vu));
} else btn.setAttribute('aria-pressed',String(vd));
}
async function handleCopyAnswer(btn) {
const answer=(S.conversation?.answers||[]).find(a=>a.id===btn.getAttribute('data-copy-answer'));
const ver=activeVersion(answer); if(!ver) return;
try { await navigator.clipboard.writeText(ver.text||''); toast('Answer copied','good'); }
catch { toast('Could not copy','bad'); }
}
function handleAskFromCard(q) {
const text=String(q||'').trim();
if(!text||S.loading) return;
const p=$('prompt'); if(p){p.value=text;autoGrow(p);} submitPrompt();
}
function handleToggleVersions(btn) {
const id=btn.getAttribute('data-toggle-versions'), p=$('vp-'+id); if(!p) return;
const open=p.classList.toggle('open');
const arrow=qs('.arrow',btn); if(arrow) arrow.style.transform=open?'rotate(90deg)':'';
btn.setAttribute('aria-expanded',String(open));
}
function handleTogglePanel(toggleId, panelId) {
const toggle=$(toggleId), panel=$(panelId); if(!toggle||!panel) return;
const open=panel.classList.toggle('open');
toggle.classList.toggle('open',open); toggle.setAttribute('aria-expanded',String(open));
}
function handleProposeToggle(btn) {
const id=btn.getAttribute('data-propose'), p=$('pp-'+id); if(!p) return;
const open=p.classList.toggle('open'); btn.setAttribute('aria-expanded',String(open));
if(open){const ta=qs('textarea',p); if(ta) setTimeout(()=>ta.focus(),80);}
}
function handleProposeCancel(btn) {
const id=btn.getAttribute('data-cancel-propose'), p=$('pp-'+id);
if(p) p.classList.remove('open');
const trigger=qs(`[data-propose="${id}"]`);
if(trigger){trigger.setAttribute('aria-expanded','false');trigger.focus();}
}
const handleSubmitProposal = debounceClick(async btn => {
const aid=btn.getAttribute('data-submit-proposal');
const box=$('pp-'+aid), ta=box?qs('textarea',box):null;
const text=ta?ta.value.trim():'';
if(!text){toast('Empty proposal','bad');return;} if(!S.conversation) return;
btn.disabled=true; const orig=btn.textContent; btn.textContent='Savingβ¦';
showStatus('Saving proposalβ¦');
S.lastAction=()=>handleSubmitProposal(btn);
const res=await callAPI('propose',{conversation_id:S.conversation.id,answer_id:aid,text});
hideStatus(); btn.disabled=false; btn.textContent=orig;
if(res.ok){S.conversation=res.conversation;save();renderConversation(S.currentQuestion,false);toast('Version proposed','good');}
else toast(res.error||'Error','bad',S.lastAction);
});
function handleWriteToggle() {
const p=$('writePanel'),btn=$('writeAnswerBtn'); if(!p||!btn) return;
const open=p.classList.toggle('open'); btn.setAttribute('aria-expanded',String(open));
if(open){const ta=$('writeTextarea');if(ta) setTimeout(()=>ta.focus(),100);}
}
function handleWriteCancel() {
const p=$('writePanel'); if(p) p.classList.remove('open');
const btn=$('writeAnswerBtn'); if(btn){btn.setAttribute('aria-expanded','false');btn.focus();}
}
function handleWriteTab(mode) {
const editTab=$('writeTabEdit'),previewTab=$('writeTabPreview');
const editorPane=$('writeEditorPane'),previewPane=$('writePreviewPane');
if(!editTab||!previewTab||!editorPane||!previewPane) return;
if(mode==='edit'){
editTab.classList.add('active'); editTab.setAttribute('aria-selected','true');
previewTab.classList.remove('active'); previewTab.setAttribute('aria-selected','false');
editorPane.style.display=''; previewPane.style.display='none';
previewPane.classList.remove('active'); $('writeTextarea')?.focus();
} else {
previewTab.classList.add('active'); previewTab.setAttribute('aria-selected','true');
editTab.classList.remove('active'); editTab.setAttribute('aria-selected','false');
editorPane.style.display='none'; previewPane.style.display='';
previewPane.classList.add('active');
const ta=$('writeTextarea');
previewPane.innerHTML = '';
if (ta) {
renderMarkdownInto(previewPane, ta.value, true);
} else {
previewPane.innerHTML = '<p style="color:var(--muted)">Nothing to preview.</p>';
}
}
}
const handleWriteSubmit = debounceClick(async () => {
const ta=$('writeTextarea'), text=ta?ta.value.trim():'';
if(!text){toast('Empty answer','bad');return;} if(!S.conversation) return;
const ws=$('writeSubmit');
if(ws){ws.disabled=true;ws.textContent='Savingβ¦';} showStatus('Saving answerβ¦');
S.lastAction=handleWriteSubmit;
const res=await callAPI('answer',{conversation_id:S.conversation.id,text,question:S.currentQuestion});
hideStatus(); if(ws){ws.disabled=false;ws.textContent='Submit answer';}
if(res.ok){
S.conversation=res.conversation; clearDraft(); save();
await renderConversation(S.currentQuestion,false); toast('Answer saved','good');
setTimeout(()=>{const el=$('bestAnswerText');if(el){el.setAttribute('tabindex','-1');el.focus();}},200);
} else toast(res.error||'Error','bad',S.lastAction);
});
/* βββββββββββββββββββββββββββββββββββββββββββ
AUTOCOMPLETE
βββββββββββββββββββββββββββββββββββββββββββ */
const debouncedAutocomplete = debounce(async q => {
if(!q||q.length<4){closeAutocomplete();return;}
const res = await callAPI('search',{query:q,limit:5});
if(!res.ok||!res.results?.length){closeAutocomplete();return;}
showAutocomplete(res.results);
}, 300);
function showAutocomplete(results) {
const dd=$('autocompleteDropdown'); if(!dd) return;
dd.innerHTML = results.map((r,i)=>
`<div class="autocomplete-item" role="option" tabindex="-1" data-ac-q="${esc(r.question)}" id="ac-item-${i}">
<span class="autocomplete-match">${esc(r.question)}</span>
<span class="autocomplete-meta">${Number(r.answer_count||0)} answer${Number(r.answer_count||0)!==1?'s':''}</span>
</div>`).join('');
dd.classList.add('open');
qsa('.autocomplete-item',dd).forEach(item=>{
item.addEventListener('click',()=>{
$('prompt').value=item.getAttribute('data-ac-q');
closeAutocomplete(); submitPrompt();
});
});
}
function closeAutocomplete() { $('autocompleteDropdown')?.classList.remove('open'); }
/* βββββββββββββββββββββββββββββββββββββββββββ
API
βββββββββββββββββββββββββββββββββββββββββββ */
function save() { if(S.conversation) localStorage.setItem('hi_last_cid',S.conversation.id); }
const inflightRequests = new Set();
async function callAPI(action, payload={}) {
const key = action+':'+JSON.stringify(payload);
if ((action==='search'||action==='get_conversation') && inflightRequests.has(key))
return {ok:false,error:'Request in progress'};
inflightRequests.add(key);
try {
const resp = await fetch('/api',{
method:'POST',
headers:{'Content-Type':'application/json','X-Client-Id':S.clientId},
body:JSON.stringify({action,client_id:S.clientId,...payload}),
});
const data = await resp.json().catch(()=>null);
if(!resp.ok) return data&&typeof data==='object' ? data : {ok:false,error:`Request failed (${resp.status})`};
return data||{ok:false,error:'Empty response from server'};
} catch(err) { return {ok:false,error:err?.message||'Network error'}; }
finally { inflightRequests.delete(key); }
}
/* βββββββββββββββββββββββββββββββββββββββββββ
ASK / SUBMIT
βββββββββββββββββββββββββββββββββββββββββββ */
async function askQuestion(q) {
cancelActiveRender();
showStatusWithEscalation(); showTyping();
S.loading=true; $('sendBtn').disabled=true; closeAutocomplete();
S.lastAction=()=>askQuestion(q);
const res = await callAPI('ask',{question:q});
removeTyping(); hideStatus(); S.loading=false; $('sendBtn').disabled=false;
if(!res.ok){toast(res.error||'Error','bad',S.lastAction);return;}
S.conversation=res.conversation; S.currentQuestion=q;
S.relatedAnswers=Array.isArray(res.related)?res.related:[];
save(); toast(res.matched?'β Existing answer found':'β New question created','good');
await renderConversation(q, shouldAnimateResponses());
}
async function submitPrompt() {
const p=$('prompt'), text=p.value.trim();
if(!text||S.loading) return;
p.value=''; autoGrow(p); await askQuestion(text);
}
function autoGrow(el) {
el.style.height='auto';
let h=Math.min(el.scrollHeight,180); if(h<40) h=40;
requestAnimationFrame(()=>{el.style.height=h+'px';});
}
/* βββββββββββββββββββββββββββββββββββββββββββ
LOAD SAVED
βββββββββββββββββββββββββββββββββββββββββββ */
function showConversationSkeleton() {
const tr=$('transcript'), wl=$('welcome');
wl.style.display='none';
tr.innerHTML=`<div class="skeleton-wrap">
<div class="skeleton skeleton-bubble"></div>
<div class="skeleton skeleton-line long"></div>
<div class="skeleton skeleton-line medium"></div>
<div class="skeleton skeleton-line short"></div></div>`;
}
async function loadConversationById(id, opts = {}) {
const {
clearLocalOnMissing = false,
replaceHistoryOnMissing = false,
showMissingToast = false,
showSkeleton = true,
statusText = 'Loading conversationβ¦',
} = opts;
if (!id) return false;
cancelActiveRender();
if (showSkeleton) showConversationSkeleton();
showStatus(statusText);
const res=await callAPI('get_conversation',{conversation_id:id});
hideStatus();
if(res.ok&&res.conversation){
S.conversation=res.conversation; S.currentQuestion=res.conversation.question||'';
S.relatedAnswers=[]; save();
await renderConversation(S.currentQuestion,false);
return true;
}
S.conversation = null; S.currentQuestion = ''; S.relatedAnswers = [];
$('transcript').innerHTML=''; $('welcome').style.display='';
updateWelcomeState();
if(clearLocalOnMissing) localStorage.removeItem('hi_last_cid');
if(replaceHistoryOnMissing) history.replaceState({},'',normalizeConversationPath());
if(showMissingToast) toast('Conversation not found','bad');
return false;
}
async function loadInitialConversation() {
if (S.routeConversationId) {
const fromRoute = await loadConversationById(S.routeConversationId, {
replaceHistoryOnMissing: true,
showMissingToast: true,
});
if (fromRoute) return;
}
const savedId = localStorage.getItem('hi_last_cid');
if (savedId) {
await loadConversationById(savedId, { clearLocalOnMissing: true });
}
}
/* βββββββββββββββββββββββββββββββββββββββββββ
NEW CHAT
βββββββββββββββββββββββββββββββββββββββββββ */
async function newChat() {
if(qsa('textarea').some(t=>t.value.trim())){
if(!await confirmModal('Start a new chat?','You have unsaved content. It will be lost.')) return;
}
cancelActiveRender();
S.conversation=null; S.currentQuestion=''; S.relatedAnswers=[]; S.atBottom=true;
S.routeConversationId='';
localStorage.removeItem('hi_last_cid');
$('transcript').innerHTML=''; $('welcome').style.display='';
updateWelcomeState(); setJumpLatest(false); $('prompt').value='';
autoGrow($('prompt')); history.replaceState({},'',normalizeConversationPath());
document.title=S.originalTitle; $('prompt').focus();
}
function confirmModal(title, msg) {
return new Promise(resolve => {
$('confirmTitle').textContent=title; $('confirmMsg').textContent=msg;
$('confirmBackdrop').classList.add('open'); $('confirmOk').focus();
function cleanup(r){$('confirmBackdrop').classList.remove('open');$('confirmOk').onclick=null;$('confirmCancel').onclick=null;resolve(r);}
$('confirmOk').onclick=()=>cleanup(true); $('confirmCancel').onclick=()=>cleanup(false);
});
}
/* βββββββββββββββββββββββββββββββββββββββββββ
SETTINGS
βββββββββββββββββββββββββββββββββββββββββββ */
function initSettings() {
const panel=$('settingsPanel'), btn=$('settingsBtn'), backdrop=$('settingsBackdrop');
function setOpen(open, focusEl=null) {
panel.classList.toggle('open',open); backdrop.classList.toggle('visible',open);
btn.setAttribute('aria-expanded',String(open)); panel.inert=!open;
if(open){qs('.anim-option',panel)?.focus();} else if(focusEl) focusEl.focus();
}
btn.onclick=()=>setOpen(!panel.classList.contains('open'));
$('settingsClose').onclick=()=>setOpen(false,btn);
backdrop.onclick=()=>setOpen(false,btn);
document.addEventListener('keydown',e=>{if(e.key==='Escape'&&panel.classList.contains('open'))setOpen(false,btn);});
// Animation options
const animOpts=qsa('.anim-option',$('animSegment'));
function syncAnim(){
animOpts.forEach(o=>{
const mode = o.getAttribute('data-anim');
const active = S.animMode===mode;
const motion = getMotion(mode);
o.classList.toggle('active',active);
o.classList.toggle('anim-static', mode==='none');
o.setAttribute('aria-checked',String(active));
o.style.setProperty('--anim-preview-duration', `${Math.max(motion.previewDuration, 1)}ms`);
o.style.setProperty('--anim-preview-ease', motion.previewEase);
});
}
async function applyAnimMode(mode) {
if (!mode || mode === S.animMode) return;
const hadActiveRender = S.rendering;
S.animMode=mode;
localStorage.setItem('hi_anim',S.animMode);
syncAnim();
if (S.conversation && hadActiveRender) {
cancelActiveRender();
await renderConversation(S.currentQuestion, shouldAnimateResponses());
}
}
animOpts.forEach(o=>{
o.addEventListener('click',async ()=>{ await applyAnimMode(o.getAttribute('data-anim')); });
o.addEventListener('keydown',e=>{if(e.key==='Enter'||e.key===' '){e.preventDefault();o.click();}});
});
// Density options
const densityOpts=qsa('.density-option',$('densitySegment'));
function syncDensity(){
densityOpts.forEach(o=>{const a=S.density===o.getAttribute('data-density');o.classList.toggle('active',a);o.setAttribute('aria-checked',String(a));});
document.documentElement.setAttribute('data-density',S.density);
}
densityOpts.forEach(o=>{
o.addEventListener('click',()=>{S.density=o.getAttribute('data-density');localStorage.setItem('hi_density',S.density);syncDensity();});
o.addEventListener('keydown',e=>{if(e.key==='Enter'||e.key===' '){e.preventDefault();o.click();}});
});
$('jumpLatest').onclick=()=>scrollBottom(true);
$('lightbox').onclick=e=>{if(e.target===$('lightbox'))closeLightbox();};
$('lightboxClose').onclick=closeLightbox;
panel.inert=true; syncAnim(); syncDensity();
}
/* βββββββββββββββββββββββββββββββββββββββββββ
COMMAND PALETTE
βββββββββββββββββββββββββββββββββββββββββββ */
const COMMANDS = [
{icon:'β¦',label:'New chat',shortcut:'Ctrl+N',action:newChat},
{icon:'π',label:'Copy best answer',action:async()=>{
const el=$('bestAnswerText');if(!el){toast('No answer to copy','bad');return;}
try{await navigator.clipboard.writeText(el.innerText);toast('Copied','good');}catch{toast('Could not copy','bad');}
}},
{icon:'β',label:'Write an answer',action:()=>$('writeAnswerBtn')?.click()},
{icon:'π',label:'Copy page URL',action:async()=>{
try{await navigator.clipboard.writeText(location.href);toast('URL copied','good');}catch{toast('Could not copy','bad');}
}},
{icon:'β',label:'Open settings',action:()=>$('settingsBtn').click()},
{icon:'β',label:'Jump to latest',action:()=>scrollBottom(true)},
];
let cmdFocusIdx=-1;
function openCommandPalette(){
$('cmdBackdrop').classList.add('open'); $('cmdInput').value='';
$('cmdInput').focus(); cmdFocusIdx=-1; renderCmdList('');
}
function closeCommandPalette(){$('cmdBackdrop').classList.remove('open');$('prompt').focus();}
function renderCmdList(query){
const list=$('cmdList'), q=query.toLowerCase();
const filtered=q?COMMANDS.filter(c=>c.label.toLowerCase().includes(q)):COMMANDS;
if(!filtered.length){list.innerHTML='<div class="cmd-empty">No commands found.</div>';return;}
list.innerHTML=filtered.map((c,i)=>
`<div class="cmd-item" role="option" data-cmd-idx="${i}" tabindex="-1">
<span class="cmd-item-icon" aria-hidden="true">${c.icon}</span>
<span class="cmd-item-label">${esc(c.label)}</span>
${c.shortcut?`<span class="cmd-item-shortcut">${esc(c.shortcut)}</span>`:''}
</div>`).join('');
list._filtered=filtered;
qsa('.cmd-item',list).forEach((item,i)=>{
item.addEventListener('click',()=>{closeCommandPalette();filtered[i].action();});
});
}
function initCommandPalette(){
const backdrop=$('cmdBackdrop'), input=$('cmdInput'), list=$('cmdList');
backdrop.addEventListener('click',e=>{if(e.target===backdrop)closeCommandPalette();});
input.addEventListener('input',()=>{cmdFocusIdx=-1;renderCmdList(input.value);});
input.addEventListener('keydown',e=>{
const items=qsa('.cmd-item',list);
if(e.key==='ArrowDown'){e.preventDefault();cmdFocusIdx=Math.min(cmdFocusIdx+1,items.length-1);items[cmdFocusIdx]?.focus();}
else if(e.key==='ArrowUp'){e.preventDefault();cmdFocusIdx=Math.max(cmdFocusIdx-1,-1);cmdFocusIdx<0?input.focus():items[cmdFocusIdx]?.focus();}
else if(e.key==='Escape') closeCommandPalette();
else if(e.key==='Enter'&&items.length) items[0]?.click();
});
}
/* βββββββββββββββββββββββββββββββββββββββββββ
GLOBAL KEYBOARD
βββββββββββββββββββββββββββββββββββββββββββ */
function initKeyboard(){
document.addEventListener('keydown',e=>{
const ctrl=e.ctrlKey||e.metaKey;
if(ctrl&&e.key==='k'){e.preventDefault();openCommandPalette();return;}
if(ctrl&&e.key==='n'){e.preventDefault();newChat();return;}
if(ctrl&&e.key==='Enter'&&e.target.tagName==='TEXTAREA'){
e.preventDefault();
if(e.target.id==='writeTextarea') handleWriteSubmit();
else{const p=e.target.closest('.propose-panel');if(p)qs('.propose-submit',p)?.click();}
return;
}
});
}
/* βββββββββββββββββββββββββββββββββββββββββββ
SUGGESTION CHIPS + PULL TO REFRESH
βββββββββββββββββββββββββββββββββββββββββββ */
function initSuggestionChips(){
qsa('.suggestion-chip').forEach(chip=>{
chip.addEventListener('click',()=>{
const q=chip.getAttribute('data-q'); if(!q) return;
$('prompt').value=q; autoGrow($('prompt')); submitPrompt();
});
});
}
function initPullToRefresh(){
const chat=$('chat'); let pullStart=0;
chat.addEventListener('touchstart',e=>{pullStart=chat.scrollTop===0?e.touches[0].clientY:0;},{passive:true});
chat.addEventListener('touchend',async e=>{
if(!pullStart) return;
if(e.changedTouches[0].clientY-pullStart>80&&S.conversation){
pullStart=0;
const ok = await loadConversationById(S.conversation.id, {
showSkeleton: false,
statusText: 'Refreshingβ¦',
});
if (ok) toast('Refreshed','good');
}
pullStart=0;
},{passive:true});
}
/* βββββββββββββββββββββββββββββββββββββββββββ
INIT
βββββββββββββββββββββββββββββββββββββββββββ */
async function init(){
updateAppHeight();
window.addEventListener('resize',updateAppHeight);
window.addEventListener('orientationchange',updateAppHeight);
if(window.visualViewport){
window.visualViewport.addEventListener('resize',updateAppHeight);
window.visualViewport.addEventListener('scroll',updateAppHeight);
}
if(window.matchMedia('(prefers-reduced-motion: reduce)').matches) S.animMode='none';
S.clientId=getClientId();
S.density=localStorage.getItem('hi_density')||'comfortable';
document.documentElement.setAttribute('data-density',S.density);
const chat=$('chat');
chat.addEventListener('scroll',()=>{
S.atBottom=isNearBottom(); if(S.atBottom) setJumpLatest(false); updateScrollProgress();
},{passive:true});
$('composeForm').addEventListener('submit',e=>{e.preventDefault();submitPrompt();});
$('sendBtn').addEventListener('click',e=>{e.preventDefault();submitPrompt();});
$('newChatBtn').addEventListener('click',newChat);
const prompt=$('prompt');
prompt.addEventListener('input',e=>{autoGrow(e.target);debouncedAutocomplete(e.target.value.trim());});
prompt.addEventListener('keydown',e=>{
if(e.key==='Enter'&&!e.shiftKey){e.preventDefault();submitPrompt();}
if(e.key==='Escape') closeAutocomplete();
if(e.key==='ArrowDown'){const f=qs('.autocomplete-item',$('autocompleteDropdown'));if(f){e.preventDefault();f.focus();}}
});
document.addEventListener('click',e=>{if(!e.target.closest('.compose-inner'))closeAutocomplete();});
initSettings(); initCommandPalette(); initKeyboard();
initSuggestionChips(); initPullToRefresh();
const d=window.__HI_INIT__||{};
if(d.client_id) S.clientId=d.client_id;
S.routeConversationId = String(d.conversation_id || '').trim();
updateWelcomeState(); await loadInitialConversation(); prompt.focus();
}
init();
})();
</script>
</body>
</html>
|