/* 文章页大纲：宽屏贴在正文右侧，可整栏收起；窄屏用右下按钮打开抽屉。 */

.文章大纲 {
  position: fixed;
  top: 5.6rem;
  left: calc(50% + min(400px, 46vw) + 1.15rem);
  z-index: 28;
  display: none;
  flex-direction: column;
  width: 228px;
  max-height: calc(100vh - 8rem);
  padding: 0.55rem 0.45rem 0.7rem 0.55rem;
  overflow: hidden;
  border: 1px solid var(--皮肤-描边, color-mix(in oklab, var(--color-base-content) 12%, transparent));
  border-radius: var(--圆-中, 0.85rem);
  background: color-mix(in oklab, var(--color-base-100) 86%, transparent);
  box-shadow: var(--皮肤-影卡, 0 1px 2px rgba(24, 16, 60, 0.05));
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  font-size: 0.84rem;
  overscroll-behavior: contain;
}

.文章大纲-头 {
  display: flex;
  align-items: center;
  margin: 0 0 0.35rem;
}

.文章大纲-开关 {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
  padding: 0.15rem 0.35rem;
  border: 0;
  border-radius: var(--圆-小, 0.5rem);
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  opacity: 0.5;
  cursor: pointer;
}

.文章大纲-开关::before {
  content: "";
  width: 0.42rem;
  height: 0.42rem;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
  transition: transform var(--时-短, 0.18s) var(--动-入, ease);
}

.文章大纲:not(.开) .文章大纲-开关::before {
  transform: rotate(-45deg);
}

.文章大纲-开关:hover {
  opacity: 0.9;
  background: var(--皮肤-淡面, color-mix(in oklab, var(--color-primary) 8%, transparent));
}

.文章大纲-体 {
  overflow: auto;
  min-height: 0;
  scrollbar-width: thin;
}

.文章大纲-树 {
  list-style: none;
  margin: 0;
  padding: 0;
}

.文章大纲-项 > .文章大纲-树 {
  padding-left: 0.55rem;
}

.文章大纲-项.折起 > .文章大纲-树 {
  display: none;
}

.文章大纲-行 {
  display: flex;
  align-items: flex-start;
  gap: 0.05rem;
}

.文章大纲-折,
.文章大纲-占 {
  flex: 0 0 1.05rem;
  width: 1.05rem;
  height: 1.35rem;
}

.文章大纲-折 {
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  opacity: 0.45;
}

.文章大纲-折::before {
  content: "";
  display: block;
  width: 0.38rem;
  height: 0.38rem;
  margin: 0.42rem auto 0;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
  transition: transform var(--时-短, 0.18s) var(--动-入, ease);
}

.文章大纲-折[aria-expanded="true"]::before {
  margin-top: 0.32rem;
  transform: rotate(45deg);
}

.文章大纲-折:hover {
  opacity: 0.9;
}

.文章大纲 a {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0.18rem 0.3rem 0.18rem 0.2rem;
  border-left: 2px solid transparent;
  line-height: 1.5;
  color: inherit;
  opacity: 0.62;
  text-decoration: none;
  word-break: break-word;
  transition: opacity 0.15s ease, color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.文章大纲 a:hover {
  opacity: 1;
  background: var(--皮肤-淡面, color-mix(in oklab, var(--color-primary) 8%, transparent));
  border-radius: 0.3rem;
}

.文章大纲 a.当前 {
  opacity: 1;
  color: var(--color-primary);
  font-weight: 600;
  border-left-color: var(--color-primary);
}

.文章大纲 .在径 > .文章大纲-行 > a:not(.当前) {
  opacity: 0.85;
}

.文章大纲钮 {
  position: fixed;
  right: 1.15rem;
  bottom: 4.25rem;
  z-index: 40;
  display: none;
  place-items: center;
  width: 2.6rem;
  height: 2.6rem;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  background: color-mix(in oklab, var(--color-primary) 88%, var(--color-base-100));
  color: var(--color-primary-content, white);
  box-shadow: 0 8px 20px color-mix(in oklab, black 18%, transparent);
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.文章大纲钮:hover {
  filter: brightness(1.06);
}

.文章大纲罩 {
  position: fixed;
  inset: 0;
  z-index: 46;
  background: color-mix(in oklab, #000 38%, transparent);
}

.文章大纲[hidden],
.文章大纲罩[hidden] {
  display: none !important;
}

body:has(.阅读区.编辑中) .文章大纲,
body:has(.阅读区.编辑中) .文章大纲钮,
body:has(.阅读区.编辑中) .文章大纲罩 {
  display: none !important;
}

#阅读正文 :is(h1, h2, h3, h4) {
  scroll-margin-top: 5.5rem;
}

@media (min-width: 1260px) {
  .文章大纲 {
    display: flex;
  }

  .文章大纲:not(.开) {
    left: auto;
    right: 0.7rem;
    width: 2.35rem;
    padding: 0.55rem 0.15rem;
  }

  .文章大纲:not(.开) .文章大纲-体 {
    display: none;
  }

  .文章大纲:not(.开) .文章大纲-头 {
    justify-content: center;
    margin: 0;
  }

  .文章大纲:not(.开) .文章大纲-开关 {
    writing-mode: vertical-rl;
    letter-spacing: 0.22em;
    padding: 0.45rem 0.15rem;
  }
}

@media (max-width: 1259px) {
  .文章大纲 {
    display: flex;
    top: 0;
    right: 0;
    left: auto;
    bottom: 0;
    width: min(20rem, 86vw);
    max-height: none;
    padding: 1rem 0.7rem 1.2rem 0.8rem;
    border-radius: var(--圆-中, 0.85rem) 0 0 var(--圆-中, 0.85rem);
    box-shadow: var(--皮肤-影浮, 0 2px 6px rgba(24, 16, 60, 0.07));
    transform: translateX(105%);
    transition: transform var(--时-中, 0.34s) var(--动-入, ease);
    z-index: 48;
  }

  .文章大纲.开 {
    transform: none;
  }

  .文章大纲钮.显 {
    display: grid;
  }
}
