:root {
  --bg-color: #FAF9F6;
  --text-main: hsl(0, 0%, 18%);
  --text-big: #454545;
  --text-sub: rgba(45, 45, 45, 0.7);    /* เทาเข้มโปร่งแสง */
  --text-mute: rgba(45, 45, 45, 0.45);  /* สำหรับ span หรือวันที่ */
  --border-light: rgba(0, 0, 0, 0.06);  /* เส้นแบ่งบางๆ */
  --border-dim: rgba(0, 0, 0, 0.12);    /* เส้นขอบที่ชัดขึ้น */
  --bg-soft: rgba(0, 0, 0, 0.06);       /* พื้นหลัง code/table */
  --bg-highlight: rgba(255, 255, 255, 0.6); /* พื้นหลัง th/td เพื่อให้ดูสว่างขึ้น */
}
/* คัดลอกไปวางต่อจาก :root เดิม หรือใช้ Class .dark-mode หุ้มไว้ */
@media (prefers-color-scheme: dark) {
  :root {
//    --bg-color: #1A1A1B;           /* เทาเข้มลึก (Deep Charcoal) */
//    --text-main: #E2E2E2;          /* ขาวนวลลดแสงจ้า */
//    --text-sub: rgba(226, 226, 226, 0.7); 
//    --text-mute: rgba(226, 226, 226, 0.45);
//    --border-light: rgba(255, 255, 255, 0.05);
//    --border-dim: rgba(255, 255, 255, 0.12);
//    --bg-soft: rgba(255, 255, 255, 0.04);     /* พื้นหลังองค์ประกอบแบบโปร่งแสง */
//    --bg-highlight: rgba(255, 255, 255, 0.08); /* ชั้นสีที่สว่างขึ้นเล็กน้อย */
  }
}
*{
    box-sizing:border-box;
}
body{
    margin:0 auto;
    width:95%;
    max-width:700px;
    font-family:
    -apple-system, BlinkMacSystemFont, 
    "Thonburi", 
    "Segoe UI", 
    "Garuda", 
    "Tahoma", 
    sans-serif;
    font-size:1rem;
    line-height:1.6;
    color: var(--text-main);
    background-color: var(--bg-color);
    transition: all 0.2s ease;
}
body > footer{
    clear:both;
}
#container img{
    max-width:100%;
    max-height:100%;
    border:1px solid var(--border-dim);
    border-radius:0.3rem;
}
a{
    color:#0862d1;
}
a:visited{
    color:#628cbf;
}
span{
    font-size:0.9em;
    color:#666;
}
span a{
    color:var(--text-sub)!important;
}
hr{
    border:none;
    border-top:3px dotted var(--border-dim);
    margin:1em 0;
}
.microblog-content table {
    display: inline-block;          /* เปลี่ยนสถานะเพื่อให้รองรับ overflow */
    max-width: 100%;             /* ให้กว้างเต็มพื้นที่ container */
    overflow-x: auto;       /* เพิ่ม scrollbar เฉพาะเมื่อข้อมูลยาวเกินหน้าจอ */
    -webkit-overflow-scrolling: touch; /* เพิ่มความลื่นไหลในการรูดบนมือถือ */
}

/* แถม: ตกแต่ง scrollbar ให้ดู Minimalist เข้ากับบล็อก */
.microblog-content table::-webkit-scrollbar {
    height: 6px;
}

.microblog-content table::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 10px;
}
table{
    border:0;
    border-collapse: separate;
    border-spacing: 5px;
    border-radius:8px;
    background-color: var(--bg-soft);
    font-size:0.9em;
    margin:1em 0;
}
th, td{
    //text-align:center;
    background-color:var(--bg-highlight);
    border: 0;
    border-radius:5px;
    padding: 0.2em 0.4em;
    margin:8px;
}
th{
    background-color: var(--border-dim);
}
/* 1. ล็อคแถวหัวตาราง (Sticky Header) */
thead th {
  position: sticky;
  top: 0;
  //background-color: #f8f9fa; /* สีพื้นที่ดูสะอาดตาแบบ Rigid */
  z-index: 15; /* ต้องสูงกว่า td ทั่วไป */
  //border-bottom: 2px solid #dee2e6;
}

/* 2. ล็อคคอลัมน์แรก (Sticky First Column) */
th:first-child, 
td:first-child {
  position: sticky;
  left: 0;
  //background-color: #ffffff;
  z-index: 10;
  //border-right: 2px solid #f0f0f0;
}

/* 3. จุดตัดสำคัญ: ล็อคช่องซ้ายบนสุด (Top-Left Cell) */
/* ช่องนี้ต้องล็อคทั้ง Top และ Left และมี z-index สูงที่สุด */
thead th:first-child {
  position: sticky;
  top: 0;
  left: 0;
  z-index: 20; 
  //background-color: #f8f9fa;
}
code{
    background-color: var(--bg-soft);
    padding: 0.2em 0.4em;
    border-radius: 4px;
}
pre code{
    background-color: var(--bg-soft);
    padding: 1em;
    display: block;
    overflow-x: auto;
}
pre{
    margin: 1em 0;
}
blockquote{
    border-left: 8px solid var(--border-dim);
    border-radius:8px;
    background-color: var(--bg-soft);
    margin: 1em 0;
    padding: 1rem 1rem;
    color: rgba(0, 0, 0, 0.7);
}
blockquote *:first-child{
    margin-top:0;
}
blockquote *:last-child{
    margin-bottom:0;
}
h1#site-title{
    font-size:0.9em;
    margin-top:0;
    margin-bottom:0px;
    display: inline-block;
}
#container{
    margin:1.5em 0;
}
header h1{
    margin-top:0;
    margin-bottom:0px;
    line-height:1.2;
    color:var(--text-big);
}
header a{
    color: var(--text-main)!important;
}
article header{
    background-color: var(--bg-soft);
    border: 1px solid var(--border-light);
    border-bottom: 4px solid var(--border-dim);
    border-radius: 1rem;
    margin:1rem -1rem;
    padding: 0.5rem 1rem;
    margin-bottom:1.5em;
}
h2, h3, h4, h5, h6{
    font-weight: bolder;
    line-height:1.2;
    text-decoration:solid underline var(--border-dim) 2px;
    padding:0.2rem 0.5rem;
    margin:1rem -0.5rem 0 -0.5rem;
    color:var(--text-main);
}
h2{
    color:var(--text-big);
    background-color: var(--border-light);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 0.5rem 1rem;
}
.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border-light); /* เส้นแบ่งบางๆ เพื่อความชัดเจนแต่ไม่ดึงสายตา */
}

.pagination a {
    text-decoration: none;
    color: var(--text-sub); /* สีเทาเข้มที่ดูนุ่มนวลกว่าสีดำสนิท */
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease; /* ใช้ transition ที่เราคุยกัน เพื่อความนุ่มนวล */
    padding: 5px 8px;
}

.pagination a:hover {
    color: var(--text-main);
    background-color: var(--bg-soft); /* เปลี่ยนพื้นหลังเพียงเล็กน้อย */
    border-radius: 8px;
}

/* หากไม่มีปุ่ม Previous ให้ปุ่ม Next ชิดขวาเสมอ */
.pagination a:only-child {
    margin-left: auto;
}

/* Special css */

table.nostyle{
    background: none;
}
table.nostyle > tr > td{
    background: none;
    border:none;
    vertical-align: top;
}
table.nostyle > tbody > tr > td{
    background: none;
    border:none;
    vertical-align: top;
}
table.nostyle th, 
table.nostyle td{
  position: static!important;
}