:root {
  --bg: #ffffff;
  --bg-glass: rgba(255, 255, 255, 0.86);
  --bg-subtle: #f8fafc;
  --bg-elevated: #ffffff;
  --bg-code: #f3f4f6;
  --text: #0f172a;
  --text-secondary: #334155;
  --muted: #64748b;
  --border: #e2e8f0;
  --border-subtle: #f1f5f9;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: rgba(37, 99, 235, 0.08);
  --accent-ring: rgba(37, 99, 235, 0.22);
  --warn-bg: #fffbeb;
  --warn-border: #d97706;
  --warn-text: #92400e;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 8px 24px -4px rgba(15, 23, 42, 0.08), 0 2px 6px -1px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 20px 40px -8px rgba(15, 23, 42, 0.14), 0 4px 12px -2px rgba(15, 23, 42, 0.06);
  --header-h: 60px;
  --sidebar-w: 272px;
  --toc-w: 236px;
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.32, 0.72, 0, 1);
  --font-sans: -apple-system, BlinkMacSystemFont, "Inter", "SF Pro Text", "Segoe UI", Roboto, "Noto Sans", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

html[data-theme="dark"] {
  --bg: #090a0f;
  --bg-glass: rgba(9, 10, 15, 0.84);
  --bg-subtle: #11131a;
  --bg-elevated: #161922;
  --bg-code: #131620;
  --text: #f8fafc;
  --text-secondary: #cbd5e1;
  --muted: #94a3b8;
  --border: #1e2330;
  --border-subtle: #151923;
  --accent: #3b82f6;
  --accent-hover: #60a5fa;
  --accent-soft: rgba(59, 130, 246, 0.14);
  --accent-ring: rgba(59, 130, 246, 0.28);
  --warn-bg: rgba(217, 119, 6, 0.1);
  --warn-border: #f59e0b;
  --warn-text: #fcd34d;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 10px 28px -4px rgba(0, 0, 0, 0.45), 0 2px 8px -1px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 24px 48px -8px rgba(0, 0, 0, 0.65), 0 6px 16px -2px rgba(0, 0, 0, 0.4);
}

*, *::before, *::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  scroll-padding-top: calc(var(--header-h) + 24px);
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  transition: background-color 0.22s ease, color 0.22s ease;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.15s ease;
}
a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Top SPA Navigation Progress Bar */
.nav-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 2.5px;
  z-index: 200;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.nav-progress.active {
  opacity: 1;
}
.nav-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), #60a5fa, #38bdf8);
  box-shadow: 0 0 10px var(--accent);
  transition: width 0.25s var(--ease-out-expo);
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  background: var(--bg-glass);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid var(--border);
  transition: background-color 0.22s ease, border-color 0.22s ease;
}

.header-inner {
  max-width: 1440px;
  margin: 0 auto;
  height: 100%;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  min-width: 0;
}

.mobile-menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-subtle);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}
.mobile-menu-btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.mobile-menu-btn:active {
  transform: scale(0.94);
}

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  font-weight: 700;
  font-size: 15.5px;
  letter-spacing: -0.015em;
  text-decoration: none !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.brand-link:hover {
  opacity: 0.88;
}
.brand-link:active {
  transform: scale(0.98);
}

.brand-icon {
  width: 28px;
  height: 28px;
  flex: none;
  display: block;
  object-fit: contain;
  filter: drop-shadow(0 1px 2px rgba(68, 129, 252, 0.22));
}

.version-pill {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-ring);
  color: var(--accent);
  flex-shrink: 0;
}

.top-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 0 8px;
  flex-shrink: 0;
}

.top-nav a {
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 7px;
  transition: background 0.15s ease, color 0.15s ease;
}
.top-nav a:hover {
  color: var(--text);
  background: var(--bg-subtle);
  text-decoration: none;
}
.top-nav a.active {
  color: var(--accent);
  background: var(--accent-soft);
  font-weight: 600;
}

.header-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
}

/* Search Trigger & Dropdown */
.search-box {
  position: relative;
  width: 230px;
  max-width: 100%;
  flex: 0 1 230px;
  min-width: 90px;
  transition: width 0.22s var(--ease-out-expo), flex-basis 0.22s var(--ease-out-expo);
}
.search-box:focus-within {
  width: 268px;
  flex-basis: 268px;
}

