/* 分类页 · 对齐 App CategoryScreen（Apple 设计语言版）
   层级：整页灰底 → 顶部胶囊/白卡 → 左栏浅灰目录 → 右栏白底商品。
   色板与 App 一致：PageBg #F8F8F8 / Rail #EFEFF2 / Brand var(--brand) / PriceRed #F73A2C */

.cat-phone {
  min-height: 810px;
  height: min(812px, calc(100vh - 48px));
  max-height: min(812px, calc(100vh - 48px));
  background-color: #f8f8f8;
  background-image: linear-gradient(
    180deg,
    #dfffc7 0%,
    #c8f59a 38%,
    #e8f8d0 74%,
    rgba(248, 248, 248, 0) 100%
  );
  background-size: 100% 138px;
  background-repeat: no-repeat;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  padding-bottom: 0;
}

.cat-phone .tabbar {
  position: absolute;
  left: var(--space-tabbar-x);
  right: var(--space-tabbar-x);
  bottom: max(var(--space-tabbar-bottom), env(safe-area-inset-bottom, 0px));
  z-index: 200;
}

@media (max-width: 420px) {
  .cat-phone {
    min-height: 100dvh;
    max-height: none;
    height: 100dvh;
  }
}

/* ---- 顶部：标题 28px/600 负字距 + 白色搜索胶囊 ---- */
.cat-head {
  padding: 14px 20px 0;
}

.cat-title {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.6px;
  color: #1d1d1f;
  margin: 0 0 12px;
}

