WARDROBE

Гардероб + библиотека костюмов Catwar. ИНСТРУКЦИЯ И ОБРАТНАЯ СВЯЗЬ: https://catwar.su/sniff1186155 | https://catwar.net/sniff1186155

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

You will need to install an extension such as Tampermonkey to install this script.

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

Advertisement:

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

Advertisement:

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name         WARDROBE
// @namespace    http://tampermonkey.net/
// @version      1.1.4
// @description  Гардероб + библиотека костюмов Catwar. ИНСТРУКЦИЯ И ОБРАТНАЯ СВЯЗЬ: https://catwar.su/sniff1186155 | https://catwar.net/sniff1186155
// @author       RESSOR
// @match        http*://*.catwar.net/rabbit*
// @match        http*://*.catwar.su/rabbit*
// @match        http*://*.catwar.net/settings_costumes*
// @match        http*://*.catwar.su/settings_costumes*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=catwar.su
// @license      MIT
// @grant        none
// ==/UserScript==

const PASS = [
    { name: "МИФИЧЕСКИЕ ЗВЕРИ", id: 12025 },      { name: "ЕГИПЕТ", id: 12053 },
    { name: "ТЁМНОЕ ФЭНТЕЗИ", id: 12119 },        { name: "ГОБЛИНКОР", id: 12335 },
    { name: "САМОЦВЕТЫ", id: 12389 },             { name: "МОРСКИЕ ГЛУБИНЫ", id: 12427 },
    { name: "ДОЛИНА ГРЁЗ", id: 12468 },           { name: "ОТТЕПЕЛЬ", id: 12524 },
    { name: "КОСМОС", id: 12604 },                { name: "СТИМПАНК", id: 12967 },
    { name: "ЯПОНИЯ", id: 13571 },                { name: "ДЖУНГЛИ", id: 13742 },
    { name: "ПИРАТЫ", id: 100000 },               { name: "ПРАЗДНИК УРОЖАЯ", id: 100494 },
    { name: "МАСКАРАД", id: 100634 },             { name: "ДИКИЙ ЗАПАД", id: 100929 },
    { name: "ЗИМНЯЯ СКАЗКА", id: 101431 },        { name: "ТЁМНЫЕ ПРОРОЧЕСТВА", id: 101970 },
    { name: "ПЕРВОБЫТНЫЙ МИР", id: 102899 },      { name: "МГНОВЕНИЯ ВЕСНЫ", id: 103309 },
    { name: "ПУТЕШЕСТВИЕ В КОСМОС", id: 103644 }, { name: "КИБЕРПАНК", id: 103813 },
    { name: "В ПОКОЯХ ЛЕСА", id: 104273 },        { name: "СЕРДЦЕ ПУСТЫНИ", id: 104575 },
];

