GLOBALGRID2050 / EXPLORE CODE

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

Test Visualise and 1 more file

A test in the explore folder of Cosmic that checks Visualise and Wafer, using haversine and SHA-256. It sets up (`setUp`), runs vis (`run_vis`) and writes JSON (`write_json`).

646 lines of Python and CSS from cosmic, in 2 files. Topic: Kuiper, cosmos and drawing engines. Section 1141 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. Test Visualise test · cosmic / tools/explore/test_visualise.py lines 1–442
  2. Ide render · cosmic / tools/explore/theme/ide.css lines 1–204

Test Visualise

A test in the explore folder of Cosmic that checks Visualise and Wafer, using haversine and SHA-256. It sets up (`setUp`), runs vis (`run_vis`) and writes JSON (`write_json`).

testcosmic / tools/explore/test_visualise.py · lines 1–442 of 442 · Entry point · pattern tiny_graph (shared by 5 files)

What it does
It tests its inputs. Defines 26 functions or classes, including tiny_graph, VisualiseTest, setUp, tearDown, run_vis. Uses libraries contextlib, glob, io, json, math. Side effects: reads or writes files; starts processes; uses storage (browser storage, DuckDB or Parquet).
Why it exists in the grid workflow
Domain stage upstream_foresight (voltage levels 132kV (all 132kV or above)): upstream engineering foresight over GB transmission and distribution topology (TSO/DNO, 132kV and above, the REPD pipeline, data centres), which Ventus Ltd states it models for foresight. Domain terms in the code: 132kV.
Inputs & outputs
In: JSON file build_graph.json; JSON file graph.json; JSON file g2.json; Parquet file files.parquet; Parquet file sections.parquet; JSON file keys.json; JSON file communities.json; JSON file drift.json. Out: JSON file. Voltage levels named: 132kV.
Downstream impact
It is itself an entry point (test); no other file was found loading it.
What it achieves
Tests for `tools/explore/visualise.py` (unittest, no network). Its code works with 132 kV. It writes `lab/keys.json`.
Why it matters
Guards the behaviour of Visualise and Wafer.
Application
cosmic · tools/explore · test
Uses
Visualise (import), Wafer (sys.path import), contextlib, glob, io, json, math, os, re, shutil
Used by
none found
Produces
tiny_graph, VisualiseTest
Defines here
tiny_graph, VisualiseTest, setUp, tearDown, run_vis, test_outputs_exist_and_compact, test_coordinates_finite_and_in_bounds, test_stage_columns_respected, test_edges_resolved_and_bad_ids_dropped, test_deterministic, test_html_noscript_links_title_author_hosts, test_colour_modes_and_legend, test_fallback_palette_when_roles_absent, test_script_passes_node_check, test_pack_siblings_no_overlap, test_approx_role, test_parquet_adapter, write_json, lab_fixture, test_no_overlays_no_buttons, test_lab_overlays_by_key_and_lazy_files, test_id_overlays_need_same_cut, test_periodic_and_laws, test_faraday_pulse_from_laws_json, test_phone_page_features, test_wafer_hash_matches_lab_law
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/test_visualise.py:1-442 · blob 913d91bae248a1e9bc00fb324421a5eb720ea870 · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: output · effects: filesystem, process, storage · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: unknown
"""Tests for tools/explore/visualise.py (unittest, no network).

    python -m unittest tools/explore/test_visualise.py
"""
import contextlib
import glob
import io
import json
import math
import os
import re
import shutil
import subprocess
import sys
import tempfile
import unittest

HERE = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, HERE)
import visualise  # noqa: E402

CONTRACT_PALETTE = {
    'geodesy': '#00ffff', 'electrical': '#ffae00', 'energy-data': '#ffff00', 'ingest': '#66ccff',
    'transform': '#00ff88', 'render': '#ff6666', 'interaction': '#ffd24a', 'storage': '#86e1d1',
    'test': '#aef7d1', 'automation': '#8d95a3', 'docs-config': '#a6adbb', 'other': '#4c5a65',
}


def tiny_graph(with_roles=True):
    stages = ['ingest', 'transform', 'output', 'unknown', 'transform', 'output', 'ingest', 'transform']
    roles = ['ingest', 'geodesy', 'render', 'other', 'electrical', 'render', 'storage', 'transform']
    files = []
    for i in range(8):
        repo = 'alpha' if i < 5 else 'beta-repo'
        files.append({
            'id': i, 'repo': repo, 'path': ('src/' if i % 2 else 'lib/deep/') + 'file%d.js' % i,
            'folder_hierarchy': [repo, 'src'], 'lang': 'JavaScript', 'lines': 10 + 37 * i,
            'section': 1 + i // 3, 'block': 1 + i % 3, 'title': 'File %d <b>' % i,
            'achieves': 'Does thing %d' % i, 'why': 'Used by %d' % ((i + 1) % 8), 'context': '',
            'essay_status': 'auto', 'stage': stages[i], 'imports': [(i + 1) % 8] if i < 7 else [99, 7],
            'imports_external': ['numpy'], 'dependents': [(i - 1) % 8], 'defines': ['fn%d' % i, 'Shared'],
            'pure': i % 2 == 0, 'role': roles[i], 'pattern': 'distanceKm' if i in (1, 4, 6) else '',
            'entry': i == 0, 'reachable': i not in (3, 5),
        })
    g = {
        'schema': 'explore-build-graph-v1', 'cut': '2026-12-05T00:00:00+00:00',
        'base': 'https://example.invalid/explore-code/',
        'topics': [{'id': 'cables', 'title': 'Cables and conductors', 'sections': 2},
                   {'id': 'maps-gis', 'title': 'Maps', 'sections': 1}],
        'repos': [{'repo': 'alpha', 'commit': 'a' * 40, 'license': 'MIT', 'license_file': 'LICENSE',
                   'citation': False, 'readme_summary': ''},
                  {'repo': 'beta-repo', 'commit': 'b' * 40, 'license': 'none found', 'license_file': None,
                   'citation': False, 'readme_summary': ''}],
        'sections': [{'section': s, 'url': 's/%04d.html' % s, 'topic': 'cables', 'repos': ['alpha'], 'lines': 100,
                      'title': 'S%d' % s} for s in (1, 2, 3)],
        'files': files,
    }
    for i, f in enumerate(files):
        f['topic'] = 'cables' if i < 6 else 'maps-gis'
    if with_roles:
        g['roles'] = [{'id': k, 'title': k.title(), 'colour': c} for k, c in CONTRACT_PALETTE.items()]
    return g


