/* R5 scoped Math Toolbox, independent from other Board application surfaces */
.sbMathPanel{position:fixed;z-index:190;top:13%;right:32px;width:min(390px,calc(100vw - 20px));max-height:min(86vh,800px);display:flex;flex-direction:column;background:#fffefa;color:#22313a;border:1px solid #bdc9cc;border-radius:17px;box-shadow:0 20px 55px #101f2c40;overflow:hidden;font:14px/1.4 system-ui,-apple-system,Segoe UI,sans-serif}
.sbMathPanel[hidden],.sbMathPane[hidden]{display:none!important}
.sbMathPanel *{box-sizing:border-box}
.sbMathHead{background:#22313a;color:#fff;display:flex;align-items:center;justify-content:space-between;padding:12px 15px;cursor:grab;touch-action:none}
.sbMathHead:active{cursor:grabbing}.sbMathHead strong{font-size:16px;display:block}.sbMathHead span{font-size:10px;color:#bed0d5}
.sbMathHead button{background:#374950;border:0;border-radius:7px;color:#fff;font-size:23px;width:32px;height:32px;cursor:pointer}
.sbMathTabs{display:grid;grid-template-columns:repeat(3,1fr);padding:9px 10px 0;gap:6px;background:#f3f3ee}
.sbMathTabs button{border:1px solid #dae1e2;border-radius:8px 8px 0 0;padding:9px 4px;background:#f6f5f1;color:#455862;cursor:pointer;font-weight:600}
.sbMathTabs button.active{background:#fffefa;border-color:#bc6b5e;color:#a54437;box-shadow:inset 0 3px #d17868}
.sbMathPane{padding:14px;overflow:auto;min-height:0;display:flex;flex-direction:column;gap:9px}
.sbMathPane label{font-size:12px;font-weight:700;color:#425660}
.sbMathPane input:not([type=checkbox],[type=range]),.sbMathPane textarea{width:100%;min-height:39px;padding:9px 11px;border-radius:8px;border:1px solid #b6c5c9;background:#fff;color:#203039;font:15px/1.4 ui-monospace,SFMono-Regular,Consolas,monospace}
.sbMathPane textarea{min-height:72px;resize:vertical}.sbMathPane input[type=range]{width:100%;accent-color:#b3483f}
.sbMathPane input:focus-visible,.sbMathPane button:focus-visible,.sbMathLaunch:focus-visible{outline:3px solid #b3483f;outline-offset:2px}
.sbMathResults{min-height:59px;padding:8px 12px;background:#f1f5f4;border:1px solid #dae0df;border-radius:9px;display:flex;flex-direction:column;gap:3px;align-items:flex-end}
.sbMathResults output{font:600 25px/1.1 ui-monospace,monospace;overflow-wrap:anywhere}.sbMathResults span{color:#8d493d;font-size:11px;min-height:12px}
.sbMathMode{display:flex;justify-content:space-between;align-items:center;gap:8px}.sbMathMode label{font-weight:500}.sbMathMode input{accent-color:#ad493c}
.sbMathMode button,.sbMathTemplates button{padding:7px 8px;border:1px solid #cbd4d5;background:#f1f3f2;border-radius:7px;color:#263c43;cursor:pointer}
.sbMathKeypad{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:5px}.sbMathKeypad button{min-width:0;padding:10px 2px;border:1px solid #c7d0d3;border-radius:7px;background:#f7f7f4;color:#233840;font-weight:700;cursor:pointer}.sbMathKeypad button:hover{background:#f2e6e2}
.sbMathPrimary{margin-top:4px;border:0;border-radius:9px;background:#aa4b3e;color:#fff;padding:12px;font-weight:700;cursor:pointer}.sbMathPrimary:disabled{opacity:.48;cursor:not-allowed}
.sbMathTemplates{display:flex;flex-wrap:wrap;gap:5px}.sbMathPane canvas{width:100%;max-width:100%;height:auto;border:1px solid #d7e1e1;border-radius:8px;background:#fff;display:block}
.sbMathRanges{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:5px}.sbMathRanges label{min-width:0}.sbMathRanges input{min-width:0!important;padding:7px 4px!important;font-size:13px!important}
.sbMathError{font-size:12px;color:#a54437;min-height:17px}.sbMathLaunch strong{font-size:21px;line-height:1;font-family:Georgia,serif}
@media(max-width:700px){.sbMathPanel{top:auto!important;left:5px!important;right:5px!important;bottom:6px;max-height:min(82dvh,720px);width:calc(100vw - 10px);border-radius:13px}.sbMathHead{touch-action:auto}.sbMathHead span{display:none}.sbMathPane{padding:11px}.sbMathKeypad button{padding:9px 1px}.sbMathRanges{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media(prefers-reduced-motion:reduce){.sbMathPanel *{scroll-behavior:auto}}
/* Override the legacy whiteboard's global canvas absolute-position rule. */
.sbMathPane canvas{position:static!important;inset:auto!important;transform:none!important;float:none!important;height:auto!important;touch-action:auto!important;z-index:auto!important}
