/* ============================================================
   MAPLE Documentation — Design System
   Inspired by ORCA / Furo / GROMACS documentation themes
   ============================================================ */

/* ----- 1. Design Tokens (CSS Variables) ----- */
:root {
  /* Brand */
  --color-brand-primary: #2962ff;
  --color-brand-content: #2a5adf;
  --color-brand-visited: #7c3aed;

  /* Backgrounds */
  --color-bg-primary: #ffffff;
  --color-bg-secondary: #f8f9fb;
  --color-bg-hover: #efeff4;
  --color-bg-code: #f8f8f8;
  --color-bg-border: #eeebee;

  /* Text */
  --color-text-primary: #1a1a2e;
  --color-text-secondary: #5a5c63;
  --color-text-muted: #646776;
  --color-text-border: #878787;

  /* Layout */
  --sidebar-width: 280px;
  --toc-width: 220px;
  --content-max-width: 800px;
  --nav-height: 56px;

  /* Typography */
  --font-stack: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-mono: "SFMono-Regular", Menlo, Consolas, Monaco, "Liberation Mono", monospace;
  --font-size-base: 100%;
  --font-size-sm: 0.875rem;
  --font-size-xs: 0.8125rem;
  --font-size-code: 0.8125rem;

  /* Admonitions */
  --color-note: #00b0ff;
  --color-tip: #00c852;
  --color-warning: #ff9100;
  --color-danger: #ff5252;
  --color-important: #00bfa5;

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.1);
}

/* ----- 2. Reset & Base ----- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: var(--font-size-base);
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-stack);
  background: var(--color-bg-primary);
  color: var(--color-text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--color-brand-content);
  text-decoration: none;
  text-underline-offset: 2px;
}
a:hover {
  text-decoration: underline;
}
a:visited {
  color: var(--color-brand-visited);
}

img { max-width: 100%; height: auto; display: block; }

/* ----- 3. Top Navigation Bar ----- */
.top-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  width: 100%;
  height: var(--nav-height);
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-bg-border);
}

.top-nav .container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  height: 100%;
  gap: 1rem;
}

.top-nav .brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  flex-shrink: 0;
}
.top-nav .brand img {
  width: 32px;
  height: 32px;
  object-fit: contain;
  border-radius: 4px;
}
.top-nav .brand a {
  text-decoration: none;
  color: var(--color-text-primary);
  font-weight: 700;
  font-size: 1.125rem;
  letter-spacing: -0.01em;
}
.top-nav .brand a:visited { color: var(--color-text-primary); }

.top-nav nav { margin-left: auto; }
.top-nav ul {
  list-style: none;
  display: flex;
  gap: 0.25rem;
  align-items: center;
}
.top-nav li a {
  display: block;
  padding: 0.4rem 0.75rem;
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  font-weight: 500;
  text-decoration: none;
  border-radius: 6px;
  transition: background var(--transition-fast), color var(--transition-fast);
  white-space: nowrap;
}
.top-nav li a:visited { color: var(--color-text-secondary); }
.top-nav li a:hover {
  background: var(--color-bg-hover);
  color: var(--color-text-primary);
  text-decoration: none;
}
.top-nav li a.active {
  color: var(--color-brand-primary);
  font-weight: 600;
}

/* Mobile hamburger */
.top-nav .mobile-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  color: var(--color-text-primary);
}
.top-nav .mobile-toggle svg { width: 24px; height: 24px; }

/* ----- 4. Page Layouts ----- */

/* 4a. Landing / Root page layout (single column with optional aside) */
.page-hero {
  max-width: 1280px;
  margin: 0 auto;
  padding: 3rem 1.5rem 2rem;
}
.page-hero h1 {
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--color-text-primary);
  margin-bottom: 0.75rem;
  line-height: 1.2;
}
.page-hero .subtitle {
  font-size: 1.125rem;
  color: var(--color-text-secondary);
  line-height: 1.6;
  max-width: 640px;
}

.page-body {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1.5rem 3rem;
}

