/*
Theme Name: Blue Manga
Description: Custom manga reader theme for blue-manga, design ported from mangakiki
Author: nanidbx
Version: 1.0
*/

:root {
  --bg: #08090d;
  --bg-elevated: #111319;
  --bg-card: #15171f;
  --border: #24262f;
  --text: #f5f6f8;
  --text-dim: #9ca0ac;
  --text-faint: #686c78;
  --accent: #38bdf8;
  --accent-2: #1d4ed8;
  --accent-contrast: #ffffff;
  --gradient-brand: linear-gradient(135deg, var(--accent), var(--accent-2));
  --rating-gold: #f3d27e; /* soft champagne gold (was #ffc107) */
  --rating-gold-hi: #fff6dc;
  --radius: 12px;
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
  --shadow-accent: 0 14px 28px -10px rgba(56, 189, 248, 0.35), 0 4px 14px rgba(0, 0, 0, 0.5);
  --header-h: 64px;
  --content-max: 900px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', 'Noto Sans Thai', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
  /* Safety net: a flex/grid item with an image can ignore an explicit width
     and expand to the image's intrinsic size unless min-width:0 is set on
     that item — this catches anywhere that guard is missing instead of
     letting the whole page grow a horizontal scrollbar. */
  overflow-x: hidden;
}

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; margin: 0; padding: 0; }
h1, h2, h3, p { margin: 0; }

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  display: flex;
  align-items: center;
  background: rgba(8, 9, 13, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(56, 189, 248, 0.15);
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.site-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.site-brand .brand-text {
  background: var(--gradient-brand);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.site-brand img {
  height: 48px;
  width: auto;
  border-radius: 4px;
  object-fit: contain;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.site-search {
  position: relative;
  display: flex;
  align-items: center;
}

.site-search-input {
  width: 0;
  opacity: 0;
  padding: 0;
  margin: 0;
  border: none;
  background: var(--bg-elevated);
  color: var(--text);
  border-radius: 999px;
  font-size: 0.85rem;
  transition: width 0.2s ease, opacity 0.2s ease, padding 0.2s ease;
  pointer-events: none;
}

.site-search.open .site-search-input {
  width: 190px;
  opacity: 1;
  padding: 9px 14px;
  border: 1px solid var(--border);
  pointer-events: auto;
  margin-right: 4px;
}

.site-search-input:focus {
  outline: none;
  border-color: var(--accent);
}

.site-search-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 999px;
  border: none;
  background: none;
  color: var(--text-dim);
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}

.site-search-toggle:hover {
  color: var(--accent);
  background: var(--bg-elevated);
}

@media (max-width: 640px) {
  .site-search.open {
    position: absolute;
    left: 16px;
    right: 16px;
    top: 0;
    height: var(--header-h);
    display: flex;
    align-items: center;
    background: var(--bg);
    z-index: 10;
  }
  .site-search.open .site-search-input {
    width: 100%;
    flex: 1;
  }
}

.site-nav ul {
  display: flex;
  align-items: center;
  gap: 4px;
}

.site-nav a {
  display: flex;
  align-items: center;
  height: 44px;
  padding: 0 14px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-dim);
  border-radius: 8px;
}

.site-nav a:hover {
  color: var(--text);
  background: var(--bg-elevated);
}

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 44px;
  height: 44px;
  background: none;
  border: none;
  cursor: pointer;
}

.nav-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 64px;
  padding: 32px 0 48px;
  color: var(--text-faint);
  font-size: 0.85rem;
  text-align: center;
}

/* ---------- Manga grid (homepage) ---------- */
.page-heading {
  padding: 32px 0 20px;
  font-size: 1.4rem;
  font-weight: 800;
}

.manga-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 18px;
  padding-bottom: 60px;
}

.manga-grid > li {
  min-width: 0;
}

/* Homepage's "อัปเดตล่าสุด" preview: fixed 4-per-row (not auto-fill). Cards
   are capped/centered within their column so they stay the same px size as
   the hero/per-type scroller cards instead of stretching on wide screens. */
.home-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.home-grid .manga-card {
  max-width: 190px;
  margin: 0 auto;
}

/* Genre/type/search listing pages: fixed 6-per-row on PC specifically —
   tablet/mobile keep the regular auto-fill/2-col grid since 6 columns would
   be cramped below desktop widths. */
@media (min-width: 1025px) {
  .grid-6 {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

.manga-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
  min-width: 0;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  position: relative;
}

.manga-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-accent);
}

.manga-card .cover img {
  transition: transform 0.25s ease;
}

.manga-card:hover .cover img {
  transform: scale(1.05);
}

.manga-card .cover {
  aspect-ratio: 2 / 3;
  width: 100%;
  background: var(--bg-elevated);
  overflow: hidden;
}

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

.manga-card .cover-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
  font-size: 0.75rem;
  text-align: center;
  padding: 8px;
}

