sldshr commited on
Commit
a3a5355
·
verified ·
1 Parent(s): 2d9c122

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +299 -256
index.html CHANGED
@@ -3,54 +3,55 @@
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>Matrix Web Client Pro</title>
7
  <style>
8
  :root {
9
- --bg-dark: #090d12;
10
- --bg-sidebar: #111720;
11
- --bg-card: #182230;
12
- --bg-hover: #222e40;
13
- --bg-input: #0d131c;
14
- --border-color: #212e40;
15
- --accent: #10b981;
16
- --accent-hover: #059669;
17
- --accent-glow: rgba(16, 185, 129, 0.2);
18
- --text-main: #f1f5f9;
 
19
  --text-muted: #8b9bb4;
20
- --danger: #ef4444;
21
- --danger-hover: #dc2626;
22
- --radius-lg: 14px;
23
- --radius-md: 10px;
24
- --radius-sm: 6px;
25
- --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
26
  }
27
 
28
  .theme-matrix {
29
- --bg-dark: #040a05;
30
- --bg-sidebar: #0a140b;
31
- --bg-card: #0e1f10;
32
- --bg-hover: #152e18;
33
- --bg-input: #060e07;
34
- --border-color: #17381b;
35
- --accent: #00ff66;
36
- --accent-hover: #00cc52;
37
- --accent-glow: rgba(0, 255, 102, 0.2);
38
  --text-main: #00ff66;
39
  --text-muted: #00aa44;
40
  }
41
 
42
  .theme-light {
43
- --bg-dark: #f1f5f9;
44
  --bg-sidebar: #ffffff;
45
- --bg-card: #f8fafc;
46
- --bg-hover: #e2e8f0;
47
  --bg-input: #ffffff;
48
- --border-color: #cbd5e1;
49
- --accent: #2563eb;
50
- --accent-hover: #1d4ed8;
51
- --accent-glow: rgba(37, 99, 235, 0.2);
52
- --text-main: #0f172a;
53
- --text-muted: #64748b;
54
  }
55
 
56
  * {
@@ -60,6 +61,15 @@
60
  font-family: var(--font-family);
61
  overflow-wrap: anywhere;
62
  word-break: break-word;
 
 
 
 
 
 
 
 
 
63
  }
64
 
65
  body, html {
@@ -72,8 +82,8 @@
72
 
73
  /* SVG Icon styling */
74
  .svg-icon {
75
- width: 20px;
76
- height: 20px;
77
  fill: currentColor;
78
  display: inline-block;
79
  vertical-align: middle;
@@ -81,8 +91,8 @@
81
  }
82
 
83
  .svg-icon.sm {
84
- width: 16px;
85
- height: 16px;
86
  }
87
 
88
  /* App Layout */
@@ -92,36 +102,36 @@
92
  width: 100vw;
93
  }
94
 
95
- /* Nav Sidebar */
96
  .nav-bar {
97
- width: 64px;
98
  background: var(--bg-sidebar);
99
  border-right: 1px solid var(--border-color);
100
  display: flex;
101
  flex-direction: column;
102
  align-items: center;
103
- padding: 16px 0;
104
- gap: 16px;
105
  z-index: 20;
106
  flex-shrink: 0;
107
  }
108
 
109
  .nav-logo {
110
- width: 42px;
111
- height: 42px;
112
  background: var(--accent-glow);
113
  color: var(--accent);
114
  border-radius: var(--radius-md);
115
  display: flex;
116
  align-items: center;
117
  justify-content: center;
118
- font-weight: bold;
119
- font-size: 20px;
 
120
  }
121
 
122
  .nav-btn {
123
- width: 44px;
124
- height: 44px;
125
  border-radius: var(--radius-md);
126
  background: transparent;
127
  border: none;
@@ -131,35 +141,35 @@
131
  align-items: center;
132
  justify-content: center;
133
  position: relative;
134
- transition: all 0.2s;
135
  }
136
 
137
- .nav-btn:hover, .nav-btn.active {
138
  background: var(--bg-hover);
139
  color: var(--text-main);
140
  }
141
 
142
  .nav-btn.active {
143
  color: var(--accent);
 
144
  border-left: 3px solid var(--accent);
145
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
146
  }
147
 
148
  .badge {
149
  position: absolute;
150
- top: 4px;
151
- right: 4px;
152
  background: var(--accent);
153
  color: #000;
154
  font-size: 10px;
155
- font-weight: bold;
156
- border-radius: 10px;
157
- padding: 2px 6px;
158
  }
159
 
160
- /* List Sidebar */
161
  .list-sidebar {
162
- width: 320px;
163
  background: var(--bg-sidebar);
164
  border-right: 1px solid var(--border-color);
165
  display: flex;
@@ -168,22 +178,24 @@
168
  }
169
 
170
  .sidebar-header {
171
- padding: 16px;
172
  border-bottom: 1px solid var(--border-color);
173
  display: flex;
174
  flex-direction: column;
175
- gap: 12px;
176
  }
177
 
178
  .sidebar-title-row {
179
  display: flex;
180
  align-items: center;
181
  justify-content: space-between;
 
182
  }
183
 
184
  .sidebar-title {
185
- font-size: 18px;
186
  font-weight: 700;
 
187
  }
188
 
189
  .action-btns {
@@ -196,15 +208,16 @@
196
  font-size: 12px;
197
  font-weight: 600;
198
  border-radius: var(--radius-sm);
199
- border: none;
200
  cursor: pointer;
201
  background: var(--accent);
202
  color: #000;
203
  display: inline-flex;
204
  align-items: center;
205
  justify-content: center;
206
- gap: 6px;
207
- transition: background 0.2s;
 
208
  }
209
 