/* 4b. Documentation 3-column layout */
.page-layout {
  display: flex;
  max-width: 1400px;
  margin: 0 auto;
  min-height: calc(100vh - var(--nav-height));
}

/* Left sidebar */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  border-right: 1px solid var(--color-bg-border);
  background: var(--color-bg-secondary);
  position: sticky;
  top: var(--nav-height);
  height: calc(100vh - var(--nav-height));
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 10;
}

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

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0 1.25rem 1rem;
  border-bottom: 1px solid var(--color-bg-border);
  margin-bottom: 0.75rem;
}
.sidebar-brand img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  border-radius: 4px;
}
.sidebar-brand span {
  font-weight: 700;
  font-size: var(--font-size-sm);
  color: var(--color-text-primary);
}

/* Sidebar tree */
.sidebar-tree { padding: 0 0.5rem; }

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

.sidebar-tree li { position: relative; }

/* Section headers (expandable) */
.sidebar-tree .tree-section {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.35rem 0.75rem;
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text-primary);
  cursor: pointer;
  border-radius: 4px;
  user-select: none;
  transition: background var(--transition-fast);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-top: 0.75rem;
}
.sidebar-tree .tree-section:first-child { margin-top: 0; }
.sidebar-tree .tree-section:hover { background: var(--color-bg-hover); }

/* Chevron */
.sidebar-tree .chevron {
  display: inline-flex;
  width: 16px;
  height: 16px;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform var(--transition-fast);
  font-size: 0.7rem;
  color: var(--color-text-muted);
}
.sidebar-tree .chevron::after { content: "▸"; }
.sidebar-tree li.open > .tree-section .chevron::after,
.sidebar-tree li.open > .tree-label .chevron::after { content: "▾"; }

/* Tree links */
.sidebar-tree a {
  display: block;
  padding: 0.3rem 0.75rem 0.3rem 1.5rem;
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  text-decoration: none;
  border-radius: 4px;
  transition: background var(--transition-fast), color var(--transition-fast);
  border-left: 2px solid transparent;
}
.sidebar-tree a:visited { color: var(--color-text-secondary); }
.sidebar-tree a:hover {
  background: linear-gradient(90deg, transparent 0%, var(--color-bg-hover) 0.5rem, var(--color-bg-hover) 100%);
  color: var(--color-text-primary);
  text-decoration: none;
}
.sidebar-tree a.active {
  font-weight: 600;
  color: var(--color-brand-primary);
  border-left-color: var(--color-brand-primary);
  background: linear-gradient(90deg, rgba(41,98,255,0.06) 0%, rgba(41,98,255,0.03) 100%);
}

/* Nested levels */
.sidebar-tree .children {
  padding-left: 0.75rem;
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.3s ease;
}
.sidebar-tree li.open > .children {
  max-height: 2000px;
}

/* Tree label (expandable link items) */
.sidebar-tree .tree-label {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.3rem 0.75rem 0.3rem 1.25rem;
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  cursor: pointer;
  border-radius: 4px;
  user-select: none;
  transition: background var(--transition-fast);
}
.sidebar-tree .tree-label:hover { background: var(--color-bg-hover); }
.sidebar-tree .tree-label a {
  padding: 0;
  border-left: none;
  background: none;
}

/* Main content area */
.content {
  flex: 1;
  min-width: 0;
  max-width: var(--content-max-width);
  padding: 2rem 3rem;
}

/* Right TOC sidebar */
.toc {
  width: var(--toc-width);
  flex-shrink: 0;
  position: sticky;
  top: var(--nav-height);
  height: calc(100vh - var(--nav-height));
  overflow-y: auto;
  padding: 2rem 1rem 2rem 0;
  display: none; /* shown on wide screens */
}

.toc-sticky {
  position: sticky;
  top: calc(var(--nav-height) + 1rem);
}

.toc h3 {
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
  padding-left: 0.75rem;
}

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

