:root {
  --bg: #f7f5f0;
  --bg-sidebar: #efede8;
  --bg-card: #ffffff;
  --bg-hover: #e8e4dd;
  --bg-active: #dfd9cf;
  --border: #d8d2c8;
  --border-light: #e8e4dd;
  --text: #1c1917;
  --text-2: #57534e;
  --text-3: #a8a29e;
  --accent: #b45309;
  --accent-2: #92400e;
  --accent-bg: #fef3c7;
  --accent-border: #78350f;
  --link: #1d4ed8;
  --link-hover: #1e40af;
  --code-bg: #f0ece4;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, .10);
  --nav-h: 52px;
  --sidebar-w:30%;
  --fs-user: 16px;

  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --font-serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "SimSun",
    Georgia, "Times New Roman", serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
    "Noto Sans SC", sans-serif;
  --font-mono: "SF Mono", SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Noto Sans Mono CJK SC", "PingFang SC",
    "Microsoft YaHei Mono", "Courier New", monospace;
}

[data-theme="dark"] {
  --bg: #141210;
  --bg-sidebar: #1c1917;
  --bg-card: #1c1917;
  --bg-hover: #282420;
  --bg-active: #312e29;
  --border: #2c2824;
  --border-light: #242018;
  --text: #e7e5e0;
  --text-2: #a8a29e;
  --text-3: #57534e;
  --accent: #f59e0b;
  --accent-2: #fbbf24;
  --accent-bg: #1c1505;
  --accent-border: #78350f;
  --link: #60a5fa;
  --link-hover: #93c5fd;
  --code-bg: #242018;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, .4);
}

/* ═══════════════════════════════════════════════════════════════
   BASE
   ═══════════════════════════════════════════════════════════════ */
html {
  box-sizing: border-box;
  font-size: 16px;
  scroll-padding-top: calc(var(--nav-h) + 24px);
}

*, *::before, *::after { box-sizing: border-box; }

body {
  background: var(--bg) !important;
  color: var(--text) !important;
  margin: 0;
  padding: 0;
  font-family: var(--font-ui);
}

/* ═══════════════════════════════════════════════════════════════
   SCROLL INDICATOR
   ═══════════════════════════════════════════════════════════════ */
.scroll-indicator {
  position: fixed;
  top: 0; left: 0;
  height: 2px;
  width: 0%;
  background: var(--accent);
  z-index: 1000;
  transition: width 80ms linear;
  pointer-events: none;
}

/* ═══════════════════════════════════════════════════════════════
   NAVBAR (top header bar)
   ═══════════════════════════════════════════════════════════════ */
.navbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: var(--bg);
  border-bottom: 1px solid var(--accent-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 300;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  font-family: var(--font-ui) !important;
}

.navbar * {
  font-family: var(--font-ui) !important;
}

[data-theme="dark"] .navbar {
  background: var(--bg-sidebar);
  border-bottom-color: var(--accent-border);
}

.navbar__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

/* Navbar logo — explicit color on all pseudo-states to prevent
   visited / active / hover from turning blue */
.navbar__logo,
.navbar__logo:link,
.navbar__logo:visited,
.navbar__logo:hover,
.navbar__logo:active {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text) !important;
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.3px;
}

/* Force span inside logo to inherit parent color explicitly */
.navbar__logo span {
  color: inherit !important;
}

.navbar__logo img {
  width: 28px; height: 28px;
  border-radius: 4px;
}

