/* ==================== 全域設定 ==================== */
body {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --header-height: 60px;
  --footer-height: 60px;
  --sidebar-width: 360px;

  --primary-color: #023147;
  --text-color: #1f2937;
  --text-secondary: #6b7280;
  --bg-color: #ffffff;
  --bg-color-gray: #f1f1f1;
  --white: #ffffff;
  --border-color: #e5e7eb;
  --border-color-dark: #cbcccf;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.15);

  --transition: all 0.3s ease;
}

.header {
  position: fixed; /* 固定定位 */
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--white);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 100;
  box-shadow: var(--shadow);
  transition: transform 0.3s ease;
}

ul {
  padding: 0;
  margin: 0;
}

/* 移除瀏覽器鍵盤焦點指示器樣式 */
:focus-visible {
  outline: none;
}

/* ==================== UI 顯示/隱藏控制 ==================== */
body:not(.ui-visible) .header {
  transform: translateY(-100%);
}

body:not(.ui-visible) .footer {
  transform: translateY(100%);
}

/* ==================== 初始提示 UI ==================== */
.initial-hint {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 200;
  background: rgba(0, 0, 0, 0.85);
  border-radius: 16px;
  padding: 18px 24px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  opacity: 1;
  transition: opacity 0.5s ease;
  pointer-events: none;
}

.initial-hint.hidden {
  opacity: 0;
}

.hint-content {
  display: flex;
  align-items: center;
  gap: 4px;
  color: white;
  flex-direction: row-reverse; /* 預設箭頭在右邊（LTR） */
}

.hint-arrow {
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.3));
  transition: transform 0.3s ease;
}

/* 從右往左翻頁（RTL）- 箭頭在左邊  */
.initial-hint.rtl .hint-content {
  flex-direction: row;
}

.initial-hint.rtl .hint-arrow {
  transform: scaleX(-1);
}

.hint-text {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: 0.5px;
}

/* ==================== 頂部標題列 ==================== */
.header {
  height: var(--header-height);
  background: var(--white);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  box-shadow: var(--shadow);
  transition: transform 0.3s ease;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.menu-btn,
.book-switch-btn,
.bookmark-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 8px;
  transition: background-color 0.2s;
}

.book-title {
  font-size: 18px;
  font-weight: 600;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  max-width: 600px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.header-actions button {
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  color: var(--text-color);
}

.header-actions button:hover {
  background: var(--bg-color);
}

.lang-btn {
  width: auto !important;
  padding: 0 16px;
  font-size: 14px;
  font-weight: 500;
}

/* ==================== 左側書籍切換選單 ==================== */
/* 彈窗遮罩 */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.3s;
}

.modal-overlay.active {
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
}

/* 彈窗內容 */
.modal-content {
  background: white;
  border-radius: 8px;
  width: 90%;
  max-width: 800px;
  max-height: 85vh;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  transform: scale(0.9);
  transition: transform 0.3s;
}

.modal-overlay.active .modal-content {
  transform: scale(1);
}

/* 彈窗標題欄 */
.modal-header {
  padding: 0 1rem;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  font-size: 1rem;
}

.close-btn {
  background: none;
  border: none;
  font-size: 2rem;
  cursor: pointer;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background-color 0.2s;
}

.close-btn:hover {
  background-color: #f5f5f5;
}

/* 彈窗主體 */
.modal-body {
  display: flex;
  height: 80vh;
}

/* 左側封面區 */
.book-cover-section {
  flex: 0 0 30%;
  padding: 1.5rem;
  background: white;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: start;
}

