/* ACI-OS 1.17.0 – luồng K3: nội dung giàu của tin bài – bảng GFM (cuộn ngang trên điện thoại), công thức toán (KaTeX), khung xem PDF, video.
   Dùng CHUNG cho trang công khai (portal/templates/base.html) và xem trước của trình soạn (md_editor.js) – xem trước đúng như khi đăng.
   Tệp riêng (không qua bản dựng Tailwind app.css) để không đụng CSS dùng chung của các luồng khác. */

/* ---------------------------------------------------------------- bảng */
div.md-table { margin: 1rem 0; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid #e2e8f0;
  border-radius: .6rem; background: #fff; }
div.md-table > table { display: table; width: max-content; min-width: 100%; max-width: none; margin: 0; border-collapse: collapse;
  font-size: .92em; line-height: 1.5; overflow: visible; }
div.md-table th, div.md-table td { padding: .5rem .75rem; border-bottom: 1px solid #e2e8f0; vertical-align: top; text-align: left;
  max-width: 28rem; white-space: normal; overflow-wrap: anywhere; }
div.md-table th { background: #f1f5f9; color: #0f172a; font-weight: 600; white-space: nowrap; }
div.md-table tbody tr:nth-child(even) td { background: #f8fafc; }
div.md-table tbody tr:last-child td { border-bottom: 0; }
div.md-table th[align="right"], div.md-table td[align="right"] { text-align: right; font-variant-numeric: tabular-nums; }
div.md-table th[align="center"], div.md-table td[align="center"] { text-align: center; }

/* ---------------------------------------------------------------- công thức */
.math-inline:not([data-done]), .math-display:not([data-done]) { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .9em; color: #334155; }
.math-display { display: block; margin: 1rem 0; overflow-x: auto; overflow-y: hidden; text-align: center; padding: .25rem 0; }
.math-display .katex-display { margin: 0; }
.math-error { color: #b91c1c; }

/* ---------------------------------------------------------------- PDF */
figure.md-pdf { margin: 1.25rem 0; border: 1px solid #e2e8f0; border-radius: .75rem; overflow: hidden; background: #f8fafc; }
.md-pdf-view { min-height: 3rem; }
.md-pdf-bar { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .4rem .75rem; font-size: .8rem;
  color: #475569; border-bottom: 1px solid #e2e8f0; background: #fff; }
.md-pdf-tools { display: inline-flex; gap: .25rem; }
.md-pdf-bar button, .md-pdf-foot button { min-width: 2rem; height: 2rem; padding: 0 .6rem; border: 1px solid #cbd5e1; border-radius: .4rem;
  background: #fff; color: #0f172a; font: inherit; cursor: pointer; }
.md-pdf-bar button:hover, .md-pdf-foot button:hover { background: #f1f5f9; }
.md-pdf-scroll { max-height: 80vh; overflow: auto; padding: .5rem; }
canvas.md-pdf-canvas { display: block; max-width: none; height: auto; margin: .5rem auto; background: #fff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .18); }
.md-pdf-foot { padding: .4rem .75rem .6rem; text-align: center; }
.md-pdf-msg { margin: 0; padding: .75rem; font-size: .85rem; color: #9a3412; background: #fff7ed; }
figure.md-pdf > figcaption, figure.md-video > figcaption { margin: 0; padding: .55rem .75rem; font-size: .8rem; line-height: 1.5;
  color: #475569; text-align: left; border-top: 1px solid #e2e8f0; background: #fff; }

/* ---------------------------------------------------------------- video */
figure.md-video { margin: 1.25rem 0; border: 1px solid #e2e8f0; border-radius: .75rem; overflow: hidden; background: #0f172a; }
figure.md-video video { display: block; width: 100%; max-height: 75vh; background: #000; }
figure.md-yt iframe { display: block; width: 100%; aspect-ratio: 16 / 9; border: 0; }

/* ---------------------------------------------------------------- chỉ số trên/dưới */
sup, sub { font-size: .75em; line-height: 0; }

/* ---------------------------------------------------------------- chế độ tối (chỉ ở ứng dụng ACI-OS – cổng công khai luôn sáng) */
.dark div.md-table { border-color: #334155; background: #0f172a; }
.dark div.md-table th { background: #1e293b; color: #e2e8f0; }
.dark div.md-table th, .dark div.md-table td { border-color: #334155; }
.dark div.md-table tbody tr:nth-child(even) td { background: #111c33; }
.dark .math-inline:not([data-done]), .dark .math-display:not([data-done]) { color: #cbd5e1; }
.dark figure.md-pdf, .dark .md-pdf-bar, .dark figure.md-pdf > figcaption, .dark figure.md-video > figcaption { border-color: #334155; background: #0f172a;
  color: #cbd5e1; }
.dark .md-pdf-bar button, .dark .md-pdf-foot button { background: #1e293b; color: #e2e8f0; border-color: #475569; }

@media print {
  div.md-table { overflow: visible; border: 0; }
  .md-pdf-bar, .md-pdf-foot { display: none; }
  .md-pdf-scroll { max-height: none; overflow: visible; }
}

/* ---------------------------------------------------------------- 1.21.0 – thư viện ảnh trong bài (js/portal_lightbox.js) */
.nute-prose img[role="button"] { cursor: zoom-in; }
.nute-prose img[role="button"]:focus-visible { outline: 2px solid #1d4ed8; outline-offset: 2px; }
html.aci-lb-open { overflow: hidden; }
.aci-lb { position: fixed; inset: 0; z-index: 9999; display: flex; align-items: center; justify-content: center; background: rgba(2, 6, 23, .92); }
.aci-lb[hidden] { display: none; }
.aci-lb-f { margin: 0; max-width: 96vw; max-height: 96vh; display: flex; flex-direction: column; align-items: center; }
.aci-lb-f img { max-width: 96vw; max-height: calc(96vh - 3.5rem); width: auto; height: auto; object-fit: contain; border-radius: .25rem; transition: opacity .15s; }
.aci-lb.is-loading .aci-lb-f img { opacity: .6; }
.aci-lb-f figcaption { margin-top: .6rem; max-width: 70ch; color: #e2e8f0; font-size: .875rem; line-height: 1.45; text-align: center; }
.aci-lb-c { position: absolute; top: .9rem; left: 1rem; color: #cbd5e1; font-size: .8rem; font-variant-numeric: tabular-nums; }
.aci-lb button { position: absolute; border: 0; background: rgba(15, 23, 42, .55); color: #fff; cursor: pointer; line-height: 1; border-radius: 999px; width: 2.75rem; height: 2.75rem; font-size: 1.9rem; display: flex; align-items: center; justify-content: center; }
.aci-lb button:hover, .aci-lb button:focus-visible { background: rgba(51, 65, 85, .9); outline: 2px solid #fff; }
.aci-lb-x { top: .7rem; right: .8rem; }
.aci-lb-p { left: .8rem; top: 50%; margin-top: -1.4rem; }
.aci-lb-n { right: .8rem; top: 50%; margin-top: -1.4rem; }
.aci-lb.is-single .aci-lb-p, .aci-lb.is-single .aci-lb-n { display: none; }
@media (max-width: 640px) { .aci-lb-p, .aci-lb-n { top: auto; bottom: .8rem; margin-top: 0; } }
@media (prefers-reduced-motion: reduce) { .aci-lb-f img { transition: none; } }

/* ---------------------------------------------------------------- 1.23.0 – NV-20261112-05: căn lề khối, gạch chân, tiêu đề cấp 4
   Cú pháp «::: can-giua … :::» (backend/aci/portal/render.py) → <div class="can-…">. Chỉ bốn lớp cố định – không có style tùy ý trong bài.
   Ảnh trong bài mặc định căn giữa (lớp prose [&_img]:mx-auto) – bộ chọn dưới đây cụ thể hơn nên thắng. Dùng chung trang công khai, xem trước
   của trình soạn, bản in. */
div.can-trai { text-align: left; }
div.can-giua { text-align: center; }
div.can-phai { text-align: right; }
div.can-deu { text-align: justify; text-justify: inter-word; }
div.can-deu li, div.can-deu blockquote { text-align: justify; }
div.can-trai figure > img, div.can-trai figure > video { margin-left: 0; margin-right: auto; }
div.can-giua figure > img, div.can-giua figure > video { margin-left: auto; margin-right: auto; }
div.can-phai figure > img, div.can-phai figure > video { margin-left: auto; margin-right: 0; }
div.can-trai figure > figcaption { text-align: left; }
div.can-phai figure > figcaption { text-align: right; }
div.can-giua figure > figcaption, div.can-deu figure > figcaption { text-align: center; }
div.can-giua .math-display, div.can-deu .math-display { text-align: center; }
div.can-trai .math-display { text-align: left; }
div.can-phai .math-display { text-align: right; }
u { text-decoration: underline; text-underline-offset: 2px; }
.nute-prose h5, [data-preview] h5 { margin: 1rem 0 .4rem; font-size: 1em; font-weight: 600; color: #0f172a; }
.dark [data-preview] h5 { color: #f1f5f9; }
