/* Base container positioning */
.document-container {
  position: relative;
  max-width: var(--width-content);
  margin: 0 auto;
  padding: 1rem;
}

/* Toggle button - fixed to viewport edge */
/* Toggle button - adjusted positioning and size */
.toc-toggle {
  position: fixed;  top: 50%;
  right: 0.5rem; /* Move button away from edge */
  /* transform: translateY(-50%) rotate(-90deg) translateX(50%); Adjust transform to center */
  transform: translateY(-50%); /* Adjust transform to center */
  /* transform-origin: center right; */
  padding: 0.5rem 1rem; /* Reduced padding */
  background: var(--color-bg);
  border: 1px solid var(--color-bg-secondary);
  border-radius: var(--border-radius);
  cursor: pointer;
  z-index: 1000;
  white-space: nowrap;
  box-shadow: -2px 0 4px rgba(0, 0, 0, 0.1);
  font-size: 0.875rem; /* Slightly smaller font */
  line-height: 1;
  color: var(--color-text-secondary);
}

/* TOC wrapper - fixed positioning */
.toc-wrapper {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: 280px;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  z-index: 999;
  background: var(--color-bg);
}

.toc-wrapper.show {
  transform: translateX(0);
}

/* TOC content styling */
.toc {
  height: 100vh;
  overflow-y: auto;
  padding: 2rem 1rem;
  border-left: 1px solid var(--color-bg-secondary);
  box-shadow: -2px 0 4px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
}

/* .toc ul {
  list-style: none;
  padding: 0;
  margin: 0;
  transition: font-size 0.2s ease;
  flex: 1;
  display: flex;
  flex-direction: column;
} */

.toc li {
  padding: 0.025rem 0;
  padding: 0.25rem;
  flex: 1;
  display: flex;
  align-items: center;
  min-height: 2rem; /* Ensure minimum height for very short lists */
}

.toc a {
  text-decoration: none;
  color: var(--color-text);
  display: block;
  width: 100%;
  padding: 0.5rem 0;
  line-height: 1.2;
  transition: color 0.2s ease;
  /* Prevent text wrapping for cleaner appearance */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toc a:hover {
  color: var(--color-link);
}

/* Level indentation - using relative units */
.toc-h2 { padding-left: 1em; }
.toc-h3 { padding-left: 2em; }
.toc-h4 { padding-left: 3em; }

.toc .active {
  color: var(--color-link);
  font-weight: bold;
}

/* Return to top button */
/* .return-to-top {
  position: sticky;
  bottom: 0;
  width: 100%;
  padding: 0.75rem;
  margin-top: auto;
  background: var(--color-bg);
  border: 1px solid var(--color-bg-secondary);
  border-radius: var(--border-radius);
  cursor: pointer;
  box-shadow: 0 -2px 4px rgba(0, 0, 0, 0.05);
} */

/* Main content adjustment */
.markdown-content {
  max-width: calc(100% - 3rem);
  margin-right: 3rem;
}

/* Scrollbar styling */
/* .toc {
  scrollbar-width: thin;
  scrollbar-color: var(--color-bg-secondary) transparent;
} */

.toc::-webkit-scrollbar {
  width: 6px;
}

.toc::-webkit-scrollbar-track {
  background: transparent;
}

.toc::-webkit-scrollbar-thumb {
  background-color: var(--color-bg-secondary);
  border-radius: 3px;
}

/* Mobile adjustments */
@media (max-width: 768px) {
  .markdown-content {
    max-width: calc(100% - 2rem);
    margin-right: 2rem;
  }
  
  .toc-wrapper {
    width: 260px;
  }
  
  .toc-toggle {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
  }
  
  .toc li {
    min-height: 1.5rem; /* Smaller minimum height on mobile */
  }
}


.toc {
  height: 100vh;
  padding: 2rem 1rem;
  border-left: 1px solid var(--color-bg-secondary);
  box-shadow: -2px 0 4px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  overflow: hidden; /* Changed from overflow-y: auto */
}

.toc ul {
  list-style: none;
  padding: 0;
  margin: 0;
  transition: font-size 0.2s ease, line-height 0.2s ease;
  flex: 1;
  overflow-y: auto; /* Move scrolling to ul instead of container */
  min-height: 0; /* Required for Firefox */
}

.return-to-top {
  position: static; /* Changed from sticky */
  width: 100%;
  padding: 0.75rem;
  margin-bottom: 2.5rem;
  color: var(--color-text-secondary);
  background: var(--color-bg);
  border: 1px solid var(--color-bg-secondary);
  border-radius: var(--border-radius);
  cursor: pointer;
  box-shadow: 0 -2px 4px rgba(0, 0, 0, 0.05);
  flex-shrink: 0; /* Prevent button from shrinking */
}