:root {
  --comic-bg: #000000;      
  --panel-bg: #ffffff;      
  --panel-border: #e5e5e7;  
  --btn-bg: #f2f2f7;        
  --btn-hover: #e5e5ea;     
  --text-color: #1d1d1f;    
  --accent-color: #ef4444;  
}

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

html, body { width: 100%; height: 100%; overflow: hidden; }
body { 
  display: flex; 
  flex-direction: column; 
  background-color: var(--comic-bg); 
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
}

/* 頂部標題列 CSS */
.top-bar {
  width: 100%;
  height: 50px;
  background-color: var(--panel-bg);
  border-bottom: 1px solid var(--panel-border);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 20px;
  z-index: 100;
  transition: all 0.3s cubic-bezier(0.1, 0.9, 0.2, 1);
}
.manga-title-wrap {
  display: flex;
  gap: 12px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-color);
}
.top-bar.hidden {
  height: 0 !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  border-bottom-color: transparent !important;
  overflow: hidden !important;
}

/* 漫畫主顯示區 */
.viewer-main {
  flex: 1;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  cursor: pointer;
  user-select: none;
}

.comic-stage {
  display: flex;
  width: 100%;
  height: 100%;
  background: #000;
  position: relative;
}

.comic-page {
  flex: 1;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center; 
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center center; 
  background-color: #000;
  transition: background-color 0.2s ease;
}

/* 雙頁模式對齊 */
.comic-stage.double-mode #leftPage {
  background-position: right center; 
  justify-content: flex-end; 
}
.comic-stage.double-mode #rightPage {
  background-position: left center;  
  justify-content: flex-start; 
}

/* 模擬漫畫頁面大小的白底畫布 */
.blank-padding-box {
  height: 100%;
  max-width: 100%;
  background-color: #ffffff;
}

/* 書脊陰影 */
.comic-stage.double-mode::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 30px; 
  background: linear-gradient(to right, 
    rgba(0,0,0,0) 0%, 
    rgba(0,0,0,0.15) 30%, 
    rgba(0,0,0,0.35) 50%, 
    rgba(0,0,0,0.15) 70%, 
    rgba(0,0,0,0) 100%
  );
  pointer-events: none;
  mix-blend-mode: multiply;
  z-index: 10;
}

/* 實體控制列 */
.control-bar {
  width: 100%;
  height: 65px; 
  background-color: var(--panel-bg);
  border-top: 1px solid var(--panel-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 100;
  transition: all 0.3s cubic-bezier(0.1, 0.9, 0.2, 1);
  direction: rtl; 
}

.control-bar.hidden {
  height: 0 !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  border-top-color: transparent !important;
  overflow: hidden !important; 
}

.btn-group { 
  display: flex; 
  gap: 6px; 
  align-items: center;
  direction: rtl; 
}

button {
  background-color: var(--btn-bg);
  color: var(--text-color);
  border: none;
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.2s;
  white-space: nowrap;
}
button:hover { background-color: var(--btn-hover); }
button:disabled { background-color: #f9f9f9; color: #c8c8cc; cursor: not-allowed; }
button svg { display: block; flex-shrink: 0; }

/* 進度條 */
.slider-container {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 20px;
  direction: rtl;
}
.page-slider {
  flex: 1;
  height: 4px;
  -webkit-appearance: none;
  background: #e5e5ea;
  border-radius: 2px;
  outline: none;
}
.page-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent-color);
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.page-info { 
  min-width: 65px; 
  text-align: center; 
  font-size: 13px; 
  direction: ltr; 
  color: var(--text-color);
  font-weight: 500;
}

.btn-close { background-color: #fef2f2; color: #ef4444; }
.btn-close:hover { background-color: #fee2e2; }

/* 浮動開啟選單按鈕 */
.floating-menu-trigger {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 99;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  background-color: var(--panel-bg);
  border: 1px solid var(--panel-border);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  transform: scale(0.6);
  transition: all 0.25s ease;
  pointer-events: none;
}
.floating-menu-trigger.show {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}

/* ===== RWD 手機版樣式優化 ===== */
@media (max-width: 768px) {
  .comic-stage.double-mode::after { display: none; }
  
  /* 【修改】在這裡把「切換單頁」、「隱藏選單」以及「全螢幕」按鈕在手機版一併隱藏 */
  .btn-mode-toggle, .btn-hide, #btnFullscreen { display: none !important; } 
  
  .control-bar { 
    height: 55px; 
    padding: 0 8px; 
  }
  .btn-group { gap: 4px; } 
  
  button .btn-txt { display: none !important; }
  button { 
    padding: 0 !important; 
    width: 34px !important;
    height: 34px !important;
    border-radius: 50% !important; 
    flex-shrink: 0 !important;
  }
  
  /* 釋放空間給進度條與頁數 */
  .slider-container { 
    margin: 0 8px; 
    gap: 6px;
    min-width: 0; 
  }
  .page-info {
    min-width: 50px; 
    font-size: 11px;
  }
  .floating-menu-trigger { bottom: 15px; left: 15px; }
  .top-bar { height: 45px; }
  .manga-title-wrap { font-size: 13px; gap: 8px; }
}