/*
Theme Name: Manga Reader Theme
Theme URI: https://example.com/manga-reader-theme
Author: PHappy-Home
Author URI: https://example.com
Description: ธีมเว็บอ่านการ์ตูนแบบ Responsive สำหรับเว็บมังงะ รองรับการตั้งค่าสีผ่าน Customizer
Version: 1.0.1
Text Domain: manga-reader
*/

/* CSS Reset แบบย่อ */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.6;
  background-color: #111;
  color: #f5f5f5;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

.site-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.site-main {
  flex: 1 0 auto;
}

/* Header */
.site-header {
  --site-logo-max-height: 52px;
  --site-logo-max-width: 220px;
  background: #111;
  border-bottom: 2px solid #e50914;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.site-branding {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  max-width: var(--site-logo-max-width);
  flex-shrink: 1;
}

.site-logo {
  min-width: 0;
  max-width: var(--site-logo-max-width);
  max-height: var(--site-logo-max-height);
  width: auto;
  height: auto;
  border-radius: 0;
  overflow: hidden;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: none;
  flex-shrink: 1;
}

.site-logo .custom-logo-link {
  display: block;
  min-width: 0;
  max-width: 100%;
  max-height: var(--site-logo-max-height);
  line-height: 0;
}

.site-logo img.custom-logo {
  max-width: var(--site-logo-max-width);
  max-height: var(--site-logo-max-height);
  width: auto !important;
  height: auto !important;
  object-fit: contain;
  display: block;
}

.site-title {
  font-size: 1.4rem;
  font-weight: 700;
}

.primary-nav {
  margin-left: auto;
}

.primary-menu {
  display: flex;
  list-style: none;
  gap: 20px;
  font-weight: 500;
}

.primary-menu a {
  padding: 6px 2px;
  position: relative;
}

.primary-menu a::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -2px;
  width: 0;
  height: 2px;
  background: #e50914;
  transition: width 0.2s ease-out;
}

.primary-menu a:hover::after,
.primary-menu .current-menu-item > a::after {
  width: 100%;
}

.nav-toggle {
  display: none;
  border: none;
  background: transparent;
  color: inherit;
  font-size: 1.6rem;
}

/* Layout */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 16px 40px;
}

