/* ==========================================================================
   LUNAR Documentation Portal - Cyber-Lunar Theme
   Pure Custom CSS (Zero framework runtime overhead)
   ========================================================================== */

:root {
  --bg-main: #070a12;
  --bg-surface: #0b1120;
  --bg-card: #0f172a;
  --bg-card-hover: #17233d;
  --bg-code: #0a0f1d;
  
  --border-subtle: #1e293b;
  --border-glow: rgba(99, 102, 241, 0.25);
  --border-focus: #6366f1;

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --accent-primary: #6366f1;
  --accent-secondary: #8b5cf6;
  --accent-cyan: #06b6d4;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;

  --header-height: 64px;
  --sidebar-width: 290px;
  --toc-width: 250px;
  
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --transition-fast: 150ms ease;
  --transition-smooth: 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  color-scheme: dark;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-primary);
  line-height: 1.65;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Subtle background glowing orb effect */
body::before {
  content: "";
  position: fixed;
  top: -150px;
  left: 30%;
  width: 600px;
  height: 400px;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.08) 0%, rgba(6, 182, 212, 0.04) 50%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
  background: #1e293b;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #334155;
}

/* Reading Progress Bar */
#reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-primary), var(--accent-secondary));
  z-index: 1000;
  transition: width 100ms ease-out;
}

/* ==========================================================================
   Header Navbar
   ========================================================================== */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: rgba(11, 17, 32, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.mobile-menu-btn {
  display: none;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 6px;
}
.mobile-menu-btn:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: inherit;
}

.brand-icon-wrapper {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #4f46e5, #06b6d4);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 0 15px rgba(99, 102, 241, 0.4);
}

.brand-title {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  background: linear-gradient(90deg, #ffffff, #cbd5e1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-emerald);
  border: 1px solid rgba(16, 185, 129, 0.3);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--accent-emerald);
  box-shadow: 0 0 8px var(--accent-emerald);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
  100% { opacity: 1; transform: scale(1); }
}

.header-center {
  flex: 1;
  max-width: 440px;
  margin: 0 1.5rem;
}

.search-trigger-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 0.5rem 0.85rem;
  color: var(--text-muted);
  font-size: 0.875rem;
  cursor: pointer;
  transition: var(--transition-fast);
}

.search-trigger-btn:hover {
  border-color: var(--border-focus);
  color: var(--text-secondary);
  background: var(--bg-card);
}

.search-trigger-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.kbd-shortcut {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  background: #1e293b;
  color: var(--text-secondary);
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  border: 1px solid #334155;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.stats-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.stat-pill {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}
.stat-pill strong {
  color: var(--accent-cyan);
}

.github-link-btn {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.85rem;
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.35);
  color: #c7d2fe;
  border-radius: 8px;
  font-size: 0.825rem;
  font-weight: 600;
  text-decoration: none;
  transition: var(--transition-fast);
}

.github-link-btn:hover {
  background: rgba(99, 102, 241, 0.25);
  border-color: var(--accent-primary);
  color: #ffffff;
  box-shadow: 0 0 15px rgba(99, 102, 241, 0.3);
}

/* ==========================================================================
   Main Grid Layout
   ========================================================================== */
.layout-container {
  display: flex;
  min-height: calc(100vh - var(--header-height));
  margin-top: var(--header-height);
  position: relative;
}

/* ==========================================================================
   Left Navigation Sidebar
   ========================================================================== */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  height: calc(100vh - var(--header-height));
  position: sticky;
  top: var(--header-height);
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  overflow-y: auto;
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  z-index: 50;
  transition: transform var(--transition-smooth);
}

.sidebar-filter-wrapper {
  position: relative;
}

.sidebar-filter-input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 0.45rem 0.75rem 0.45rem 2rem;
  color: var(--text-primary);
  font-size: 0.825rem;
  outline: none;
  transition: var(--transition-fast);
}
.sidebar-filter-input:focus {
  border-color: var(--border-focus);
}
.sidebar-filter-icon {
  position: absolute;
  left: 0.65rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.nav-category {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.nav-category-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 0.25rem 0.75rem;
  margin-bottom: 0.25rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  transition: var(--transition-fast);
  border-left: 2px solid transparent;
}

.nav-item:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

.nav-item.active {
  background: rgba(99, 102, 241, 0.12);
  color: #a5b4fc;
  border-left-color: var(--accent-primary);
  font-weight: 600;
}

.nav-item-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.8;
}
.nav-item.active .nav-item-icon {
  color: var(--accent-cyan);
  opacity: 1;
}

/* ==========================================================================
   Content Area
   ========================================================================== */