const PASS_PASS = {
    PASS: { ids: [12025, 12026, 12027, 12028, 12029, 12030, 12031, 12032, 12033, 12034, 12035, 12036, 12037, 12038, 12039, 12040, 12041, 12049, 12053, 12054, 12055, 12056, 12057, 12058, 12059, 12060, 12061, 12062, 12063, 12064, 12065, 12066, 12067, 12068, 12069, 12070, 12071, 12072, 12073, 12074, 12075, 12076, 12077, 12078, 12079, 12080, 12081, 12082, 12083, 12084, 12085, 12086, 12087, 12088, 12089, 12090, 12091, 12092, 12093, 12094, 12095, 12096, 12097, 12098, 12099, 12100, 12101, 12102, 12103, 12104, 12105, 12106, 12119, 12120, 12121, 12122, 12123, 12124, 12125, 12126, 12127, 12128, 12129, 12130, 12131, 12132, 12133, 12134, 12135, 12136, 12137, 12138, 12139, 12140, 12141, 12142, 12143, 12260, 12261, 12262, 12263, 12264, 12265, 12266, 12267, 12268, 12269, 12270, 12271, 12272, 12273, 12274, 12275, 12276, 12277, 12278, 12279, 12280, 12281, 12282, 12283, 12284, 12285, 12286, 12287, 12288, 12289, 12290, 12291, 12292, 12293, 12294, 12295, 12296, 12297, 12298, 12299, 12300, 12301, 12311, 12312, 12313, 12314, 12315, 12316, 12317, 12318, 12319, 12173, 12174, 12175, 12176, 12177, 12178, 12179, 12180, 12181, 12182, 12183, 12184, 12185, 12186, 12187, 12188, 12189, 12190, 12191, 12192, 12193, 12194, 12195, 12196, 12197, 12198, 12199, 12200, 12201, 12202, 12203, 12204, 12205, 12206, 12207, 12208, 12209, 12210, 12211, 12212, 12213, 12214, 12215, 12216, 12217, 12218, 12219, 12220, 12221, 12222, 12223, 12224, 12225, 12226, 12227, 12228, 12229, 12230, 12231, 12232, 12305, 12306, 12307, 12338, 12339, 12340, 12344, 12345, 12346, 12362, 12363, 12364, 12365, 12366, 12367, 12368, 12369, 12370, 12371, 12372, 12373, 12374, 12375, 12376, 12377, 12378, 12379, 12380, 12381, 12382, 12383, 12384, 12385, 12386, 12387, 12388, 12389, 12390, 12391, 12392, 12393, 12394, 12395, 12396, 12415, 12416, 12417, 12421, 12422, 12423, 12424, 12425, 12426, 12427, 12428, 12429, 12430, 12431, 12432, 12433, 12434, 12441, 12442, 12443, 12444, 12445, 12446, 12457, 12458, 12459, 12460, 12461, 12462, 12463, 12464, 12465, 12466, 12468, 12469, 12470, 12471, 12472, 12473, 12474, 12475, 12476, 12477, 12478, 12479, 12480, 12481, 12482, 12483, 12484, 12485, 12486, 12487, 12488, 12489, 12490, 12491, 12492, 12493, 12494, 12495, 12496, 12509, 12510, 12511, 12512, 12513, 12514, 12500, 12501, 12502, 12503, 12504, 12505, 12506, 12507, 12508, 2515, 12516, 12517, 12524, 12525, 12526, 12527, 12528, 12529, 12530, 12531, 12532, 12533, 12599, 12600, 12601, 12604, 12605, 12606, 12607, 12608, 12609, 12610, 12611, 12612, 12613, 12614, 12615, 12616, 12617, 12618, 12619, 12620, 12621, 12622, 12623, 12624, 12625, 12626, 12627, 12628, 12629, 12630, 12631, 12632, 12633, 12634, 12635, 12636, 12637, 12638, 12639, 12640, 12641, 12642, 12643, 12644, 12645, 12646, 12647, 12648, 12649, 12650, 12651, 12652, 12653, 12654, 12655, 12656, 12657, 12658, 12659, 12660, 12661, 12662, 12663, 12664, 12665, 12666, 12667, 12668, 12669, 12670, 12671, 12672, 12673, 12674, 12675, 12676, 12677, 12678, 12679, 12680, 12681, 12682, 12683, 12684, 12685, 12686, 12687, 12693, 12694, 12695, 12696, 12933, 12934, 12935, 12936, 12937, 12938, 12939, 12940, 12941, 12948, 12967, 12968, 12969, 12970, 12971, 12972, 12973, 12974, 12975, 12976, 12977, 12978, 12979, 12980, 12981, 12982, 12983, 12984, 12985, 12986, 12987, 12988, 12989, 12990, 12991, 12992, 12993, 12994, 12995, 12996, 12997, 12998, 12999, 13000, 13001, 13002, 13031, 13032, 13033, 13034, 13035, 13036, 13037, 13038, 13039, 13040, 13041, 13042, 13043, 13044, 13045, 13046, 13047, 13048, 13049, 13050, 13051, 13052, 13053, 13054, 13055, 13056, 13087, 13088, 13089, 13090, 13091, 13092, 13093, 13094, 13095, 13096, 13097, 13098, 13099, 13100, 13101, 13102, 13103, 13104, 13105, 13106, 13107, 13108, 13109, 13110, 13111, 13112, 13113, 13114, 13115, 13116, 13117, 13118, 13119, 13120, 13121, 13122, 13123, 13124, 13125, 13126, 13127, 13128, 13129, 13130, 13131, 13132, 13133, 13134, 13135, 13136, 13137, 13138, 13139, 13140, 13141, 13142, 13143, 13144, 13145, 13146, 13147, 13148, 13149, 13150, 13151, 13152, 13153, 13154, 13155, 13156, 13157, 13158, 13159, 13160, 13161, 13162, 13163, 13164, 13165, 13166, 13167, 13168, 13169, 13170, 13171, 13172, 13173, 13174, 13175, 13176, 13177, 13178, 13179, 13180, 13181, 13182, 13183, 13184, 13185, 13186, 13187, 13188, 13189, 13190, 13191, 13192, 13193, 13194, 13195, 13196, 13197, 13198, 13199, 13200, 13201, 13202, 13203, 13204, 13205, 13206, 13207, 13208, 13209, 13210, 13211, 13212, 13213, 13214, 13215, 13216, 13217, 13218, 13219, 13220, 13221, 13222, 13223, 13224, 13225, 13226, 13227, 13228, 13229, 13230, 13231, 13232, 13233, 13234, 13235, 13236, 13237, 13238, 13239, 13240, 13241, 13242, 13243, 13244, 13245, 13246, 13247, 13248, 13249, 13250, 13251, 13252, 13253, 13254, 13255, 13256, 13257, 13258, 13259, 13260, 13261, 13262, 13263, 13264, 13265, 13266, 13267, 13268, 13269, 13270, 13271, 13272, 13273, 13274, 13275, 13276, 13277, 13278, 13279, 13280, 13281, 13282, 13283, 13284, 13285, 13286, 13287, 13288, 13289, 13290, 13291, 13292, 13293, 13294, 13295, 13296, 13297, 13298, 13299, 13300, 13301, 13302, 13303, 13304, 13305, 13306, 13307, 13308, 13309, 13310, 13311, 13312, 13313, 13314, 13315, 13316, 13317, 13318, 13319, 13320, 13321, 13322, 13323, 13324, 13325, 13326, 13327, 13328, 13329, 13330, 13331, 13332, 13333, 13334, 13335, 13336, 13337, 13338, 13339, 13340, 13341, 13342, 13343, 13344, 13345, 13346, 13347, 13348, 13349, 13350, 13351, 13352, 13353, 13354, 13355, 13356, 13357, 13358, 13359, 13360, 13361, 13362, 13363, 13364, 13365, 13366, 13367, 13368, 13369, 13370, 13371, 13372, 13373, 13374, 13375, 13376, 13377, 13378, 13379, 13380, 13381, 13382, 13383, 13384, 13385, 13386, 13387, 13388, 13389, 13390, 13391, 13392, 13571, 13572, 13573, 13574, 13575, 13576, 13577, 13578, 13579, 13580, 13581, 13582, 13583, 13584, 13585, 13586, 13587, 13588, 13589, 13590, 13591, 13592, 13593, 13594, 13595, 13596, 13597, 13598, 13599, 13600, 13601, 13602, 13603, 13604, 13605, 13606, 13607, 13608, 13609, 13610, 13611, 13639, 13640, 13641, 13642, 13643, 13644, 13645, 13646, 13647, 13648, 13649, 13650, 13657, 13658, 13659, 13660, 13661, 13662, 13663, 13664, 13665, 13666, 13667, 13668, 13669, 13670, 13671, 13672, 13673, 13674, 13675, 13676, 13681, 13682, 13683, 13684, 13685, 13686, 13687, 13688, 13689, 13690, 13691, 13692, 13693, 13694, 13695, 13696, 13697, 13698, 13699, 13700, 13701, 13702, 13703, 13704, 13705, 13706, 13707, 13708, 13709, 13710, 13711, 13712, 13713, 13714, 13715, 13716, 13717, 13718, 13719, 13720, 13721, 13722, 13723, 13724, 13725, 13726, 13727, 13728, 13742, 13743, 13744, 13745, 13746, 13747, 13748, 13749, 13750, 13751, 13752, 13753, 13754, 13755, 13756, 13757, 13758, 13759, 13760, 13761, 13762, 13763, 13764, 13765, 13766, 13767, 13787, 13788, 13789, 13790, 13791, 13792, 13793, 13794, 13830, 13831, 13832, 13833, 13834, 13835, 13836, 13837, 13838, 13839, 13840, 13841, 13856, 13857, 13858, 13859, 13860, 13861, 13862, 13863, 13864, 13865, 14097, 14098, 14099, 14100, 14101, 14102, 14103, 14104, 14105, 14106, 14107, 14108, 14109, 14110, 14111, 14112, 14113, 14114, 14115, 14116, 14117, 14120, 14121, 100000, 100001, 100002, 100003, 100004, 100005, 100006, 100007, 100008, 100009, 100010, 100011, 100012, 100013, 100014, 100015, 100016, 100017, 100018, 100019, 100020, 100021, 100022, 100023, 100024, 100025, 100026, 100027, 100028, 100029, 100030, 100046, 100047, 100048, 100049, 100050, 100051, 100052, 100053, 100054, 100055, 100056, 100057, 100058, 100059, 100060, 100061, 100062, 100063, 100064, 100065, 100080, 100031, 100032, 100033, 100034, 100035, 100036, 100037, 100038, 100039, 100040, 100041, 100042, 100043, 100044, 100045, 100081, 100082, 100083, 100084, 100085, 100086, 100087, 100088, 100089, 100090, 100091, 100092, 100093, 100094, 100095, 100096, 100097, 100098, 100099, 100100, 100101, 100102, 100103, 100104, 100105, 100106, 100107, 100108, 100109, 100110, 100111, 100112, 100113, 100114, 100115, 100116, 100117, 100118, 100119, 100120, 100121, 100122, 100123, 100124, 100125, 100126, 100127, 100128, 100129, 100130, 100131, 100132, 100133, 100134, 100135, 100444, 100445, 100446, 100447, 100448, 100449, 100450, 100451, 100452, 100485, 100486, 100487, 100488, 100489, 100490, 100491, 100492, 100493, 100494, 100495, 100496, 100497, 100498, 100499, 100500, 100501, 100502, 100503, 100504, 100505, 100506, 100507, 100508, 100509, 100510, 100511, 100512, 100513, 100514, 100515, 100557, 100588, 100589, 100590, 100591, 100592, 100599, 100600, 100601, 100602, 100603, 100604, 100610, 100611, 100612, 100613, 100614, 100679, 100680, 100681, 100682, 100683, 100684, 100685, 100686, 100687, 100688, 100774, 100775, 100776, 100777, 100778, 100843, 100844, 100845, 100846, 100847, 100848, 100857, 100858, 100859, 100860, 100861, 100862, 100863, 100864, 100865, 100866, 100867, 100868, 100869, 100870, 100871, 100872, 100873, 100874, 100875, 100876, 100877, 100878, 100879, 100880, 100881, 100882, 100883, 100884, 100885, 100886, 100887, 100888, 100889, 100890, 100891, 100892, 100893, 100894, 100895, 100896, 100897, 100898, 100899, 100900, 100901, 100902, 100903, 100904, 100905, 100906, 100907, 100908, 100909, 100910, 100911, 100912, 100913, 100914, 100915, 100916, 100917, 100918, 100919, 100920, 100921, 100922, 100923, 100924, 100925, 100926, 100927, 100928, 101004, 101005, 101006, 101007, 101008, 101009, 101010, 101011, 101012, 101013, 101014, 101015, 101016, 101017, 101018, 101019, 101020, 101021, 101022, 101023, 101024, 101025, 101026, 101027, 101028, 101029, 101030, 101031, 101032, 101033, 101034, 101035, 101036, 101037, 101038, 101039, 101040, 101041, 101042, 101043, 101044, 101045, 101046, 101047, 101048, 101049, 101050, 101051, 101052, 101053, 101054, 101055, 101056, 101057, 101058, 101059, 101060, 101061, 101062, 101063, 101064, 101065, 101066, 101067, 101068, 101069, 101070, 101071, 101072, 101073, 101074, 101075, 101076, 101077, 101078, 101079, 101080, 101081, 101082, 101083, 101084, 101085, 101086, 101087, 101088, 101089, 101090, 101091, 101092, 101093, 101094, 101095, 101096, 101097, 101098, 101099, 101100, 101101, 101102, 101103, 101104, 101105, 101106, 101107, 101108, 101109, 101110, 101111, 101112, 101113, 101114, 101115, 101116, 101117, 101118, 101119, 101120, 101121, 101122, 101123, 101124, 101125, 101126, 101127, 101128, 101129, 101130, 101131, 101132, 101133, 101134, 101135, 101136, 101137, 101138, 101139, 101140, 101141, 101142, 101143, 101144, 101145, 101146, 101147, 101148, 101149, 101150, 101151, 101152, 101153, 101154, 101155, 101156, 101157, 101158, 101159, 101160, 101161, 101162, 101163, 101164, 101165, 101166, 101167, 101168, 101169, 101170, 101171, 101172, 101173, 101174, 101175, 101176, 101177, 101178, 101179, 101180, 101181, 101182, 101183, 101184, 101185, 101186, 101187, 101188, 101189, 101190, 101191, 101192, 101193, 101194, 101195, 101196, 101197, 101198, 101199, 101200, 101201, 101202, 101203, 101204, 101205, 101206, 101207, 101208, 101209, 101210, 101211, 101212, 101213, 101214, 101215, 101216, 101217, 101218, 101219, 101220, 101221, 101222, 101223, 101224, 101225, 101226, 101227, 101228, 101229, 101230, 101231, 101232, 101233, 101234, 101235, 101236, 101237, 101238, 101239, 101240, 101241, 101242, 101309, 101310, 101311, 101312, 101313, 101314, 101315, 101316, 101317, 101318, 101319, 101320, 101321, 101376, 101377, 101378, 101379, 101380, 101381, 101382, 101383, 101384, 101385, 101386, 101387, 101388, 101389, 101390, 101391, 101392, 101393, 101394, 101395, 101396, 101397, 101398, 101399, 101400, 101401, 101402, 101431, 101432, 101433, 101434, 101435, 101436, 101437, 101438, 101439, 101440, 101441, 101442, 101443, 101444, 101445, 101446, 101447, 101448, 101449, 101450, 101451, 101452, 101453, 101454, 101455, 101456, 101457, 101458, 101459, 101460, 101461, 101462, 101463, 101464, 101465, 101466, 101467, 101468, 101469, 101470, 101471, 101472, 101473, 101474, 101475, 101476, 101477, 101478, 101479, 101480, 101481, 101482, 101483, 101484, 101485, 101486, 101487, 101488, 101489, 101490, 101491, 101492, 101493, 101494, 101495, 101496, 101497, 101498, 101499, 101500, 101501, 101502, 101503, 101504, 101505, 101506, 101507, 101508, 101509, 101510, 101511, 101512, 101513, 101514, 101515, 101516, 101517, 101518, 101519, 101520, 101521, 101522, 101523, 101524, 101525, 101526, 101527, 101528, 101529, 101530, 101531, 101532, 101533, 101534, 101535, 101536, 101537, 101538, 101539, 101540, 101541, 101542, 101543, 101544, 101545, 101546, 101547, 101548, 101549, 101550, 101551, 101552, 101553, 101554, 101555, 101556, 101557, 101558, 101559, 101560, 101561, 101562, 101563, 101564, 101565, 101566, 101567, 101568, 101569, 101570, 101571, 101572, 101705, 101706, 101707, 101708, 101709, 101710, 101711, 101712, 101843, 101844, 101845, 101846, 101847, 101848, 101849, 101850, 101851, 101852, 101853, 101854, 101855, 101856, 101857, 101858, 101859, 101860, 101861, 101862, 101863, 101960, 101961, 101962, 101963, 101964, 101965, 101966, 101967, 101968, 101969, 101970, 101971, 101972, 101973, 101974, 101975, 101976, 101977, 101978, 101979, 101980, 101981, 101982, 101983, 101984, 101985, 101986, 101987, 101988, 101989, 101990, 101991, 101992, 101993, 101994, 101995, 101996, 101997, 101998, 101999, 102000, 102001, 102002, 102003, 102004, 102005, 102006, 102007, 102008, 102009, 102010, 102011, 102012, 102013, 102014, 102015, 102016, 102017, 102018, 102019, 102020, 102021, 102022, 102023, 102024, 102025, 102026, 102027, 102028, 102029, 102030, 102031, 102032, 102033, 102034, 102035, 102036, 102037, 102038, 102039, 102040, 102041, 102042, 102043, 102044, 102045, 102046, 102047, 102048, 102049, 102050, 102051, 102052, 102053, 102054, 102055, 102056, 102057, 102058, 102059, 102060, 102061, 102062, 102063, 102064, 102065, 102066, 102067, 102068, 102069, 102070, 102071, 102072, 102073, 102074, 102075, 102076, 102077, 102078, 102079, 102080, 102081, 102082, 102083, 102084, 102085, 102086, 102087, 102088, 102089, 102090, 102091, 102092, 102093, 102094, 102095, 102096, 102097, 102098, 102099, 102100, 102101, 102102, 102103, 102104, 102105, 102106, 102107, 102108, 102109, 102110, 102111, 102112, 102113, 102114, 102115, 102116, 102117, 102118, 102119, 102120, 102121, 102122, 102123, 102124, 102125, 102126, 102127, 102128, 102129, 102130, 102131, 102132, 102133, 102134, 102135, 102136, 102137, 102138, 102139, 102140, 102141, 102142, 102143, 102144, 102145, 102146, 102147, 102899, 102900, 102901, 102902, 102903, 102904, 102905, 102906, 102907, 102908, 102909, 102910, 102911, 102912, 102913, 102914, 102915, 102916, 102917, 102918, 102919, 102920, 102921, 102922, 102923, 102924, 102925, 102926, 102927, 102928, 102929, 102930, 102931, 102932, 102933, 102934, 102935, 102936, 102937, 102938, 102939, 102940, 102941, 102942, 102943, 102944, 102945, 102946, 102947, 102948, 102949, 102950, 102951, 102952, 102953, 102954, 102955, 102956, 102957, 102958, 102959, 102960, 102961, 102962, 102963, 102964, 102965, 102966, 102967, 102968, 102969, 102970, 102971, 102972, 102973, 102974, 102975, 102976, 102977, 102978, 102979, 102980, 102981, 102982, 102983, 102984, 102985, 102986, 102987, 102988, 102989, 102990, 102991, 102992, 102993, 102994, 102995, 102996, 102997, 102998, 102999, 103000, 103001, 103002, 103003, 103004, 103005, 103006, 103007, 103008, 103009, 103010, 103011, 103012, 103013, 103014, 103015, 103016, 103017, 103018, 103019, 103020, 103021, 103022, 103023, 103024, 103025, 103026, 103027, 103028, 103029, 103030, 103031, 103032, 103033, 103034, 103035, 103036, 103037, 103038, 103039, 103040, 103041, 103042, 103043, 103044, 103045, 103046, 103047, 103048, 103049, 103050, 103051, 103052, 103053, 103054, 103055, 103056, 103057, 103058, 103059, 103060, 103061, 103062, 103063, 103064, 103065, 103066, 103067, 103068, 103069, 103070, 103071, 103072, 103073, 103074, 103075, 103076, 103077, 103078, 103079, 103080, 103081, 103082, 103083, 103084, 103085, 103086, 103087, 103088, 103089, 103090, 103091, 103092, 103093, 103094, 103095, 103096, 103097, 103098, 103099, 103100, 103101, 103102, 103103, 103104, 103105, 103106, 103107, 103108, 103109, 103110, 103111, 103112, 103113, 103114, 103115, 103116, 103117, 103118, 103119, 103120, 103121, 103122, 103123, 103124, 103125, 103126, 103127, 103128, 103129, 103130, 103131, 103199, 103200, 103201, 103202, 103203, 103204, 103205, 103206, 103213, 103214, 103215, 103216, 103217, 103218, 103265, 103266, 103267, 103268, 103269, 103270, 103271, 103279, 103280, 103281, 103282, 103283, 103309, 103310, 103311, 103312, 103313, 103314, 103315, 103316, 103317, 103318, 103319, 103320, 103321, 103322, 103323, 103324, 103325, 103326, 103327, 103328, 103329, 103330, 103331, 103332, 103333, 103334, 103335, 103336, 103337, 103338, 103339, 103340, 103341, 103342, 103343, 103344, 103345, 103346, 103347, 103348, 103349, 103350, 103351, 103352, 103353, 103354, 103355, 103356, 103357, 103358, 103359, 103360, 103361, 103362, 103363, 103364, 103365, 103366, 103367, 103368, 103369, 103370, 103371, 103372, 103373, 103374, 103375, 103376, 103377, 103378, 103379, 103380, 103409, 103410, 103411, 103412, 103413, 103414, 103415, 103416, 103417, 103418, 103419, 103420, 103421, 103422, 103423, 103424, 103425, 103426, 103427, 103428, 103429, 103430, 103431, 103432, 103433, 103434, 103435, 103436, 103437, 103438, 103439, 103440, 103388, 103389, 103390, 103391, 103392, 103393, 103394, 103395, 103396, 103397, 103398, 103399, 103400, 103401, 103402, 103403, 103404, 103405, 103406, 103407, 103408, 103441, 103442, 103443, 103444, 103445, 103446, 103447, 103448, 103449, 103450, 103451, 103452, 103453, 103454, 103455, 103456, 103457, 103458, 103459, 103460, 103461, 103462, 103463, 103464, 103465, 103466, 103467, 103468, 103469, 103470, 103471, 103472, 103644, 103645, 103662, 103663, 103664, 103665, 103666, 103667, 103668, 103669, 103689, 103690, 103691, 103692, 103693, 103694, 103695, 103696, 103697, 103711, 103712, 103713, 103714, 103715, 103716, 103717, 103718, 103719, 103720, 103721, 103722, 103723, 103724, 103725, 103726, 103727, 103728, 103729, 103730, 103731, 103732, 103733, 103734, 103735, 103736, 103737, 103738, 103782, 103783, 103784, 103785, 103786, 103787, 103788, 103789, 103790, 103791, 103792, 103793, 103794, 103795, 103796, 103797, 103798, 103799, 103800, 103801, 103802, 103803, 103804, 103805, 103806, 103807, 103808, 103809, 103810, 103811, 103812, 103933, 103934, 103935, 103936, 103937, 103938, 103939, 103940, 103941, 103942, 103943, 103944, 103945, 103946, 103947, 103948, 103949, 103950, 104066, 104067, 104068, 104074, 104075, 104076, 104077, 104078, 104079, 104080, 104081, 104092, 104093, 104094, 104095, 104096, 104097, 104098, 104099, 104100, 104101, 104102, 104103, 104104, 104105, 104106, 104107, 104108, 104109, 104110, 104111, 104112, 104113, 104114, 104115, 104116, 104117, 104118, 104119, 104120, 104121, 104122, 104123, 104124, 104125, 104126, 104127, 104128, 104129, 104130, 104131, 104132, 104133, 104134, 104135, 104136, 104137, 104138, 104139, 104140, 104141, 104142, 104143, 104144, 104145, 104146, 104147, 104148, 104149, 104150, 104151, 104152, 104153, 104154, 104155, 104156, 104157, 104158, 104159, 104160, 104161, 104162, 104163, 104164, 104165, 104166, 104167, 104168, 104169, 104170, 104171, 104172, 104173, 104174, 104175, 104176, 104177, 104178, 104179, 104180, 104181, 104182, 104183, 104184, 104185, 104186, 104187, 104188, 104189, 104190, 104191, 104192, 104193, 104194, 104195, 104196, 104197, 104198, 104199, 104200, 104201, 104202, 104203, 104204, 104205, 104206, 104207, 104208, 104209, 104210, 104211, 104212, 104213, 104214, 104215, 104216, 104217, 104218, 104219, 104220, 104221, 104222, 104223, 104224, 104225, 104226, 104227, 104228, 104229, 104230, 104231, 104232, 104233, 104234, 104235, 104236, 104237, 104238, 104239, 104240, 104241, 104242, 104243, 104244, 104245, 104246, 104247, 104248, 104249, 104250, 104251, 104252, 104253, 104254, 104255, 104256, 104257, 104258, 104259, 104260, 104261, 104262, 104263, 104264, 104265, 104266, 104267, 104268, 104269, 104270, 104271, 104272, 104039, 104040, 104041, 104042, 104043, 104044, 104273, 104274, 104275, 104276, 104277, 104278, 104279, 104280, 104281, 104282, 104283, 104284, 104285, 104286, 104287, 104288, 104289, 104290, 104291, 104292, 104293, 104294, 104295, 104296, 104297, 104298, 104299, 104300, 104301, 104302, 104303, 104304, 104305, 104306, 104307, 104308, 104309, 104310, 104311, 104312, 104313, 104314, 104315, 104316, 104317, 104318, 104319, 104320, 104321, 104322, 104323, 104324, 104325, 104326, 104327, 104328, 104329, 104330, 104331, 104332, 104333, 104373, 104374, 104375, 104376, 104377, 104378, 104379, 104380, 104381, 104382, 104383, 104384, 104385, 104386, 104387, 104388, 104389, 104390, 104391, 104392, 104393, 104394, 104395, 104396, 104397, 104398, 104399, 104400, 104401, 104402, 104418, 104419, 104420, 104421, 104422, 104423, 104424, 104425, 104426, 104427, 104428, 104429, 104430, 104431, 104432, 104433, 104434, 104435, 104436, 104437, 104438, 104439, 104440, 104441, 104442, 104443, 104444, 104445, 104446, 104447, 104448, 104449, 104450, 104515, 104516, 104517, 104518, 104519, 104520, 104521, 104522, 104523, 104524, 104525, 104526, 104527, 104528, 104529, 104530, 104531, 104532, 104533, 104534, 104535, 104536, 104537, 104538, 104539, 104540, 104541, 104542, 104543, 104544, 104545, 104546, 104547, 104548, 104549, 104550, 104551, 104552, 104553, 104554, 104555, 104556, 104557, 104558, 104559, 104560, 104561, 104562, 104563, 104564, 104565, 104566, 104567, 104568, 104569, 104570, 104571, 104572, 104573, 104574, 102319, 102326, 102333, 102340, 102320, 102327, 102334, 102341, 102321, 102328, 102335, 102342, 102322, 102329, 102336, 102343, 102323, 102330, 102337, 102344, 102324, 102331, 102338, 102345, 102325, 102332, 102339, 102346, 102644, 102645, 102646, 102647, 102648, 102649, 102650, 102651, 102652, 102653, 102654, 102655, 102656, 102657, 102658, 102659, 102660, 102661, 102662, 102663, 102664, 102665, 102666, 102667, 102668, 102669, 102670, 102671, 102672, 102673, 102674, 102675, 102676, 102874, 102875, 102876, 102877, 102878, 104575, 104576, 104577, 104578, 104579, 104580, 104581, 104582, 104583, 104584, 104585, 104586, 104587, 104588, 104589, 104590, 104591, 104592, 104593, 104594, 104595, 104596, 104597, 104598, 104599, 104600, 104601, 104602, 104603, 104604, 104605, 104606, 104607, 104608, 104609, 104610, 104611, 104612, 104613, 104614, 104615, 104616, 104617, 104618, 104619, 104620, 104621, 104622, 104623, 104624, 104625, 104626, 104627, 104628, 104629, 104630, 105016, 105017, 105018, 105019, 105020, 105021, 105022, 105023, 105024, 105025, 105026, 105027, 105028, 105029, 105030, 105031, 105032, 105033, 105034, 105035, 105036, 105107, 105108, 105109, 105110, 105111, 105112, 105113, 105114, 105115, 105116, 105117, 105118, 105119, 105120, 105121, 105122, 105123, 105124, 105125, 105126, 105127, 105128, 105129, 105130, 105131, 105132, 105133, 105134, 105135, 105136, 105137, 105138, 105139, 105140, 105141, 105142, 105143, 105144, 105145, 105146, 105147, 105148, 105149, 105150, 105151, 105152, 105153, 105154, 105155, 105156, 105157, 105158, 105159, 105160, 105161, 105162, 105163, 105164, 105165, 105166, 105167, 105168, 105169, 105170, 105171, 105212, 105213, 105214, 105215, 105216, 105217, 105218, 105219, 105220, 105221, 105222, 105223, 105224, 105225, 105226, 105227, 105228, 105229, 105230, 105231, 105232, 105233, 105234, 105235, 105236, 105237, 105238, 105239, 105240, 105241, 105242, 105285, 105286, 105287, 105288, 105289, 105290, 105291, 105292, 105293, 105294, 105295, 105296, 105297, 105298, 105299, 105300, 105317, 105318, 105319, 105320, 105321, 104951, 104952, 104953, 104954, 104955, 104956, 104957, 104958, 104959, 104960, 104961, 104962, 104963, 104964, 104965, 104966, 104967, 104968, 104969, 104970, 104971, 104972, 104973, 104974, 104975, 104976, 104977, 104978, 104979, 104980, 104981, 104982, 104983, 104984, 104985, 104986, 104987, 104988, 104989, 104990, 104991, 104992, 104993, 104994, 104995, 104996, 104997, 104998, 104999, 105000, 105001, 105002, 105003, 105004, 105005, 105006, 105007, 105008, 105009, 105010, 105011, 105012, 105013, 105014, 105015], color: '#752424bd', bgColor: '#914f4f38', label: 'В ПРОПУСКЕ' }
};

    const COSTUME_COLLECTIONS = {
    DE: { ids: [916, 917, 918, 919], color: '#4b2475c7', bgColor: '#83766740', label: 'ДС / СС' },
    MANUSCRIPT: { ids: [9126, 9127, 9128, 9129, 9130, 9131, 9132, 9133, 9134, 9135, 9136, 9137], color: '#247544c7', bgColor: '#83766740', label: 'МАНУСКРИПТ' },
    CAULDRON: { ids: [1750, 1751, 1752, 1753, 1754, 1755, 1756, 1757, 1758, 1759, 1760, 1761, 1762, 1763, 1764, 1765, 1766, 1767, 1768, 1769], color: '#247544c7', bgColor: '#83766740', label: 'КОТЁЛ' },
    IR: { ids: [7125, 7126, 7127, 7128, 7129, 7130, 7131, 7132], color: '#246e75c7', bgColor: '#83766740', label: 'ЛЕДЯНАЯ РОЗА' },
    NY_CARD: { ids: [1945, 1946, 1948, 1949, 1950, 1951, 1952, 2102, 2105, 2111, 2115, 2116, 2118, 2123], color: '#242675c7', bgColor: '#83766740', label: 'НОВОГОДНЯЯ ОТКРЫТКА (ДО ID 2123)' },
    NY_SPIRITS_2022: { ids: [7120, 7121, 7122, 7123, 7124], color: '#247566c7', bgColor: '#83766740', label: 'ДУХИ НОВОГО ГОДА 2022' },
    CHARMS: { ids: [3140, 3137, 3139, 3138], color: '#755524c7', bgColor: '#83766740', label: 'ОБЕРЕГИ' },
    SPHERES: { ids: [93, 94, 95, 96, 97], color: '#752460c7', bgColor: '#83766740', label: 'СФЕРЫ' },
    DESIGN: { ids: [7100, 7101, 7102, 7105, 7106, 7107, 7110, 7111, 7112, 7115], color: '#756724c7', bgColor: '#83766740', label: 'КОСТЮМЫ ЗА ДИЗАЙН' },
    MERCHANT: { ids: [4000, 4001, 4002, 4003, 4004, 4005, 4006, 4007, 4008, 4009, 4010, 4011, 4012, 4013, 4014, 4015, 4016, 4017, 4018, 4019, 4020], color: '#612475c7', bgColor: '#83766740', label: 'ТОРГОВЦЫ (ВТ)' },
    RARE_BUFFS: { ids: [1729, 1730, 1731, 1732, 1733, 1734, 1735, 1736, 1737, 1738, 1739, 1740, 1741, 1742, 1743, 1744, 1745, 1746, 1747, 1748], color: '#752451c7', bgColor: '#83766740', label: 'РЕДКИЕ БАФФЫ' },
    CLIMING: { ids: [795], color: '#595959c7', bgColor: '#83766740', label: 'ПЕРЕПЛЕТЕНИЕ ВЕТВЕЙ И ПЕРЬЕВ' },
    DIVING: { ids: [144, 142, 143, 141], color: '#245075c7', bgColor: '#83766740', label: 'КОСТЮМЫ С НЫРКОВ' },
    COLLARS: { ids: [955, 956, 957, 958, 959, 960, 961, 962, 964, 965, 967], color: '#246675c7', bgColor: '#83766740', label: 'ОШЕЙНИКИ ДОМАШНИХ' },
    VT: { ids: [997, 998, 999, 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019, 1020, 1021, 1022, 1023, 1023, 1024, 1025, 1026, 1027], color: '#247541c7', bgColor: '#83766740', label: 'ДУХИ (ВТ)' },
    SHARD: { ids: [2093], color: '#595959c7', bgColor: '#83766740', label: 'ОСКОЛОК (СТАРЫЙ КВЕСТ ВТ)' },
    AMBER: { ids: [2183], color: '#595959c7', bgColor: '#83766740', label: 'УГОЛЬ (КВЕСТ ВТ)' }
};

