/* ==========================================================================
   SHEEPA LIBRARY - MINIMALIST ZEN DESIGN SYSTEM
   ========================================================================== */

:root {
  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-serif: 'Merriweather', 'Lora', Georgia, 'Times New Roman', serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.16, 1, 0.3, 1);

  /* Light Theme (Zen Paper) */
  --bg-primary: #faf9f6;
  --bg-secondary: #f3f1ec;
  --bg-card: #ffffff;
  --bg-hover: #ebe8e1;
  --border-color: #e5e0d8;
  --border-light: #ece7de;
  --text-main: #232220;
  --text-secondary: #6e6b65;
  --text-tertiary: #9c978f;
  --accent: #27272a;
  --primary-accent: var(--accent);
  --accent-contrast: #ffffff;
  --accent-badge: #e4e0d7;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.05);
  --reader-max-width: 720px;

  /* Goodreads & Awards */
  --gr-star-fill: #e87a15;
  --gr-star-empty: #e2e0d8;
  --gr-badge-bg: #fdfaf3;
  --gr-badge-border: #ebdcb8;
  --gr-badge-tag: #92400e;
  --gr-badge-score: #451a03;
  --gr-badge-votes: #78350f;
  --award-bg: rgba(234, 150, 20, 0.08);
  --award-border: rgba(234, 150, 20, 0.28);
  --award-text: #92400e;
}

[data-theme="dark"] {
  /* Dark Theme (Slate Charcoal - Dịu mắt khi đọc đêm) */
  --bg-primary: #121316;
  --bg-secondary: #1a1b1f;
  --bg-card: #1e1f24;
  --bg-hover: #26272e;
  --border-color: #2c2e36;
  --border-light: #23242b;
  --text-main: #ececec;
  --text-secondary: #a3a4ab;
  --text-tertiary: #6b6d77;
  --accent: #f4f4f5;
  --accent-contrast: #121316;
  --accent-badge: #272932;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.3);

  /* Goodreads & Awards Dark */
  --gr-star-fill: #f59e0b;
  --gr-star-empty: #333640;
  --gr-badge-bg: #222019;
  --gr-badge-border: #4d3d25;
  --gr-badge-tag: #fbbf24;
  --gr-badge-score: #fef3c7;
  --gr-badge-votes: #d97706;
  --award-bg: rgba(245, 158, 11, 0.12);
  --award-border: rgba(245, 158, 11, 0.35);
  --award-text: #fcd34d;
}

[data-theme="sepia"] {
  /* Vintage Warm Paper - Nền nâu vàng giấy cũ cổ điển, dịu nhẹ thư thái cho mắt */
  --bg-primary: #f5eed9;
  --bg-secondary: #ebdcb9;
  --bg-card: #fbf4e2;
  --bg-hover: #e2d2ab;
  --border-color: #d8c49a;
  --border-light: #e4d4b1;
  --text-main: #382b1a;
  --text-secondary: #6e583c;
  --text-tertiary: #967f60;
  --accent: #4d3822;
  --accent-contrast: #fcf7e8;
  --accent-badge: #e6d7b4;
  --shadow-sm: 0 1px 3px rgba(56, 43, 26, 0.08);
  --shadow-md: 0 4px 14px rgba(56, 43, 26, 0.12);

  /* Goodreads & Awards Sepia */
  --gr-star-fill: #c66f12;
  --gr-star-empty: #d8c49a;
  --gr-badge-bg: #f4e7cc;
  --gr-badge-border: #dec292;
  --gr-badge-tag: #78350f;
  --gr-badge-score: #451a03;
  --gr-badge-votes: #92400e;
  --award-bg: rgba(198, 111, 18, 0.1);
  --award-border: rgba(198, 111, 18, 0.3);
  --award-text: #6b3805;
}

/* Tự động làm sáng toàn bộ bộ Icon và Logo khi bật Dark Mode (trừ ảnh bìa sách thật và mã QR) */
[data-theme="dark"] .brand-logo,
[data-theme="dark"] .hero-badge-img,
[data-theme="dark"] .search-icon-img,
[data-theme="dark"] .header-filter-icon,
[data-theme="dark"] .header-btn-icon,
[data-theme="dark"] .card-icon-frame img,
[data-theme="dark"] .detail-cover-box img:not(.detail-cover-real),
[data-theme="dark"] .chapter-count img,
[data-theme="dark"] .section-heading img,
[data-theme="dark"] .site-footer img:not(.footer-qr-img) {
  filter: brightness(0) invert(0.92);
  transition: filter var(--transition-normal);
}

[data-theme="dark"] .card-icon-frame,
[data-theme="dark"] .detail-cover-box {
  background: #252730;
  border-color: #383b48;
}

/* Tông màu vintage dịu mắt cho chế độ Giấy Cũ */
[data-theme="sepia"] .card-icon-frame,
[data-theme="sepia"] .detail-cover-box {
  background: #faefd6;
  border-color: #d8c49a;
}

[data-theme="sepia"] .brand-logo,
[data-theme="sepia"] .hero-badge-img,
[data-theme="sepia"] .search-icon-img,
[data-theme="sepia"] .header-filter-icon,
[data-theme="sepia"] .header-btn-icon,
[data-theme="sepia"] .card-icon-frame img,
[data-theme="sepia"] .detail-cover-box img:not(.detail-cover-real),
[data-theme="sepia"] .chapter-count img,
[data-theme="sepia"] .section-heading img,
[data-theme="sepia"] .site-footer img:not(.footer-qr-img) {
  filter: sepia(0.35) contrast(0.95);
}

/* Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-main);
  line-height: 1.6;
  transition: background-color var(--transition-normal), color var(--transition-normal);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

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

button {
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
}

/* ==========================================================================
   HEADER & NAVBAR
   ========================================================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background-color: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: border-color var(--transition-normal), background-color var(--transition-normal);
}

.header-container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0.85rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-logo {
  width: 36px;
  height: 36px;
  object-fit: contain;
  border-radius: 8px;
  transition: transform var(--transition-fast);
}

.brand-link:hover .brand-logo {
  transform: rotate(-4deg) scale(1.05);
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.brand-subtitle {
  font-size: 0.72rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 500;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

/* Header Filter Dropdowns */
.header-filter-wrapper {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  height: 38px;
  padding: 0 0.65rem 0 0.55rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  transition: all var(--transition-fast);
  position: relative;
  cursor: pointer;
}

.header-filter-wrapper:hover {
  border-color: var(--text-secondary);
  background: var(--bg-hover);
}

/* Header Action Pill Button (Tiến độ) */
.header-action-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  height: 38px;
  padding: 0 0.75rem 0 0.55rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  user-select: none;
}

.header-action-pill-btn:hover {
  border-color: var(--text-secondary);
  background: var(--bg-hover);
  color: var(--text-main);
  transform: translateY(-1px);
}

.header-action-pill-btn:active {
  transform: translateY(0);
}

.header-action-pill-icon {
  width: 22px;
  height: 22px;
  object-fit: contain;
  opacity: 0.9;
  flex-shrink: 0;
}

.header-action-pill-label {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-main);
  white-space: nowrap;
}

.header-filter-icon {
  width: 22px;
  height: 22px;
  object-fit: contain;
  opacity: 0.9;
  flex-shrink: 0;
  pointer-events: none;
}

.header-filter-label {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-main);
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
  user-select: none;
}

.header-filter-arrow {
  flex-shrink: 0;
  color: var(--text-secondary);
  pointer-events: none;
  margin-left: -0.1rem;
}

.header-filter-select {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  -webkit-appearance: menulist;
  appearance: menulist;
}

.header-filter-select option {
  background: var(--bg-primary);
  color: var(--text-main);
  padding: 4px;
}

/* Header View Mode Toggle & Icon Buttons */
.header-icon-btn, .theme-toggle-btn, .icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-main);
  transition: all var(--transition-fast);
  cursor: pointer;
}

.header-icon-btn:hover, .theme-toggle-btn:hover, .icon-btn:hover {
  background: var(--bg-hover);
  border-color: var(--text-secondary);
}

.header-btn-icon {
  width: 24px;
  height: 24px;
  object-fit: contain;
  opacity: 0.9;
}

.inline-glyph-icon {
  width: 17px;
  height: 17px;
  vertical-align: -2px;
  margin-right: 5px;
  object-fit: contain;
  display: inline-block;
}

[data-theme="dark"] .inline-glyph-icon {
  filter: brightness(0) invert(0.92);
}

[data-theme="sepia"] .inline-glyph-icon {
  filter: sepia(0.35) contrast(0.95);
}

.theme-toggle-btn svg, .icon-btn svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ==========================================================================
   APP MAIN CONTENT
   ========================================================================== */
#app {
  flex: 1;
  width: 100%;
}

.page-container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}

/* ==========================================================================
   VIEW: LIBRARY (THƯ VIỆN TOÀN BỘ)
   ========================================================================== */
.library-hero {
  margin-bottom: 2.5rem;
  text-align: center;
  padding: 1.5rem 0;
}

.hero-badge-img {
  width: 64px;
  height: 64px;
  object-fit: contain;
  margin-bottom: 1rem;
  transition: transform var(--transition-fast);
}

.hero-badge-img:hover {
  transform: scale(1.1) rotate(-4deg);
}

.library-hero h1 {
  font-size: 2.25rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 0.65rem;
}

.hero-tagline {
  color: var(--text-secondary);
  font-size: 1.05rem;
  max-width: 720px;
  margin: 0 auto;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  transition: opacity 0.3s ease, transform 0.3s ease, color var(--transition-fast);
  cursor: pointer;
  user-select: none;
}

.hero-tagline:hover {
  color: var(--text-main);
}

.hero-tagline.fade-out {
  opacity: 0;
  transform: translateY(4px);
}

.tagline-quote {
  font-style: italic;
  display: block;
}

.tagline-quote.tagline-intro {
  font-style: normal;
}

.tagline-author {
  display: block;
  font-style: normal;
  font-weight: 600;
  font-size: 0.92rem;
  opacity: 0.85;
}

.search-filter-section {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-bottom: 2.5rem;
}

.search-box-wrapper {
  position: relative;
  max-width: 580px;
  margin: 0 auto;
  width: 100%;
}

.search-icon-img {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  opacity: 0.6;
}

.search-input {
  width: 100%;
  padding: 0.85rem 1rem 0.85rem 2.85rem;
  font-size: 0.95rem;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-main);
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.search-input:focus {
  border-color: var(--text-main);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .search-input:focus {
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.1);
}

.filter-tags {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.5rem;
  justify-content: center;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding: 0.25rem 0.5rem;
  max-width: 100%;
}

.filter-tags::-webkit-scrollbar {
  display: none;
}

.filter-btn {
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  border: 1px solid transparent;
  transition: all var(--transition-fast);
  white-space: nowrap;
  flex-shrink: 0;
}

.filter-btn:hover {
  color: var(--text-main);
  background: var(--bg-hover);
}

.filter-btn.active {
  background: var(--accent);
  color: var(--accent-contrast);
  border-color: var(--accent);
}

/* --- LIBRARY TOOLBAR (COUNT & SORT) --- */
.library-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: -0.5rem;
  margin-bottom: 1.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.88rem;
  color: var(--text-secondary);
  flex-wrap: wrap;
  gap: 0.75rem;
}

.toolbar-info strong {
  color: var(--text-main);
}

.sort-select-wrapper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sort-select {
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-main);
  font-size: 0.85rem;
  font-weight: 500;
  outline: none;
  cursor: pointer;
}

.sort-select:focus {
  border-color: var(--primary-accent);
}

/* --- PAGINATION CONTROLS --- */
.pagination-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  margin-top: 3rem;
  margin-bottom: 2rem;
  user-select: none;
}

.pagination-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  height: 38px;
  padding: 0 0.5rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-main);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.pagination-btn:hover:not(:disabled):not(.active) {
  background: var(--bg-hover);
  border-color: var(--text-secondary);
}

.pagination-btn.active {
  background: var(--accent);
  color: var(--accent-contrast, #ffffff);
  border-color: var(--accent);
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
  pointer-events: none;
}

.pagination-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.pagination-ellipsis {
  padding: 0 0.4rem;
  color: var(--text-tertiary);
  font-weight: 600;
  font-size: 1rem;
}

/* Bookshelf Grid */
.books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.75rem;
}

.book-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
  position: relative;
}

.book-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--text-secondary);
}

