/* ===================================
   Article Detail Page Styles
   =================================== */

/* หัวบทความเป็นแผงไล่เฉดสีดำในกรอบ container ไม่กินเต็มความกว้างจอ
   เดิมเอารูปปกมาเบลอเป็นพื้นหลังสูง 400px เต็มจอ ซึ่งทั้งอ่านหัวข้อยาก
   และรูปก็ดูไม่ออก รูปปกย้ายไปแสดงคมชัดที่ .article-cover แทน */
.article-detail-hero {
    padding-top: 1.75rem;
    margin-bottom: 0;
}

.article-hero-panel {
    position: relative;
    overflow: hidden;
    padding: 2.1rem 2.4rem 1.9rem;
    border-radius: 20px;
    background: linear-gradient(135deg, #2c3d4e 0%, #18222d 55%, #0d1319 100%);
    box-shadow: 0 10px 30px rgba(13, 19, 25, .18);
}

/* แสงจาง ๆ มุมขวาบน กันไม่ให้แผงดูแบนเป็นสี่เหลี่ยมทึบ */
.article-hero-panel::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(115% 85% at 88% 0%, rgba(255, 255, 255, .09), transparent 62%);
    pointer-events: none;
}

.article-hero-inner {
    position: relative;
    z-index: 1;
    max-width: 62rem;
}

.article-breadcrumb {
    background: transparent;
    padding: 0;
    margin-bottom: 1rem;
}

.article-breadcrumb .breadcrumb-item a {
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
}

.article-breadcrumb .breadcrumb-item a:hover {
    color: white;
}

.article-breadcrumb .breadcrumb-item.active {
    color: rgba(255, 255, 255, 0.7);
}

.article-breadcrumb .breadcrumb-item + .breadcrumb-item::before {
    color: rgba(255, 255, 255, 0.7);
}

.article-detail-title {
    color: #fff;
    font-size: 2.1rem;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 1rem;
    /* พื้นหลังเรียบแล้ว ไม่ต้องมีเงาช่วยให้ตัวอักษรลอยจากรูปอีก */
}

.article-hero-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem 1.35rem;
    color: rgba(255, 255, 255, 0.78);
    font-size: 0.88rem;
}

.article-hero-meta .meta-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.article-hero-meta .meta-item i {
    font-size: 0.9rem;
    opacity: .8;
}

.article-detail-content {
    padding: 2rem 0;
}

/* รูปปกแบบคมชัด ไม่เบลอ ไม่ถูกฉากดำทับ */
.article-cover {
    margin: 0 0 1.5rem;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    border-radius: 16px;
    background: #eef2f6;
    box-shadow: 0 2px 12px rgba(16, 24, 40, .08);
}

.article-cover img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.article-detail-body {
    background: white;
    padding: 2.5rem;
    border-radius: 16px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    margin-bottom: 2rem;
}

.article-detail-body h2 {
    color: #2d3748;
    font-size: 2rem;
    font-weight: 700;
    margin: 2rem 0 1rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 3px solid #4b7096;
}

.article-detail-body h3 {
    color: #4a5568;
    font-size: 1.5rem;
    font-weight: 600;
    margin: 1.5rem 0 1rem 0;
}

.article-detail-body p {
    color: #4a5568;
    line-height: 1.8;
    margin-bottom: 1.25rem;
    font-size: 1.05rem;
}