const THEMES = {
    dark: {
        gold: '#a29b8b', goldDim: '#7a6230', bg: '#1d1c19', panel: '#2d2b28',
        glass: 'rgba(255,255,255,0.03)', border: '#3c3932', borderHi: 'rgba(201,168,76,0.7)',
        text: '#e8dfc8', muted: '#998e7c', red: '#8b2020', shadow: 'rgba(0,0,0,.6)',
        labelBg: 'rgba(0,0,0,.65)', thumbHoverBg: 'rgba(201,168,76,0.06)',
    },
    light: {
        gold: '#695d45', goldDim: '#c9a84c', bg: '#d7d3c8', panel: '#cbc5b8',
        glass: 'rgba(0,0,0,0.03)', border: '#b4ab9b', borderHi: 'rgba(154,110,26,0.75)',
        text: '#2c2416', muted: '#5e5645', red: '#b03030', shadow: 'rgba(0,0,0,.18)',
        labelBg: '#dfd8cf', thumbHoverBg: 'rgba(154,110,26,0.07)',
    }
};

let currentTheme = localStorage.getItem('wd-theme') || 'dark';
let C = { ...THEMES[currentTheme] };
let DEFAULT_MODEL_URL = '';
let layerCounter = 0;
let pendingUrl = { model: null, costume: null };
let searchStartID = 1;
let searchItemsPerPage = 40;
let activeLayers = [];

