/* ===================================================================
   文档中心 — 设计系统
   明亮现代 SaaS 文档风格 · 亮色/暗色双主题 · WCAG AA
   =================================================================== */

/* -------------------------------------------------------------------
   1. Design Tokens — Light Theme (default)
   ------------------------------------------------------------------- */
:root {
  /* ── Color Palette ── */
  --color-bg:              #fafbfc;
  --color-bg-secondary:    #f0f2f5;
  --color-bg-tertiary:     #e4e7eb;
  --color-surface:         #ffffff;
  --color-surface-hover:   #f7f8fa;
  --color-surface-raised:  #ffffff;

  --color-border:          #e2e5e9;
  --color-border-light:    #eef0f3;
  --color-border-strong:   #d1d5db;

  --color-text-primary:    #0f172a;
  --color-text-secondary:  #475569;
  --color-text-tertiary:   #94a3b8;
  --color-text-inverse:    #f8fafc;

  /* ── Accent ── */
  --color-accent:          #2563eb;
  --color-accent-hover:    #1d4ed8;
  --color-accent-soft:     #eff6ff;
  --color-accent-border:   #bfdbfe;
  --color-accent-text:     #1e40af;

  /* ── Semantic ── */
  --color-success:         #059669;
  --color-success-soft:    #ecfdf5;
  --color-warning:         #d97706;
  --color-warning-soft:    #fffbeb;
  --color-error:           #dc2626;
  --color-error-soft:      #fef2f2;
  --color-info:            #2563eb;
  --color-info-soft:       #eff6ff;

  /* ── Sidebar ── */
  --sidebar-bg:            #f8fafc;
  --sidebar-border:        #e2e5e9;
  --sidebar-hover:         #f0f2f5;
  --sidebar-active:        #eff6ff;
  --sidebar-text:          #475569;
  --sidebar-text-active:   #2563eb;
  --sidebar-icon:          #94a3b8;
  --sidebar-accent-strip:  #2563eb;

  /* ── Code ── */
  --code-bg:               #f1f5f9;
  --code-text:             #e2e8f0;
  --code-block-bg:         #0f172a;
  --code-block-text:       #e2e8f0;
  --code-border:           #e2e5e9;

  /* ── Typography ── */
  --font-sans:             "Inter", "SF Pro Text", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  --font-mono:             "JetBrains Mono", "Cascadia Code", "Fira Code", "SF Mono", Consolas, monospace;

  --text-xs:               0.75rem;    /* 12px */
  --text-sm:               0.8125rem;  /* 13px */
  --text-base:             0.9375rem;  /* 15px */
  --text-lg:               1.0625rem;  /* 17px */
  --text-xl:               1.25rem;    /* 20px */
  --text-2xl:              1.5rem;     /* 24px */
  --text-3xl:              1.875rem;   /* 30px */
  --text-4xl:              2.25rem;    /* 36px */

  --leading-tight:         1.25;
  --leading-snug:          1.375;
  --leading-normal:        1.6;
  --leading-relaxed:       1.75;

  --weight-normal:         400;
  --weight-medium:         500;
  --weight-semibold:       600;
  --weight-bold:           700;

  --tracking-tight:        -0.02em;
  --tracking-normal:       0;
  --tracking-wide:         0.02em;

  /* ── Spacing (4px base) ── */
  --space-1:  0.25rem;   /*  4px */
  --space-2:  0.5rem;    /*  8px */
  --space-3:  0.75rem;   /* 12px */
  --space-4:  1rem;      /* 16px */
  --space-5:  1.25rem;   /* 20px */
  --space-6:  1.5rem;    /* 24px */
  --space-8:  2rem;      /* 32px */
  --space-10: 2.5rem;    /* 40px */
  --space-12: 3rem;      /* 48px */
  --space-16: 4rem;      /* 64px */
  --space-20: 5rem;      /* 80px */

  /* ── Sizing ── */
  --sidebar-width:        272px;
  --sidebar-collapsed:    0px;
  --content-max:          48rem;    /* ~768px, optimal reading */
  --content-wide:         56rem;    /* ~896px */
  --toc-width:            224px;
  --header-height:        0px;

  /* ── Radii ── */
  --radius-sm:            0.375rem;  /* 6px */
  --radius-md:            0.5rem;    /* 8px */
  --radius-lg:            0.75rem;   /* 12px */
  --radius-xl:            1rem;      /* 16px */
  --radius-full:           9999px;

  /* ── Shadows ── */
  --shadow-xs:            0 1px 2px 0 rgb(0 0 0 / 0.03);
  --shadow-sm:            0 1px 3px 0 rgb(0 0 0 / 0.04), 0 1px 2px -1px rgb(0 0 0 / 0.03);
  --shadow-md:            0 4px 6px -1px rgb(0 0 0 / 0.05), 0 2px 4px -2px rgb(0 0 0 / 0.04);
  --shadow-lg:            0 10px 15px -3px rgb(0 0 0 / 0.06), 0 4px 6px -4px rgb(0 0 0 / 0.04);
  --shadow-xl:            0 20px 25px -5px rgb(0 0 0 / 0.08), 0 8px 10px -6px rgb(0 0 0 / 0.04);

  /* ── Transitions ── */
  --ease-out-expo:        cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out-quart:       cubic-bezier(0.25, 1, 0.5, 1);
  --ease-in-out:          cubic-bezier(0.65, 0, 0.35, 1);
  --duration-fast:        150ms;
  --duration-normal:      250ms;
  --duration-slow:        400ms;

  /* ── Progress bar ── */
  --progress: 0%;
}

