YMRohit Claude Fable 5 commited on
Commit
face158
·
1 Parent(s): 0f49ef9

Redesign: Apple-minimal design system (style.css) + new 4-tab HTML structure (Build/Expert/Leaderboard/Run locally), professional copy, zero emoji/em-dash

Browse files
Files changed (3) hide show
  1. CODEX_BRIEF.md +92 -58
  2. app.py +167 -112
  3. style.css +379 -189
CODEX_BRIEF.md CHANGED
@@ -1,61 +1,95 @@
1
- # Codex task — make the Kernel Mint demo land in the first 10 seconds
2
-
3
- You are improving a Hugging Face Gradio Space submitted to the "Build Small" hackathon.
4
- The app (`app.py` + `style.css`) is a custom-JS machine-builder: a user snaps blocks
5
- together (norm → ±residual → activation), presses BUILD, and a 1B model (MiniCPM5-1B) writes
6
- a real Triton GPU kernel that an immutable referee compiles, correctness-checks vs PyTorch,
7
- and times against `torch.compile`. Verified kernels that beat the compiler hit a leaderboard.
8
-
9
- ## The one problem to solve
10
- The live backend scales to zero, so the FIRST mint of a session takes ~90 seconds while the
11
- model wakes up. A hackathon judge who opens the Space, clicks BUILD, and stares at a "waking
12
- up" spinner for 90s will leave. We must make the value obvious in the first ~10 seconds
13
- WITHOUT lying about anything.
14
-
15
- ## What you have
16
- `replays/index.json` holds THREE real, verified mints recorded from the live backend today
17
- (softmax 1.052×, rmsnorm→gelu 1.045×, add+layernorm→silu 1.083×). Each entry has the real
18
- `source` (the Triton kernel the 1B actually wrote), `statuses` (the per-attempt referee
19
- verdicts, e.g. ["ok","ok","ok","ok"]), `speedup_compile`, `speedup_eager`, `gen_seconds`,
20
- and `explanation`. These are genuine outputs, not mockups.
21
-
22
- ## What to build (in priority order)
23
- 1. **Instant "Watch a real mint" path.** On load, before the backend is warm, let the user
24
- replay one of the three recorded mints with a button (e.g. "▶ Watch a real mint (instant)"
25
- near the BUILD button, or auto-offer it when the machine matches a recorded recipe). It
26
- must animate the SAME result UI the live path uses — the attempts streaming in, the
27
- referee verdict, the speedup, the real kernel source — sourced from `replays/index.json`.
28
- Label it honestly as a recorded run ("a real mint we recorded earlier — press BUILD to mint
29
- your own live"). This is the headline fix: the judge sees the whole loop in 2 seconds.
30
- 2. **Make the cold-start wait pleasant and honest.** While a live mint is in flight, show
31
- that the referee is the point: a step ticker ("model waking…", "drafting 4 kernels…",
32
- "compiling…", "checking correctness vs PyTorch…", "timing vs torch.compile…"). If the
33
- backend returns the "waking up" message, keep the user engaged (offer the instant replay)
34
- rather than showing a raw error.
35
- 3. **Tighten the visual hierarchy** so the BUILD action and the verdict are unmissable.
36
- Improve the result card: clear ✅/❌, the speedup number big, "k of n attempts passed the
37
- referee", and a collapsible real-kernel-source view. Keep the existing block-machine and
38
- the kid-friendly tone — do not rip out the working UI, refine it.
39
- 4. Keep the Leaderboard and Learn pages; make sure nav still works.
40
-
41
- ## Hard constraints
42
- - Pure Gradio + custom JS in `gr.HTML` (no new heavy deps). Frontend talks to the backend
43
- exactly as it does now (the `do_mint` Python bridge). Do not change backend URLs or the
44
- request/response contract.
45
- - `replays/index.json` is bundled in the repo — load it client-side (you can inline it into
46
- the page via Python at render time, or fetch it; inlining avoids a network hop).
47
- - Everything must degrade gracefully if the backend is down: the instant replay still works.
48
- - Do NOT invent performance numbers anywhere. Only show numbers that come from the live
49
- backend or from `replays/index.json`.
50
- - Test that `python app.py` imports and builds the Blocks without error (set a dummy
51
- `BACKEND_URL` if needed; you don't have GPU/backend access, so verify the UI renders and the
52
- replay path works, not a live mint).
53
 
54
- ## Commit discipline
55
- - Make focused commits in this repo as you go.
56
- - Author is the repo's configured user (Rohit / ymrohit). ALSO add this trailer to every
57
- commit you make so the work is attributed to Codex for the hackathon's OpenAI prize:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
 
59
- Co-authored-by: Codex <codex@openai.com>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
 
61
- - End with a one-paragraph summary of what changed and how you verified it.
 
1
+ # Codex task: rewrite APP_JS for the redesigned Kernel Mint (new DOM + Expert mode)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
+ The file `app.py` was redesigned. `style.css` (a new Apple-minimal design system) and the new
4
+ `APP_HTML` are DONE and must not be restyled or rewritten. Your job is to **rewrite the `APP_JS`
5
+ string** so the app works against the new DOM, and to add the new Expert mode. Keep the Python
6
+ bridge and `do_mint`/`fetch_lb` exactly as they are.
7
+
8
+ The OLD `APP_JS` is still in the file. Reuse its data dictionaries (ACTS, NORMS, MEM, CLASSICS,
9
+ INPUT) and its working logic for the number-flow SVG viz, the live build animation, the replay
10
+ system, the leaderboard render, and the Python bridge. Adapt all of it to the new DOM below.
11
+
12
+ ## Hard rules
13
+ - NO emoji anywhere in any string. NO em-dash or en-dash characters (use a period, comma, or
14
+ parentheses). The whole point of the redesign is a professional, Apple-grade tone.
15
+ - Do not touch `style.css`, the `APP_HTML`, the Python functions, or the bridge components
16
+ (`#km_recipe`, `#km_result`, `#km_lb`, `#km_go`). Only rewrite the `APP_JS` string.
17
+ - Pure vanilla JS inside the existing `() => { ... }` IIFE that Gradio runs via `demo.load`.
18
+
19
+ ## The Python bridge (unchanged, reuse the old approach)
20
+ `recipe()` returns JSON written into `#km_recipe` textarea; then click `#km_go`; the result blob
21
+ arrives in `#km_result` as `<span data-blob="base64(json)">`. A MutationObserver decodes it and
22
+ calls `showResult(d)`. `#km_lb` delivers `{rows:[...]}` the same way. The recipe shape is:
23
+ `{mode:'build'|'classic', norm, residual:bool, acts:[...], classic, spark, k, temp, pro, name}`.
24
+
25
+ ## New DOM contract (IDs/classes that exist in APP_HTML now)
26
+ - Tabs: `#km-tabs` has 4 `.km-tab[data-tab=build|expert|lb|docs]` and a `#km-tab-pill`. Clicking a
27
+ tab shows the matching `.km-page[data-page=...]` (hide others with `hidden`) and slides the pill
28
+ under the active tab (set pill `transform: translateX()` and `width` to match the button).
29
+ - Build composer (replaces drag-drop): the pipeline stages are `.km-pick[data-slot=mem|norm|act|act2]`.
30
+ Populate each with `.km-opt` chip buttons:
31
+ - `mem`: two chips, "none" and "add input" (residual off/on). Default none.
32
+ - `norm`: "RMSNorm", "LayerNorm" (keys rmsnorm/layernorm). Default RMSNorm.
33
+ - `act`: one chip per ACTS key, label = ACTS[k].lbl. Default gelu.
34
+ - `act2`: "none" + one chip per ACTS key. Default none. (optional second activation)
35
+ Clicking a chip sets `.on` on it (single-select within its slot) and updates the recipe + viz +
36
+ `#km-info` knowledge line (use ACTS/NORMS/MEM `.info` text; on hover too). Keep `slots` state.
37
+ - Compose/Classics segmented: `.km-segb[data-mode=build|classic]`. Toggling shows `#km-compose` vs
38
+ `#km-classic`. Populate `#km-classics` with `.km-opt` chips from CLASSICS (single-select).
39
+ - Attempts stepper: `#km-tries` (build) and `#km-xtries` (expert) are empty containers. Fill each
40
+ with buttons 1..8 (`.km-stepper` is the wrapper, already styled; append `<button>` children).
41
+ Selected has `.on`; reflect value into `#km-tries-v` / `#km-xtries-v`.
42
+ - Temperature: `#km-temp` / `#km-xtemp` range inputs; mirror `(value/100).toFixed(2)` into
43
+ `#km-temp-v` / `#km-xtemp-v`.
44
+ - Pro toggle: `#km-pro` / `#km-xpro` checkboxes.
45
+ - Name: `#km-name` (build only).
46
+ - Mint buttons: `#km-build` (build), `#km-xbuild` (expert). Recorded mint button `#km-replay`
47
+ and `.km-replay-picks` work as before.
48
+ - Result targets: `#km-verdict` (build), `#km-xverdict` (expert). `showResult(d)` must render into
49
+ whichever page is active (track last-minted mode). Source goes to `#km-source > #km-code` (build)
50
+ or `#km-xsource > .km-code` (expert).
51
+ - Viz: `#km-svg` + `#km-stage-label` (was `#km-stage`). Keep the morph/play animation; restyle uses
52
+ CSS vars already. Use stroke `#34e0a1` for the line and `#34e0a1`/`#ff7a7a` for dots (or read the
53
+ CSS var). The old viz code is fine, just point it at `#km-stage-label`.
54
+ - History: `#km-hist`.
55
+ - Glossary: `#km-learn-blocks` (in docs). Build the block glossary as before with `.km-gloss` rows.
56
 
57
+ ## Expert mode (new)
58
+ - `#km-xbrief` textarea: as the user types, resolve the text to the nearest verifiable spec and show
59
+ it in `#km-xresolved` (`.v` holds the resolved op label; add class `unknown` and an honest message
60
+ if nothing matches).
61
+ - Resolver: scan the lowercased brief for keywords -> build a recipe.
62
+ - norm: "rmsnorm"/"rms norm"/"rms" -> rmsnorm; "layernorm"/"layer norm" -> layernorm (default rmsnorm).
63
+ - residual: "residual"/"resid"/"skip"/"add input"/"+ input" -> true.
64
+ - activation: match any ACTS key or its lbl/verb words (gelu, silu/swish, relu, tanh, sigmoid,
65
+ relu2/"squared relu", gelu_erf/"exact gelu", leaky, elu, mish). First match = acts[0], a second
66
+ distinct match = acts[1].
67
+ - classics: if the brief clearly names softmax / scaled softmax / swiglu / geglu, use mode classic
68
+ with that key (takes precedence over the compose path).
69
+ - If no norm and no activation and no classic matched -> unknown; tell the user it could not map and
70
+ to pick from the supported list. Disable `#km-xbuild` when unknown.
71
+ - The recipe passes `spark: <the full brief text>` so the model sees the expert's exact words.
72
+ - `#km-oplist` (expert) and `#km-docs-ops` (docs): render `.km-optag` chips for the supported space
73
+ (the norm x residual x activation combos are large, so show a representative set: the classics +
74
+ e.g. "add_rmsnorm_gelu", "layernorm_silu", "rmsnorm_mish", etc. plus the raw activation names).
75
+ Clicking an `.km-optag` in the expert panel fills `#km-xbrief` with a matching brief and re-resolves.
76
+ - `#km-xbuild` mints using the resolved recipe via the same bridge; result renders into `#km-xverdict`.
77
+
78
+ ## Docs copy buttons
79
+ `.km-copy` buttons inside `.km-codeblock`: on click, copy the codeblock's text (minus the button)
80
+ to clipboard via `navigator.clipboard.writeText`, briefly set the button text to "Copied".
81
+
82
+ ## Verify before finishing
83
+ - `python -c "import app"` (or py_compile) passes. Use the sibling Gradio venv at
84
+ `/home/tihor/webllm/verifier-self-distillation-loop/domains/hackathon-build-small/glass-brain/.venv/bin/python`
85
+ to import and build `app.demo` with a dummy `BACKEND_URL`.
86
+ - Headless smoke with the playwright chromium in `/home/tihor/webllm/.venv-train/bin/python`: load
87
+ the app, assert all four tabs switch, the compose chips select, the stepper works, the expert
88
+ resolver shows a resolved op for "fused rmsnorm with residual and silu", the recorded-mint replay
89
+ renders a verdict, and the leaderboard table renders. Screenshot to /tmp for a sanity check.
90
+ - Grep your new APP_JS for emoji and em-dash/en-dash; there must be zero.
91
+
92
+ ## Commit discipline
93
+ Commit as the repo user with this trailer on every commit (for the hackathon OpenAI prize):
94
 
95
+ Co-authored-by: Codex <codex@openai.com>
app.py CHANGED
@@ -83,130 +83,185 @@ except Exception:
83
 
84
  APP_HTML = r"""
85
  <div id="km">
86
- <header id="km-hero">
87
- <h1>Kernel&nbsp;Mint</h1>
88
- <p>Snap blocks together, learn what each does, watch your numbers transform, then let a tiny AI build it for real.</p>
89
- </header>
90
-
91
- <nav id="km-nav">
92
- <button class="km-navb on" data-page="build">🧱 Build</button>
93
- <button class="km-navb" data-page="lb">🏆 Leaderboard</button>
94
- <button class="km-navb" data-page="learn">📚 Learn</button>
95
- </nav>
 
 
 
96
  <script id="km-replays-data" type="application/json">__KM_REPLAYS__</script>
97
 
98
- <!-- ============ BUILD PAGE ============ -->
99
  <div class="km-page" data-page="build">
100
- <div id="km-grid">
101
- <section class="km-panel">
102
- <div class="km-seg">
103
- <button class="km-segb on" data-mode="build">🧱 Build your own</button>
104
- <button class="km-segb" data-mode="classic">🎯 Famous ones</button>
105
- </div>
106
-
107
- <div id="km-buildmode">
108
- <div class="km-label">① snap a block into each slot</div>
109
- <div id="km-machine">
110
- <div class="km-slot" data-slot="mem" data-accept="mem"><span class="km-ph">+ memory <i>(optional)</i></span></div>
111
- <div class="km-arrow">↓</div>
112
- <div class="km-slot" data-slot="norm" data-accept="norm"><span class="km-ph">📐 a tidy-up block</span></div>
113
- <div class="km-arrow">↓</div>
114
- <div class="km-slot" data-slot="act" data-accept="act"><span class="km-ph">🎨 a bend block</span></div>
115
- <div class="km-arrow">↓</div>
116
- <div class="km-slot km-slot-opt" data-slot="act2" data-accept="act"><span class="km-ph">🌀 bend again <i>(hard mode)</i></span></div>
117
  </div>
118
- <div class="km-label">② drag a block up — hover any block to learn what it does</div>
119
- <div id="km-tray"></div>
120
- </div>
121
-
122
- <div id="km-classic" hidden>
123
- <div class="km-label">pick a famous operation — these run inside every AI model</div>
124
- <div id="km-classics"></div>
125
- </div>
126
-
127
- <div id="km-info" class="km-info"></div>
128
-
129
- <div class="km-label">③ make it yours</div>
130
- <div class="km-knobs">
131
- <label><span>✨ spark</span><input id="km-spark" placeholder="your idea for the AI… e.g. keep it short"></label>
132
- <label><span>🎲 tries</span><input type="range" id="km-tries" min="1" max="8" value="4"><b id="km-tries-v">4</b></label>
133
- <label><span>🌶️ wild</span><input type="range" id="km-temp" min="20" max="130" value="70"><b id="km-temp-v">0.70</b></label>
134
- <label><span>🏷️ name</span><input id="km-name" placeholder="for the leaderboard"></label>
135
- <label class="km-pro"><input type="checkbox" id="km-pro"><span>🔥 Pro mode</span> <i>the big 27B model — slower, smarter</i></label>
136
- </div>
137
-
138
- <div class="km-label">④ your call — will it beat the compiler, or just tie?</div>
139
- <div id="km-guess">
140
- <button class="km-gbtn on" data-g="beat">👍 It'll beat it</button>
141
- <button class="km-gbtn" data-g="tie">🤝 Just a tie</button>
142
- </div>
143
-
144
- <div class="km-actions">
145
- <button id="km-surprise">🎲 Surprise me</button>
146
- <button id="km-build">⚒️ BUILD MY KERNEL</button>
147
- </div>
148
- <div id="km-replay-callout" class="km-replay-callout">
149
- <div>
150
- <b>Need the whole loop now?</b>
151
- <span id="km-replay-note">Watch a real mint recorded earlier. Then press BUILD to mint your own live.</span>
152
  </div>
153
- <button id="km-replay" data-replay-key="rmsnorm_gelu">▶ Watch a real mint (instant)</button>
154
- </div>
155
- <div id="km-replay-picks" class="km-replay-picks" aria-label="recorded mints"></div>
156
- </section>
157
 
158
- <section class="km-panel">
159
- <div class="km-label">watch your numbers go through the machine</div>
160
- <div id="km-viz"><svg id="km-svg" viewBox="0 0 320 150" preserveAspectRatio="none"></svg>
161
- <div id="km-stage">your numbers</div></div>
162
- <div id="km-verdict"><div class="km-card"><b>Press BUILD to begin 🚀</b><br>
163
- <span class="km-dim">Snap a tidy-up block and a bend block into the machine, or watch a recorded mint instantly.</span></div></div>
164
- <details id="km-source" class="km-source" hidden>
165
- <summary>Real Triton kernel source</summary>
166
- <pre id="km-code"></pre>
167
- </details>
168
- <div class="km-label">your kernels this session</div>
169
- <div id="km-hist" class="km-dim">none yet</div>
170
- </section>
171
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
172
  </div>
173
 
174
- <!-- ============ LEADERBOARD PAGE ============ -->
175
- <div class="km-page" data-page="lb" hidden>
176
- <div class="km-panel">
177
- <div class="km-label">best verified kernel per machine · 👑 = the big 27B model you're racing</div>
178
- <div id="km-lb-view" class="km-dim">loading…</div>
179
- <button id="km-lb-refresh" class="km-mini">↻ refresh</button>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
180
  </div>
181
  </div>
182
 
183
- <!-- ============ LEARN PAGE ============ -->
184
- <div class="km-page" data-page="learn" hidden>
185
- <div class="km-panel km-learn">
186
- <h3>What am I actually building?</h3>
187
- <p>A <b>GPU kernel</b> is a tiny program that does one job for an AI model on the graphics
188
- chip — tidying numbers, or bending them into a useful shape. AI models run <i>millions</i>
189
- of these. The trick: every time the chip fetches numbers from memory it loses time, so when
190
- you <b>fuse</b> several steps into one kernel, the numbers travel once instead of many times.
191
- That is where most real speed in running AI comes from. You just made one.</p>
192
- <h3>Who decides if mine is real?</h3>
193
- <p>A <b>referee that can't be fooled.</b> For your kernel it (1) compiles it, (2) checks it
194
- gives the <b>same answers as PyTorch</b> on tricky numbers — odd sizes, huge values, low
195
- precision — (3) <b>times</b> it against the computer's own professional compiler, and
196
- (4) <b>catches cheats</b> by design. Your ✅ is earned, not given.</p>
197
- <h3>The blocks</h3>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
198
  <div id="km-learn-blocks"></div>
199
- <h3>The knobs</h3>
200
- <p><b>Tries</b> — how many kernels the AI drafts; the referee keeps the best. More tries,
201
- better odds.<br><b>Wild</b> — how adventurous the AI is. Low is safe and tidy; high explores
202
- strange kernels that sometimes win bigger and sometimes flop.<br><b>Spark</b> — type your own
203
- idea and the AI follows it while staying correct.<br><b>Pro mode</b> — swaps the 1B model for
204
- the 27B: slower, but it knows more and writes faster kernels.</p>
205
- <h3>Why a tiny model?</h3>
206
- <p>The model building your kernels is only <b>one billion</b> numbers — small enough to run
207
- cheaply. The 👑 you race were set by one <b>27× bigger</b>. The secret of this whole project:
208
- the clever part isn't the giant model, it's the <b>honest referee</b>.</p>
209
- </div>
210
  </div>
211
  </div>
212
  """
 
83
 
84
  APP_HTML = r"""
85
  <div id="km">
86
+ <div id="km-top">
87
+ <div id="km-brand">
88
+ <span class="mark"><span class="dot"></span>Kernel Mint</span>
89
+ <span class="sub">an OUROBOROS demo</span>
90
+ </div>
91
+ <div id="km-tabs">
92
+ <span id="km-tab-pill"></span>
93
+ <button class="km-tab on" data-tab="build">Build</button>
94
+ <button class="km-tab" data-tab="expert">Expert</button>
95
+ <button class="km-tab" data-tab="lb">Leaderboard</button>
96
+ <button class="km-tab" data-tab="docs">Run locally</button>
97
+ </div>
98
+ </div>
99
  <script id="km-replays-data" type="application/json">__KM_REPLAYS__</script>
100
 
101
+ <!-- ============ BUILD ============ -->
102
  <div class="km-page" data-page="build">
103
+ <header id="km-hero">
104
+ <h1>A 1B model writes a real GPU kernel. <span class="g">A referee that can't be fooled checks it.</span></h1>
105
+ <p>Compose an operation, and a 1-billion-parameter model writes a fused Triton kernel for it. The kernel is compiled, checked against PyTorch on adversarial inputs, and timed against PyTorch's own compiler before anything counts as a win.</p>
106
+ </header>
107
+ <div id="km-grid">
108
+ <section class="km-card">
109
+ <div class="km-seg" role="tablist">
110
+ <button class="km-segb on" data-mode="build">Compose</button>
111
+ <button class="km-segb" data-mode="classic">Classic ops</button>
 
 
 
 
 
 
 
 
112
  </div>
113
+
114
+ <div id="km-compose">
115
+ <div class="km-section-label">Pipeline</div>
116
+ <div id="km-pipe">
117
+ <div class="km-stage fixed"><span class="km-stage-k">input</span><span class="km-dim">a row of activations</span></div>
118
+ <div class="km-flow">&darr;</div>
119
+ <div class="km-stage"><span class="km-stage-k">residual</span><span class="km-pick" data-slot="mem"></span></div>
120
+ <div class="km-flow">&darr;</div>
121
+ <div class="km-stage"><span class="km-stage-k">normalize</span><span class="km-pick" data-slot="norm"></span></div>
122
+ <div class="km-flow">&darr;</div>
123
+ <div class="km-stage"><span class="km-stage-k">activate</span><span class="km-pick" data-slot="act"></span></div>
124
+ <div class="km-flow">&darr;</div>
125
+ <div class="km-stage"><span class="km-stage-k">then</span><span class="km-pick" data-slot="act2"></span></div>
126
+ </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
127
  </div>
 
 
 
 
128
 
129
+ <div id="km-classic" hidden>
130
+ <div class="km-section-label">A named operation from a real transformer</div>
131
+ <div class="km-pick" id="km-classics"></div>
132
+ </div>
133
+
134
+ <div id="km-info"></div>
135
+
136
+ <div class="km-params">
137
+ <div class="km-field">
138
+ <label>Attempts the model drafts <b id="km-tries-v">4</b></label>
139
+ <div class="km-stepper" id="km-tries"></div>
140
+ </div>
141
+ <div class="km-field">
142
+ <label>Sampling temperature <b id="km-temp-v">0.70</b></label>
143
+ <input type="range" class="km-range" id="km-temp" min="20" max="130" value="70">
144
+ </div>
145
+ <div class="km-field">
146
+ <label>Name for the leaderboard</label>
147
+ <input class="km-input" id="km-name" placeholder="optional" autocomplete="off">
148
+ </div>
149
+ <label class="km-toggle"><input type="checkbox" id="km-pro"><span class="km-switch"></span>Use the 27B model (slower, knows more)</label>
150
+ </div>
151
+
152
+ <div class="km-actions">
153
+ <button class="km-btn primary" id="km-build">Mint kernel</button>
154
+ <button class="km-btn ghost" id="km-replay" data-replay-key="rmsnorm_gelu">Watch a recorded mint</button>
155
+ </div>
156
+ <div id="km-replay-picks" class="km-replay-picks" aria-label="recorded mints"></div>
157
+ </section>
158
+
159
+ <section class="km-card">
160
+ <div class="km-section-label">The operation, stage by stage</div>
161
+ <div id="km-viz"><svg id="km-svg" viewBox="0 0 320 150" preserveAspectRatio="none"></svg>
162
+ <div id="km-stage-label">input</div></div>
163
+ <div id="km-verdict"><div class="km-card"><div class="km-result-top"><div class="km-verdict-icon">&rarr;</div>
164
+ <div><span class="km-run-label">ready</span><b>Press Mint to begin</b></div></div>
165
+ <p class="km-dim" style="margin-top:10px">Compose a pipeline on the left and mint it, or watch a recorded verified mint to see the whole referee loop instantly.</p></div></div>
166
+ <details id="km-source" class="km-source" hidden>
167
+ <summary>Triton kernel source</summary>
168
+ <pre id="km-code"></pre>
169
+ </details>
170
+ <div class="km-section-label">This session</div>
171
+ <div id="km-hist" class="km-dim">No mints yet.</div>
172
+ </section>
173
+ </div>
174
  </div>
175
 
176
+ <!-- ============ EXPERT ============ -->
177
+ <div class="km-page" data-page="expert" hidden>
178
+ <header id="km-hero">
179
+ <h1>Free-test the verifier.</h1>
180
+ <p>Describe the fused operation you want in plain language. The model writes a Triton kernel and the referee certifies it against PyTorch and times it against torch.compile. The referee can only certify operations it has a reference for, so your request is resolved to the nearest one it can check.</p>
181
+ </header>
182
+ <div class="km-expert-grid">
183
+ <section class="km-card">
184
+ <div class="km-section-label">Your brief</div>
185
+ <textarea class="km-textarea" id="km-xbrief" placeholder="e.g. fused RMSNorm with a residual add and a SiLU activation, contiguous rows"></textarea>
186
+ <div id="km-xresolved" class="km-resolved"><span class="k">resolves to</span><div class="v">rmsnorm with gelu</div></div>
187
+ <div class="km-params">
188
+ <div class="km-field">
189
+ <label>Attempts the model drafts <b id="km-xtries-v">5</b></label>
190
+ <div class="km-stepper" id="km-xtries"></div>
191
+ </div>
192
+ <div class="km-field">
193
+ <label>Sampling temperature <b id="km-xtemp-v">0.70</b></label>
194
+ <input type="range" class="km-range" id="km-xtemp" min="20" max="130" value="70">
195
+ </div>
196
+ <label class="km-toggle"><input type="checkbox" id="km-xpro"><span class="km-switch"></span>Use the 27B model</label>
197
+ </div>
198
+ <div class="km-actions">
199
+ <button class="km-btn primary" id="km-xbuild">Mint from brief</button>
200
+ </div>
201
+ </section>
202
+ <section class="km-card">
203
+ <div class="km-section-label">What the referee can verify</div>
204
+ <p class="km-limits">It certifies fusions of a <b>normalization</b> (RMSNorm or LayerNorm), an optional <b>residual add</b>, and one or two <b>activations</b>, plus a set of named operators from real transformers. Click one to load it into your brief.</p>
205
+ <div class="km-oplist" id="km-oplist"></div>
206
+ <div id="km-xverdict" style="margin-top:16px"></div>
207
+ <details id="km-xsource" class="km-source" hidden>
208
+ <summary>Triton kernel source</summary>
209
+ <pre class="km-code"></pre>
210
+ </details>
211
+ </section>
212
  </div>
213
  </div>
214
 
215
+ <!-- ============ LEADERBOARD ============ -->
216
+ <div class="km-page" data-page="lb" hidden>
217
+ <section class="km-card">
218
+ <div class="km-h">Leaderboard</div>
219
+ <p class="km-lede">The best verified kernel per operation. Crowned rows were minted by the 27B model. Every speedup here was measured by the referee, not reported by the model.</p>
220
+ <div id="km-lb-view" class="km-dim" style="margin-top:16px">Loading.</div>
221
+ <button id="km-lb-refresh" class="km-mini">Refresh</button>
222
+ </section>
223
+ </div>
224
+
225
+ <!-- ============ RUN LOCALLY / DOCS ============ -->
226
+ <div class="km-page" data-page="docs" hidden>
227
+ <section class="km-card km-docs">
228
+ <h2>What this is</h2>
229
+ <p>A GPU kernel is the small program that runs one step of a neural network on the graphics card. Fusing several steps into one kernel cuts trips to memory, which is where a lot of real inference speed comes from. Here, a 1-billion-parameter model writes those kernels, and an immutable referee decides whether each one is real.</p>
230
+ <p>The bet behind the project: the scarce thing is not the big model, it is a verifier the model cannot fool. Correctness is a yes or no, speed is a measurement, and the model learns from its own verified wins.</p>
231
+
232
+ <h2>The referee</h2>
233
+ <p>For every kernel the referee compiles it, checks it gives the same answers as PyTorch on adversarial inputs (odd shapes, large magnitudes, low precision), times it against <b>torch.compile</b> max-autotune, and blocks three specific ways of gaming the benchmark. A green result is earned, not asserted.</p>
234
+
235
+ <h2>Run it locally</h2>
236
+ <p>The 1B smith is published and small enough to run on a modest GPU. Install the libraries, load the adapter on its base model, and prompt it for a kernel.</p>
237
+ <div class="km-codeblock"><button class="km-copy">Copy</button>pip install torch transformers peft triton</div>
238
+ <div class="km-codeblock"><button class="km-copy">Copy</button>from transformers import AutoModelForCausalLM, AutoTokenizer
239
+ from peft import PeftModel
240
+
241
+ base = AutoModelForCausalLM.from_pretrained(
242
+ "openbmb/MiniCPM5-1B", trust_remote_code=True, device_map="cuda")
243
+ model = PeftModel.from_pretrained(
244
+ base, "YMRohit/ouroboros-kernelsmith-minicpm5-1b")
245
+ tok = AutoTokenizer.from_pretrained(
246
+ "openbmb/MiniCPM5-1B", trust_remote_code=True)</div>
247
+
248
+ <h2>How to prompt the model</h2>
249
+ <p>The model was trained to answer a short request for one fused operation and return a single Triton kernel with a <code>run(...)</code> entry point. Keep the request to one operation, name the pieces (normalization, residual, activation), and ask for the kernel only.</p>
250
+ <div class="km-codeblock"><button class="km-copy">Copy</button>Write a fused Triton kernel for: RMSNorm followed by a GELU
251
+ activation, with a residual add of the input. One @triton.jit
252
+ kernel plus a run(x, residual, weight) entry point. Triton only.</div>
253
+ <p>Always run whatever it writes through a verifier before trusting it. That is the entire point of the project, and the referee in this app is one you can reuse.</p>
254
+
255
+ <h2>What it can and cannot verify</h2>
256
+ <p>The referee needs a PyTorch reference to check against, so it certifies a fixed space of operations: a normalization (RMSNorm or LayerNorm), an optional residual add, and one or two activations, plus a set of named operators from real transformers. Anything outside that space cannot be certified here, by design.</p>
257
+ <div id="km-docs-ops" class="km-oplist"></div>
258
+
259
+ <h2>The pieces</h2>
260
  <div id="km-learn-blocks"></div>
261
+
262
+ <h2>License and source</h2>
263
+ <p>MIT licensed. The models are <a href="https://huggingface.co/YMRohit/ouroboros-kernelsmith-minicpm5-1b" style="color:var(--accent)">MiniCPM5-1B</a> and <a href="https://huggingface.co/YMRohit/ouroboros-kernelsmith-qwen3.6-27b" style="color:var(--accent)">Qwen3.6-27B</a> (both Apache-2.0). The verified kernels and evidence reports are in the <a href="https://huggingface.co/datasets/YMRohit/ouroboros-kernel-corpus" style="color:var(--accent)">corpus</a>.</p>
264
+ </section>
 
 
 
 
 
 
 
265
  </div>
266
  </div>
267
  """
style.css CHANGED
@@ -1,190 +1,380 @@
1
- :root{
2
- --ease:cubic-bezier(0.23,1,0.32,1);
3
- --bg:#080c0a; --panel:#0d1411; --line:#1b2620; --txt:#e8f0ec; --mut:#7e948b; --acc:#2dd4a7;
4
- --norm:#6db6e6; --act:#e8a665; --mem:#b49ae6;
5
- }
6
- .gradio-container{max-width:1060px!important;margin:auto;background:#080c0a!important;}
7
- footer{display:none!important;}
8
- #km{color:var(--txt);}
9
- #km-hero{text-align:center;padding:10px 0 14px;}
10
- #km-hero h1{margin:0;font-size:38px;font-weight:800;letter-spacing:-1.5px;background:linear-gradient(95deg,#fcd34d,#2dd4a7 55%,#7dd3fc);-webkit-background-clip:text;-webkit-text-fill-color:transparent;}
11
- #km-hero p{margin:7px auto 0;color:var(--mut);font-size:15px;max-width:560px;}
12
-
13
- /* page nav */
14
- #km-nav{display:flex;gap:6px;justify-content:center;margin-bottom:16px;}
15
- .km-navb{border:1px solid var(--line);background:#0a100d;color:var(--mut);border-radius:11px;padding:9px 18px;font-weight:700;font-size:14px;cursor:pointer;transition:transform .14s var(--ease),background .2s,color .2s;}
16
- .km-navb:active{transform:scale(0.97);}
17
- .km-navb.on{background:#13241c;color:#7df0c8;border-color:#1f6f51;}
18
-
19
- #km-grid{display:grid;grid-template-columns:1fr 1fr;gap:16px;align-items:start;}
20
- @media(max-width:820px){#km-grid{grid-template-columns:1fr;}}
21
- .km-panel{border:1px solid var(--line);border-radius:18px;padding:18px;background:var(--panel);}
22
- .km-label{font-size:11px;letter-spacing:.12em;text-transform:uppercase;color:var(--mut);font-weight:700;margin:16px 0 8px;}
23
- .km-label:first-child{margin-top:0;}
24
-
25
- .km-seg{display:flex;gap:6px;background:#0a100d;padding:4px;border-radius:13px;border:1px solid var(--line);}
26
- .km-segb{flex:1;border:0;background:transparent;color:var(--mut);border-radius:10px;padding:9px;font-weight:700;font-size:13.5px;cursor:pointer;transition:transform .14s var(--ease),background .2s,color .2s;}
27
- .km-segb:active{transform:scale(0.97);}
28
- .km-segb.on{background:#13241c;color:#7df0c8;}
29
-
30
- /* machine */
31
- #km-machine{display:flex;flex-direction:column;align-items:stretch;}
32
- .km-arrow{text-align:center;color:#2f4138;font-size:15px;line-height:1;margin:5px 0;}
33
- .km-slot{border:1.5px dashed #2a3a32;border-radius:13px;min-height:52px;display:flex;align-items:center;justify-content:center;background:#0a100d;font-weight:700;font-size:14.5px;transition:transform .18s var(--ease),border-color .15s,background .25s;position:relative;padding:0 42px;}
34
- .km-slot .km-ph{color:#52685e;font-weight:600;}
35
- .km-slot .km-ph i{font-weight:400;opacity:.75;font-style:italic;}
36
- .km-slot .km-fill{text-align:center;width:100%;}
37
- .km-slot.over{border-color:var(--acc);border-style:solid;transform:scale(1.015);background:#0c1813;}
38
- .km-slot.filled{border-style:solid;}
39
- .km-slot-opt{opacity:.6;}
40
- .km-x{position:absolute;right:10px;top:50%;transform:translateY(-50%);border:1px solid currentColor;background:transparent;color:currentColor;border-radius:50%;width:24px;height:24px;line-height:1;display:flex;align-items:center;justify-content:center;cursor:pointer;font-weight:700;font-size:12px;opacity:.55;transition:opacity .15s;}
41
- .km-x:hover{opacity:1;}
42
- .km-slot.fnorm{border-color:var(--norm);color:var(--norm);background:#0e1820;}
43
- .km-slot.fact{border-color:var(--act);color:var(--act);background:#1a140d;}
44
- .km-slot.fmem{border-color:var(--mem);color:var(--mem);background:#161324;}
45
-
46
- /* tray */
47
- #km-tray{display:flex;flex-wrap:wrap;gap:8px;}
48
- .km-tile{border:1.5px solid;border-radius:11px;padding:8px 13px;font-weight:700;font-size:13.5px;cursor:grab;user-select:none;background:#0c120f;transition:transform .14s var(--ease),background .2s;}
49
- .km-tile.tmem{border-color:var(--mem);color:var(--mem);}
50
- .km-tile.tnorm{border-color:var(--norm);color:var(--norm);}
51
- .km-tile.tact{border-color:var(--act);color:var(--act);}
52
- .km-tile:active{cursor:grabbing;transform:scale(0.95) translateY(1px);}
53
- .km-tile.drag{opacity:.4;}
54
- @media(hover:hover){.km-tile:hover{transform:translateY(-2px);background:#101713;}}
55
-
56
- .km-chip{border:1px solid var(--line);background:#0a100d;color:var(--txt);border-radius:999px;padding:8px 14px;font-weight:600;cursor:pointer;transition:transform .14s var(--ease),background .2s;}
57
- .km-chip:active{transform:scale(0.97);}
58
- .km-chip.on{background:#13241c;border-color:#1f6f51;color:#7df0c8;}
59
- #km-classics{display:flex;flex-wrap:wrap;gap:8px;}
60
-
61
- /* info panel — knowledge */
62
- .km-info{margin-top:14px;border:1px solid var(--line);border-left:3px solid var(--acc);border-radius:10px;background:#0a130f;padding:11px 13px;color:#bfe9d8;font-size:13px;line-height:1.5;min-height:42px;}
63
-
64
- /* knobs — aligned labels */
65
- .km-knobs{display:flex;flex-direction:column;gap:11px;}
66
- .km-knobs label{display:flex;align-items:center;gap:12px;font-size:13.5px;color:var(--mut);font-weight:600;}
67
- .km-knobs label>span{width:60px;flex:none;color:var(--txt);}
68
- .km-knobs input[type=text],.km-knobs input:not([type]){flex:1;background:#0a100d;border:1px solid var(--line);border-radius:10px;padding:9px 12px;color:var(--txt);font-size:13.5px;min-width:0;}
69
- .km-knobs input[type=range]{flex:1;accent-color:var(--acc);min-width:0;}
70
- .km-knobs input[type=range]+b{width:38px;text-align:right;color:var(--txt);font-variant-numeric:tabular-nums;}
71
- .km-knobs .km-pro{color:var(--txt);}
72
- .km-knobs .km-pro span{width:auto;}
73
- .km-knobs .km-pro i{color:var(--mut);font-size:12px;font-style:italic;}
74
-
75
- .km-actions{display:flex;gap:10px;margin-top:18px;}
76
- #km-surprise{flex:1;border:1px solid var(--line);background:#0a100d;color:var(--txt);border-radius:13px;padding:14px;font-weight:700;cursor:pointer;transition:transform .14s var(--ease),background .2s;}
77
- #km-surprise:active{transform:scale(0.97);}
78
- @media(hover:hover){#km-surprise:hover{background:#101713;}}
79
- #km-build{flex:2;border:0;border-radius:13px;padding:15px 14px;font-weight:900;font-size:17px;color:#04130d;cursor:pointer;background:linear-gradient(95deg,#34d399,#2dd4a7);box-shadow:0 12px 30px rgba(45,212,167,.18);transition:transform .14s var(--ease),filter .2s,box-shadow .2s;}
80
- #km-build:active{transform:scale(0.98) translateY(1px);}
81
- @media(hover:hover){#km-build:hover{filter:brightness(1.07);box-shadow:0 16px 38px rgba(45,212,167,.25);}}
82
- .km-replay-callout{margin-top:10px;border:1px solid #1f6f51;border-radius:12px;background:#0b1712;padding:12px;display:grid;grid-template-columns:1fr auto;gap:12px;align-items:center;}
83
- .km-replay-callout b{display:block;color:#d8fff0;font-size:13.5px;margin-bottom:2px;}
84
- .km-replay-callout span{display:block;color:#8fb6a7;font-size:12.5px;line-height:1.35;}
85
- #km-replay,.km-inline-replay{border:0;border-radius:11px;background:#d8fff0;color:#062015;font-weight:900;padding:10px 13px;cursor:pointer;white-space:nowrap;transition:transform .14s var(--ease),filter .2s;}
86
- #km-replay:active,.km-inline-replay:active{transform:scale(.98);}
87
- @media(hover:hover){#km-replay:hover,.km-inline-replay:hover{filter:brightness(1.05);}}
88
- .km-replay-picks{display:flex;flex-wrap:wrap;gap:7px;margin-top:8px;}
89
- .km-rpick{border:1px solid var(--line);border-radius:10px;background:#0a100d;color:#9db3aa;padding:7px 9px;font-size:12px;font-weight:750;cursor:pointer;transition:background .2s,border-color .2s,color .2s,transform .14s var(--ease);}
90
- .km-rpick span{color:#7df0c8;font-variant-numeric:tabular-nums;margin-left:3px;}
91
- .km-rpick.on{background:#13241c;border-color:#1f6f51;color:#e8fff6;}
92
- .km-rpick:active{transform:scale(.98);}
93
- @media(max-width:560px){.km-actions,.km-replay-callout{grid-template-columns:1fr;display:grid}.km-actions{gap:8px}#km-surprise,#km-build,#km-replay{width:100%;}.km-replay-callout{align-items:stretch;}}
94
-
95
- /* visualisation */
96
- #km-viz{border:1px solid var(--line);border-radius:14px;background:radial-gradient(120% 100% at 50% 0,#0e1813,#0a100d);padding:14px 14px 6px;}
97
- #km-svg{width:100%;height:170px;display:block;}
98
- #km-stage{text-align:center;color:#7df0c8;font-size:13.5px;font-weight:650;padding:8px 0 2px;min-height:20px;}
99
-
100
- #km-verdict{margin-top:14px;}
101
- .km-card{border:1px solid var(--line);border-radius:14px;padding:16px;background:#0a100d;font-size:15px;line-height:1.5;}
102
- .km-card.ok{border-color:#1f6f51;background:#0b1611;}.km-card.miss{border-color:#5a4326;}.km-card.err{border-color:#5b4a30;}
103
- .km-card b{color:var(--txt);}.km-dim{color:var(--mut);font-size:13.5px;}
104
- .km-result-card{background:radial-gradient(140% 120% at 15% 0,#123126,#0a100d 62%);}
105
- .km-result-top{display:flex;gap:12px;align-items:center;margin-bottom:12px;}
106
- .km-result-top b{display:block;font-size:18px;line-height:1.15;}
107
- .km-result-top span:not(.km-run-label){display:block;color:#9db3aa;font-size:13px;margin-top:3px;}
108
- .km-verdict-icon{width:38px;height:38px;display:grid;place-items:center;border-radius:10px;background:#13241c;border:1px solid #1f6f51;font-size:20px;flex:none;}
109
- .km-verdict-icon.bad{background:#241313;border-color:#5a2626;}
110
- .km-run-label{display:inline-block;color:#7df0c8!important;font-size:11px!important;font-weight:850;text-transform:uppercase;letter-spacing:.08em;margin-bottom:4px;}
111
- .km-run-label.recorded,.km-guess-res.recorded{background:#122119;color:#9ff3d6;border-color:#1f6f51;}
112
- .km-speed-hero{border:1px solid #1f6f51;border-radius:13px;background:#07110d;padding:14px;text-align:center;margin:10px 0 12px;}
113
- .km-speed-hero big{display:block;color:#7df0c8;font-size:46px;font-weight:950;line-height:.95;font-variant-numeric:tabular-nums;}
114
- .km-speed-hero span{display:block;color:#a2bdb2;font-size:12px;font-weight:800;text-transform:uppercase;letter-spacing:.08em;margin-top:8px;}
115
- .km-ref-summary{border-left:3px solid var(--acc);padding:6px 0 6px 10px;color:#9db3aa;font-size:13.5px;margin:10px 0;}
116
- .km-ref-summary b{font-variant-numeric:tabular-nums;}
117
- .km-attempts{display:flex;flex-wrap:wrap;gap:7px;margin:10px 0 12px;}
118
- .km-attempt{border:1px solid var(--line);border-radius:9px;background:#0c130f;color:#9db3aa;padding:6px 8px;font-size:12px;font-weight:750;}
119
- .km-attempt b{margin-right:4px;}
120
- .km-attempt.ok{border-color:#1f6f51;background:#102018;color:#bfffe7;}
121
- .km-attempt.bad{border-color:#5a2626;background:#241313;color:#f6b3b3;}
122
- .km-stats{display:flex;gap:10px;margin:14px 0 4px;}
123
- .km-stats>div{flex:1;border:1px solid var(--line);border-radius:12px;padding:12px 6px;background:#0c130f;text-align:center;}
124
- .km-stats big{display:block;font-size:28px;font-weight:850;color:var(--acc);line-height:1;font-variant-numeric:tabular-nums;}
125
- .km-stats span{color:var(--mut);font-size:10.5px;display:block;margin-top:6px;line-height:1.2;}
126
- .km-crown,.km-board{display:inline-block;border-radius:999px;padding:5px 12px;font-weight:800;font-size:12.5px;margin-bottom:11px;}
127
- .km-crown{background:#332a09;color:#fcd34d;border:1px solid #6b5210;}.km-board{background:#13241c;color:#7df0c8;border:1px solid #1f6f51;}
128
- .km-source{margin-top:12px;border:1px solid var(--line);border-radius:12px;background:#070b09;overflow:hidden;}
129
- .km-source summary{cursor:pointer;padding:12px 13px;color:#d8fff0;font-weight:850;font-size:13px;list-style:none;}
130
- .km-source summary::-webkit-details-marker{display:none;}
131
- .km-source summary:after{content:"+";float:right;color:#7df0c8;}
132
- .km-source[open] summary:after{content:"-";}
133
- #km-code{margin:0;border-top:1px solid var(--line);padding:13px;color:#9be6c9;font-size:11.5px;line-height:1.5;overflow:auto;max-height:280px;white-space:pre-wrap;font-family:ui-monospace,Menlo,monospace;}
134
- #km-hist .km-hrow{border:1px solid var(--line);border-radius:9px;padding:8px 11px;background:#0a100d;font-size:13px;margin-bottom:6px;}
135
- #km-hist code{color:#9be6c9;}
136
-
137
- /* leaderboard page */
138
- table.km-lbt{width:100%;border-collapse:collapse;font-size:14px;}
139
- table.km-lbt th{text-align:left;color:var(--mut);font-weight:700;font-size:11px;text-transform:uppercase;letter-spacing:.07em;padding:10px 12px;border-bottom:1px solid var(--line);}
140
- table.km-lbt td{padding:10px 12px;border-bottom:1px solid #131e18;color:var(--txt);}
141
- table.km-lbt td.hot{color:var(--acc);font-weight:800;text-align:right;font-variant-numeric:tabular-nums;}
142
- table.km-lbt td:nth-child(5){text-align:right;color:var(--mut);font-variant-numeric:tabular-nums;}
143
- table.km-lbt tr.champ td{background:linear-gradient(90deg,#1a160833,transparent);}
144
- table.km-lbt code{color:#9be6c9;background:#070b09;padding:1px 6px;border-radius:5px;font-size:12.5px;}
145
- .km-mini{margin-top:14px;border:1px solid var(--line);background:#0a100d;color:var(--mut);border-radius:10px;padding:8px 14px;font-weight:600;cursor:pointer;}
146
- .km-mini:active{transform:scale(0.97);}
147
-
148
- /* learn page */
149
- .km-learn h3{color:var(--txt);font-size:17px;margin:18px 0 6px;}
150
- .km-learn h3:first-child{margin-top:0;}
151
- .km-learn p{color:var(--mut);font-size:14px;line-height:1.65;margin:0;}
152
- .km-learn b{color:var(--txt);}
153
- #km-learn-blocks{display:flex;flex-direction:column;gap:8px;margin-top:6px;}
154
- .km-gloss{border:1px solid var(--line);border-radius:11px;padding:10px 13px;background:#0a100d;}
155
- .km-gloss b{display:block;color:var(--txt);font-size:14px;margin-bottom:3px;}
156
- .km-gloss span{color:var(--mut);font-size:13px;line-height:1.5;}
157
-
158
- @media(prefers-reduced-motion:reduce){#km *{animation:none!important;transition:none!important;}}
159
-
160
- /* bridge components: present in the DOM (so custom JS can reach them) but hidden */
161
- #km_recipe, #km_go, #km_result, #km_lb{position:absolute!important;width:1px!important;height:1px!important;overflow:hidden!important;clip:rect(0 0 0 0)!important;opacity:0!important;pointer-events:none!important;margin:-1px!important;}
162
-
163
- /* guess mechanic */
164
- #km-guess{display:flex;gap:8px;}
165
- .km-gbtn{flex:1;border:1px solid var(--line);background:#0a100d;color:var(--mut);border-radius:12px;padding:11px;font-weight:700;font-size:14px;cursor:pointer;transition:transform .14s var(--ease),background .2s,color .2s,border-color .2s;}
166
- .km-gbtn:active{transform:scale(0.97);}
167
- .km-gbtn.on{background:#13241c;border-color:#1f6f51;color:#7df0c8;}
168
- .km-guess-res{display:inline-block;border-radius:999px;padding:5px 12px;font-weight:800;font-size:12.5px;margin-bottom:11px;}
169
- .km-guess-res.hit{background:#13241c;color:#7df0c8;border:1px solid #1f6f51;}
170
- .km-guess-res.miss{background:#2a1414;color:#fca5a5;border:1px solid #5a2626;}
171
- .km-guess-res b{color:inherit;}
172
-
173
- /* live build progress */
174
- .km-card.building{border-color:#1f6f51;}
175
- .km-card.replaying{background:radial-gradient(130% 120% at 12% 0,#13241c,#0a100d 62%);}
176
- .km-build-steps{display:grid;gap:6px;margin:12px 0;}
177
- .km-build-steps span{border:1px solid var(--line);border-radius:9px;background:#0c130f;color:#6f877d;padding:7px 9px;font-size:12px;font-weight:750;}
178
- .km-build-steps span.on{border-color:#1f6f51;color:#d8fff0;background:#102018;}
179
- .km-build-steps span.done{color:#7df0c8;}
180
- .km-bar{height:7px;border-radius:999px;background:#0c130f;border:1px solid var(--line);overflow:hidden;margin:13px 0;}
181
- .km-bar i{display:block;height:100%;width:6%;border-radius:999px;background:linear-gradient(90deg,#f59e0b,#2dd4a7);transition:width .6s var(--ease);}
182
- .km-inline-replay{display:inline-block;margin-top:12px;font-size:13px;}
183
- .km-replay-stage{color:#d8fff0;font-weight:850;margin:8px 0 2px;}
184
- .km-rawerr{color:#7e948b;font-size:12px;line-height:1.45;margin:10px 0 0;}
185
-
186
- @media(max-width:560px){
187
- .km-result-top{align-items:flex-start;}
188
- .km-speed-hero big{font-size:40px;}
189
- .km-stats{flex-direction:column;}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
190
  }
 
1
+ /* OUROBOROS Kernel Mint — design system
2
+ Apple-minimal: SF system type, one emerald accent on layered near-black, hairlines,
3
+ restrained motion. No emoji, no em-dashes, one accent, one radius scale. */
4
+
5
+ :root {
6
+ --bg: #0b0c0e;
7
+ --surface: #131519;
8
+ --surface-2: #181b20;
9
+ --surface-3: #1e2227;
10
+ --line: rgba(255,255,255,0.07);
11
+ --line-2: rgba(255,255,255,0.12);
12
+ --text: #f4f6f7;
13
+ --muted: #9aa1ab;
14
+ --faint: #686f79;
15
+ --accent: #34e0a1;
16
+ --accent-deep: #10b981;
17
+ --accent-ink: #052b1e;
18
+ --accent-soft: rgba(52,224,161,0.12);
19
+ --accent-line: rgba(52,224,161,0.32);
20
+ --danger: #ff7a7a;
21
+ --danger-soft: rgba(255,122,122,0.10);
22
+ --amber: #f1c47a;
23
+ --r: 14px;
24
+ --r-sm: 10px;
25
+ --r-pill: 980px;
26
+ --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI", system-ui, sans-serif;
27
+ --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;
28
+ --ease: cubic-bezier(0.16, 1, 0.3, 1);
29
+ --shadow: 0 1px 0 rgba(255,255,255,0.04) inset, 0 12px 40px rgba(0,0,0,0.42);
30
+ --shadow-sm: 0 1px 0 rgba(255,255,255,0.04) inset, 0 4px 16px rgba(0,0,0,0.30);
31
+ }
32
+
33
+ /* Gradio host: let our surface own the page */
34
+ .gradio-container, .gradio-container * { font-family: var(--sans); }
35
+ .gradio-container { max-width: 100% !important; padding: 0 !important; background: var(--bg) !important; }
36
+ gradio-app { background: var(--bg); }
37
+ footer, .footer, #footer { display: none !important; }
38
+ /* hide the python bridge components but keep them in the DOM */
39
+ #km_recipe, #km_result, #km_lb, #km_go { position: absolute !important; width: 1px; height: 1px;
40
+ overflow: hidden; clip: rect(0 0 0 0); opacity: 0; pointer-events: none; }
41
+
42
+ #km {
43
+ --pad: clamp(16px, 4vw, 40px);
44
+ color: var(--text); background: var(--bg);
45
+ font: 15px/1.55 var(--sans); letter-spacing: -0.01em;
46
+ max-width: 1180px; margin: 0 auto; padding: 0 var(--pad) 64px;
47
+ -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
48
+ }
49
+ #km *, #km *::before, #km *::after { box-sizing: border-box; }
50
+ #km h1, #km h2, #km h3 { margin: 0; font-weight: 600; letter-spacing: -0.025em; }
51
+ #km p { margin: 0; }
52
+ #km code, #km .mono, #km .num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
53
+
54
+ /* ---------- top bar ---------- */
55
+ #km-top {
56
+ display: flex; align-items: center; justify-content: space-between; gap: 20px;
57
+ padding: 22px 0 18px; flex-wrap: wrap;
58
+ }
59
+ #km-brand { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
60
+ #km-brand .mark {
61
+ font-size: 19px; font-weight: 600; letter-spacing: -0.03em; color: var(--text);
62
+ display: inline-flex; align-items: center; gap: 9px;
63
+ }
64
+ #km-brand .dot {
65
+ width: 9px; height: 9px; border-radius: 50%; background: var(--accent);
66
+ box-shadow: 0 0 0 4px var(--accent-soft); flex: none;
67
+ }
68
+ #km-brand .sub { color: var(--faint); font-size: 13px; letter-spacing: -0.01em; }
69
+
70
+ /* segmented tab control (Apple style) */
71
+ #km-tabs {
72
+ display: inline-flex; gap: 2px; padding: 4px; border-radius: var(--r-pill);
73
+ background: var(--surface); border: 1px solid var(--line); position: relative;
74
+ }
75
+ .km-tab {
76
+ appearance: none; border: 0; background: transparent; color: var(--muted);
77
+ font: 500 13.5px/1 var(--sans); letter-spacing: -0.01em; cursor: pointer;
78
+ padding: 9px 16px; border-radius: var(--r-pill); position: relative; z-index: 1;
79
+ transition: color 0.25s var(--ease);
80
+ }
81
+ .km-tab:hover { color: var(--text); }
82
+ .km-tab.on { color: var(--text); }
83
+ #km-tab-pill {
84
+ position: absolute; top: 4px; left: 4px; height: calc(100% - 8px);
85
+ background: var(--surface-3); border: 1px solid var(--line-2); border-radius: var(--r-pill);
86
+ box-shadow: var(--shadow-sm); transition: transform 0.34s var(--ease), width 0.34s var(--ease);
87
+ z-index: 0;
88
+ }
89
+
90
+ /* ---------- page + layout ---------- */
91
+ .km-page[hidden] { display: none; }
92
+ .km-page { animation: km-fade 0.4s var(--ease); }
93
+ @keyframes km-fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
94
+ #km-grid { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 18px; }
95
+ @media (max-width: 880px) { #km-grid { grid-template-columns: 1fr; } }
96
+
97
+ .km-card {
98
+ background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
99
+ padding: 22px; box-shadow: var(--shadow-sm);
100
+ }
101
+ .km-eyebrow { font-size: 12px; font-weight: 600; color: var(--faint); letter-spacing: 0.02em;
102
+ margin-bottom: 14px; }
103
+ .km-h { font-size: 21px; font-weight: 600; letter-spacing: -0.03em; margin-bottom: 6px; }
104
+ .km-lede { color: var(--muted); font-size: 14px; max-width: 64ch; }
105
+
106
+ /* ---------- intro / hero strip ---------- */
107
+ #km-hero { padding: 8px 0 26px; max-width: 70ch; }
108
+ #km-hero h1 { font-size: clamp(28px, 5vw, 42px); font-weight: 600; letter-spacing: -0.035em; line-height: 1.05; }
109
+ #km-hero h1 .g { color: var(--accent); }
110
+ #km-hero p { color: var(--muted); font-size: clamp(15px, 2vw, 17px); margin-top: 14px; max-width: 60ch; }
111
+
112
+ /* ---------- segmented (compose/classics, model) ---------- */
113
+ .km-seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2);
114
+ border: 1px solid var(--line); border-radius: var(--r-sm); }
115
+ .km-seg button {
116
+ appearance: none; border: 0; background: transparent; color: var(--muted);
117
+ font: 500 13px/1 var(--sans); cursor: pointer; padding: 8px 13px; border-radius: 7px;
118
+ transition: background 0.2s var(--ease), color 0.2s var(--ease);
119
+ }
120
+ .km-seg button.on { background: var(--surface-3); color: var(--text); box-shadow: var(--shadow-sm); }
121
+
122
+ /* ---------- the pipeline composer ---------- */
123
+ .km-section-label { font-size: 12.5px; font-weight: 600; color: var(--faint); margin: 22px 0 10px; }
124
+ .km-section-label:first-child { margin-top: 4px; }
125
+ #km-pipe { display: flex; flex-direction: column; gap: 0; }
126
+ .km-stage {
127
+ display: flex; align-items: center; gap: 12px; padding: 13px 15px;
128
+ background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm);
129
+ transition: border-color 0.2s var(--ease), background 0.2s var(--ease);
130
+ }
131
+ .km-stage + .km-stage { margin-top: 8px; }
132
+ .km-stage .km-stage-k { font-size: 11px; color: var(--faint); width: 64px; flex: none; font-weight: 600; }
133
+ .km-stage.fixed { background: transparent; border-style: dashed; }
134
+ .km-stage .km-pick {
135
+ flex: 1; display: flex; gap: 6px; flex-wrap: wrap;
136
+ }
137
+ .km-opt {
138
+ appearance: none; border: 1px solid var(--line); background: var(--surface-3); color: var(--muted);
139
+ font: 500 13px/1 var(--sans); cursor: pointer; padding: 8px 12px; border-radius: var(--r-pill);
140
+ transition: all 0.18s var(--ease); white-space: nowrap;
141
+ }
142
+ .km-opt:hover { color: var(--text); border-color: var(--line-2); transform: translateY(-1px); }
143
+ .km-opt.on { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }
144
+ .km-opt.off { opacity: 0.5; }
145
+ .km-flow { color: var(--faint); text-align: center; font-size: 13px; line-height: 1; margin: 6px 0; }
146
+ .km-toggle {
147
+ display: inline-flex; align-items: center; gap: 9px; cursor: pointer; user-select: none;
148
+ font-size: 13px; color: var(--muted);
149
+ }
150
+ .km-switch { width: 38px; height: 22px; border-radius: var(--r-pill); background: var(--surface-3);
151
+ border: 1px solid var(--line-2); position: relative; transition: background 0.24s var(--ease); flex: none; }
152
+ .km-switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px;
153
+ border-radius: 50%; background: #c9ced6; transition: transform 0.24s var(--ease); }
154
+ .km-toggle input { position: absolute; opacity: 0; }
155
+ .km-toggle input:checked + .km-switch { background: var(--accent-deep); border-color: transparent; }
156
+ .km-toggle input:checked + .km-switch::after { transform: translateX(16px); background: #fff; }
157
+
158
+ /* info / knowledge line */
159
+ #km-info, #km-xinfo { margin-top: 16px; padding: 13px 15px; border-radius: var(--r-sm);
160
+ background: var(--surface-2); border: 1px solid var(--line); color: var(--muted);
161
+ font-size: 13px; line-height: 1.5; min-height: 44px; }
162
+
163
+ /* parameters */
164
+ .km-params { margin-top: 18px; display: grid; gap: 14px; }
165
+ .km-field { display: flex; flex-direction: column; gap: 7px; }
166
+ .km-field > label { font-size: 12.5px; color: var(--faint); font-weight: 600; display: flex;
167
+ justify-content: space-between; align-items: center; }
168
+ .km-field > label b { color: var(--text); font-family: var(--mono); font-size: 12.5px; }
169
+ .km-input, .km-textarea {
170
+ appearance: none; width: 100%; background: var(--surface-2); border: 1px solid var(--line);
171
+ border-radius: var(--r-sm); color: var(--text); font: 14px/1.5 var(--sans); padding: 11px 13px;
172
+ transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
173
+ }
174
+ .km-textarea { font-family: var(--mono); font-size: 13px; resize: vertical; min-height: 96px; }
175
+ .km-input::placeholder, .km-textarea::placeholder { color: var(--faint); }
176
+ .km-input:focus, .km-textarea:focus { outline: none; border-color: var(--accent-line);
177
+ box-shadow: 0 0 0 3px var(--accent-soft); }
178
+ input[type=range].km-range { -webkit-appearance: none; appearance: none; width: 100%; height: 4px;
179
+ border-radius: 4px; background: var(--surface-3); outline: none; }
180
+ input[type=range].km-range::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px;
181
+ border-radius: 50%; background: var(--text); cursor: pointer; border: 0;
182
+ box-shadow: 0 1px 4px rgba(0,0,0,0.4); transition: transform 0.15s var(--ease); }
183
+ input[type=range].km-range::-webkit-slider-thumb:active { transform: scale(1.15); }
184
+ input[type=range].km-range::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%;
185
+ background: var(--text); cursor: pointer; border: 0; }
186
+
187
+ /* segmented stepper for attempts */
188
+ .km-stepper { display: inline-flex; gap: 2px; padding: 3px; background: var(--surface-2);
189
+ border: 1px solid var(--line); border-radius: var(--r-sm); }
190
+ .km-stepper button { appearance: none; border: 0; background: transparent; color: var(--muted);
191
+ font: 500 13px var(--mono); cursor: pointer; width: 30px; height: 30px; border-radius: 7px;
192
+ transition: all 0.16s var(--ease); }
193
+ .km-stepper button.on { background: var(--accent-soft); color: var(--accent); }
194
+ .km-stepper button:hover:not(.on) { color: var(--text); }
195
+
196
+ /* ---------- buttons ---------- */
197
+ .km-actions { display: flex; gap: 10px; margin-top: 22px; flex-wrap: wrap; }
198
+ .km-btn {
199
+ appearance: none; border: 1px solid var(--line-2); background: var(--surface-3); color: var(--text);
200
+ font: 600 14px/1 var(--sans); letter-spacing: -0.01em; cursor: pointer; padding: 13px 18px;
201
+ border-radius: var(--r-sm); transition: transform 0.16s var(--ease), background 0.2s var(--ease), border-color 0.2s var(--ease);
202
+ display: inline-flex; align-items: center; gap: 8px;
203
+ }
204
+ .km-btn:hover { border-color: var(--line-2); transform: translateY(-1px); }
205
+ .km-btn:active { transform: scale(0.985); }
206
+ .km-btn.primary {
207
+ background: linear-gradient(180deg, var(--accent), var(--accent-deep)); color: var(--accent-ink);
208
+ border-color: transparent; flex: 1; justify-content: center; min-width: 180px;
209
+ box-shadow: 0 1px 0 rgba(255,255,255,0.18) inset, 0 8px 24px rgba(16,185,129,0.22);
210
+ }
211
+ .km-btn.primary:hover { filter: brightness(1.04); }
212
+ .km-btn.ghost { background: transparent; }
213
+ .km-btn .ic { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.8; }
214
+
215
+ /* ---------- visualisation ---------- */
216
+ #km-viz { position: relative; background: var(--surface-2); border: 1px solid var(--line);
217
+ border-radius: var(--r-sm); height: 168px; overflow: hidden; margin-bottom: 14px; }
218
+ #km-svg { width: 100%; height: 100%; display: block; }
219
+ #km-stage-label { position: absolute; left: 14px; bottom: 12px; font-size: 12px; color: var(--muted);
220
+ font-family: var(--mono); letter-spacing: -0.01em; }
221
+
222
+ /* ---------- verdict / result ---------- */
223
+ #km-verdict .km-card, .km-result-card { padding: 20px; }
224
+ .km-card.ok { border-color: var(--accent-line); background:
225
+ radial-gradient(120% 130% at 0% 0%, rgba(52,224,161,0.07), transparent 60%), var(--surface); }
226
+ .km-card.err, .km-card.miss { border-color: rgba(255,122,122,0.28); }
227
+ .km-card.building, .km-card.replaying { border-color: var(--accent-line); }
228
+ .km-result-top { display: flex; align-items: flex-start; gap: 13px; margin-bottom: 4px; }
229
+ .km-verdict-icon { width: 34px; height: 34px; border-radius: 9px; flex: none; display: grid;
230
+ place-items: center; background: var(--accent-soft); color: var(--accent); font-size: 17px;
231
+ border: 1px solid var(--accent-line); }
232
+ .km-verdict-icon.bad { background: var(--danger-soft); color: var(--danger); border-color: rgba(255,122,122,0.28); }
233
+ .km-run-label { display: block; font-size: 11px; color: var(--faint); font-weight: 600;
234
+ letter-spacing: 0.02em; text-transform: uppercase; margin-bottom: 2px; }
235
+ .km-result-top b { font-size: 16px; font-weight: 600; letter-spacing: -0.02em; }
236
+ .km-result-top > div > span:last-child { display: block; color: var(--muted); font-size: 13px;
237
+ font-family: var(--mono); margin-top: 2px; }
238
+ .km-speed-hero { text-align: center; padding: 22px 0 16px; border: 1px solid var(--line);
239
+ border-radius: var(--r-sm); background: var(--surface-2); margin: 16px 0; }
240
+ .km-speed-hero big { display: block; font: 600 52px/1 var(--mono); letter-spacing: -0.04em;
241
+ font-variant-numeric: tabular-nums; color: var(--text); }
242
+ .km-speed-hero span { display: block; font-size: 11.5px; color: var(--faint); font-weight: 600;
243
+ letter-spacing: 0.04em; text-transform: uppercase; margin-top: 8px; }
244
+ .km-ref-summary { font-size: 13.5px; color: var(--muted); margin: 4px 0 10px; }
245
+ .km-ref-summary b { color: var(--text); font-family: var(--mono); }
246
+ .km-attempts { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 2px; }
247
+ .km-attempt { display: inline-flex; align-items: center; gap: 5px; font-size: 12px;
248
+ font-family: var(--mono); padding: 5px 10px; border-radius: var(--r-pill); border: 1px solid var(--line);
249
+ background: var(--surface-2); color: var(--muted); }
250
+ .km-attempt.ok { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }
251
+ .km-attempt.bad { color: var(--danger); border-color: rgba(255,122,122,0.24); background: var(--danger-soft); }
252
+ .km-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0 4px; }
253
+ .km-stats > div { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 13px;
254
+ background: var(--surface-2); text-align: center; }
255
+ .km-stats big { display: block; font: 600 26px/1 var(--mono); letter-spacing: -0.03em; color: var(--text);
256
+ font-variant-numeric: tabular-nums; }
257
+ .km-stats span { display: block; color: var(--faint); font-size: 11px; margin-top: 6px; }
258
+ .km-dim { color: var(--muted); font-size: 13px; line-height: 1.5; }
259
+ .km-rawerr { color: var(--faint); font-size: 12px; font-family: var(--mono); margin-top: 10px;
260
+ word-break: break-word; }
261
+ .km-pill-note { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 5px 11px;
262
+ border-radius: var(--r-pill); margin-bottom: 12px; letter-spacing: -0.01em; }
263
+ .km-pill-note.recorded { background: var(--surface-3); color: var(--muted); border: 1px solid var(--line); }
264
+ .km-pill-note.hit { background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent-line); }
265
+ .km-pill-note.miss { background: var(--danger-soft); color: var(--danger); border: 1px solid rgba(255,122,122,0.24); }
266
+ .km-crown { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 5px 11px; margin-bottom: 12px;
267
+ border-radius: var(--r-pill); background: rgba(241,196,122,0.12); color: var(--amber);
268
+ border: 1px solid rgba(241,196,122,0.28); margin-left: 8px; }
269
+ .km-board { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 5px 11px; margin-bottom: 12px;
270
+ border-radius: var(--r-pill); background: var(--accent-soft); color: var(--accent);
271
+ border: 1px solid var(--accent-line); margin-left: 8px; }
272
+
273
+ /* build progress */
274
+ .km-build-steps { display: grid; gap: 6px; margin: 14px 0; }
275
+ .km-build-steps span { font-family: var(--mono); font-size: 12px; color: var(--faint);
276
+ padding: 8px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2);
277
+ transition: all 0.25s var(--ease); }
278
+ .km-build-steps span.on { color: var(--text); border-color: var(--accent-line); background: var(--accent-soft); }
279
+ .km-build-steps span.done { color: var(--accent); }
280
+ .km-bar { height: 5px; border-radius: 4px; background: var(--surface-3); overflow: hidden; margin: 13px 0; }
281
+ .km-bar i { display: block; height: 100%; width: 6%; border-radius: 4px;
282
+ background: linear-gradient(90deg, var(--accent-deep), var(--accent)); transition: width 0.5s var(--ease); }
283
+ .km-bstage { font-size: 14px; font-weight: 600; }
284
+ .km-replay-stage { font-size: 13px; color: var(--text); font-weight: 600; margin: 8px 0 4px; }
285
+
286
+ /* kernel source */
287
+ .km-source { margin-top: 14px; border: 1px solid var(--line); border-radius: var(--r-sm);
288
+ background: #08090b; overflow: hidden; }
289
+ .km-source summary { cursor: pointer; padding: 12px 15px; font-size: 13px; font-weight: 600;
290
+ color: var(--text); list-style: none; display: flex; justify-content: space-between; align-items: center; }
291
+ .km-source summary::-webkit-details-marker { display: none; }
292
+ .km-source summary::after { content: "+"; color: var(--accent); font-family: var(--mono); }
293
+ .km-source[open] summary::after { content: "\2212"; }
294
+ #km-code, .km-code { margin: 0; border-top: 1px solid var(--line); padding: 14px; color: #b9e6d3;
295
+ font: 12px/1.6 var(--mono); overflow: auto; max-height: 320px; white-space: pre; }
296
+
297
+ /* history */
298
+ #km-hist .km-hrow { border: 1px solid var(--line); border-radius: 9px; padding: 9px 12px;
299
+ background: var(--surface-2); font-size: 13px; margin-bottom: 6px; color: var(--muted);
300
+ display: flex; justify-content: space-between; }
301
+ #km-hist code { color: var(--text); }
302
+
303
+ /* recorded replay callout */
304
+ .km-replay-callout { display: flex; align-items: center; justify-content: space-between; gap: 14px;
305
+ margin-top: 14px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--r-sm);
306
+ background: var(--surface-2); }
307
+ .km-replay-callout b { font-size: 13.5px; font-weight: 600; display: block; margin-bottom: 2px; }
308
+ .km-replay-callout span { color: var(--muted); font-size: 12.5px; }
309
+ .km-replay-picks { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
310
+ .km-rpick { appearance: none; border: 1px solid var(--line); background: var(--surface-2); color: var(--muted);
311
+ font: 500 12.5px var(--sans); cursor: pointer; padding: 8px 12px; border-radius: var(--r-pill);
312
+ transition: all 0.18s var(--ease); }
313
+ .km-rpick:hover { color: var(--text); border-color: var(--line-2); }
314
+ .km-rpick.on { border-color: var(--accent-line); color: var(--accent); background: var(--accent-soft); }
315
+ .km-rpick span { font-family: var(--mono); color: var(--accent); margin-left: 5px; }
316
+ .km-inline-replay { appearance: none; margin-top: 12px; background: var(--surface-3); border: 1px solid var(--line-2);
317
+ color: var(--text); font: 500 13px var(--sans); cursor: pointer; padding: 9px 14px; border-radius: var(--r-sm);
318
+ transition: all 0.18s var(--ease); }
319
+ .km-inline-replay:hover { border-color: var(--accent-line); color: var(--accent); }
320
+
321
+ /* ---------- expert mode ---------- */
322
+ .km-expert-grid { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,0.9fr); gap: 18px; }
323
+ @media (max-width: 880px) { .km-expert-grid { grid-template-columns: 1fr; } }
324
+ .km-resolved { margin-top: 14px; padding: 13px 15px; border: 1px solid var(--line); border-radius: var(--r-sm);
325
+ background: var(--surface-2); font-size: 13px; }
326
+ .km-resolved .k { color: var(--faint); font-size: 11.5px; font-weight: 600; text-transform: uppercase;
327
+ letter-spacing: 0.03em; }
328
+ .km-resolved .v { color: var(--accent); font-family: var(--mono); font-size: 14px; margin-top: 4px; }
329
+ .km-resolved.unknown .v { color: var(--amber); }
330
+ .km-limits { font-size: 12.5px; color: var(--muted); line-height: 1.6; }
331
+ .km-limits b { color: var(--text); }
332
+ .km-oplist { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
333
+ .km-optag { font: 500 11.5px var(--mono); padding: 5px 9px; border-radius: 7px; background: var(--surface-2);
334
+ border: 1px solid var(--line); color: var(--muted); cursor: pointer; transition: all 0.16s var(--ease); }
335
+ .km-optag:hover { color: var(--accent); border-color: var(--accent-line); }
336
+
337
+ /* ---------- leaderboard ---------- */
338
+ .km-lbt { width: 100%; border-collapse: collapse; font-size: 13.5px; }
339
+ .km-lbt th { text-align: left; color: var(--faint); font-weight: 600; font-size: 11.5px;
340
+ text-transform: uppercase; letter-spacing: 0.04em; padding: 0 12px 12px; }
341
+ .km-lbt th:nth-child(4), .km-lbt td:nth-child(4), .km-lbt th:nth-child(5), .km-lbt td:nth-child(5) { text-align: right; }
342
+ .km-lbt td { padding: 12px; border-top: 1px solid var(--line); }
343
+ .km-lbt tbody tr { transition: background 0.15s var(--ease); }
344
+ .km-lbt tbody tr:hover { background: var(--surface-2); }
345
+ .km-lbt tr.champ td { background: rgba(241,196,122,0.05); }
346
+ .km-lbt code { color: var(--text); font-size: 12.5px; }
347
+ .km-lbt .hot { color: var(--accent); font-family: var(--mono); font-weight: 600; font-variant-numeric: tabular-nums; }
348
+ .km-lbt td:nth-child(5) { color: var(--muted); font-family: var(--mono); font-variant-numeric: tabular-nums; }
349
+ .km-rank { color: var(--faint); font-family: var(--mono); }
350
+
351
+ /* ---------- docs ---------- */
352
+ .km-docs { max-width: 760px; }
353
+ .km-docs h2 { font-size: 22px; margin: 34px 0 10px; letter-spacing: -0.03em; }
354
+ .km-docs h2:first-child { margin-top: 0; }
355
+ .km-docs p { color: var(--muted); font-size: 15px; line-height: 1.65; margin: 0 0 12px; max-width: 68ch; }
356
+ .km-docs b { color: var(--text); font-weight: 600; }
357
+ .km-docs ol, .km-docs ul { color: var(--muted); font-size: 15px; line-height: 1.65; padding-left: 20px; margin: 0 0 14px; }
358
+ .km-docs li { margin-bottom: 7px; }
359
+ .km-codeblock { background: #08090b; border: 1px solid var(--line); border-radius: var(--r-sm);
360
+ padding: 15px 16px; font: 12.5px/1.7 var(--mono); color: #b9e6d3; overflow: auto; margin: 0 0 16px;
361
+ white-space: pre; position: relative; }
362
+ .km-copy { position: absolute; top: 9px; right: 9px; appearance: none; border: 1px solid var(--line-2);
363
+ background: var(--surface-3); color: var(--muted); font: 500 11px var(--sans); cursor: pointer;
364
+ padding: 5px 9px; border-radius: 7px; transition: all 0.16s var(--ease); }
365
+ .km-copy:hover { color: var(--accent); border-color: var(--accent-line); }
366
+ .km-gloss { display: grid; grid-template-columns: 130px 1fr; gap: 10px; padding: 11px 0; border-top: 1px solid var(--line); }
367
+ .km-gloss b { color: var(--text); font-size: 13.5px; font-weight: 600; }
368
+ .km-gloss span { color: var(--muted); font-size: 13.5px; line-height: 1.55; }
369
+ .km-callout { border: 1px solid var(--accent-line); background: var(--accent-soft); border-radius: var(--r-sm);
370
+ padding: 14px 16px; font-size: 13.5px; color: var(--text); margin: 0 0 16px; }
371
+
372
+ /* ---------- misc ---------- */
373
+ .km-mini { appearance: none; border: 1px solid var(--line); background: var(--surface-2); color: var(--muted);
374
+ font: 500 12.5px var(--sans); cursor: pointer; padding: 8px 13px; border-radius: var(--r-sm); margin-top: 14px;
375
+ transition: all 0.18s var(--ease); }
376
+ .km-mini:hover { color: var(--text); border-color: var(--line-2); }
377
+
378
+ @media (prefers-reduced-motion: reduce) {
379
+ #km *, #km *::before, #km *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
380
  }