.card-top {
  display: flex;
  align-items: center;
  gap: 1.15rem;
  margin-bottom: 0.65rem;
}

.book-cover-real {
  width: 70px;
  height: 100px;
  object-fit: cover;
  border-radius: 6px;
  box-shadow: 2px 4px 12px rgba(0, 0, 0, 0.2);
  flex-shrink: 0;
  transition: transform var(--transition-fast);
}

.book-card:hover .book-cover-real {
  transform: translateY(-2px) scale(1.02);
}

.card-icon-frame {
  width: 64px;
  height: 84px;
  border-radius: 8px;
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1px solid var(--border-light);
}

.card-icon-frame img {
  width: 44px;
  height: 44px;
  object-fit: contain;
}

.card-meta {
  flex: 1;
  min-width: 0;
}

.card-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.3;
  margin-bottom: 0.15rem;
}

.card-original-title {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-style: italic;
  line-height: 1.25;
  margin-top: -0.05rem;
  margin-bottom: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.01em;
}

.card-author {
  font-size: 0.84rem;
  color: var(--text-secondary);
  line-height: 1.25;
}

/* Goodreads Star Rating in Cards (Grid & List) */
.card-gr-rating {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.35rem;
  font-size: 0.8rem;
  line-height: 1;
  white-space: nowrap;
}

.gr-stars-container {
  position: relative;
  display: inline-block;
  vertical-align: middle;
  line-height: 1;
  flex-shrink: 0;
}

.gr-stars-base,
.gr-stars-fill {
  display: flex;
  align-items: center;
  line-height: 1;
}

.gr-stars-base {
  color: var(--gr-star-empty);
}

.gr-stars-fill {
  position: absolute;
  top: 0;
  left: 0;
  overflow: hidden;
  white-space: nowrap;
  color: var(--gr-star-fill);
  pointer-events: none;
}

.gr-star-svg {
  flex-shrink: 0;
  display: block;
  fill: currentColor;
}

.gr-score-val {
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--text-main);
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.gr-count-val {
  font-size: 0.74rem;
  color: var(--text-tertiary);
  white-space: nowrap;
}

/* Horizontal Badges Row Across Full Card Width */
.card-badges-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 0.5rem;
  margin: 0.35rem 0 0.85rem 0;
}

.badge-tag {
  font-size: 0.72rem;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-weight: 500;
  white-space: nowrap !important;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  line-height: 1.25;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
}

.badge-tag:hover {
  background: var(--bg-hover);
  color: var(--text-main);
  border-color: var(--border-color);
}

.badge-series {
  background: #f5f3ff;
  color: #7c3aed;
  font-weight: 600;
  border: 1px solid rgba(124, 58, 237, 0.25);
  white-space: nowrap !important;
  display: inline-flex;
  align-items: center;
  line-height: 1.25;
  flex-shrink: 0;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.badge-series:hover {
  background: #ede9fe;
  border-color: #7c3aed;
  color: #5b21b6;
  transform: translateY(-1px);
}

[data-theme="dark"] .badge-series {
  background: #2e1065;
  color: #c4b5fd;
  border-color: rgba(196, 181, 253, 0.3);
}

[data-theme="dark"] .badge-series:hover {
  background: #3b1382;
  color: #ffffff;
  border-color: #a78bfa;
}

[data-theme="sepia"] .badge-series {
  background: #f3e8ff;
  color: #6b21a8;
  border-color: rgba(107, 33, 168, 0.25);
}

[data-theme="sepia"] .badge-series:hover {
  background: #e9d5ff;
  color: #581c87;
}

.detail-series-banner {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.85rem;
  border-radius: 6px;
  background: #f5f3ff;
  color: #6d28d9;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  border: 1px solid rgba(124, 58, 237, 0.2);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.detail-series-banner:hover {
  background: #ede9fe;
  border-color: #7c3aed;
  color: #5b21b6;
}

[data-theme="dark"] .detail-series-banner {
  background: #2e1065;
  color: #ddd6fe;
  border-color: rgba(196, 181, 253, 0.25);
}

[data-theme="dark"] .detail-series-banner:hover {
  background: #3b1382;
  border-color: #a78bfa;
}

.badge-status {
  font-size: 0.72rem;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  font-weight: 600;
  white-space: nowrap !important;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  line-height: 1.25;
}

.badge-status.completed {
  background: #ecfdf5;
  color: #059669;
}

[data-theme="dark"] .badge-status.completed {
  background: #064e3b;
  color: #6ee7b7;
}

.badge-status.ongoing {
  background: #eff6ff;
  color: #2563eb;
}

[data-theme="dark"] .badge-status.ongoing {
  background: #1e3a8a;
  color: #93c5fd;
}

/* Bilingual Badge for Book Cards */
.badge-bilingual {
  background: #eef2ff;
  color: #4f46e5;
  border: 1px solid rgba(79, 70, 229, 0.25);
  font-weight: 600;
  font-size: 0.72rem;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  white-space: nowrap !important;
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  line-height: 1.25;
  flex-shrink: 0;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.badge-bilingual:hover {
  background: #e0e7ff;
  border-color: #6366f1;
  color: #4338ca;
}

[data-theme="dark"] .badge-bilingual {
  background: rgba(99, 102, 241, 0.18);
  color: #a5b4fc;
  border-color: rgba(165, 180, 252, 0.35);
}

[data-theme="dark"] .badge-bilingual:hover {
  background: rgba(99, 102, 241, 0.32);
  color: #ffffff;
  border-color: #818cf8;
}

[data-theme="sepia"] .badge-bilingual {
  background: #ede9fe;
  color: #5b21b6;
  border-color: rgba(91, 33, 182, 0.25);
}

[data-theme="sepia"] .badge-bilingual:hover {
  background: #ddd6fe;
  color: #4c1d95;
}

.card-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.3;
  margin-bottom: 0.15rem;
}

.card-author {
  font-size: 0.84rem;
  color: var(--text-secondary);
}

.card-desc {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.48;
  margin-bottom: 1rem;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border-light);
  padding-top: 0.9rem;
  margin-top: auto;
}

.chapter-count {
  font-size: 0.82rem;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.chapter-count img {
  width: 16px;
  height: 16px;
  opacity: 0.7;
}

.card-actions {
  display: flex;
  gap: 0.5rem;
}

.btn-sm {
  padding: 0.4rem 0.8rem;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: 6px;
  transition: all var(--transition-fast);
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-contrast);
}

.btn-primary:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.btn-outline {
  border: 1px solid var(--border-color);
  color: var(--text-main);
  background: var(--bg-card);
}

.btn-outline:hover {
  background: var(--bg-hover);
  border-color: var(--text-secondary);
}

/* ==========================================================================
   BOOKSHELF LIST VIEW MODE
   ========================================================================== */
.books-grid.list-view {
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
}

.books-grid.list-view .book-card {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 1.5rem;
  padding: 1.25rem 1.5rem;
}

.books-grid.list-view .card-top {
  margin-bottom: 0;
  display: flex;
  align-items: flex-start;
  flex-shrink: 0;
}

.books-grid.list-view .book-cover-real {
  width: 72px;
  height: 104px;
}

.books-grid.list-view .card-icon-frame {
  width: 72px;
  height: 104px;
}

.books-grid.list-view .card-content-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.books-grid.list-view .card-meta {
  margin-bottom: 0.25rem;
}

.books-grid.list-view .card-title {
  font-size: 1.25rem;
  margin-bottom: 0.15rem;
}

.books-grid.list-view .card-author {
  font-size: 0.88rem;
}

.books-grid.list-view .card-badges-row {
  margin: 0.25rem 0 0.5rem 0;
}

.books-grid.list-view .card-desc {
  font-size: 0.82rem;
  line-height: 1.45;
  margin-bottom: 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.books-grid.list-view .card-footer {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 0.85rem;
  flex-shrink: 0;
  min-width: 145px;
}

.books-grid.list-view .chapter-count {
  font-size: 0.85rem;
}

.books-grid.list-view .card-actions {
  display: flex;
  flex-direction: row;
  gap: 0.5rem;
}

@media (max-width: 768px) {
  .header-container {
    padding: 0.65rem 1rem;
    flex-wrap: wrap;
    gap: 0.65rem;
  }
  .nav-actions {
    gap: 0.4rem;
    flex-wrap: wrap;
  }
  .header-filter-wrapper {
    height: 34px;
    padding: 0 0.5rem 0 0.4rem;
    gap: 0.35rem;
  }
  .header-action-pill-btn {
    height: 34px;
    padding: 0 0.55rem 0 0.45rem;
    gap: 0.35rem;
  }
  .header-action-pill-icon {
    width: 19px;
    height: 19px;
  }
  .header-action-pill-label {
    font-size: 0.75rem;
  }
  .header-filter-label {
    max-width: 75px;
    font-size: 0.75rem;
  }
  .header-filter-icon {
    width: 19px;
    height: 19px;
  }
  .header-icon-btn, .theme-toggle-btn {
    width: 34px;
    height: 34px;
  }
  .header-btn-icon {
    width: 21px;
    height: 21px;
  }
  .theme-toggle-btn svg {
    width: 18px;
    height: 18px;
  }
  .books-grid.list-view .book-card {
    flex-direction: column;
    gap: 1rem;
    align-items: flex-start;
  }
  .books-grid.list-view .card-footer {
    width: 100%;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border-light);
    padding-top: 0.75rem;
  }
}

/* ==========================================================================
   VIEW: BOOK DETAIL (CHI TIẾT CUỐN SÁCH)
   ========================================================================== */
.back-nav-bar {
  margin-bottom: 1.5rem;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-weight: 500;
  transition: color var(--transition-fast);
}

.back-link:hover {
  color: var(--text-main);
}

.book-detail-header {
  display: flex;
  align-items: center;
  gap: 2.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 2.25rem;
  margin-bottom: 2rem;
}

@media (max-width: 768px) {
  .book-detail-header {
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 1.5rem;
    gap: 1.5rem;
  }
}

.detail-cover-box {
  flex: 0 0 270px;
  width: 270px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  align-self: center;
  background: transparent;
  border: none;
  overflow: visible;
}

.detail-cover-real {
  width: 100%;
  max-width: 270px;
  height: auto;
  max-height: 440px;
  object-fit: contain;
  display: block;
  border-radius: 12px;
  box-shadow: 0 10px 28px -4px rgba(0, 0, 0, 0.22), 0 6px 14px -3px rgba(0, 0, 0, 0.12);
  border: 1px solid rgba(0, 0, 0, 0.08);
}

[data-theme="dark"] .detail-cover-real {
  box-shadow: 0 10px 28px -4px rgba(0, 0, 0, 0.65), 0 6px 14px -3px rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .detail-cover-box:has(.detail-cover-real),
[data-theme="sepia"] .detail-cover-box:has(.detail-cover-real) {
  background: transparent;
  border-color: transparent;
}

.detail-cover-box:not(:has(.detail-cover-real)) {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  min-height: 320px;
  padding: 1.5rem;
  gap: 0.5rem;
  width: 260px;
  align-items: center;
  justify-content: center;
}

.detail-cover-box img:not(.detail-cover-real) {
  width: 72px;
  height: 72px;
  object-fit: contain;
}

@media (max-width: 768px) {
  .detail-cover-box {
    flex: 0 0 auto;
    width: auto;
    max-width: 230px;
    align-self: center;
  }
  .detail-cover-real {
    max-width: 230px;
  }
}

.detail-info {
  flex: 1;
}

.detail-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.5rem;
  align-items: center;
  margin-bottom: 0.75rem;
}

@media (max-width: 768px) {
  .detail-badges {
    justify-content: center;
  }
}

.detail-title {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 0.25rem;
}

.detail-original-title {
  font-size: 1rem;
  color: var(--text-tertiary);
  font-style: italic;
  margin-bottom: 0.85rem;
}

/* Goodreads Rating & Awards in Book Detail */
.detail-showcase-card {
  background: var(--gr-badge-bg);
  border: 1px solid var(--gr-badge-border);
  border-radius: 12px;
  padding: 0.75rem 1.15rem;
  margin-bottom: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  box-shadow: 0 1px 4px rgba(146, 64, 14, 0.04);
  transition: all var(--transition-fast);
}

.showcase-rating-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.65rem;
  line-height: 1;
}

.showcase-brand {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gr-badge-tag);
}

.showcase-score-group {
  display: inline-flex;
  align-items: baseline;
  gap: 0.2rem;
}

