/* ====== 文章页布局 ====== */
.article-page {
  max-width: none;
  min-width: 0;
}

/* ====== 面包屑 ====== */
.breadcrumb {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: var(--space-lg);
}

.breadcrumb a { transition: color var(--transition); }
.breadcrumb a:hover { color: var(--link); }
.breadcrumb__separator { margin: 0 6px; color: var(--text-ghost); }
.breadcrumb__current { color: var(--text-secondary); }

/* ====== 文章头部 ====== */
.article__header {
  margin-bottom: var(--space-xl);
  padding-bottom: var(--space-lg);
  border-bottom: 1px solid var(--border);
}

/* ── detail 面板：header/toc 固定，只有正文内容滚动 ──────── */

/* article 撑满 panel flex 剩余空间，切换为 2 列 grid */
.workspace--detail #av-article {
  display: grid;
  grid-template-columns: 1fr 180px;
  grid-template-rows: auto 1fr auto;
  column-gap: var(--space-xl);
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* header：全宽第一行，静止不滚动 */
.workspace--detail .article__header {
  grid-column: 1 / -1;
  grid-row: 1;
  position: static;
  z-index: auto;
  background: var(--bg-body);
  padding-top: var(--space-lg);
  margin-bottom: 0;
}

/* article__body 透明化，让 content/toc 直接进入 article grid */
.workspace--detail .article__body {
  display: contents;
}

/* 正文列：唯一滚动区域，撑满 1fr 列宽 */
.workspace--detail .article__content {
  grid-column: 1;
  grid-row: 2;
  max-width: none;
  overflow-y: auto;
  min-height: 0;
  padding-top: var(--space-lg);
  padding-bottom: var(--space-2xl);   /* 滚动到底时最后一段不贴边 */
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.workspace--detail .article__content::-webkit-scrollbar { width: 4px; }

.workspace--detail .article__content::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.workspace--detail .article__content::-webkit-scrollbar-thumb:hover {
  background: var(--border-strong);
}

/* ── 标题区折叠动效（向下滚动时收缩） ───────────────────────── */

/* header 本身：内边距丝滑过渡（背景由 panel 提供，header 保持透明） */
.workspace--detail .article__header {
  transition:
    padding-top    300ms cubic-bezier(0.4, 0, 0.2, 1),
    padding-bottom 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* 标题字号过渡 */
.workspace--detail .article__title {
  transition:
    font-size   320ms cubic-bezier(0.4, 0, 0.2, 1),
    line-height 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* panel 全宽渐变背景（折叠时生效，从顶部向下染色） */
.workspace--detail .panel--detail {
  transition: background 360ms cubic-bezier(0.4, 0, 0.2, 1);
}

.workspace--detail .panel--detail.panel--header-collapsed {
  background: linear-gradient(
    to bottom,
    #e5e4de var(--panel-header-h, 38px),
    var(--bg-body) var(--panel-header-h, 38px)
  );
}

/* 会被折叠的子元素：max-height + opacity 过渡 */
.workspace--detail .article__indicators,
.workspace--detail .article__subtitle,
.workspace--detail .article__affected {
  overflow: hidden;
  max-height: 240px;
  transition:
    max-height 340ms cubic-bezier(0.4, 0, 0.2, 1),
    opacity    280ms ease,
    margin     320ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* 折叠态：header 背景透明，颜色由 panel 全宽渐变提供 */
.workspace--detail .article__header--collapsed {
  background-color: transparent;
  padding-top:    var(--space-xs) !important;
  padding-bottom: var(--space-xs) !important;
}

.workspace--detail .article__header--collapsed .article__title {
  font-size:   17px;
  line-height: 1.25;
}

.workspace--detail .article__header--collapsed .article__indicators,
.workspace--detail .article__header--collapsed .article__subtitle,
.workspace--detail .article__header--collapsed .article__affected {
  max-height: 0;
  opacity: 0;
  margin-top:    0 !important;
  margin-bottom: 0 !important;
}

/* 标签行：全宽，位于内容下方 */
.workspace--detail .article__tags {
  grid-column: 1 / -1;
  grid-row: 3;
}


/* 窄屏隐藏目录，正文占全宽 */
@media (max-width: 960px) {
  .workspace--detail #av-article {
    grid-template-columns: 1fr;
  }
  .workspace--detail .toc { display: none; }
  .workspace--detail .article__tags { grid-column: 1; }
}

.article__indicators {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
  flex-wrap: wrap;
  font-size: 12.5px;
}

.article__cvss {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius);
}

.article__category-link {
  color: var(--link);
  font-weight: 500;
}

.article__views {
  color: var(--text-muted);
  font-size: 12px;
}

.article__category-link:hover { color: var(--link-hover); }
.article__date, .article__readtime { color: var(--text-muted); }

.article__cve-id {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--severity-critical);
}

.article__author-name { color: var(--text-muted); }

.article__title {
  font-family: var(--font-heading);
  font-size: 28px;
  font-weight: 700;
  color: var(--text-heading);
  line-height: 1.3;
}

.article__title .title-prefix {
  font-size: 0.85em;
  letter-spacing: -0.3px;
  margin-bottom: var(--space-sm);
}

.article__subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.55;
}

