:root{
  --bg:#1e1e1e;--bg2:#252525;--bg3:#2a2a2a;--bg4:#333;
  --fg:#ddd;--fg2:#aaa;--fg3:#888;--accent:#4fc3f7;
  --ok:#6ad86a;--err:#f77;--warn:#fc3;--code:#ce9178;--border:#333;
  --v-num:#22d3ee;--v-null:#64748b;--v-bool-t:#4ade80;--v-bool-f:#94a3b8;
  --c-basic:#4fc3f7;--c-sys:#22d3ee;--c-net:#38bdf8;--c-sensors:#a78bfa;
  --c-hw:#fb923c;--c-display:#f472b6;--c-apps:#facc15;--c-comm:#2dd4bf;
  --c-detail:#fbbf24;--c-file:#c084fc;--c-watch:#f472b6;
}
/* MTAPI_108: @media light убран */
html[data-theme="light"]{--bg:#f8f8f8;--bg2:#fff;--bg3:#f0f0f0;--bg4:#e0e0e0;
  --fg:#222;--fg2:#555;--fg3:#777;--accent:#0288d1;
  --ok:#388e3c;--err:#c62828;--warn:#f57c00;--code:#c2185b;--border:#ddd;
  --v-num:#00838f;--v-null:#94a3b8;--v-bool-t:#2e7d32;--v-bool-f:#64748b;
  --c-basic:#0288d1;--c-sys:#00838f;--c-net:#0277bd;--c-sensors:#6a1b9a;
  --c-hw:#e65100;--c-display:#c2185b;--c-apps:#f57c00;--c-comm:#00897b;
  --c-detail:#ef6c00;--c-file:#7b1fa2;--c-watch:#c2185b}
html[data-theme="dark"]{--bg:#1e1e1e;--bg2:#252525;--bg3:#2a2a2a;--bg4:#333;
  --fg:#ddd;--fg2:#aaa;--fg3:#888;--accent:#4fc3f7;
  --ok:#6ad86a;--err:#f77;--warn:#fc3;--code:#ce9178;--border:#333;
  --v-num:#22d3ee;--v-null:#64748b;--v-bool-t:#4ade80;--v-bool-f:#94a3b8;
  --c-basic:#4fc3f7;--c-sys:#22d3ee;--c-net:#38bdf8;--c-sensors:#a78bfa;
  --c-hw:#fb923c;--c-display:#f472b6;--c-apps:#facc15;--c-comm:#2dd4bf;
  --c-detail:#fbbf24;--c-file:#c084fc;--c-watch:#f472b6}
*{box-sizing:border-box}html,body{margin:0;padding:0;height:100%}
body{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:13px;
  line-height:1.4;background:var(--bg);color:var(--fg);overflow-x:hidden;overflow-y:auto;
  -webkit-text-size-adjust:100%;transition:background .2s,color .2s}
.wrap{max-width:960px;margin:0 auto;padding:12px;
  padding-top:calc(12px + env(safe-area-inset-top));
  padding-bottom:calc(24px + env(safe-area-inset-bottom))}
header{display:flex;gap:6px;align-items:center;justify-content:space-between;
flex-wrap:nowrap;margin-bottom:8px;min-width:0}
h1{font-size:18px;margin:0;color:var(--fg)}
.head-right{display:flex;gap:4px;align-items:center;flex-wrap:nowrap;
justify-content:flex-start;min-width:0}
.token{background:var(--bg3);padding:3px 6px;border-radius:4px;font-size:10px;
  word-break:break-all;user-select:all;-webkit-user-select:all;max-width:100px;
  overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--fg2)}
.icon-btn{background:var(--bg3);color:var(--accent);border:1px solid var(--border);
  border-radius:4px;padding:3px 7px;cursor:pointer;font-size:11px;font-family:inherit;
  white-space:nowrap;line-height:1.4}
.icon-btn:hover{background:var(--bg4)}
.icon-btn.on{background:var(--accent);color:var(--bg);border-color:var(--accent)}
.stats{display:flex;gap:8px;flex-wrap:nowrap;margin-bottom:6px;
font-size:11px;color:var(--fg2);width:100%}
.stat{background:var(--bg3);padding:4px 8px;border-radius:4px;
flex:1;text-align:center;min-width:0;overflow:hidden}
.stat b{color:var(--fg);font-weight:600}
.stat .bar{display:block;width:100%;height:8px;background:var(--bg4);
border-radius:2px;overflow:hidden;margin-top:4px}
.bar i{display:block;height:100%;background:var(--accent)}
.bar i.pct-lo{background:var(--err)}
.bar i.pct-md{background:var(--warn)}
.bar i.pct-hi{background:var(--ok)}
.stat .bar>i{display:block;height:100%;background:var(--ok);transition:width .3s}
.stat .bar>i.pct-hi{background:var(--ok)}
.stat .bar>i.pct-md{background:var(--warn)}
.stat .bar>i.pct-lo{background:var(--err)}
.search{width:100%;padding:8px 10px;background:var(--bg2);border:1px solid var(--border);
  border-radius:6px;color:var(--fg);font-family:inherit;font-size:13px;margin-bottom:10px}
.search:focus{outline:none;border-color:var(--accent)}
.group{margin-bottom:14px}
.group-h{font-size:11px;color:var(--fg3);text-transform:uppercase;letter-spacing:.06em;
  margin:0 0 6px 0;font-weight:600;position:relative;padding-left:10px}
.group-h::before{content:'';position:absolute;left:0;top:2px;bottom:2px;width:3px;
  border-radius:2px;background:var(--g,var(--accent))}
.group[data-group="Basic"]{--g:var(--c-basic)}
.group[data-group="System"]{--g:var(--c-sys)}
.group[data-group="Network"]{--g:var(--c-net)}
.group[data-group="Sensors"]{--g:var(--c-sensors)}
.group[data-group="Hardware"]{--g:var(--c-hw)}
.group[data-group="Display / Audio"]{--g:var(--c-display)}
.group[data-group="Apps"]{--g:var(--c-apps)}
.group[data-group="Contacts / SMS"]{--g:var(--c-comm)}
.group[data-group="Detailed"]{--g:var(--c-detail)}
.group[data-group="Files / Audio play"]{--g:var(--c-file)}
.group[data-group="Watch (logcat)"]{--g:var(--c-watch)}
.ep{background:var(--bg2);border-radius:6px;margin-bottom:5px;overflow:hidden;
  border:1px solid var(--border);border-left:3px solid var(--g,var(--accent));
  content-visibility:auto;contain-intrinsic-size:80px}
.ep-h{display:flex;align-items:center;gap:6px;padding:7px 10px}
.ep-h .run{flex:1;text-align:left;background:none;border:none;color:var(--accent);
  padding:0;cursor:pointer;font-family:inherit;font-size:12px;word-break:break-all}
.ep-h .run:hover{text-decoration:underline}
.ep-h .status{font-size:10px;color:var(--fg3);min-width:44px;text-align:right;white-space:nowrap}
.ep-h .status.ok{color:var(--ok)}.ep-h .status.err{color:var(--err)}
.ep-h .status.loading{color:var(--warn)}
.ep-h .live{font-size:10px;color:var(--ok);margin-left:4px}
.ep-h .toggle{background:var(--bg3);border:none;color:var(--fg2);padding:2px 7px;
  border-radius:3px;cursor:pointer;font-size:10px;font-family:inherit;display:none}
.ep-h .toggle:hover{background:var(--bg4);color:var(--fg)}
.ep-b{padding:0 10px 10px 10px;overflow-x:auto}
.ep-b[hidden]{display:none}
.ep-b .raw{margin-top:8px;border-top:1px solid var(--border);padding-top:8px}
.ep-b .raw summary{cursor:pointer;color:var(--fg3);font-size:11px;user-select:none}
.ep-b .raw pre{background:var(--bg);padding:8px;border-radius:4px;overflow-x:auto;
  font-size:11px;margin:6px 0 0 0;white-space:pre-wrap;word-break:break-all}
/* Uniform 30/70 key-value table */
table{width:100%;border-collapse:collapse;font-size:11px;margin:0}
table.kv{table-layout:fixed}
table.kv th{width:30%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
table.kv td{width:70%;word-break:break-word;overflow-wrap:anywhere}
th,td{padding:4px 7px;border-bottom:1px solid var(--border);text-align:left;vertical-align:top}
th{background:var(--bg3);color:var(--fg2);font-weight:600;font-size:10px}
tr:hover td{background:var(--bg3)}
/* Value semantics */
td.v-num{color:var(--v-num);font-variant-numeric:tabular-nums}
td.v-null{color:var(--v-null);font-style:italic}
td.v-bool-t{color:var(--v-bool-t);font-weight:600}
td.v-bool-f{color:var(--v-bool-f)}
.empty{color:var(--fg3);font-style:italic;padding:6px 0;font-size:11px}
.scalar{padding:6px 0;word-break:break-all;font-size:12px}
code{background:var(--bg3);padding:1px 4px;border-radius:3px;color:var(--code);font-size:10px}
.spin{display:inline-block;width:10px;height:10px;border:2px solid var(--border);
  border-top-color:var(--warn);border-radius:50%;animation:sp .6s linear infinite;
  vertical-align:middle}
@keyframes sp{to{transform:rotate(360deg)}}
@media (prefers-reduced-motion: reduce) {
  *{transition:none!important;animation:none!important}
}
.icon-btn.danger{background:#7f1d1d;color:#fca5a5;border-color:#7f1d1d}
.icon-btn.danger:hover{background:#991b1b}
.ep.dropped{opacity:.4;text-decoration:line-through}
.ep.dropped .status{color:var(--err)}
/* MTAPI_HARD_FIX_72 */
/* MTAPI_TABLES_74_CSS: nested object/array visuals */
.hw-card-title{font-weight:600;color:var(--fg2);letter-spacing:.02em}
table.kv td.v-num{text-align:right}
table tbody tr:last-child td,
table tbody tr:last-child th{border-bottom:none}
.ep-b table{margin:4px 0}
.ep-b details > summary{cursor:pointer;font-size:11px;color:var(--fg3);padding:4px 0}
/* MTAPI_DEEP_TABLES_77_CSS: nested table polish */
.ep-b table.kv.nested,
.ep-b table table.kv { border:1px solid var(--bg4); border-radius:4px; }
.ep-b table td > table,
.ep-b table td > table.kv { margin:0; }
.ep-b table td > table td,
.ep-b table td > table th { padding:2px 4px; font-size:10px; }
.ep-b table td > table td > table td,
.ep-b table td > table td > table th { padding:1px 3px; font-size:9px; }
.ep-b code { font-size:10px; padding:1px 3px; }

/* MTAPI_DETAILS_96: collapsible endpoint cards */
details.ep summary{cursor:pointer;list-style:none;outline:none}
details.ep summary::-webkit-details-marker{display:none}
details.ep summary::before{content:'▸';color:var(--fg3);font-size:10px;
transition:transform .15s;display:inline-block;width:12px;text-align:center;
margin-right:2px}
details.ep[open] summary::before{transform:rotate(90deg)}
details.ep .ep-b{padding:0 10px 10px 20px}

/* MTAPI_137: nested sub-sections */
details.sub{margin:2px 0 4px}
details.sub > summary{
  cursor:pointer;list-style:none;color:var(--fg2);font-size:11px;
  padding:3px 6px;background:var(--bg3);border-radius:4px;
  border-left:3px solid var(--accent);user-select:none}
details.sub > summary::-webkit-details-marker{display:none}
details.sub > summary::before{
  content:'▸';display:inline-block;width:10px;text-align:center;
  margin-right:2px;color:var(--fg3);transition:transform .15s}
details.sub[open] > summary::before{transform:rotate(90deg)}
details.sub[open] > summary{background:var(--bg4);border-radius:4px 4px 0 0}
details.sub > *:not(summary){padding-left:8px}
details.sub > table{margin:4px 0 4px 8px}

/* MTAPI_253: debug panel */
.debug-panel{position:fixed;inset:10px;background:var(--bg);border:1px solid var(--border);
border-radius:8px;z-index:9998;display:flex;flex-direction:column;overflow:hidden;
box-shadow:0 8px 32px rgba(0,0,0,.5)}
.debug-header{display:flex;align-items:center;justify-content:space-between;
padding:8px 12px;background:var(--bg3);border-bottom:1px solid var(--border);flex-shrink:0}
.debug-header > span:first-child{font-weight:600;font-size:13px;color:var(--accent)}
.debug-actions{display:flex;gap:4px}
.debug-btn{background:var(--bg4);color:var(--fg);border:1px solid var(--border);
border-radius:4px;padding:4px 8px;cursor:pointer;font-family:inherit;font-size:11px}
.debug-btn:hover{background:var(--accent);color:var(--bg)}
.debug-close{color:var(--err)}
.debug-content{flex:1;overflow-y:auto;padding:8px}
.debug-section{margin-bottom:12px;border:1px solid var(--border);border-radius:4px;overflow:hidden}
.debug-section-title{background:var(--bg3);padding:4px 8px;font-size:11px;font-weight:600;
color:var(--fg2);text-transform:uppercase;letter-spacing:.06em}
.debug-pre{margin:0;padding:8px;font-size:10px;font-family:ui-monospace,monospace;
background:var(--bg2);color:var(--fg);white-space:pre-wrap;word-break:break-all;max-height:200px;overflow-y:auto}
.debug-logcat{max-height:300px;color:var(--fg2)}
.debug-errors{max-height:200px;color:var(--err)}
.debug-empty{padding:20px;text-align:center;color:var(--fg3);font-style:italic}
.debug-err{padding:8px;background:#7f1d1d;color:#fca5a5;border-radius:4px;font-size:11px}

/* MTAPI_260: logcat panel */
.logcat-toolbar{display:flex;gap:6px;align-items:center;flex-wrap:wrap;
padding:6px 8px;background:var(--bg3);border-bottom:1px solid var(--border);font-size:11px}
.logcat-levels{display:flex;gap:4px}
.logcat-lvl{display:inline-flex;align-items:center;gap:2px;cursor:pointer;user-select:none}
.logcat-lvl input{display:none}
.logcat-lvl span{padding:2px 6px;border-radius:3px;font-weight:600;font-size:10px;
background:var(--bg4);color:var(--fg2);border:1px solid var(--border);transition:all .15s}
.logcat-lvl input:checked + span.lvl-v{background:#6366f1;color:#fff;border-color:#6366f1}
.logcat-lvl input:checked + span.lvl-d{background:#22c55e;color:#fff;border-color:#22c55e}
.logcat-lvl input:checked + span.lvl-i{background:#06b6d4;color:#fff;border-color:#06b6d4}
.logcat-lvl input:checked + span.lvl-w{background:#f59e0b;color:#fff;border-color:#f59e0b}
.logcat-lvl input:checked + span.lvl-e{background:#ef4444;color:#fff;border-color:#ef4444}
.logcat-lvl input:checked + span.lvl-f{background:#dc2626;color:#fff;border-color:#dc2626;font-weight:800}
.logcat-search{flex:1;min-width:100px;padding:4px 8px;background:var(--bg);color:var(--fg);
border:1px solid var(--border);border-radius:4px;font-family:inherit;font-size:11px}
.logcat-search:focus{outline:none;border-color:var(--accent)}
.logcat-btn{background:var(--bg4);color:var(--fg);border:1px solid var(--border);
border-radius:4px;padding:3px 8px;cursor:pointer;font-size:11px}
.logcat-btn:hover{background:var(--accent);color:var(--bg)}
.logcat-live{display:inline-flex;align-items:center;gap:2px;cursor:pointer;font-size:10px;color:var(--fg2)}
.logcat-pre{margin:0;padding:6px 8px;max-height:400px;overflow-y:auto;
background:var(--bg);border:none;border-radius:0;font-size:10px}
.logcat-line{display:block;white-space:pre-wrap;word-break:break-all;padding:1px 4px;border-radius:2px}
.logcat-line.lvl-v{color:#818cf8}
.logcat-line.lvl-d{color:#4ade80}
.logcat-line.lvl-i{color:#22d3ee}
.logcat-line.lvl-w{color:#fbbf24;background:rgba(251,191,36,.08)}
.logcat-line.lvl-e{color:#f87171;background:rgba(248,113,113,.08)}
.logcat-line.lvl-f{color:#fff;background:#dc2626;font-weight:600}

/* MTAPI_261: tooltips (native title + cursor help) */
[title]{cursor:help}
.ep-h .run[title]{cursor:pointer}
.ep-h .status[title]{cursor:help}
.logcat-lvl span[title]{cursor:help}
.logcat-btn[title]{cursor:pointer}
.logcat-search[title]{cursor:text}
.icon-btn[title]{cursor:pointer}
.health-ind[title]{cursor:help}
.stat[title]{cursor:help}
.group-h[title]{cursor:pointer}

/* MTAPI_281: highlight search in logcat */
.logcat-hl{background:#fbbf24;color:#000;padding:0 1px;border-radius:2px;font-weight:600}
.logcat-line.lvl-w .logcat-hl{background:#fde68a}
.logcat-line.lvl-e .logcat-hl{background:#fca5a5}
.logcat-line.lvl-f .logcat-hl{background:#fff}
.logcat-status{margin-left:auto;font-size:10px;color:var(--fg2);font-family:ui-monospace,monospace}

/* MTAPI_300: data search + highlight + arrows */
.data-search-toolbar{display:flex;gap:4px;align-items:center;padding:6px 8px;
background:var(--bg3);border-bottom:1px solid var(--border);font-size:11px}
.data-search{flex:1;min-width:100px;padding:4px 8px;background:var(--bg);color:var(--fg);
border:1px solid var(--border);border-radius:4px;font-family:inherit;font-size:11px}
.data-search:focus{outline:none;border-color:var(--accent)}
.data-search-prev,.data-search-next{background:var(--bg4);color:var(--fg);
border:1px solid var(--border);border-radius:4px;padding:2px 8px;cursor:pointer;font-size:11px}
.data-search-prev:hover,.data-search-next:hover{background:var(--accent);color:var(--bg)}
.data-search-status{font-size:10px;color:var(--fg2);font-family:ui-monospace,monospace;
min-width:40px;text-align:right}
.data-hl{background:#fbbf24;color:#000;padding:0 1px;border-radius:2px;font-weight:600}
.data-hl-active{background:#f97316;color:#fff;box-shadow:0 0 0 2px #f97316}
.data-hl-active.data-hl{background:#f97316;color:#fff}

/* MTAPI_305: chrome://inspect */
.debug-chrome{background:var(--bg2);border:1px solid var(--border);border-radius:4px;color:var(--fg)}
.debug-chrome code{background:var(--bg3);padding:1px 4px;border-radius:2px;font-size:11px}
.debug-chrome pre{margin:4px 0;font-size:10px;white-space:pre-wrap;word-break:break-all}

/* MTAPI_349: uptime button */
.btn-uptime{background:transparent;border:none;color:var(--fg);cursor:pointer;
font-family:inherit;font-size:inherit;padding:0;text-decoration:underline;text-decoration-style:dotted}
.btn-uptime:hover{color:var(--accent)}

/* MTAPI_GUI: красный border на endpoint с ошибкой (виден при collapsed) */
details.ep.ep-err > summary.ep-h {
  border-left: 3px solid var(--err);
  padding-left: 4px;
}

/* MTAPI_GUI: кнопка copy (📋) — как toggle { } */
button.copy {
  font-size: 12px;
  padding: 1px 6px;
  margin-left: 4px;
  background: var(--bg3);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 3px;
  cursor: pointer;
  font-family: inherit;
}
button.copy:hover {
  background: var(--bg2);
}

/* MTAPI_TABLE_SEARCH: toolbar над таблицами с большими данными */
.tbl-toolbar {
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 4px 0 6px 0;
}
.tbl-search, .proc-search {
  flex: 1;
  font-size: 12px;
  padding: 3px 6px;
  background: var(--bg3);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 3px;
  font-family: inherit;
  outline: none;
}
.tbl-search:focus, .proc-search:focus {
  border-color: var(--accent, #4a8);
}
.tbl-status {
  font-size: 11px;
  color: var(--fg2);
  min-width: 60px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
mark.tbl-hl {
  background: #ffeb3b;
  color: #000;
  border-radius: 2px;
  padding: 0 1px;
}
.proc-line {
  display: block;
  white-space: pre;
}

/* MTAPI_SCROLLBARS: видимые скроллбары для devtools-frame и src-pre */
#devtools-frame {
  scrollbar-width: thin;
  scrollbar-color: #555 #222;
}
#devtools-frame::-webkit-scrollbar,
#src-pre::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
#devtools-frame::-webkit-scrollbar-track,
#src-pre::-webkit-scrollbar-track {
  background: #222;
  border-radius: 4px;
}
#devtools-frame::-webkit-scrollbar-thumb,
#src-pre::-webkit-scrollbar-thumb {
  background: #555;
  border-radius: 4px;
}
#devtools-frame::-webkit-scrollbar-thumb:hover,
#src-pre::-webkit-scrollbar-thumb:hover {
  background: #777;
}
#src-pre {
  scrollbar-width: thin;
  scrollbar-color: #555 #222;
  scroll-behavior: smooth;
}

/* MTAPI_SECTIONS: визуальное разделение Logcat / JS Logs / Eval / Perf / DevTools */
#logcat-sub > summary {
  border-left: 3px solid #f80;
  padding-left: 6px;
  font-weight: 600;
}
#jslog-sub > summary,
#eval-sub > summary,
#perf-sub > summary {
  border-left: 3px solid #08f;
  padding-left: 6px;
  font-weight: 600;
}
#devtools-sub > summary {
  border-left: 3px solid #a0a;
  padding-left: 6px;
  font-weight: 600;
}


/* ── TOOLTIPS (online help) ───────────────────────────────── */
[data-tip]{position:relative;cursor:help}
[data-tip]:hover::after,
[data-tip]:focus-within::after{
  content:attr(data-tip);
  position:absolute;left:0;top:calc(100% + 6px);
  background:#1e1e1e;color:#eee;border:1px solid #444;
  border-radius:6px;padding:8px 12px;font-size:11px;
  line-height:1.55;max-width:420px;white-space:pre-line;
  z-index:100000;box-shadow:0 4px 12px rgba(0,0,0,0.5);
  pointer-events:none;font-family:ui-monospace,monospace;
  font-weight:normal;text-align:left;
}
[data-tip]:hover::before,
[data-tip]:focus-within::before{
  content:"";position:absolute;left:10px;top:100%;
  border:5px solid transparent;border-bottom-color:#1e1e1e;
  z-index:100001;pointer-events:none;
}
html[data-theme="light"] [data-tip]:hover::after,
body.light [data-tip]:hover::after{background:#f5f5f5;color:#1a1a1a;border-color:#ccc}
html[data-theme="light"] [data-tip]:hover::before,
body.light [data-tip]:hover::before{border-bottom-color:#f5f5f5}

/* ── HELP MODE (wiki-style online help) ───────────────────── */
/* 1. Light-blue wash over whole page (tooltips stay color) */
body.help-mode::before {
  content: "";
  position: fixed; inset: 0;
  background: rgba(179, 229, 252, 0.55);
  backdrop-filter: brightness(1.05) saturate(0.85);
  -webkit-backdrop-filter: brightness(1.05) saturate(0.85);
  z-index: 99998;
  pointer-events: none;
  transition: opacity 0.2s;
}
html[data-theme="light"] body.help-mode::before,
body.help-mode.light::before {
  background: rgba(144, 202, 249, 0.45);
  backdrop-filter: brightness(1.02) saturate(0.9);
  -webkit-backdrop-filter: brightness(1.02) saturate(0.9);
}

/* 2. Top banner */
body.help-mode::after {
  content: "HELP MODE · tap=describe · long=act · 2×tap=exit · Esc=close";
  position: fixed; top: 0; left: 0; right: 0;
  background: #0288d1; color: #fff;
  font-family: ui-monospace, monospace;
  font-size: 10px; font-weight: 600;
  text-align: center; padding: 3px;
  z-index: 100003; letter-spacing: 0.2px;
  pointer-events: none;
}

/* 3a. Suppress native long-press menu (copy / select all / web search) */
body.help-mode,
body.help-mode * {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
/* Allow selection inside tooltips (users may want to copy) */
body.help-mode #mtapi-help-tip,
body.help-mode #mtapi-help-tip *,
body.help-mode #mtapi-help-intro,
body.help-mode #mtapi-help-intro * {
  -webkit-user-select: text;
  -moz-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}

/* 3. Cursor + hover highlight */
body.help-mode [data-tip],
body.help-mode [title],
body.help-mode button,
body.help-mode [role="button"],
body.help-mode summary,
body.help-mode input,
body.help-mode textarea { cursor: help !important; }

body.help-mode [data-tip]:hover,
body.help-mode [data-tip]:focus-within {
  outline: 2px solid #0288d1 !important;
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(2,136,209,0.3) !important;
  transition: outline-color 0.1s, box-shadow 0.1s;
}

/* 4. Help button active */
body.help-mode #mtapi-debug-help-btn {
  background: #0288d1 !important;
  color: #fff !important;
  border-color: #0288d1 !important;
  box-shadow: 0 0 0 3px rgba(2,136,209,0.45) !important;
}

/* 5. Pinned wiki tooltip (above overlay) */
#mtapi-help-tip {
  position: fixed; max-width: 440px; max-height: 62vh; overflow: auto;
  background: var(--bg3, #2a2a2a); color: var(--fg, #eee);
  border: 1px solid #0288d1;
  border-radius: 8px; padding: 10px 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px; line-height: 1.55; white-space: pre-line;
  z-index: 100002; box-shadow: 0 8px 24px rgba(0,0,0,0.6);
  display: none; pointer-events: auto;
  backdrop-filter: blur(3px);
}
#mtapi-help-tip.show { display: block; }
#mtapi-help-tip .help-close {
  float: right; cursor: pointer; color: var(--fg3, #888); font-weight: bold;
  margin-left: 8px; padding: 0 4px; border-radius: 3px;
}
#mtapi-help-tip .help-close:hover { background: var(--bg4, #444); color: var(--fg, #fff); }

/* 6. Ensure z-index ordering: tooltips > overlay */
[data-tip]:hover::after,
[data-tip]:focus-within::after { z-index: 100001; }
[data-tip]:hover::before,
[data-tip]:focus-within::before { z-index: 100002; }


/* ── HELP button in header (рядом с 🌙) ───────────────────── */
#help-btn {
  position: absolute;
  left: calc(50% + 22px);
  width: 16px; height: 16px;
  font-size: 12px; font-weight: bold;
  padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  background: transparent; color: inherit;
  border: 1px solid var(--bg4, #444); border-radius: 3px;
}
#help-btn:hover { background: var(--bg3, #333); }
body.help-mode #help-btn {
  background: #0288d1 !important;
  color: #fff !important;
  border-color: #0288d1 !important;
  box-shadow: 0 0 0 3px rgba(2,136,209,0.45) !important;
}


/* ── HELP MODE INTRO (modal на входе) ─────────────────────── */
#mtapi-help-intro {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.38);  /* lighter — debug button visible behind */
  z-index: 100005;
  display: none;
  align-items: center;
  justify-content: center;
  font-family: ui-monospace, monospace;
}
#mtapi-help-intro.show { display: flex; }
#mtapi-help-intro .hi-card {
  background: rgba(30, 30, 30, 0.88);  /* semi-transparent: FAB / page visible through */
  color: var(--fg, #eee);
  border: 1px solid var(--accent, #0288d1);
  border-radius: 10px;
  padding: 18px 20px;
  max-width: 360px;
  width: calc(100% - 32px);
  box-shadow: 0 12px 40px rgba(0,0,0,0.65);
  font-size: 12px;
  line-height: 1.55;
}
#mtapi-help-intro .hi-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--accent, #4fc3f7);
  margin-bottom: 4px;
}
#mtapi-help-intro .hi-sub {
  color: var(--fg3, #888);
  font-size: 11px;
  margin-bottom: 12px;
}
#mtapi-help-intro .hi-list {
  list-style: none;
  padding: 0;
  margin: 0 0 14px;
}
#mtapi-help-intro .hi-list li {
  padding: 5px 0;
  border-bottom: 1px solid var(--bg4, #444);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
#mtapi-help-intro .hi-list li:last-child { border-bottom: none; }
#mtapi-help-intro .hi-list li b {
  color: var(--accent, #4fc3f7);
  font-weight: 700;
  min-width: 70px;
}
#mtapi-help-intro .hi-list li span {
  color: var(--fg2, #aaa);
  font-size: 11px;
  text-align: right;
  flex: 1;
}
#mtapi-help-intro .hi-noshow {
  display: block;
  font-size: 11px;
  color: var(--fg3, #888);
  margin: 10px 0 12px;
  cursor: pointer;
  user-select: none;
}
#mtapi-help-intro .hi-noshow input { vertical-align: middle; margin-right: 6px; }
#mtapi-help-intro .hi-ok {
  width: 100%;
  padding: 8px 14px;
  background: var(--accent, #0288d1);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-family: monospace;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.3px;
}
#mtapi-help-intro .hi-ok:hover { filter: brightness(1.1); }
html[data-theme="light"] #mtapi-help-intro .hi-card,
body.light #mtapi-help-intro .hi-card { background: rgba(245,245,245,0.92); color: #1a1a1a; }


/* ── browser-btn disabled in help mode ────────────────────── */
#browser-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  filter: grayscale(1);
  pointer-events: auto;  /* disabled handles click block */
}