/* -------------------------------------------------------------------
   2. Dark Theme
   ------------------------------------------------------------------- */
[data-theme="dark"] {
  --color-bg:              #0c0e14;
  --color-bg-secondary:    #141820;
  --color-bg-tertiary:     #1c2029;
  --color-surface:         #161922;
  --color-surface-hover:   #1c2029;
  --color-surface-raised:  #1e2230;

  --color-border:          #262a35;
  --color-border-light:    #1e2230;
  --color-border-strong:   #323845;

  --color-text-primary:    #e8ecf2;
  --color-text-secondary:  #9ca3af;
  --color-text-tertiary:   #6b7280;
  --color-text-inverse:    #0f172a;

  --color-accent:          #60a5fa;
  --color-accent-hover:    #93bbfd;
  --color-accent-soft:     #1e293b;
  --color-accent-border:   #1e3a5f;
  --color-accent-text:     #93bbfd;

  --color-success:         #34d399;
  --color-success-soft:    #022c22;
  --color-warning:         #fbbf24;
  --color-warning-soft:    #451a03;
  --color-error:           #f87171;
  --color-error-soft:      #450a0a;
  --color-info:            #60a5fa;
  --color-info-soft:       #172554;

  --sidebar-bg:            #0f1119;
  --sidebar-border:        #1e2230;
  --sidebar-hover:         #161922;
  --sidebar-active:        #1e293b;
  --sidebar-text:          #9ca3af;
  --sidebar-text-active:   #60a5fa;
  --sidebar-icon:          #6b7280;
  --sidebar-accent-strip:  #60a5fa;

  --code-bg:               #1e2230;
  --code-text:             #e2e8f0;
  --code-block-bg:         #0b0d14;
  --code-block-text:       #e2e8f0;
  --code-border:           #262a35;

  --shadow-xs:            0 1px 2px 0 rgb(0 0 0 / 0.2);
  --shadow-sm:            0 1px 3px 0 rgb(0 0 0 / 0.25);
  --shadow-md:            0 4px 6px -1px rgb(0 0 0 / 0.3);
  --shadow-lg:            0 10px 15px -3px rgb(0 0 0 / 0.35);
  --shadow-xl:            0 20px 25px -5px rgb(0 0 0 / 0.4);
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  color-scheme: light dark;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--color-text-primary);
  background: var(--color-bg);
  display: flex;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background var(--duration-normal) var(--ease-out-quart),
              color var(--duration-normal) var(--ease-out-quart);
}

a {
  color: var(--color-accent);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease-out-quart);
}
a:hover { color: var(--color-accent-hover); }

img, svg, video {
  display: block;
  max-width: 100%;
}

::selection {
  background: var(--color-accent-soft);
  color: var(--color-accent-text);
}

/* -------------------------------------------------------------------
   4. Focus Styles
   ------------------------------------------------------------------- */
:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* -------------------------------------------------------------------
   5. Progress Bar
   ------------------------------------------------------------------- */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  background: var(--color-accent);
  z-index: 1000;
  width: var(--progress);
  transition: width 100ms linear;
  pointer-events: none;
}