210
  .btn-sm:hover {
@@ -223,7 +236,7 @@
223
 
224
  .search-input {
225
  width: 100%;
226
- padding: 8px 12px;
227
  background: var(--bg-input);
228
  border: 1px solid var(--border-color);
229
  border-radius: var(--radius-md);
@@ -239,21 +252,20 @@
239
  .room-list {
240
  flex: 1;
241
  overflow-y: auto;
242
- padding: 8px;
243
  display: flex;
244
  flex-direction: column;
245
- gap: 4px;
246
  }
247
 
248
  .room-item {
249
  display: flex;
250
  align-items: center;
251
- gap: 12px;
252
- padding: 10px 12px;
253
  border-radius: var(--radius-md);
254
  cursor: pointer;
255
  transition: background 0.15s;
256
- user-select: none;
257
  min-width: 0;
258
  }
259
 
@@ -267,19 +279,20 @@
267
  }
268
 
269
  .avatar {
270
- width: 40px;
271
- height: 40px;
272
  border-radius: var(--radius-md);
273
  object-fit: cover;
274
  background: var(--bg-card);
275
  display: flex;
276
  align-items: center;
277
  justify-content: center;
278
- font-weight: bold;
279
  color: var(--accent);
280
  border: 1px solid var(--border-color);
281
  flex-shrink: 0;
282
  overflow: hidden;
 
283
  }
284
 
285
  .avatar img {
@@ -301,7 +314,7 @@
301
  }
302
 
303
  .room-name {
304
- font-size: 14px;
305
  font-weight: 600;
306
  white-space: nowrap;
307
  overflow: hidden;
@@ -309,15 +322,14 @@
309
  }
310
 
311
  .room-topic {
312
- font-size: 12px;
313
  color: var(--text-muted);
314
  white-space: nowrap;
315
  overflow: hidden;
316
  text-overflow: ellipsis;
317
- margin-top: 2px;
318
  }
319
 
320
- /* Workspace Main */
321
  .workspace {
322
  flex: 1;
323
  display: flex;
@@ -335,8 +347,8 @@
335
  }
336
 
337
  .chat-header {
338
- height: 64px;
339
- padding: 0 20px;
340
  border-bottom: 1px solid var(--border-color);
341
  display: flex;
342
  align-items: center;
@@ -348,7 +360,7 @@
348
  .chat-header-info {
349
  display: flex;
350
  align-items: center;
351
- gap: 12px;
352
  min-width: 0;
353
  }
354
 
@@ -357,7 +369,7 @@
357
  }
358
 
359
  .chat-title {
360
- font-size: 16px;
361
  font-weight: 700;
362
  white-space: nowrap;
363
  overflow: hidden;
@@ -365,7 +377,7 @@
365
  }
366
 
367
  .chat-subtitle {
368
- font-size: 12px;
369
  color: var(--text-muted);
370
  white-space: nowrap;
371
  overflow: hidden;
@@ -375,10 +387,10 @@
375
  .timeline {
376
  flex: 1;
377
  overflow-y: auto;
378
- padding: 20px;
379
  display: flex;
380
  flex-direction: column;
381
- gap: 14px;
382
  }
383
 
384
  .message-group {
@@ -402,8 +414,8 @@
402
  .message-header {
403
  display: flex;
404
  align-items: center;
405
- gap: 8px;
406
- margin-bottom: 4px;
407
  font-size: 11px;
408
  }
409
 
@@ -417,18 +429,19 @@
417
  }
418
 
419
  .message-bubble {
420
- padding: 10px 14px;
421
- border-radius: 14px;
422
- font-size: 14px;
423
- line-height: 1.4;
424
  position: relative;
425
  max-width: 100%;
426
  }
427
 
428
  .message-group.me .message-bubble {
429
  background: var(--accent);
430
- color: #000;
431
  border-top-right-radius: 2px;
 
432
  }
433
 
434
  .message-group.other .message-bubble {
@@ -449,7 +462,7 @@
449
  background: var(--bg-card);
450
  border: 1px solid var(--border-color);
451
  border-radius: 12px;
452
- padding: 2px 8px;
453
  font-size: 11px;
454
  cursor: pointer;
455
  display: flex;
@@ -464,12 +477,12 @@
464
 
465
  /* Input Footer */
466
  .chat-footer {
467
- padding: 16px;
468
  border-top: 1px solid var(--border-color);
469
  background: var(--bg-sidebar);
470
  display: flex;
471
  flex-direction: column;
472
- gap: 8px;
473
  }
474
 
475
  .reply-banner {
@@ -477,7 +490,7 @@
477
  align-items: center;
478
  justify-content: space-between;
479
  background: var(--bg-card);
480
- padding: 6px 12px;
481
  border-radius: var(--radius-sm);
482
  border-left: 3px solid var(--accent);
483
  font-size: 12px;
@@ -491,12 +504,12 @@
491
 
492
  .chat-input {
493
  flex: 1;
494
- padding: 12px 16px;
495
  background: var(--bg-input);
496
  border: 1px solid var(--border-color);
497
  border-radius: var(--radius-md);
498
  color: var(--text-main);
499
- font-size: 14px;
500
  outline: none;
501
  }
502
 
@@ -505,7 +518,7 @@
505
  }
506
 
507
  .icon-btn {
508
- padding: 10px;
509
  background: var(--bg-card);
510
  border: 1px solid var(--border-color);
511
  border-radius: var(--radius-md);
@@ -514,35 +527,34 @@
514
  display: flex;
515
  align-items: center;
516
  justify-content: center;
517
- transition: all 0.2s;
518
  }
519
 
520
  .icon-btn:hover {
521
  background: var(--bg-hover);
522
  }
523
 
524
- /* Members Drawer Panel */
525
  .members-sidebar {
526
- width: 260px;
527
  background: var(--bg-sidebar);
528
  border-left: 1px solid var(--border-color);
529
  display: flex;
530
  flex-direction: column;
531
- padding: 16px;
532
- gap: 12px;
533
  overflow-y: auto;
534
  }
535
 
536
  .member-item {
537
  display: flex;
538
  align-items: center;
539
- gap: 10px;
540
- padding: 6px 0;
541
  min-width: 0;
542
  }
543
 
544
  .member-name {
545
- font-size: 13px;
546
  white-space: nowrap;
547
  overflow: hidden;
548
  text-overflow: ellipsis;
@@ -552,13 +564,13 @@
552
  .modal-overlay {
553
  position: fixed;
554
  inset: 0;
555
- background: rgba(0, 0, 0, 0.75);
556
- backdrop-filter: blur(4px);
557
  z-index: 100;
558
  display: flex;
559
  align-items: center;
560
  justify-content: center;
561
- padding: 20px;
562
  }
563
 
564
  .modal-card {
@@ -566,12 +578,12 @@
566
  border: 1px solid var(--border-color);
567
  border-radius: var(--radius-lg);
568
  width: 100%;
569
- max-width: 480px;
570
- padding: 24px;
571
  display: flex;
572
  flex-direction: column;
573
- gap: 16px;
574
- box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
575
  max-height: 90vh;
576
  overflow-y: auto;
577
  }
@@ -580,36 +592,32 @@
580
  display: flex;
581
  justify-content: space-between;
582
  align-items: center;
583
- font-size: 18px;
584
- font-weight: bold;
585
- gap: 12px;
586
- }
587
-
588
- .modal-header span {
589
- overflow-wrap: anywhere;
590
- word-break: break-word;
591
  }
592
 
593
  .form-group {
594
  display: flex;
595
  flex-direction: column;
596
- gap: 6px;
597
  }
598
 
599
  .form-label {
600
- font-size: 12px;
601
- font-weight: 600;
602
  color: var(--text-muted);
603
  text-transform: uppercase;
 
604
  }
605
 
606
  .form-input, .form-select {
607
- padding: 10px 14px;
608
  background: var(--bg-input);
609
  border: 1px solid var(--border-color);
610
  border-radius: var(--radius-md);
611
  color: var(--text-main);
612
- font-size: 14px;
613
  outline: none;
614
  width: 100%;
615
  }
@@ -618,14 +626,13 @@
618
  border-color: var(--accent);
619
  }
620
 
621
- /* Custom Context Menu */
622
  .context-menu {
623
  position: fixed;
624
  background: var(--bg-card);
625
  border: 1px solid var(--border-color);
626
  border-radius: var(--radius-md);
627
- box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
628
- padding: 6px;
629
  z-index: 200;
630
  display: flex;
631
  flex-direction: column;
@@ -634,14 +641,15 @@
634
  }
635
 
636
  .context-item {
637
- padding: 8px 12px;
638
- font-size: 13px;
639
  border-radius: var(--radius-sm);
640
  cursor: pointer;
641
  color: var(--text-main);
642
  display: flex;
643
  align-items: center;
644
  gap: 8px;
 
645
  }
646
 
647
  .context-item:hover {
@@ -653,13 +661,13 @@
653
  }
654
 
655
  .context-item.danger:hover {
656
- background: rgba(239, 68, 68, 0.1);
657
  }
658
 
659
  /* Media Previews */
660
  .media-img {
661
- max-width: 320px;
662
- max-height: 240px;
663
  border-radius: var(--radius-md);
664
  cursor: pointer;
665
  margin-top: 4px;
@@ -667,7 +675,7 @@
667
  }
668
 
669
  .media-video {
670
- max-width: 340px;
671
  border-radius: var(--radius-md);
672
  margin-top: 4px;
673
  }
@@ -675,8 +683,8 @@
675
  .code-block {
676
  background: var(--bg-dark);
677
  border: 1px solid var(--border-color);
678
- padding: 8px 12px;
679
- border-radius: 6px;
680
  font-family: monospace;
681
  font-size: 12px;
682
  margin-top: 4px;
@@ -688,7 +696,6 @@
688
  </head>
689
  <body id="appBody">
690
 
691
- <!-- SVG Icon Definitions -->
692
  <svg style="display: none;">
693
  <symbol id="icon-chat" viewBox="0 0 24 24">
694
  <path d="M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm0 14H5.2L4 17.2V4h16v12z"/>
@@ -696,6 +703,9 @@
696
  <symbol id="icon-user" viewBox="0 0 24 24">
697
  <path d="M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z"/>
698
  </symbol>
 
 
 
699
  <symbol id="icon-inbox" viewBox="0 0 24 24">
700
  <path d="M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H5v-3h3.58c.77 1.19 2.08 2 3.58 2s2.81-.81 3.58-2H19v3zm0-5h-4.17c-.41 1.16-1.52 2-2.83 2s-2.42-.84-2.83-2H5V5h14v9z"/>
701
  </symbol>
@@ -724,26 +734,37 @@
724
  <path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z"/>
725
  </symbol>
726
  <symbol id="icon-members" viewBox="0 0 24 24">
727
- <path d="M16 11c1.66 0 2.99-1.34 2.99-3S17.66 5 16 5c-1.66 0-3 1.34-3 3s1.34 3 3 3zm-8 0c1.66 0 2.99-1.34 2.99-3S9.66 5 8 5C6.34 5 5 6.34 5 8s1.34 3 3 3zm0 2c-2.33 0-7 1.17-7 3.5V19h14v-2.5c0-2.33-4.67-3.5-7-3.5zm8 0c-.29 0-.62.02-.97.05 1.16.84 1.97 1.97 1.97 3.45V19h6v-2.5c0-2.33-4.67-3.5-7-3.5z"/>
 
 
 
 
 
 
 
 
 
 
 
 
728
  </symbol>
729
  </svg>
730
 
731
- <!-- Toast Notifications Container -->
732
- <div id="toastContainer" style="position: fixed; top: 20px; right: 20px; z-index: 300; display: flex; flex-direction: column; gap: 8px;"></div>
733
 
734
  <!-- Right Click Context Menu -->
735
  <div id="customContextMenu" class="context-menu hidden"></div>
736
 
737
  <!-- LOGIN SCREEN -->
738
  <div id="loginView" style="height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;">
739
- <div class="modal-card" style="max-width: 400px;">
740
- <div style="text-align: center; margin-bottom: 8px;">
741
- <div class="nav-logo" style="margin: 0 auto 12px auto; width: 56px; height: 56px; font-size: 28px;">M</div>
742
- <h1 style="font-size: 22px;">Вход в Matrix</h1>
743
- <p style="font-size: 13px; color: var(--text-muted); margin-top: 4px;">Выберите сервер и войдите в систему</p>
744
  </div>
745
 
746
- <form onsubmit="handleLogin(event)" style="display: flex; flex-direction: column; gap: 14px;">
747
  <div class="form-group">
748
  <label class="form-label">Сервер (Homeserver)</label>
749
  <select id="hsSelect" class="form-select" onchange="toggleCustomServerInput()">
@@ -763,7 +784,7 @@
763
  </select>
764
  </div>
765
 
766
- <div id="passAuthFields" class="form-group" style="gap: 12px;">
767
  <div class="form-group">
768
  <label class="form-label">Никнейм / MXID</label>
769
  <input type="text" id="userInput" class="form-input" placeholder="username или @user:server.org">
@@ -779,7 +800,7 @@
779
  <input type="password" id="tokenInput" class="form-input" placeholder="syt_...">
780
  </div>
781
 
782
- <button type="submit" id="loginBtn" class="btn-sm" style="padding: 12px; font-size: 14px; margin-top: 8px;">Войти</button>
783
  </form>
784
  </div>
785
  </div>
@@ -788,7 +809,7 @@
788
  <div id="mainView" class="hidden" style="height: 100vh; width: 100vw; display: flex;">
789
  <!-- Left Nav Sidebar -->
790
  <div class="nav-bar">
791
- <div class="nav-logo">M</div>
792
  <button onclick="switchTab('chats')" id="tabBtn-chats" class="nav-btn active" title="Чаты">
793
  <svg class="svg-icon"><use href="#icon-chat"/></svg>
794
  </button>
@@ -812,14 +833,19 @@
812
  <div class="sidebar-header">
813
  <div class="sidebar-title-row">
814
  <h2 id="sidebarTitle" class="sidebar-title">Чаты</h2>
 
 
815
  <div id="chatActionBtns" class="action-btns">
816
- <button onclick="openModal('createDmModal')" class="btn-sm btn-secondary" title="Начать ЛС">
817
- <svg class="svg-icon sm"><use href="#icon-user"/></svg>+
 
818
  </button>
819
- <button onclick="openModal('createRoomModal')" class="btn-sm" title="Создать комнату">
 
 
820
  <svg class="svg-icon sm"><use href="#icon-plus"/></svg>
821
  </button>
822
- <button onclick="openModal('joinRoomModal')" class="btn-sm btn-secondary" title="Присоединиться">
823
  <svg class="svg-icon sm"><use href="#icon-link"/></svg>
824
  </button>
825
  </div>
@@ -840,10 +866,10 @@
840
  <div id="currentRoomAvatar" class="avatar">#</div>
841
  <div class="chat-title-group">
842
  <h3 id="currentRoomName" class="chat-title">Выберите чат</h3>
843
- <p id="currentRoomTopic" class="chat-subtitle">Matrix Client</p>
844
  </div>
845
  </div>
846
- <div style="display: flex; gap: 8px;">
847
  <button onclick="toggleMembersSidebar()" class="btn-sm btn-secondary" title="Участники">
848
  <svg class="svg-icon sm"><use href="#icon-members"/></svg>
849
  </button>
@@ -854,7 +880,7 @@
854
  </div>
855
 
856
  <div id="messageTimeline" class="timeline">
857
- <div style="margin: auto; color: var(--text-muted); text-align: center; font-size: 14px;">
858
  Выберите комнату или личное сообщение из списка слева
859
  </div>
860
  </div>
@@ -871,8 +897,8 @@
871
  <svg class="svg-icon"><use href="#icon-attach"/></svg>
872
  <input type="file" id="fileInput" onchange="sendFile(this)" style="display: none;">
873
  </label>
874
- <input type="text" id="msgInput" class="chat-input" placeholder="Написать сообщение (поддерживается **bold**, *italic*, `code`)..." autocomplete="off">
875
- <button type="submit" class="btn-sm" style="padding: 12px 18px;">
876
  <svg class="svg-icon"><use href="#icon-send"/></svg>
877
  </button>
878
  </form>
@@ -881,18 +907,18 @@
881
 
882
  <!-- Members Sidebar Panel -->
883
  <div id="membersSidebar" class="members-sidebar hidden">
884
- <h4 style="font-size: 14px; margin-bottom: 8px;">Участники</h4>
885
- <div id="membersList" style="display: flex; flex-direction: column; gap: 8px;"></div>
886
  </div>
887
 
888
  <!-- Settings View -->
889
- <div id="settingsView" class="hidden" style="flex: 1; padding: 40px; overflow-y: auto;">
890
- <div style="max-width: 500px; margin: 0 auto; display: flex; flex-direction: column; gap: 24px;">
891
- <h2>Настройки профиля</h2>
892
 
893
  <div class="modal-card">
894
- <div style="display: flex; align-items: center; gap: 20px;">
895
- <div id="settingsAvatarPreview" class="avatar" style="width: 72px; height: 72px; font-size: 24px;">?</div>
896
  <label class="btn-sm btn-secondary" style="cursor: pointer;">
897
  Изменить аватар
898
  <input type="file" accept="image/*" onchange="uploadProfileAvatar(this)" style="display: none;">
@@ -914,11 +940,11 @@
914
  </div>
915
 
916
  <div class="modal-card">
917
- <h3>Тема оформления</h3>
918
- <div style="display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 10px;">
919
- <button onclick="setAppTheme('dark')" class="btn-sm btn-secondary" style="padding: 16px;">Dark</button>
920
- <button onclick="setAppTheme('matrix')" class="btn-sm btn-secondary" style="padding: 16px; color:#00ff66;">Matrix</button>
921
- <button onclick="setAppTheme('light')" class="btn-sm btn-secondary" style="padding: 16px; color:#0f172a;">Light</button>
922
  </div>
923
  </div>
924
  </div>
@@ -937,7 +963,7 @@
937
  <svg class="svg-icon"><use href="#icon-close"/></svg>
938
  </button>
939
  </div>
940
- <form onsubmit="handleCreateRoom(event)" style="display: flex; flex-direction: column; gap: 12px;">
941
  <div class="form-group">
942
  <label class="form-label">Название *</label>
943
  <input type="text" id="newRoomName" class="form-input" required>
@@ -958,7 +984,7 @@
958
  <input type="checkbox" id="newRoomPublic">
959
  <label for="newRoomPublic" style="font-size: 13px;">Публичная комната</label>
960
  </div>
961
- <button type="submit" class="btn-sm" style="padding: 12px; margin-top: 8px;">Создать</button>
962
  </form>
963
  </div>
964
  </div>
@@ -967,17 +993,17 @@
967
  <div id="createDmModal" class="modal-overlay hidden">
968
  <div class="modal-card">
969
  <div class="modal-header">
970
- <span>Написать пользователю (ЛС)</span>
971
  <button onclick="closeModal('createDmModal')" style="background:none; border:none; color:var(--text-main); cursor:pointer;">
972
  <svg class="svg-icon"><use href="#icon-close"/></svg>
973
  </button>
974
  </div>
975
- <form onsubmit="handleStartDm(event)" style="display: flex; flex-direction: column; gap: 12px;">
976
  <div class="form-group">
977
  <label class="form-label">Matrix ID пользователя *</label>
978
  <input type="text" id="dmUserIdInput" class="form-input" required placeholder="@user:matrix.org">
979
  </div>
980
- <button type="submit" class="btn-sm" style="padding: 12px; margin-top: 8px;">Начать чат</button>
981
  </form>
982
  </div>
983
  </div>
@@ -991,12 +1017,12 @@
991
  <svg class="svg-icon"><use href="#icon-close"/></svg>
992
  </button>
993
  </div>
994
- <form onsubmit="handleJoinRoom(event)" style="display: flex; flex-direction: column; gap: 12px;">
995
  <div class="form-group">
996
  <label class="form-label">ID или Алиас комнаты *</label>
997
  <input type="text" id="joinRoomInput" class="form-input" required placeholder="#room:matrix.org или !id:matrix.org">
998
  </div>
999
- <button type="submit" class="btn-sm" style="padding: 12px; margin-top: 8px;">Войти</button>
1000
  </form>
1001
  </div>
1002
  </div>
@@ -1010,15 +1036,15 @@
1010
  <svg class="svg-icon"><use href="#icon-close"/></svg>
1011
  </button>
1012
  </div>
1013
- <div style="display: flex; flex-direction: column; items-center; gap: 12px; text-align: center;">
1014
- <div id="infoModalAvatar" class="avatar" style="width: 64px; height: 64px; margin: 0 auto; font-size: 24px;">#</div>
1015
- <h3 id="infoModalName" style="max-width: 100%;"></h3>
1016
- <p id="infoModalTopic" style="font-size: 13px; color: var(--text-muted);"></p>
1017
- <div class="form-group" style="text-align: left; width: 100%; margin-top: 12px;">
1018
  <label class="form-label">ROOM ID</label>
1019
  <input type="text" id="infoModalId" class="form-input" readonly>
1020
  </div>
1021
- <button onclick="leaveCurrentRoom()" class="btn-sm" style="background: var(--danger); color: white; width: 100%; margin-top: 12px;">Выйти из комнаты</button>
1022
  </div>
1023
  </div>
1024
  </div>
@@ -1047,34 +1073,28 @@
1047
  const container = document.getElementById('toastContainer');
1048
  const toast = document.createElement('div');
1049
  toast.style.cssText = `
1050
- padding: 12px 16px;
1051
- border-radius: 8px;
1052
- background: ${isError ? '#ef4444' : '#182230'};
1053
  color: #fff;
1054
- font-size: 13px;
1055
  border: 1px solid var(--border-color);
1056
- box-shadow: 0 10px 15px -3px rgba(0,0,0,0.5);
1057
- transition: opacity 0.3s;
1058
  `;
1059
  toast.innerText = msg;
1060
  container.appendChild(toast);
1061
  setTimeout(() => {
1062
  toast.style.opacity = '0';
1063
- setTimeout(() => toast.remove(), 300);
1064
  }, 3000);
1065
  }
1066
 
1067
- // MXC URI converter with authenticated media fallback
1068
  function mxcToHttp(mxcUrl) {
1069
  if (!mxcUrl || typeof mxcUrl !== 'string' || !mxcUrl.startsWith('mxc://')) return null;
1070
  const parts = mxcUrl.substring(6).split('/');
1071
  if (parts.length < 2) return null;
1072
-
1073
- const serverName = parts[0];
1074
- const mediaId = parts[1];
1075
-
1076
- // Modern Matrix endpoint & legacy fallbacks
1077
- return `${state.hsUrl}/_matrix/media/v3/download/${serverName}/${mediaId}`;
1078
  }
1079
 
1080
  async function apiReq(endpoint, method = 'GET', body = null, isRaw = false) {
@@ -1183,6 +1203,7 @@
1183
  document.getElementById('settingsUserId').value = state.userId;
1184
  loadUserProfile();
1185
  startSync();
 
1186
  }
1187
 
1188
  async function loadUserProfile() {
@@ -1234,28 +1255,12 @@
1234
 
1235
  const allEvents = [...(roomData.state?.events || []), ...(roomData.timeline?.events || [])];
1236
  for (const ev of allEvents) {
1237
- // Room Name
1238
- if (ev.type === 'm.room.name' && ev.content?.name) {
1239
- room.name = ev.content.name;
1240
- }
1241
- // Canonical Alias
1242
- if (ev.type === 'm.room.canonical_alias' && ev.content?.alias && !room.name) {
1243
- room.name = ev.content.alias;
1244
- }
1245
- // Room Topic
1246
- if (ev.type === 'm.room.topic' && ev.content?.topic) {
1247
- room.topic = ev.content.topic;
1248
- }
1249
- // Direct Room Avatar
1250
- if (ev.type === 'm.room.avatar' && ev.content?.url) {
1251
- room.avatar = mxcToHttp(ev.content.url);
1252
- }
1253
- // Direct Message state
1254
- if (ev.type === 'm.direct') {
1255
- room.isDirect = true;
1256
- }
1257
 
1258
- // Room Members & User Avatars
1259
  if (ev.type === 'm.room.member') {
1260
  const sender = ev.state_key || ev.sender;
1261
  const memberAvatar = mxcToHttp(ev.content?.avatar_url);
@@ -1268,7 +1273,6 @@
1268
  };
1269
  }
1270
 
1271
- // Message events
1272
  if (ev.type === 'm.room.message') {
1273
  if (!room.events.some(e => e.event_id === ev.event_id)) {
1274
  room.events.push(ev);
@@ -1276,7 +1280,6 @@
1276
  }
1277
  }
1278
 
1279
- // Reactions
1280
  if (ev.type === 'm.reaction' && ev.content?.['m.relates_to']) {
1281
  const rel = ev.content['m.relates_to'];
1282
  const targetId = rel.event_id;
@@ -1289,7 +1292,6 @@
1289
  }
1290
  }
1291
 
1292
- // Dynamically resolve room display name and avatar if not explicitly set
1293
  computeRoomNameAndAvatar(room);
1294
  }
1295
  }
