:root {
  --primary-color: #0079ff;
  --primary-dark: #0063d1;
  --primary-light: #59abff;
  --secondary-color: #2b7fff;
  --accent-color: #38bdf8;
  --success-color: #00af5c;
  --warning-color: #ff9500;
  --danger-color: #ff3b30;

  --bg-primary: #f4f7fb;
  --bg-secondary: #ebf1f8;
  --bg-tertiary: #dde7f2;
  --bg-code: #edf3fa;
  --bg-sidebar: #f7faff;

  --text-primary: #0f172a;
  --text-secondary: #55657d;
  --text-tertiary: #8493a8;
  --text-inverse: #ffffff;
  --text-code: #006fe8;
  --text-code-bg: #f1f6fd;

  --border-color: #d1dceb;
  --border-light: #dde6f2;
  --shadow: rgba(8, 15, 28, 0.08);
  --shadow-lg: rgba(8, 15, 28, 0.14);

  --sidebar-width: 280px;
  --toc-width: 280px;
  --header-height: 64px;

  --font-sans: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  --font-mono: "SF Mono", Monaco, "Cascadia Code", "Roboto Mono", Consolas,
    "Courier New", monospace;

  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --radius: 8px;
  --radius-sm: 4px;
}

[data-theme="dark"] {
  --bg-primary: #0b1220;
  --bg-secondary: #111827;
  --bg-tertiary: #172033;
  --bg-code: #0e1626;
  --bg-sidebar: #0f1728;

  --text-primary: #e6eef8;
  --text-secondary: #9fb0c7;
  --text-tertiary: #70839d;
  --text-code: #6cbcff;
  --text-code-bg: #10192b;

  --border-color: #22324a;
  --border-light: #18253a;
  --shadow: rgba(0, 0, 0, 0.38);
  --shadow-lg: rgba(0, 0, 0, 0.58);

  --primary-color: #0079ff;
  --primary-dark: #0063d1;
  --primary-light: #59abff;
  --secondary-color: #2b7fff;
}

/* ==================== RESET & BASE ==================== */

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

html {
  scroll-behavior: smooth;
  font-size: 15px;
}

body {
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-primary);
  overflow-x: hidden;
}

/* ==================== HEADER ==================== */

.wiki-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  z-index: 1000;
  box-shadow: 0 2px 8px var(--shadow);
}

[data-theme="dark"] .wiki-header {
  border-bottom: 1px solid rgba(0, 121, 255, 0.28);
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  max-width: 1920px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 700;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

.logo:hover .logo-icon {
  transform: scale(1.05);
}

.logo-icon {
  font-size: 2rem;
  width: 2rem;
  height: 2rem;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: all var(--transition);
}

[data-theme="dark"] .logo-icon {
  box-shadow: 0 2px 12px rgba(0, 121, 255, 0.16);
}

.logo h1 {
  font-size: 1.5rem;
  color: var(--primary-color);
  white-space: nowrap;
}

.logo-text-short {
  display: none;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.home-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.875rem;
  background: transparent;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  font-weight: 500;
  transition: all var(--transition);
  border: none;
}

.home-btn:hover {
  color: var(--text-primary);
  background: var(--bg-secondary);
}

.home-btn:active {
  transform: scale(0.95);
}

.home-btn svg {
  width: 18px;
  height: 18px;
}

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.icon-btn:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.icon-btn:active {
  transform: scale(0.95);
}

.mobile-only {
  display: none;
}

/* Theme toggle icons */
[data-theme="light"] .moon-icon,
[data-theme="dark"] .sun-icon {
  display: none;
}

/* ==================== CONTAINER ==================== */

.wiki-container {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr var(--toc-width);
  margin-top: var(--header-height);
  min-height: calc(100vh - var(--header-height));
  max-width: 100vw;
  overflow-x: hidden;
}

/* ==================== MAIN CONTENT WRAPPER ==================== */

.wiki-content-wrapper {
  position: relative;
  overflow-y: auto;
  overflow-x: hidden;
  height: calc(100vh - var(--header-height));
  background: var(--bg-primary);
  scroll-behavior: smooth; /* Ensure smooth scrolling */
}

/* Custom scrollbar for main content */
.wiki-content-wrapper::-webkit-scrollbar {
  width: 8px;
}

.wiki-content-wrapper::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

.wiki-content-wrapper::-webkit-scrollbar-thumb {
  background: var(--text-tertiary);
  border-radius: 4px;
}

.wiki-content-wrapper::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* ==================== MAIN CONTENT ==================== */

.wiki-content {
  max-width: 900px;
  margin: 0 auto;
  padding: 3rem 3rem 6rem;
  background: var(--bg-primary);
  min-height: 100%;
  box-sizing: border-box;
}

/* ==================== SIDEBAR ==================== */

.wiki-sidebar {
  position: sticky;
  top: var(--header-height);
  height: calc(100vh - var(--header-height));
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  overflow-y: auto;
  overflow-x: hidden;
}

[data-theme="dark"] .wiki-sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid rgba(0, 121, 255, 0.16);
  box-shadow: inset -1px 0 0 rgba(0, 121, 255, 0.06);
}

