/* ==========================================================================
   维修兔 · 全球拆件主板库 —— 前台样式
   手机优先：所有尺寸先按 390px 宽的手机写，再往上加断点。
   纯原生 CSS，无框架无 CDN（和本机那套一致，离线也能打开看）。
   ========================================================================== */

:root {
  --bg: #f6f8f7;
  --bg2: #ffffff;
  --card: #ffffff;
  --soft: #f1f5f3;
  --line: #e4eae7;
  --tx: #16211c;
  --tx2: #5d6f67;
  --tx3: #93a39b;
  --acc: #16a06a;
  --acc-dk: #0d7a50;
  --acc-soft: #e3f5ec;
  --warn: #c8763a;
  --bad: #c0392b;
  --blue: #2f6fd0;
  --sh: 0 1px 2px rgba(16, 48, 34, .05), 0 8px 24px rgba(16, 48, 34, .06);
  --sh-sm: 0 1px 2px rgba(16, 48, 34, .05), 0 3px 10px rgba(16, 48, 34, .04);
  --r: 16px;
  --r-sm: 11px;
  --top-h: 108px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1512;
    --bg2: #161d1a;
    --card: #182019;
    --soft: #1f2824;
    --line: #28332e;
    --tx: #e8f0eb;
    --tx2: #9bada4;
    --tx3: #708078;
    --acc: #3fc98c;
    --acc-dk: #7fdcb0;
    --acc-soft: #163325;
    --sh: 0 1px 2px rgba(0, 0, 0, .35), 0 8px 24px rgba(0, 0, 0, .3);
    --sh-sm: 0 1px 2px rgba(0, 0, 0, .3), 0 3px 10px rgba(0, 0, 0, .22);
  }
}

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

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

body {
  margin: 0;
  padding: calc(var(--top-h) + env(safe-area-inset-top)) 0 calc(72px + env(safe-area-inset-bottom));
  background: var(--bg);
  color: var(--tx);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Microsoft YaHei", "Noto Sans SC", Roboto, sans-serif;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
button, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }   /* class 的 display 会盖掉 [hidden]，必须 !important */

/* ---------------------------------------------------------------- 顶栏 */
.top {
  position: fixed; inset: 0 0 auto 0; z-index: 30;
  padding: calc(8px + env(safe-area-inset-top)) 14px 10px;
  background: color-mix(in srgb, var(--bg2) 88%, transparent);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.top-row { display: flex; align-items: center; gap: 10px; height: 34px; }
.logo { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; }
.logo svg { width: 24px; height: 24px; color: var(--acc); flex: none; }
.logo-t { font-weight: 700; font-size: 15px; letter-spacing: .2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lang {
  flex: none; height: 30px; padding: 0 12px; border-radius: 15px;
  border: 1px solid var(--line); background: var(--soft); color: var(--tx2);
  font-size: 12px; font-weight: 600; letter-spacing: .5px;
}

.searchbar { position: relative; margin-top: 9px; }
.searchbar .si {
  position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; color: var(--tx3); pointer-events: none;
}
#q {
  width: 100%; height: 46px; padding: 0 42px 0 40px;
  border: 1px solid var(--line); border-radius: 23px;
  background: var(--card); box-shadow: var(--sh-sm);
  outline: none; -webkit-appearance: none;
}
#q:focus { border-color: var(--acc); box-shadow: 0 0 0 3px var(--acc-soft); }
#q::-webkit-search-cancel-button { display: none; }
.clr {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 34px; height: 34px; border: 0; border-radius: 17px;
  background: var(--soft); color: var(--tx2); font-size: 13px;
}

/* ---------------------------------------------------------------- 主体 */
main { padding: 14px; max-width: 900px; margin: 0 auto; }

.sec-t {
  display: flex; align-items: baseline; gap: 8px;
  margin: 18px 2px 9px; font-size: 13px; font-weight: 700; color: var(--tx2);
}
.sec-t:first-child { margin-top: 2px; }
.sec-t b { color: var(--acc); font-size: 13px; }
.sec-t .more { margin-left: auto; font-weight: 600; color: var(--tx3); font-size: 12px; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--sh-sm); padding: 14px;
}

/* 统计条 */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 4px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 11px 10px; text-align: center; }
.stat b { display: block; font-size: 19px; font-weight: 800; color: var(--acc); letter-spacing: -.5px; }
.stat span { font-size: 11px; color: var(--tx3); }

.notice {
  margin: 12px 0 2px; padding: 12px 14px; border-radius: var(--r-sm);
  background: var(--acc-soft); color: var(--acc-dk); font-size: 13px; line-height: 1.6;
}

