kaizen-agent 1.61.4 → 1.61.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/cli/pty.ts CHANGED
@@ -125,7 +125,7 @@ export function startPty(key: string, cmd: string[], cwd: string, pidFile?: stri
125
125
  const ps = winPs();
126
126
  p.proc = Bun.spawn([ps, "-NoProfile", "-NonInteractive", "-EncodedCommand", conptyHost()], {
127
127
  cwd,
128
- env: { ...colorEnv(), KZ_PTY_CMD: innerCommand(ps, cmd), KZ_PTY_CWD: cwd, KZ_PTY_COLS: "120", KZ_PTY_ROWS: "32" },
128
+ env: { ...colorEnv(), KAIZEN_BOARD_PID: String(process.pid), KZ_PTY_CMD: innerCommand(ps, cmd), KZ_PTY_CWD: cwd, KZ_PTY_COLS: "120", KZ_PTY_ROWS: "32" },
129
129
  stdin: "pipe", stdout: "pipe", stderr: "pipe", windowsHide: true,
130
130
  });
131
131
  const read = async (s: ReadableStream<Uint8Array>) => {
@@ -137,7 +137,7 @@ export function startPty(key: string, cmd: string[], cwd: string, pidFile?: stri
137
137
  read(p.proc.stderr as ReadableStream<Uint8Array>).catch(() => {});
138
138
  } else p.proc = Bun.spawn(cmd, {
139
139
  cwd,
140
- env: { ...colorEnv(), TERM: "xterm-256color", COLORTERM: "truecolor" },
140
+ env: { ...colorEnv(), TERM: "xterm-256color", COLORTERM: "truecolor", KAIZEN_BOARD_PID: String(process.pid) },
141
141
  terminal: { cols: 120, rows: 32, data: (_t, d) => push(dec.decode(d, { stream: true })) },
142
142
  });
143
143
  if (opts.tmux && cmd[0] === tmuxBin()) p.tmux = opts.tmux;
@@ -298,7 +298,8 @@ export function loginEnv(shell = process.env.SHELL): Record<string, string> | nu
298
298
  if (!shell || process.platform === "win32") return null;
299
299
  const MARK = "__kaizen_env__";
300
300
  try {
301
- const r = Bun.spawnSync([shell, "-l", "-i", "-c", `echo ${MARK}; env -0`], { stdin: "ignore", stderr: "ignore", timeout: 5000, killSignal: "SIGKILL" });
301
+ // detached: an interactive shell takes the terminal foreground and never hands it back, which left ctrl-c reaching nothing.
302
+ const r = Bun.spawnSync([shell, "-l", "-i", "-c", `echo ${MARK}; env -0`], { stdin: "ignore", stderr: "ignore", timeout: 5000, killSignal: "SIGKILL", detached: true });
302
303
  const out = r.stdout.toString(), at = out.indexOf(MARK + "\n");
303
304
  if (r.exitCode !== 0 || at < 0) return null;
304
305
  const env: Record<string, string> = {};
@@ -167,3 +167,28 @@ test.skipIf(!posix)("a stopped or crashed board resumes its card agents, once af
167
167
  Bun.spawnSync(["pkill", "-f", `${bin}/claude`]);
168
168
  }
169
169
  }, 40_000);
170
+
171
+ // A phone reaches the board through a proxy pinned to its port, so the board an update
172
+ // starts has to outwait the old one instead of walking to the next port.
173
+ test.skipIf(!posix || !Bun.which("lsof"))("a new board takes over the port of a board slow to stop", async () => {
174
+ const port = 20000 + Math.floor(Math.random() * 20000);
175
+ const home = join(root, "takeover");
176
+ mkdirSync(home, { recursive: true });
177
+ const script = join(home, "old.ts");
178
+ writeFileSync(script, `Bun.serve({ hostname: "127.0.0.1", port: ${port}, fetch: () => new Response("old", { headers: { "x-kaizen-version": "0.0.0" } }) });
179
+ process.on("SIGTERM", () => setTimeout(() => process.exit(0), 1500));
180
+ console.log("up");`);
181
+ const old = Bun.spawn([process.execPath, script], { stdout: "pipe" });
182
+ await new Response(old.stdout).body!.getReader().read();
183
+ const fresh = Bun.spawn([process.execPath, join(import.meta.dir, "install.ts"), "web", "--port", String(port), "--no-open", "--foreground"], {
184
+ cwd: home, env: { ...process.env, HOME: home, USERPROFILE: home }, stdin: "ignore", stdout: "ignore", stderr: "ignore",
185
+ });
186
+ try {
187
+ let version: string | null = null;
188
+ for (let i = 0; i < 60 && (!version || version === "0.0.0"); i++) {
189
+ await Bun.sleep(200);
190
+ version = await fetch(`http://127.0.0.1:${port}/`).then((r) => r.headers.get("x-kaizen-version"), () => null);
191
+ }
192
+ expect(version).toBe(JSON.parse(readFileSync(join(import.meta.dir, "..", "package.json"), "utf8")).version);
193
+ } finally { fresh.kill("SIGKILL"); old.kill("SIGKILL"); }
194
+ }, 20000);
package/cli/web.ts CHANGED
@@ -513,9 +513,17 @@ export async function web(repoDir: string, opts: Opts = {}) {
513
513
  // older kaizen serves 404 for whatever came since; both are ours to stop.
514
514
  const pid = await pidOnPort(port);
515
515
  if (pid && pid !== process.pid) {
516
+ // This shell is a tab of that board: stopping it would end the shell running this.
517
+ if (process.env.KAIZEN_BOARD_PID === String(pid)) { console.log(`\n the board on ${port} hosts this terminal; restart it from a terminal outside the board\n`); process.exit(1); }
516
518
  try { process.kill(pid, "SIGTERM"); console.log(` stopped a ${up ? "stale" : "hung"} board on ${port} (pid ${pid})`); } catch { /* not ours to kill */ }
517
- await Bun.sleep(300);
518
- try { server = serve(port); continue; } catch { /* still held */ }
519
+ // A stopping board saves its agents first and can hold the port for seconds. Walking
520
+ // up now would strand this one on a port the phone's tailscale serve does not proxy.
521
+ for (let waited = 0; waited < 8000 && !server; waited += 200) {
522
+ await Bun.sleep(200);
523
+ if (waited === 5000) try { process.kill(pid, "SIGKILL"); } catch { /* already gone */ }
524
+ try { server = serve(port); } catch { /* still held */ }
525
+ }
526
+ if (server) continue;
519
527
  }
520
528
  console.log(` port ${port} refused by the OS and nothing answers there; trying ${port + 1}`);
521
529
  }
@@ -742,7 +750,7 @@ export async function web(repoDir: string, opts: Opts = {}) {
742
750
  // id is read from that run's state.json, never taken from the page). Claude only: it is
743
751
  // the agent whose session id runs record. Refused while that session is still running
744
752
  // elsewhere, since two copies of one conversation overwrite each other's history.
745
- const runKey = typeof body.run === "string" && body.run.length <= 300 ? body.run : "";
753
+ const runKey = typeof body.run === "string" && body.run.length <= 2000 ? body.run : "";
746
754
  if (body.resume === true) {
747
755
  const id = runKey.startsWith("run:" + dir + ":") ? runKey.slice(dir.length + 5) : "";
748
756
  let st: any = {};
@@ -2022,7 +2030,12 @@ export async function web(repoDir: string, opts: Opts = {}) {
2022
2030
  await new Promise<void>((resolve) => {
2023
2031
  // The card agents are listed for the next board and ended (saveLive); the short wait
2024
2032
  // lets each take its /exit, or be ended with what it started, before this process goes.
2033
+ let stopping = false;
2025
2034
  const stop = () => {
2035
+ // A second ctrl-c, or a shutdown that hangs, still ends the process.
2036
+ if (stopping) process.exit(0);
2037
+ stopping = true;
2038
+ setTimeout(() => process.exit(0), 3000).unref();
2026
2039
  const live = ptyKeys().some((k) => ptyState(k)?.alive);
2027
2040
  saveLive();
2028
2041
  clearInterval(poll); clearInterval(ping); clearInterval(gather); clearInterval(loop); clearInterval(keepList);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kaizen-agent",
3
- "version": "1.61.4",
3
+ "version": "1.61.5",
4
4
  "description": "Staged workflow for AI agents — code, writing, research, operations: plan, human approval, build, independent review, bounded fix loop.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -3,7 +3,9 @@
3
3
  // on a computer; a phone has Home, Chat, Runs and Settings.
4
4
  import { runPopup } from "./cards.ts";
5
5
  import { $, html, raw } from "./dom.ts";
6
- import { cardHref, logo, railData, stateOf, subline, titleOf, usageChips } from "./workspace.ts";
6
+ import { cardHref, logo, railData, stateOf, subline, titleOf, usageChips, wsHref } from "./workspace.ts";
7
+ import { toast } from "./toast.ts";
8
+ import { agentStatus, wsKey, type Agent, type Status } from "./ws-tabs.ts";
7
9
 
8
10
  export const isPhone = () => matchMedia("(max-width:640px)").matches;
9
11
 
@@ -11,6 +13,7 @@ type Computer = { name: string; dns: string; os: string; online: boolean };
11
13
  let net: { self: Computer | null; computers: Computer[]; tailscale: boolean } = { self: null, computers: [], tailscale: false };
12
14
  let usage: any[] = [];
13
15
  let mode: "home" | "device" | null = null;
16
+ let allDevices = false;
14
17
 
15
18
  const chev = raw(`<svg class="pchev" viewBox="0 0 24 24" aria-hidden="true"><path d="M9 6l6 6-6 6"/></svg>`);
16
19
  const runs = () => railData().cards.filter((c) => c.kind === "run" && !c.archived);
@@ -27,6 +30,81 @@ function row(c, now: number) {
27
30
  return html`<a class="prow" href="${cardHref(c)}" data-dir="${c.state}" data-id="${rowKey(c)}"><span class="si ${stateOf(c)}"></span><span class="pmain"><b>${titleOf(c)}</b><small>${logo(c.state, name, railData().projects)}${name}</small><code>${subline(c, now)}</code></span></a>`;
28
31
  }
29
32
 
33
+ // Home's slider: one card per workspace with an agent open, those asking first.
34
+ const WORD: Record<Status, string> = { asking: "Asking", working: "Working", done: "Done" };
35
+ const DOT: Record<Status, string> = { asking: "wait", working: "build", done: "done" };
36
+ const RANK: Record<Status, number> = { asking: 0, working: 1, done: 2 };
37
+ const agentIco = (a: Agent) => {
38
+ const id = "i-" + (a.agent || "").toLowerCase();
39
+ return raw(`<svg class="pag-ico" aria-hidden="true"><use href="#${document.getElementById(id) ? id : "i-ai"}"/></svg>`);
40
+ };
41
+ const wsName = (a: Agent) => a.ws?.split(/[\\/]/).pop() || "main";
42
+ const groupKey = (a: Agent) => a.dir + "\n" + (a.ws ?? ""); // a NUL would not survive innerHTML
43
+ function agentGroups(now: number) {
44
+ const groups = new Map<string, { a: Agent; st: Status }[]>();
45
+ for (const a of (railData().agents ?? []) as Agent[]) {
46
+ const k = groupKey(a);
47
+ groups.set(k, [...(groups.get(k) ?? []), { a, st: agentStatus(a, now) }]);
48
+ }
49
+ const list = [...groups].map(([k, rows]) => ({ k, rows: rows.sort((x, y) => RANK[x.st] - RANK[y.st]) }));
50
+ return list.sort((x, y) => RANK[x.rows[0].st] - RANK[y.rows[0].st]);
51
+ }
52
+ function agentCards(now: number) {
53
+ const groups = agentGroups(now);
54
+ const asking = groups.filter((g) => g.rows[0].st === "asking").length;
55
+ const cards = groups.map(({ k, rows }) => {
56
+ const { a, st } = rows[0];
57
+ return html`<button type="button" class="pag${st === "asking" ? " ask" : ""}" data-group="${k}"><span class="pag-st"><i class="si ${DOT[st]}"></i>${rows.length > 1 ? rows.length + " agents" : WORD[st]}<span class="pag-icos">${rows.map((r) => agentIco(r.a))}</span></span><span class="pag-ws">${wsName(a)}</span><small>${projName(a.dir)}</small></button>`;
58
+ });
59
+ return html`<section class="psec2"><div class="pag-h"><h3>Agents${asking ? html`<span class="pag-n">${asking} asking</span>` : ""}</h3><button type="button" class="pag-new">New</button></div>${groups.length ? html`<div class="pslide">${cards}</div>` : html`<p class="pnote">No agents running.</p>`}</section>`;
60
+ }
61
+ function openTerm(a: Agent) {
62
+ if (dispatchEvent(new CustomEvent("kz-open-term", { cancelable: true, detail: { dir: a.dir, ws: a.ws, key: a.key } }))) location.href = wsHref(a.dir, a.ws ?? "");
63
+ }
64
+ // Several agents in a workspace: a sheet picks which terminal to open.
65
+ function pickAgent(rows: { a: Agent; st: Status }[]) {
66
+ const d = document.createElement("dialog");
67
+ d.className = "pagsheet";
68
+ d.innerHTML = String(html`<h4>${wsName(rows[0].a)}</h4>${rows.map(({ a, st }, i) => html`<button type="button" data-i="${String(i)}">${agentIco(a)}${a.name || a.agent || "Terminal"}<i class="si ${DOT[st]}"></i><small>${WORD[st]}</small></button>`)}<button type="button" data-new="1">${agentIco({ agent: "" } as Agent)}New agent</button>`);
69
+ d.addEventListener("click", (e) => {
70
+ const b = (e.target as HTMLElement).closest<HTMLButtonElement>("button");
71
+ d.close();
72
+ if (b?.dataset.new) void newSheet(rows[0].a.dir, rows[0].a.ws);
73
+ else if (b) openTerm(rows[Number(b.dataset.i)].a);
74
+ });
75
+ d.addEventListener("close", () => d.remove());
76
+ document.body.append(d);
77
+ d.showModal();
78
+ }
79
+
80
+ // New: pick a workspace, then an agent or a plain shell. It starts as a tab of that
81
+ // workspace, the same POST the workspace's own + button makes.
82
+ async function newSheet(dir?: string, ws?: string) {
83
+ const spots = (railData().projects ?? []).flatMap((p) => (p.workspaces ?? []).map((w) => ({ dir: p.dir as string, ws: w.path as string, name: w.branch || w.path.split(/[\\/]/).pop() })));
84
+ const first = agentGroups(Date.now())[0]?.rows[0].a;
85
+ const on = spots.find((x) => x.dir === (dir ?? first?.dir) && x.ws === (ws ?? first?.ws)) ?? spots[0];
86
+ if (!on) return toast("Add a project on a computer first");
87
+ const list = await fetch("/agents?dir=" + encodeURIComponent(on.dir)).then((r) => r.json(), () => null);
88
+ const kinds: { cmd: string; name: string }[] = [...(list?.agents ?? []), { cmd: "", name: "Shell" }];
89
+ const d = document.createElement("dialog");
90
+ d.className = "pagsheet";
91
+ d.innerHTML = String(html`<h4>New in</h4><select aria-label="Workspace">${spots.map((x, i) => html`<option value="${String(i)}"${raw(x === on ? " selected" : "")}>${projName(x.dir)} ${x.name}</option>`)}</select>${kinds.map((k, i) => html`<button type="button" data-i="${String(i)}">${k.cmd ? agentIco({ agent: k.cmd } as Agent) : raw(`<svg class="pag-ico" aria-hidden="true"><use href="#i-term"/></svg>`)}${k.name}</button>`)}`);
92
+ d.addEventListener("click", async (e) => {
93
+ const b = (e.target as HTMLElement).closest<HTMLButtonElement>("button");
94
+ if (e.target === d) return d.close();
95
+ if (!b) return;
96
+ const at = spots[Number(d.querySelector("select")!.value)], cmd = kinds[Number(b.dataset.i)].cmd;
97
+ d.close();
98
+ const r = await fetch("/shell", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ dir: at.dir, ws: at.ws, run: wsKey(at.dir, at.ws), ...(cmd ? { agent: cmd } : {}) }) }).catch(() => null);
99
+ const sh = r?.ok ? await r.json() : null;
100
+ if (sh) openTerm({ dir: at.dir, ws: at.ws, key: sh.key } as Agent);
101
+ else toast("No new terminal: " + ((await r?.json().catch(() => null))?.error || "the board did not answer"));
102
+ });
103
+ d.addEventListener("close", () => d.remove());
104
+ document.body.append(d);
105
+ d.showModal();
106
+ }
107
+
30
108
  function home() {
31
109
  const now = Date.now();
32
110
  const all = runs();
@@ -34,12 +112,15 @@ function home() {
34
112
  const waiting = all.filter((c) => stateOf(c) === "wait").length;
35
113
  const projects = new Set(all.map((c) => c.state)).size;
36
114
  const me = net.self?.name || "This computer";
37
- const others = net.computers.map(
115
+ // Two devices show, this computer first; the rest wait behind Show more.
116
+ const others = net.computers.slice(0, allDevices ? undefined : 1).map(
38
117
  (d) =>
39
118
  html`<a class="pdev" href="${d.dns ? "https://" + d.dns + "/" : "#"}" target="_blank" rel="noopener"${raw(d.dns ? "" : ' aria-disabled="true"')}><span class="pico"><svg><use href="#r-desk"/></svg></span><span class="pmain"><b>${d.name}</b><small><i class="pdot${d.online ? " on" : ""}"></i>${d.online ? "Connected" : "Disconnected"}${d.os ? " · " + d.os : ""}</small></span>${chev}</a>`,
40
119
  );
41
120
  const recent = [...all].sort((a, b) => (b.moved ?? 0) - (a.moved ?? 0)).slice(0, 12);
42
- return html`<section class="psec2"><h3>Devices</h3><a class="pdev" href="/?view=device" data-dev="here"><span class="pico"><svg><use href="#r-desk"/></svg></span><span class="pmain"><b>${me}</b><small><i class="pdot on"></i>Connected · ${projects} project${projects === 1 ? "" : "s"} · ${active.length} active${waiting ? html` · <em>${waiting} waiting</em>` : ""}</small></span>${chev}</a>${others}${net.tailscale ? "" : html`<p class="pnote">Tailscale is off on this computer: other devices do not show.</p>`}</section>
121
+ const hidden = net.computers.length - 1;
122
+ const more = hidden > 0 ? html`<button type="button" class="pmore" aria-expanded="${String(allDevices)}"><span>${allDevices ? "Show less" : `Show ${hidden} more`}</span><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M6 9l6 6 6-6"/></svg></button>` : "";
123
+ return html`${agentCards(now)}<section class="psec2"><h3>Devices</h3><a class="pdev" href="/?view=device" data-dev="here"><span class="pico"><svg><use href="#r-desk"/></svg></span><span class="pmain"><b>${me}</b><small><i class="pdot on"></i>Connected · ${projects} project${projects === 1 ? "" : "s"} · ${active.length} active${waiting ? html` · <em>${waiting} waiting</em>` : ""}</small></span>${chev}</a>${others}${more}${net.tailscale ? "" : html`<p class="pnote">Tailscale is off on this computer: other devices do not show.</p>`}</section>
43
124
  <section class="psec2"><h3>Runs</h3><div class="plist2">${recent.map((c) => row(c, now))}${recent.length ? "" : html`<p class="pnote">No runs yet.</p>`}</div></section>${usage.length ? html`<section class="psec2"><h3>Usage</h3><div class="pusage">${raw(usageChips(usage))}</div></section>` : ""}`;
44
125
  }
45
126
 
@@ -59,7 +140,10 @@ function draw() {
59
140
  const el = $("phome");
60
141
  if (!el || !mode) return;
61
142
  const keep = mode === "device" ? [...el.querySelectorAll("details")].map((d) => d.open) : [];
143
+ const slid = el.querySelector(".pslide")?.scrollLeft ?? 0;
62
144
  el.innerHTML = String(mode === "home" ? home() : device());
145
+ const slide = el.querySelector(".pslide");
146
+ if (slide) slide.scrollLeft = slid;
63
147
  el.querySelectorAll("details").forEach((d, i) => keep[i] !== undefined && (d.open = keep[i]));
64
148
  }
65
149
 
@@ -103,7 +187,16 @@ export function initPhone(go: (v: string, push?: boolean) => void, openRun: (c)
103
187
  );
104
188
  $("phome")?.addEventListener("click", (e) => {
105
189
  if ((e as MouseEvent).ctrlKey || (e as MouseEvent).metaKey) return;
106
- const a = (e.target as HTMLElement).closest<HTMLAnchorElement>("a");
190
+ const t = e.target as HTMLElement;
191
+ if (t.closest(".pag-new")) return void newSheet();
192
+ if (t.closest(".pmore")) return (allDevices = !allDevices), draw();
193
+ const group = t.closest<HTMLElement>(".pag")?.dataset.group;
194
+ if (group) {
195
+ const rows = agentGroups(Date.now()).find((g) => g.k === group)?.rows;
196
+ if (rows) rows.length > 1 ? pickAgent(rows) : openTerm(rows[0].a);
197
+ return;
198
+ }
199
+ const a = t.closest<HTMLAnchorElement>("a");
107
200
  if (!a) return;
108
201
  if (a.dataset.dev) return (e.preventDefault(), go("device", true));
109
202
  if (a.getAttribute("aria-disabled")) return e.preventDefault();
package/web/board.html CHANGED
@@ -162,12 +162,20 @@ html body.runv .app{grid-template-rows:auto minmax(0,1fr)}html body.runv .hdr{di
162
162
  html body.runv #rtabs{padding:0 10px 6px}html body.runv .app{margin:0!important}
163
163
  .srow{grid-template-columns:minmax(0,1fr) auto}.srow select.sel{max-width:52vw}
164
164
  body.phomev .hdr>:not(h1):not(#newtop),body.phomev #board{display:none!important}
165
+ body.phomev:not(.pdevv) #newtop{display:none!important}
165
166
  body.phomev #phome{display:block;flex:1;min-height:0;overflow:auto;padding:4px 16px 24px;animation:fi .2s}
166
167
  }
167
168
  #phome h3{margin:18px 4px 8px;font-size:11px;font-weight:600;letter-spacing:.06em;text-transform:uppercase;color:var(--dim)}
168
169
  #phome .psec2:first-child h3{margin-top:6px}
169
170
  .pdev{display:flex;align-items:center;gap:12px;margin-bottom:8px;padding:10px 12px;border:1px solid var(--line);border-radius:12px;background:var(--bg-2);color:var(--ink);text-decoration:none}
170
171
  .pdev[aria-disabled]{opacity:.6}
172
+ .pslide{display:grid;grid-auto-flow:column;grid-template-rows:repeat(2,auto);grid-auto-columns:min(44vw,164px);gap:8px;overflow-x:auto;scroll-snap-type:x proximity;scroll-padding:0 16px;margin:0 -16px;padding:0 16px 4px;scrollbar-width:none;overscroll-behavior-x:contain}.pslide::-webkit-scrollbar{display:none}
173
+ .pag{all:unset;box-sizing:border-box;cursor:pointer;scroll-snap-align:start;display:flex;flex-direction:column;gap:6px;min-width:0;min-height:92px;padding:10px 12px;border:1px solid var(--line);border-radius:12px;background:var(--bg-2);color:var(--ink);transition:border-color .15s}.pag:active{border-color:var(--ink)}.pag:focus-visible,.pmore:focus-visible{outline:2px solid var(--accent)}.pag.ask{border-color:var(--warn)}
174
+ .pag-st{display:flex;align-items:center;gap:6px;font-size:13px;font-weight:600}.pag-icos{display:flex;gap:4px;margin-left:auto}.pag-ico{width:16px;height:16px;flex:none}.pag-ws{font:12px var(--mono);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.pag small{font-size:12px;color:var(--dim);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.pag-n{float:right;text-transform:none;letter-spacing:0}
175
+ .pmore{all:unset;box-sizing:border-box;cursor:pointer;display:flex;align-items:center;justify-content:space-between;width:100%;min-height:48px;margin-bottom:8px;padding:0 12px;border:1px solid var(--line);border-radius:12px;background:var(--bg-2);font-size:15px;color:var(--ink);transition:background .15s}.pmore:active{background:var(--hover)}.pmore svg{width:18px;height:18px;fill:none;stroke:var(--dim);stroke-width:2;stroke-linecap:round;stroke-linejoin:round;transition:transform .2s}.pmore[aria-expanded=true] svg{transform:rotate(180deg)}
176
+ .pag-h{display:flex;align-items:center;justify-content:space-between;gap:8px}.pag-h h3{flex:1}.pag-new{all:unset;cursor:pointer;display:flex;align-items:center;min-height:44px;padding:0 4px 0 12px;font-size:14px;font-weight:600;color:var(--ink)}.pag-new:focus-visible{outline:2px solid var(--accent)}.pagsheet select{width:100%;min-height:44px;margin-bottom:8px;font:inherit;color:var(--ink);background:var(--bg);border:1px solid var(--line);border-radius:8px;padding:0 8px}
177
+ .pagsheet{position:fixed;inset:auto 0 0;width:100%;max-width:none;margin:0;padding:12px 16px calc(20px + env(safe-area-inset-bottom));border:0;border-top:1px solid var(--line);border-radius:16px 16px 0 0;background:var(--bg-2);color:var(--ink)}.pagsheet::backdrop{background:rgb(0 0 0/.45)}.pagsheet h4{margin:0 0 8px;font:13px var(--mono)}.pagsheet button{all:unset;box-sizing:border-box;cursor:pointer;display:flex;align-items:center;gap:8px;width:100%;min-height:48px;border-top:1px solid var(--line);font-size:14px}.pagsheet small{margin-left:auto;font-size:12px;color:var(--dim)}
178
+ @media(prefers-reduced-motion:reduce){.pmore svg{transition:none}}
171
179
  .pico{width:36px;height:36px;display:grid;place-items:center;flex:none;border-radius:9px;background:var(--hover);color:var(--dim)}.pico svg{width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:1.8}
172
180
  .pmain{flex:1;min-width:0;display:flex;flex-direction:column;gap:2px}
173
181
  .pmain b{font-size:14px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}