/* topic_styles.css - Fixed Layout Version */
/* ✅ FIXED: Layout conflicts between header and main content */

/* Import Comment Styles */
@import url('topic_styles_comment.css');

/* ==================== CSS VARIABLES ==================== */
:root {
    /* "อัลตร้าส์ ทองประกาศศึก" (Ultras War Gold), chosen by user 2026-08-14 from the theme preview switcher */
    --bg-primary:    #120A0A;
    --bg-secondary:  #000000;
    --bg-card:       #1C1010;
    --bg-hover:      #2A1616;

    --text-primary:   #F5EDE0;
    --text-secondary: #D9C9A8;
    --text-muted:     #A08F6C;
    --text-subtle:    #6B5D45;

    --accent-main:   #C8102E;
    --accent-second: #D4AF37;
    --accent-warm:   #FFD966;
    --accent-danger: #fc8181;

    --border-primary:   #1C1010;
    --border-secondary: #2A1616;

    --gradient-main: linear-gradient(135deg, var(--accent-main), var(--accent-second));
    --gradient-warm: linear-gradient(135deg, var(--accent-warm), #fbb6ce);

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 15px rgba(0,0,0,0.2);
    --shadow-lg: 0 8px 25px rgba(0,0,0,0.3);

    /* view-tier palette */
    --tier-hot:  #ff4757;
    --tier-warm: #ff7f50;
    --tier-mid:  #3d84f7;
    --tier-cool: #FF4500;
}

/* ==================== BASE STYLES ==================== */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.4;
    margin: 0;
    padding: 0;
}

a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.3s ease;
}

a:hover {
    color: var(--text-primary);
}

/* ==================== HEADER LAYOUT (Fixed) ==================== */
.header {
    background: var(--bg-secondary);
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-content {
    max-width: 1200px; 
    margin: 0 auto; 
    padding: 12px 20px; 
    display: flex;
    justify-content: space-between; 
    align-items: center; 
    box-sizing: border-box;
    /* ✅ FIXED: Proper container constraints */
}

.header-left {
    flex: 0 0 auto;
}

.header-right {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Logo Styles */
.logo-link { 
    display: flex; align-items: center; text-decoration: none; 
    transition: all 0.3s ease;
}
.logo-link:hover { transform: scale(1.02); }
.logo-container { display: flex; flex-direction: column; align-items: flex-start; }
.logo-main { display: flex; align-items: center; gap: 8px; margin-bottom: 2px; }
.logo-icon {
    font-size: 28px; background: linear-gradient(135deg, var(--accent-main), var(--accent-second));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; animation: pulse 2s infinite;
}
.logo-text {
    font-size: 22px; background: linear-gradient(135deg, var(--accent-main), var(--accent-second));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; font-weight: 600; margin: 0;
}
.logo-tagline {
    font-size: 11px; color: var(--text-muted); margin: 0; font-weight: 400;
    opacity: 0.8; transition: all 0.3s ease;
}
.logo-link:hover .logo-tagline { opacity: 1; color: var(--accent-main); }

/* Navigation Controls */
.nav-controls { display: flex; align-items: center; gap: 8px; }

.back-btn {
    display: flex; align-items: center; gap: 6px; padding: 8px 16px;
    background: rgba(255, 69, 0, 0.08); border: 1px solid rgba(255, 69, 0, 0.15);
    border-radius: 8px; color: var(--accent-main); text-decoration: none;
    font-size: 14px; font-weight: 500; transition: all 0.3s ease;
}
.back-btn:hover {
    background: rgba(255, 69, 0, 0.12); border-color: rgba(255, 69, 0, 0.25);
    transform: translateY(-1px); box-shadow: 0 4px 15px rgba(255, 69, 0, 0.2);
}

/* Create Post Button */
.create-post-btn {
    width: 36px; height: 36px; border-radius: 8px;
    background: rgba(255, 69, 0, 0.08); border: 1px solid rgba(255, 69, 0, 0.15);
    color: var(--accent-main); cursor: pointer; transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex; align-items: center; justify-content: center; font-size: 14px;
}
.create-post-btn:hover {
    background: rgba(255, 69, 0, 0.12); border-color: rgba(255, 69, 0, 0.25);
    transform: translateY(-1px); box-shadow: 0 8px 25px rgba(255, 69, 0, 0.15);
}

/* Hamburger Menu */
.hamburger-menu {
    width: 36px; height: 36px; background: rgba(160, 174, 192, 0.05);
    border: 1px solid rgba(160, 174, 192, 0.12); border-radius: 8px; cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1); display: flex; flex-direction: column;
    justify-content: center; align-items: center; gap: 4px; padding: 10px;
}
.hamburger-menu:hover {
    background: rgba(160, 174, 192, 0.08); border-color: rgba(255, 69, 0, 0.2);
    transform: translateY(-1px); box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
}
.hamburger-menu span {
    width: 16px; height: 2px; background: var(--text-secondary);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); border-radius: 2px;
}
.hamburger-menu:hover span { background: var(--accent-main); }

/* Auth Section */
.auth-section { display: flex; align-items: center; gap: 10px; }
.user-info { display: flex; align-items: center; gap: 8px; color: var(--text-primary); font-size: 14px; }

/* ✅ FIXED: User Avatar - Proper sizing and overflow control */
.user-avatar {
    width: 32px; height: 32px; border-radius: 50%; background: var(--accent-main);
    display: flex; align-items: center; justify-content: center; font-size: 14px;
    font-weight: 600; color: white; overflow: hidden; flex-shrink: 0; position: relative;
}
.user-avatar img { 
    width: 100%; height: 100%; object-fit: cover; 
    max-width: 100%; max-height: 100%; position: absolute; top: 0; left: 0; border-radius: 50%;
}

