/* rich1 + rich2 (blocks) + rich3 (formulas, image+text) — Advanced editor posts (.ams-rich): scoped, contained, theme-aware. A post can style its own content only.
   Palette: ar-c-<name> (text) / ar-bg-<name> (soft box background) from CSS variables; dark values are the default
   (site theme), light values apply under [data-theme=light] / .ams-light or prefers-color-scheme: light when the page opts in. */
:root{
  --ar-red:#ff6b6b;--ar-orange:#ffa94d;--ar-yellow:#ffd43b;--ar-green:#69db7c;--ar-teal:#38d9a9;--ar-blue:#74c0fc;--ar-purple:#b197fc;--ar-pink:#f783ac;--ar-gray:#ced4da;--ar-muted:#9aa4b2;
  --ar-red-bg:rgba(255,107,107,.14);--ar-orange-bg:rgba(255,169,77,.14);--ar-yellow-bg:rgba(255,212,59,.13);--ar-green-bg:rgba(105,219,124,.13);--ar-teal-bg:rgba(56,217,169,.13);
  --ar-blue-bg:rgba(116,192,252,.14);--ar-purple-bg:rgba(177,151,252,.15);--ar-pink-bg:rgba(247,131,172,.14);--ar-gray-bg:rgba(206,212,218,.10);--ar-muted-bg:rgba(154,164,178,.10);
  --ar-line:rgba(255,255,255,.14);--ar-code-bg:rgba(255,255,255,.06)
}
:root[data-theme=light],.ams-light{
  --ar-red:#c92a2a;--ar-orange:#d9480f;--ar-yellow:#946c00;--ar-green:#2b8a3e;--ar-teal:#087f5b;--ar-blue:#1864ab;--ar-purple:#5f3dc4;--ar-pink:#a61e4d;--ar-gray:#495057;--ar-muted:#6c757d;
  --ar-red-bg:#fff0f0;--ar-orange-bg:#fff4e6;--ar-yellow-bg:#fff9db;--ar-green-bg:#ebfbee;--ar-teal-bg:#e6fcf5;--ar-blue-bg:#e7f5ff;--ar-purple-bg:#f3f0ff;--ar-pink-bg:#fff0f6;--ar-gray-bg:#f1f3f5;--ar-muted-bg:#f8f9fa;
  --ar-line:rgba(0,0,0,.14);--ar-code-bg:rgba(0,0,0,.05)
}
.ams-rich{contain:layout paint;isolation:isolate;position:relative;overflow:hidden;max-width:100%;min-width:0;overflow-wrap:anywhere;word-break:normal;text-align:start}
.ams-rich *{box-sizing:border-box}
.ams-rich :not(.katex):not(.katex *){max-width:100%;position:static!important}   /* rich3: KaTeX needs its own positioning */
.ams-rich img,.ams-rich video{height:auto}
.ams-rich iframe{max-width:100%;border:0}
.ams-rich table{display:block;overflow-x:auto;border-collapse:collapse;width:auto!important}
.ams-rich td,.ams-rich th{border-color:var(--ar-line);padding:.3em .5em;vertical-align:top}
.ams-rich table[border] td,.ams-rich table[border] th{border:1px solid var(--ar-line)}
.ams-rich pre{white-space:pre-wrap;background:var(--ar-code-bg);padding:.6em .8em;border-radius:6px;overflow-x:auto}
.ams-rich code{background:var(--ar-code-bg);padding:0 .25em;border-radius:4px}
.ams-rich pre code{background:none;padding:0}
.ams-rich blockquote{margin:.6em 0;padding:.3em 0;padding-inline-start:.9em;border-inline-start:3px solid var(--ar-line)}
.ams-rich hr{border:0;border-top:1px solid var(--ar-line);margin:1em 0}
.ams-rich h1,.ams-rich h2,.ams-rich h3,.ams-rich h4,.ams-rich h5,.ams-rich h6{line-height:1.3;margin:.7em 0 .4em}
.ams-rich h1{font-size:1.6em}.ams-rich h2{font-size:1.4em}.ams-rich h3{font-size:1.2em}
.ams-rich ul,.ams-rich ol{padding-inline-start:1.4em}
.ams-rich [style*="float"]{max-width:50%}
.ams-rich::after{content:"";display:block;clear:both}
.ams-rich .ar-c-red{color:var(--ar-red)}.ams-rich .ar-c-orange{color:var(--ar-orange)}.ams-rich .ar-c-yellow{color:var(--ar-yellow)}.ams-rich .ar-c-green{color:var(--ar-green)}.ams-rich .ar-c-teal{color:var(--ar-teal)}
.ams-rich .ar-c-blue{color:var(--ar-blue)}.ams-rich .ar-c-purple{color:var(--ar-purple)}.ams-rich .ar-c-pink{color:var(--ar-pink)}.ams-rich .ar-c-gray{color:var(--ar-gray)}.ams-rich .ar-c-muted{color:var(--ar-muted)}
.ams-rich .ar-bg-red{background:var(--ar-red-bg)}.ams-rich .ar-bg-orange{background:var(--ar-orange-bg)}.ams-rich .ar-bg-yellow{background:var(--ar-yellow-bg)}.ams-rich .ar-bg-green{background:var(--ar-green-bg)}.ams-rich .ar-bg-teal{background:var(--ar-teal-bg)}
.ams-rich .ar-bg-blue{background:var(--ar-blue-bg)}.ams-rich .ar-bg-purple{background:var(--ar-purple-bg)}.ams-rich .ar-bg-pink{background:var(--ar-pink-bg)}.ams-rich .ar-bg-gray{background:var(--ar-gray-bg)}.ams-rich .ar-bg-muted{background:var(--ar-muted-bg)}
.ams-rich [class*="ar-bg-"]{border-radius:6px;padding:.15em .35em}
.ams-rich div[class*="ar-bg-"],.ams-rich p[class*="ar-bg-"]{padding:.6em .8em}
/* ---- rich2: ready-made blocks (CKEditor plugin amsblocks) ---- */
.ams-rich .ar-h{font-size:1.3em;font-weight:700;margin:.9em 0 .45em;padding-bottom:.3em;border-bottom:2px solid var(--ar-blue)}
.ams-rich .ar-callout{margin:.7em 0;padding:.65em .9em;padding-inline-start:2.4em;border-radius:8px;border-inline-start:4px solid var(--ar-blue);background:var(--ar-blue-bg);position:relative!important}
.ams-rich .ar-callout::before{content:"i";position:absolute;inset-inline-start:.75em;top:.7em;width:1.15em;height:1.15em;border-radius:50%;font:700 .8em/1.15em system-ui,sans-serif;text-align:center;color:#111;background:var(--ar-blue)}
.ams-rich .ar-callout-warning{border-inline-start-color:var(--ar-orange);background:var(--ar-orange-bg)}
.ams-rich .ar-callout-warning::before{content:"!";background:var(--ar-orange)}
.ams-rich .ar-callout-success{border-inline-start-color:var(--ar-green);background:var(--ar-green-bg)}
.ams-rich .ar-callout-success::before{content:"\2713";background:var(--ar-green)}
.ams-rich .ar-callout>:first-child,.ams-rich .ar-box>:first-child{margin-top:0}.ams-rich .ar-callout>:last-child,.ams-rich .ar-box>:last-child{margin-bottom:0}
.ams-rich .ar-box{margin:.7em 0;padding:.75em .95em;border-radius:10px;border:1px solid var(--ar-line)}
.ams-rich .ar-code{direction:ltr;text-align:left;unicode-bidi:isolate;font:13px/1.5 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;white-space:pre;overflow-x:auto;border:1px solid var(--ar-line);tab-size:4}
.ams-rich .ar-hr{border:0;height:2px;margin:1.2em auto;width:60%;background:linear-gradient(90deg,transparent,var(--ar-muted),transparent)}
.ams-rich .ar-hr-dots{height:auto;background:none;width:auto;text-align:center;border:0;overflow:visible}
.ams-rich .ar-hr-dots::after{content:"\2022  \2022  \2022";white-space:pre;color:var(--ar-muted);letter-spacing:.4em}
.ams-rich .ar-btn{display:inline-block;margin:.25em 0;padding:.45em 1.1em;border-radius:999px;background:var(--ar-blue);color:#0b1220!important;font-weight:600;text-decoration:none!important;line-height:1.3}
.ams-rich .ar-btn:hover{filter:brightness(1.1)}
.ams-rich .ar-btn-outline{background:transparent;color:var(--ar-blue)!important;border:1.5px solid var(--ar-blue)}
.ams-rich .ar-table{margin:.7em 0;overflow-x:auto;-webkit-overflow-scrolling:touch;border:1px solid var(--ar-line);border-radius:8px}
.ams-rich .ar-table table{display:table;width:100%!important;min-width:420px;margin:0;border-collapse:collapse}
.ams-rich .ar-table th{background:var(--ar-blue-bg);font-weight:600;text-align:start}
.ams-rich .ar-table th,.ams-rich .ar-table td{border:0;border-bottom:1px solid var(--ar-line);padding:.45em .7em}
.ams-rich .ar-table tbody tr:nth-child(even){background:var(--ar-code-bg)}
.ams-rich .ar-table tbody tr:last-child td{border-bottom:0}
@media (max-width:520px){.ams-rich .ar-table table{font-size:.9em}.ams-rich .ar-callout{padding-inline-start:2.1em}}
/* ---- rich3: formulas (KaTeX, rendered by /assets/ams-math.js) and image + text layouts ---- */
.ams-rich .ar-math{direction:ltr;unicode-bidi:isolate;font-family:ui-monospace,Menlo,Consolas,monospace;font-size:.95em}
.ams-rich .ar-math[data-ar-m]{font-family:inherit;font-size:inherit}
.ams-rich .ar-math-d{display:block;margin:.7em 0;padding:.35em 0;text-align:center;overflow-x:auto;overflow-y:hidden}
.ams-rich .ar-math .katex{color:inherit}
.ams-rich .ar-math .katex-display{margin:0}
.ams-rich .ar-math .katex-error{color:var(--ar-red)!important}
.ams-rich .ar-media{display:grid;grid-template-columns:minmax(0,2fr) minmax(0,3fr);gap:1em;align-items:center;margin:.8em 0}
.ams-rich .ar-media-end{grid-template-columns:minmax(0,3fr) minmax(0,2fr)}
.ams-rich .ar-media-end>.ar-media-img{order:2}
.ams-rich .ar-media-img img{display:block;width:100%!important;height:auto!important;border-radius:10px}
.ams-rich .ar-media-txt>:first-child{margin-top:0}.ams-rich .ar-media-txt>:last-child{margin-bottom:0}
@media (max-width:560px){.ams-rich .ar-media,.ams-rich .ar-media-end{grid-template-columns:minmax(0,1fr);gap:.6em}.ams-rich .ar-media-end>.ar-media-img{order:0}}
.ams-rich div.ar-callout.ar-callout{position:relative!important}   /* rich3: keeps the callout icon anchored (beats the KaTeX-aware static rule) */