@@ -1310,7 +1312,6 @@
1310
  updateUI();
1311
  }
1312
 
1313
- // Resolves DM names and member-based fallback avatars properly
1314
  function computeRoomNameAndAvatar(room) {
1315
  const memberKeys = Object.keys(room.members).filter(id => id !== state.userId);
1316
 
@@ -1342,6 +1343,41 @@
1342
  }
1343
  }
1344
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1345
  function renderSidebarList() {
1346
  const list = document.getElementById('listContainer');
1347
  list.innerHTML = '';
@@ -1389,9 +1425,9 @@
1389
  card.className = 'modal-card';
1390
  card.style.padding = '12px';
1391
  card.innerHTML = `
1392
- <div style="font-weight:bold; font-size:14px;">${escapeHtml(inv.name)}</div>
1393
- <div style="font-size:12px; color:var(--text-muted);">От: ${escapeHtml(inv.inviter)}</div>
1394
- <div style="display:flex; gap:8px; margin-top:8px;">
1395
  <button onclick="acceptInvite('${inv.roomId}')" class="btn-sm" style="flex:1;">Принять</button>
1396
  <button onclick="rejectInvite('${inv.roomId}')" class="btn-sm btn-secondary" style="flex:1;">Отклонить</button>
1397
  </div>
@@ -1421,14 +1457,10 @@
1421
  renderMembersList();
1422
  }
1423
 
1424
- // Formatting markdown and text content securely
1425
  function formatMessageContent(text) {
1426
  let html = escapeHtml(text);
1427
- // Bold
1428
  html = html.replace(/\*\*(.*?)\*\*/g, '<strong>$1</strong>');
1429
- // Italic
1430
  html = html.replace(/\*(.*?)\*/g, '<em>$1</em>');
1431
- // Code inline
1432
  html = html.replace(/`(.*?)`/g, '<code class="code-block">$1</code>');
1433
  return html;
1434
  }
@@ -1461,7 +1493,6 @@
1461
  contentHtml = `<video src="${videoUrl}" controls class="media-video"></video><br>` + contentHtml;
1462
  }
1463
 
1464
- // Render message reactions
1465
  let reactionsHtml = '';
1466
  const evReactions = room.reactions[ev.event_id];
1467
  if (evReactions) {
@@ -1507,7 +1538,7 @@
1507
  ? `<img src="${m.avatar}" onerror="this.onerror=null; this.parentElement.innerText='${(m.name[0] || '?').toUpperCase()}';">`
1508
  : (m.name[0] || '?').toUpperCase();
1509
  item.innerHTML = `
1510
- <div class="avatar" style="width:28px; height:28px; font-size:12px;">${avatarHtml}</div>
1511
  <span class="member-name">${escapeHtml(m.name)}</span>
1512
  `;
1513
  container.appendChild(item);
@@ -1518,8 +1549,6 @@
1518
  e.preventDefault();
1519
  closeContextMenu();
1520
  const menu = document.getElementById('customContextMenu');
1521
- menu.style.left = `${e.clientX}px`;
1522
- menu.style.top = `${e.clientY}px`;
1523
  menu.innerHTML = `
1524
  <div class="context-item" onclick="openRoomDetailsModal('${roomId}')">
1525
  <svg class="svg-icon sm"><use href="#icon-info"/></svg> Информация
@@ -1529,21 +1558,51 @@
1529
  </div>
1530
  `;
1531
  menu.classList.remove('hidden');
 
1532
  }
1533
 
1534
  function showMessageContextMenu(e, ev) {
1535
  e.preventDefault();
1536
  closeContextMenu();
1537
  const menu = document.getElementById('customContextMenu');
1538
- menu.style.left = `${e.clientX}px`;
1539
- menu.style.top = `${e.clientY}px`;
 
1540
  menu.innerHTML = `
1541
- <div class="context-item" onclick="setReply('${ev.event_id}', '${escapeHtml(ev.content?.body)}')">↩️ Ответить</div>
1542
- <div class="context-item" onclick="sendReaction('${ev.event_id}', '👍')">👍 Реакция</div>
1543
- <div class="context-item" onclick="sendReaction('${ev.event_id}', '❤️')">❤️ Реакция</div>
1544
- <div class="context-item danger" onclick="deleteMessageLocally('${ev.event_id}')">🗑️ Удалить у себя</div>
 
 
 
 
 
 
 
 
1545
  `;
1546
  menu.classList.remove('hidden');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1547
  }
1548
 
1549
  function closeContextMenu() {
@@ -1793,22 +1852,6 @@
1793
  document.body.className = theme === 'matrix' ? 'theme-matrix' : theme === 'light' ? 'theme-light' : '';
1794
  }
1795
 
1796
- function switchTab(tab) {
1797
- state.activeTab = tab;
1798
- ['chats', 'dms', 'inbox', 'settings'].forEach(t => {
1799
- const btn = document.getElementById(`tabBtn-${t}`);
1800
- if (btn) btn.classList.toggle('active', t === tab);
1801
- });
1802
-
1803
- document.getElementById('chatView').classList.toggle('hidden', tab === 'settings');
1804
- document.getElementById('settingsView').classList.toggle('hidden', tab !== 'settings');
1805
-
1806
- const titleMap = { chats: 'Чаты', dms: 'Личные сообщения', inbox: 'Приглашения', settings: 'Настройки' };
1807
- document.getElementById('sidebarTitle').innerText = titleMap[tab] || 'Чаты';
1808
-
1809
- renderSidebarList();
1810
- }
1811
-
1812
  function filterRooms() {
1813
  const query = document.getElementById('searchInput').value.toLowerCase();
1814
  const items = document.querySelectorAll('#listContainer .room-item');
 
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Matrix Hydrogen Client</title>
7
  <style>
8
  :root {
9
+ /* Hydrogen Minimal Palette */
10
+ --bg-dark: #0d131a;
11
+ --bg-sidebar: #151d28;
12
+ --bg-card: #1c2636;
13
+ --bg-hover: #243246;
14
+ --bg-input: #090e14;
15
+ --border-color: #212c3d;
16
+ --accent: #0dbd8b;
17
+ --accent-hover: #0aa378;
18
+ --accent-glow: rgba(13, 189, 139, 0.15);
19
+ --text-main: #e6edf3;
20
  --text-muted: #8b9bb4;
21
+ --danger: #f85149;
22
+ --danger-hover: #da3633;
23
+ --radius-lg: 10px;
24
+ --radius-md: 6px;
25
+ --radius-sm: 4px;
26
+ --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
27
  }
28
 
29
  .theme-matrix {
30
+ --bg-dark: #040d06;
31
+ --bg-sidebar: #09170b;
32
+ --bg-card: #0f2412;
33
+ --bg-hover: #16361b;
34
+ --bg-input: #030804;
35
+ --border-color: #173d1c;
36
+ --accent: #00e676;
37
+ --accent-hover: #00c853;
38
+ --accent-glow: rgba(0, 230, 118, 0.2);
39
  --text-main: #00ff66;
40
  --text-muted: #00aa44;
41
  }
42
 
43
  .theme-light {
44
+ --bg-dark: #f6f8fa;
45
  --bg-sidebar: #ffffff;
46
+ --bg-card: #f3f4f6;
47
+ --bg-hover: #e5e7eb;
48
  --bg-input: #ffffff;
49
+ --border-color: #d0d7de;
50
+ --accent: #0969da;
51
+ --accent-hover: #0451a5;
52
+ --accent-glow: rgba(9, 105, 218, 0.15);
53
+ --text-main: #1f2328;
54
+ --text-muted: #656d76;
55
  }
56
 
57
  * {
 
61
  font-family: var(--font-family);
62
  overflow-wrap: anywhere;
63
  word-break: break-word;
64
+ /* Disable text selection everywhere in UI */
65
+ user-select: none;
66
+ -webkit-user-select: none;
67
+ }
68
+
69
+ /* Allow selection only inside actual message contents */
70
+ .message-bubble, .form-input, .search-input, .chat-input {
71
+ user-select: text;
72
+ -webkit-user-select: text;
73
  }
74
 
75
  body, html {
 
82
 
83
  /* SVG Icon styling */
84
  .svg-icon {
85
+ width: 18px;
86
+ height: 18px;
87
  fill: currentColor;
88
  display: inline-block;
89
  vertical-align: middle;
 
91
  }
92
 
93
  .svg-icon.sm {
94
+ width: 15px;
95
+ height: 15px;
96
  }
97
 
98
  /* App Layout */
 
102
  width: 100vw;
103
  }
104
 
 
105
  .nav-bar {
106
+ width: 58px;
107
  background: var(--bg-sidebar);
108
  border-right: 1px solid var(--border-color);
109
  display: flex;
110
  flex-direction: column;
111
  align-items: center;
112
+ padding: 12px 0;
113
+ gap: 12px;
114
  z-index: 20;
115
  flex-shrink: 0;
116
  }
117
 
118
  .nav-logo {
119
+ width: 38px;
120
+ height: 38px;
121
  background: var(--accent-glow);
122
  color: var(--accent);
123
  border-radius: var(--radius-md);
124
  display: flex;
125
  align-items: center;
126
  justify-content: center;
127
+ font-weight: 700;
128
+ font-size: 18px;
129
+ border: 1px solid var(--accent);
130
  }
131
 
132
  .nav-btn {
133
+ width: 40px;
134
+ height: 40px;
135
  border-radius: var(--radius-md);
136
  background: transparent;
137
  border: none;
 
141
  align-items: center;
142
  justify-content: center;
143
  position: relative;
144
+ transition: all 0.15s ease;
145
  }
146
 
147
+ .nav-btn:hover {
148
  background: var(--bg-hover);
149
  color: var(--text-main);
150
  }
151
 
152
  .nav-btn.active {
153
  color: var(--accent);
154
+ background: var(--bg-card);
155
  border-left: 3px solid var(--accent);
156
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
157
  }
158
 
159
  .badge {
160
  position: absolute;
161
+ top: 2px;
162
+ right: 2px;
163
  background: var(--accent);
164
  color: #000;
165
  font-size: 10px;
166
+ font-weight: 700;
167
+ border-radius: 8px;
168
+ padding: 1px 5px;
169
  }
170
 
 
171
  .list-sidebar {
172
+ width: 300px;
173
  background: var(--bg-sidebar);
174
  border-right: 1px solid var(--border-color);
175
  display: flex;
 
178
  }
179
 
180
  .sidebar-header {
181
+ padding: 14px;
182
  border-bottom: 1px solid var(--border-color);
183
  display: flex;
184
  flex-direction: column;
185
+ gap: 10px;
186
  }
187
 
188
  .sidebar-title-row {
189
  display: flex;
190
  align-items: center;
191
  justify-content: space-between;
192
+ height: 32px;
193
  }
194
 
195
  .sidebar-title {
196
+ font-size: 16px;
197
  font-weight: 700;
198
+ letter-spacing: -0.2px;
199
  }
200
 
201
  .action-btns {
 
208
  font-size: 12px;
209
  font-weight: 600;
210
  border-radius: var(--radius-sm);
211
+ border: 1px solid transparent;
212
  cursor: pointer;
213
  background: var(--accent);
214
  color: #000;
215
  display: inline-flex;
216
  align-items: center;
217
  justify-content: center;
218
+ gap: 5px;
219
+ transition: background 0.15s;
220
+ white-space: nowrap;
221
  }
222
 
223
  .btn-sm:hover {
 
236
 
237
  .search-input {
238
  width: 100%;
239
+ padding: 7px 10px;
240
  background: var(--bg-input);
241
  border: 1px solid var(--border-color);
242
  border-radius: var(--radius-md);
 
252
  .room-list {
253
  flex: 1;
254
  overflow-y: auto;
255
+ padding: 6px;
256
  display: flex;
257
  flex-direction: column;
258
+ gap: 2px;
259
  }
260
 
261
  .room-item {
262
  display: flex;
263
  align-items: center;
264
+ gap: 10px;
265
+ padding: 8px 10px;
266
  border-radius: var(--radius-md);
267
  cursor: pointer;
268
  transition: background 0.15s;
 
269
  min-width: 0;
270
  }
271
 
 
279
  }
280
 
281
  .avatar {
282
+ width: 36px;
283
+ height: 36px;
284
  border-radius: var(--radius-md);
285
  object-fit: cover;
286
  background: var(--bg-card);
287
  display: flex;
288
  align-items: center;
289
  justify-content: center;
290
+ font-weight: 700;
291
  color: var(--accent);
292
  border: 1px solid var(--border-color);
293
  flex-shrink: 0;
294
  overflow: hidden;
295
+ font-size: 14px;
296
  }
297
 
298
  .avatar img {
 
314
  }
315
 
316
  .room-name {
317
+ font-size: 13.5px;
318
  font-weight: 600;
319
  white-space: nowrap;
320
  overflow: hidden;
 
322
  }
323
 
324
  .room-topic {
325
+ font-size: 11.5px;
326
  color: var(--text-muted);
327
  white-space: nowrap;
328
  overflow: hidden;
329
  text-overflow: ellipsis;
330
+ margin-top: 1px;
331
  }
332
 
 
333
  .workspace {
334
  flex: 1;
335
  display: flex;
 
347
  }
348
 
349
  .chat-header {
350
+ height: 56px;
351
+ padding: 0 16px;
352
  border-bottom: 1px solid var(--border-color);
353
  display: flex;
354
  align-items: center;
 
360
  .chat-header-info {
361
  display: flex;
362
  align-items: center;
363
+ gap: 10px;
364
  min-width: 0;
365
  }
366
 
 
369
  }
370
 
371
  .chat-title {
372
+ font-size: 15px;
373
  font-weight: 700;
374
  white-space: nowrap;
375
  overflow: hidden;
 
377
  }
378
 
379
  .chat-subtitle {
380
+ font-size: 11px;
381
  color: var(--text-muted);
382
  white-space: nowrap;
383
  overflow: hidden;
 
387
  .timeline {
388
  flex: 1;
389
  overflow-y: auto;
390
+ padding: 16px 20px;
391
  display: flex;
392
  flex-direction: column;
393
+ gap: 10px;
394
  }
395
 
396
  .message-group {
 
414
  .message-header {
415
  display: flex;
416
  align-items: center;
417
+ gap: 6px;
418
+ margin-bottom: 3px;
419
  font-size: 11px;
420
  }
421
 
 
429
  }
430
 
431
  .message-bubble {
432
+ padding: 8px 12px;
433
+ border-radius: var(--radius-lg);
434
+ font-size: 13.5px;
435
+ line-height: 1.45;
436
  position: relative;
437
  max-width: 100%;
438
  }
439
 
440
  .message-group.me .message-bubble {
441
  background: var(--accent);
442
+ color: #041009;
443
  border-top-right-radius: 2px;
444
+ font-weight: 500;
445
  }
446
 
447
  .message-group.other .message-bubble {
 
462
  background: var(--bg-card);
463
  border: 1px solid var(--border-color);
464
  border-radius: 12px;
465
+ padding: 2px 7px;
466
  font-size: 11px;
467
  cursor: pointer;
468
  display: flex;
 
477
 
478
  /* Input Footer */
479
  .chat-footer {
480
+ padding: 12px 16px;
481
  border-top: 1px solid var(--border-color);
482
  background: var(--bg-sidebar);
483
  display: flex;
484
  flex-direction: column;
485
+ gap: 6px;
486
  }
487
 
488
  .reply-banner {
 
490
  align-items: center;
491
  justify-content: space-between;
492
  background: var(--bg-card);
493
+ padding: 6px 10px;
494
  border-radius: var(--radius-sm);
495
  border-left: 3px solid var(--accent);
496
  font-size: 12px;
 
504
 
505
  .chat-input {
506
  flex: 1;
507
+ padding: 10px 14px;
508
  background: var(--bg-input);
509
  border: 1px solid var(--border-color);
510
  border-radius: var(--radius-md);
511
  color: var(--text-main);
512
+ font-size: 13.5px;
513
  outline: none;
514
  }
515
 
 
518
  }
519
 
520
  .icon-btn {
521
+ padding: 8px;
522
  background: var(--bg-card);
523
  border: 1px solid var(--border-color);
524
  border-radius: var(--radius-md);
 
527
  display: flex;
528
  align-items: center;
529
  justify-content: center;
530
+ transition: all 0.15s;
531
  }
532
 
533
  .icon-btn:hover {
534
  background: var(--bg-hover);
535
  }
536
 
 
537
  .members-sidebar {
538
+ width: 240px;
539
  background: var(--bg-sidebar);
540
  border-left: 1px solid var(--border-color);
541
  display: flex;
542
  flex-direction: column;
543
+ padding: 14px;
544
+ gap: 10px;
545
  overflow-y: auto;
546
  }
547
 
548
  .member-item {
549
  display: flex;
550
  align-items: center;
551
+ gap: 8px;
552
+ padding: 4px 0;
553
  min-width: 0;
554
  }
555
 
556
  .member-name {
557
+ font-size: 12.5px;
558
  white-space: nowrap;
559
  overflow: hidden;
560
  text-overflow: ellipsis;
 
564
  .modal-overlay {
565
  position: fixed;
566
  inset: 0;
567
+ background: rgba(0, 0, 0, 0.7);
568
+ backdrop-filter: blur(2px);
569
  z-index: 100;
570
  display: flex;
571
  align-items: center;
572
  justify-content: center;
573
+ padding: 16px;
574
  }
575
 
576
  .modal-card {
 
578
  border: 1px solid var(--border-color);
579
  border-radius: var(--radius-lg);
580
  width: 100%;
581
+ max-width: 440px;
582
+ padding: 20px;
583
  display: flex;
584
  flex-direction: column;
585
+ gap: 14px;
586
+ box-shadow: 0 16px 32px rgba(0, 0, 0, 0.5);
587
  max-height: 90vh;
588
  overflow-y: auto;
589
  }
 
592
  display: flex;
593
  justify-content: space-between;
594
  align-items: center;
595
+ font-size: 16px;
596
+ font-weight: 700;
597
+ gap: 10px;
 
 
 
 
 
598
  }
599
 
600
  .form-group {
601
  display: flex;
602
  flex-direction: column;
603
+ gap: 5px;
604
  }
605
 
606
  .form-label {
607
+ font-size: 11px;
608
+ font-weight: 700;
609
  color: var(--text-muted);
610
  text-transform: uppercase;
611
+ letter-spacing: 0.5px;
612
  }
613
 
614
  .form-input, .form-select {
615
+ padding: 9px 12px;
616
  background: var(--bg-input);
617
  border: 1px solid var(--border-color);
618
  border-radius: var(--radius-md);
619
  color: var(--text-main);
620
+ font-size: 13.5px;
621
  outline: none;
622
  width: 100%;
623
  }
 
626
  border-color: var(--accent);
627
  }
628
 
 
629
  .context-menu {
630
  position: fixed;
631
  background: var(--bg-card);
632
  border: 1px solid var(--border-color);
633
  border-radius: var(--radius-md);
634
+ box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
635
+ padding: 4px;
636
  z-index: 200;
637
  display: flex;
638
  flex-direction: column;
 
641
  }
642
 
643
  .context-item {
644
+ padding: 7px 10px;
645
+ font-size: 12.5px;
646
  border-radius: var(--radius-sm);
647
  cursor: pointer;
648
  color: var(--text-main);
649
  display: flex;
650
  align-items: center;
651
  gap: 8px;
652
+ transition: background 0.1s;
653
  }
654
 
655
  .context-item:hover {
 
661
  }
662
 
663
  .context-item.danger:hover {
664
+ background: rgba(248, 81, 73, 0.12);
665
  }
666
 
667
  /* Media Previews */
668
  .media-img {
669
+ max-width: 280px;
670
+ max-height: 220px;
671
  border-radius: var(--radius-md);
672
  cursor: pointer;
673
  margin-top: 4px;
 
675
  }
676
 
677
  .media-video {
678
+ max-width: 300px;
679
  border-radius: var(--radius-md);
680
  margin-top: 4px;
681
  }
 
683
  .code-block {
684
  background: var(--bg-dark);
685
  border: 1px solid var(--border-color);
686
+ padding: 6px 10px;
687
+ border-radius: 4px;
688
  font-family: monospace;
689
  font-size: 12px;
690
  margin-top: 4px;
 
696
  </head>
697
  <body id="appBody">
698
 
 
699
  <svg style="display: none;">
700
  <symbol id="icon-chat" viewBox="0 0 24 24">
701
  <path d="M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm0 14H5.2L4 17.2V4h16v12z"/>
 
703
  <symbol id="icon-user" viewBox="0 0 24 24">
704
  <path d="M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z"/>
705
  </symbol>
706
+ <symbol id="icon-add-user" viewBox="0 0 24 24">
707
+ <path d="M15 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm-9-2V7H4v3H1v2h3v3h2v-3h3v-2H6zm9 4c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z"/>
708
+ </symbol>
709
  <symbol id="icon-inbox" viewBox="0 0 24 24">
710
  <path d="M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H5v-3h3.58c.77 1.19 2.08 2 3.58 2s2.81-.81 3.58-2H19v3zm0-5h-4.17c-.41 1.16-1.52 2-2.83 2s-2.42-.84-2.83-2H5V5h14v9z"/>
711
  </symbol>
 
734
  <path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z"/>
735
  </symbol>
736
  <symbol id="icon-members" viewBox="0 0 24 24">
737
+ <path d="M16 11c1.66 0 2.99-1.34 2.99-3S17.66 5 16 5c-1.66 0-3 1.34-3 3zm-8 0c1.66 0 2.99-1.34 2.99-3S9.66 5 8 5C6.34 5 5 6.34 5 8s1.34 3 3 3zm0 2c-2.33 0-7 1.17-7 3.5V19h14v-2.5c0-2.33-4.67-3.5-7-3.5zm8 0c-.29 0-.62.02-.97.05 1.16.84 1.97 1.97 1.97 3.45V19h6v-2.5c0-2.33-4.67-3.5-7-3.5z"/>
738
+ </symbol>
739
+ <symbol id="icon-reply" viewBox="0 0 24 24">
740
+ <path d="M10 9V5l-7 7 7 7v-4.1c5 0 8.5 1.6 11 5.1-1-5-4-10-11-11z"/>
741
+ </symbol>
742
+ <symbol id="icon-like" viewBox="0 0 24 24">
743
+ <path d="M1 21h4V9H1v12zm22-11c0-1.1-.9-2-2-2h-6.31l.95-4.57.03-.32c0-.41-.17-.79-.44-1.06L14.17 1 7.58 7.59C7.22 7.95 7 8.45 7 9v10c0 1.1.9 2 2 2h9c.83 0 1.54-.5 1.84-1.22l3.02-7.05c.09-.23.14-.47.14-.73v-2z"/>
744
+ </symbol>
745
+ <symbol id="icon-heart" viewBox="0 0 24 24">
746
+ <path d="M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z"/>
747
+ </symbol>
748
+ <symbol id="icon-trash" viewBox="0 0 24 24">
749
+ <path d="M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"/>
750
  </symbol>
751
  </svg>
752
 
753
+ <div id="toastContainer" style="position: fixed; top: 16px; right: 16px; z-index: 300; display: flex; flex-direction: column; gap: 8px;"></div>
 
754
 
755
  <!-- Right Click Context Menu -->
756
  <div id="customContextMenu" class="context-menu hidden"></div>
757
 
758
  <!-- LOGIN SCREEN -->
759
  <div id="loginView" style="height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;">
760
+ <div class="modal-card" style="max-width: 380px;">
761
+ <div style="text-align: center; margin-bottom: 4px;">
762
+ <div class="nav-logo" style="margin: 0 auto 10px auto; width: 48px; height: 48px; font-size: 24px;">H</div>
763
+ <h1 style="font-size: 20px;">Matrix Hydrogen</h1>
764
+ <p style="font-size: 12px; color: var(--text-muted); margin-top: 2px;">Вход в аккаунт Matrix</p>
765
  </div>
766
 
767
+ <form onsubmit="handleLogin(event)" style="display: flex; flex-direction: column; gap: 12px;">
768
  <div class="form-group">
769
  <label class="form-label">Сервер (Homeserver)</label>
770
  <select id="hsSelect" class="form-select" onchange="toggleCustomServerInput()">
 
784
  </select>
785
  </div>
786
 
787
+ <div id="passAuthFields" class="form-group" style="gap: 10px;">
788
  <div class="form-group">
789
  <label class="form-label">Никнейм / MXID</label>
790
  <input type="text" id="userInput" class="form-input" placeholder="username или @user:server.org">
 
800
  <input type="password" id="tokenInput" class="form-input" placeholder="syt_...">
801
  </div>
802
 
803
+ <button type="submit" id="loginBtn" class="btn-sm" style="padding: 10px; font-size: 13px; margin-top: 4px;">Войти</button>
804
  </form>
805
  </div>
806
  </div>
 
809
  <div id="mainView" class="hidden" style="height: 100vh; width: 100vw; display: flex;">
810
  <!-- Left Nav Sidebar -->
811
  <div class="nav-bar">
812
+ <div class="nav-logo">H</div>
813
  <button onclick="switchTab('chats')" id="tabBtn-chats" class="nav-btn active" title="Чаты">
814
  <svg class="svg-icon"><use href="#icon-chat"/></svg>
815
  </button>
 
833
  <div class="sidebar-header">
834
  <div class="sidebar-title-row">
835
  <h2 id="sidebarTitle" class="sidebar-title">Чаты</h2>
836
+
837
+ <!-- Contextual Actions per tab -->
838
  <div id="chatActionBtns" class="action-btns">
839
+ <!-- Visible ONLY in DMs tab -->
840
+ <button onclick="openModal('createDmModal')" id="btnActionDm" class="btn-sm btn-secondary hidden" title="Начать ЛС">
841
+ <svg class="svg-icon sm"><use href="#icon-add-user"/></svg> Добавить друга
842
  </button>
843
+
844
+ <!-- Visible ONLY in Rooms/Chats tab -->
845
+ <button onclick="openModal('createRoomModal')" id="btnActionCreateRoom" class="btn-sm" title="Создать комнату">
846
  <svg class="svg-icon sm"><use href="#icon-plus"/></svg>
847
  </button>
848
+ <button onclick="openModal('joinRoomModal')" id="btnActionJoinRoom" class="btn-sm btn-secondary" title="Присоединиться">
849
  <svg class="svg-icon sm"><use href="#icon-link"/></svg>
850
  </button>
851
  </div>
 
866
  <div id="currentRoomAvatar" class="avatar">#</div>
867
  <div class="chat-title-group">
868
  <h3 id="currentRoomName" class="chat-title">Выберите чат</h3>
869
+ <p id="currentRoomTopic" class="chat-subtitle">Hydrogen Matrix Client</p>
870
  </div>
871
  </div>
872
+ <div style="display: flex; gap: 6px;">
873
  <button onclick="toggleMembersSidebar()" class="btn-sm btn-secondary" title="Участники">
874
  <svg class="svg-icon sm"><use href="#icon-members"/></svg>
875
  </button>
 
880
  </div>
881
 
882
  <div id="messageTimeline" class="timeline">
883
+ <div style="margin: auto; color: var(--text-muted); text-align: center; font-size: 13px;">
884
  Выберите комнату или личное сообщение из списка слева
885
  </div>
886
  </div>
 
897
  <svg class="svg-icon"><use href="#icon-attach"/></svg>
898
  <input type="file" id="fileInput" onchange="sendFile(this)" style="display: none;">
899
  </label>
900
+ <input type="text" id="msgInput" class="chat-input" placeholder="Написать сообщение (**bold**, *italic*, `code`)..." autocomplete="off">
901
+ <button type="submit" class="btn-sm" style="padding: 9px 14px;">
902
  <svg class="svg-icon"><use href="#icon-send"/></svg>
903
  </button>
904
  </form>
 
907
 
908
  <!-- Members Sidebar Panel -->
909
  <div id="membersSidebar" class="members-sidebar hidden">
910
+ <h4 style="font-size: 13px; font-weight:700;">Участники</h4>
911
+ <div id="membersList" style="display: flex; flex-direction: column; gap: 6px;"></div>
912
  </div>
913
 
914
  <!-- Settings View -->
915
+ <div id="settingsView" class="hidden" style="flex: 1; padding: 30px; overflow-y: auto;">
916
+ <div style="max-width: 460px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px;">
917
+ <h2 style="font-size:18px;">Настройки профиля</h2>
918
 
919
  <div class="modal-card">
920
+ <div style="display: flex; align-items: center; gap: 16px;">
921
+ <div id="settingsAvatarPreview" class="avatar" style="width: 60px; height: 60px; font-size: 20px;">?</div>
922
  <label class="btn-sm btn-secondary" style="cursor: pointer;">
923
  Изменить аватар
924
  <input type="file" accept="image/*" onchange="uploadProfileAvatar(this)" style="display: none;">
 
940
  </div>
941
 
942
  <div class="modal-card">
943
+ <h3 style="font-size:14px;">Тема оформления</h3>
944
+ <div style="display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 6px;">
945
+ <button onclick="setAppTheme('dark')" class="btn-sm btn-secondary" style="padding: 12px;">Dark</button>
946
+ <button onclick="setAppTheme('matrix')" class="btn-sm btn-secondary" style="padding: 12px; color:#00ff66;">Matrix</button>
947
+ <button onclick="setAppTheme('light')" class="btn-sm btn-secondary" style="padding: 12px; color:#1f2328;">Light</button>
948
  </div>
949
  </div>
950
  </div>
 
963
  <svg class="svg-icon"><use href="#icon-close"/></svg>
964
  </button>
965
  </div>
966
+ <form onsubmit="handleCreateRoom(event)" style="display: flex; flex-direction: column; gap: 10px;">
967
  <div class="form-group">
968
  <label class="form-label">Название *</label>
969
  <input type="text" id="newRoomName" class="form-input" required>
 
984
  <input type="checkbox" id="newRoomPublic">
985
  <label for="newRoomPublic" style="font-size: 13px;">Публичная комната</label>
986
  </div>
987
+ <button type="submit" class="btn-sm" style="padding: 10px; margin-top: 6px;">Создать</button>
988
  </form>
989
  </div>
990
  </div>
 
993
  <div id="createDmModal" class="modal-overlay hidden">
994
  <div class="modal-card">
995
  <div class="modal-header">
996
+ <span>Добавить друга (Начать ЛС)</span>
997
  <button onclick="closeModal('createDmModal')" style="background:none; border:none; color:var(--text-main); cursor:pointer;">
998
  <svg class="svg-icon"><use href="#icon-close"/></svg>
999
  </button>
1000
  </div>
1001
+ <form onsubmit="handleStartDm(event)" style="display: flex; flex-direction: column; gap: 10px;">
1002
  <div class="form-group">
1003
  <label class="form-label">Matrix ID пользователя *</label>
1004
  <input type="text" id="dmUserIdInput" class="form-input" required placeholder="@user:matrix.org">
1005
  </div>
1006
+ <button type="submit" class="btn-sm" style="padding: 10px; margin-top: 6px;">Начать чат</button>
1007
  </form>
1008
  </div>
1009
  </div>
 
1017
  <svg class="svg-icon"><use href="#icon-close"/></svg>
1018
  </button>
1019
  </div>
1020
+ <form onsubmit="handleJoinRoom(event)" style="display: flex; flex-direction: column; gap: 10px;">
1021
  <div class="form-group">
1022
  <label class="form-label">ID или Алиас комнаты *</label>
1023
  <input type="text" id="joinRoomInput" class="form-input" required placeholder="#room:matrix.org или !id:matrix.org">
1024
  </div>
1025
+ <button type="submit" class="btn-sm" style="padding: 10px; margin-top: 6px;">Войти</button>
1026
  </form>
1027
  </div>
1028
  </div>
 
1036
  <svg class="svg-icon"><use href="#icon-close"/></svg>
1037
  </button>
1038
  </div>
1039
+ <div style="display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center;">
1040
+ <div id="infoModalAvatar" class="avatar" style="width: 56px; height: 56px; font-size: 20px;">#</div>
1041
+ <h3 id="infoModalName" style="max-width: 100%; font-size:15px;"></h3>
1042
+ <p id="infoModalTopic" style="font-size: 12px; color: var(--text-muted);"></p>
1043
+ <div class="form-group" style="text-align: left; width: 100%; margin-top: 8px;">
1044
  <label class="form-label">ROOM ID</label>
1045
  <input type="text" id="infoModalId" class="form-input" readonly>
1046
  </div>
1047
+ <button onclick="leaveCurrentRoom()" class="btn-sm" style="background: var(--danger); color: white; width: 100%; margin-top: 8px;">Выйти из комнаты</button>
1048
  </div>
1049
  </div>
1050
  </div>
 
1073
  const container = document.getElementById('toastContainer');
1074
  const toast = document.createElement('div');
1075
  toast.style.cssText = `
1076
+ padding: 10px 14px;
1077
+ border-radius: 6px;
1078
+ background: ${isError ? '#f85149' : '#1c2636'};
1079
  color: #fff;
1080
+ font-size: 12.5px;
1081
  border: 1px solid var(--border-color);
1082
+ box-shadow: 0 8px 16px rgba(0,0,0,0.4);
1083
+ transition: opacity 0.25s;
1084
  `;
1085
  toast.innerText = msg;
1086
  container.appendChild(toast);
1087
  setTimeout(() => {
1088
  toast.style.opacity = '0';
1089
+ setTimeout(() => toast.remove(), 250);
1090
  }, 3000);
1091
  }
1092
 
 
1093
  function mxcToHttp(mxcUrl) {
1094
  if (!mxcUrl || typeof mxcUrl !== 'string' || !mxcUrl.startsWith('mxc://')) return null;
1095
  const parts = mxcUrl.substring(6).split('/');
1096
  if (parts.length < 2) return null;
1097
+ return `${state.hsUrl}/_matrix/media/v3/download/${parts[0]}/${parts[1]}`;
 
 
 
 
 
1098
  }
1099
 
1100
  async function apiReq(endpoint, method = 'GET', body = null, isRaw = false) {
 
1203
  document.getElementById('settingsUserId').value = state.userId;
1204
  loadUserProfile();
1205
  startSync();
1206
+ switchTab('chats');
1207
  }
1208
 
1209
  async function loadUserProfile() {
 
1255
 
1256
  const allEvents = [...(roomData.state?.events || []), ...(roomData.timeline?.events || [])];
1257
  for (const ev of allEvents) {
1258
+ if (ev.type === 'm.room.name' && ev.content?.name) room.name = ev.content.name;
1259
+ if (ev.type === 'm.room.canonical_alias' && ev.content?.alias && !room.name) room.name = ev.content.alias;
1260
+ if (ev.type === 'm.room.topic' && ev.content?.topic) room.topic = ev.content.topic;
1261
+ if (ev.type === 'm.room.avatar' && ev.content?.url) room.avatar = mxcToHttp(ev.content.url);
1262
+ if (ev.type === 'm.direct') room.isDirect = true;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1263
 
 
1264
  if (ev.type === 'm.room.member') {
1265
  const sender = ev.state_key || ev.sender;
1266
  const memberAvatar = mxcToHttp(ev.content?.avatar_url);
 
1273
  };
1274
  }
1275
 
 
1276
  if (ev.type === 'm.room.message') {
1277
  if (!room.events.some(e => e.event_id === ev.event_id)) {
1278
  room.events.push(ev);
 
1280
  }
1281
  }
1282
 
 
1283
  if (ev.type === 'm.reaction' && ev.content?.['m.relates_to']) {
1284
  const rel = ev.content['m.relates_to'];
1285
  const targetId = rel.event_id;
 
1292
  }
1293
  }
1294
 
 
1295
  computeRoomNameAndAvatar(room);
1296
  }
1297
  }
 
1312
  updateUI();
1313
  }
1314
 
 
1315
  function computeRoomNameAndAvatar(room) {
1316
  const memberKeys = Object.keys(room.members).filter(id => id !== state.userId);
1317
 
 
1343
  }
1344
  }
1345
 
1346
+ function switchTab(tab) {
1347
+ state.activeTab = tab;
1348
+ ['chats', 'dms', 'inbox', 'settings'].forEach(t => {
1349
+ const btn = document.getElementById(`tabBtn-${t}`);
1350
+ if (btn) btn.classList.toggle('active', t === tab);
1351
+ });
1352
+
1353
+ document.getElementById('chatView').classList.toggle('hidden', tab === 'settings');
1354
+ document.getElementById('settingsView').classList.toggle('hidden', tab !== 'settings');
1355
+
1356
+ const titleMap = { chats: 'Чаты', dms: 'Личные сообщения', inbox: 'Приглашения', settings: 'Настройки' };
1357
+ document.getElementById('sidebarTitle').innerText = titleMap[tab] || 'Чаты';
1358
+
1359
+ // Show/Hide Contextual Action Buttons in sidebar header
1360
+ const btnDm = document.getElementById('btnActionDm');
1361
+ const btnCreate = document.getElementById('btnActionCreateRoom');
1362
+ const btnJoin = document.getElementById('btnActionJoinRoom');
1363
+
1364
+ if (tab === 'dms') {
1365
+ btnDm.classList.remove('hidden');
1366
+ btnCreate.classList.add('hidden');
1367
+ btnJoin.classList.add('hidden');
1368
+ } else if (tab === 'chats') {
1369
+ btnDm.classList.add('hidden');
1370
+ btnCreate.classList.remove('hidden');
1371
+ btnJoin.classList.remove('hidden');
1372
+ } else {
1373
+ btnDm.classList.add('hidden');
1374
+ btnCreate.classList.add('hidden');
1375
+ btnJoin.classList.add('hidden');
1376
+ }
1377
+
1378
+ renderSidebarList();
1379
+ }
1380
+
1381
  function renderSidebarList() {
1382
  const list = document.getElementById('listContainer');
1383
  list.innerHTML = '';
 
1425
  card.className = 'modal-card';
1426
  card.style.padding = '12px';
1427
  card.innerHTML = `
1428
+ <div style="font-weight:bold; font-size:13px;">${escapeHtml(inv.name)}</div>
1429
+ <div style="font-size:11px; color:var(--text-muted);">От: ${escapeHtml(inv.inviter)}</div>
1430
+ <div style="display:flex; gap:6px; margin-top:6px;">
1431
  <button onclick="acceptInvite('${inv.roomId}')" class="btn-sm" style="flex:1;">Принять</button>
1432
  <button onclick="rejectInvite('${inv.roomId}')" class="btn-sm btn-secondary" style="flex:1;">Отклонить</button>
1433
  </div>
 
1457
  renderMembersList();
1458
  }