.showcase-score {
  font-size: 0.96rem;
  font-weight: 800;
  color: var(--gr-badge-score);
}

.showcase-max {
  font-size: 0.76rem;
  font-weight: 500;
  color: var(--gr-badge-votes);
  opacity: 0.8;
}

.showcase-count {
  font-size: 0.78rem;
  color: var(--gr-badge-votes);
}

.showcase-awards-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.showcase-awards-list.has-rating-divider {
  border-top: 1px dashed var(--gr-badge-border);
  margin-top: 0.15rem;
  padding-top: 0.55rem;
}

.showcase-award-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.83rem;
  color: var(--award-text);
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: -0.01em;
}

.showcase-trophy {
  flex-shrink: 0;
  color: var(--gr-star-fill);
}

.detail-specs-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  padding: 0.85rem 1rem;
  background: var(--bg-secondary);
  border-radius: 8px;
  font-size: 0.85rem;
}

@media (max-width: 600px) {
  .detail-specs-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.spec-item strong {
  display: block;
  color: var(--text-tertiary);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.15rem;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

@media (max-width: 768px) {
  .detail-actions {
    justify-content: center;
  }
}

.btn-lg {
  padding: 0.75rem 1.4rem;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: all var(--transition-fast);
}

.detail-blurb-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 1.75rem;
  margin-bottom: 2rem;
}

.section-heading {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.section-heading img {
  width: 22px;
  height: 22px;
}

.detail-blurb-box p {
  color: var(--text-secondary);
  line-height: 1.7;
  font-size: 1rem;
}

/* Chapters Table of Contents */
.detail-toc-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 1.75rem;
  margin-bottom: 2rem;
}

.toc-list {
  list-style: none;
  display: flex;
  flex-direction: column;
}

/* --- HIERARCHICAL TOC ACCORDION (PARTS & CHAPTERS) --- */
.detail-toc-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.btn-toggle-all-parts {
  background: var(--bg-hover);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}

.btn-toggle-all-parts:hover {
  background: var(--bg-card);
  color: var(--accent-color);
  border-color: var(--accent-color);
}

.toc-part-group {
  margin-top: 0.6rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-card);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.toc-part-group:first-child {
  margin-top: 0;
}

.toc-part-group:hover {
  border-color: var(--border-dark);
}

.toc-group-header {
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--text-main);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.85rem 1rem;
  background: var(--bg-hover);
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.2s ease;
}

.toc-group-header:hover {
  background: var(--border-light);
}

.toc-group-title {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex: 1;
}

.toc-part-name {
  font-weight: 700;
}

.toc-part-group:not(.open) .toc-folder-open { display: none !important; }
.toc-part-group:not(.open) .toc-folder-closed { display: inline-block !important; }
.toc-part-group.open .toc-folder-open { display: inline-block !important; }
.toc-part-group.open .toc-folder-closed { display: none !important; }

.toc-part-count {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-card);
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--border-light);
  text-transform: none;
  letter-spacing: normal;
  margin-left: 0.25rem;
}

.toc-group-actions {
  display: flex;
  align-items: center;
  padding-left: 0.5rem;
}

.toc-chevron {
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  color: var(--text-secondary);
}

.toc-part-group:not(.open) .toc-chevron {
  transform: rotate(-90deg);
}

.toc-part-group.open .toc-chevron {
  transform: rotate(0deg);
}

.toc-group-content {
  border-top: 1px solid var(--border-light);
}

.toc-part-group:not(.open) .toc-group-content {
  display: none;
}

.toc-item-link.toc-sub-item {
  padding-left: 1.5rem;
  border-bottom: 1px dashed var(--border-light);
}

.toc-item-link.toc-sub-item:hover {
  padding-left: 1.85rem;
}

.toc-item-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--border-light);
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: 500;
  transition: background-color var(--transition-fast), padding-left var(--transition-fast);
}

.toc-item-link:last-child {
  border-bottom: none;
}

.toc-item-link:hover {
  background-color: var(--bg-secondary);
  padding-left: 1.35rem;
}

.toc-index {
  color: var(--text-tertiary);
  font-size: 0.85rem;
  font-weight: 600;
  margin-right: 0.75rem;
}

.toc-arrow {
  color: var(--text-tertiary);
  font-size: 1.1rem;
}

/* ==========================================================================
   VIEW: ZEN READER (GIAO DIỆN ĐỌC ONLINE)
   ========================================================================== */
.reader-view {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.reader-progress-bar-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: transparent;
  z-index: 100;
}

.reader-progress-bar {
  height: 100%;
  width: 0%;
  background: var(--text-main);
  transition: width 0.1s ease-out;
}

.reader-nav {
  position: sticky;
  top: 0;
  z-index: 40;
  background-color: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.reader-nav-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0.7rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.reader-title-info {
  text-align: center;
  flex: 1;
  padding: 0 1rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reader-book-name {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: block;
}

.reader-chapter-name {
  font-size: 0.95rem;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reader-tools {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Reader Typography Engine */
.reader-article-container {
  max-width: var(--reader-max-width);
  margin: 0 auto;
  padding: 2rem 1.5rem 5rem;
  width: 100%;
  transition: max-width var(--transition-fast);
}

.reader-content {
  font-size: 1.15rem;
  line-height: 1.85;
  transition: font-size var(--transition-fast), line-height var(--transition-fast);
}

/* Reader Content Markdown Styles */
.reader-content h1 {
  font-size: 2.15rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  text-align: center !important;
  margin-top: 1rem;
  margin-bottom: 1.75rem;
  padding-bottom: 0.85rem;
  position: relative;
  border-bottom: none;
}

.reader-content h1::after {
  content: "";
  display: block;
  width: 64px;
  height: 2px;
  background: var(--primary-accent);
  margin: 0.9rem auto 0;
  border-radius: 2px;
  opacity: 0.65;
}

.reader-content h2 {
  font-size: 1.45rem;
  font-weight: 700;
  margin-top: 2rem;
  margin-bottom: 1rem;
}

/* Chapter Title & Excerpt in novel headers (Joy Moore, Benny Abbott, Trích đoạn hồi ký) */
.reader-content h2.h2-1,
.reader-content .h2-1,
.reader-content h2.chapter-title,
.reader-content .chapter-title,
.reader-content p.p0,
.reader-content .p0,
.reader-content .h-name-1 {
  text-align: center !important;
  margin-left: auto;
  margin-right: auto;
  display: block;
}

.reader-content p.p0 {
  margin-top: 0.5rem;
  margin-bottom: 1.25rem;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  opacity: 0.9;
}

.bilingual-pair.chapter-title-pair .bilingual-vi-content,
.bilingual-pair.chapter-title-pair .bilingual-en-content,
.bilingual-pair.excerpt-pair .bilingual-vi-content,
.bilingual-pair.excerpt-pair .bilingual-en-content,
.bilingual-pair.chapter-subtitle-pair .bilingual-vi-content,
.bilingual-pair.chapter-subtitle-pair .bilingual-en-content {
  text-align: center !important;
}

.reader-content p {
  margin-bottom: 1.35rem;
  text-align: justify;
  text-justify: inter-word;
  line-height: inherit;
}

/* Reader Alignment Setting (Căn đều vs Căn trái) */
.reader-content[data-text-align="justify"] p {
  text-align: justify;
  text-justify: inter-word;
}

.reader-content[data-text-align="left"] p {
  text-align: left;
}

.reader-content .chapter-part-eyebrow,
.reader-content p.chapter-part-eyebrow {
  font-style: italic;
  color: var(--text-secondary);
  font-size: 1.05rem;
  font-weight: 500;
  opacity: 0.88;
  margin-top: 0.5rem;
  margin-bottom: -0.25rem;
  text-align: center !important;
}

.reader-content .chapter-part-eyebrow + h1 {
  margin-top: 0.35rem !important;
}

.reader-content .chapter-subtitle {
  font-style: italic;
  color: var(--text-secondary);
  font-size: 1.08rem;
  margin-top: -0.65rem;
  margin-bottom: 2rem;
  font-weight: 600;
  opacity: 0.92;
  text-align: center !important;
}

/* Scene break divider (<hr class="scene-break"/>, • • •, ✦ ✦ ✦, * * *) */
.reader-content hr,
.reader-content hr.scene-break,
.reader-content hr.split-symbol {
  border: 0 !important;
  border-top: none !important;
  border-bottom: none !important;
  text-align: center !important;
  margin: 2.5rem auto !important;
  height: auto !important;
  width: 100% !important;
  clear: both;
  background: transparent !important;
  display: block !important;
  overflow: visible !important;
}

.reader-content hr::before,
.reader-content hr.scene-break::before,
.reader-content hr.split-symbol::before {
  content: "✦ ✦ ✦";
  color: #C5A059;
  letter-spacing: 0.55em;
  font-size: 1.15rem;
  display: block;
  text-align: center !important;
  margin: 0 auto !important;
  font-weight: 600;
  line-height: 1;
}

.reader-content .scene-break,
.reader-content p.scene-break,
.reader-content .split-symbol,
.reader-content p.split-symbol {
  text-align: center !important;
  letter-spacing: 0.55em;
  margin: 2.25rem auto !important;
  font-size: 1.15rem;
  color: #C5A059;
  user-select: none;
  font-weight: 600;
  display: block;
}

/* Trang Lời đề tặng (Dedication / Epigraph) */
.reader-content.is-dedication {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 40vh;
}

.reader-content.is-dedication p {
  text-align: center !important;
  font-style: italic;
  font-size: 1.12em;
  max-width: 82%;
  margin: 1.25rem auto !important;
  line-height: 1.9;
  color: var(--text-secondary);
}

/* --- TEXT ALIGNMENT IN READER & MARKDOWN --- */
.reader-content p[align="center"],
.reader-content div[align="center"],
.reader-content h1[align="center"],
.reader-content h2[align="center"],
.reader-content h3[align="center"],
.reader-content center,
.reader-content .text-center,
.reader-content .scene-break,
.reader-content p.scene-break,
.reader-content .chapter-subtitle,
.reader-content .chapter-part-eyebrow,
.reader-content.is-dedication p,
.bilingual-pair.scene-break,
.bilingual-pair.scene-break .scene-break,
.bilingual-vi-content.text-center,
.bilingual-en-content.text-center {
  text-align: center !important;
  margin-left: auto;
  margin-right: auto;
}

.reader-content p[align="right"],
.reader-content div[align="right"],
.reader-content h1[align="right"],
.reader-content h2[align="right"],
.reader-content h3[align="right"],
.reader-content .text-right {
  text-align: right !important;
  margin-left: auto;
}

.reader-content p[align="justify"],
.reader-content .text-justify {
  text-align: justify !important;
}

/* --- DROP CAP (CHỮ HOA ĐẦU CHƯƠNG NGHỆ THUẬT) --- */
.reader-content.enable-dropcap p.has-dropcap::first-letter {
  font-family: var(--font-playfair), 'Merriweather', 'Lora', Georgia, serif;
  float: left;
  font-size: 3.5em;
  line-height: 0.8;
  padding-top: 4px;
  padding-right: 10px;
  padding-bottom: 2px;
  font-weight: 700;
  color: var(--primary-accent);
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.05);
  font-style: normal;
}

[data-theme="sepia"] .reader-content.enable-dropcap p.has-dropcap::first-letter {
  color: #8f3d1b;
}

[data-theme="dark"] .reader-content.enable-dropcap p.has-dropcap::first-letter {
  color: #ffaa5b;
}

.reader-content.enable-dropcap p.has-dropcap::after {
  content: "";
  display: table;
  clear: both;
}

/* Khóa cứng Drop Cap cho các chương đặc biệt (Lời đề tặng, Giới thiệu, Lời bạt, Ghi chú...) */
.reader-content.dropcap-locked p.has-dropcap::first-letter,
.reader-content.dropcap-locked ::first-letter {
  float: none !important;
  font-size: inherit !important;
  line-height: inherit !important;
  font-weight: inherit !important;
  padding: 0 !important;
  margin: 0 !important;
  text-shadow: none !important;
  color: inherit !important;
}

.reader-content.dropcap-locked p.has-dropcap::after {
  display: inline !important;
}

/* --- DIALOGUE & INTERVIEW TABLES (BẢNG HỘI THOẠI TRONG EBOOK) --- */
.dialogue-table {
  width: 100%;
  max-width: 100%;
  margin: 1.5rem 0;
  border-collapse: separate;
  border-spacing: 0 0.4rem;
  border: none !important;
  background: transparent !important;
}

.dialogue-table tr {
  background: transparent !important;
  border: none !important;
}

.dialogue-table td {
  border: none !important;
  padding: 0.3rem 0.5rem;
  line-height: 1.7;
  font-size: inherit;
}

.dialogue-table td.dialogue-speaker,
.dialogue-table td.ask {
  width: 1%;
  white-space: nowrap;
  vertical-align: top;
  text-align: right;
  font-weight: 700;
  color: var(--text-main);
  padding-right: 1.25rem;
  padding-left: 0.25rem;
  letter-spacing: -0.01em;
}

.dialogue-table td.dialogue-speaker::first-letter,
.dialogue-table td.ask::first-letter,
.dialogue-table td.dialogue-text::first-letter,
.dialogue-table td.reply::first-letter {
  float: none !important;
  font-size: inherit !important;
  line-height: inherit !important;
  font-weight: inherit !important;
  color: inherit !important;
  padding: 0 !important;
  margin: 0 !important;
  text-shadow: none !important;
}

.dialogue-table td.dialogue-text,
.dialogue-table td.reply {
  vertical-align: top;
  text-align: justify;
  color: var(--text-main);
  padding-right: 0.5rem;
}

[data-theme="dark"] .dialogue-table td.dialogue-speaker {
  color: #f3f4f6;
}

[data-theme="sepia"] .dialogue-table td.dialogue-speaker {
  color: #382b1a;
}

/* Bảng nội dung thông thường */
.content-table {
  width: 100%;
  margin: 1.5rem 0;
  border-collapse: collapse;
  font-size: 0.95em;
}

.content-table th,
.content-table td {
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--border-color);
  text-align: left;
}

.content-table th {
  background: var(--bg-secondary);
  font-weight: 700;
}

.reader-content blockquote {
  border-left: 3px solid var(--text-tertiary);
  padding-left: 1.25rem;
  margin: 1.5rem 0;
  color: var(--text-secondary);
  font-style: italic;
  line-height: inherit;
}

.reader-content ul, .reader-content ol {
  padding-left: 1.5rem;
  margin-bottom: 1.35rem;
}

.reader-content li {
  margin-bottom: 0.5rem;
  line-height: inherit;
}

/* Reader Top & Bottom Navigation */
.reader-header-nav,
.reader-footer-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border-color);
  padding: 1.5rem 0;
  margin-top: 2rem;
  gap: 1rem;
}