function applyTheme(theme) {
    currentTheme = theme;
    C = { ...THEMES[theme] };
    localStorage.setItem('wd-theme', theme);
    rebuildPanel();
}

function injectStyles() {
    const style = document.createElement('style');
    style.id = 'wd-style';
    style.textContent = `
        @import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600&family=Jost:wght@300;400&display=swap');
        #try-on-panel-wrapper * { font-family: 'Jost', sans-serif; }
        #try-on-panel-wrapper h2, #try-on-panel-wrapper .wd-title { font-family: 'Cinzel', serif; }
        #try-on-panel-wrapper input:focus { border-color: ${C.gold} !important; outline: none; }
        #try-on-panel-wrapper button:hover { border-color: ${C.gold} !important; color: ${C.gold} !important; }
        .sortable-ghost { opacity: .4; background: ${C.glass}; border-radius: 2px; }
        @keyframes wd-fade-in { from { opacity:0; transform:translateY(-6px); } to { opacity:1; transform:translateY(0); } }
        #try-on-panel-content { animation: wd-fade-in .25s ease; }
        #wd-theme-toggle {
            border: 2px solid ${C.gold}; color: ${C.gold};
            font-size: 14px; cursor: pointer; padding: 3px 7px; border-radius: 50px;
            transition: border-color .15s, color .15s; line-height: 1.4; flex-shrink: 0;
        }
        #wd-theme-toggle:hover { border-color: ${C.gold} !important; color: ${C.gold} !important; background-color: ${C.bg} !important; }
        @media (max-width: 768px) {
            .w-flex { flex-direction: column !important; align-items: stretch !important; }
            #control-col { margin-right: 0 !important; margin-bottom: 20px !important; }
            .s-ctrl { flex-direction: column !important; gap: 8px !important; }
            .s-ctrl > * { width: 100% !important; box-sizing: border-box; }
        }
    `;
    document.head.appendChild(style);
}