/* Hero section */
.hero {
  margin-bottom: 36px;
  padding: 32px 24px 36px;
  background: linear-gradient(135deg, #1a1a1a 0%, #0f0f0f 50%, #141414 100%);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.hero-title {
  margin: 0 0 16px;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.35;
  text-align: center;
  letter-spacing: -0.02em;
  color: #fff;
}

.hero-title::after {
  content: "";
  display: block;
  width: 60px;
  height: 3px;
  margin: 12px auto 0;
  background: linear-gradient(90deg, #e50914, #ff6b35);
  border-radius: 2px;
}

.hero-content {
  max-width: 680px;
  margin: 0 auto;
  text-align: center;
}

.hero-content p {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.75;
  color: rgba(255, 255, 255, 0.88);
}

.hero-content p strong,
.hero-content b {
  color: rgba(255, 255, 255, 0.98);
  font-weight: 600;
}

@media (max-width: 600px) {
  .hero {
    padding: 24px 16px 28px;
  }

  .hero-title {
    font-size: 1.25rem;
  }

  .hero-content p {
    font-size: 0.9rem;
    line-height: 1.7;
  }
}

/* Boxes */
.box {
  margin-bottom: 32px;
  padding: 16px 18px 20px;
  border-radius: 10px;
  background: #181818;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.6);
}

.box-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.box-title {
  font-size: 1.4rem;
}

.manga-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 16px;
}

/* อัพเดทมังงะล่าสุด: แถบหัวสีแดง + ปุ่มมังงะทั้งหมด */
.box-latest .box-header-red {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  margin-bottom: 16px;
  background: #e50914;
  border-radius: 6px 6px 0 0;
}

.box-latest .box-header-red .box-title {
  margin: 0;
  color: #fff !important;
  font-size: 1.25rem;
  font-weight: 700;
}

.box-latest .box-header-btn {
  display: inline-block;
  padding: 6px 14px;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid #fff;
  border-radius: 6px;
  transition: background 0.2s, color 0.2s;
}

.box-latest .box-header-btn:hover {
  background: #fff;
  color: #e50914;
}

/* กริด 5 คอลัมน์ การ์ดสูงเท่ากัน */
.manga-grid-latest {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
  padding: 16px 0;
  align-items: stretch;
}

.box-latest .manga-card {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.box-latest .manga-card a {
  display: flex;
  flex-direction: column;
  height: 100%;
  text-decoration: none;
}

.box-latest .manga-thumb {
  flex-shrink: 0;
}

/* เมื่อแสดงมากกว่า 1 ตอน: ลดความสูงรูป, object-position top, overflow hidden */
.box-latest .manga-card.manga-card-latest-multi .manga-thumb {
  aspect-ratio: 1 / 1;
}

.box-latest .manga-card.manga-card-latest-multi .manga-thumb img {
  object-position: top center; /* แสดงส่วนบนของภาพ ไม่ตัดหัวตัวละคร */
}

.box-latest .manga-card.manga-card-latest-multi {
  overflow: hidden;
}

.box-latest .manga-card .manga-meta {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 88px;
}

@media (max-width: 1200px) {
  .manga-grid-latest {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 768px) {
  .manga-grid-latest {
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
  }
}

@media (max-width: 480px) {
  .manga-grid-latest {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* การ์ดอัพเดทล่าสุด: แทบใต้ภาพ – 1 ตอน ใช้ min-height เล็ก, มากกว่า 1 ตอน ใช้ 200px */
.box-latest .manga-meta.latest-card-meta,
.box-latest .manga-meta {
  padding: 10px 12px 12px;
  background: #0d0d0d;
  display: flex !important;
  flex-direction: column !important;
  min-height: 90px !important;
  border: none !important;
  border-top: none !important;
}

.box-latest .manga-card.manga-card-latest-multi .manga-meta {
  min-height: 200px !important;
}

/* 1 ตอน: แทบ accent สีเหลือง | มากกว่า 1 ตอน: ซ่อน */
.box-latest .manga-card.manga-card-latest-multi .manga-meta::after {
  display: none !important;
}

.box-latest .manga-card:not(.manga-card-latest-multi) .manga-meta::after {
  content: "";
  display: block !important;
  width: 48px;
  height: 3px;
  margin-top: 8px;
  background: #ffeb3b;
  flex-shrink: 0;
}

/* บรรทัด 1: ชื่อเรื่อง - เล็กลง 2 ระดับ */
.box-latest .manga-meta .manga-title {
  color: #fff !important;
  font-size: 0.85rem !important;
  font-weight: 700;
  margin: 0 0 6px 0;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex-shrink: 0;
}

/* บรรทัด 2: ตอนที่ X - ปุ่มแดงมุมโค้ง ตัวขาว เล็กกว่าชื่อเรื่อง 1 ระดับ */
.box-latest .manga-meta .manga-chapter {
  display: inline-block !important;
  background: #e50914;
  color: #fff !important;
  font-size: 0.8rem !important;
  font-weight: 600;
  margin: 0 0 6px 0;
  padding: 4px 10px;
  border-radius: 6px;
  flex-shrink: 0;
}

/* บรรทัด 3: เวลา - อยู่ล่างสุดของกรอบ latest-card-meta */
.box-latest .manga-meta .manga-time {
  color: rgba(255, 255, 255, 0.9) !important;
  font-size: 0.75rem !important;
  margin-top: auto !important;
  padding-top: 8px;
  flex-shrink: 0;
}

/* อัพเดทมังงะล่าสุด: หลายตอนต่อการ์ด – ตอนที่ชิดซ้าย เวลาชิดขวา บรรทัดเดียว */
.box-latest .latest-card-chapters {
  list-style: none;
  margin: 0;
  padding: 0;
  margin-top: 6px;
}
.box-latest .latest-chapter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  width: 100%;
}
.box-latest .latest-chapter-row:last-child {
  margin-bottom: 0;
}
.box-latest .latest-chapter-label {
  display: inline-block;
  background: #e50914;
  color: #fff !important;
  font-size: 0.8rem !important;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  text-decoration: none !important;
  flex-shrink: 0;
  margin-right: auto;
}
.box-latest .latest-chapter-label:hover {
  background: #b80712;
  color: #fff !important;
}
.box-latest .latest-chapter-time {
  font-size: 0.7rem !important;
  color: rgba(255, 255, 255, 0.85) !important;
  flex-shrink: 0;
  margin-left: auto;
  text-align: right;
}

.box-latest .manga-card .manga-category {
  display: none;
}

.manga-grid-empty {
  grid-column: 1 / -1;
  padding: 24px;
  text-align: center;
  color: rgba(255, 255, 255, 0.7);
}

.manga-card {
  background: #101010;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  transition: transform 0.18s ease-out, box-shadow 0.18s ease-out, border-color 0.18s ease-out;
}

.manga-card:hover {
  transform: translateY(-4px);
  border-color: #e50914;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.85);
}

.manga-thumb {
  position: relative;
  aspect-ratio: 3 / 4;
  overflow: hidden;
}

.manga-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.manga-thumb::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.65), transparent 55%);
  opacity: 0;
  transition: opacity 0.2s ease-out;
}

.manga-card:hover .manga-thumb::after {
  opacity: 1;
}

.manga-meta {
  padding: 10px 10px 12px;
}

.manga-category {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.7;
  margin-bottom: 4px;
}

.manga-title {
  font-size: 0.96rem;
  font-weight: 600;
}

.article-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
}