.sidebar-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

[data-theme="dark"] .sidebar-header {
  background: rgba(0, 121, 255, 0.04);
  border-bottom: 1px solid rgba(0, 121, 255, 0.12);
}

.sidebar-header h2 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
}

.sidebar-nav {
  padding: 1rem 0;
}

.nav-section {
  margin-bottom: 1.5rem;
}

[data-theme="dark"] .nav-section {
  position: relative;
}

[data-theme="dark"] .nav-section:not(:last-child)::after {
  content: "";
  position: absolute;
  bottom: -0.75rem;
  left: 1.5rem;
  right: 1.5rem;
  height: 1px;
  background: rgba(0, 121, 255, 0.16);
}

.nav-section h3 {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
  padding: 0 1.5rem;
  margin-bottom: 0.5rem;
}

[data-theme="dark"] .nav-section h3 {
  color: var(--primary-light);
  font-weight: 800;
}

.nav-section ul {
  list-style: none;
}

.nav-section a {
  display: block;
  padding: 0.5rem 1.5rem;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9375rem;
  transition: all var(--transition);
  border-left: 3px solid transparent;
}

.nav-section a:hover {
  color: var(--text-primary);
  background: var(--bg-secondary);
  border-left-color: var(--primary-color);
}

[data-theme="dark"] .nav-section a:hover {
  background: rgba(0, 121, 255, 0.08);
  border-left-color: var(--primary-color);
}

.nav-section a.active {
  color: var(--primary-color);
  background: var(--bg-secondary);
  border-left-color: var(--primary-color);
  font-weight: 600;
}

[data-theme="dark"] .nav-section a.active {
  background: rgba(0, 121, 255, 0.12);
  border-left: 3px solid var(--primary-color);
  color: var(--primary-light);
  box-shadow: inset 0 0 0 1px rgba(0, 121, 255, 0.08);
}

.sidebar-footer {
  padding: 1.5rem;
  border-top: 1px solid var(--border-color);
  margin-top: auto;
}

[data-theme="dark"] .sidebar-footer {
  background: rgba(0, 121, 255, 0.04);
  border-top: 1px solid rgba(0, 121, 255, 0.12);
}

.quick-links {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.quick-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.quick-link:hover {
  background: var(--bg-secondary);
  color: var(--primary-color);
}

[data-theme="dark"] .quick-link:hover {
  background: rgba(0, 121, 255, 0.08);
  color: var(--primary-light);
}

.version-badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  background: var(--primary-color);
  color: var(--text-inverse);
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 12px;
}

/* ==================== MAIN CONTENT ==================== */

.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  color: var(--text-secondary);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border-color);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Markdown Content Styles */

.wiki-content h1 {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--text-primary);
  line-height: 1.2;
}

.wiki-content h2 {
  font-size: 2rem;
  font-weight: 700;
  margin: 3rem 0 1.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--border-color);
  color: var(--text-primary);
  line-height: 1.3;
}

[data-theme="dark"] .wiki-content h2 {
  border-bottom: 2px solid rgba(0, 121, 255, 0.24);
}

.wiki-content h3 {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 2.5rem 0 1rem;
  color: var(--text-primary);
}

.wiki-content h4 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 2rem 0 0.75rem;
  color: var(--text-primary);
}

.wiki-content h5,
.wiki-content h6 {
  font-size: 1rem;
  font-weight: 600;
  margin: 1rem 0 0.5rem;
  color: var(--text-secondary);
}

