/* ==========================================================================
   MOBILE & TABLET READER RESPONSIVE OVERRIDES
   ========================================================================== */

@media (max-width: 640px) {
  /* 状态栏遮罩：正文滚到顶部时被裁剪，绝不与时间/WiFi 图标重叠 */
  .reader-status-mask {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: env(safe-area-inset-top, 0px);
    z-index: 48;
    background: var(--reader-bg);
    pointer-events: none;
  }
  .comic-status-mask {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: env(safe-area-inset-top, 0px);
    z-index: 58;
    background: #000;
    pointer-events: none;
  }

  /* 顶栏整体放在安全区下方、紧贴时钟，消除大空隙；配色与正文底色一致 */
  .reader-top,
  .reader-bottom-nav {
    background: var(--reader-bg);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    transform: translateZ(0);
  }

  .reader-top {
    top: env(safe-area-inset-top, 0px);
    height: 46px;
    padding: 0 8px;
    gap: 4px;
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease;
  }

  .reader-top.mobile-nav-hidden {
    transform: translateY(-100%);
    opacity: 0;
    pointer-events: none;
  }

  .reader-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    /* 高度必须包含底部安全区，否则 PWA 下内容区被 Home 条挤压 */
    height: calc(56px + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0);
    z-index: 50;
    background: var(--reader-bg);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    transform: translateZ(0);
    border-top: 1px solid var(--rchrome-line);
    display: flex;
    align-items: center;
    justify-content: space-around;
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4);
  }

  .reader-bottom-nav.mobile-nav-hidden {
    transform: translateY(100%);
    opacity: 0;
    pointer-events: none;
  }

  .bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    flex: 1;
    height: 100%;
    background: transparent;
    border: none;
    color: var(--rchrome-ink-2);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.15s ease, transform 0.15s ease;
  }
  .bottom-nav-item:active {
    transform: scale(0.92);
    color: var(--accent-gold);
  }
  .bottom-nav-item span {
    font-size: 10.5px;
  }

  .reader-top__title {
    max-width: 38vw;
    font-size: 12.5px;
    gap: 3px;
  }

  .reader-top__title .top-prog-pct {
    display: none;
  }

  .reader-ic {
    height: 32px;
    min-width: 32px;
    padding: 0 6px;
  }

  .reader-content {
    padding: calc(60px + env(safe-area-inset-top, 0px)) 16px calc(100px + env(safe-area-inset-bottom, 0px));
  }

  /* 显式像素图标尺寸：不依赖 Tailwind JIT，PWA 独立窗口下也稳定 */
  .bottom-nav-item svg { width: 22px; height: 22px; }
  .reader-ic svg { width: 21px; height: 21px; }

  .reader-chap {
    font-size: 21px;
    margin: 14px 0 6px 0;
    text-align: center;
  }

  .reader-meta {
    margin: 6px 0 22px;
    font-size: 12px;
    justify-content: center;
  }

  .toc-dropdown-backdrop {
    padding: 30px 10px 16px 10px;
    align-items: center;
  }

  .toc-popover-card {
    max-height: 84vh;
    border-radius: 18px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.85);
  }

  .rc-row {
    padding: 10px 14px;
    min-height: 44px;
    box-sizing: border-box;
    border-radius: 10px;
    font-size: 13.5px;
    display: flex;
    align-items: center;
  }

  .rc-row__nm {
    font-size: 13.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    flex: 1 1 auto;
    min-width: 0;
  }

  .drawer-content {
    max-width: 100%;
    padding: 20px 16px;
  }

  .reader-progress {
    display: none !important;
  }
}