.article__affected {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: var(--space-sm);
}

.article__affected-item {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-muted);
  background: var(--bg-body);
  border: 1px solid var(--border);
  padding: 2px 7px;
  border-radius: var(--radius);
}

/* ====== 内容 + 目录 ====== */
.article__body {
  display: grid;
  grid-template-columns: 1fr 180px;
  gap: var(--space-xl);
  align-items: start;
}

.article__content {
  max-width: 78ch;
}

/* ====== 目录 ====== */
.toc {
  position: sticky;
  top: calc(var(--nav-height) + var(--space-lg));
  font-size: 12px;
  order: 2;
}

/* 目录列：固定在右侧，不随正文滚动 */
.workspace--detail .toc {
  grid-column: 2;
  grid-row: 2;
  position: static;
  top: auto;
  align-self: start;
  overflow-y: auto;
  max-height: 100%;
  padding-top: var(--space-lg);
}

.toc__title {
  font-family: var(--font-heading);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-heading);
  margin-bottom: var(--space-sm);
}

.toc__list {
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border);
}

.toc__link {
  display: block;
  padding: 3px 10px;
  color: var(--text-muted);
  transition: color var(--transition);
  border-left: 1.5px solid transparent;
  margin-left: -1px;
  line-height: 1.4;
}

.toc__link:hover { color: var(--text-body); }
.toc__link--active { color: var(--link); border-left-color: var(--link); }
/* h3 子目录缩进 */
.toc__link--h3 { padding-left: 22px; font-size: 0.88em; }

/* 大纲点击定位：浅灰衬底 + 左侧指示条 + 标题标记 + 入场引导 */
.toc-section {
  position: relative;
  border-radius: 6px;
  scroll-margin-top: 12px;
}
.toc-section::before {
  content: '';
  position: absolute;
  left: -14px;
  right: -14px;
  top: -2px;
  bottom: -2px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.045);
  box-shadow: inset 3px 0 0 rgba(0, 0, 0, 0.14);
  opacity: 0;
  transition: opacity 0.35s ease, box-shadow 0.35s ease;
  pointer-events: none;
  z-index: 0;
}
.toc-section--focus::before {
  opacity: 1;
  box-shadow: inset 3px 0 0 rgba(0, 0, 0, 0.22);
}
.toc-section--focus.toc-section--enter::before {
  animation: tocSectionPulse 1s ease;
}
.toc-section > * { position: relative; z-index: 1; }

/* 左侧下滑引导箭头（仅入场时播放 2 次） */
.toc-section::after {
  content: '';
  position: absolute;
  left: -10px;
  top: 12px;
  width: 7px;
  height: 7px;
  border-right: 2px solid rgba(0, 0, 0, 0.28);
  border-bottom: 2px solid rgba(0, 0, 0, 0.28);
  transform: rotate(45deg);
  opacity: 0;
  pointer-events: none;
  z-index: 2;
}
.toc-section--focus.toc-section--enter::after {
  animation: tocArrowGuide 0.75s ease 2;
}

/* 标题行：下划线 + 「当前位置」标记 */
.toc-section--focus > :is(h2, h3):first-child {
  position: relative;
}
.toc-section--focus > :is(h2, h3):first-child::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -3px;
  height: 2px;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.16) 0%, rgba(0, 0, 0, 0.06) 55%, transparent 100%);
  border-radius: 1px;
  pointer-events: none;
}
.toc-section--focus > :is(h2, h3):first-child::after {
  content: '当前位置';
  display: inline-block;
  margin-left: 12px;
  padding: 2px 9px;
  font-family: var(--font-heading);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.1em;
  line-height: 1.5;
  vertical-align: middle;
  color: var(--link);
  background: var(--severity-info-bg);
  border: 1px solid rgba(44, 82, 130, 0.35);
  border-radius: 4px;
  box-shadow: 0 1px 0 rgba(44, 82, 130, 0.08);
  animation: tocMarkerIn 0.45s ease;
}