.article-detail-body img {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    margin: 1.5rem 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.article-detail-body ul,
.article-detail-body ol {
    margin: 1.25rem 0;
    padding-left: 2rem;
}

.article-detail-body li {
    color: #4a5568;
    line-height: 1.8;
    margin-bottom: 0.75rem;
}

.article-detail-body ul li {
    list-style-type: none;
    position: relative;
    padding-left: 1.5rem;
}

.article-detail-body ul li:before {
    content: "▸";
    position: absolute;
    left: 0;
    color: #4b7096;
    font-weight: bold;
}

.article-detail-body blockquote {
    background: linear-gradient(135deg, #4b709608, #2d456008);
    border-left: 4px solid #4b7096;
    padding: 1.5rem;
    margin: 1.5rem 0;
    border-radius: 8px;
}

.article-detail-body blockquote p {
    color: #4a5568;
    font-style: italic;
    margin: 0;
}

.article-tags-section {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 2px solid #e2e8f0;
}

.article-tags-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #2d3748;
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.article-tags-title i {
    color: #4b7096;
}

.article-tags-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.article-tag-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.5rem 1rem;
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    color: #4a5568;
    border-radius: 20px;
    font-size: 0.9rem;
    text-decoration: none;
    transition: all 0.3s ease;
    border: 1px solid #e2e8f0;
}

.article-tag-badge:hover {
    background: linear-gradient(135deg, #4b7096, #2d4560);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.article-share-section {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    margin-bottom: 2rem;
}

.article-share-section .share-title {
    color: #2d3748;
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.article-share-section .share-title i {
    color: #4b7096;
}

.share-buttons-modern {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.share-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    text-decoration: none;
    color: white;
    font-weight: 500;
    transition: all 0.3s ease;
}

.share-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    color: white;
    text-decoration: none;
}

.share-facebook {
    background: linear-gradient(135deg, #1877f2, #0c5bc6);
}

.share-twitter {
    background: linear-gradient(135deg, #1da1f2, #0c7abf);
}

.share-line {
    background: linear-gradient(135deg, #06c755, #00b900);
}

.related-articles-modern {
    margin-top: 3rem;
    margin-bottom: 2rem;
}

.related-articles-modern .related-title {
    color: #2d3748;
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.related-articles-modern .related-title i {
    color: #4b7096;
}

.related-articles-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

.related-article-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    text-decoration: none;
    display: flex;
    flex-direction: column;
}

.related-article-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    text-decoration: none;
}

.related-article-image-wrapper {
    position: relative;
    width: 100%;
    height: 200px;
    overflow: hidden;
}

.related-article-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.related-article-card:hover .related-article-image {
    transform: scale(1.1);
}

.related-article-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(102, 126, 234, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.related-article-card:hover .related-article-overlay {
    opacity: 1;
}

.related-article-overlay i {
    color: white;
    font-size: 2rem;
}

.related-article-content {
    padding: 1.25rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.related-article-title {
    color: #2d3748;
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.related-article-excerpt {
    color: #718096;
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: 1rem;
    flex: 1;
}

.related-article-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding-top: 1rem;
    border-top: 1px solid #e2e8f0;
    color: #a0aec0;
    font-size: 0.85rem;
}

.related-article-meta i {
    font-size: 0.9rem;
}

.article-back-button {
    margin-top: 2rem;
    text-align: center;
}

.back-btn-modern {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, #4b7096, #2d4560);
    color: white;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s ease;
}

.back-btn-modern:hover {
    transform: translateX(-5px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    color: white;
    text-decoration: none;
}

/* Dark Mode Support */
/* แผงหัวบทความเข้มอยู่แล้วทั้งสองธีม จึงไม่ต้องมีกฎ dark mode ของตัวมันเอง
   ส่วนรูปปกใช้พื้นรองคนละสีตอนยังโหลดไม่เสร็จ */
[data-theme="dark"] .article-cover {
    background: #0f172a;
    box-shadow: 0 2px 12px rgba(0, 0, 0, .3);
}

[data-theme="dark"] .article-breadcrumb .breadcrumb-item a {
    color: rgba(255, 255, 255, 0.95);
}

[data-theme="dark"] .article-breadcrumb .breadcrumb-item.active {
    color: rgba(255, 255, 255, 0.8);
}

[data-theme="dark"] .article-breadcrumb .breadcrumb-item + .breadcrumb-item::before {
    color: rgba(255, 255, 255, 0.8);
}

[data-theme="dark"] .article-detail-content {
    background: var(--bg-primary, #0f172a);
}

[data-theme="dark"] .article-detail-body,
[data-theme="dark"] .article-share-section,
[data-theme="dark"] .related-article-card {
    background: #1e293b;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .article-detail-body h2,
[data-theme="dark"] .article-tags-title,
[data-theme="dark"] .article-share-section .share-title,
[data-theme="dark"] .related-articles-modern .related-title,
[data-theme="dark"] .related-article-title {
    color: #e2e8f0;
}

[data-theme="dark"] .article-detail-body h3,
[data-theme="dark"] .article-detail-body p,
[data-theme="dark"] .article-detail-body li,
[data-theme="dark"] .article-detail-body blockquote p {
    color: #cbd5e1;
}

[data-theme="dark"] .article-tags-section {
    border-top-color: #334155;
}

[data-theme="dark"] .article-tag-badge {
    background: linear-gradient(135deg, #334155, #475569);
    color: #cbd5e1;
    border-color: #475569;
}

[data-theme="dark"] .article-tag-badge:hover {
    background: linear-gradient(135deg, #4b7096, #2d4560);
    color: white;
}

[data-theme="dark"] .related-article-excerpt {
    color: #94a3b8;
}

[data-theme="dark"] .related-article-meta {
    border-top-color: #334155;
    color: #64748b;
}

/* Responsive Design */
/* Responsive Design */
@media (max-width: 992px) {
    .related-articles-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .article-detail-title {
        font-size: 2rem;
    }

    .article-detail-body {
        padding: 2rem;
    }
}

@media (max-width: 768px) {
    .article-detail-hero {
        padding-top: 1rem;
    }

    .article-hero-panel {
        padding: 1.5rem 1.35rem 1.35rem;
        border-radius: 16px;
    }

    .article-detail-title {
        font-size: 1.6rem;
    }

    /* เดิมเรียงลงมาทีละบรรทัด ทำให้แผงหัวบทความสูงเกินครึ่งจอมือถือ
       ตอนนี้ .article-hero-meta ห่อบรรทัดได้อยู่แล้ว ปล่อยให้เรียงเป็นแถว */
    .article-hero-meta {
        gap: 0.35rem 0.9rem;
        font-size: 0.82rem;
    }

    /* ชื่อบทความใน breadcrumb ยาวจนตกสามบรรทัด ทั้งที่ <h1> อยู่ใต้ลงมาแค่นิดเดียว
       ตัดด้วยจุดไข่ปลาแทนการซ่อน เพื่อให้ยังเป็นเนื้อหาที่มองเห็นตามที่ schema ควรเป็น */
    .article-breadcrumb .breadcrumb-item.active {
        max-width: 12rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .article-detail-body {
        padding: 1.5rem;
    }

    .article-detail-body h2 {
        font-size: 1.5rem;
    }

    .article-detail-body h3 {
        font-size: 1.25rem;
    }

    .related-articles-grid {
        grid-template-columns: 1fr;
    }

    .share-buttons-modern {
        flex-direction: column;
    }

    .share-btn {
        justify-content: center;
    }
}

/* =====================================================================
   เลย์เอาต์ 2 คอลัมน์ + สารบัญ + Conversion Loop
   เพิ่มตามพิมพ์เขียว "Single Article Page" (2026-09-30)
   ===================================================================== */

/* ---------- Badge หมวดหมู่บนภาพ hero ---------- */

.article-hero-cat {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.9rem;
    padding: 0.35rem 0.9rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.35);
    backdrop-filter: blur(6px);
    color: #fff;
    font-size: 0.82rem;
    font-weight: 600;
    text-decoration: none;
    transition: background-color .25s ease;
}

.article-hero-cat:hover,
.article-hero-cat:focus {
    background: rgba(255, 255, 255, 0.3);
    color: #fff;
    text-decoration: none;
}

/* ---------- คอลัมน์ ---------- */

/* ห้ามใส่ align-items: flex-start ที่แถวนี้
   flex-start ทำให้คอลัมน์ไซด์บาร์สูงเท่าเนื้อหาของมันเอง
   position: sticky ข้างในจึงไม่มีระยะให้เลื่อนตาม และดูเหมือนไม่ทำงาน
   ค่า stretch (ค่าเริ่มต้นของ .row) ยืดคอลัมน์ให้สูงเท่าคอลัมน์เนื้อหา
   สารบัญจึงเกาะอยู่ได้ตลอดความยาวบทความ */
.article-layout {
    align-items: stretch;
}

/* คอลัมน์ขวาเกาะไว้ระหว่างเลื่อนอ่าน
   top เว้นความสูง navbar (sticky-top) ไว้ ไม่ให้สารบัญมุดใต้แถบเมนู */
.article-sidebar-sticky {
    position: sticky;
    top: 80px;
    /* บทความที่หัวข้อเยอะ ไซด์บาร์จะสูงเกินจอ ท้ายกล่องสั่งทำจะโดนตัด
       และเลื่อนลงไปดูไม่ได้เพราะตัวมันเกาะอยู่กับที่
       จำกัดความสูงไว้เท่าจอแล้วให้เลื่อนในตัวเองแทน */
    max-height: calc(100vh - 6rem);
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    /* เผื่อที่ให้เงาของการ์ดข้างใน ไม่ให้ถูก overflow ตัดเป็นขอบคม */
    padding: 6px;
    margin: -6px;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e0 transparent;
}

.article-sidebar-sticky::-webkit-scrollbar {
    width: 6px;
}

.article-sidebar-sticky::-webkit-scrollbar-track {
    background: transparent;
}

.article-sidebar-sticky::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
}

[data-theme="dark"] .article-sidebar-sticky {
    scrollbar-color: #475569 transparent;
}

[data-theme="dark"] .article-sidebar-sticky::-webkit-scrollbar-thumb {
    background: #475569;
}

/* บนเดสก์ท็อปให้มีแถบเลื่อนชั้นเดียวคือของไซด์บาร์
   ถ้าสารบัญเลื่อนในตัวเองด้วย จะกลายเป็นสองแถบซ้อนกันและจับผิดอัน */
@media (min-width: 992px) {
    .article-toc-body {
        max-height: none;
        overflow: visible;
    }
}

/* ---------- สารบัญ ---------- */

.article-toc {
    background: #fff;
    border: 1px solid #e6ebf1;
    border-radius: 16px;
    box-shadow: 0 2px 10px rgba(16, 24, 40, 0.05);
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.article-toc-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    cursor: pointer;
    list-style: none;
    font-weight: 700;
    color: #2d3748;
    font-size: 1rem;
    user-select: none;
}

/* ซ่อนสามเหลี่ยมของ <details> ที่เบราว์เซอร์ใส่มาให้ ใช้ไอคอนของเราเอง */
.article-toc-head::-webkit-details-marker {
    display: none;
}

.article-toc-head::marker {
    content: "";
}

.article-toc-head > span:first-child {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
}

.article-toc-head i:first-child {
    color: var(--color-main, #45637d);
}

.article-toc-head .toc-caret {
    font-size: 0.8rem;
    color: #94a3b8;
    transition: transform .25s ease;
}

.article-toc[open] .article-toc-head .toc-caret {
    transform: rotate(180deg);
}

.article-toc-body {
    padding: 0 1.25rem 1.1rem;
    max-height: min(58vh, 460px);
    overflow-y: auto;
    overscroll-behavior: contain;
}

.article-toc .toc-menu {
    list-style: none;
    margin: 0;
    padding: 0;
    border-left: 2px solid #e6ebf1;
}

.article-toc .toc-menu li {
    margin: 0;
    padding: 0;
}

.article-toc .toc-link {
    display: block;
    padding: 0.42rem 0.75rem;
    margin-left: -2px;
    border-left: 2px solid transparent;
    color: #64748b;
    font-size: 0.9rem;
    line-height: 1.5;
    text-decoration: none;
    transition: color .2s ease, border-color .2s ease;
}

.article-toc .toc-sub-item .toc-link {
    padding-left: 1.6rem;
    font-size: 0.85rem;
}

.article-toc .toc-link:hover,
.article-toc .toc-link:focus {
    color: var(--color-main, #45637d);
    text-decoration: none;
}

/* หัวข้อที่กำลังอ่าน — คลาสนี้ถูกสลับโดย library/js/article-reading.js */
.article-toc .toc-link.is-active {
    color: var(--color-main-active, #354c61);
    border-left-color: var(--color-main, #45637d);
    font-weight: 700;
}

/* เผื่อที่ให้ navbar ตอนกดลิงก์สารบัญแบบไม่มี JavaScript
   (สคริปต์คำนวณ offset จริงให้อยู่แล้ว ตัวนี้เป็นตัวสำรอง) */
.article-detail-body h2,
.article-detail-body h3 {
    scroll-margin-top: 96px;
}

/* ---------- กล่องสั่งทำแบบย่อในไซด์บาร์ ---------- */

.article-side-cta {
    padding: 1.25rem;
    border-radius: 16px;
    border: 1.5px solid #f2d9a6;
    background: linear-gradient(135deg, #fffaf0, #fdf1d8);
    text-align: center;
}

.article-side-cta img {
    width: 100%;
    max-width: 200px;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: 12px;
    margin-bottom: 0.9rem;
}

.side-cta-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    background: #f6c453;
    color: #4a3410;
    font-size: 0.72rem;
    font-weight: 700;
    margin-bottom: 0.6rem;
}

.side-cta-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: #2d3748;
    margin-bottom: 0.4rem;
}

.side-cta-text {
    font-size: 0.86rem;
    color: #6b7280;
    line-height: 1.6;
    margin-bottom: 1rem;
}

/* ---------- กล่องสั่งทำท้ายบทความ ---------- */

.conversion-box {
    display: flex;
    align-items: center;
    gap: 1.75rem;
    margin: 2.5rem 0;
    padding: 1.75rem;
    border-radius: 20px;
    border: 1.5px solid #f2d9a6;
    background: linear-gradient(135deg, #fffaf0, #fdf1d8);
}

.conversion-box-media {
    flex: 0 0 200px;
}

.conversion-box-media img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: 14px;
    box-shadow: 0 4px 14px rgba(120, 90, 20, 0.18);
}

.conversion-box-text {
    flex: 1 1 auto;
    min-width: 0;
}

.conversion-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.85rem;
    border-radius: 999px;
    background: #f6c453;
    color: #4a3410;
    font-size: 0.78rem;
    font-weight: 700;
    margin-bottom: 0.7rem;
}

/* h2 ในกล่องนี้ต้องไม่กินสไตล์ h2 ของเนื้อหาบทความ ซึ่งมีเส้นคาดซ้าย */
.conversion-box-text h2 {
    font-size: 1.35rem;
    font-weight: 700;
    color: #2d3748;
    margin-bottom: 0.55rem;
    border: 0;
    padding: 0;
}

.conversion-box-text p {
    color: #6b7280;
    font-size: 0.95rem;
    line-height: 1.75;
    margin-bottom: 1.1rem;
}

.conversion-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

/* ---------- แถบ CTA ลอยขอบล่าง (มือถือ) ---------- */

.article-cta-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 998;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.7rem 1rem calc(0.7rem + env(safe-area-inset-bottom, 0px));
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(10px);
    border-top: 1px solid #e6ebf1;
    box-shadow: 0 -4px 18px rgba(16, 24, 40, 0.1);
    /* ซ่อนด้วย transform ไม่ใช่ display เพื่อให้เลื่อนขึ้นมาได้นุ่ม */
    transform: translateY(110%);
    transition: transform .3s ease;
    pointer-events: none;
}

.article-cta-bar.is-visible {
    transform: translateY(0);
    pointer-events: auto;
}

.cta-bar-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.3;
}

.cta-bar-text strong {
    font-size: 0.92rem;
    color: #2d3748;
}

.cta-bar-text small {
    font-size: 0.74rem;
    color: #94a3b8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cta-bar-btn {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.65rem 1.1rem;
    border-radius: 10px;
    background: linear-gradient(135deg, #f6c453, #e0a32b);
    color: #3b2a08;
    font-weight: 700;
    font-size: 0.9rem;
    text-decoration: none;
    box-shadow: 0 3px 10px rgba(224, 163, 43, 0.35);
}

.cta-bar-btn:hover,
.cta-bar-btn:focus {
    color: #3b2a08;
    text-decoration: none;
}

/* ยกปุ่มลอย (library/css/fab.css) ขึ้นให้พ้นแถบ CTA
   คลาสนี้ถูกใส่/ถอดที่ <body> โดย library/js/article-reading.js */
body.has-article-cta .mk-fab-stack {
    bottom: calc(86px + env(safe-area-inset-bottom, 0px));
    transition: bottom .3s ease;
}

/* ---------- บทความที่เกี่ยวข้อง: ส่วนที่เพิ่ม ---------- */

.related-article-cat {
    display: inline-block;
    margin-bottom: 0.45rem;
    padding: 0.15rem 0.6rem;
    border-radius: 999px;
    background: #eef2f6;
    color: #64748b;
    font-size: 0.72rem;
    font-weight: 600;
}

.related-more {
    margin-top: 1.5rem;
    text-align: center;
}

.related-more a {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--color-main, #45637d);
    font-weight: 600;
    font-size: 0.95rem;
    text-decoration: none;
}

.related-more a:hover {
    color: var(--color-main-active, #354c61);
    text-decoration: underline;
}

/* =====================================================================
   Dark Mode ของส่วนที่เพิ่ม
   ===================================================================== */

[data-theme="dark"] .article-toc {
    background: #1e293b;
    border-color: #334155;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .article-toc-head {
    color: #e2e8f0;
}

[data-theme="dark"] .article-toc-head i:first-child {
    color: #9dbad6;
}

[data-theme="dark"] .article-toc .toc-menu {
    border-left-color: #334155;
}

[data-theme="dark"] .article-toc .toc-link {
    color: #94a3b8;
}

[data-theme="dark"] .article-toc .toc-link:hover,
[data-theme="dark"] .article-toc .toc-link:focus {
    color: #bcd0e4;
}

[data-theme="dark"] .article-toc .toc-link.is-active {
    color: #d4e2f0;
    border-left-color: #7f9dbb;
}

[data-theme="dark"] .article-side-cta,
[data-theme="dark"] .conversion-box {
    border-color: #6b5320;
    background: linear-gradient(135deg, #2a2312, #3a2f17);
}

[data-theme="dark"] .side-cta-title,
[data-theme="dark"] .conversion-box-text h2 {
    color: #f1e7d0;
}

[data-theme="dark"] .side-cta-text,
[data-theme="dark"] .conversion-box-text p {
    color: #bfae8c;
}

[data-theme="dark"] .article-cta-bar {
    background: rgba(15, 23, 42, 0.97);
    border-top-color: #334155;
    box-shadow: 0 -4px 18px rgba(0, 0, 0, 0.45);
}

[data-theme="dark"] .cta-bar-text strong {
    color: #e2e8f0;
}

[data-theme="dark"] .cta-bar-text small {
    color: #64748b;
}

[data-theme="dark"] .related-article-cat {
    background: #334155;
    color: #94a3b8;
}

[data-theme="dark"] .related-more a {
    color: #9dbad6;
}

/* =====================================================================
   Responsive ของส่วนที่เพิ่ม
   ===================================================================== */

@media (max-width: 991.98px) {

    /* ต่ำกว่า lg คอลัมน์เรียงต่อกัน sticky จึงไม่มีประโยชน์
       ปล่อยให้สารบัญไหลไปกับเนื้อหาตามปกติ
       ต้องคืนค่าความสูงกับ overflow ที่ตั้งไว้สำหรับโหมด sticky ด้วย
       ไม่งั้นกล่องจะถูกจำกัดสูงเท่าจอแล้วมีแถบเลื่อนซ้อนอยู่ข้างในเปล่า ๆ */
    .article-sidebar-sticky {
        position: static;
        top: auto;
        max-height: none;
        overflow: visible;
        padding: 0;
        margin: 0;
    }

    .article-sidebar {
        margin-bottom: 1.75rem;
    }

    .article-toc-body {
        max-height: 50vh;
    }

    .conversion-box {
        flex-direction: column;
        text-align: center;
        padding: 1.5rem 1.25rem;
    }

    .conversion-box-media {
        flex: 0 0 auto;
        max-width: 220px;
    }

    .conversion-actions {
        justify-content: center;
    }

    .conversion-actions .btn-cta,
    .conversion-actions .btn-cta-ghost {
        flex: 1 1 100%;
        justify-content: center;
    }

    /* เว้นที่ท้ายหน้าไว้ให้แถบ CTA ไม่ทับปุ่มกลับหน้ารวมบทความ */
    .article-detail-content {
        padding-bottom: 5.5rem;
    }
}

@media (max-width: 575.98px) {
    .conversion-box-text h2 {
        font-size: 1.15rem;
    }

    .cta-bar-text strong {
        font-size: 0.85rem;
    }

    .cta-bar-btn {
        padding: 0.6rem 0.9rem;
        font-size: 0.85rem;
    }
}

@media (prefers-reduced-motion: reduce) {

    .article-cta-bar,
    .article-toc .toc-link,
    .article-toc-head .toc-caret,
    body.has-article-cta .mk-fab-stack {
        transition: none;
    }
}

/* กล่องสั่งซื้อที่แทรกกลางเนื้อหาด้วย [cta] — เล็กกว่ากล่องท้ายบทความ
   เพราะแทรกคั่นระหว่างย่อหน้า ไม่ควรดึงสายตาไปจากเนื้อหาที่กำลังอ่าน */
.conversion-box-inline {
    gap: 1.25rem;
    margin: 2rem 0;
    padding: 1.25rem;
    border-radius: 16px;
}

.conversion-box-inline .conversion-box-media {
    flex: 0 0 130px;
}

.conversion-box-inline h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: #2d3748;
    margin-bottom: 0.45rem;
    border: 0;
    padding: 0;
}

.conversion-box-inline p {
    font-size: 0.9rem;
    line-height: 1.7;
    margin-bottom: 0.9rem;
}

[data-theme="dark"] .conversion-box-inline h3 {
    color: #f1e7d0;
}

@media (max-width: 575.98px) {
    .conversion-box-inline .conversion-box-media {
        max-width: 160px;
    }
}

/* =====================================================================
   ส่วนท้ายบทความ — แท็ก / แชร์ / บทความที่เกี่ยวข้อง
   ย้ายออกมานอกคอลัมน์เนื้อหา (8/12) แล้วใช้ความกว้างเต็ม container
   ปรับตามฟีดแบ็ก 2026-09-30: ของเดิมถูกบีบจนการ์ดเล็กเกินอ่าน
   ===================================================================== */

.article-footer-sections {
    margin-top: 3rem;
}

/* ---------- แถบแท็ก + แชร์ ---------- */

.article-footer-bar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1.5rem 2.5rem;
    padding: 1.35rem 1.6rem;
    background: #fff;
    border: 1px solid #e6ebf1;
    border-radius: 16px;
    box-shadow: 0 2px 10px rgba(16, 24, 40, .05);
}

.footer-bar-tags {
    flex: 1 1 320px;
    min-width: 0;
}

.footer-bar-share {
    flex: 0 0 auto;
}

.footer-bar-label {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    margin-bottom: 0.7rem;
    color: #94a3b8;
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.footer-bar-label i {
    font-size: 0.8rem;
    color: var(--color-main, #45637d);
}

/* ---------- แท็ก ---------- */

.article-tags-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

/* เดิมเป็นเม็ดใหญ่มีไอคอน # กินพื้นที่เท่ากับหัวข้อย่อย
   แท็กเป็นข้อมูลรอง จึงลดให้เป็นป้ายเล็กสีเรียบ */
.article-tags-list .article-tag-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.22rem 0.62rem;
    border-radius: 6px;
    background: #f1f5f9;
    color: #64748b;
    font-size: 0.78rem;
    font-weight: 500;
    line-height: 1.6;
}

.article-tags-list .article-tag-badge::before {
    content: '#';
    margin-right: .18rem;
    color: #b6c2d1;
}

/* ---------- ปุ่มแชร์ ---------- */

.share-buttons-modern {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* เดิมเป็นปุ่มทึบสีแบรนด์ขนาดใหญ่ 3 ปุ่มเรียงกัน แย่งสายตาไปจากเนื้อหา
   เปลี่ยนเป็นปุ่มเส้นขอบ ติดสีแบรนด์เฉพาะตอน hover */
.article-footer-bar .share-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.45rem 0.85rem;
    border: 1px solid #e2e8f0;
    border-radius: 9px;
    background: #fff;
    color: #475569;
    font-size: 0.82rem;
    font-weight: 600;
    line-height: 1.5;
    text-decoration: none;
    cursor: pointer;
    transition: background-color .2s ease, border-color .2s ease, color .2s ease;
}

.article-footer-bar .share-btn i {
    font-size: 0.9rem;
}

.article-footer-bar .share-btn:hover,
.article-footer-bar .share-btn:focus {
    color: #fff;
    text-decoration: none;
}

.article-footer-bar .share-facebook:hover,
.article-footer-bar .share-facebook:focus {
    background: #1877f2;
    border-color: #1877f2;
}

.article-footer-bar .share-twitter:hover,
.article-footer-bar .share-twitter:focus {
    background: #0f1419;
    border-color: #0f1419;
}

.article-footer-bar .share-line:hover,
.article-footer-bar .share-line:focus {
    background: #06c755;
    border-color: #06c755;
}

.article-footer-bar .share-copy:hover,
.article-footer-bar .share-copy:focus {
    background: var(--color-main, #45637d);
    border-color: var(--color-main, #45637d);
}

/* สถานะหลังกดคัดลอก — สลับคลาสโดย library/js/article-reading.js */
.article-footer-bar .share-copy.is-copied {
    background: #16a34a;
    border-color: #16a34a;
    color: #fff;
}

/* ---------- บทความที่เกี่ยวข้อง ---------- */

.related-articles-modern {
    margin-top: 3rem;
}

.related-articles-modern .related-title {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 1.5rem;
    color: #2d3748;
    font-size: 1.5rem;
    font-weight: 700;
}

.related-articles-modern .related-title i {
    color: var(--color-main, #45637d);
    font-size: 1.3rem;
}

.related-articles-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.75rem;
}

.related-article-card {
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid #e6ebf1;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(16, 24, 40, .05);
    text-decoration: none;
    transition: transform .3s ease, box-shadow .3s ease;
}

.related-article-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 28px rgba(16, 24, 40, .12);
    text-decoration: none;
}

.related-article-image-wrapper {
    position: relative;
    aspect-ratio: 16 / 10;
    overflow: hidden;
    background: #eef2f6;
}

.related-article-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .5s ease;
}

/* เหตุผลเดียวกับการ์ดหน้ารวม: กัน Loading.gif ถูกยืดจนเบลอเต็มกรอบ */
.related-article-image.lazyload {
    object-fit: contain;
    padding: 32%;
    opacity: .45;
}

.related-article-card:hover .related-article-image {
    transform: scale(1.06);
}

/* ไอคอนลูกศรที่ขึ้นตอน hover ทับรูปอยู่เต็มใบ บังรูปโดยไม่ได้บอกอะไรเพิ่ม */
.related-article-overlay {
    display: none;
}

.related-article-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    padding: 1.1rem 1.15rem 1.15rem;
}

.related-article-cat {
    align-self: flex-start;
    display: inline-block;
    margin-bottom: 0.5rem;
    padding: 0.18rem 0.55rem;
    border-radius: 6px;
    background: #eef2f6;
    color: #4b7096;
    font-size: 0.7rem;
    font-weight: 700;
}

.related-article-title {
    margin-bottom: 0.45rem;
    color: #2d3748;
    font-size: 1.02rem;
    font-weight: 700;
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.related-article-card:hover .related-article-title {
    color: var(--color-main, #45637d);
}

.related-article-excerpt {
    margin-bottom: 0.9rem;
    color: #718096;
    font-size: 0.87rem;
    line-height: 1.65;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.related-article-meta {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: auto;
    padding-top: 0.75rem;
    border-top: 1px solid #eef2f6;
    color: #a0aec0;
    font-size: 0.78rem;
}

.related-more {
    margin-top: 1.75rem;
    text-align: center;
}

/* ---------- ปุ่มกลับ ---------- */

.article-back-button {
    margin-top: 2.5rem;
    text-align: center;
}

/* =====================================================================
   Dark Mode — ส่วนท้ายบทความ
   ===================================================================== */

[data-theme="dark"] .article-footer-bar {
    background: #1e293b;
    border-color: #334155;
    box-shadow: 0 2px 10px rgba(0, 0, 0, .3);
}

[data-theme="dark"] .footer-bar-label {
    color: #64748b;
}

[data-theme="dark"] .footer-bar-label i {
    color: #9dbad6;
}

[data-theme="dark"] .article-tags-list .article-tag-badge {
    background: #334155;
    color: #cbd5e1;
}

[data-theme="dark"] .article-tags-list .article-tag-badge::before {
    color: #64748b;
}

[data-theme="dark"] .article-footer-bar .share-btn {
    background: #0f172a;
    border-color: #334155;
    color: #cbd5e1;
}

[data-theme="dark"] .related-articles-modern .related-title {
    color: #e2e8f0;
}

[data-theme="dark"] .related-articles-modern .related-title i {
    color: #9dbad6;
}

[data-theme="dark"] .related-article-card {
    background: #1e293b;
    border-color: #334155;
    box-shadow: 0 2px 10px rgba(0, 0, 0, .3);
}

[data-theme="dark"] .related-article-card:hover {
    box-shadow: 0 12px 28px rgba(0, 0, 0, .45);
}

[data-theme="dark"] .related-article-image-wrapper {
    background: #0f172a;
}

[data-theme="dark"] .related-article-cat {
    background: #334155;
    color: #9dbad6;
}

[data-theme="dark"] .related-article-title {
    color: #e2e8f0;
}

[data-theme="dark"] .related-article-card:hover .related-article-title {
    color: #9dbad6;
}

[data-theme="dark"] .related-article-excerpt {
    color: #94a3b8;
}

[data-theme="dark"] .related-article-meta {
    border-top-color: #334155;
    color: #64748b;
}

/* =====================================================================
   Responsive — ส่วนท้ายบทความ
   ===================================================================== */

@media (max-width: 991.98px) {
    .related-articles-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.25rem;
    }
}

@media (max-width: 767.98px) {
    .article-footer-sections {
        margin-top: 2rem;
    }

    .article-footer-bar {
        flex-direction: column;
        gap: 1.25rem;
        padding: 1.15rem 1.1rem;
    }

    .footer-bar-share,
    .footer-bar-tags {
        flex: 1 1 100%;
        width: 100%;
    }

    /* ปุ่มแชร์แบ่งครึ่งจอ กดง่ายกว่าปุ่มเล็ก 4 อันเรียงชิดกัน
       กฎเดิมที่ @media (max-width: 768px) ตั้ง flex-direction: column ไว้
       ทำให้ปุ่มเรียงลงมาเต็มความกว้างทีละอัน ต้องสั่งกลับเป็น row ตรงนี้ */
    .article-footer-bar .share-buttons-modern {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .article-footer-bar .share-btn {
        flex: 1 1 calc(50% - 0.25rem);
        justify-content: center;
    }

    .related-articles-grid {
        grid-template-columns: 1fr;
    }

    .related-articles-modern .related-title {
        font-size: 1.25rem;
    }
}

@media (prefers-reduced-motion: reduce) {

    .related-article-card,
    .related-article-image,
    .article-footer-bar .share-btn {
        transition: none;
    }

    .related-article-card:hover {
        transform: none;
    }

    .related-article-card:hover .related-article-image {
        transform: none;
    }
}

/* ===================================================================
   กล่องคำถามที่พบบ่อยท้ายบทความ (FAQ)

   FAQ ถูกเก็บเป็น HTML อยู่ใน article_content จึงอยู่ใน .article-detail-body
   ต้อง override สไตล์ h2/h3 ของ body เพื่อให้กล่องนี้ดูแยกออกมาเป็นชุด
   โครง .faq-item / .faq-a ต้องตรงกับ articleFaqItems() ที่อ่านไปทำ schema
   =================================================================== */
.article-detail-body .article-faq {
    margin-top: 2.5rem;
    padding: 1.75rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
}

.article-detail-body .article-faq > h2 {
    margin-top: 0;
    font-size: 1.6rem;
    border-bottom: 2px solid #4b7096;
}

/* หน้าบทความโหลด faq-section.css ตามมาทีหลัง (อยู่ในชุด defer ของ index.php)
   ไฟล์นั้นเขียน .faq-item ไว้เป็นการ์ดขาวของหน้า /faq: background #fff,
   กรอบ 2px, เงา, มุมโค้ง 15px ชื่อคลาสดันตรงกับ FAQ ท้ายบทความพอดี
   จึงต้องล้างค่าพวกนั้นทิ้งที่นี่ก่อน ไม่งั้นโหมดมืดจะได้การ์ดขาวโพลน
   ทุกตัวที่ล้างต้องเขียนเป็นคู่ reset + ค่าจริง ห้ามพึ่งลำดับไฟล์ */
.article-detail-body .faq-item {
    padding: 1.1rem 0;
    margin-bottom: 0;
    background: transparent;
    box-shadow: none;
    border-radius: 0;
    border: 0;
    border-bottom: 1px solid #e2e8f0;
}

/* faq-section.css เปลี่ยนสีกรอบตอน hover ด้วย กันไว้ให้นิ่ง */
.article-detail-body .faq-item:hover {
    box-shadow: none;
    transform: none;
    border-color: transparent;
    border-bottom-color: #e2e8f0;
}

.article-detail-body .faq-item:last-child {
    padding-bottom: 0;
    border-bottom: 0;
}

.article-detail-body .faq-item > h3 {
    display: flex;
    gap: 0.6rem;
    margin: 0 0 0.6rem 0;
    color: #2d3748;
    font-size: 1.15rem;
    line-height: 1.5;
}

/* เครื่องหมายคำถามหน้าหัวข้อ วาดด้วย CSS จะได้ไม่ปนเข้าไปใน schema */
.article-detail-body .faq-item > h3::before {
    content: "?";
    flex: 0 0 1.6rem;
    height: 1.6rem;
    border-radius: 50%;
    background: #4b7096;
    color: #fff;
    font-size: 0.95rem;
    font-weight: 700;
    text-align: center;
    line-height: 1.6rem;
}

.article-detail-body .faq-a {
    padding-left: 2.2rem;
}

.article-detail-body .faq-a p:last-child {
    margin-bottom: 0;
}

/* โหมดมืด
   กล่อง FAQ ฝังสีอ่อนไว้ตายตัว พอ .article-detail-body เปลี่ยนเป็นพื้นเข้ม
   ตัวอักษรในกล่องถูกกฎ dark ของ body เปลี่ยนเป็นสีอ่อนตามไปด้วย
   กลายเป็นตัวอักษรสีอ่อนบนพื้นสีอ่อน อ่านไม่ออก จึงต้องคุมพื้นกับเส้นขอบเอง
   ใช้เฉดเดียวกับส่วนอื่นของไฟล์นี้: พื้น #0f172a เส้น #334155 หัวข้อ #e2e8f0 */
[data-theme="dark"] .article-detail-body .article-faq {
    background: #0f172a;
    border-color: #334155;
}

[data-theme="dark"] .article-detail-body .article-faq > h2 {
    border-bottom-color: #6b8fb8;
}

[data-theme="dark"] .article-detail-body .faq-item {
    background: transparent;
    border-bottom-color: #334155;
}

[data-theme="dark"] .article-detail-body .faq-item:hover {
    border-bottom-color: #334155;
}

[data-theme="dark"] .article-detail-body .faq-item > h3 {
    color: #e2e8f0;
}

[data-theme="dark"] .article-detail-body .faq-item > h3::before {
    background: #6b8fb8;
    color: #0f172a;
}

@media (max-width: 576px) {
    .article-detail-body .article-faq {
        padding: 1.25rem;
    }

    .article-detail-body .faq-a {
        padding-left: 0;
    }
}