.switch-book-cover {
  width: 250px;
  height: auto;
  background: white;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.switch-book-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.book-cover-placeholder {
  font-size: 3rem;
  color: white;
}

/* 右側版本列表區 */
.book-versions-section {
  flex: 1;
  padding: 1.5rem 1.5rem 1.5rem 0;
  overflow-y: auto;
}

.version-thumbnail {
  display: none;
}

.versions-title {
  font-size: 1rem;
  color: var(--text-color);
  margin: 0;
  margin-bottom: 1rem;
  font-weight: 600;
}

.version-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.version-item {
  padding: 0.8rem 1.25rem;
  border: 2px solid var(--bg-color-gray);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.version-item:hover {
  background-color: var(--bg-color-gray);
}

.version-item.active {
  background-color: rgb(240, 240, 240);
  border: 2px solid var(--primary-color);
}

.version-name {
  font-weight: 500;
  font-size: 1rem;
}

.version-badge {
  background: var(--primary-color);
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

/* ==================== 左側章節選單 ==================== */
.sidebar {
  position: fixed;
  left: -100%;
  top: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--white);
  box-shadow: var(--shadow-lg);
  transition: var(--transition);
  padding-top: var(--header-height);
  z-index: 90;
  overflow-y: auto;
}

.sidebar.open {
  left: 0;
}

.sidebar-header {
  padding: 0;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  background: var(--white);
  z-index: 10;
}

.sidebar-header h2 {
  font-size: 18px;
  font-weight: 600;
}

/* 側邊欄 Tabs */
.sidebar-tabs {
  display: flex;
  flex: 1;
}

.sidebar-tab-btn {
  flex: 1;
  padding: 16px 20px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: var(--transition);
  border-bottom: 2px solid transparent;
}

.sidebar-tab-btn:hover {
  background: var(--bg-color);
  color: var(--text-color);
}

.sidebar-tab-btn.active {
  color: var(--primary-color);
  border-bottom-color: var(--primary-color);
  background: transparent;
}

.close-sidebar-btn {
  width: 48px;
  height: auto;
  border: none;
  background: transparent;
  font-size: 28px;
  cursor: pointer;
  color: var(--text-secondary);
  line-height: 1;
  border-radius: 0;
  transition: var(--transition);
  flex-shrink: 0;
}

.close-sidebar-btn:hover {
  background: var(--bg-color);
  color: var(--text-color);
}

/* 側邊欄內容切換 */
.sidebar-tab-content {
  display: none;
}

.sidebar-tab-content.active {
  display: block;
}

/* 章節列表 */
.chapter-list {
  list-style: none;
}

.chapter-item {
  display: block;
  padding: 16px 20px;
  text-decoration: none;
  color: var(--text-color);
  border-bottom: 1px solid var(--border-color);
  transition: var(--transition);
  font-size: 15px;
}

.chapter-item:hover {
  background: var(--bg-color);
  padding-left: 24px;
}

.chapter-item.active {
  background: #eff6ff;
  color: var(--primary-color);
  font-weight: 500;
  border-left: 3px solid var(--primary-color);
}

/* 書籤列表 */
.bookmark-list {
  list-style: none;
}

.bookmark-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-color);
  gap: 12px;
  transition: var(--transition);
}

.bookmark-item:hover {
  background: var(--bg-color);
}

.bookmark-link {
  flex: 1;
  text-decoration: none;
  color: var(--text-color);
  display: block;
}

.bookmark-title {
  font-size: 15px;
  line-height: 1.5;
  display: block;
}

.bookmark-delete-btn {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--text-secondary);
  border-radius: 4px;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

/* ==================== 右側設定面板 ==================== */
.settings-panel {
  position: fixed;
  right: -100%;
  top: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--white);
  box-shadow: var(--shadow-lg);
  transition: var(--transition);
  z-index: 90;
  overflow-y: auto;
  padding-top: var(--header-height);
  box-sizing: border-box;
}

.settings-panel.open {
  right: 0;
}

.settings-header {
  padding: 0;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  background: var(--white);
  z-index: 10;
}

.tabs {
  display: flex;
  flex: 1;
}

.tab-btn {
  flex: 1;
  padding: 16px 20px;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 15px;
  font-weight: 500;
  transition: var(--transition);
  border-bottom: 2px solid transparent;
}

.tab-btn:hover {
  background: var(--bg-color);
  color: var(--text-color);
}

.tab-btn.active {
  color: var(--primary-color);
  border-bottom-color: var(--primary-color);
  background: transparent;
}

.tab-btn svg {
  flex-shrink: 0;
}

.tab-btn span {
  display: inline;
}

.settings-header h2 {
  font-size: 18px;
  font-weight: 600;
}

.close-settings-btn {
  width: 48px;
  height: 58px;
  border: none;
  background: transparent;
  font-size: 28px;
  cursor: pointer;
  color: var(--text-secondary);
  line-height: 1;
  border-radius: 0;
  transition: var(--transition);
  flex-shrink: 0;
}

.close-settings-btn:hover {
  background: var(--bg-color);
  color: var(--text-color);
}

.settings-content {
  padding: 20px;
}

/* 頁籤內容切換 */
.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.setting-group {
  margin-bottom: 24px;
}

.setting-group label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 12px;
  color: var(--text-color);
}