.reader-header-nav {
  border-top: none;
  border-bottom: 1px solid var(--border-color);
  padding: 0.8rem 0 1.25rem 0;
  margin-top: 0;
  margin-bottom: 1.75rem;
}

.reader-nav-btn {
  padding: 0.65rem 1.2rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-main);
  font-size: 0.9rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: all var(--transition-fast);
}

.reader-nav-btn:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--text-main);
}

.reader-nav-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Reader Drawer / Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(3px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast);
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  width: 100%;
  max-width: 450px;
  max-height: min(90vh, 620px);
  overflow-y: auto;
  overscroll-behavior: contain;
  box-shadow: var(--shadow-md);
  padding: 1.1rem 1.25rem;
  transform: translateY(12px);
  transition: transform var(--transition-fast);
}

.modal-content::-webkit-scrollbar {
  width: 5px;
}
.modal-content::-webkit-scrollbar-track {
  background: transparent;
}
.modal-content::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

.modal-overlay.active .modal-content {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.65rem;
}

.modal-header-titles {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding-right: 0.5rem;
}

.modal-header h3 {
  font-size: 0.98rem;
  font-weight: 700;
  line-height: 1.3;
  margin: 0;
}

/* Modal Download Counter Badge */
.modal-download-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.15rem;
}

.modal-download-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-hover);
  padding: 0.18rem 0.62rem;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  transition: transform var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
  user-select: none;
}

.modal-download-badge svg {
  color: #10b981;
  flex-shrink: 0;
}

[data-theme="sepia"] .modal-download-badge svg {
  color: #15803d;
}

[data-theme="dark"] .modal-download-badge svg {
  color: #34d399;
}

.modal-download-badge.count-bumped {
  transform: scale(1.08);
  border-color: #10b981;
  color: #10b981;
}

.modal-subtitle {
  font-size: 0.76rem;
  color: var(--text-secondary);
  margin-bottom: 0.45rem;
}

.download-option-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  padding: 0.52rem 0.8rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  margin-bottom: 0.42rem;
  background: var(--bg-secondary);
  color: var(--text-main);
  transition: all var(--transition-fast);
  text-decoration: none;
}

.download-option-btn > div:first-child {
  flex: 1 1 auto;
  min-width: 0;
}

.download-option-btn:hover {
  background: var(--bg-hover);
  border-color: var(--text-secondary);
}

.download-opt-title {
  font-weight: 700;
  font-size: 0.84rem;
  line-height: 1.25;
}

.download-opt-desc {
  font-size: 0.72rem;
  color: var(--text-tertiary);
  line-height: 1.25;
  margin-top: 0.1rem;
}

.download-badge {
  font-size: 0.68rem;
  font-weight: 700;
  background: var(--accent);
  color: var(--accent-contrast);
  padding: 0.25rem 0.65rem;
  border-radius: 5px;
  white-space: nowrap !important;
  flex-shrink: 0 !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0.3px;
}

/* --- PASSCODE LOCK FOR DOWNLOAD MODAL --- */
.download-lock-box {
  background: var(--bg-secondary);
  border: 1px dashed var(--border-color);
  border-radius: 8px;
  padding: 0.65rem 0.85rem;
  margin-bottom: 0.65rem;
  text-align: center;
}

.lock-box-header {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  margin-bottom: 0.25rem;
}

.lock-icon-badge {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--bg-hover);
  color: var(--primary-accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.lock-box-title {
  font-weight: 700;
  font-size: 0.86rem;
  color: var(--text-main);
}

.lock-box-desc {
  font-size: 0.74rem;
  color: var(--text-secondary);
  margin-bottom: 0.45rem;
  line-height: 1.35;
}

.passcode-input-group {
  display: flex;
  gap: 0.4rem;
  max-width: 300px;
  margin: 0 auto;
}

.passcode-input-group input {
  flex: 1;
  padding: 0.4rem 0.65rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-main);
  color: var(--text-main);
  font-size: 0.82rem;
  outline: none;
  transition: border-color var(--transition-fast);
}

.passcode-input-group input:focus {
  border-color: var(--primary-accent);
}

.passcode-input-group button {
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
}

.passcode-error-msg {
  color: #e53e3e;
  font-size: 0.75rem;
  margin-top: 0.35rem;
  font-weight: 500;
}

.passcode-hint {
  font-size: 0.72rem;
  color: var(--text-tertiary);
  margin-top: 0.35rem;
  line-height: 1.3;
}

.passcode-hint a {
  color: var(--primary-accent);
  text-decoration: underline;
  font-weight: 600;
}

.download-unlocked-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.65rem;
  background: var(--bg-secondary);
  padding: 0.42rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.unlocked-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: #2e7d32;
  background: rgba(46, 125, 50, 0.1);
  padding: 0.2rem 0.55rem;
  border-radius: 20px;
}

[data-theme="dark"] .unlocked-status-badge {
  color: #81c784;
  background: rgba(129, 199, 132, 0.15);
}

.btn-relock {
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-size: 0.72rem;
  cursor: pointer;
  text-decoration: underline;
  padding: 0.2rem 0.4rem;
}
.btn-relock:hover {
  color: var(--text-main);
}

.download-locked-btn:hover {
  border-color: var(--primary-accent);
  background: var(--bg-hover);
}

/* Settings Drawer (Font size, family, line-height, width, theme) */
.settings-drawer {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.25rem;
  box-shadow: var(--shadow-md);
  z-index: 100;
  width: 310px;
  display: none;
  flex-direction: column;
  gap: 0.85rem;
}

.settings-drawer.active {
  display: flex;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.88rem;
}

.btn-group {
  display: flex;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  overflow: hidden;
}

.btn-group-item {
  padding: 0.35rem 0.65rem;
  font-size: 0.82rem;
  background: var(--bg-card);
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.btn-group-item.active {
  background: var(--accent);
  color: var(--accent-contrast);
}

/* ==========================================================================
   FOOTER
   ========================================================================== */
.site-footer {
  border-top: 1px solid var(--border-color);
  background: var(--bg-primary);
  padding: 2.5rem 1.5rem;
  margin-top: auto;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.footer-inner {
  max-width: 1080px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
}

/* Footer Contact (Telegram & Facebook) */
.footer-contact {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 1.1rem 1.6rem;
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.footer-contact:hover {
  border-color: var(--text-secondary);
  box-shadow: var(--shadow-md);
}

.footer-channels {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.footer-channel-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.footer-channels-divider {
  width: 1px;
  height: 44px;
  background-color: var(--border-color);
  opacity: 0.7;
}

.footer-qr-link {
  display: inline-block;
  border-radius: 10px;
  overflow: hidden;
  background: #ffffff;
  padding: 3px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  transition: transform var(--transition-fast);
  flex-shrink: 0;
}

.footer-qr-link:hover {
  transform: scale(1.05);
}

.footer-qr-img {
  width: 76px;
  height: 76px;
  object-fit: contain;
  display: block;
  border-radius: 8px;
}

.footer-channel-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 0.95rem;
  padding: 0.45rem 0.95rem;
  border-radius: 8px;
  transition: all var(--transition-fast);
  text-decoration: none;
}

.channel-icon {
  width: 18px;
  height: 18px;
  fill: currentColor;
  flex-shrink: 0;
}

.footer-telegram-link {
  color: #229ED9;
  background: rgba(34, 158, 217, 0.08);
  border: 1px solid rgba(34, 158, 217, 0.25);
}

.footer-telegram-link:hover {
  background: #229ED9;
  color: #ffffff;
  border-color: #229ED9;
  transform: translateY(-1px);
}

.footer-facebook-link {
  color: #1877F2;
  background: rgba(24, 119, 242, 0.08);
  border: 1px solid rgba(24, 119, 242, 0.25);
}

.footer-facebook-link:hover {
  background: #1877F2;
  color: #ffffff;
  border-color: #1877F2;
  transform: translateY(-1px);
}

.footer-contact-sub {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
  text-align: center;
}

/* Live Community & Daily Stats Counter */
.footer-stats {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.5rem 0.85rem;
  padding: 0.45rem 1.15rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 999px;
  font-size: 0.82rem;
  color: var(--text-secondary);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-normal);
  user-select: none;
}

.footer-stats:hover {
  border-color: var(--text-secondary);
  box-shadow: var(--shadow-md);
}

.footer-stat-item {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  font-weight: 500;
}

.stat-pulse-dot {
  width: 8px;
  height: 8px;
  background-color: #10b981;
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  animation: stat-pulse 2s infinite cubic-bezier(0.4, 0, 0.6, 1);
  flex-shrink: 0;
}

@keyframes stat-pulse {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  }
  70% {
    transform: scale(1);
    box-shadow: 0 0 0 7px rgba(16, 185, 129, 0);
  }
  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

.stat-num {
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.01em;
}

.footer-stat-sep {
  color: var(--text-tertiary);
  opacity: 0.6;
  font-size: 0.75rem;
}

.stat-icon-book {
  vertical-align: -2px;
  color: #3b82f6;
  flex-shrink: 0;
}

[data-theme="sepia"] .stat-icon-book {
  color: #a46d2f;
}

[data-theme="dark"] .stat-icon-book {
  color: #60a5fa;
}

.footer-copyright {
  font-size: 0.82rem;
  color: var(--text-tertiary);
}

@media (max-width: 600px) {
  .footer-contact {
    padding: 1rem 0.85rem;
    gap: 0.75rem;
  }
  .footer-channels {
    gap: 0.85rem;
  }
  .footer-channels-divider {
    display: none;
  }
  .footer-channel-item {
    gap: 0.65rem;
  }
  .footer-qr-img {
    width: 64px;
    height: 64px;
  }
  .footer-channel-link {
    font-size: 0.85rem;
    padding: 0.4rem 0.75rem;
  }
  .footer-stats {
    border-radius: 14px;
    padding: 0.5rem 0.85rem;
    font-size: 0.78rem;
    gap: 0.35rem 0.6rem;
  }
}

/* ==========================================================================
   BILINGUAL READER & INTERLINEAR TRANSLATION STYLES
   ========================================================================== */

/* Bilingual CTA Button on Book Detail */
.btn-bilingual {
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  color: #ffffff;
  border: none;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.28);
  transition: all var(--transition-fast);
}

.btn-bilingual:hover {
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  color: #ffffff;
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(99, 102, 241, 0.38);
}

.btn-bilingual svg {
  color: #ffffff;
}

[data-theme="dark"] .btn-bilingual {
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.45);
}

