diff --git a/docs/feature-map/README.md b/docs/feature-map/README.md
index 76a9eb2..2553db5 100644
--- a/docs/feature-map/README.md
+++ b/docs/feature-map/README.md
@@ -110,6 +110,7 @@ Bot 讀得到的是開頭、子功能、使用者怎麼到、Bot 那一行和沒
- [apps](apps.md):Mac 的郵件、備忘錄、訊息,電話、簡訊、X、手機的行事曆與聯絡人。
- [channels](channels.md):Slack、Discord、Telegram、Teams。
- [phone](phone.md):手機頁面、手機上的卡、長相與顏色、裝成 App。
+- [phonefit](phonefit.md):手機畫面貼齊:主畫面 App 自己量螢幕,iOS 少給下面一條時讓開上面的霧面、不重複留底;鍵盤收起沒長回來就重排;設定 › 更新 › 畫面的量尺。
- [account](account.md):AnyBot 帳號、備份、大腦、同一個網路直接連、推播通知。
### 管住它、調整它
diff --git a/docs/feature-map/phonefit.md b/docs/feature-map/phonefit.md
new file mode 100644
index 0000000..294f7d7
--- /dev/null
+++ b/docs/feature-map/phonefit.md
@@ -0,0 +1,34 @@
+# 手機畫面貼齊
+
+加到主畫面的 AnyBot 要從螢幕最上面到最下面都是自己的:不被切到、不被霧面蓋到、下面不空一塊。每支 iPhone、每個 iOS 版本給網頁的空間不一樣,所以手機頁面打開時自己量,照量到的排,不靠一個寫死的數字。
+
+## 子功能
+
+- `phonefit-measure` 量:打開、回到前面、轉向、離開輸入框時,比螢幕高度、這頁看得到的高度和上下留白(狀態列、底部手勢條)。只看 iPhone 加入主畫面的 App;iPad、瀏覽器裡的不動。
+- `phonefit-short` iOS 少給下面一條(iOS 26.1、26.5 以後、27;WebKit 問題 301994):看得到的比螢幕少一個狀態列高,那條由系統畫、網頁畫不到,上面還多一層霧面。這時標題列往下讓開霧面(上面留白改成狀態列的 1.55 倍),底部不再多留手勢條的空間(它已經在系統那條裡),輸入框底下的顏色改成跟頁面一樣(系統那條也是這個顏色)。狀態列佔了上面的那種(上面留白是 0)不動。
+- `phonefit-keyboard` 鍵盤收起後畫面沒長回來(iOS 主畫面 App 的老問題,要關掉 App 才好):離開輸入框 0.14 秒後還比量過最高的矮,就把整頁重新排一次(捲到哪裡留著),再量一次。
+- `phonefit-ruler` 設定 › 更新 ›「這支手機」›「畫面」:一行寫量到的——螢幕寬×高、看得到多高、上/下留白、是哪一種、iOS 版本、主畫面 App 還是瀏覽器。點了打開量尺:上面、下面每 10 一格的刻度,中間是那幾個數字,頁面底下外面一條紅色(看得到=下面那條也能畫);點一下關掉。
+
+## 使用者怎麼到
+
+- iPhone:Safari 分享 ›「加入主畫面」,從主畫面打開;量是自動的。
+- 設定(帳戶選單)›「更新」›「畫面」。
+
+## 怎麼操作(verify-anybot)
+
+- Bot:沒有專門的工具;使用者說手機畫面被切到、上面糊糊的、下面空一塊,請他到 設定 › 更新 ›「畫面」打開量尺截圖。
+
+前提:
+
+- 基本前提和「手機已登入」(README)。無頭 Chrome 不是 iPhone 主畫面 App:用 `window.FIT_TEST` 代替手機量到的數字(只在那一頁有效)。
+
+- **iOS 少給下面一條**(covers `phonefit-measure`、`phonefit-short`):指令:`$CTL phone click '.row[data-bot="1"]' && $CTL phone js '(() => { window.FIT_TEST = {iphone:true,standalone:true,screenW:393,screenH:852,innerH:793,safeT:59,safeB:34}; fit(); const cs = (q) => getComputedStyle(document.querySelector(q)); return [FIT.mode, cs("#v-chat .bar").paddingTop, cs(".dock").paddingBottom].join(" "); })()' && $CTL phone shot phonefit-short`;再把 innerH 換成 852(正常)、safeT 換成 0(狀態列佔上面)、iphone 換成 false(iPad)各跑一次。看到:「short 95px 8px」,截圖標題列往下、輸入框貼近底部;另外三次 mode 是空的或 topbar,標題列 4px、底部 8px(Chrome 的留白是 0)。
+- **量尺**(covers `phonefit-ruler`):換過程式後要開兩次(第一次是存著的舊頁面)。指令:`$CTL phone open --listed && $CTL phone open --listed && $CTL phone click '#b-me' && $CTL phone click '#sheet-in .opt' --text 設定 && $CTL phone click '[data-go="updates"]' && $CTL phone wait '[data-ruler]' && $CTL phone click '[data-ruler]' && $CTL phone wait '#ruler' && $CTL phone shot phonefit-ruler`。看到:「畫面」那行「390×844,看得到 844;上 0/下 0;整個螢幕都是 AnyBot 的;iOS 18.0;瀏覽器」;量尺左上、右下各一排刻度(20、40…140),中間是那幾個數字;紅色那條在畫面外(Chrome 看不到)。
+- **鍵盤收起、真的 iPhone**(covers `phonefit-keyboard`、`phonefit-short`):指令:走不到——要實機:主畫面打開、打字再收鍵盤、看上面糊不糊、下面空不空,打開量尺截圖。看到:實機上標題列清楚、輸入框貼近手勢條,量尺那行是實機的數字。
+- 自動測試:`cargo test featuremap::`。
+
+## 陷阱
+
+- 下面那條是系統畫的,網頁畫不到:只能讓顏色一樣,輸入框不會跑進去(不切到)。
+- 霧面往下多深是量 iPhone 15 Pro 的截圖估的(狀態列的 1.55 倍);別的機型、別的 iOS 版本用量尺確認後再調。
+- 用帳號連線時,手機頁面是帳號伺服器發的:改了要更新帳號伺服器;更新後第一次打開還是存著的舊頁面,再打開一次才換新的。
diff --git a/mobile/index.html b/mobile/index.html
index 365d79d..810ba38 100644
--- a/mobile/index.html
+++ b/mobile/index.html
@@ -532,7 +532,7 @@ textarea.field{min-height:96px;line-height:1.5}
.fmedia{padding:28px 18px;display:grid;gap:12px;place-items:center}
.fmedia audio,.fmedia video{width:100%;max-width:560px;border-radius:var(--r-m)}
.fdl{display:grid;place-items:center;gap:14px;padding:64px 24px;color:var(--text2);text-align:center;line-height:1.6}
-.pager{display:flex;align-items:center;justify-content:center;gap:14px;padding:8px 12px;padding-bottom:max(8px,env(safe-area-inset-bottom));border-top:1px solid var(--line);background:var(--pane);flex:none}
+.pager{display:flex;align-items:center;justify-content:center;gap:14px;padding:8px 12px;padding-bottom:max(8px,var(--safe-b));border-top:1px solid var(--line);background:var(--pane);flex:none}
.pager span{font-size:var(--fs-small);color:var(--text2);min-width:72px;text-align:center}
.boxwrap{position:fixed;inset:0;z-index:50;background:var(--stage);display:none}
.boxwrap iframe{width:100%;height:100%;border:0;display:block}
@@ -578,6 +578,14 @@ textarea.field{min-height:96px;line-height:1.5}
.pair-line{display:block;font:var(--fs-caption)/1.5 var(--mono);background:var(--hover);padding:10px;border-radius:var(--r-m);margin:6px 16px;word-break:break-all}
/* ---- feels installed (a PWA on every phone) ---- */
:root{--safe-l:env(safe-area-inset-left,0px);--safe-r:env(safe-area-inset-right,0px)}
+/* 頂天立地 (fit() below): on an iPhone that gives a home-screen app a status bar less at the bottom
+ (the system draws that strip, in the page's colour), what meets it is the page's colour too. */
+html.fit-short .dock{background:linear-gradient(to bottom,transparent,var(--pane) 40%)}
+html.fit-short .tools{background:var(--pane)}
+/* 畫面量尺 (設定 › 更新 › 畫面): where the frost ends at the top, where the page ends at the bottom. */
+#ruler{position:fixed;inset:0;z-index:99;background:color-mix(in srgb,var(--pane) 55%,transparent);font:var(--fs-caption)/1.3 var(--font);color:var(--text)}
+#ruler .info{position:absolute;left:16px;right:16px;top:40%;transform:translateY(-50%);background:var(--elev);border:1px solid var(--line);border-radius:var(--r-l);padding:14px 16px;white-space:pre-wrap}
+#ruler .past{position:absolute;left:0;right:0;bottom:-80px;height:80px;background:var(--danger);color:var(--on-color);display:grid;place-items:center;font-weight:600}
/* No font inflation when the phone turns sideways. */
html{-webkit-text-size-adjust:100%;text-size-adjust:100%}
/* A phone on its side with a notch: every screen paints edge to edge, its content stays clear of it. */
@@ -3247,8 +3255,11 @@ function drawSettings(kind, quiet) {
if (kind === "updates") {
h += group("", item({icon: "info", k: "版本", v: st.built ? `${stamp(st.built)} 建置` : "", r: st.version || ""}) + (st.newer ? item({icon: "download", k: "有新版", v: "電腦上的 AnyBot 已經下載新版,重新啟動就會換上"}) : item({icon: "circle-check", k: "已是最新版"})));
h += `
Bot 的電腦的更新在「電腦」裡。
`;
+ h += group("這支手機", item({icon: "smartphone", k: "畫面", v: fitWords(), tap: 1, data: 'data-ruler="1"'}));
+ h += `畫面看起來被切到、上面糊糊的、下面空一塊時,按「畫面」打開量尺截圖給我們。
`;
}
el.innerHTML = h + ``;
+ el.querySelectorAll("[data-ruler]").forEach((x) => x.onclick = ruler);
if (quiet) el.scrollTop = sc;
wireSettings(kind, st);
}
@@ -4378,6 +4389,102 @@ if ("serviceWorker" in navigator) navigator.serviceWorker.addEventListener("mess
}
if (d.bot && S.token) go("chat", {bot: +d.bot}); else if (d.bot) S.open = +d.bot;
});
+// ── 頂天立地: what the phone really gives the page, measured (no one CSS value is right on every iOS) ──
+// · Most phones and iOS versions: the whole screen, drawn under a clear status bar — nothing to do.
+// · iOS 26.1, 26.5 and later, 27 (WebKit bug 301994): a home-screen app still starts under the
+// status bar but is a status bar short at the bottom — the system draws that strip, the page
+// can't — and a frosted system bar lies over the top (measured on an iPhone 15 Pro: down to
+// about the status bar and a half). Then the header moves below the frost, the home-indicator
+// room isn't added again (it is inside the system's strip), and what meets the strip is the
+// page's colour.
+// · The status bar taking its room at the top (the inset is 0 then): nothing to do.
+// · The keyboard bug (after the first keyboard the page stays a status bar short until the app is
+// closed): when a text box lets go the page is laid out again once (that undoes it), then measured.
+// (window.FIT_TEST stands in for the phone in the scratch checks: {iphone, standalone, screenW,
+// screenH, innerH, safeT, safeB}.)
+const FIT = {mode: "", lost: 0, safeT: 0, safeB: 0, screenW: 0, screenH: 0, innerH: 0, tallest: {}, healed: 0};
+function insets() {
+ const p = document.createElement("div");
+ p.style.cssText = "position:fixed;visibility:hidden;pointer-events:none;padding-top:env(safe-area-inset-top);padding-bottom:env(safe-area-inset-bottom)";
+ document.body.appendChild(p);
+ const cs = getComputedStyle(p), v = [parseFloat(cs.paddingTop) || 0, parseFloat(cs.paddingBottom) || 0];
+ p.remove();
+ return v;
+}
+function fit() {
+ if (!document.body) return;
+ const T = window.FIT_TEST || {};
+ const iphone = T.iphone ?? /iPhone/.test(navigator.userAgent);
+ const standalone = T.standalone ?? installed();
+ const [safeT, safeB] = T.safeT != null ? [T.safeT, T.safeB || 0] : insets();
+ const sw = T.screenW ?? screen.width, sh = T.screenH ?? screen.height;
+ const landscape = matchMedia("(orientation: landscape)").matches;
+ const screenH = landscape ? Math.min(sw, sh) : Math.max(sw, sh), innerH = T.innerH ?? innerHeight;
+ const key = landscape ? "l" : "p";
+ FIT.tallest[key] = Math.max(FIT.tallest[key] || 0, innerH);
+ // Only an iPhone's home-screen app, and only about a status bar's worth (an iPad in a window
+ // is much shorter than its screen, and that is not this).
+ const lost = iphone && standalone ? Math.round(screenH - innerH) : 0;
+ const mode = lost >= 20 && lost <= 90 ? (safeT >= 20 ? "short" : "topbar") : "";
+ const root = document.documentElement;
+ if (mode === "short") {
+ root.style.setProperty("--safe-t", Math.round(safeT * 1.55) + "px");
+ root.style.setProperty("--safe-b", Math.max(0, Math.round(safeB - lost)) + "px");
+ root.classList.add("fit-short");
+ } else {
+ root.style.removeProperty("--safe-t");
+ root.style.removeProperty("--safe-b");
+ root.classList.remove("fit-short");
+ }
+ Object.assign(FIT, {mode, lost, safeT, safeB, screenW: landscape ? Math.max(sw, sh) : Math.min(sw, sh), screenH, innerH});
+}
+// A text box let go: the keyboard bug leaves the page short — laid out again once, scroll kept.
+function heal() {
+ const app = document.querySelector(".app");
+ if (!app) return;
+ const keep = [...document.querySelectorAll(".scroll")].map((x) => [x, x.scrollTop]);
+ app.style.display = "none"; void app.offsetHeight; app.style.display = "";
+ keep.forEach(([x, y]) => { x.scrollTop = y; });
+ FIT.healed++;
+}
+document.addEventListener("focusout", (e) => {
+ if (!e.target || !e.target.matches || !e.target.matches("input,textarea,[contenteditable]")) return;
+ setTimeout(() => {
+ const key = matchMedia("(orientation: landscape)").matches ? "l" : "p";
+ if (installed() && innerHeight < (FIT.tallest[key] || 0) - 4) heal();
+ requestAnimationFrame(fit);
+ }, 140);
+});
+addEventListener("resize", fit);
+addEventListener("orientationchange", () => setTimeout(fit, 300));
+addEventListener("pageshow", fit);
+document.addEventListener("visibilitychange", () => { if (!document.hidden) fit(); });
+fit();
+// 設定 › 更新 › 畫面: what was measured, in words.
+function fitWords() {
+ const f = FIT, ios = (navigator.userAgent.match(/OS (\d+)_(\d+)/) || []).slice(1).join(".");
+ const what = f.mode === "short" ? `iOS 少給了下面 ${f.lost} pt(系統自己畫),上面讓開霧面` : f.mode === "topbar" ? `狀態列佔了上面 ${f.lost} pt` : "整個螢幕都是 AnyBot 的";
+ return `${f.screenW}×${f.screenH},看得到 ${f.innerH};上 ${f.safeT}/下 ${f.safeB};${what}${ios ? `;iOS ${ios}` : ""}${installed() ? ";主畫面 App" : ";瀏覽器"}`;
+}
+// The ruler: tick marks every 10 pt from the top and from the bottom, the numbers in the middle,
+// and a red band just past the page's bottom (seen: the strip below can be drawn on). A tap closes it.
+function ruler() {
+ const old = $("ruler");
+ if (old) { old.remove(); return; }
+ fit();
+ const r = document.createElement("div");
+ r.id = "ruler";
+ let h = "";
+ // (Every mark in its own inline style: nothing else on the page may size it.)
+ const tick = (side, y) => `` +
+ (y % 20 ? "" : `${y}`);
+ for (let y = 0; y <= 140; y += 10) h += tick("top", y) + tick("bottom", y);
+ h += `${esc(fitWords().split(";").join("\n"))}\n\n上面糊到哪一格、下面最後看得到哪一格?截圖給我們。點一下關掉。
`;
+ h += `看到這條紅色=最下面還能畫
`;
+ r.innerHTML = h;
+ r.onclick = () => r.remove();
+ document.body.appendChild(r);
+}
// iOS: the keyboard floats over the page instead of shrinking it; measure it and lift the composer.
if (window.visualViewport) {
const kb = () => {
diff --git a/src/featuremap.rs b/src/featuremap.rs
index 65af9b1..2ea1f8f 100644
--- a/src/featuremap.rs
+++ b/src/featuremap.rs
@@ -63,6 +63,7 @@ pub const AREAS: &[Area] = &[
area!("apps", "Mac App 與電話"),
area!("channels", "訊息管道"),
area!("phone", "手機頁面"),
+ area!("phonefit", "手機畫面貼齊"),
area!("account", "帳號與直接連線"),
area!("safety", "安全與核准"),
area!("sandbox", "安全規則與沙盒"),