.navbar__items {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.navbar__item {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ═══════════════════════════════════════════════════════════════
   CLEAN BUTTON (icon button used in navbar)
   ═══════════════════════════════════════════════════════════════ */
.clean-btn {
  width: 32px; height: 32px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 150ms;
  flex-shrink: 0;
  padding: 0;
  font-family: var(--font-ui);
}

.clean-btn:hover {
  background: var(--bg-hover);
  color: var(--text-2);
}

.clean-btn--active {
  color: var(--accent);
  background: var(--accent-bg);
  border-color: var(--accent-border);
}

/* font control group inside navbar */
.font-control {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--bg);
  border: 1px solid var(--accent-border);
  border-radius: 6px;
  padding: 2px;
  height: 32px;
}

.font-btn {
  width: 28px; height: 28px;
  border: none;
  background: transparent;
  color: var(--accent-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 150ms;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-sans);
  padding: 0;
}

.font-btn:hover {
  background: var(--accent-bg);
  color: var(--accent);
}

/* Range input — amber-themed, filled track left of thumb */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(
    to right,
    var(--accent) var(--_fill, 0%),
    var(--bg-active) var(--_fill, 0%)
  );
  outline: none;
  cursor: pointer;
  flex: 1;
  min-width: 60px;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--accent-2);
  cursor: pointer;
  transition: background 150ms;
}

input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--accent-2);
  cursor: pointer;
}

input[type="range"]:hover::-webkit-slider-thumb,
input[type="range"]:focus::-webkit-slider-thumb {
  background: var(--accent-2);
}

/* mobile hamburger visibility */
.navbar__toggle {
  display: none;
}

/* ═══════════════════════════════════════════════════════════════
   DROPDOWN (mobile settings)
   ═══════════════════════════════════════════════════════════════ */
.dropdown {
  display: none;
  position: absolute;
  top: calc(var(--nav-h) + 6px);
  right: 12px;
  min-width: 220px;
  background: var(--bg-card);
  border: 1px solid var(--accent-border);
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  padding: 8px;
  z-index: 400;
  font-family: var(--font-ui);
}

.dropdown--open { display: block; }

.dropdown__label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-3);
  padding: 8px 12px 4px;
}

.dropdown__row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
}

.stepper {
  width: 28px; height: 28px;
  border: 1px solid var(--accent-border);
  border-radius: 6px;
  background: var(--accent-bg);
  color: var(--accent);
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0;
  transition: all 150ms;
}

.stepper:hover {
  background: var(--accent);
  color: var(--bg);
}

.dropdown__rule {
  height: 1px;
  background: var(--border-light);
  margin: 6px 8px;
}

.dropdown__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
  transition: background 150ms;
  user-select: none;
}

.dropdown__item:hover {
  background: var(--bg-hover);
}

/* ═══════════════════════════════════════════════════════════════
   DOC WRAPPER (shell)
   ═══════════════════════════════════════════════════════════════ */
.doc-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ═══════════════════════════════════════════════════════════════
   SIDEBAR — Overlay style (all viewports)
   Default hidden, slides over body when opened.
   ═══════════════════════════════════════════════════════════════ */
.doc-sidebar {
  position: fixed;
  top: var(--nav-h); left: 0; bottom: 0;
  width: var(--sidebar-w);
  transform: translateX(-100%);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 200;
  transition: transform 300ms cubic-bezier(0.4, 0, 0.2, 1);
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  box-shadow: none;
  margin-top: 0 !important;
  padding-top: 0 !important;
}

.doc-sidebar::-webkit-scrollbar { width: 5px; }
.doc-sidebar::-webkit-scrollbar-track { background: transparent; }
.doc-sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.doc-sidebar--open {
  transform: translateX(0);
  box-shadow: var(--shadow-md);
}

/* sidebar nav tree container */
.sidebar-nav {
  padding: 8px 0 40px;
  font-family: var(--font-ui) !important;
}

.sidebar-nav * {
  font-family: var(--font-ui) !important;
}

/* ═══════════════════════════════════════════════════════════════
   SIDEBAR MENU — Docusaurus-style entry list
   nav > ul > li  structure; caret sits on the RIGHT side.
   ═══════════════════════════════════════════════════════════════ */
.sidebar-menu,
.sidebar-menu ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sidebar-menu {
  font-size: 14px;
  line-height: 1.25;
}