/* 一排可点的标签（分类、品牌、成色） */
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 7px 12px; border-radius: 16px; border: 1px solid var(--line);
  background: var(--card); color: var(--tx2); font-size: 13px; line-height: 1;
}
.chip i { font-style: normal; color: var(--tx3); font-size: 11px; }
.chip.on { background: var(--acc); border-color: var(--acc); color: #fff; }
.chip.on i { color: rgba(255, 255, 255, .8); }

/* 列表项 */
.list { display: flex; flex-direction: column; gap: 8px; }
.item {
  display: flex; align-items: center; gap: 11px; padding: 12px 13px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r-sm); box-shadow: var(--sh-sm);
}
.item:active { transform: scale(.995); }
.thumb {
  width: 52px; height: 52px; flex: none; border-radius: 9px; object-fit: cover;
  background: var(--soft); border: 1px solid var(--line);
}
.ic {
  width: 42px; height: 42px; flex: none; border-radius: 11px;
  display: grid; place-items: center; background: var(--acc-soft); color: var(--acc-dk);
  font-size: 11px; font-weight: 800; letter-spacing: -.3px; text-align: center; padding: 2px;
}
.it { flex: 1; min-width: 0; }
.it-1 { font-weight: 650; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.it-1 .hl { background: var(--acc-soft); color: var(--acc-dk); border-radius: 3px; padding: 0 1px; }
.it-2 { font-size: 12px; color: var(--tx3); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag {
  font-size: 10.5px; font-weight: 700; padding: 2px 6px; border-radius: 5px;
  background: var(--soft); color: var(--tx2); line-height: 1.4; flex: none;
}
.tag.b { background: var(--acc-soft); color: var(--acc-dk); }
.tag.n { background: #fdf0e3; color: var(--warn); }
@media (prefers-color-scheme: dark) { .tag.n { background: #33261a; } }
.qty { flex: none; text-align: right; }
.qty b { display: block; font-size: 16px; font-weight: 800; color: var(--acc); letter-spacing: -.4px; }
.qty span { font-size: 10px; color: var(--tx3); }
.qty.zero b { color: var(--tx3); }

.empty { text-align: center; padding: 44px 20px; color: var(--tx3); font-size: 13px; line-height: 1.8; }
.empty b { display: block; font-size: 15px; color: var(--tx2); margin-bottom: 6px; }

/* ---------------------------------------------------------------- 详情页 */
.back {
  display: inline-flex; align-items: center; gap: 5px; margin-bottom: 10px;
  padding: 6px 12px 6px 9px; border-radius: 15px; border: 1px solid var(--line);
  background: var(--card); color: var(--tx2); font-size: 12.5px;
}
.hero { padding: 16px; }
.hero h1 { margin: 0; font-size: 21px; line-height: 1.3; letter-spacing: -.3px; }
.hero .sub { margin-top: 5px; color: var(--tx3); font-size: 13px; }
.hero .meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 11px; }

.gal { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 6px;
  scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch; }
.gal img {
  width: 148px; height: 148px; flex: none; object-fit: cover; scroll-snap-align: start;
  border-radius: 12px; border: 1px solid var(--line); background: var(--soft);
}

.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13.5px; }
.kv dt { color: var(--tx3); }
.kv dd { margin: 0; }

/* 芯片清单按分类分组 */
.grp { margin-top: 14px; }
.grp-t { display: flex; align-items: center; gap: 7px; margin: 0 2px 7px;
  font-size: 12px; font-weight: 700; color: var(--tx2); }
.grp-t em { font-style: normal; color: var(--tx3); font-weight: 600; }
.grp-t::after { content: ''; flex: 1; height: 1px; background: var(--line); }

/* 联系按钮 */
.cta { display: grid; gap: 9px; margin-top: 14px; }
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  height: 48px; border-radius: 13px; border: 1px solid var(--line);
  background: var(--card); font-weight: 650; font-size: 14.5px;
}
.btn.main { background: var(--acc); border-color: var(--acc); color: #fff; box-shadow: var(--sh); }
.btn.main:active { background: var(--acc-dk); }
.btn svg { width: 19px; height: 19px; }
.copied { text-align: center; font-size: 12px; color: var(--acc); margin-top: -4px; }

/* ---------------------------------------------------------------- 底部导航 */
.tabbar {
  position: fixed; inset: auto 0 0 0; z-index: 30; display: flex;
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg2) 92%, transparent);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-top: 1px solid var(--line);
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 5px 0; color: var(--tx3); font-size: 10.5px; font-weight: 600;
}
.tabbar a svg { width: 21px; height: 21px; }
.tabbar a.on { color: var(--acc); }

/* ---------------------------------------------------------------- 图片放大 */
.viewer {
  position: fixed; inset: 0; z-index: 90; background: rgba(0, 0, 0, .94);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
  touch-action: none;
}
.vstage { width: 100%; height: 100%; display: grid; place-items: center; overflow: hidden; }
.vstage img { max-width: 100%; max-height: 100%; transform-origin: center center;
  will-change: transform; user-select: none; -webkit-user-drag: none; }
.vclose {
  position: absolute; top: calc(12px + env(safe-area-inset-top)); right: 14px; z-index: 2;
  width: 40px; height: 40px; border: 0; border-radius: 20px;
  background: rgba(255, 255, 255, .14); color: #fff; font-size: 15px;
}
.vhint {
  position: absolute; bottom: calc(22px + env(safe-area-inset-bottom)); left: 0; right: 0;
  text-align: center; color: rgba(255, 255, 255, .6); font-size: 12px; pointer-events: none;
}

/* 加载骨架 */
.skel { height: 66px; border-radius: var(--r-sm); background: var(--soft);
  animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .5; } }

