/* 下载中心首页（深色，与详情页统一） */
.market-page {
  max-width: 560px;
  margin-inline: auto;
  padding-bottom: calc(80px + env(safe-area-inset-bottom));
}
.home-main,
.market-main {
  width: 100%;
  padding: 20px 22px 0;
}
/* 吸顶顶栏会遮住锚点目标，滚动时预留顶栏高度 */
#all-apps { scroll-margin-top: calc(70px + env(safe-area-inset-top)); }

/* ---------- Banner 轮播 ---------- */
.home-banner {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 1;
  border-radius: 16px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  margin-bottom: 24px;
  cursor: grab;
  touch-action: pan-y;
  -webkit-user-select: none;
  user-select: none;
}
.home-banner.banner-dragging { cursor: grabbing; }
.banner-track { position: absolute; inset: 0; }
.banner-slide {
  position: absolute;
  inset: 0;
  display: block;
  opacity: 0;
  transition: opacity 0.55s ease;
  pointer-events: none;
}
.banner-slide.active { opacity: 1; pointer-events: auto; }
.banner-media { position: absolute; inset: 0; display: block; }
.banner-slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  -webkit-user-drag: none;
  user-select: none;
}
.banner-fallback {
  width: 100%;
  height: 100%;
  background:
    radial-gradient(circle at 18% 20%, rgba(165, 231, 188, 0.32), transparent 55%),
    radial-gradient(circle at 82% 80%, rgba(87, 105, 247, 0.22), transparent 55%),
    linear-gradient(135deg, #1c2a21, #121512);
}
.banner-caption {
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  padding: 34px 18px 26px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  background: linear-gradient(180deg, transparent, rgba(7, 10, 8, 0.82));
}
.banner-caption strong {
  font-size: 17px;
  font-weight: 750;
  letter-spacing: -0.2px;
  color: #fff;
  overflow-wrap: anywhere;
}
.banner-caption span {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.72);
  overflow-wrap: anywhere;
}
.banner-dots {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  z-index: 2;
}
.banner-dots button {
  width: 6px;
  height: 6px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.38);
  transition: width 0.25s, background 0.25s;
}
.banner-dots button.active { width: 18px; background: #fff; }

/* ---------- 板块 ---------- */
.home-section { margin-bottom: 26px; }
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}
.section-head h2 { font-size: 18px; font-weight: 700; letter-spacing: -0.3px; }
.section-more { flex-shrink: 0; font-size: 12px; color: var(--muted); }
.section-more:hover { color: var(--accent); }
.section-count { flex-shrink: 0; font-size: 12px; color: var(--muted-light, var(--muted)); }

/* ---------- 首页精选入口卡片 ---------- */
.home-featured-card {
  position: relative;
  display: block;
  aspect-ratio: 16 / 9;
  border-radius: 18px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.32);
}
/* 有关联 App 时略微增高，避免文案与 App 条拥挤 */
.home-featured-card.has-app { aspect-ratio: 16 / 10; }

/* 整卡点击层：位于图片之上、文案之下 */
.home-featured-link {
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: inherit;
}
.home-featured-link:focus-visible { outline-offset: -4px; }

.home-featured-media {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.home-featured-overlay {
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 56px 16px 16px;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.82));
  /* 点击穿透到整卡链接，只有 App 条内的按钮单独接收点击 */
  pointer-events: none;
}
.home-featured-overlay .app-strip {
  width: 100%;
  pointer-events: auto;
}

.home-featured-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
}

.home-featured-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
  color: #fff;
}
.home-featured-topic {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: 0.4px;
  color: #a5e7bc;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.5);
  overflow-wrap: anywhere;
}
.home-featured-copy strong {
  font-size: 20px;
  font-weight: 800;
  line-height: 1.26;
  letter-spacing: -0.4px;
  color: #fff;
  overflow-wrap: anywhere;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.45);
}
.home-featured-sub {
  font-size: 12.5px;
  line-height: 1.55;
  color: #dfe7e1;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.45);
}
.home-featured-enter {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.22);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  color: #fff;
  transition: background 0.18s ease;
}
.home-featured-enter svg { width: 20px; height: 20px; }
.home-featured-card:active .home-featured-enter { background: rgba(255, 255, 255, 0.42); }
@media (hover: hover) {
  .home-featured-card:hover .home-featured-enter { background: rgba(255, 255, 255, 0.34); }
}
@media (max-width: 400px) {
  .home-featured-overlay { padding: 48px 13px 13px; }
  .home-featured-topic { font-size: 11px; }
  .home-featured-copy strong { font-size: 18px; }
  .home-featured-sub { font-size: 12px; }
  .home-featured-enter { width: 36px; height: 36px; }
  .home-featured-enter svg { width: 18px; height: 18px; }
  .home-featured-overlay .app-strip { padding: 8px 10px; gap: 8px; }
  .home-featured-overlay .app-strip-logo { width: 36px; height: 36px; border-radius: 10px; }
  .home-featured-overlay .app-strip-name { font-size: 13px; }
}