/* Each menu item row — flex layout with caret on the right */
.sidebar-item {
  position: relative;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  margin: 2px 8px;
}

.sidebar-item--collapsible {
  flex-direction: column;
  align-items: stretch;
}

/* The link — takes remaining space, leaving room for caret */
.sidebar-link {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  flex: 1 1 auto;
  min-width: 0;
  padding: 6px 10px;
  border-radius: 4px;
  color: var(--text-2);
  text-decoration: none !important;
  font-size: 14px;
  line-height: 1.45;
  transition: background 120ms, color 120ms;
  cursor: pointer;
  order: 0;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: break-word;
}

.sidebar-link:hover {
  background: var(--accent-bg);
  color: var(--accent);
}

/* Active item — left accent bar + subtle bg */
.sidebar-link--active {
  color: var(--accent);
  background: var(--accent-bg);
  font-weight: 500;
}

/* Light-theme reading indicator — uses dark text on a deeper
   accent background so the active heading is clearly visible,
   mirroring the strong contrast seen in dark mode. */
:root:not([data-theme="dark"]) .sidebar-link--active {
  color: var(--text);
  background: var(--accent-bg);
  font-weight: 600;
}

.sidebar-link--active::before {
  content: "";
  position: absolute;
  left: 0; top: 4px; bottom: 4px;
  width: 3px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}
.sidebar-item-row {
  display: flex;
  align-items: flex-start;
  width: 100%;
  padding: 0;
}

/* 行内的链接/标签自然撑开 */
.sidebar-item-row .sidebar-link,
.sidebar-item-row .sidebar-category-label {
  flex: 1 1 auto;
  min-width: 0;
}

/* 按钮保持固定宽度，紧贴右侧 */
.sidebar-item-row .sidebar-caret {
  flex-shrink: 0;
  margin-left: 2px;
  margin-top: 4px;
}

/* The caret toggle button — sits on the RIGHT */
.sidebar-caret {
  display: inline-flex;
  width: 22px; height: 22px;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: var(--text-3);
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 200ms;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 4px;
  font-family: var(--font-ui);
  margin-left: 2px;
}

.sidebar-caret:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.sidebar-item[data-collapsed="false"] > .sidebar-caret {
  transform: rotate(90deg);
}

/* Category label (non-link collapsible header) */
.sidebar-category-label {
  display: flex;
  align-items: flex-start;
  gap: 4px;
  padding: 6px 10px;
  flex: 1 1 auto;
  min-width: 0;
  cursor: pointer;
  user-select: none;
  border-radius: 4px;
  transition: background 120ms;
  color: var(--text);
  font-weight: 500;
  text-decoration: none;
  font-size: 14px;
  line-height: 1.45;
  order: 0;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: break-word;
}

.sidebar-category-label:hover {
  background: var(--bg-hover);
}

.sidebar-menu--nested {
  /* 原有的 .sidebar-menu ul 样式保留，去掉 order:2 和 flex-basis */
  order: unset;
  max-height: 0;
  overflow: hidden;
  transition: max-height 250ms ease;
  padding-left: 14px;
  border-left: 2px solid var(--accent-border);
  margin-left: 11px;
  width: auto;
  /* 不需要 100% */
}
.sidebar-menu ul {
  overflow: hidden;
  transition: max-height 250ms ease;
  width: 100%;
  padding-left: 14px;
  border-left: 2px solid var(--accent-border);
  margin-left: 11px;
}

.sidebar-item[data-collapsed="true"] > ul {
  max-height: 0;
}

.sidebar-item[data-collapsed="false"] > ul {
  max-height: 3000px;
}

/* Level-1 items (top-level) */
.sidebar-menu > .sidebar-item > .sidebar-link,
.sidebar-menu > .sidebar-item > .sidebar-category-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