/* -------------------------------------------------------------------
   6. Theme Toggle
   ------------------------------------------------------------------- */
.theme-toggle {
  position: absolute;
  bottom: var(--space-4);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  background: var(--sidebar-hover);
  border: 1px solid var(--sidebar-border);
  border-radius: var(--radius-full);
  padding: var(--space-1);
  cursor: pointer;
  width: fit-content;
  transition: all var(--duration-fast) var(--ease-out-quart);
}

.theme-toggle:hover {
  background: var(--sidebar-active);
  border-color: var(--color-accent-border);
}

.theme-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--sidebar-icon);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out-quart);
  font-size: 1rem;
  line-height: 1;
}

.theme-toggle-btn.active {
  background: var(--color-surface);
  color: var(--sidebar-text-active);
  box-shadow: var(--shadow-xs);
}

.theme-toggle-btn:hover {
  color: var(--sidebar-text);
}

/* -------------------------------------------------------------------
   7. Sidebar
   ------------------------------------------------------------------- */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  height: 100vh;
  position: sticky;
  top: 0;
  left: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow: hidden;
  transition: background var(--duration-normal) var(--ease-out-quart),
              border-color var(--duration-normal) var(--ease-out-quart);
}

.sidebar-header {
  padding: var(--space-5) var(--space-5) var(--space-4);
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.sidebar-header h2 {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-tight);
}

.sidebar-header a {
  color: var(--color-text-primary);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.sidebar-header a:hover {
  color: var(--color-accent);
  text-decoration: none;
}

.sidebar-header .logo-icon {
  font-size: 1.25rem;
  opacity: 0.85;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-3) 0;
  /* hide scrollbar */
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
}

.sidebar-nav:hover {
  scrollbar-color: var(--color-border-strong) transparent;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb {
  background: transparent;
  border-radius: 2px;
}
.sidebar-nav:hover::-webkit-scrollbar-thumb {
  background: var(--color-border-strong);
}

.sidebar-footer {
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--sidebar-border);
  flex-shrink: 0;
  position: relative;
  padding-bottom: calc(var(--space-3) + 56px); /* room for theme toggle */
}

.sidebar-footer small {
  color: var(--color-text-tertiary);
  font-size: var(--text-xs);
  display: block;
  text-align: center;
}

/* ── Tree Navigation ── */
.tree-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.tree-root {
  /* top-level container */
}

.tree-item {
  margin: 0;
  position: relative;
}

/* Hide default details marker */
.tree-item summary {
  list-style: none;
  cursor: pointer;
  display: block;
}

.tree-item summary::-webkit-details-marker { display: none; }
.tree-item summary::marker { display: none; content: none; }

/* Indentation via padding */
.tree-list .tree-list {
  /* nested children */
}

.tree-item.level-0 > details > .tree-label,
.tree-item.tree-file.level-0 {
  padding-left: var(--space-4);
}
.tree-item.level-1 > details > .tree-label,
.tree-item.tree-file.level-1 {
  padding-left: calc(var(--space-4) + var(--space-6));
}
.tree-item.level-2 > details > .tree-label,
.tree-item.tree-file.level-2 {
  padding-left: calc(var(--space-4) + var(--space-12));
}
.tree-item.level-3 > details > .tree-label,
.tree-item.tree-file.level-3 {
  padding-left: calc(var(--space-4) + var(--space-16));
}

/* Tree labels & files */
.tree-label,
.tree-file {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 5px var(--space-3);
  padding-right: var(--space-4);
  font-size: var(--text-sm);
  line-height: var(--leading-snug);
  border-left: 2px solid transparent;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin: 1px var(--space-2) 1px 0;
  transition: all var(--duration-fast) var(--ease-out-quart);
  color: var(--sidebar-text);
  cursor: pointer;
  position: relative;
}

.tree-label {
  font-weight: var(--weight-medium);
}

/* Level-specific border accents */
.tree-item.level-0 > .tree-label,
.tree-file.level-0 {
  border-left-color: var(--sidebar-accent-strip);
  font-weight: var(--weight-semibold);
  font-size: var(--text-base);
}
.tree-item.level-1 > .tree-label,
.tree-file.level-1 {
  border-left-color: transparent;
}
.tree-item.level-2 > .tree-label,
.tree-file.level-2 {
  border-left-color: transparent;
}

