/* home.css — Home screen: common headers, sections, filter chips, cat-* headers, station-scroll */

#view-chat { display: flex; flex-direction: column; bottom: calc(50px + env(safe-area-inset-bottom, 0px)); }

.view-scroll {
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  /* 1. 彻底清空 padding，加上 !important 防止被底层基础 CSS 覆盖导致双重留白 */
  padding-top: 0 !important;
  padding-bottom: calc(130px + env(safe-area-inset-bottom, 0px));
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
}

/* 2. 终极完美解法：为滚动容器的顶部生成一个永远吸附的“状态栏挡板” */
.view-scroll::before {
  content: '';
  display: block;
  position: -webkit-sticky;
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  height: env(safe-area-inset-top, 0px);
  background: var(--main-bg);
  z-index: 50; /* 最高层级，专门负责遮住滑上去的任何内容 */
}

.common-header {
  display: flex; align-items: center; justify-content: space-between;
  /* 3. 恢复最原始的间距，无需再计算刘海，因为上方的挡板已经把位置占好了 */
  padding: 10px var(--edge-pad) 6px var(--edge-pad);
  position: relative;
}
.header-title {
  font-size: 28px; font-weight: 800; letter-spacing: -0.5px;
  color: var(--text-dark);
  margin: 0;
}
.header-logo {
  width: 40px; height: 40px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
}

.home-section { padding: 0 var(--edge-pad); margin-bottom: 4px; }

/* ──────────────────────────────────────────────────────────────────────────
   ★ v3.10: 主页顶部 chip 条 (sticky 在 view-scroll 顶部)
   ────────────────────────────────────────────────────────────────────────── */
.home-chip-bar {
  /* 4. 删除之前那个惹祸的局部遮罩，只需纯粹的吸顶即可 */
  position: -webkit-sticky;
  position: sticky;
  top: env(safe-area-inset-top, 0px); /* 向上滑时，刚好吸附在挡板的正下方 */
  z-index: 40; /* 层级低于挡板(50)，但高于电台卡片 */
  background: var(--main-bg);
  margin-top: 4px;
  padding: 8px 0 10px 0;
  transition: box-shadow 0.2s ease;
}

.home-chip-track {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0 var(--edge-pad);
  scrollbar-width: none; -ms-overflow-style: none;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  scroll-behavior: smooth;
}
.home-chip-track::-webkit-scrollbar { display: none; }

.home-chip {
  flex-shrink: 0;
  padding: 8px 16px;
  border-radius: 18px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-dark);
  background: rgba(0, 0, 0, 0.06);
  border: none;
  cursor: pointer;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
}
.home-chip:active { transform: scale(0.96); }
.home-chip.active {
  background: var(--text-dark);
  color: var(--card-bg);
}
@media (prefers-color-scheme: dark) {
  .home-chip { background: rgba(255, 255, 255, 0.1); }
  .home-chip.active { background: var(--text-dark); color: var(--main-bg); }
}

.home-grid {
  display: grid;
  
  /* 👇 删掉写死的 repeat(4, 1fr)，替换成下面这行“自适应填充” 👇 */
  grid-template-columns: repeat(auto-fill, minmax(74px, 1fr));
  
  gap: 16px 8px;
  padding: 12px var(--edge-pad);
  justify-items: center;
}
.home-grid .station-card {
  width: 100%;
  max-width: 74px;
  min-width: 0;
  scroll-snap-align: unset; 
}

.home-grid-empty {
  padding: 40px var(--edge-pad);
  text-align: center;
  color: var(--tab-inactive);
  font-size: 14px;
}

.section-title {
  font-size: 20px; font-weight: 700; color: var(--text-dark);
  margin: 6px 0 6px 0;
}

.filter-row {
  display: flex; gap: 8px;
  padding: 0 var(--edge-pad) 4px var(--edge-pad);
  margin-bottom: 4px;
  /* 5. 搜索页的过滤条同步修改，清爽吸顶 */
  position: -webkit-sticky;
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 40;
  background: var(--main-bg);
}

.filter-chip {
  padding: 6px 18px; border-radius: 20px;
  font-size: 13px; font-weight: 600;
  color: var(--text-dark); background: transparent;
  border: 1px solid transparent;
  opacity: 0.5; cursor: pointer;
  transition: all 0.2s;
}
.filter-chip.active {
  background: var(--glass-bg);
  border-color: var(--glass-border);
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  opacity: 1; color: var(--primary);
}

.cat-section { margin-bottom: 0px; }

.cat-header {
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 5px var(--edge-pad);
  margin-bottom: 5px;
  margin-top: 0;
  border-bottom: 0.5px solid transparent;
  transition: border-color 0.2s;
}

.cat-title {
  font-size: 20px; font-weight: 700;
  color: var(--text-dark); margin: 0;
}

.cat-see-all {
  background: none; border: none;
  cursor: pointer;
  color: var(--tab-inactive);
  display: flex; align-items: center; justify-content: center;
  padding: 4px;
  transition: opacity 0.2s;
}
.cat-see-all:active { opacity: 0.6; }
.cat-see-all svg { width: 18px; height: 18px; stroke-width: 2.5px; }

.station-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto; overflow-y: hidden;
  scroll-snap-type: x proximity;
  padding: 0 var(--edge-pad) 0 var(--edge-pad);
  scroll-padding-left: var(--edge-pad);
  scroll-padding-right: var(--edge-pad);
  scrollbar-width: none; -ms-overflow-style: none;
  justify-content: flex-start;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}
.station-scroll::-webkit-scrollbar { display: none; }