const thumbCSS = (url, h) =>
    `width:100%;height:${h};background:url('${url}') center/contain no-repeat;` +
    `cursor:pointer;border:1px solid ${C.border};border-radius:2px;box-sizing:border-box;` +
    `transition:border-color .15s,background-color .15s;`;

function loaderHTML(type, title, withRestore) {
    const inputS = `width:100%;padding:5px 8px;background:${C.bg};color:${C.text};border:1px solid ${C.border};` +
        `border-radius:2px;font-size:16px;box-sizing:border-box;outline:none;font-family:inherit;`;
    const btnS = col => `width:100%;padding:5px 8px;background:${col};color:${C.text};border:1px solid ${C.border};` +
        `border-radius:2px;cursor:pointer;font-size:16px;letter-spacing:.06em;font-family:inherit;transition:border-color .15s,color .15s;`;
    return `
        <div style="margin-bottom:6px;order:${type === 'model' ? 3 : 4};">
            <div id="${type}-loader-header" style="display:flex;justify-content:space-between;align-items:center;cursor:pointer;padding:6px 0;border-top:1px solid ${C.border};">
                <span style="font-size:12px;font-weight:bolder;letter-spacing:.12em;color:${C.muted};text-transform:uppercase;">${title}</span>
                <button id="${type}-loader-toggle-btn" style="background:none;border:none;color:${C.gold};font-size:12px;cursor:pointer;padding:0;">▸</button>
            </div>
            <div id="${type}-loader-content" style="display:none;padding:6px 0;">
                <input type="text" id="${type}-url-input" placeholder="URL изображения" style="${inputS} margin-bottom:5px;">
                <input type="file" id="${type}-file-input" style="display:none;" accept="image/png,image/jpeg">
                <button id="${type}-select-file-btn" style="${btnS(C.glass)} margin-bottom:4px;">выбрать файл</button>
                ${withRestore ? `<button id="restore-model-btn" style="${btnS(C.glass)}">вернуть оригинал</button>` : ''}
            </div>
        </div>`;
}

