/**
 * EPUBビューワー reader.css (v0.12.3)
 * 横読み/縦読み/見開き/進捗メーター対応
 */
.dc-reader {
  position: fixed;
  top: 44px; left: 0; right: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  background: #1a1a1a;
  color: #eee;
  overflow: hidden;
}

/* ===== ツールバー ===== */
.dc-reader__toolbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 12px;
  background: rgba(0, 0, 0, 0.6);
  z-index: 10;
  pointer-events: none;
}
.dc-reader__toolbar-left,
.dc-reader__toolbar-right {
  pointer-events: auto;
}
.dc-reader__toolbtn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.15s ease;
}
.dc-reader__toolbtn:hover {
  background: rgba(255, 255, 255, 0.2);
}
.dc-reader__page-count {
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

/* ===== ステージ ===== */
.dc-reader__stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}
.dc-reader__stage--horizontal {
  cursor: pointer;
}
.dc-reader__stage--spread {
  cursor: pointer;
}
.dc-reader__stage--vertical {
  overflow-y: auto;
  overflow-x: hidden;
  align-items: stretch;
  flex-direction: column;
  justify-content: flex-start;
  padding-top: 44px; /* toolbar高さ分 */
  padding-bottom: 30px;
  cursor: default;
}
.dc-reader__stage--cta {
  cursor: default;
}

.dc-reader__page-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  /* v0.12.3b: 画像保存防止 */
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
  -khtml-user-drag: none;
  -moz-user-drag: none;
  -o-user-drag: none;
  user-drag: none;
  -webkit-touch-callout: none;
  pointer-events: none;
}
.dc-reader__page-img--vertical {
  width: 100%;
  max-width: 800px;
  max-height: none;
  height: auto;
  margin: 0 auto;
  display: block;
}

/* ===== 見開き ===== */
.dc-reader__spread {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  height: 100%;
  max-height: 100%;
}
.dc-reader__spread .dc-reader__page-img {
  height: 100%;
  max-height: 100%;
  width: auto;
}

/* ===== ナビ矢印 ===== */
.dc-reader__btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 80px;
  background: rgba(0, 0, 0, 0.4);
  border: none;
  color: #fff;
  font-size: 2rem;
  cursor: pointer;
  z-index: 5;
  border-radius: 4px;
  transition: background 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}
.dc-reader__btn:hover {
  background: rgba(0, 0, 0, 0.7);
}
.dc-reader__btn--prev { left: 8px; }
.dc-reader__btn--next { right: 8px; }

/* ===== 進捗メーター ===== */
.dc-reader__progress-meter {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 12px;
  background: transparent;
  z-index: 10;
  padding: 4px 0;
}
.dc-reader__progress-meter::before {
  content: '';
  position: absolute;
  left: 0; right: 0;
  top: 50%;
  transform: translateY(-50%);
  height: 4px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
  pointer-events: none;
}
.dc-reader__progress-fill {
  position: relative;
  height: 4px;
  background: #ff6b35;
  width: 0%;
  transition: width 0.2s ease;
  border-radius: 2px;
  margin-top: 4px;
  pointer-events: none;
}
/* 縦読み時は右側に縦メーター */
.dc-reader--vertical .dc-reader__progress-meter {
  top: 44px; bottom: auto; right: 0; left: auto;
  width: 4px;
  height: calc(100% - 44px);
  padding: 0;
}
.dc-reader--vertical .dc-reader__progress-meter::before {
  width: 100%;
  height: 100%;
  top: 0;
  transform: none;
}
.dc-reader--vertical .dc-reader__progress-fill {
  width: 100%;
  height: 0%;
  transition: height 0.2s ease;
  margin-top: 0;
}