.article-card {
  background: #101010;
  border-radius: 8px;
  padding: 14px 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.article-card-title {
  font-size: 1.02rem;
  margin-bottom: 6px;
}

.article-card-excerpt {
  font-size: 0.9rem;
  opacity: 0.85;
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.box-latest .pagination-latest {
  margin-top: 24px;
  margin-bottom: 8px;
  padding: 12px 0;
}

.pagination .page-numbers {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: #111;
  font-weight: 600;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.pagination .page-numbers:hover {
  border-color: #e50914;
  transform: translateY(-1px);
}

.pagination .page-numbers.current {
  background: #e50914;
  border-color: #e50914;
  color: #fff;
}

/* Reader (single.php) */
.readercontent {
  color: #f5f5f5;
  padding: 24px 16px 40px;
  text-align: center;
}

.readercontent .wrapper {
  max-width: 980px;
  margin: 0 auto;
}

.chapterbody {
  background: #181818;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.6);
  padding: 18px;
}

.postarea {
  display: block;
}

.headpost .entry-title {
  font-size: 2rem;
  margin-bottom: 8px;
}

.ts-breadcrumb {
  margin: 10px 0 18px !important;
  font-size: 0.9rem;
  opacity: 0.9;
  text-align: center !important;
  display: block;
}

.ts-breadcrumb .breadcrumb-inline {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100% !important;
  max-width: 720px;
  background: #151515 !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  border-radius: 6px !important;
  padding: 8px 16px !important;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.45) !important;
}

.ts-breadcrumb .breadcrumb-sep {
  margin: 0;
  padding: 0;
}

.ts-breadcrumb a {
  margin: 0;
  padding: 0;
}

.ts-breadcrumb a {
  color: inherit;
}

.entry-content-single {
  background: #101010;
  border-radius: 10px;
  padding: 14px 16px 20px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.chdesc {
  margin-bottom: 12px;
  opacity: 0.9;
}

.chnav {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 12px 0;
}

.chnav .selector,
.chnav .navlef,
.chnav .navrig {
  display: flex;
  align-items: center;
  justify-content: center;
}

.chnav .selector {
  width: 100%;
}

.chnav .navlef {
  width: 100%;
}

.chnav .npv {
  width: 100%;
}

.nvx select,
#chapter {
  background: #111;
  color: #f5f5f5;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  padding: 8px 14px;
  width: 100%;
  min-width: 0;
  margin: 0 auto;
}

.nvx {
  width: 100%;
}

.nextprev a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: #111;
  font-weight: 600;
  margin: 0 4px;
  transition: border-color 0.2s ease, transform 0.2s ease;
  min-width: 110px;
}

.nextprev a:hover {
  border-color: #e50914;
  transform: translateY(-1px);
}

.nextprev {
  display: flex;
  align-items: center;
  justify-content: space-between !important;
  gap: 12px;
  flex-wrap: nowrap;
  width: 100% !important;
}

.nextprev .ch-next-btn {
  margin-right: auto !important;
  background: #0f0f0f !important;
  border-color: rgba(255, 255, 255, 0.2) !important;
}

.nextprev .ch-prev-btn {
  margin-left: auto !important;
  background: #e50914 !important;
  border-color: #e50914 !important;
  color: #fff !important;
}

#readerarea {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin: 0 auto;
}

