/* ==========================================================================
   Tài liệu — bố cục 3 cột (cây mục lục · nội dung · mục lục trang),
   bộ trình bày công thức toán bằng HTML + CSS, khối ví dụ / lưu ý / mã.
   Chỉ nạp ở trang tài liệu nên không làm nặng phần còn lại của ứng dụng.
   ========================================================================== */

.docs-shell { padding-bottom: 2rem; }
.docs-layout {
  display: grid; grid-template-columns: 236px minmax(0, 1fr) 204px;
  gap: 1.8rem; align-items: start; margin-top: 1.2rem;
}
@media (max-width: 1180px) {
  .docs-layout { grid-template-columns: 224px minmax(0, 1fr); }
  .docs-toc { display: none; }
}
@media (max-width: 820px) {
  .docs-layout { grid-template-columns: 1fr; gap: 1rem; }
  .docs-sidebar { position: static !important; max-height: none !important; }
  .docs-nav { display: none; }
  .docs-nav.open { display: block; }
  .docs-toggle { display: inline-flex !important; }
}

/* --------------------------------------------------------- cây mục lục trái */
.docs-sidebar { position: sticky; top: 74px; max-height: calc(100vh - 92px);
                overflow-y: auto; padding-right: .3rem; }
.docs-sidebar-head { display: flex; align-items: center; justify-content: space-between;
                     margin-bottom: .5rem; }
.docs-sidebar-title { font-size: .74rem; text-transform: uppercase; letter-spacing: .08em;
                      color: var(--muted); font-weight: 700; }
.docs-toggle { display: none; }

.docs-section { margin-bottom: .15rem; }
.docs-section > summary {
  list-style: none; cursor: pointer; padding: .35rem .5rem; border-radius: 7px;
  font-size: .88rem; font-weight: 650; color: var(--ink);
  display: flex; align-items: center; gap: .45rem;
}
.docs-section > summary::-webkit-details-marker { display: none; }
.docs-section > summary::marker { content: ""; }
.docs-section > summary:hover { background: var(--surface-2); }
.docs-section > summary::after { content: "\25B8"; margin-left: auto;
                                 color: var(--line-strong); font-size: .8rem;
                                 transition: transform .15s; }
.docs-section[open] > summary::after { transform: rotate(90deg); }
.docs-section-icon { color: var(--brand); font-size: .82rem; width: 1em; text-align: center; }
.docs-section ul { list-style: none; margin: .1rem 0 .5rem .85rem; padding: 0 0 0 1.35rem;
                   border-left: 1px solid var(--line); }
.docs-section li a { display: block; padding: .28rem .5rem; border-radius: 6px;
                     font-size: .855rem; color: var(--ink-soft); line-height: 1.35; }
.docs-section li a:hover { background: var(--surface-2); text-decoration: none;
                           color: var(--ink); }
.docs-section li a.active { background: var(--brand-soft); color: var(--brand-dark);
                            font-weight: 650; }
.docs-nav-foot { margin-top: .8rem; padding-top: .6rem; border-top: 1px solid var(--line);
                 font-size: .82rem; }

/* -------------------------------------------------------------- nội dung giữa */
.docs-content { min-width: 0; max-width: 80ch; }
.docs-breadcrumb { font-size: .8rem; color: var(--muted); display: flex; gap: .4rem;
                   margin-bottom: .35rem; }
.docs-content h1 { font-size: 1.85rem; margin-bottom: .3rem; }
.docs-summary { font-size: 1.02rem; color: var(--ink-soft); margin-bottom: 1.4rem;
                padding-bottom: 1rem; border-bottom: 1px solid var(--line); }
.docs-content h2 { font-size: 1.22rem; margin: 2rem 0 .7rem; scroll-margin-top: 78px; }
.docs-content h3 { font-size: 1.02rem; margin: 1.4rem 0 .5rem; scroll-margin-top: 78px; }
.docs-content p { line-height: 1.68; }
.docs-content ul, .docs-content ol { line-height: 1.68; padding-left: 1.3rem; }
.docs-content li + li { margin-top: .3rem; }
.docs-content table.data { margin: 1rem 0; }
.docs-content table.data th { position: static; }
.docs-content .anchor { opacity: 0; color: var(--line-strong); margin-left: .35rem;
                        font-weight: 400; text-decoration: none; }
.docs-content h2:hover .anchor, .docs-content h3:hover .anchor { opacity: 1; }
.docs-content .term { font-weight: 650; color: var(--brand-dark); }
.docs-content kbd { font-family: var(--mono); font-size: .8em; padding: .1rem .35rem;
                    border: 1px solid var(--line-strong); border-bottom-width: 2px;
                    border-radius: 5px; background: var(--surface-2); }

/* ---------------------------------------------------------- mục lục bên phải */
.docs-toc { position: sticky; top: 74px; font-size: .82rem; }
.docs-toc-title { font-size: .72rem; text-transform: uppercase; letter-spacing: .07em;
                  color: var(--muted); font-weight: 700; margin-bottom: .5rem; }
.docs-toc ul { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--line); }
.docs-toc li a { display: block; padding: .22rem .7rem; color: var(--muted); line-height: 1.4;
                 margin-left: -2px; border-left: 2px solid transparent; }
.docs-toc li a:hover { color: var(--ink); text-decoration: none; }
.docs-toc li a.active { color: var(--brand-dark); border-left-color: var(--brand);
                        font-weight: 600; }
.docs-toc li.level-3 a { padding-left: 1.35rem; font-size: .95em; }

/* ------------------------------------------------------- điều hướng cuối trang */
.docs-pager { display: flex; justify-content: space-between; gap: 1rem; margin-top: 2.5rem;
              padding-top: 1.2rem; border-top: 1px solid var(--line); }