@keyframes tocSectionPulse {
  0%   { box-shadow: inset 3px 0 0 rgba(0, 0, 0, 0.32), 0 0 0 0 rgba(0, 0, 0, 0.06); }
  45%  { box-shadow: inset 3px 0 0 rgba(0, 0, 0, 0.28), 0 0 0 5px rgba(0, 0, 0, 0.035); }
  100% { box-shadow: inset 3px 0 0 rgba(0, 0, 0, 0.22), 0 0 0 0 rgba(0, 0, 0, 0); }
}
@keyframes tocArrowGuide {
  0%, 100% { transform: rotate(45deg) translateY(0);    opacity: 0.35; }
  50%      { transform: rotate(45deg) translateY(5px); opacity: 0.95; }
}
@keyframes tocMarkerIn {
  from { opacity: 0; transform: translateY(-3px); }
  to   { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .toc-section--focus.toc-section--enter::before,
  .toc-section--focus.toc-section--enter::after,
  .toc-section--focus > :is(h2, h3):first-child::after {
    animation: none;
  }
}

/* ====== 文章正文 ====== */
.article__content { order: 1; min-width: 0; }

.article__content h2 {
  font-family: var(--font-heading);
  font-size: 20px;
  font-weight: 700;
  color: var(--text-heading);
  margin: var(--space-xl) 0 var(--space-md);
  padding-top: var(--space-sm);
}

.article__content h2:first-child { margin-top: 0; }

.article__content h3 {
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 700;
  color: var(--text-heading);
  margin: var(--space-lg) 0 var(--space-sm);
}

.article__content p { margin-bottom: var(--space-md); }
.article__content strong { color: var(--text-heading); font-weight: 600; }

.article__content a {
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-color: var(--border);
}
.article__content a:hover { text-decoration-color: var(--link); }

.article__content ul, .article__content ol {
  margin-bottom: var(--space-md);
  padding-left: var(--space-lg);
}

.article__content ul { list-style: disc; }
.article__content ul li, .article__content ol li { margin-bottom: var(--space-xs); }
.article__content ol { list-style: decimal; }

.article__content code {
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--bg-code);
  padding: 1px 5px;
  border-radius: 2px;
  color: var(--severity-high);
}

.article__content pre {
  margin-bottom: var(--space-lg);
  background: var(--bg-code-block);
  border-radius: var(--radius);
  overflow-x: auto;
}

.article__content pre code {
  display: block;
  padding: 14px 18px;
  background: transparent;
  color: #d4d4d4;
  font-size: 12.5px;
  line-height: 1.65;
  border-radius: 0;
}

.article__content table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: var(--space-lg);
  font-size: 13.5px;
  line-height: 1.5;
  overflow-x: auto;
  display: block;
}

.article__content thead {
  background: var(--bg-surface);
}

.article__content th {
  text-align: left;
  padding: 9px 14px;
  font-weight: 600;
  color: var(--text-heading);
  font-size: 12.5px;
  border: 1px solid var(--border);
  white-space: nowrap;
}

.article__content td {
  padding: 8px 14px;
  border: 1px solid var(--border);
  color: var(--text-body);
  vertical-align: top;
}

.article__content tbody tr:hover td {
  background: var(--bg-surface);
}

.article__content blockquote {
  margin: 0 0 var(--space-md) 0;
  padding: var(--space-sm) var(--space-md);
  border-left: 3px solid var(--border-strong);
  color: var(--text-secondary);
  background: var(--bg-surface);
  border-radius: 0 var(--radius) var(--radius) 0;
}

.article__content blockquote p:last-child {
  margin-bottom: 0;
}

.article__content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: var(--space-xl) 0;
}

.article__content img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  margin: var(--space-sm) 0;
}

.article__content del {
  color: var(--text-muted);
}

/* ====== 标签 ====== */
.article__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: var(--space-xl);
  padding-top: var(--space-lg);
  border-top: 1px solid var(--border);
}

.tag {
  font-size: 12px;
  color: var(--text-secondary);
  padding: 3px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color var(--transition);
}

.tag:hover { border-color: var(--border-strong); }


/* ====== 正文增强：图片看大图 + 代码复制 ====== */