class VisualiseTest(unittest.TestCase):
    def setUp(self):
        self.tmp = tempfile.mkdtemp()
        self.gpath = os.path.join(self.tmp, 'build_graph.json')
        with open(self.gpath, 'w') as fh:
            json.dump(tiny_graph(), fh)

    def tearDown(self):
        shutil.rmtree(self.tmp)

    def run_vis(self, out, graph=None):
        visualise.main(['--graph', graph or self.gpath, '--out', out])
        with open(os.path.join(out, 'graph.json'), encoding='utf-8') as fh:
            raw = fh.read()
        with open(os.path.join(out, 'index.html'), encoding='utf-8') as fh:
            page = fh.read()
        return raw, json.loads(raw), page

    def test_outputs_exist_and_compact(self):
        out = os.path.join(self.tmp, 'v')
        raw, v, _ = self.run_vis(out)
        for name in ('index.html', 'graph.json', 'README.md'):
            self.assertTrue(os.path.getsize(os.path.join(out, name)) > 0, name)
        self.assertNotIn('\n', raw)
        self.assertNotIn(': ', raw.replace('": "', ''))  # no pretty-print separators
        self.assertEqual(v['schema'], 'explore-visual-v1')
        self.assertEqual(len(v['n']['r']), 8)
        for k, col in v['n'].items():
            self.assertEqual(len(col), 8, k)

    def test_coordinates_finite_and_in_bounds(self):
        _, v, _ = self.run_vis(os.path.join(self.tmp, 'v'))
        n = v['n']
        for xs, ys, box in (('px', 'py', v['pipe']), ('mx', 'my', v['map'])):
            for x, y in zip(n[xs], n[ys]):
                self.assertTrue(math.isfinite(x) and math.isfinite(y))
                self.assertTrue(0 <= x <= box['W'] and 0 <= y <= box['H'], (xs, x, y, box['W'], box['H']))

    def test_stage_columns_respected(self):
        _, v, _ = self.run_vis(os.path.join(self.tmp, 'v'))
        cols = v['pipe']['cols']
        stages = [s[0] for s in v['stages']]
        self.assertEqual(stages, ['ingest', 'transform', 'output', 'unknown'])
        for i, s in enumerate(v['n']['s']):
            x0, x1 = cols[s][0], cols[s][1]
            self.assertTrue(x0 <= v['n']['px'][i] <= x1, (i, s))
        self.assertEqual([c[3] for c in cols], [2, 3, 2, 1])
        for a, b in zip(cols, cols[1:]):
            self.assertLess(a[1], b[0])

    def test_edges_resolved_and_bad_ids_dropped(self):
        _, v, _ = self.run_vis(os.path.join(self.tmp, 'v'))
        e = v['e']
        pairs = list(zip(e[::2], e[1::2]))
        self.assertIn((0, 1), pairs)
        self.assertTrue(all(0 <= a < 8 and 0 <= b < 8 and a != b for a, b in pairs))
        self.assertEqual(pairs, sorted(set(pairs)))

    def test_deterministic(self):
        a, b = os.path.join(self.tmp, 'a'), os.path.join(self.tmp, 'b')
        self.run_vis(a)
        self.run_vis(b)
        for name in ('index.html', 'graph.json', 'README.md'):
            with open(os.path.join(a, name), 'rb') as f1, open(os.path.join(b, name), 'rb') as f2:
                self.assertEqual(f1.read(), f2.read(), name)

    def test_html_noscript_links_title_author_hosts(self):
        _, _, page = self.run_vis(os.path.join(self.tmp, 'v'))
        self.assertIn('<title>Explore Code visualiser — GlobalGrid2050</title>', page)
        self.assertIn('<meta name="author" content="Ventus Ltd — GlobalGrid2050">', page)
        self.assertIn('<noscript>', page)
        self.assertIn('href="../repos/beta-repo.html"', page)
        self.assertIn('href="../topics/cables.html"', page)
        self.assertIn('href="../topics/maps-gis.html"', page)
        hosts = set(re.findall(r'(?:https?:)?//([a-z0-9.-]+\.[a-z]{2,})', page, re.I))
        self.assertTrue(hosts <= {'cdn.jsdelivr.net'}, hosts)
        self.assertNotIn('File 3 <b>', page)

    def test_colour_modes_and_legend(self):
        _, v, page = self.run_vis(os.path.join(self.tmp, 'v'))
        for m in ('role', 'topic', 'stage', 'pattern'):
            self.assertIn('<option value="%s">' % m, page)
        self.assertLess(page.index('<option value="role">'), page.index('<option value="topic">'))  # default
        self.assertEqual({r[0]: r[2] for r in v['roles']}, CONTRACT_PALETTE)
        self.assertIn('id="legend"', page)
        for colour in CONTRACT_PALETTE.values():
            self.assertIn('background:%s' % colour, page)  # static legend, also the filter targets
        roles = [v['roles'][o][0] for o in v['n']['o']]
        self.assertEqual(roles[:3], ['ingest', 'geodesy', 'render'])
        self.assertTrue(all(len(t) == 4 and re.match(r'#[0-9a-f]{6}$', t[3]) for t in v['topics']))
        self.assertTrue(all(re.match(r'#[0-9a-f]{6}$', s[2]) for s in v['stages']))
        # pattern: shared key gets one stable colour; unique files point at -1 (grey)
        self.assertEqual(v['pats'], [['distanceKm', visualise.pattern_colour('distanceKm'), 3]])
        self.assertEqual([i for i, p in enumerate(v['n']['p']) if p == 0], [1, 4, 6])
        self.assertEqual(v['n']['p'].count(-1), 5)
        self.assertEqual(visualise.pattern_colour('distanceKm'), visualise.pattern_colour('distanceKm'))
        self.assertNotEqual(visualise.pattern_colour('distanceKm'), visualise.pattern_colour('haversine'))
        for k in ('a', 'b', 'renderMap', 'index.html', 'x' * 40):  # every pattern hue is bright on black
            c = visualise.pattern_colour(k)
            r, g, b = (int(c[i:i + 2], 16) / 255 for i in (1, 3, 5))
            self.assertGreaterEqual(0.2126 * r + 0.7152 * g + 0.0722 * b, 0.42, c)
        # reachability tri-state: 1 true, 0 false, 2 unknown
        self.assertEqual(v['n']['en'][0], 1)
        self.assertEqual([i for i, r in enumerate(v['n']['re']) if r == 0], [3, 5])
        self.assertIn('candidates for review', page)
        self.assertNotRegex(page.lower(), r'>[^<]*\bdead\b')

    def test_fallback_palette_when_roles_absent(self):
        g = tiny_graph(with_roles=False)
        g['files'][2]['role'] = 'no-such-role'
        p = os.path.join(self.tmp, 'g2.json')
        with open(p, 'w') as fh:
            json.dump(g, fh)
        _, v, _ = self.run_vis(os.path.join(self.tmp, 'v2'), p)
        self.assertEqual({r[0]: r[2] for r in v['roles']}, CONTRACT_PALETTE)
        self.assertEqual(v['roles'][v['n']['o'][2]][0], 'other')

    def test_script_passes_node_check(self):
        node = shutil.which('node')
        if not node:
            self.skipTest('node not installed')
        _, _, page = self.run_vis(os.path.join(self.tmp, 'v'))
        scripts = re.findall(r'<script>(.*?)</script>', page, re.S)
        self.assertEqual(len(scripts), 1)
        js = os.path.join(self.tmp, 'app.js')
        with open(js, 'w', encoding='utf-8') as fh:
            fh.write(scripts[0])
        r = subprocess.run([node, '--check', js], capture_output=True, text=True)
        self.assertEqual(r.returncode, 0, r.stderr)

    def test_pack_siblings_no_overlap(self):
        circles = [[0.0, 0.0, float(r), i] for i, r in enumerate([30, 20, 20, 12, 9, 9, 5, 4, 3, 3, 2, 1])]
        R = visualise.pack_siblings(circles)
        for i, a in enumerate(circles):
            self.assertLessEqual(math.hypot(a[0], a[1]) + a[2], R + 1e-6)
            for b in circles[i + 1:]:
                self.assertGreaterEqual(math.hypot(a[0] - b[0], a[1] - b[1]), a[2] + b[2] - 1e-3)

    def test_approx_role(self):
        self.assertEqual(visualise.approx_role('tests/test_cable.py', ''), 'test')
        self.assertEqual(visualise.approx_role('.github/workflows/ci.yml', ''), 'automation')
        self.assertEqual(visualise.approx_role('src/haversine.js', ''), 'geodesy')
        self.assertEqual(visualise.approx_role('src/cable_derating.py', ''), 'electrical')
        self.assertEqual(visualise.approx_role('app/style.css', ''), 'render')
        self.assertEqual(visualise.approx_role('package.json', ''), 'docs-config')
        self.assertEqual(visualise.approx_role('x/qq.js', ''), 'other')

    def test_parquet_adapter(self):
        try:
            import pyarrow as pa
            import pyarrow.parquet as pq
        except ImportError:
            self.skipTest('pyarrow not installed')
        data = os.path.join(self.tmp, 'site', 'data')
        os.makedirs(data)
        os.makedirs(os.path.join(self.tmp, 'site', 's'))
        rows = [(1, 1, 'r1', 'src/a.js', 1, 100, 'cables', 'Load cable data.'),
                (1, 2, 'r1', 'src/b.js', 1, 50, 'cables', ''),
                (2, 1, 'r1', 'src/b.js', 51, 80, 'cables', ''),
                (2, 2, 'r2', 'tests/test_x.py', 1, 20, 'automation', '')]
        cols = list(zip(*rows))
        pq.write_table(pa.table({'section': list(cols[0]), 'block': list(cols[1]), 'repo': list(cols[2]),
                                 'commit_sha': ['c' * 40] * 4, 'path': list(cols[3]), 'blob_sha': ['d' * 40] * 4,
                                 'line_from': list(cols[4]), 'line_to': list(cols[5]), 'topic': list(cols[6]),
                                 'capability': list(cols[7])}), os.path.join(data, 'files.parquet'))
        pq.write_table(pa.table({'section': [1, 2], 'topic': ['cables', 'automation'], 'lines': [150, 50],
                                 'repos': [['r1'], ['r1', 'r2']], 'summary': ['s1', 's2'],
                                 'cut': ['2026-12-05T00:00:00+00:00'] * 2}), os.path.join(data, 'sections.parquet'))
        with open(os.path.join(self.tmp, 'site', 's', '0001.html'), 'w') as fh:
            fh.write('<section id="f1"><dl class="v"><dt>Uses</dt><dd><a href="../s/0001.html#f2">r1 / src/b.js</a>'
                     '</dd></dl></section>')
        g = visualise.graph_from_parquet(data)
        self.assertEqual([(f['repo'], f['path'], f['lines']) for f in g['files']],
                         [('r1', 'src/a.js', 100), ('r1', 'src/b.js', 80), ('r2', 'tests/test_x.py', 20)])
        self.assertEqual(g['files'][0]['imports'], [1])
        self.assertEqual(g['files'][1]['dependents'], [0])
        self.assertEqual(g['files'][2]['role'], 'test')
        self.assertTrue(all(f['stage'] == 'unknown' and f['entry'] is None and f['reachable'] is None
                            for f in g['files']))
        out = os.path.join(self.tmp, 'pv')
        visualise.main(['--from-parquet', data, '--out', out])
        self.assertTrue(os.path.isfile(os.path.join(out, 'index.html')))

    # ------------------------------------------------------------ generator 2.x: phone page + lazy overlays
    def write_json(self, name, obj):
        p = os.path.join(self.tmp, name)
        os.makedirs(os.path.dirname(p), exist_ok=True)
        with open(p, 'w') as fh:
            json.dump(obj, fh)
        return p

    def lab_fixture(self):
        """A lab dir whose ids are in a different order from the graph (reversed), matched by key."""
        g = tiny_graph()
        cut = '2026-01-01T00:00:00+00:00'  # another cut: only key matching can line it up
        order = list(reversed(range(8)))  # lab id k -> graph file order[k]
        keys = ['%s@%s:%s' % (g['files'][j]['repo'], 'c' * 12, g['files'][j]['path']) for j in order]
        keys.append('gone@c:removed.js')  # a file the graph no longer has
        comm = [0, 0, 1, 1, -1, 0, 1, 2, 0]  # by lab id
        d = os.path.join(self.tmp, 'lab')
        self.write_json('lab/keys.json', {'schema': 'explore-lab-keys-v1', 'cut': cut, 'k': keys})
        self.write_json('lab/communities.json', {
            'cut': cut, 'n': 9, 'rules': 'r', 'cols': {'c': comm},
            'legend': {'c': ['id', 'label', 'size', 'top_repo', 'top_repo_share', 'repos', 'hub_file'],
                       'rows': [[0, 'big one', 4, 'alpha', 1, 1, 0], [1, 'second', 3, 'alpha', 1, 1, 2],
                                [2, 'tiny', 1, 'alpha', 1, 1, 7]]}})
        self.write_json('lab/drift.json', {
            'cut': cut, 'n': 9, 'rules': 'r', 'cols': {'fam': [0, 0, -1, -1, -1, -1, -1, -1, 0], 'canon': []},
            'edges': [1, 0, 800, 8, 0, 650], 'legend': {}, 'safe_review': [1, 8]})
        self.write_json('lab/wafer.json', {
            'cut': cut, 'legend': {'dies': ['repo', 'repo_number', 'cx', 'cy', 'radius'],
                                   'rows': [['beta-repo', 4, 0, 0, 0.14]]}, 'cols': {}})
        return d, order

    def test_no_overlays_no_buttons(self):
        raw, v, page = self.run_vis(os.path.join(self.tmp, 'v'))
        self.assertEqual(v['gen'], visualise.GENERATOR_VERSION)
        self.assertEqual(v['ov'], {})
        self.assertEqual(glob.glob(os.path.join(self.tmp, 'v', 'ov-*.json')), [])
        for absent in ('data-view="wafer"', 'id="tdrift"', 'id="tsafe"', 'value="community"', 'value="clarity"',
                       'value="periodic"', 'value="laws"'):
            self.assertNotIn(absent, page)

    def test_lab_overlays_by_key_and_lazy_files(self):
        lab, order = self.lab_fixture()
        out = os.path.join(self.tmp, 'v')
        err = io.StringIO()
        with contextlib.redirect_stderr(err):
            visualise.main(['--graph', self.gpath, '--out', out, '--lab', lab])
        with open(os.path.join(out, 'graph.json')) as fh:
            v = json.load(fh)
        with open(os.path.join(out, 'index.html')) as fh:
            page = fh.read()
        self.assertEqual(sorted(v['ov']), ['community', 'drift', 'wafer'])
        for name, size in v['ov'].items():  # graph.json holds only the manifest; data is in ov-<name>.json
            self.assertEqual(os.path.getsize(os.path.join(out, 'ov-%s.json' % name)), size)
            self.assertNotIn(name + '":{', json.dumps(v['ov']))
        with open(os.path.join(out, 'ov-community.json')) as fh:
            c = json.load(fh)
        # lab id k describes graph file order[k]: graph file 7 is lab id 0 (community 0 = "big one")
        lab_comm = [0, 0, 1, 1, -1, 0, 1, 2]
        want = [None] * 8
        for k, j in enumerate(order):
            want[j] = lab_comm[k]
        titles = [c['cats'][x][0] if x >= 0 else None for x in c['v']]
        names = {0: 'big one', 1: 'second', 2: 'tiny', -1: None}
        self.assertEqual(titles, [names[w] for w in want])
        self.assertEqual(c['cats'][0][0], 'big one')  # largest first
        with open(os.path.join(out, 'ov-drift.json')) as fh:
            d = json.load(fh)
        self.assertEqual(d['e'], [order[1], order[0], 800])  # edge to the vanished file (lab id 8) dropped
        self.assertEqual(d['safe'], [order[1]])
        with open(os.path.join(out, 'ov-wafer.json')) as fh:
            w = json.load(fh)
        self.assertEqual(w['numbers'], {'beta-repo': 4, 'alpha': 5})  # unseen repo appended, never renumbered
        for present in ('data-view="wafer"', 'id="tdrift"', 'id="tsafe"', '<option value="community">'):
            self.assertIn(present, page)
        self.assertNotIn('value="clarity"', page)

    def test_id_overlays_need_same_cut(self):
        g = tiny_graph()
        cats = ['core', 'copy', 'core', 'unreached', 'core', 'via', 'core', 'copy']
        ok = self.write_json('c/clarity.json', {'schema': 'clarity-v1', 'cut': g['cut'], 'file_category': cats,
                                                'categories': ['core', 'copy', 'via', 'unreached'],
                                                'titles': {'core': 'Unique and in use'}})
        bad = self.write_json('c/old.json', {'cut': 'other', 'file_category': cats})
        out = os.path.join(self.tmp, 'v')
        err = io.StringIO()
        with contextlib.redirect_stderr(err):
            visualise.main(['--graph', self.gpath, '--out', out, '--clarity', bad, '--periodic', '/no/such.json'])
        self.assertIn('another cut', err.getvalue())
        self.assertIn('not found', err.getvalue())
        self.assertFalse(os.path.exists(os.path.join(out, 'ov-clarity.json')))
        visualise.main(['--graph', self.gpath, '--out', out, '--clarity', ok])
        with open(os.path.join(out, 'ov-clarity.json')) as fh:
            c = json.load(fh)
        self.assertEqual(c['cats'][0], ['Unique and in use', '#00ff88'])
        self.assertEqual(c['v'], [0, 1, 0, 3, 0, 2, 0, 1])
        # a rerun without the overlay removes its stale file (same inputs -> same file set)
        visualise.main(['--graph', self.gpath, '--out', out])
        self.assertFalse(os.path.exists(os.path.join(out, 'ov-clarity.json')))

    def test_periodic_and_laws(self):
        g = tiny_graph()
        per = self.write_json('p/periodic.json', {
            'schema': 'explore-periodic-v1', 'cut': g['cut'], 'counts': {'files': 8},
            'axes': {'periods': [{'n': 1, 'title': 'Constants'}, {'n': 5, 'title': 'Engines'}]},
            'elements': [{'key': 'block:Cg', 'symbol': 'Cg', 'number': 12, 'title': 'Cable geometry', 'period': 5,
                          'analogue': {'symbol': 'Fe', 'name': 'Iron'}},
                         {'key': 'candidate:X', 'symbol': None, 'number': None, 'title': 'X', 'period': 1}],
            'files': {'0': {'element': 'block:Cg'}, '3': {'element': 'candidate:X'}, '5': {'element': 'nope'}}})
        laws = self.write_json('laws/a.json', {'cut': g['cut'], 'files': {'1': {'law': 'gravity'}, '2': 'inertia'},
                                               'titles': {'gravity': 'Gravity'}})
        out = os.path.join(self.tmp, 'v')
        visualise.main(['--graph', self.gpath, '--out', out, '--periodic', per, '--laws', os.path.dirname(laws)])
        with open(os.path.join(out, 'ov-periodic.json')) as fh:
            p = json.load(fh)
        self.assertEqual(p['v'], [0, -1, -1, 1, -1, -1, -1, -1])
        self.assertEqual(p['els'][0][:4], ['Cg', 12, 'Cable geometry', 5])
        self.assertEqual([c[2] for c in p['cats']], [1, 5])
        with open(os.path.join(out, 'ov-laws.json')) as fh:
            lw = json.load(fh)
        self.assertEqual([c[0] for c in lw['cats']], ['Gravity', 'inertia'])
        self.assertEqual(lw['v'][:4], [-1, 0, 1, -1])
        with open(os.path.join(out, 'index.html')) as fh:
            page = fh.read()
        self.assertIn('<option value="periodic">', page)
        self.assertIn('<option value="laws">', page)

    def test_faraday_pulse_from_laws_json(self):
        g = tiny_graph()
        laws = self.write_json('lw/laws.json', {'graph_cut': g['cut'], 'laws': {'FA': {
            'verdict': 'HOLDS', 'law': 'When a used file changes, the files that use it change with it.',
            'numbers': {'used_changed_user_changed': 32, 'used_changed_user_same': 5, 'lift': 3.37,
                        'replicated_pairs': 275}}}})
        out = os.path.join(self.tmp, 'vf')
        with contextlib.redirect_stderr(io.StringIO()):  # laws.json has no per-file classes: a warning, no laws mode
            visualise.main(['--graph', self.gpath, '--out', out, '--laws', laws])
        with open(os.path.join(out, 'ov-faraday.json')) as fh:
            f = json.load(fh)
        self.assertEqual((f['k'], f['n'], f['p']), (32, 37, round(32 / 37, 4)))
        with open(os.path.join(out, 'index.html')) as fh:
            page = fh.read()
        self.assertIn('id="tfaraday"', page)
        self.assertNotIn('<option value="laws">', page)
        # a law that does not hold gives no pulse and no control
        bad = self.write_json('lw2/laws.json', {'laws': {'FA': {'verdict': 'REFUTED', 'numbers': {}}}})
        out2 = os.path.join(self.tmp, 'vf2')
        with contextlib.redirect_stderr(io.StringIO()):
            visualise.main(['--graph', self.gpath, '--out', out2, '--faraday', bad])
        self.assertFalse(os.path.exists(os.path.join(out2, 'ov-faraday.json')))
        with open(os.path.join(out2, 'index.html')) as fh:
            self.assertNotIn('id="tfaraday"', fh.read())

    def test_phone_page_features(self):
        _, v, page = self.run_vis(os.path.join(self.tmp, 'v'))
        size = os.path.getsize(os.path.join(self.tmp, 'v', 'graph.json'))
        self.assertIn('data-bytes="%d"' % size, page)  # loading bar knows the size
        self.assertIn('Loading map (', page)
        self.assertNotIn('.js #plain{display:none}', page)  # plain list stays for screen readers
        self.assertIn('id="plain"', page)
        self.assertIn('aria-controls="sug"', page)
        self.assertIn('id="ftoggle"', page)
        self.assertIn('pushState', page)
        self.assertIn("(narrow() ? 'map' : 'pipeline')", page)  # Estate galaxy default on phones
        self.assertIn('min-height:44px', page)
        self.assertRegex(page, r'button,select,input,#legtitle\{font-size:16px\}')
        self.assertIn("(t[0] ? '<dt>Topic</dt>", page)  # no link to topics/.html

    def test_wafer_hash_matches_lab_law(self):
        node = shutil.which('node')
        if not node:
            self.skipTest('node not installed')
        js = visualise.read_asset('app.js')
        a, b = js.index('  var SHA_K'), js.index('  function buildWafer')
        names = ['132kV/a.js', 'gridatlas/atlas/index.html', 'x/café ☃.py', 'r/' + 'p' * 70]
        harness = os.path.join(self.tmp, 'h.js')
        with open(harness, 'w', encoding='utf-8') as fh:
            fh.write(js[a:b] + '\nconsole.log(JSON.stringify([%s].map(sha256word0).concat([hexCell(0),hexCell(1),hexCell(7),hexCell(20)])));'
                     % ','.join(json.dumps(n) for n in names))
        r = subprocess.run([node, harness], capture_output=True, text=True)
        self.assertEqual(r.returncode, 0, r.stderr)
        got = json.loads(r.stdout)
        import hashlib
        self.assertEqual(got[:4], [int(hashlib.sha256(n.encode()).hexdigest()[:8], 16) for n in names])
        sys.path.insert(0, os.path.join(HERE, 'lab'))
        try:
            import wafer as lab_wafer
        except ImportError:
            self.skipTest('lab/wafer.py not importable')
        for (x, y), i in zip(got[4:], (0, 1, 7, 20)):
            ex, ey = lab_wafer.hex_cell(i)
            self.assertAlmostEqual(x, ex, places=12)
            self.assertAlmostEqual(y, ey, places=12)