.main-content {
  flex: 1;
  min-width: 0;
  padding: 2.5rem 3rem;
  max-width: 920px;
  margin: 0 auto;
}

.content-header-banner {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}
.breadcrumb a {
  color: var(--text-secondary);
  text-decoration: none;
}
.breadcrumb a:hover {
  color: var(--accent-cyan);
}
.breadcrumb-separator {
  opacity: 0.5;
}

.doc-hero-title {
  font-size: 2.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-bottom: 0.75rem;
  background: linear-gradient(135deg, #ffffff 30%, #94a3b8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.doc-hero-desc {
  font-size: 1.05rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 1rem;
}

.doc-metadata-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.doc-meta-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--bg-card);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
}

/* ==========================================================================
   Markdown Typography & Elements
   ========================================================================== */
.markdown-body {
  font-size: 1rem;
  color: #cbd5e1;
  line-height: 1.75;
}

.markdown-body h1 {
  font-size: 1.85rem;
  font-weight: 700;
  margin: 2.5rem 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
}

.markdown-body h2 {
  font-size: 1.45rem;
  font-weight: 700;
  margin: 2rem 0 0.85rem;
  color: #f1f5f9;
  position: relative;
  scroll-margin-top: calc(var(--header-height) + 1.5rem);
}

.markdown-body h3 {
  font-size: 1.15rem;
  font-weight: 600;
  margin: 1.5rem 0 0.65rem;
  color: #e2e8f0;
  scroll-margin-top: calc(var(--header-height) + 1.5rem);
}

.markdown-body h4 {
  font-size: 1rem;
  font-weight: 600;
  margin: 1.25rem 0 0.5rem;
  color: #cbd5e1;
}

.markdown-body p {
  margin-bottom: 1.25rem;
}

.markdown-body ul, .markdown-body ol {
  margin: 0.75rem 0 1.25rem 1.5rem;
}
.markdown-body li {
  margin-bottom: 0.4rem;
}

.markdown-body a {
  color: #818cf8;
  text-decoration: underline;
  text-decoration-color: rgba(129, 140, 248, 0.4);
  text-underline-offset: 3px;
  transition: var(--transition-fast);
}
.markdown-body a:hover {
  color: var(--accent-cyan);
  text-decoration-color: var(--accent-cyan);
}

.markdown-body hr {
  border: none;
  height: 1px;
  background: var(--border-subtle);
  margin: 2.5rem 0;
}

.markdown-body blockquote {
  border-left: 3px solid var(--accent-primary);
  padding: 0.75rem 1.25rem;
  background: rgba(99, 102, 241, 0.05);
  border-radius: 0 8px 8px 0;
  margin: 1.25rem 0;
  color: #cbd5e1;
}

