/* ============================================================
   沉浸阅读模式 —— 仅作用于 /novel/ 下的章节页(JS 加 body.nr-on)
   设计延续书房视觉:长春花蓝 #6576c5
   ============================================================ */

body.nr-on {
  --nr-fs: 18px;
  --nr-lh: 1.95;
  --nr-w: 42rem;
  --nr-bg: #ffffff;
  --nr-fg: #2b2b33;
  --nr-dim: #8a8a99;
  --nr-accent: #6576c5;
  --nr-shadow: 0 2px 20px rgba(101, 118, 197, .10);
}

body.nr-on[data-nr-theme="sepia"] {
  --nr-bg: #f7f1e3;
  --nr-fg: #4a3f2f;
  --nr-dim: #9a8b73;
  --nr-shadow: 0 2px 20px rgba(120, 100, 60, .12);
}

body.nr-on[data-nr-theme="night"] {
  --nr-bg: #1b1c21;
  --nr-fg: #c3c5cd;
  --nr-dim: #6d7078;
  --nr-shadow: 0 2px 20px rgba(0, 0, 0, .5);
  background: #131418;
}

/* ---------- 版心 ---------- */
body.nr-on .md-content {
  max-width: var(--nr-w);
  margin: 0 auto;
}

body.nr-on .md-content__inner {
  background: var(--nr-bg);
  padding: 2.4rem 2.6rem 3.2rem;
  border-radius: 14px;
  box-shadow: var(--nr-shadow);
  transition: background .25s ease, color .25s ease;
}

/* ---------- 正文排版:中文小说式样 ---------- */
body.nr-on .md-content__inner > p,
body.nr-on .md-content__inner > div > p {
  font-size: var(--nr-fs);
  line-height: var(--nr-lh);
  color: var(--nr-fg);
  text-indent: 2em;
  margin: 0.85em 0;
  letter-spacing: .01em;
}

body.nr-on .md-content__inner > p.nr-restored {
  animation: nr-flash 1.2s ease;
}

@keyframes nr-flash {
  0% { background: rgba(101, 118, 197, .18); }
  100% { background: transparent; }
}

body.nr-on .md-content__inner > h1 {
  font-size: calc(var(--nr-fs) * 1.55);
  font-weight: 700;
  color: var(--nr-fg);
  margin: 0 0 1.6rem;
  padding-bottom: .8rem;
  border-bottom: 2px solid var(--nr-accent);
  text-indent: 0;
}

body.nr-on[data-nr-theme="night"] .md-content__inner > h1 {
  border-bottom-color: #3a3d47;
}

body.nr-on .md-content__inner blockquote,
body.nr-on .md-content__inner li {
  font-size: var(--nr-fs);
  line-height: var(--nr-lh);
  color: var(--nr-fg);
}

body.nr-on .md-content__inner a {
  color: var(--nr-accent);
}

/* ---------- 顶部进度条 ---------- */
body.nr-on .headerlink {
  display: none;
}

#nr-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;
}

/* ---------- 悬浮控制台 ---------- */
#nr-bar {
  position: fixed;
  right: 12px;
  bottom: calc(70px + env(safe-area-inset-bottom, 0px));
  z-index: 1160;
  width: min(324px, calc(100vw - 24px));
}

#nr-bar button,
#nr-bar a {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: #fff;
  color: #4a4f66;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 3px 12px rgba(60, 70, 120, .18);
  transition: transform .12s ease, background .12s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none !important;
}

#nr-bar button:hover,
#nr-bar a:hover {
  transform: translateY(-2px);
  background: #f0f2fb;
}

#nr-bar button:active {
  transform: scale(.94);
}

#nr-panel {
  display: none;
  background: #fff;
  border-radius: 14px;
  padding: 14px 16px;
  width: 232px;
  box-shadow: 0 8px 30px rgba(50, 60, 110, .22);
  font-size: 13px;
  color: #3c4257;
}

#nr-panel.nr-open {
  display: block;
}

#nr-panel .nr-row {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 9px 0;
}

#nr-panel .nr-row > span:first-child {
  flex: 0 0 34px;
  color: #8a8fa8;
}