/* Bilingual Switcher in Reader Sticky Header */
.reader-mode-switch {
  display: inline-flex;
  align-items: center;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 999px;
  padding: 3px 6px 3px 3px;
  gap: 2px;
  flex-shrink: 0;
  margin-right: 0.5rem; /* Khoảng cách đồng đều 0.5rem (8px) với các nút công cụ phía sau */
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.mode-tab-btn {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.32rem 0.8rem;
  border-radius: 999px;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.mode-tab-btn:hover {
  color: var(--text-main);
}

.mode-tab-btn.active {
  background: var(--accent);
  color: var(--accent-contrast);
  font-weight: 700;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}

[data-theme="dark"] .mode-tab-btn.active {
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.3);
}

/* Quick English Visibility Toggle Button inside the mode cluster */
.bilingual-visibility-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  border-radius: 999px;
  margin-left: 6px; /* Cách ra 1 chút xíu với nút Song Ngữ */
  padding: 0;
  cursor: pointer;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.bilingual-visibility-btn:hover {
  background: rgba(0, 0, 0, 0.07);
  color: var(--accent);
}

[data-theme="dark"] .bilingual-visibility-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--accent);
}

.bilingual-visibility-btn.hidden {
  display: none !important;
}

/* Order Toggle Button (VI->EN vs EN->VI) inside the mode cluster */
.bilingual-order-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 25px;
  padding: 0 0.45rem;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-secondary);
  border-radius: 999px;
  margin-left: 5px;
  cursor: pointer;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  transition: all var(--transition-fast);
  flex-shrink: 0;
  user-select: none;
}

.bilingual-order-btn:hover {
  background: var(--bg-hover);
  color: #6366f1;
  border-color: #6366f1;
}

[data-theme="dark"] .bilingual-order-btn {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.15);
}

[data-theme="dark"] .bilingual-order-btn:hover {
  background: rgba(99, 102, 241, 0.2);
  color: #a5b4fc;
  border-color: #818cf8;
}

.bilingual-order-btn.hidden {
  display: none !important;
}

/* Interlinear Bilingual Paragraph Pairs (Flexible VE / EV Ordering) */
.bilingual-pair {
  margin-bottom: 1.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  border-radius: 8px;
  transition: background var(--transition-fast);
}

.bilingual-block {
  display: flex;
  flex-direction: column;
  transition: all 0.2s ease-out;
}

.bilingual-vi-content,
.bilingual-en-content {
  text-align: justify;
  line-height: inherit;
  word-break: break-word;
}

.reader-content[data-text-align="justify"] .bilingual-vi-content,
.reader-content[data-text-align="justify"] .bilingual-en-content {
  text-align: justify;
}

.reader-content[data-text-align="left"] .bilingual-vi-content,
.reader-content[data-text-align="left"] .bilingual-en-content {
  text-align: left;
}

.bilingual-pair.scene-break {
  margin: 2.25rem auto !important;
  text-align: center !important;
  border: none !important;
  background: transparent !important;
  display: flex !important;
  justify-content: center !important;
  align-items: center !important;
  width: 100% !important;
}

.bilingual-pair.scene-break .bilingual-block,
.bilingual-pair.scene-break .bilingual-vi-content,
.bilingual-pair.scene-break .bilingual-en-content {
  text-align: center !important;
  border-left: none !important;
  padding-left: 0 !important;
}

.bilingual-pair.scene-break .bilingual-toggle-pill {
  display: none !important;
}

.bilingual-pair.chapter-part-eyebrow {
  margin-top: 0.5rem !important;
  margin-bottom: -0.25rem !important;
  text-align: center !important;
  border: none !important;
  background: transparent !important;
  padding: 0 !important;
}

.bilingual-pair.chapter-part-eyebrow .chapter-part-eyebrow {
  margin: 0 auto !important;
  text-align: center !important;
}

.bilingual-pair.chapter-part-eyebrow + h1 {
  margin-top: 0.35rem !important;
}

.bilingual-pair.chapter-subtitle-pair {
  margin-top: -0.65rem !important;
  margin-bottom: 2rem !important;
  text-align: center !important;
  border: none !important;
  background: transparent !important;
}

.bilingual-pair.chapter-subtitle-pair .chapter-subtitle {
  margin: 0 auto !important;
  text-align: center !important;
}

/* --- Toggle Pill for "Chạm để mở" Mode --- */
.bilingual-toggle-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.22rem 0.65rem;
  border-radius: 999px;
  border: 1px dashed var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
  margin-bottom: 0.35rem;
  align-self: flex-start;
}

.bilingual-toggle-pill:hover {
  background: var(--bg-hover);
  color: var(--text-main);
  border-color: #6366f1;
  border-style: solid;
}

.pill-badge {
  display: inline-block;
  padding: 0.05rem 0.32rem;
  border-radius: 4px;
  font-weight: 800;
  font-size: 0.68rem;
  letter-spacing: 0.04em;
}

.pill-en .pill-badge {
  background: rgba(99, 102, 241, 0.15);
  color: #6366f1;
}

.pill-vi .pill-badge {
  background: rgba(16, 185, 129, 0.15);
  color: #059669;
}

[data-theme="dark"] .pill-vi .pill-badge {
  background: rgba(16, 185, 129, 0.22);
  color: #34d399;
}

.pill-arrow {
  transition: transform 0.25s ease;
  stroke-width: 2.5;
}

/* ========================================================
   ORDER 1: VE (Tiếng Việt trước - Tiếng Anh sau: Mặc định)
   ======================================================== */
[data-bilingual-order="ve"] .bilingual-vi-block {
  order: 1;
}

[data-bilingual-order="ve"] .bilingual-vi-block .pill-vi {
  display: none !important;
}

[data-bilingual-order="ve"] .bilingual-vi-content {
  color: var(--text-main);
  display: block !important;
  font-size: 1em;
  line-height: inherit;
}

[data-bilingual-order="ve"] .bilingual-en-block {
  order: 2;
  margin-top: 0.2rem;
  padding-left: 0.95rem;
  border-left: 2px solid rgba(99, 102, 241, 0.5);
}

[data-theme="sepia"] [data-bilingual-order="ve"] .bilingual-en-block {
  border-left-color: rgba(143, 61, 27, 0.45);
}

[data-theme="dark"] [data-bilingual-order="ve"] .bilingual-en-block {
  border-left-color: rgba(139, 92, 246, 0.6);
}

[data-bilingual-order="ve"] .bilingual-en-content {
  font-size: 0.93em;
  line-height: 1.65;
  color: var(--text-secondary);
}

/* VE: Hiện tất cả */
[data-bilingual-order="ve"][data-en-visibility="show-all"] .bilingual-en-block .pill-en {
  display: none !important;
}

[data-bilingual-order="ve"][data-en-visibility="show-all"] .bilingual-en-content {
  display: block !important;
}

/* VE: Chạm để mở (Ẩn tiếng Anh) */
[data-bilingual-order="ve"][data-en-visibility="tap-reveal"] .bilingual-en-block:not(.is-revealed) .bilingual-en-content {
  display: none !important;
}

[data-bilingual-order="ve"][data-en-visibility="tap-reveal"] .bilingual-en-block.is-revealed .bilingual-en-content {
  display: block !important;
  animation: biFadeIn 0.22s ease-out;
}

[data-bilingual-order="ve"][data-en-visibility="tap-reveal"] .bilingual-en-block.is-revealed .pill-arrow {
  transform: rotate(180deg);
}

[data-bilingual-order="ve"][data-en-visibility="tap-reveal"] .bilingual-en-block.is-revealed .bilingual-toggle-pill {
  background: var(--bg-hover);
  border-color: var(--border-color);
}

/* ========================================================
   ORDER 2: EV (Tiếng Anh trước - Tiếng Việt sau)
   ======================================================== */
[data-bilingual-order="ev"] .bilingual-en-block {
  order: 1;
  border-left: none !important;
  padding-left: 0 !important;
  margin-top: 0 !important;
}

[data-bilingual-order="ev"] .bilingual-en-block .pill-en {
  display: none !important;
}

[data-bilingual-order="ev"] .bilingual-en-content {
  color: var(--text-main);
  display: block !important;
  font-size: 1em;
  line-height: inherit;
}

[data-bilingual-order="ev"] .bilingual-vi-block {
  order: 2;
  margin-top: 0.2rem;
  padding-left: 0.95rem;
  border-left: 2px solid rgba(16, 185, 129, 0.5);
}

[data-theme="sepia"] [data-bilingual-order="ev"] .bilingual-vi-block {
  border-left-color: rgba(143, 61, 27, 0.45);
}

[data-theme="dark"] [data-bilingual-order="ev"] .bilingual-vi-block {
  border-left-color: rgba(52, 211, 153, 0.6);
}

[data-bilingual-order="ev"] .bilingual-vi-content {
  font-size: 0.93em;
  line-height: 1.65;
  color: var(--text-secondary);
}

/* EV: Hiện tất cả */
[data-bilingual-order="ev"][data-en-visibility="show-all"] .bilingual-vi-block .pill-vi {
  display: none !important;
}

[data-bilingual-order="ev"][data-en-visibility="show-all"] .bilingual-vi-content {
  display: block !important;
}

/* EV: Chạm để mở (Ẩn tiếng Việt) */
[data-bilingual-order="ev"][data-en-visibility="tap-reveal"] .bilingual-vi-block:not(.is-revealed) .bilingual-vi-content {
  display: none !important;
}

[data-bilingual-order="ev"][data-en-visibility="tap-reveal"] .bilingual-vi-block.is-revealed .bilingual-vi-content {
  display: block !important;
  animation: biFadeIn 0.22s ease-out;
}

[data-bilingual-order="ev"][data-en-visibility="tap-reveal"] .bilingual-vi-block.is-revealed .pill-arrow {
  transform: rotate(180deg);
}

[data-bilingual-order="ev"][data-en-visibility="tap-reveal"] .bilingual-vi-block.is-revealed .bilingual-toggle-pill {
  background: var(--bg-hover);
  border-color: var(--border-color);
}

/* ========================================================
   Pure VI Mode (Chỉ đọc Tiếng Việt)
   ======================================================== */
[data-reader-mode="vi"] .bilingual-en-block {
  display: none !important;
}

[data-reader-mode="vi"] .bilingual-vi-block {
  order: 1 !important;
  border-left: none !important;
  padding-left: 0 !important;
  margin-top: 0 !important;
}

[data-reader-mode="vi"] .bilingual-vi-block .pill-vi {
  display: none !important;
}

[data-reader-mode="vi"] .bilingual-vi-content {
  color: var(--text-main) !important;
  font-size: 1em !important;
  display: block !important;
  line-height: inherit !important;
}

/* Drop Cap Support for Bilingual Paragraphs */
.reader-content.enable-dropcap[data-bilingual-order="ve"] .bilingual-vi-content.has-dropcap::first-letter,
.reader-content.enable-dropcap[data-bilingual-order="ev"] .bilingual-en-content.has-dropcap::first-letter,
.reader-content.enable-dropcap[data-reader-mode="vi"] .bilingual-vi-content.has-dropcap::first-letter {
  font-family: var(--font-playfair), 'Merriweather', 'Lora', Georgia, serif;
  float: left;
  font-size: 3.5em;
  line-height: 0.8;
  padding-top: 4px;
  padding-right: 10px;
  padding-bottom: 2px;
  font-weight: 700;
  color: #8f3d1b;
}

[data-theme="dark"] .reader-content.enable-dropcap[data-bilingual-order="ve"] .bilingual-vi-content.has-dropcap::first-letter,
[data-theme="dark"] .reader-content.enable-dropcap[data-bilingual-order="ev"] .bilingual-en-content.has-dropcap::first-letter,
[data-theme="dark"] .reader-content.enable-dropcap[data-reader-mode="vi"] .bilingual-vi-content.has-dropcap::first-letter {
  color: #ffaa5b;
}

.reader-content.enable-dropcap .bilingual-vi-content.has-dropcap::after,
.reader-content.enable-dropcap .bilingual-en-content.has-dropcap::after {
  content: "";
  display: table;
  clear: both;
}