/* Callout Alerts */
.callout {
  margin: 1.5rem 0;
  padding: 1rem 1.25rem;
  border-radius: 8px;
  border-left: 4px solid;
  background: var(--bg-card);
  font-size: 0.95rem;
}
.callout-title {
  font-weight: 700;
  margin-bottom: 0.35rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.callout-note {
  border-color: #3b82f6;
  background: rgba(59, 130, 246, 0.08);
}
.callout-note .callout-title { color: #60a5fa; }
.callout-tip {
  border-color: #10b981;
  background: rgba(16, 185, 129, 0.08);
}
.callout-tip .callout-title { color: #34d399; }
.callout-warning {
  border-color: #f59e0b;
  background: rgba(245, 158, 11, 0.08);
}
.callout-warning .callout-title { color: #fbbf24; }
.callout-important {
  border-color: #8b5cf6;
  background: rgba(139, 92, 246, 0.08);
}
.callout-important .callout-title { color: #a78bfa; }

/* Inline code tags */
.markdown-body :not(pre) > code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: rgba(30, 41, 59, 0.7);
  color: #38bdf8;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  border: 1px solid rgba(56, 189, 248, 0.2);
}

/* Code Blocks Container */
.code-block-wrapper {
  position: relative;
  margin: 1.5rem 0;
  background: var(--bg-code);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
}

.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.45rem 1rem;
  background: rgba(15, 23, 42, 0.9);
  border-bottom: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.code-lang-tag {
  text-transform: uppercase;
  font-weight: 600;
  color: var(--accent-cyan);
}

.copy-code-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  transition: var(--transition-fast);
}
.copy-code-btn:hover {
  background: var(--bg-card);
  color: var(--text-primary);
  border-color: var(--border-subtle);
}
.copy-code-btn.copied {
  color: var(--accent-emerald);
}

.markdown-body pre {
  margin: 0;
  padding: 1rem 1.25rem;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.6;
}

/* ASCII / Architecture Diagrams */
.ascii-container {
  background: #060912;
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 8px;
  margin: 1.5rem 0;
  overflow: hidden;
  box-shadow: 0 0 25px rgba(99, 102, 241, 0.08);
}

.ascii-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1rem;
  background: #090e1c;
  border-bottom: 1px solid rgba(99, 102, 241, 0.2);
}

.terminal-dots {
  display: flex;
  align-items: center;
  gap: 6px;
}
.terminal-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.dot-red { background: #ef4444; }
.dot-yellow { background: #f59e0b; }
.dot-green { background: #10b981; }

.ascii-title {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.ascii-content {
  padding: 1.25rem;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.825rem;
  line-height: 1.45;
  color: #38bdf8;
  white-space: pre;
}

/* Mermaid Diagram Container */
.mermaid-wrapper {
  margin: 1.5rem 0;
  padding: 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  display: flex;
  justify-content: center;
  overflow-x: auto;
}
.mermaid-wrapper svg {
  max-width: 100%;
  height: auto;
}

/* Mobile Sidebar Backdrop Overlay */
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 7, 14, 0.75);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 45;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-smooth);
}
.sidebar-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.sidebar-mobile-header {
  display: none;
}

/* Tables */
.markdown-body table {
  display: block;
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.875rem;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
}

.markdown-body th {
  background: #1e293b;
  color: var(--text-primary);
  font-weight: 600;
  text-align: left;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
}

.markdown-body td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  color: #cbd5e1;
}

.markdown-body tr:nth-child(even) {
  background: rgba(15, 23, 42, 0.4);
}
.markdown-body tr:hover {
  background: rgba(30, 41, 59, 0.5);
}

/* Document Bottom Navigation */
.doc-pagination {
  margin-top: 3.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.pagination-card {
  display: flex;
  flex-direction: column;
  padding: 1rem 1.25rem;
  border-radius: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  text-decoration: none;
  flex: 1;
  max-width: 320px;
  transition: var(--transition-fast);
}
.pagination-card:hover {
  border-color: var(--border-focus);
  background: var(--bg-card-hover);
  transform: translateY(-2px);
}
.pagination-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}
.pagination-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
}
.pagination-card.next {
  text-align: right;
  margin-left: auto;
}

/* ==========================================================================
   Right Table of Contents (On This Page)
   ========================================================================== */
.toc-sidebar {
  width: var(--toc-width);
  flex-shrink: 0;
  height: calc(100vh - var(--header-height));
  position: sticky;
  top: var(--header-height);
  padding: 2.5rem 1.5rem 2rem 1rem;
  overflow-y: auto;
  font-size: 0.825rem;
}

.toc-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.toc-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  border-left: 1px solid var(--border-subtle);
  padding-left: 0.75rem;
}

.toc-link {
  color: var(--text-muted);
  text-decoration: none;
  display: block;
  line-height: 1.4;
  transition: var(--transition-fast);
}
.toc-link:hover {
  color: var(--text-primary);
}
.toc-link.active {
  color: var(--accent-cyan);
  font-weight: 600;
}
.toc-h3 {
  padding-left: 0.75rem;
  font-size: 0.78rem;
}

.toc-footer {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.toc-action-link {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.78rem;
  transition: var(--transition-fast);
}
.toc-action-link:hover {
  color: var(--text-primary);
}

/* ==========================================================================
   Search Modal
   ========================================================================== */
.search-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 200;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
}
.search-modal-backdrop.open {
  display: flex;
}

.search-modal-card {
  width: 90%;
  max-width: 620px;
  background: var(--bg-card);
  border: 1px solid #334155;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  max-height: 75vh;
}

.search-input-wrapper {
  display: flex;
  align-items: center;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
  background: #0b1120;
}
.search-input-icon {
  color: var(--accent-cyan);
  margin-right: 0.75rem;
}
.modal-search-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 1rem;
  outline: none;
}
.modal-search-input::placeholder {
  color: var(--text-muted);
}

.search-results-list {
  overflow-y: auto;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.search-result-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  transition: var(--transition-fast);
  border: 1px solid transparent;
}
.search-result-item:hover, .search-result-item.selected {
  background: #1e293b;
  border-color: var(--accent-primary);
}

.search-result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.search-result-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
}
.search-result-category {
  font-size: 0.7rem;
  padding: 0.15rem 0.45rem;
  background: rgba(99, 102, 241, 0.15);
  color: #a5b4fc;
  border-radius: 4px;
}
.search-result-snippet {
  font-size: 0.825rem;
  color: var(--text-secondary);
  line-height: 1.4;
}
.search-result-snippet mark {
  background: rgba(6, 182, 212, 0.3);
  color: #67e8f9;
  padding: 0.1rem 0.2rem;
  border-radius: 2px;
}