function buildPanelInnerHTML(modelSrc) {
    const quickBtns = PASS.map(cat =>
        `<button onclick="document.getElementById('search-start-id-input').value='${cat.id}';document.getElementById('search-range-btn').click();"
            style="padding:3px 8px;font-size:14px;letter-spacing:.08em;background:${C.glass};color:${C.muted};border:1px solid ${C.border};border-radius:2px;cursor:pointer;transition:border-color .15s,color .15s;font-family:inherit;">
            ${cat.name}</button>`
    ).join('');

    const collectionBtns = Object.entries(COSTUME_COLLECTIONS).map(([key, data]) =>
        `<button onclick="document.getElementById('search-start-id-input').value='${data.ids[0]}';document.getElementById('search-range-btn').click();"
            style="padding:3px 8px;font-size:14px;letter-spacing:.08em;background:${C.glass};color:${C.muted};border:1px solid ${C.border};border-radius:2px;cursor:pointer;transition:border-color .15s,color .15s;font-family:inherit;">
            ${data.label}</button>`
    ).join('');

    return `
        <div style="position:absolute;top:0;left:0;right:0;height:1px;background:linear-gradient(90deg,transparent,${C.gold},transparent);"></div>
        <div id="main-panel-header" style="display:flex;align-items:center;cursor:pointer;padding:14px 0;gap:12px;">
            <button id="main-panel-toggle-btn" style="background:none;border:none;color:${C.gold};font-size:16px;cursor:pointer;padding:0;line-height:1;transition:transform .2s;">▸</button>
            <h2 class="wd-title" style="font-size:13px;margin:0;color:${C.gold};letter-spacing:.2em;font-weight:600;">ПРИМЕРКА КОСТЮМОВ</h2>
            <div style="flex-grow:1;height:1px;background:linear-gradient(90deg,${C.border},transparent);margin-left:8px;"></div>
            <button id="wd-theme-toggle" title="${currentTheme === 'dark' ? 'Светлая тема' : 'Тёмная тема'}">${currentTheme === 'dark' ? '☀' : '☾'}</button>
        </div>
        <div id="try-on-panel-content" style="display:none;flex-direction:column;padding-bottom:20px;">
            <div class="w-flex" style="display:flex;align-items:flex-start;gap:24px;">
                <div id="control-col" style="display:flex;flex-direction:column;align-items:stretch;flex-shrink:0;width:190px;">
                    <div style="text-align:center;margin-bottom:16px;">
                        <div style="font-size:12px;letter-spacing:.18em;color:${C.muted};margin-bottom:35px;text-transform:uppercase;">предпросмотр</div>
                        <div class="try-on-container" style="position:relative;width:100px;height:150px;margin:0 auto 20px;transform:scale(1.4);transform-origin:center;">
                            <img id="player-model" src="${modelSrc}" style="position:absolute;top:0;left:0;width:100%;height:100%;object-fit:contain;z-index:1;">
                        </div>
                    </div>
                    <div style="display:flex;flex-direction:column;">
                        ${loaderHTML('model', 'Заменить модель', true)}
                        ${loaderHTML('costume', 'Загрузить костюм', false)}
                    </div>
                    <div style="margin-top:10px;">
                        <div style="font-size:12px;letter-spacing:.18em;color:${C.muted};margin-bottom:6px;text-transform:uppercase;">слои</div>
                        <div id="try-on-controller-panel" style="max-height:320px;overflow-y:auto;padding:4px;background:${C.bg};border:1px solid ${C.border};border-radius:3px;">
                            <p style="font-style:italic;color:${C.muted};font-size:13px;text-align:center;padding:10px 0;margin:0;">нажмите на костюмы</p>
                        </div>
                    </div>
                </div>
                <div style="flex-grow:1;min-width:0;">
                    <div style="font-size:12px;letter-spacing:.18em;color:${C.muted};margin-bottom:8px;text-transform:uppercase;">костюмы на странице</div>
                    <div id="try-on-thumbnails" style="display:grid;grid-template-columns:repeat(1,1fr);gap:3px;padding:8px;background:${C.bg};border:1px solid ${C.border};border-radius:3px;width:100%;box-sizing:border-box;"></div>
                </div>
            </div>
            <div style="margin-top:20px;border-top:4px solid ${C.border};padding-top:14px;">
                <div id="costume-search-header" style="display:flex;align-items:center;background:linear-gradient(to right,${C.border} 0%,transparent 100%);padding:10px;font-weight:600;border-radius:15px;cursor:pointer;gap:10px;margin-bottom:4px;">
                    <button id="costume-search-toggle-btn" style="background:none;border:none;color:${C.gold};font-size:14px;cursor:pointer;padding:0;line-height:1;">▸</button>
                    <span class="wd-title" style="font-size:13px;letter-spacing:.2em;color:${C.gold};">ПОИСК КОСТЮМОВ</span>
                </div>
                <div id="costume-search-content" style="display:none;padding-top:12px;">
                    <div id="quick-panel" style="display:flex;flex-direction:column;gap:8px;margin-bottom:12px;">
                        <div style="font-size:12px;letter-spacing:.12em;color:${C.muted};text-transform:uppercase;font-weight:600;padding:0 8px;">ПРОПУСКИ</div>
                        <div style="display:flex;flex-wrap:wrap;gap:4px;padding:8px;background:${C.bg};border:1px solid ${C.border};border-radius:3px;">
                            ${quickBtns}
                        </div>
                        <div style="font-size:12px;letter-spacing:.12em;color:${C.muted};text-transform:uppercase;font-weight:600;padding:0 8px;margin-top:4px;">ДРУГИЕ КОСТЮМЫ</div>
                        <div style="display:flex;flex-wrap:wrap;gap:4px;padding:8px;background:${C.bg};border:1px solid ${C.border};border-radius:3px;">
                            ${collectionBtns}
                        </div>
                    </div>
                    <div class="s-ctrl" style="display:flex;align-items:center;gap:8px;margin-bottom:10px;flex-wrap:wrap;">
                        <span style="font-size:12px;letter-spacing:.08em;color:${C.muted};white-space:nowrap;">ID от:</span>
                        <input type="text" id="search-start-id-input" placeholder="число"
                            style="width:80px;padding:5px 8px;background:${C.bg};color:${C.text};border:1px solid ${C.border};border-radius:2px;font-size:12px;font-family:inherit;box-sizing:border-box;">
                        <button id="search-range-btn"
                            style="padding:5px 14px;background:${C.glass};color:${C.text};border:1px solid ${C.border};border-radius:2px;cursor:pointer;font-size:10px;letter-spacing:.1em;font-family:inherit;transition:border-color .15s,color .15s;">
                            НАЙТИ</button>
                    </div>
                    <div class="s-ctrl" style="display:flex;align-items:center;justify-content:space-between;margin-bottom:10px;padding:6px 10px;background:${C.bg};border:1px solid ${C.border};border-radius:3px;">
                        <button id="prev-page-btn" style="background:none;border:none;color:${C.muted};font-size:35px;cursor:pointer;padding:0;transition:color .15s;line-height:1;">&#8592;</button>
                        <span id="current-id-display" style="font-size:12px;letter-spacing:.1em;color:${C.muted};">1 — 40</span>
                        <button id="next-page-btn" style="background:none;border:none;color:${C.muted};font-size:35px;cursor:pointer;padding:0;transition:color .15s;line-height:1;">&#8594;</button>
                    </div>
                    <div id="costume-search-thumbnails" style="display:grid;grid-template-columns:repeat(1,1fr);gap:4px;padding:8px;background:${C.bg};border:1px solid ${C.border};border-radius:3px;width:100%;box-sizing:border-box;"></div>
                </div>
            </div>
        </div>`;
}

function gridCols(panelId, minW, gap, fallback) {
    const el = document.getElementById(panelId);
    if (!el) return 1;
    return Math.max(1, Math.floor(((el.clientWidth || el.offsetWidth || fallback) + gap) / (minW + gap)));
}

function updateLayerOrder() {
    const layers = document.getElementById('try-on-controller-panel')?.querySelectorAll('.costume-controller');
    if (!layers) return;
    layers.forEach((ctrl, i) => {
        const img = document.getElementById(ctrl.dataset.layerId);
        if (img) img.style.zIndex = 1000 + (layers.length - i) * 10;
    });
}

