@layer existing {
/* 长笔记阅读辅助：进度、目录、排版与专注模式。 */
.nb-page {
  --text: var(--fg);
  --text-muted: var(--muted);
  --bg-soft: var(--surface-2);
}
.nr-progress { position: fixed; inset: 0 0 auto; z-index: 200; height: 3px; background: transparent; }
.nr-progress i { display: block; width: 0; height: 100%; background: var(--accent, #0071e3); transition: width .08s linear; }

.nr-toc {
  position: fixed; z-index: 80; top: 92px; left: max(18px, calc(50vw - 660px));
  width: 220px; max-height: calc(100vh - 180px); padding: 16px;
  overflow: auto; border: 1px solid var(--ln-hair, rgba(127,127,127,.22)); border-radius: 16px;
  background: color-mix(in srgb, var(--surface, #fff) 90%, transparent);
  box-shadow: 0 12px 36px rgba(0,0,0,.08); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
}
.nr-toc-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; color: var(--text, #1d1d1f); font-size: 12px; font-weight: 700; letter-spacing: .08em; }
.nr-toc-title span { color: var(--text-muted, #6e6e73); font-weight: 500; letter-spacing: 0; }
.nr-toc a { display: block; margin: 2px 0; padding: 7px 8px; overflow: hidden; border-radius: 8px; color: var(--text-muted, #6e6e73); font-size: 12px; line-height: 1.35; text-decoration: none; text-overflow: ellipsis; white-space: nowrap; }
.nr-toc a[data-level="5"] { padding-left: 17px; }
.nr-toc a:hover, .nr-toc a.active { color: var(--accent, #0071e3); background: color-mix(in srgb, var(--accent, #0071e3) 9%, transparent); }

.nr-toolbar {
  position: fixed; z-index: 90; right: 20px; bottom: 22px; display: flex; gap: 6px; align-items: center;
  padding: 7px; border: 1px solid var(--ln-hair, rgba(127,127,127,.22)); border-radius: 15px;
  background: color-mix(in srgb, var(--surface, #fff) 90%, transparent); box-shadow: 0 14px 40px rgba(0,0,0,.14);
  -webkit-backdrop-filter: blur(20px) saturate(150%); backdrop-filter: blur(20px) saturate(150%);
}
.nr-toolbar button {
  min-width: 38px; height: 36px; padding: 0 10px; border: 0; border-radius: 10px;
  color: var(--text, #1d1d1f); background: transparent; font: inherit; font-size: 13px; cursor: pointer;
}
.nr-toolbar button:hover { background: var(--bg-soft, rgba(127,127,127,.10)); }
.nr-toolbar .nr-done.done { color: #fff; background: #34c759; }
.nr-toolbar .nr-ai-btn { color: #fff; background: linear-gradient(135deg, var(--accent, #0071e3), #5e5ce6); white-space: nowrap; }
.nr-toolbar .nr-ai-btn:hover { background: linear-gradient(135deg, var(--accent-hover, #0066cc), #4948c8); }
.nr-toolbar .nr-divider { width: 1px; height: 22px; background: var(--ln-hair, rgba(127,127,127,.22)); }
.nr-mobile-toc { display: none; }

.nb-page.nr-focus .nb-topbar, .nb-page.nr-focus .nr-toc { display: none ; }
.nb-page.nr-focus .nb-wrap { max-width: 850px ; }
.nb-page.nr-focus .nr-toolbar { opacity: .55; }
.nb-page.nr-focus .nr-toolbar:hover { opacity: 1; }
.nb-page .nb-body { font-size: var(--nr-font-size, 16px); line-height: var(--nr-line-height, 1.8); }

@media (min-width: 1180px) {
  .nb-page:not(.nr-focus) .nb-wrap { margin-left: max(270px, calc(50vw - 390px)); margin-right: auto; }
}
@media (max-width: 1179px) {
  .nr-toc { display: none; }
  .nr-mobile-toc { display: inline-flex; }
  .nr-toc.mobile-open { display: block; top: auto; right: 14px; bottom: 76px; left: 14px; width: auto; max-height: min(60vh, 520px); }
}
@media (max-width: 600px) {
  .nr-toolbar { right: 10px; bottom: 10px; left: 10px; justify-content: center; border-radius: 14px; }
  .nr-toolbar button { flex: 1; min-width: 0; padding: 0 6px; font-size: 12px; }
  .nr-toolbar .nr-small-label { display: none; }
  .nb-page .nb-wrap { padding-bottom: 82px; }
}

@media print {
  .nr-progress, .nr-toc, .nr-toolbar { display: none ; }
}

}