/* Level-2+ items */
.sidebar-menu .sidebar-menu .sidebar-link,
.sidebar-menu .sidebar-menu .sidebar-category-label {
  font-size: 13.5px;
  font-weight: 400;
}

/* Badge inside sidebar item */
.sidebar-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  background: var(--accent-bg);
  color: var(--accent);
  border: 1px solid var(--accent-border);
  border-radius: 4px;
  margin-left: auto;
  flex-shrink: 0;
  font-family: var(--font-mono);
  letter-spacing: 0.3px;
  line-height: 1;
}

/* ═══════════════════════════════════════════════════════════════
   SIDEBAR OVERLAY
   ═══════════════════════════════════════════════════════════════ */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.25);
  z-index: 150;
  backdrop-filter: blur(2px);
}

.sidebar-overlay--visible { display: block; }

/* ═══════════════════════════════════════════════════════════════
   BREADCRUMB (inside sidebar top for epub mode)
   ═══════════════════════════════════════════════════════════════ */
.breadcrumb {
  display: block;
  padding: 10px 16px 14px;
  font-size: 12px;
  font-family: var(--font-ui);
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 4px;
  position: sticky;
  top: 0;
  background: var(--bg-sidebar);
  z-index: 10;
  line-height: 1.5;
}

.breadcrumb--faded { display: none; }

/* Breadcrumb children flow like normal text — they sit on the same
   line and wrap only at word boundaries, never breaking inside
   a word or isolating the separator on its own line. */
.breadcrumb > a,
.breadcrumb > span {
  display: inline;
  vertical-align: baseline;
  white-space: normal;
}

.breadcrumb a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  transition: color 150ms;
}

.breadcrumb a:hover {
  color: var(--accent-2);
  text-decoration: underline;
}

.breadcrumb__sep {
  color: var(--text-3);
  opacity: 0.5;
  font-size: 11px;
  margin: 0 2px;
}

/* ═══════════════════════════════════════════════════════════════
   SECTION DIVIDER (used between TOC and Other Works)
   ═══════════════════════════════════════════════════════════════ */
.section-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 16px 8px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent-2);
  font-family: var(--font-ui);
}

.section-divider::before,
.section-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--accent-border);
}

/* ═══════════════════════════════════════════════════════════════
   DOC MAIN (content area)
   ═══════════════════════════════════════════════════════════════ */
.doc-main {
  flex: 1;
  margin-left: 0;
  min-width: 0;
  padding-top: var(--nav-h);
  position: relative;
}

/* ═══════════════════════════════════════════════════════════════
   DOC CONTENT
   ═══════════════════════════════════════════════════════════════ */
.doc-content {
  max-width: 880px;
  margin: 0 auto;
  padding: 0 32px 80px;
}

/* ═══════════════════════════════════════════════════════════════
   PROSE (article body)
   ═══════════════════════════════════════════════════════════════ */
.prose {
  font-size: var(--fs-user);
  line-height: 1.8;
  color: var(--text);
  font-family: var(--font-serif);
}

.prose :is(h1, h2, h3, h4, h5, h6) {
  font-family: var(--font-serif);
  font-weight: 600;
  line-height: 1.3;
  margin-top: 2em;
  margin-bottom: 0.75em;
  color: var(--text);
  scroll-margin-top: calc(var(--nav-h) + 24px);
}

.prose h1 { font-size: 1.75em; border-bottom: 1px solid var(--border); padding-bottom: 0.3em; }
.prose h2 { font-size: 1.45em; }
.prose h3 { font-size: 1.2em; }
.prose h4 { font-size: 1.05em; }

.prose a {
  color: var(--link);
  text-decoration: none !important;
  border-bottom: 1px solid transparent;
  transition: all 150ms;
}

.prose a:hover {
  color: var(--link-hover);
  border-bottom-color: var(--link-hover);
  text-decoration: none !important;
}

.prose p { margin: 0.75em 0; }