1459
 
 
1460
  function formatMessageContent(text) {
1461
  let html = escapeHtml(text);
 
1462
  html = html.replace(/\*\*(.*?)\*\*/g, '<strong>$1</strong>');
 
1463
  html = html.replace(/\*(.*?)\*/g, '<em>$1</em>');
 
1464
  html = html.replace(/`(.*?)`/g, '<code class="code-block">$1</code>');
1465
  return html;
1466
  }
 
1493
  contentHtml = `<video src="${videoUrl}" controls class="media-video"></video><br>` + contentHtml;
1494
  }
1495
 
 
1496
  let reactionsHtml = '';
1497
  const evReactions = room.reactions[ev.event_id];
1498
  if (evReactions) {
 
1538
  ? `<img src="${m.avatar}" onerror="this.onerror=null; this.parentElement.innerText='${(m.name[0] || '?').toUpperCase()}';">`
1539
  : (m.name[0] || '?').toUpperCase();
1540
  item.innerHTML = `
1541
+ <div class="avatar" style="width:26px; height:26px; font-size:11px;">${avatarHtml}</div>
1542
  <span class="member-name">${escapeHtml(m.name)}</span>
1543
  `;
1544
  container.appendChild(item);
 
1549
  e.preventDefault();
1550
  closeContextMenu();
1551
  const menu = document.getElementById('customContextMenu');
 
 
1552
  menu.innerHTML = `
1553
  <div class="context-item" onclick="openRoomDetailsModal('${roomId}')">
1554
  <svg class="svg-icon sm"><use href="#icon-info"/></svg> Информация
 
1558
  </div>
1559
  `;
1560
  menu.classList.remove('hidden');
1561
+ positionContextMenu(e, menu);
1562
  }