.tree-label:hover,
.tree-file:hover {
  background: var(--sidebar-hover);
  color: var(--color-text-primary);
}

.tree-label a,
.tree-file a {
  color: inherit;
  text-decoration: none;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: inherit;
  font-weight: inherit;
}

.tree-label a:hover,
.tree-file a:hover {
  color: var(--color-accent);
}

/* Chevron indicator for folders */
.tree-label {
  position: relative;
}

/* Simpler: use a subtle indicator */
.folder-icon,
.file-icon {
  display: none; /* replaced by CSS mask */
}

/* Active/current page highlight */
.tree-label.active,
.tree-file.active {
  background: var(--sidebar-active);
  color: var(--sidebar-text-active);
  border-left-color: var(--sidebar-accent-strip);
}

.tree-label.active a,
.tree-file.active a {
  color: var(--sidebar-text-active);
}

/* Focus within tree */
.tree-label a:focus-visible,
.tree-file a:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: -2px;
  border-radius: var(--radius-sm);
}

/* -------------------------------------------------------------------
   8. Main Content Area
   ------------------------------------------------------------------- */
.main-content {
  flex: 1;
  min-width: 0;
  padding: var(--space-10) var(--space-8) var(--space-16);
  transition: padding var(--duration-normal) var(--ease-out-quart);
}

/* -------------------------------------------------------------------
   9. Breadcrumbs
   ------------------------------------------------------------------- */
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  font-size: var(--text-sm);
  color: var(--color-text-tertiary);
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--color-border-light);
}

.breadcrumbs a {
  color: var(--color-text-secondary);
  font-weight: var(--weight-medium);
  transition: color var(--duration-fast) var(--ease-out-quart);
}

.breadcrumbs a:hover {
  color: var(--color-accent);
  text-decoration: none;
}

.breadcrumb-sep {
  color: var(--color-border-strong);
  user-select: none;
  font-size: var(--text-xs);
}

.breadcrumb-current {
  color: var(--color-text-primary);
  font-weight: var(--weight-semibold);
}

/* -------------------------------------------------------------------
   10. Directory View (Card Grid)
   ------------------------------------------------------------------- */
.dir-view {
  animation: fadeInUp var(--duration-slow) var(--ease-out-expo);
}

.dir-title {
  font-size: var(--text-3xl);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-tight);
  margin-bottom: var(--space-3);
  color: var(--color-text-primary);
}

.dir-subtitle {
  font-size: var(--text-base);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-8);
  max-width: 40rem;
}

.dir-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-4);
}

.dir-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-5);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: var(--color-text-primary);
  transition: all var(--duration-normal) var(--ease-out-quart);
  position: relative;
  overflow: hidden;
}

.dir-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--color-accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--duration-normal) var(--ease-out-expo);
}

.dir-card:hover {
  border-color: var(--color-accent-border);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  color: var(--color-text-primary);
  text-decoration: none;
}

.dir-card:hover::before {
  transform: scaleX(1);
}

.dir-card-icon {
  font-size: 1.75rem;
  line-height: 1;
  opacity: 0.8;
  transition: transform var(--duration-normal) var(--ease-out-quart);
}

.dir-card:hover .dir-card-icon {
  transform: scale(1.1);
}

.dir-card-name {
  font-weight: var(--weight-semibold);
  font-size: var(--text-base);
  line-height: var(--leading-snug);
  color: var(--color-text-primary);
  word-break: break-word;
}

.dir-card-badge {
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--color-text-tertiary);
  background: var(--color-bg-secondary);
  padding: 2px 10px;
  border-radius: var(--radius-full);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
}

.dir-card-folder .dir-card-badge {
  background: var(--color-accent-soft);
  color: var(--color-accent-text);
}

.dir-card-file .dir-card-badge {
  background: var(--color-success-soft);
  color: var(--color-success);
}

/* Empty state */
.empty-dir {
  text-align: center;
  padding: var(--space-16) var(--space-8);
  color: var(--color-text-tertiary);
  animation: fadeInUp var(--duration-slow) var(--ease-out-expo);
}

.empty-dir .empty-icon {
  font-size: 3rem;
  margin-bottom: var(--space-4);
  opacity: 0.4;
}

.empty-dir p {
  font-size: var(--text-lg);
  font-weight: var(--weight-medium);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-2);
}

