/* Table of Contents */
.toc-container {
    position: fixed !important;
    right: 0 !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    width: 300px !important;
    height: calc(100vh - 120px) !important;
    max-height: 800px !important;
    background: rgba(10, 10, 10, 0.95) !important;
    border-left: 1px solid rgba(237, 41, 57, 0.2) !important;
    border-top-left-radius: 16px !important;
    border-bottom-left-radius: 16px !important;
    box-shadow: 
      -4px 0 20px rgba(0, 0, 0, 0.3),
      -2px 0 10px rgba(237, 41, 57, 0.1) !important;
    backdrop-filter: blur(10px) !important;
    z-index: 1000 !important;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    opacity: 1 !important;
  }
  
  .toc-container::before {
    content: '' !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    border-top-left-radius: 16px !important;
    border-bottom-left-radius: 16px !important;
    background: linear-gradient(90deg, transparent, rgba(237, 41, 57, 0.05)) !important;
    z-index: -1 !important;
  }
  
  .toc-header {
    padding: 20px !important;
    background: rgba(20, 20, 20, 0.8) !important;
    border-bottom: 1px solid rgba(237, 41, 57, 0.2) !important;
    backdrop-filter: blur(10px) !important;
    border-top-left-radius: 16px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
  }
  
  .toc-content {
    flex: 1 !important;
    overflow-y: auto !important;
    padding: 20px !important;
    background: rgba(15, 15, 15, 0.4) !important;
  }
  
  .toc-container.collapsed {
    transform: translate(100%, -50%) !important;
    opacity: 0 !important;
  }
  
  /* Floating ToC button - Make it always visible */
  .toc-float-button {
    position: fixed !important;
    right: 0 !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    width: 45px !important;
    height: 45px !important;
    border-top-left-radius: 8px !important;
    border-bottom-left-radius: 8px !important;
    background: rgba(10, 10, 10, 0.95) !important;
    border: 1px solid rgba(237, 41, 57, 0.2) !important;
    border-right: none !important;
    box-shadow: 
      -4px 0 20px rgba(0, 0, 0, 0.3),
      -2px 0 10px rgba(237, 41, 57, 0.1) !important;
    backdrop-filter: blur(10px) !important;
    z-index: 998 !important; /* Keep it below the panel but above other content */
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    color: var(--highlight-color) !important;
    opacity: 0.8 !important;
    pointer-events: auto !important;
  }
  
  .toc-float-button:hover {
    opacity: 1 !important;
    width: 50px !important;
    color: #ffffff !important;
    background: rgba(237, 41, 57, 0.2) !important;
    box-shadow: 
      -4px 0 20px rgba(0, 0, 0, 0.4),
      -2px 0 15px rgba(237, 41, 57, 0.2),
      0 0 10px rgba(237, 41, 57, 0.1) inset !important;
  }
  
  .toc-float-button svg {
    transition: transform 0.3s ease !important;
  }
  
  .toc-float-button:hover svg {
    transform: scale(1.1) !important;
  }
  
  /* Enhanced ToC Header */
  .toc-header {
    padding: 20px !important;
    background: rgba(20, 20, 20, 0.8) !important;
    border-bottom: 1px solid rgba(237, 41, 57, 0.2) !important;
    backdrop-filter: blur(10px) !important;
    border-top-left-radius: 16px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
  }
  
  .toc-title {
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
    font-family: 'Ubuntu Mono', monospace !important;
    text-transform: uppercase !important;
    letter-spacing: 1px !important;
    font-weight: 700 !important;
    font-size: 14px !important;
    color: var(--highlight-color) !important;
    text-shadow: 0 0 8px rgba(237, 41, 57, 0.3) !important;
  }
  
  .toc-title svg {
    filter: drop-shadow(0 0 4px rgba(237, 41, 57, 0.4)) !important;
  }
  
  /* Enhanced ToC Links */
  .toc-item {
    margin: 12px 0 !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    transition: all 0.2s ease !important;
    position: relative !important;
    padding-left: 24px !important;
  }
  
  .toc-item::before {
    content: '>' !important;
    position: absolute !important;
    left: 0 !important;
    color: var(--highlight-color) !important;
    font-family: 'Ubuntu Mono', monospace !important;
    opacity: 0 !important;
    transform: translateX(-10px) !important;
    transition: all 0.3s ease !important;
  }
  
  .toc-item:hover::before,
  .toc-item:has(.toc-link.active)::before {
    opacity: 1 !important;
    transform: translateX(0) !important;
  }
  
  .toc-link {
    color: #e6e6e6 !important;
    text-decoration: none !important;
    font-size: 14px !important;
    font-family: 'Ubuntu Mono', monospace !important;
    transition: all 0.3s ease !important;
    position: relative !important;
    padding-left: 0 !important;
    line-height: 1.4 !important;
    width: 100% !important;
  }
  
  .toc-link:hover,
  .toc-link.active {
    color: var(--highlight-color) !important;
    text-shadow: 0 0 8px rgba(237, 41, 57, 0.3) !important;
    padding-left: 5px !important;
    text-decoration: none !important;
  }
  
  .toc-link::after {
    content: '' !important;
    position: absolute !important;
    left: 0 !important;
    bottom: -2px !important;
    width: 0 !important;
    height: 1px !important;
    background: var(--highlight-color) !important;
    transition: width 0.3s ease !important;
    box-shadow: 0 0 8px var(--highlight-color) !important;
    opacity: 0.5 !important;
  }
  
  .toc-link:hover::after,
  .toc-link.active::after {
    width: 100% !important;
  }
  
  .toc-item.level-2 {
    padding-left: 30px !important;
    font-size: 0.95em !important;
  }
  
  .toc-item.level-3 {
    padding-left: 45px !important;
    font-size: 0.9em !important;
  }
  
  /* Scanline effect */
  .toc-container::after {
    content: '' !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    height: 100% !important;
    background: linear-gradient(
      transparent 0%,
      rgba(237, 41, 57, 0.05) 50%,
      transparent 100%
    ) !important;
    animation: scanline 8s linear infinite !important;
    pointer-events: none !important;
  }
  
  @keyframes scanline {
    0% { transform: translateY(-100%) !important; }
    100% { transform: translateY(100%) !important; }
  }
  
  /* Close button enhancement */
  .toc-toggle {
    background: transparent !important;
    border: none !important;
    color: var(--highlight-color) !important;
    cursor: pointer !important;
    padding: 8px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    opacity: 0.8 !important;
    transition: all 0.3s ease !important;
    border-radius: 4px !important;
  }
  
  .toc-toggle:hover {
    opacity: 1 !important;
    background: rgba(237, 41, 57, 0.1) !important;
    box-shadow: 0 0 10px rgba(237, 41, 57, 0.2) !important;
  }
  
  .toc-toggle svg {
    filter: drop-shadow(0 0 4px rgba(237, 41, 57, 0.4)) !important;
  }
  
  /* Enhanced scrollbar */
  .toc-content::-webkit-scrollbar {
    width: 4px !important;
  }
  
  .toc-content::-webkit-scrollbar-track {
    background: transparent !important;
  }
  
  .toc-content::-webkit-scrollbar-thumb {
    background: rgba(237, 41, 57, 0.3) !important;
    border-radius: 2px !important;
  }
  
  .toc-content::-webkit-scrollbar-thumb:hover {
    background: rgba(237, 41, 57, 0.5) !important;
  }
  
  /* Mobile responsiveness */
  @media (max-width: 1024px) {
    .toc-container {
      width: 280px !important;
      height: calc(100vh - 80px) !important;
    }
    
    .toc-container.collapsed {
      transform: translate(100%, -50%) !important;
    }
  }
  
  @media (max-width: 480px) {
    .toc-container {
      width: 85% !important;
      height: calc(100vh - 60px) !important;
    }
  }
  
  /* Adjust main content padding when ToC is visible */
  .wrapper {
    padding-right: 300px !important;
    transition: padding-right 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
  }
  
  .wrapper.toc-collapsed {
    padding-right: 0 !important;
  }
  
  @media (max-width: 1024px) {
    .wrapper {
      padding-right: 0 !important;
    }
  }
  
  /* Scrollbar styling for ToC */
  .toc-content::-webkit-scrollbar {
    width: 6px !important;
  }
  
  .toc-content::-webkit-scrollbar-track {
    background: transparent !important;
  }
  
  .toc-content::-webkit-scrollbar-thumb {
    background: rgba(237, 41, 57, 0.2) !important;
    border-radius: 3px !important;
  }
  
  .toc-content::-webkit-scrollbar-thumb:hover {
    background: rgba(237, 41, 57, 0.4) !important;
  }
  
  /* ToC list styling */
  .toc-list {
    list-style: none !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  
  .toc-item {
    margin: 12px 0 !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    transition: all 0.2s ease !important;
  }
  
  .toc-item.level-2 {
    padding-left: 30px !important;
    font-size: 0.95em !important;
    opacity: 0.9 !important;
  }
  
  .toc-item.level-3 {
    padding-left: 45px !important;
    font-size: 0.9em !important;
    opacity: 0.8 !important;
  }
  
  .toc-link {
    color: #e6e6e6 !important;
    text-decoration: none !important;
    font-size: 14px !important;
    font-family: 'Ubuntu Mono', monospace !important;
    transition: all 0.2s ease !important;
    position: relative !important;
    padding-left: 5px !important;
    line-height: 1.4 !important;
  }
  
  .toc-link:hover,
  .toc-link.active {
    color: var(--highlight-color) !important;
  }
  
  /* Add keyboard navigation section */
  .toc-keyboard-nav {
    padding: 6px 12px !important;
    background: rgba(0, 0, 0, 0.15) !important;
    border-top: 1px solid rgba(237, 41, 57, 0.2) !important;
    margin-top: auto !important;
  }
  
  .keyboard-shortcuts {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 4px !important;
    flex-wrap: nowrap !important;
  }
  
  .key {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-width: 22px !important;
    height: 22px !important;
    padding: 0 3px !important;
    background: rgba(20, 20, 20, 0.95) !important;
    border: 1px solid rgba(237, 41, 57, 0.2) !important;
    border-radius: 3px !important;
    font-family: 'Ubuntu Mono', monospace !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    color: var(--highlight-color) !important;
    line-height: 1 !important;
  }
  
  .key[data-key="shift+p"] {
    min-width: 30px !important;
    font-size: 13px !important;
    font-weight: 700 !important;
    background: rgba(237, 41, 57, 0.1) !important;
  }
  
  .key-label {
    color: rgba(255, 255, 255, 0.5) !important;
    font-size: 10px !important;
    margin: 0 2px !important;
    white-space: nowrap !important;
  }
  
  .key.pressed {
    transform: translateY(1px) !important;
    background: rgba(237, 41, 57, 0.1) !important;
  }
  
  /* Remove any old keyboard navigation styles */
  .keyboard-shortcuts .shortcut-group,
  .keyboard-shortcuts .shortcut-row,
  .keyboard-hint {
    display: none !important;
  }
  
  /* Enhanced keyboard navigation focus styles */
  .toc-link.keyboard-focus {
    background: rgba(237, 41, 57, 0.1) !important;
    border-radius: 4px !important;
    position: relative !important;
    outline: none !important;
    color: var(--highlight-color) !important;
    text-shadow: 0 0 8px rgba(237, 41, 57, 0.3) !important;
    padding-left: 5px !important;
  }
  
  .toc-link.keyboard-focus::before {
    content: '>' !important;
    position: absolute !important;
    left: -15px !important;
    color: var(--highlight-color) !important;
    animation: cursorBlink 1s ease-in-out infinite !important;
  }
  
  .toc-link.keyboard-focus::after {
    content: '' !important;
    position: absolute !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    height: 1px !important;
    background: var(--highlight-color) !important;
    box-shadow: 0 0 8px var(--highlight-color) !important;
    animation: scanlineHover 2s ease-in-out infinite !important;
  }
  
  @keyframes cursorBlink {
    0%, 100% { opacity: 1 !important; }
    50% { opacity: 0.3 !important; }
  }
  
  @keyframes scanlineHover {
    0% {
        background-position: -100% 0 !important;
        opacity: 0.5 !important;
    }
    50% {
        opacity: 1 !important;
    }
    100% {
        background-position: 200% 0 !important;
        opacity: 0.5 !important;
    }
  }
  
  /* Heading animations */
  .heading-underline {
    position: absolute !important;
    left: 0 !important;
    bottom: -4px !important;
    width: 0 !important;
    height: 2px !important;
    background: linear-gradient(90deg, var(--highlight-color), #ff4444, var(--highlight-color)) !important;
    box-shadow: 0 0 8px var(--highlight-color) !important;
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1) !important;
    opacity: 0 !important;
  }
  
  /* Content headings base style */
  .content h1, .content h2, .content h3 {
    position: relative !important;
    display: inline-block !important;
    transition: all 0.3s ease !important;
    color: var(--heading-color) !important; /* Reset to normal color */
    text-shadow: none !important; /* Remove default shadow */
  }
  
  /* Active state from TOC */
  .heading-active {
    color: var(--highlight-color) !important;
    text-shadow: 0 0 8px rgba(237, 41, 57, 0.5) !important;
  }
  
  .heading-active .heading-underline {
    width: 100% !important;
    opacity: 1 !important;
  }
  
  /* Hover effects */
  .hover-effect .heading-underline {
    width: 100% !important;
    opacity: 1 !important;
  }
  
  /* Always show neon effect on hover, regardless of active state */
  .content h1:hover, 
  .content h2:hover, 
  .content h3:hover {
    color: var(--highlight-color) !important;
    text-shadow: 
        0 0 8px rgba(237, 41, 57, 0.5),
        0 0 12px rgba(237, 41, 57, 0.3) !important;
  }
  
  /* Hover effect for non-active headings */
  .content h1:not(.heading-active):hover .heading-underline,
  .content h2:not(.heading-active):hover .heading-underline,
  .content h3:not(.heading-active):hover .heading-underline {
    width: 100% !important;
    opacity: 1 !important;
  }
  
  /* Active heading styles */
  .hover-active {
    color: var(--highlight-color) !important;
    text-shadow: 0 0 8px rgba(237, 41, 57, 0.5) !important;
    animation: textGlitch 3s infinite !important;
  }
  
  @keyframes textGlitch {
    0% {
        text-shadow: 0 0 8px rgba(237, 41, 57, 0.5) !important;
        transform: translate(0) !important;
    }
    98% {
        text-shadow: 0 0 8px rgba(237, 41, 57, 0.5) !important;
        transform: translate(0) !important;
    }
    99% {
        text-shadow: -2px 0 #ff0000, 2px 2px #00ff00 !important;
        transform: translate(2px, -2px) !important;
    }
    100% {
        text-shadow: 0 0 8px rgba(237, 41, 57, 0.5) !important;
        transform: translate(0) !important;
    }
  }

  .heading-active {
    color: var(--highlight-color) !important;
    text-shadow: 0 0 8px rgba(237, 41, 57, 0.5) !important;
  }

  .heading-active .heading-underline {
    width: 100% !important;
    opacity: 1 !important;
  }

  /* Remove automatic hover animations when heading is active */
  .heading-active:hover .heading-underline {
    /* Keep the underline visible when hovering active heading */
    opacity: 1 !important;
  }

  /* Hover animation (only when not active) */
  .hover-effect .heading-underline {
    width: 100% !important;
    opacity: 1 !important;
  }

  