/* MPF-I Lab window */
.mpf{position:fixed;inset:0;z-index:60;display:flex;flex-direction:column;background:var(--bg);color:var(--text);font:13px -apple-system,system-ui,"Segoe UI",sans-serif}
.mpf[hidden]{display:none}
.mpf *{box-sizing:border-box}
.mpf button,.mpf select,.mpf input,.mpf textarea{font:inherit;color:inherit}
.mpf-head{display:flex;align-items:center;gap:12px;padding:8px 12px;background:var(--panel-solid);border-bottom:1px solid var(--stroke);flex-wrap:wrap}
.mpf-title{display:flex;flex-direction:column;min-width:150px}.mpf-title b{font-size:15px}.mpf-title span{font-size:11px;color:var(--text-2)}
.mpf-ctl{display:flex;gap:6px;align-items:center;flex-wrap:wrap;flex:1}
.mpf button{background:var(--panel-solid);border:1px solid var(--stroke);border-radius:8px;padding:5px 10px;cursor:pointer}
.mpf button:hover{background:rgba(120,120,128,.14)}
.mpf button.pri{background:var(--accent);border-color:var(--accent);color:#fff;font-weight:600}
.mpf button.x{border:0;font-size:16px}
.mpf button.mini{padding:2px 7px;font-size:11px}
.mpf select,.mpf input:not([type]),.mpf input[type=text],.mpf textarea{background:var(--panel-solid);border:1px solid var(--stroke);border-radius:7px;padding:4px 7px}
.mpf-body{flex:1;display:grid;grid-template-columns:minmax(330px,470px) 1fr;gap:10px;padding:10px;min-height:0}
.mpf-left{display:flex;flex-direction:column;gap:10px;overflow:auto;min-height:0}
.mpf-right{display:flex;flex-direction:column;min-height:0;background:var(--panel-solid);border:1px solid var(--stroke);border-radius:12px;overflow:hidden}
.mpf-card{background:var(--panel-solid);border:1px solid var(--stroke);border-radius:12px;padding:10px}
.mpf-lab{font-size:11px;text-transform:uppercase;letter-spacing:.5px;font-weight:700;color:var(--text-2);margin-bottom:8px;display:flex;gap:8px;align-items:center}
.mpf-lab .mini{margin-left:auto}
.mpf-note{font-size:11px;color:var(--text-2);text-transform:none;letter-spacing:0;font-weight:400}
.mpf-disp{width:100%;background:#120a0a;border-radius:8px;padding:8px;display:block}
.mpf-dbg{fill:#1b0d0d}.mpf-seg{fill:#ff3b30;opacity:.07}
.mpf-keys{display:grid;grid-template-columns:repeat(6,1fr);gap:6px}
.mpf-key{padding:9px 0!important;font-weight:700;font-size:12.5px;text-align:center;user-select:none;background:var(--bg)!important}
.mpf-key.fn{background:rgba(10,132,255,.14)!important;font-size:11px}
.mpf-key.on{background:var(--accent)!important;color:#fff!important}
.mpf-key.mini{padding:4px 10px!important;font-size:10px;line-height:1.1}
.mpf-gap{display:block}
.mpf-row{display:flex;align-items:center;gap:10px;margin-top:8px}
.mpf-spk{margin-left:auto;color:var(--text-2)}.mpf-spk.on{color:#ff9f0a;font-weight:700}.mpf-spk i{font-style:normal;font-variant-numeric:tabular-nums}
.mpf-pad{display:flex;flex-direction:column;gap:8px}
.mpf-leds,.mpf-sws{display:flex;gap:7px;justify-content:space-between}
.mpf-led{width:22px;height:22px;border-radius:50%;background:#3a1210;border:1px solid var(--stroke);display:block}.mpf-led.on{background:#ff3b30;box-shadow:0 0 10px #ff3b30}
.mpf-sw{width:34px;height:46px;padding:0!important;display:flex;flex-direction:column;align-items:center;justify-content:flex-end;gap:2px;position:relative}
.mpf-sw i{display:block;width:16px;height:20px;border-radius:5px;background:#8e8e93;margin-top:4px;transition:transform .08s}.mpf-sw.on i{background:var(--accent-2);transform:translateY(-14px)}
.mpf-sw small{font-size:10px;color:var(--text-2)}
.mpf-termcard{flex:1;min-height:140px;display:flex;flex-direction:column}
.mpf-term{flex:1;min-height:90px;margin:0;background:#0b0d10;color:#7CFC9A;border-radius:8px;padding:8px;font:12px/1.35 ui-monospace,Menlo,Consolas,monospace;overflow:auto;white-space:pre-wrap;outline:none}
.mpf-term:focus{box-shadow:0 0 0 2px var(--accent)}
.mpf-tabs{display:flex;gap:2px;padding:6px 6px 0;border-bottom:1px solid var(--stroke);flex-wrap:wrap}
.mpf-tabs button{border:0;border-radius:8px 8px 0 0;background:transparent;padding:7px 12px;color:var(--text-2);font-weight:600}
.mpf-tabs button.on{background:var(--bg);color:var(--text)}
.mpf-pane{flex:1;overflow:auto;padding:12px;min-height:0;display:flex;flex-direction:column;gap:10px}
.mpf-pane h3{margin:6px 0 2px;font-size:14px}.mpf-pane h4{margin:10px 0 2px;font-size:11px;text-transform:uppercase;letter-spacing:.5px;color:var(--text-2)}
.mpf-bar{display:flex;gap:6px;align-items:center;flex-wrap:wrap}.mpf-sp{flex:1}
.mpf-intro{color:var(--text-2);line-height:1.5}
.mpf-src{width:100%;flex:1;min-height:220px;resize:vertical;font:12.5px/1.45 ui-monospace,Menlo,Consolas,monospace!important;tab-size:8;white-space:pre}
.mpf-sub{display:flex;gap:8px;align-items:center;flex-wrap:wrap}
.mpf-msg{font-size:12px}.mpf-msg.ok{color:var(--accent-2)}.mpf-msg.bad{color:#ff453a}
.mpf-list,.mpf-dis,.mpf-dump{font:12px/1.5 ui-monospace,Menlo,Consolas,monospace;background:var(--bg);border-radius:8px;padding:6px;overflow:auto;max-height:260px}
.mpf-dump{max-height:none}
.ln{display:flex;gap:10px;white-space:pre;align-items:baseline}.ln .no{color:var(--text-2);width:30px;text-align:right}
.ln .ad{color:var(--accent);width:40px}.ln a.ad{cursor:pointer;text-decoration:none}.ln a.ad:hover{text-decoration:underline}
.ln .by{color:var(--text-2);width:110px;overflow:hidden}.ln .by.wide{width:370px}.ln .sr{flex:1}
.ln.err{background:rgba(255,69,58,.12)}.ln .em{color:#ff453a;margin-left:10px}.ln.bp{background:rgba(255,159,10,.2)}.ln.cur{background:rgba(10,132,255,.18);font-weight:700}
.syms{margin-top:8px;display:flex;flex-wrap:wrap;gap:4px 12px}.sy{color:var(--text-2)}.sy b{color:var(--text)}
.mpf-ex{display:block;width:100%;text-align:left;margin:4px 0;padding:9px 11px!important}.mpf-ex b{display:block}.mpf-ex span{display:block;color:var(--text-2);font-size:12px;margin-top:2px}
.mpf-exd{background:var(--bg);border-radius:10px;padding:12px;line-height:1.5}.mpf-exd h3{margin-top:0}.mpf-exd ul{margin:4px 0 8px;padding-left:18px}
.mpf-regs{display:grid;grid-template-columns:repeat(auto-fill,minmax(92px,1fr));gap:6px}
.reg{background:var(--bg);border-radius:8px;padding:6px 9px;display:flex;justify-content:space-between;font:13px ui-monospace,Menlo,Consolas,monospace}.reg span{color:var(--text-2)}
.mpf-flags{display:flex;gap:6px}.fl{padding:3px 9px;border-radius:6px;background:var(--bg);color:var(--text-2);font-weight:700}.fl.on{background:var(--accent);color:#fff}
.mpf-misc{line-height:1.8;color:var(--text-2)}.mpf-misc b{color:var(--text)}.bad{color:#ff453a}
.chips{display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:8px}
.chip{position:relative;background:var(--bg);border:1px solid var(--stroke);border-radius:8px;padding:9px 10px 9px 22px;cursor:pointer;line-height:1.35}.chip small{display:block;color:var(--text-2);font-size:11px}.chip.glue{opacity:.8}
.chip:hover{border-color:var(--accent)}
.act{position:absolute;left:8px;top:12px;width:8px;height:8px;border-radius:50%;background:#555}.act.on{background:#30d158;box-shadow:0 0 8px #30d158}
.bus{display:flex;gap:2px;align-items:center;margin:4px 0;flex-wrap:wrap}.bl{width:70px;font-size:11px;color:var(--text-2)}
.bl-led{width:10px;height:14px;border-radius:3px;background:#3a1210;display:block;margin-right:1px}.bl-led.on{background:#ff3b30}
.ctl{font-size:11px;padding:2px 7px;border-radius:5px;background:var(--bg);color:var(--text-2);margin-right:4px;display:inline-block;margin-bottom:3px}.ctl.on{background:#30d158;color:#000}.ctl.warn{background:#ff9f0a;color:#000}
.mpf-table table,.mpf-ptbl,.mpf-flist table,.mpf-help table{width:100%;border-collapse:collapse}
.mpf-table td,.mpf-table th,.mpf-ptbl td,.mpf-ptbl th,.mpf-flist td,.mpf-flist th,.mpf-help td,.mpf-help th{padding:5px 8px;border-bottom:1px solid var(--stroke);text-align:left;vertical-align:top}
.mpf-help th{white-space:nowrap}
.mpf-help{line-height:1.55}.mpf-help code{background:var(--bg);padding:1px 5px;border-radius:5px}
.mpf-ptbl input{width:auto}.mpf-chk{display:flex;gap:8px;align-items:center}
.acts{white-space:nowrap}.acts button{padding:2px 7px;font-size:11px;margin-left:3px}a.flink{cursor:pointer;color:var(--accent)}
.mpf-toast{position:absolute;left:50%;bottom:18px;transform:translateX(-50%);background:#1c1c1e;color:#fff;padding:8px 14px;border-radius:20px;opacity:0;pointer-events:none;transition:opacity .2s}.mpf-toast.on{opacity:1}
body.mpf-open{overflow:hidden}
@media (max-width:900px){.mpf-body{grid-template-columns:1fr;overflow:auto}.mpf-left{overflow:visible}.mpf-right{min-height:520px}}

/* right-click menu */
.ctxmenu{position:fixed;z-index:80;min-width:230px;max-height:80vh;overflow:auto;background:var(--panel-solid);border:1px solid var(--stroke-strong,var(--stroke));border-radius:12px;box-shadow:0 12px 36px rgba(0,0,0,.28);padding:5px;font:13px -apple-system,system-ui,"Segoe UI",sans-serif;color:var(--text)}
.ctxhead{padding:5px 9px 4px;font-size:10.5px;font-weight:700;letter-spacing:.5px;text-transform:uppercase;color:var(--text-2)}
.ctxsep{height:1px;background:var(--stroke);margin:4px 2px}
.ctxitem{display:flex;align-items:center;gap:9px;width:100%;border:0;background:transparent;color:inherit;font:inherit;text-align:left;padding:6px 9px;border-radius:8px;cursor:pointer}
.ctxitem:hover:not(:disabled){background:var(--accent);color:#fff}
.ctxitem:disabled{opacity:.4;cursor:default}
.ctxitem.danger{color:#ff453a}.ctxitem.danger:hover{background:#ff453a;color:#fff}
.ctxitem .ci{width:18px;text-align:center}.ctxitem .cl{flex:1}.ctxitem .ck{font-size:11px;opacity:.6}