.toc li a {
  display: block;
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  text-decoration: none;
  transition: color var(--transition-fast), border-color var(--transition-fast);
  border-left: 2px solid transparent;
  margin-left: -1px;
}
.toc li a:visited { color: var(--color-text-muted); }
.toc li a:hover {
  color: var(--color-text-primary);
  text-decoration: none;
}
.toc li a.active {
  color: var(--color-brand-primary);
  border-left-color: var(--color-brand-primary);
  font-weight: 600;
}

.toc li.toc-h3 a { padding-left: 1.5rem; }

/* ----- 5. Breadcrumbs ----- */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.breadcrumb a {
  color: var(--color-text-muted);
  text-decoration: none;
  transition: color var(--transition-fast);
}
.breadcrumb a:visited { color: var(--color-text-muted); }
.breadcrumb a:hover { color: var(--color-brand-content); }
.breadcrumb .separator {
  color: var(--color-text-muted);
  opacity: 0.5;
  font-size: 0.7rem;
}
.breadcrumb .current {
  color: var(--color-text-secondary);
  font-weight: 500;
}
.breadcrumb ol {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  list-style: none;
  margin: 0;
  padding: 0;
  flex-wrap: wrap;
}
.breadcrumb ol li::after {
  content: "/";
  margin-left: 0.4rem;
  color: var(--color-text-muted);
  opacity: 0.5;
  font-size: 0.7rem;
}
.breadcrumb ol li:last-child::after { content: none; }
.breadcrumb ol li:last-child {
  color: var(--color-text-secondary);
  font-weight: 500;
}

/* ----- 6. Typography ----- */
article h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 1rem;
  line-height: 1.25;
  color: var(--color-text-primary);
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--color-bg-border);
}

article h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-top: 2rem;
  margin-bottom: 0.75rem;
  line-height: 1.3;
  color: var(--color-text-primary);
}

article h3 {
  font-size: 1.2rem;
  font-weight: 600;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
  color: var(--color-text-primary);
}

article h4 {
  font-size: 1.05rem;
  font-weight: 600;
  margin-top: 1.25rem;
  margin-bottom: 0.4rem;
  color: var(--color-text-primary);
}

article p {
  margin-bottom: 0.75rem;
  color: var(--color-text-primary);
  line-height: 1.7;
}

article ul, article ol {
  margin-bottom: 0.75rem;
  padding-left: 1.5rem;
}
article li {
  margin-bottom: 0.3rem;
  line-height: 1.6;
  color: var(--color-text-primary);
}

article strong { font-weight: 600; }

/* ----- 7. Code Blocks ----- */
code, kbd, samp {
  font-family: var(--font-mono);
  font-size: var(--font-size-code);
}

/* Inline code */
code {
  background: var(--color-bg-secondary);
  padding: 0.15em 0.35em;
  border-radius: 4px;
  color: var(--color-text-primary);
  font-size: 0.85em;
}

/* Block code */
pre {
  position: relative;
  background: var(--color-bg-code);
  border-radius: 0.5rem;
  padding: 1rem 1.25rem;
  margin: 1rem 0;
  overflow-x: auto;
  line-height: 1.55;
  border: 1px solid var(--color-bg-border);
}
pre code {
  background: none;
  padding: 0;
  border-radius: 0;
  font-size: var(--font-size-code);
  color: var(--color-text-primary);
}

/* Code copy button */
.code-wrapper {
  position: relative;
}
.copy-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg-primary);
  border: 1px solid var(--color-bg-border);
  border-radius: 6px;
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--transition-fast), background var(--transition-fast);
  color: var(--color-text-muted);
  z-index: 2;
}
.code-wrapper:hover .copy-btn { opacity: 1; }
.copy-btn:hover {
  background: var(--color-bg-hover);
  color: var(--color-text-primary);
}
.copy-btn.copied {
  color: var(--color-tip);
  border-color: var(--color-tip);
}
.copy-btn svg { width: 14px; height: 14px; }