.button-group {
  display: flex;
  gap: 8px;
}

.setting-btn {
  flex: 1;
  padding: 10px 16px;
  border: 1px solid var(--border-color);
  background: var(--white);
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 500;
  transition: var(--transition);
  color: var(--text-color);
}

.setting-btn:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.setting-btn.active {
  background: var(--primary-color);
  border-color: var(--primary-color);
  color: var(--white);
}

.setting-btn.icon-btn {
  flex: 0 0 auto;
  width: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
}

.info-btn {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border-color);
  background: var(--white);
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: var(--transition);
}

.info-btn:hover {
  background: var(--bg-color);
}

/* ==================== 書籍資訊樣式 ==================== */
.book-info {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.book-cover {
  text-align: center;
  padding: 20px 0;
}

.book-cover img {
  max-width: 150px;
  height: auto;
  border-radius: 4px;
}

.info-group {
  display: flex;
  align-items: baseline;
  justify-content: flex-start;
  border-bottom: 1px solid #eee;
  padding-bottom: 5px;
}

/* epub-reader.css 內 */

.info-group label {
  font-weight: 600;
  color: #4b5563;
  min-width: 80px;
  flex-shrink: 0;
  margin-right: 1rem;
  text-align: left;
}

.info-group p {
  margin: 0;
  color: #1f2937;
  text-align: left;
  flex-grow: 0;
  flex-shrink: 1;
}

.info-group.full-width {
  grid-column: 1 / -1;
}

.info-group .description {
  font-size: 16px;
  line-height: 1.7;
}

.info-columns {
  display: flex;
  gap: 20px;
  width: 100%;
}

.info-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ==================== 主要內容區域 ==================== */
.main-content {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--bg-color);
  z-index: 1;
}

/* ==================== EPUB 顯示區域 ==================== */
.epub-viewer {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.epub-viewer.vertical-scroll {
  overflow-y: auto;
  overflow-x: hidden;
  align-items: flex-start;
}

/* 滾動模式隱藏側邊卷軸 */
#epubViewer.vertical-scroll {
  overflow-x: auto !important;
  overflow-y: scroll;
  /* Firefox 隱藏捲軸 */
  scrollbar-width: none;

  /* IE / Edge 隱藏捲軸 */
  -ms-overflow-style: none;
}

/* Webkit 瀏覽器 (Chrome, Safari) 隱藏捲軸 */
#epubViewer.vertical-scroll::-webkit-scrollbar {
  display: none;
}

.epub-view::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  cursor: pointer;
  background: transparent;
}

/* 縮放容器 */
.epub-scaler {
  width: 100%;
  height: 100%;
  transform-origin: center center;
  transition: transform 0.1s ease-out;
  transition: none;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  cursor: grab;
}

.epub-scaler:active {
  cursor: grabbing;
}

.epub-scaler.vertical-scroll {
  /* height: auto; */
  width: 100%;
  margin: 0 auto;
  min-height: 100%;
  align-items: flex-start;
  transform-origin: center center;
}

/* 左右頁容器 */
.epub-container {
  display: flex;
  width: 100%;
  height: 100%;
}

/* 直排模式 */
.epub-container.vertical {
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  height: auto;
  align-items: stretch;
}

/* 直書文字單頁模式：隱藏右側 iframe，左側置中 */
.epub-container.vertical-text-mode #rightPage {
  display: none !important;
}

.epub-container.vertical-text-mode #leftPage {
  width: 100% !important;
  display: flex !important;
  justify-content: center !important;
  align-items: center !important;
}

.epub-container.vertical-text-mode #leftIframe {
  width: 100% !important;
  height: 100% !important;
}

/* 單頁 + 直立模式，顯示所有頁面 */
.epub-container.single-page.vertical .epub-view:last-child {
  margin: 0;
  display: flex;
}

.epub-container.single-page .epub-view:first-child {
  margin: 0;
  flex: 1 1 50%;
  justify-content: center;
}

/* 橫書文字模式：隱藏右側 iframe */
.epub-container.horizontal-text-mode #rightPage {
  display: none !important;
}

.epub-container.horizontal-text-mode #leftPage {
  width: 100% !important;
}

/* 封面模式 - LTR：隱藏右頁，左頁居中 */
.epub-container.cover-mode.ltr .epub-view:last-child {
  margin: 0;
  display: none !important;
}

.epub-container.cover-mode.ltr .epub-view:first-child {
  flex: 1 1 100% !important;
  justify-content: center !important;
}