.card-chapters {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 12px 12px;
}

.card-chapter-text {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-dim);
}

.card-chapter-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-dim);
  transition: border-color 0.15s ease, color 0.15s ease;
}

.card-chapter-btn:hover {
  border-color: var(--accent);
  color: var(--text);
}

.chapter-btn-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}

.chapter-btn-time {
  flex-shrink: 0;
  font-size: 0.64rem;
  font-weight: 600;
  color: var(--text-faint);
}

/* Fixed-width slot in front of every chapter label — always renders
   *something* (a faint dot, or the bell for a genuinely new chapter) so
   every row lines up identically instead of only new rows getting extra
   padding. */
.chapter-btn-indicator {
  flex: 0 0 12px;
  width: 12px;
  height: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chapter-btn-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(147, 197, 253, 0.55);
}

/* "New chapter" alert: a glowing ice-blue four-point sparkle that twinkles,
   with a smaller sparkle flickering off its corner. Pure CSS on the
   existing .chapter-btn-bell element, so the PHP card templates and
   assets/search.js need no markup change. */
.chapter-btn-bell {
  position: relative;
  display: inline-block;
  flex-shrink: 0;
  width: 12px;
  height: 12px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23e0f2fe' d='M12 0c.6 6.2 5.8 11.4 12 12-6.2.6-11.4 5.8-12 12-.6-6.2-5.8-11.4-12-12C6.2 11.4 11.4 6.2 12 0z'/%3E%3C/svg%3E") center / contain no-repeat;
  filter: drop-shadow(0 0 2px #38bdf8) drop-shadow(0 0 5px rgba(56, 189, 248, 0.85));
  animation: sparkle-twinkle 2.4s ease-in-out infinite;
}

.chapter-btn-bell::after {
  content: '';
  position: absolute;
  top: -4px;
  right: -5px;
  width: 6px;
  height: 6px;
  background: inherit;
  background-size: contain;
  animation: sparkle-mini 2.4s ease-in-out infinite 0.6s;
}

@keyframes sparkle-twinkle {
  0%, 100% { transform: scale(0.8) rotate(0deg); opacity: 0.75; }
  45%      { transform: scale(1.12) rotate(45deg); opacity: 1; }
  60%      { transform: scale(0.95) rotate(60deg); opacity: 0.9; }
}

@keyframes sparkle-mini {
  0%, 55%, 100% { transform: scale(0); opacity: 0; }
  70%           { transform: scale(1); opacity: 1; }
  85%           { transform: scale(0.4); opacity: 0.4; }
}

/* Series page chapter list: a text "NEW" tag instead of the sparkle. */
.chapter-new-tag {
  margin-right: 8px;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  line-height: 1;
  color: #fff;
  text-shadow: 0 0 3px #38bdf8, 0 0 8px rgba(56, 189, 248, 0.9), 0 0 14px rgba(56, 189, 248, 0.6);
  animation: new-tag-glow 2.4s ease-in-out infinite;
}

@keyframes new-tag-glow {
  0%, 100% { text-shadow: 0 0 3px #38bdf8, 0 0 8px rgba(56, 189, 248, 0.9), 0 0 14px rgba(56, 189, 248, 0.6); }
  50%      { text-shadow: 0 0 2px #38bdf8, 0 0 4px rgba(56, 189, 248, 0.6), 0 0 8px rgba(56, 189, 248, 0.3); }
}

@media (prefers-reduced-motion: reduce) {
  .chapter-btn-bell, .chapter-btn-bell::after, .chapter-new-tag { animation: none; }
}

.new-dot {
  flex-shrink: 0;
  background: var(--gradient-brand);
  color: var(--accent-contrast);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 3px;
  margin-right: 4px;
}

/* ---------- Hero slider (homepage banner, series-linked) ---------- */
.hero-slider {
  position: relative;
}

.hero-slider-track {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}

.hero-slider-track::-webkit-scrollbar {
  display: none;
}

.hero-slide {
  position: relative;
  flex: 0 0 100%;
  scroll-snap-align: start;
  aspect-ratio: 1900 / 400;
  min-height: 160px;
  display: block;
  overflow: hidden;
}

.hero-slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: var(--pos-m, center center);
}

@media (min-width: 768px) {
  .hero-slide img {
    object-position: var(--pos-d, center center);
  }
}

.hero-slide-scrim {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(8, 9, 13, 0.92) 0%, rgba(8, 9, 13, 0.35) 45%, rgba(8, 9, 13, 0.05) 75%);
}

.hero-slide-content {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  /* Bottom padding clears the dots pill (bottom: 10px, ~22px tall). */
  padding: 16px 24px 40px;
  max-width: 900px;
  margin: 0 auto;
}

/* Decorative slide text — deliberately <span>, not a heading element, so
   this carousel never competes with the page's real H1/H2 hierarchy. */
.hero-slide-title {
  display: block;
  font-size: 1.4rem;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
  margin-bottom: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hero-slide-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.hero-slide-meta-item {
  font-size: 0.8rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.75);
}

.hero-slide-meta > * + *::before {
  content: '|';
  margin-right: 10px;
  color: rgba(255, 255, 255, 0.3);
}

.hero-slide-synopsis {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-width: 640px;
  font-size: 0.82rem;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.7);
}

