/* 文章版式：桌面正文 896px 居中，≥1440px 时右侧留白放目录，不挤正文 */
@media (min-width: 768px) {
  .article-content {
    font-size: 1.0625rem;
  }
}

article h1 {
  text-wrap: pretty;
}

.article-content h2[id],
article h1[id] {
  scroll-margin-top: 96px;
}

.toc {
  display: none;
}

@media (min-width: 1440px) {
  .container.article-layout {
    display: grid;
    grid-template-columns: 1fr minmax(0, 896px) 1fr;
    column-gap: 28px;
    align-items: start;
    max-width: none;
  }

  .container.article-layout > article {
    grid-column: 2;
    min-width: 0;
  }

  .container.article-layout > .toc {
    display: block;
    grid-column: 1;
    grid-row: 1;
    justify-self: center;
    position: sticky;
    top: 96px;
    margin: 0;
    width: max-content;
    height: 32px;
    border: 1px solid #dfe6f1;
    border-radius: 999px;
    background: #fff;
    box-shadow: 0 2px 10px rgba(15, 23, 42, .06);
    overflow: hidden;
    transition: width .18s ease, border-radius .18s ease, box-shadow .18s ease;
  }

  .container.article-layout > .toc[open] {
    width: 100%;
    max-width: 248px;
    height: auto;
    max-height: calc(100vh - 128px);
    border-color: #e6ecf5;
    border-radius: 14px;
    box-shadow: 0 8px 28px rgba(15, 23, 42, .10);
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .toc:not([open]) > summary {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    height: 30px;
    padding: 0 .75rem 0 .7rem;
    list-style: none;
    font-size: .78rem;
    font-weight: 600;
    letter-spacing: .06em;
    color: #475569;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
  }

  .toc:not([open]) > summary::-webkit-details-marker {
    display: none;
  }

  .toc:not([open]) .toc-btn-icon {
    font-size: .8rem;
    line-height: 1;
    color: #2563eb;
  }

  .toc:not([open]) .toc-btn-label {
    line-height: 1;
  }

  .toc:not([open]) > summary:hover {
    color: #1d4ed8;
    background: #f8fafc;
  }

  .toc[open] .toc-btn-icon,
  .toc[open] .toc-btn-label {
    display: none;
  }

  .toc:not([open]) .toc-title,
  .toc:not([open]) .toc-total,
  .toc:not([open]) .toc-progress,
  .toc:not([open]) .toc-caret {
    display: none;
  }

  .toc[open] > summary {
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .7rem .6rem .55rem .95rem;
    background: #fff;
    list-style: none;
    font-size: .76rem;
    font-weight: 700;
    letter-spacing: .12em;
    color: #64748b;
    line-height: 1.4;
    cursor: pointer;
  }

  .toc[open] > summary::-webkit-details-marker {
    display: none;
  }

  .toc[open] > summary::before {
    content: "";
    flex: none;
    width: 3px;
    height: 12px;
    border-radius: 2px;
    background: #2563eb;
  }

  .toc[open] .toc-caret {
    display: block;
    flex: none;
    width: 6px;
    height: 6px;
    border-top: 1.5px solid #94a3b8;
    border-right: 1.5px solid #94a3b8;
    transform: rotate(45deg);
  }

  .toc-total {
    display: none;
  }

  .toc-progress {
    display: none;
    align-items: baseline;
    gap: .18rem;
    margin-left: auto;
    font-size: .74rem;
    font-weight: 700;
    color: #94a3b8;
    font-variant-numeric: tabular-nums;
  }

  .toc[open] .toc-progress {
    display: inline-flex;
  }

  .toc-progress b {
    font-size: .86rem;
    color: #2563eb;
  }

  .toc-list {
    list-style: none;
    margin: 0 .45rem .5rem;
    padding: 0;
    border-left: 1px solid #e2e8f0;
  }

  .toc-list li {
    margin: 0;
  }

  .toc-list a {
    display: flex;
    align-items: baseline;
    gap: .65rem;
    margin-left: -1px;
    padding: .42rem .6rem .42rem .9rem;
    border-left: 2px solid transparent;
    border-radius: 0 8px 8px 0;
    color: #475569;
    text-decoration: none;
    font-size: .86rem;
    line-height: 1.5;
  }

  .toc-list a:hover {
    color: #1d4ed8;
    background: #f8fafc;
  }

  .toc-n {
    flex: none;
    min-width: 1.3rem;
    font-size: .72rem;
    font-weight: 700;
    color: #94a3b8;
    font-variant-numeric: tabular-nums;
  }

  .toc-t {
    min-width: 0;
  }

  .toc-list a.is-active {
    color: #1d4ed8;
    background: #eff6ff;
    border-left-color: #2563eb;
    font-weight: 600;
  }

  .toc-list a.is-active .toc-n {
    color: #2563eb;
  }

  .toc-home {
    padding-bottom: .4rem;
    margin-bottom: .4rem;
    border-bottom: 1px dashed #e2e8f0;
  }

  .toc-home .toc-n {
    font-size: .78rem;
    color: #2563eb;
  }

  .dark .container.article-layout > .toc {
    border-color: #1f2937;
    background: #111827;
    box-shadow: 0 2px 10px rgba(0, 0, 0, .35);
    color: #cbd5e1;
  }

  .dark .container.article-layout > .toc[open] {
    border-color: #1f2937;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
  }

  .dark .toc:not([open]) > summary {
    color: #cbd5e1;
  }

  .dark .toc:not([open]) > summary:hover {
    color: #93c5fd;
    background: rgba(255, 255, 255, .04);
  }

  .dark .toc:not([open]) .toc-btn-icon {
    color: #93c5fd;
  }

  .dark .toc[open] > summary {
    background: #111827;
    color: #94a3b8;
  }

  .dark .toc > summary {
    color: #94a3b8;
  }

  .dark .toc-caret {
    border-color: #64748b;
  }

  .dark .toc-progress {
    color: #64748b;
  }

  .dark .toc-progress b {
    color: #93c5fd;
  }

  .dark .toc-list {
    border-left-color: #1f2937;
  }

  .dark .toc-list a {
    color: #cbd5e1;
  }

  .dark .toc-list a:hover {
    color: #93c5fd;
    background: rgba(255, 255, 255, .04);
  }

  .dark .toc-n {
    color: #64748b;
  }

  .dark .toc-list a.is-active {
    color: #bfdbfe;
    background: rgba(37, 99, 235, .18);
    border-left-color: #3b82f6;
  }

  .dark .toc-list a.is-active .toc-n {
    color: #93c5fd;
  }

  .dark .toc-home {
    border-bottom-color: #1f2937;
  }

  .dark .toc-home .toc-n {
    color: #93c5fd;
  }

}

@media print {
  .toc {
    display: none;
  }
}
