forked from NiuTrans/ToFu
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
2860 lines (2734 loc) · 243 KB
/
Copy pathindex.html
File metadata and controls
2860 lines (2734 loc) · 243 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover">
<title>Tofu</title>
<meta name="description" content="Tofu — a self-hosted AI assistant with chat, web search, document translation, and agentic tools.">
<!-- PWA: Add to Home Screen support -->
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="apple-mobile-web-app-title" content="Tofu">
<meta name="theme-color" content="#F5F3ED">
<link rel="manifest" href="static/manifest.json" crossorigin="use-credentials">
<link rel="apple-touch-icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 180 180'><defs><linearGradient id='t' x1='0' y1='0' x2='.5' y2='1'><stop offset='0%25' stop-color='%23fef8ec'/><stop offset='100%25' stop-color='%23fdf2d7'/></linearGradient><linearGradient id='f' x1='0' y1='0' x2='.2' y2='1'><stop offset='0%25' stop-color='%23fdf4dc'/><stop offset='100%25' stop-color='%23f5e8c8'/></linearGradient><linearGradient id='r' x1='0' y1='0' x2='1' y2='.7'><stop offset='0%25' stop-color='%23ecdcc0'/><stop offset='100%25' stop-color='%23dcc8a4'/></linearGradient></defs><path d='M86 26 L36 54 L91 90 L147 59Z' fill='url(%23t)'/><path d='M36 54 L34 119 L97 153 L91 90Z' fill='url(%23f)'/><path d='M91 90 L97 153 L145 125 L147 59Z' fill='url(%23r)'/><path d='M86 26 L36 54 L34 119 L97 153 L145 125 L147 59Z' stroke='%231a1520' stroke-width='3.2' stroke-linejoin='round' fill='none'/><path d='M53 38 L74 31 L80 34 L59 41Z' fill='white' opacity='.5'/><rect x='44' y='80' width='15' height='19' rx='1' fill='%231a1520'/><rect x='52' y='81' width='5' height='7' rx='1' fill='white' opacity='.92'/><rect x='45' y='89' width='3' height='4' rx='.5' fill='white' opacity='.45'/><rect x='73' y='93' width='15' height='21' rx='1' fill='%231a1520'/><rect x='81' y='94' width='5' height='7' rx='1' fill='white' opacity='.92'/><rect x='74' y='104' width='3' height='5' rx='.5' fill='white' opacity='.45'/><path d='M57 113 Q68 121 78 113' stroke='%231a1520' stroke-width='1.5' fill='none' stroke-linecap='round' opacity='.45'/><ellipse cx='45' cy='103' rx='5.5' ry='4' fill='%23ffaaa2' opacity='.5'/><ellipse cx='84' cy='120' rx='6' ry='4' fill='%23feaca5' opacity='.5'/></svg>">
<link rel="icon" type="image/svg+xml" href="static/icons/tofu-welcome.svg">
<link rel="stylesheet" href="static/vendor/google-fonts-local.css">
<link rel="stylesheet" href="static/vendor/github-dark.min.css">
<link rel="stylesheet" href="static/vendor/katex/katex.min.css">
<link rel="stylesheet" href="static/styles.css">
<script>
// Prevent flash of wrong theme — apply before render (default: tofu)
(function(){var t=localStorage.getItem('claude_ui_theme')||'tofu';document.documentElement.setAttribute('data-theme',t);})();
// Prevent layout shift (CLS) — stamp the project-rail width hint BEFORE first
// paint, mirroring the theme no-FOUC script above. The folder render caches a
// lightweight `tofu_has_folders` hint; reading it here lets the sidebar paint
// at its correct steady-state width immediately, so the async folders
// round-trip only reconciles CONTENT, never GEOMETRY. New/zero-folder users
// (no hint) paint single-column, exactly as before.
(function(){try{
if(localStorage.getItem('tofu_has_folders')==='1'){
var c=localStorage.getItem('tofu_project_rail_collapsed')==='1';
document.documentElement.setAttribute('data-rail',c?'collapsed':'full');
}
}catch(e){}})();
</script>
<script>
// ── Loading guard — stub functions for inline handlers ──
// Prevents ReferenceError spam when defer scripts are still downloading
// (common on slow networks or macOS MIME-type misconfigurations).
// Real implementations in main.js / core.js replace these on load.
(function() {
var _loaded = false, _warned = false;
function _notReady() {
if (_loaded) return false; // scripts loaded, shouldn't happen
if (!_warned) {
_warned = true;
console.warn('[LoadGuard] Scripts still loading — please wait…');
}
return true;
}
// Stub critical handlers that users can trigger immediately
var stubs = ['handleKeyDown','sendMessage','newChat','togglePresetDropdown',
'cycleTheme','toggleDebug','closeDebug','toggleSidebar','openSettings','toggleCodeExec',
'toggleBrowser','toggleMemory','toggleSwarm','toggleAutoTranslate',
'toggleAutoApply','selectThinkingDepth','cycleSearchMode','enterImageGenMode',
'toggleSidebarSearch','closeSidebarSearch','togglePaperMode',
'openOrchestration','openTaskMode'];
for (var i = 0; i < stubs.length; i++) {
(function(name) {
window[name] = function() { _notReady(); };
})(stubs[i]);
}
// Mark as loaded once main.js executes (it re-defines these functions)
window._markScriptsLoaded = function() { _loaded = true; window._scriptsReady = true; };
})();
// ── i18n fallback: stub t() so the app works even if i18n.js fails to load ──
// i18n.js will overwrite this with the real implementation on successful load.
if (typeof t !== 'function') {
window.t = function(key) { return key; };
}
// ── Script load error tracker (defined early so onerror handlers can find it) ──
var _scriptLoadErrors = [];
var _scriptLoadCount = 0; // incremented by onload handlers
var _scriptTotal = 0; // set after DOM parse (count of defer scripts)
function _onScriptError(e) {
var src = (e.target && e.target.src) || 'unknown';
_scriptLoadErrors.push(src);
console.error('[LoadGuard] ❌ Failed to load script:', src);
}
function _onScriptLoad() { _scriptLoadCount++; }
// ── Catch script runtime errors (SyntaxError, ReferenceError, etc.) ──
// These are NOT caught by onerror on <script> tags (which only fires on network errors).
// A runtime error in core.js prevents all subsequent scripts from working properly.
var _scriptRuntimeErrors = [];
window.addEventListener('error', function(e) {
if (window._scriptsReady) return; // only capture pre-init errors
if (e.filename && e.filename.indexOf('/static/') !== -1) {
var file = e.filename.split('/').pop().split('?')[0];
_scriptRuntimeErrors.push(file + ':' + e.lineno + ' ' + e.message);
console.error('[LoadGuard] ❌ Script runtime error in ' + file + ':', e.message);
}
});
</script>
<script defer src="static/vendor/highlight.min.js" onload="_onScriptLoad()" onerror="_onScriptError(event)"></script>
<script defer src="static/vendor/marked.min.js" onload="_onScriptLoad()" onerror="_onScriptError(event)"></script>
<script defer src="static/vendor/purify.min.js" onload="_onScriptLoad()" onerror="_onScriptError(event)"></script>
<!-- katex.min.js lazy-loaded on first math render to avoid DevTools freeze -->
<!-- pdf.min.js lazy-loaded on first PDF upload to avoid DevTools freeze -->
</head>
<body>
<aside class="sidebar" id="sidebar">
<div class="sidebar-header">
<h1><img class="sidebar-tofu-icon" src="static/icons/tofu-welcome.svg" alt="Tofu" width="22" height="22"><span class="sidebar-brand"><span class="sidebar-brand-t">T</span><span class="sidebar-brand-o">o</span><span class="sidebar-brand-f">f</span><span class="sidebar-brand-u">u</span></span></h1>
<div class="sidebar-header-actions">
<!-- Feature launchers (Paper / My Day / Trading / Studio) live in the
topbar as labeled buttons. Search, Settings and debug toggle live
here. Theme switching moved into Settings (theme picker). -->
<button class="action-btn" id="sidebarSearchToggle" onclick="toggleSidebarSearch()" title="搜索对话" data-i18n-title="sidebar.search">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"><circle cx="11" cy="11" r="7"/><line x1="16.5" y1="16.5" x2="21" y2="21"/></svg>
</button>
<button class="action-btn" id="debugToggle" onclick="toggleDebug()" title="Debug"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 12V19"/><path d="M18.4 6.6a9 9 0 0 0-12.8 0"/><circle cx="12" cy="8" r="2"/><path d="M20 15.5a9 9 0 0 1-18 0"/><path d="m2 12 2 .5M22 12l-2 .5M7 20l1-1.5M17 20l-1-1.5"/></svg></button>
<button class="action-btn" onclick="openSettings()" title="设置" data-i18n-title="sidebar.settings">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="3"/><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"/></svg>
</button>
</div>
</div>
<div class="sidebar-action-row">
<button class="new-chat-btn" onclick="newChat()">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5"><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg>
<span>New Chat</span>
</button>
</div>
<div class="sidebar-search-wrapper" id="sidebarSearchWrapper" style="display:none">
<div class="sidebar-search-box">
<span class="sidebar-search-icon"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"><circle cx="11" cy="11" r="7"/><line x1="16.5" y1="16.5" x2="21" y2="21"/></svg></span>
<input type="text" class="sidebar-search-input" id="sidebarSearchInput" placeholder="Search conversations..." autocomplete="off" spellcheck="false">
<button class="sidebar-search-clear" id="sidebarSearchClear" onclick="closeSidebarSearch()"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg></button>
</div>
<div class="sidebar-search-stats" id="sidebarSearchStats"></div>
</div>
<button class="folder-quickadd" id="folderQuickAdd" title="新建文件夹" data-i18n-title="sidebar.newFolder">
<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg>
<span data-i18n="sidebar.newFolder">New Folder</span>
</button>
<div class="sidebar-body" id="sidebarBody">
<nav class="project-rail" id="folderTabs" aria-label="Projects"></nav>
<div class="conversations-list" id="convList"></div>
</div>
<!-- ═══ Paper Sidebar Overlay — paper library, shown when paperMode is active ═══ -->
<div class="paper-sidebar-overlay" id="paperSidebarOverlay">
<!-- Current paper info card -->
<div class="paper-sidebar-current" id="paperSidebarCurrent">
<div class="paper-sidebar-current-icon">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="var(--accent)" stroke-width="1.5"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/></svg>
</div>
<div class="paper-sidebar-current-meta">
<span class="paper-sidebar-title" id="paperSidebarTitle" data-i18n="paper.noPaperOpen">No paper open</span>
<span class="paper-sidebar-pages" id="paperPageCount"></span>
</div>
</div>
<!-- Action buttons: "New Paper" inline in library header -->
<!-- Paper library (like conversations list) -->
<div class="paper-sidebar-lib-header">
<span data-i18n="paper.myPapers">My Papers</span>
<div style="display:flex;align-items:center;gap:6px;">
<span class="paper-sidebar-lib-count" id="paperLibCount"></span>
<button class="paper-sidebar-new-inline-btn" onclick="_showPaperLandingForNew()" data-i18n-title="paper.addPaper" title="Add paper">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 5v14"/><path d="M5 12h14"/></svg>
</button>
</div>
</div>
<div class="paper-library-list" id="paperLibraryList">
<!-- Populated by _renderPaperLibrary() -->
</div>
</div>
</aside>
<main class="main">
<div class="topbar">
<button class="toggle-sidebar-btn" onclick="toggleSidebar()" aria-label="Toggle sidebar">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="3" y1="6" x2="21" y2="6"/><line x1="3" y1="12" x2="21" y2="12"/><line x1="3" y1="18" x2="21" y2="18"/></svg>
</button>
<span class="topbar-title" id="topbarTitle">New Chat</span>
<!-- ── Feature launchers (relocated from the sidebar header) ──
Labeled icon+text buttons so each tool's purpose is self-evident. -->
<div class="topbar-tools" id="topbarTools">
<button class="topbar-tool-btn" id="paperModeBtn" onclick="togglePaperMode()" title="Paper Reader — read & chat with PDFs">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 19.5A2.5 2.5 0 0 1 6.5 17H20"/><path d="M6.5 2H20v20H6.5A2.5 2.5 0 0 1 4 19.5v-15A2.5 2.5 0 0 1 6.5 2z"/><line x1="8" y1="7" x2="16" y2="7"/><line x1="8" y1="11" x2="14" y2="11"/></svg>
<span class="topbar-tool-label" data-i18n="topbar.paper">Paper</span>
</button>
<button class="topbar-tool-btn" onclick="openDailyReport()" title="My Day — daily activity report">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M9 11l3 3L22 4"/><path d="M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"/></svg>
<span class="topbar-tool-label" data-i18n="topbar.myday">My Day</span>
</button>
<button class="topbar-tool-btn" onclick="openOrchestration()" title="Orchestration Studio — design multi-agent workflows">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="6" cy="6" r="2.5"/><circle cx="18" cy="6" r="2.5"/><circle cx="12" cy="18" r="2.5"/><path d="M6 8.5v3a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2v-3"/><path d="M12 13.5v2"/></svg>
<span class="topbar-tool-label" data-i18n="topbar.studio">Studio</span>
</button>
<button class="topbar-tool-btn" onclick="openTaskMode()" title="Task Mode — watch and reopen durable orchestration runs">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="4" width="18" height="14" rx="2"/><path d="M7 11.5l2.5 2.5L13 9l2 3h2"/><path d="M8 21h8"/></svg>
<span class="topbar-tool-label" data-i18n="topbar.tasks">Tasks</span>
</button>
<button class="update-btn topbar-tool-btn" id="updateBtn" onclick="openUpdateDialog()" title="检查更新" data-i18n-title="update.checkTitle"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"/><path d="M3 3v5h5"/><path d="M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16"/><path d="M21 21v-5h-5"/></svg><span class="update-btn-label" data-i18n="update.btnLabel">更新</span><span class="update-btn-pill" data-i18n="update.btnNew">New</span></button>
<span class="topbar-tool-btn timer-trigger" id="timerBadge" onclick="toggleTimerPanel(event)" title="Active Counter — background timer watchers" data-i18n-title="timer.badgeTitle" style="display:none"><span class="tm-dot"></span><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="9"/><path d="M12 7v5l3 2"/></svg><span class="topbar-tool-label" data-i18n="topbar.timer">Active Counter</span><span class="timer-count" id="timerCount" style="display:none">0</span>
<div class="timer-panel" id="timerPanel">
<div class="timer-panel-title"><svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="vertical-align:-2px"><line x1="10" x2="14" y1="2" y2="2"/><line x1="12" x2="15" y1="14" y2="11"/><circle cx="12" cy="14" r="8"/></svg> <span data-i18n="timer.panelTitle">Active Counter</span></div>
<div id="timerPanelContent"><div class="timer-panel-empty" data-i18n="timer.empty">No timers. The AI can create one with timer_create during a task.</div></div>
</div>
</span>
<!-- Real-time network latency signal indicator (driven by push.js RTT probe) -->
<span class="net-latency-badge" id="netLatencyBadge" data-state="unknown" title="网络延迟">
<span class="net-bars"></span>
<span class="net-ms">—</span>
</span>
</div>
<!-- Tool-status badges (SEARCH/PROJECT/CODE EXEC/BROWSER/MEMORY) removed:
redundant with the input-box toggles, which already show enabled state. -->
<span class="optimizer-badge" id="optimizerBadge" data-i18n-title="optimizer.badgeTitle" title="Daily Optimizer — autonomous improvement proposals"><span class="opt-dot"></span>OPTIMIZER<span class="optimizer-count" id="optimizerCount" style="display:none">0</span>
<div class="optimizer-panel" id="optimizerPanel">
<div class="optimizer-panel-title"><svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="vertical-align:-2px"><path d="m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z"/><circle cx="12" cy="12" r="10"/></svg> <span data-i18n="optimizer.panelTitle">Daily Optimizer</span></div>
<div id="optimizerPanelContent"><div class="optimizer-panel-empty" data-i18n="optimizer.loading">Loading…</div></div>
</div>
</span>
<!-- model-badge removed (redundant — the model picker in the input bar is
the single source of truth). Theme cycle, and
debug toggle relocated to the sidebar header. -->
</div>
<!-- ═══ Paper Mode — Full-page split: PDF (left) + Tabs (right) ═══ -->
<div class="paper-mode-container" id="paperModeContainer" style="display:none">
<!-- Main split view -->
<div class="paper-body" data-paper-view="pdf">
<!-- Left: PDF viewer — takes the most space -->
<div class="paper-left">
<div class="paper-pdf-toolbar">
<button class="paper-toolbar-btn icon-box" onclick="paperFitWidth()" data-i18n-title="paper.fitWidth" title="Fit to width"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M15 3h6v6"/><path d="M9 21H3v-6"/><path d="M21 3l-7 7"/><path d="M3 21l7-7"/></svg></button>
<button class="paper-toolbar-btn icon-box" onclick="paperZoomOut()" data-i18n-title="paper.zoomOut" title="Zoom out"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12h14"/></svg></button>
<input type="range" id="paperZoomSlider" class="paper-zoom-slider" min="25" max="400" value="150" step="5" oninput="paperSetScaleFromSlider(this.value)">
<input type="text" id="paperZoomLevel" class="paper-toolbar-zoom-input" value="150%" onchange="paperSetScaleFromInput(this.value)" onkeydown="if(event.key==='Enter'){this.blur();}">
<button class="paper-toolbar-btn icon-box" onclick="paperZoomIn()" data-i18n-title="paper.zoomIn" title="Zoom in"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12h14"/><path d="M12 5v14"/></svg></button>
</div>
<div class="paper-pdf-container" id="paperPdfViewer">
<!-- PDF pages rendered here — vertical scroll -->
</div>
<!-- Floating selection toolbar (alphaxiv-style) -->
<div class="paper-selection-bar" id="paperQuoteBtn" style="display:none">
<button class="paper-sel-btn" onclick="_askAboutPaperSelection()" title="Ask AI about this selection">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><circle cx="12" cy="12" r="10"/><path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"/><line x1="12" y1="17" x2="12.01" y2="17"/></svg>
Ask
</button>
<div class="paper-sel-divider"></div>
<button class="paper-sel-btn" onclick="_quotePaperSelection()" title="Quote selection into Q&A input">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M3 21c3 0 7-1 7-8V5c0-1.25-.756-2.017-2-2H4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2 1 0 1 0 1 1v1c0 1-1 2-2 2s-1 .008-1 1.031V21z"/><path d="M15 21c3 0 7-1 7-8V5c0-1.25-.757-2.017-2-2h-4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2h.75c0 2.25.25 4-2.75 4v3c0 1 0 1 1 1z"/></svg>
Quote
</button>
</div>
</div>
<!-- Resize handle -->
<div class="paper-divider" id="paperDivider"></div>
<!-- Right: Q&A / Report / Babel PDF -->
<div class="paper-right">
<!-- Floating selection toolbar for the GENERATED REPORT — lets a
confusing report passage become a one-click Q&A question. -->
<div class="paper-selection-bar" id="paperReportQuoteBtn" style="display:none">
<button class="paper-sel-btn" onclick="_askAboutPaperSelection()" title="Ask AI about this selection">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><circle cx="12" cy="12" r="10"/><path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"/><line x1="12" y1="17" x2="12.01" y2="17"/></svg>
Ask
</button>
<div class="paper-sel-divider"></div>
<button class="paper-sel-btn" onclick="_quotePaperSelection()" title="Quote selection into Q&A input">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M3 21c3 0 7-1 7-8V5c0-1.25-.756-2.017-2-2H4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2 1 0 1 0 1 1v1c0 1-1 2-2 2s-1 .008-1 1.031V21z"/><path d="M15 21c3 0 7-1 7-8V5c0-1.25-.757-2.017-2-2h-4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2h.75c0 2.25.25 4-2.75 4v3c0 1 0 1 1 1z"/></svg>
Quote
</button>
</div>
<div class="paper-tabs">
<button class="paper-tab-btn active" data-tab="qa" onclick="_switchPaperTab('qa')">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/></svg>
<span data-i18n="paper.tabQA">Q&A</span>
</button>
<button class="paper-tab-btn" data-tab="report" onclick="_switchPaperTab('report')">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/><line x1="16" y1="13" x2="8" y2="13"/><line x1="16" y1="17" x2="8" y2="17"/></svg>
<span data-i18n="paper.tabReport">Report</span>
</button>
<button class="paper-tab-btn" data-tab="review" onclick="_switchPaperTab('review')">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M9 11l3 3L22 4"/><path d="M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"/></svg>
<span data-i18n="paper.tabReview">Review</span>
</button>
<button class="paper-tab-btn" data-tab="translate" onclick="_switchPaperTab('translate')">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"><path d="M3 21h4l1-4h8l1 4h4"/><path d="M5 17l2-8h10l2 8"/><path d="M8 9l1-4h6l1 4"/></svg>
<span data-i18n="paper.tabBabel">Babel PDF</span>
</button>
</div>
<!-- QA Panel -->
<div class="paper-tab-panel" data-tab="qa">
<div class="paper-qa-messages" id="paperQAMessages">
<div class="paper-qa-empty">
<div class="paper-qa-empty-icon"><svg width="32" height="32" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719"/></svg></div>
<p data-i18n="paper.qaEmptyTitle">Ask questions about this paper</p>
<p class="paper-qa-hint" data-i18n="paper.qaEmptyHint">Select text in the PDF sidebar to quote it, or type a question below</p>
</div>
</div>
<div class="paper-qa-input-area">
<textarea id="paperQAInput" data-i18n-placeholder="paper.qaInputPlaceholder" placeholder="Ask a question about this paper…" rows="2"></textarea>
<button class="paper-qa-send-btn" onclick="_sendPaperQuestion()" data-i18n-title="paper.send" title="Send (Enter)">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"><line x1="22" y1="2" x2="11" y2="13"/><polygon points="22 2 15 22 11 13 2 9 22 2"/></svg>
</button>
</div>
</div>
<!-- Report Panel -->
<div class="paper-tab-panel" data-tab="report" style="display:none">
<div class="paper-report-toolbar">
<div class="paper-report-model-picker" id="paperReportModelPicker">
<button class="paper-report-model-btn" onclick="_togglePaperReportModelDropdown(event)" data-i18n-title="paper.reportSelectModelTitle" title="Select model for report generation">
<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><circle cx="12" cy="12" r="3"/><path d="M12 1v2M12 21v2M4.22 4.22l1.42 1.42M18.36 18.36l1.42 1.42M1 12h2M21 12h2M4.22 19.78l1.42-1.42M18.36 5.64l1.42-1.42"/></svg>
<span id="paperReportModelLabel" data-i18n="paper.reportSelectModel">Select model</span>
<svg width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"><polyline points="6 9 12 15 18 9"/></svg>
</button>
<div class="paper-report-model-dropdown" id="paperReportModelDropdown">
<!-- Populated by _populatePaperReportModelDropdown() -->
</div>
</div>
<!-- EN / 中 segmented control: per-paper report generation language
(persisted). Switching regenerates/loads in the new language
(cached separately per (paper_hash, lang)). -->
<!-- Reader comfort: text-size A−/A+ + reading-width cycle. Drives
--reader-font-scale / --reader-measure on the reader container,
persisted to localStorage (see _applyReaderPrefs). -->
<div class="paper-reader-settings" role="group" data-i18n-aria-label="paper.readerSettings" aria-label="Reading comfort">
<button type="button" class="paper-reader-set-btn paper-reader-set-dec" onclick="_readerFontStep(-1)" data-i18n-title="paper.readerFontSmaller" title="Smaller text" aria-label="Decrease text size">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"><line x1="5" y1="12" x2="19" y2="12"/></svg>
</button>
<button type="button" class="paper-reader-set-btn" onclick="_readerFontStep(1)" data-i18n-title="paper.readerFontLarger" title="Larger text" aria-label="Increase text size">
<span style="font-size:10px;font-weight:700">A</span>
<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg>
</button>
<button type="button" class="paper-reader-set-btn paper-reader-set-width" onclick="_readerWidthCycle()" data-i18n-title="paper.readerWidth" title="Reading width" aria-label="Cycle reading width">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><polyline points="7 8 3 12 7 16"/><polyline points="17 8 21 12 17 16"/><line x1="3" y1="12" x2="21" y2="12"/></svg>
<span class="paper-reader-width-label" data-i18n="paper.readerWidthComfortable">Comfortable</span>
</button>
</div>
<div class="paper-report-lang-toggle" id="reportLangToggle" data-i18n-title="paper.reportLangTitle" title="Report language">
<button type="button" class="paper-report-lang-opt" data-lang="en" onclick="_setReportLang('en','report')">EN</button>
<button type="button" class="paper-report-lang-opt" data-lang="zh" onclick="_setReportLang('zh','report')">中</button>
</div>
<button class="paper-report-btn paper-report-stop-btn" id="paperReportStopBtn" onclick="_stopPaperReport()" data-i18n-title="paper.reportStop" title="Stop generation" style="display:none">
<svg width="13" height="13" viewBox="0 0 24 24" fill="currentColor" stroke="none"><rect x="6" y="6" width="12" height="12" rx="2.5"/></svg>
<span data-i18n="paper.reportStop">Stop</span>
</button>
<button class="paper-report-btn" id="paperReportRegenBtn" onclick="_regeneratePaperReport()" data-i18n-title="paper.reportRegenerate" title="Regenerate">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><polyline points="23 4 23 10 17 10"/><path d="M20.49 15a9 9 0 1 1-2.12-9.36L23 10"/></svg>
<span data-i18n="paper.reportRegenerate">Regenerate</span>
</button>
<button class="paper-report-btn" onclick="_copyPaperReport()" data-i18n-title="paper.reportCopy" title="Copy">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>
<span id="paperReportCopyLabel" data-i18n="paper.reportCopy">Copy</span>
</button>
<div class="paper-report-export" id="paperReportExportMenu">
<button class="paper-report-btn" onclick="_togglePaperReportExportMenu(event)" data-i18n-title="paper.reportExport" title="Export">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>
<span data-i18n="paper.reportExport">Export</span>
<svg width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"><polyline points="6 9 12 15 18 9"/></svg>
</button>
<div class="paper-report-export-dropdown" id="paperReportExportDropdown">
<button class="paper-report-export-item" onclick="_exportPaperReport('md')" data-i18n="paper.reportExportMd">Markdown (.md)</button>
<button class="paper-report-export-item" onclick="_exportPaperReport('html')" data-i18n="paper.reportExportHtml">Standalone HTML</button>
<button class="paper-report-export-item" onclick="_exportPaperReport('pdf')" data-i18n="paper.reportExportPdf">Print / Save as PDF</button>
</div>
</div>
</div>
<div class="paper-report-content" id="paperReportContent">
<div class="paper-report-empty">
<p data-i18n="paper.reportEmptyTitle">Ready — click below to generate the analysis report</p>
<p class="paper-report-hint" data-i18n="paper.reportEmptyHint">Adjust the model & language above first if needed; the model will search the web for additional context and related work</p>
<button class="paper-report-generate-btn" onclick="_generatePaperReport()">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M5 3l14 9-14 9V3z"/></svg>
<span data-i18n="paper.reportGenerate">Generate report</span>
</button>
</div>
</div>
</div>
<!-- Review Panel — venue-aware peer review, reuses the report engine -->
<div class="paper-tab-panel" data-tab="review" style="display:none">
<div class="paper-report-toolbar">
<div class="paper-report-model-picker" id="paperReviewVenuePicker">
<button class="paper-report-model-btn" onclick="_toggleReviewVenueDropdown(event)" data-i18n-title="paper.reviewSelectVenueTitle" title="Select target conference">
<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 21h18"/><path d="M5 21V7l8-4v18"/><path d="M19 21V11l-6-4"/><path d="M9 9v.01M9 12v.01M9 15v.01M9 18v.01"/></svg>
<span id="paperReviewVenueLabel" data-i18n="paper.reviewSelectVenue">Select venue</span>
<svg width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"><polyline points="6 9 12 15 18 9"/></svg>
</button>
<div class="paper-report-model-dropdown" id="paperReviewVenueDropdown">
<!-- Populated by _populateReviewVenueDropdown() -->
</div>
</div>
<div class="paper-report-model-picker" id="paperReviewModelPicker">
<button class="paper-report-model-btn" onclick="_togglePaperReviewModelDropdown(event)" data-i18n-title="paper.reportSelectModelTitle" title="Select model for review generation">
<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><circle cx="12" cy="12" r="3"/><path d="M12 1v2M12 21v2M4.22 4.22l1.42 1.42M18.36 18.36l1.42 1.42M1 12h2M21 12h2M4.22 19.78l1.42-1.42M18.36 5.64l1.42-1.42"/></svg>
<span id="paperReviewModelLabel" data-i18n="paper.reportSelectModel">Select model</span>
<svg width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"><polyline points="6 9 12 15 18 9"/></svg>
</button>
<div class="paper-report-model-dropdown" id="paperReviewModelDropdown">
<!-- Populated by _populatePaperReportModelDropdown(reviewView) -->
</div>
</div>
<button class="paper-report-btn paper-report-stop-btn" id="paperReviewStopBtn" onclick="_stopPaperReview()" data-i18n-title="paper.reportStop" title="Stop generation" style="display:none">
<svg width="13" height="13" viewBox="0 0 24 24" fill="currentColor" stroke="none"><rect x="6" y="6" width="12" height="12" rx="2.5"/></svg>
<span data-i18n="paper.reportStop">Stop</span>
</button>
<button class="paper-report-btn" id="paperReviewRegenBtn" onclick="_regeneratePaperReview()" data-i18n-title="paper.reportRegenerate" title="Regenerate">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><polyline points="23 4 23 10 17 10"/><path d="M20.49 15a9 9 0 1 1-2.12-9.36L23 10"/></svg>
<span data-i18n="paper.reportRegenerate">Regenerate</span>
</button>
<!-- Review is generated + cached + exported in English (submission
language). The EN/中 control is a READING toggle: '中' shows an
on-demand translated view (canonical English is never touched),
'EN' restores the original. Always available (both directions),
independent of the app UI language. Managed by
_syncReviewTranslateBtn; per-paper choice persisted. -->
<div class="paper-reader-settings" role="group" data-i18n-aria-label="paper.readerSettings" aria-label="Reading comfort">
<button type="button" class="paper-reader-set-btn paper-reader-set-dec" onclick="_readerFontStep(-1)" data-i18n-title="paper.readerFontSmaller" title="Smaller text" aria-label="Decrease text size">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"><line x1="5" y1="12" x2="19" y2="12"/></svg>
</button>
<button type="button" class="paper-reader-set-btn" onclick="_readerFontStep(1)" data-i18n-title="paper.readerFontLarger" title="Larger text" aria-label="Increase text size">
<span style="font-size:10px;font-weight:700">A</span>
<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg>
</button>
<button type="button" class="paper-reader-set-btn paper-reader-set-width" onclick="_readerWidthCycle()" data-i18n-title="paper.readerWidth" title="Reading width" aria-label="Cycle reading width">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><polyline points="7 8 3 12 7 16"/><polyline points="17 8 21 12 17 16"/><line x1="3" y1="12" x2="21" y2="12"/></svg>
<span class="paper-reader-width-label" data-i18n="paper.readerWidthComfortable">Comfortable</span>
</button>
</div>
<div class="paper-report-lang-toggle" id="reviewLangToggle" data-i18n-title="paper.reviewTranslateTitle" title="Review reading language">
<button type="button" class="paper-report-lang-opt" data-lang="en" onclick="_setReportLang('en','review')">EN</button>
<button type="button" class="paper-report-lang-opt" data-lang="zh" onclick="_setReportLang('zh','review')">中</button>
</div>
<button class="paper-report-btn" onclick="_copyPaperReview()" data-i18n-title="paper.reportCopy" title="Copy">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>
<span id="paperReviewCopyLabel" data-i18n="paper.reportCopy">Copy</span>
</button>
<div class="paper-report-export" id="paperReviewExportMenu">
<button class="paper-report-btn" onclick="_togglePaperReviewExportMenu(event)" data-i18n-title="paper.reportExport" title="Export">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>
<span data-i18n="paper.reportExport">Export</span>
<svg width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"><polyline points="6 9 12 15 18 9"/></svg>
</button>
<div class="paper-report-export-dropdown" id="paperReviewExportDropdown">
<button class="paper-report-export-item" onclick="_exportPaperReview('md')" data-i18n="paper.reportExportMd">Markdown (.md)</button>
<button class="paper-report-export-item" onclick="_exportPaperReview('html')" data-i18n="paper.reportExportHtml">Standalone HTML</button>
<button class="paper-report-export-item" onclick="_exportPaperReview('pdf')" data-i18n="paper.reportExportPdf">Print / Save as PDF</button>
</div>
</div>
</div>
<div class="paper-report-content" id="paperReviewContent">
<div class="paper-report-empty">
<p data-i18n="paper.reviewEmptyTitle">Pick a target conference above, then click below to generate a peer review</p>
<p class="paper-report-hint" data-i18n="paper.reviewEmptyHint">The model reviews against the venue's real scorecard and verifies code/data claims via web search</p>
<button class="paper-report-generate-btn" onclick="_generatePaperReview()">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M5 3l14 9-14 9V3z"/></svg>
<span data-i18n="paper.reviewGenerate">Generate review</span>
</button>
</div>
</div>
</div>
<!-- Babel PDF Panel -->
<div class="paper-tab-panel" data-tab="translate" style="display:none">
<div class="paper-translate-content" id="paperTranslateContent">
<!-- Populated by _initBabelPdfTab() -->
</div>
</div>
</div>
<!-- Mobile-only view switcher: full-screen PDF ⇄ Reader (Q&A/Report/Babel) -->
<div class="paper-mobile-switch" id="paperMobileSwitch">
<button class="paper-mobile-switch-btn active" data-view="pdf" onclick="_setPaperMobileView('pdf')">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/></svg>
<span data-i18n="paper.viewPdf">PDF</span>
</button>
<button class="paper-mobile-switch-btn" data-view="reader" onclick="_setPaperMobileView('reader')">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z"/><path d="M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z"/></svg>
<span data-i18n="paper.viewReader">Reader</span>
</button>
</div>
</div>
</div>
<!-- Project Collaboration Bar — a slim line under the top bar (project mode
only, shown only when there's collaborative state to surface). Populated
by presence.js from the 'presence' + 'project' push channels; clicking
it opens the Project Brain panel. Replaces the old crowding presence
strip that sat above the messages.
ONE project-scoped cluster (brainSummary, push-driven): it LEADS with the
Pillar #7 ambient status headline (summary.statusLine — "where is the
project right now", truncated; falls back to a "Project" label when no
snapshot exists yet), followed by the action-ordered coordination counts
(conflicts · decisions awaiting you · epics in progress · open · peers
online) and per-peer "advancing «epic»" joins. The bar hides when there
is neither a status headline nor any count. The per-conversation
influence lens ("how is THIS chat affected") is NOT duplicated here — it
lives in full inside the Project Brain panel, one click away. -->
<div class="presence-strip collab-bar" id="presenceStrip" hidden></div>
<div class="chat-wrapper">
<!-- ═══ Project Brain — cross-conversation Activity Feed (Pillar #1) ═══
A slide-in overlay panel, opened from the project bar. Three columns
(Charter / Board / Activity); only Activity is live in Pillar #1.
Populated by project-brain.js (registered in _BUNDLE_FILES). -->
<div class="project-brain-overlay" id="projectBrainOverlay" hidden onclick="if(event.target===this)closeProjectBrain()">
<div class="project-brain-panel" role="dialog" aria-modal="true">
<div class="project-brain-head">
<span class="project-brain-title">
<span class="project-brain-title-ico" id="projectBrainHeadIcon"></span>
<span data-i18n="projectBrain.title">Project Brain</span>
</span>
<div class="project-brain-head-actions">
<button type="button" class="pb-tr-toggle" id="projectBrainTranslateToggle" aria-pressed="false" role="switch">
<span class="pb-tr-toggle-ico"></span>
<span class="pb-tr-toggle-label" data-i18n="projectBrain.translateToggle">Translate content</span>
</button>
<button class="project-brain-close" onclick="closeProjectBrain()" title="Close">✕</button>
</div>
</div>
<!-- ═══ Per-conversation Influence lens ═══
How the CURRENT conversation is affected by the shared brain:
the charter it's bound by, epics it owns vs. must avoid, and
decisions awaiting a human. Populated by project-brain.js
(renderInfluence). Hidden until an active conv is resolved. -->
<div class="project-brain-influence" id="projectBrainInfluence" hidden>
<div class="pb-influence-head">
<span class="pb-influence-title" data-i18n="projectBrain.influenceTitle">How this conversation is influenced</span>
<span class="pb-influence-conv" id="projectBrainInfluenceConv"></span>
</div>
<div class="pb-influence-body" id="projectBrainInfluenceBody"></div>
</div>
<!-- ═══ Tab bar ═══
The four surfaces (Charter / Board / Activity / Team) are shown
ONE-AT-A-TIME so each gets the full panel width — four side-by-side
columns collapse to unreadable slivers on a narrow / port-forwarded
viewport. Tabs are wired by project-brain.js (_initTabs); the count
badges are refreshed after each render. -->
<div class="project-brain-tabs" id="projectBrainTabs" role="tablist">
<button type="button" class="pb-tab pb-tab-active" data-pb-tab="charter" role="tab" aria-selected="true">
<span class="pb-tab-label" data-i18n="projectBrain.charter">Charter</span>
<span class="pb-tab-count" id="pbTabCountCharter" hidden></span>
</button>
<button type="button" class="pb-tab" data-pb-tab="board" role="tab" aria-selected="false">
<span class="pb-tab-label" data-i18n="projectBrain.board">Board</span>
<span class="pb-tab-count" id="pbTabCountBoard" hidden></span>
</button>
<button type="button" class="pb-tab" data-pb-tab="activity" role="tab" aria-selected="false">
<span class="pb-tab-label" data-i18n="projectBrain.activity">Activity</span>
</button>
<button type="button" class="pb-tab" data-pb-tab="peers" role="tab" aria-selected="false">
<span class="pb-tab-label" data-i18n="projectBrain.team">Team</span>
<span class="pb-tab-count" id="pbTabCountPeers" hidden></span>
</button>
<button type="button" class="pb-tab" data-pb-tab="status" role="tab" aria-selected="false">
<span class="pb-tab-label" data-i18n="projectBrain.status">Status & Watch</span>
</button>
</div>
<div class="project-brain-columns">
<div class="project-brain-col project-brain-col-charter pb-tab-panel pb-tab-panel-active" data-pb-panel="charter">
<div class="project-brain-col-body" id="projectBrainCharterBody">
<div class="pb-charter-empty" data-i18n="projectBrain.charterEmpty">No charter yet</div>
</div>
</div>
<div class="project-brain-col project-brain-col-board pb-tab-panel" data-pb-panel="board">
<div class="project-brain-col-body" id="projectBrainBoardBody">
<div class="pb-board-empty" data-i18n="projectBrain.boardEmpty">Board is empty</div>
</div>
</div>
<div class="project-brain-col project-brain-col-activity pb-tab-panel" data-pb-panel="activity">
<div class="project-brain-col-body">
<div class="pb-activity-list" id="projectBrainActivityList">
<div class="pb-activity-empty" data-i18n="projectBrain.activityEmpty">No activity yet</div>
</div>
</div>
</div>
<!-- ═══ Team / Peers ═══
The conversations-as-a-room surface: each active sibling conv
(title · what it's advancing · presence dot · current round),
plus the peer-message exchanges as an inline thread. Populated
by project-brain-peers.js (renderPeers) from the LIVE
Api.project.brainPeers roster + the feed's peer notes. -->
<div class="project-brain-col project-brain-col-peers pb-tab-panel" data-pb-panel="peers">
<div class="project-brain-col-body" id="projectBrainPeersBody">
<div class="pb-peers-empty" data-i18n="projectBrain.peersEmpty">No sibling conversations active</div>
</div>
</div>
<!-- ═══ Status (Pillar #7 human↔brain status lane) ═══
Ask the PROJECT "where are we / are we drifting from the
charter" and get a synthesized answer, backed by an append-only
history of status snapshots. Read-only synthesis (increment 1);
populated by project-brain-status.js from Api.project.brainStatus.
HUMAN-FACING ONLY — never injected into sibling agent prompts. -->
<div class="project-brain-col project-brain-col-status pb-tab-panel" data-pb-panel="status">
<div class="project-brain-col-body" id="projectBrainStatusBody">
<div class="pb-status-empty" data-i18n="projectBrain.statusEmpty">No status yet</div>
</div>
</div>
</div>
</div>
</div>
<div class="chat-container" id="chatContainer">
<div class="chat-inner" id="chatInner">
<div class="welcome" id="welcome">
<div class="welcome-icon"><img src="static/icons/tofu-welcome.svg" alt="Tofu" width="64" height="64"></div>
<h2 class="tofu-brand"><span class="tofu-brand-t">T</span><span class="tofu-brand-o1">o</span><span class="tofu-brand-f">f</span><span class="tofu-brand-u">u</span><small>豆腐</small></h2>
<div class="feature-pills"><span class="feature-pill"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="width:13px;height:13px;vertical-align:-0.125em;flex-shrink:0"><path d="M12 18V5"/><path d="M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4"/><path d="M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5"/><path d="M17.997 5.125a4 4 0 0 1 2.526 5.77"/><path d="M18 18a4 4 0 0 0 2-7.464"/><path d="M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517"/><path d="M6 18a4 4 0 0 1-2-7.464"/><path d="M6.003 5.125a4 4 0 0 0-2.526 5.77"/></svg>Extended Thinking</span><span class="feature-pill"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="width:13px;height:13px;vertical-align:-0.125em;flex-shrink:0"><path d="m21 21-4.34-4.34"/><circle cx="11" cy="11" r="8"/></svg>Search</span><span class="feature-pill"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="width:13px;height:13px;vertical-align:-0.125em;flex-shrink:0"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" x2="12" y1="15" y2="3"/></svg>URL Fetch</span><span class="feature-pill"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="width:13px;height:13px;vertical-align:-0.125em;flex-shrink:0"><rect width="18" height="18" x="3" y="3" rx="2" ry="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"/></svg>Image Input</span><span class="feature-pill"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="width:13px;height:13px;vertical-align:-0.125em;flex-shrink:0"><path d="M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"/></svg>Co-Pilot</span><span class="feature-pill"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="width:13px;height:13px;vertical-align:-0.125em;flex-shrink:0"><path d="m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z"/><circle cx="12" cy="12" r="10"/></svg>Browser</span></div>
</div>
</div>
</div>
<div class="turn-nav" id="turnNav"></div>
<div class="debug-panel" id="debugPanel">
<div class="debug-header">
<span id="debugTitle">Messages</span>
<div style="display:flex;gap:4px;align-items:center;">
<button class="debug-clear" id="debugCopyBtn" onclick="copyDebugContent()" data-i18n-title="debug.copyAllTooltip" title="复制全部">Copy</button>
<button class="debug-clear" onclick="closeDebug()">✕</button>
</div>
</div>
<div id="debugContent"></div>
</div>
<div class="input-area">
<div class="input-inner">
<div class="project-bar" id="projectBar" style="display:none">
<span class="project-bar-icon" onclick="openProjectModal()" style="cursor:pointer" title="Manage folders"></span>
<span class="project-bar-folders" id="projectBarFolders" onclick="openProjectModal()" style="cursor:pointer" title="Click to manage folders"></span>
<span class="project-bar-stats" id="projectBarStats"></span>
<button class="project-autoapply-toggle" id="autoApplyToggle" onclick="toggleAutoApply()" title="Writes need confirmation (click for auto)">
<span class="autoapply-dot"></span>
<span class="autoapply-label">Manual</span>
</button>
<button class="project-bar-btn scene-switch-btn icon-box" id="sceneSwitchBtn" onclick="window.TofuPet&&window.TofuPet.cycleDecor()" title="Scene: Meadow · click to change">
<svg width="13" height="13" viewBox="0 0 24 24" fill="none" aria-hidden="true"><path d="M2 20h20" stroke="currentColor" stroke-width="2" stroke-linecap="round"/><path d="M3 20l5-8 3.5 5L15 11l6 9" stroke="currentColor" stroke-width="2" stroke-linejoin="round" stroke-linecap="round"/><circle cx="17.5" cy="6.5" r="2.5" stroke="currentColor" stroke-width="2"/></svg>
<span class="scene-switch-label">Meadow</span>
</button>
<button class="project-bar-close icon-box" onclick="clearProject()" title="Close project">
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" aria-hidden="true"><path d="M6 6l12 12M18 6L6 18" stroke="currentColor" stroke-width="2.2" stroke-linecap="round"/></svg>
</button>
</div>
<div class="image-previews" id="imagePreviews"></div>
<div class="pdf-progress" id="pdfProgress" style="display:none">
<div class="pulse"></div>
<span id="pdfProgressText">Processing PDF...</span>
<div class="pdf-progress-bar"><div class="pdf-progress-fill" id="pdfProgressFill" style="width:0%"></div></div>
</div>
<!-- Log Noise Clean Banner -->
<div class="log-clean-banner" id="logCleanBanner" style="display:none">
<div class="log-clean-banner-icon"></div>
<div class="log-clean-banner-body">
<div class="log-clean-banner-info" id="logCleanInfo"></div>
<div class="log-clean-banner-details" id="logCleanDetails"></div>
</div>
<div class="log-clean-banner-actions">
<button class="log-clean-btn preview" onclick="previewLogClean()" title="对比预览" data-i18n-title="debug.previewCompare" data-i18n="debug.preview">预览</button>
<button class="log-clean-btn apply" onclick="applyLogClean()" title="应用规则清理" data-i18n-title="debug.cleanApply" data-i18n="debug.clean">清理</button>
<button class="log-clean-btn ai-compress" id="aiCompressBtn" onclick="aiCompressLog()" title="用 AI 智能压缩,去除冗余保留关键信息" data-i18n-title="debug.aiCompressDesc" data-i18n="debug.aiCompress">AI压缩</button>
<button class="log-clean-btn dismiss" onclick="hideLogCleanBanner()" title="保持原文" data-i18n-title="debug.keepOriginal">✕</button>
</div>
</div>
<div id="pendingQueueContainer"></div>
<div class="toolset-apply-banner" id="toolsetApplyBanner" style="display:none">
<span class="toolset-apply-banner-icon" aria-hidden="true">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="9"/><line x1="12" y1="8" x2="12" y2="12.5"/><line x1="12" y1="16" x2="12.01" y2="16"/></svg>
</span>
<div class="toolset-apply-banner-text" id="toolsetApplyBannerText"
data-i18n="toolset.pending">工具改动将在新会话生效(保持缓存命中)</div>
<div class="toolset-apply-banner-actions">
<button class="toolset-apply-btn apply" onclick="applyToolsetNow()"
title="立即应用工具改动(会重建一次提示缓存)"
data-i18n-title="toolset.applyNowDesc" data-i18n="toolset.applyNow">立即应用</button>
<button class="toolset-apply-btn dismiss" onclick="dismissToolsetBanner()"
title="撤销改动,把工具开关恢复到不破坏缓存的状态"
data-i18n-title="toolset.dismissDesc" data-i18n="toolset.restore">恢复工具</button>
</div>
</div>
<input type="file" id="fileInput" accept="image/*,.pdf,application/pdf,.docx,.doc,application/vnd.openxmlformats-officedocument.wordprocessingml.document,.pptx,application/vnd.openxmlformats-officedocument.presentationml.presentation,.xlsx,.xls,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel,.ppt,application/vnd.ms-powerpoint,.txt,.md,.csv,.json,.xml,.html,.yaml,.yml,.toml,.py,.js,.ts,.java,.c,.cpp,.go,.rs,.rb,.sh,.sql,.tex,.log,.rst,.ini,.cfg" multiple onchange="handleFileUpload(event)" style="display:none">
<div class="input-box">
<div class="input-row">
<textarea id="userInput" placeholder="Type your message..." rows="1" onkeydown="handleKeyDown(event)"></textarea>
</div>
<div class="input-actions">
<!-- ★ Attach files — leftmost toolbar affordance (the conventional "+"
spot). Moved out of .input-row so the textarea is a clean
full-width field and every control lives in one toolbar row. -->
<button class="attach-btn" id="attachBtn" onclick="document.getElementById('fileInput').click()" data-i18n-title="toolbar.attachFiles" title="Attach files (images, PDF, docs)">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M13.234 20.252 21 12.3"/><path d="m16 6-8.414 8.586a2 2 0 0 0 0 2.828 2 2 0 0 0 2.828 0l8.414-8.586a4 4 0 0 0 0-5.656 4 4 0 0 0-5.656 0l-8.415 8.585a6 6 0 1 0 8.486 8.486l7.766-7.952"/></svg>
</button>
<div class="input-actions-scroll">
<!-- ── Primary: Model & Depth ── -->
<div class="input-group" id="modelGroup">
<div class="preset-toggle-wrapper" id="presetWrapper">
<div class="preset-toggle" id="presetToggle" data-model="" onclick="togglePresetDropdown(event)" title="Select model">
<span class="ps-icon"></span>
<span class="ps-label">Model</span>
<span class="ps-arrow"><svg width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"/></svg></span>
</div>
<div class="preset-dropdown" id="presetDropdown">
<!-- ★ Model list — populated dynamically by _populateModelDropdown() from /api/server-config -->
<div class="preset-dropdown-list" id="presetDropdownList">
<div class="ps-dd-loading" data-i18n="toolbar.loadingModels">正在加载模型…</div>
</div>
<!-- ★ Thinking depth — folded in from the toolbar row (only shown for thinking-capable models) -->
<div class="ps-dd-depth-wrap" id="thinkingDepthSection" style="display:none">
<div class="ps-dd-depth-title" data-i18n="mobile.thinkingDepth">思考深度</div>
<div class="thinking-depth-bar">
<button class="depth-btn" data-depth="off" onclick="selectThinkingDepth('off')">Off</button>
<button class="depth-btn active" data-depth="medium" onclick="selectThinkingDepth('medium')">Med</button>
<button class="depth-btn" data-depth="high" onclick="selectThinkingDepth('high')">High</button>
<button class="depth-btn" data-depth="xhigh" onclick="selectThinkingDepth('xhigh')" title="Claude Opus 4.7+ only — downgrades to High on other models">xHigh</button>
<button class="depth-btn" data-depth="max" onclick="selectThinkingDepth('max')">Max</button>
</div>
</div>
</div>
</div>
</div>
</div><!-- /input-actions-scroll -->
<!-- ── Secondary: Sub-menu Toggles ── -->
<div class="input-group">
<!-- ★ AI Enhance sub-menu -->
<div class="toolbar-submenu" id="submenuAI">
<button class="submenu-trigger" onclick="toggleSubmenu('submenuAI')" data-i18n-title="toolbar.aiEnhanceTooltip" title="AI 增强">
<span class="submenu-label" data-i18n="toolbar.enhance">增强</span>
<span class="submenu-count" id="submenuAICount"></span>
<span class="submenu-arrow"><svg width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"/></svg></span>
</button>
<div class="submenu-dropdown">
<div class="submenu-item" id="codeExecToggle" onclick="toggleCodeExec();updateSubmenuCounts()" title="Allow AI to execute code">
<span class="submenu-item-icon"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="4 17 10 11 4 5"/><line x1="12" y1="19" x2="20" y2="19"/></svg></span>
<span class="submenu-item-text"><span class="submenu-item-name" data-i18n="toolbar.codeExec">代码执行</span><span class="submenu-item-desc" data-i18n="toolbar.codeExecDesc">允许 AI 运行代码</span></span>
<span class="submenu-item-check">✓</span>
</div>
<div class="submenu-item" id="memoryToggle" onclick="toggleMemory();updateSubmenuCounts()" title="Memory — accumulated experience">
<span class="submenu-item-icon"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z"/><path d="M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z"/></svg></span>
<span class="submenu-item-text"><span class="submenu-item-name" data-i18n="toolbar.memory">记忆经验</span><span class="submenu-item-desc" data-i18n="toolbar.memoryDesc">注入积累的经验</span></span>
<span class="submenu-item-check">✓</span>
</div>
<div class="submenu-item" id="translateToggle" onclick="toggleAutoTranslate();updateSubmenuCounts()" title="Auto-translate: Chinese↔English (Ctrl+Shift+K to exclude selected text from translation)">
<span class="submenu-item-icon"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M5 8l6 6"/><path d="M4 14l6-6 2-3"/><path d="M2 5h12"/><path d="M7 2v3"/><path d="M22 22l-5-10-5 10"/><path d="M14 18h6"/></svg></span>
<span class="submenu-item-text"><span class="submenu-item-name" data-i18n="toolbar.autoTranslate">自动翻译</span><span class="submenu-item-desc" data-i18n="toolbar.autoTranslateDesc">中英互译 · ⌘⇧K 跳过选中</span></span>
<span class="submenu-item-check">✓</span>
</div>
<!-- Hidden badges for JS compatibility -->
<span class="tool-badge" id="translateBadge" style="display:none">译</span>
</div>
</div>
<!-- ★ Tools sub-menu -->
<div class="toolbar-submenu" id="submenuTools">
<button class="submenu-trigger" onclick="toggleSubmenu('submenuTools')" data-i18n-title="toolbar.externalToolsTooltip" title="外部工具">
<span class="submenu-label" data-i18n="toolbar.tools">工具</span>
<span class="submenu-count" id="submenuToolsCount"></span>
<span class="submenu-arrow"><svg width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"/></svg></span>
</button>
<div class="submenu-dropdown">
<div class="submenu-item" id="browserToggle" onclick="toggleBrowser();updateSubmenuCounts()" title="Browser Bridge">
<span class="submenu-item-icon"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="2" y1="12" x2="22" y2="12"/><path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"/></svg></span>
<span class="submenu-item-text"><span class="submenu-item-name" data-i18n="toolbar.browserBridge">浏览器桥接</span><span class="submenu-item-desc" data-i18n="toolbar.browserBridgeDesc">控制浏览器标签页</span></span>
<span class="submenu-item-check">✓</span>
</div>
<div class="submenu-item" id="desktopToggle" onclick="toggleDesktop();updateSubmenuCounts()" title="Desktop Agent">
<span class="submenu-item-icon"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="3" width="20" height="14" rx="2" ry="2"/><line x1="8" y1="21" x2="16" y2="21"/><line x1="12" y1="17" x2="12" y2="21"/></svg></span>
<span class="submenu-item-text"><span class="submenu-item-name" data-i18n="toolbar.desktopControl">桌面控制</span><span class="submenu-item-desc" data-i18n="toolbar.desktopControlDesc">操作本地应用与文件</span></span>
<span class="submenu-item-check">✓</span>
<span class="tool-badge" id="desktopBadge" style="display:none"></span>
</div>
<div class="submenu-item" id="schedulerToggle" onclick="toggleScheduler();updateSubmenuCounts()" title="Scheduler">
<span class="submenu-item-icon"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><polyline points="12 6 12 12 16 14"/></svg></span>
<span class="submenu-item-text"><span class="submenu-item-name" data-i18n="toolbar.scheduledTasks">定时任务</span><span class="submenu-item-desc" data-i18n="toolbar.scheduledTasksDesc">计划任务与 Cron</span></span>
<span class="submenu-item-check">✓</span>
</div>
<div class="submenu-item" id="imageGenToggle" onclick="toggleImageGenTool();updateSubmenuCounts()" title="AI Image Generation">
<span class="submenu-item-icon"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/></svg></span>
<span class="submenu-item-text"><span class="submenu-item-name" data-i18n="toolbar.aiDrawing">AI 绘图</span><span class="submenu-item-desc" data-i18n="toolbar.aiDrawingDesc">对话中生成图片</span></span>
<span class="submenu-item-check">✓</span>
</div>
<div class="submenu-item" id="humanGuidanceToggle" onclick="toggleHumanGuidance();updateSubmenuCounts()" title="Human Guidance">
<span class="submenu-item-icon"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"/><line x1="12" y1="17" x2="12.01" y2="17"/></svg></span>
<span class="submenu-item-text"><span class="submenu-item-name" data-i18n="toolbar.humanAICollab">人机协作</span><span class="submenu-item-desc" data-i18n="toolbar.humanAICollabDesc">AI 可向你提问寻求指导</span></span>
<span class="submenu-item-check">✓</span>
</div>
<!-- Divider: the entries below are one-shot LAUNCHERS (enter a
workspace / open a panel), not on/off toggles — no check. -->
<div class="submenu-divider" role="separator"></div>
<div class="submenu-item" id="imageGenModeBtn" onclick="toggleSubmenu('submenuTools');enterImageGenMode()" title="Creative image canvas">
<span class="submenu-item-icon"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/></svg></span>
<span class="submenu-item-text"><span class="submenu-item-name" data-i18n="toolbar.creativeMode">创作模式</span><span class="submenu-item-desc" data-i18n="toolbar.creativeModeDesc">切换到图像创作画布</span></span>
</div>
<div class="submenu-item" id="projectToggle" onclick="toggleSubmenu('submenuTools');openProjectModal()" title="Project Co-Pilot">
<span class="submenu-item-icon"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"/></svg></span>
<span class="submenu-item-text"><span class="submenu-item-name" data-i18n="mobile.projectAssistant">项目助手</span><span class="submenu-item-desc" data-i18n="mobile.projectAssistantDesc">打开项目面板</span></span>
</div>
</div>
</div>
<!-- ★ Mode sub-menu -->
<div class="toolbar-submenu" id="submenuMode">
<button class="submenu-trigger" onclick="toggleSubmenu('submenuMode')" data-i18n-title="toolbar.execModeTooltip" title="执行模式">
<span class="submenu-label" data-i18n="toolbar.mode">模式</span>
<span class="submenu-count" id="submenuModeCount"></span>
<span class="submenu-arrow"><svg width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"/></svg></span>
</button>
<div class="submenu-dropdown">
<div class="submenu-item" id="swarmToggle" onclick="toggleSwarm();updateSubmenuCounts()" title="Agent Swarm">
<span class="submenu-item-icon"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="7" r="3"/><circle cx="5" cy="17" r="3"/><circle cx="19" cy="17" r="3"/><line x1="12" y1="10" x2="5" y2="14"/><line x1="12" y1="10" x2="19" y2="14"/></svg></span>
<span class="submenu-item-text"><span class="submenu-item-name" data-i18n="toolbar.swarmAgents">蜂群代理</span><span class="submenu-item-desc" data-i18n="toolbar.swarmAgentsDesc">并行子代理分解任务</span></span>
<span class="submenu-item-check">✓</span>
<span class="tool-badge" id="swarmBadge" style="display:none"></span>
</div>
<div class="submenu-item" id="endpointToggle" onclick="toggleEndpoint();updateSubmenuCounts()" title="Endpoint Mode">
<span class="submenu-item-icon"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 2v4"/><path d="M12 18v4"/><path d="M4.93 4.93l2.83 2.83"/><path d="M16.24 16.24l2.83 2.83"/><path d="M2 12h4"/><path d="M18 12h4"/><path d="M4.93 19.07l2.83-2.83"/><path d="M16.24 7.76l2.83-2.83"/><circle cx="12" cy="12" r="4"/></svg></span>
<span class="submenu-item-text"><span class="submenu-item-name" data-i18n="toolbar.autonomousMode">自主模式</span><span class="submenu-item-desc" data-i18n="toolbar.autonomousModeDesc">自主执行+自我审查循环</span></span>
<span class="submenu-item-check">✓</span>
<span class="tool-badge" id="endpointBadge" style="display:none"></span>
</div>
<div class="submenu-item" id="autopilotToggle" onclick="toggleAutopilot();updateSubmenuCounts()" title="Autopilot — virtual user auto-replies">
<span class="submenu-item-icon"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="3"/><path d="M12 1v6m0 10v6m11-11h-6m-10 0H1m17.66-6.34l-4.24 4.24m-5.66 5.66l-4.24 4.24m12.14 0l-4.24-4.24m-5.66-5.66L4.34 4.34"/></svg></span>
<span class="submenu-item-text"><span class="submenu-item-name" data-i18n="toolbar.autopilot">自动驾驶</span><span class="submenu-item-desc" data-i18n="toolbar.autopilotDesc">虚拟用户自动回复,直到任务完成</span></span>
<span class="submenu-item-check">✓</span>
<span class="tool-badge" id="autopilotBadge" style="display:none"></span>
</div>
<!-- ★ Orchestration Flow selector — runs the whole conversation on
a Studio-authored flow (or a built-in). Mutually exclusive with
the toggles above (the flow IS the execution mode). -->
<div class="submenu-flow-row" id="flowMenuWrapper">
<div class="submenu-item" id="flowToggle" onclick="toggleFlowMenu(event)" title="Orchestration Flow">
<span class="submenu-item-icon"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="7" height="7" rx="1"/><rect x="14" y="14" width="7" height="7" rx="1"/><path d="M10 6.5h4a2 2 0 0 1 2 2V14"/></svg></span>
<span class="submenu-item-text"><span class="submenu-item-name" data-i18n="toolbar.flow">编排流程</span><span class="submenu-item-desc" id="flowActiveLabel" data-i18n="toolbar.flowNone">不使用</span></span>
<span class="submenu-arrow"><svg width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"/></svg></span>
<span class="tool-badge" id="flowBadge" style="display:none"></span>
</div>
<div class="flow-menu" id="flowMenu">
<div class="flow-menu-list" id="flowMenuList"></div>
</div>
</div>
</div>
</div>
</div>
<div class="input-actions-right">
<!-- Mobile-only "more" button — opens bottom sheet with all toggles -->
<button class="mobile-more-btn" id="mobileMoreBtn" onclick="toggleMobileSheet()" data-i18n-title="toolbar.moreOptionsTooltip" title="更多选项"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"><circle cx="5" cy="12" r="1.5"/><circle cx="12" cy="12" r="1.5"/><circle cx="19" cy="12" r="1.5"/></svg></button>
<button class="mic-btn" id="micBtn" onclick="toggleVoiceInput()" data-i18n-title="voice.tooltip" title="Voice input" style="display:none">
<svg class="mic-icon" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z"/><path d="M19 10v2a7 7 0 0 1-14 0v-2"/><line x1="12" y1="19" x2="12" y2="22"/></svg>
</button>
<div class="search-mode-toggle" id="searchModeToggle" data-mode="off" onclick="cycleSearchMode()" data-i18n-title="search.toggleTooltip" title="Web search — click to toggle on/off">
<span class="sm-icon"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"><circle cx="11" cy="11" r="7"/><line x1="16.5" y1="16.5" x2="21" y2="21"/></svg></span>
<span class="sm-label">Search</span>
<span class="sm-mode-pill">OFF</span>
</div>
<button class="send-btn" id="sendBtn" onclick="sendMessage()" title="Send (Enter)">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="M6 12L20 12"/><path d="M13 5l7 7-7 7"/></svg>
</button>
</div><!-- /input-actions-right -->
</div>
<!-- ═══ Image Generation Mode Toolbar — single-row canvas bar ═══ -->
<div class="ig-toolbar" id="igModeToolbar">
<button class="ig-exit" onclick="exitImageGenMode()" data-i18n-title="toolbar.exitCreativeTooltip" title="退出创作模式 (Esc)">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>
</button>
<!-- Model picker — reuses preset-toggle-wrapper pattern -->
<div class="preset-toggle-wrapper ig-model-wrapper" id="igModelPicker">
<div class="preset-toggle ig-preset" data-brand="generic" onclick="toggleIgModelDropdown(event)" title="Select image model">
<span class="ps-icon" id="igModelIcon"></span>
<span class="ps-label" id="igModelLabel">Gemini 3.1 Flash</span>
<span class="ps-arrow"><svg width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"/></svg></span>
</div>
<!-- Populated dynamically by _loadIgModels() -->
<div class="preset-dropdown ig-preset-dropdown" id="igModelDropdown"></div>
</div>
<span class="ig-sep"></span>
<!-- Aspect ratio — inline pill bar (like thinking-depth-bar) -->
<div class="ig-seg" id="igAspectBar">
<button class="ig-pill active" data-ar="1:1" onclick="selectIgAspect(this)" title="1:1 正方形" data-i18n-title="ig.square">1:1</button>
<button class="ig-pill" data-ar="16:9" onclick="selectIgAspect(this)" title="16:9 横屏宽幅" data-i18n-title="ig.landscape">16:9</button>
<button class="ig-pill" data-ar="9:16" onclick="selectIgAspect(this)" title="9:16 竖屏" data-i18n-title="ig.portrait">9:16</button>
<button class="ig-pill" data-ar="4:3" onclick="selectIgAspect(this)" title="4:3 经典" data-i18n-title="ig.classic">4:3</button>
<button class="ig-pill" data-ar="3:4" onclick="selectIgAspect(this)" title="3:4 竖版" data-i18n-title="ig.tallPortrait">3:4</button>
</div>
<span class="ig-sep"></span>
<!-- Resolution — inline pill bar -->
<div class="ig-seg" id="igResolutionBar">
<button class="ig-pill ig-pill-q active" data-res="1K" onclick="selectIgResolution(this)" data-i18n-title="ig.stdResTooltip" title="1024px · 标准分辨率">1K</button>
<button class="ig-pill ig-pill-q" data-res="2K" onclick="selectIgResolution(this)" data-i18n-title="ig.hdResTooltip" title="2048px · 高清分辨率">2K</button>
</div>
<span class="ig-sep"></span>
<!-- Gacha batch count — inline pill bar -->
<div class="ig-seg" id="igCountBar">
<button class="ig-pill ig-pill-n active" data-count="1" onclick="selectIgCount(this)" title="生成单张图片" data-i18n-title="ig.singleDesc" data-i18n="ig.single">单抽</button>
<button class="ig-pill ig-pill-n" data-count="2" onclick="selectIgCount(this)" title="同时生成 2 张,多个选择" data-i18n-title="ig.doubleDesc" data-i18n="ig.double">2连</button>
<button class="ig-pill ig-pill-n" data-count="4" onclick="selectIgCount(this)" title="同时生成 4 张,大量出图!" data-i18n-title="ig.quadDesc" data-i18n="ig.quad">4连</button>
</div>
<span class="ig-flex"></span>
<!-- Generate button -->
<button class="ig-generate-btn" id="igGenerateBtn" onclick="generateImageDirect()" data-i18n-title="ig.generateTooltip" title="生成 (Enter)">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"/></svg>
<span class="ig-gen-text" data-i18n="toolbar.generate">生成</span>
</button>
</div>
</div>
<div class="input-footer"><span class="input-hint" id="inputHint">Enter send · Ctrl+Enter / Shift+Enter newline · <svg class="input-hint-clip" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551"/></svg> or drop files</span></div>
</div>
</div>
</div>
</main>
<!-- Settings Modal — Tabbed Panel -->
<div class="modal-overlay" id="settingsModal" onclick="if(event.target===this)closeSettings()">
<div class="modal settings-panel">
<!-- Header -->
<div class="settings-header">
<h3 data-i18n="settings.title">设置</h3>
<button class="settings-close-btn" onclick="closeSettings()" title="关闭" data-i18n-title="settings.close">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>
</button>
</div>
<div class="settings-body">
<!-- Tab Navigation (left sidebar) -->
<nav class="settings-tabs">
<button class="settings-tab active" data-tab="general" onclick="switchSettingsTab('general')">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="3"/><path d="M19.4 15a1.65 1.65 0 00.33 1.82l.06.06a2 2 0 010 2.83 2 2 0 01-2.83 0l-.06-.06a1.65 1.65 0 00-1.82-.33 1.65 1.65 0 00-1 1.51V21a2 2 0 01-4 0v-.09A1.65 1.65 0 009 19.4a1.65 1.65 0 00-1.82.33l-.06.06a2 2 0 01-2.83-2.83l.06-.06A1.65 1.65 0 004.68 15a1.65 1.65 0 00-1.51-1H3a2 2 0 010-4h.09A1.65 1.65 0 004.6 9a1.65 1.65 0 00-.33-1.82l-.06-.06a2 2 0 012.83-2.83l.06.06A1.65 1.65 0 009 4.68a1.65 1.65 0 001-1.51V3a2 2 0 014 0v.09a1.65 1.65 0 001 1.51 1.65 1.65 0 001.82-.33l.06-.06a2 2 0 012.83 2.83l-.06.06A1.65 1.65 0 0019.4 9a1.65 1.65 0 001.51 1H21a2 2 0 010 4h-.09a1.65 1.65 0 00-1.51 1z"/></svg>
<span data-i18n="settings.tabGeneral">通用</span>
</button>
<button class="settings-tab" data-tab="api" onclick="switchSettingsTab('api')">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M10 13a5 5 0 007.54.54l3-3a5 5 0 00-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 00-7.54-.54l-3 3a5 5 0 007.07 7.07l1.71-1.71"/></svg>
<span data-i18n="settings.tabProviders">服务商</span>
</button>
<button class="settings-tab" data-tab="preset" onclick="switchSettingsTab('preset')">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 16V8a2 2 0 00-1-1.73l-7-4a2 2 0 00-2 0l-7 4A2 2 0 003 8v8a2 2 0 001 1.73l7 4a2 2 0 002 0l7-4A2 2 0 0021 16z"/><polyline points="3.27 6.96 12 12.01 20.73 6.96"/><line x1="12" y1="22.08" x2="12" y2="12"/></svg>
<span data-i18n="settings.tabDisplay">显示</span>
</button>
<button class="settings-tab" data-tab="search" onclick="switchSettingsTab('search')">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/></svg>
<span data-i18n="settings.tabSearch">搜索</span>
</button>
<button class="settings-tab" data-tab="translate" onclick="switchSettingsTab('translate')">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M5 8l6 6"/><path d="M4 14l6-6 2-3"/><path d="M2 5h12"/><path d="M7 2v3"/><path d="M22 22l-5-10-5 10"/><path d="M14 18h6"/></svg>
<span data-i18n="settings.tabTranslate">翻译</span>
</button>
<button class="settings-tab" data-tab="speech" onclick="switchSettingsTab('speech')">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3z"/><path d="M19 10v2a7 7 0 0 1-14 0v-2"/><line x1="12" y1="19" x2="12" y2="22"/></svg>
<span data-i18n="settings.tabSpeech">语音识别</span>
</button>
<button class="settings-tab" data-tab="network" onclick="switchSettingsTab('network')">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="2" y1="12" x2="22" y2="12"/><path d="M12 2a15.3 15.3 0 014 10 15.3 15.3 0 01-4 10 15.3 15.3 0 01-4-10 15.3 15.3 0 014-10z"/></svg>
<span data-i18n="settings.tabNetwork">网络</span>
</button>
<button class="settings-tab" data-tab="feishu" onclick="switchSettingsTab('feishu')">
<svg width="15" height="15" viewBox="62.16 94.5 407.87 324.19"><path d="M274.18 264.785q.515-.517 1.03-1.027c.685-.688 1.372-1.258 2.056-1.945l1.37-1.372 4.118-4.113 5.598-5.601 4.8-4.797 4.575-4.457 4.796-4.688 4.344-4.344 6.059-6.054c1.14-1.145 2.285-2.29 3.543-3.317 2.168-2.054 4.457-4 6.855-5.828 2.172-1.715 4.344-3.312 6.516-4.914 3.082-2.172 6.398-4.344 9.71-6.285 3.204-1.941 6.63-3.656 10.06-5.371 3.199-1.602 6.515-2.973 9.827-4.23 1.829-.684 3.774-1.372 5.602-2.055.914-.344 1.941-.688 2.856-.914-8.57-33.715-24.227-64.575-45.258-90.86-4.114-5.14-10.399-8.113-17.028-8.113H130.754c-3.203 0-4.457 4-1.945 5.941 59.543 43.66 109.144 99.887 145.03 164.801 0-.226.227-.34.34-.457" fill="#00d6b9"/><path d="M204.79 418.691c90.288 0 169.03-49.828 210.058-123.543 1.488-2.628 2.859-5.257 4.23-7.882q-3.087 6-6.86 11.312l-2.741 3.77c-1.141 1.488-2.399 2.972-3.657 4.457-1.03 1.144-2.058 2.285-3.086 3.316-2.058 2.172-4.343 4.227-6.629 6.172a53 53 0 0 1-3.886 3.2c-1.598 1.144-3.086 2.284-4.684 3.429-1.031.683-2.058 1.371-3.086 1.941-1.144.684-2.172 1.258-3.316 1.942a131 131 0 0 1-6.969 3.543c-2.059.918-4.117 1.828-6.289 2.515-2.285.801-4.57 1.602-6.969 2.285-3.543.914-7.086 1.715-10.742 2.286-2.629.457-5.258.687-8 .914-2.86.23-5.601.23-8.457.23-3.086 0-6.289-.23-9.488-.57a83 83 0 0 1-7.086-1.031c-2.055-.34-4.113-.801-6.168-1.258-1.031-.227-2.176-.57-3.203-.797-2.973-.8-6.055-1.602-9.028-2.516-1.488-.457-2.972-.914-4.457-1.258-2.172-.683-4.457-1.37-6.629-2.058-1.828-.57-3.656-1.14-5.37-1.711q-2.573-.86-5.145-1.715c-1.14-.344-2.285-.8-3.543-1.144-1.371-.457-2.856-1.028-4.227-1.485-1.027-.344-2.058-.687-2.972-1.027-1.942-.688-4-1.488-5.942-2.172-1.144-.457-2.285-.914-3.43-1.258-1.484-.57-3.085-1.144-4.57-1.828-1.601-.687-3.203-1.258-4.8-1.945-1.028-.457-2.06-.797-3.087-1.258-1.257-.57-2.628-1.027-3.886-1.598-1.028-.457-1.942-.8-2.969-1.258l-3.086-1.37c-.914-.344-1.832-.801-2.746-1.145a44 44 0 0 1-2.512-1.14c-.8-.345-1.715-.802-2.515-1.145-.914-.344-1.715-.801-2.512-1.141-1.031-.457-2.172-1.031-3.203-1.484-1.14-.575-2.285-1.032-3.426-1.602-1.258-.574-2.402-1.144-3.66-1.715-1.027-.457-2.055-1.027-3.082-1.484-54.172-26.973-102.172-63.086-143.09-106.746-2.055-2.172-5.71-.684-5.71 2.289l.112 154.398v12.57c0 7.317 3.543 14.06 9.598 18.172 38.172 24.801 83.773 39.543 132.914 39.543" fill="#3370ff"/><path d="M414.84 295.188c0 .113-.113.113-.113.226l.8-1.489c-.343.457-.574 1.028-.8 1.488m3.793-7.05.226-.457.114-.23q-.17.513-.34.687" fill="#133c9a"/><path d="M470.035 201.121c-18.285-9.031-38.86-14.059-60.687-14.059-12.914 0-25.485 1.829-37.371 5.141-1.372.344-2.743.8-4.114 1.258-.914.344-1.941.574-2.855.914-1.945.688-3.774 1.375-5.602 2.059-3.316 1.257-6.629 2.742-9.828 4.23-3.43 1.598-6.742 3.426-10.058 5.371a128 128 0 0 0-9.715 6.285c-2.285 1.602-4.457 3.2-6.512 4.914a154 154 0 0 0-6.86 5.828c-1.14 1.141-2.398 2.172-3.542 3.313l-6.055 6.059-4.344 4.343-4.8 4.684-4.57 4.46-4.802 4.798-11.086 11.086c-.687.687-1.37 1.37-2.058 1.945l-1.028 1.027c-.457.457-1.027 1.028-1.601 1.485-.57.57-1.14 1.031-1.711 1.601a244.4 244.4 0 0 1-49.828 35.313c1.027.457 2.168 1.027 3.199 1.488.8.34 1.715.797 2.512 1.14.8.344 1.715.801 2.515 1.145.801.344 1.602.684 2.516 1.14.914.345 1.828.802 2.742 1.145l3.086 1.371c1.027.457 1.942.801 2.969 1.258 1.258.57 2.629 1.028 3.887 1.598 1.03.46 2.058.8 3.086 1.258 1.601.687 3.199 1.258 4.8 1.945 1.485.57 3.086 1.14 4.57 1.828 1.145.457 2.286.914 3.43 1.258 1.946.684 4 1.484 5.946 2.172a81 81 0 0 1 2.968 1.027c1.371.457 2.856 1.028 4.23 1.485 1.141.343 2.286.8 3.544 1.14q2.567.86 5.14 1.719c1.829.57 3.657 1.14 5.372 1.71 2.171.688 4.457 1.376 6.628 2.06 1.489.457 2.973.914 4.457 1.257 2.973.914 5.942 1.715 9.032 2.512 1.027.344 2.168.574 3.199.8 2.055.458 4.113.915 6.172 1.259 2.398.457 4.683.8 7.082 1.03 3.203.34 6.402.571 9.488.571 2.856 0 5.715 0 8.457-.23 2.63-.227 5.371-.457 8-.914 3.656-.57 7.2-1.371 10.742-2.286 2.399-.683 4.688-1.37 6.973-2.285 2.172-.8 4.227-1.601 6.285-2.515 2.399-1.028 4.684-2.285 6.973-3.543 1.14-.57 2.168-1.258 3.312-1.942 1.028-.687 2.059-1.257 3.086-1.945 1.602-1.027 3.2-2.168 4.684-3.426a52 52 0 0 0 3.887-3.203c2.289-1.941 4.457-4 6.628-6.168 1.032-1.031 2.06-2.172 3.086-3.316 1.258-1.485 2.516-2.969 3.657-4.457.918-1.258 1.828-2.512 2.742-3.77 2.515-3.543 4.8-7.316 6.86-11.199l2.284-4.688 21.145-42.171v.113c6.742-14.742 16.226-28.113 27.656-39.426" fill="#133c9a"/></svg>
<span data-i18n="settings.tabFeishu">飞书</span>
</button>
<button class="settings-tab" data-tab="oauth" onclick="switchSettingsTab('oauth')">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M15 3h4a2 2 0 012 2v14a2 2 0 01-2 2h-4"/><polyline points="10 17 15 12 10 7"/><line x1="15" y1="12" x2="3" y2="12"/></svg>
<span data-i18n="settings.tabOAuth">订阅登录</span>
</button>
<button class="settings-tab" data-tab="mcp" onclick="switchSettingsTab('mcp')">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 2v4m0 12v4M2 12h4m12 0h4"/><circle cx="12" cy="12" r="3"/><path d="M12 8V6m0 12v-2M8 12H6m12 0h-2"/></svg>
<span>MCP</span>
</button>
<button class="settings-tab" data-tab="skills" onclick="switchSettingsTab('skills')">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"/><polyline points="3.27 6.96 12 12.01 20.73 6.96"/><line x1="12" y1="22.08" x2="12" y2="12"/></svg>
<span data-i18n="settings.tabSkills">Skills</span>
</button>
<button class="settings-tab" data-tab="preferences" onclick="switchSettingsTab('preferences')">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="4" y1="21" x2="4" y2="14"/><line x1="4" y1="10" x2="4" y2="3"/><line x1="12" y1="21" x2="12" y2="12"/><line x1="12" y1="8" x2="12" y2="3"/><line x1="20" y1="21" x2="20" y2="16"/><line x1="20" y1="12" x2="20" y2="3"/><line x1="1" y1="14" x2="7" y2="14"/><line x1="9" y1="8" x2="15" y2="8"/><line x1="17" y1="16" x2="23" y2="16"/></svg>
<span data-i18n="settings.tabPreferences">记忆与偏好</span>
</button>
<!-- Relay-admin tabs (用户/定价/兑换码/支付) moved to the standalone
/admin console (static/admin.html). Settings is now pure
single-user config. -->
<button class="settings-tab" data-tab="advanced" onclick="switchSettingsTab('advanced')">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/></svg>
<span data-i18n="settings.tabAdvanced">高级</span>
</button>
</nav>
<!-- Tab Content Panels -->
<div class="settings-content">
<!-- ═══ General Tab ═══ -->
<div class="settings-tab-panel active" id="settingsTab_general">
<div class="settings-row two-col">
<div class="settings-field">
<div class="settings-section-title" data-i18n="settings.theme" style="margin-bottom:8px">主题</div>
<div class="theme-picker" id="themePicker">
<div class="theme-option active" data-theme="dark" onclick="selectTheme('dark')">
<div class="theme-preview dark-preview"></div>
<span class="theme-option-label"><svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401"/></svg><span data-i18n="settings.themeDark">暗色</span></span>
</div>
<div class="theme-option" data-theme="light" onclick="selectTheme('light')">
<div class="theme-preview light-preview"></div>
<span class="theme-option-label"><svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="4"/><path d="M12 2v2"/><path d="M12 20v2"/><path d="m4.93 4.93 1.41 1.41"/><path d="m17.66 17.66 1.41 1.41"/><path d="M2 12h2"/><path d="M20 12h2"/><path d="m6.34 17.66-1.41 1.41"/><path d="m19.07 4.93-1.41 1.41"/></svg><span data-i18n="settings.themeLight">亮色</span></span>
</div>
<div class="theme-option" data-theme="tofu" onclick="selectTheme('tofu')">
<div class="theme-preview tofu-preview"></div>
<span class="theme-option-label"><svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M5 11c0-3 3-5 7-5s7 2 7 5"/><path d="M5 11l1.3 6.6a2 2 0 0 0 2 1.4h7.4a2 2 0 0 0 2-1.4L19 11Z"/><path d="M3 20h18"/></svg><span data-i18n="settings.themeTofu">豆腐</span></span>
</div>
</div>
</div>
<div class="settings-field">
<div class="settings-section-title" data-i18n="settings.language" style="margin-bottom:8px">界面语言</div>
<div class="lang-picker" id="langPicker">
<div class="lang-option active" data-lang="zh" onclick="_onLanguageChange('zh')">
<span class="lang-flag"><svg width="20" height="14" viewBox="0 0 24 16"><rect width="24" height="16" fill="#de2910"/><path d="M5 3l.7 2.1H8l-1.85 1.35.7 2.15L5 7.25 3.15 8.6l.7-2.15L2 5.1h2.3z" fill="#ffde00"/></svg></span>
<span class="lang-label">中文</span>
</div>
<div class="lang-option" data-lang="en" onclick="_onLanguageChange('en')">
<span class="lang-flag"><svg width="20" height="14" viewBox="0 0 24 16"><rect width="24" height="16" fill="#fff"/><g fill="#b22234"><rect width="24" height="1.85"/><rect y="3.7" width="24" height="1.85"/><rect y="7.4" width="24" height="1.85"/><rect y="11.1" width="24" height="1.85"/><rect y="14.15" width="24" height="1.85"/></g><rect width="10" height="8.6" fill="#3c3b6e"/></svg></span>
<span class="lang-label">English</span>
</div>
</div>
<!-- hidden select kept for JS compat -->