.search-input {
  width: 100%;
  height: 36px;
  padding: 0 54px 0 32px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-subtle);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}
.search-input:hover {
  border-color: var(--muted);
}
.search-input:focus {
  outline: none;
  background: var(--bg-elevated);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.search-input::placeholder {
  color: var(--muted);
}

.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--muted);
  pointer-events: none;
  transition: color 0.18s ease;
}
.search-box:focus-within .search-icon {
  color: var(--accent);
}

.search-kbd {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 1px 5px;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--muted);
  background: var(--bg);
  pointer-events: none;
}

.search-results {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: min(440px, 92vw);
  max-height: min(420px, 70vh);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 6px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px) scale(0.98);
  transform-origin: top right;
  pointer-events: none;
  transition: opacity 0.18s var(--ease-out-expo), transform 0.18s var(--ease-out-expo), visibility 0.18s;
  z-index: 120;
}
.search-results.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.search-result-item {
  display: block;
  padding: 9px 12px;
  border-radius: 8px;
  text-decoration: none !important;
  color: var(--text);
  transition: background 0.12s ease, transform 0.12s ease;
}
.search-result-item + .search-result-item {
  margin-top: 2px;
}
.search-result-item:hover,
.search-result-item.focused {
  background: var(--accent-soft);
}
.search-result-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 6px;
}
.search-result-snippet {
  font-size: 12px;
  color: var(--muted);
  margin-top: 3px;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.search-empty {
  padding: 20px 14px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

.lang-select {
  height: 36px;
  padding: 0 26px 0 10px;
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background-color: var(--bg-subtle);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  appearance: none;
  -webkit-appearance: none;
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
.lang-select:hover {
  border-color: var(--muted);
}
.lang-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.theme-btn {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-subtle);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s var(--ease-spring), color 0.15s ease;
}
.theme-btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
.theme-btn:active {
  transform: scale(0.9) rotate(12deg);
}
.theme-btn svg {
  width: 16px;
  height: 16px;
  transition: transform 0.28s var(--ease-spring);
}

/* Main 3-Column Layout */
.layout-shell {
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w);
  flex: 1;
}

/* Left Sidebar */
.sidebar {
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  overscroll-behavior: contain;
  border-right: 1px solid var(--border);
  padding: 24px 16px 40px 20px;
  background: var(--bg);
  transition: background-color 0.22s ease, border-color 0.22s ease;
}

.sidebar-mobile-head {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 4px 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-mobile-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 14.5px;
  color: var(--text);
}
.sidebar-close-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.sidebar-close-btn:hover {
  color: var(--text);
  background: var(--accent-soft);
}

.sidebar-group + .sidebar-group {
  margin-top: 22px;
}

.sidebar-group-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 8px 10px;
}

.sidebar-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.sidebar-list li + li {
  margin-top: 2px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none !important;
  position: relative;
  transition: background 0.15s ease, color 0.15s ease, transform 0.12s ease;
}
.sidebar-link:hover {
  background: var(--bg-subtle);
  color: var(--text);
}
.sidebar-link:active {
  transform: scale(0.99);
}
.sidebar-link.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.sidebar-link.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}

/* Main Content Column */
.main-column {
  min-width: 0;
  padding: 32px 48px 72px;
}

.doc-container {
  max-width: 760px;
  margin: 0 auto;
  animation: docPageEnter 0.26s var(--ease-out-expo) both;
}