.docs-pager-item { display: flex; flex-direction: column; gap: .1rem; padding: .6rem .9rem;
                   border: 1px solid var(--line); border-radius: var(--radius);
                   background: var(--surface); max-width: 48%; }
.docs-pager-item:hover { border-color: var(--brand); text-decoration: none;
                         background: var(--brand-soft); }
.docs-pager-item.right { text-align: right; }
.docs-feedback { display: flex; align-items: center; gap: .7rem; flex-wrap: wrap;
                 margin-top: 1.2rem; padding: .7rem .9rem; background: var(--surface-2);
                 border: 1px solid var(--line); border-radius: var(--radius); }

/* ==========================================================================
   Công thức toán — dựng bằng HTML + CSS, không dùng MathJax/KaTeX nên vẫn
   chạy khi mất mạng và không phải nới lỏng Content-Security-Policy.
   ========================================================================== */
.math {
  font-family: "Cambria Math", "Latin Modern Math", "STIX Two Math", Cambria,
               Georgia, "Times New Roman", serif;
  font-size: 1.18rem; line-height: 2.1; color: var(--ink); white-space: nowrap;
}
.math-block {
  position: relative; display: block; text-align: center; overflow-x: auto;
  margin: 1.1rem 0; padding: 1.15rem 1rem;
  background: linear-gradient(180deg, #fcfdff, var(--surface-2));
  border: 1px solid var(--line); border-radius: var(--radius);
}
.math-tag { position: absolute; right: .7rem; top: .5rem; font-size: .72rem;
            color: var(--muted); font-family: var(--font); }
.math .mi { font-style: italic; }
.math .mn { font-style: normal; }
.math .mo { font-style: normal; padding: 0 .3em; }
.math .mtext { font-style: normal; font-size: .8em; font-family: var(--font); }
.math sub, .math sup { font-size: .62em; font-style: normal; }

.msum { display: inline-flex; flex-direction: column; align-items: center;
        vertical-align: middle; margin: 0 .18em; line-height: 1; }
.msum .sym { font-size: 1.55em; line-height: .92; }
.msum .sym-op { font-style: normal; font-size: 1em; line-height: 1.1; }
.msum .lim { font-size: .58em; font-style: normal; line-height: 1.25;
             font-family: var(--font); white-space: nowrap; }

.mfrac { display: inline-flex; flex-direction: column; align-items: center;
         vertical-align: middle; margin: 0 .25em; line-height: 1.25; }
.mfrac .num { padding: 0 .35em .05em; }
.mfrac .den { padding: .05em .35em 0; border-top: 1.2px solid currentColor; }

/* ------------------------------------------------------- hộp ví dụ và lưu ý */
.doc-example { border: 1px solid #cfe3d6; border-radius: var(--radius); overflow: hidden;
               margin: 1.1rem 0; background: #fbfefc; }
.doc-example-head { padding: .5rem .9rem; background: #edf8f1;
                    border-bottom: 1px solid #cfe3d6; font-weight: 650; font-size: .88rem;
                    color: #14532d; }
.doc-example-icon { margin-right: .3rem; }
.doc-example-body { padding: .9rem; }
.doc-example-body > p:last-child { margin-bottom: 0; }
.doc-example-body .math-block { background: #ffffff; margin: .7rem 0; }

.doc-note { display: flex; gap: .7rem; padding: .8rem .95rem; border-radius: var(--radius);
            margin: 1.1rem 0; border: 1px solid; font-size: .92rem; line-height: 1.6; }
.doc-note-icon { font-size: 1rem; line-height: 1.5; }
.doc-note-info { background: var(--brand-soft); border-color: #d6e2fd; color: #1e3a8a; }
.doc-note-tip { background: var(--ok-soft); border-color: #cdeed9; color: #14532d; }
.doc-note-warn { background: var(--warn-soft); border-color: #f6e2bd; color: #7c2d12; }
.doc-note-danger { background: var(--danger-soft); border-color: #f4cccc; color: #7f1d1d; }
.doc-note p:last-child { margin-bottom: 0; }

/* -------------------------------------------------------------- khối mã nguồn */
.code-block { margin: 1.1rem 0; border: 1px solid var(--line); border-radius: var(--radius);
              overflow: hidden; background: #fbfcfe; }
.code-block figcaption { display: flex; align-items: center; padding: .35rem .8rem;
                         background: var(--surface-2); border-bottom: 1px solid var(--line); }
.code-lang { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em;
             color: var(--muted); font-weight: 650; }
.code-block pre { margin: 0; padding: .8rem .9rem; overflow-x: auto; }
.code-block code { font-family: var(--mono); font-size: .82rem; line-height: 1.6;
                   color: #1f2937; white-space: pre; }

/* ------------------------------------------------------------- trang tác giả */
.author-card { display: flex; gap: 1.2rem; align-items: center; flex-wrap: wrap;
               padding: 1.1rem; margin-bottom: 1.2rem; background: var(--surface-2);
               border: 1px solid var(--line); border-radius: var(--radius-lg); }
.author-photo { width: 104px; height: 104px; border-radius: 50%; object-fit: cover;
                flex: none; border: 3px solid var(--surface); box-shadow: var(--shadow); }
.author-photo-empty { display: grid; place-items: center; font-size: 2rem; font-weight: 700;
                      background: linear-gradient(135deg, var(--brand), var(--accent));
                      color: #fff; }
.author-intro { min-width: 220px; flex: 1; }
.author-title { font-weight: 600; color: var(--brand-dark); margin: .1rem 0 .3rem; }
.author-links { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .6rem; }
