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

@import url("home-fonts.css");

/* ----- 1. Design Tokens (CSS Variables) ----- */
:root {
  /* Brand */
  --color-brand-primary: #d32021;
  --color-brand-content: #d32021;
  --color-brand-visited: #8f1b16;
  --color-brand-soft: #fde8e6;
  --color-brand-glow: rgba(226,58,46,.18);

  /* Backgrounds */
  --color-bg-primary: #ffffff;
  --color-bg-secondary: #fafaf8;
  --color-bg-hover: #fde8e6;
  --color-bg-code: #f7f4ee;
  --color-bg-border: #e5e6ea;
  --color-bg-soft: #fff7f6;

  /* Text */
  --color-text-primary: #0c0c10;
  --color-text-secondary: #3b3e47;
  --color-text-muted: #6c707a;
  --color-text-border: #9aa0aa;

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

  /* Typography */
  --font-stack: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Source Serif 4", "IBM Plex Serif", Georgia, "Times New Roman", serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "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(12,12,16,.04), 0 4px 12px rgba(12,12,16,.05);
  --shadow-md: 0 12px 32px rgba(12,12,16,.08), 0 4px 12px rgba(12,12,16,.05);
  --shadow-lg: 0 24px 60px rgba(12,12,16,.12), 0 10px 24px rgba(12,12,16,.06);
}

