GLOBALGRID2050 / EXPLORE CODE

Part of: Explore Code / Kuiper, cosmos and drawing engines / cosmic / tools/explore/repokuiper

Repokuiper Overlays and 1 more file

A JavaScript file in the explore folder of Cosmic that computes reach (`computeReach`), sets mode (`setMode`) and renders panel (`renderPanel`).

374 lines of JavaScript and CSS from cosmic, in 2 files. Topic: Kuiper, cosmos and drawing engines. Section 1131 of 2044.

Cut 2026-12-06T03:07:51+00:00. A copy for reading; the repository at the stated commit is the source.

In the State lines below, domain stage, users and canonical status are rule-based first approximations from code and path evidence (rules explore-agent-rules-v1), not observed facts: the rules.

In this section

  1. Repokuiper Overlays render · cosmic / tools/explore/repokuiper/repokuiper-overlays.js lines 1–329
  2. Repokuiper Speed render · cosmic / tools/explore/repokuiper/repokuiper-speed.css lines 1–45

Repokuiper Overlays

A JavaScript file in the explore folder of Cosmic that computes reach (`computeReach`), sets mode (`setMode`) and renders panel (`renderPanel`).

rendercosmic / tools/explore/repokuiper/repokuiper-overlays.js · lines 1–329 of 329 · Not reached from any entry point (candidate for review) · pattern setMode (shared by 7 files)