/* ===== CTA(立ち読み終了) ===== */
.dc-reader__cta {
  text-align: center;
  padding: 2rem 1.5rem;
  max-width: 480px;
  margin: auto;
}
.dc-reader__cta-title {
  font-size: 1.4rem;
  margin: 0 0 1rem;
  color: #fff;
}
.dc-reader__cta-msg {
  margin: 0 0 1.5rem;
  color: #ccc;
  font-size: 0.95rem;
}
.dc-reader__cta-btn {
  display: inline-block;
  background: #ff6b35;
  color: #fff;
  padding: 0.8rem 2rem;
  border-radius: 4px;
  text-decoration: none;
  font-weight: 600;
  margin-bottom: 1rem;
  transition: background 0.15s ease;
}
.dc-reader__cta-btn:hover { background: #e55a25; }
.dc-reader__cta-back {
  display: block;
  margin: 0.5rem auto 0;
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #ccc;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
}
.dc-reader__cta-back:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* ===== ローディング・エラー ===== */
.dc-reader__loading,
.dc-reader__error {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #eee;
  font-size: 0.95rem;
  padding: 2rem;
  text-align: center;
}
.dc-reader__error { color: #ff6b6b; }

/* ===== スマホ ===== */
@media (max-width: 768px) {
  .dc-reader__btn { display: none; } /* スマホはタップで操作 */
  .dc-reader__toolbar { padding: 4px 8px; }
  .dc-reader__toolbtn,
  .dc-reader__page-count { font-size: 0.75rem; padding: 4px 8px; }
}

/* ===== v0.12.3a: 縦読みのページ間隙間 + CTA表示 ===== */
.dc-reader__page-img--vertical {
  margin-bottom: 8px;  /* ページとページの間隙 */
}
.dc-reader__cta-vertical-slot {
  width: 100%;
  max-width: 800px;
  margin: 24px auto 60px;
  padding: 24px;
  background: #2a2a2a;
  border-radius: 8px;
  color: #eee;
  text-align: center;
}

/* viewer-header の縦読みモード時、ツールバーは page-read.php 側で管理 */
body.dc-reader--vertical .dc-reader__toolbar { display: none; }

/* スマホでは画像はみ出し防止 */
@media (max-width: 768px) {
  .dc-reader__page-img--vertical {
    width: 100%;
    max-width: 100% !important;
  }
}

/* ===== v0.12.3b: 画像保存防止 — body 全体での補助 ===== */
body.dc-reader-page {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
body.dc-reader-page img {
  -webkit-user-drag: none !important;
  user-drag: none !important;
  -webkit-touch-callout: none !important;
  pointer-events: none !important;
}
/* テキスト要素(CTA / トースト等)は選択を許可 */
body.dc-reader-page .dc-reader__cta,
body.dc-reader-page .viewer-gate {
  -webkit-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
  user-select: text;
}

/* ===== v0.12.5g: ローディング進捗バー ===== */
.dc-reader__loading,
.dc-reader__error {
  flex-direction: column;
  gap: 1rem;
}
.dc-reader__loading-bar {
  width: 240px;
  height: 6px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
  overflow: hidden;
}
.dc-reader__loading-bar-fill {
  height: 100%;
  background: #ff6b35;
  width: 0%;
  transition: width 0.2s ease;
  border-radius: 3px;
}
.dc-reader__spinner {
  /* 旧スピナー(縦読み準備中などで使用) */
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: #ff6b35;
  border-radius: 50%;
  animation: dc-reader-spin 0.8s linear infinite;
}
@keyframes dc-reader-spin {
  to { transform: rotate(360deg); }
}
.dc-reader__loading-msg {
  margin: 0;
  color: #eee;
  font-size: 0.9rem;
  letter-spacing: 0.05em;
  font-variant-numeric: tabular-nums;
}
.dc-reader__loading-inline {
  width: 100%;
  text-align: center;
  padding: 2rem;
  color: #aaa;
  font-size: 0.85rem;
}

/* ========================================================================
   v0.12.4a: 読了ページ — 白背景カードデザイン
   ======================================================================== */
.dc-reader__stage--cta {
  align-items: flex-start !important;
  justify-content: center !important;
  overflow-y: auto;
  padding: 24px 16px 60px;
}
.dc-reader--vertical .dc-reader__cta-vertical-slot {
  background: transparent;
  padding: 24px 0 0;
}

.dc-endpage {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  background: #ffffff;
  color: #1f2933;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 24px 20px;
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

.dc-endpage__title {
  font-size: 1.4rem;
  margin: 0;
  text-align: center;
  color: #1f2933;
  font-weight: 700;
}
.dc-endpage__msg {
  margin: 0;
  text-align: center;
  color: #555;
  font-size: 0.9rem;
}

.dc-endpage__h3 {
  font-size: 0.95rem;
  margin: 0 0 10px;
  color: #1f2933;
  padding-bottom: 6px;
  border-bottom: 1px solid #e3e8ee;
  font-weight: 700;
}

/* === 今読んでいた作品 === */
.dc-endpage__current {
  display: flex;
  gap: 14px;
  background: #f7f9fa;
  padding: 14px;
  border-radius: 8px;
  align-items: flex-start;
}
.dc-endpage__current-cover {
  width: 100px;
  height: auto;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  flex: 0 0 100px;
  border: 2px solid #333;
  border-radius: 4px;
}
.dc-endpage__current-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.dc-endpage__current-title {
  font-size: 1rem;
  font-weight: 700;
  margin: 0;
  color: #1f2933;
}
.dc-endpage__current-sub {
  font-size: 0.85rem;
  margin: 0;
  color: #555;
}

/* 配信ストアトリガー(current/latest 共通) */
.dc-endpage__store-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  margin-top: 4px;
  background: #ffffff;
  border: 1px solid #1f2933;
  color: #1f2933;
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  align-self: flex-start;
}
.dc-endpage__store-trigger:hover {
  background: #1f2933;
  color: #fff;
}

/* === ストアモーダル === */
.dc-endpage__store-modal {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.dc-endpage__store-modal[hidden] { display: none; }
.dc-endpage__store-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.6);
}
.dc-endpage__store-modal-dialog {
  position: relative;
  background: #fff;
  color: #1f2933;
  border-radius: 8px;
  padding: 20px;
  max-width: 480px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
}
.dc-endpage__store-modal-dialog h4 {
  margin: 0 0 12px;
  text-align: center;
  font-size: 1rem;
  font-weight: 700;
}
.dc-endpage__store-modal-close {
  position: absolute;
  top: 8px; right: 12px;
  background: none;
  border: none;
  color: #1f2933;
  font-size: 1.4rem;
  cursor: pointer;
}

/* === 次の話/巻 === */
.dc-endpage__next-card {
  display: flex;
  gap: 12px;
  background: #ff6b35;
  color: #fff !important;
  padding: 12px;
  border-radius: 8px;
  text-decoration: none;
  transition: background 0.15s ease;
}
.dc-endpage__next-card:hover { background: #e55a25; }
.dc-endpage__next-card--trial {
  background: #1f2933;
}
.dc-endpage__next-card--trial:hover { background: #1a1a1a; }
.dc-endpage__next-thumb {
  width: 80px;
  height: auto;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  flex: 0 0 80px;
  border-radius: 4px;
}
.dc-endpage__next-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
}
.dc-endpage__next-title {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
}
.dc-endpage__next-badge {
  display: inline-block;
  background: #fff;
  color: #ff6b35;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 700;
  align-self: flex-start;
}
.dc-endpage__next-badge--trial {
  color: #1f2933;
}

/* === ストアリスト(モーダル内) === */
.dc-endpage__store-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 8px;
}
.dc-endpage__store-item {
  background: #fff;
  border-radius: 4px;
  overflow: hidden;
}
.dc-endpage__store-item a {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3px;
  height: 50px;
  border: 3px solid transparent;
  border-radius: 4px;
  position: relative;
}
.dc-endpage__store-item.is-advance a {
  border-color: #ff6b35;
}
.dc-endpage__store-item img {
  max-width: 100%;
  max-height: 30px;
  object-fit: contain;
}
.dc-endpage__store-item span:not(.dc-endpage__store-badge) {
  color: #333333;
  font-size: 0.78rem;
}
.dc-endpage__store-badge {
  position: absolute;
  top: -8px;
  right: -6px;
  background: #ff6b35;
  color: #fff;
  font-size: 0.65rem;
  padding: 1px 6px;
  border-radius: 3px;
  font-weight: 700;
}

/* === 最新コミックス === */
.dc-endpage__latest-card {
  display: flex;
  gap: 14px;
  background: #f7f9fa;
  padding: 14px;
  border-radius: 8px;
  align-items: flex-start;
}
.dc-endpage__latest-thumb {
  width: 100px;
  height: auto;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  flex: 0 0 100px;
  border-radius: 4px;
}
.dc-endpage__latest-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 6px;
}
.dc-endpage__latest-title {
  margin: 0;
  font-weight: 700;
  color: #1f2933;
  font-size: 0.95rem;
}
.dc-endpage__latest-status {
  margin: 0;
  color: #ff6b35;
  font-size: 0.85rem;
  font-weight: 600;
}

/* === アクションボタン === */
.dc-endpage__actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}
.dc-endpage__action {
  background: #fff;
  border: 1px solid #d0d4d8;
  color: #1f2933;
  padding: 8px 14px;
  border-radius: 4px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.dc-endpage__action:hover:not(:disabled) {
  background: #f0f0f0;
}
.dc-endpage__action:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* === シェアモーダル === */
.dc-endpage__share-modal {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.dc-endpage__share-modal[hidden] { display: none; }
.dc-endpage__share-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.6);
}
.dc-endpage__share-dialog {
  position: relative;
  background: #fff;
  color: #1f2933;
  border-radius: 8px;
  padding: 20px;
  max-width: 320px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.dc-endpage__share-dialog h4 {
  margin: 0 0 8px;
  text-align: center;
  font-size: 1rem;
}
.dc-endpage__share-close {
  position: absolute;
  top: 8px; right: 12px;
  background: none;
  border: none;
  color: #1f2933;
  font-size: 1.4rem;
  cursor: pointer;
}
.dc-endpage__share-btn {
  display: block;
  text-align: center;
  padding: 10px;
  background: #444;
  color: #fff;
  border-radius: 4px;
  text-decoration: none;
  font-weight: 600;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
}
.dc-endpage__share-btn--x { background: #333; }
.dc-endpage__share-btn--line { background: #00b900; }
.dc-endpage__share-btn--copy { background: #555; }
.dc-endpage__share-btn:hover { opacity: 0.85; }

/* === レーベル === */
.dc-endpage__label {
  text-align: center;
}
.dc-endpage__label-link {
  display: inline-block;
  text-decoration: none;
  color: #555;
  font-size: 0.85rem;
}
.dc-endpage__label-link img {
  max-height: 36px;
  width: auto;
  vertical-align: middle;
}

/* === おすすめ作品 === */
.dc-endpage__rec-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.dc-endpage__rec-item {
  background: #f7f9fa;
  border-radius: 6px;
  overflow: hidden;
  text-decoration: none;
  color: #1f2933;
  display: flex;
  flex-direction: column;
}
.dc-endpage__rec-item img {
  width: 100%;
  height: auto;
  display: block;
}
.dc-endpage__rec-item p {
  margin: 0;
  padding: 8px;
  font-size: 0.78rem;
  text-align: center;
}
@media (min-width: 768px) {
  .dc-endpage__rec-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* === フッター === */
.dc-endpage__footer {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
  align-items: center;
}
.dc-reader__cta-back {
  background: #fff;
  border: 1px solid #1f2933;
  color: #1f2933;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
}
.dc-reader__cta-back:hover {
  background: #1f2933;
  color: #fff;
}

/* v0.12.5a: 読了ページ NO IMAGE フォールバック */
.dc-endpage__no-image {
  background: #e3e8ee;
  color: #888;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  border-radius: 4px;
  /* 元の dc-endpage__*-cover/thumb クラスの aspect-ratio を活用 */
}

/* v0.12.5d: 読了ページ コミックス最新刊の NEW リボン(斜め) */
.dc-endpage__latest-thumb-wrap {
  position: relative;
  flex: 0 0 100px;
  overflow: hidden;
}
.dc-endpage__latest-ribbon {
  position: absolute;
  top: 8px;
  left: -25px;
  background: #ff6b35;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 2px 25px;
  transform: rotate(-45deg);
  transform-origin: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  z-index: 2;
  text-align: center;
  line-height: 1.2;
}
.dc-endpage__latest-thumb-wrap .dc-endpage__latest-thumb {
  flex: none;
}

/* v0.12.5f: 読了ページ 会員限定ラベル */
.dc-endpage__next-members,
.dc-endpage__latest-members {
  display: inline-block;
  background: #f9f0fc;
  color: #6a2480;
  border: 1px solid #d8b4e8;
  padding: 2px 8px;
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: 4px;
  align-self: flex-start;
  margin: 2px 0;
}
.dc-endpage__next-card--trial .dc-endpage__next-members {
  background: rgba(255,255,255,0.95);
  color: #6a2480;
}