@keyframes docPageEnter {
  from {
    opacity: 0;
    transform: translateY(7px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.breadcrumbs a {
  color: var(--muted);
  font-weight: 500;
  transition: color 0.15s ease;
}
.breadcrumbs a:hover {
  color: var(--accent);
  text-decoration: none;
}

/* Mobile Collapsible TOC ("On this page") */
.mobile-toc {
  display: none;
  margin: 0 0 22px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-subtle);
  overflow: hidden;
}
.mobile-toc summary {
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
}
.mobile-toc summary::-webkit-details-marker {
  display: none;
}
.mobile-toc summary::after {
  content: "";
  width: 7px;
  height: 7px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform 0.2s var(--ease-out-expo);
  margin-right: 4px;
}
.mobile-toc[open] summary::after {
  transform: rotate(-135deg);
}
.mobile-toc-list {
  list-style: none;
  margin: 0;
  padding: 4px 14px 12px;
  border-top: 1px solid var(--border);
}
.mobile-toc-list li + li {
  margin-top: 4px;
}
.mobile-toc-list a {
  display: block;
  padding: 4px 0;
  font-size: 13px;
  color: var(--text-secondary);
  text-decoration: none !important;
}
.mobile-toc-list li.level-3 a {
  padding-left: 14px;
  font-size: 12.5px;
  color: var(--muted);
}
.mobile-toc-list a:hover {
  color: var(--accent);
}

/* Markdown Typography */
.doc-prose h1 {
  font-size: clamp(23px, 4vw, 30px);
  line-height: 1.24;
  letter-spacing: -0.025em;
  margin: 0 0 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.doc-prose h2 {
  font-size: clamp(18px, 2.8vw, 21px);
  line-height: 1.35;
  letter-spacing: -0.015em;
  margin: 38px 0 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
  color: var(--text);
}

.doc-prose h3 {
  font-size: 16px;
  line-height: 1.42;
  margin: 26px 0 8px;
  color: var(--text);
}

.header-anchor {
  margin-left: 6px;
  opacity: 0;
  color: var(--muted);
  font-weight: 400;
  text-decoration: none !important;
  transition: opacity 0.15s ease, color 0.15s ease;
}
.doc-prose h2:hover .header-anchor,
.doc-prose h3:hover .header-anchor,
.header-anchor:focus-visible {
  opacity: 1;
  color: var(--accent);
}

.doc-prose p, .doc-prose ul, .doc-prose ol {
  margin: 0 0 16px;
  color: var(--text-secondary);
  font-size: 15px;
  overflow-wrap: break-word;
}

.doc-prose ul, .doc-prose ol {
  padding-left: 22px;
}
.doc-prose li + li {
  margin-top: 6px;
}
.doc-prose li > ul, .doc-prose li > ol {
  margin-top: 6px;
  margin-bottom: 6px;
}

.doc-prose strong {
  color: var(--text);
  font-weight: 600;
}

.doc-prose code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--bg-code);
  border: 1px solid var(--border-subtle);
  padding: 1.5px 5.5px;
  border-radius: 5px;
  color: var(--text);
  word-break: break-word;
}

.code-block {
  margin: 16px 0 22px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-code);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-subtle);
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--muted);
}

.copy-code-btn {
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 11.5px;
  font-weight: 500;
  padding: 3px 9px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.copy-code-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}
.copy-code-btn.copied {
  color: #10b981;
  border-color: rgba(16, 185, 129, 0.4);
  background: rgba(16, 185, 129, 0.1);
}

.code-block pre {
  margin: 0;
  padding: 14px 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.55;
}
.code-block pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
  word-break: normal;
}

/* Tables — Responsive Horizontal Scroll Without Crushing Columns */
.table-wrap {
  margin: 18px 0 24px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  box-shadow: var(--shadow-sm);
}

.doc-prose table {
  width: 100%;
  min-width: 540px;
  border-collapse: collapse;
  font-size: 13.5px;
  text-align: left;
}

.doc-prose th {
  background: var(--bg-subtle);
  color: var(--text);
  font-weight: 600;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  line-height: 1.4;
}

.doc-prose td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  vertical-align: top;
  line-height: 1.55;
}
.doc-prose th:first-child,
.doc-prose td:first-child {
  min-width: 135px;
}
.doc-prose tr:last-child td {
  border-bottom: none;
}
.doc-prose tbody tr {
  transition: background-color 0.12s ease;
}
.doc-prose tbody tr:hover {
  background-color: var(--bg-subtle);
}

/* Callouts */
.callout {
  margin: 18px 0;
  padding: 13px 16px;
  border-left: 3.5px solid var(--accent);
  background: var(--bg-subtle);
  border-radius: 0 8px 8px 0;
}
.callout p {
  margin: 0;
  font-size: 14px;
}
.callout-warning, .callout-important {
  border-left-color: var(--warn-border);
  background: var(--warn-bg);
}
.callout-warning p, .callout-important p {
  color: var(--text);
}