.prose :is(ul, ol) {
  margin: 0.75em 0;
  padding-left: 1.8em;
}

.prose li { margin: 0.25em 0; }

.prose blockquote {
  margin: 1.2em 0;
  padding: 0.5em 1em;
  border-left: 3px solid var(--accent);
  background: var(--bg-card);
  color: var(--text-2);
}

.prose code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--code-bg);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--accent-2);
}

.prose pre {
  background: var(--code-bg);
  padding: 16px;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 0.85em;
  line-height: 1.6;
  border: 1px solid var(--border);
}

.prose pre code { background: none; padding: 0; color: inherit; }

.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 1em 0;
  font-size: 0.92em;
}

.prose th, .prose td {
  padding: 8px 12px;
  border: 1px solid var(--border);
  text-align: left;
}

.prose th {
  background: var(--bg-hover);
  font-weight: 600;
  font-family: var(--font-ui);
  font-size: 0.9em;
}

.prose tr:nth-child(even) { background: var(--bg-card); }

.prose img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 1em auto;
}

.prose hr {
  border: none;
  height: 1px;
  background: var(--border);
  margin: 2em 0;
}

.prose sup {
  font-size: 0.75em;
  vertical-align: super;
  line-height: 0;
}

.prose sup a { color: var(--accent); font-weight: 500; }

/* Heading anchor */
.prose :is(h1, h2, h3, h4, h5, h6) .anchor {
  opacity: 0;
  margin-left: 8px;
  text-decoration: none;
  color: var(--text-3);
  font-weight: 400;
  font-size: 0.85em;
  transition: opacity 150ms;
  border: none;
}

.prose :is(h1, h2, h3, h4, h5, h6):hover .anchor { opacity: 1; }
.prose .anchor:hover { color: var(--accent); }

/* ═══════════════════════════════════════════════════════════════
   TABLE WRAPPER
   ═══════════════════════════════════════════════════════════════ */
.table-wrapper {
  overflow-x: auto;
  max-width: 100%;
  display: block;
  margin: 1em 0;
}

/* ═══════════════════════════════════════════════════════════════
   DOC HEADER (pathbar inside content)
   ═══════════════════════════════════════════════════════════════ */
.doc-header {
  max-width: 880px;
  margin: 0 auto 32px;
  padding: 48px 32px 0;
}

.doc-header__pathbar {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 4px;
  font-size: 13px;
  font-family: var(--font-ui) !important;
  overflow: hidden;
}

/* Prevent child items from wrapping or shrinking, so the breadcrumb
   stays on one line as a whole; if too long it clips rather than
   breaking across columns. */
.doc-header__pathbar > * {
  white-space: nowrap;
  flex-shrink: 0;
}

.doc-header__pathbar .crumb {
  text-decoration: underline;
  text-decoration-color: var(--border);
  text-underline-offset: 3px;
  color: var(--text-3);
  transition: color 150ms, text-decoration-color 150ms;
  line-height: 1.5;
}

.doc-header__pathbar .crumb:hover {
  color: var(--accent);
  text-decoration-color: var(--accent-border);
}

.doc-header__pathbar .crumb--active {
  color: var(--text);
  cursor: default;
  pointer-events: none;
  font-weight: 500;
}

.doc-header__pathbar .crumb-sep {
  margin: 0 4px;
  color: var(--text-3);
  opacity: 0.5;
  font-size: 11px;
}

/* ═══════════════════════════════════════════════════════════════
   DOC FOOTER (pagination)
   ═══════════════════════════════════════════════════════════════ */
.doc-footer {
  margin-top: 60px;
  padding-bottom: 60px;
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  gap: 16px;
  font-family: var(--font-ui) !important;
}

.doc-footer * {
  font-family: var(--font-ui) !important;
}

