/* 对齐 App：不随系统字体缩放（iOS/Android WebView 常用） */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

:root {
  --bg: #f8f8f8;
  --ink: #333333;
  --muted: rgba(0, 0, 0, 0.3);
  --brand: #89f800;
  --brand-dot: #88fa00;
  --price-from: #ff0028;
  --price-to: #ff0093;
  --phone-w: 375px;
  /* Figma 957:326 实测（375×812） */
  --design-w: 375px;
  --space-page: 10px;
  --space-brand-x: 16px;
  --space-status-to-brand: 12px;
  --space-search-x: 22px;
  --space-city-search: 16px;
  --space-section: 8px;
  --space-promo-gap: 12px;
  --space-goods-gap: 11px;
  --banner-h: 211px;
  --cats-h: 146px;
  --promo-row-w: 355px;
  --promo-w: 110px;
  --promo-h: 108px;
  --tab-h: 26px;
  --space-tabbar-x: 15px;
  --space-tabbar-bottom: 20px;
  --tabbar-height: 51px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  min-height: 100%;
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(900px 480px at 12% -8%, #dfffc7 0%, transparent 55%),
    linear-gradient(180deg, #eef3ea 0%, #dfe6e0 100%);
  display: grid;
  justify-items: center;
  padding: 24px 12px 40px;
}

.phone {
  width: min(100%, var(--phone-w));
  min-height: 812px;
  max-height: min(812px, calc(100vh - 48px));
  height: min(812px, calc(100vh - 48px));
  background:
    linear-gradient(
      180deg,
      #dfffc7 0%,
      #e2fdb9 40.865%,
      rgba(229, 255, 134, 0) 83.173%
    ),
    var(--bg);
  background-size: 100% 163px, 100% 100%;
  background-repeat: no-repeat;
  border-radius: 28px;
  box-shadow: 0 24px 64px rgba(20, 40, 30, 0.16);
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
  padding-bottom: 0;
}

/* 可滚动内容区；底栏在 .phone 外层固定，不随滚动漂移 */
.phone-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(var(--tabbar-height) + var(--space-tabbar-bottom) + var(--space-section));
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE/Edge legacy */
}
.phone-scroll::-webkit-scrollbar {
  display: none; /* Chrome/Safari */
}

/* 设计稿假状态栏（9:41/信号）：真机由系统状态栏承担，隐藏避免重复 */
.status-bar {
  display: none !important;
  height: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  overflow: hidden !important;
  pointer-events: none !important;
}

.status-icons {
  display: flex;
  gap: 6px;
  align-items: center;
}

.signal,
.wifi,
.battery {
  display: block;
  background: #111;
}

.signal {
  width: 16px;
  height: 10px;
  clip-path: polygon(0 100%, 20% 70%, 40% 85%, 60% 50%, 80% 65%, 100% 20%, 100% 100%);
}

.wifi {
  width: 14px;
  height: 10px;
  border-radius: 50% 50% 0 0;
  opacity: 0.85;
}

.battery {
  width: 22px;
  height: 10px;
  border-radius: 3px;
}

/* 假状态栏隐藏后，给顶部内容留出刘海/系统栏安全区（分类等无 brand-bar 的页） */
.phone > .cat-head,
.phone > .aa-head,
.detail-shell > .detail-nav,
.phone > .search-head {
  padding-top: max(0px, env(safe-area-inset-top, 0px));
}

.brand-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 25px;
  margin-top: max(var(--space-status-to-brand), env(safe-area-inset-top, 0px));
  padding: 0 var(--space-brand-x);
}