function removeLayer(id) {
    document.getElementById(id)?.remove();
    document.querySelector(`.costume-controller[data-layer-id="${id}"]`)?.remove();
    activeLayers = activeLayers.filter(l => l.id !== id);
    updateLayerOrder();
    const panel = document.getElementById('try-on-controller-panel');
    if (panel?.children.length === 0)
        panel.innerHTML = `<p style="font-style:italic;color:${C.muted};font-size:13px;text-align:center;padding:10px 0;">нажмите на костюмы</p>`;
}

function changeModel(url) {
    const img = document.getElementById('player-model');
    if (!img || !url) return;
    img.src = url;
    document.getElementById('model-url-input').value = '';
    document.getElementById('model-file-input').value = '';
    pendingUrl.model = null;
}

function renderCostumeLayer(id, url, container, panel) {
    panel.querySelector('p')?.remove();

    const img = document.createElement('img');
    img.id = id;
    img.src = url;
    img.style.cssText = `position:absolute;top:0;left:0;width:100%;height:100%;object-fit:contain;z-index:100;`;
    container.appendChild(img);

    const costumeID = url.match(/costume\/(\d+)\.png/)?.[1] ?? '—';
    const ctrl = document.createElement('div');
    ctrl.className = 'costume-controller';
    ctrl.dataset.layerId = id;
    ctrl.style.cssText =
        `display:flex;align-items:center;gap:6px;border:1px solid ${C.border};border-radius:3px;` +
        `padding:5px 6px;margin-bottom:4px;background:${C.glass};font-size:12px;cursor:move;transition:border-color .15s;`;
    ctrl.innerHTML = `
        <div style="width:24px;height:24px;flex-shrink:0;background:url('${url}') center/contain no-repeat;border:1px solid ${C.border};border-radius:2px;"></div>
        <span style="flex-grow:1;color:${C.text};letter-spacing:.04em;">ID ${costumeID}</span>
        <button class="remove-layer-btn" data-layer-id="${id}"
            style="background:${C.red};color:#fff;border:none;width:18px;height:18px;border-radius:2px;cursor:pointer;font-size:12px;line-height:1;flex-shrink:0;">✕</button>
    `;
    ctrl.addEventListener('mouseenter', () => ctrl.style.borderColor = C.goldDim);
    ctrl.addEventListener('mouseleave', () => ctrl.style.borderColor = C.border);
    ctrl.querySelector('.remove-layer-btn').addEventListener('click', e => { e.stopPropagation(); removeLayer(id); });
    panel.prepend(ctrl);
}

function addCostumeLayer(url) {
    if (!url || url.includes('/cw3/composited/')) return;
    const id = `costume-layer-${++layerCounter}`;
    const container = document.querySelector('#try-on-panel-content .try-on-container');
    const panel = document.getElementById('try-on-controller-panel');
    if (!container || !panel) return;
    activeLayers.unshift({ id, url });
    renderCostumeLayer(id, url, container, panel);
    updateLayerOrder();
}

function handleFileSelect(e, type) {
    const file = e.target.files[0];
    if (!file || !['image/png', 'image/jpeg'].includes(file.type)) return;
    const reader = new FileReader();
    reader.onload = ev => { pendingUrl[type] = ev.target.result; handleLoad(type); };
    reader.readAsDataURL(file);
}

function handleLoad(type) {
    const url = pendingUrl[type] || document.getElementById(`${type}-url-input`)?.value;
    if (!url) return;
    if (type === 'model') {
        changeModel(url);
    } else {
        addCostumeLayer(url);
        pendingUrl.costume = null;
        document.getElementById('costume-file-input').value = '';
        document.getElementById('costume-url-input').value = '';
    }
}

function togglePanel(id) {
    const content = document.getElementById(`${id}-content`);
    const arrow = document.getElementById(`${id}-toggle-btn`);
    if (!content || !arrow) return;
    const open = content.style.display === 'none' || content.style.display === '';
    content.style.display = open ? 'block' : 'none';
    arrow.textContent = open ? '▾' : '▸';
    if (open && id === 'costume-search' && !document.getElementById('costume-search-thumbnails').children.length)
        updateSearchDisplay(1);
}

function updateSearchDisplay(startId) {
    const panel = document.getElementById('costume-search-thumbnails');
    if (!panel) return;
    const cols = gridCols('costume-search-thumbnails', 100, 4, 600);
    searchItemsPerPage = cols * 5;
    searchStartID = Math.max(1, startId);
    panel.style.gridTemplateColumns = `repeat(${cols}, 1fr)`;
    panel.innerHTML = '';
    for (let i = 0; i < searchItemsPerPage; i++) {
        const costumeID = searchStartID + i;
        const url = `/cw3/cats/0/costume/${costumeID}.png`;

        let collection = null;
        for (const [name, data] of Object.entries({ ...COSTUME_COLLECTIONS, ...PASS_PASS })) {
            if (data.ids.includes(costumeID)) {
                collection = { name, ...data };
                break;
            }
        }

        const thumb = document.createElement('div');
        thumb.style.cssText = thumbCSS(url, '150px') + `position:relative;background-color:${C.glass};overflow:hidden;`;

        const label = document.createElement('div');
        label.style.cssText = `position:absolute;bottom:0;left:0;width:100%;background:${C.labelBg};color:${C.muted};font-size:11px;text-align:center;padding:2px 0;`;
        label.textContent = costumeID;
        thumb.appendChild(label);

        if (collection) {
            const collectionLabel = document.createElement('div');
            collectionLabel.style.cssText = `position:absolute;top:2px;left:50%;transform:translateX(-50%);background:${collection.color};color:#fff;font-size:9px;text-align:center;padding:1px 6px;font-weight:bold;z-index:2;border-radius:3px;white-space:normal;word-break:break-word;width:90%;`;
            collectionLabel.textContent = collection.label;
            thumb.style.backgroundColor = collection.bgColor;
            thumb.appendChild(collectionLabel);
        }

        const defaultBg = collection ? collection.bgColor : C.glass;
        thumb.style.backgroundColor = defaultBg;
        thumb.addEventListener('click', () => addCostumeLayer(url));
        thumb.addEventListener('mouseenter', () => { thumb.style.borderColor = C.gold; thumb.style.backgroundColor = C.thumbHoverBg; });
        thumb.addEventListener('mouseleave', () => { thumb.style.borderColor = C.border; thumb.style.backgroundColor = defaultBg; });
        panel.appendChild(thumb);
    }
    document.getElementById('current-id-display').textContent = `${searchStartID} — ${searchStartID + searchItemsPerPage - 1}`;
}

function handleSearchRange() {
    const raw = parseInt(document.getElementById('search-start-id-input').value.replace(/\D/g, ''), 10) || 1;
    updateSearchDisplay(Math.max(1, Math.floor((raw - 1) / searchItemsPerPage) * searchItemsPerPage + 1));
}

function navigateSearch(dir) {
    updateSearchDisplay(Math.max(1, searchStartID + dir * searchItemsPerPage));
}

function buildPageGrid(costumeUrls) {
    const panel = document.getElementById('try-on-thumbnails');
    if (!panel) return;
    const cols = gridCols('try-on-thumbnails', 50, 3, 400);
    panel.style.gridTemplateColumns = `repeat(${cols}, 1fr)`;
    panel.innerHTML = '';

    costumeUrls.forEach(url => {
        const thumb = document.createElement('div');
        thumb.style.cssText = thumbCSS(url, '75px') + `background-color:${C.glass};`;
        thumb.addEventListener('click', () => addCostumeLayer(url));
        thumb.addEventListener('mouseenter', () => { thumb.style.borderColor = C.gold; thumb.style.backgroundColor = C.thumbHoverBg; });
        thumb.addEventListener('mouseleave', () => { thumb.style.borderColor = C.border; thumb.style.backgroundColor = C.glass; });
        panel.appendChild(thumb);
    });

    const rem = costumeUrls.length % cols;
    if (rem) for (let i = 0; i < cols - rem; i++) {
        const ghost = document.createElement('div');
        ghost.style.cssText = `width:100%;height:75px;box-sizing:border-box;`;
        panel.appendChild(ghost);
    }
}

