:root {
  --primary: #4f6ef7;
  --primary-dark: #3b5bdb;
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #1f2430;
  --text-2: #5b6472;
  --border: #e6eaf2;
  --shadow: 0 2px 12px rgba(31, 41, 72, .08);
  --radius: 14px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.6;
}
.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }
a { text-decoration: none; color: inherit; }

/* 顶部 */
.header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(255,255,255,.92); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; gap: 18px; height: 60px; }
.logo { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; white-space: nowrap; }
.logo-icon { font-size: 24px; }
.nav { display: flex; gap: 4px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  padding: 6px 12px; border-radius: 20px; font-size: 14px; color: var(--text-2); white-space: nowrap;
  transition: all .2s;
}
.nav a:hover, .nav a.active { background: var(--primary); color: #fff; }
.admin-link { font-size: 13px; color: var(--text-2); white-space: nowrap; padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; }
.admin-link:hover { color: var(--primary); border-color: var(--primary); }

/* Hero */
.hero {
  padding: 56px 0 40px; text-align: center;
  background: linear-gradient(160deg, #eef2ff 0%, #f5f7fb 60%);
  border-bottom: 1px solid var(--border);
}
.hero-title { font-size: 38px; margin-bottom: 12px; }
.grad { background: linear-gradient(90deg, #4f6ef7, #9b5cf6, #f65c8c); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-sub { color: var(--text-2); margin-bottom: 26px; }
.search-box {
  display: flex; max-width: 640px; margin: 0 auto;
  background: #fff; border-radius: 30px; overflow: hidden;
  box-shadow: var(--shadow); border: 1px solid var(--border);
}
.search-box input { flex: 1; border: none; outline: none; padding: 14px 22px; font-size: 15px; background: transparent; }
.search-box button {
  border: none; background: var(--primary); color: #fff; padding: 0 34px;
  font-size: 15px; cursor: pointer; transition: background .2s;
}
.search-box button:hover { background: var(--primary-dark); }
.quick-tags { margin-top: 18px; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.quick-tags span {
  font-size: 13px; color: var(--text-2); background: #fff; border: 1px solid var(--border);
  padding: 5px 14px; border-radius: 20px; cursor: pointer; transition: all .2s;
}
.quick-tags span:hover { color: var(--primary); border-color: var(--primary); }

/* 区块 */
.section { margin-top: 40px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.section-head h2 { font-size: 22px; }
.btn-clear { border: 1px solid var(--border); background: #fff; padding: 6px 16px; border-radius: 8px; cursor: pointer; color: var(--text-2); }
.btn-clear:hover { color: var(--primary); border-color: var(--primary); }
.empty { text-align: center; color: var(--text-2); padding: 40px 0; }

/* 卡片网格 */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; display: flex; flex-direction: column; gap: 8px;
  transition: transform .2s, box-shadow .2s; position: relative;
}
.card:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(31,41,72,.12); }
.card-top { display: flex; align-items: center; gap: 10px; }
.card-icon {
  width: 40px; height: 40px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, var(--primary), #9b5cf6);
  overflow: hidden;
}
.card-icon img { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; display: block; }
.card-name { font-weight: 600; font-size: 16px; }
.badges { display: flex; gap: 6px; margin-left: auto; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 10px; white-space: nowrap; }
.badge.hot { background: #fff1f0; color: #f5222d; }
.badge.featured { background: #fff7e6; color: #fa8c16; }
.card-desc {
  font-size: 13px; color: var(--text-2);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  min-height: 42px;
}
.card-foot { display: flex; align-items: center; justify-content: space-between; margin-top: auto; }
.card-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.tag { font-size: 11px; color: var(--primary); background: #eef2ff; padding: 2px 8px; border-radius: 10px; }
.card-link {
  font-size: 13px; color: var(--primary); background: #eef2ff;
  padding: 5px 14px; border-radius: 8px; white-space: nowrap; transition: all .2s;
}
.card-link:hover { background: var(--primary); color: #fff; }

/* 页脚 */
.footer { margin-top: 60px; padding: 40px 0 24px; color: var(--text-2); font-size: 13px; border-top: 1px solid var(--border); background: #fff; }
.footer a { color: var(--primary); }
.footer-grid { display: grid; grid-template-columns: 1.4fr 1fr 1.2fr; gap: 32px; text-align: left; }
.footer-col h4 { font-size: 15px; color: var(--text); margin-bottom: 10px; }
.footer-col p { line-height: 1.8; }
.footer-list { list-style: none; line-height: 2; }
.footer-mail {
  display: inline-flex; align-items: center; gap: 8px; margin-top: 12px;
  padding: 10px 18px; border-radius: 10px; font-size: 14px; font-weight: 600;
  background: linear-gradient(135deg, var(--primary), #9b5cf6); color: #fff !important;
  transition: transform .2s, box-shadow .2s;
}
.footer-mail:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(79,110,247,.28); }
.footer-bottom { margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--border); text-align: center; font-size: 12px; color: var(--text-2); }
.footer-bottom .icp { margin-top: 6px; }
.footer-bottom .icp a { color: var(--text-2); }

/* 广告位占位 */
.ad-slot {
  display: flex; align-items: center; gap: 14px;
  margin: 0 0 26px; padding: 14px 18px;
  border: 1px dashed var(--border); border-radius: 14px;
  background: linear-gradient(90deg, #f7f9ff, #fdf7ff);
}
.ad-label {
  flex-shrink: 0; font-size: 11px; color: var(--text-2);
  border: 1px solid var(--border); border-radius: 4px; padding: 1px 6px; background: #fff;
}
.ad-body { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ad-body b { font-size: 15px; color: var(--text); }
.ad-body span { font-size: 13px; color: var(--text-2); }
.ad-cta {
  flex-shrink: 0; font-size: 13px; font-weight: 600; color: #fff;
  background: linear-gradient(135deg, var(--primary), #9b5cf6);
  padding: 8px 16px; border-radius: 8px; white-space: nowrap;
  transition: transform .2s, box-shadow .2s;
}
.ad-cta:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(79,110,247,.28); }
@media (max-width: 640px) {
  .ad-slot { flex-wrap: wrap; }
  .ad-body { flex: 1 1 60%; }
  .ad-cta { width: 100%; text-align: center; }
}
@media (max-width: 768px) {
  .footer-grid { grid-template-columns: 1fr; gap: 22px; }
}

/* 回到顶部 */
#backTop {
  position: fixed; right: 24px; bottom: 32px; width: 44px; height: 44px;
  border: none; border-radius: 50%; background: var(--primary); color: #fff;
  font-size: 18px; cursor: pointer; display: none; box-shadow: var(--shadow);
}
#backTop.show { display: block; }

@media (max-width: 768px) {
  .hero-title { font-size: 28px; }
  .header-inner { gap: 10px; }
  .admin-link { padding: 4px 8px; }
}

/* ================= 移动端 App 式布局 ================= */
.section, [id^="cat-"] { scroll-margin-top: 70px; }

@media (max-width: 768px) {
  /* 内容底部留出标签栏高度（含全面屏安全区） */
  body { padding-bottom: calc(60px + env(safe-area-inset-bottom)); }

  /* 顶栏紧凑化；顶部横向分类隐藏，改用底部“分类”弹层 */
  .header-inner { height: 52px; }
  .logo-text { font-size: 16px; }
  .nav { display: none; }

  /* Hero 紧凑化 */
  .hero { padding: 20px 0 18px; }
  .hero-title { font-size: 22px; margin-bottom: 6px; }
  .hero-sub { font-size: 13px; margin-bottom: 14px; }
  .search-box { border-radius: 22px; box-shadow: none; }
  .search-box input { padding: 11px 16px; font-size: 14px; }
  .search-box button { padding: 0 20px; font-size: 14px; }
  .quick-tags {
    margin-top: 12px; flex-wrap: nowrap; justify-content: flex-start;
    overflow-x: auto; scrollbar-width: none;
  }
  .quick-tags::-webkit-scrollbar { display: none; }
  .quick-tags span { flex-shrink: 0; }

  /* 广告位 */
  .ad-slot { padding: 10px 12px; gap: 10px; border-radius: 12px; }
  .ad-body b { font-size: 14px; }
  .ad-cta { padding: 7px 12px; font-size: 12px; }

  /* 区块 */
  .section { margin-top: 26px; }
  .section-head { margin-bottom: 12px; }
  .section-head h2 { font-size: 18px; }

  /* 双列卡片（应用商店风格） */
  .grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .card { padding: 12px; border-radius: 12px; gap: 6px; }
  .card:hover { transform: none; box-shadow: var(--shadow); }
  .card:active { transform: scale(.97); background: #f4f6ff; }
  .card-icon { width: 34px; height: 34px; border-radius: 9px; }
  .card-icon img { border-radius: 9px; }
  .card-name { font-size: 14px; }
  .badge { font-size: 10px; padding: 1px 6px; }
  .card-desc { font-size: 12px; min-height: 34px; }
  .card-foot { display: none; }   /* 整卡可点，去掉底部行更清爽 */

  /* 页脚紧凑 */
  .footer { margin-top: 34px; padding: 24px 0 18px; }
  .footer-col p { font-size: 13px; }
  .footer-mail { display: block; text-align: center; }

  /* 回到顶部移到标签栏上方 */
  #backTop { right: 14px; bottom: calc(74px + env(safe-area-inset-bottom)); width: 40px; height: 40px; }

  /* ===== 底部标签栏 ===== */
  .tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 150;
    display: flex; background: #fff; border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -4px 16px rgba(31,41,72,.06);
  }
  .tab {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 8px 0 6px; font-size: 11px; color: var(--text-2); cursor: pointer;
    -webkit-tap-highlight-color: transparent; user-select: none;
  }
  .tab svg { width: 22px; height: 22px; }
  .tab.active { color: var(--primary); font-weight: 600; }

  /* ===== 分类底部弹层 ===== */
  .sheet-mask {
    position: fixed; inset: 0; z-index: 180; background: rgba(15,20,35,.45);
    display: none; align-items: flex-end;
  }
  .sheet-mask.open { display: flex; }
  .sheet {
    width: 100%; background: #fff; border-radius: 18px 18px 0 0;
    padding: 16px 16px calc(18px + env(safe-area-inset-bottom));
    animation: sheetUp .22s ease;
  }
  @keyframes sheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
  .sheet-head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 14px; font-size: 16px; font-weight: 600;
  }
  .sheet-close {
    border: none; background: #f2f4f8; color: var(--text-2);
    width: 30px; height: 30px; border-radius: 50%; font-size: 14px; cursor: pointer;
  }
  .sheet-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
  .sheet-item {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 12px 4px; border-radius: 12px; background: #f6f8fc;
    font-size: 13px; font-weight: 600; color: var(--text); text-align: center;
    -webkit-tap-highlight-color: transparent;
  }
  .sheet-item small { font-size: 11px; color: var(--text-2); font-weight: 400; }
  .sheet-item:active { background: #eef2ff; color: var(--primary); }
}

/* 桌面端隐藏移动端组件 */
@media (min-width: 769px) {
  .tabbar, .sheet-mask { display: none !important; }
}