@keyframes biFadeIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Download Modal Bilingual Section */
.download-section-heading {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.35rem;
}

.download-section-heading.bilingual-heading {
  color: #6366f1;
}

.badge-bilingual-pill {
  font-size: 0.64rem;
  font-weight: 600;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: rgba(99, 102, 241, 0.12);
  color: #6366f1;
  margin-left: auto;
  text-transform: none;
  letter-spacing: normal;
}

.badge-bilingual-tag {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.18), rgba(139, 92, 246, 0.18));
  color: #6366f1;
  border: 1px solid rgba(99, 102, 241, 0.3);
  font-weight: 700;
  font-size: 0.68rem;
  padding: 0.12rem 0.4rem;
}

.badge-bilingual-download {
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%) !important;
  color: #ffffff !important;
  white-space: nowrap !important;
  flex-shrink: 0 !important;
}

.download-bilingual-option:hover {
  border-color: #6366f1;
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.18);
}

/* Mobile Responsive Tweaks for Reader Navigation */
@media (max-width: 680px) {
  .reader-nav-inner {
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.5rem 0.85rem;
  }
  .reader-mode-switch {
    order: 3;
    width: 100%;
    justify-content: center;
    margin-right: 0;
    margin-top: 0.25rem;
  }
}


/* --- ACCESSIBLE HIDDEN HEADERS & TEXT (TIÊU ĐỀ ẨN / TÊN CHƯƠNG BẰNG ẢNH) --- */
.invi,
.hide,
.is-hidden,
.hidden-header,
.sr-only,
.reader-content .hide,
.reader-content h1.hide,
.reader-content h2.invi,
.reader-content h2.hide,
.reader-content p.invi,
.reader-content p.hide {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Hiển thị tiêu đề Header 1 có class invi trên nền tảng đọc trang web theo yêu cầu */
.reader-content h1.invi,
.reader-content h1.toc-title {
  position: static !important;
  width: auto !important;
  height: auto !important;
  clip: auto !important;
  white-space: normal !important;
  overflow: visible !important;
  margin: 1.5rem auto 1.25rem !important;
  text-align: center !important;
  display: block !important;
  font-size: 1.65rem !important;
  font-weight: 700 !important;
  color: var(--text-primary) !important;
  opacity: 1 !important;
  visibility: visible !important;
}

/* --- EPIGRAPH & ATTRIBUTION (LỜI ĐỀ TỪ / TRÍCH DẪN ĐẦU CHƯƠNG) --- */
.reader-content .epigraph,
.reader-content div.epigraph,
.reader-content blockquote.epigraph,
.reader-content .epigraph-wrapper {
  margin: 1.5rem auto 2.2rem;
  padding: 0.95rem 1.4rem;
  max-width: 90%;
  border-left: 3px solid var(--accent-primary, #b7791f);
  background: rgba(120, 100, 80, 0.05);
  border-radius: 0 6px 6px 0;
}

[data-theme="dark"] .reader-content .epigraph,
[data-theme="dark"] .reader-content div.epigraph {
  background: rgba(255, 255, 255, 0.04);
  border-left-color: #ffaa5b;
}

[data-theme="sepia"] .reader-content .epigraph,
[data-theme="sepia"] .reader-content div.epigraph {
  background: rgba(143, 61, 27, 0.06);
  border-left-color: #8f3d1b;
}

.reader-content .epigraph p,
.reader-content div.epigraph p,
.reader-content p.epigraph {
  font-style: italic;
  font-size: 1.02rem;
  line-height: 1.7;
  color: var(--text-secondary);
  margin-bottom: 0.6rem;
  text-indent: 0 !important;
}

.reader-content .epigraph p:last-child,
.reader-content div.epigraph p:last-child {
  margin-bottom: 0;
}

/* Attribution / Source line */
.reader-content .attribution,
.reader-content p.attribution,
.reader-content .epigraph .attribution,
.reader-content .epigraph-source {
  display: block;
  font-style: normal;
  font-size: 0.88rem;
  color: var(--text-tertiary, #888);
  text-align: right !important;
  margin-top: 0.5rem;
  opacity: 0.9;
}

.reader-content .attribution em,
.reader-content p.attribution em {
  font-style: italic;
}


/* Ngăn tuyệt đối Drop Cap xuất hiện trên các đoạn căn giữa, tiêu đề phụ */
.reader-content p.text-center::first-letter,
.reader-content p[align="center"]::first-letter,
.reader-content .chapter-subtitle::first-letter,
.reader-content .chapter-part-eyebrow::first-letter,
.reader-content p.has-dropcap.text-center::first-letter,
.reader-content p.has-dropcap[style*="text-align: center"]::first-letter,
.reader-content p.has-dropcap[align="center"]::first-letter {
  float: none !important;
  font-size: inherit !important;
  line-height: inherit !important;
  font-weight: inherit !important;
  color: inherit !important;
  padding: 0 !important;
  margin: 0 !important;
}

/* Ngăn tuyệt đối Drop Cap xuất hiện bên trong Epigraph */
.reader-content .epigraph::first-letter,
.reader-content .epigraph p::first-letter,
.reader-content div.epigraph p::first-letter,
.reader-content p.epigraph::first-letter,
.reader-content .attribution::first-letter {
  float: none !important;
  font-size: inherit !important;
  line-height: inherit !important;
  font-weight: inherit !important;
  color: inherit !important;
  padding: 0 !important;
  margin: 0 !important;
}

/* Hỗ trợ hiển thị ảnh tên chương và ảnh minh họa trong nội dung */
.reader-content img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
}

.reader-content .chapter-title-img,
.reader-content p > img:only-child,
.reader-content div > img:only-child {
  display: block;
  margin: 1.5rem auto 2.2rem;
  text-align: center;
}

.reader-content .chapter-title-img img,
.reader-content .reader-image {
  max-width: 100%;
  max-height: 80vh;
  width: auto;
  height: auto;
  display: block;
  margin: 0 auto;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.reader-content .mess-icon img {
  display: inline-block;
  vertical-align: middle;
  height: 1.35em;
  width: auto;
  margin: 0 0.15rem;
  border-radius: 2px;
  box-shadow: none;
}

/* ==========================================================================
   AUTHOR PROFILE COMPONENT (BOTTOM SHEET ON MOBILE / CENTERED MODAL ON DESKTOP)
   ========================================================================== */

.author-interactive {
  cursor: pointer;
  transition: color var(--transition-fast), text-decoration-color var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 3px;
  position: relative;
}

.author-interactive:hover {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
}

.inline-author-arrow {
  display: inline-block;
  opacity: 0.6;
  margin-left: 2px;
  transition: transform var(--transition-fast), opacity var(--transition-fast);
}

.spec-item-author:hover .inline-author-arrow,
.author-interactive:hover .inline-author-arrow {
  opacity: 1;
  transform: translateX(3px);
}

/* Modal Overlay */
.author-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.58);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  z-index: 1050;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.24s cubic-bezier(0.16, 1, 0.3, 1);
}

.author-modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

/* Sheet Content (Desktop Centered Modal) */
.author-sheet-content {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  width: 100%;
  max-width: 620px;
  max-height: min(88vh, 720px);
  overflow-y: auto;
  overscroll-behavior: contain;
  box-shadow: 0 24px 54px rgba(0, 0, 0, 0.18);
  padding: 1.5rem 1.65rem 1.65rem;
  transform: scale(0.96) translateY(10px);
  transition: transform 0.26s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
}

.author-sheet-content::-webkit-scrollbar {
  width: 6px;
}
.author-sheet-content::-webkit-scrollbar-track {
  background: transparent;
}
.author-sheet-content::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

.author-modal-overlay.active .author-sheet-content {
  transform: scale(1) translateY(0);
}

/* Handle for Mobile Drag/Pull (Shared across all bottom sheets) */
.author-sheet-handle,
.modal-sheet-handle {
  width: 44px;
  height: 4px;
  border-radius: 999px;
  background: var(--border-color);
  margin: 0.25rem auto 0.85rem;
  cursor: grab;
  display: none;
  flex-shrink: 0;
  opacity: 0.8;
}

/* Mobile Bottom Sheet (max-width: 680px) */
@media (max-width: 680px) {
  .author-sheet-handle,
  .modal-sheet-handle {
    display: block;
  }

  .author-modal-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .author-sheet-content {
    border-radius: 22px 22px 0 0;
    max-width: 100%;
    max-height: 85vh;
    padding: 0.65rem 1.15rem max(2rem, env(safe-area-inset-bottom, 2rem));
    transform: translateY(100%);
    border-bottom: none;
    border-left: none;
    border-right: none;
    box-shadow: 0 -12px 36px rgba(0, 0, 0, 0.22);
  }

  .author-modal-overlay.active .author-sheet-content {
    transform: translateY(0);
  }
}

/* Header */
.author-sheet-header {
  display: flex;
  gap: 1.15rem;
  align-items: flex-start;
  margin-bottom: 1.1rem;
}

.author-avatar-box {
  flex-shrink: 0;
}

.author-avatar-img {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  background: var(--bg-secondary);
  display: block;
}

.author-avatar-initials {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, #854d0e, #d97706);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.45rem;
  font-weight: 700;
  font-family: var(--font-sans);
  letter-spacing: 0.5px;
  box-shadow: var(--shadow-sm);
  border: 2px solid rgba(255, 255, 255, 0.2);
}

.author-header-info {
  flex: 1;
  min-width: 0;
}

.author-header-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
}

.author-name {
  font-size: 1.28rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.25;
  margin: 0 0 0.45rem;
}

.author-close-btn {
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 0.35rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.author-close-btn:hover {
  background: var(--bg-hover);
  color: var(--text-main);
}

.author-meta-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.author-meta-badge {
  font-size: 0.73rem;
  font-weight: 600;
  padding: 0.22rem 0.6rem;
  border-radius: 20px;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  border: 1px solid var(--border-light);
}

.author-meta-badge.genre-badge {
  background: var(--accent-badge);
  color: var(--text-main);
}

/* Bio Box */
.author-bio-box {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 0.85rem 1.05rem;
  margin-bottom: 1.15rem;
}

.author-bio-box p {
  font-size: 0.88rem;
  line-height: 1.62;
  color: var(--text-secondary);
  margin: 0;
}

/* Books Section */
.author-books-section {
  display: flex;
  flex-direction: column;
}

.author-books-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.65rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border-light);
}

.author-books-header h4 {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.author-books-count {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-tertiary);
}

.author-books-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.author-book-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.6rem 0.8rem;
  border-radius: 12px;
  border: 1px solid var(--border-light);
  background: var(--bg-card);
  transition: transform var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
  cursor: pointer;
}

.author-book-item:hover {
  transform: translateY(-1px);
  border-color: var(--border-color);
  box-shadow: var(--shadow-sm);
  background: var(--bg-hover);
}

.author-book-cover-wrap {
  width: 44px;
  height: 64px;
  flex-shrink: 0;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  background: var(--bg-secondary);
}

.author-book-cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.author-book-info {
  flex: 1;
  min-width: 0;
}

.author-book-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0 0 0.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.author-book-orig-title {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  font-style: italic;
  margin-bottom: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.author-book-meta {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  align-items: center;
}

.author-book-badge {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.12rem 0.42rem;
  border-radius: 4px;
  background: var(--bg-secondary);
  color: var(--text-secondary);
}

.author-book-category {
  font-size: 0.68rem;
  color: var(--text-tertiary);
}

.author-book-actions {
  flex-shrink: 0;
}

.btn-author-read {
  display: inline-block;
  padding: 0.36rem 0.8rem;
  border-radius: 6px;
  font-size: 0.76rem;
  font-weight: 600;
  background: var(--accent);
  color: var(--accent-contrast) !important;
  text-decoration: none;
  transition: opacity var(--transition-fast);
}

.btn-author-read:hover {
  opacity: 0.88;
}

.author-empty-books {
  padding: 1.5rem;
  text-align: center;
  font-size: 0.84rem;
  color: var(--text-tertiary);
}

/* --- Author Modal Upcoming Projects Section --- */
.author-upcoming-section {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--border-light);
}

.author-upcoming-cover-wrap {
  position: relative;
}

.author-upcoming-pill {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(109, 40, 217, 0.92);
  color: #ffffff;
  font-size: 0.52rem;
  font-weight: 700;
  text-align: center;
  padding: 2px 1px;
  line-height: 1.1;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  border-bottom-left-radius: 5px;
  border-bottom-right-radius: 5px;
}