.search-modal-footer {
  padding: 0.6rem 1.25rem;
  background: #090e1c;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
}
.search-footer-keys {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.search-footer-keys span {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

/* ==========================================================================
   Loading & Error States
   ========================================================================== */
.loading-container {
  padding: 3rem 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  color: var(--text-secondary);
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(99, 102, 241, 0.15);
  border-top-color: var(--accent-cyan);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.error-card {
  margin: 2rem 0;
  padding: 2rem;
  border-radius: 12px;
  background: rgba(244, 63, 94, 0.06);
  border: 1px solid rgba(244, 63, 94, 0.3);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}
.error-card-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: #fb7185;
}
.error-card-desc {
  font-size: 0.9rem;
  color: var(--text-secondary);
  max-width: 480px;
}
.retry-btn {
  padding: 0.5rem 1.25rem;
  background: #e11d48;
  color: white;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: var(--transition-fast);
}
.retry-btn:hover {
  background: #be123c;
}

/* ==========================================================================
   Responsive Adaptations
   ========================================================================== */
@media (max-width: 1200px) {
  .toc-sidebar {
    display: none;
  }
  .main-content {
    max-width: 100%;
    padding: 2.25rem 2rem;
  }
}

@media (max-width: 992px) {
  .stats-container {
    display: none;
  }
}

@media (max-width: 860px) {
  .mobile-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    height: 100vh;
    width: min(85vw, 320px);
    transform: translateX(-100%);
    box-shadow: 10px 0 35px rgba(0, 0, 0, 0.85);
    z-index: 150;
    padding: 1.25rem 1rem;
  }
  .sidebar.mobile-open {
    transform: translateX(0);
  }

  .sidebar-mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 0.85rem;
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: 1rem;
  }
  .sidebar-mobile-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-primary);
  }
  .close-sidebar-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.4rem;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .close-sidebar-btn:hover {
    color: var(--text-primary);
    background: var(--bg-card);
  }

  .main-content {
    padding: 1.75rem 1.25rem;
  }

  .doc-hero-title {
    font-size: 1.85rem;
  }

  .doc-pagination {
    flex-direction: column;
    gap: 0.75rem;
  }
  .pagination-card {
    max-width: 100%;
  }
  .pagination-card.next {
    margin-left: 0;
    text-align: left;
  }
}

@media (max-width: 640px) {
  :root {
    --header-height: 58px;
  }

  .site-header {
    padding: 0 0.85rem;
  }
  .header-left {
    gap: 0.6rem;
  }
  .brand-title {
    font-size: 1.15rem;
  }
  .brand-icon-wrapper {
    width: 32px;
    height: 32px;
  }

  .header-center {
    margin: 0 0.5rem;
  }
  .search-trigger-btn {
    padding: 0.4rem 0.65rem;
    font-size: 0.8rem;
  }
  .kbd-shortcut {
    display: none;
  }

  .main-content {
    padding: 1.5rem 0.85rem;
  }
  .doc-hero-title {
    font-size: 1.55rem;
  }
  .doc-hero-desc {
    font-size: 0.95rem;
  }

  .ascii-content {
    font-size: 0.68rem;
    line-height: 1.35;
    padding: 0.85rem;
  }

  /* Full-screen native app search modal on mobile */
  .search-modal-backdrop {
    padding-top: 0;
    align-items: stretch;
  }
  .search-modal-card {
    width: 100%;
    max-width: 100%;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    border: none;
  }
  .search-footer-keys {
    display: none;
  }
  .search-modal-footer {
    padding: 0.75rem 1rem;
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .site-header {
    padding: 0 0.65rem;
  }
  .search-trigger-left span {
    display: none;
  }
  .search-trigger-btn {
    width: 34px;
    height: 34px;
    padding: 0;
    justify-content: center;
    border-radius: 8px;
  }
  .search-trigger-left {
    gap: 0;
  }
  .github-link-btn span {
    display: none;
  }
  .github-link-btn {
    width: 34px;
    height: 34px;
    padding: 0;
    justify-content: center;
    border-radius: 8px;
  }

  .doc-hero-title {
    font-size: 1.35rem;
  }
  .doc-metadata-bar {
    gap: 0.35rem;
    font-size: 0.7rem;
  }
  .doc-meta-item {
    padding: 0.15rem 0.4rem;
  }

  .ascii-content {
    font-size: 0.58rem;
    padding: 0.65rem;
  }
  .code-block-wrapper pre {
    padding: 0.75rem 0.85rem;
    font-size: 0.78rem;
  }
}
