:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --text: #1f2329;
  --text-2: #646a73;
  --text-3: #8f959e;
  --border: #e8ebf0;
  --primary: #1f6feb;
  --primary-soft: #e8f1ff;
  --accent: #e8553f;
  --shadow: 0 1px 3px rgba(20, 30, 60, .06), 0 6px 18px rgba(20, 30, 60, .05);
  --radius: 12px;
  --header-h: 54px;
  --channel-h: 46px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ===== 顶部导航 ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  max-width: 800px;
  margin: 0 auto;
  background: linear-gradient(135deg, #1f6feb, #2a8a6b);
  color: #fff;
  box-shadow: 0 2px 10px rgba(20, 40, 90, .18);
}

.topbar-inner {
  max-width: 800px;
  margin: 0 auto;
  height: var(--header-h);
  padding: 0 14px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand {
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 1px;
  white-space: nowrap;
}

.brand:hover {
  text-decoration: none;
  opacity: .92;
}

.cat-nav {
  display: flex;
  margin-left: auto;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}

.cat-nav::-webkit-scrollbar {
  display: none;
}

.cat-tab {
  appearance: none;
  border: 0;
  background: rgba(255, 255, 255, .16);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  padding: 7px 16px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .18s, transform .08s;
}

.cat-tab:hover {
  background: rgba(255, 255, 255, .28);
}

.cat-tab:active {
  transform: scale(.96);
}

.cat-tab.active {
  background: #fff;
  color: var(--primary);
}

/* ===== 频道条 ===== */
.channel-bar {
  position: sticky;
  top: var(--header-h);
  z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  height: var(--channel-h);
  display: flex;
  align-items: center;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 0 12px;
  gap: 8px;
}

.channel-bar::-webkit-scrollbar {
  display: none;
}

.channel-bar:empty {
  display: none;
}

.channel-select {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  max-width: 480px;
  padding: 8px 36px 8px 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23646a73' d='M6 8.5L1.5 4h9z'/%3E%3C/svg%3E") no-repeat right 12px center;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

.channel-select:hover {
  border-color: var(--primary);
}

.channel-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(31, 111, 235, .15);
}

.channel-select option {
  font-weight: 500;
}

/* ===== 频道页网格（表格样式） ===== */
.channel-body {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.ch-card {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 10px;
  background: var(--surface);
  border: none;
  cursor: pointer;
  text-align: center;
  transition: background .15s, color .15s;
  font-family: inherit;
}

.ch-card:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

.ch-card:active {
  background: var(--primary-soft);
  color: var(--primary);
}

.ch-name {
  font-size: 15px;
  font-weight: 400;
  color: inherit;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.ch-tid {
  font-size: 12px;
  color: var(--text-3);
  font-weight: 500;
  flex-shrink: 0;
}

/* 频道页分区标题（独占一行、居中） */
.ch-section-title {
  grid-column: 1 / -1;
  background: linear-gradient(135deg, #eef3fb, #e8f5ef);
  border-bottom: 1px solid var(--primary);
  font-size: 15px;
  font-weight: 700;
  color: var(--primary);
  text-align: center;
  padding: 9px 0;
  letter-spacing: 1px;
}

.chip {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font-size: 14px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  flex: 0 0 auto;
  transition: all .15s;
}

.chip:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* ===== 主区域 ===== */
.main {
  max-width: 800px;
  margin: 0 auto;
  padding: 16px 14px 80px;
  background: var(--surface);
}

.view[hidden] {
  display: none;
}

.list-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--text-2);
  font-size: 13px;
  padding: 5px;
  flex-wrap: nowrap;
  width: 100%;
}

/* 列表页返回行滚动时悬停 */
#listMeta {
  position: sticky;
  top: var(--header-h);
  z-index: 21;
  background: var(--surface);
}

.list-meta .col-name {
  color: var(--text);
  font-weight: 600;
}

/* 列表页三栏专用：返回(左) + 标题(中) + 条数(右) */
.list-meta .list-back {
  flex-shrink: 0;
  white-space: nowrap;
  margin-bottom: 0;
}

.list-meta .list-title {
  flex: 1;
  min-width: 0;
  text-align: center;
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-meta .list-count {
  flex-shrink: 0;
  white-space: nowrap;
}

.list-body {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: none;
  border-radius: 0;
  padding: 12px 14px;
  cursor: pointer;
  transition: background .15s, color .15s;
  text-align: left;
  font-family: inherit;
}

.card:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

.card:active {
  background: var(--primary-soft);
  color: var(--primary);
}

/* 空状态/错误提示时去掉表格外观 */
.list-body:has(.empty) {
  background: none;
  border: none;
  border-radius: 0;
}

.card .idx {
  flex: 0 0 auto;
  min-width: 26px;
  height: 26px;
  padding: 0 6px;
  border-radius: 7px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card .ttl {
  flex: 1 1 auto;
  font-size: 15px;
  font-weight: 500;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* ===== 分页 ===== */
.pagination {
  margin: 22px 0 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
}

.pager-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  min-width: 38px;
  height: 38px;
  padding: 0 10px;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}

.pager-btn:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
}

.pager-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.pager-btn:disabled {
  opacity: .4;
  cursor: not-allowed;
}

.pager-info {
  color: var(--text-3);
  font-size: 13px;
  padding: 0 6px;
}

.lbl-mini {
  display: none;
}

/* 手机端短标签（桌面隐藏） */
.pager-jump {
  width: 64px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 9px;
  text-align: center;
  font-size: 14px;
}

.pager-jump:focus {
  outline: 2px solid var(--primary-soft);
  border-color: var(--primary);
}

/* ===== 文章页 ===== */
.article-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 18px 8px;
  box-shadow: var(--shadow);
}

.article-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 5px;
  position: sticky;
  top: var(--header-h);
  z-index: 21;
  background: var(--surface);
}