.author-badge-upcoming {
  background: #ede9fe !important;
  color: #6d28d9 !important;
  font-weight: 700 !important;
}
[data-theme="dark"] .author-badge-upcoming {
  background: rgba(124, 58, 237, 0.25) !important;
  color: #c4b5fd !important;
}
[data-theme="sepia"] .author-badge-upcoming {
  background: rgba(120, 53, 15, 0.15) !important;
  color: #78350f !important;
}

.btn-author-progress {
  display: inline-block;
  padding: 0.36rem 0.8rem;
  border-radius: 6px;
  font-size: 0.76rem;
  font-weight: 600;
  background: var(--accent);
  color: var(--accent-contrast) !important;
  border: none;
  cursor: pointer;
  transition: opacity var(--transition-fast);
  line-height: normal;
  text-align: center;
  white-space: nowrap;
}
.btn-author-progress:hover {
  opacity: 0.88;
}

/* ==========================================================================
   CHANGELOG (NHẬT KÝ CẬP NHẬT)
   ========================================================================== */
.header-changelog-btn {
  position: relative;
}

.header-changelog-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 9px;
  background: #e65100;
  color: #ffffff;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(230, 81, 0, 0.4);
  pointer-events: none;
  border: 1.5px solid var(--bg-card);
}

.changelog-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast);
}

.changelog-modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.changelog-modal-content {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  width: 100%;
  max-width: 620px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
  transform: translateY(16px) scale(0.98);
  transition: transform var(--transition-fast), opacity var(--transition-fast);
  overflow: hidden;
}

.changelog-modal-overlay.active .changelog-modal-content {
  transform: translateY(0) scale(1);
}

.changelog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-card);
}

.changelog-title-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.changelog-header-icon {
  width: 32px;
  height: 32px;
  object-fit: contain;
  flex-shrink: 0;
}

.changelog-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.changelog-subtitle {
  margin: 0.2rem 0 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.changelog-filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 1.25rem;
  background: var(--bg-main);
  border-bottom: 1px solid var(--border-color);
  font-size: 0.825rem;
}

.changelog-tabs {
  display: flex;
  gap: 0.5rem;
}

.changelog-tab-btn {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 0.3rem 0.75rem;
  border-radius: 20px;
  font-size: 0.775rem;
  cursor: pointer;
  font-weight: 500;
  transition: all var(--transition-fast);
}

.changelog-tab-btn:hover {
  color: var(--text-main);
  border-color: var(--text-muted);
}

.changelog-tab-btn.active {
  background: var(--accent);
  color: var(--accent-contrast, #ffffff);
  border-color: var(--accent);
  font-weight: 600;
}

.changelog-body {
  padding: 1.25rem;
  overflow-y: auto;
  flex: 1;
}

.changelog-timeline {
  position: relative;
  padding-left: 1.5rem;
}

.changelog-timeline::before {
  content: '';
  position: absolute;
  top: 6px;
  bottom: 6px;
  left: 5px;
  width: 2px;
  background: var(--border-color);
}

.changelog-item {
  position: relative;
  margin-bottom: 1.15rem;
  padding-bottom: 0.15rem;
}

.changelog-item:last-child {
  margin-bottom: 0;
}

.changelog-dot {
  position: absolute;
  left: -1.5rem;
  top: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 2.5px solid var(--accent);
  box-shadow: 0 0 0 2px var(--bg-card);
  z-index: 1;
}

.changelog-item-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.changelog-time {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
}

.changelog-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.15rem 0.55rem;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.badge-chapter {
  background: rgba(33, 150, 243, 0.12);
  color: #1976d2;
  border: 1px solid rgba(33, 150, 243, 0.3);
}

.badge-ebook {
  background: rgba(255, 152, 0, 0.12);
  color: #f57c00;
  border: 1px solid rgba(255, 152, 0, 0.3);
}

.badge-release {
  background: rgba(76, 175, 80, 0.12);
  color: #388e3c;
  border: 1px solid rgba(76, 175, 80, 0.3);
}

.badge-proofread {
  background: rgba(156, 39, 176, 0.12);
  color: #7b1fa2;
  border: 1px solid rgba(156, 39, 176, 0.3);
}

[data-theme="dark"] .badge-chapter { color: #64b5f6; }
[data-theme="dark"] .badge-ebook { color: #ffb74d; }
[data-theme="dark"] .badge-release { color: #81c784; }
[data-theme="dark"] .badge-proofread { color: #ba68c8; }

.changelog-book-link {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.changelog-book-link:hover {
  color: var(--accent);
  text-decoration: underline;
}

.changelog-item-title {
  font-size: 0.86rem;
  font-weight: 500;
  color: var(--text-secondary);
  line-height: 1.45;
  margin: 0.15rem 0 0 0;
}

.changelog-item-desc {
  font-size: 0.825rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0;
  background: var(--bg-main);
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.changelog-footer {
  padding: 0.85rem 1.25rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
}

.changelog-footer-note {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.changelog-empty {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-muted);
}

.changelog-empty-icon {
  width: 48px;
  height: 48px;
  opacity: 0.6;
  margin-bottom: 0.75rem;
}



/* ==========================================================================
   POLL & WISHLIST MODAL STYLES
   ========================================================================== */

.poll-modal-content {
  max-width: 580px;
  max-height: 88vh;
  overflow-y: auto;
  padding: 1.5rem 1.65rem;
}

.poll-header-title-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.poll-header-icon {
  width: 36px;
  height: 36px;
  object-fit: contain;
  flex-shrink: 0;
}

.poll-main-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.3;
}

.poll-header-desc {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-top: 0.2rem;
  margin-bottom: 0;
}

.poll-section-title {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.86rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  margin-bottom: 0.85rem;
  padding-bottom: 0.45rem;
  border-bottom: 1px solid var(--border-color);
}

.poll-section-icon {
  width: 21px;
  height: 21px;
  object-fit: contain;
  flex-shrink: 0;
}

.poll-candidate-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-bottom: 1.5rem;
}

.poll-candidate-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 0.95rem 1.15rem;
  transition: all var(--transition-fast);
}

.poll-candidate-card:hover {
  border-color: var(--text-secondary);
  box-shadow: var(--shadow-sm);
}

.poll-candidate-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.4rem;
}

.poll-candidate-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.35;
}

.poll-candidate-author {
  font-size: 0.78rem;
  color: var(--text-secondary);
  font-weight: 500;
  margin-top: 0.15rem;
}

.poll-candidate-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 0.65rem;
  line-height: 1.45;
}

.poll-candidate-progress-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.poll-progress-bar {
  flex: 1;
  height: 8px;
  background: var(--bg-hover);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}

.poll-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #60a5fa);
  border-radius: 999px;
  transition: width 0.5s ease-out;
}

[data-theme="sepia"] .poll-progress-fill {
  background: linear-gradient(90deg, #a46d2f, #d49a4e);
}

[data-theme="dark"] .poll-progress-fill {
  background: linear-gradient(90deg, #3b82f6, #818cf8);
}

.poll-votes-text {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-secondary);
  white-space: nowrap;
  min-width: 65px;
  text-align: right;
}

.poll-vote-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.42rem 0.85rem;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  color: var(--text-main);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  flex-shrink: 0;
}

.poll-vote-btn:hover:not(:disabled) {
  background: #3b82f6;
  color: #ffffff;
  border-color: #3b82f6;
  transform: translateY(-1px);
}

.poll-vote-btn:hover:not(:disabled) .poll-btn-glyph {
  filter: brightness(0) invert(1);
}

.poll-vote-btn:disabled,
.poll-vote-btn.voted {
  background: rgba(16, 185, 129, 0.12);
  color: #10b981;
  border-color: rgba(16, 185, 129, 0.3);
  cursor: default;
}

.poll-btn-glyph {
  width: 17px;
  height: 17px;
  object-fit: contain;
  flex-shrink: 0;
  transition: filter var(--transition-fast);
}

.poll-check-icon {
  font-weight: bold;
  font-size: 0.95rem;
  color: #10b981;
}

/* Suggest Form */
.poll-suggest-box {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.15rem;
}

.poll-form-group {
  margin-bottom: 0.85rem;
}

.poll-form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
}

.poll-form-input,
.poll-form-textarea {
  width: 100%;
  padding: 0.55rem 0.85rem;
  font-size: 0.85rem;
  font-family: inherit;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-main);
  outline: none;
  transition: border-color var(--transition-fast);
}

.poll-form-input:focus,
.poll-form-textarea:focus {
  border-color: var(--accent-color, #3b82f6);
}

.poll-form-textarea {
  min-height: 60px;
  resize: vertical;
}

.poll-submit-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  width: 100%;
  padding: 0.65rem 1rem;
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: 8px;
  background: var(--accent-color, #3b82f6);
  color: #ffffff;
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.poll-submit-btn:hover:not(:disabled) {
  opacity: 0.92;
  transform: translateY(-1px);
}

.poll-submit-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.poll-submit-icon {
  width: 20px;
  height: 20px;
  object-fit: contain;
  flex-shrink: 0;
  filter: brightness(0) invert(1);
}

.poll-msg {
  margin-top: 0.75rem;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  font-size: 0.82rem;
  text-align: center;
}

.poll-msg.success {
  background: rgba(16, 185, 129, 0.12);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.poll-msg.error {
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.25);
}

/* Theme support for poll modal icons */
[data-theme="dark"] .poll-header-icon,
[data-theme="dark"] .poll-section-icon,
[data-theme="dark"] .poll-btn-glyph {
  filter: brightness(0) invert(0.92);
}

[data-theme="sepia"] .poll-header-icon,
[data-theme="sepia"] .poll-section-icon,
[data-theme="sepia"] .poll-btn-glyph {
  filter: sepia(0.35) contrast(0.95);
}



/* ==========================================================================
   TRANSLATION PROGRESS / PROJECTS MODAL STYLES
   ========================================================================== */

.progress-modal-content {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  width: 100%;
  max-width: 680px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
  transform: translateY(16px) scale(0.98);
  transition: transform var(--transition-fast), opacity var(--transition-fast);
  overflow: hidden;
  padding: 0;
}

.modal-overlay.active .progress-modal-content {
  transform: translateY(0) scale(1);
}

.progress-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.4rem;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-card);
  flex-shrink: 0;
}

.progress-header-title-group {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.progress-header-icon {
  width: 44px;
  height: 44px;
  object-fit: contain;
  flex-shrink: 0;
}

.progress-main-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
}

.progress-header-desc {
  margin: 0.2rem 0 0 0;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

/* Modal Filter Tabs */
.progress-tabs-container {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.75rem 1.4rem;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
}

.progress-tabs-container::-webkit-scrollbar {
  display: none;
}

.progress-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.8rem;
  border-radius: 20px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.progress-tab-btn:hover {
  background: var(--bg-hover);
  color: var(--text-main);
  border-color: var(--text-secondary);
}

.progress-tab-btn.active {
  background: var(--accent);
  color: var(--accent-contrast);
  border-color: var(--accent);
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.14);
}

.progress-tab-count {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.1rem 0.45rem;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.08);
  color: inherit;
}

.progress-tab-btn.active .progress-tab-count {
  background: rgba(255, 255, 255, 0.28);
  color: var(--accent-contrast);
}

[data-theme="dark"] .progress-tab-btn.active .progress-tab-count {
  background: rgba(0, 0, 0, 0.3);
  color: var(--accent-contrast);
}

/* Modal Project Cards List */
.progress-list-container {
  padding: 1.25rem 1.4rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
  flex-grow: 1;
}

.progress-project-card {
  display: flex;
  gap: 1.15rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.1rem;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
}

