html {
    scroll-behavior: smooth;
  }

  /* Burger Menu Button - Hidden on wide screens */
  .toc-burger {
    position: fixed;
    right: 20px;
    top: 20px;
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    z-index: 1001;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    transition: all 0.3s ease;
  }

  .toc-burger:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.6);
  }

  .toc-burger span {
    display: block;
    width: 24px;
    height: 3px;
    background: white;
    border-radius: 2px;
    transition: all 0.3s ease;
  }

  .toc-burger.active span:nth-child(1) {
    transform: rotate(45deg) translate(7px, 7px);
  }

  .toc-burger.active span:nth-child(2) {
    opacity: 0;
  }

  .toc-burger.active span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -7px);
  }

  /* Hide burger on wide screens */
  @media screen and (min-width: 1400px) {
    .toc-burger {
      display: none;
    }
  }

  /* Table of Contents Panel */
  .toc-wrapper {
    position: fixed;
    right: -31%;
    top: 0;
    width: 31%;
    height: 100vh;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 0;
    box-shadow: -2px 0 20px rgba(0, 0, 0, 0.15);
    overflow-y: auto;
    z-index: 1000;
    transition: right 0.3s ease;
    border-left: 1px solid rgba(255, 255, 255, 0.3);
  }

  .toc-wrapper.active {
    right: 0;
  }

  .toc-header {
    position: sticky;
    top: 0;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.95) 0%, rgba(118, 75, 162, 0.95) 100%);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  }

  .toc-header h4 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 700;
  }

  .toc-close {
    background: transparent;
    border: none;
    color: white;
    font-size: 2rem;
    cursor: pointer;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
    line-height: 1;
  }

  .toc-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
  }

  /* Wide screen: Always show TOC on the right side - 10% width */
  @media screen and (min-width: 1400px) {
    .toc-wrapper {
      right: 20px;
      top: 100px;
      width: 137.5px;
      height: auto;
      max-height: 80vh;
      background: rgba(255, 255, 255, 0.75);
      backdrop-filter: blur(15px);
      -webkit-backdrop-filter: blur(15px);
      padding: 10px;
      border-radius: 8px;
      box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
      border: 1px solid rgba(255, 255, 255, 0.3);
      transition: none;
    }

    .toc-wrapper.active {
      right: 20px;
    }

    .toc-header {
      position: static;
      background: none;
      backdrop-filter: none;
      -webkit-backdrop-filter: none;
      color: #333;
      padding: 0;
      border-bottom: none;
      margin-bottom: 8px;
    }

    .toc-header h4 {
      color: #333;
      font-size: 0.75em;
      font-weight: 600;
      text-transform: none;
      letter-spacing: normal;
      margin: 0;
    }

    .toc-close {
      display: none;
    }

    .toc-list {
      padding: 0;
    }

    .toc-list li {
      margin: 4px 0;
    }

    .toc-list a {
      padding: 0;
      font-size: 0.675em;
      line-height: 1.4;
      display: block;
      color: #4a4a4a;
    }

    .toc-list a:hover {
      color: #3273dc;
      background: none;
      backdrop-filter: none;
      -webkit-backdrop-filter: none;
      transform: none;
    }
  }

  /* Burger mode styles - only apply when NOT in wide screen */
  @media screen and (max-width: 1399px) {
    .toc-list {
      list-style-type: none;
      padding: 20px;
      margin: 0;
    }

    .toc-list li {
      margin: 0;
    }

    .toc-list a {
      display: block;
      color: #4a4a4a;
      text-decoration: none;
      font-size: 0.95rem;
      padding: 12px 15px;
      border-radius: 8px;
      transition: all 0.3s ease;
      font-weight: 500;
    }

    .toc-list a:hover {
      background: linear-gradient(135deg, rgba(102, 126, 234, 0.9) 0%, rgba(118, 75, 162, 0.9) 100%);
      color: white;
      transform: translateX(5px);
      backdrop-filter: blur(10px);
      -webkit-backdrop-filter: blur(10px);
    }

    .toc-list a:active {
      background: linear-gradient(135deg, rgba(102, 126, 234, 0.9) 0%, rgba(118, 75, 162, 0.9) 100%);
      color: white;
    }
  }

  /* Common styles for all sizes */
  .toc-list {
    list-style-type: none;
  }

  .toc-list a {
    text-decoration: none;
    display: block;
    transition: all 0.3s ease;
  }

  /* Overlay */
  .toc-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
  }

  .toc-overlay.active {
    opacity: 1;
    pointer-events: all;
  }

  /* Hide overlay on wide screens */
  @media screen and (min-width: 1400px) {
    .toc-overlay {
      display: none;
    }
  }

  /* Mobile adjustments */
  @media screen and (max-width: 768px) {
    .toc-wrapper {
      width: 60%;
      right: -60%;
    }

    .toc-burger {
      right: 15px;
      top: 15px;
    }
  }

  @media screen and (min-width: 769px) and (max-width: 1024px) {
    .toc-wrapper {
      width: 40%;
      right: -40%;
    }
  }

  @media screen and (min-width: 1025px) and (max-width: 1399px) {
    .toc-wrapper {
      width: 31%;
      right: -31%;
    }
  }