.hero-slider-dots {
  position: absolute;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px 6px;
  border-radius: 999px;
  background: rgba(8, 9, 13, 0.45);
  backdrop-filter: blur(6px);
  z-index: 2;
}

/* Each dot is a small SVG: a core dot, plus (on the active slide) a ring
   that fills clockwise over the autoplay interval — so the dots double as
   a countdown to the next slide. Timing comes from --hero-interval, set by
   app.js; the ring pauses with the slider (.is-paused). */
.hero-dot {
  width: 16px;
  height: 16px;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  display: grid;
  place-items: center;
  -webkit-tap-highlight-color: transparent;
}

.hero-dot svg {
  width: 14px;
  height: 14px;
  overflow: visible;
  transform: rotate(-90deg);
}

.hero-dot-track,
.hero-dot-ring {
  fill: none;
  stroke-width: 1.6;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.hero-dot-track { stroke: rgba(56, 189, 248, 0.25); }

.hero-dot-ring {
  stroke: var(--accent);
  stroke-linecap: round;
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
}

.hero-dot-core {
  fill: rgba(56, 189, 248, 0.45);
  transform-origin: 8px 8px;
  transition: fill 0.25s ease, transform 0.25s ease;
}

.hero-dot:hover .hero-dot-core { fill: rgba(56, 189, 248, 0.8); }

.hero-dot.active .hero-dot-track,
.hero-dot.active .hero-dot-ring { opacity: 1; }

.hero-dot.active .hero-dot-ring {
  animation: hero-dot-progress var(--hero-interval, 6s) linear forwards;
}

.hero-dot.active .hero-dot-core {
  fill: var(--accent);
  transform: scale(1.15);
  filter: drop-shadow(0 0 2px rgba(56, 189, 248, 0.9));
}

.hero-slider.is-paused .hero-dot.active .hero-dot-ring { animation-play-state: paused; }

@keyframes hero-dot-progress {
  to { stroke-dashoffset: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .hero-dot.active .hero-dot-ring { animation: none; stroke-dashoffset: 0; }
}

/* ---------- Homepage H1 / intro description ---------- */
.home-intro {
  padding: 22px 0 6px;
  text-align: center;
  position: relative;
}

.home-intro::before {
  content: '';
  position: absolute;
  top: -40px;
  left: 50%;
  translate: -50% 0;
  width: 700px;
  max-width: 140vw;
  height: 220px;
  background: radial-gradient(closest-side, rgba(56, 189, 248, 0.14), transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.home-intro-h1 {
  position: relative;
  z-index: 1;
  font-size: 1.35rem;
  font-weight: 800;
  background: var(--gradient-brand);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-bottom: 6px;
}

.home-intro-desc {
  position: relative;
  z-index: 1;
  color: var(--text-dim);
  font-size: 0.85rem;
  line-height: 1.6;
}

.home-intro-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
  margin: 4px auto 0;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
}

.home-intro-toggle-icon {
  width: 16px;
  height: 16px;
  background: var(--text-dim);
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  transition: transform 0.2s ease;
}

.home-intro-toggle.expanded .home-intro-toggle-icon {
  transform: rotate(180deg);
}

@media (max-width: 640px) {
  .hero-slide { aspect-ratio: 4 / 3; min-height: 0; }
  .hero-slide-title { font-size: 1.25rem; }
  .home-intro-h1 { font-size: 1.15rem; }

  /* Full text always stays server-rendered in the DOM — only visually
     clipped to 2 lines via line-clamp, expanded by toggling .expanded
     (see the script at the bottom of this page). Safe for SEO: Google
     indexes and ranks collapsed/accordion content the same as visible
     content, since nothing here removes it from the initial HTML. */
  .home-intro-desc {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .home-intro-desc.expanded {
    display: block;
    overflow: visible;
  }
  .home-intro-toggle {
    display: flex;
  }

  /* 4-line layout on mobile: title / stars+type / genre / synopsis —
     genre gets forced onto its own line (its "|" separator dropped since
     it no longer follows anything on the same line). */
  .hero-slide-meta-item-genre {
    flex-basis: 100%;
  }
  .hero-slide-meta-item-genre::before {
    content: none;
    margin-right: 0;
  }
}

/* Full-bleed hero slide grows tall with its width on very wide viewports —
   trim the height back by 20% past 1440px so it doesn't dominate the page. */
@media (min-width: 1441px) {
  .hero-slide {
    aspect-ratio: 1900 / 320;
  }
}

/* ---------- Hero strip (featured) ---------- */
.hero-strip {
  padding: 10px 0 8px;
  position: relative;
}

.hero-strip::before {
  content: '';
  position: absolute;
  top: -80px;
  left: 50%;
  translate: -50% 0;
  width: 900px;
  max-width: 140vw;
  height: 320px;
  background: radial-gradient(closest-side, rgba(56, 189, 248, 0.16), transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.hero-strip .scroller-section {
  position: relative;
  z-index: 1;
}

/* ---------- Card scroller (shared by featured + per-type rows) ---------- */
.scroller-section {
  padding: 22px 0 6px;
}

.card-scroller-wrap {
  position: relative;
}

.card-scroller {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 8px;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.card-scroller::-webkit-scrollbar {
  display: none;
}

.card-scroller-item { flex: 0 0 auto; width: 190px; min-width: 0; scroll-snap-align: start; }

.scroller-nav {
  display: none;
  position: absolute;
  /* Centers on the cover image band (150px item width, 2:3 cover = 225px
     tall), not the full card — the card also has a title/chapter text block
     below the image, so centering on the wrapper's full height would sit
     noticeably below the image's actual midpoint. */
  top: 112px;
  translate: 0 -50%;
  z-index: 5;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(21, 23, 31, 0.9);
  backdrop-filter: blur(6px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
  color: var(--text);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.scroller-nav:hover {
  background: var(--gradient-brand);
  border-color: transparent;
  box-shadow: 0 8px 20px rgba(56, 189, 248, 0.4);
  transform: translateY(-1px);
}

.scroller-nav:active {
  transform: translateY(0);
}

.scroller-nav-prev { left: -18px; }
.scroller-nav-next { right: -18px; }

/* Arrow scroll is a PC affordance — touch devices already swipe natively,
   and hover-capable pointer is the most reliable signal for "has a mouse". */
@media (hover: hover) and (pointer: fine) {
  .scroller-nav { display: flex; }
}

/* ---------- Home layout (main content + sidebar) ---------- */
.home-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 32px;
  padding-top: 24px;
  padding-bottom: 40px;
  align-items: start;
}

@media (min-width: 1025px) {
  .home-layout {
    grid-template-columns: minmax(0, 1fr) 300px;
  }
}

.home-main {
  min-width: 0;
}

.home-sidebar {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.sidebar-block {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 18px;
}

.sidebar-title {
  font-size: 0.95rem;
  font-weight: 800;
  padding-bottom: 14px;
}

.genre-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  display: inline-flex;
  align-items: center;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-dim);
}

.pill:hover {
  border-color: var(--accent);
  color: var(--text);
}

.top10-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* An explicit `display` above always beats the `hidden` attribute's UA
   default — learned the hard way on .reader-page-nav, applying the fix
   proactively here too. */
.top10-list[hidden] {
  display: none;
}

.continue-reading-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.top10-header {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  padding-bottom: 14px;
}

.top10-header .sidebar-title {
  padding-bottom: 0;
}

.top10-tabs {
  display: flex;
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}

.top10-tab {
  flex: 1;
  text-align: center;
  justify-content: center;
  background: none;
  border: none;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-dim);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.top10-tab.active {
  background: var(--gradient-brand);
  color: var(--accent-contrast);
}

.top10-item {
  display: flex;
  align-items: center;
  gap: 10px;
}

.top10-rank {
  flex-shrink: 0;
  width: 22px;
  font-size: 1.1rem;
  font-weight: 800;
  font-style: italic;
  color: var(--text-faint);
  text-align: center;
}

@keyframes burn-1 {
  0%, 100% { text-shadow: 0 -1px 3px #bae6fd, 0 -4px 8px #38bdf8, 3px -8px 16px #0ea5e9, -3px -14px 24px #0284c7, 0 -20px 32px #1d4ed8; transform: scale(1.08); }
  33% { text-shadow: 0 -2px 4px #bae6fd, 2px -5px 10px #38bdf8, -2px -10px 18px #0ea5e9, 2px -16px 28px #0284c7, -2px -22px 38px #1d4ed8; }
  66% { text-shadow: 0 -1px 3px #bae6fd, -2px -4px 8px #38bdf8, 2px -7px 14px #0ea5e9, -2px -12px 20px #0284c7, 2px -18px 30px #1d4ed8; }
}

@keyframes burn-2 {
  0%, 100% { text-shadow: 0 -1px 2px #bae6fd, 0 -2px 4px #38bdf8, 1px -4px 7px #0ea5e9, -1px -6px 10px #0284c7; transform: scale(1.02); }
  33% { text-shadow: 0 -1px 2px #bae6fd, 1px -3px 5px #38bdf8, -1px -5px 8px #0ea5e9, 1px -7px 12px #0284c7; }
  66% { text-shadow: 0 -1px 2px #bae6fd, -1px -2px 4px #38bdf8, 1px -4px 6px #0ea5e9, -1px -5px 9px #0284c7; }
}

@keyframes burn-3 {
  0%, 100% { text-shadow: 0 -1px 1px #bae6fd, 0 -1px 3px #38bdf8, 1px -2px 4px #0284c7; }
  33% { text-shadow: 0 -1px 2px #bae6fd, 1px -2px 4px #38bdf8, -1px -3px 5px #0284c7; }
  66% { text-shadow: 0 -1px 1px #bae6fd, -1px -1px 3px #38bdf8, 1px -2px 4px #0284c7; }
}

.top10-list li:nth-child(-n+3) .top10-rank {
  color: #fff;
  background: none;
  -webkit-background-clip: unset;
  background-clip: unset;
}
.top10-list li:nth-child(1) .top10-rank {
  animation: burn-1 0.4s infinite alternate;
  font-size: 1.4rem;
}
.top10-list li:nth-child(2) .top10-rank {
  animation: burn-2 0.5s infinite alternate;
  font-size: 1.25rem;
}
.top10-list li:nth-child(3) .top10-rank {
  animation: burn-3 0.6s infinite alternate;
  font-size: 1.15rem;
}

.top10-cover {
  flex-shrink: 0;
  width: 64px;
  min-width: 0;
  aspect-ratio: 2 / 3;
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg-elevated);
  box-shadow: var(--shadow);
}

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

.top10-info {
  min-width: 0;
}

.top10-title {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.top10-genre {
  font-size: 0.72rem;
  color: var(--text-faint);
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top10-info .star-rating-compact {
  margin-top: 3px;
}

/* ---------- Pagination ---------- */
.pagination {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  padding: 12px 0 60px;
}

.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  height: 38px;
  padding: 0 10px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-dim);
  background: var(--bg-card);
  border: 1px solid var(--border);
}

.page-btn:hover {
  border-color: var(--accent);
  color: var(--text);
}

.page-btn.active {
  background: var(--gradient-brand);
  border-color: transparent;
  color: var(--accent-contrast);
}

.page-btn.disabled {
  opacity: 0.35;
  pointer-events: none;
}

.page-ellipsis {
  display: inline-flex;
  align-items: center;
  color: var(--text-faint);
  padding: 0 4px;
}

.manga-card-link {
  display: block;
}

.manga-card .info {
  padding: 10px 12px 6px;
}

.manga-card .title {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.35;
  height: 2.7em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* "มังงะยอดนิยม" badge on cards: frosted dark glass disc with an ice-blue
   glowing, gently flickering flame, in the same ice-blue style as the
   new-chapter sparkle (.chapter-btn-bell). CSS-only, so the shared markup
   from bm_featured_badge_html() and assets/search.js stays unchanged. */
.featured-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: #e0f2fe;
  background: radial-gradient(circle at 35% 30%, rgba(56, 189, 248, 0.35), rgba(8, 9, 13, 0.75) 70%);
  border: 1px solid rgba(125, 211, 252, 0.55);
  backdrop-filter: blur(4px);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.45), inset 0 0 6px rgba(125, 211, 252, 0.25);
  animation: featured-glow 3s ease-in-out infinite;
}

.featured-badge svg {
  width: 15px;
  height: 15px;
  transform-origin: 50% 90%;
  filter: drop-shadow(0 0 2px #38bdf8) drop-shadow(0 0 4px rgba(56, 189, 248, 0.8));
  animation: flame-flicker 1.6s ease-in-out infinite;
}

/* Hollow-looking inner flame: dark core inside the ice-blue outer flame. */
.featured-badge .flame-core {
  fill: #0b1220;
  opacity: 0.55;
}

/* Gentle sway/stretch like a real flame, anchored at its base. */
@keyframes flame-flicker {
  0%, 100% { transform: scale(1, 1) skewX(0deg); }
  25%      { transform: scale(0.96, 1.06) skewX(-3deg); }
  50%      { transform: scale(1.03, 0.97) skewX(2deg); }
  75%      { transform: scale(0.98, 1.04) skewX(-1deg); }
}

@keyframes featured-glow {
  0%, 100% { box-shadow: 0 0 8px rgba(56, 189, 248, 0.35), inset 0 0 6px rgba(125, 211, 252, 0.2); }
  50%      { box-shadow: 0 0 14px rgba(56, 189, 248, 0.7), inset 0 0 8px rgba(125, 211, 252, 0.35); }
}

@media (prefers-reduced-motion: reduce) {
  .featured-badge, .featured-badge svg { animation: none; }
}

@keyframes ring-bell {
  0%, 10% { transform: rotate(0); }
  15% { transform: rotate(15deg); }
  20% { transform: rotate(-15deg); }
  25% { transform: rotate(12deg); }
  30% { transform: rotate(-12deg); }
  35% { transform: rotate(9deg); }
  40% { transform: rotate(-9deg); }
  45% { transform: rotate(0); }
  100% { transform: rotate(0); }
}

.new-bell {
  animation: ring-bell 3s infinite;
  transform-origin: top center;
}

.empty-state {
  padding: 80px 20px;
  text-align: center;
  color: var(--text-dim);
}

.search-result-count {
  color: var(--text-faint);
  font-size: 0.85rem;
  margin-top: -12px;
  padding-bottom: 16px;
}

/* ---------- Series detail ---------- */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-dim);
  font-size: 0.9rem;
  padding: 20px 0 0;
}
.back-link:hover { color: var(--text); }

.series-hero-wrap {
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.series-backdrop {
  position: absolute;
  inset: -10%;
  background-size: cover;
  background-position: center 25%;
  background-repeat: no-repeat;
  filter: blur(50px) saturate(1.5) brightness(0.5);
  transform: scale(1.15);
  z-index: 0;
}

.series-hero-wrap::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(8, 9, 13, 0.35) 0%, var(--bg) 96%);
  z-index: 1;
}

.series-hero-wrap > .container {
  position: relative;
  z-index: 2;
}

.series-hero {
  display: flex;
  gap: 28px;
  padding: 24px 0 32px;
}

.series-hero .cover-lg {
  flex: 0 0 200px;
  width: 200px;
  height: 280px;
  min-width: 0;
  border-radius: var(--radius);
  overflow: hidden;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.series-hero .meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.series-title {
  font-size: 1.7rem;
  font-weight: 800;
  line-height: 1.25;
}

.meta-fields {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.meta-field {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.meta-label {
  flex-shrink: 0;
  width: 64px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-faint);
}

.meta-field-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* ---------- Star rating (series detail, read-only) ---------- */
.star-rating {
  display: flex;
  align-items: center;
  gap: 10px;
}

.star-rating-stars {
  display: inline-flex;
  gap: 2px;
}

.star-rating-stars .star {
  position: relative;
  font-size: 1.3rem;
  line-height: 1;
  color: var(--border);
}

/* Filled part: soft gold with a light shimmer sweeping across the stars
   one after another, plus a faint warm glow. */
.star-rating-stars .star::before {
  content: '★';
  position: absolute;
  inset: 0;
  width: var(--fill);
  overflow: hidden;
  color: transparent;
  background: linear-gradient(110deg, var(--rating-gold) 0%, var(--rating-gold) 40%, var(--rating-gold-hi) 50%, var(--rating-gold) 60%, var(--rating-gold) 100%);
  background-size: 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  filter: drop-shadow(0 0 3px rgba(243, 210, 126, 0.45));
  animation: star-shimmer 4.5s ease-in-out infinite;
}

.star-rating-stars .star:nth-child(2)::before { animation-delay: 0.12s; }
.star-rating-stars .star:nth-child(3)::before { animation-delay: 0.24s; }
.star-rating-stars .star:nth-child(4)::before { animation-delay: 0.36s; }
.star-rating-stars .star:nth-child(5)::before { animation-delay: 0.48s; }

@keyframes star-shimmer {
  0%, 55% { background-position: 100% 0; }
  85%, 100% { background-position: 0 0; }
}

.star-rating-avg {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--rating-gold);
  text-shadow: 0 0 6px rgba(243, 210, 126, 0.35);
}

@media (prefers-reduced-motion: reduce) {
  .star-rating-stars .star::before { animation: none; }
}

.star-rating-compact {
  gap: 5px;
  margin-top: 4px;
}

.star-rating-compact .star-rating-stars {
  gap: 1px;
}

.star-rating-compact .star-rating-stars .star {
  font-size: 0.72rem;
}

.star-rating-compact .star-rating-avg {
  font-size: 0.72rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
}

a.chip:hover {
  border-color: var(--accent);
  color: var(--text);
}

.chip.accent {
  color: var(--accent);
  border-color: rgba(56, 189, 248, 0.4);
  background: rgba(56, 189, 248, 0.08);
}

.synopsis {
  color: var(--text-dim);
  line-height: 1.7;
  font-size: 0.92rem;
  max-width: 65ch;
}

.cta-row {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.btn:hover { border-color: var(--accent); }

.btn-primary {
  background: var(--gradient-brand);
  border-color: transparent;
  color: var(--accent-contrast);
  box-shadow: 0 6px 16px -4px rgba(56, 189, 248, 0.45);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px -4px rgba(56, 189, 248, 0.55);
  border-color: transparent;
}

.section-title {
  font-size: 1.05rem;
  font-weight: 800;
  padding: 8px 0 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ---------- Section title row (used with scroller sections) ---------- */
.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0 14px;
}

.section-title-row .section-title,
.section-title-row .page-heading {
  padding: 0;
}

.see-all-link {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-dim);
  flex-shrink: 0;
}

.see-all-link:hover {
  color: var(--accent);
}

.chapter-jump {
  margin-bottom: 14px;
}

.chapter-jump input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 0.9rem;
}

.chapter-jump input:focus {
  outline: none;
  border-color: var(--accent);
}

.chapter-select {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.82rem;
  max-width: 200px;
}

.chapter-list {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-height: 480px;
  overflow-y: auto;
  overscroll-behavior: contain;
  margin-bottom: 60px;
  scrollbar-width: thin;
  scrollbar-color: var(--accent-2) transparent;
}

.chapter-list::-webkit-scrollbar {
  width: 8px;
}

.chapter-list::-webkit-scrollbar-thumb {
  background: var(--accent-2);
  border-radius: 4px;
}

.chapter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  transition: background 0.15s ease;
}

.chapter-row:last-child { border-bottom: none; }
.chapter-row:hover { background: var(--bg-elevated); }

.chapter-row .chapter-name {
  font-size: 0.92rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chapter-row .chapter-sub {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text-faint);
  font-size: 0.78rem;
}

/* ---------- Chapter reader ---------- */
.reader-topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(8, 9, 13, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: 12px 0;
}

.reader-topbar .row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.reader-topbar .series-link {
  color: var(--text-dim);
  font-size: 0.82rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.reader-topbar .series-link:hover { color: var(--text); }

.reader-topbar .series-link-text {
  display: none;
}

/* Bare arrow on mobile/tablet (saves space); desktop shows the series title
   next to it so the topbar doesn't feel empty. */
@media (min-width: 769px) {
  .reader-topbar .series-link-text {
    display: inline;
    margin-left: 4px;
  }
}

.reader-topbar .chapter-title {
  font-weight: 700;
  font-size: 0.95rem;
  text-align: center;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 10px;
}

.reader-body {
  max-width: var(--content-max);
  margin: 0 auto;
  padding-top: 4px;
}

.reader-body img {
  width: 100%;
  height: auto;
  background: var(--bg-elevated);
}

.reader-header {
  padding: 36px 0 4px;
  text-align: center;
}

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text-faint);
  margin-bottom: 10px;
}

.breadcrumb a {
  color: var(--text-dim);
}

.breadcrumb a:hover {
  color: var(--accent);
}

.breadcrumb [aria-current="page"] {
  color: var(--text);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 240px;
}

.reader-h1 {
  font-size: 1.2rem;
  font-weight: 800;
  line-height: 1.35;
  margin-bottom: 8px;
}

.reader-series-back {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 10px;
}

.reader-series-back a {
  color: var(--text);
  font-weight: 600;
}

.reader-series-back a:hover {
  color: var(--accent);
}

.reader-description {
  font-size: 0.85rem;
  color: var(--text-dim);
  line-height: 1.6;
  margin-bottom: 4px;
}

.reader-description strong {
  color: var(--text);
}

.reader-nav-bar {
  max-width: var(--content-max);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 0;
}

.reader-nav-bar .chapter-select {
  max-width: 280px;
  flex: 1;
}

.reader-nav-btns {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

/* Bottom bar mirrors the top one on desktop: dropdown on the left, prev/next
   on the right — DOM order stays btns-then-select (needed for the mobile
   stack order below) and gets flipped visually here instead. */
@media (min-width: 769px) {
  .reader-nav-bottom .chapter-select {
    order: -1;
  }
}

.reader-nav-btns .btn { justify-content: center; }
.reader-nav-btns .btn[aria-disabled="true"] {
  opacity: 0.35;
  pointer-events: none;
}

/* ---------- Reading mode (long-strip vs page-by-page) ---------- */
/* Direct-child combinators only — .chapter-select is reused (for shared
   styling) by the page-select nested two levels deeper inside
   .reader-mode-row, and a plain descendant selector here would wrongly
   catch that too and fight its own internal ordering. */
.reader-nav-top > .chapter-select { order: 1; }
.reader-mode-row { order: 2; }
.reader-nav-top > .reader-nav-btns { order: 3; }

.reader-mode-row {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.reader-mode-toggle {
  display: inline-flex;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}

.mode-btn {
  background: none;
  border: none;
  padding: 7px 16px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-dim);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.mode-btn.active {
  background: var(--gradient-brand);
  color: var(--accent-contrast);
}

/* Order within the page-nav group itself: dropdown, then prev, then next —
   independent of how .reader-mode-row stacks it against the mode toggle. */
.reader-page-nav {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.reader-page-nav .page-select { order: 1; }
.reader-page-nav .reader-page-btns { order: 2; }

/* The `hidden` attribute alone loses to the explicit `display: flex` above
   (an author style always beats the UA stylesheet's [hidden] default) —
   this attribute selector has higher specificity so it wins instead. */
.reader-page-nav[hidden] {
  display: none;
}

.reader-page-nav .page-select {
  max-width: 280px;
  width: 100%;
}

.reader-page-btns {
  display: none;
  gap: 10px;
}

.reader-body.page-mode img {
  cursor: pointer;
}

/* Tablet: chapter dropdown + prev/next share a row (like desktop), but the
   mode toggle and the page-nav group each get their own full-width line —
   there isn't room to also put them side by side at this width. */
@media (min-width: 769px) {
  .reader-nav-top {
    display: grid;
    grid-template-columns: 1fr auto;
    row-gap: 10px;
    column-gap: 12px;
  }
  .reader-nav-top > .chapter-select { grid-column: 1; grid-row: 1; }
  .reader-nav-top > .reader-nav-btns { grid-column: 2; grid-row: 1; }
  .reader-mode-row {
    grid-column: 1 / -1;
    grid-row: 2;
    align-items: center;
  }
  .reader-page-nav {
    flex-direction: row;
    width: auto;
  }
  .reader-page-btns {
    display: flex;
  }
}

/* Desktop only: mode toggle and page-nav group share one row (toggle left,
   page-nav right) — same breakpoint the sidebar switches on, for a
   consistent "this is desktop now" line across the site. */
@media (min-width: 1025px) {
  .reader-mode-row {
    flex-direction: row;
    justify-content: space-between;
  }
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  .nav-toggle { display: flex; }

  .site-nav {
    position: fixed;
    top: var(--header-h);
    left: 0;
    right: 0;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.2s ease;
  }

  .site-nav.open { max-height: 300px; }

  .site-nav ul {
    flex-direction: column;
    align-items: stretch;
    padding: 8px;
    gap: 2px;
  }

  .site-nav a { height: 48px; padding: 0 16px; }
}

@media (max-width: 640px) {
  .container { padding: 0 16px; }
  .series-hero { flex-direction: column; gap: 16px; }
  .series-hero .cover-lg { flex-basis: auto; width: 190px; height: 266px; margin: 0 auto; }
  .series-hero .meta { text-align: center; align-items: center; }
  .series-hero .meta-fields { align-items: center; }
  .series-hero .meta-field { justify-content: center; }
  .series-hero .meta-field-tags { justify-content: center; }
  .series-hero .star-rating { justify-content: center; }
  .series-hero .synopsis { text-align: left; }
  .series-title { font-size: 1.2rem; }
  .synopsis { font-size: 0.88rem; }
  .manga-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .card-scroller-item { width: 160px; }
  .cta-row { flex-wrap: wrap; }
  .cta-row .btn { flex: 1 1 auto; justify-content: center; }
  .chapter-row { padding: 12px; }
  .chapter-row .chapter-sub { font-size: 0.7rem; }
  .reader-topbar .series-link { max-width: 90px; }
  .reader-header { padding-top: 52px; }
  .btn, .chip, .pill { min-height: 36px; }

  .reader-nav-bar {
    flex-direction: column;
    align-items: stretch;
    padding: 12px 0;
  }
  .reader-nav-bar .chapter-select {
    max-width: none;
    width: 100%;
  }
  .reader-nav-btns .btn { flex: 1; }
}

/* ---------- Rich Text Footer ---------- */
.rich-text-footer {
  font-size: 0.9rem;
  color: var(--text-dim);
  line-height: 1.6;
}
.rich-text-footer h1, .rich-text-footer h2, .rich-text-footer h3 {
  color: var(--text);
  margin-top: 1rem;
  margin-bottom: 0.5rem;
}
.rich-text-footer a {
  color: var(--accent);
  text-decoration: underline;
}
.rich-text-footer ul {
  list-style-type: disc;
  padding-left: 1.5rem;
  margin-bottom: 1rem;
}
.rich-text-footer ol {
  list-style-type: decimal;
  padding-left: 1.5rem;
  margin-bottom: 1rem;
}
.rich-text-footer p {
  margin-bottom: 0.5rem;
}

/* Ported from ScrollToTop.astro's component-scoped <style> (Astro injects
   this separately from global.css at build time) */
.scroll-to-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  background: var(--gradient-brand);
  color: var(--accent-contrast);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4), inset 0 2px 4px rgba(255, 255, 255, 0.2);
  opacity: 0;
  visibility: hidden;
  transform: translateY(1rem);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 90;
}
.scroll-to-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  animation: float-btn 3s ease-in-out infinite;
}
.scroll-to-top:hover {
  transform: translateY(-0.35rem) scale(1.05) !important;
  box-shadow: var(--shadow-accent);
  filter: brightness(1.15);
}
@keyframes float-btn {
  0% { transform: translateY(0); box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4), inset 0 2px 4px rgba(255, 255, 255, 0.2); }
  50% { transform: translateY(-6px); box-shadow: 0 8px 24px rgba(56, 189, 248, 0.25), inset 0 2px 4px rgba(255, 255, 255, 0.2); }
  100% { transform: translateY(0); box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4), inset 0 2px 4px rgba(255, 255, 255, 0.2); }
}
@media (max-width: 768px) {
  .scroll-to-top { bottom: 1.5rem; right: 1.5rem; width: 2.75rem; height: 2.75rem; }
}
