.page-toc {
  position: fixed;
  top: 92px;
  right: max(16px, calc((100vw - 840px) / 2 - 282px));
  z-index: 10020;
  width: 260px;
  max-height: calc(100vh - 132px);
  overflow: auto;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #1f2937;
  box-shadow: none;
  padding: 0;
  scrollbar-width: none;
}

.page-toc::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.page-toc:hover,
.page-toc:focus-within {
  border-color: rgba(203, 213, 225, 0.9);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.14);
  padding: 0;
  backdrop-filter: blur(12px);
}

.page-toc-title {
  position: sticky;
  top: 0;
  display: block;
  max-height: 0;
  overflow: hidden;
  padding: 0 14px;
  border-bottom: 0;
  background: rgba(255, 255, 255, 0.96);
  font-size: 13px;
  font-weight: 800;
}

.page-toc:hover .page-toc-title,
.page-toc:focus-within .page-toc-title {
  max-height: none;
  padding: 12px 14px 9px;
  border-bottom: 1px solid #e2e8f0;
}

.page-toc-list {
  display: block;
  list-style: none;
  margin: 0;
  padding: 8px 10px;
}

.page-toc:hover .page-toc-list,
.page-toc:focus-within .page-toc-list {
  padding: 8px;
}

.page-toc-item {
  margin: 0 0 11px;
  line-height: 1;
  text-align: right;
}

.page-toc:hover .page-toc-item,
.page-toc:focus-within .page-toc-item {
  margin: 0;
  text-align: left;
}

.page-toc-link {
  display: block;
  margin-left: auto;
  width: 28px;
  height: 4px;
  padding: 0;
  border-radius: 6px;
  overflow: hidden;
  background: #e5e7eb;
  color: transparent;
  text-indent: 120%;
  white-space: nowrap;
  text-decoration: none;
  font-size: 0;
  line-height: 1;
}

.page-toc-h3 .page-toc-link {
  width: 22px;
}

.page-toc:hover .page-toc-link,
.page-toc:focus-within .page-toc-link {
  width: auto;
  height: auto;
  margin-left: 0;
  padding: 7px 8px;
  overflow: visible;
  background: transparent;
  color: #475569;
  text-indent: 0;
  white-space: normal;
  font-size: 13px;
  line-height: 1.35;
}

.page-toc:hover .page-toc-link:hover,
.page-toc:focus-within .page-toc-link:hover {
  background: #f8fafc;
  color: #1d4ed8;
}

.page-toc-link.active {
  width: 30px;
  background: #2f2f2f;
  color: transparent;
  font-weight: 750;
}

.page-toc:hover .page-toc-link.active,
.page-toc:focus-within .page-toc-link.active {
  width: auto;
  background: transparent;
  color: #2563eb;
}

.page-toc:hover .page-toc-h3 .page-toc-link,
.page-toc:focus-within .page-toc-h3 .page-toc-link {
  padding-left: 18px;
  font-size: 12.5px;
  color: #64748b;
}

.page-toc-toggle {
  position: fixed;
  right: 12px;
  bottom: 86px;
  z-index: 10035;
  display: none;
  min-width: 44px;
  min-height: 38px;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  color: #1f2937;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.16);
  font: 800 13px/1.2 system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  padding: 8px 13px;
  cursor: pointer;
  backdrop-filter: blur(12px);
}

.page-toc-toggle:hover,
.page-toc-toggle:focus-visible {
  border-color: #2563eb;
  color: #1d4ed8;
  outline: none;
}

html[data-theme="dark"] .page-toc {
  border-color: transparent;
  background: transparent;
  color: #e5edf8;
  box-shadow: none;
}

html[data-theme="dark"] .page-toc:hover,
html[data-theme="dark"] .page-toc:focus-within {
  border-color: #334155;
  background: rgba(17, 24, 39, 0.96);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.34);
}

html[data-theme="dark"] .page-toc-title {
  border-color: #334155;
  background: rgba(17, 24, 39, 0.96);
  color: #e5edf8;
}

html[data-theme="dark"] .page-toc-link {
  background: #334155;
  color: transparent;
}

html[data-theme="dark"] .page-toc:hover .page-toc-link,
html[data-theme="dark"] .page-toc:focus-within .page-toc-link {
  background: transparent;
  color: #9aa8bd;
}

html[data-theme="dark"] .page-toc:hover .page-toc-link:hover,
html[data-theme="dark"] .page-toc:focus-within .page-toc-link:hover {
  background: #182235;
  color: #bfdbfe;
}

html[data-theme="dark"] .page-toc-link.active {
  background: #e5edf8;
  color: transparent;
}

html[data-theme="dark"] .page-toc:hover .page-toc-link.active,
html[data-theme="dark"] .page-toc:focus-within .page-toc-link.active {
  background: transparent;
  color: #93c5fd;
}

html[data-theme="dark"] .page-toc-toggle {
  border-color: #475569;
  background: rgba(15, 23, 42, 0.94);
  color: #e5edf8;
}

html[data-theme="dark"] .page-toc-toggle:hover,
html[data-theme="dark"] .page-toc-toggle:focus-visible {
  border-color: #60a5fa;
  color: #bfdbfe;
}

@media (max-width: 1359px) {
  .page-toc {
    top: auto;
    right: 12px;
    bottom: 132px;
    display: none;
    width: min(320px, calc(100vw - 24px));
    max-height: min(56vh, 460px);
    border-color: rgba(203, 213, 225, 0.9);
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.14);
    padding: 0;
    backdrop-filter: blur(12px);
    scrollbar-width: thin;
  }

  .page-toc-title {
    display: block;
    max-height: none;
    padding: 12px 14px 9px;
    border-bottom: 1px solid #e2e8f0;
  }

  .page-toc-list {
    display: block;
    padding: 8px;
  }

  .page-toc-link,
  .page-toc-link.active {
    width: auto;
    height: auto;
    padding: 7px 8px;
    overflow: visible;
    background: transparent;
    color: #475569;
    text-indent: 0;
    white-space: normal;
    font-size: 13px;
    line-height: 1.35;
  }

  .page-toc-link:hover,
  .page-toc-link.active {
    color: #2563eb;
  }

  .page-toc-h3 .page-toc-link {
    width: auto;
    padding-left: 18px;
    font-size: 12.5px;
    color: #64748b;
  }

  .page-toc.open {
    display: block;
  }

  .page-toc-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  html[data-theme="dark"] .page-toc {
    border-color: #334155;
    background: rgba(17, 24, 39, 0.96);
    box-shadow: 0 18px 44px rgba(0, 0, 0, 0.34);
  }

  html[data-theme="dark"] .page-toc-link,
  html[data-theme="dark"] .page-toc-link.active {
    background: transparent;
    color: #9aa8bd;
  }

  html[data-theme="dark"] .page-toc-link:hover,
  html[data-theme="dark"] .page-toc-link.active {
    color: #93c5fd;
  }
}

@media (min-width: 1360px) {
  .page-toc-toggle {
    display: none !important;
  }
}
