File size: 22,125 Bytes
6b77482
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<!doctype html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Q-MCT v4.2 Metrology Benchmarks: CAI Noise Floor, DSAC Allan Deviation &amp; GGT Orbit Precision</title>

    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com">
    <link href="https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.tailwindcss.com"></script>

    <style>
      @font-face {
        font-family: "Google Sans";
        src: url("https://fonts.gstatic.com/s/googlesans/v58/4UaRrENHsxJlGDuGo1OIlJfC6l_24rlCK1Yo_Iq2vgCI.woff2") format("woff2");
        font-weight: 400; font-style: normal; font-display: swap;
      }
      :root, html[data-theme="light"] {
        --surface-color: #FFFFFF;
        --surface-card: #F8FAFC;
        --on-surface: #1B1C1D;
        --on-surface-variant: #575B5F;
        --outline-variant: #E2E8F0;
        --google-blue: #1A73E8;
        --cyan: #12B5CB;
        --magenta: #F538A0;
        --tangerine: #FA903E;
        --mint-green: #81C995;
        --red: #D93025;
      }
      html[data-theme="dark"] {
        --surface-color: #141414;
        --surface-card: #1E222B;
        --on-surface: #FFFFFF;
        --on-surface-variant: #A2A9B0;
        --outline-variant: #333942;
        --google-blue: #1A73E8;
        --cyan: #12B5CB;
        --magenta: #F538A0;
        --tangerine: #FA903E;
        --mint-green: #81C995;
        --red: #D93025;
      }
      .tabular-nums {
        font-variant-numeric: tabular-nums;
      }
      input[type=range] {
        -webkit-appearance: none;
        background: var(--outline-variant);
        height: 4px;
        border-radius: 2px;
      }
      input[type=range]::-webkit-slider-thumb {
        -webkit-appearance: none;
        height: 14px;
        width: 14px;
        border-radius: 50%;
        background: var(--google-blue);
        cursor: pointer;
      }
    </style>
    <script>
      tailwind.config = {
        darkMode: ['class', '[data-theme="dark"]'],
        theme: {
          extend: {
            fontFamily: {
              sans: ['"Google Sans"', '"Open Sans"', 'sans-serif'],
              mono: ['"JetBrains Mono"', 'monospace']
            },
            colors: {
              surface: 'var(--surface-color)',
              'surface-card': 'var(--surface-card)',
              'on-surface': 'var(--on-surface)',
              'on-surface-variant': 'var(--on-surface-variant)',
              'outline-variant': 'var(--outline-variant)',
              'g-blue': 'var(--google-blue)',
              'g-cyan': 'var(--cyan)',
              'g-magenta': 'var(--magenta)',
              'g-tangerine': 'var(--tangerine)',
              'g-mint': 'var(--mint-green)',
              'g-red': 'var(--red)'
            }
          }
        }
      }
    </script>
  </head>
  <body class="font-sans bg-surface text-on-surface m-0 p-3 sm:p-5 flex justify-center w-full min-h-screen">
    <main class="w-full max-w-[860px] flex flex-col gap-4">
      <!-- Header Banner -->
      <header class="w-full bg-slate-900 text-white rounded-lg p-3.5 border border-slate-700 flex flex-col sm:flex-row sm:items-center justify-between gap-3">
        <div>
          <div class="flex items-center gap-2">
            <span class="text-xs font-mono font-bold tracking-wider text-cyan-300">Q-MCT v4.2 ANALYTICAL MODULE 01</span>
            <span class="text-[10px] px-1.5 py-0.5 rounded bg-blue-950 text-blue-300 border border-blue-700 font-mono">LAYER 4 METROLOGY</span>
          </div>
          <h1 class="text-lg sm:text-xl font-semibold text-white mt-0.5">
            Quantum Metrology Benchmarks: CAI Noise Floor, DSAC Stability &amp; GGT Orbit Precision
          </h1>
        </div>
        <div class="flex items-center gap-2 font-mono text-[11px] shrink-0">
          <a href="q_mct_flight_deck.html" class="px-2.5 py-1.5 rounded bg-slate-800 hover:bg-slate-700 border border-slate-600 text-cyan-300 transition">
            ← Flight Deck
          </a>
          <a href="algorithmic_benchmarks.html" class="px-2.5 py-1.5 rounded bg-blue-600 hover:bg-blue-500 text-white font-semibold transition">
            Algorithmic Module →
          </a>
        </div>
      </header>

      <!-- Interactive Parameter Bar -->
      <section class="bg-surface-card border border-outline-variant rounded-lg p-3 grid grid-cols-1 md:grid-cols-3 gap-3 text-xs">
        <div class="flex flex-col gap-1.5">
          <div class="flex justify-between font-medium">
            <span>CAI Interrogation Regime:</span>
            <span id="regime-badge" class="font-mono text-g-blue font-bold">SOTA (2T = 5s)</span>
          </div>
          <div class="grid grid-cols-4 gap-1 font-mono text-[10px]">
            <button data-regime="0" class="regime-btn py-1 rounded border bg-surface border-outline-variant text-on-surface-variant">No Mir</button>
            <button data-regime="1" class="regime-btn py-1 rounded border bg-blue-600 text-white border-blue-600 font-bold">2T=5s</button>
            <button data-regime="2" class="regime-btn py-1 rounded border bg-surface border-outline-variant text-on-surface-variant">2T=10s</button>
            <button data-regime="3" class="regime-btn py-1 rounded border bg-surface border-outline-variant text-on-surface-variant">2T=20s</button>
          </div>
        </div>

        <div class="flex flex-col gap-1.5">
          <div class="flex justify-between font-medium">
            <span>DSAC Averaging Time (τ):</span>
            <span id="tau-readout" class="font-mono text-cyan-600 dark:text-cyan-400 font-bold tabular-nums">100 s</span>
          </div>
          <input type="range" id="tau-slider" min="0" max="5" step="0.05" value="2" class="w-full mt-1">
          <div class="flex justify-between text-[10px] font-mono text-on-surface-variant">
            <span>1 s</span>
            <span>100 s</span>
            <span>10,000 s</span>
            <span>100,000 s</span>
          </div>
        </div>

        <div class="flex flex-col gap-1.5">
          <div class="flex justify-between font-medium">
            <span>EGM2008 Harmonic Degree (N_max):</span>
            <span id="degree-readout" class="font-mono text-emerald-600 dark:text-emerald-400 font-bold tabular-nums">N = 300</span>
          </div>
          <div class="grid grid-cols-4 gap-1 font-mono text-[10px]">
            <button data-deg="80" class="deg-btn py-1 rounded border bg-surface border-outline-variant text-on-surface-variant">N=80</button>
            <button data-deg="150" class="deg-btn py-1 rounded border bg-surface border-outline-variant text-on-surface-variant">N=150</button>
            <button data-deg="250" class="deg-btn py-1 rounded border bg-surface border-outline-variant text-on-surface-variant">N=250</button>
            <button data-deg="300" class="deg-btn py-1 rounded border bg-emerald-600 text-white border-emerald-600 font-bold">N=300</button>
          </div>
        </div>
      </section>

      <!-- Panel 1: CAI Sensitivity Noise Floor -->
      <section class="bg-surface-card border border-outline-variant rounded-lg p-3.5 flex flex-col gap-2">
        <div class="flex flex-wrap items-center justify-between gap-2">
          <div>
            <h2 class="text-sm font-bold text-on-surface">1. Cold-Atom Interferometer (CAI) Acceleration Noise Floor (Log Scale)</h2>
            <p class="text-[11px] text-on-surface-variant">
              Suppression of Coriolis and wavefront aberration noise from uncompensated baseline (10⁻⁸) to far-future BEC matter-wave regimes (10⁻¹² m/s²/√Hz).
            </p>
          </div>
          <div class="font-mono text-xs px-2.5 py-1 rounded bg-surface border border-outline-variant tabular-nums">
            Active Floor: <span id="active-cai-floor" class="font-bold text-g-blue">5.00e-10 m/s²/√Hz</span>
          </div>
        </div>
        <div class="w-full h-[185px] bg-slate-950 rounded border border-slate-800 overflow-hidden">
          <canvas id="cai-chart" class="w-full h-full block"></canvas>
        </div>
      </section>

      <!-- Panel 2 & Panel 3 Side-by-Side Grid -->
      <div class="grid grid-cols-1 md:grid-cols-2 gap-3.5">
        <!-- Panel 2: DSAC Allan Deviation -->
        <section class="bg-surface-card border border-outline-variant rounded-lg p-3.5 flex flex-col gap-2">
          <div class="flex items-start justify-between gap-2">
            <div>
              <h2 class="text-sm font-bold text-on-surface">2. DSAC 40.5 GHz Allan Deviation σ_y(τ)</h2>
              <p class="text-[11px] text-on-surface-variant">
                ¹⁹⁹Hg⁺ trapped-ion clock (1.5×10⁻¹³ @ 1s, 3×10⁻¹⁵ drift) vs. legacy space clocks &amp; optical lattice.
              </p>
            </div>
          </div>
          <div class="w-full h-[215px] bg-slate-950 rounded border border-slate-800 overflow-hidden">
            <canvas id="allan-chart" class="w-full h-full block"></canvas>
          </div>
          <div class="grid grid-cols-3 gap-1.5 font-mono text-[10px] tabular-nums">
            <div class="bg-surface p-1.5 rounded border border-outline-variant">
              <div class="text-on-surface-variant">Legacy Rb/Cs</div>
              <div id="allan-legacy-val" class="font-bold text-amber-500">1.50e-13</div>
            </div>
            <div class="bg-surface p-1.5 rounded border border-outline-variant">
              <div class="text-on-surface-variant">DSAC (Hg⁺)</div>
              <div id="allan-dsac-val" class="font-bold text-cyan-400">1.50e-14</div>
            </div>
            <div class="bg-surface p-1.5 rounded border border-outline-variant">
              <div class="text-on-surface-variant">Optical Lattice</div>
              <div id="allan-opt-val" class="font-bold text-emerald-400">1.00e-16</div>
            </div>
          </div>
        </section>

        <!-- Panel 3: GGT Autonomous Orbit Determination -->
        <section class="bg-surface-card border border-outline-variant rounded-lg p-3.5 flex flex-col gap-2">
          <div>
            <h2 class="text-sm font-bold text-on-surface">3. GGT EKF Autonomous Orbit Error (24 hr)</h2>
            <p class="text-[11px] text-on-surface-variant">
              Radial &amp; cross-track error bounded &lt;100 m via 4.7 mE/√Hz Chu-Bordé gradiometry vs. unbounded IMU drift.
            </p>
          </div>
          <div class="w-full h-[215px] bg-slate-950 rounded border border-slate-800 overflow-hidden">
            <canvas id="ggt-chart" class="w-full h-full block"></canvas>
          </div>
          <div class="grid grid-cols-3 gap-1.5 font-mono text-[10px] tabular-nums">
            <div class="bg-surface p-1.5 rounded border border-outline-variant">
              <div class="text-on-surface-variant">Classical IMU</div>
              <div class="font-bold text-rose-500">&gt;14.2 km (Drift)</div>
            </div>
            <div class="bg-surface p-1.5 rounded border border-outline-variant">
              <div class="text-on-surface-variant">GGT EKF Steady</div>
              <div id="ggt-steady-val" class="font-bold text-emerald-400">42.1 m (&lt;100m)</div>
            </div>
            <div class="bg-surface p-1.5 rounded border border-outline-variant">
              <div class="text-on-surface-variant">Laplace BIST</div>
              <div class="font-bold text-cyan-400">Tr(V) = 0.00 E</div>
            </div>
          </div>
        </section>
      </div>
    </main>

    <script>
      const state = {
        regimeIdx: 1,
        tauLog: 2.0,
        harmonicDegree: 300
      };

      const regimes = [
        { name: 'Uncompensated Mirror', short: 'No Mirror', val: 1.0e-8, logVal: -8.0, color: '#FA903E', desc: 'Coriolis limit (1e-8)' },
        { name: 'SOTA (2T = 5s)', short: 'SOTA 2T=5s', val: 5.0e-10, logVal: -9.301, color: '#1A73E8', desc: 'Wavefront limited (5e-10)' },
        { name: 'Near-Future QPN (2T = 10s)', short: 'QPN 2T=10s', val: 1.0e-11, logVal: -11.0, color: '#12B5CB', desc: 'QPN-limited (1e-11)' },
        { name: 'Far-Future BEC (2T = 20s)', short: 'BEC 2T=20s', val: 1.0e-12, logVal: -12.0, color: '#81C995', desc: 'BEC limit (1e-12)' }
      ];

      function setupCanvas(canvas) {
        const dpr = window.devicePixelRatio || 1;
        const rect = canvas.parentElement.getBoundingClientRect();
        canvas.width = rect.width * dpr;
        canvas.height = rect.height * dpr;
        const ctx = canvas.getContext('2d');
        ctx.scale(dpr, dpr);
        return { ctx, w: rect.width, h: rect.height };
      }

      function drawCAIChart() {
        const { ctx, w, h } = setupCanvas(document.getElementById('cai-chart'));
        ctx.fillStyle = '#060A17';
        ctx.fillRect(0, 0, w, h);

        const padL = 72, padR = 24, padT = 20, padB = 30;
        const plotW = w - padL - padR;
        const plotH = h - padT - padB;

        // Log Y axis from -7 to -13
        const minLog = -13, maxLog = -7;
        ctx.strokeStyle = 'rgba(148, 163, 184, 0.16)';
        ctx.font = '10px "JetBrains Mono"';
        ctx.fillStyle = '#94A3B8';

        for (let lg = maxLog; lg >= minLog; lg--) {
          const y = padT + ((maxLog - lg) / (maxLog - minLog)) * plotH;
          ctx.beginPath();
          ctx.moveTo(padL, y);
          ctx.lineTo(w - padR, y);
          ctx.stroke();
          ctx.fillText(`10^${lg}`, 14, y + 3);
        }

        const barSlot = plotW / regimes.length;
        regimes.forEach((r, idx) => {
          const isSelected = idx === state.regimeIdx;
          const bx = padL + idx * barSlot + barSlot * 0.22;
          const bw = barSlot * 0.56;
          const topY = padT + ((maxLog - r.logVal) / (maxLog - minLog)) * plotH;
          const barH = (padT + plotH) - topY;

          ctx.fillStyle = isSelected ? r.color : 'rgba(100, 116, 139, 0.45)';
          ctx.fillRect(bx, topY, bw, barH);

          if (isSelected) {
            ctx.strokeStyle = '#FFFFFF';
            ctx.lineWidth = 1.5;
            ctx.strokeRect(bx, topY, bw, barH);
          }

          ctx.fillStyle = isSelected ? '#FFFFFF' : '#CBD5E1';
          ctx.font = isSelected ? 'bold 10px "JetBrains Mono"' : '10px "JetBrains Mono"';
          ctx.textAlign = 'center';
          ctx.fillText(r.val.toExponential(1), bx + bw / 2, topY - 6);
          ctx.fillText(r.short, bx + bw / 2, h - 10);
        });
        ctx.textAlign = 'left';
      }

      function evalLegacy(tau) {
        return 1.5e-12 / Math.sqrt(tau) + 2.5e-14;
      }
      function evalDSAC(tau) {
        return 1.5e-13 / Math.sqrt(tau) + (3.0e-15 / 86400) * tau;
      }
      function evalOptical(tau) {
        return 1.0e-15 / Math.sqrt(tau) + 5.0e-18;
      }

      function drawAllanChart() {
        const { ctx, w, h } = setupCanvas(document.getElementById('allan-chart'));
        ctx.fillStyle = '#060A17';
        ctx.fillRect(0, 0, w, h);

        const padL = 56, padR = 16, padT = 16, padB = 26;
        const plotW = w - padL - padR;
        const plotH = h - padT - padB;
        const minLogY = -17, maxLogY = -11;
        const maxLogX = 5; // 10^0 to 10^5

        ctx.strokeStyle = 'rgba(148, 163, 184, 0.16)';
        ctx.font = '9px "JetBrains Mono"';
        ctx.fillStyle = '#94A3B8';

        for (let ly = maxLogY; ly >= minLogY; ly--) {
          const y = padT + ((maxLogY - ly) / (maxLogY - minLogY)) * plotH;
          ctx.beginPath();
          ctx.moveTo(padL, y);
          ctx.lineTo(w - padR, y);
          ctx.stroke();
          ctx.fillText(`1e${ly}`, 8, y + 3);
        }

        for (let lx = 0; lx <= maxLogX; lx++) {
          const x = padL + (lx / maxLogX) * plotW;
          ctx.beginPath();
          ctx.moveTo(x, padT);
          ctx.lineTo(x, padT + plotH);
          ctx.stroke();
          ctx.fillText(`10^${lx}s`, x - 10, h - 8);
        }

        const curves = [
          { fn: evalLegacy, color: '#FA903E' },
          { fn: evalDSAC, color: '#12B5CB' },
          { fn: evalOptical, color: '#81C995' }
        ];

        curves.forEach(c => {
          ctx.strokeStyle = c.color;
          ctx.lineWidth = 2;
          ctx.beginPath();
          for (let step = 0; step <= 100; step++) {
            const lx = (step / 100) * maxLogX;
            const tau = Math.pow(10, lx);
            const ly = Math.log10(c.fn(tau));
            const px = padL + (lx / maxLogX) * plotW;
            const py = padT + ((maxLogY - ly) / (maxLogY - minLogY)) * plotH;
            if (step === 0) ctx.moveTo(px, py);
            else ctx.lineTo(px, py);
          }
          ctx.stroke();
        });

        // Interactive Tau Vertical Cursor
        const curX = padL + (state.tauLog / maxLogX) * plotW;
        ctx.save();
        ctx.strokeStyle = 'rgba(255, 255, 255, 0.65)';
        ctx.setLineDash([3, 3]);
        ctx.beginPath();
        ctx.moveTo(curX, padT);
        ctx.lineTo(curX, padT + plotH);
        ctx.stroke();
        ctx.restore();

        const tauVal = Math.pow(10, state.tauLog);
        document.getElementById('tau-readout').textContent = `${tauVal >= 100 ? Math.round(tauVal) : tauVal.toFixed(1)} s`;
        document.getElementById('allan-legacy-val').textContent = evalLegacy(tauVal).toExponential(2);
        document.getElementById('allan-dsac-val').textContent = evalDSAC(tauVal).toExponential(2);
        document.getElementById('allan-opt-val').textContent = evalOptical(tauVal).toExponential(2);
      }

      function drawGGTChart() {
        const { ctx, w, h } = setupCanvas(document.getElementById('ggt-chart'));
        ctx.fillStyle = '#060A17';
        ctx.fillRect(0, 0, w, h);

        const padL = 48, padR = 16, padT = 16, padB = 26;
        const plotW = w - padL - padR;
        const plotH = h - padT - padB;
        const maxErr = 180; // meters

        ctx.strokeStyle = 'rgba(148, 163, 184, 0.16)';
        ctx.font = '9px "JetBrains Mono"';
        ctx.fillStyle = '#94A3B8';

        [0, 50, 100, 150].forEach(val => {
          const y = padT + ((maxErr - val) / maxErr) * plotH;
          ctx.beginPath();
          ctx.moveTo(padL, y);
          ctx.lineTo(w - padR, y);
          ctx.stroke();
          ctx.fillText(`${val}m`, 10, y + 3);
        });

        // 100m Requirement Threshold Line
        const reqY = padT + ((maxErr - 100) / maxErr) * plotH;
        ctx.save();
        ctx.strokeStyle = '#F538A0';
        ctx.setLineDash([4, 4]);
        ctx.beginPath();
        ctx.moveTo(padL, reqY);
        ctx.lineTo(w - padR, reqY);
        ctx.stroke();
        ctx.fillStyle = '#F538A0';
        ctx.fillText('100m MAX BOUND', padL + 8, reqY - 5);
        ctx.restore();

        // Classical IMU Divergence Curve
        ctx.strokeStyle = '#D93025';
        ctx.lineWidth = 2;
        ctx.beginPath();
        for (let t = 0; t <= 24; t += 0.5) {
          const err = 15 + 3.2 * t * t;
          const px = padL + (t / 24) * plotW;
          const py = Math.max(padT, padT + ((maxErr - err) / maxErr) * plotH);
          if (t === 0) ctx.moveTo(px, py);
          else ctx.lineTo(px, py);
        }
        ctx.stroke();

        // GGT EKF Bounded Convergence Curve
        const degreeFactor = 300 / state.harmonicDegree;
        const steadyErr = 42.1 * Math.pow(degreeFactor, 0.65);
        ctx.strokeStyle = '#81C995';
        ctx.lineWidth = 2.2;
        ctx.beginPath();
        for (let t = 0; t <= 24; t += 0.25) {
          const err = steadyErr + (115 - steadyErr) * Math.exp(-t / 2.8) + Math.sin(t * 2.1) * 3.5;
          const px = padL + (t / 24) * plotW;
          const py = padT + ((maxErr - err) / maxErr) * plotH;
          if (t === 0) ctx.moveTo(px, py);
          else ctx.lineTo(px, py);
        }
        ctx.stroke();

        document.getElementById('ggt-steady-val').textContent = `${steadyErr.toFixed(1)} m (<100m)`;
        [0, 6, 12, 18, 24].forEach(hr => {
          const x = padL + (hr / 24) * plotW;
          ctx.fillStyle = '#94A3B8';
          ctx.fillText(`${hr}h`, x - 6, h - 8);
        });
      }

      function renderAll() {
        const reg = regimes[state.regimeIdx];
        document.getElementById('regime-badge').textContent = reg.name;
        document.getElementById('active-cai-floor').textContent = `${reg.val.toExponential(2)} m/s²/√Hz`;
        drawCAIChart();
        drawAllanChart();
        drawGGTChart();
      }

      document.querySelectorAll('.regime-btn').forEach(btn => {
        btn.addEventListener('click', (e) => {
          state.regimeIdx = parseInt(e.currentTarget.getAttribute('data-regime'));
          document.querySelectorAll('.regime-btn').forEach(b => {
            b.className = 'regime-btn py-1 rounded border bg-surface border-outline-variant text-on-surface-variant';
          });
          e.currentTarget.className = 'regime-btn py-1 rounded border bg-blue-600 text-white border-blue-600 font-bold';
          renderAll();
        });
      });

      document.getElementById('tau-slider').addEventListener('input', (e) => {
        state.tauLog = parseFloat(e.target.value);
        drawAllanChart();
      });

      document.querySelectorAll('.deg-btn').forEach(btn => {
        btn.addEventListener('click', (e) => {
          state.harmonicDegree = parseInt(e.currentTarget.getAttribute('data-deg'));
          document.getElementById('degree-readout').textContent = `N = ${state.harmonicDegree}`;
          document.querySelectorAll('.deg-btn').forEach(b => {
            b.className = 'deg-btn py-1 rounded border bg-surface border-outline-variant text-on-surface-variant';
          });
          e.currentTarget.className = 'deg-btn py-1 rounded border bg-emerald-600 text-white border-emerald-600 font-bold';
          drawGGTChart();
        });
      });

      window.addEventListener('resize', renderAll);
      document.fonts.ready.then(renderAll);
    </script>
  </body>
</html>