.empty-dir small {
  font-size: var(--text-sm);
  color: var(--color-text-tertiary);
}

/* -------------------------------------------------------------------
   11. Document Layout
   ------------------------------------------------------------------- */
.doc-layout {
  display: flex;
  gap: var(--space-8);
  align-items: flex-start;
  position: relative;
}

.doc-article {
  flex: 1;
  min-width: 0;
  animation: fadeInUp var(--duration-slow) var(--ease-out-expo);
}

/* ── Table of Contents ── */
.doc-toc {
  width: var(--toc-width);
  min-width: var(--toc-width);
  position: sticky;
  top: var(--space-8);
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  font-size: var(--text-sm);
  max-height: calc(100vh - var(--space-16));
  overflow-y: auto;
  box-shadow: var(--shadow-xs);
}

.doc-toc h3 {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-tertiary);
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--color-border-light);
}

.doc-toc ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.doc-toc li {
  margin: 1px 0;
  line-height: var(--leading-snug);
}

.doc-toc li ul {
  padding-left: var(--space-3);
  border-left: 1px solid var(--color-border-light);
  margin-left: var(--space-2);
}

.doc-toc a {
  display: block;
  color: var(--color-text-secondary);
  font-size: var(--text-xs);
  padding: 3px var(--space-2);
  border-radius: var(--radius-sm);
  transition: all var(--duration-fast) var(--ease-out-quart);
  border-left: 2px solid transparent;
}

.doc-toc a:hover {
  color: var(--color-accent);
  background: var(--color-accent-soft);
  text-decoration: none;
}

.doc-toc a.active-toc {
  color: var(--color-accent);
  background: var(--color-accent-soft);
  border-left-color: var(--color-accent);
  font-weight: var(--weight-medium);
}

/* -------------------------------------------------------------------
   12. Markdown Content Styles
   ------------------------------------------------------------------- */
.markdown-body {
  line-height: var(--leading-relaxed);
  font-size: var(--text-base);
  color: var(--color-text-primary);
  word-wrap: break-word;
}

/* ── Headings ── */
.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
  color: var(--color-text-primary);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-tight);
  line-height: var(--leading-tight);
  scroll-margin-top: var(--space-8);
}

.markdown-body h1 {
  font-size: var(--text-4xl);
  margin: 0 0 var(--space-5);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--color-border);
  letter-spacing: -0.025em;
}

.markdown-body h2 {
  font-size: var(--text-2xl);
  margin: var(--space-10) 0 var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--color-border-light);
}

.markdown-body h3 {
  font-size: var(--text-xl);
  margin: var(--space-8) 0 var(--space-3);
}

.markdown-body h4 {
  font-size: var(--text-lg);
  margin: var(--space-6) 0 var(--space-2);
}

.markdown-body h5,
.markdown-body h6 {
  font-size: var(--text-base);
  margin: var(--space-5) 0 var(--space-2);
  color: var(--color-text-secondary);
}

/* ── Paragraphs & Lists ── */
.markdown-body p {
  margin: 0 0 var(--space-4);
}

.markdown-body strong {
  font-weight: var(--weight-semibold);
  color: var(--color-text-primary);
}

.markdown-body ul,
.markdown-body ol {
  margin: 0 0 var(--space-4);
  padding-left: var(--space-6);
}

.markdown-body li {
  margin: var(--space-1) 0;
  padding-left: var(--space-1);
}

.markdown-body li > ul,
.markdown-body li > ol {
  margin-bottom: 0;
}

.markdown-body ul {
  list-style-type: disc;
}

.markdown-body ul ul {
  list-style-type: circle;
}

.markdown-body ul ul ul {
  list-style-type: square;
}

/* ── Blockquotes ── */
.markdown-body blockquote {
  margin: 0 0 var(--space-5);
  padding: var(--space-3) var(--space-5);
  border-left: 3px solid var(--color-accent);
  background: var(--color-accent-soft);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  color: var(--color-text-secondary);
  font-style: italic;
}

.markdown-body blockquote p:last-child {
  margin-bottom: 0;
}

.markdown-body blockquote strong {
  color: var(--color-accent-text);
}

/* ── Inline Code ── */
.markdown-body code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  font-weight: var(--weight-medium);
  background: var(--code-bg);
  color: var(--color-accent-text);
  padding: 0.15em 0.4em;
  border-radius: var(--radius-sm);
  border: 1px solid var(--code-border);
  white-space: nowrap;
}

