/* 小程序预览器 UI（Apple 极简风，与后台一致）
   注意：这里只写预览器外壳；小程序自身样式在 mp-wx.css（由构建脚本生成）
   例外：swiper 是小程序原生组件，wxss 里没有滑动/指示点样式，
   故轮播的滑动与圆点在本文末单独补齐 */
:root {
  --pv-bg: #f5f3ef;
  --pv-panel: rgba(255, 255, 255, .82);
  --pv-line: rgba(0, 0, 0, .07);
  --pv-text: #232019;
  --pv-sub: #837c71;
  --pv-blue: #8a6a45;
  --pv-radius: 18px;
  --pv-w: 375px;
  --pv-h: 812px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--pv-bg);
  background-image:
    radial-gradient(900px 500px at 12% -10%, rgba(138,106,69, .07), transparent 60%),
    radial-gradient(760px 460px at 96% 6%, rgba(133,124,112, .10), transparent 62%);
  color: var(--pv-text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  -webkit-font-smoothing: antialiased;
}

.pv-app { display: flex; gap: 20px; padding: 20px; min-height: 100vh; align-items: flex-start; }

/* ---------- 左侧页面列表 ---------- */
.pv-side {
  width: 232px;
  flex: 0 0 232px;
  background: var(--pv-panel);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--pv-line);
  border-radius: var(--pv-radius);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 12px 32px rgba(0, 0, 0, .06);
  padding: 16px 12px;
  position: sticky;
  top: 20px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
}

.pv-side-hd {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 0 8px 12px;
  border-bottom: 1px solid var(--pv-line);
  margin-bottom: 10px;
}

.pv-side-hd h1 { font-size: 17px; font-weight: 600; margin: 0; letter-spacing: .2px; }
.pv-side-hd .pv-count { font-size: 12px; color: var(--pv-sub); }

.pv-group {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .8px;
  color: var(--pv-sub);
  padding: 12px 10px 6px;
  text-transform: uppercase;
}

.pv-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  margin-bottom: 2px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--pv-text);
  font-size: 13.5px;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: background .15s, color .15s;
}

