/* ═══ Math Modal Overlay ═══ */
.math-overlay{position:fixed;inset:0;background:rgba(26,16,53,.45);z-index:10000;display:flex;align-items:center;justify-content:center;animation:mathFadeIn .2s ease-out}
@keyframes mathFadeIn{from{opacity:0}to{opacity:1}}
.math-modal{background:var(--w);width:94%;max-width:720px;max-height:80vh;border-radius:14px;box-shadow:0 20px 60px rgba(26,16,53,.25);display:flex;flex-direction:column;animation:mathSlideIn .25s ease-out;overflow:hidden}
@keyframes mathSlideIn{from{opacity:0;transform:translateY(-12px) scale(.97)}to{opacity:1;transform:translateY(0) scale(1)}}
/* Header */
.math-modal-head{display:flex;align-items:center;justify-content:space-between;padding:.7rem 1.1rem;background:linear-gradient(135deg,var(--p6),#4a7dbd);border-bottom:2px solid rgba(201,168,76,.35);flex-shrink:0}
.math-modal-title{font-family:'Lora',serif;font-size:.92rem;font-weight:600;color:var(--w);line-height:1.3}
.math-modal-close{width:28px;height:28px;border-radius:50%;border:none;background:rgba(255,255,255,.18);color:var(--w);font-size:1rem;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:all var(--t);flex-shrink:0}
.math-modal-close:hover{background:rgba(255,255,255,.35);transform:scale(1.1)}
/* Body */
.math-modal-body{overflow-y:auto;padding:1.2rem 1.3rem;flex:1;min-height:0;scrollbar-width:thin;scrollbar-color:var(--p2) transparent}
/* Formula sections */
.math-section{margin-bottom:1.4rem;padding-bottom:1rem;border-bottom:1px solid var(--p1)}
.math-section:last-child{border-bottom:none;margin-bottom:0;padding-bottom:0}
.math-section-heading{font-family:'Outfit',sans-serif;font-size:.78rem;font-weight:600;color:var(--p6);margin-bottom:.6rem;letter-spacing:.01em}
.math-formula-block{background:linear-gradient(135deg,rgba(107,63,160,.03),rgba(74,125,189,.04));border:1px solid rgba(107,63,160,.1);border-radius:10px;padding:.9rem 1rem;margin-bottom:.6rem;overflow-x:auto;text-align:center}
.math-formula-block .katex-display{margin:0;overflow-x:auto;overflow-y:hidden;padding:.2rem 0}
.math-formula-block .katex{font-size:1.05em}
.math-note{font-size:.74rem;color:var(--p5);line-height:1.65;margin-top:.4rem;font-style:italic}
/* Definitions */
.math-defs{margin-top:.3rem}
.math-defs-title{font-family:'Outfit',sans-serif;font-size:.74rem;font-weight:600;color:var(--p7);margin-bottom:.4rem}
.math-def-list{display:grid;gap:.3rem}
.math-def-item{display:flex;gap:.5rem;align-items:baseline;font-size:.74rem;line-height:1.55;padding:.3rem .6rem;border-radius:6px;background:rgba(107,63,160,.03)}
.math-def-symbol{flex-shrink:0;min-width:2.5rem;text-align:right;color:var(--p6);font-weight:600}
.math-def-symbol .katex{font-size:.9em}
.math-def-meaning{color:var(--p7);flex:1}
/* Source attribution */
.math-source{margin-top:1rem;padding-top:.7rem;border-top:1px solid var(--p1);font-size:.62rem;color:var(--p4);text-align:center;line-height:1.5}
.math-source a{color:var(--p5);text-decoration:underline}
/* ═══ Nerd Mode — Inline Math Blocks ═══ */
.math-inline{margin-top:.8rem;padding:.8rem 1rem;background:linear-gradient(135deg,rgba(107,63,160,.04),rgba(74,125,189,.05));border:1px solid rgba(107,63,160,.12);border-radius:10px;border-left:3px solid #1565C0;animation:mathInlineFade .3s ease-out}
@keyframes mathInlineFade{from{opacity:0;transform:translateY(-6px)}to{opacity:1;transform:translateY(0)}}
.math-inline-title{font-family:'Lora',serif;font-size:.78rem;font-weight:600;color:var(--p6);margin-bottom:.5rem}
.math-inline-heading{font-family:'Outfit',sans-serif;font-size:.72rem;font-weight:600;color:#1565C0;margin-top:.6rem;margin-bottom:.3rem}
.math-inline .math-formula-block{margin-bottom:.4rem}
.math-inline .math-note{font-size:.7rem;margin-bottom:.4rem}
.math-inline .math-defs{margin-top:.5rem;padding-top:.4rem;border-top:1px solid rgba(107,63,160,.08)}
.math-inline .math-defs-title{font-size:.7rem}
.math-inline .math-def-item{font-size:.7rem;padding:.2rem .4rem}
.math-inline .math-def-symbol{min-width:2rem}
/* ─── Math Responsive ─── */
@media(max-width:480px){
.math-modal{width:100%;max-width:100%;max-height:85vh;border-radius:14px 14px 0 0;position:fixed;bottom:0;left:0;right:0;top:auto;animation:mathSlideUp .25s ease-out}
@keyframes mathSlideUp{from{opacity:0;transform:translateY(30px)}to{opacity:1;transform:translateY(0)}}
.math-modal::before{content:'';display:block;width:32px;height:4px;background:rgba(255,255,255,.4);border-radius:4px;margin:.4rem auto .1rem}
.math-modal-head{padding:.5rem .8rem}
.math-modal-title{font-size:.82rem}
.math-modal-body{padding:.8rem .9rem}
.math-formula-block{padding:.6rem .7rem}
.math-formula-block .katex{font-size:.9em}
.math-def-item{padding:.25rem .4rem;font-size:.7rem}
}