1563
 
1564
  function showMessageContextMenu(e, ev) {
1565
  e.preventDefault();
1566
  closeContextMenu();
1567
  const menu = document.getElementById('customContextMenu');
1568
+
1569
+ const bodyEscaped = escapeHtml(ev.content?.body || '');
1570
+
1571
  menu.innerHTML = `
1572
+ <div class="context-item" onclick="setReply('${ev.event_id}', '${bodyEscaped}')">
1573
+ <svg class="svg-icon sm"><use href="#icon-reply"/></svg> Ответить
1574
+ </div>
1575
+ <div class="context-item" onclick="sendReaction('${ev.event_id}', '👍')">
1576
+ <svg class="svg-icon sm"><use href="#icon-like"/></svg> Лайк
1577
+ </div>
1578
+ <div class="context-item" onclick="sendReaction('${ev.event_id}', '❤️')">
1579
+ <svg class="svg-icon sm"><use href="#icon-heart"/></svg> Сердце
1580
+ </div>
1581
+ <div class="context-item danger" onclick="deleteMessageLocally('${ev.event_id}')">
1582
+ <svg class="svg-icon sm"><use href="#icon-trash"/></svg> Удалить у себя
1583
+ </div>
1584
  `;
1585
  menu.classList.remove('hidden');
1586
+ positionContextMenu(e, menu);
1587
+ }
1588
+
1589
+ // Position context menu with boundary safety
1590
+ function positionContextMenu(e, menu) {
1591
+ const menuWidth = menu.offsetWidth || 170;
1592
+ const menuHeight = menu.offsetHeight || 140;
1593
+
1594
+ let posX = e.clientX;
1595
+ let posY = e.clientY;
1596
+
1597
+ if (posX + menuWidth > window.innerWidth) {
1598
+ posX = Math.max(10, window.innerWidth - menuWidth - 10);
1599
+ }
1600
+ if (posY + menuHeight > window.innerHeight) {
1601
+ posY = Math.max(10, window.innerHeight - menuHeight - 10);
1602
+ }
1603
+
1604
+ menu.style.left = `${posX}px`;
1605
+ menu.style.top = `${posY}px`;
1606
  }
1607
 
1608
  function closeContextMenu() {
 
1852
  document.body.className = theme === 'matrix' ? 'theme-matrix' : theme === 'light' ? 'theme-light' : '';
1853
  }
1854
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1855
  function filterRooms() {
1856
  const query = document.getElementById('searchInput').value.toLowerCase();
1857
  const items = document.querySelectorAll('#listContainer .room-item');