#readerarea img {
  width: 100%;
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 10px auto;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.5);
}

#readerarea p,
#readerarea div {
  width: 100%;
  max-width: 100%;
  text-align: center;
}

.chaptertags {
  margin-top: 18px;
}

.chaptertags .post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: center;
}

.chaptertags .post-tags a {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: #111;
  font-size: 0.86rem;
  transition: border-color 0.2s ease;
}

.chaptertags .post-tags a:hover {
  border-color: #e50914;
}

@media (max-width: 768px) {
  .readercontent {
    padding: 18px 12px 28px;
  }

  .chapterbody {
    padding: 14px;
  }

  .headpost .entry-title {
    font-size: 1.5rem;
  }
  .chnav {
    justify-content: center;
  }

  .chnav .selector,
  .chnav .navlef {
    margin: 0;
  }

  .nvx select,
  #chapter {
    width: 100%;
    min-width: 0;
  }

  .nextprev a {
    margin-left: 0;
  }
}

.manga-chapters {
  list-style: none;
  margin-top: 6px;
  padding-left: 0;
  font-size: 0.84rem;
}

.manga-chapters li + li {
  margin-top: 2px;
}

/* หน้ามังงะทั้งหมด: การ์ดแบบ index (เรื่อง, 5 ตอนล่าสุด + วันที่) */
.manga-grid-all {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
}

.box-all-manga .manga-card-all {
  display: flex;
  flex-direction: column;
  background: #101010;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.box-all-manga .manga-meta-all {
  padding: 10px 12px 12px;
  background: #0d0d0d;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.box-all-manga .manga-meta-all .manga-title {
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 8px;
  line-height: 1.3;
}

.box-all-manga .manga-meta-all .manga-title a {
  color: #fff;
  text-decoration: none;
}

.box-all-manga .manga-meta-all .manga-title a:hover {
  color: #e50914;
}

.box-all-manga .manga-chapters-list {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.8rem;
  width: 100%;
}

/* แถวตอน: ความกว้างเต็ม ตอนที่ X ชิดซ้าย เวลาชิดขวา */
.box-all-manga .manga-chapter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  padding: 0;
  width: 100%;
  box-sizing: border-box;
}

.box-all-manga .manga-chapter-row:last-child {
  margin-bottom: 0;
}

/* ตอนที่ X - กรอบสีแดง เล็ก ชิดซ้าย (บังคับไม่ให้ theme ทับ) */
body .box-all-manga .manga-chapter-row a.chapter-label {
  display: inline-block;
  color: #e50914 !important;
  text-decoration: none !important;
  font-weight: 600;
  font-size: 0.75rem !important;
  padding: 2px 6px;
  border: 1px solid #e50914 !important;
  border-radius: 4px;
  background: rgba(229, 9, 20, 0.15) !important;
  transition: background 0.2s, color 0.2s;
  flex-shrink: 0;
  margin-right: auto;
}

body .box-all-manga .manga-chapter-row a.chapter-label:hover {
  background: #e50914 !important;
  color: #fff !important;
}