/* Google Auth Button */
.google-auth-btn {
    background: white; border: 1px solid #dadce0; border-radius: 50%;
    width: 40px; height: 40px; display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: all 0.3s ease; box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.google-auth-btn:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.15); transform: translateY(-1px);
}
.google-logo { width: 16px; height: 16px; }

/* Breadcrumb Navigation */
.breadcrumb-nav {
    background: linear-gradient(135deg, rgba(45, 55, 72, 0.8), rgba(74, 85, 104, 0.6));
    border-bottom: 1px solid var(--border-primary); 
    /*top: 65px; /* ✅ FIXED: Adjust based on header height */
    z-index: 99; 
    backdrop-filter: blur(8px);
}
.breadcrumb-container {
    max-width: 1200px; margin: 0 auto; padding: 6px 20px; display: flex;
    align-items: center; gap: 4px; font-size: 11px; flex-wrap: wrap;
}
.breadcrumb-item {
    display: flex; align-items: center; gap: 4px; padding: 3px 6px;
    border-radius: 4px; color: var(--text-muted); text-decoration: none;
    transition: all 0.3s ease; white-space: nowrap;
}
.breadcrumb-item:hover { background: rgba(74, 85, 104, 0.2); color: var(--text-secondary); }
.breadcrumb-item.current {
    color: var(--text-secondary); background: rgba(74, 85, 104, 0.15);
    border: 1px solid rgba(74, 85, 104, 0.3);
}
.breadcrumb-separator { color: var(--text-muted); font-size: 8px; margin: 0 1px; opacity: 0.6; }

.debug-badge {
    background: linear-gradient(135deg, #ef4444, #dc2626); color: white;
    padding: 4px 8px; border-radius: 4px; font-size: 10px; font-weight: 600;
}

/* ==================== MAIN LAYOUT (Fixed) ==================== */
/* ✅ FIXED: Main container with proper spacing and constraints */
.main-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 20px;
    /* ✅ FIXED: Ensure it doesn't conflict with header */
    box-sizing: border-box;
    min-height: calc(100vh - 120px); /* Account for header + breadcrumb */
}

/* ==================== BUTTONS ==================== */
.btn, .btn-small {
    padding: 8px 16px;
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    background: var(--bg-card);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-small {
    padding: 4px 8px;
    font-size: 11px;
}

.btn:hover, .btn-small:hover {
    background: var(--bg-hover);
    transform: translateY(-1px);
}

.btn.primary {
    background: var(--gradient-main);
    border-color: var(--accent-main);
    color: white;
}

.btn.danger {
    background: linear-gradient(135deg, var(--accent-danger), #f56565);
    border-color: var(--accent-danger);
    color: white;
}

/* ==================== TOPIC CARD ==================== */
.topic-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--shadow-md);
    margin-bottom: 20px;
    /* ✅ FIXED: Ensure proper width constraints */
    width: 100%;
    box-sizing: border-box;
}

.topic-header {
    padding: 20px 20px 16px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-primary);
}