/* 横向滚动：一屏 4 个，可左右滑动 */
.h-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
  margin-inline: -22px;
  padding: 2px 22px 4px;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x pan-y;
}
.h-scroll::-webkit-scrollbar { display: none; }
/* 第 5 个 App 图标在屏内露出约 10%，提示右侧可横向滑动 */
.h-inner { display: flex; gap: calc(21.3px - min(100vw, 560px) / 32); }
.h-card {
  flex: 0 0 calc((min(100vw, 560px) - 44px - 30px) / 4);
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.h-icon {
  width: 60px;
  height: 60px;
  border-radius: 14px;
  object-fit: contain;
  background: var(--surface);
  border: 1px solid #ffffff0d;
}
.h-name {
  width: 100%;
  font-size: 12px;
  line-height: 1.3;
  color: var(--ink);
  text-align: center;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow-wrap: anywhere;
}
.h-rating { font-size: 11px; color: #f7b500; line-height: 1.2; }

/* ---------- 全部应用 ---------- */
.list-empty {
  padding: 48px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  border: 1px dashed var(--border);
  border-radius: 14px;
}
.app-list { display: flex; flex-direction: column; gap: 10px; }
.app-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  transition: border-color 0.15s, background 0.15s;
}
.app-card:hover { border-color: var(--accent); background: #202721; }
.app-card-logo {
  width: 58px;
  height: 58px;
  border-radius: 14px;
  object-fit: contain;
  flex-shrink: 0;
  background: var(--surface-2, #222923);
  border: 1px solid #ffffff0d;
}
.app-card-body { flex: 1; min-width: 0; }
.app-card-name {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 15px;
  font-weight: 650;
  min-width: 0;
}
.app-card-name-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.app-card-cat {
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  background: #263229;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 6px;
}
.app-card-sub {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.app-card-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 7px;
  color: var(--muted);
  font-size: 11px;
  flex-wrap: wrap;
}
.app-card-rating { color: #f7b500; font-weight: 600; }
.app-card-arrow { width: 18px; height: 18px; color: var(--muted); flex-shrink: 0; }

/* ---------- 底部导航 ---------- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  inset-inline: 0;
  width: 100%;
  max-width: 560px;
  margin-inline: auto;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: rgba(28, 33, 29, 0.72);
  -webkit-backdrop-filter: blur(18px) saturate(1.5);
  backdrop-filter: blur(18px) saturate(1.5);
  border-top: 1px solid rgba(53, 64, 56, 0.72);
  z-index: 30;
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 0 7px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
  transform-origin: center bottom;
}
.bottom-nav a.active { color: var(--accent); }
.bottom-nav svg { width: 20px; height: 20px; }
@keyframes nav-pop {
  0% { transform: scale(1); }
  45% { transform: scale(1.16); }
  100% { transform: scale(1); }
}
.bottom-nav a.nav-pop {
  animation: nav-pop 0.34s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@media (prefers-reduced-motion: reduce) {
  .bottom-nav a.nav-pop { animation: none; }
}

/* ---------- 应用/游戏分类页 ---------- */
.category-page {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.category-menu {
  flex: 0 0 88px;
  position: sticky;
  /* 顶栏吸顶后占据 58px（含安全区），再留 12px 间距 */
  top: calc(70px + env(safe-area-inset-top));
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 2px 0;
  max-height: calc(100vh - 170px);
  overflow-y: auto;
  scrollbar-width: none;
}
.category-menu::-webkit-scrollbar { display: none; }
.category-menu a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  padding: 9px 8px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}
.category-menu a:hover { background: var(--surface); color: var(--ink); }
.category-menu a.active {
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
}
.category-content { flex: 1; min-width: 0; }
.category-content .section-head { margin-bottom: 10px; }
.category-content .section-head h2 { font-size: 16px; }

/* ---------- 安装按钮 / 新卡片 ---------- */
.app-card-main {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
  min-width: 0;
  color: inherit;
}
.app-card-install { gap: 10px; }
.install-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 54px;
  padding: 7px 12px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.install-btn:hover { background: #8cdba8; }
.install-btn.disabled {
  background: var(--surface-2, #222923);
  color: var(--muted);
  font-weight: 500;
}

/* 分类页右侧列表更紧凑 */
/* L 形分隔线：标题下方横线与列表左侧竖线，左上角圆角 */
.category-content .app-list {
  border-top: 1px solid var(--border);
  border-left: 1px solid var(--border);
  border-top-left-radius: 14px;
  padding: 10px 0 4px 12px;
}
/* 列表平铺：取消卡片背景、边框与圆角 */
.category-content .app-card {
  padding: 10px 8px;
  gap: 8px;
  background: transparent;
  border: 0;
  border-radius: 0;
}
.category-content .app-card:hover {
  background: rgba(255, 255, 255, 0.045);
}
.category-content .app-card-main { gap: 10px; }
.category-content .app-card-logo {
  width: 44px;
  height: 44px;
  border-radius: 11px;
}
.category-content .app-card-name { font-size: 13px; }
.category-content .app-card-sub { font-size: 11px; margin-top: 2px; }
.category-content .app-card-meta {
  gap: 6px;
  margin-top: 4px;
  font-size: 10px;
}
.category-content .app-card-name .app-card-cat { display: none; }
.category-content .install-btn {
  min-width: 44px;
  padding: 6px 8px;
  font-size: 11px;
}

/* ---------- 排行页 ---------- */
.ranking-main { padding-top: 20px; }
.ranking-main .section-head { margin-bottom: 12px; }
.ranking-main .section-head h2 { font-size: 18px; }
/* 排序说明：位于精选卡片下方、排行列表上方，字号字重与「下载排行」标题一致 */
.ranking-main .ranking-sort-note {
  margin-bottom: 12px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

/* 前三名：合并在一个圆角卡片内，行间用细线分隔 */
.ranking-main .ranking-top {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}
.ranking-main .ranking-top .app-card {
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
}
.ranking-main .ranking-top .app-card:last-child { border-bottom: 0; }
.ranking-main .ranking-top .app-card:hover {
  background: rgba(255, 255, 255, 0.045);
  border-color: transparent;
}
/* overflow: hidden 会裁掉默认 focus 外描边，改为内描边 */
.ranking-main .ranking-top .app-card-main:focus-visible,
.ranking-main .ranking-top .install-btn:focus-visible { outline-offset: -4px; }

/* 名次：1 名金色皇冠，2、3 名银色 / 铜色奖牌 */
.ranking-main .app-card-rank {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 40px;
  font-size: 15px;
  font-weight: 800;
  line-height: 1;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.ranking-main .app-card-rank .rank-medal { width: 18px; height: 18px; }
.ranking-main .app-card-rank.medal-1 { color: #f7b500; }
.ranking-main .app-card-rank.medal-2 { color: #c6d2cc; }
.ranking-main .app-card-rank.medal-3 { color: #d18a57; }

/* 4 名之后取消卡片背景，改为平铺列表 */
.ranking-main .app-list > .app-card {
  background: transparent;
  border-color: transparent;
}
.ranking-main .app-list > .app-card:hover {
  background: rgba(255, 255, 255, 0.045);
  border-color: transparent;
}

/* 右侧信息更紧凑：压缩行高、行距与卡片上下内边距 */
.ranking-main .app-card { padding-block: 11px; }
.ranking-main .app-card-name { line-height: 1.3; }
.ranking-main .app-card-meta {
  margin-top: 4px;
  row-gap: 4px;
  column-gap: 6px;
  line-height: 1.35;
}

@media (max-width: 400px) {
  .home-main,
  .market-main { padding-inline: 17px; }
  .h-scroll { margin-inline: -17px; padding-inline: 17px; }
  .h-card { flex-basis: calc((min(100vw, 560px) - 34px - 30px) / 4); }
  .h-inner { gap: calc(19.15px - 100vw / 32); }
  .h-icon { width: 54px; height: 54px; border-radius: 12px; }
  .app-card { padding: 12px; gap: 12px; }
  .app-card-logo { width: 52px; height: 52px; border-radius: 12px; }
  .category-menu { flex-basis: 78px; }
  .category-content .app-card { padding: 9px 6px; gap: 6px; }
  .category-content .app-card-logo { width: 40px; height: 40px; border-radius: 10px; }
  .category-content .app-card-main { gap: 8px; }
  .category-content .install-btn { min-width: 40px; padding: 6px; font-size: 10px; }
  .ranking-main .app-card { padding-block: 10px; }
  .ranking-main .app-card-rank { width: 30px; font-size: 14px; }
  .ranking-main .app-card-rank .rank-medal { width: 16px; height: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .banner-slide { transition: none; }
}
