diff --git a/index.html b/index.html
index a2bea39..8d69113 100644
--- a/index.html
+++ b/index.html
@@ -792,15 +792,20 @@ function showTab(tabId){
}
/* ---------- helpers ---------- */
-function seg(el){ el.querySelectorAll("button").forEach(b=>b.onclick=()=>{
- el.querySelectorAll("button").forEach(x=>x.classList.remove("on")); b.classList.add("on");});}
-seg($("segPx")); seg($("segLen"));
+function seg(el){
+ if(!el) return;
+ el.querySelectorAll("button").forEach(b=>b.onclick=()=>{
+ el.querySelectorAll("button").forEach(x=>x.classList.remove("on"));
+ b.classList.add("on");
+ });
+}
+document.querySelectorAll(".seg").forEach(el=>seg(el));
document.querySelectorAll(".sw").forEach(s=>s.onclick=()=>{
s.classList.toggle("on");
- if(s.id==="swRouter") $("routerCfg").style.display = s.classList.contains("on") ? "block" : "none";
+ if(s.id==="swRouter" && $("routerCfg")) $("routerCfg").style.display = s.classList.contains("on") ? "block" : "none";
});
-const segVal=el=>el.querySelector("button.on").dataset.v;
-const swOn=id=>$(id).classList.contains("on");
+const segVal=el=>(el && el.querySelector("button.on")) ? el.querySelector("button.on").dataset.v : "";
+const swOn=id=>$(id) ? $(id).classList.contains("on") : false;
/* ---------- appearance settings (accent color, density, page size) ---------- */
const ACCENT_PRESETS = ["#22d3ee","#e879f9","#4ade80","#fbbf24","#f87171","#818cf8","#fb923c"];