* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(180deg, #f5f7fb 0%, #edf2f9 100%);
    color: #1f2937;
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
    -webkit-text-size-adjust: 100%;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
    opacity: 0.025;
    pointer-events: none;
    z-index: -1;
}

.site-header {
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid rgba(15, 23, 42, 0.06);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    white-space: nowrap;
}

.logo {
    flex-shrink: 1;
    min-width: 0;
    display: inline-flex;
    align-items: center;
    /* 窄屏兜底：允许 logo 收缩，防止 header 整体横向溢出 */
    max-width: 38%;
}

.logo img {
    height: 40px;
    width: auto;
    /* 宽度自适应收缩：窄屏时按容器压缩，保持宽高比不变形 */
    max-width: 100%;
    max-height: 40px;
    /* 默认隐藏，避免加载失败时闪烁 broken icon */
    opacity: 0;
    transition: opacity 0.15s ease;
}
.logo img[data-loaded="1"] {
    opacity: 1;
}

/* PJAX 加载过渡 */
.pjax-loading .site-main {
    opacity: 0.4;
    pointer-events: none;
    transition: opacity 0.15s ease;
}
.site-main {
    transition: opacity 0.2s ease;
}

/* 页面跳转全屏加载遮罩（与漫画详情页 comic-page-loading 一致：白底 + 蓝色转圈 + 文字） */
.page-nav-loading {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: #ffffff;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
}
.page-nav-loading.show {
    display: flex;
}
.page-nav-loading .spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e2e8f0;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: nav-spin 0.8s linear infinite;
}
.page-nav-loading .loading-text {
    font-size: 12px;
    color: #6b7280;
}
@keyframes nav-spin {
    from { transform: rotate(0); }
    to { transform: rotate(360deg); }
}

.main-nav {
    display: flex;
    gap: 24px;
}

.nav-item {
    color: #64748b;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: color 0.3s ease;
    position: relative;
}

.nav-item:hover,
.nav-item.active {
    color: #2563eb;
}

.nav-item.active::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 100%;
    height: 2px;
    background: #2563eb;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.search-input {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    padding: 8px 16px;
    color: #1f2937;
    font-size: 14px;
    width: 220px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.search-input:hover {
    border-color: #cbd5e1;
}

.search-input:focus {
    outline: none;
    border-color: #2563eb;
    background: #fff;
    cursor: text;
}

.search-input::placeholder {
    color: #9aa3b2;
}

/* 漫画/小说切换（默认 PC 隐藏，仅移动端显示） */
.domain-toggle {
    display: none;
    align-items: center;
    gap: 2px;
    padding: 3px;
    background: #f1f5f9;
    border-radius: 999px;
    flex-shrink: 0;
}

.domain-toggle-item {
    padding: 5px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    color: #64748b;
    text-decoration: none;
    white-space: nowrap;
    transition: all 0.3s ease;
}

.domain-toggle-item:hover {
    color: #2563eb;
}

.domain-toggle-item.active {
    background: #2563eb;
    color: #fff;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.35);
}

.site-main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 12px 12px 50px;
}

.site-footer {
    background: rgba(255, 255, 255, 0.92);
    border-top: 1px solid rgba(15, 23, 42, 0.06);
    margin-top: 16px;
}

.footer-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 16px 24px;
    text-align: center;
}

.copyright {
    color: #94a3b8;
    font-size: 13px;
    margin-bottom: 8px;
}

.icp-number {
    color: #a5b0c0;
    font-size: 12px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.section-title {
    font-size: 20px;
    font-weight: 600;
    color: #1f2937;
    position: relative;
    padding-left: 12px;
}

.section-title::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 20px;
    background: #2563eb;
}

.more-link {
    color: #6b7280;
    text-decoration: none;
    font-size: 14px;
    transition: color 0.3s ease;
}

.more-link:hover {
    color: #2563eb;
}

.comic-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px;
}

.comic-card {
    background: #ffffff;
    border-radius: 4px;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.3s ease;
    border: 1px solid #e9edf3;
    min-width: 0;
}

.comic-card:hover {
    border-color: rgba(37, 99, 235, 0.4);
}