.topic-meta {
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.topic-meta i {
    color: var(--accent-main);
}

.topic-meta-fixture i {
    color: #D4AF37;
}

.verified-badge {
    background: var(--gradient-main);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
}

.topic-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 15px;
    line-height: 1.3;
    /* ✅ FIXED: Prevent text overflow */
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.topic-stats {
    display: flex;
    gap: 20px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(255, 69, 0, 0.1);
    border: 1px solid rgba(255, 69, 0, 0.3);
    border-radius: 20px;
    font-size: 12px;
    color: var(--text-muted);
}

.stat-item i {
    color: var(--accent-main);
}

.topic-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.action-btn {
    padding: 8px 16px;
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
}

.action-btn:hover {
    background: rgba(255, 69, 0, 0.1);
    border-color: var(--accent-main);
    color: var(--accent-main);
    transform: translateY(-1px);
}

.action-btn.liked {
    background: rgba(236, 72, 153, 0.2);
    border-color: #ec4899;
    color: #ec4899;
}

/* ==================== TOPIC CONTENT ==================== */
.topic-content {
    padding: 20px 20px 10px;
    font-size: 16px;
    line-height: 1.7;
    color: var(--text-secondary);
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}

/* ==================== COMPACT STATS INFOGRAPHIC (csi) ==================== */

.topic-stats, .topic-actions { display: none; }

.csi-block {
    padding: 10px 0 16px;
    margin-bottom: 18px;
    border-bottom: 1px solid rgba(74,85,104,0.45);
}

/* meta chips row */
.csi-meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 10px;
}
.csi-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 20px;
    background: rgba(74,85,104,0.25);
    font-size: 10px;
    color: var(--text-muted);
    white-space: nowrap;
}
.csi-chip i { font-size: 9px; }
.csi-chip.csi-yt  { background: rgba(255,50,50,0.1); color: #fc8181; border: 1px solid rgba(255,80,80,0.2); }
.csi-chip.csi-fire{ background: rgba(246,173,85,0.1); color: #f6ad55; border: 1px solid rgba(246,173,85,0.2); }
.csi-block-flex { display: flex; flex-direction: column; align-items: stretch; gap: 10px; }
.csi-block-content { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* ── ตราสโมสร: อยู่บนสุด กึ่งกลาง ใหญ่ขึ้น + คลื่นเรเดียนวิ่งออก + วงแหวนขีดหมุนรอบตัว (ไม่มีชื่อทีม/เส้นแสงแฉกแล้วตามที่ขอ) ── */
/* margin: auto 0 ทำให้ flexbox ดันโลโก้ไปอยู่กึ่งกลางแนวตั้งของพื้นที่ว่างจริงเสมอ (ไม่ใช่แค่กึ่งกลาง "ลำดับที่" ระหว่าง
   3 บล็อก) ต่อให้แถบ meta-row ด้านบน (ชื่อสำนักข่าว/วันที่) ไม่โชว์ (ข่าวส่วนใหญ่ไม่มีสถิติวิดีโอต้นฉบับ) โลโก้ก็ยังลง
   มาอยู่กลางจริงๆ แทนที่จะค้างอยู่บนสุดเพราะไม่มีอะไรอยู่เหนือมัน */
.csi-team-badge-block { display: flex; align-items: center; justify-content: center; align-self: center; text-decoration: none; margin: auto 0; }
.csi-team-badge-wrap { position: relative; width: 72px; height: 72px; display: flex; align-items: center; justify-content: center; }
.csi-team-badge {
    position: relative; z-index: 2; width: 72px; height: 72px; border-radius: 50%;
    background: rgba(255,255,255,.95); display: flex; align-items: center; justify-content: center;
    box-shadow: 0 0 0 2.5px color-mix(in srgb, var(--tcp) 60%, transparent), 0 4px 16px rgba(0,0,0,.35);
    animation: csiBadgeGlow 2.4s ease-in-out infinite;
    transition: transform .2s ease;
}
.csi-team-badge-block:hover .csi-team-badge { transform: scale(1.06); }
.csi-team-badge img { width: 46px; height: 46px; object-fit: contain; }
@keyframes csiBadgeGlow {
    0%, 100% { box-shadow: 0 0 0 2.5px color-mix(in srgb, var(--tcp) 60%, transparent), 0 4px 16px rgba(0,0,0,.35); }
    50%      { box-shadow: 0 0 0 3px color-mix(in srgb, var(--tcp) 78%, transparent), 0 0 20px color-mix(in srgb, var(--tcp) 65%, transparent), 0 4px 16px rgba(0,0,0,.35); }
}
/* คลื่นเรเดียน (sonar ping) วิ่งขยายออกจากโลโก้เป็นวงๆ ต่อเนื่อง */
.csi-team-ripples { position: absolute; inset: 0; z-index: 0; pointer-events: none; }
.csi-team-ripples span {
    position: absolute; inset: 0; border-radius: 50%;
    border: 1.5px solid var(--tcp); opacity: 0;
    animation: csiRipplePing 2.7s cubic-bezier(.2,.6,.35,1) infinite;
}
.csi-team-ripples span:nth-child(2) { animation-delay: .9s; }
.csi-team-ripples span:nth-child(3) { animation-delay: 1.8s; }
@keyframes csiRipplePing { 0% { transform: scale(1); opacity: .85; } 100% { transform: scale(2.5); opacity: 0; } }

/* วงแหวนขีดหมุนรอบโลโก้ ให้ดูล้ำๆ แบบเรดาร์ */
.csi-team-orbit {
    position: absolute; inset: -9px; z-index: 1; border-radius: 50%;
    border: 1.5px dashed color-mix(in srgb, var(--tcp) 65%, transparent);
    animation: csiOrbitSpin 7s linear infinite;
}
@keyframes csiOrbitSpin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
    .csi-team-badge, .csi-team-ripples span, .csi-team-orbit { animation: none; }
    .csi-team-ripples { display: none; }
}

/* bars */
.csi-bars-wrap { display: flex; flex-direction: column; gap: 5px; margin-bottom: 10px; }

.csi-bar-row {
    display: grid;
    grid-template-columns: 13px 1fr 36px;
    align-items: center;
    gap: 8px;
}
.csi-bar-row i { font-size: 10px; text-align: center; }
.csi-icon-views { color: #63b3ed; }
.csi-icon-likes { color: #FF4500; }
.csi-icon-cmts  { color: #b794f4; }
.csi-icon-read  { color: #FFD635; }

.csi-track {
    height: 5px;
    background: rgba(255,255,255,0.06);
    border-radius: 10px;
    overflow: hidden;
}
.csi-fill {
    height: 100%;
    border-radius: 10px;
    width: 0%;
    transition: width 1s cubic-bezier(.4,0,.2,1);
}
.csi-fill-views { background: linear-gradient(90deg,#3b82f6,#63b3ed); box-shadow: 0 0 6px rgba(99,179,237,.3); }
.csi-fill-likes { background: linear-gradient(90deg,#38a169,#FF4500); box-shadow: 0 0 6px rgba(255, 69, 0,.3); }
.csi-fill-cmts  { background: linear-gradient(90deg,#805ad5,#b794f4); box-shadow: 0 0 6px rgba(183,148,244,.3); }

.csi-val {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    text-align: right;
    white-space: nowrap;
}

/* action row */
.csi-action-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
/* เวอร์ชันในกรอบการ์ด (ใต้โลโก้สโมสร) — เว้นเส้นคั่นด้านบนกันรู้สึกติดกัน + จัดกลางให้เข้ากับการ์ดแคบ */
.csi-action-row--incard {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(255,255,255,0.07);
    justify-content: center;
}
.csi-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 18px;
    border: 1px solid rgba(255, 69, 0,0.2);
    background: rgba(255, 69, 0,0.06);
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all .2s ease;
    line-height: 1;
}
.csi-btn i { font-size: 11px; color: var(--accent-main); }
.csi-btn:hover { background: rgba(255, 69, 0,0.13); color: var(--text-primary); transform: translateY(-1px); }
.csi-like i  { color: #f472b6; }
.csi-like.liked { background: rgba(244,114,182,0.12); border-color: #f472b6; color: #f472b6; }
.csi-share i { color: var(--accent-second); }
.csi-share  { padding: 4px 9px; }

.csi-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 9px;
    border-radius: 18px;
    background: rgba(74,85,104,0.2);
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1;
}
.csi-pill i { font-size: 10px; color: var(--text-subtle); }

@media (max-width: 480px) {
    .csi-bar-row { grid-template-columns: 12px 1fr 30px; gap: 6px; }
    .csi-btn  { font-size: 11px; padding: 4px 8px; }
    .csi-pill { font-size: 10px; padding: 3px 7px; }
}

/* ==================== MAGAZINE CONTENT STYLES ==================== */

/* ลบกรอบซ้อน — เนื้อหาอยู่โดยตรงใน topic-content */
.ai-content-section {
    width: 100%;
    box-sizing: border-box;
}

.ai-section-content {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Magazine Drop Cap สำหรับย่อหน้าแรก */
.ai-summary > p:first-of-type::first-letter,
.ai-summary::first-letter {
    font-size: 3.8em;
    font-weight: 800;
    float: left;
    line-height: 0.8;
    margin: 4px 8px 0 0;
    color: var(--accent-main);
    font-family: Georgia, serif;
}

/* Magazine body text */
.ai-summary {
    font-size: 17px;
    line-height: 1.4;
    color: var(--text-secondary);
    letter-spacing: 0.01em;
    position: relative;
    padding: 0;
    margin: 0;
    background: none;
    border: none;
    font-style: normal;
}

/* เทมเพลตข่าวที่ AI สร้าง (generate_news.php) ฝัง <h1> หัวข้อซ้ำไว้ในเนื้อหาเองอยู่แล้ว (ต่อจาก badge
   ป้ายหมวดข่าว) ซ้ำกับ <h1 class="topic-title"> ที่หน้าแสดงไว้บนสุดแล้ว — ซ่อนตัวที่ซ้ำ (ตัวใน body) ทิ้ง
   เก็บไว้แค่ตัวบนสุดของหน้าเท่านั้น */
.ai-summary h1:first-of-type { display: none; }

/* ── การ์ดรูปบุคคลจริง (นักเตะ/ผู้จัดการทีม) ในข่าว — โผล่ทันทีตอนเปิดอ่าน ก่อนย่อหน้าแรก
   (autofootball/generate_news.php แทรก HTML นี้ตอน generate จากรูปจริงของ TheSportsDB เท่านั้น
   ไม่มีรูป = ไม่แทรก) ใช้ --tcp (สีทีมในข่าวนั้น) ตัวแปรเดียวกับที่การ์ดตราสโมสรบนหน้านี้ใช้อยู่แล้ว ── */
.an-person-strip { display: flex; gap: 10px; flex-wrap: wrap; margin: 0 0 22px; }
.an-person-card {
    display: flex; align-items: center; gap: 10px; flex: 1; min-width: 200px;
    background: rgba(255,255,255,.03);
    border: 1px solid color-mix(in srgb, var(--tcp, #D4AF37) 35%, transparent);
    border-radius: 14px;
    padding: 8px 16px 8px 8px;
    text-decoration: none; cursor: pointer;
    transition: transform .2s ease, background .2s ease;
}
.an-person-card:hover { transform: translateY(-2px); background: rgba(255,255,255,.05); }
.an-person-photo-wrap { position: relative; flex-shrink: 0; display: inline-flex; }
.an-person-photo {
    width: 54px; height: 54px; border-radius: 50%; object-fit: cover; object-position: top center;
    background: rgba(255,255,255,.08); flex-shrink: 0;
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--tcp, #D4AF37) 55%, transparent), 0 3px 10px rgba(0,0,0,.35);
    animation: anPersonGlow 2.6s ease-in-out infinite;
}
/* ── คะแนนความสามารถ (OVR) — โผล่มุมล่างขวารูป เฉพาะคนที่มีข้อมูลจริงแล้ว ── */
.an-person-ovr {
    position: absolute; bottom: -2px; right: -2px; min-width: 20px; height: 20px; padding: 0 4px;
    border-radius: 10px; background: linear-gradient(135deg, #2ecc71, #1a9c53); color: #06210f;
    font-size: .62rem; font-weight: 900; display: flex; align-items: center; justify-content: center;
    box-shadow: 0 2px 6px rgba(0,0,0,.4), 0 0 0 2px #11181c;
}
@keyframes anPersonGlow {
    0%, 100% { box-shadow: 0 0 0 2px color-mix(in srgb, var(--tcp, #D4AF37) 55%, transparent), 0 3px 10px rgba(0,0,0,.35); }
    50%      { box-shadow: 0 0 0 2px color-mix(in srgb, var(--tcp, #D4AF37) 75%, transparent), 0 0 12px color-mix(in srgb, var(--tcp, #D4AF37) 55%, transparent), 0 3px 10px rgba(0,0,0,.35); }
}
.an-person-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.an-person-name { font-weight: 800; font-size: .95rem; color: var(--text-primary); line-height: 1.25; }
.an-person-role { font-size: .74rem; color: var(--text-muted); line-height: 1.3; }
@media (max-width: 480px) {
    .an-person-strip { flex-direction: column; }
    .an-person-card { min-width: 0; }
}
@media (prefers-reduced-motion: reduce) {
    .an-person-photo { animation: none; }
}

/* ── ep-* — DeepSeek มักสร้างองค์ประกอบเสริม (หัวข้อย่อย/กรอบคำคม/กรอบไฮไลต์) เป็น class พวกนี้แทนที่จะ
   ทำตาม inline-style ตรงๆ ตามพรอมต์เป๊ะ (พฤติกรรมที่ควบคุมยากฝั่ง prompt) เดิมไม่มี CSS รองรับเลย เลยโชว์
   เป็นตัวหนังสือเปล่าๆ ไม่มีสไตล์ — เป็นสาเหตุหลักที่บางบทความ "ดูเล็ก/แบน" ทั้งที่มีองค์ประกอบครบ
   แก้ตรงนี้จุดเดียวมีผลย้อนหลังกับบทความเก่าที่บันทึกไว้แล้วในฐานข้อมูลด้วย ── */
.ep-label { display: flex; align-items: center; gap: 10px; margin: 28px 0 14px; }
.ep-label-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent-second); flex-shrink: 0; box-shadow: 0 0 8px var(--accent-second); }
.ep-label-text { font-size: 11px; font-weight: 800; letter-spacing: 3px; text-transform: uppercase; color: var(--accent-second); white-space: nowrap; }
.ep-label-line { flex: 1; height: 1px; background: linear-gradient(90deg, rgba(212,175,55,.4), transparent); }

.ep-quote { border-top: 1px solid rgba(255,255,255,.15); border-bottom: 1px solid rgba(255,255,255,.15); padding: 20px 10px; margin: 28px 0; text-align: center; }
.ep-quote-mark { font-size: 2.6rem; font-family: Georgia, serif; color: var(--accent-second); line-height: 1; margin-bottom: 4px; opacity: .75; }
.ep-quote-text { font-style: italic; font-size: 1.1rem; color: var(--text-primary); line-height: 1.55; }

.ep-callout { display: flex; gap: 14px; align-items: flex-start; background: rgba(200,16,46,.08); border: 1px solid rgba(200,16,46,.28); border-radius: 10px; padding: 18px 20px; margin: 30px 0; }
.ep-callout-icon { font-size: 1.4rem; flex-shrink: 0; line-height: 1.3; }
.ep-callout-text { font-size: 1rem; line-height: 1.6; color: var(--text-primary); }

.ai-summary::before { display: none; }

/* Reading progress bar ด้านบนเนื้อหา */
.reading-progress-bar {
    height: 3px;
    background: linear-gradient(90deg, var(--accent-main), var(--accent-second));
    border-radius: 2px;
    margin-bottom: 24px;
    transform-origin: left;
    transition: width 0.3s ease;
}

/* Pull quote / highlight box */
.pull-quote {
    border-left: 4px solid var(--accent-main);
    padding: 12px 20px;
    margin: 28px 0;
    background: rgba(255, 69, 0, 0.06);
    border-radius: 0 8px 8px 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--accent-main);
    line-height: 1.5;
}

/* Section divider magazine style */
.section-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 28px 0;
}
.section-divider::before,
.section-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border-primary), transparent);
}
.section-divider-icon {
    color: var(--accent-main);
    font-size: 14px;
    opacity: 0.7;
}

/* Readability score badge */
.readability-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 69, 0, 0.1);
    border: 1px solid rgba(255, 69, 0, 0.25);
    border-radius: 20px;
    padding: 4px 12px;
    font-size: 11px;
    color: var(--accent-main);
    margin-bottom: 16px;
}
.readability-stars {
    color: #FFD635;
    font-size: 10px;
    letter-spacing: 1px;
}

/* Estimated reading time */
.reading-meta-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 0 20px 0;
    border-bottom: 1px solid rgba(74, 85, 104, 0.4);
    margin-bottom: 24px;
    font-size: 12px;
    color: var(--text-muted);
    flex-wrap: wrap;
}
.reading-meta-bar i { color: var(--accent-main); margin-right: 4px; }

/* Key points highlight */
.key-points-box {
    background: linear-gradient(135deg, rgba(255, 69, 0, 0.08), rgba(0, 121, 211, 0.05));
    border: 1px solid rgba(255, 69, 0, 0.2);
    border-radius: 12px;
    padding: 16px 20px;
    margin: 24px 0;
}
.key-points-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--accent-main);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.key-points-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.key-points-list li {
    padding: 4px 0 4px 20px;
    position: relative;
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
}
.key-points-list li::before {
    content: '▸';
    position: absolute;
    left: 0;
    color: var(--accent-main);
}

/* detail2 content — magazine style continuation */
.detail2-content {
    font-size: 16px;
    line-height: 1.85;
    color: var(--text-secondary);
    margin-top: 20px;
    letter-spacing: 0.01em;
}

/* Footer brand stamp */
.brand-stamp {
    text-align: center;
    padding: 16px 0 8px;
}
.brand-stamp-inner {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, rgba(255, 69, 0,0.1), rgba(0, 121, 211,0.08));
    border: 1px solid rgba(255, 69, 0,0.2);
    border-radius: 30px;
    padding: 6px 20px;
    font-size: 13px;
    font-weight: 600;
    color: var(--accent-main);
}

.ai-title {
    font-size: 20px;
    font-weight: 600;
    background: var(--gradient-main);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 15px;
}

.detail-title {
    color: var(--accent-main);
    margin: 20px 0 10px 0;
}

.detail-title.secondary {
    color: var(--accent-second);
}

/* ==================== MOBILE MAGAZINE OPTIMIZATIONS ==================== */
@media (max-width: 768px) {
    .ai-summary {
        font-size: 16px;
        line-height: 1.8;
    }
    .ai-summary::first-letter,
    .ai-summary > p:first-of-type::first-letter {
        font-size: 3.2em;
    }
    .pull-quote {
        font-size: 16px;
        padding: 10px 16px;
        margin: 20px 0;
    }
    .key-points-box {
        padding: 14px 16px;
    }
    .reading-meta-bar {
        gap: 12px;
    }
}

@media (max-width: 480px) {
    .ai-summary {
        font-size: 15px;
        line-height: 1.75;
    }
    .reading-meta-bar {
        font-size: 11px;
    }
}

.topic-tags {
    padding: 0 25px 25px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.topic-tags .tag {
    background: rgba(255, 69, 0, 0.1);
    color: var(--accent-main);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    border: 1px solid rgba(255, 69, 0, 0.3);
    cursor: pointer;
    transition: all 0.3s ease;
}

.topic-tags .tag:hover {
    background: rgba(255, 69, 0, 0.2);
    transform: translateY(-1px);
}

/* ==================== SIDEBAR ==================== */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
    /* ✅ FIXED: Ensure sidebar doesn't overflow */
    min-width: 0; /* Allow shrinking */
    max-width: 300px;
}

.sidebar-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--shadow-md);
    /* ✅ FIXED: Proper width constraints */
    width: 100%;
    box-sizing: border-box;
}

.sidebar-header {
    background: var(--bg-card);
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-primary);
}

.sidebar-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-content {
    padding: 20px;
}

.video-preview {
    position: relative;
    margin-bottom: 15px;
    border-radius: 12px;
    overflow: hidden;
}

.video-thumbnail {
    width: 100%;
    height: 160px;
    object-fit: cover;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.video-thumbnail:hover {
    transform: scale(1.05);
}

.play-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,0.7);
    color: white;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.play-overlay:hover {
    background: var(--accent-main);
    transform: translate(-50%, -50%) scale(1.1);
}

.video-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
    line-height: 1.4;
}

.video-channel {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.video-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 15px;
}

.video-stat {
    background: var(--bg-primary);
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
    border: 1px solid var(--border-primary);
}

.video-stat i {
    color: var(--accent-main);
    margin-right: 4px;
}

.video-actions {
    display: flex;
    gap: 8px;
}

.video-btn {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    text-decoration: none;
}

.video-btn.primary {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
}

.video-btn.secondary {
    background: transparent;
    border: 1px solid var(--border-primary);
    color: var(--text-muted);
}

.video-btn:hover {
    filter: brightness(1.1);
    color: white;
}

.video-btn.secondary:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* Related Topics */
.related-topic {
    background: var(--bg-primary);
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    color: var(--text-secondary);
}

.related-topic:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--accent-main);
    transform: translateY(-1px);
}

.related-header {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 8px;
}

.related-title {
    font-size: 13px;
    font-weight: 500;
    color: inherit;
    line-height: 1.3;
    flex: 1;
}

.related-preview {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 8px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.related-meta {
    font-size: 10px;
    color: var(--text-muted);
    display: flex;
    gap: 10px;
}

.related-meta i {
    color: var(--accent-main);
}

/* Tag Container */
.tag-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag-container .tag {
    background: rgba(255, 69, 0, 0.1);
    color: var(--accent-main);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    border: 1px solid rgba(255, 69, 0, 0.3);
    cursor: pointer;
    transition: all 0.3s ease;
}

.tag-container .tag:hover {
    background: rgba(255, 69, 0, 0.2);
    transform: translateY(-1px);
}

/* ==================== NOTIFICATIONS ==================== */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: 8px;
    color: white;
    font-size: 14px;
    z-index: 10000;
    transform: translateX(400px);
    transition: transform 0.3s ease;
    box-shadow: var(--shadow-lg);
    max-width: 300px;
}

.notification.success { background: linear-gradient(135deg, #10b981, #059669); }
.notification.error { background: linear-gradient(135deg, #ef4444, #dc2626); }
.notification.warning { background: linear-gradient(135deg, #f59e0b, #d97706); }
.notification.info { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.notification.show { transform: translateX(0); }

/* ==================== ANIMATIONS ==================== */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* ==================== MOBILE RESPONSIVE (Enhanced) ==================== */
@media (max-width: 768px) {
    /* Header Mobile Adjustments */
    .header-content { 
        padding: 12px 15px; 
    }
    
    .logo-icon { font-size: 24px; }
    .logo-text { font-size: 18px; }
    .logo-tagline { font-size: 9px; }
    .back-btn span { display: none; }
    .breadcrumb-nav { top: 55px; }
    .user-info span { display: none; }
    .user-avatar { width: 28px; height: 28px; font-size: 12px; flex-shrink: 0; }
    .create-post-btn, .hamburger-menu { width: 32px; height: 32px; font-size: 13px; }
    .google-auth-btn { width: 36px; height: 36px; }
    .google-logo { width: 14px; height: 14px; }
    
    /* Main Menu Mobile */
    .main-menu { width: 100%; max-width: 280px; }
    .quick-nav-grid { grid-template-columns: repeat(2, 1fr); }
    
    /* Main Container Mobile */
    .main-container {
        grid-template-columns: 1fr;
        padding: 15px;
        gap: 15px;
        min-height: calc(100vh - 100px);
    }
    
    .sidebar { 
        order: 2; 
        max-width: 100%;
    }
    
    .topic-header, 
    .topic-content {
        padding: 16px 14px;
    }
    
    .topic-title { 
        font-size: 20px; 
    }
    
    .topic-actions, 
    .topic-stats {
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .video-stats { 
        grid-template-columns: 1fr; 
    }
    
    .video-actions { 
        flex-direction: column; 
    }
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

@media (max-width: 480px) {
    .topic-header,
    .topic-content {
        padding: 14px 12px;
    }
    
    .topic-title {
        font-size: 18px;
    }
    
    .main-container {
        padding: 8px;
    }
}

/* ==================== LOADING AND ERROR STATES ==================== */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

.loading i {
    animation: spin 1s linear infinite;
    font-size: 24px;
    color: var(--accent-main);
    margin-bottom: 10px;
}

.error-state {
    text-align: center;
    padding: 40px;
    color: var(--accent-danger);
    background: rgba(252, 129, 129, 0.1);
    border: 1px solid rgba(252, 129, 129, 0.3);
    border-radius: 12px;
    margin: 20px 0;
}

/* ==================== ACCESSIBILITY IMPROVEMENTS ==================== */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Focus indicators */
button:focus,
a:focus,
input:focus,
textarea:focus {
    outline: 2px solid var(--accent-main);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --bg-primary: #000000;
        --bg-secondary: #1a1a1a;
        --text-primary: #d7dadc;
        --border-primary: #666666;
    }
}

/* ==================== VIEW TIER CARDS ==================== */

.rt-card { background: rgba(45,55,72,0.8); border: 1px solid rgba(74,85,104,0.5); }

.rt-card.tier-hot {
    background: linear-gradient(135deg, rgba(255,71,87,.12) 0%, rgba(45,55,72,0.85) 60%);
    border-color: rgba(255,71,87,.25);
}
.rt-card.tier-warm {
    background: linear-gradient(135deg, rgba(255,127,80,.10) 0%, rgba(45,55,72,0.85) 60%);
    border-color: rgba(255,127,80,.22);
}
.rt-card.tier-mid {
    background: linear-gradient(135deg, rgba(61,132,247,.10) 0%, rgba(45,55,72,0.85) 60%);
    border-color: rgba(61,132,247,.2);
}

.rt-card .rt-accent-line { background: var(--tc, var(--accent-main)); }
.rt-card.tier-hot  { --tc: var(--tier-hot);  }
.rt-card.tier-warm { --tc: var(--tier-warm); }
.rt-card.tier-mid  { --tc: var(--tier-mid);  }
.rt-card.tier-cool { --tc: var(--tier-cool); }

.rt-tier-badge {
    position: absolute;
    top: 7px; right: 7px;
    font-size: 9px; font-weight: 700;
    letter-spacing: .6px;
    text-transform: uppercase;
    padding: 2px 6px;
    border-radius: 4px;
    color: #fff;
    background: var(--tc, var(--accent-main));
    opacity: .9;
}
.rt-card { position: relative; }

.rt-card.tier-hot .rt-accent-line {
    animation: flamePulse 1.8s ease-in-out infinite;
}
@keyframes flamePulse {
    0%,100% { opacity:.85; }
    50%      { opacity:1; box-shadow: 0 0 8px rgba(255,71,87,.5); }
}

.rt-card.tier-hot  .rt-icon-wrap { color: var(--tier-hot)  !important; }
.rt-card.tier-warm .rt-icon-wrap { color: var(--tier-warm) !important; }
.rt-card.tier-mid  .rt-icon-wrap { color: var(--tier-mid)  !important; }
.rt-card.tier-cool .rt-icon-wrap { color: var(--tier-cool) !important; }

/* ── การ์ดแดง-ดำเข้ากับธีม War Gold ของหน้าแรก (เดิมเป็นโทน slate navy ของโปรเจกต์ก่อน ไม่เคย retheme) ── */
.rt-sidebar-card {
    background: #1a1010;
    border-color: rgba(255,255,255,.07);
    box-shadow: 0 4px 20px rgba(0,0,0,.35);
}

.rt-sidebar-card .sidebar-content { background: transparent; padding: 10px 12px 12px; }

/* ── โลโก้เล็ก KickTH ── */
.rt-logo-mark {
    display: inline-flex;
    align-items: baseline;
    gap: 0;
    background: rgba(200,16,46,.14);
    border: 1px solid rgba(200,16,46,.28);
    border-radius: 5px;
    padding: 3px 6px 3px 5px;
    flex-shrink: 0;
    line-height: 1;
}
.rt-logo-mark-sm { padding: 2px 5px 2px 4px; }
.rt-logo-ai {
    font-size: 13px;
    font-weight: 900;
    letter-spacing: -0.5px;
    color: #C8102E;
    font-family: -apple-system, 'Segoe UI', sans-serif;
}
.rt-logo-th {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1px;
    color: rgba(255,255,255,.45);
    font-family: -apple-system, 'Segoe UI', sans-serif;
}

/* header text */
.rt-sidebar-card .rt-sidebar-label { color: #D9C9A8; font-size: 12px; letter-spacing: 2px; }
.rt-sidebar-card .rt-sidebar-sub   { color: #A08F6C; letter-spacing: 3px; }
.rt-sidebar-card .rt-sidebar-line  { background: linear-gradient(90deg, rgba(200,16,46,.3), transparent); }

/* cards inside */
.rt-sidebar-card .rt-card {
    background: rgba(255,255,255,.04);
    border-color: rgba(255,255,255,.07);
}
.rt-sidebar-card .rt-card:hover {
    background: rgba(255,255,255,.08);
    transform: translateX(3px);
    box-shadow: 0 2px 12px rgba(0,0,0,.25);
}
.rt-sidebar-card .rt-card.tier-hot {
    background: linear-gradient(135deg, rgba(255,71,87,.1) 0%, rgba(26,16,16,.9) 60%);
    border-color: rgba(255,71,87,.2);
}
.rt-sidebar-card .rt-card.tier-warm {
    background: linear-gradient(135deg, rgba(255,127,80,.09) 0%, rgba(26,16,16,.9) 60%);
    border-color: rgba(255,127,80,.18);
}
.rt-sidebar-card .rt-card.tier-mid {
    background: linear-gradient(135deg, rgba(61,132,247,.09) 0%, rgba(26,16,16,.9) 60%);
    border-color: rgba(61,132,247,.18);
}

/* text สีอ่อนบน dark — ใช้โทนทองอบอุ่นแทนฟ้าเทาเดิม */
.rt-sidebar-card .rt-title   { color: #F5EDE0; font-size: 12.5px; }
.rt-sidebar-card .rt-preview { color: #B8A888; opacity: 1; }
.rt-sidebar-card .rt-foot span { color: #A08F6C; }
.rt-sidebar-card .rt-card .rt-stat-nerds { border-color: rgba(255,255,255,.07); }
.rt-sidebar-card .rt-sn-item { background: rgba(255,255,255,.06); color: #B8A888; }
.rt-card .rt-stat-nerds {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 5px;
    padding-top: 5px;
    border-top: 1px solid rgba(0,0,0,.06);
    flex-wrap: wrap;
}
.rt-sidebar-card .rt-card .rt-stat-nerds { border-color: rgba(0,0,0,.08); }

.rt-sn-item {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 9.5px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    letter-spacing: .2px;
    padding: 2px 6px;
    border-radius: 3px;
    background: rgba(255,255,255,.12);
    color: var(--text-subtle);
}
.rt-sidebar-card .rt-sn-item { background: rgba(0,0,0,.05); color: #A08F6C; }

.rt-sn-item i { font-size: 8px; }
.rt-sn-item.sn-hot  { color: #e05050; background: rgba(224,80,80,.1); }
.rt-sn-item.sn-like { color: #e06070; background: rgba(224,96,112,.1); }
.rt-sn-item.sn-cmt  { color: #D4AF37; background: rgba(212,175,55,.12); }

/* engagement rate badge */
.rt-engage-rate {
    margin-left: auto;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: .5px;
    padding: 2px 6px;
    border-radius: 3px;
    color: #fff;
}
.rt-engage-rate.eng-high { background: #e05050; }
.rt-engage-rate.eng-mid  { background: #D4AF37; }
.rt-engage-rate.eng-low  { background: #5a8a6a; }

/* ── "อ่านต่อ" header ── */
.rt-sidebar-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 14px 0;
}
/* ── Tags card ── */
.jp-tags-card { overflow: visible; }

.jp-tags-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 14px 10px;
    border-bottom: 1px solid rgba(255,255,255,.06);
}
.jp-tags-title-wrap {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.jp-tags-label {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--text-secondary);
    line-height: 1;
}
.jp-tags-sub {
    font-size: 8px;
    letter-spacing: 2.5px;
    color: var(--text-subtle);
    text-transform: uppercase;
    line-height: 1;
}

/* tag pills — 5 Japanese colours cycling */
.jp-tag-container {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}
.jp-tag {
    display: inline-flex;
    align-items: center;
    padding: 4px 11px;
    border-radius: 3px;           /* square-ish — Japanese label feel */
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .4px;
    cursor: pointer;
    transition: all .2s ease;
    border-left: 3px solid;
}
.jp-tag:hover { filter: brightness(1.15); transform: translateY(-1px); }

/* 1 — 朱 vermillion */
.jp-tag-1 {
    background: rgba(192,57,43,.12);
    color: #e07060;
    border-color: #c0392b;
}
/* 2 — 藍 indigo */
.jp-tag-2 {
    background: rgba(74,111,165,.13);
    color: #7eb8d4;
    border-color: #4a6fa5;
}
/* 3 — 萌黄 yellow-green */
.jp-tag-3 {
    background: rgba(107,153,63,.13);
    color: #a8cc6e;
    border-color: #6b993f;
}
/* 4 — 紫 purple */
.jp-tag-4 {
    background: rgba(120,80,160,.13);
    color: #b08fe0;
    border-color: #7850a0;
}
/* 5 — 黄土 ochre */
.jp-tag-5 {
    background: rgba(185,140,50,.13);
    color: #d4aa55;
    border-color: #b98c32;
}

/* ── ตราสโมสรดัง grid (แทน jp-tag เดิม) ── */
.jp-club-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
}
.jp-club-item {
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1 / 1;
    background: rgba(255,255,255,.05);
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 8px;
    padding: 5px;
    transition: transform .18s ease, border-color .18s ease, background .18s ease;
}
.jp-club-item:hover {
    transform: translateY(-2px) scale(1.06);
    border-color: var(--accent-warm);
    background: rgba(212,175,55,.1);
}
.jp-club-item img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}
.jp-club-hidden { display: none; }
.jp-club-more-btn {
    display: block;
    width: 100%;
    margin-top: 10px;
    padding: 7px;
    border-radius: 6px;
    border: 1px solid rgba(212,175,55,.3);
    background: rgba(212,175,55,.08);
    color: var(--accent-warm);
    font-size: 11.5px;
    font-weight: 700;
    cursor: pointer;
    transition: background .18s ease;
}
.jp-club-more-btn:hover { background: rgba(212,175,55,.18); }
@media (max-width: 480px) {
    .jp-club-grid { grid-template-columns: repeat(5, 1fr); }
}

/* ลบ sidebar-header เดิม — ใช้ rt-section-title แทน */
#relatedTopics { padding: 0; }

.sidebar-content { padding: 14px 14px 10px; }

.rt-card {
    display: flex;
    align-items: stretch;
    border-radius: 10px;
    overflow: hidden;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.06);
    margin-bottom: 8px;
    cursor: pointer;
    transition: background .2s ease, transform .2s ease;
}
.rt-card:last-child { margin-bottom: 0; }
.rt-card:hover {
    background: rgba(255,255,255,0.07);
    transform: translateX(2px);
}

.rt-accent-line {
    width: 3px;
    flex-shrink: 0;
    border-radius: 10px 0 0 10px;
    opacity: .85;
}

.rt-body {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    padding: 10px 10px 10px 9px;
    flex: 1;
    min-width: 0;
}

.rt-icon-wrap {
    font-size: 13px;
    margin-top: 1px;
    flex-shrink: 0;
    opacity: .85;
}

.rt-content { flex: 1; min-width: 0; }

.rt-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    line-height: 1.4;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.rt-preview {
    font-size: 10px;
    color: var(--text-muted);
    line-height: 1.4;
    margin-bottom: 5px;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
    opacity: .75;
}

.rt-foot {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.rt-foot span {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 10px;
    color: var(--text-subtle);
}
.rt-foot i { font-size: 9px; }
.rt-time { margin-left: auto; }

.rt-tag {
    font-size: 9px;
    padding: 1px 5px;
    border-radius: 4px;
    background: rgba(129,140,248,.15);
    color: #a5b4fc;
}

/* ==================== SCROLL TO TOP ==================== */
#scrollTopBtn {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    bottom: 24px;
    right: 18px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(30, 36, 54, 0.82);
    border: 1px solid rgba(255, 69, 0, 0.3);
    color: var(--accent-main);
    font-size: 13px;
    cursor: pointer;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 2px 12px rgba(0,0,0,0.4);
    transition: transform .2s ease, background .2s ease;
    z-index: 999;
}
#scrollTopBtn:hover {
    background: rgba(255, 69, 0, 0.18);
    transform: translateY(-2px);
}
#scrollTopBtn:active { transform: scale(0.92); }

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}