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 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>CodeCanvas - AI Code Generation Studio</title>
    <link rel="stylesheet" href="static/style.css" />
    <link
      href="https://fonts.googleapis.com/css2?family=Work+Sans:wght@400;600;700&family=Inter:wght@300;400;500;600&display=swap"
      rel="stylesheet"
    />
    <script type="module" src="https://md-block.verou.me/md-block.js"></script>
    <link
      rel="stylesheet"
      href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"
    />
    <!-- Removed Prism.js and added Monaco Editor -->
     <script src="https://cdn.jsdelivr.net/npm/markdown-it@14.0.0/dist/markdown-it.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/monaco-editor@0.44.0/min/vs/loader.js"></script>
  </head>
  <body>
    <!-- Particle Background -->
    <div class="particle-background">
      <canvas id="particle-canvas"></canvas>
    </div>

    <!-- Header -->
    <header class="header">
      <div class="header-content">
        <!-- Added hamburger menu for mobile -->
        <button class="hamburger-btn" id="hamburger-btn">
          <span></span>
          <span></span>
          <span></span>
        </button>

        <div class="logo">
          <i class="fas fa-palette"></i>
          <span>CodeCanvas</span>
        </div>
        <div class="header-actions">
          <!-- Separated load and save session buttons -->
          <button class="session-btn" id="load-session-btn">
            <svg
              width="16"
              height="16"
              viewBox="0 0 24 24"
              fill="none"
              stroke="currentColor"
              stroke-width="2"
            >
              <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" />
              <polyline points="10,9 9,9 8,9" />
            </svg>
            <span>Load</span>
          </button>
          <button class="session-btn" id="save-session-btn">
            <svg
              width="16"
              height="16"
              viewBox="0 0 24 24"
              fill="none"
              stroke="currentColor"
              stroke-width="2"
            >
              <path
                d="M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"
              />
              <polyline points="17,21 17,13 7,13 7,21" />
              <polyline points="7,3 7,8 15,8" />
            </svg>
            <span>Save</span>
          </button>
          <button class="theme-toggle" id="theme-toggle">
            <i class="fas fa-moon"></i>
          </button>
        </div>
      </div>
    </header>

    <!-- ... existing popups ... -->
    <!-- Separate Load Session Popup -->
    <div class="session-popup hidden" id="load-session-popup">
      <div class="popup-overlay"></div>
      <div class="popup-content">
        <div class="popup-header">
          <h3>
            <svg
              width="20"
              height="20"
              viewBox="0 0 24 24"
              fill="none"
              stroke="currentColor"
              stroke-width="2"
            >
              <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>
            Load Session
          </h3>
          <button class="popup-close" id="load-session-popup-close">
            <i class="fas fa-times"></i>
          </button>
        </div>
        <div class="popup-body">
          <select id="session-select" class="select-input">
            <option value="">No sessions found</option>
          </select>
          <div class="button-row">
            <button id="load-session-action-btn" class="btn btn-primary">
              <i class="fas fa-upload"></i> Load Session
            </button>
            <button id="delete-session-btn" class="btn btn-destructive">
              <i class="fas fa-trash"></i> Delete
            </button>
          </div>
          <button id="new-session-btn" class="btn btn-outline">
            <i class="fas fa-plus"></i> New Session
          </button>
        </div>
      </div>
    </div>

    <!-- Separate Save Session Popup -->
    <div class="session-popup hidden" id="save-session-popup">
      <div class="popup-overlay"></div>
      <div class="popup-content">
        <div class="popup-header">
          <h3>
            <svg
              width="20"
              height="20"
              viewBox="0 0 24 24"
              fill="none"
              stroke="currentColor"
              stroke-width="2"
            >
              <path
                d="M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"
              />
              <polyline points="17,21 17,13 7,13 7,21" />
              <polyline points="7,3 7,8 15,8" />
            </svg>
            Save Session
          </h3>
          <button class="popup-close" id="save-session-popup-close">
            <i class="fas fa-times"></i>
          </button>
        </div>
        <div class="popup-body">
          <div class="input-group">
            <input
              type="text"
              id="session-name-input"
              class="text-input"
              placeholder="Enter session name..."
            />
            <button id="save-session-action-btn" class="btn btn-accent">
              <i class="fas fa-save"></i> Save
            </button>
          </div>
        </div>
      </div>
    </div>

    <!-- Main Container -->
    <div class="main-container">
      <!-- Added mobile overlay for sidebar -->
      <div class="sidebar-overlay" id="sidebar-overlay"></div>

      <!-- Redesigned sidebar with better organization -->
      <aside class="sidebar" id="sidebar">
        <div class="sidebar-content">
          <!-- Info Panels moved to top -->
          <div class="info-panels">
            <details
              id="analysis-container"
              class="info-panel info-panel-dull glass-effect hidden"
            >
              <summary class="info-header">
                <i class="fas fa-brain"></i>
                <span>AI Thoughts</span>
                <i class="fas fa-chevron-down"></i>
              </summary>
              <div id="ai-analysis" class="info-content auto-scroll"></div>
            </details>

            <details
              id="changes-container"
              class="info-panel info-panel-dull glass-effect hidden"
            >
              <summary class="info-header">
                <i class="fas fa-list-ul"></i>
                <span>Changes Summary</span>
                <i class="fas fa-chevron-down"></i>
              </summary>
              <div
                id="summary-of-changes"
                class="info-content auto-scroll"
              ></div>
            </details>

            <details
              id="instructions-container"
              class="info-panel glass-effect hidden"
            >
              <summary class="info-header">
                <i class="fas fa-lightbulb"></i>
                <span>Instructions</span>
                <i class="fas fa-chevron-down"></i>
              </summary>
              <div
                id="game-instructions"
                class="info-content auto-scroll"
              ></div>
            </details>
          </div>

          <!-- Loading Spinner -->
          <div class="spinner-container hidden">
            <div class="spinner">
              <div class="spinner-ring"></div>
              <div class="spinner-ring"></div>
              <div class="spinner-ring"></div>
            </div>
            <p class="spinner-text" style="width: 100%; text-align: center">
              Summoning ideas
            </p>
          </div>

          <!-- Initial Generation moved down -->
          <div
            id="initial-generation"
            class="panel generation-panel glass-effect"
          >
            <div class="panel-header">
              <h3><i class="fas fa-magic"></i> Create</h3>
            </div>
            <div class="panel-content">
              <textarea
                id="prompt-input"
                class="textarea-input"
                placeholder="Describe your idea... e.g., A bouncing ball simulation, interactive data visualization, animated landing page..."
              ></textarea>

              <!-- Redesigned file upload with smaller button -->
              <div class="file-upload-container">
                <label
                  for="generate-file-input"
                  class="file-upload-label-small"
                >
                  <svg
                    width="16"
                    height="16"
                    viewBox="0 0 24 24"
                    fill="none"
                    stroke="currentColor"
                    stroke-width="2"
                  >
                    <path
                      d="M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66L9.64 16.2a2 2 0 0 1-2.83-2.83l8.49-8.48"
                    />
                  </svg>
                  Attach Files
                </label>
                <input
                  type="file"
                  id="generate-file-input"
                  multiple
                  class="file-upload-input"
                />
                <div id="generate-file-list" class="file-list"></div>
              </div>

              <button
                id="generate-btn"
                class="btn btn-primary btn-large pulse-on-hover"
              >
                <i class="fas fa-wand-magic-sparkles"></i>
                Generate Code
              </button>
            </div>
          </div>

          <!-- Modification Panel moved down -->
          <div
            id="modification-panel"
            class="panel modification-panel glass-effect hidden"
          >
            <div class="panel-header">
              <h3><i class="fas fa-edit"></i> Modify</h3>
            </div>
            <div class="panel-content">
              <textarea
                id="modification-input"
                class="textarea-input"
                placeholder="Describe your changes... e.g., Make it more colorful, add animations, change the layout..."
              ></textarea>

              <!-- Redesigned file upload with smaller button -->
              <div class="file-upload-container">
                <label for="modify-file-input" class="file-upload-label-small">
                  <svg
                    width="16"
                    height="16"
                    viewBox="0 0 24 24"
                    fill="none"
                    stroke="currentColor"
                    stroke-width="2"
                  >
                    <path
                      d="M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66L9.64 16.2a2 2 0 0 1-2.83-2.83l8.49-8.48"
                    />
                  </svg>
                  Attach Files
                </label>
                <input
                  type="file"
                  id="modify-file-input"
                  multiple
                  class="file-upload-input"
                />
                <div id="modify-file-list" class="file-list"></div>
              </div>

              <!-- Console Output -->
              <div id="console-container" class="console-container hidden">
                <label class="console-label">
                  <i class="fas fa-terminal"></i> Console Output
                </label>
                <textarea
                  id="console-output"
                  class="console-output"
                  readonly
                ></textarea>
              </div>

              <div class="button-grid">
                <button id="modify-btn" class="btn btn-primary pulse-on-hover">
                  <i class="fas fa-sync-alt"></i> Apply Changes
                </button>
              </div>
            </div>
          </div>
        </div>
      </aside>

      <!-- Main Content -->
      <main class="main-content">
        <div class="content-header glass-effect">
          <div class="view-tabs">
            <button id="toggle-preview-btn" class="tab-btn active">
              <i class="fas fa-eye"></i>
              <span>Live Preview</span>
            </button>
            <button id="toggle-code-btn" class="tab-btn">
              <i class="fas fa-code"></i>
              <span>Source Code</span>
            </button>
          </div>
          <!-- Moved download and open buttons to content header with SVG icons -->
          <div class="content-actions">
            <!-- Version History moved from sidebar -->
            <div
              id="version-history-controls"
              class="version-history-header-compact hidden"
            >
              <svg
                width="18"
                height="18"
                viewBox="0 0 24 24"
                fill="none"
                stroke="currentColor"
                stroke-width="2"
              >
                <path d="M3 3v5h5" />
                <path d="M3.05 13A9 9 0 1 0 6 5.3L3 8" />
                <path d="M12 7v5l4 2" />
              </svg>
              <select
                id="version-history-select"
                class="select-input-header"
              ></select>
            </div>

            <button id="copy-code-btn" class="action-btn" title="Copy Code">
              <svg
                width="18"
                height="18"
                viewBox="0 0 24 24"
                fill="none"
                stroke="currentColor"
                stroke-width="2"
              >
                <rect x="9" y="9" width="13" height="13" rx="2" ry="2" />
                <path
                  d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"
                />
              </svg>
            </button>
            <!-- Moved download button from sidebar to header -->
            <button id="download-btn" class="action-btn" title="Download Code">
              <svg
                width="18"
                height="18"
                viewBox="0 0 24 24"
                fill="none"
                stroke="currentColor"
                stroke-width="2"
              >
                <path <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>
            </button>
            <!-- Moved open tab button from sidebar to header -->
            <button
              id="open-tab-btn"
              class="action-btn"
              title="Open in New Window"
            >
              <svg
                width="18"
                height="18"
                viewBox="0 0 24 24"
                fill="none"
                stroke="currentColor"
                stroke-width="2"
              >
                <path
                  d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"
                />
                <polyline points="15,3 21,3 21,9" />
                <line x1="10" y1="14" x2="21" y2="3" />
              </svg>
            </button>
            <button
              id="refresh-preview-btn"
              class="action-btn hidden"
              title="Refresh Preview"
            >
              <svg
                width="18"
                height="18"
                viewBox="0 0 24 24"
                fill="none"
                stroke="currentColor"
                stroke-width="2"
              >
                <polyline points="23,4 23,10 17,10" />
                <polyline points="1,20 1,14 7,14" />
                <path
                  d="M20.49 9A9 9 0 0 0 5.64 5.64L1 10m22 4l-4.64 4.36A9 9 0 0 1 3.51 15"
                />
              </svg>
            </button>
          </div>
        </div>

        <div class="content-body">
          <!-- Enhanced code editor with Monaco Editor -->
          <div class="code-container hidden">
            <div class="code-editor-wrapper glass-effect">
              <!-- Replaced overlapping textarea/pre with single Monaco container -->
              <div id="monaco-editor" class="monaco-editor-container"></div>
            </div>
          </div>

          <!-- Enhanced preview with better scrolling -->
          <div class="preview-container">
            <div class="preview-wrapper glass-effect">
              <iframe
                id="game-iframe"
                class="preview-iframe"
                sandbox="allow-scripts allow-pointer-lock allow-same-origin"
                title="Generated Visualization"
              >
              </iframe>
              <div class="preview-placeholder">
                <div class="placeholder-content">
                  <i class="fas fa-palette floating-icon"></i>
                  <h3>Ready to Create</h3>
                  <p>
                    Describe your idea in the sidebar to get started with AI
                    code generation
                  </p>
                </div>
              </div>
            </div>
          </div>
        </div>
      </main>
    </div>

    <!-- Fixed follow-up floating button -->
    <div class="followup-float" id="followup-float">
      <button class="followup-btn" id="followup-btn">
        <i class="fas fa-question-circle"></i>
      </button>
      <div class="followup-tooltip">Ask AI</div>
    </div>

    <div class="followup-popup hidden" id="followup-popup">
      <div class="popup-overlay"></div>
      <div class="popup-content">
        <div class="popup-header">
          <h3><i class="fas fa-question-circle"></i> Ask AI</h3>
          <button class="popup-close" id="followup-popup-close">
            <i class="fas fa-times"></i>
          </button>
        </div>
        <div class="popup-body">
          <textarea
            id="follow-up-input"
            class="textarea-input"
            placeholder="Ask about the code... e.g., How does this work? Can you explain this function?"
          ></textarea>
          <button id="follow-up-btn" class="btn btn-accent pulse-on-hover">
            <i class="fas fa-paper-plane"></i> Ask Question
          </button>

          <div id="follow-up-spinner" class="spinner-container hidden">
            <div class="spinner-small">
              <div class="spinner-ring"></div>
            </div>
            <p class="spinner-text">Thinking...</p>
          </div>

          <div id="follow-up-output-container" class="follow-up-output hidden">
            <div class="output-header">
              <i class="fas fa-robot"></i> AI Response
            </div>
            <div id="follow-up-output" class="output-content"></div>
          </div>
        </div>
      </div>
    </div>

    <script src="static/script.js"></script>
  </body>
</html>