.comic-cover {
    position: relative;
    padding-top: 140%;
    overflow: hidden;
    background: #f1f5f9 url('/assets/images/default_cover.png') center/cover no-repeat;
}

.comic-cover img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.comic-card:hover .comic-cover img {
    transform: scale(1.05);
}

.comic-info {
    padding: 12px;
}

.comic-title {
    font-size: 14px;
    font-weight: 500;
    color: #1f2937;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.comic-author {
    font-size: 12px;
    color: #94a3b8;
}

.comic-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.comic-row {
    display: flex;
    align-items: center;
    gap: 16px;
    background: #ffffff;
    border-radius: 4px;
    padding: 12px;
    text-decoration: none;
    color: inherit;
    transition: background 0.3s ease;
    border: 1px solid #e9edf3;
}

.comic-row:hover {
    background: #f8fafc;
    border-color: rgba(37, 99, 235, 0.2);
}

.rank-num {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 2px;
    font-size: 14px;
    font-weight: 600;
    background: #f1f5f9;
    color: #94a3b8;
}

.rank-num.rank-top {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: #fff;
}

.comic-thumb {
    width: 50px;
    height: 65px;
    object-fit: cover;
    border-radius: 2px;
}

.comic-meta {
    flex: 1;
}

.comic-stats {
    font-size: 12px;
    color: #94a3b8;
    margin-top: 4px;
}

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid rgba(15, 23, 42, 0.08);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 6px 0 env(safe-area-inset-bottom, 6px);
    z-index: 200;
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    text-decoration: none;
    color: #94a3b8;
    transition: color 0.2s ease;
    padding: 4px 12px;
    min-width: 56px;
}

.bottom-nav-icon {
    font-size: 22px;
    line-height: 1;
    transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.3, 1), color 0.2s ease;
}

.bottom-nav-label {
    font-size: 10px;
    line-height: 1.2;
    transition: color 0.2s ease;
}

.bottom-nav-item.active {
    color: #2563eb;
}

.bottom-nav-item.active .bottom-nav-icon {
    transform: scale(1.25);
}

.bottom-nav-item:hover {
    color: #64748b;
}

.bottom-nav-item.active:hover {
    color: #2563eb;
}

.page-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 50vh;
    text-align: center;
    gap: 16px;
}

.placeholder-icon {
    font-size: 64px;
    color: #cbd5e1;
}

.placeholder-title {
    font-size: 20px;
    font-weight: 600;
    color: #1f2937;
}

.placeholder-desc {
    color: #94a3b8;
    font-size: 14px;
}

@media (max-width: 768px) {
    .header-inner {
        flex-wrap: nowrap;
        gap: 12px;
        padding: 12px 16px;
    }

    .main-nav {
        display: none;
    }

    .logo img {
        height: 32px;
        max-height: 32px;
    }

    .header-actions {
        flex: 1;
        justify-content: flex-end;
        gap: 8px;
    }

    .search-input {
        flex: 1;
        width: auto;
        min-width: 0;
    }

    .domain-toggle {
        display: inline-flex;
    }

    /* 超窄屏（≤360px）：进一步压缩切换按钮，配合 logo 收缩避免横向溢出 */
    @media (max-width: 360px) {
        .domain-toggle-item {
            padding: 5px 8px;
            font-size: 11px;
        }
        .logo {
            max-width: 30%;
        }
    }

    .comic-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 16px;
    }

    .hero-sidebar {
        display: none;
    }
}

/* ===== 广告位 ===== */
.ad-slot {
  display: block;
  overflow: hidden;
  text-align: center;
  margin: 12px 0;
  line-height: 0;
  /* 隔离广告内超高 z-index（外部广告脚本可能动态插入 z-index:2147483647 的元素），避免盖过顶底栏/弹窗 */
  position: relative;
  z-index: 1;
  isolation: isolate;
}

.ad-slot .ad-js-inline {
  position: relative;
  z-index: 1;
  isolation: isolate;
}

.ad-slot img.ad-img {
  max-width: 100%;
  height: auto;
  display: inline-block;
}

.ad-link {
  display: inline-block;
  line-height: 0;
  text-decoration: none;
}