function bindPanelEvents(costumeUrls) {
    document.getElementById('model-loader-header').addEventListener('click', () => togglePanel('model-loader'));
    document.getElementById('costume-loader-header').addEventListener('click', () => togglePanel('costume-loader'));
    document.getElementById('costume-search-header').addEventListener('click', () => togglePanel('costume-search'));
    document.getElementById('restore-model-btn').addEventListener('click', () => changeModel(DEFAULT_MODEL_URL));
    document.getElementById('search-range-btn').addEventListener('click', handleSearchRange);
    document.getElementById('prev-page-btn').addEventListener('click', () => navigateSearch(-1));
    document.getElementById('next-page-btn').addEventListener('click', () => navigateSearch(1));

    const navBtnHover = id => {
        const el = document.getElementById(id);
        el.addEventListener('mouseenter', () => el.style.color = C.gold);
        el.addEventListener('mouseleave', () => el.style.color = C.muted);
    };
    navBtnHover('prev-page-btn');
    navBtnHover('next-page-btn');

    ['model', 'costume'].forEach(type => {
        document.getElementById(`${type}-select-file-btn`).addEventListener('click', () => document.getElementById(`${type}-file-input`).click());
        document.getElementById(`${type}-file-input`).addEventListener('change', e => handleFileSelect(e, type));
        document.getElementById(`${type}-url-input`).addEventListener('keydown', e => { if (e.key === 'Enter') handleLoad(type); });
    });

    document.getElementById('main-panel-header').addEventListener('click', e => {
        if (e.target.closest('#wd-theme-toggle')) return;
        const content = document.getElementById('try-on-panel-content');
        const wrapper = document.getElementById('try-on-panel-wrapper');
        const toggleBtn = document.getElementById('main-panel-toggle-btn');
        const open = content.style.display === 'none';
        content.style.display = open ? 'flex' : 'none';
        toggleBtn.textContent = open ? '▾' : '▸';
        toggleBtn.style.transform = open ? 'rotate(0deg)' : '';
        wrapper.style.paddingBottom = open ? '20px' : '0';
    });

    document.getElementById('wd-theme-toggle').addEventListener('click', e => {
        e.stopPropagation();
        applyTheme(currentTheme === 'dark' ? 'light' : 'dark');
    });

    requestAnimationFrame(() => buildPageGrid(costumeUrls));

    new ResizeObserver(() => {
        buildPageGrid(costumeUrls);
        const sp = document.getElementById('costume-search-thumbnails');
        if (sp?.children.length) updateSearchDisplay(searchStartID);
    }).observe(document.getElementById('try-on-thumbnails'));

    const initSortable = () => new Sortable(document.getElementById('try-on-controller-panel'), {
        animation: 150, ghostClass: 'sortable-ghost', onEnd: updateLayerOrder,
    });
    if (window.Sortable) {
        initSortable();
    } else if (!document.querySelector('script[src*="sortablejs"]')) {
        const sortableScript = document.createElement('script');
        sortableScript.src = 'https://cdn.jsdelivr.net/npm/[email protected]/Sortable.min.js';
        sortableScript.onload = initSortable;
        document.head.appendChild(sortableScript);
    }
}

function rebuildPanel() {
    const wrapper = document.getElementById('try-on-panel-wrapper');
    if (!wrapper) return;

    const wasOpen     = document.getElementById('try-on-panel-content')?.style.display !== 'none';
    const searchOpen  = document.getElementById('costume-search-content')?.style.display !== 'none';
    const modelOpen   = document.getElementById('model-loader-content')?.style.display !== 'none';
    const costumeOpen = document.getElementById('costume-loader-content')?.style.display !== 'none';
    const modelSrc    = document.getElementById('player-model')?.src ?? DEFAULT_MODEL_URL;

    document.getElementById('wd-style')?.remove();
    injectStyles();

    wrapper.style.cssText =
        `border:1px solid ${C.border};border-radius:4px;background:${C.panel};` +
        `backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px);` +
        `padding:0 20px;margin:20px auto;width:90%;max-width:1300px;color:${C.text};` +
        `position:relative;overflow:hidden;`;
    wrapper.innerHTML = buildPanelInnerHTML(modelSrc);

    const costumeUrls = [];
    document.querySelectorAll('#main button div[style*="background-image: url"]').forEach(icon => {
        const m = window.getComputedStyle(icon).backgroundImage.match(/url\(['"]?(.*?)['"]?\)/);
        if (m?.[1]?.includes('/cw3/cats/')) costumeUrls.push(m[1]);
    });
    bindPanelEvents(costumeUrls);

    if (wasOpen) {
        document.getElementById('try-on-panel-content').style.display = 'flex';
        document.getElementById('main-panel-toggle-btn').textContent = '▾';
        wrapper.style.paddingBottom = '20px';
    }
    if (searchOpen) {
        document.getElementById('costume-search-content').style.display = 'block';
        document.getElementById('costume-search-toggle-btn').textContent = '▾';
        updateSearchDisplay(searchStartID);
    }
    ['model', 'costume'].forEach(t => {
        if (t === 'model' ? modelOpen : costumeOpen)
            document.getElementById(`${t}-loader-content`).style.display = 'block';
    });

    if (activeLayers.length) {
        const container = document.querySelector('#try-on-panel-content .try-on-container');
        const panel = document.getElementById('try-on-controller-panel');
        [...activeLayers].reverse().forEach(({ id, url }) => renderCostumeLayer(id, url, container, panel));
        updateLayerOrder();
    }
}

function extractModelUrl(firstDiv) {
    if (firstDiv) {
        const attr = firstDiv.getAttribute('style') || '';
        const m = attr.match(/url\(['"]?(.*?)['"]?\)/);
        if (m?.[1]) return m[1];
        const cm = window.getComputedStyle(firstDiv).backgroundImage.match(/url\(['"]?(.*?)['"]?\)/);
        if (cm?.[1]) return cm[1];
    }
    for (const el of document.querySelectorAll('div[style*="/cw3/composited/"]')) {
        const m = el.getAttribute('style').match(/url\(['"]?(.*?)['"]?\)/);
        if (m?.[1]) return m[1];
    }
    const comp = document.querySelector('div[style*="composited"]');
    if (comp) {
        const m = window.getComputedStyle(comp).backgroundImage.match(/url\(['"]?(.*?)['"]?\)/);
        if (m?.[1]) return m[1];
    }
    return '';
}

function injectPanel(anchorEl, firstDivOrPosition, costumeSourceSelector) {
    let insertPosition, firstDiv;
    if (typeof firstDivOrPosition === 'string') {
        insertPosition = firstDivOrPosition;
        firstDiv = null;
    } else {
        insertPosition = 'afterend';
        firstDiv = firstDivOrPosition;
        costumeSourceSelector = 'div[style*="background-image: url"]';
    }

    const url = extractModelUrl(firstDiv);
    if (url) DEFAULT_MODEL_URL = url;

    injectStyles();

    const wrapper = document.createElement('div');
    wrapper.id = 'try-on-panel-wrapper';
    wrapper.style.cssText =
        `border:1px solid ${C.border};border-radius:4px;background:${C.panel};` +
        `backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px);` +
        `padding:0 20px;margin:20px auto;width:90%;max-width:1300px;color:${C.text};` +
        `position:relative;overflow:hidden;`;

    if (insertPosition === 'afterend') {
        anchorEl.insertAdjacentElement('afterend', document.createElement('hr'));
        anchorEl.insertAdjacentElement('afterend', wrapper);
    } else {
        anchorEl.insertAdjacentHTML(insertPosition, wrapper.outerHTML + '<hr>');
    }

    document.getElementById('try-on-panel-wrapper').innerHTML = buildPanelInnerHTML(DEFAULT_MODEL_URL);

    const costumeUrls = [];
    document.querySelectorAll(costumeSourceSelector).forEach(icon => {
        const m = window.getComputedStyle(icon).backgroundImage.match(/url\(['"]?(.*?)['"]?\)/);
        if (m?.[1]?.includes('/cw3/cats/')) costumeUrls.push(m[1]);
    });

    bindPanelEvents(costumeUrls);
}

(function () {
    const isSettingsCostumes = /\/settings_costumes/.test(location.pathname);

    if (isSettingsCostumes) {
        const tryInsert = () => {
            if (document.getElementById('try-on-panel-wrapper')) return true;
            const col3 = document.querySelector('div[data-v-5fa27571][class*="col-3"]');
            if (!col3) return false;
            const firstDiv =
                col3.querySelector('[class="first"]') ||
                col3.querySelector('[class*="first"]') ||
                document.querySelector('[data-v-59afe5e8][class="first"]') ||
                document.querySelector('[class="first"]');
            if (!firstDiv) return false;
            injectPanel(col3, firstDiv);
            return true;
        };

        if (!tryInsert()) {
            const observer = new MutationObserver(() => { if (tryInsert()) observer.disconnect(); });
            observer.observe(document.body, { childList: true, subtree: true });
        }
    } else {
        const mainDiv = document.getElementById('main');
        if (!mainDiv) return;
        injectPanel(mainDiv, 'beforebegin', '#main button div[style*="background-image: url"]');
    }
})();