.back-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: all .15s;
  flex: 0 0 auto;
}

.back-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.article-title {
  margin: 0 0 14px;
  font-size: 22px;
  line-height: 1.4;
  font-weight: 700;
  word-break: break-word;
  text-align: center;
}

.article-title::after {
  content: "";
  display: block;
  margin: 12px auto 0;
  width: 60%;
  max-width: 320px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border), transparent);
}

.article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  flex: 1 1 auto;
}

.tag {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 999px;
  background: #f0f2f5;
  color: var(--text-2);
}

.tag.link {
  background: var(--primary-soft);
  color: var(--primary);
  cursor: pointer;
}

.article-body {
  font-size: 16px;
  line-height: 1.8;
  overflow: hidden;
  word-break: break-word;
}

.article-body img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 10px auto;
  border-radius: 8px;
}

.article-body p {
  margin: 10px 0;
}

/* 禁用手机浏览器对正文中数字串自动识别为电话/邮箱链接 */
.article-body a[href^="tel:"],
.article-body a[href^="mailto:"] {
  color: inherit;
  text-decoration: none;
  cursor: text;
  pointer-events: none;
}

.article-nav {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 22px 0 14px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fbfcfe;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
  transition: border-color .15s, background .15s;
}

.nav-link:hover:not(:disabled) {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.nav-link:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.nav-link .nav-label {
  font-size: 12px;
  color: var(--text-3);
  flex: 0 0 auto;
}

.nav-link .nav-title {
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1 1 auto;
  min-width: 0;
}

/* ===== 空状态 / 错误 ===== */
.empty {
  text-align: center;
  padding: 56px 20px;
  color: var(--text-2);
}

.empty .empty-icon {
  font-size: 40px;
  margin-bottom: 12px;
}

.empty h3 {
  margin: 0 0 8px;
  color: var(--text);
  font-size: 18px;
}

.empty p {
  margin: 4px 0;
  font-size: 14px;
}

.empty code {
  background: #eef1f6;
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 13px;
}

.empty .retry-btn {
  margin-top: 16px;
  border: 0;
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  padding: 9px 22px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 14px;
}

.empty .retry-btn:hover {
  background: #1858c4;
}

/* ===== 广告位 ===== */
.category-ad {
  max-width: 800px;
  margin: 0 auto;
  background: var(--surface);
}

.category-ad iframe {
  display: block;
  width: 100%;
  border: 0;
}

/* ===== 公告栏（小喇叭 + 向左滚动公告词） ===== */
.notice-bar {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  background: var(--primary-soft);
  border-bottom: 1px solid var(--border);
}

.notice-bar[hidden] {
  display: none;
}

.notice-icon {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  color: var(--primary);
  animation: notice-bell 2.4s ease-in-out infinite;
}

@keyframes notice-bell {

  0%,
  100% {
    transform: rotate(0);
  }

  8% {
    transform: rotate(-14deg);
  }

  16% {
    transform: rotate(12deg);
  }

  24% {
    transform: rotate(-8deg);
  }

  32% {
    transform: rotate(0);
  }
}

.notice-track {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  cursor: default;
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 12px, #000 calc(100% - 12px), transparent 100%);
  mask-image: linear-gradient(90deg, transparent 0, #000 12px, #000 calc(100% - 12px), transparent 100%);
}

/* 鼠标悬停公告词时暂停滚动 */
.notice-track:hover .notice-content {
  animation-play-state: paused;
}

.notice-content {
  display: inline-block;
  white-space: nowrap;
  /* 经典跑马灯：左侧留一个轨道宽度的空白，文字起始位置正好在右边缘外 */
  padding-left: 100%;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  animation: notice-scroll linear infinite;
}

/* 从右边缘外（translateX 0）移动到整段完全移出左侧（-100%，相对元素自身宽度=轨道宽+文字宽） */
@keyframes notice-scroll {
  from {
    transform: translateX(0);
  }

  to {
    transform: translateX(-100%);
  }
}

@media (max-width: 600px) {
  .notice-bar {
    padding: 6px 10px;
    gap: 6px;
  }

  .notice-icon {
    width: 18px;
    height: 18px;
  }

  .notice-content {
    font-size: 13px;
  }
}

.ad-slot {
  max-width: 800px;
  margin: 0 auto;
  text-align: center;
  background: var(--surface);
}

.ad-slot:empty {
  display: none;
  /* 空广告位不占位 */
}

.ad-item {
  margin: 0;
  font-size: 32px;
  color: var(--text-2);
  line-height: 1.5;
  overflow: hidden;
  text-align: center;
}

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

.ad-item a {
  display: block;
}

/*广告*/
.ad-box {
  width: 100%;
  margin: auto;
  margin: 10px 0px 0px 0px;
}

.ad-box {
  width: 100%;
  border-collapse: collapse;
  text-align: center;
}

.ad-box td {
  margin: 7px;
  border: 1px solid #e1e1e1;
  font-size: 26px;
}

.ad-box td a {
  display: block;
  color: #333;
  text-decoration: none;
  color: #0000FF;
}

.ad-box td a:hover {
  color: #0000FF;
  background-color: #f8f8f8;
}

.ad-t2 {
  width: 100%;
  margin: auto;
  margin: 0px 0px;
  border-collapse: collapse;
  text-align: center;
}

.ad-t2 td {
  width: 50%;
  margin: 7px;
  border: 1px solid #e1e1e1;
  font-size: 26px;
}

.ad-t2 td a {
  display: block;
  color: #333;
  text-decoration: none;
  color: #0000FF;
}

.ad-t2 td a:hover {
  color: #0000FF;
  background-color: #f8f8f8;
}

.wz2f1 td {
  width: 50%;
}

/* 手机自适应字体 */
@media (max-width:768px) {
  .ad-box td {
    font-size: clamp(14px, 4vw, 22px);
  }
}

.footer {
  max-width: 800px;
  margin: 0 auto;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 18px 14px calc(18px + env(safe-area-inset-bottom, 0));
}

.footer-inner {
  max-width: 800px;
  margin: 0 auto;
  text-align: center;
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.8;
}

.footer-text {
  margin: 0 0 4px;
  font-size: 13px;
  color: var(--text-2);
}

.footer-copy {
  margin: 0;
  font-size: 12px;
  color: var(--text-3);
}

/* ===== 回到顶部 ===== */
.to-top {
  position: fixed;
  right: 18px;
  bottom: 22px;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(31, 111, 235, .4);
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
}

.to-top:hover {
  background: #1858c4;
}

/* ===== 加载层 ===== */
.loading {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(244, 246, 250, .72);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.loading[hidden] {
  display: none;
}

.loading-card {
  background: var(--surface);
  padding: 22px 30px;
  border-radius: 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.loading-text {
  color: var(--text-2);
  font-size: 14px;
}

.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid #e3e8f0;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* 视图切换动画已禁用 —— 避免 iOS Safari 上 opacity/transform 创建的 stacking context 干扰 fixed 头部层级 */
.view {
  animation: none;
}

/* ===== 响应式 ===== */
@media (max-width: 600px) {
  :root {
    --header-h: 50px;
  }

  .brand {
    font-size: 16px;
  }

  .cat-tab {
    font-size: 14px;
    padding: 6px 13px;
  }

  .main {
    padding: 12px 10px 80px;
  }

  .channel-body {
    grid-template-columns: repeat(4, 1fr);
  }

  .ch-card {
    padding: 10px 4px;
  }

  .ch-name {
    font-size: 15px;
  }

  .article-wrap {
    padding: 14px 14px 6px;
  }

  .article-title {
    font-size: 19px;
  }

  /* 分页：手机端一行显示 */
  .pagination {
    gap: 4px;
    margin: 16px 0 4px;
  }

  .pager-btn {
    min-width: 30px;
    height: 32px;
    padding: 0 7px;
    font-size: 13px;
    border-radius: 7px;
  }

  .pager-edge,
  .pager-info,
  .lbl-full {
    display: none;
  }

  .lbl-mini {
    display: inline;
  }

  .pager-jump {
    width: 46px;
    height: 32px;
    font-size: 13px;
  }
}

/* ===== 列表页返回按钮 ===== */
.list-back {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: all .15s;
  margin-bottom: 10px;
}

.list-back:hover {
  border-color: var(--primary);
  color: var(--primary);
}

/* ===== 图片查看器 ===== */
.img-viewer {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

.img-viewer[hidden] {
  display: none;
}

.imgv-close {
  position: absolute;
  top: 16px;
  right: 18px;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 22px;
  line-height: 1;
  border-radius: 50%;
  cursor: pointer;
  transition: all .15s;
  z-index: 2;
}

.imgv-close:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.5);
  transform: scale(1.06);
}

.imgv-stage {
  width: 94vw;
  height: 86vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.imgv-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  -webkit-user-drag: none;
  user-drag: none;
  transform-origin: center center;
  will-change: transform;
  cursor: grab;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  border-radius: 6px;
}

.imgv-img:active {
  cursor: grabbing;
}

.imgv-tip {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.55);
  font-size: 12px;
  letter-spacing: .5px;
  pointer-events: none;
}

@media (max-width: 600px) {
  .imgv-close {
    top: 10px;
    right: 12px;
    width: 36px;
    height: 36px;
    font-size: 20px;
  }

  .imgv-stage {
    width: 96vw;
    height: 80vh;
  }

  .imgv-tip {
    font-size: 11px;
    bottom: 10px;
  }
}

/* ===== 文章图片水印 ===== */
.article-img-wrap {
  position: relative;
  display: inline-block;
  max-width: 100%;
  vertical-align: middle;
}

.article-img-wrap>img {
  display: block;
  max-width: 100%;
  height: auto;
}

.article-watermark {
  position: absolute;
  left: 10px;
  bottom: 10px;
  padding: 6px 14px;
  background: rgba(0, 0, 0, 0.4);
  color: rgba(255, 255, 255, 0.92);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
  border-radius: 999px;
  letter-spacing: .5px;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
  white-space: nowrap;
}

@media (max-width: 600px) {
  .article-watermark {
    left: 6px;
    bottom: 6px;
    padding: 5px 10px;
    font-size: 13px;
  }
}