/* MAPLE input syntax highlighting */
pre .comment { color: #6a9955; font-style: italic; }
pre .keyword { color: #0070c1; font-weight: 600; }
pre .value { color: #a31515; }
pre .param { color: #795e26; }
pre .section { color: #267f99; font-weight: 600; }

/* ----- 8. Admonition Boxes ----- */
.admonition {
  margin: 1rem 0;
  padding: 0;
  border-radius: 0.4rem;
  border-left: 3px solid var(--color-note);
  overflow: hidden;
}
.admonition-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: var(--font-size-xs);
  font-weight: 600;
  background: rgba(0, 176, 255, 0.08);
}
.admonition-title svg { width: 16px; height: 16px; flex-shrink: 0; }
.admonition-body {
  padding: 0.5rem 1rem 0.75rem;
  font-size: var(--font-size-sm);
  line-height: 1.6;
}
.admonition-body p { margin-bottom: 0.4rem; }
.admonition-body p:last-child { margin-bottom: 0; }

/* Variants */
.admonition.note { border-left-color: var(--color-note); }
.admonition.note .admonition-title { background: rgba(0, 176, 255, 0.08); color: #0077b3; }

.admonition.tip { border-left-color: var(--color-tip); }
.admonition.tip .admonition-title { background: rgba(0, 200, 82, 0.08); color: #00873e; }

.admonition.warning { border-left-color: var(--color-warning); }
.admonition.warning .admonition-title { background: rgba(255, 145, 0, 0.08); color: #b36500; }

.admonition.danger { border-left-color: var(--color-danger); }
.admonition.danger .admonition-title { background: rgba(255, 82, 82, 0.08); color: #c62828; }

.admonition.important { border-left-color: var(--color-important); }
.admonition.important .admonition-title { background: rgba(0, 191, 165, 0.08); color: #00796b; }

/* ----- 9. Tables ----- */
article table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: var(--font-size-sm);
  border-radius: 0.4rem;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-bg-border);
}
article thead th {
  background: var(--color-bg-secondary);
  padding: 0.6rem 0.75rem;
  text-align: left;
  font-weight: 600;
  color: var(--color-text-primary);
  border-bottom: 2px solid var(--color-bg-border);
  font-size: var(--font-size-xs);
  white-space: nowrap;
}
article tbody td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--color-bg-border);
  color: var(--color-text-primary);
  vertical-align: top;
}
article tbody tr:last-child td { border-bottom: none; }
article tbody tr:nth-child(even) { background: rgba(0,0,0,0.015); }
article tbody tr:hover { background: var(--color-bg-hover); }

/* Responsive table wrapper */
.table-wrapper {
  overflow-x: auto;
  margin: 1rem 0;
  border-radius: 0.4rem;
}

/* ----- 10. Cards ----- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
  margin: 1.5rem 0;
}

.card {
  background: var(--color-bg-primary);
  border: 1px solid var(--color-bg-border);
  border-radius: 0.5rem;
  padding: 1.25rem;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.card:hover {
  border-color: var(--color-brand-content);
  box-shadow: var(--shadow-md);
}
.card h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  margin-top: 0;
  color: var(--color-text-primary);
}
.card h3 a {
  color: var(--color-text-primary);
  text-decoration: none;
}
.card h3 a:hover { color: var(--color-brand-content); }
.card p {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  line-height: 1.5;
  margin: 0;
}
.card .card-tag {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-brand-primary);
  margin-bottom: 0.5rem;
}

/* ----- 11. Page Navigation (prev/next) ----- */
.page-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-bg-border);
}
.page-nav a {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 1rem;
  font-size: var(--font-size-sm);
  color: var(--color-brand-content);
  text-decoration: none;
  border: 1px solid var(--color-bg-border);
  border-radius: 6px;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}
.page-nav a:visited { color: var(--color-brand-content); }
.page-nav a:hover {
  border-color: var(--color-brand-content);
  background: rgba(42, 90, 223, 0.04);
  text-decoration: none;
}
.page-nav .next { margin-left: auto; }

/* ----- 12. Footer ----- */
footer {
  border-top: 1px solid var(--color-bg-border);
  padding: 1.5rem 2rem;
  text-align: center;
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
  background: var(--color-bg-secondary);
}

/* ----- 13. Hero Section (Landing Page) ----- */
.hero {
  padding: 4rem 0 3rem;
  text-align: center;
}
.hero h1 {
  font-size: 3rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--color-text-primary);
  margin-bottom: 1rem;
  line-height: 1.15;
}
.hero .lead {
  font-size: 1.2rem;
  color: var(--color-text-secondary);
  max-width: 600px;
  margin: 0 auto 2rem;
  line-height: 1.6;
}

.hero-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 1.5rem;
  font-size: var(--font-size-sm);
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
}
.btn-primary {
  background: var(--color-brand-primary);
  color: #fff;
  border-color: var(--color-brand-primary);
}
.btn-primary:visited { color: #fff; }
.btn-primary:hover {
  background: #1e4fd6;
  border-color: #1e4fd6;
  text-decoration: none;
}
.btn-secondary {
  background: var(--color-bg-primary);
  color: var(--color-text-primary);
  border-color: var(--color-bg-border);
}
.btn-secondary:visited { color: var(--color-text-primary); }
.btn-secondary:hover {
  background: var(--color-bg-hover);
  border-color: var(--color-text-border);
  text-decoration: none;
}

/* Feature grid on landing page */
.features {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1.5rem;
  padding: 2rem 0;
}
.feature-card {
  padding: 1.5rem;
  border-radius: 0.5rem;
  border: 1px solid var(--color-bg-border);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.feature-card:hover {
  border-color: var(--color-brand-content);
  box-shadow: var(--shadow-md);
}
.feature-card .icon {
  font-size: 1.5rem;
  margin-bottom: 0.75rem;
}
.feature-card h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
  margin-top: 0;
}
.feature-card p {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  margin: 0;
  line-height: 1.5;
}

/* News section on landing page */
.news-sidebar {
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-bg-border);
  border-radius: 0.5rem;
  padding: 1.25rem;
}
.news-sidebar h2 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--color-text-primary);
}
.news-item {
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--color-bg-border);
}
.news-item:last-child { border-bottom: none; }
.news-item .date {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-bottom: 0.15rem;
}
.news-item p {
  font-size: var(--font-size-sm);
  color: var(--color-text-primary);
  margin: 0;
}