/* 可点击放大的图片 */
.article__content img.is-zoomable {
  cursor: zoom-in;
  transition: filter var(--transition), box-shadow 0.2s ease;
}
.article__content img.is-zoomable:hover {
  filter: brightness(1.03);
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.16);
}
.article__content img.is-zoomable:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 3px;
}

/* 代码块：外壳 + 顶栏（语言标签 + 复制按钮） */
.article__content .code-wrap {
  position: relative;
  margin-bottom: var(--space-lg);
  background: var(--bg-code-block);
  border: 1px solid var(--code-border, transparent);
  border-radius: var(--radius);
  overflow: hidden;
}

.article__content .code-wrap pre {
  margin: 0;
  border-radius: 0;
  background: transparent;
}

.code-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  padding: 5px 8px 5px 14px;
  background: rgba(255, 255, 255, 0.045);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.code-lang {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.42);
  user-select: none;
}
.code-lang.is-empty { visibility: hidden; }

.code-copy {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-body);
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1;
  color: #d0d0cc;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--radius);
  padding: 4px 9px;
  cursor: pointer;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease;
}
.code-copy:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.3);
  color: #fff;
}
.code-copy:focus-visible {
  outline: none;
  border-color: rgba(255, 255, 255, 0.55);
}
.code-copy svg { width: 13px; height: 13px; flex: none; }

.code-copy.code-copy--done {
  color: #7ee2a8;
  border-color: rgba(126, 226, 168, 0.42);
  background: rgba(126, 226, 168, 0.14);
}
.code-copy.code-copy--fail {
  color: #f0a0a0;
  border-color: rgba(240, 160, 160, 0.42);
  background: rgba(240, 160, 160, 0.14);
}

/* 行号（自带样式，避免插件注入 <style> 被 CSP 拦截）
   注意：行号插件会把代码包成 <table><td>，必须隔离正文通用 table/td/th 样式，
   否则非高亮代码会继承 .article__content td 的 var(--text-body)，在浅色模式下深底深字不可见 */