.wiki-content p {
  margin-bottom: 1.25rem;
  color: var(--text-primary);
  line-height: 1.7;
}

.wiki-content a {
  color: var(--primary-color);
  text-decoration: none;
  transition: color var(--transition);
}

.wiki-content a:hover {
  color: var(--primary-dark);
  text-decoration: underline;
}

.wiki-content strong {
  font-weight: 600;
  color: var(--text-primary);
}

.wiki-content em {
  font-style: italic;
}

.wiki-content code {
  padding: 0.2em 0.4em;
  background: var(--text-code-bg);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.875em;
  color: var(--text-code);
  font-weight: 500;
}

.wiki-content pre {
  margin: 1.5rem 0;
  padding: 1.25rem;
  background: var(--bg-code);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  overflow-x: auto;
  line-height: 1.5;
  position: relative;
  color: var(--text-primary);
}

.wiki-content pre code {
  padding: 0;
  background: none;
  border: none;
  font-size: 0.875rem;
  color: inherit;
  font-weight: normal;
}

/* Command-specific styling */
.wiki-content code[class*="language-"],
.wiki-content pre[class*="language-"] {
  color: var(--text-primary);
}

/* Inline code in tables and other elements */
.wiki-content td code,
.wiki-content th code,
.wiki-content li code,
.wiki-content p code {
  color: var(--text-code);
  background: var(--text-code-bg);
}

/* ==================== COPY BUTTON STYLING ==================== */

.copy-code-btn {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  font-family: var(--font-sans);
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition);
  z-index: 10;
  box-shadow: 0 2px 4px var(--shadow);
  user-select: none;
  white-space: nowrap;
  min-width: 60px;
  text-align: center;
}

[data-theme="dark"] .copy-code-btn {
  background: var(--bg-tertiary);
  border-color: rgba(0, 121, 255, 0.3);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

/* Hover states */
.copy-code-btn:hover {
  background: var(--primary-color);
  border-color: var(--primary-color);
  color: var(--text-inverse);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px var(--shadow);
}

[data-theme="dark"] .copy-code-btn:hover {
  background: var(--primary-color);
  border-color: var(--primary-color);
  box-shadow: 0 4px 12px rgba(0, 121, 255, 0.22);
}

/* Active/pressed state */
.copy-code-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px var(--shadow);
}

/* Success state (when copied) */
.copy-code-btn.copied {
  background: var(--success-color);
  border-color: var(--success-color);
  color: var(--text-inverse);
}

[data-theme="dark"] .copy-code-btn.copied {
  background: #00d084;
  border-color: #00d084;
}

/* Show button on code block hover */
.wiki-content pre:hover .copy-code-btn {
  opacity: 1;
  visibility: visible;
}

/* Focus states for accessibility */
.copy-code-btn:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
  opacity: 1;
  visibility: visible;
}

/* Icon support */
.copy-code-btn svg {
  width: 14px;
  height: 14px;
  margin-right: 0.25rem;
  vertical-align: middle;
}