/* Landing page two-column layout */
.landing-grid {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 2rem;
  align-items: start;
}

/* ----- 14. Section Headers ----- */
.section-header {
  margin-bottom: 1.5rem;
}
.section-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-text-primary);
  margin-bottom: 0.3rem;
}
.section-header p {
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
}

/* ----- 15. Parameter Tables (documentation-specific) ----- */
.param-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-sm);
}
.param-table th {
  background: var(--color-bg-secondary);
  padding: 0.5rem 0.75rem;
  text-align: left;
  font-weight: 600;
  border-bottom: 2px solid var(--color-bg-border);
  font-size: var(--font-size-xs);
}
.param-table td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--color-bg-border);
  vertical-align: top;
}
.param-table code {
  font-size: 0.8rem;
  white-space: nowrap;
}

/* ----- 16. Tutorial/Category Grid ----- */
.tutorial-categories {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1.5rem;
  margin: 1.5rem 0;
}

.category-card {
  border: 1px solid var(--color-bg-border);
  border-radius: 0.5rem;
  overflow: hidden;
}
.category-card h3 {
  padding: 1rem 1.25rem 0.5rem;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-text-primary);
  margin: 0;
}
.category-card ul {
  list-style: none;
  padding: 0 1.25rem 1rem;
  margin: 0;
}
.category-card li {
  padding: 0.3rem 0;
}
.category-card li a {
  font-size: var(--font-size-sm);
  color: var(--color-brand-content);
  text-decoration: none;
}
.category-card li a:hover { text-decoration: underline; }