/* 封面模式 - RTL：隱藏左頁，右頁居中 */
.epub-container.cover-mode.rtl .epub-view:first-child {
  display: none !important;
}

.epub-container.cover-mode.rtl .epub-view:last-child {
  flex: 1 1 100% !important;
  justify-content: center !important;
}

/* 原始模式的置中樣式 */
.epub-container.original-mode #leftPage {
  display: flex;
  justify-content: center;
  align-items: center;
}

.epub-container.original-mode .epub-view iframe {
  min-height: auto !important;
}

.epub-container.vertical .epub-view {
  flex: 0 0 auto;
  width: 100%;
  height: 100vh;
  max-height: 100vh;
}

/* 每一頁的容器 */
.epub-view {
  flex: 1 1 50%;
  min-width: 0;
  height: auto !important;
  width: auto !important;
  background: var(--white);
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: flex-start;
}

/* 直立模式 */
.epub-container.vertical .epub-view {
  flex: 0 0 auto;
  width: 100%;
  height: auto;
  min-height: 0;
}

/* 滾動模式：控制整體寬度和置中 */
.epub-viewer.vertical-scroll {
  width: 100%;
  margin: 0 auto; /* 水平置中 */
  overflow-y: auto;
  overflow-x: hidden;
  height: 100%;
}

.epub-viewer.vertical-scroll .epub-scaler {
  width: 50% !important;
  height: auto !important;
}

.epub-viewer.vertical-scroll .epub-container {
  width: 100% !important;
  height: auto !important;
  display: flex;
  flex-direction: column; /* 垂直排列每個 epub 檔案 */
  align-items: stretch;
}

.epub-viewer.vertical-scroll .epub-view {
  width: 100% !important;
  height: auto !important;
  flex: none !important;
}

.epub-viewer.vertical-scroll .epub-view iframe {
  width: 100% !important;
  height: auto !important;
  min-height: 100vh;
  border: none;
}

/* 滾動模式下隱藏翻頁按鈕 */
.epub-viewer.vertical-scroll ~ .nav-btn {
  display: none;
}

/* 響應式調整 */
@media (max-width: 768px) {
  .epub-viewer.vertical-scroll {
    width: 90%; /* 手機上寬度增加到 90% */
  }
}

@media (max-width: 480px) {
  .epub-viewer.vertical-scroll {
    width: 95%; /* 更小螢幕上寬度增加到 95% */
  }

  .epub-viewer.vertical-scroll .epub-view {
    margin-bottom: 1rem; /* 減少間距 */
  }
}

/* 左頁：內容靠右 */
.epub-view:first-child {
  justify-content: flex-start;
  margin: 0;
}

/* 右頁：內容靠左 */
.epub-view:last-child {
  justify-content: flex-end;
  margin: 0;
}

.epub-view iframe {
  min-height: 100vh !important;
  width: 100%;
  height: auto;
  border: none;
  display: block;
  box-sizing: border-box;
  overflow: hidden;
}

.epub-view iframe[src=""] {
  display: none;
}

/* ==================== 滾動模式設定 ==================== */
/* pdf2htmlEX 模式允許滾動 */
.epub-container.pdf2htmlex-native .epub-view iframe {
  overflow: auto !important;
  pointer-events: auto !important;
}

/* 滾動模式的 epub-view */
.epub-view.scroll-page {
  flex: 0 0 auto !important;
  width: 100% !important;
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  overflow: hidden !important;
}

/* 滾動模式的 iframe - 覆蓋預設的 min-height */
.epub-view.scroll-page iframe,
iframe.scroll-iframe {
  min-height: 0 !important;
  height: auto !important;
  max-height: none !important;
}

/* 滾動模式的內容容器 */
.epub-container.scroll-mode {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: auto;
  align-items: stretch;
}

/* 確保滾動容器內的所有 iframe 都套用 */
.epub-container.scroll-mode .epub-view {
  flex: 0 0 auto !important;
  height: auto !important;
  min-height: 0 !important;
}

.epub-container.scroll-mode .epub-view iframe {
  min-height: 0 !important;
  max-height: none !important;
}

/* ==================== 翻頁按鈕 ==================== */
.nav-btn {
  position: absolute;
  width: 100px;
  height: 100%;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  z-index: 10;
  color: var(--text-color);
  transition: all 0.3s ease;
}

.nav-btn:hover {
  transform: scale(1.1);
}

