SrishtiMehta commited on
Commit
51334f9
·
verified ·
1 Parent(s): 3dc5262

first commit

Browse files
Files changed (6) hide show
  1. app.py +40 -0
  2. requirements.txt +3 -0
  3. static/logo.jpeg +0 -0
  4. static/script.js +149 -0
  5. static/styles.css +453 -0
  6. templates/index.html +128 -0
app.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI
2
+ from fastapi.responses import HTMLResponse
3
+ from fastapi.staticfiles import StaticFiles
4
+ from fastapi.templating import Jinja2Templates
5
+ from fastapi import Request
6
+ import uvicorn
7
+
8
+ app = FastAPI()
9
+
10
+ # Mount static files
11
+ app.mount("/static", StaticFiles(directory="static"), name="static")
12
+
13
+ templates = Jinja2Templates(directory="templates")
14
+
15
+ # Frontend route
16
+ @app.get("/", response_class=HTMLResponse)
17
+ async def home(request: Request):
18
+ return templates.TemplateResponse("index.html", {"request": request})
19
+
20
+ # Your moderation endpoint (example)
21
+ @app.post("/moderate")
22
+ async def moderate(data: dict):
23
+ text = data.get("text", "")
24
+
25
+ # 🔥 Replace with your real model logic
26
+ return {
27
+ "decision": "flag",
28
+ "confidence": 0.85,
29
+ "explanation": "Potentially harmful content detected",
30
+ "ai_scores": {
31
+ "toxicity": 0.8,
32
+ "insult": 0.6,
33
+ "threat": 0.7,
34
+ "obscene": 0.5
35
+ }
36
+ }
37
+
38
+ # Run locally
39
+ if __name__ == "__main__":
40
+ uvicorn.run(app, host="0.0.0.0", port=7860)
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ fastapi
2
+ uvicorn
3
+ jinja2
static/logo.jpeg ADDED
static/script.js ADDED
@@ -0,0 +1,149 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ let total = 0, allowedCount = 0, removedCount = 0, confSum = 0;
2
+ http
3
+ function now() {
4
+ const d = new Date();
5
+ return d.getHours().toString().padStart(2, '0') + ':' +
6
+ d.getMinutes().toString().padStart(2, '0');
7
+ }
8
+
9
+ async function analyze() {
10
+ const text = document.getElementById('inputText').value.trim();
11
+ if (!text) return;
12
+
13
+ const btn = document.getElementById('analyzeBtn');
14
+ btn.disabled = true;
15
+ btn.innerHTML = '<span class="loading-dots">Analyzing</span>';
16
+
17
+ const resultsWrap = document.getElementById('resultsWrap');
18
+ resultsWrap.style.display = 'block';
19
+
20
+ document.getElementById('explText').innerHTML =
21
+ '<span class="loading-dots">Analyzing content</span>';
22
+ document.getElementById('decisionBadge').className = 'decision-badge';
23
+ document.getElementById('decisionBadge').textContent = '';
24
+ document.getElementById('scoresContainer').innerHTML = '';
25
+
26
+ try {
27
+ const res = await fetch("/moderate", {
28
+ method: "POST",
29
+ headers: {
30
+ "Content-Type": "application/json"
31
+ },
32
+ body: JSON.stringify({ text })
33
+ });
34
+
35
+ if (!res.ok) {
36
+ throw new Error("Server error");
37
+ }
38
+
39
+ const result = await res.json();
40
+
41
+ if (!result || !result.ai_scores) {
42
+ throw new Error("Invalid response format");
43
+ }
44
+
45
+ renderResult(result, text);
46
+
47
+ } catch (e) {
48
+ console.error(e);
49
+ document.getElementById('explText').textContent =
50
+ 'Error analyzing content. Check backend.';
51
+ } finally {
52
+ btn.disabled = false;
53
+ btn.innerHTML = `
54
+ <svg class="shield-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
55
+ <path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/>
56
+ </svg> Analyze Content
57
+ `;
58
+ }
59
+ }
60
+
61
+ function renderResult(r, text) {
62
+ const conf = Math.round(r.confidence * 100);
63
+
64
+ const badge = document.getElementById('decisionBadge');
65
+ const icons = { allow: '✓', flag: '⚠', remove: '✕', review: 'ℹ' };
66
+
67
+ badge.className = 'decision-badge badge-' + r.decision;
68
+ badge.textContent =
69
+ (icons[r.decision] || '') + ' ' + r.decision.toUpperCase();
70
+
71
+ document.getElementById('explText').textContent = r.explanation;
72
+ document.getElementById('metaDecision').textContent = r.decision;
73
+ document.getElementById('metaConf').textContent = conf + '%';
74
+
75
+ const sc = r.ai_scores;
76
+
77
+ const labels = ['Toxicity', 'Insult', 'Threat', 'Obscene'];
78
+ const keys = ['toxicity', 'insult', 'threat', 'obscene'];
79
+
80
+ document.getElementById('scoresContainer').innerHTML = keys.map((k, i) => {
81
+ const val = sc[k] || 0;
82
+ const pct = Math.round(val * 100);
83
+
84
+ const cls =
85
+ pct >= 60 ? 'fill-high' :
86
+ pct >= 30 ? 'fill-mid' :
87
+ 'fill-low';
88
+
89
+ return `
90
+ <div class="score-row">
91
+ <div class="score-header">
92
+ <span>${labels[i]}</span>
93
+ <span>${pct}%</span>
94
+ </div>
95
+ <div class="score-bar">
96
+ <div class="score-fill ${cls}" style="width:${pct}%"></div>
97
+ </div>
98
+ </div>
99
+ `;
100
+ }).join('');
101
+
102
+ /* STATS */
103
+ total++;
104
+ if (r.decision === 'allow') allowedCount++;
105
+ if (r.decision === 'remove') removedCount++;
106
+
107
+ confSum += r.confidence;
108
+
109
+ document.getElementById('stat-total').textContent = total;
110
+ document.getElementById('stat-allowed').textContent = allowedCount;
111
+ document.getElementById('stat-removed').textContent = removedCount;
112
+
113
+ document.getElementById('stat-allowed-pct').textContent =
114
+ Math.round((allowedCount / total) * 100) + '% of total';
115
+
116
+ document.getElementById('stat-removed-pct').textContent =
117
+ Math.round((removedCount / total) * 100) + '% of total';
118
+
119
+ document.getElementById('stat-conf').textContent =
120
+ Math.round((confSum / total) * 100) + '%';
121
+
122
+ /* HISTORY */
123
+ const list = document.getElementById('historyList');
124
+ const empty = list.querySelector('.empty-history');
125
+ if (empty) empty.remove();
126
+
127
+ const item = document.createElement('div');
128
+ item.className = 'history-item';
129
+
130
+ item.innerHTML = `
131
+ <div>
132
+ <div class="h-badge h-${r.decision}">
133
+ ${(r.decision === 'allow' ? '✓ ' :
134
+ r.decision === 'remove' ? '✕ ' : '⚠ ')
135
+ + r.decision.toUpperCase()}
136
+ </div>
137
+ <div class="history-text">
138
+ ${text.length > 80 ? text.slice(0, 80) + '…' : text}
139
+ </div>
140
+ </div>
141
+ <div class="history-time">${now()}</div>
142
+ `;
143
+
144
+ list.prepend(item);
145
+ }
146
+
147
+ document.getElementById('inputText').addEventListener('keydown', e => {
148
+ if (e.key === 'Enter' && (e.ctrlKey || e.metaKey)) analyze();
149
+ });
static/styles.css ADDED
@@ -0,0 +1,453 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ * {
2
+ box-sizing: border-box;
3
+ margin: 0;
4
+ padding: 0
5
+ }
6
+
7
+ body {
8
+ font-family: 'Segoe UI', system-ui, sans-serif;
9
+ background: #0B132B;
10
+ color: #fff;
11
+ min-height: 100vh
12
+ }
13
+
14
+ /* HEADER */
15
+ .header {
16
+ padding: 18px 32px;
17
+ display: flex;
18
+ align-items: center;
19
+ border-bottom: 1px solid rgba(255, 255, 255, 0.06);
20
+ }
21
+
22
+ .brand {
23
+ display: flex;
24
+ align-items: center;
25
+ gap: 14px;
26
+ }
27
+
28
+ /* LOGO */
29
+ .logo {
30
+ width: 44px;
31
+ height: 44px;
32
+ border-radius: 50%;
33
+ object-fit: cover;
34
+ background: #dbeafe;
35
+ padding: 4px;
36
+ }
37
+
38
+ /* TITLE */
39
+ .title {
40
+ font-size: 26px;
41
+ font-weight: 700;
42
+ background: linear-gradient(90deg, #4F7DF3, #3FB6B2);
43
+ -webkit-background-clip: text;
44
+ -webkit-text-fill-color: transparent;
45
+ }
46
+
47
+ /* GRADIENT BAR */
48
+ .gradient-bar {
49
+ height: 3px;
50
+ background: linear-gradient(90deg, #5A3E8B, #3A6EA5, #3FB6B2);
51
+ width: 100%
52
+ }
53
+
54
+ /* STATS */
55
+ .stats {
56
+ display: grid;
57
+ grid-template-columns: repeat(4, 1fr);
58
+ gap: 16px;
59
+ padding: 24px 32px
60
+ }
61
+
62
+ .stat-card {
63
+ background: #132040;
64
+ border: 1px solid rgba(255, 255, 255, 0.07);
65
+ border-radius: 12px;
66
+ padding: 20px 24px
67
+ }
68
+
69
+ .stat-label {
70
+ display: flex;
71
+ align-items: center;
72
+ gap: 8px;
73
+ font-size: 11px;
74
+ font-weight: 600;
75
+ letter-spacing: 0.08em;
76
+ color: #7A8BAA;
77
+ text-transform: uppercase;
78
+ margin-bottom: 12px
79
+ }
80
+
81
+ .stat-label svg {
82
+ opacity: 0.6
83
+ }
84
+
85
+ .stat-value {
86
+ font-size: 36px;
87
+ font-weight: 700;
88
+ color: #fff;
89
+ line-height: 1
90
+ }
91
+
92
+ .stat-sub {
93
+ font-size: 12px;
94
+ color: #7A8BAA;
95
+ margin-top: 6px
96
+ }
97
+
98
+ /* ANALYZER SECTION */
99
+ .analyzer-wrap {
100
+ margin: 0 32px 24px;
101
+ background: linear-gradient(135deg, rgba(90, 62, 139, 0.15), rgba(58, 110, 165, 0.15));
102
+ border: 1px solid rgba(90, 62, 139, 0.4);
103
+ border-radius: 16px;
104
+ padding: 28px
105
+ }
106
+
107
+ .section-title {
108
+ font-size: 22px;
109
+ font-weight: 700;
110
+ color: #fff;
111
+ margin-bottom: 6px
112
+ }
113
+
114
+ .section-sub {
115
+ font-size: 14px;
116
+ color: #7A8BAA;
117
+ margin-bottom: 20px
118
+ }
119
+
120
+ textarea {
121
+ width: 100%;
122
+ height: 140px;
123
+ background: #0B132B;
124
+ border: 1px solid rgba(58, 110, 165, 0.5);
125
+ border-radius: 10px;
126
+ color: #fff;
127
+ font-family: monospace;
128
+ font-size: 14px;
129
+ padding: 14px;
130
+ resize: vertical;
131
+ outline: none;
132
+ transition: border-color 0.2s
133
+ }
134
+
135
+ textarea:focus {
136
+ border-color: #3A6EA5
137
+ }
138
+
139
+ textarea::placeholder {
140
+ color: #3A5070
141
+ }
142
+
143
+ .btn-row {
144
+ display: flex;
145
+ justify-content: flex-end;
146
+ margin-top: 14px
147
+ }
148
+
149
+ .analyze-btn {
150
+ display: flex;
151
+ align-items: center;
152
+ gap: 8px;
153
+ background: linear-gradient(135deg, #3A6EA5, #3FB6B2);
154
+ border: none;
155
+ border-radius: 10px;
156
+ color: #fff;
157
+ font-size: 15px;
158
+ font-weight: 600;
159
+ padding: 12px 24px;
160
+ cursor: pointer;
161
+ transition: opacity 0.2s
162
+ }
163
+
164
+ .analyze-btn:hover {
165
+ opacity: 0.9
166
+ }
167
+
168
+ .analyze-btn:disabled {
169
+ opacity: 0.5;
170
+ cursor: not-allowed
171
+ }
172
+
173
+ .shield-icon {
174
+ width: 18px;
175
+ height: 18px
176
+ }
177
+
178
+ /* RESULTS */
179
+ .results-wrap {
180
+ margin: 0 32px 24px;
181
+ background: #132040;
182
+ border: 1px solid rgba(255, 255, 255, 0.07);
183
+ border-radius: 16px;
184
+ padding: 28px;
185
+ display: none
186
+ }
187
+
188
+ .results-header {
189
+ display: flex;
190
+ align-items: center;
191
+ justify-content: space-between;
192
+ margin-bottom: 20px
193
+ }
194
+
195
+ .results-title {
196
+ font-size: 18px;
197
+ font-weight: 600
198
+ }
199
+
200
+ .decision-badge {
201
+ display: flex;
202
+ align-items: center;
203
+ gap: 6px;
204
+ font-size: 12px;
205
+ font-weight: 700;
206
+ letter-spacing: 0.06em;
207
+ padding: 6px 14px;
208
+ border-radius: 20px;
209
+ border: 1.5px solid
210
+ }
211
+
212
+ .badge-allow {
213
+ color: #3FB6B2;
214
+ border-color: #3FB6B2;
215
+ background: rgba(63, 182, 178, 0.1)
216
+ }
217
+
218
+ .badge-flag {
219
+ color: #FFD166;
220
+ border-color: #FFD166;
221
+ background: rgba(255, 209, 102, 0.1)
222
+ }
223
+
224
+ .badge-remove {
225
+ color: #EF476F;
226
+ border-color: #EF476F;
227
+ background: rgba(239, 71, 111, 0.1)
228
+ }
229
+
230
+ .badge-review {
231
+ color: #74B3F4;
232
+ border-color: #74B3F4;
233
+ background: rgba(116, 179, 244, 0.1)
234
+ }
235
+
236
+ .results-grid {
237
+ display: grid;
238
+ grid-template-columns: 1fr 1fr;
239
+ gap: 20px
240
+ }
241
+
242
+ .explanation-box {}
243
+
244
+ .expl-label {
245
+ font-size: 11px;
246
+ font-weight: 700;
247
+ letter-spacing: 0.1em;
248
+ color: #7A8BAA;
249
+ text-transform: uppercase;
250
+ margin-bottom: 10px
251
+ }
252
+
253
+ .expl-text {
254
+ font-size: 14px;
255
+ color: #B0BFD8;
256
+ line-height: 1.6;
257
+ margin-bottom: 16px
258
+ }
259
+
260
+ .meta-row {
261
+ display: grid;
262
+ grid-template-columns: 1fr 1fr;
263
+ gap: 12px
264
+ }
265
+
266
+ .meta-card {
267
+ background: #0B132B;
268
+ border: 1px solid rgba(255, 255, 255, 0.06);
269
+ border-radius: 10px;
270
+ padding: 14px
271
+ }
272
+
273
+ .meta-key {
274
+ font-size: 11px;
275
+ color: #7A8BAA;
276
+ margin-bottom: 4px
277
+ }
278
+
279
+ .meta-val {
280
+ font-size: 16px;
281
+ font-weight: 700;
282
+ color: #fff
283
+ }
284
+
285
+ .scores-box {}
286
+
287
+ .score-row {
288
+ margin-bottom: 14px
289
+ }
290
+
291
+ .score-header {
292
+ display: flex;
293
+ justify-content: space-between;
294
+ font-size: 13px;
295
+ color: #B0BFD8;
296
+ margin-bottom: 6px
297
+ }
298
+
299
+ .score-bar {
300
+ height: 6px;
301
+ background: #1E3050;
302
+ border-radius: 3px;
303
+ overflow: hidden
304
+ }
305
+
306
+ .score-fill {
307
+ height: 100%;
308
+ border-radius: 3px;
309
+ transition: width 0.6s ease
310
+ }
311
+
312
+ .fill-low {
313
+ background: #3FB6B2
314
+ }
315
+
316
+ .fill-mid {
317
+ background: #FFD166
318
+ }
319
+
320
+ .fill-high {
321
+ background: #EF476F
322
+ }
323
+
324
+ /* HISTORY */
325
+ .history-wrap {
326
+ margin: 0 32px 32px;
327
+ background: #132040;
328
+ border: 1px solid rgba(255, 255, 255, 0.07);
329
+ border-radius: 16px;
330
+ padding: 28px
331
+ }
332
+
333
+ .history-title {
334
+ display: flex;
335
+ align-items: center;
336
+ gap: 10px;
337
+ font-size: 18px;
338
+ font-weight: 600;
339
+ margin-bottom: 20px
340
+ }
341
+
342
+ .history-item {
343
+ background: #0B132B;
344
+ border: 1px solid rgba(255, 255, 255, 0.06);
345
+ border-radius: 10px;
346
+ padding: 14px 16px;
347
+ margin-bottom: 10px;
348
+ display: flex;
349
+ align-items: flex-start;
350
+ justify-content: space-between;
351
+ gap: 12px
352
+ }
353
+
354
+ .history-item:last-child {
355
+ margin-bottom: 0
356
+ }
357
+
358
+ .history-text {
359
+ font-family: monospace;
360
+ font-size: 13px;
361
+ color: #B0BFD8;
362
+ flex: 1;
363
+ margin-top: 2px
364
+ }
365
+
366
+ .history-time {
367
+ font-size: 12px;
368
+ color: #7A8BAA;
369
+ white-space: nowrap
370
+ }
371
+
372
+ .h-badge {
373
+ display: inline-flex;
374
+ align-items: center;
375
+ gap: 4px;
376
+ font-size: 10px;
377
+ font-weight: 700;
378
+ letter-spacing: 0.07em;
379
+ padding: 4px 10px;
380
+ border-radius: 20px;
381
+ margin-bottom: 6px;
382
+ border: 1px solid
383
+ }
384
+
385
+ .h-allow {
386
+ color: #3FB6B2;
387
+ border-color: #3FB6B2;
388
+ background: rgba(63, 182, 178, 0.12)
389
+ }
390
+
391
+ .h-flag {
392
+ color: #FFD166;
393
+ border-color: #FFD166;
394
+ background: rgba(255, 209, 102, 0.12)
395
+ }
396
+
397
+ .h-remove {
398
+ color: #EF476F;
399
+ border-color: #EF476F;
400
+ background: rgba(239, 71, 111, 0.12)
401
+ }
402
+
403
+ .h-review {
404
+ color: #74B3F4;
405
+ border-color: #74B3F4;
406
+ background: rgba(116, 179, 244, 0.12)
407
+ }
408
+
409
+ .empty-history {
410
+ color: #7A8BAA;
411
+ font-size: 14px;
412
+ text-align: center;
413
+ padding: 20px 0
414
+ }
415
+
416
+ .loading-dots::after {
417
+ content: '...';
418
+ animation: dots 1.2s steps(4, end) infinite
419
+ }
420
+
421
+ @keyframes dots {
422
+ 0%,
423
+ 20% {
424
+ content: '.'
425
+ }
426
+
427
+ 40% {
428
+ content: '..'
429
+ }
430
+
431
+ 60%,
432
+ 100% {
433
+ content: '...'
434
+ }
435
+ }
436
+
437
+ @media(max-width:700px) {
438
+ .stats {
439
+ grid-template-columns: repeat(2, 1fr)
440
+ }
441
+
442
+ .results-grid {
443
+ grid-template-columns: 1fr
444
+ }
445
+
446
+ .stats,
447
+ .analyzer-wrap,
448
+ .results-wrap,
449
+ .history-wrap {
450
+ margin-left: 16px;
451
+ margin-right: 16px
452
+ }
453
+ }
templates/index.html ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+
4
+ <head>
5
+ <meta charset="UTF-8" />
6
+ <meta name="viewport" content="width=device-width,initial-scale=1" />
7
+ <title>SafeStream AI</title>
8
+ <link rel="stylesheet" href="/static/styles.css" />
9
+ </head>
10
+
11
+ <body>
12
+
13
+ <div class="header">
14
+ <div class="brand">
15
+ <img src="/static/logo.jpeg" class="logo" />
16
+ <h1 class="title">SafeStream AI</h1>
17
+ </div>
18
+ </div>
19
+ <div class="gradient-bar"></div>
20
+
21
+ <div class="stats">
22
+ <div class="stat-card">
23
+ <div class="stat-label">
24
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
25
+ <polyline points="22 12 18 12 15 21 9 3 6 12 2 12" />
26
+ </svg>
27
+ Total Analyzed
28
+ </div>
29
+ <div class="stat-value" id="stat-total">0</div>
30
+ </div>
31
+ <div class="stat-card">
32
+ <div class="stat-label">
33
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="#3FB6B2" stroke-width="2">
34
+ <path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z" />
35
+ </svg>
36
+ Allowed
37
+ </div>
38
+ <div class="stat-value" id="stat-allowed">0</div>
39
+ <div class="stat-sub" id="stat-allowed-pct">0% of total</div>
40
+ </div>
41
+ <div class="stat-card">
42
+ <div class="stat-label">
43
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="#EF476F" stroke-width="2">
44
+ <circle cx="12" cy="12" r="10" />
45
+ <line x1="15" y1="9" x2="9" y2="15" />
46
+ <line x1="9" y1="9" x2="15" y2="15" />
47
+ </svg>
48
+ Removed
49
+ </div>
50
+ <div class="stat-value" id="stat-removed">0</div>
51
+ <div class="stat-sub" id="stat-removed-pct">0% of total</div>
52
+ </div>
53
+ <div class="stat-card">
54
+ <div class="stat-label">
55
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
56
+ <line x1="18" y1="20" x2="18" y2="10" />
57
+ <line x1="12" y1="20" x2="12" y2="4" />
58
+ <line x1="6" y1="20" x2="6" y2="14" />
59
+ </svg>
60
+ Avg Confidence
61
+ </div>
62
+ <div class="stat-value" id="stat-conf">0%</div>
63
+ </div>
64
+ </div>
65
+
66
+ <div class="analyzer-wrap">
67
+ <div class="section-title">Analyze Content</div>
68
+ <div class="section-sub">Enter text to scan for toxicity, threats, and policy violations.</div>
69
+ <textarea id="inputText" placeholder="Paste comment, message, or post text here..."></textarea>
70
+ <div class="btn-row">
71
+ <button class="analyze-btn" id="analyzeBtn" onclick="analyze()">
72
+ <svg class="shield-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
73
+ <path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z" />
74
+ </svg>
75
+ Analyze Content
76
+ </button>
77
+ </div>
78
+ </div>
79
+
80
+ <div class="results-wrap" id="resultsWrap">
81
+ <div class="results-header">
82
+ <div class="results-title">Analysis Results</div>
83
+ <div class="decision-badge" id="decisionBadge"></div>
84
+ </div>
85
+ <div class="results-grid">
86
+ <div class="explanation-box">
87
+ <div class="expl-label">Explanation</div>
88
+ <div class="expl-text" id="explText"></div>
89
+ <div class="meta-row">
90
+ <div class="meta-card">
91
+ <div class="meta-key">RL Decision</div>
92
+ <div class="meta-val" id="metaDecision"></div>
93
+ </div>
94
+ <div class="meta-card">
95
+ <div class="meta-key">Confidence</div>
96
+ <div class="meta-val" id="metaConf"></div>
97
+ </div>
98
+ </div>
99
+ </div>
100
+ <div class="scores-box">
101
+ <div class="expl-label" style="display:flex;align-items:center;gap:8px">
102
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
103
+ <polyline points="22 12 18 12 15 21 9 3 6 12 2 12" />
104
+ </svg>
105
+ AI Scores
106
+ </div>
107
+ <div id="scoresContainer"></div>
108
+ </div>
109
+ </div>
110
+ </div>
111
+
112
+ <div class="history-wrap">
113
+ <div class="history-title">
114
+ <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
115
+ <circle cx="12" cy="12" r="10" />
116
+ <polyline points="12 6 12 12 16 14" />
117
+ </svg>
118
+ Recent History
119
+ </div>
120
+ <div id="historyList">
121
+ <div class="empty-history">No analyses yet. Submit some content above to get started.</div>
122
+ </div>
123
+ </div>
124
+
125
+ <script src="/static/script.js"></script>
126
+ </body>
127
+
128
+ </html>