/* JS 代码广告：主文档直接执行（广告商反 iframe 检测，故不用 iframe） */
.ad-js-inline {
  display: block;
  text-align: center;
  line-height: 0;
}

.ad-js-inline script {
  display: none;
}

/* ===== 统一分页 ===== */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin: 24px 0;
}

.pagination .page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 12px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #fff;
  color: #64748b;
  font-size: 13px;
  text-decoration: none;
  transition: all 0.2s;
  box-sizing: border-box;
}

.pagination .page-btn:hover {
  border-color: #2563eb;
  color: #2563eb;
  background: #eff6ff;
}

.pagination .page-btn.is-active {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}

.pagination .page-info {
  font-size: 13px;
  color: #94a3b8;
}

.pagination .page-btn.page-ellipsis {
  border: none;
  background: transparent;
  color: #94a3b8;
  cursor: default;
  min-width: 24px;
}

.pagination .page-btn.page-ellipsis:hover {
  border: none;
  background: transparent;
  color: #94a3b8;
}

/* ===== 分页手机端适配 ===== */
@media (max-width: 768px) {
  .pagination {
    flex-wrap: nowrap; /* 保持单行；窗口页码已精简(≤7个)，375px 内可完整容纳 */
    gap: 6px;
    margin: 18px 0;
    padding: 0 12px; /* 两侧留白，避免贴边 */
  }

  .pagination .page-btn {
    min-width: 34px;
    height: 32px;
    padding: 0 9px;
    font-size: 12px;
    white-space: nowrap; /* 关键：防止"上一页/下一页"文字换行竖排 */
    flex: 0 0 auto; /* 允许 shrink 时不压缩到无法容纳文字，但保持基线尺寸 */
  }

  /* 上一页/下一页在窄屏只显示文字，但去掉 min-width 依赖，按内容自适应 */
  .pagination .page-btn:first-child,
  .pagination .page-btn:last-child {
    min-width: 0;
    padding: 0 10px;
    flex: 0 0 auto;
  }
}

/* ===== 通用弹窗 showDialog（全站唯一弹窗实现，替代浏览器 alert/confirm） ===== */
.ui-dialog-mask {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.2s cubic-bezier(0.2, 0.8, 0.3, 1);
}

.ui-dialog-mask.show {
  opacity: 1;
}

.ui-dialog {
  width: 86%;
  max-width: 320px;
  background: #ffffff;
  border-radius: 8px;
  border: 1px solid #e9edf3;
  padding: 24px 20px 18px;
  text-align: center;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.16);
  opacity: 0;
  transform: translateY(12px) scale(0.96);
  transition: transform 0.26s cubic-bezier(0.18, 0.9, 0.32, 1.2), opacity 0.2s ease;
}

.ui-dialog-mask.show .ui-dialog {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.ui-dialog-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 12px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #eff6ff;
  border: 1px solid #dbeafe;
}

.ui-dialog-icon .iconify {
  font-size: 26px;
  color: #2563eb;
}

.ui-dialog-icon.is-danger {
  background: #fef2f2;
  border-color: #fee2e2;
}

.ui-dialog-icon.is-danger .iconify {
  color: #dc2626;
}

.ui-dialog-title {
  font-size: 16px;
  font-weight: 600;
  color: #1f2937;
  margin-bottom: 8px;
}

.ui-dialog-message {
  font-size: 14px;
  color: #6b7280;
  line-height: 1.6;
  margin-bottom: 20px;
  white-space: pre-line;
}

.ui-dialog-actions {
  display: flex;
  gap: 10px;
}

.ui-dialog-btn {
  flex: 1;
  border: none;
  border-radius: 6px;
  padding: 10px 0;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.18s ease;
}

.ui-dialog-btn.is-cancel {
  background: #f1f5f9;
  color: #64748b;
}

.ui-dialog-btn.is-cancel:hover {
  background: #e2e8f0;
}

.ui-dialog-btn.is-confirm {
  background: #2563eb;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.28);
}

.ui-dialog-btn.is-confirm:hover {
  background: #1d4ed8;
}

.ui-dialog-btn.is-confirm.is-danger {
  background: #dc2626;
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.28);
}

.ui-dialog-btn.is-confirm.is-danger:hover {
  background: #b91c1c;
}

