/* ============================================================
   商品查询 · H5
   移动优先；桌面端自动收窄为 480px 居中
   ============================================================ */

:root {
  --text: #16192b;
  --sub: #6b7280;
  --mute: #9aa1ad;
  --line: #eceef2;
  --bg: #f4f5f7;
  --card: #ffffff;
  --brand: #2563eb;
  --brand-soft: #eef4ff;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --hd-h: 0px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img { display: block; max-width: 100%; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input { font: inherit; color: inherit; border: 0; outline: 0; background: none; }
a { color: inherit; text-decoration: none; }

/* 桌面端：收窄居中 */
@media (min-width: 560px) {
  body { background: #e9ecf1; }
  .app {
    max-width: 480px;
    margin: 0 auto;
    box-shadow: 0 0 0 1px rgba(16, 24, 40, .06), 0 18px 50px rgba(16, 24, 40, .1);
    background: var(--bg);
    min-height: 100vh;
  }
}

/* ==================== 顶部 ==================== */
.hd {
  position: sticky;
  top: 0;
  z-index: 30;
  background: #fff;
  padding-top: env(safe-area-inset-top, 0px);
}

.hd-row { padding: 8px 12px 6px; }

.search {
  display: flex;
  align-items: center;
  height: 40px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--bg);
  border: 1.5px solid transparent;
  transition: background .16s, border-color .16s;
}

.search.on {
  background: #fff;
  border-color: var(--brand);
}

.mag {
  width: 18px;
  height: 18px;
  flex: none;
  color: var(--mute);
  margin-right: 8px;
}

.search.on .mag { color: var(--brand); }

.search input {
  flex: 1;
  min-width: 0;
  height: 40px;
  font-size: 15px;
  appearance: none;
  -webkit-appearance: none;
}

.search input::placeholder { color: var(--mute); }
.search input::-webkit-search-cancel-button { display: none; }

.clr {
  flex: none;
  width: 18px;
  height: 18px;
  margin-left: 6px;
  color: #c7ccd4;
}

.clr svg { width: 100%; height: 100%; }

/* ---------- 大分类 ---------- */
.tabs {
  display: flex;
  gap: 2px;
  padding: 0 8px;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  border-bottom: 1px solid var(--line);
}

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

.tab {
  position: relative;
  flex: none;
  height: 42px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  color: var(--sub);
}

.tab b { font-weight: 400; font-size: 11px; color: var(--mute); }
.tab.on { color: var(--text); font-weight: 600; }
.tab.on b { color: var(--brand); }

.tab.on::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 20px;
  height: 2.5px;
  border-radius: 2px;
  background: var(--brand);
  transform: translateX(-50%);
}

/* ---------- 筛选行 ---------- */
.fbar { background: #fff; }

.fbar-in {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px 9px;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
}

.fbar-in::-webkit-scrollbar { display: none; }

.chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 11px;
  border-radius: 999px;
  background: var(--bg);
  color: var(--sub);
  font-size: 12.5px;
}

.chip.primary { background: var(--brand-soft); color: var(--brand); font-weight: 500; }
.chip.on { background: var(--brand-soft); color: var(--brand); box-shadow: inset 0 0 0 1px #c7dbff; }
.chip.ghost { background: #fff; color: var(--mute); box-shadow: inset 0 0 0 1px var(--line); }

.chip .badge {
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font-size: 10.5px;
  line-height: 16px;
  text-align: center;
}

.arr { width: 9px; height: 6px; opacity: .75; }
.chip .x { font-size: 13px; opacity: .5; margin-left: 1px; }

/* ==================== 统计 ==================== */
.summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px 7px;
  font-size: 12px;
  color: var(--mute);
}

.summary b { color: var(--text); font-weight: 600; }
.summary .r.brand { color: var(--brand); }

/* ==================== 列表 ==================== */
.list { padding: 0 12px calc(24px + var(--safe-b)); }

.item {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--card);
  border-radius: 10px;
  padding: 11px;
  margin-bottom: 8px;
  box-shadow: 0 1px 4px rgba(16, 24, 40, .04);
  transition: background .12s;
}