/* Mobile optimizations */
@media (max-width: 768px) {
  .copy-code-btn {
    opacity: 1;
    visibility: visible;
    position: static;
    float: right;
    margin-top: -2.5rem;
    margin-right: 0.5rem;
    padding: 0.375rem 0.5rem;
    font-size: 0.6875rem;
  }

  /* Ensure mobile buttons don't interfere with scrolling */
  .wiki-content pre {
    padding-top: 3rem;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .copy-code-btn {
    border-width: 2px;
    font-weight: 600;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .copy-code-btn {
    transition: opacity 0.1s;
  }
}

.wiki-content ul,
.wiki-content ol {
  margin: 1.5rem 0;
  padding-left: 2rem;
  line-height: 1.8;
}

.wiki-content li {
  margin: 0.75rem 0;
}

.wiki-content li > ul,
.wiki-content li > ol {
  margin: 0.5rem 0;
}

.wiki-content blockquote {
  margin: 1.5rem 0;
  padding: 1rem 1.5rem;
  background: var(--bg-secondary);
  border-left: 4px solid var(--primary-color);
  border-radius: var(--radius-sm);
}

[data-theme="dark"] .wiki-content blockquote {
  border-left: 4px solid var(--primary-color);
  background: rgba(0, 121, 255, 0.08);
}

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

.wiki-content table {
  width: 100%;
  margin: 2rem 0;
  border-collapse: separate;
  border-spacing: 0;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  overflow: hidden;
  font-size: 0.9375rem;
}

[data-theme="dark"] .wiki-content table {
  border: 1px solid rgba(0, 121, 255, 0.18);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.wiki-content th {
  background: var(--bg-secondary);
  padding: 1rem 1.25rem;
  font-weight: 600;
  text-align: left;
  border-bottom: 2px solid var(--border-color);
  color: var(--text-primary);
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

/* Respect align attributes */
.wiki-content th[align="right"],
.wiki-content td[align="right"] {
  text-align: right;
}

.wiki-content th[align="center"],
.wiki-content td[align="center"] {
  text-align: center;
}

.wiki-content th[align="left"],
.wiki-content td[align="left"] {
  text-align: left;
}

[data-theme="dark"] .wiki-content th {
  background: rgba(0, 121, 255, 0.06);
  border-bottom: 2px solid rgba(0, 121, 255, 0.22);
}

.wiki-content td {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-primary);
  vertical-align: top;
}

[data-theme="dark"] .wiki-content td {
  border-bottom: 1px solid rgba(0, 121, 255, 0.08);
}

.wiki-content tr:last-child td {
  border-bottom: none;
}

.wiki-content tbody tr {
  transition: background-color var(--transition);
}

.wiki-content tr:hover {
  background: var(--bg-secondary);
}

[data-theme="dark"] .wiki-content tbody tr:hover {
  background: rgba(0, 121, 255, 0.05);
}

/* Alternating row colors for better readability */
[data-theme="dark"] .wiki-content tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.01);
}

/* First column styling (often labels/keys) */
.wiki-content td:first-child {
  font-weight: 500;
}

[data-theme="dark"] .wiki-content td:first-child {
  color: var(--primary-light);
}

/* Code in tables */
.wiki-content table code {
  font-size: 0.8125rem;
  padding: 0.125rem 0.375rem;
}

/* Better spacing around tables */
.wiki-content h2 + table,
.wiki-content h3 + table,
.wiki-content h4 + table {
  margin-top: 1.5rem;
}

.wiki-content table + p,
.wiki-content table + ul,
.wiki-content table + ol,
.wiki-content table + h2,
.wiki-content table + h3,
.wiki-content table + h4 {
  margin-top: 2.5rem;
}

.wiki-content table + table {
  margin-top: 3rem;
}

/* ==================== TABLE SCROLL WRAPPER ==================== */

/* JS wraps every rendered table in this div for clean horizontal scroll */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  margin: 2rem 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border-color) transparent;
}

[data-theme="dark"] .table-wrap {
  border-color: rgba(0, 121, 255, 0.18);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* When inside wrapper, table handles its own internal layout */
.table-wrap .wiki-content table,
.table-wrap table {
  margin: 0 !important;
  border: none !important;
  border-radius: 0 !important;
  min-width: 480px;
  width: 100%;
}

/* Responsive table wrapper */
@media (max-width: 768px) {
  /* Fallback for tables not yet wrapped by JS */
  .wiki-content table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    /* NOTE: white-space:nowrap intentionally removed - it caused runaway table width */
  }

  .wiki-content th,
  .wiki-content td {
    padding: 0.75rem 0.875rem;
    /* Allow text to wrap within cells */
    white-space: normal;
  }

  /* Ensure wrapper itself scrolls properly inside the wiki layout */
  .table-wrap {
    max-width: 100%;
  }
}

.wiki-content hr {
  margin: 2rem 0;
  border: none;
  border-top: 1px solid var(--border-color);
}

.wiki-content img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  margin: 1.5rem 0;
}

/* Alert/Note boxes */
.wiki-content .note,
.wiki-content .warning,
.wiki-content .tip {
  margin: 1.5rem 0;
  padding: 1rem 1.5rem;
  border-radius: var(--radius);
  border-left: 4px solid;
}

.wiki-content .note {
  background: #e3f2fd;
  border-color: #2196f3;
}

.wiki-content .warning {
  background: #fff3e0;
  border-color: #ff9800;
}

.wiki-content .tip {
  background: #e8f5e9;
  border-color: #4caf50;
}