/* ---------------------------------------------------------------- 大屏 */
@media (min-width: 720px) {
  :root { --top-h: 112px; }
  body { padding-bottom: 40px; }
  .tabbar {
    position: fixed; top: calc(8px + env(safe-area-inset-top)); bottom: auto;
    left: auto; right: max(14px, calc(50% - 450px + 14px));
    width: auto; border: 0; background: none; backdrop-filter: none; padding: 0;
    height: 34px; gap: 2px;
  }
  .tabbar a { flex-direction: row; gap: 5px; padding: 0 11px; height: 34px;
    border-radius: 17px; font-size: 12.5px; }
  .tabbar a.on { background: var(--acc-soft); }
  .tabbar a svg { width: 16px; height: 16px; }
  .top-row { max-width: 900px; margin: 0 auto; padding-right: 330px; }
  .searchbar { max-width: 900px; margin: 9px auto 0; }
  .stats { grid-template-columns: repeat(4, 1fr); }
  .list.two { display: grid; grid-template-columns: 1fr 1fr; }
  .gal img { width: 190px; height: 190px; }
}

/* ---------------------------------------------------------------- 联系购买
   机型页/芯片页上只放一个绿色大按钮，点了才从底部升起这一层。
   这样页面主体留给「板上有什么芯片」，联系方式不抢位置。 */
.btn.big { height: 54px; font-size: 15.5px; }
/* 联系方式按钮：标题一行、说明一行，别挤在一行被截断 */
.c-btn { flex-direction: column; gap: 2px; height: auto; min-height: 50px; padding: 9px 12px; }
.c-btn b { font-weight: 650; font-size: 14.5px; }
.c-btn em { font-style: normal; font-weight: 500; font-size: 11.5px; color: var(--tx3);
  line-height: 1.4; text-align: center; }
.c-btn.main em { color: rgba(255, 255, 255, .8); }
.c-btn em:empty { display: none; }

.contact {
  position: fixed; inset: 0; z-index: 80; display: flex; align-items: flex-end;
  background: rgba(10, 20, 16, 0); transition: background .2s ease;
}
.contact.on { background: rgba(10, 20, 16, .5); }
.c-card {
  width: 100%; max-height: 86vh; overflow-y: auto;
  background: var(--bg2); border-radius: 22px 22px 0 0;
  padding: 18px 16px calc(20px + env(safe-area-inset-bottom));
  transform: translateY(100%); transition: transform .22s cubic-bezier(.22, .7, .3, 1);
  box-shadow: 0 -8px 40px rgba(10, 30, 20, .22);
}
.contact.on .c-card { transform: translateY(0); }
.c-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 10px; }
.c-h1 { font-size: 17px; font-weight: 700; }
.c-h2 { font-size: 12.5px; color: var(--tx3); margin-top: 3px; line-height: 1.5; }
.c-x {
  flex: none; width: 34px; height: 34px; margin-left: auto;
  border: 0; border-radius: 17px; background: var(--soft); color: var(--tx2); font-size: 13px;
}
.c-what {
  font-size: 12.5px; color: var(--acc-dk); background: var(--acc-soft);
  border-radius: 9px; padding: 8px 12px; margin-bottom: 12px; word-break: break-all;
}
.c-what:empty { display: none; }
.clist { display: grid; gap: 9px; }
.c-row.wx {
  display: grid; gap: 8px; justify-items: center; padding: 13px;
  background: var(--card); border: 1px solid var(--line); border-radius: 13px;
}
/* 二维码压到 150px：再大就把下面的闲鱼/WhatsApp 挤出屏幕，客户得滚半天才看到 */
.c-row .qr { width: 150px; height: 150px; object-fit: contain;
  background: #fff; border-radius: 8px; padding: 5px; }
.c-row .qr-h { font-size: 11.5px; color: var(--tx3); text-align: center; line-height: 1.5; }
.c-row .c-t { font-weight: 650; font-size: 14.5px; align-self: start; justify-self: start; }
.c-row .c-t em { font-style: normal; font-weight: 500; font-size: 11.5px; color: var(--tx3); margin-left: 7px; }
.c-row .btn { width: 100%; }

@media (min-width: 720px) {
  .contact { align-items: center; justify-content: center; }
  .c-card { max-width: 420px; border-radius: 20px; transform: translateY(20px) scale(.97); }
  .contact.on .c-card { transform: none; }
}