/* ── Code Blocks ── */
.markdown-body pre {
  background: var(--code-block-bg);
  color: var(--code-block-text);
  padding: var(--space-5);
  border-radius: var(--radius-lg);
  overflow-x: auto;
  margin: 0 0 var(--space-5);
  font-size: 0.85rem;
  line-height: 1.65;
  position: relative;
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
}

.markdown-body pre code {
  background: none;
  padding: 0;
  border: none;
  color: inherit;
  font-size: inherit;
  font-weight: var(--weight-normal);
  white-space: pre;
  display: block;
}

/* Copy button */
.code-block-wrapper {
  position: relative;
  margin: 0 0 var(--space-5);
}

.code-block-wrapper pre {
  margin: 0;
}

.copy-btn {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.5);
  cursor: pointer;
  font-size: 0.85rem;
  transition: all var(--duration-fast) var(--ease-out-quart);
  opacity: 0;
  backdrop-filter: blur(4px);
}

.code-block-wrapper:hover .copy-btn,
.copy-btn:focus-visible {
  opacity: 1;
}

.copy-btn:hover {
  background: rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.9);
  border-color: rgba(255,255,255,0.2);
}

.copy-btn.copied {
  background: var(--color-success);
  border-color: var(--color-success);
  color: white;
}

/* ── Tables ── */
.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 var(--space-5);
  font-size: var(--text-sm);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--color-border);
}

.markdown-body th {
  background: var(--color-bg-secondary);
  font-weight: var(--weight-semibold);
  color: var(--color-text-primary);
  text-align: left;
  padding: var(--space-3) var(--space-4);
  border-bottom: 2px solid var(--color-border);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
}

.markdown-body td {
  padding: var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--color-border-light);
  vertical-align: top;
}

.markdown-body tr:last-child td {
  border-bottom: none;
}

.markdown-body tr:hover td {
  background: var(--color-surface-hover);
}

/* ── Images ── */
.markdown-body img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border-light);
  box-shadow: var(--shadow-sm);
  margin: var(--space-5) 0;
}

/* ── Horizontal Rules ── */
.markdown-body hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: var(--space-8) 0;
}

/* ── Links in content ── */
.markdown-body a {
  color: var(--color-accent);
  text-decoration: underline;
  text-decoration-color: var(--color-accent-border);
  text-underline-offset: 3px;
  transition: text-decoration-color var(--duration-fast) var(--ease-out-quart);
}

.markdown-body a:hover {
  text-decoration-color: var(--color-accent);
}

/* ── Permalink (TOC extension) ── */
.markdown-body .headerlink {
  opacity: 0;
  margin-left: var(--space-2);
  font-size: 0.8em;
  color: var(--color-text-tertiary);
  text-decoration: none;
  transition: opacity var(--duration-fast) var(--ease-out-quart);
  vertical-align: middle;
}

.markdown-body h1:hover .headerlink,
.markdown-body h2:hover .headerlink,
.markdown-body h3:hover .headerlink,
.markdown-body h4:hover .headerlink {
  opacity: 0.5;
}

.markdown-body .headerlink:hover {
  opacity: 1;
  color: var(--color-accent);
}

/* ── Task lists ── */
.markdown-body input[type="checkbox"] {
  margin-right: var(--space-2);
  accent-color: var(--color-accent);
  vertical-align: middle;
}

/* ── Definition lists ── */
.markdown-body dl {
  margin: 0 0 var(--space-5);
}

.markdown-body dt {
  font-weight: var(--weight-semibold);
  margin: var(--space-3) 0 var(--space-1);
  color: var(--color-text-primary);
}

.markdown-body dd {
  margin-left: var(--space-6);
  color: var(--color-text-secondary);
}

/* ── Abbreviations ── */
.markdown-body abbr[title] {
  text-decoration: underline dotted;
  cursor: help;
}

/* -------------------------------------------------------------------
   13. Back to Top Button
   ------------------------------------------------------------------- */
.back-to-top {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  box-shadow: var(--shadow-md);
  z-index: 90;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: all var(--duration-normal) var(--ease-out-quart);
}

