:root {
  --bg-color: #333333;
  --header-height: 50px;
  --footer-height: 60px;
  --accent-color: #e57373;
}

body {
  margin: 0;
  background-color: var(--bg-color);
  font-family: sans-serif;
  color: #fff;
  /* 100vhではなく100dvhを使うことで、スマホのメニューバーを考慮した高さになります */
  height: 100dvh; 
  overflow: hidden;
  position: relative;
}

/* ヘッダー */
.viewer-header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: var(--header-height);
  z-index: 1000;
  background-color: rgba(34, 34, 34, 0.9); /* 少し透過させるとモダンです */
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
  box-sizing: border-box;
}
.header-title { font-size: 1rem; font-weight: bold; }
.header-close {
  color: #fff;
  text-decoration: none;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  z-index: 100;
}

/* メイン表示領域 */
.viewer-body {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%; /* 画面いっぱい */
  display: flex;
  justify-content: center;
  align-items: center;
  /* ヘッダーとフッターに画像が被らないようにガードレールを引く */
  padding-top: var(--header-height);
  padding-bottom: var(--footer-height);
  box-sizing: border-box;
  z-index: 10;
}

/* クリックエリア */
.click-area-left, .click-area-right {
  position: absolute;
  top: 0;
  width: 50%;
  height: 100%;
  z-index: 10;
}
.click-area-left { left: 0; }
.click-area-right { right: 0; }

/* カーソル定義 */
.cursor-next-page {
  cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32"><text x="0" y="24" font-size="24" fill="white">◀</text></svg>') 16 16, auto;
}
.cursor-prev-page {
  cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32"><text x="0" y="24" font-size="24" fill="white">▶</text></svg>') 16 16, auto;
}
.cursor-default { cursor: default; }

/* ページコンテナ */
.page-container {
  display: flex;
  width: 100%;
  height: 100%;
  justify-content: center;
  align-items: center;
  pointer-events: none;
}

.manga-page {
  height: 100%;
  width: 100%;
  max-height: 100%; /* viewer-bodyのpaddingを除いた内側に収まる */
  max-width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.manga-page.left-slot { justify-content: flex-end; }
.manga-page.right-slot { justify-content: flex-start; }

.manga-page img {
  max-height: 100% !important;
  max-width: 100% !important;
  object-fit: contain;
}

/* UIボタン */
.page-aspect-box {
  height: 100%;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ui-btn {
  display: inline-block;
  padding: 15px 30px;
  border: 2px solid #333;
  color: #333;
  text-decoration: none;
  font-weight: bold;
  font-size: 1.2rem;
  background: #fff;
  position: relative;
  z-index: 20;
  pointer-events: auto;
  cursor: pointer;
}
.ui-btn::before {
  content: "";
  position: absolute;
  top: -40px; bottom: -40px; left: -60px; right: -60px;
  z-index: -1;
}

/* フッター・スライダー */
.viewer-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: var(--footer-height);
  z-index: 1000;
  background: rgba(34, 34, 34, 0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 20px;
  box-sizing: border-box;
}
.page-tooltip {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 18px;
  font-weight: bold;
  display: none;
  pointer-events: none;
  z-index: 100;
  border: 1px solid rgba(255,255,255,0.2);
}
.page-slider {
  width: 100%;
  cursor: pointer;
  transform: scaleX(-1);
  -webkit-appearance: none;
  background: #666;
  height: 6px;
  border-radius: 3px;
}
.page-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  background: var(--accent-color);
  width: 24px;
  height: 24px;
  border-radius: 50%;
}

/* ページ送り案内画像 */
.nav-guide {
  position: absolute;
  left: 5%;
  top: 50%;
  transform: translateY(-50%);
  z-index: 50;
  pointer-events: none;
  opacity: 0;
  max-width: 100px;
  animation: fade-guide 1s ease-in-out 3 forwards;
}

@keyframes fade-guide {
  0% { opacity: 0; }
  15% { opacity: 0.8; }
  60% { opacity: 0.8; }
  80% { opacity: 0; }
}

@media (max-width: 768px) {
  .manga-page { width: 100%; justify-content: center !important; }
}