.cat-searchbar {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 12px 0 14px;
  background: #fff;
  border-radius: 12px;
}
.cat-searchbar img { display: block; opacity: 0.45; }
.cat-searchbar input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 14px;
  letter-spacing: -0.2px;
  color: #1d1d1f;
}
.cat-searchbar input::placeholder { color: #6e6e73; }
.cat-searchbar input::-webkit-search-cancel-button { display: none; }
.cat-clear {
  border: 0;
  background: transparent;
  padding: 4px;
  font-size: 13px;
  line-height: 1;
  color: #6e6e73;
  cursor: pointer;
}

/* ---- ① 一级分类：横滑胶囊条 —— 对齐首页 .tabs / .tab ---- */
.cat-tabs {
  display: flex;
  align-items: center;
  gap: var(--space-section, 8px);
  overflow-x: auto;
  overflow-y: hidden;
  padding: var(--space-section, 8px) var(--space-page, 10px);
  margin: 0;
  scrollbar-width: none;
  -ms-overflow-style: none;
  flex-shrink: 0;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x;
  overscroll-behavior-x: contain;
}
.cat-tabs::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}
.cat-tabs .tab {
  flex: 0 0 auto;
  box-sizing: border-box;
  height: var(--tab-h, 26px);
  line-height: var(--tab-h, 26px);
  padding: 0 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 12.5px;
  background: #fff;
  font: inherit;
  font-size: 16px;
  font-weight: 500;
  letter-spacing: normal;
  color: var(--ink, #333);
  cursor: pointer;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  box-shadow: none;
}
.cat-tabs .tab.on {
  background: var(--brand, #89f800);
  font-weight: 800;
  color: #000;
  border-radius: 32px;
  padding: 0 12px;
}

/* ---- 主体：左栏目录 + 右栏商品 ---- */
.cat-body {
  flex: 1;
  display: flex;
  min-height: 0;
  margin-top: 8px;
  align-items: stretch;
  overflow: hidden;
  /* 给固定底栏留空，避免列表被挡住 */
  padding-bottom: calc(var(--tabbar-height) + var(--space-tabbar-bottom));
}

/* ② 左栏：二级分类（灰底，选中 = 白底 + 品牌绿刻度）
   对齐 App RailWidth=76dp：约 4 个 13px 汉字 + 内边距 */
.cat-rail {
  width: 76px;
  flex-shrink: 0;
  box-sizing: border-box;
  background: #efeff2;
  padding: 4px 0 16px;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.cat-rail::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}
.cat-rail .rail-item {
  position: relative;
  display: flex;
  align-items: center;
  box-sizing: border-box;
  width: 100%;
  min-height: 52px;
  padding: 6px 6px 6px 14px;
  font-size: 13px;
  letter-spacing: -0.15px;
  line-height: 17px;
  color: #6e6e73;
  cursor: pointer;
  user-select: none;
  /* 超出 4 字宽度时换行，不撑破左栏 */
  white-space: normal;
  overflow-wrap: break-word;
  word-break: break-word;
}
.cat-rail .rail-item.on {
  background: #fff;
  font-size: 13.5px;
  font-weight: 600;
  color: #1d1d1f;
}
.cat-rail .rail-item.on::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 2px;
  height: 16px;
  border-radius: 1px;
  background: var(--brand, #89f800);
}
.cat-rail .rail-msg {
  padding: 40px 10px 0;
  font-size: 12px;
  color: #6e6e73;
  text-align: center;
}

/* ③ 右栏：排序条 + 商品网格（整幅白底）；仅纵向滚动，禁止左右滑动 */
.cat-pane {
  flex: 1 1 0;
  min-width: 0;
  min-height: 0;
  background: #fff;
  margin: 0 8px 0 0;
  padding: 0 8px;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  overscroll-behavior-x: none;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.cat-pane::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

/* 排序条：文字 + 选中项下方品牌绿短线 */
.cat-sort {
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 2px 0 8px;
  flex-shrink: 0;
}
.cat-sort button {
  border: 0;
  background: transparent;
  padding: 6px 2px 0;
  font-size: 13px;
  letter-spacing: -0.15px;
  color: #6e6e73;
  cursor: pointer;
  position: relative;
}
.cat-sort button.on {
  font-weight: 600;
  color: #1d1d1f;
}
.cat-sort button.on::after {
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 18px;
  height: 2.5px;
  border-radius: 1.25px;
  background: var(--brand, #89f800);
}

/* 商品网格：两列大图卡（同 App：无壳，图 1:1.22 圆角 12） */
.cat-goods {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  column-gap: 8px;
  row-gap: 8px;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  padding-bottom: 76px;
}

/* 优选专区：单列；一卡占满右栏整宽（原先两列合计宽度） */
.cat-goods.is-single {
  display: flex;
  flex-direction: column;
  grid-template-columns: none;
  gap: 12px;
  width: 100%;
}
.cat-goods.is-single .cg {
  display: block;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  flex: 0 0 auto;
}
.cat-goods.is-single .cg .thumb {
  width: 100%;
  /* 沿用双列卡片比例，随右栏整宽拉伸，不另改裁切规则 */
  aspect-ratio: 0.82;
}
.cat-goods.is-single .cg-body {
  display: flex;
  flex-direction: column;
  gap: 0;
  width: 100%;
  box-sizing: border-box;
  padding: 0 2px;
}
.cat-goods.is-single .cg-name {
  margin: 10px 0 0;
  min-height: 0;
  font-size: 15px;
  font-weight: 600;
  line-height: 22px;
  letter-spacing: -0.25px;
  color: #1d1d1f;
  -webkit-line-clamp: 2;
}
.cat-goods.is-single .cg .price-row {
  margin-top: 8px;
  align-items: baseline;
  gap: 8px;
}
.cat-goods.is-single .cg .price {
  font-size: 22px;
  letter-spacing: -0.5px;
}
.cat-goods.is-single .cg .price small {
  font-size: 15px;
}
.cat-goods.is-single .cg .origin {
  font-size: 13px;
}
.cat-goods.is-single .cg .sold {
  margin-top: 6px;
}

.cg {
  cursor: pointer;
  min-width: 0;
}
.cg .thumb {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  background: #f5f5f7;
  aspect-ratio: 0.82;
}
.cg .thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.cg .badge-sale {
  position: absolute;
  left: 5px;
  top: 5px;
  min-width: 31.7px;
  height: 17px;
  padding: 0 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8.5px;
  background: var(--brand, #89f800);
  color: #000;
  font-size: 10px;
  font-weight: 700;
  line-height: 10px;
}
.cg-body {
  min-width: 0;
}
.cg-name {
  margin: 8px 0 0;
  min-height: 38px;
  font-size: 13px;
  line-height: 19px;
  letter-spacing: -0.15px;
  color: #1d1d1f;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.cg .price-row {
  margin-top: 6px;
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
}
.cg .price {
  color: #f73a2c;
  font-weight: 800;
  letter-spacing: -0.4px;
  font-size: 20px;
  line-height: 1;
}
.cg .price small { font-size: 14px; }
.cg .origin {
  font-size: 12px;
  color: #86868b;
  text-decoration: line-through;
}
.cg .sold {
  margin: 4px 0 0;
  font-size: 12px;
  letter-spacing: -0.1px;
  color: #86868b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 加载尾：加载中 / 已经到底了 */
.cat-foot {
  text-align: center;
  padding: 12px 0 80px;
  font-size: 12px;
  letter-spacing: -0.1px;
  color: #86868b;
}

/* 骨架屏：浅灰块呼吸 */
.sk {
  border-radius: 12px;
  background: #e8e8ed;
  animation: skBreath 1s ease-in-out infinite alternate;
}
@keyframes skBreath {
  from { opacity: 0.55; }
  to   { opacity: 0.95; }
}

/* 空态 / 错误态：圆形图标位 + 一句话 + 动作按钮 */
.cat-state {
  text-align: center;
  padding: 48px 12px 90px;
}
.cat-state .ico {
  width: 56px;
  height: 56px;
  margin: 0 auto 18px;
  border-radius: 50%;
  background: #f5f5f7;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: #6e6e73;
}
.cat-state strong {
  display: block;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.3px;
  color: #1d1d1f;
}
.cat-state span {
  display: block;
  margin-top: 8px;
  font-size: 13px;
  letter-spacing: -0.15px;
  color: #6e6e73;
}
.cat-state .retry {
  margin-top: 20px;
  border: 0;
  height: 40px;
  padding: 0 24px;
  border-radius: 999px;
  background: var(--brand, #89f800);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.2px;
  color: #1c330d;
  cursor: pointer;
}

/* 分类页禁止假状态栏占位 */
.cat-phone > .status-bar { display: none !important; height: 0 !important; }