[data-theme="dark"] .wiki-content .note {
  background: rgba(33, 150, 243, 0.1);
}

[data-theme="dark"] .wiki-content .warning {
  background: rgba(255, 152, 0, 0.1);
}

[data-theme="dark"] .wiki-content .tip {
  background: rgba(76, 175, 80, 0.1);
}

/* ==================== TABLE OF CONTENTS ==================== */

.wiki-toc {
  position: relative;
  width: 100%;
  height: calc(100vh - var(--header-height));
  padding: 2rem 1.5rem;
  border-left: 1px solid var(--border-color);
  overflow-y: auto;
  overflow-x: hidden;
  scroll-behavior: smooth; /* Enable smooth scrolling for TOC */
  scrollbar-width: thin;
  scrollbar-color: var(--border-color) transparent;
  background: var(--bg-primary);
  box-sizing: border-box;
}

/* Custom scrollbar for webkit browsers */
.wiki-toc::-webkit-scrollbar {
  width: 6px;
}

.wiki-toc::-webkit-scrollbar-track {
  background: transparent;
}

.wiki-toc::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

.wiki-toc::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}

.toc-header {
  margin-bottom: 1rem;
  background: var(--bg-primary);
  padding-bottom: 0.5rem;
  z-index: 10;
}

.toc-header h3 {
  font-size: 0.875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
}

.toc-nav {
  display: flex;
  flex-direction: column;
  gap: 0.125rem; /* Tighter spacing for better flow */
  position: relative;
}

/* Reading progress indicator */
.toc-progress {
  position: absolute;
  left: -2px;
  top: 0;
  width: 3px;
  height: 0%;
  background: var(--primary-color);
  border-radius: 0 2px 2px 0;
  transition: height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1;
  box-shadow: 0 0 8px rgba(0, 121, 255, 0.22);
}

[data-theme="dark"] .toc-progress {
  background: var(--primary-color);
  box-shadow: 0 0 10px rgba(0, 121, 255, 0.22);
}

/* Empty state styling */
.toc-empty {
  color: var(--text-tertiary);
  font-style: italic;
  text-align: center;
  padding: 2rem 1rem;
}

.toc-nav a {
  display: block;
  padding: 0.5rem 0.75rem;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  border-left: 3px solid transparent;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  line-height: 1.4;
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
}

/* Hover effect with subtle background */
.toc-nav a::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--primary-color);
  opacity: 0;
  transition: opacity var(--transition);
  z-index: -1;
}

.toc-nav a:hover {
  color: var(--text-primary);
  border-left-color: var(--primary-light);
  transform: translateX(4px);
}

.toc-nav a:hover::before {
  opacity: 0.05;
}

/* Active state with enhanced visual feedback */
.toc-nav a.active {
  color: var(--primary-color);
  border-left-color: var(--primary-color);
  font-weight: 600;
  background: rgba(0, 121, 255, 0.08);
  transform: translateX(6px);
  box-shadow: 0 2px 8px rgba(0, 121, 255, 0.14);
}

.toc-nav a.active::before {
  opacity: 0.1;
}

/* Enhanced dark theme active state */
[data-theme="dark"] .toc-nav a.active {
  border-left: 3px solid var(--primary-color);
  background: rgba(0, 121, 255, 0.1);
  color: var(--primary-light);
  box-shadow: 0 0 0 1px rgba(0, 121, 255, 0.16);
}

/* Nested heading styles with better indentation */
.toc-nav a.toc-h3 {
  padding-left: 1.75rem;
  font-size: 0.8125rem;
  opacity: 0.9;
}

.toc-nav a.toc-h4 {
  padding-left: 2.5rem;
  font-size: 0.8125rem;
  color: var(--text-tertiary);
  opacity: 0.8;
}

/* Active nested headings */
.toc-nav a.toc-h3.active,
.toc-nav a.toc-h4.active {
  opacity: 1;
}

/* Progress indicator (optional visual enhancement) */
.toc-nav::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  width: 2px;
  height: 100%;
  background: var(--border-light);
  z-index: -2;
}