.article__content .hljs-ln {
  display: table;
  width: 100%;
  margin: 0;
  border-collapse: collapse;
  font-size: inherit;
  background: transparent;
}
.article__content .hljs-ln td,
.article__content .hljs-ln th {
  padding: 0;
  border: none;
  background: transparent;
  color: #d4d4d4;
  vertical-align: top;
  white-space: inherit;
}
.article__content .hljs-ln td.hljs-ln-numbers {
  width: 1%;
  white-space: nowrap;
  text-align: right;
  padding-right: 14px;
  color: rgba(255, 255, 255, 0.3);
  user-select: none;
  -webkit-user-select: none;
}
.article__content .hljs-ln td.hljs-ln-code { padding-left: 0; color: #d4d4d4; }
.article__content .hljs-ln-n::before { content: attr(data-line-number); }
.article__content .hljs-ln tbody tr:hover td,
.article__content .hljs-ln td:hover { background: transparent; }

/* highlight.js 语法主题（自托管，深色，统一浅/暗页面） */
.article__content .hljs { color: #d4d4d4; background: transparent; }
.article__content .hljs-comment,
.article__content .hljs-quote { color: #6a9955; font-style: italic; }
.article__content .hljs-keyword,
.article__content .hljs-selector-tag,
.article__content .hljs-built_in,
.article__content .hljs-name,
.article__content .hljs-tag { color: #569cd6; }
.article__content .hljs-string,
.article__content .hljs-attr,
.article__content .hljs-template-tag,
.article__content .hljs-addition,
.article__content .hljs-regexp,
.article__content .hljs-symbol,
.article__content .hljs-attribute { color: #ce9178; }
.article__content .hljs-number,
.article__content .hljs-literal,
.article__content .hljs-variable,
.article__content .hljs-template-variable,
.article__content .hljs-bullet,
.article__content .hljs-link { color: #b5cea8; }
.article__content .hljs-title,
.article__content .hljs-section,
.article__content .hljs-title.function_ { color: #dcdcaa; }
.article__content .hljs-type,
.article__content .hljs-title.class_,
.article__content .hljs-class .hljs-title { color: #4ec9b0; }
.article__content .hljs-meta { color: #9b9b9b; }
.article__content .hljs-meta .hljs-keyword { color: #569cd6; }
.article__content .hljs-deletion { color: #d16969; }
.article__content .hljs-emphasis { font-style: italic; }
.article__content .hljs-strong { font-weight: 700; }

/* 离屏复制回退用元素 */
.cp-offscreen {
  position: fixed;
  left: -9999px;
  top: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* ====== 图片灯箱 ====== */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 5vh 5vw;
  background: rgba(18, 18, 16, 0);
  opacity: 0;
  visibility: hidden;
  cursor: zoom-out;
  transition:
    opacity 0.26s ease,
    visibility 0.26s ease,
    background 0.26s ease;
}
.lightbox--open {
  opacity: 1;
  visibility: visible;
  background: rgba(18, 18, 16, 0.84);
}

.lightbox__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  max-height: 100%;
  transform: scale(0.96);
  transition: transform 0.28s cubic-bezier(0.2, 0.7, 0.3, 1);
}
.lightbox--open .lightbox__inner { transform: scale(1); }

.lightbox__img {
  max-width: 100%;
  max-height: 86vh;
  object-fit: contain;
  border-radius: var(--radius);
  background: var(--bg-surface);
  box-shadow: 0 14px 50px rgba(0, 0, 0, 0.5);
  cursor: default;
}
.lightbox__caption {
  max-width: 72ch;
  color: rgba(255, 255, 255, 0.8);
  font-size: 12.5px;
  line-height: 1.5;
  text-align: center;
}
.lightbox__caption.is-empty { display: none; }

.lightbox__close {
  position: absolute;
  top: 16px;
  right: 18px;
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
}
.lightbox__close:hover { background: rgba(255, 255, 255, 0.22); }
.lightbox__close:active { transform: scale(0.94); }
.lightbox__close:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.7);
  outline-offset: 2px;
}
.lightbox__close svg { width: 22px; height: 22px; }

body.lightbox-lock { overflow: hidden; }

@media (prefers-reduced-motion: reduce) {
  .lightbox,
  .lightbox__inner { transition: opacity 0.15s ease, visibility 0.15s ease; }
  .lightbox__inner { transform: none; }
  .lightbox--open .lightbox__inner { transform: none; }
}

/* ====== 响应式 ====== */
@media (max-width: 960px) {
  .article__body { grid-template-columns: 1fr; }
  .toc {
    position: static;
    order: -1;
    margin-bottom: var(--space-md);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
  }
  .article__title { font-size: 22px; }
}

/* ====== 阅读进度条 + 返回顶部 ====== */
.read-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 60;
  background: transparent;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.read-progress.is-active { opacity: 1; }

.read-progress__fill {
  height: 100%;
  width: 100%;
  transform-origin: left center;
  transform: scaleX(var(--read-progress, 0));
  background: linear-gradient(90deg, var(--link), var(--severity-info));
  transition: transform 0.08s linear;
}

.to-top {
  position: fixed;
  right: 22px;
  bottom: 26px;
  width: 40px;
  height: 40px;
  z-index: 1001;   /* 高于底部音乐播放器栏（z-index:1000），避免被遮挡 */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 50%;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
  cursor: pointer;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition:
    opacity 0.2s ease,
    transform 0.2s ease,
    color var(--transition),
    border-color var(--transition),
    background var(--transition);
}
.to-top.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.to-top:hover { color: var(--text-heading); border-color: var(--border-strong); }
.to-top svg { width: 20px; height: 20px; }

/* 播放器栏（高 62px）激活时，整体抬高让开，避免被遮住 */
body.has-mp-player .to-top { bottom: 84px; }

@media (max-width: 520px) {
  .to-top { right: 14px; bottom: 16px; }
  body.has-mp-player .to-top { bottom: 74px; }
}

@media (prefers-reduced-motion: reduce) {
  .read-progress__fill { transition: none; }
  .to-top { transition: opacity 0.2s ease; }
}

/* ====== 暗色模式：修正硬编码装饰色 ====== */
:root[data-theme="dark"] .workspace--detail .panel--detail.panel--header-collapsed {
  background: linear-gradient(
    to bottom,
    #20242b var(--panel-header-h, 38px),
    var(--bg-body) var(--panel-header-h, 38px)
  );
}
:root[data-theme="dark"] .toc-section::before {
  background: rgba(255, 255, 255, 0.05);
  box-shadow: inset 3px 0 0 rgba(255, 255, 255, 0.16);
}
:root[data-theme="dark"] .toc-section--focus::before {
  box-shadow: inset 3px 0 0 rgba(255, 255, 255, 0.26);
}
:root[data-theme="dark"] .toc-section::after {
  border-right-color: rgba(255, 255, 255, 0.34);
  border-bottom-color: rgba(255, 255, 255, 0.34);
}
:root[data-theme="dark"] .toc-section--focus > :is(h2, h3):first-child::before {
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0.08) 55%, transparent 100%);
}

/* ====== 文章互动（点赞 / 收藏） ====== */
.actions {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin-top: 34px;
}

.actions__btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 22px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition:
    color var(--transition),
    border-color var(--transition),
    background-color var(--transition),
    transform var(--transition);
}

.actions__btn svg { width: 17px; height: 17px; }

.actions__btn:hover {
  color: var(--text-heading);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.actions__count {
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  font-size: 12px;
}

.actions__btn--like.is-active {
  color: #e0245e;
  border-color: rgba(224, 36, 94, 0.45);
  background: rgba(224, 36, 94, 0.08);
}

.actions__btn--fav.is-active {
  color: #d98e04;
  border-color: rgba(217, 142, 4, 0.45);
  background: rgba(217, 142, 4, 0.08);
}

.actions__btn.is-active svg { fill: currentColor; }
.actions__btn.is-active .actions__count { color: inherit; }

@keyframes actions-pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.35); }
  100% { transform: scale(1); }
}

.actions__btn.is-pop svg { animation: actions-pop 0.35s ease; }

/* ====== 文章分享栏 ====== */
.share {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.share__label {
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 1px;
  margin-right: 2px;
}

.share__btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition:
    color var(--transition),
    border-color var(--transition),
    background-color var(--transition),
    transform var(--transition);
}

.share__btn svg { width: 16px; height: 16px; }

.share__btn:hover { transform: translateY(-2px); color: #fff; }
.share__btn--wechat:hover { background: #07c160; border-color: #07c160; }
.share__btn--qq:hover     { background: #12b7f5; border-color: #12b7f5; }
.share__btn--weibo:hover  { background: #e6162d; border-color: #e6162d; }
.share__btn--tg:hover     { background: #26a5e4; border-color: #26a5e4; }
.share__btn--x:hover      { background: #14171a; border-color: #444; }
.share__btn--copy:hover,
.share__btn--sys:hover    { background: var(--link); border-color: var(--link); }

.share__btn.is-ok,
.share__btn.is-ok:hover {
  background: var(--severity-low);
  border-color: var(--severity-low);
  color: #fff;
}

/* ====== 微信扫码弹层 ====== */
.share-qrmask {
  position: fixed;
  inset: 0;
  z-index: 1200;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.share-qrmask.is-open { opacity: 1; }

.share-qrcard {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 22px 28px 20px;
  text-align: center;
  max-width: 90vw;
  transform: scale(0.94) translateY(6px);
  transition: transform 0.2s ease;
}

.share-qrmask.is-open .share-qrcard { transform: scale(1) translateY(0); }

.share-qrcard__title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-heading);
  margin-bottom: 14px;
}

/* 二维码底色固定白色，保证暗色模式下可扫 */
.share-qrbox {
  width: 200px;
  height: 200px;
  margin: 0 auto;
  padding: 10px;
  background: #fff;
  box-sizing: content-box;
}

.share-qrbox svg { width: 100%; height: 100%; display: block; }

.share-qrcard__hint {
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-muted);
  max-width: 220px;
}

.share-qrcard__close {
  margin-top: 14px;
  padding: 5px 20px;
  font-size: 12px;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
}

.share-qrcard__close:hover { color: var(--text-heading); border-color: var(--border-strong); }

/* 剪贴板降级用的离屏 textarea */
.u-offscreen {
  position: fixed;
  left: -9999px;
  top: 0;
  opacity: 0;
}

/* ====== 内置浏览器分享引导层（微信/手机QQ：指向右上角原生分享菜单） ====== */
.share-guide {
  position: fixed;
  inset: 0;
  z-index: 1300;
  background: rgba(0, 0, 0, 0.78);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  padding: 18px 22px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.share-guide.is-open { opacity: 1; }

.share-guide__arrow {
  color: #fff;
  margin-right: 6px;
  animation: share-guide-bounce 1.1s ease-in-out infinite;
}

.share-guide__arrow svg {
  width: 52px;
  height: 52px;
}

.share-guide__text {
  margin-top: 14px;
  color: #fff;
  font-size: 16px;
  line-height: 1.9;
  text-align: right;
  white-space: pre-line;
  letter-spacing: 0.5px;
}

.share-guide__hint {
  margin-top: auto;
  align-self: center;
  margin-bottom: 48px;
  color: rgba(255, 255, 255, 0.55);
  font-size: 12px;
  letter-spacing: 1px;
}

@keyframes share-guide-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