.pagination-link {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 4px;
  padding: 14px 18px;
  border: 1px solid var(--accent-border);
  border-radius: 8px;
  color: var(--text-2);
  text-decoration: none !important;
  font-size: 14px;
  transition: all 200ms;
  width: calc(50% - 8px);
  background: var(--bg-card);
  min-height: 64px;
}

.pagination-link:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-bg);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.pagination-link__dir {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--accent);
  opacity: 0.85;
  line-height: 1;
}

.pagination-link:hover .pagination-link__dir {
  opacity: 1;
}

.pagination-link__label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  max-width: 100%;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: break-word;
  line-height: 1.45;
}

.pagination-link:hover .pagination-link__label {
  color: var(--accent-2);
}

.pagination-link--next {
  margin-left: auto;
  align-items: flex-end;
  text-align: right;
}

.pagination-link--placeholder {
  width: calc(50% - 8px);
  visibility: hidden;
  pointer-events: none;
}

/* ═══════════════════════════════════════════════════════════════
   POPOVER (footnote tooltip)
   ═══════════════════════════════════════════════════════════════ */
.popover {
  display: none;
  position: absolute;
  z-index: 500;
  width: 340px;
  max-height: 320px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  padding: 14px 18px;
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--text);
  font-family: var(--font-serif);
  overflow-y: auto;
  pointer-events: auto;
}

.popover--visible { display: block; }

.popover__body { margin-bottom: 10px; }
.popover__body :last-child { margin-bottom: 0; }

.popover__jump {
  display: inline-block;
  margin-top: 8px;
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
  font-family: var(--font-ui);
  font-weight: 500;
  transition: color 150ms;
}

.popover__jump:hover {
  color: var(--accent-2);
  text-decoration: underline;
}

.popover__jump--cross::before { content: "\2197 "; }
.popover__jump:not(.popover__jump--cross)::before { content: "\2193 "; }

/* ═══════════════════════════════════════════════════════════════
   VOLUME INDEX PAGE — Docusaurus-style entry list
   Font size follows var(--fs-user).
   ═══════════════════════════════════════════════════════════════ */
.vol-index-title {
  font-family: var(--font-serif);
  font-size: calc(var(--fs-user) * 1.6);
  font-weight: 600;
  margin-bottom: 0.5em;
  padding-bottom: 0.4em;
  border-bottom: 2px solid var(--accent);
  color: var(--text);
  text-align: center;
}

/* Center headings extracted from original volume index page */
.vol-index-headings :is(h1, h2, h3, h4, h5, h6) {
  margin:0.5em auto;
  text-align: center;
}

/* TOC inside volume index page */
.doc-toc {
  font-family: var(--font-ui);
  font-size: calc(var(--fs-user) * 0.875);
  line-height: 1.5;
}

.doc-toc ul,
.doc-toc ol {
  list-style: none;
  padding: 0;
  margin: 0;
}

/* TOC item — two layout modes:
   1. Flat (legacy): li > a + button   (flex row, may wrap button)
   2. Wrapped (preferred): li > div > a + button  (never wraps button)
   ------------------------------------------------------------------ */
.doc-toc .toc-item {
  position: relative;
  margin: 2px 0;
}

/* Legacy flat layout — keep for backwards compatibility */
.doc-toc .toc-item:not(:has(> .toc-item-row)) {
  display: flex;
  flex-wrap: nowrap;
  align-items: flex-start;
}

/* Wrapped layout: li > div.toc-item-row > a + button */
.doc-toc .toc-item-row {
  display: flex;
  align-items: flex-start;
  width: 100%;
  padding: 0;
}

.doc-toc .toc-item--collapsible:has(> .toc-item-row) {
  flex-direction: column;
  align-items: stretch;
}

.doc-toc .toc-item--collapsible:not(:has(> .toc-item-row)) {
  flex-direction: row;
  align-items: flex-start;
  flex-wrap: wrap;
}