/* เวลา - ชิดขวาสุด ตัวเล็กกว่าตอนที่ 2 ระดับ */
body .box-all-manga .manga-chapter-row .chapter-date {
  display: block;
  color: rgba(255, 255, 255, 0.85) !important;
  font-size: 0.6rem !important;
  line-height: 1.2;
  flex-shrink: 0;
  margin-left: auto;
  text-align: right;
  min-width: 4em;
}

/* ===== หน้ารายการตอน (category.php) ===== */
.category-content.manga-info {
  color: #f5f5f5;
}

.category-wrapper {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px 32px;
}

.category-banner.img-blur {
  width: 100%;
  height: 180px;
  background-size: cover;
  background-position: center;
  filter: blur(12px);
  opacity: 0.5;
  border-radius: 8px 8px 0 0;
}

.category-body {
  background: #0d0d0d;
  border-radius: 0 0 8px 8px;
  overflow: hidden;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.5);
}

.category-main-info {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 24px;
  padding: 20px 20px 24px;
}

@media (max-width: 640px) {
  .category-main-info {
    grid-template-columns: 1fr;
    padding: 16px;
  }
}

.category-info-left {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.category-thumb {
  border-radius: 8px;
  overflow: hidden;
  background: #151515;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.category-thumb img {
  width: 100%;
  height: auto;
  display: block;
}

.category-posted-by {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.6);
}

.category-info-right {
  min-width: 0;
}

.category-desc-box {
  margin-bottom: 16px;
}

.category-title.entry-title {
  font-size: 1.5rem;
  margin-bottom: 8px;
  color: #fff;
}

.category-desc.entry-content p {
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.85);
  margin: 0;
}

.category-ep-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}

.category-ep-buttons .ep-btn-wrap a {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 20px;
  background: #e50914;
  color: #fff !important;
  border-radius: 8px;
  font-weight: 600;
  text-decoration: none !important;
  transition: background 0.2s, transform 0.15s;
}

.category-ep-buttons .ep-btn-wrap a:hover {
  background: #b80712;
  color: #fff !important;
}

.category-ep-buttons .ep-btn-wrap a .epcur {
  display: block;
  font-size: 0.85rem;
  margin-top: 2px;
}

.category-chapter-list-wrap {
  margin-bottom: 20px;
}

.chapter-list-style {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 400px;
  overflow-y: auto;
  background: #111;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.chapter-list-item {
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  padding: 0;
}

.chapter-list-item:last-child {
  border-bottom: none;
}

.chapter-list-item a {
  display: block;
  padding: 10px 14px;
  color: inherit;
  text-decoration: none !important;
}

.chapter-list-item a:hover {
  background: rgba(229, 9, 20, 0.15);
}

.chapter-list-item .chapternum {
  display: block;
  color: #fff;
  font-size: 0.95rem;
  font-weight: 500;
}

.chapter-list-item .chapterdate {
  display: block;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.55);
  margin-top: 4px;
}

.category-breadcrumb.ts-breadcrumb {
  margin: 10px 0 0;
  font-size: 0.9rem;
  opacity: 0.9;
}

.category-breadcrumb .breadcrumb-inline {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 8px;
  color: rgba(255, 255, 255, 0.7);
}

.category-breadcrumb .breadcrumb-inline a {
  color: rgba(255, 255, 255, 0.85);
}

.category-breadcrumb .breadcrumb-inline a:hover {
  color: #e50914;
}

/* ===== Header Search Bar ===== */
.header-search-bar {
  background: #0a0a0a;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding: 10px 0;
}

.header-search-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
  position: relative;
}

.header-search-form {
  display: flex;
  align-items: center;
  gap: 0;
}

.header-search-input {
  flex: 1;
  background: #1a1a1a;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-right: none;
  border-radius: 6px 0 0 6px;
  color: #f5f5f5;
  font-size: 0.95rem;
  padding: 9px 14px;
  outline: none;
  transition: border-color 0.2s;
}

.header-search-input::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

.header-search-input:focus {
  border-color: #e50914;
}