#nr-panel input[type="range"] {
  flex: 1;
  accent-color: #6576c5;
}

#nr-panel .nr-themes {
  display: flex;
  gap: 7px;
  margin-top: 4px;
}

#nr-panel .nr-themes button {
  flex: 1;
  height: 30px;
  width: auto;
  border-radius: 8px;
  font-size: 12.5px;
  box-shadow: none;
  border: 1px solid #e2e5f0;
}

#nr-panel .nr-themes button.nr-sel {
  background: #6576c5;
  color: #fff;
  border-color: #6576c5;
}

#nr-tip {
  position: fixed;
  left: 50%;
  bottom: 30px;
  transform: translateX(-50%) translateY(20px);
  background: rgba(40, 45, 65, .92);
  color: #fff;
  padding: 9px 18px;
  border-radius: 22px;
  font-size: 13.5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s ease, transform .3s ease;
  z-index: 1200;
}

#nr-tip.nr-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---------- 暗色主题下的侧栏和谐化 ---------- */
body.nr-on[data-nr-theme="night"] .md-main {
  background: #131418;
}

body.nr-on[data-nr-theme="night"] #nr-bar button {
  background: #262832;
  color: #c3c5cd;
}

body.nr-on[data-nr-theme="night"] #nr-bar button:hover {
  background: #32353f;
}

body.nr-on[data-nr-theme="night"] #nr-panel {
  background: #262832;
  color: #c3c5cd;
}

body.nr-on[data-nr-theme="night"] #nr-panel .nr-themes button {
  background: #2f323c;
  border-color: #3a3d47;
  color: #c3c5cd;
}

body.nr-on[data-nr-theme="night"] #nr-panel .nr-themes button.nr-sel {
  background: #6576c5;
  color: #fff;
}

body.nr-on[data-nr-theme="night"] #nr-panel input[type="range"] {
  accent-color: #9aa7e0;
}

/* ---------- 窄屏 ---------- */
@media (max-width: 76.25em) {
  body.nr-on .md-content__inner {
    padding: 1.6rem 1.2rem 2.4rem;
    border-radius: 0;
  }
  /* 移动端:触摸目标放大到 48px,并避让 iPhone 底部手势条 */
  #nr-bar {
  position: fixed;
  right: 12px;
  bottom: calc(70px + env(safe-area-inset-bottom, 0px));
  z-index: 1160;
  width: min(324px, calc(100vw - 24px));
}
  #nr-bar button,
  #nr-bar a {
    width: 48px;
    height: 48px;
    font-size: 19px;
  }
  #nr-panel {
    width: min(78vw, 260px);
  }
  body.nr-on .md-content__inner > p,
  body.nr-on .md-content__inner > div > p {
    text-indent: 1.6em;
  }
}

/* 极窄屏:工具栏改为横向一排,避免遮挡正文 */
@media (max-width: 30em) {
  #nr-bar {
  position: fixed;
  right: 12px;
  bottom: calc(70px + env(safe-area-inset-bottom, 0px));
  z-index: 1160;
  width: min(324px, calc(100vw - 24px));
}
  #nr-panel {
    position: absolute;
    right: 0;
    bottom: 56px;
    width: min(88vw, 280px);
  }
}

/* ---------- 目录页的小说卡片 ---------- */
.nr-shelf {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  margin: 20px 0;
}

.nr-book {
  display: block;
  padding: 18px 20px;
  border-radius: 14px;
  background: linear-gradient(140deg, #f2f4fd 0%, #e8ecfb 100%);
  border: 1px solid #dde2f5;
  text-decoration: none !important;
  transition: transform .16s ease, box-shadow .16s ease;
}

.nr-book:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 26px rgba(101, 118, 197, .18);
}

.nr-book h3 {
  margin: 0 0 6px;
  color: #41477a;
  font-size: 17px;
}

.nr-book p {
  margin: 0;
  color: #7b81a0;
  font-size: 13.5px;
  line-height: 1.6;
}

/* ---------- 目录页的「返回」导航条(小说/漫画通用) ---------- */
.nv-parts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
  gap: 10px;
  margin: 0 0 22px;
}

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