.item:active { background: #fbfcfd; }

/* 浏览态：无图紧凑行 */
.item.plain { padding: 9px 10px 9px 7px; margin-bottom: 6px; border-radius: 8px; }

.cbar {
  flex: none;
  width: 3px;
  height: 26px;
  border-radius: 2px;
  margin-right: 10px;
  background: var(--brand);
}

.cbar.b1 { background: #2563eb; }
.cbar.b2 { background: #e08a2e; }
.cbar.b3 { background: #7a5af0; }

.thumb {
  flex: none;
  width: 78px;
  height: 78px;
  border-radius: 8px;
  overflow: hidden;
  background: #f2f3f6;
  margin-right: 11px;
}

.thumb-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fff;
}

.thumb-ph {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  color: #b6bcc7;
  letter-spacing: .5px;
  background: linear-gradient(135deg, #f5f6f8, #eceef2);
}

.info { flex: 1; min-width: 0; }

.name {
  font-size: 14.5px;
  line-height: 20px;
  font-weight: 500;
  color: var(--text);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  word-break: break-all;
}

.item.plain .name { -webkit-line-clamp: 1; line-height: 19px; }

.sub {
  margin-top: 4px;
  font-size: 12px;
  color: var(--mute);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sub .code { color: var(--sub); font-variant-numeric: tabular-nums; }
.sub i { font-style: normal; margin: 0 5px; opacity: .55; }

/* 中分类：从灰色小字里独立出来，加底色和字重，扫列表时能一眼分辨品类 */
.sub .mid {
  display: inline-block;
  margin-left: 6px;
  padding: 0 5px;
  font-style: normal;
  font-size: 11px;
  line-height: 16px;
  font-weight: 600;
  color: #1b2233;
  background: #dde2ea;
  border-radius: 3px;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: 1px;
}
.sub .mid mark { background: #ffe9a8; color: inherit; border-radius: 2px; }

.tags { display: flex; gap: 5px; margin-top: 6px; overflow: hidden; }

.tag {
  flex: none;
  font-size: 10.5px;
  line-height: 17px;
  padding: 0 6px;
  border-radius: 4px;
  background: var(--bg);
  color: var(--sub);
  white-space: nowrap;
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tag.b1 { background: #eef4ff; color: #2563eb; }
.tag.b2 { background: #fff3e6; color: #c2650a; }
.tag.b3 { background: #f3f0ff; color: #6d4bd8; }
.tag.kg { background: #e9f7f1; color: #0f7a5c; }

.chev { flex: none; color: #c9ced6; font-size: 17px; padding-left: 4px; line-height: 1; }

.more {
  text-align: center;
  font-size: 12px;
  color: #b9bfc9;
  padding: 12px 0 20px;
}

.sentinel { height: 1px; }

/* ==================== 骨架 ==================== */
.skeleton { padding: 0 12px 20px; }

.sk {
  height: 47px;
  border-radius: 8px;
  margin-bottom: 6px;
  background: linear-gradient(90deg, #f0f1f4 25%, #e5e7eb 37%, #f0f1f4 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
}

@keyframes shimmer {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

/* ==================== 状态 ==================== */
.state { padding: 80px 44px 40px; text-align: center; }

.state-ico {
  width: 46px;
  height: 46px;
  line-height: 46px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: #fdecec;
  color: #d64545;
  font-size: 22px;
  font-weight: 600;
}

.state-t { font-size: 15px; font-weight: 500; }
.state-d { font-size: 12.5px; color: var(--mute); margin-top: 8px; line-height: 1.75; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  padding: 0 26px;
  border-radius: 999px;
  font-size: 14px;
  background: var(--brand);
  color: #fff;
}

.btn.ghost { background: var(--bg); color: var(--sub); }
.btn.primary { background: var(--brand); color: #fff; }

.state .btn { margin-top: 18px; }

/* ==================== 筛选抽屉 ==================== */
.mask {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(16, 24, 40, .42);
  animation: fade .18s ease;
}

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 61;
  display: flex;
  flex-direction: column;
  max-height: 80vh;
  background: #fff;
  border-radius: 16px 16px 0 0;
  padding-bottom: var(--safe-b);
  animation: up .24s cubic-bezier(.22, .61, .36, 1);
}

@media (min-width: 560px) {
  .sheet { left: 50%; right: auto; width: 480px; transform: translateX(-50%); animation-name: upD; }
  @keyframes upD {
    from { opacity: 0; transform: translate(-50%, 100%); }
    to   { opacity: 1; transform: translate(-50%, 0); }
  }
}

@keyframes up {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.sheet-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 8px;
}

.sheet-hd h2 { font-size: 16px; font-weight: 600; }

.sheet-x { width: 26px; height: 26px; color: var(--mute); }
.sheet-x svg { width: 100%; height: 100%; }

.sheet-bd {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 16px 8px;
}

.fsec { padding: 12px 0 4px; }

.fsec h3 {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 10px;
}

.fsec h3 span { font-size: 11.5px; color: var(--mute); font-weight: 400; margin-left: 6px; }

.opts { display: flex; flex-wrap: wrap; gap: 8px; }

.opt {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 31px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--bg);
  color: var(--sub);
  font-size: 12.5px;
  border: 1.5px solid transparent;
}

.opt.on {
  background: var(--brand-soft);
  color: var(--brand);
  border-color: #b9d2ff;
  font-weight: 500;
}

.opt em { font-style: normal; font-size: 10.5px; opacity: .55; }

.sheet-ft {
  display: flex;
  gap: 10px;
  padding: 12px 16px 16px;
  border-top: 1px solid var(--line);
}

.sheet-ft .btn { flex: 1; padding: 0; }

/* ==================== 详情（底部抽屉） ==================== */
.dmask {
  position: fixed;
  inset: 0;
  z-index: 49;
  background: rgba(15, 18, 28, .34);
  opacity: 0;
  transition: opacity .26s ease;
}
.dmask.show { opacity: 1; }

.detail {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  height: 80%;
  background: var(--bg);
  border-radius: 18px 18px 0 0;
  overflow: hidden;
  box-shadow: 0 -10px 40px rgba(15, 18, 28, .16);
  transform: translateY(100%);
  transition: transform .3s cubic-bezier(.32, .72, 0, 1);
  will-change: transform;
}
.detail.show { transform: translateY(0); }

/* 抽屉顶部的拖拽把手 */
.detail::before {
  content: '';
  position: absolute;
  top: 7px;
  left: 50%;
  width: 36px;
  height: 4px;
  margin-left: -18px;
  border-radius: 2px;
  background: #d3d7df;
  z-index: 12;
  pointer-events: none;
}

@media (min-width: 560px) {
  .detail {
    left: 50%;
    right: auto;
    width: 480px;
    transform: translate(-50%, 100%);
  }
  .detail.show { transform: translate(-50%, 0); }
}

.dbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  height: calc(56px + env(safe-area-inset-top, 0px));
  padding: calc(env(safe-area-inset-top, 0px) + 8px) 10px 0;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color .18s;
}

.detail.scrolled .dbar { border-bottom-color: var(--line); }

.dback, .dshare {
  flex: none;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--text);
}

.dback svg, .dshare svg { width: 21px; height: 21px; }
.dback:active, .dshare:active { background: rgba(16, 24, 40, .06); }

.dbar-t {
  flex: 1;
  min-width: 0;
  font-size: 14.5px;
  font-weight: 500;
  opacity: 0;
  transition: opacity .2s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.detail.scrolled .dbar-t { opacity: 1; }

.dscroll {
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-top: calc(56px + env(safe-area-inset-top, 0px));
  padding-bottom: calc(28px + var(--safe-b));
}

/* 图片区 */
.hero { background: #fff; padding: 8px 0 0; }

.hero-track {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.hero-track::-webkit-scrollbar { display: none; }

.hero-img {
  flex: none;
  width: 100%;
  height: 260px;
  scroll-snap-align: center;
  object-fit: contain;
  background: #fff;
}

.hero-ph {
  width: 100%;
  height: 260px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  color: #b6bcc7;
  background: linear-gradient(135deg, #f5f6f8, #eceef2);
}

.dots { display: flex; justify-content: center; gap: 5px; padding: 10px 0; }

.dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #d8dce3;
  transition: width .2s, background .2s;
}

.dot.on { width: 14px; border-radius: 3px; background: var(--brand); }

/* 标题区 */
.dhead { background: #fff; padding: 2px 16px 14px; }

.dname { font-size: 18px; line-height: 26px; font-weight: 600; }

.dmeta { display: flex; align-items: center; gap: 8px; margin-top: 8px; }

.dcode {
  font-size: 13px;
  color: var(--sub);
  font-variant-numeric: tabular-nums;
  letter-spacing: .2px;
}

.dcopy {
  font-size: 11px;
  color: var(--brand);
  background: var(--brand-soft);
  padding: 2px 7px;
  border-radius: 4px;
}

.dtags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

/* 信息卡片 */
.sec {
  background: #fff;
  margin: 10px 12px 0;
  border-radius: 10px;
  padding: 13px 14px 5px;
  box-shadow: 0 1px 4px rgba(16, 24, 40, .04);
}

.sec h3 { font-size: 13.5px; font-weight: 600; margin-bottom: 3px; }

.srow {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid #f4f5f7;
}

.srow:last-child { border-bottom: 0; }

.sk2 { flex: none; width: 74px; font-size: 12.5px; color: var(--mute); line-height: 20px; }
.sv { flex: 1; font-size: 13px; line-height: 20px; word-break: break-all; }

.selling { font-size: 13.5px; line-height: 23px; color: #3b4252; padding: 4px 0 12px; }

.guides {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0 12px;
  scrollbar-width: none;
}

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

.guides img {
  flex: none;
  width: 168px;
  height: 94px;
  border-radius: 6px;
  object-fit: cover;
  background: #f2f3f6;
}

.dfoot { text-align: center; font-size: 11.5px; color: #b6bcc7; padding: 18px 0 6px; }

/* 详情骨架 */
.dsk { padding: 16px; }
.dsk .b { background: #eef0f4; border-radius: 8px; margin-bottom: 12px; animation: pulse 1.2s ease infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .55; } }

/* ==================== Toast ==================== */
.toast {
  position: fixed;
  left: 50%;
  bottom: 90px;
  transform: translate(-50%, 10px);
  z-index: 200;
  max-width: 76vw;
  padding: 9px 18px;
  border-radius: 999px;
  background: rgba(22, 25, 43, .9);
  color: #fff;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}

.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ==================== 杂项 ==================== */

/* 详情打开时锁住背景滚动（保留位置） */
body.lock {
  position: fixed;
  left: 0;
  right: 0;
  width: 100%;
  overflow: hidden;
}

mark {
  background: #fff0a8;
  color: inherit;
  padding: 0 1px;
  border-radius: 2px;
}

.wh-more { color: var(--brand); }

/* 详情页标签沿用列表样式 */
.dtags .tag { font-size: 11px; line-height: 19px; padding: 0 7px; }

/* hidden 属性优先级保护（.sheet / .detail 等设了 display，会盖掉 UA 的 [hidden]） */
[hidden] { display: none !important; }

/* 无图时不要撑出大片空白 */
.hero-ph { height: 170px; font-size: 13px; }

/* 占位字更淡，避免看成内容 */
.thumb-ph { font-size: 13px; color: #c3c9d2; }

.opt.more { background: #fff; color: var(--brand); box-shadow: inset 0 0 0 1px #c7dbff; }

/* 空结果用中性放大镜图标，不用红色警示 */
.state-ico { position: relative; }
.state-ico.empty { background: #eef0f4; color: transparent; }
.state-ico.empty::before {
  content: ''; position: absolute; left: 12px; top: 11px;
  width: 17px; height: 17px; border: 2px solid #b6bcc7; border-radius: 50%;
}
.state-ico.empty::after {
  content: ''; position: absolute; right: 11px; bottom: 13px;
  width: 9px; height: 2px; background: #b6bcc7; border-radius: 1px;
  transform: rotate(45deg);
}

.state-ico.empty { display: flex; align-items: center; justify-content: center; }
.state-ico.empty::before, .state-ico.empty::after { display: none; }