.pv-item:hover { background: rgba(0, 0, 0, .045); }
.pv-item.active { background: var(--pv-blue); color: #fff; font-weight: 500; }
.pv-item .pv-dot { width: 5px; height: 5px; border-radius: 50%; background: #8a6a45; flex: 0 0 5px; }
/*★ 2026-10-19：侧栏窄（约 220px），路由文字 `pages/category/categories` 较长，
   原样式让它无限伸展 → 把页面名挤成竖排单字（「商品分类」看着像四行）。
   铁律：flex 子项必须 `min-width:0` + `flex-shrink`，否则长文本不缩、挤的是别的东西。
   路由改用省略号 + title 全称（悬停可见），页面名不再被压。 */
.pv-item .pv-label {
  min-width: 0; flex: 0 1 auto; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.pv-item .pv-route {
  margin-left: auto; flex: 0 1 auto; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 10.5px; color: var(--pv-sub); font-variant-numeric: tabular-nums;
}
.pv-item.active .pv-route { color: rgba(255, 255, 255, .7); }

/* ---------- 右侧舞台 ---------- */
.pv-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.pv-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  background: var(--pv-panel);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--pv-line);
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
}

.pv-bar .pv-title { font-size: 14px; font-weight: 600; }
.pv-bar .pv-path {
  font-size: 12px;
  color: var(--pv-sub);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.pv-bar .pv-spacer { flex: 1; }

.pv-btn {
  border: 1px solid var(--pv-line);
  background: rgba(255, 255, 255, .9);
  color: var(--pv-text);
  border-radius: 9px;
  padding: 5px 12px;
  font-size: 12.5px;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s, transform .15s, box-shadow .15s;
}
.pv-btn:hover { background: #fff; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0, 0, 0, .07); }
.pv-btn.primary { background: var(--pv-blue); border-color: var(--pv-blue); color: #fff; }
.pv-btn.primary:hover { background: #9c7a52; }

.pv-zoom { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--pv-sub); }
.pv-zoom input[type=range] { width: 96px; accent-color: var(--pv-blue); }

/* ---------- 手机外壳 ---------- */
.pv-phone-wrap {
  /* 缩放锚点：内部 fixed 元素靠 .pv-screen 的 transform 定位到屏幕内 */
  transform-origin: top center;
}

.pv-phone {
  width: calc(var(--pv-w) + 22px);
  height: calc(var(--pv-h) + 22px);
  padding: 11px;
  border-radius: 54px;
  background: linear-gradient(160deg, #3d382f, #232019 40%, #2c2c2e);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, .09) inset,
    0 30px 70px rgba(0, 0, 0, .22),
    0 8px 20px rgba(0, 0, 0, .12);
  flex: 0 0 auto;
}

.pv-screen {
  position: relative;
  width: var(--pv-w);
  height: var(--pv-h);
  border-radius: 44px;
  overflow: hidden;
  background: #f5f3ef;
  /* 关键：创建包含块，让小程序里的 position:fixed 定位到屏幕内而非 iframe 视口 */
  transform: translateZ(0);
  display: flex;
  flex-direction: column;
}

/* 灵动岛 */
.pv-island {
  position: absolute;
  top: 11px;
  left: 50%;
  transform: translateX(-50%);
  width: 116px;
  height: 32px;
  border-radius: 18px;
  background: #000;
  z-index: 9998;
  pointer-events: none;
}

/* 状态栏 */
.pv-statusbar {
  position: relative;
  z-index: 9999;
  height: 44px;
  flex: 0 0 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 26px 0 30px;
  font-size: 14px;
  font-weight: 600;
  color: #000;
  background: transparent;
  pointer-events: none;
  letter-spacing: .2px;
}

.pv-statusbar.dark { color: #fff; }
.pv-sb-right { display: flex; align-items: center; gap: 5px; }
.pv-sb-right svg { display: block; }

/* 页面容器（小程序 page） */
.pv-pagebox { flex: 1; overflow-y: auto; overflow-x: hidden; position: relative; -webkit-overflow-scrolling: touch; }
.pv-pagebox::-webkit-scrollbar { width: 0; height: 0; }

/* tabBar 容器：小程序里是 fixed，靠 .pv-screen 的 transform 落在屏幕底部 */
.pv-tabbar-slot { flex: 0 0 auto; }

/* 加载 / 空态 */
.pv-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 60px 0;
  color: #8b8478;
  font-size: 13px;
}
.pv-spin {
  width: 16px; height: 16px;
  border: 2px solid rgba(0, 0, 0, .12);
  border-top-color: var(--pv-blue);
  border-radius: 50%;
  animation: pv-spin .7s linear infinite;
}
@keyframes pv-spin { to { transform: rotate(360deg); } }

/* Toast */
.pv-toast {
  position: absolute;
  left: 50%;
  bottom: 140px;
  transform: translateX(-50%) translateY(8px);
  background: rgba(0, 0, 0, .78);
  color: #fff;
  font-size: 13px;
  padding: 9px 16px;
  border-radius: 10px;
  z-index: 100000;
  opacity: 0;
  transition: opacity .2s, transform .2s;
  pointer-events: none;
  max-width: 260px;
  text-align: center;
}
.pv-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.pv-foot { font-size: 12px; color: var(--pv-sub); text-align: center; line-height: 1.6; }
.pv-foot code {
  background: rgba(0, 0, 0, .05);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* ===== 首页轮播：模拟小程序 swiper（横向滑动 + 指示点） =====
   结构对齐 pages/index/index.wxml 的 swiper / swiper-item，
   尺寸沿用 mp-wx.css 里 .hb-swiper 的高度，此处只补滑动与圆点。 */
[data-mp="pages/index/index"] .hb-swiper {
  position: relative;
  overflow: hidden;
}
[data-mp="pages/index/index"] .hb-track {
  display: flex;
  height: 100%;
  transition: transform .5s ease;
  will-change: transform;
}
[data-mp="pages/index/index"] .hb-slide {
  flex: 0 0 100%;
  width: 100%;
  height: 100%;
}
/* 后台给这张 Banner 配了点击跳转时加 .hb-link —— 只是提示「可以点」，不影响布局 */
[data-mp="pages/index/index"] .hb-slide.hb-link {
  cursor: pointer;
}
[data-mp="pages/index/index"] .hb-dots {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 10px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  z-index: 2;
}
[data-mp="pages/index/index"] .hb-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .55);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
  transition: all .3s ease;
}
[data-mp="pages/index/index"] .hb-dot.on {
  width: 16px;
  border-radius: 3px;
  background: #fff;
}

/* ===== H5 归一化：抹掉真机没有的浏览器默认控件外观 =====
   小程序 <textarea> 没有 resize 手柄、<input type="number"> 没有步进箭头；
   预览器不抹掉这些，会让人误以为真机也长这样（活动报名表单的备注框就是个例子）。 */
#mpPage textarea {
  resize: none;
}
#mpPage input[type="number"]::-webkit-outer-spin-button,
#mpPage input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
#mpPage input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

/* 商品分类页的一级分类在真机是 <scroll-view scroll-x>，预览器里是 <div>。
   wxss 只给了 white-space:nowrap，div 不会自己横向滚动 → 靠右的分类被
   .cat-page 的 overflow:hidden 裁掉、点不到。这里补上等价的可滚行为。 */
[data-mp="pages/category/category"] .cat-nav {
  overflow-x: auto;
  overflow-y: hidden;
}

/* 同理：社区页的板块横排（feed-community 组件的 .boards）。
   真机是 <scroll-view scroll-x>，组件 wxss 只写 white-space:nowrap；
   预览器里是普通 div → 整行溢出 144px、被裁掉，「茶友晒单」之后的板块点不到。
   ⚠️ 这条同时消掉了排版探针 _probe_type_scale.mjs 报的「横溢出」误报。 */
[data-mp="pages/community/community"] .boards {
  overflow-x: auto;
  overflow-y: hidden;
}