/* Prev / Next Footer Navigation */
.page-nav {
  margin-top: 52px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.page-nav-card {
  display: flex;
  flex-direction: column;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  text-decoration: none !important;
  transition: border-color 0.18s ease, background-color 0.18s ease, transform 0.18s var(--ease-out-expo), box-shadow 0.18s ease;
}
.page-nav-card:hover {
  border-color: var(--accent);
  background: var(--bg-subtle);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.page-nav-card:active {
  transform: translateY(0);
}
.page-nav-card.next {
  text-align: right;
  grid-column: 2;
}
.page-nav-label {
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 500;
  transition: transform 0.18s var(--ease-out-expo);
}
.page-nav-card.prev:hover .page-nav-label {
  transform: translateX(-3px);
}
.page-nav-card.next:hover .page-nav-label {
  transform: translateX(3px);
}
.page-nav-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  margin-top: 3px;
}

/* Right Table of Contents */
.toc-aside {
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  padding: 28px 20px 40px 12px;
  border-left: 1px solid var(--border-subtle);
}

.toc-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text);
  margin: 0 0 10px;
}

.toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 1px solid var(--border);
}

.toc-item a {
  display: block;
  padding: 5px 0 5px 12px;
  font-size: 12.5px;
  color: var(--muted);
  text-decoration: none !important;
  border-left: 2px solid transparent;
  margin-left: -1px;
  line-height: 1.4;
  transition: color 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}
.toc-item.level-3 a {
  padding-left: 22px;
  font-size: 12px;
}
.toc-item a:hover {
  color: var(--text);
}
.toc-item a.active {
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 600;
}

/* Site Footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 22px 20px;
  font-size: 12.5px;
  color: var(--muted);
  text-align: center;
  background: var(--bg-subtle);
}

/* Floating Back-to-Top */
.back-to-top {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  box-shadow: var(--shadow-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px) scale(0.9);
  transition: opacity 0.22s var(--ease-out-expo), transform 0.22s var(--ease-out-expo), visibility 0.22s, border-color 0.15s ease, color 0.15s ease;
  z-index: 45;
}
.back-to-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}
.back-to-top:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-2px) scale(1.03);
}

/* Mobile Backdrop — Smooth Blur Fade */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(9, 10, 15, 0.48);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 60;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.28s var(--ease-out-expo), visibility 0.28s;
}
.drawer-backdrop.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* Responsive Breakpoints */
@media (max-width: 1180px) {
  .layout-shell {
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  }
  .toc-aside {
    display: none;
  }
  .top-nav {
    display: none;
  }
  .mobile-toc {
    display: block;
  }
}

@media (max-width: 768px) {
  :root {
    --header-h: 56px;
  }
  .header-inner {
    padding: 0 12px;
    gap: 8px;
  }
  .layout-shell {
    grid-template-columns: minmax(0, 1fr);
  }
  .mobile-menu-btn {
    display: inline-flex;
  }
  .version-pill {
    display: none;
  }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    height: 100vh;
    height: 100dvh;
    width: min(290px, 84vw);
    z-index: 70;
    padding: 16px 16px 36px;
    transform: translateX(-104%);
    transition: transform 0.32s var(--ease-spring);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-mobile-head {
    display: flex;
  }
  .main-column {
    padding: 20px 16px 56px;
  }
  .header-controls {
    gap: 6px;
  }
  .search-box {
    flex: 1 1 120px;
    width: auto;
    min-width: 0;
    max-width: 210px;
  }
  .search-box:focus-within {
    flex: 1 1 160px;
    width: auto;
    max-width: 240px;
  }
  .search-input {
    height: 34px;
    padding: 0 10px 0 30px;
    font-size: 13px;
  }
  .search-kbd {
    display: none;
  }
  .search-results {
    position: fixed;
    top: calc(var(--header-h) + 6px);
    left: 12px;
    right: 12px;
    width: auto;
    max-height: 68vh;
    transform-origin: top center;
  }
  .lang-select {
    height: 34px;
    padding: 0 22px 0 8px;
    font-size: 12px;
  }
  .theme-btn,
  .mobile-menu-btn {
    width: 34px;
    height: 34px;
  }
  .page-nav {
    grid-template-columns: 1fr;
    gap: 10px;
    margin-top: 36px;
  }
  .page-nav-card.next {
    grid-column: 1;
    text-align: left;
  }
}

/* Prevent Brand Title & Search Box Collision on Compact Mobile Viewports */
@media (max-width: 580px) {
  .brand-link span {
    display: none;
  }
  .brand-wrap {
    gap: 6px;
  }
  .search-box,
  .search-box:focus-within {
    max-width: none;
  }
}

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