/* ----- 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:
    radial-gradient(ellipse 56rem 30rem at 92% 0%, rgba(226,58,46,.055), transparent 72%),
    linear-gradient(180deg, #fff 0%, var(--color-bg-secondary) 100%);
  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.86);
  backdrop-filter: blur(18px) saturate(180%);
  -webkit-backdrop-filter: blur(18px) saturate(180%);
  border-bottom: 1px solid var(--color-bg-border);
}

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

.top-nav .brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  text-decoration: none;
  flex-shrink: 0;
}
.top-nav .brand img {
  width: 50px;
  height: 50px;
  object-fit: contain;
  border-radius: 0;
}
.top-nav .brand a {
  text-decoration: none;
  color: var(--color-text-primary);
  font-weight: 900;
  font-size: 1.9rem;
  letter-spacing: .04em;
}
.top-nav .brand a + a { font-family: var(--font-display); }
.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: inline-flex;
  align-items: center;
  height: 38px;
  padding: 0 0.95rem;
  color: var(--color-text-secondary);
  font-size: 0.94rem;
  font-weight: 500;
  text-decoration: none;
  border-radius: 8px;
  transition: background var(--transition-fast), color var(--transition-fast);
  white-space: nowrap;
  position: relative;
}
.top-nav li a:visited { color: var(--color-text-secondary); }
.top-nav li a:hover {
  background: transparent;
  color: var(--color-brand-primary);
  text-decoration: none;
}
.top-nav li a.active {
  color: var(--color-brand-primary);
  font-weight: 700;
}
.top-nav li a.active::after {
  content: "";
  position: absolute;
  left: 0.95rem;
  right: 0.95rem;
  bottom: -23px;
  height: 3px;
  border-radius: 2px;
  background: var(--color-brand-primary);
}

/* Mobile hamburger */
.top-nav .mobile-toggle {
  display: none;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,.72);
  border: 1px solid var(--color-bg-border);
  border-radius: 10px;
  cursor: pointer;
  padding: 0;
  color: var(--color-text-secondary);
  transition: border-color var(--transition-fast), background var(--transition-fast), color var(--transition-fast);
}
.top-nav .mobile-toggle:hover {
  background: #fff;
  border-color: var(--color-brand-primary);
  color: var(--color-brand-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: 4rem 2.5rem 2.25rem;
}
.page-hero h1 {
  font-family: var(--font-display);
  font-size: clamp(2.55rem, 5vw, 4.8rem);
  font-weight: 900;
  letter-spacing: -0.04em;
  color: var(--color-text-primary);
  margin-bottom: 0.75rem;
  line-height: 1.02;
}
.page-hero .subtitle {
  font-size: 1.125rem;
  color: var(--color-text-secondary);
  line-height: 1.75;
  max-width: 720px;
}

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

/* 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;
  display: block;
  width: fit-content;
  max-width: 100%;
  background: var(--color-bg-code);
  border-radius: 0.5rem;
  padding: 0.75rem 3rem 0.75rem 1rem;
  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;
  display: block;
  width: fit-content;
  max-width: 100%;
  margin: 1rem 0;
}
.code-wrapper pre {
  margin: 0;
}
.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; }

pre.maple-code {
  border-left: 4px solid var(--color-brand-primary);
}

pre.maple-code code {
  color: #272a31;
}

pre.maple-code .hash {
  color: var(--color-brand-primary);
  font-weight: 800;
}

pre.maple-code .directive {
  color: var(--color-brand-primary);
  font-weight: 800;
}

pre.maple-code .param {
  color: #7b3f00;
  font-weight: 700;
}

pre.maple-code .value {
  color: #8f1b16;
  background: rgba(211,32,33,.08);
  border-radius: 4px;
  padding: 0 .18em;
}

pre.maple-code .atom {
  color: #067a4a;
  font-weight: 800;
}

pre.maple-code .number {
  color: #3d4858;
}

pre.maple-code .filename {
  color: #6b3fc6;
  font-weight: 700;
}

/* Scan-line parameter groups: atom indices · step size · number of steps */
pre.maple-code .atom-idx  { color: #7b3f00; font-weight: 700; }
pre.maple-code .step-size { color: #267f99; font-weight: 700; }
pre.maple-code .n-steps   { color: #3d4858; font-weight: 600; }

/* ML family sections on About page */
.ml-family-section { margin: 1.5rem 0 2rem; scroll-margin-top: 96px; }
.ml-family-section + .ml-family-section { margin-top: 2.25rem; }
.ml-family-section > h3 { margin-bottom: 0.75rem; }

/* ----- 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: #007a38; }

.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;
}

/* Whole-card clickable variant */
a.card {
  display: block;
  text-decoration: none;
  color: inherit;
}
a.card:visited { color: inherit; }
a.card:hover {
  text-decoration: none;
}
a.card:hover h3 { color: var(--color-brand-content); }
.card-cta {
  color: var(--color-brand-content);
  font-size: var(--font-size-sm);
  font-weight: 500;
}
a.card:hover .card-cta { text-decoration: underline; }

/* ----- 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;
}

/* Clickable feature card variant */
a.feature-card {
  display: block;
  text-decoration: none;
  color: inherit;
}
a.feature-card:visited { color: inherit; }
a.feature-card:hover { text-decoration: none; }
a.feature-card:hover h3 { color: var(--color-brand-content); }

/* "More coming soon" placeholder variant */
.feature-card.coming-soon {
  border-style: dashed;
  background: var(--color-bg-secondary);
}
.feature-card.coming-soon h3,
.feature-card.coming-soon p,
.feature-card.coming-soon .icon {
  color: var(--color-text-muted);
}
.feature-card.coming-soon:hover {
  border-color: var(--color-text-border);
  box-shadow: none;
}

/* Platform overview figure at bottom of landing page */
.overview {
  margin-top: 3rem;
}
.overview-figure {
  margin: 1rem 0 0;
  text-align: center;
}
.overview-figure img {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  border-radius: 0.5rem;
  border: 1px solid var(--color-bg-border);
  background: var(--color-bg-primary);
}

/* 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-sidebar h2 a {
  color: inherit;
  text-decoration: none;
}
.news-sidebar h2 a:hover {
  color: var(--color-brand-content);
  text-decoration: none;
}
a.news-item,
.news-item {
  display: block;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--color-bg-border);
  color: inherit;
  text-decoration: none;
  transition: background var(--transition-fast);
}
a.news-item:visited { color: inherit; }
a.news-item:hover {
  background: var(--color-bg-hover);
  text-decoration: none;
}
a.news-item:hover p {
  color: var(--color-brand-content);
}
.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;
  transition: color var(--transition-fast);
}

/* 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; }
.sidebar-fab { display: none; }

@media (max-width: 67em) {
  .sidebar-fab {
    position: fixed;
    left: 0;
    top: 50vh;
    z-index: 60;
    width: 26px;
    height: 58px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--color-bg-border);
    border-left: 0;
    border-radius: 0 12px 12px 0;
    background: rgba(255,255,255,.72);
    color: var(--color-text-secondary);
    box-shadow: 0 4px 12px rgba(0,0,0,.08);
    cursor: pointer;
    opacity: .62;
    transform: translate(-10px, -50%);
    transition: opacity var(--transition-fast), background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
  }
  .sidebar-fab:hover,
  .sidebar-fab.active {
    opacity: 1;
    background: var(--color-bg-primary);
    color: var(--color-brand-primary);
    border-color: rgba(37,99,235,.35);
  }
  .sidebar-fab.active { transform: translate(calc(var(--sidebar-width) - 1px), -50%); }
  .sidebar-fab svg { width: 15px; height: 15px; }
}

/* ----- 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: 0;
    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: none; }
  .content { padding: 1.5rem; }
  .landing-grid { grid-template-columns: 1fr; }
}

/* Mobile */
@media (max-width: 52em) {
  .top-nav {
    height: auto;
    min-height: var(--nav-height);
  }
  .top-nav .container {
    min-height: var(--nav-height);
    height: auto;
    flex-wrap: wrap;
    align-content: center;
  }
  .top-nav .brand { order: 1; }
  .top-nav .mobile-toggle {
    order: 2;
    display: flex;
    margin-left: auto;
  }
  .top-nav nav {
    order: 3;
    flex: 0 0 100%;
    margin-left: 0;
  }
  .top-nav ul { display: none; }
  .top-nav ul.open {
    display: flex;
    flex-direction: column;
    position: static;
    background: transparent;
    border-top: 1px solid var(--color-bg-border);
    border-bottom: 0;
    padding: 0.5rem 0 0.8rem;
    box-shadow: none;
  }
  .top-nav ul.open li a {
    padding: 0.6rem 1rem;
    width: 100%;
    text-align: center;
  }

  .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. Homepage-aligned Aesthetic Pass ----- */
/* Aesthetic direction: Jiahao Xie. Preserve content; tune only the shared visual system. */
.page-layout {
  background:
    radial-gradient(ellipse 42rem 24rem at 95% 2%, rgba(226,58,46,.055), transparent 72%),
    linear-gradient(180deg, #fff 0%, var(--color-bg-secondary) 100%);
}

.content article,
.page-body article,
.main-content {
  background: rgba(255,255,255,.88);
  border: 1px solid var(--color-bg-border);
  border-radius: 24px;
  box-shadow: var(--shadow-sm);
}

.content article {
  padding: 2.4rem;
}

.page-body article,
.main-content {
  padding: 2.6rem;
}

.content article > :last-child,
.page-body article > :last-child,
.main-content > :last-child { margin-bottom: 0; }

.welcome-section,
.new-section {
  margin-bottom: 2rem;
}

.welcome-section h1,
article h1,
article h2,
.section-header h2 {
  font-family: var(--font-display);
  font-weight: 900;
  letter-spacing: -.035em;
}

.welcome-section h1,
article h1 {
  font-size: clamp(2rem, 3.5vw, 3.2rem);
  border-bottom: 1px solid var(--color-bg-border);
  position: relative;
}

.welcome-section h1::after,
article h1::after,
.section-header h2::after {
  content: "";
  display: block;
  width: 3.1rem;
  height: 3px;
  margin-top: .85rem;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--color-brand-primary), rgba(226,58,46,.26));
}

article h2 {
  font-size: clamp(1.55rem, 2vw, 2.05rem);
}

article h3,
article h4,
.card h3 {
  letter-spacing: -.015em;
}

.tagline,
.page-hero .subtitle,
.section-header p,
article p,
article li {
  color: var(--color-text-secondary);
}

.sidebar {
  background:
    radial-gradient(ellipse 18rem 18rem at 88% 0%, rgba(226,58,46,.08), transparent 74%),
    rgba(250,250,248,.95);
}

.sidebar-brand {
  padding-top: .2rem;
}

.sidebar-brand img {
  width: 42px;
  height: 42px;
  border-radius: 0;
}

.sidebar-brand span {
  font-size: 1rem;
  color: var(--color-text-primary);
}

.sidebar-tree .tree-section {
  border-radius: 10px;
  color: var(--color-text-primary);
  font-weight: 800;
}

.sidebar-tree .tree-section:hover,
.sidebar-tree .tree-label:hover {
  background: rgba(211,32,33,.07);
}

.sidebar-tree a,
.sidebar-tree .tree-label {
  border-radius: 10px;
}

.sidebar-tree a:hover {
  background: rgba(211,32,33,.06);
  color: var(--color-brand-primary);
}

.sidebar-tree a.active {
  color: var(--color-brand-primary);
  border-left-color: var(--color-brand-primary);
  background: linear-gradient(90deg, rgba(211,32,33,.12), rgba(211,32,33,.035));
}

.breadcrumb a:hover,
.card h3 a:hover,
a.card:hover h3,
.category-card li a:hover,
.news-sidebar h2 a:hover,
a.news-item:hover p {
  color: var(--color-brand-primary);
}

code {
  background: var(--color-brand-soft);
  color: #7a1712;
}

pre {
  background:
    linear-gradient(180deg, rgba(255,255,255,.72), rgba(247,244,238,.95)),
    var(--color-bg-code);
  border-color: var(--color-bg-border);
  box-shadow: var(--shadow-sm);
}

pre.maple-code {
  background:
    radial-gradient(ellipse 34rem 18rem at 12% 0%, rgba(226,58,46,.08), transparent 68%),
    linear-gradient(180deg, rgba(255,255,255,.9), rgba(247,244,238,.98));
  border-color: rgba(211,32,33,.22);
  box-shadow: 0 10px 28px rgba(12,12,16,.08);
}

pre .keyword { color: var(--color-brand-primary); }
pre .section { color: #b02121; }

.admonition {
  border-radius: 16px;
  border-left-width: 4px;
  background: rgba(255,255,255,.82);
  box-shadow: var(--shadow-sm);
}

.admonition-title {
  gap: .6rem;
  padding: .8rem 1.35rem .75rem 1.55rem;
  line-height: 1.35;
  margin: 0;
}

.admonition-body {
  padding: .95rem 1.35rem 1.15rem 1.55rem;
  line-height: 1.7;
}

.admonition > p:not(.admonition-title),
.admonition > ul,
.admonition > ol {
  margin: 0;
  padding: .95rem 1.35rem 1.15rem 1.55rem;
  line-height: 1.7;
}

.admonition > p:not(.admonition-title) + p:not(.admonition-title),
.admonition > ul + p:not(.admonition-title),
.admonition > ol + p:not(.admonition-title) {
  padding-top: 0;
}

.admonition.note,
.admonition.important { border-left-color: var(--color-brand-primary); }
.admonition.note .admonition-title,
.admonition.important .admonition-title {
  background: rgba(211,32,33,.08);
  color: var(--color-brand-primary);
}

article table,
.card,
.category-card,
.feature-card,
.news-sidebar,
.param-table {
  background: rgba(255,255,255,.86);
  border-color: var(--color-bg-border);
  border-radius: 18px;
  box-shadow: var(--shadow-sm);
}

article thead th,
.param-table th {
  background: linear-gradient(180deg, #fff7f6, var(--color-bg-secondary));
}

article tbody tr:nth-child(even) { background: rgba(211,32,33,.018); }
article tbody tr:hover { background: rgba(211,32,33,.055); }

.card {
  transition: transform var(--transition-normal), border-color var(--transition-normal), box-shadow var(--transition-normal);
}

.card:hover,
.feature-card:hover {
  border-color: rgba(211,32,33,.34);
  box-shadow: var(--shadow-md);
  transform: translateY(-3px);
}

.card .card-tag {
  color: var(--color-brand-primary);
  font-family: var(--font-mono);
  font-size: .68rem;
  letter-spacing: .08em;
}

.btn {
  border-radius: 6px;
  border-width: 1.5px;
  font-weight: 800;
}

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

.btn-primary:hover {
  background: var(--color-brand-primary);
  border-color: var(--color-brand-primary);
  box-shadow: 0 14px 32px rgba(226,58,46,.28);
}

.btn-secondary:hover,
.page-nav a:hover {
  background: rgba(211,32,33,.05);
  border-color: rgba(211,32,33,.34);
  color: var(--color-brand-primary);
}

.page-nav a {
  border-radius: 12px;
  background: rgba(255,255,255,.72);
}

.toc ul {
  border-left-color: var(--color-bg-border);
}

.toc li a.active {
  color: var(--color-brand-primary);
  border-left-color: var(--color-brand-primary);
}

footer {
  background:
    radial-gradient(ellipse 28rem 12rem at 50% -10%, rgba(226,58,46,.08), transparent 70%),
    var(--color-bg-secondary);
}

.sidebar-fab {
  color: var(--color-brand-primary);
}

@media (max-width: 68.75em) {
  :root { --nav-height: 70px; }

  .top-nav {
    height: auto;
    min-height: var(--nav-height);
  }

  .top-nav .container {
    min-height: var(--nav-height);
    height: auto;
    flex-wrap: wrap;
    align-content: center;
    padding: 0 22px;
    column-gap: .8rem;
  }

  .top-nav .brand img {
    width: 44px;
    height: 44px;
  }

  .top-nav .brand a {
    font-size: 1.6rem;
  }

  .top-nav .brand { order: 1; }
  .top-nav .mobile-toggle {
    order: 2;
    display: flex;
    margin-left: auto;
  }

  .top-nav nav {
    order: 3;
    flex: 0 0 100%;
    margin-left: 0;
  }

  .top-nav ul { display: none; }
  .top-nav ul.open {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    position: static;
    background: transparent;
    border-top: 1px solid var(--color-bg-border);
    border-bottom: 0;
    padding: .5rem 0 .8rem;
    box-shadow: none;
  }

  .top-nav ul.open li a {
    width: 100%;
    justify-content: center;
    padding: 0.6rem 1rem;
    text-align: center;
  }

  .top-nav li a.active::after { display: none; }
}

@media (max-width: 52em) {
  .page-hero,
  .page-body {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .content {
    padding: 1rem;
  }

  .content article,
  .page-body article,
  .main-content {
    padding: 1.25rem;
    border-radius: 18px;
  }
}

/* ----- 20. Dark Mode ----- */
@media (prefers-color-scheme: dark) {
  :root {
    --color-bg-primary: #141414;
    --color-bg-secondary: #1d1b1a;
    --color-bg-hover: #2a201f;
    --color-bg-code: #211f1d;
    --color-bg-border: #37302e;
    --color-bg-soft: #261b1a;
    --color-text-primary: #f1eeee;
    --color-text-secondary: #d2cccc;
    --color-text-muted: #a8a1a0;
    --color-text-border: #6f6765;
    --color-brand-primary: #f15a4f;
    --color-brand-content: #f15a4f;
    --color-brand-visited: #ff9a92;
    --color-brand-soft: rgba(241,90,79,.16);
  }

  .top-nav {
    background: rgba(20, 20, 20, 0.9);
  }

  .btn-primary {
    background: var(--color-brand-primary);
    border-color: var(--color-brand-primary);
  }
  .btn-primary:hover {
    background: #d83c34;
    border-color: #d83c34;
  }

  .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. Figure / Chart Images ----- */
figure.doc-figure {
  margin: 1.75rem auto;
  text-align: center;
}

figure.doc-figure img {
  max-width: 100%;
  height: auto;
  margin-left: auto;
  margin-right: auto;
  border: 1px solid var(--color-bg-border);
  border-radius: 4px;
  background: var(--color-bg-secondary);
}

figure.doc-figure figcaption {
  margin-top: 0.4rem;
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

.figure-row {
  display: flex;
  gap: 1.25rem;
  justify-content: center;
  flex-wrap: wrap;
  margin: 1.75rem 0;
}

.figure-row figure.doc-figure {
  margin: 0;
  flex: 1 1 260px;
  max-width: 400px;
}

/* ----- 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; }
