/* 目录与正文共用昼夜色板，窄屏将侧栏折叠到正文上方。 */
.article-detail:has(.reading-toc) { max-width: 1100px; }
.reading-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; align-items: start; }
.reading-layout:has(.reading-toc) { grid-template-columns: minmax(0, 1fr) 210px; }
.reading-body { min-width: 0; overflow-wrap: anywhere; }
.reading-body h2, .reading-body h3 { scroll-margin-top: 112px; }
.reading-body h3 { margin: 27px 0 12px; font-size: 20px; line-height: 1.6; }
.reading-body :is(h2, h3):focus { outline: none; }
.reading-body :is(h2, h3):focus-visible { outline: 2px solid var(--blue); outline-offset: 6px; border-radius: 2px; }
.reading-toc { position: sticky; top: 108px; min-width: 0; padding: 18px 14px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface-panel); backdrop-filter: blur(20px); box-shadow: var(--glass-shadow); }
.reading-toc summary { color: var(--text); font-size: 13px; font-weight: 700; cursor: pointer; }
.reading-toc summary:focus-visible, .reading-toc a:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; border-radius: 4px; }
.reading-toc nav { max-height: calc(100dvh - 205px); overflow: auto; margin-top: 14px; overscroll-behavior: contain; }
.reading-toc ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.reading-toc li { min-width: 0; }
.reading-toc a { display: block; border-left: 2px solid transparent; padding: 7px 8px; color: var(--muted); font-size: 12px; line-height: 1.7; overflow-wrap: anywhere; text-decoration: none; }
.reading-toc .toc-subsection a { padding-left: 19px; font-size: 11px; }
.reading-toc a:hover { color: var(--text); background: var(--control-bg); border-radius: 0 6px 6px 0; }
.reading-toc a[aria-current="location"] { color: var(--blue); border-left-color: var(--blue); background: var(--control-bg); }
.reading-toc-inline { position: static; margin-top: 20px; box-shadow: none; }
.reading-toc-inline nav { max-height: 280px; }
.reading-body > :first-child { margin-top: 28px; }
.reading-body .code-block pre { max-width: 100%; margin: 0; padding: 20px; overflow-x: auto; color: var(--code-text); font: 13px/1.7 var(--mono); }
.reading-body .code-block pre code { display: block; width: max-content; min-width: 100%; font: inherit; white-space: pre; overflow-wrap: normal; }
.code-language { margin-right: auto; text-transform: uppercase; color: var(--muted); font: 11px/1.4 var(--mono); }
.detail-shell > h1 { overflow-wrap: anywhere; }

/* 高亮颜色为真实语法 token 设置；字符串和注释不再被关键词二次替换。 */
:root { --syntax-comment: #a5b9cf; --syntax-keyword: #c3b5ff; --syntax-string: #99dfc5; --syntax-number: #a4d9ff; --syntax-function: #7cdbf2; --syntax-operator: #d0def1; }
:root[data-theme="light"] { --syntax-comment: #526c83; --syntax-keyword: #6844a0; --syntax-string: #1f6658; --syntax-number: #245f9e; --syntax-function: #065c81; --syntax-operator: #38536f; }
.code-block .token:is(.comment, .prolog, .doctype, .cdata) { color: var(--syntax-comment); }
.code-block .token:is(.keyword, .boolean, .atrule, .selector) { color: var(--syntax-keyword); }
.code-block .token:is(.string, .char, .attr-value, .regex, .inserted) { color: var(--syntax-string); }
.code-block .token:is(.number, .constant, .symbol, .property, .attr-name) { color: var(--syntax-number); }
.code-block .token:is(.function, .class-name, .builtin, .tag) { color: var(--syntax-function); }
.code-block .token:is(.operator, .punctuation) { color: var(--syntax-operator); }
.code-block .token.important, .code-block .token.bold { font-weight: 700; }
.code-block .token.italic { font-style: italic; }

@media (max-width: 1099px) {
  .article-detail:has(.reading-toc) { max-width: 820px; }
  .reading-layout:has(.reading-toc) { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .reading-layout > .reading-toc { position: static; grid-row: 1; padding: 15px 18px; }
  .reading-toc nav { max-height: 260px; }
  .reading-toc a { font-size: 13px; padding-block: 9px; }
  .reading-toc .toc-subsection a { font-size: 12px; }
}
@media (max-width: 700px) {
  .reading-body h2, .reading-body h3 { scroll-margin-top: 88px; }
  .reading-body .code-block pre { padding: 16px 14px; font-size: 12px; }
}
@supports not (backdrop-filter: blur(1px)) { .reading-toc { background: var(--glass-fallback); } }
@media (prefers-reduced-transparency: reduce) { .reading-toc { background: var(--glass-fallback); backdrop-filter: none; } }
