<!-- SOLID CITY · part 27 -->
f (css) e.style.cssText = css;
  if (text != null) e.textContent = text;
  if (parent) parent.appendChild(e);
  return e;
}
function fmt(n, d) { return (n == null || !isFinite(n)) ? '—' : Number(n).toFixed(d == null ? 2 : d); }
function record(line) {
  D.lines.unshift(line); if (D.lines.length > 40) D.lines.pop();
  try {
    var all = JSON.parse(localStorage.getItem('solid-audit-records') || '[]');
    all.push({ t: Date.now(), line: line }); while (all.length > 40) all.shift();
    localStorage.setItem('solid-audit-records', JSON.stringify(all));
  } catch (e) {}
  if (A.logBuild) A.logBuild({ t: Date.now(), site: 'TRIANGLE-SEAM AUDITOR', what: line });
  renderLines();
}
function renderLines() {
  if (!D.listEl) return;
  D.listEl.innerHTML = '';
  if (!D.lines.length) { el('div', 'opacity:.65;', D.listEl, 'No audits yet. Choose a structure above — the Auditor reads its actual triangles.'); return; }
  D.lines.slice(0, 14).forEach(function (l) { el('div', 'padding:3px 0;border-bottom:1px solid rgba(154,164,181,.14);', D.listEl, l); });
}
function runAudit(entry) {
  if (!D.mod) return;
  var r;
  try { r = D.mod.auditStructure({ mesh: entry.mesh, name: entry.name, standAt: entry.standAt || null, expectedUp: entry.expectedUp !== false }); }
  catch (e) { record('▸ ' + entry.name + ' — AUDIT FAILED: ' + (e && e.message ? e.message : e)); return; }
  var findings = (r.findings || []).slice();
  var aside = '';
  if (entry.kind === 'slab') {
    // A box slab's underside faces down by construction, and probes that
    // land on it are not standing probes. Both are set aside — counted and
    // named here, never dressed as faults and never hidden either.
    findings = findings.filter(function (f) { return f !== 'MISSING_STANDING_PROBES' && f !== 'DOWNWARD_TRIANGLES'; });
    aside = ' · slab: ' + r.down + ' underside tris face down by construction' + (r.standMissing > 0 ? ' · ' + r.standMissing + ' non-standing probes set aside' : '');
  } else if (r.standMissing > 0) {
    findings = findings.filter(function (f) { return f !== 'MISSING_STANDING_PROBES'; });
    aside = ' · ' + r.standMissing + ' probes on non-standing faces set aside';
  }
  var stand = (entry.standAt) ? ('standing Δ max ' + fmt(r.standMaxDelta, 4) + ' m · p95 ' + fmt(r.standP95Delta, 4) + ' · ' + r.sampled + ' probes') : 'standing not claimed';
  var line = '▸ ' + entry.name + ' — ' + r.triangles + ' tris · ' + r.up + ' up / ' + r.down + ' down · ' + r.degenerate + ' degenerate · quality med ' + fmt(r.medianQuality, 2) + ' · ' + stand + aside + (findings.length ? ' · FINDINGS: ' + findings.join(', ') : ' · no findings');
  record(line);
}
function renderButtons() {
  if (!D.btnEl) return;
  D.btnEl.innerHTML = '';
  var list = (window.SC.auditables || []);
  if (!list.length) { el('div', 'opacity:.65;', D.btnEl, 'The builders have named no geometry yet — the registry fills as the world loads. Tap ↻ to look again.'); return; }
  list.forEach(function (entry) {
    var b = el('button', 'display:block;width:100%;text-align:left;margin:0 0 5px;padding:7px 9px;background:#2b3448;color:#e8ecf3;border:1px solid rgba(216,168,51,.45);border-radius:8px;font-size:12px;', D.btnEl, '📐 ' + entry.name);
    b.addEventListener('click', function () { runAudit(entry); });
  });
  var all = el('button', 'display:block;width:100%;text-align:left;margin:2px 0 0;padding:8px 9px;background:#3a2f14;color:#ffd27a;border:1px solid #d8a833;border-radius:8px;font-size:12px;font-weight:700;', D.btnEl, '📐 AUDIT ALL — ' + list.length + ' structures');
  all.addEventListener('click', function () { list.forEach(runAudit); });
}
function build() {
  if (D.built) return; D.built = true;
  var chip = el('button', 'position:fixed;left:10px;bottom:98px;z-index:60;padding:8px 12px;background:rgba(35,44,61,.92);color:#ffd27a;border:1px solid #d8a833;border-radius:10px;font-size:13px;font-weight:700;', document.body, '📐 AUDIT');
  var panel = el('div', 'position:fixed;left:10px;bottom:142px;z-index:60;width:min(330px,92vw);max-height:52vh;overflow:auto;display:none;background:rgba(35,44,61,.96);color:#e8ecf3;border:1px solid rgba(216,168,51,.6);border-radius:12px;padding:10px 12px;font-size:12px;line-height:1.45;', document.body);
  el('div', 'font-weight:700;color:#ffd27a;margin-bottom:2px;', panel, '📐 THE TRIANGLE-AND-SEAM AUDITOR');
  el('div', 'opacity:.75;margin-bottom:8px;', panel, 'The geometric inspector. It reads the actual triangles of a built structure and asks whether they agree with the standing law their builder registered. On demand only — it never runs per frame.');
  var refresh = el('button', 'float:right;margin-top:-24px;padding:3px 9px;background:#2b3448;color:#e8ecf3;border:1px solid rgba(154,164,181,.5);border-radius:8px;font-size:12px;', panel, '↻');
  refresh.addEventListener('click', renderButtons);
  D.btnEl = el('div', '', panel);
  D.listEl = el('div', 'margin-top:6px;', panel);
  chip.addEventListener('click', f