.header-search-btn {
  background: #e50914;
  border: 1px solid #e50914;
  border-radius: 0 6px 6px 0;
  color: #fff;
  font-size: 1rem;
  padding: 9px 16px;
  cursor: pointer;
  transition: background 0.2s;
  line-height: 1;
}

.header-search-btn:hover {
  background: #b80712;
  border-color: #b80712;
}

/* Dropdown ผลลัพธ์ live search */
.header-search-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 16px;
  right: 0;
  background: #1a1a1a;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  z-index: 9999;
  max-height: 360px;
  overflow-y: auto;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.7);
}

.header-search-dropdown.is-open {
  display: block;
}

.search-drop-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  text-decoration: none;
  color: #f5f5f5;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  transition: background 0.15s;
}

.search-drop-item:last-child {
  border-bottom: none;
}

.search-drop-item:hover {
  background: rgba(229, 9, 20, 0.18);
  color: #fff;
}

.search-drop-thumb {
  width: 40px;
  height: 56px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
  background: #252525;
}

.search-drop-thumb-placeholder {
  width: 40px;
  height: 56px;
  border-radius: 4px;
  flex-shrink: 0;
  background: linear-gradient(135deg, #e50914, #ff9800);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
  color: #fff;
}

.search-drop-info {
  min-width: 0;
}

.search-drop-name {
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-drop-count {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.55);
  margin-top: 2px;
}

.search-drop-empty {
  padding: 14px;
  text-align: center;
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.9rem;
}

.search-drop-loading {
  padding: 14px;
  text-align: center;
  color: rgba(255, 255, 255, 0.4);
  font-size: 0.85rem;
}

/* Footer */
.site-footer {
  flex-shrink: 0;
  background: #050505;
  padding: 22px 16px 28px;
  border-top: 2px solid #e50914;
}

.footer-inner {
  max-width: 800px;
  margin: 0 auto;
  text-align: center;
}

.footer-logo {
  margin: 0 auto 8px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #e50914, #ff9800);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 22px;
  color: #fff;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.7);
}

.footer-text {
  font-size: 0.86rem;
  opacity: 0.8;
}

/* Typography – สีจะถูก override ด้วย Customizer */
h1,
.hero-title {
  font-size: 2rem;
  margin-bottom: 0.35em;
  text-align: center;
}

h2,
.box-title {
  font-size: 1.5rem;
  margin-bottom: 0.3em;
}

h3 {
  font-size: 1.2rem;
  margin-bottom: 0.25em;
}

/* Responsive */
@media (max-width: 768px) {
  .site-header {
    --site-logo-max-height: 44px;
    --site-logo-max-width: 180px;
  }

  .header-inner {
    flex-wrap: wrap;
  }

  .primary-nav {
    width: 100%;
  }

  .primary-menu {
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 12px 18px;
    margin-top: 8px;
  }
}
/* ===== Scroll to Top: ลอยกลางแนวตั้ง ชิดขวา (สคริปต์ใน footer จะย้ายปุ่มไปเป็นลูกของ body) ===== */
#scrollToTopBtn.scrollToTop,
body .scrollToTop {
  display: none;
  position: fixed !important;
  top: 50% !important;
  right: 15px !important;
  bottom: auto !important;
  left: auto !important;
  width: 48px !important;
  height: 48px !important;
  margin: 0 !important;
  padding: 0 !important;
  transform: translateY(-50%) !important;
  -webkit-transform: translateY(-50%) !important;
  z-index: 2147483647 !important;
  border: none;
  border-radius: 50%;
  background: #366ad3;
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  line-height: 48px;
  box-sizing: border-box;
  box-shadow: 0 4px 12px rgba(0,0,0,0.35);
  transition: background 0.2s;
}

#scrollToTopBtn.scrollToTop:hover,
body .scrollToTop:hover {
  background: #4a7ae0;
  color: #fff;
}

#scrollToTopBtn.scrollToTop .fas,
body .scrollToTop .fas {
  display: inline-block;
  vertical-align: middle;
}