.nav-btn:active {
  transform: scale(0.95);
}

.nav-btn-prev {
  left: 0;
  padding-right: 50px;
}

.nav-btn-next {
  right: 0;
  padding-left: 50px;
}

/* ==================== 底部進度條 ==================== */
.footer {
  position: fixed; /* 固定定位 */
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--footer-height);
  background: var(--bg-color-gray);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 40px;
  z-index: 80;
  transition: transform 0.3s ease;
}

.progress-container {
  width: 100%;
  max-width: 800px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.progress-slider {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: var(--border-color);
  outline: none;
  cursor: pointer;
  transition: var(--transition);
  margin: 0;
  padding: 0;
}

/* 滑桿軌道 - Chrome/Safari */
.progress-slider::-webkit-slider-track {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--border-color);
}

/* 滑桿已填充部分 - Chrome/Safari */
.progress-slider::-webkit-slider-runnable-track {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(
    to right,
    var(--border-color-dark) 100%
  );
}

/* 滑桿按鈕 - Chrome/Safari */
.progress-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--white);
  border: 3px solid var(--primary-color);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  transition: var(--transition);
  margin-top: -7px; /* (20px - 6px) / 2 = 7px，讓按鈕垂直居中 */
}

.progress-slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
}

.progress-slider::-webkit-slider-thumb:active {
  transform: scale(1.05);
}

/* 滑桿軌道 - Firefox */
.progress-slider::-moz-range-track {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--border-color);
  border: none;
}

/* 滑桿已填充部分 - Firefox */
.progress-slider::-moz-range-progress {
  height: 6px;
  border-radius: 3px;
  background: var(--primary-color);
}

/* 滑桿按鈕 - Firefox */
.progress-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--white);
  border: 3px solid var(--primary-color);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  transition: var(--transition);
}

.progress-slider::-moz-range-thumb:hover {
  transform: scale(1.15);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
}

/* 進度文字 - 改為在右側 */
.progress-label {
  flex-shrink: 0;
  min-width: 30px;
  text-align: right;
}

.page-number {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
}

/* ==================== 縮圖按鈕 ==================== */
.thumbnail-btn {
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: var(--transition);
  color: var(--text-color);
  flex-shrink: 0;
  margin-right: 12px;
}

.thumbnail-btn:hover {
  background: var(--bg-color);
}

.thumbnail-btn svg {
  width: 24px;
  height: 24px;
}

/* ==================== 縮圖視窗 ==================== */
.thumbnail-panel {
  position: fixed;
  bottom: -100%;
  left: 0;
  right: 0;
  height: 60vh;
  max-height: 500px;
  background: var(--white);
  transition: bottom 0.3s ease;
  z-index: 70;
  display: flex;
  flex-direction: column;
}

.thumbnail-panel.open {
  bottom: 0;
}

.close-thumbnail-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  font-size: 28px;
  cursor: pointer;
  color: var(--text-secondary);
  line-height: 1;
  border-radius: 4px;
  transition: var(--transition);
}

.close-thumbnail-btn:hover {
  color: var(--text-color);
}

/* 縮圖網格 */
.thumbnail-grid {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  padding-bottom: 5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* 隱藏滾動條但保持功能 */
.thumbnail-grid::-webkit-scrollbar {
  width: 8px;
}

.thumbnail-grid::-webkit-scrollbar-track {
  background: var(--bg-color);
}

.thumbnail-grid::-webkit-scrollbar-thumb {
  background: var(--border-color-dark);
  border-radius: 4px;
}

.thumbnail-grid::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

.thumbnail-iframe-wrapper {
  background-color: var(--border-color);
}

/* 單個縮圖項目 - 固定寬度 */
.thumbnail-item {
  position: relative;
  cursor: pointer;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border-color);
  transition: var(--transition);
  width: 120px;
  height: auto;
  display: block;
}

.thumbnail-item:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
}

.thumbnail-item.active {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 1px var(--primary-color);
}

/* 內層：實際的網格容器 */
.thumbnail-grid-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: flex-start;
  align-content: start;
  margin-left: auto;
  margin-right: auto;
  max-width: 100%;
  width: fit-content;
}

/* iframe 包裝器 */
.thumbnail-grid-inner {
  display: grid;
  grid-template-columns: repeat(auto-fill, 120px);
  gap: 16px;
  justify-content: start;
  align-content: start;
}
/* 縮圖中的 iframe */
.thumbnail-item iframe {
  width: 100%;
  height: 100%;
  border: none;
  pointer-events: none;
  display: block;
}

