/* ============================================================
   漫画阅读模式 —— 仅作用于 /novel/*-comic/ 的阅读页
   竖向长滚动 + 惰性加载,深色底更适合看图
   ============================================================ */

body.cm-on {
  --cm-w: 860px;
  --cm-bg: #14151a;
  --cm-accent: #6576c5;
}

body.cm-on .md-main,
body.cm-on .md-content {
  background: var(--cm-bg);
}

body.cm-on .md-content {
  max-width: none;
}

body.cm-on .md-content__inner {
  max-width: var(--cm-w);
  margin: 0 auto;
  padding: 0;
  background: transparent;
  box-shadow: none;
}

/* 隐藏正文页的标题和锚点(阅读时不占空间) */
body.cm-on .md-content__inner > h1 {
  display: none;
}

body.cm-on .headerlink {
  display: none;
}

/* ---------- 图片条 ---------- */
.cm-strip {
  margin: 0 auto;
  padding: 0;
  line-height: 0;
}

.cm-img {
  display: block;
  width: 100%;
  height: auto;
  margin: 0;
  padding: 0;
  border: 0;
  background: #1c1d24;
}

.cm-img:not([complete]) {
  min-height: 40px;
}

/* ---------- 顶部信息条 ---------- */
.cm-head {
  position: sticky;
  top: 0;
  z-index: 900;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: rgba(20, 21, 26, .92);
  backdrop-filter: blur(6px);
  color: #b9bcc6;
  font-size: 13px;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
}

.cm-head .cm-vol {
  color: #8f97c9;
  font-weight: 600;
}

.cm-head .cm-ch {
  color: #e6e8ef;
  font-weight: 600;
}

.cm-head .cm-count {
  margin-left: auto;
  color: #7c8090;
}

/* 返回目录 —— 移动端主要入口 */
.cm-head .cm-back {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: rgba(101, 118, 197, .22);
  color: #cfd4f0 !important;
  text-decoration: none !important;
  font-size: 15px;
  line-height: 1;
}

.cm-head .cm-back:hover {
  background: #6576c5;
  color: #fff !important;
}

#cm-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0;
  background: linear-gradient(90deg, #6576c5, #9aa7e0);
  z-index: 1200;
  transition: width .08s linear;
  pointer-events: none;
}

/* ---------- 悬浮控制台 ---------- */
#cm-bar {
  position: fixed;
  right: 20px;
  bottom: 24px;
  z-index: 1200;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#cm-bar button,
#cm-bar a {
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 50%;
  background: rgba(48, 50, 62, .92);
  color: #dfe1e8;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 3px 14px rgba(0, 0, 0, .4);
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none !important;
  transition: transform .12s ease, background .12s ease;
}

#cm-bar button:hover,
#cm-bar a:hover {
  transform: translateY(-2px);
  background: #3d4050;
}

#cm-bar button:disabled {
  opacity: .35;
  cursor: default;
  transform: none;
}

#cm-page {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  background: rgba(30, 32, 40, .9);
  color: #cfd2dc;
  padding: 7px 16px;
  border-radius: 20px;
  font-size: 13px;
  z-index: 1200;
  pointer-events: none;
  transition: opacity .3s ease;
}

#cm-page.cm-hide {
  opacity: 0;
}

/* ---------- 话末导航 ---------- */
.cm-foot {
  max-width: var(--cm-w);
  margin: 0 auto;
  padding: 26px 16px 90px;
  text-align: center;
}

.cm-foot .cm-links {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.cm-foot a {
  display: inline-block;
  padding: 10px 22px;
  border-radius: 999px;
  background: #2b2e3a;
  color: #dfe1e8 !important;
  text-decoration: none !important;
  font-size: 14px;
  transition: background .15s ease;
}

.cm-foot a:hover {
  background: var(--cm-accent);
}

/* ---------- 目录页(书架/册目录) ---------- */
.cm-shelf {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
  margin: 20px 0;
}

.cm-shelf a {
  display: block;
  padding: 16px 14px;
  border-radius: 12px;
  background: linear-gradient(140deg, #f2f4fd 0%, #e8ecfb 100%);
  border: 1px solid #dde2f5;
  text-decoration: none !important;
  color: #41477a;
  text-align: center;
  transition: transform .16s ease, box-shadow .16s ease;
}

.cm-shelf a:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 24px rgba(101, 118, 197, .18);
}

.cm-shelf .cm-vno {
  display: block;
  font-size: 21px;
  font-weight: 700;
  color: #6576c5;
}

.cm-shelf .cm-vmeta {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: #8a8fa8;
}

.cm-cover {
  max-width: 300px;
  margin: 0 0 20px;
  border-radius: 10px;
  box-shadow: 0 6px 24px rgba(60, 70, 120, .18);
}

/* ============================================================
   移动端优化
   ============================================================ */
@media (max-width: 76.25em) {
  body.cm-on .md-content__inner {
    max-width: none;
  }

  /* 触摸目标放大到 48px,并避让 iPhone 手势条/刘海 */
  #cm-bar {
    right: 12px;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  }

  #cm-bar button,
  #cm-bar a {
    width: 48px;
    height: 48px;
    font-size: 18px;
  }

  .cm-head {
    padding: calc(8px + env(safe-area-inset-top, 0px)) 12px 8px;
    font-size: 12.5px;
    gap: 8px;
  }

  .cm-head .cm-back {
    width: 40px;
    height: 40px;
    font-size: 17px;
  }

  #cm-page {
    bottom: calc(76px + env(safe-area-inset-bottom, 0px));
    font-size: 12px;
    padding: 6px 14px;
  }

  .cm-foot {
    padding-bottom: calc(100px + env(safe-area-inset-bottom, 0px));
  }

  /* 图片禁掉点击高亮与长按菜单,读图更顺 */
  .cm-img {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    user-select: none;
  }
}

/* 极窄屏:悬浮栏横排,减少遮挡 */
@media (max-width: 30em) {
  #cm-bar {
    flex-direction: row;
    right: 10px;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }
}

/* 横屏看单页:限制高度,避免图片被拉得过大 */
@media (max-width: 76.25em) and (orientation: landscape) {
  .cm-img {
    max-height: 92vh;
    width: auto;
    margin: 0 auto;
  }
}
