/* ================================================================
   软件库 - 公共样式
   ================================================================ */

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { overflow-y: scroll; scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: #f5f5f5; color: #333; padding-bottom: 0; min-height: 100vh;
  transition: background .3s, color .3s; overflow-x: hidden;
}
body.dark-mode { background: #1a1a1a; color: #fff; }
a { text-decoration: none; color: inherit; }
img { max-width: 100%; }

/* 顶部搜索栏 */
.search-header {
  background: #fff; padding: 12px 16px; padding-top: calc(12px + env(safe-area-inset-top));
  position: sticky; top: 0; z-index: 100; border-bottom: 1px solid #eee;
  display: flex; align-items: center;
}
body.dark-mode .search-header { background: #1f1f1f; border-bottom-color: #333; }
.search-bar {
  flex: 1; display: flex; align-items: center; background: #f5f5f5;
  border-radius: 20px; padding: 8px 16px; cursor: pointer;
}
body.dark-mode .search-bar { background: #333; }
.search-icon { width: 18px; height: 18px; margin-right: 8px; color: #999; flex-shrink: 0; }
.search-input {
  flex: 1; border: none; outline: none; font-size: 15px; background: transparent;
  color: #333; cursor: pointer;
}
body.dark-mode .search-input { color: #fff; }
.search-input::placeholder { color: #999; }
body.dark-mode .search-input::placeholder { color: #666; }
.dark-mode-toggle {
  width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
  margin-left: 10px; cursor: pointer; border-radius: 50%; transition: background .2s;
}
.dark-mode-toggle:active { background: rgba(0,0,0,.05); }
body.dark-mode .dark-mode-toggle:active { background: rgba(255,255,255,.1); }
.dark-mode-toggle svg { width: 22px; height: 22px; color: #000; }
body.dark-mode .dark-mode-toggle svg { color: #fff; }

/* 搜索栏（发现页内嵌） */
.search-box-bar {
  background: #fff; padding: 8px 16px; border-bottom: 1px solid #eee;
  display: flex; align-items: center;
}
body.dark-mode .search-box-bar { background: #1f1f1f; border-bottom-color: #333; }
.search-input-field {
  flex: 1; padding: 10px 16px; border: 1px solid #ddd; border-radius: 20px;
  font-size: 15px; outline: none; background: #fff;
}
body.dark-mode .search-input-field { background: #2a2a2a; border-color: #444; color: #fff; }
.search-submit-btn {
  padding: 10px 20px; background: #07c160; color: #fff; border: none;
  border-radius: 20px; font-size: 14px; cursor: pointer;
}

/* Banner */
.banner {
  position: relative; margin: 12px; height: 180px; border-radius: 12px;
  overflow: hidden; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  box-shadow: 0 4px 12px rgba(0,0,0,.1);
}
.banner img { width: 100%; height: 100%; object-fit: cover; }
.banner-overlay {
  position: absolute; bottom: 0; left: 0; right: 0; padding: 20px 16px;
  background: linear-gradient(transparent, rgba(0,0,0,.7)); color: #fff;
}
.banner-overlay-center {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center;
  background: linear-gradient(135deg, #667eea, #764ba2);
  padding: 20px; color: #fff;
}
.banner-title { font-size: 20px; font-weight: bold; margin-bottom: 4px; }
.banner-subtitle { font-size: 13px; opacity: .9; }

/* 分类图标区 */
.category-section {
  background: #fff; margin: 12px; border-radius: 12px; padding: 20px 10px;
  display: flex; flex-wrap: wrap; justify-content: space-around;
}
body.dark-mode .category-section { background: #2a2a2a; }
.category-item {
  display: flex; flex-direction: column; align-items: center; cursor: pointer;
  transition: transform .2s; min-width: 60px;
}
.category-item:active { transform: scale(.95); }
.category-icon {
  width: 50px; height: 50px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; margin-bottom: 8px;
}
.category-icon.purple { background: linear-gradient(135deg, #667eea, #764ba2); }
.category-icon.blue { background: linear-gradient(135deg, #4facfe, #00f2fe); }
.category-icon.orange { background: linear-gradient(135deg, #fa709a, #fee140); }
.category-icon.green { background: linear-gradient(135deg, #43e97b, #38f9d7); }
.category-icon.cyan { background: linear-gradient(135deg, #a18cd1, #fbc2eb); }
.category-icon-image { background: transparent !important; border-radius: 16px; overflow: hidden; }
.category-icon-img { width: 100%; height: 100%; object-fit: contain; display: block; }
.category-name { font-size: 13px; color: #333; }
body.dark-mode .category-name { color: #ddd; }
.category-horizontal {
  display: flex; align-items: center; gap: 10px; background: #fff;
  border-radius: 12px; padding: 12px 14px; text-decoration: none; color: #333;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
body.dark-mode .category-horizontal { background: #2a2a2a; color: #ddd; box-shadow: none; }

/* 节标题 */
.section-title { padding: 16px 16px 8px; font-size: 16px; font-weight: bold; }
.hot-section-title { display: flex; align-items: center; gap: 7px; }
.section-title-icon { width: 26px; height: 26px; object-fit: contain; flex-shrink: 0; vertical-align: -5px; }
.header-title-icon { width: 22px; height: 22px; object-fit: contain; vertical-align: -4px; margin-right: 5px; }
.page-title-icon { width: 24px; height: 24px; object-fit: contain; vertical-align: -4px; margin-right: 5px; }
.balance-icon { width: 24px; height: 24px; object-fit: contain; vertical-align: -4px; }
.coin-icon { width: 18px; height: 18px; object-fit: contain; vertical-align: -3px; }
.log-icon-img { width: 24px; height: 24px; object-fit: contain; display: block; }
.task-icon-img { width: 28px; height: 28px; object-fit: contain; display: block; }
.btn-icon { width: 18px; height: 18px; object-fit: contain; vertical-align: -3px; }
.stat-icon { width: 18px; height: 18px; object-fit: contain; vertical-align: -3px; }
.checkin-main-icon { width: 48px; height: 48px; object-fit: contain; display: block; margin: 0 auto 12px; }

/* 应用列表 */
.app-list { background: #fff; margin: 0 12px; border-radius: 12px; overflow: hidden; }
body.dark-mode .app-list { background: #2a2a2a; }
.app-item {
  display: flex; align-items: center; padding: 14px 16px;
  border-bottom: 1px solid #f0f0f0; cursor: pointer; transition: background .2s;
}
body.dark-mode .app-item { border-bottom-color: #3a3a3a; }
.app-item:last-child { border-bottom: none; }
.app-item:active { background: #f8f8f8; }
body.dark-mode .app-item:active { background: #333; }
.app-icon {
  width: 60px; height: 60px; border-radius: 12px; object-fit: cover;
  flex-shrink: 0;
}
.app-icon-placeholder {
  width: 60px; height: 60px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; color: #fff; font-weight: 700;
}
.icon-badge-wrap {
  position: relative; width: 60px; height: 60px; margin-right: 14px;
  border-radius: 12px; overflow: hidden; flex: 0 0 60px;
}
.icon-badge-wrap-detail {
  width: 72px; height: 72px; border-radius: 16px; flex-basis: 72px;
}
.icon-badge {
  position: absolute; z-index: 2; top: 8px; right: -28px; width: 88px; height: 17px;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
  color: #fff; background: var(--badge-color, #2389da); transform: rotate(45deg);
  box-shadow: 0 1px 3px rgba(0,0,0,.24); font-size: 9px; font-weight: 700; line-height: 1;
  white-space: nowrap; pointer-events: none;
}
.icon-badge-wrap-detail .icon-badge { top: 10px; right: -30px; width: 100px; height: 19px; font-size: 10px; }
.icon-badge-medium { font-size: 8px; }
.icon-badge-long { font-size: 7px; }
.icon-badge > span { position: relative; z-index: 1; max-width: 78%; overflow: hidden; text-overflow: ellipsis; }
.icon-badge::after {
  content: ''; position: absolute; top: -10px; bottom: -10px; left: -24px; width: 14px;
  background: rgba(255,255,255,.62); filter: blur(2px); transform: skewX(-20deg);
  animation: icon-badge-shine 2.4s ease-in-out infinite;
}
@keyframes icon-badge-shine {
  0%, 35% { transform: translateX(0) skewX(-20deg); opacity: 0; }
  45% { opacity: .9; }
  65%, 100% { transform: translateX(136px) skewX(-20deg); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .icon-badge::after { animation: none; display: none; }
}
.app-info { flex: 1; min-width: 0; }
.app-name {
  font-size: 17px; font-weight: 500; margin-bottom: 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.app-stats { font-size: 13px; color: #999; display: flex; align-items: center; gap: 12px; }
.app-stat-icon { width: 14px; height: 14px; object-fit: contain; vertical-align: -2px; margin-right: 3px; }
body.dark-mode .app-stats { color: #888; }
.stat-item { display: flex; align-items: center; gap: 4px; }
.download-btn {
  padding: 6px 20px; background: #07c160; color: #fff;
  border: none; border-radius: 20px; font-size: 14px;
  cursor: pointer; flex-shrink: 0; transition: all .2s; font-weight: 500;
}
.download-btn:active { opacity: .7; }

/* 底部导航 */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; width: 100%; height: 60px;
  background: #fff; display: flex; align-items: center;
  box-shadow: 0 -2px 10px rgba(0,0,0,.05); z-index: 1000; padding: 0 4px;
  border-top: 1px solid #eee;
}
body.dark-mode .bottom-nav { background: #1f1f1f; border-top: 1px solid #333; }
.nav-item, .nav-post-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  flex: 1; height: 50px; text-decoration: none; cursor: pointer;
  color: #888; font-size: 10px;
}
.nav-item.active { color: #333; font-weight: 600; }
body.dark-mode .nav-item { color: #888; }
body.dark-mode .nav-item.active { color: #fff; }
.nav-item .nav-icon { width: 20px; height: 20px; margin-bottom: 3px; fill: currentColor; }
.nav-item span, .nav-post-btn span { font-size: 10px; line-height: 1; }
.nav-post-btn { position: relative; }
.nav-post-btn.active { color: #333; }
body.dark-mode .nav-post-btn.active { color: #fff; }
.nav-post-btn .post-circle {
  width: 44px; height: 44px; background: linear-gradient(135deg, #ff4444, #d63031);
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  color: white; box-shadow: 0 4px 12px rgba(255,68,68,.4);
  border: 3px solid #fff; transition: all .3s;
}
.nav-post-btn:active .post-circle { transform: scale(.9); }
body.dark-mode .nav-post-btn .post-circle { border-color: #121212; }
.nav-post-btn .post-circle svg { width: 24px; height: 24px; fill: white; }

/* 发现页分类栏 */
.discover-category-bar {
  display: flex; overflow-x: auto; gap: 8px; padding: 12px 16px;
  background: #fff; border-bottom: 1px solid #eee; white-space: nowrap;
  scrollbar-width: none; position: sticky; top: 56px; z-index: 99;
}
body.dark-mode .discover-category-bar { background: #1f1f1f; border-bottom-color: #333; }
.discover-category-bar::-webkit-scrollbar { display: none; }
.discover-cat-btn {
  padding: 6px 16px; border-radius: 20px; border: 1px solid #d9d9d9;
  background: #fff; cursor: pointer; font-size: 13px; flex-shrink: 0;
  text-decoration: none; color: #333; transition: all .2s;
}
body.dark-mode .discover-cat-btn { background: #2a2a2a; border-color: #444; color: #ddd; }
.discover-cat-btn:hover { border-color: #07c160; color: #07c160; }
.discover-cat-btn.active { background: #07c160; color: #fff; border-color: #07c160; }
.discover-list { padding: 12px; }
.discover-list .app-list { margin: 0; }

/* 详情页 - 顶部导航 */
.top-nav {
  position: sticky; top: 0; background: #fff; padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top));
  display: flex; align-items: center; z-index: 100; border-bottom: 1px solid #eee;
}
body.dark-mode .top-nav { background: #1f1f1f; border-bottom-color: #333; }
.back-btn {
  width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; margin-right: 12px;
}
.back-btn svg { width: 24px; height: 24px; color: #333; }
body.dark-mode .back-btn svg { color: #fff; }
.nav-title {
  flex: 1; font-size: 17px; font-weight: 500; text-align: center;
  margin-right: 52px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* 轮播 */
.swiper-container { width: 100%; overflow: hidden; position: relative; background: #000; }
.swiper-wrapper {
  display: flex; overflow-x: auto; scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.swiper-wrapper::-webkit-scrollbar { display: none; }
.swiper-slide { flex-shrink: 0; width: 100%; scroll-snap-align: start; }
.swiper-slide img { width: 100%; height: 220px; object-fit: contain; display: block; background: #f5f5f5; }
/* 应用详情页截图 - 横向滑动，按屏幕宽度自适应每屏数量 */
.screenshot-swiper { background: transparent !important; }
.screenshot-swiper .swiper-wrapper {
  display: flex !important;
  flex-wrap: nowrap !important;
  gap: 8px;
  padding: 6px;
  box-sizing: border-box;
  overflow-x: auto !important;
  scroll-snap-type: x mandatory !important;
  -webkit-overflow-scrolling: touch;
}
.screenshot-swiper .swiper-wrapper::-webkit-scrollbar { display: none; }
.screenshot-swiper .swiper-slide {
  flex: 0 0 calc((100% - 8px) / 2) !important;
  width: calc((100% - 8px) / 2) !important;
  padding: 0 !important;
  scroll-snap-align: start !important;
  box-sizing: border-box;
  display: flex;
  justify-content: center;
}
.screenshot-swiper .swiper-slide img {
  width: 100% !important;
  height: auto !important;
  max-height: 340px;
  object-fit: contain;
  display: block;
  cursor: zoom-in;
  border-radius: 12px;
  background: #f5f5f5;
  box-shadow: 0 2px 10px rgba(0,0,0,.08);
}
body.dark-mode .screenshot-swiper .swiper-slide img { background: #2a2a2a; }
.screenshot-swiper .swiper-dots { display: none !important; }

@media (min-width: 481px) {
  .screenshot-swiper .swiper-slide {
    flex: 0 0 calc((100% - 20px) / 3) !important;
    width: calc((100% - 20px) / 3) !important;
  }
}

@media (min-width: 768px) {
  .screenshot-swiper .swiper-wrapper {
    gap: 12px;
    padding: 4px 0;
  }
  .screenshot-swiper .swiper-slide {
    flex: 0 0 calc((100% - 36px) / 4) !important;
    width: calc((100% - 36px) / 4) !important;
  }
}

/* ===== 截图点击放大 Lightbox ===== */
#lightbox {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 9999;
  background: rgba(0,0,0,.92);
  display: none; align-items: center; justify-content: center;
  cursor: zoom-out; overflow: hidden;
  touch-action: none;
}
#lightbox img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 8px;
  display: block;
}
#lightbox .lb-close {
  position: absolute; top: 14px; right: 18px;
  width: 40px; height: 40px; color: #fff;
  font-size: 30px; line-height: 40px; text-align: center;
  cursor: pointer; background: rgba(255,255,255,.15); border-radius: 50%;
  user-select: none;
}
#lightbox .lb-prev,
#lightbox .lb-next {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 44px; height: 44px; color: #fff;
  font-size: 30px; line-height: 44px; text-align: center;
  cursor: pointer; background: rgba(0,0,0,.45); border-radius: 50%;
  user-select: none; z-index: 10; border: 1.5px solid rgba(255,255,255,.25);
}
#lightbox .lb-prev { left: 12px; }
#lightbox .lb-next { right: 12px; }
#lightbox .lb-prev:active, #lightbox .lb-next:active { background: rgba(0,0,0,.65); }
#lightbox .lb-prev.hidden, #lightbox .lb-next.hidden { display: none; }
.placeholder-slide {
  width: 100%; height: 220px; display: flex; align-items: center;
  justify-content: center; background: #2a2a2a; color: #666; font-size: 14px;
}
.swiper-dots {
  position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 6px;
}
.swiper-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: rgba(255,255,255,.5); transition: all .3s;
}
.swiper-dot.active { width: 18px; border-radius: 3px; background: #fff; }

/* 详情信息区 */
.app-info-section { background: #fff; padding: 16px; margin-bottom: 10px; }
body.dark-mode .app-info-section { background: #2a2a2a; }
.app-header { display: flex; align-items: flex-start; margin-bottom: 14px; }
.detail-app-icon {
  width: 72px; height: 72px; border-radius: 16px; object-fit: cover;
  flex-shrink: 0;
}
.detail-app-icon-placeholder {
  width: 72px; height: 72px; border-radius: 16px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; color: #fff; font-weight: 700;
}
.app-basic-info { flex: 1; min-width: 0; }
.detail-app-name { font-size: 19px; font-weight: 600; margin-bottom: 4px; line-height: 1.3; }
.app-tags { display: flex; flex-wrap: wrap; gap: 8px 0; margin-top: 8px; }
.app-tag { font-size: 12px; color: #666; }
body.dark-mode .app-tag { color: #aaa; }
.app-tag:not(.row-start)::before { content: '|'; color: #ddd; margin: 0 8px; }
body.dark-mode .app-tag:not(.row-start)::before { color: #444; }

/* 特色标签 */
.feature-tags {
  display: flex; flex-wrap: wrap; gap: 10px; padding-top: 14px;
  border-top: 1px solid #f0f0f0;
}
body.dark-mode .feature-tags { border-top-color: #3a3a3a; }
.feature-tag {
  display: flex; align-items: center; padding: 4px 10px;
  background: #f5f5f5; border-radius: 14px; font-size: 13px; color: #1a73e8;
}
body.dark-mode .feature-tag { background: #333; color: #5b9cf0; }

/* 卡片 */
.section-card { background: #fff; margin-bottom: 10px; padding: 16px; }
body.dark-mode .section-card { background: #2a2a2a; }
.section-card .section-title { padding: 0 0 14px; font-size: 17px; font-weight: 600; }

/* 福利列表 */
.welfare-list { display: flex; flex-direction: column; gap: 8px; }
.welfare-item { font-size: 14px; color: #ff6b35; display: flex; align-items: center; gap: 6px; }
body.dark-mode .welfare-item { color: #ff8c5a; }
.welfare-item::before { content: '•'; font-size: 18px; line-height: 1; }

/* 介绍 */
.intro-content {
  font-size: 14px; line-height: 1.7; color: #666; position: relative;
  max-height: 80px; overflow: hidden; transition: max-height .3s;
}
body.dark-mode .intro-content { color: #aaa; }
.intro-content.expanded { max-height: 1000px; }
.intro-toggle {
  display: none; align-items: center; justify-content: center; gap: 4px;
  margin-top: 10px; color: #07c160; font-size: 14px; cursor: pointer;
}
.intro-toggle.visible { display: flex; }

/* 详细信息 */
.detail-list { display: flex; flex-direction: column; gap: 12px; }
.detail-item { display: flex; justify-content: space-between; align-items: center; }
.detail-label { font-size: 14px; color: #999; }
body.dark-mode .detail-label { color: #888; }
.detail-value { font-size: 14px; color: #333; }
body.dark-mode .detail-value { color: #ddd; }

/* 响应式 */
@media (max-width: 640px) {
  .search-header { flex-wrap: wrap; gap: 10px; padding: 12px 16px; }
  .category-section { justify-content: space-around; }
}