/* 縮圖面板遮罩 */
.thumbnail-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 60;
  opacity: 0;
  pointer-events: none;
  transition: var(--transition);
}

.thumbnail-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

/* ==================== 遮罩層 ==================== */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 80;
  opacity: 0;
  pointer-events: none;
  transition: var(--transition);
}

.overlay.active {
  opacity: 1;
  pointer-events: auto;
}

/* ==================== RWD ==================== */

/* 響應式設計 */
@media (max-width: 1200px) {
  .book-title {
    max-width: 400px;
  }
}

@media (max-width: 992px) {
  .book-title {
    max-width: 300px;
  }
}

@media (max-width: 768px) {
  .initial-hint {
    padding: 8px 16px;
    border-radius: 8px;
  }

  .hint-arrow {
    width: 24px;
    height: 24px;
  }

  .hint-text {
    font-size: 16px;
  }
}

/* 手機直向 - 單頁模式 */
@media (max-width: 768px) and (orientation: portrait) {
  .nav-transparent-mobile {
    opacity: 0 !important;
    cursor: pointer !important;
  }

  .book-title {
    display: none;
  }

  .epub-container {
    gap: 0;
  }

  /* 隱藏大封面區 */
  .book-cover-section {
    display: none;
  }

  .modal-body {
    flex-direction: column;
  }

  .book-versions-section {
    padding: 1rem;
  }

  /* 每個項目顯示縮圖 */
  .version-item {
    display: grid;
    grid-template-columns: 60px 1fr auto;
    gap: 0.8rem;
    align-items: center;
    padding: 0.8rem;
  }

  .version-thumbnail {
    display: block;
    width: 60px;
    height: 85px;
    border-radius: 4px;
    overflow: hidden;
    background: #f5f5f5;
  }

  .version-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  .version-item {
    position: relative;
  }

  .version-badge {
    position: absolute;
    top: -8px;
    right: -2px;
  }

  /* 強制單頁 */
  .epub-view:last-child {
    display: none !important;
  }

  .epub-viewer.vertical-scroll .epub-scaler {
    width: 100% !important;
    height: auto !important;
  }

  /* 縮圖 */
  .thumbnail-panel {
    height: 70vh;
    max-height: none;
  }
  .thumbnail-grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 12px;
    padding: 16px;
  }
  .thumbnail-btn {
    width: 36px;
    height: 36px;
    margin-right: 8px;
  }
}

/* 手機橫向 - 雙頁模式 */
@media (max-width: 768px) and (orientation: landscape) {
  .epub-view {
    width: 45vw;
    height: calc(100vh - var(--header-height) - var(--footer-height) - 20px);
  }
}

/* 小螢幕調整 */
@media (max-width: 480px) {
  :root {
    --header-height: 56px;
    --sidebar-width: 100vw;
  }

  .header {
    padding: 0 12px;
  }

  .book-title {
    font-size: 14px;
    max-width: 150px;
  }

  .header-actions {
    gap: 4px;
  }

  .header-actions button {
    width: 36px;
    height: 36px;
  }

  .lang-btn {
    display: none;
  }

  .thumbnail-grid {
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 8px;
    padding: 12px;
  }

  .zoom-out-btn,
  .zoom-reset-btn,
  .zoom-in-btn {
    display: none !important;
  }
}

/* ==================== 縮放比例 ==================== */
.epub-scaler.zoom-80 {
  transform: scale(0.8);
}

.epub-scaler.zoom-90 {
  transform: scale(0.9);
}

.epub-scaler.zoom-100 {
  transform: scale(1);
}

.epub-scaler.zoom-110 {
  transform: scale(1.1);
}

.epub-scaler.zoom-120 {
  transform: scale(1.2);
}

.epub-scaler.zoom-130 {
  transform: scale(1.3);
}

.epub-scaler.zoom-140 {
  transform: scale(1.4);
}

.epub-scaler.zoom-150 {
  transform: scale(1.5);
}

.epub-scaler.zoom-160 {
  transform: scale(1.6);
}

.epub-scaler.zoom-170 {
  transform: scale(1.7);
}

.epub-scaler.zoom-180 {
  transform: scale(1.8);
}

.epub-scaler.zoom-190 {
  transform: scale(1.9);
}

.epub-scaler.zoom-200 {
  transform: scale(2);
}