.brand-header {
  width: 220px;
  height: 25px;
  object-fit: contain;
  object-position: left center;
  display: block;
  flex: 0 0 auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.logo-wrap {
  width: 44px;
  height: 25px;
  overflow: hidden;
  flex: 0 0 auto;
}

.logo {
  width: 44px;
  height: 135%;
  object-fit: cover;
  object-position: top center;
  display: block;
}

.brand-title {
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 0.02em;
  background: linear-gradient(90deg, #66ff33, #00c9a7 45%, #00aeef);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  white-space: nowrap;
}

.badge {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 74px;
  height: 22px;
}

.badge img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.badge em {
  position: relative;
  z-index: 1;
  font-style: normal;
  font-size: 13px;
  font-weight: 800;
  color: #fff;
  line-height: 1;
}

.msg {
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  display: grid;
}

.city {
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0;
  cursor: pointer;
  white-space: nowrap;
  flex: 0 0 auto;
  max-width: 42%;
  padding: 0;
}

.city span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  border: 0;
  background: transparent;
  border-radius: 34px;
  padding: 0 8px;
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.search-ph {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 12px;
  color: rgba(0, 0, 0, 0.3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.content {
  padding: var(--space-section) var(--space-page) var(--space-section);
}

.hero {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  height: var(--banner-h);
  background: #0d4034;
}

.hero-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* App BannerSearchBar：叠在轮播顶部，半透明白底圆角条 */
.banner-search {
  position: absolute;
  left: 0;
  right: 0;
  top: 12px;
  z-index: 2;
  display: flex;
  align-items: center;
  height: 36px;
  margin: 0;
  padding: 0 10px 0 12px;
  border-radius: 34px;
  background: rgba(255, 255, 255, 0.86);
  gap: var(--space-city-search);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.banner-search.is-hidden {
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
}

.dots {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 10px;
  display: flex;
  justify-content: center;
  gap: 8px;
  z-index: 1;
}

.dots span {
  width: 8px;
  height: 8px;
  border-radius: 16px;
  background: rgba(51, 51, 51, 0.2);
}

.dots .on {
  width: 23px;
  background: var(--brand-dot);
}

.cats {
  margin-top: var(--space-section);
  height: var(--cats-h);
  box-sizing: border-box;
  /* 左右收紧，给四字标签留足宽度，避免贴边裁切 */
  padding: 10px 6px;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  grid-template-rows: 56px 56px;
  align-content: space-between;
  justify-items: stretch;
  column-gap: 0;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid #fff;
  border-radius: 16px;
  backdrop-filter: blur(15px);
  overflow: visible;
}

.cats a {
  text-decoration: none;
  color: #000;
  width: 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 0;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  overflow: visible;
  text-align: center;
}

/* App：39×39 热区，图片按 Figma 实测宽高居中，禁止统一放大 */
.cats .cat-ico {
  width: 39px;
  height: 39px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}

.cats .cat-ico img {
  width: auto;
  height: auto;
  max-width: 39px;
  max-height: 39px;
  object-fit: contain;
  display: block;
}

.promo-row {
  margin-top: var(--space-section);
  width: var(--promo-row-w);
  height: var(--promo-h);
  display: flex;
  gap: var(--space-promo-gap);
  align-items: stretch;
}

/* 对齐 App PromoCard：装饰块 + 产品图(13,0) + 顶遮罩/标题 + 左下渐变角标 */
.promo {
  position: relative;
  width: var(--promo-w);
  height: var(--promo-h);
  display: block;
  flex: 0 0 auto;
  text-decoration: none;
  color: inherit;
  overflow: visible;
}

.promo-deco {
  position: absolute;
  left: 0;
  top: 11px;
  width: 97px;
  height: 97px;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(155, 255, 0, 0.25), rgba(217, 255, 152, 0.25));
  pointer-events: none;
}

.promo-img {
  position: absolute;
  left: 13px;
  top: 0;
  width: 97px;
  height: 97px;
  border-radius: 14px;
  object-fit: cover;
  display: block;
  background: #f3f3f3;
}

.promo-shade {
  position: absolute;
  left: 13px;
  top: 0;
  width: 97px;
  height: 97px;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.5), transparent);
  pointer-events: none;
}

.promo-title {
  position: absolute;
  left: 25px;
  top: 10px;
  right: 8px;
  z-index: 2;
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  pointer-events: none;
}

.promo-badge {
  position: absolute;
  left: 0;
  bottom: 0;
  z-index: 3;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 0 10px 0 10px;
  background: linear-gradient(180deg, #86ff00, #eeff05);
  pointer-events: none;
}

.promo-badge em {
  font-style: normal;
  font-size: 12px;
  font-weight: 700;
  line-height: 14px;
  color: rgba(0, 0, 0, 0.75);
  text-align: center;
}

.tabs {
  margin-top: var(--space-section);
  display: flex;
  gap: var(--space-section);
  overflow-x: auto;
  scrollbar-width: none;
  position: sticky;
  top: 0;
  z-index: 39;
  background: var(--bg);
  padding: 0 0 var(--space-section);
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  flex: 0 0 auto;
  border: 0;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  font-weight: 500;
  padding: 0 8px;
  height: var(--tab-h);
  line-height: var(--tab-h);
  border-radius: 12.5px;
  cursor: pointer;
}

.tab.on {
  background: var(--brand);
  font-weight: 800;
  border-radius: 32px;
  padding: 0 12px;
}

.goods {
  margin-top: var(--space-section);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-goods-gap);
}

/* 优选专区仅 1 款：单列正常展示 */
.goods.is-single {
  grid-template-columns: 1fr;
}

.goods.is-single .thumb {
  height: 220px;
}

.card {
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  padding-bottom: 10px;
}

.thumb {
  position: relative;
  height: 168px;
  background: #f3f3f3;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.badge-sale {
  position: absolute;
  left: 5px;
  top: 5px;
  background: var(--brand);
  color: #000;
  font-size: 10px;
  font-weight: 700;
  border-radius: 16px;
  padding: 2px 8px;
  min-width: 32px;
  text-align: center;
}

.card h3 {
  font-size: 16px;
  font-weight: 600;
  /* Figma 1023:2551：图底 → 标题 6px；标题行高 22.4px；标题底 → 标签行 2px */
  margin: 6px 8px 2px;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #140e0e;
}

.desc {
  margin: 0 8px;
  font-size: 12px;
  /* Figma 1023:2551：标签行行高 16.8px */
  line-height: 1.4;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.price-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  /* Figma 1023:2551：标签行底 → 价格顶 0px（紧贴） */
  margin: 0 8px 2px;
}

.price {
  background: linear-gradient(90deg, var(--price-from), var(--price-to));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-weight: 700;
}

.price b {
  font-size: 24px;
  font-weight: 700;
}

.price small {
  font-size: 16px;
}

.origin {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-decoration: line-through;
}

.sold {
  margin: 0 8px;
  font-size: 12px;
  color: var(--muted);
}

/* 对齐 App BottomBar：固定在 .phone 底部（不随内容滚动），345×51、SpaceEvenly、绿胶囊 */
.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));
  height: var(--tabbar-height);
  background: #fff;
  border: 1px solid #fff;
  border-radius: 67px;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-evenly;
  z-index: 200;
  pointer-events: auto;
  overflow: visible;
  box-sizing: border-box;
}