if __name__ == '__main__':
    unittest.main()

Ide

A style sheet in the theme folder of Cosmic.

rendercosmic / tools/explore/theme/ide.css · lines 1–204 of 204 · Not reached from any entry point (candidate for review)

What it does
Side effects: changes the web page (DOM).
Why it exists in the grid workflow
README: "Section pages (`s/*.html`) also get `ide.css`/`ide.js`, which bonus B (HOTBAR-36) owns."
What it achieves
Explore Code IDE layer (HOTBAR-36). Every rule is scoped to body.ide, which only `ide.js` sets, so with JS off the section pages look and read exactly as before.
Why it matters
No other file in the estate was found to import it.
Application
cosmic · tools/explore/theme · 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/theme/ide.css:1-204 · blob ddab3a65f4589d93ee76b671debf0ccccf0e00c0 · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: output · effects: dom · domain stage: unknown · users: none · canonical: unreached_review
/* Explore Code IDE layer (HOTBAR-36). Every rule is scoped to body.ide, which only ide.js sets,
   so with JS off the section pages look and read exactly as before.
   Look: Solar Design Studio / Energy Transition Simulator HUD: black ground, hairline edges, dim text,
   cyan accent, outline (never filled) buttons. */
body.ide {
  --ide-bg: #000; --ide-panel: #0b0e14; --ide-line: #2f343d; --ide-text: #fff; --ide-dim: #a6adbb;
  --ide-link: #66ccff; --ide-acc: #00ffff; --ide-sky: #9cdbff; --ide-warn: #ffd24a; --ide-ok: #00ff88; --ide-bad: #ff8a7a;
  --ide-rail: 264px; --ide-facts: 330px; --ide-bar: 56px;
  overflow-x: hidden;
}
body.ide [data-ide] { box-sizing: border-box; }
body.ide .ide-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  font: 12px/1.2 ui-monospace, Menlo, Consolas, monospace; color: var(--ide-dim); background: var(--ide-panel);
  border: 1px solid var(--ide-line); border-radius: 4px; padding: 6px 9px; min-height: 32px; cursor: pointer;
  text-decoration: none; white-space: nowrap;
}
body.ide .ide-btn:hover, body.ide .ide-btn:focus-visible { color: #fff; border-color: var(--ide-sky); }
body.ide .ide-btn.ide-flash { color: var(--ide-ok); border-color: var(--ide-ok); }
body.ide :focus-visible { outline: 2px solid var(--ide-acc); outline-offset: 2px; }
body.ide .ide-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: none; box-shadow: 0 0 6px currentColor; }
body.ide .ide-cap { margin: 14px 0 6px; font-size: 10px; letter-spacing: .14em; color: var(--ide-dim); text-transform: uppercase; }
body.ide .ide-role { display: inline-block; border: 1px solid; border-radius: 3px; padding: 0 6px; font-size: 11px; margin-right: 6px; }
body.ide .ide-aside { display: inline-block; color: var(--ide-warn); font-size: 11px; }
body.ide kbd { font: 11px ui-monospace, Menlo, monospace; border: 1px solid var(--ide-line); border-bottom-width: 2px; border-radius: 3px; padding: 0 5px; color: #fff; background: #05070b; }
body.ide .ide-hint { font-size: 11px; color: var(--ide-dim); }

/* ---- code: gutter + pre side by side; the pre scrolls sideways inside itself */
/* Flex, not grid: on iPhone Safari the grid let the gutter cover the first characters of every code line. The code
   paints above the gutter, never under it, and nothing indents or shifts the code text. */
body.ide .ide-codewrap { position: relative; display: flex; flex-wrap: wrap; align-items: stretch; margin: 10px 0 16px; width: 100%; min-width: 0; max-width: 100%; }
body.ide .ide-codewrap > pre { flex: 1 1 0; margin: 0; min-width: 0; border-left: 0; position: relative; z-index: 1; padding-left: 12px; text-indent: 0; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body.ide .ide-codewrap > pre > code { margin: 0; padding: 0; text-indent: 0; }
body.ide .ide-gutter {
  white-space: pre; text-align: right; user-select: none; color: #4c5a65; background: #05070b;
  border: 1px solid var(--ide-line); border-right: 1px solid #1c2c3a; padding: 12px 8px 12px 6px;
  font: 13px/1.5 ui-monospace, Menlo, Consolas, monospace; min-width: 3ch;
  flex: 0 0 auto; position: relative; z-index: 0; -webkit-text-size-adjust: 100%; text-size-adjust: 100%;
}
body.ide .ide-head {
  grid-column: 1 / -1; flex: 0 0 100%; box-sizing: border-box; min-width: 0; max-width: 100%; display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  background: linear-gradient(90deg, #0b0e14, #05070b); border: 1px solid var(--ide-line); border-bottom: 0;
  padding: 5px 8px; font-size: 12px;
}
body.ide .ide-headkey { flex: 1 1 200px; min-width: 0; color: var(--ide-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.ide .ide-lineflash { position: absolute; left: 0; right: 0; background: rgba(0, 255, 255, .16); border-left: 2px solid var(--ide-acc); pointer-events: none; animation: ide-fade 2.2s ease-out forwards; }
@keyframes ide-fade { 0%, 60% { opacity: 1 } 100% { opacity: 0 } }

/* ---- sticky top bar: current file and its key */
body.ide #ide-top { cursor: pointer;
  position: sticky; top: var(--ide-hudh, 0px); z-index: 20; display: flex; align-items: center; gap: 8px; min-width: 0;
  background: rgba(0, 0, 0, .92); border-bottom: 1px solid var(--ide-line); padding: 6px 0; font-size: 12px;
  backdrop-filter: blur(4px);
}
body.ide #ide-top b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40%; color: #fff; }
body.ide .ide-topkey { flex: 1; min-width: 0; color: var(--ide-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body.ide .ide-topn { color: var(--ide-acc); }

/* ---- the in-section compact card (phones/tablets) */
body.ide .ide-card { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: 12px; color: var(--ide-dim); margin: 2px 0 6px; }
body.ide .ide-hl { background: rgba(0, 255, 255, .12); outline: 1px solid var(--ide-acc); transition: background .3s; }

/* ---- Clarity mode: set aside unreached files and copies */
body.ide .ide-fold { display: none; }
body.ide.ide-clarity section.ide-asideable:not(.ide-open) > :not(h2):not(.ide-card):not(.ide-fold) { display: none; }
body.ide.ide-clarity section.ide-asideable { opacity: .7; border-left-style: dashed; }
body.ide.ide-clarity section.ide-asideable:not(.ide-open) .ide-fold {
  display: block; width: 100%; text-align: left; margin: 4px 0 10px; min-height: 44px;
  background: #05070b; color: var(--ide-warn); border: 1px dashed #4c5a65; border-radius: 4px; padding: 8px 10px; font: 12px ui-monospace, Menlo, monospace; cursor: pointer;
}
body.ide.ide-clarity .ide-files a.ide-dim { opacity: .4; text-decoration: line-through; }

/* ---- rails (desktop) */
body.ide .ide-panel {
  display: none; position: fixed; top: var(--ide-hudh, 0px); bottom: 0; z-index: 29; overflow-y: auto; overscroll-behavior: contain;
  background: var(--ide-panel); padding: 10px 14px 20px; font-size: 13px; scrollbar-width: thin; scrollbar-color: #2f343d transparent;
}
body.ide #ide-rail { left: 0; width: var(--ide-rail); border-right: 1px solid var(--ide-line); }
body.ide #ide-facts { right: 0; width: var(--ide-facts); border-left: 1px solid var(--ide-line); box-shadow: inset 3px 0 0 -1px var(--role, #2f343d); }
body.ide .ide-panel::before { content: ''; position: absolute; top: 6px; left: 6px; width: 10px; height: 10px; border-top: 1px solid var(--ide-acc); border-left: 1px solid var(--ide-acc); opacity: .7; }
body.ide.ide-hudmodes .ide-modes { display: none; }
body.ide .ide-modes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin: 6px 0 10px; }
body.ide .ide-mode {
  font: 11px ui-monospace, Menlo, monospace; letter-spacing: .04em; color: var(--ide-dim); background: #05070b;
  border: 1px solid var(--ide-line); border-radius: 4px; min-height: 34px; padding: 4px 2px; cursor: pointer;
}
body.ide .ide-mode:hover { color: #fff; }
body.ide .ide-mode[aria-pressed="true"] { color: #000; background: var(--ide-acc); border-color: var(--ide-acc); box-shadow: 0 0 10px rgba(0, 255, 255, .45); }
body.ide .ide-level { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--ide-acc); letter-spacing: .08em; }
body.ide .ide-xp { flex: 1; height: 4px; background: #05070b; border: 1px solid var(--ide-line); border-radius: 2px; overflow: hidden; }
body.ide .ide-xp i { display: block; height: 100%; background: linear-gradient(90deg, #0066ff, var(--ide-acc)); }
body.ide .ide-files { list-style: none; margin: 0; padding: 0; counter-reset: f; }
body.ide .ide-files li { margin: 0; }
body.ide .ide-files a {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 4px; color: var(--ide-dim);
  text-decoration: none; border: 1px solid transparent; min-height: 32px;
}
body.ide .ide-files a:hover { color: #fff; background: #11161f; }
body.ide .ide-files a.ide-cur { color: #fff; border-color: var(--ide-line); background: #05070b; box-shadow: inset 2px 0 0 var(--ide-acc); }
body.ide .ide-files a.ide-seen .ide-fn::after { content: ' ·'; color: var(--ide-ok); }
body.ide .ide-fn { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.ide .ide-ln { color: #4c5a65; font-size: 11px; }
body.ide .ide-secnav { display: flex; gap: 6px; flex-wrap: wrap; }
body.ide .ide-topic { display: block; margin-top: 8px; font-size: 12px; }
body.ide .ide-trail { display: flex; flex-wrap: wrap; gap: 4px; }
body.ide .ide-trail a, body.ide .ide-trail span { font-size: 11px; border: 1px solid var(--ide-line); border-radius: 3px; padding: 2px 6px; text-decoration: none; }
body.ide .ide-trail .ide-here { color: #000; background: var(--ide-acc); border-color: var(--ide-acc); }
body.ide .ide-ft { font-size: 15px; margin: 2px 0 6px; overflow-wrap: anywhere; }
body.ide .ide-syn { font-size: 12px; color: #dfe6f0; border-left: 2px solid var(--role, var(--ide-acc)); padding-left: 8px; margin: 8px 0; }
body.ide .ide-links { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--ide-dim); }
body.ide .ide-links a { overflow-wrap: anywhere; }
body.ide .ide-more { color: #4c5a65; font-size: 11px; }
body.ide .ide-key { display: block; font-size: 11px; color: var(--ide-sky); background: #05070b; border: 1px solid var(--ide-line); padding: 6px; overflow-wrap: anywhere; }
body.ide .ide-acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
body.ide .ide-miniwrap { position: relative; border: 1px solid var(--ide-line); }
body.ide #ide-mini { display: block; width: 100%; height: 200px; cursor: pointer; }
body.ide .ide-minivp { position: absolute; left: 0; right: 0; border: 1px solid var(--ide-acc); background: rgba(0, 255, 255, .07); pointer-events: none; }

/* ---- bottom bar (phones and tablets): 44px targets */
body.ide #ide-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; display: grid; grid-template-columns: repeat(5, 1fr);
  gap: 4px; padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px)); background: rgba(5, 7, 11, .96);
  border-top: 1px solid var(--ide-line); max-width: none; margin: 0; border-bottom: 0;
}
body.ide .ide-bb {
  display: flex; align-items: center; justify-content: center; min-height: 44px; min-width: 0; padding: 0 4px;
  font: 13px ui-monospace, Menlo, monospace; color: var(--ide-sky); background: var(--ide-panel); border: 1px solid var(--ide-line);
  border-radius: 6px; text-decoration: none; cursor: pointer;
}
body.ide .ide-bb:active { border-color: var(--ide-acc); color: #fff; }
body.ide .ide-bb.ide-off { opacity: .3; }
body.ide { padding-bottom: calc(var(--ide-bar) + env(safe-area-inset-bottom, 0px)); }
body.ide.ide-bump #ide-top { box-shadow: 0 2px 0 var(--ide-bad); }

/* ---- overlays: help + palette + map + toast */
body.ide #ide-ov { position: fixed; inset: 0; z-index: 100; background: rgba(0, 0, 0, .7); display: flex; align-items: flex-start; justify-content: center; padding: 10vh 12px 12px; }
body.ide .ide-box {
  position: relative; width: min(640px, 100%); max-height: 78vh; overflow: auto; background: var(--ide-panel);
  border: 1px solid var(--ide-line); border-radius: 6px; padding: 12px 14px; box-shadow: 0 0 0 1px #000, 0 0 30px rgba(0, 255, 255, .12);
}
body.ide .ide-box::before, body.ide .ide-box::after { content: ''; position: absolute; width: 12px; height: 12px; border-color: var(--ide-acc); border-style: solid; }
body.ide .ide-box::before { top: -1px; left: -1px; border-width: 2px 0 0 2px; }
body.ide .ide-box::after { bottom: -1px; right: -1px; border-width: 0 2px 2px 0; }
body.ide .ide-keys td { border-bottom: 1px solid #1a1f27; padding: 6px 8px; }
body.ide .ide-pin { width: 100%; box-sizing: border-box; min-height: 44px; font-size: 16px; background: #05070b; border: 1px solid var(--ide-sky); border-radius: 4px; color: #fff; padding: 8px 10px; }
body.ide .ide-pres { list-style: none; margin: 8px 0 0; padding: 0; }
body.ide .ide-pres li { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 0 8px; padding: 7px 8px; border-radius: 4px; cursor: pointer; margin: 0; min-height: 30px; }
body.ide .ide-pres li.on { background: #11161f; box-shadow: inset 2px 0 0 var(--ide-acc); }
body.ide .ide-pk { font-size: 10px; color: var(--ide-dim); text-transform: uppercase; letter-spacing: .08em; padding-top: 2px; }
body.ide .ide-ptt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.ide .ide-ps { grid-column: 2; font-size: 11px; color: var(--ide-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.ide #ide-map { display: none; }
body.ide.ide-mapon #ide-map { display: flex; flex-direction: column; position: fixed; z-index: 50; top: var(--ide-hudh, 0px); bottom: 0; left: var(--ide-rail); right: var(--ide-facts); background: #000; border-left: 1px solid var(--ide-line); }
body.ide .ide-maphead { display: flex; gap: 8px; align-items: center; padding: 6px 10px; border-bottom: 1px solid var(--ide-line); font-size: 12px; }
body.ide .ide-maphead b { flex: 1; color: var(--ide-acc); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.ide #ide-map iframe { flex: 1; border: 0; width: 100%; background: #000; }
body.ide #ide-toast {
  position: fixed; left: 50%; bottom: calc(var(--ide-bar) + 14px); transform: translate(-50%, 10px); z-index: 90; opacity: 0; pointer-events: none;
  background: #05070b; color: #fff; border: 1px solid var(--ide-acc); border-radius: 4px; padding: 8px 12px; font-size: 12px; max-width: min(90vw, 560px);
  transition: opacity .2s, transform .2s;
}
body.ide #ide-toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ---- wide: three panes, using the whole screen */
@media (min-width: 1200px) {
  body.ide { padding-bottom: 0; }
  body.ide .ide-panel { display: block; }
  body.ide #ide-bar { display: none; }
  body.ide #ide-toast { bottom: 18px; }
  body.ide > header, body.ide > nav, body.ide > main, body.ide > footer {
    max-width: none; margin-left: var(--ide-rail); margin-right: var(--ide-facts); padding-left: 28px; padding-right: 28px;
  }
  body.ide p { max-width: 1100px; }
  body.ide .ide-card { display: none; }
  body.ide main section.file { margin-left: -16px; }
}
@media (min-width: 1700px) { body.ide { --ide-rail: 300px; --ide-facts: 380px; } }

/* ---- narrow: single column, code first under the compact card */
@media (max-width: 1199.98px) {
  body.ide #ide-top b { max-width: 55%; }
}
@media (max-width: 759.98px) {
  body.ide > header, body.ide > nav, body.ide > main, body.ide > footer { padding-left: 12px; padding-right: 12px; }
  body.ide main section.file { display: flex; flex-direction: column; margin-left: -8px; padding-left: 8px; min-width: 0; }
  body.ide main section.file > * { order: 6; min-width: 0; max-width: 100%; }
  body.ide main section.file > h2 { order: 0; }
  body.ide main section.file > .ide-card { order: 1; }
  body.ide main section.file > .ide-fold { order: 2; }
  body.ide main section.file > .ide-codewrap { order: 3; }
  body.ide main section.file > p.syn { order: 4; }
  body.ide main section.file > p.k { order: 5; }
  body.ide .ide-gutter { font-size: 12px; padding-left: 3px; padding-right: 5px; }
  body.ide .ide-codewrap > pre { font-size: 12px; }
  body.ide .ide-codewrap > pre { max-height: 75vh; overflow: auto; }
  body.ide .ide-gutter { max-height: 75vh; overflow: hidden; }
  body.ide .ide-head .ide-btn { min-height: 40px; }
  body.ide #ide-top .ide-topkey { display: none; }
  body.ide dl.v { grid-template-columns: 1fr; }
  body.ide dl.v dt { margin-top: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  body.ide *, body.ide *::before, body.ide *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}