.back-to-top.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.back-to-top:hover {
  background: var(--color-accent);
  color: white;
  border-color: var(--color-accent);
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

/* -------------------------------------------------------------------
   14. Mobile Menu Toggle
   ------------------------------------------------------------------- */
.menu-toggle {
  display: none;
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-primary);
  font-size: 1.2rem;
  cursor: pointer;
  z-index: 200;
  box-shadow: var(--shadow-lg);
  align-items: center;
  justify-content: center;
  transition: all var(--duration-fast) var(--ease-out-quart);
}

.menu-toggle:hover {
  background: var(--color-accent);
  color: white;
  border-color: var(--color-accent);
}

/* -------------------------------------------------------------------
   15. Animations
   ------------------------------------------------------------------- */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.5; }
}

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

/* -------------------------------------------------------------------
   16. Responsive Design
   ------------------------------------------------------------------- */

/* Large: wider content layout */
@media (min-width: 1280px) {
  .dir-grid {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: var(--space-5);
  }
}

/* Extra large */
@media (min-width: 1600px) {
  .main-content {
    padding: var(--space-10) var(--space-12) var(--space-16);
  }
  .dir-grid {
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--space-6);
  }
}

/* Ultra wide */
@media (min-width: 1920px) {
  .main-content {
    padding: var(--space-10) var(--space-16) var(--space-16);
  }
  .dir-grid {
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  }
  .doc-layout {
    gap: var(--space-12);
  }
}

/* Tablet: narrow sidebar */
@media (max-width: 1024px) {
  :root {
    --sidebar-width: 240px;
    --toc-width: 180px;
  }
  .main-content {
    padding: var(--space-8) var(--space-6) var(--space-12);
  }
}

/* Tablet vertical / large phone */
@media (max-width: 860px) {
  .doc-layout {
    flex-direction: column;
  }
  .doc-toc {
    position: static;
    width: 100%;
    min-width: unset;
    max-height: unset;
    margin-bottom: var(--space-6);
  }
}

/* Mobile */
@media (max-width: 768px) {
  :root {
    --sidebar-width: 280px;
  }

  .sidebar {
    position: fixed;
    left: calc(-1 * var(--sidebar-width));
    top: 0;
    height: 100vh;
    height: 100dvh;
    transition: left var(--duration-normal) var(--ease-out-expo);
    box-shadow: none;
  }

  .sidebar.open {
    left: 0;
    box-shadow: var(--shadow-xl);
  }

  /* Overlay when sidebar is open */
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgb(0 0 0 / 0.3);
    z-index: 99;
    backdrop-filter: blur(2px);
  }

  .sidebar.open + .sidebar-overlay {
    display: block;
  }

  .main-content {
    padding: var(--space-5) var(--space-4) var(--space-12);
    max-width: 100%;
  }

  .menu-toggle {
    display: flex;
  }

  .dir-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: var(--space-3);
  }

  .dir-card {
    padding: var(--space-4);
  }

  .markdown-body h1 { font-size: var(--text-2xl); }
  .markdown-body h2 { font-size: var(--text-xl); }
  .markdown-body h3 { font-size: var(--text-lg); }

  .back-to-top {
    bottom: var(--space-20);
    right: var(--space-4);
  }
}

/* Small phone */
@media (max-width: 480px) {
  .dir-grid {
    grid-template-columns: 1fr;
  }
  .breadcrumbs {
    font-size: var(--text-xs);
  }
}

/* -------------------------------------------------------------------
   17. Print Styles
   ------------------------------------------------------------------- */
@media print {
  .sidebar,
  .doc-toc,
  .menu-toggle,
  .back-to-top,
  .theme-toggle,
  .reading-progress {
    display: none !important;
  }

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

  .markdown-body {
    font-size: 11pt;
    line-height: 1.5;
    color: #000;
  }

  .markdown-body pre {
    background: #f5f5f5;
    color: #000;
    border: 1px solid #ccc;
    white-space: pre-wrap;
    word-wrap: break-word;
  }

  .markdown-body a {
    color: #000;
    text-decoration: underline;
  }
}

/* -------------------------------------------------------------------
   18. Utility: Skip to content (a11y)
   ------------------------------------------------------------------- */
.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-4);
  background: var(--color-accent);
  color: white;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  font-weight: var(--weight-semibold);
  z-index: 1001;
  transition: top var(--duration-fast) var(--ease-out-quart);
}

.skip-link:focus {
  top: var(--space-4);
}
