.math-fragment { display: inline-block; max-width: 100%; vertical-align: middle; white-space: normal; }
.math-fragment mjx-container { max-width: 100%; margin: .15em 0; }
.math-fragment mjx-container > svg { max-width: 100%; height: auto; }
.math-display { display: block; text-align: center; margin-block: .65em; }
.math-fragment[data-math-state="error"] { text-decoration: underline wavy var(--danger); text-underline-offset: 4px; }
.math-editor { min-width: 0; }
.math-editor-controls { display: flex; align-items: center; justify-content: space-between; gap: 10px 20px; flex-wrap: wrap; margin-top: 10px; }
.math-editor-controls .checkbox { font-size: 13px; color: var(--ink); }
.math-editor .math-hint { font-size: 12px; margin: 8px 0 12px; line-height: 1.6; }
.math-preview { min-height: 48px; padding: 12px 15px; border: 1px dashed var(--primary-border); border-radius: 8px; background: var(--primary-soft); overflow-wrap: anywhere; white-space: pre-wrap; font-size: 17px; line-height: 1.8; }
.math-preview-label { display: block; margin: 10px 0 6px; color: var(--muted); font-size: 12px; font-weight: 600; }
.math-preview:empty::before { content: 'Escribe para ver el resultado.'; font-size: 13px; color: var(--muted); }
.math-preview-picture { display: block; width: auto; max-height: 260px; margin: 10px auto; text-align: center; }
.math-guide { margin: 0; padding: 15px 18px; border: 1px solid var(--line); border-radius: 9px; background: var(--paper); }
.math-guide summary { cursor: pointer; color: var(--primary); font-weight: 650; }
.math-guide p, .math-guide li { font-size: 14px; }
.math-guide p:first-of-type { margin-top: 14px; }
.math-guide code, .math-hint code { overflow-wrap: anywhere; white-space: normal; }
.math-error-note { color: var(--danger); font-size: 13px; white-space: normal; margin-top: 8px; }
@media (max-width:600px) { .math-preview { font-size: 16px; padding: 10px 12px; } }

.source-underline { text-decoration-line: underline; text-underline-offset: .16em; }
.text-format-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
.underline-toggle { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 7px; background: var(--paper); color: var(--primary); font-size: 13px; }
.underline-toggle > u { font-size: 18px; font-weight: 700; text-underline-offset: 3px; }
.underline-toggle[aria-pressed="true"] { background: var(--primary-soft); border-color: var(--primary); }
.underline-toggle:disabled { background: var(--line); color: var(--muted); border-style: dashed; cursor: not-allowed; }
.underline-hint { font-size: 12px; margin-block: 6px; }
.format-status { display: block; font-size: 13px; color: var(--primary); }
.format-status:empty { display: none; }