/* Smooth transitions for all interactive elements */
.toc-nav a,
.toc-nav a::before {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Focus states for accessibility */
.toc-nav a:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* ==================== SEARCH MODAL ==================== */

.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 2000;
  align-items: flex-start;
  justify-content: center;
  padding: 10vh 1rem;
  overflow-y: auto;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--bg-primary);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px var(--shadow-lg);
  max-width: 600px;
  width: 100%;
  animation: slideIn 0.2s ease-out;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.search-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.search-header input {
  flex: 1;
  font-size: 1.125rem;
  font-family: var(--font-sans);
  border: none;
  background: transparent;
  color: var(--text-primary);
  outline: none;
}

.search-header input::placeholder {
  color: var(--text-tertiary);
}

.search-results {
  max-height: 60vh;
  overflow-y: auto;
  padding: 1rem;
}

.search-hint {
  padding: 2rem;
  text-align: center;
  color: var(--text-tertiary);
}

.search-result {
  padding: 1rem;
  margin-bottom: 0.5rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
}

.search-result:hover {
  background: var(--bg-secondary);
}

.search-result-title {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.search-result-excerpt {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.search-result-excerpt mark {
  background: var(--warning-color);
  color: var(--text-inverse);
  padding: 0.125rem 0.25rem;
  border-radius: 2px;
}

/* ==================== PAGE NAVIGATION ==================== */

.page-navigation {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 2px solid var(--border-color);
}

/* When there's only a next button (first page), position it on the right */
.page-navigation:has(.next-page:only-child) {
  justify-content: flex-end;
}

/* Fallback for browsers that don't support :has() selector */
.page-navigation .next-page:only-child {
  margin-left: auto;
}

[data-theme="dark"] .page-navigation {
  border-top: 1px solid rgba(0, 121, 255, 0.18);
}

.page-nav-btn {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text-primary);
  transition: all var(--transition);
  flex: 1;
  max-width: 48%;
}

[data-theme="dark"] .page-nav-btn {
  background: var(--bg-secondary);
  border: 1px solid rgba(0, 121, 255, 0.18);
}

.page-nav-btn:hover {
  background: var(--bg-tertiary);
  border-color: var(--primary-color);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px var(--shadow);
}

[data-theme="dark"] .page-nav-btn:hover {
  background: var(--bg-tertiary);
  border-color: var(--primary-color);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.24);
}

.page-nav-btn svg {
  flex-shrink: 0;
  color: var(--text-tertiary);
  transition: color var(--transition);
}

.page-nav-btn:hover svg {
  color: var(--primary-color);
}

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

.nav-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
}

.nav-title {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-primary);
}

.prev-page {
  justify-content: flex-start;
}

.next-page {
  justify-content: flex-end;
  text-align: right;
}

.page-nav-btn:only-child {
  max-width: 100%;
}

@media (max-width: 768px) {
  .page-navigation {
    flex-direction: column;
    gap: 0.75rem;
  }

  .page-nav-btn {
    max-width: 100%;
  }
}

/* ==================== BACK TO TOP ==================== */

.back-to-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 48px;
  height: 48px;
  border: none;
  background: var(--primary-color);
  color: var(--text-inverse);
  border-radius: 50%;
  box-shadow: 0 4px 12px var(--shadow);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition);
  z-index: 100;
}

.back-to-top.visible {
  opacity: 1;
  visibility: visible;
}

.back-to-top:hover {
  background: var(--primary-dark);
  transform: translateY(-4px);
  box-shadow: 0 6px 16px var(--shadow-lg);
}

.back-to-top:active {
  transform: translateY(-2px);
}

/* ==================== RESPONSIVE ==================== */

@media (max-width: 1200px) {
  .wiki-toc {
    display: none;
  }

  .wiki-container {
    grid-template-columns: var(--sidebar-width) 1fr;
  }

  /* Mobile TOC toggle button */
  .mobile-toc-toggle {
    position: fixed;
    bottom: 80px;
    right: 1rem;
    width: 48px;
    height: 48px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50%;
    box-shadow: 0 4px 12px var(--shadow-lg);
    cursor: pointer;
    z-index: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    opacity: 0.9;
  }

  .mobile-toc-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px var(--shadow-lg);
    opacity: 1;
  }

  /* Mobile TOC overlay */
  .wiki-toc.mobile-active {
    display: block;
    position: fixed;
    top: var(--header-height);
    right: 0;
    width: min(300px, 80vw);
    height: calc(100vh - var(--header-height));
    background: var(--bg-primary);
    border-left: 1px solid var(--border-color);
    box-shadow: -4px 0 20px var(--shadow-lg);
    transform: translateX(0);
    z-index: 800;
    animation: slideInRight 0.3s ease-out;
  }

  @keyframes slideInRight {
    from {
      transform: translateX(100%);
    }
    to {
      transform: translateX(0);
    }
  }

  /* Backdrop for mobile TOC */
  .mobile-toc-backdrop {
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    z-index: 750;
    opacity: 0;
    animation: fadeIn 0.3s ease-out forwards;
  }

  @keyframes fadeIn {
    to {
      opacity: 1;
    }
  }
}