/* TOC link — shared styles */
.doc-toc .toc-link {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  flex: 1 1 auto;
  min-width: 0;
  padding: 6px 12px;
  border-radius: 4px;
  color: var(--text-2);
  text-decoration: none !important;
  border-bottom: 1px solid var(--accent-border);
  font-size: 1em;
  line-height: 1.45;
  transition: background 120ms, color 120ms;
  position: relative;
  order: 0;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: break-word;
}

/* Inside wrapped row — link naturally stretches */
.doc-toc .toc-item-row .toc-link {
  flex: 1 1 auto;
  min-width: 0;
}

/* Top-level items have no separator between them — only nested ones */
.doc-toc > ul > .toc-item > .toc-link,
.doc-toc > ol > .toc-item > .toc-link {
  border-bottom-color: transparent;
}

.doc-toc .toc-link:hover {
  background: var(--accent-bg);
  color: var(--accent);
  text-decoration: none !important;
  border-bottom-color: var(--accent);
}

.doc-toc .toc-link--active {
  color: var(--accent);
  background: var(--accent-bg);
  font-weight: 500;
}

.doc-toc .toc-link--active::before {
  content: "";
  position: absolute;
  left: 0; top: 4px; bottom: 4px;
  width: 3px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}

/* TOC caret — shared styles */
.doc-toc .toc-caret {
  display: inline-flex;
  width: 22px; height: 22px;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: var(--text-3);
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 200ms;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 4px;
  font-family: var(--font-ui);
  order: 1;
  margin-left: 2px;
  margin-top: 4px;
}

/* Inside wrapped row — fixed width, hugging the right edge */
.doc-toc .toc-item-row .toc-caret {
  flex-shrink: 0;
  margin-left: 2px;
  margin-top: 4px;
}

.doc-toc .toc-caret:hover {
  background: var(--bg-hover);
  color: var(--text);
}

/* Flat layout: caret is direct child of li */
.doc-toc .toc-item[data-collapsed="false"] > .toc-caret {
  transform: rotate(90deg);
}

/* Wrapped layout: caret is inside .toc-item-row */
.doc-toc .toc-item[data-collapsed="false"] > .toc-item-row > .toc-caret {
  transform: rotate(90deg);
}

/* Nested TOC list — shared */
.doc-toc ul ul,
.doc-toc ol ol,
.doc-toc li > ul,
.doc-toc li > ol {
  overflow: hidden;
  transition: max-height 250ms ease;
  width: 100%;
  padding-left: 16px;
  border-left: 2px solid var(--accent-border);
  margin-left: 11px;
}

/* Flat layout: nested list needs flex-basis & order to drop below */
.doc-toc .toc-item:not(:has(> .toc-item-row)) > ul,
.doc-toc .toc-item:not(:has(> .toc-item-row)) > ol {
  order: 2;
  flex-basis: 100%;
}

/* Collapse states — flat layout (direct children of li) */
.doc-toc .toc-item[data-collapsed="true"] > ul,
.doc-toc .toc-item[data-collapsed="true"] > ol {
  max-height: 0;
}

.doc-toc .toc-item[data-collapsed="false"] > ul,
.doc-toc .toc-item[data-collapsed="false"] > ol {
  max-height: 3000px;
}

/* Collapse states — wrapped layout (siblings of .toc-item-row) */
.doc-toc .toc-item[data-collapsed="true"] > .toc-item-row ~ ul,
.doc-toc .toc-item[data-collapsed="true"] > .toc-item-row ~ ol {
  max-height: 0;
}

.doc-toc .toc-item[data-collapsed="false"] > .toc-item-row ~ ul,
.doc-toc .toc-item[data-collapsed="false"] > .toc-item-row ~ ol {
  max-height: 3000px;
}

/* Level-1 TOC links */
.doc-toc > ul > .toc-item > .toc-link,
.doc-toc > ol > .toc-item > .toc-link {
  font-weight: 500;
  color: var(--text);
}

