/* แก้ปัญหาลิงก์ anchor แล้วหัวข้อโดนบัง */
html {
  scroll-padding-top: 200px; /* เท่ากับ header (115px) + nav (65px) + margin เผื่อ */
}

body {
    font-family: sans-serif;
    margin: 0;
    padding: 0;
    background: #f5f5f5;
  }
  
  header {
    background: #3729fa;
    color: white;
    padding: 1rem;
    text-align: center;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
  }
  
  nav {
    background: #56cfff;
    padding: 1rem;
    text-align: center;
    position: fixed;
    top: 115px;
    left: 0;
    width: 100%;
    z-index: 999;
  }
  
  nav a {
    color: rgb(0, 0, 0);
    margin: 0 15px;
    text-decoration: none;
    font-weight: bold;
  }

  nav a:hover, nav a:active {
            text-decoration: underline;
            color: #fff;
            background-color: #f5620c;
       }
  
.sidebar {
  position: fixed;
  top: 180px; /* ให้อยู่ต่ำกว่าหัวข้อบนสุด */
  left: 0;
  width: 200px;
  height: calc(100% - 180px);
  background-color: #f0f0f0;
  padding: 1rem;
  overflow-y: auto;
  border-right: 1px solid #ccc;
  z-index: 998;
}

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

.sidebar li {
  margin-bottom: 10px;
}

.sidebar a {
  display: block;
  text-decoration: none;
  color: #333;
  padding: 8px 10px;
  border-radius: 4px;
}

.sidebar a:hover {
  background-color: #fa966f;
}
  
  section {
    padding: 160px 2rem 2rem;
    margin-left: 220px; /* ขยับออกจาก sidebar */
  }
  
  h2 {
    color: #333;
  }
  
  .note {
    background: rgb(224, 225, 226);
    padding: 1rem;
    margin: 1rem 0;
    border: 1px solid;
    border-radius: 5px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
  }

  .note2 {
    background: rgb(255, 255, 255);
    padding: 12rem;
    margin: 1rem 0;
  }

  
  .copy-btn {
    background-color: #4CAF50;
    color: white;
    border: none;
    padding: 8px 16px;
    cursor: pointer;
    border-radius: 5px;
    margin-top: 10px;
  }
  
  .copy-btn:hover {
    background-color: #45a049;
  }
  
  .imgresponsive {
    width: 100%;
    height: auto;
  }
  
  pre {
    background-color: #f0f0f0;
    padding: 10px;
    border-radius: 5px;
    font-size: 16px;
    font-family: monospace;
    white-space: pre-wrap;
    word-wrap: break-word;
    margin-bottom: 10px;
  }

  .centermsg {
    text-align: center;
  }

  .redmsg {
      color: red;
      font-weight: bold;
      text-align: center;
  }

  .redmsgleft {
      color: red;
      font-weight: bold;
  }

  .bluemsgleft {
      color: rgb(31, 15, 252);
      font-weight: bold;
  }

  .blackmsgleft {
      color: rgb(0, 0, 0);
      font-weight: bold;
  }

  .orangemsgleft {
      color: rgb(255, 146, 4);
      font-weight: bold;
  }

  .purplemsgleft {
      color: rgb(238, 15, 190);
      font-weight: bold;
  }

  .greenmsgleft {
      color: rgb(14, 107, 2);
      font-weight: bold;
  }

  .brownmsgleft {
      color: rgb(104, 59, 9);
      font-weight: bold;
  }

  .footer {
      position: fixed;
      left: 0;
      bottom: 0;
      padding-left: 3px;
      color: white;
      background-color: #555555;
      width: 100%;
      text-align: center;
  }

  .toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #4CAF50;
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 9999;
  }

  .img-container {
  display: flex;
  justify-content: center;
}

.center-img {
  display: block;
  margin-left: auto;
  margin-right: auto;
}

  .highlight-target {
  animation: highlight-fade 2s ease-out;
  background-color: #ffeaa7;
  transition: background-color 0.5s ease;
}

@keyframes highlight-fade {
  0% {
    background-color: #ffeaa7;
  }
  100% {
    background-color: transparent;
  }
}