.math-source-input { position:absolute!important; width:1px!important; height:1px!important; opacity:0; clip-path:inset(50%); padding:0!important; border:0!important; pointer-events:none; }
.math-edit-wrap { width:100%; min-width:0; margin:5px 0 10px; }
.math-editor { box-sizing:border-box; width:100%; border:1px solid #c5cfe0; border-radius:9px; padding:12px; background:white; color:#172536; font:inherit; line-height:1.8; white-space:pre-wrap; overflow-wrap:anywhere; cursor:text; }
.math-editor:focus { outline:2px solid #6d8cfd; outline-offset:1px; }
.math-editor:empty:before { content:attr(data-placeholder); color:#788597; pointer-events:none; }
.math-editor[aria-disabled=true] { background:#f3f5f7; }
.math-formula-chip { display:inline-block; max-width:100%; overflow-x:auto; vertical-align:middle; padding:2px 5px; border-radius:4px; background:#f1f5ff; border:1px solid transparent; cursor:pointer; white-space:normal; }
.math-formula-chip:hover,.math-formula-chip:focus { border-color:#5278e6; }
.math-formula-invalid,.math-formula-error { color:#ae3c23; }
.math-edit-hint { font-size:12px; color:#65748b; margin-left:8px; }
.math-insert { margin-top:5px; padding:5px 10px; font-size:13px; }
.math-formula-dialog { width:min(680px,90vw); border:1px solid #b9c9e4; border-radius:12px; padding:22px; color:#172536; }
.math-formula-dialog::backdrop { background:#17253655; }
.math-formula-tools,.math-formula-actions { display:flex; flex-wrap:wrap; gap:8px; margin:12px 0; }
.math-formula-tools button { padding:7px 12px; }
.math-formula-dialog math-field { display:block; min-height:70px; font-size:24px; padding:10px; border:1px solid #a8b9d5; border-radius:8px; }
.math-formula-dialog math-field::part(virtual-keyboard-toggle),.math-formula-dialog math-field::part(menu-toggle) { display:none; }

.chat-entry .math-edit-wrap { flex:1; margin:0; }
.chat-entry .math-editor { min-height:4em!important; max-height:150px; overflow-y:auto; font-size:14px; }