/* Sidebar backdrop (mobile) */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  top: var(--header-height);
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
  z-index: 998;
  animation: fadeIn 0.2s ease-out forwards;
}

.sidebar-backdrop.active {
  display: block;
}

@keyframes fadeIn {
  to {
    opacity: 1;
  }
}

@media (max-width: 768px) {
  .mobile-only {
    display: flex;
  }

  .home-btn span {
    display: none;
  }

  .home-btn {
    padding: 0.5rem;
    width: 40px;
    height: 40px;
    justify-content: center;
  }

  .wiki-container {
    grid-template-columns: 1fr;
  }

  /* Fix nested scroll - let the page scroll naturally on mobile */
  .wiki-content-wrapper {
    height: auto;
    min-height: 70vh;
    overflow-y: visible;
    overflow-x: hidden;
  }

  .wiki-sidebar {
    position: fixed;
    top: var(--header-height);
    left: -100%;
    width: 280px;
    z-index: 999;
    transition: left var(--transition);
    box-shadow: 4px 0 12px var(--shadow);
  }

  .wiki-sidebar.active {
    left: 0;
  }

  .wiki-content {
    padding: 2rem 1.25rem 4rem;
    margin: 0 auto;
  }

  .wiki-content h1 {
    font-size: 2rem;
  }

  .wiki-content h2 {
    font-size: 1.75rem;
  }

  .header-content {
    padding: 0 1rem;
  }

  .logo h1 {
    font-size: 1.25rem;
  }

  .back-to-top {
    bottom: 1rem;
    right: 1rem;
  }
}

@media (max-width: 480px) {
  /* Show short logo text on very small screens */
  .logo-text-full {
    display: none;
  }
  .logo-text-short {
    display: inline;
  }

  .wiki-content {
    padding: 1.5rem 1rem 3rem;
    margin: 0 auto;
  }

  .wiki-content h1 {
    font-size: 1.75rem;
  }

  .wiki-content h2 {
    font-size: 1.5rem;
  }

  .wiki-content h3 {
    font-size: 1.25rem;
  }

  .wiki-content pre {
    padding: 1rem;
    font-size: 0.8125rem;
  }

  /* Better list readability on tiny screens */
  .wiki-content ul,
  .wiki-content ol {
    padding-left: 1.25rem;
  }

  .modal {
    padding: 5vh 0.5rem;
  }
}

/* ==================== SCROLLBAR ==================== */

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--text-tertiary);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

[data-theme="dark"] .wiki-sidebar::-webkit-scrollbar-thumb {
  background: rgba(0, 121, 255, 0.35);
}

[data-theme="dark"] .wiki-sidebar::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 121, 255, 0.55);
}

[data-theme="dark"] .wiki-sidebar::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
}

/* ==================== PRINT ==================== */

@media print {
  .wiki-header,
  .wiki-sidebar,
  .wiki-toc,
  .back-to-top,
  #searchModal {
    display: none !important;
  }

  .wiki-container {
    grid-template-columns: 1fr;
    margin-top: 0;
  }

  .wiki-content {
    max-width: 100%;
    padding: 0;
  }
}

/* Enhanced syntax highlighting colors for different code types */

/* YAML/Configuration syntax */
.wiki-content pre code .token.key,
.wiki-content code .yaml-key {
  color: var(--primary-color);
  font-weight: 600;
}

.wiki-content pre code .token.string,
.wiki-content code .yaml-value {
  color: var(--success-color);
}

/* Command syntax highlighting */
.wiki-content code[class*="shell"],
.wiki-content code[class*="bash"],
.wiki-content code[class*="cmd"],
.wiki-content pre[class*="shell"],
.wiki-content pre[class*="bash"],
.wiki-content pre[class*="cmd"] {
  color: var(--text-primary);
}

