.post-layout {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
}

.post-content-wrapper {
  flex: 1;
  min-width: 0;
}

.sidebar-toc {
  position: sticky;
  top: 2rem;
  flex: 0 0 auto;
  width: 220px;
  max-height: calc(100vh - 4rem);
  overflow-y: auto;
  padding: 1rem 1.25rem;
  background-color: var(--bg_s);
  border: 1px solid var(--bg2);
  border-radius: 0.3rem;
  font-size: 0.9rem;
  line-height: 1.5;

  .sidebar-toc-header {
    font-weight: bold;
    font-size: 1rem;
    padding-bottom: 0.5rem;
    margin-bottom: 0.75rem;
    border-bottom: 1px solid var(--bg2);
    color: var(--fg);
  }

  #TableOfContents {
    nav,
    ul,
    ol {
      padding-left: 0;
      margin: 0;
      list-style: none;
    }

    ul ul,
    ol ol,
    ul ol,
    ol ul {
      padding-left: 1rem;
      margin: 0;
    }

    li {
      margin: 0.2rem 0;
    }

    a {
      color: var(--fg4);
      text-decoration: none;
      display: block;
      padding: 0.15rem 0;
      border-left: 2px solid transparent;
      padding-left: 0.5rem;
      transition: color 0.2s ease, border-color 0.2s ease;

      &:hover {
        color: var(--fg);
        text-decoration: none;
      }

      &.active {
        color: var(--yellow-dim);
        border-left-color: var(--yellow-dim);
        font-weight: 600;
      }
    }
  }
}

@media (max-width: 768px) {
  .post-layout {
    flex-direction: column;
  }

  .sidebar-toc {
    position: static;
    width: 100%;
    max-height: none;
    margin-bottom: 1.5rem;
  }
}