.nv-parts a:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(101, 118, 197, .17);
}

.nv-parts strong {
  display: block;
  font-size: 13.5px;
  color: #3d437a;
  font-weight: 600;
}

.nv-parts span {
  display: block;
  margin-top: 3px;
  font-size: 12px;
  color: #8a8fa8;
}

/* 章节网格:紧凑多列,一屏看全 */
.nv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(196px, 1fr));
  gap: 2px 14px;
  margin: 10px 0 4px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #fafbff;
  border: 1px solid #edf0fa;
}

.nv-grid a {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 13.5px;
  line-height: 1.5;
  color: #33406b !important;
  text-decoration: none !important;
  transition: background .12s ease, color .12s ease;
}

.nv-grid a:hover {
  background: #e9edfc;
  color: #2b3568 !important;
}

.nv-grid a i {
  flex: 0 0 auto;
  min-width: 21px;
  font-style: normal;
  font-size: 11.5px;
  color: #9aa0bd;
  font-variant-numeric: tabular-nums;
}

.nv-grid a:hover i {
  color: #6576c5;
}

/* ---------- 章节页底部常驻导航条(长章节快速回退) ---------- */
#nr-dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1150;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px calc(8px + env(safe-area-inset-bottom, 0px));
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(8px);
  border-top: 1px solid #e6e9f5;
  font-size: 13px;
  box-shadow: 0 -2px 14px rgba(60, 70, 120, .07);
}

body[data-nr-theme="night"] #nr-dock {
  background: rgba(27, 28, 33, .95);
  border-top-color: #2f323c;
  box-shadow: 0 -2px 14px rgba(0, 0, 0, .4);
}

#nr-dock a,
#nr-dock button {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  padding: 0 12px;
  border: none;
  border-radius: 10px;
  background: #eef1fb;
  color: #4c5cab !important;
  font-size: 14px;
  text-decoration: none !important;
  cursor: pointer;
}

#nr-dock a:hover,
#nr-dock button:hover {
  background: #6576c5;
  color: #fff !important;
}

#nr-dock .nr-dock-info {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

#nr-dock .nr-dock-title {
  font-size: 12.5px;
  color: #6b7285;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

body[data-nr-theme="night"] #nr-dock .nr-dock-title {
  color: #9b9eab;
}

#nr-dock .nr-dock-bar {
  height: 4px;
  border-radius: 3px;
  background: #e6e9f5;
  overflow: hidden;
}

body[data-nr-theme="night"] #nr-dock .nr-dock-bar {
  background: #33363f;
}

#nr-dock .nr-dock-bar > i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #6576c5, #9aa7e0);
  transition: width .1s linear;
}

body.nr-on {
  padding-bottom: 62px;
}

.cm-navbar {
  margin: 0 0 16px;
}

.cm-navbar a {
  display: inline-block;
  padding: 9px 18px;
  border-radius: 999px;
  background: #eef1fb;
  color: #4c5cab !important;
  text-decoration: none !important;
  font-size: 13.5px;
  border: 1px solid #dde2f5;
  transition: background .15s ease, color .15s ease;
}

.cm-navbar a:hover {
  background: #6576c5;
  border-color: #6576c5;
  color: #fff !important;
}

@media (max-width: 76.25em) {
  .cm-navbar a {
    padding: 11px 20px;
    font-size: 14px;
  }
}

/* 窄屏:底栏只留图标,节省横向空间 */
@media (max-width: 30em) {
  #nr-dock .nr-txt { display: none; }
  #nr-dock a, #nr-dock button { min-width: 38px; padding: 0 9px; }
}

/* ---------- 底栏避让:把主题自带的浮动元素抬到控制条之上 ---------- */
/* Material 的「回到页面顶部」按钮默认固定在右下角,会和底栏的翻页键重叠 */
body.nr-on .md-top {
  bottom: calc(76px + env(safe-area-inset-bottom, 0px)) !important;
  right: 14px !important;
}

/* 设置面板默认收起,避免遮挡正文 */
#nr-panel {
  display: none;
}

#nr-panel.nr-open {
  display: block;
}