/* Level-2+ TOC links */
.doc-toc ul ul .toc-link,
.doc-toc ol ol .toc-link {
  font-weight: 400;
}

/* Numbered TOC (ol) */
.doc-toc ol {
  counter-reset: toc-item;
}

.doc-toc ol > .toc-item {
  counter-increment: toc-item;
}

.doc-toc ol > .toc-item > .toc-link::before {
  content: counter(toc-item) ".";
  color: var(--text-3);
  font-size: 0.85em;
  font-variant-numeric: tabular-nums;
  min-width: 1.5em;
  flex-shrink: 0;
}

.doc-toc ol > .toc-item > .toc-link--active::before {
  color: var(--accent);
}

/* Continuous mode (left border accent for flat lists) */
.doc-toc--continuous {
  border-left: 1px solid var(--border);
  padding-left: 4px;
  margin-left: 4px;
}

.doc-toc--continuous .toc-link {
  border-radius: 0 4px 4px 0;
}

.doc-toc--continuous .toc-link--active::before {
  left: -4px;
}

/* ═══════════════════════════════════════════════════════════════
   CARD / INDEX PAGE (build11.js inline styles)
   ═══════════════════════════════════════════════════════════════ */
.hero {
  max-width: 1200px;
  margin: 0 auto;
  padding: 60px 20px;
  text-align: center;
}

.hero__title {
  font-size: 2.5rem;
  font-weight: 600;
  margin-bottom: 12px;
  font-family: var(--font-serif);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 24px;
  text-align: left;
  margin-top: 40px;
}

.card {
  display: block;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  text-decoration: none;
  color: inherit;
  transition: all 200ms;
}

.card:hover {
  border-color: var(--accent);
  background: var(--accent-bg);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.card__tag {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
  background: var(--accent-bg);
  color: var(--accent);
  border: 1px solid var(--accent-border);
  border-radius: 4px;
  font-family: var(--font-mono);
}

.card__heading {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 12px 0 8px;
  color: var(--text);
}

.card__body {
  font-size: 0.95rem;
  color: var(--text-2);
  line-height: 1.6;
  margin: 0;
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE — Mobile only tweaks
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .doc-sidebar {
    width: min(85vw, 300px);
  }

  .doc-content { padding: 0 16px 60px; }

  .doc-header { padding: 24px 16px 0; }

  .doc-footer {
    padding-bottom: 40px;
    flex-direction: column;
    gap: 12px;
  }

  .pagination-link {
    width: 100%;
    max-width: 100%;
  }

  .pagination-link--next { margin-left: 0; align-items: flex-start; text-align: left; }
  .pagination-link--placeholder { display: none; }

  .navbar__item { display: none; }

  .navbar__toggle { display: flex; }

  /* Cards side-by-side on mobile (2 columns) */
  .card-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .card {
    padding: 16px;
  }

  .card__heading {
    font-size: 1.05rem;
    margin: 8px 0 4px;
  }

  .card__body {
    font-size: 0.85rem;
  }

  .popover {
    position: fixed;
    left: 12px !important; right: 12px !important;
    top: auto !important; bottom: 12px;
    width: auto;
    max-height: 45vh;
  }
}

/* ═══════════════════════════════════════════════════════════════
   ACCESSIBILITY
   ═══════════════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .doc-sidebar,
  .sidebar-menu ul,
  .doc-toc ul,
  .doc-toc ol {
    transition: none;
  }
}

.clean-btn:focus-visible,
.font-btn:focus-visible,
.stepper:focus-visible,
.pagination-link:focus-visible,
.sidebar-link:focus-visible,
.sidebar-category-label:focus-visible,
.sidebar-caret:focus-visible,
.toc-link:focus-visible,
.toc-caret:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

::selection {
  background: var(--accent-bg);
  color: var(--accent-2);
}

/* ═══════════════════════════════════════════════════════════════
   UTILITY
   ═══════════════════════════════════════════════════════════════ */
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}