.progress-project-card:hover {
  border-color: var(--text-secondary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

/* Left: Book Cover */
.progress-card-cover-wrap {
  width: 90px;
  flex-shrink: 0;
}

.progress-card-cover {
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 6px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
  border: 1px solid var(--border-color);
}

/* Right: Main Content */
.progress-card-main {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.progress-card-badges {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 0.45rem;
}

.progress-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.73rem;
  font-weight: 600;
  padding: 0.22rem 0.6rem;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.progress-badge.badge-editing {
  background: rgba(147, 51, 234, 0.12);
  color: #9333ea;
  border: 1px solid rgba(147, 51, 234, 0.25);
}

.progress-badge.badge-translating {
  background: rgba(37, 99, 235, 0.12);
  color: #2563eb;
  border: 1px solid rgba(37, 99, 235, 0.25);
}

.progress-badge.badge-upcoming {
  background: rgba(217, 119, 6, 0.12);
  color: #d97706;
  border: 1px solid rgba(217, 119, 6, 0.25);
}

.progress-category-tag {
  font-size: 0.75rem;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}

.progress-book-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.35;
}

.progress-book-author {
  margin: 0.2rem 0 0.75rem 0;
  font-size: 0.83rem;
  color: var(--text-secondary);
  font-style: italic;
}

/* Progress Track & Details (for Translating & Editing) */
.progress-meter-wrap {
  margin-bottom: 0.75rem;
}

.progress-meter-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.82rem;
  margin-bottom: 0.35rem;
}

.progress-meter-chapter {
  color: var(--text-main);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.progress-meter-pct {
  font-weight: 700;
  color: #2563eb;
  font-variant-numeric: tabular-nums;
}

.progress-track {
  width: 100%;
  height: 8px;
  background: var(--bg-secondary);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6 0%, #2563eb 100%);
  border-radius: 999px;
  transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.progress-badge.badge-editing ~ .progress-meter-wrap .progress-bar-fill,
.badge-editing-fill {
  background: linear-gradient(90deg, #a855f7 0%, #7c3aed 100%);
}

.progress-date-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 0.7rem;
}

.progress-date-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.55rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-main);
  font-size: 0.78rem;
}

/* Upcoming Box (Sắp triển khai) */
.progress-upcoming-box {
  background: var(--bg-secondary);
  border: 1px dashed var(--border-color);
  border-radius: 8px;
  padding: 0.75rem 0.9rem;
  margin-bottom: 0.75rem;
}

.progress-upcoming-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.progress-countdown-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.6rem;
  border-radius: 20px;
  background: rgba(217, 119, 6, 0.12);
  color: #d97706;
  font-size: 0.78rem;
  font-weight: 600;
  border: 1px solid rgba(217, 119, 6, 0.25);
}

.progress-upcoming-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

/* Translator's Note Box */
.progress-note-box {
  background: rgba(0, 0, 0, 0.02);
  border-left: 3px solid #f59e0b;
  border-radius: 0 6px 6px 0;
  padding: 0.55rem 0.75rem;
  margin-bottom: 0.75rem;
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--text-main);
}

[data-theme="dark"] .progress-note-box {
  background: rgba(255, 255, 255, 0.04);
}

[data-theme="sepia"] .progress-note-box {
  background: rgba(139, 90, 43, 0.05);
}

.progress-note-header {
  font-weight: 600;
  color: #d97706;
  margin-bottom: 0.15rem;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.progress-note-text {
  margin: 0;
  font-style: italic;
  color: var(--text-secondary);
}

/* Card Action / Footer */
.progress-card-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin-top: auto;
  padding-top: 0.4rem;
}

.progress-heart-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.75rem;
  border-radius: 20px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.progress-heart-btn:hover {
  border-color: #ef4444;
  color: #ef4444;
  background: rgba(239, 68, 68, 0.05);
}

.progress-heart-btn.hearted {
  background: rgba(239, 68, 68, 0.1);
  border-color: #ef4444;
  color: #ef4444;
  font-weight: 600;
}

.progress-heart-btn svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  transition: transform var(--transition-fast);
}

.progress-heart-btn.hearted svg {
  fill: #ef4444;
  stroke: #ef4444;
  transform: scale(1.1);
}

/* Empty State */
.progress-empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-secondary);
}

.progress-empty-icon {
  width: 52px;
  height: 52px;
  margin-bottom: 0.75rem;
  opacity: 0.8;
}

.progress-empty-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 0.35rem;
}

/* Theme Filter Icons */
[data-theme="dark"] .progress-header-icon,
[data-theme="dark"] .progress-empty-icon {
  filter: brightness(0) invert(0.92);
}

[data-theme="sepia"] .progress-header-icon,
[data-theme="sepia"] .progress-empty-icon {
  filter: sepia(0.35) contrast(0.95);
}

/* ==========================================================================
   UNIFIED MOBILE BOTTOM SHEET RESPONSIVE STYLES (All Modals on Mobile <= 680px)
   ========================================================================== */
@media (max-width: 680px) {
  /* 1. All Overlays align to bottom */
  .modal-overlay,
  .changelog-modal-overlay,
  .author-modal-overlay {
    align-items: flex-end !important;
    justify-content: center !important;
    padding: 0 !important;
  }

  /* 2. All Modal Contents slide up smoothly as bottom sheets */
  .modal-content,
  .poll-modal-content,
  .progress-modal-content,
  .changelog-modal-content,
  .author-sheet-content {
    border-radius: 22px 22px 0 0 !important;
    max-width: 100% !important;
    width: 100% !important;
    max-height: 85vh !important;
    border-bottom: none !important;
    border-left: none !important;
    border-right: none !important;
    box-shadow: 0 -12px 36px rgba(0, 0, 0, 0.24) !important;
    transform: translateY(100%);
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    padding-left: 1.15rem !important;
    padding-right: 1.15rem !important;
    padding-top: 0.65rem !important;
    padding-bottom: max(2rem, env(safe-area-inset-bottom, 2rem)) !important;
    overflow-y: auto !important;
    overscroll-behavior: contain !important;
    -webkit-overflow-scrolling: touch !important;
  }

  /* Active states */
  .modal-overlay.active .modal-content,
  .modal-overlay.active .poll-modal-content,
  .modal-overlay.active .progress-modal-content,
  .changelog-modal-overlay.active .changelog-modal-content,
  .author-modal-overlay.active .author-sheet-content {
    transform: translateY(0);
  }

  /* 3. Handle visibility */
  .modal-sheet-handle,
  .author-sheet-handle {
    display: block !important;
  }

  /* 4. iOS Safari Auto-Zoom Prevention (inputs >= 16px) */
  input[type="text"],
  input[type="password"],
  textarea,
  .poll-form-input,
  .poll-form-textarea,
  #download-passcode-input {
    font-size: 16px !important;
  }

  /* 5. Headers on Mobile */
  .modal-header h3,
  .poll-main-title,
  .progress-main-title,
  .changelog-title {
    font-size: 1.05rem !important;
    line-height: 1.3 !important;
  }

  .poll-header-desc,
  .progress-header-desc,
  .changelog-subtitle {
    font-size: 0.78rem !important;
    line-height: 1.35 !important;
  }

  .poll-header-icon,
  .progress-header-icon,
  .changelog-header-icon {
    width: 32px !important;
    height: 32px !important;
  }

  /* 6. Poll / Suggest Modal Mobile Ergonomics */
  .poll-candidate-list {
    gap: 0.75rem !important;
  }

  .poll-candidate-card {
    padding: 0.85rem !important;
    border-radius: 12px !important;
  }

  .poll-candidate-title {
    font-size: 0.92rem !important;
  }

  .poll-candidate-author {
    font-size: 0.75rem !important;
  }

  .poll-candidate-desc {
    font-size: 0.78rem !important;
    margin-bottom: 0.55rem !important;
  }

  .poll-vote-btn {
    padding: 0.42rem 0.75rem !important;
    font-size: 0.8rem !important;
    min-height: 36px !important;
  }

  .poll-suggest-box {
    padding: 0.85rem !important;
    border-radius: 12px !important;
  }

  .poll-form-label {
    font-size: 0.78rem !important;
  }

  .poll-form-input,
  .poll-form-textarea {
    padding: 0.6rem 0.8rem !important;
    border-radius: 8px !important;
  }

  .poll-submit-btn {
    padding: 0.72rem 1rem !important;
    min-height: 46px !important;
    font-size: 0.9rem !important;
    border-radius: 10px !important;
  }

  /* 7. Progress Modal Mobile Ergonomics */
  .progress-modal-header {
    padding: 0.85rem 1rem !important;
  }

  .progress-tabs-container {
    padding: 0.45rem 1rem !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important;
    gap: 0.45rem !important;
  }

  .progress-tabs-container::-webkit-scrollbar {
    display: none !important;
  }

  .progress-tab-btn {
    white-space: nowrap !important;
    flex-shrink: 0 !important;
    padding: 0.35rem 0.7rem !important;
    font-size: 0.75rem !important;
  }

  .progress-list-container {
    padding: 0.85rem 1rem 1.75rem !important;
    gap: 0.85rem !important;
  }

  .progress-project-card {
    flex-direction: row !important;
    align-items: flex-start !important;
    padding: 0.8rem !important;
    gap: 0.8rem !important;
    border-radius: 12px !important;
  }

  .progress-card-cover-wrap {
    width: 60px !important;
    height: 88px !important;
    margin: 0 !important;
    flex-shrink: 0 !important;
    border-radius: 6px !important;
  }

  .progress-project-info {
    flex: 1 !important;
    min-width: 0 !important;
  }

  .progress-book-title {
    font-size: 0.95rem !important;
    margin-bottom: 0.2rem !important;
  }

  .progress-book-author {
    font-size: 0.78rem !important;
    margin-bottom: 0.35rem !important;
  }

  .progress-card-heart-btn {
    padding: 0.3rem 0.65rem !important;
    font-size: 0.75rem !important;
  }

  /* 8. Download Modal Mobile Ergonomics */
  .download-option-btn {
    padding: 0.62rem 0.85rem !important;
    min-height: 48px !important;
  }

  .download-opt-title {
    font-size: 0.88rem !important;
  }

  .download-opt-desc {
    font-size: 0.72rem !important;
  }
}



/* ==========================================================================
   BODY SCROLL LOCK & MOBILE MODAL TOUCH ISOLATION (Ngăn cuộn xuyên trang nền)
   ========================================================================== */
body.modal-open {
  overflow: hidden !important;
  touch-action: none !important;
  -webkit-overflow-scrolling: auto !important;
}

.modal-overlay,
.author-modal-overlay,
.changelog-modal-overlay,
.poll-modal-overlay {
  overscroll-behavior: contain !important;
  touch-action: none !important;
}

.modal-content,
.poll-modal-content,
.progress-modal-content,
.changelog-modal-content,
.author-sheet-content {
  overscroll-behavior: contain !important;
  -webkit-overflow-scrolling: touch !important;
  touch-action: pan-y !important;
}

.modal-sheet-handle,
.author-sheet-handle {
  touch-action: none !important;
  cursor: grab;
}


/* --- TOP ANNOUNCEMENT BAR (GHIM ĐỈNH TRANG — APPLE/VERCEL STYLE) --- */
.sheepa-top-bar {
  background: #18181b;
  color: #f4f4f5;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  font-family: var(--font-sans);
  font-size: 0.815rem;
  line-height: 1.4;
  position: relative;
  z-index: 52;
  overflow: hidden;
  max-height: 120px;
  transition: max-height 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease, padding 0.3s ease;
}

[data-theme="sepia"] .sheepa-top-bar {
  background: #342413;
  color: #fbf4e2;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sheepa-top-bar.is-hidden {
  max-height: 0 !important;
  opacity: 0 !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  border-bottom: none !important;
  pointer-events: none;
}

.top-bar-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 6px 40px 6px 16px;
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.top-bar-content {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px 10px;
  text-align: center;
}

.top-bar-icon {
  font-size: 0.95rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.top-bar-text {
  font-weight: 450;
  color: inherit;
}

.top-bar-text strong {
  font-weight: 700;
  color: #fef08a; /* Golden amber highlight */
}

.top-bar-cta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #0088cc;
  color: #ffffff !important;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.74rem;
  padding: 2px 10px;
  border-radius: 999px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: background 0.18s ease, transform 0.18s ease;
  white-space: nowrap;
  flex-shrink: 0;
}

.top-bar-cta:hover {
  background: #0077b5;
  transform: translateY(-1px);
}

.top-bar-arrow {
  display: inline-block;
  transition: transform 0.18s ease;
}

.top-bar-cta:hover .top-bar-arrow {
  transform: translate(1px, -1px);
}

.top-bar-close {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.65);
  font-size: 0.85rem;
  line-height: 1;
  padding: 5px 7px;
  cursor: pointer;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease, background 0.15s ease;
}

.top-bar-close:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.15);
}

@media (max-width: 640px) {
  .sheepa-top-bar {
    font-size: 0.75rem;
  }
  .top-bar-inner {
    padding: 6px 34px 6px 12px;
  }
  .top-bar-cta {
    font-size: 0.7rem;
    padding: 2px 8px;
  }
}