/* ----- 17. Installation Steps ----- */
.install-step {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  align-items: flex-start;
}
.install-step .step-num {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-brand-primary);
  color: #fff;
  border-radius: 50%;
  font-size: var(--font-size-sm);
  font-weight: 700;
}
.install-step .step-content {
  flex: 1;
}
.install-step .step-content h4 {
  margin-top: 0;
  margin-bottom: 0.3rem;
}

/* ----- 18. Mobile Navigation Overlay ----- */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 9;
}
.sidebar-overlay.active { display: block; }

/* ----- 19. Responsive Design ----- */

/* Wide screens: show TOC */
@media (min-width: 82em) {
  .toc { display: block; }
  html { font-size: 105%; }
}

/* Medium screens: hide TOC, adjust content */
@media (max-width: 82em) {
  .toc { display: none; }
  .content { max-width: none; padding: 2rem 2rem; }
}

/* Tablet: sidebar becomes drawer */
@media (max-width: 67em) {
  .sidebar {
    position: fixed;
    top: 0;
    left: -var(--sidebar-width);
    height: 100vh;
    transform: translateX(-100%);
    transition: transform var(--transition-normal);
    z-index: 50;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .top-nav .mobile-toggle { display: flex; }
  .content { padding: 1.5rem; }
  .landing-grid { grid-template-columns: 1fr; }
}

/* Mobile */
@media (max-width: 52em) {
  .top-nav ul { display: none; }
  .top-nav ul.open {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: var(--nav-height);
    left: 0;
    right: 0;
    background: var(--color-bg-primary);
    border-bottom: 1px solid var(--color-bg-border);
    padding: 0.5rem;
    box-shadow: var(--shadow-md);
  }
  .top-nav ul.open li a {
    padding: 0.6rem 1rem;
    width: 100%;
  }
  .top-nav .mobile-toggle { display: flex; }

  .hero h1 { font-size: 2rem; }
  .hero .lead { font-size: 1rem; }
  .page-hero h1 { font-size: 1.75rem; }

  .features { grid-template-columns: 1fr; }
  .card-grid { grid-template-columns: 1fr; }
  .tutorial-categories { grid-template-columns: 1fr; }

  .page-nav { flex-direction: column; }
  .page-nav .next { margin-left: 0; }

  article h1 { font-size: 1.5rem; }
  article h2 { font-size: 1.25rem; }
}

/* ----- 20. Dark Mode ----- */
@media (prefers-color-scheme: dark) {
  :root {
    --color-bg-primary: #131416;
    --color-bg-secondary: #1a1c1e;
    --color-bg-hover: #1e2124;
    --color-bg-code: #1e1e1e;
    --color-bg-border: #303335;
    --color-text-primary: #cfd0d0;
    --color-text-secondary: #9ca0a5;
    --color-text-muted: #6b6f76;
    --color-text-border: #555;
    --color-brand-primary: #5c8aff;
    --color-brand-content: #6b9bff;
    --color-brand-visited: #b27aeb;
  }

  .top-nav {
    background: rgba(19, 20, 22, 0.92);
  }

  .btn-primary {
    background: #4070e0;
    border-color: #4070e0;
  }
  .btn-primary:hover {
    background: #3060d0;
    border-color: #3060d0;
  }

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

  pre .comment { color: #6a9955; }
  pre .keyword { color: #569cd6; }
  pre .value { color: #ce9178; }
  pre .param { color: #dcdcaa; }
  pre .section { color: #4ec9b0; }

  img { opacity: 0.9; }
}

/* ----- 21. Print Styles ----- */
@media print {
  .top-nav, .sidebar, .toc, .page-nav, .copy-btn, .mobile-toggle { display: none !important; }
  .content { max-width: 100%; padding: 0; }
  .page-layout { display: block; }
  body { font-size: 12pt; }
}

/* ----- 22. Utility Classes ----- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

.text-center { text-align: center; }
.text-muted { color: var(--color-text-muted); }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