/* Java code syntax */
.wiki-content code[class*="java"],
.wiki-content pre[class*="java"] {
  color: var(--text-primary);
}

.wiki-content pre code .token.keyword {
  color: var(--primary-color);
  font-weight: 600;
}

.wiki-content pre code .token.function {
  color: var(--accent-color);
}

.wiki-content pre code .token.comment {
  color: var(--text-secondary);
  font-style: italic;
}

/* Permission node styling */
.wiki-content code[class*="permission"],
.wiki-content code:contains("fpp.") {
  color: var(--secondary-color);
  background: var(--text-code-bg);
}

/* Better contrast for dark theme code */
[data-theme="dark"] .wiki-content code {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .wiki-content pre {
  background: rgba(255, 255, 255, 0.02);
  border-color: rgba(255, 255, 255, 0.1);
}

/* ==================== ERROR PAGES ==================== */

.error-page {
  text-align: center;
  padding: 4rem 2rem;
  max-width: 600px;
  margin: 0 auto;
}

.error-icon {
  font-size: 4rem;
  margin-bottom: 1.5rem;
  display: block;
}

.error-page h1 {
  color: var(--text-primary);
  font-size: 2.5rem;
  margin-bottom: 1rem;
  font-weight: 700;
}

.error-message {
  color: var(--text-secondary);
  font-size: 1.125rem;
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

.error-details {
  color: var(--text-tertiary);
  font-size: 0.9375rem;
  margin-bottom: 2rem;
  font-family: var(--font-mono);
  background: var(--bg-code);
  padding: 1rem;
  border-radius: var(--radius-sm);
  border-left: 4px solid var(--warning-color);
}

.error-suggestions {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin: 2rem 0;
  border-left: 4px solid var(--primary-color);
}

.error-suggestions h3 {
  color: var(--text-primary);
  font-size: 1.125rem;
  margin-bottom: 1rem;
  font-weight: 600;
}

.suggestion-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.suggestion-list li a {
  display: block;
  padding: 0.75rem 1rem;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--primary-color);
  text-decoration: none;
  transition: all var(--transition);
  font-weight: 500;
}

.suggestion-list li a:hover {
  background: var(--primary-color);
  color: var(--text-inverse);
  transform: translateX(4px);
}

.error-actions {
  display: flex;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 2rem;
}

.btn-primary,
.btn-secondary {
  padding: 0.875rem 1.75rem;
  border: none;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.9375rem;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-primary {
  background: var(--primary-color);
  color: var(--text-inverse);
}

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px var(--shadow);
}

.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: var(--bg-tertiary);
  border-color: var(--primary-color);
  transform: translateY(-2px);
}

/* All Pages Grid */
.all-pages {
  padding: 2rem 0;
}

.page-category {
  margin: 3rem 0;
}

.page-category h2 {
  color: var(--text-primary);
  font-size: 1.5rem;
  margin-bottom: 1.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--border-color);
}

[data-theme="dark"] .page-category h2 {
  border-bottom: 2px solid rgba(0, 121, 255, 0.24);
}

.page-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.page-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-decoration: none;
  color: var(--text-primary);
  transition: all var(--transition);
  display: block;
}

.page-card:hover {
  background: var(--bg-tertiary);
  border-color: var(--primary-color);
  transform: translateY(-4px);
  box-shadow: 0 8px 24px var(--shadow);
}

[data-theme="dark"] .page-card:hover {
  background: var(--bg-tertiary);
  border-color: var(--primary-color);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.26);
}

.page-card h3 {
  font-size: 1.125rem;
  font-weight: 600;
  margin: 0;
  color: inherit;
}

/* Responsive error pages */
@media (max-width: 768px) {
  .error-page {
    padding: 3rem 1rem;
  }

  .error-icon {
    font-size: 3rem;
  }

  .error-page h1 {
    font-size: 2rem;
  }

  .error-actions {
    flex-direction: column;
    align-items: center;
  }

  .btn-primary,
  .btn-secondary {
    width: 100%;
    max-width: 280px;
    justify-content: center;
  }

  .page-grid {
    grid-template-columns: 1fr;
  }
}