What it does
It draws its content. Defines 18 functions or classes, including reduce, computeReach, hasReach, modeList, load. Side effects: changes the web page (DOM).
What it achieves
It computes reach (`computeReach`), sets mode (`setMode`) and renders panel (`renderPanel`). `repokuiper-overlays.js` (K3, ALBEDO-47): intelligence overlays for a repository Kuiper. It responds to click events.
Why it matters
No other file in the estate was found to import it.
Application
cosmic · tools/explore/repokuiper · script
Uses
none found
Used by
none found
Produces
reduce, computeReach, hasReach, modeList, load, ramp, styler, legendFor, setMode, shortName, renderPanel, link
Defines here
reduce, computeReach, hasReach, modeList, load, ramp, styler, legendFor, setMode, shortName, renderPanel, link, add, countFrom, frameBox, SX, onScreen, start
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
cosmic@51bebf892d63a617408bc5e25b270b9f893e9c03 tools/explore/repokuiper/repokuiper-overlays.js:1-329 · blob dc6803530c701fe577d2b210a88f1668d412e47d · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: output · effects: dom · domain stage: unknown · users: none · canonical: unreached_review
// repokuiper-overlays.js (K3, ALBEDO-47): intelligence overlays for a repository Kuiper.
// Colour/size modes from the estate's own data, each with a legend and the key of its source (Kuiper's first law:
// no claim without a key). The manifest <page>.overlays.json lists the modes the build could line up with this cut;
// each mode's column <page>.ov-<mode>.json is fetched the first time that mode is chosen. A mode whose data is
// missing is not offered. "Entry points and reach" needs no extra data: it uses the page's own flags and edges.
// Positions are never touched or stored here; the core computes them from the ordinal law.
(() => {
'use strict';
if (!window.KUIPER || !window.KUIPER.use) return;
window.KUIPER.use('overlays', (K) => {
  const esc = K.esc, fmt = K.fmt;
  const DIM = '#2f343d', ROLE = 'role';
  const reduce = () => K.reducedMotion || matchMedia('(prefers-reduced-motion: reduce)').matches;
  let man = null;                 // manifest {modes:{name:{title,state,legend,key,file,size}}}
  const data = {};                // name -> loaded mode object (or inline)
  let mode = ROLE, only = -1;     // only: legend row isolated (-1 = all)
  let reach = null;               // computed on first use: {n:Int32Array(per body entries reaching), pairs:Int32Array}
  let panel = null, btn = null, pulse0 = 0;

  // ------------------------------------------------------------ reach (from the page's own data)
  function computeReach() {
    if (reach) return reach;
    const NB = K.NB, out = K.arr.bout, ent = K.arr.bentry;
    const n = new Int32Array(NB), seen = new Int32Array(NB).fill(-1), pairs = [];
    const CAP = 6000;
    for (let e = 0; e < NB; e++) {
      if (!ent[e]) continue;
      const q = [e]; seen[e] = e;
      for (let h = 0; h < q.length; h++) {
        const a = q[h], o = out[a];
        for (let j = 0; j < o.length; j++) {
          const b = o[j];
          if (seen[b] === e) continue;
          seen[b] = e; n[b]++; q.push(b);
          if (pairs.length < CAP * 2) pairs.push(e, b);
        }
      }
    }
    let mx = 1; for (let i = 0; i < NB; i++) if (n[i] > mx) mx = n[i];
    reach = { n, pairs: Int32Array.from(pairs), max: mx };
    return reach;
  }
  const hasReach = () => !K.isIndex && K.D.edges && K.D.edges.length && K.D.files.some((f) => f[5] & 2);

  // ------------------------------------------------------------ modes
  function modeList() {
    const L = [[ROLE, 'Role (default)']];
    if (hasReach()) L.push(['reach', 'Entry points and reach']);
    const m = (man && man.modes) || {};
    for (const k of ['community', 'drift', 'clarity', 'identity', 'words', 'element', 'importance', 'faraday']) {
      if (m[k] && (k !== 'faraday' || !K.isIndex)) L.push([k, m[k].title]);
    }
    return L;
  }
  function load(name) {
    if (data[name] || name === ROLE || name === 'reach') return Promise.resolve(data[name] || null);
    const m = man.modes[name];
    if (name === 'faraday' || man.inline) { data[name] = m; return Promise.resolve(m); }
    return K.loadJSON(m.file).then((d) => {
      if (d && Array.isArray(d.v) && d.v.length === K.NB) data[name] = d;
      return data[name] || null;
    });
  }
  const ramp = (x) => {          // 0..1 -> #2f343d .. #00ffff through #66ccff (site palette only), 7 steps (few batches)
    x = Math.round(Math.max(0, Math.min(1, x)) * 6) / 6;
    const a = [0x2f, 0x34, 0x3d], b = [0x66, 0xcc, 0xff], c = [0x00, 0xff, 0xff];
    const [p, q, k] = x < 0.5 ? [a, b, x * 2] : [b, c, (x - 0.5) * 2];
    return '#' + p.map((v, i) => Math.round(v + (q[i] - v) * k).toString(16).padStart(2, '0')).join('');
  };
  function styler(name) {
    const d = data[name];
    const off = { col: DIM, alpha: 0.35 };
    if (name === 'reach') {
      const R = computeReach(), ent = K.arr.bentry;
      return (i) => {
        if (ent[i]) return (only < 0 || only === 0) ? { col: '#ffffff', scale: 1.5 } : off;
        const k = R.n[i] ? 1 : 2;
        if (only >= 0 && only !== k) return off;
        return R.n[i] ? { col: ramp(0.35 + 0.65 * R.n[i] / R.max) } : off;
      };
    }
    if (name === 'faraday') return (i) => (K.arr.bin[i].length ? { col: '#66ccff', scale: 1 + Math.min(1, K.arr.bin[i].length / 8) } : off);
    if (!d) return null;
    if (d.size) return (i) => (d.v[i] >= 0 ? { scale: 0.45 + 1.6 * d.v[i] / 1000, alpha: 0.4 + 0.6 * d.v[i] / 1000 } : { scale: 0.45, alpha: 0.3 });
    if (d.pct) return (i) => (d.v[i] >= 0 ? { col: ramp(d.v[i] / 100) } : off);
    const row = name === 'element' ? (i) => (d.v[i] >= 0 ? d.el_row[d.v[i]] : -1) : (i) => d.v[i];
    return (i) => {
      const r = row(i);
      if (r < 0 || r == null || (only >= 0 && r !== only)) return off;
      const L = d.legend[r];
      return L ? { col: L[1] } : off;
    };
  }
  function legendFor(name) {
    if (name === ROLE) return '';
    let rows, title, key, state;
    if (name === 'reach') {
      const R = computeReach();
      let reached = 0; for (let i = 0; i < K.NB; i++) if (R.n[i]) reached++;
      const ents = K.D.files.filter((f) => f[5] & 2).length;
      rows = [['entry point', '#ffffff', ents], ['reached (brighter = from more entries)', '#66ccff', reached],
        ['not reached through edges inside this repository', DIM, K.NB - reached - ents]];
      title = 'Entry points and reach'; state = 'rays: entry to every file it reaches through resolved edges';
      key = { source: 'this page: flags and edges', cut: K.D.cut };
    } else if (name === 'faraday') {
      const f = man.modes.faraday;
      title = f.title; state = f.state; key = f.key;
      rows = [['used by others: pulses its users when selected', '#66ccff', ''],
        ['measured: users changed with the used file in ' + Math.round(f.p * 100) + '% of ' + fmt(f.n) + ' cases', '#00ffff', '']];
    } else {
      const d = data[name] || man.modes[name];
      rows = d.legend; title = d.title; key = d.key; state = d.state;
    }
    const sized = (data[name] || {}).size;
    const lis = rows.map((r, k) => {
      const n = r[2] === '' || r[2] == null ? '' : ' <span class="ov-n">' + fmt(r[2]) + '</span>';
      const hub = r[3] >= 0 ? ' <a class="ov-hub" data-ovsel="' + r[3] + '" href="#">hub</a>' : '';
      const cls = only === k ? ' class="ov-on"' : (only >= 0 ? ' class="ov-off"' : '');
      return '<li' + cls + '><button type="button" data-ovcat="' + k + '"' + (sized ? ' disabled' : '') + '><i style="background:' +
        esc(r[1]) + '"></i>' + esc(r[0]) + n + '</button>' + hub + '</li>';
    }).join('');
    return '<div class="ov-leg"><b>' + esc(title) + '</b>' + (state ? ' <span class="ov-state">' + esc(state) + '</span>' : '') +
      '<ol>' + lis + '</ol><p class="ov-key">key: ' + esc(key.source) + (key.cut ? ' @ ' + esc(key.cut) : '') +
      (only >= 0 ? ' &middot; <a href="#" data-ovcat="-1">show all</a>' : '') + '</p></div>';
  }
  function setMode(name) {
    if (name !== ROLE && !modeList().some((m) => m[0] === name)) name = ROLE;
    return load(name).then(() => {
      if (name !== ROLE && name !== 'reach' && name !== 'faraday' && !data[name]) name = ROLE;  // data missing: hide
      if (mode !== name) only = -1;
      mode = name;
      const fn = name === ROLE ? null : styler(name);
      K.setStyler(fn ? 'ov-' + name : null, fn);
      K.legend(legendFor(name));
      if (btn) btn.textContent = name === ROLE ? 'colour' : 'colour: ' + shortName(name);
      renderPanel();
      K.emit('ov:mode', name);
      K.redraw();
    });
  }
  const shortName = (n) => ({ reach: 'reach', community: 'community', drift: 'drift', clarity: 'clarity', identity: 'identity',
    words: 'words', element: 'element', importance: 'size', faraday: 'faraday' }[n] || n);

  // ------------------------------------------------------------ panel (mode picker)
  function renderPanel() {
    if (!panel) return;
    panel.innerHTML = '<p class="ov-h">Colour and size by</p><ul class="ov-modes">' + modeList().map(([k, t]) =>
      '<li><button type="button" data-ovmode="' + k + '" aria-pressed="' + (k === mode) + '">' + esc(t) + '</button></li>').join('') +
      '</ul><p class="ov-note">Each mode is measured on this build cut; a mode without data for it is not offered.</p>';
  }
  document.addEventListener('click', (ev) => {
    const t = ev.target.closest('[data-ovmode],[data-ovcat],[data-ovsel]');
    if (!t) return;
    ev.preventDefault();
    if (t.dataset.ovmode) { setMode(t.dataset.ovmode); if (K.W < 760) { panel.hidden = true; K.setButtonOn('ov', false); } return; }
    if (t.dataset.ovsel) { K.select(+t.dataset.ovsel); return; }
    const c = +t.dataset.ovcat;
    only = (c < 0 || c === only) ? -1 : c;
    const fn = styler(mode);
    if (fn) K.setStyler('ov-' + mode, fn);
    K.legend(legendFor(mode)); K.redraw();
  });

  // ------------------------------------------------------------ card
  const link = (i) => '<a data-sel="' + i + '">' + esc(K.D.files[i][0]) + '</a>';
  K.addCardSection('overlays', (i) => {
    if (K.isIndex || i < 0) {
      if (K.isIndex && i >= 0 && man) {
        const b = [];
        for (const [k, m] of Object.entries(man.modes)) if (m.v && m.v[i] >= 0) b.push(esc(m.title) + ': <b>' + m.v[i] + '%</b>');
        return b.length ? '<div class="ov-card">' + b.join('<br>') + '</div>' : '';
      }
      return '';
    }
    const parts = [];
    const add = (name, html) => parts.push('<li' + (name === mode ? ' class="ov-cur"' : '') + '>' + html + '</li>');
    if (mode === 'reach' || reach) {
      const R = computeReach();
      add('reach', K.arr.bentry[i] ? 'Entry point: reaches <b>' + fmt(countFrom(i)) + '</b> files here' :
        'Reached from <b>' + fmt(R.n[i]) + '</b> entry point' + (R.n[i] === 1 ? '' : 's') + ' through edges inside this repository');
    }
    let d = data.community;
    if (d && d.v[i] >= 0) add('community', 'Community: <b>' + esc(d.legend[d.v[i]][0]) + '</b>' + (d.legend[d.v[i]][3] >= 0 && d.legend[d.v[i]][3] !== i ? ' (hub ' + link(d.legend[d.v[i]][3]) + ')' : ''));
    d = data.drift;
    if (d) {
      const near = [];
      for (const [a, b, s] of d.links) if (a === i || b === i) near.push(link(a === i ? b : a) + ' ' + Math.round(s / 10) + '%');
      const outs = d.outside.filter((x) => x[0] === i).map((x) => esc(x[1]) + ' &times;' + x[2]);
      if (d.v[i] >= 0 || near.length || outs.length) {
        add('drift', 'Near copies (CANDIDATE): ' + (d.v[i] >= 0 ? esc(d.legend[d.v[i]][0]) + '; ' : '') +
          (near.slice(0, 8).join(', ') || 'none here') + (outs.length ? '; in other repositories: ' + outs.slice(0, 4).join(', ') : '') +
          (d.safe.indexOf(i) >= 0 ? '; <b>safe to review</b>' : ''));
      }
    }
    d = data.clarity;
    if (d && d.v[i] >= 0) add('clarity', 'Clarity: <b>' + esc(d.legend[d.v[i]][0]) + '</b>');
    d = data.identity;
    if (d && d.v[i] >= 0) {
      const of = d.of.find((x) => x[0] === i);
      add('identity', 'Identity: <b>' + esc(d.legend[d.v[i]][0]) + '</b>' + (d.sim[i] ? ' (' + d.sim[i] + '% of lines)' : '') +
        (of ? ' &middot; of ' + (of[1] ? esc(of[1]) + ' file' : link(of[2])) : ''));
    }
    d = data.words;
    if (d && d.fw[i].length) {
      const fns = K.D.files[i][11] || [];
      add('words', 'VEDIC words (CANDIDATE): ' + d.fw[i].map((w) => {
        const [word, id] = d.dict[w], lw = word.toLowerCase();
        const hit = fns.filter((f) => f.toLowerCase().indexOf(lw) >= 0).slice(0, 3);
        return '<b>' + esc(word) + '</b>' + (id ? ' <span class="ov-id">' + esc(id) + '</span>' : '') +
          (hit.length ? ' in ' + hit.map((f) => '<code>' + esc(f) + '</code>').join(', ') : '');
      }).join('; ') + (d.ids_key ? '<br><span class="ov-key">ids: ' + esc(d.ids_key.source) + '</span>' : ''));
    }
    d = data.element;
    if (d && d.v[i] >= 0) {
      const e = d.els[d.v[i]];
      add('element', 'Element: <b>' + esc(e[0] || '?') + (e[1] ? ' ' + e[1] : '') + '</b> ' + esc(e[2]) +
        (e[4] && e[4] !== 'numbered' ? ' <span class="ov-state">' + esc(String(e[4]).toUpperCase()) + '</span>' : ''));
    }
    d = data.importance;
    if (d && d.v[i] >= 0) add('importance', 'Importance: <b>' + d.v[i] + '</b> / 1000');
    if (mode === 'faraday' && man.modes.faraday) {
      const u = K.arr.bin[i].length, f = man.modes.faraday;
      add('faraday', u ? 'Faraday pulse: <b>' + u + '</b> file' + (u === 1 ? '' : 's') + ' here use this one; in the estate, users changed with the used file in <b>' +
        Math.round(f.p * 100) + '%</b> of ' + fmt(f.n) + ' measured cases' : 'Faraday pulse: no file here uses this one');
    }
    if (!parts.length) return '';
    const keys = Object.keys(data).filter((k) => data[k].key).map((k) => esc(data[k].key.source)).join(', ');
    return '<div class="ov-card"><ul>' + parts.join('') + '</ul>' + (keys ? '<p class="ov-key">keys: ' + keys + ' @ ' + esc(man.cut || K.D.cut) + '</p>' : '') + '</div>';
  });
  function countFrom(e) { const P = computeReach().pairs; let c = 0; for (let k = 0; k < P.length; k += 2) if (P[k] === e) c++; return c; }

  // ------------------------------------------------------------ drawing (allocation-free per frame)
  const box = { x0: 0, y0: 0, s: 1, cx: 0, cy: 0 };
  function frameBox() {
    const v = K.view(), c = K.cam, a = K.arr;
    box.s = c.s; box.cx = v.cx; box.cy = v.cy;
    box.x0 = a.fx[K.follow] + c.x; box.y0 = a.fy[K.follow] + c.y;
  }
  const SX = (wx) => (wx - box.x0) * box.s + box.cx, SY = (wy) => (wy - box.y0) * box.s + box.cy;
  const onScreen = (x, y) => x > -40 && y > -40 && x < K.W + 40 && y < K.H + 40;

  K.addOverlay('ov-links', { z: 'under', draw(g) {
    if (K.isIndex || (mode !== 'reach' && mode !== 'drift')) return;
    const a = K.arr; frameBox();
    const sel = K.sel;
    if (mode === 'reach') {
      const P = computeReach().pairs;
      g.lineWidth = 1; g.strokeStyle = '#66ccff';
      g.globalAlpha = sel >= 0 ? 0.55 : 0.12;
      g.beginPath();
      let drawn = 0;
      for (let k = 0; k < P.length && drawn < (sel >= 0 ? 3000 : 1200); k += 2) {
        const e = P[k], b = P[k + 1];
        if (sel >= 0 && e !== sel && b !== sel) continue;
        const x1 = SX(a.bx[e]), y1 = SY(a.by[e]), x2 = SX(a.bx[b]), y2 = SY(a.by[b]);
        if (!onScreen(x1, y1) && !onScreen(x2, y2)) continue;
        g.moveTo(x1, y1); g.lineTo(x2, y2); drawn++;
      }
      g.stroke(); g.globalAlpha = 1;
      return;
    }
    const d = data.drift; if (!d) return;
    g.lineWidth = 1.2; g.strokeStyle = '#ffae00'; g.setLineDash && g.setLineDash([4, 4]);
    g.globalAlpha = 0.5; g.beginPath();
    for (const L of d.links) {
      const [p, q] = L;
      if (sel >= 0 && p !== sel && q !== sel) continue;
      if (only >= 0 && d.v[p] !== only) continue;
      const x1 = SX(a.bx[p]), y1 = SY(a.by[p]), x2 = SX(a.bx[q]), y2 = SY(a.by[q]);
      if (!onScreen(x1, y1) && !onScreen(x2, y2)) continue;
      g.moveTo(x1, y1); g.lineTo(x2, y2);
    }
    g.stroke(); g.setLineDash && g.setLineDash([]); g.globalAlpha = 1;
  } });

  K.addOverlay('ov-marks', { z: 'over', draw(g) {
    if (K.isIndex) return;
    const sel = K.sel, a = K.arr;
    if (sel < 0) return;
    frameBox();
    if (mode === 'faraday') {
      const users = a.bin[sel]; if (!users.length) return;
      const ph = reduce() ? 0.5 : ((performance.now() - pulse0) % 1600) / 1600;
      g.strokeStyle = '#00ffff'; g.lineWidth = 1.5;
      g.globalAlpha = reduce() ? 0.8 : 1 - ph;
      g.beginPath();
      for (let j = 0; j < users.length; j++) {
        const u = users[j], x = SX(a.bx[u]), y = SY(a.by[u]);
        if (!onScreen(x, y)) continue;
        const r = Math.max(4, a.brw[u] * box.s) * (1.4 + 2.2 * ph);
        g.moveTo(x + r, y); g.arc(x, y, r, 0, Math.PI * 2);
      }
      g.stroke(); g.globalAlpha = 1;
    } else if (mode === 'words' && data.words && data.words.fw[sel].length) {
      const d = data.words, x = SX(a.bx[sel]), y = SY(a.by[sel]);
      if (!onScreen(x, y)) return;
      const r = Math.max(8, a.brw[sel] * box.s) + 14;
      g.font = '12px system-ui, sans-serif'; g.fillStyle = '#00ffff'; g.textAlign = 'center';
      const w = d.fw[sel];
      for (let k = 0; k < w.length; k++) {
        const ang = -Math.PI / 2 + (k - (w.length - 1) / 2) * 0.7;
        g.fillText(d.dict[w[k]][0], x + r * 1.6 * Math.cos(ang), y + r * 1.6 * Math.sin(ang));
      }
      g.textAlign = 'start';
    }
  } });

  K.onFrame(() => mode === 'faraday' && K.sel >= 0 && !reduce());
  K.on('select', () => { pulse0 = performance.now(); });

  // ------------------------------------------------------------ start
  function start(m) {
    man = m && m.modes ? m : { modes: {} };
    if (man.inline) for (const k in man.modes) data[k] = man.modes[k];
    if (modeList().length < 2) return;            // nothing to offer: no button, no legend
    panel = K.panel('ov');
    btn = K.addButton({ id: 'ov', label: 'colour', title: 'colour and size modes (c)', key: 'c', toggle: true,
      onClick(on) { panel.hidden = !on; if (on) renderPanel(); } });
    K.addKey('m', () => {                          // m: next mode
      const L = modeList(), k = L.findIndex((x) => x[0] === mode);
      setMode(L[(k + 1) % L.length][0]); return true;
    });
    K.addKey('Escape', () => { if (panel && !panel.hidden) { panel.hidden = true; K.setButtonOn('ov', false); return true; } return false; });
    const want = (location.hash.match(/[#&]mode=([\w-]+)/) || [])[1];
    if (want) setMode(want);
  }
  K.loadJSON('overlays').then(start, () => start(null));
});
})();

Repokuiper Speed

A style sheet in the explore folder of Cosmic.

rendercosmic / tools/explore/repokuiper/repokuiper-speed.css · lines 1–45 of 45 · Not reached from any entry point (candidate for review)

What it does
Side effects: changes the web page (DOM).
What it achieves
`repokuiper-speed.css` (K5, TACHYON-29): command palette, "what uses this" trail, speed HUD, toast, card buttons.
Why it matters
No other file in the estate was found to import it.
Application
cosmic · tools/explore/repokuiper · style sheet
Uses
none found
Used by
none found
Produces
none declared
Defines here
none
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
cosmic@51bebf892d63a617408bc5e25b270b9f893e9c03 tools/explore/repokuiper/repokuiper-speed.css:1-45 · blob b9f5f1c16122f11470eb3a33be7c50bd0a0aa554 · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: output · effects: dom · domain stage: unknown · users: none · canonical: unreached_review
/* repokuiper-speed.css (K5, TACHYON-29): command palette, "what uses this" trail, speed HUD, toast, card buttons.
   Scoped to #kp-speed*, .sp-*. Palette: #000 #0b0e14 #2f343d #fff #a6adbb #66ccff #00ffff. 390px first, 44px taps. */
#kp-speed,#kp-speed-uses{left:8px;right:8px;max-width:560px;max-height:min(72vh,560px);max-height:min(72dvh,560px);display:flex;
  flex-direction:column;background:#0b0e14;border:1px solid #00ffff;border-radius:4px;padding:8px;z-index:25;overflow:hidden;
  box-sizing:border-box}
#kp-speed[hidden],#kp-speed-uses[hidden],#kp-speed-hud[hidden],#kp-speed-toast[hidden]{display:none}
.sp-row{display:flex;align-items:center;gap:6px;min-width:0}
.sp-q{flex:1;min-width:0;font:inherit;font-size:16px;background:#000;color:#fff;border:1px solid #66ccff;border-radius:3px;
  padding:8px;min-height:44px;box-sizing:border-box}
.sp-q:focus{outline:2px solid #00ffff;outline-offset:1px}
.sp-btn{font:inherit;font-size:13px;color:#fff;background:#000;border:1px solid #2f343d;border-radius:3px;min-width:44px;
  min-height:44px;padding:0 10px;cursor:pointer;display:inline-flex;align-items:center;justify-content:center}
.sp-btn:hover,.sp-btn:focus-visible{border-color:#00ffff;color:#00ffff;outline:none}
.sp-title{flex:1;min-width:0;color:#00ffff;font-weight:normal;overflow-wrap:anywhere}
.sp-sub{color:#a6adbb;font-size:11px;min-width:0;overflow-wrap:anywhere}
.sp-status{margin:6px 2px 0}
.sp-trail{margin:4px 2px 0}
.sp-trail a{color:#00ffff;text-decoration:none;display:inline-block;padding:6px 0}
.sp-list{list-style:none;margin:6px 0 0;padding:0;overflow-y:auto;overflow-x:hidden;flex:1;-webkit-overflow-scrolling:touch}
.sp-list li{display:flex;flex-direction:column;justify-content:center;min-height:44px;padding:4px 6px;border-bottom:1px solid #2f343d;
  cursor:pointer;color:#fff;box-sizing:border-box}
.sp-list li.on,.sp-list li:hover{background:#2f343d}
.sp-list li.on .sp-main{color:#00ffff}
.sp-main{min-width:0;overflow-wrap:anywhere}
.sp-main em{color:#66ccff;font-style:normal;font-size:11px}
#kp-speed-hud{top:auto!important;left:auto;right:8px;bottom:calc(8px + env(safe-area-inset-bottom));max-width:calc(100vw - 16px);
  width:auto;padding:4px 8px;font-size:11px;color:#a6adbb;background:#000c;border:1px solid #2f343d;border-radius:3px;z-index:4;
  overflow:visible;max-height:none}
#kp-speed-hud b{color:#00ffff;font-weight:normal}
#kp-speed-hud a{color:#66ccff;display:inline-block;padding:2px 0}
#kp-speed-toast{top:auto!important;left:50%;right:auto;transform:translateX(-50%);bottom:calc(52px + env(safe-area-inset-bottom));
  max-width:calc(100vw - 32px);background:#0b0e14;border:1px solid #00ffff;color:#fff;border-radius:4px;padding:10px 12px;z-index:30;
  font-size:12px;overflow-wrap:anywhere;pointer-events:none}
.sp-card{display:flex;flex-wrap:wrap;gap:6px;margin-top:6px}
.sp-cardhud{margin-top:4px}
.sp-cardhud b{color:#00ffff;font-weight:normal}
.sp-clip{position:fixed;left:-9999px;top:0;opacity:0}
/* tablet/laptop: palette centred near the top; the trail on the left, clear of the right-hand card */
@media (min-width:760px){
  #kp-speed{left:50%;right:auto;transform:translateX(-50%);width:560px}
  #kp-speed-uses{right:auto;width:420px;max-height:min(60vh,520px)}
  #card:not([hidden]) ~ #kp-speed-hud{right:404px}
  .sp-sub{font-size:12px}
}
@media (prefers-reduced-motion:reduce){.sp-list{scroll-behavior:auto}}