repositories / pi-ext
pi-ext
bugabingas pi extensions
owned by bugabinga
extensions/diff-review/render.ts
Rawimport { parsePatchFiles } from "@pierre/diffs";
import { preloadFileDiff } from "@pierre/diffs/ssr";
import type { GitStatus } from "@pierre/trees";
import {
preloadFileTree,
serializeFileTreeSsrPayload,
} from "@pierre/trees/ssr";
import type { CollectedDiff, FindingDraft, ReviewPayload } from "./types.js";
export async function renderPage(options: {
diff: CollectedDiff;
round: number;
findings: FindingDraft[];
notes?: string;
carriedFindings?: import("./types.js").Finding[];
}): Promise<string> {
const { diff, round, findings, notes, carriedFindings = [] } = options;
const files = parsePatchFiles(
diff.diffText,
`diff-review-${round}`,
true,
).flatMap((patch) => patch.files);
const fileTreePayload = preloadFileTree({
paths: diff.files.flatMap((f) =>
f.prevPath && f.prevPath !== f.path ? [f.prevPath, f.path] : [f.path],
),
gitStatus: diff.files.map((f) => ({
path: f.path,
status: gitStatusFor(f.status),
})),
initialExpansion: "open",
});
const fileTreeHtml = serializeFileTreeSsrPayload(
fileTreePayload,
"declarative",
);
const diffHtmls: string[] = [];
for (const file of files) {
const fileFindings = carriedFindings.filter(
(f) => f.file === file.name && f.status === "open",
);
const annotations = fileFindings.flatMap((f) =>
Array.from({ length: f.endLine - f.startLine + 1 }, (_, i) => ({
side: f.side as "additions" | "deletions",
lineNumber: f.startLine + i,
metadata: {
findingId: f.id,
severity: f.severity,
category: f.category,
comment: f.comment,
},
})),
);
const result = await preloadFileDiff({
fileDiff: file,
options: {
diffStyle: "split",
overflow: "scroll",
// SSR must stay interactive on local review startup.
// Plain text avoids cold Shiki init while keeping lines/anchors/annotations.
tokenizeMaxLength: 0,
},
annotations,
});
diffHtmls.push(`<section class="file-section" data-file="${esc(file.name)}">
<h2 class="file-title">${esc(file.prevName && file.prevName !== file.name ? `${file.prevName} → ${file.name}` : file.name)}</h2>
${result.prerenderedHTML}
</section>`);
}
const totals = diff.files.reduce(
(sum, f) => ({
additions: sum.additions + f.additions,
deletions: sum.deletions + f.deletions,
}),
{ additions: 0, deletions: 0 },
);
return `<!doctype html>
<html lang="en" data-theme="dark">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Pi Diff Review</title>
<style>
${INLINE_CSS}
</style>
</head>
<body>
<div id="app">
<aside id="sidebar">
<div class="brand"><h1>Diff Review</h1><div class="subtitle">Pi × Pierre</div><button id="theme-toggle" type="button" title="Toggle theme">◐</button></div>
<div id="meta">
<span class="meta-chip"><span class="meta-label">round</span><span class="meta-value">${round}</span></span>
<span class="meta-chip"><span class="meta-label">reviewing</span><span class="meta-value">${esc(sourceLabel(diff.source))}</span></span>
</div>
<div id="tree">${fileTreeHtml}</div>
</aside>
<main id="main">
<header id="topbar">
<div>
<div class="topbar-title">Review changed lines</div>
<div id="summary">${diff.files.length} files · +${totals.additions} −${totals.deletions}${diff.skippedFiles.length ? ` · skipped ${diff.skippedFiles.length}` : ""}</div>
</div>
<div class="topbar-actions">
<div class="search-wrap"><input id="search" type="text" placeholder="Search code…" autocomplete="off" /><span id="search-badge" hidden></span><button id="search-clear" type="button" aria-label="Clear search" hidden>×</button></div>
<div id="search-results" hidden></div>
<div id="finding-count" class="count-pill">${findings.length} finding${findings.length === 1 ? "" : "s"}</div>
</div>
</header>
<div id="diffs">${diffHtmls.join("\n")}</div>
<dialog id="finding-dialog">
<form method="post" action="finding" id="finding-form">
<h3>New finding</h3>
<div id="selection-label">Click a changed line.</div>
<input type="hidden" name="file" id="f-file" />
<input type="hidden" name="side" id="f-side" />
<input type="hidden" name="startLine" id="f-start" />
<input type="hidden" name="endLine" id="f-end" />
<div class="field-row">
<label>Severity
<select name="severity" id="f-severity">
<option value="high">🔥 high</option>
<option value="medium" selected>😒 medium</option>
<option value="low">🦟 low</option>
</select>
<div class="field-subtitle" id="severity-sub">suspicious little gremlin</div>
</label>
<label>Category
<select name="category" id="f-category">
<option value="bug" selected>🐛 bug</option>
<option value="style">💅 style</option>
<option value="perf">🐌 perf</option>
<option value="question">🤨 question</option>
</select>
<div class="field-subtitle" id="category-sub">exquisite disaster</div>
</label>
</div>
<label>Finding
<textarea name="comment" rows="4" placeholder="Describe the issue" required></textarea>
</label>
<div class="actions">
<button type="button" id="f-cancel">Cancel</button>
<button type="submit">Add finding</button>
</div>
</form>
</dialog>
</main>
<aside id="drawer">
<section class="card">
<div class="card-title">Collected findings <span id="drawer-count">${findings.length}</span></div>
<div id="findings">${renderFindings(findings)}</div>
</section>
<section class="card">
<div class="card-title">Review notes</div>
<form method="post" action="submit">
<textarea name="notes" rows="4" placeholder="Optional context">${esc(notes ?? "")}</textarea>
<footer class="actions">
<button type="submit" formaction="cancel" formmethod="post">Cancel</button>
<button type="submit">Send to Pi</button>
</footer>
</form>
</section>
</aside>
<button id="toggle-left" class="pane-toggle" type="button" aria-label="Collapse file tree">‹</button>
<button id="toggle-right" class="pane-toggle" type="button" aria-label="Collapse review panel">›</button>
<div id="status" role="status" aria-live="polite">Ready</div>
</div>
<script>
(() => {
const status = document.getElementById('status');
function setStatus(text, tone) { status.textContent = text; status.className = tone || ''; }
const dialog = document.getElementById('finding-dialog');
const form = document.getElementById('finding-form');
const label = document.getElementById('selection-label');
const fFile = document.getElementById('f-file');
const fSide = document.getElementById('f-side');
const fStart = document.getElementById('f-start');
const fEnd = document.getElementById('f-end');
const cancelBtn = document.getElementById('f-cancel');
let selected = null;
document.getElementById('diffs').addEventListener('click', (e) => {
const line = e.target.closest('[data-line]');
if (!line) return;
const section = line.closest('.file-section');
if (!section) return;
const file = section.dataset.file;
const sideEl = line.closest('[data-additions], [data-deletions]');
const side = sideEl?.dataset.additions !== undefined ? 'additions' : 'deletions';
const lineNum = Number(line.dataset.line);
if (e.shiftKey && selected && selected.file === file && selected.side === side) {
selected.end = lineNum;
} else {
selected = { file, side, start: lineNum, end: lineNum };
}
const start = Math.min(selected.start, selected.end);
const end = Math.max(selected.start, selected.end);
fFile.value = file;
fSide.value = side;
fStart.value = start;
fEnd.value = end;
label.textContent = file + ':' + start + (start === end ? '' : '-' + end) + ' ' + side;
dialog.showModal();
});
cancelBtn.addEventListener('click', () => dialog.close());
dialog.addEventListener('click', (e) => { if (e.target === dialog) dialog.close(); });
const SEVERITY_SUBS = { high: 'ship it to prod, coward', medium: 'suspicious little gremlin', low: 'tiny crime, still crime' };
const CATEGORY_SUBS = { bug: 'exquisite disaster', style: 'crimes against taste', perf: 'artisanal slowness', question: 'answerable with a shrug' };
const sevSub = document.getElementById('severity-sub');
const catSub = document.getElementById('category-sub');
document.getElementById('f-severity').addEventListener('change', (e) => { sevSub.textContent = SEVERITY_SUBS[e.target.value] || ''; });
document.getElementById('f-category').addEventListener('change', (e) => { catSub.textContent = CATEGORY_SUBS[e.target.value] || ''; });
form.addEventListener('submit', async (e) => {
e.preventDefault();
const data = new URLSearchParams(new FormData(form));
await fetch('finding', { method: 'POST', body: data, headers: { 'Authorization': 'Bearer ' + new URLSearchParams(location.search).get('token') } });
setStatus('Finding added', 'ok');
location.reload();
});
document.querySelectorAll('#findings form').forEach(f => {
f.addEventListener('submit', async (e) => {
e.preventDefault();
const data = new URLSearchParams(new FormData(f));
await fetch('finding/delete', { method: 'POST', body: data, headers: { 'Authorization': 'Bearer ' + new URLSearchParams(location.search).get('token') } });
location.reload();
});
});
const searchInput = document.getElementById('search');
const searchResults = document.getElementById('search-results');
const searchClear = document.getElementById('search-clear');
const searchBadge = document.getElementById('search-badge');
let searchDebounce;
searchInput.addEventListener('input', () => {
clearTimeout(searchDebounce);
const q = searchInput.value.trim();
if (!q) { searchResults.hidden = true; searchClear.hidden = true; searchBadge.hidden = true; return; }
searchClear.hidden = false;
searchDebounce = setTimeout(async () => {
const token = new URLSearchParams(location.search).get('token');
const res = await fetch('search?q=' + encodeURIComponent(q), { headers: { 'Authorization': 'Bearer ' + token } });
const html = await res.text();
searchResults.innerHTML = html;
searchResults.hidden = false;
searchBadge.hidden = true;
}, 150);
});
searchInput.addEventListener('keydown', (e) => { if (e.key === 'Escape') searchResults.hidden = true; });
searchClear.addEventListener('click', () => { searchInput.value = ''; searchResults.hidden = true; searchClear.hidden = true; searchBadge.hidden = true; searchInput.focus(); });
document.addEventListener('click', (e) => { if (!searchResults.contains(e.target) && e.target !== searchInput) searchResults.hidden = true; });
searchResults.addEventListener('click', (e) => {
const result = e.target.closest('.search-result');
if (!result) return;
e.preventDefault();
const file = result.dataset.file;
const side = result.dataset.side;
const line = result.dataset.line;
const section = document.querySelector('.file-section[data-file="' + CSS.escape(file) + '"]');
if (section) {
section.scrollIntoView({ behavior: 'smooth', block: 'start' });
const target = section.querySelector('[data-' + side + '] [data-line="' + line + '"]');
if (target) {
target.style.outline = '2px solid #c026d3';
setTimeout(() => target.style.outline = '', 2400);
}
}
searchResults.hidden = true;
});
const themeToggle = document.getElementById('theme-toggle');
const themeKey = 'diff-review-theme';
const themeValues = ['system', 'dark', 'light'];
let themeMode = localStorage.getItem(themeKey) || 'system';
function applyTheme() {
const resolved = themeMode === 'system' ? (matchMedia('(prefers-color-scheme: light)').matches ? 'light' : 'dark') : themeMode;
document.documentElement.dataset.theme = resolved;
themeToggle.title = 'Theme: ' + themeMode;
}
themeToggle.addEventListener('click', () => {
themeMode = themeValues[(themeValues.indexOf(themeMode) + 1) % themeValues.length];
localStorage.setItem(themeKey, themeMode);
applyTheme();
document.cookie = 'diff_review_theme=' + themeMode + '; SameSite=Strict; Path=/';
});
matchMedia('(prefers-color-scheme: dark)').addEventListener('change', () => { if (themeMode === 'system') applyTheme(); });
applyTheme();
const leftToggle = document.getElementById('toggle-left');
const rightToggle = document.getElementById('toggle-right');
const app = document.getElementById('app');
const layoutKey = 'diff-review-layout';
const MIN_PANE = 120;
let layout = { left: 288, right: 320, leftCollapsed: false, rightCollapsed: false };
try { layout = JSON.parse(localStorage.getItem(layoutKey)) || layout; } catch {}
function applyLayout() {
const left = layout.leftCollapsed ? 0 : layout.left;
const right = layout.rightCollapsed ? 0 : layout.right;
app.style.gridTemplateColumns = left + 'px 1fr ' + right + 'px';
app.dataset.leftCollapsed = layout.leftCollapsed;
app.dataset.rightCollapsed = layout.rightCollapsed;
leftToggle.textContent = layout.leftCollapsed ? '\u203A' : '\u2039';
rightToggle.textContent = layout.rightCollapsed ? '\u2039' : '\u203A';
leftToggle.style.left = left + 'px';
rightToggle.style.right = right + 'px';
}
leftToggle.addEventListener('click', () => { layout.leftCollapsed = !layout.leftCollapsed; applyLayout(); localStorage.setItem(layoutKey, JSON.stringify(layout)); });
rightToggle.addEventListener('click', () => { layout.rightCollapsed = !layout.rightCollapsed; applyLayout(); localStorage.setItem(layoutKey, JSON.stringify(layout)); });
// Drag splitter via toggle buttons — hold and drag to resize
function startDrag(side, e) {
e.preventDefault();
if (side === 'left') layout.leftCollapsed = false;
else layout.rightCollapsed = false;
app.dataset.resizing = side;
const onMove = (ev) => {
if (side === 'left') layout.left = Math.max(MIN_PANE, Math.min(ev.clientX, window.innerWidth - MIN_PANE - layout.right));
else layout.right = Math.max(MIN_PANE, Math.min(window.innerWidth - ev.clientX, window.innerWidth - MIN_PANE - layout.left));
applyLayout();
};
const onUp = () => {
delete app.dataset.resizing;
localStorage.setItem(layoutKey, JSON.stringify(layout));
window.removeEventListener('pointermove', onMove);
window.removeEventListener('pointerup', onUp);
window.removeEventListener('pointercancel', onUp);
};
window.addEventListener('pointermove', onMove);
window.addEventListener('pointerup', onUp, { once: true });
window.addEventListener('pointercancel', onUp, { once: true });
}
leftToggle.addEventListener('pointerdown', (e) => { if (e.shiftKey) startDrag('left', e); });
rightToggle.addEventListener('pointerdown', (e) => { if (e.shiftKey) startDrag('right', e); });
applyLayout();
})();
</script>
</body>
</html>`;
}
export function renderSearchResults(
query: string,
hits: import("./search.js").SearchMatch[],
): string {
if (!query.trim()) return '<div class="search-empty">Type to search</div>';
if (hits.length === 0) return '<div class="search-empty">No matches.</div>';
const max = Math.min(hits.length, 200);
let html = '<div class="search-list">';
for (let i = 0; i < max; i++) {
const h = hits[i];
const before = esc(h.text.slice(0, h.matchStart));
const match = esc(h.text.slice(h.matchStart, h.matchEnd));
const after = esc(h.text.slice(h.matchEnd));
html += `<a class="search-result" href="#" data-file="${esc(h.file)}" data-side="${h.side}" data-line="${h.line}">
<div class="search-file">${esc(h.file)}:${h.line} <span class="search-side">${h.side}</span></div>
<div class="search-line">${before}<mark>${match}</mark>${after}</div>
</a>`;
}
if (hits.length > max) {
html += `<div class="search-more">${hits.length - max} more matches</div>`;
}
html += "</div>";
return html;
}
export function renderFindings(findings: FindingDraft[]): string {
if (findings.length === 0) return "No findings yet.";
return findings
.map(
(f, i) =>
`<div class="finding-item severity-${f.severity}">
<div class="finding-item-head">
<span class="finding-number">${i + 1}</span>
<span class="finding-pill ${f.severity}">${f.severity}</span>
<span class="finding-pill category">${f.category}</span>
<form method="post" action="finding/delete" style="display:inline"><input type="hidden" name="index" value="${i}" /><button type="submit" class="remove-finding" title="Remove">×</button></form>
</div>
<div class="finding-location">${esc(f.file)}:${f.startLine}${f.startLine === f.endLine ? "" : `-${f.endLine}`} ${f.side}</div>
<div class="finding-comment">${esc(f.comment)}</div>
</div>`,
)
.join("\n");
}
function sourceLabel(source: ReviewPayload["source"]): string {
const scope = source.files?.length
? ` · ${source.files.length} path${source.files.length === 1 ? "" : "s"}`
: "";
if (source.kind === "working-tree") return `unstaged changes${scope}`;
if (source.kind === "staged") return `staged changes${scope}`;
return `changes vs ${source.base}${scope}`;
}
function gitStatusFor(status: string): GitStatus {
switch (status) {
case "added":
return "added";
case "modified":
return "modified";
case "deleted":
return "deleted";
case "renamed":
return "renamed";
default:
return "untracked";
}
}
function esc(text: string): string {
return text
.replace(/&/g, "&")
.replace(/</g, "<")
.replace(/>/g, ">")
.replace(/"/g, """)
.replace(/'/g, "'");
}
const INLINE_CSS = `
* { box-sizing: border-box; }
:root { --bg: #0b0d10; --fg: #e2e4e9; --panel: #11131a; --panel-2: #161922; --border: #1f232e; --muted: #6b7280; --accent: #2563eb; }
html[data-theme="light"] { --bg: #ffffff; --fg: #0a0a0a; --panel: #f3f4f6; --panel-2: #e5e7eb; --border: #d1d5db; --muted: #6b7280; --accent: #2563eb; }
html, body { margin: 0; height: 100%; font-family: Inter, ui-sans-serif, system-ui, sans-serif; font-size: 13px; color: var(--fg); background: var(--bg); }
#app { display: grid; grid-template-columns: 288px 1fr 320px; height: 100vh; overflow: hidden; position: relative; }
#app:not([data-resizing]) { transition: grid-template-columns .2s ease; }
#app[data-left-collapsed="true"] { grid-template-columns: 0px 1fr 320px; }
#app[data-right-collapsed="true"] { grid-template-columns: 288px 1fr 0px; }
#app[data-left-collapsed="true"][data-right-collapsed="true"] { grid-template-columns: 0px 1fr 0px; }
#app[data-left-collapsed="true"] #sidebar { visibility: hidden; }
#app[data-right-collapsed="true"] #drawer { visibility: hidden; }
.pane-toggle { position: absolute; top: 50%; transform: translateY(-50%); z-index: 10; background: var(--panel-2); border: 1px solid var(--border); border-radius: 4px; color: var(--muted); cursor: pointer; font-size: 14px; padding: 4px 6px; line-height: 1; }
.pane-toggle:hover { color: var(--fg); }
#toggle-left { left: 288px; }
#app:not([data-resizing]) #toggle-left { transition: left .2s ease; }
#toggle-right { right: 320px; }
#app:not([data-resizing]) #toggle-right { transition: right .2s ease; }
#app[data-left-collapsed="true"] #toggle-left { left: 0; }
#app[data-right-collapsed="true"] #toggle-right { right: 0; }
#sidebar { background: var(--panel); border-right: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; }
.brand { padding: 14px 12px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.brand h1 { margin: 0; font-size: 15px; }
.brand .subtitle { font-size: 11px; color: var(--muted); }
#theme-toggle { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 16px; line-height: 1; padding: 4px; border-radius: 4px; }
#theme-toggle:hover { background: var(--panel-2); }
#meta { padding: 8px 12px; display: flex; gap: 6px; flex-wrap: wrap; }
.meta-chip { display: inline-flex; align-items: center; gap: 4px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 4px; padding: 2px 8px; font-size: 11px; }
.meta-label { color: var(--muted); text-transform: uppercase; font-size: 10px; letter-spacing: .04em; }
#tree { flex: 1; overflow: auto; padding: 4px; }
#main { display: flex; flex-direction: column; overflow: hidden; }
#topbar { padding: 10px 16px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.topbar-title { font-weight: 600; }
#summary { font-size: 12px; color: var(--muted); }
.topbar-actions { display: flex; gap: 8px; align-items: center; }
.search-wrap { position: relative; display: flex; align-items: center; }
#search { background: var(--panel-2); border: 1px solid var(--border); border-radius: 6px; padding: 5px 10px; color: inherit; font-size: 12px; width: 180px; padding-right: 24px; }
#search-clear { position: absolute; right: 6px; background: none; border: none; color: var(--muted); cursor: pointer; font-size: 14px; line-height: 1; padding: 2px; }
#search-clear:hover { color: var(--fg); }
#search-badge { position: absolute; right: 24px; font-size: 10px; color: var(--muted); pointer-events: none; }
.count-pill { background: var(--panel-2); border: 1px solid var(--border); border-radius: 999px; padding: 2px 10px; font-size: 11px; }
#diffs { flex: 1; overflow: auto; padding: 12px 16px; }
.file-section { margin-bottom: 24px; }
.file-title { font-size: 13px; font-weight: 600; margin: 0 0 8px; }
#drawer { background: var(--panel); border-left: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; padding: 12px; gap: 12px; }
.card { background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px; }
.card-title { font-weight: 600; font-size: 12px; margin-bottom: 8px; display: flex; justify-content: space-between; }
textarea { width: 100%; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 8px; color: inherit; font-family: inherit; font-size: 12px; resize: vertical; }
.actions { display: flex; gap: 8px; margin-top: 8px; }
.actions button { flex: 1; background: var(--panel-2); border: 1px solid var(--border); border-radius: 6px; padding: 6px; color: inherit; cursor: pointer; font-size: 12px; }
.actions button[type="submit"]:last-child { background: var(--accent); border-color: var(--accent); }
.finding-item { padding: 8px; border-radius: 6px; background: var(--bg); border: 1px solid var(--border); margin-bottom: 6px; }
.finding-item-head { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.finding-number { font-size: 11px; color: var(--muted); }
.finding-pill { font-size: 10px; text-transform: uppercase; letter-spacing: .04em; padding: 1px 6px; border-radius: 4px; }
.finding-pill.high { background: #7f1d1d; color: #fecaca; }
.finding-pill.medium { background: #713f12; color: #fde68a; }
.finding-pill.low { background: #064e3b; color: #a7f3d0; }
.finding-pill.category { background: #1e3a8a; color: #bfdbfe; }
.finding-location { font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.finding-comment { font-size: 12px; }
.remove-finding { margin-left: auto; background: none; border: none; color: var(--muted); cursor: pointer; font-size: 14px; line-height: 1; }
#finding-dialog { background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; color: var(--fg); padding: 16px; width: 400px; max-width: 90vw; }
#finding-dialog::backdrop { background: rgba(0,0,0,.6); }
#finding-dialog h3 { margin: 0 0 10px; font-size: 14px; }
#finding-dialog .field-row { display: flex; gap: 10px; margin-bottom: 10px; }
#finding-dialog label { display: block; font-size: 12px; margin-bottom: 8px; }
#finding-dialog select, #finding-dialog textarea { width: 100%; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 6px; color: inherit; font-family: inherit; font-size: 12px; }
#selection-label { font-size: 11px; color: var(--muted); margin-bottom: 10px; }
.field-subtitle { font-size: 11px; color: var(--muted); margin-top: 2px; font-style: italic; }
[data-line] { cursor: pointer; }
[data-line]:hover { outline: 1px solid color-mix(in srgb, var(--focus, #2563eb) 40%, transparent); outline-offset: -1px; }
#search-results { position: absolute; top: 44px; right: 16px; width: 360px; max-height: 60vh; overflow: auto; background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; z-index: 100; padding: 8px; }
.search-list { display: flex; flex-direction: column; gap: 4px; }
.search-result { display: block; padding: 6px 8px; border-radius: 6px; text-decoration: none; color: inherit; font-size: 12px; }
.search-result:hover { background: var(--panel-2); }
.search-file { font-size: 11px; color: #6b7280; margin-bottom: 2px; }
.search-side { text-transform: uppercase; font-size: 10px; }
.search-line { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; white-space: pre-wrap; word-break: break-all; }
.search-line mark { background: #713f12; color: #fde68a; border-radius: 2px; padding: 0 2px; }
.search-empty { padding: 12px; text-align: center; color: #6b7280; font-size: 12px; }
.search-more { padding: 6px 8px; color: #6b7280; font-size: 11px; text-align: center; }
#topbar { position: relative; }
#status { position: fixed; bottom: 0; left: 0; right: 0; padding: 4px 12px; font-size: 11px; color: var(--muted); background: var(--panel); border-top: 1px solid var(--border); z-index: 100; }
#status.error { color: #f87171; }
#status.ok { color: #34d399; }
`;