.float-cart-wrap {
  position: absolute;
  right: var(--space-page);
  top: 50%;
  transform: translateY(-50%);
  z-index: 45;
  width: 56px;
  height: 56px;
  transition: opacity 0.18s ease;
}

.float-cart-wrap.is-scrolling {
  opacity: 0;
  pointer-events: none;
}

.float-cart {
  position: relative;
  width: 56px;
  height: 56px;
  border: 0;
  padding: 0;
  margin: 0;
  background: transparent url("./assets/detail-cart.png") center / contain no-repeat;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.float-cart-close {
  position: absolute;
  top: -4px;
  left: -4px;
  z-index: 2;
  width: 18px;
  height: 18px;
  border: 0;
  padding: 0;
  border-radius: 50%;
  background: #1c330d;
  color: #fff;
  font-size: 13px;
  line-height: 16px;
  cursor: pointer;
}

.float-cart-peek {
  display: none;
  width: 16px;
  height: 44px;
  border: 0;
  padding: 0;
  border-radius: 10px 0 0 10px;
  background: var(--brand);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.16);
  cursor: pointer;
}

.float-cart-wrap.is-hidden {
  right: 0;
  width: 16px;
  height: 44px;
}

.float-cart-wrap.is-hidden .float-cart,
.float-cart-wrap.is-hidden .float-cart-close {
  display: none;
}

.float-cart-wrap.is-hidden .float-cart-peek {
  display: block;
}

.float-cart svg {
  display: none;
}

.float-cart .cart-count {
  display: none;
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  padding: 0 3px;
  border-radius: 25px;
  background: #f73a2c;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  line-height: 16px;
  text-align: center;
  box-sizing: border-box;
}

.float-cart .cart-count.is-on {
  display: block;
}

/* 上滑后右上角搜索（对齐 App） */
.float-search {
  position: absolute;
  top: 48px;
  right: var(--space-page);
  z-index: 46;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  cursor: pointer;
  display: grid;
  place-items: center;
}

.float-search[hidden] {
  display: none !important;
}

/* App：选中绿胶囊高 28；图标 30 略突出上下沿；右内边距 12；字号 16 Medium */
.tabbar .item {
  flex: 1 1 0;
  min-width: 0;
  text-decoration: none;
  color: rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  font-size: 16px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.tabbar .item.active {
  color: #000;
}

.tabbar .pill {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 4px;
  height: 28px;
  max-width: 100%;
  box-sizing: border-box;
  border-radius: 46px;
  background: transparent;
  padding: 0;
  overflow: visible;
}

.tabbar .item.active .pill {
  background: var(--brand);
  padding: 0 12px 0 0; /* 对齐 App：图标贴左，右侧留 12 */
}

.tabbar .pill img {
  width: 30px;
  height: 30px;
  display: block;
  flex-shrink: 0;
  object-fit: contain;
}

.tabbar .pill > span {
  white-space: nowrap;
  font-size: 16px;
  font-weight: 500;
}

.tabbar .item:not(.active) img {
  opacity: 0.25;
}

.tabbar .item:not(.active) .pill > span {
  color: rgba(0, 0, 0, 0.25);
}

.tabbar .item.active .pill > span {
  color: #000;
}

@media (max-width: 420px) {
  body {
    padding: 0;
    background: var(--bg);
  }

  .phone {
    width: 100%;
    min-height: 100dvh;
    max-height: none;
    height: 100dvh;
    border-radius: 0;
    box-shadow: none;
  }

  .phone-scroll {
    padding-bottom: calc(var(--tabbar-height) + max(var(--space-tabbar-bottom), env(safe-area-inset-bottom, 0px)) + var(--space-section));
  }

  .tabbar {
    bottom: max(var(--space-tabbar-bottom), env(safe-area-inset-bottom, 0px));
  }
}
