:root {
  --primary: #2f7fd1; --primary-dark: #1f63aa; --primary-light: #e3f0fc;
  --gold: #c9973f; --gold-light: #faf1de; --gold-bright: #ffe3a3;
  --bg: #eef5fb; --card: #ffffff; --surface: #f3f8fc; --text: #1f2d3d; --text-secondary: #7c8ba1; --border: #dce8f4;
  --success: #3fa732; --danger: #e4483d;
  --shadow-card: 0 4px 20px rgba(47,127,209,0.1);
  --tabbar-h: 58px; --topbar-h: 48px;
  --radius: 14px;
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px;
  overscroll-behavior: contain; touch-action: manipulation;
}
button, input, textarea { font-family: inherit; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

.app-root { min-height: 100dvh; display: flex; flex-direction: column; }

/* ===== 顶部 Header（蓝天白云渐变） ===== */
.app-header {
  padding: calc(env(safe-area-inset-top) + 14px) 16px 16px;
  background:
    radial-gradient(ellipse 55% 45% at 12% 10%, rgba(255,255,255,0.55), transparent 60%),
    radial-gradient(ellipse 45% 35% at 82% -5%, rgba(255,255,255,0.4), transparent 60%),
    radial-gradient(ellipse 60% 30% at 50% 105%, rgba(255,255,255,0.2), transparent 70%),
    linear-gradient(160deg, #3f93e0 0%, #5da8ec 55%, #8cc6f3 100%);
  border-bottom: 1px solid rgba(255,255,255,0.4);
  color: #fff; flex-shrink: 0;
}
.app-header-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
/* 首页顶部宣传图：后台上传后按2.5:1裁切展示，没有设置时这个容器不渲染，不占位置 */
.banner-wrap { border-radius: 14px; overflow: hidden; margin-bottom: 10px; box-shadow: 0 6px 20px rgba(20,70,120,0.18); }
.banner-wrap img { width: 100%; aspect-ratio: 2.5 / 1; object-fit: cover; display: block; }
.app-title { font-size: 18px; font-weight: 800; display: flex; align-items: center; gap: 9px; letter-spacing: 0.3px; color: #fff; text-shadow: 0 1px 4px rgba(20,70,120,0.2); }
.app-title .em { width: 28px; height: 28px; border-radius: 50%; background: linear-gradient(135deg, #ffe3a3, #c9973f); display: inline-flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0; box-shadow: 0 2px 8px rgba(0,0,0,0.2); }
.login-pill { background: rgba(255,255,255,0.24); border: 1px solid rgba(255,255,255,0.4); color: #fff; font-size: 12.5px; font-weight: 600; padding: 6px 13px; border-radius: 20px; display: flex; align-items: center; gap: 5px; }
.balance-pill { background: rgba(255,255,255,0.24); border: 1px solid rgba(255,255,255,0.4); color: #fff; font-size: 12.5px; font-weight: 700; padding: 6px 13px; border-radius: 20px; }
.balance-pill b { color: var(--gold-bright); margin-left: 2px; }

.marquee-bar { background: rgba(255,255,255,0.2); border: 1px solid rgba(255,255,255,0.3); border-radius: 20px; padding: 7px 14px; font-size: 12px; color: #fff; display: flex; align-items: center; gap: 8px; }
.marquee-bar .ic { flex-shrink: 0; }
/* 文字滚动的裁切范围只框住这个视口，不包含喇叭图标，所以transform滑动时不会滑到图标上面 */
.marquee-viewport { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; }
.marquee-track { display: inline-block; animation: marquee 14s linear infinite; }
@keyframes marquee { from { transform: translateX(0); } to { transform: translateX(-100%); } }

/* ===== 简易返回顶栏（详情页用） ===== */
.topbar-simple {
  height: calc(var(--topbar-h) + env(safe-area-inset-top)); padding-top: env(safe-area-inset-top);
  display: flex; align-items: center; padding-left: 10px; background: var(--card); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20; flex-shrink: 0;
}
.back-btn { width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; font-size: 20px; color: var(--text); }
.topbar-simple .t { font-size: 15.5px; font-weight: 700; letter-spacing: 0.2px; }

/* ===== 内容区 ===== */
.page-body { flex: 1; overflow-y: auto; padding: 14px 14px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 20px); }

/* ===== 底部 Tab ===== */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom); background: var(--card); border-top: 1px solid var(--border);
  display: flex; z-index: 30;
}
.tab-item { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--text-secondary); font-size: 11px; font-weight: 600; min-height: 44px; }
.tab-item .ic { font-size: 18px; line-height: 1; padding: 4px; border-radius: 50%; transition: background .2s; }
.tab-item.active { color: var(--primary); }
.tab-item.active .ic { background: var(--primary-light); }

/* ===== 商品详情页底部购买栏 ===== */
.buy-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  padding: 10px 14px calc(env(safe-area-inset-bottom) + 10px); background: var(--card); border-top: 1px solid var(--border);
  display: none;
}

/* ===== 卡片 / 商品列表 ===== */
.search-bar { position: relative; margin-bottom: 12px; }
.search-bar input { width: 100%; height: 40px; border: 1px solid var(--border); border-radius: 20px; padding: 0 38px 0 36px; font-size: 13.5px; background: var(--card); color: var(--text); box-shadow: var(--shadow-card); outline: none; }
.search-bar input::placeholder { color: var(--text-secondary); }
.search-bar input:focus { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-light), var(--shadow-card); }
.search-bar .ic { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--text-secondary); font-size: 14px; pointer-events: none; }
.search-bar .clear { display: none; position: absolute; right: 10px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; border-radius: 50%; background: var(--border); color: #fff; font-size: 13px; line-height: 20px; text-align: center; }
.search-bar.has-value .clear { display: block; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-card); overflow: hidden; }
.section-title { font-size: 14.5px; font-weight: 800; margin: 18px 0 10px 2px; display: flex; align-items: center; gap: 6px; color: var(--text); }

.product-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.product-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-card); transition: transform .15s, box-shadow .15s; }
.product-card:active { transform: scale(0.98); }
.img-wrap { background: linear-gradient(135deg, #eaf3fb, #dbe9f7); display: flex; align-items: center; justify-content: center; font-size: 34px; overflow: hidden; }
.img-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; }
.product-card .img-wrap { width: 100%; aspect-ratio: 1; }
.product-card .pbody { padding: 10px 11px 12px; }
.product-card .pname { font-size: 13px; font-weight: 700; margin-bottom: 8px; line-height: 1.3; height: 2.6em; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; color: var(--text); }
.product-card .pprice { font-size: 11px; color: var(--gold); font-weight: 700; margin-bottom: 6px; }

.progress-track { height: 7px; background: var(--surface); border: 1px solid var(--border); border-radius: 4px; overflow: hidden; margin-bottom: 4px; }
.progress-fill { height: 100%; background: linear-gradient(90deg, #2f7fd1, #6fb3ef); border-radius: 4px; transition: width .3s; }
.progress-label { font-size: 10.5px; color: var(--text-secondary); display: flex; justify-content: space-between; }

.empty-state { text-align: center; padding: 60px 20px; color: var(--text-secondary); font-size: 13px; }
.empty-state .ic { font-size: 40px; margin-bottom: 10px; opacity: 0.5; }
.skeleton-wrap { padding: 50px 0; text-align: center; color: var(--text-secondary); font-size: 13px; }

/* ===== 按钮 ===== */
.btn { height: 44px; border: none; border-radius: 22px; font-size: 15px; font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn-primary { background: linear-gradient(135deg, #4a97dd, #2a6fc4); color: #fff; box-shadow: 0 8px 22px rgba(47,127,209,0.32), inset 0 1px 0 rgba(255,255,255,0.25); }
.btn-primary:disabled { background: var(--border); color: var(--text-secondary); box-shadow: none; }
.btn-block { width: 100%; }
.btn-ghost { background: var(--surface); color: var(--text); border: 1.5px solid var(--border); }
.btn-sm { height: 34px; padding: 0 16px; border-radius: 18px; font-size: 12.5px; }

/* ===== 表单 ===== */
.form-item { margin-bottom: 14px; }
.form-item label { display: block; font-size: 12.5px; color: var(--text-secondary); margin-bottom: 6px; font-weight: 600; }
.form-input { width: 100%; height: 46px; border: 1.5px solid var(--border); border-radius: 12px; padding: 0 14px; font-size: 15px; outline: none; background: var(--surface); color: var(--text); }
.form-input::placeholder { color: var(--text-secondary); }
.form-input:focus { border-color: var(--primary); }

/* ===== 底部弹层 / 遮罩 ===== */
.sheet-mask { display: none; position: fixed; inset: 0; background: rgba(15,35,55,0.4); z-index: 200; }
.sheet-mask.show { display: block; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; background: var(--card); border: 1px solid var(--border); border-bottom: none; border-radius: 20px 20px 0 0; z-index: 201;
  transform: translateY(100%); transition: transform .25s ease; max-height: 86vh; display: flex; flex-direction: column; box-shadow: 0 -20px 50px rgba(47,127,209,0.18); }
.sheet-mask.show .sheet { transform: translateY(0); }
.sheet-hd { padding: 18px 20px 6px; display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
.sheet-hd h3 { font-size: 16px; font-weight: 800; color: var(--text); }
.sheet-hd .x { font-size: 22px; color: var(--text-secondary); padding: 4px; }
.sheet-body { padding: 10px 20px calc(env(safe-area-inset-bottom) + 20px); overflow-y: auto; }

.toast-wrap { position: fixed; top: calc(env(safe-area-inset-top) + 14px); left: 0; right: 0; display: flex; justify-content: center; z-index: 999; pointer-events: none; }
.toast { background: rgba(31,45,61,0.94); border: 1px solid rgba(255,255,255,0.12); color: #fff; padding: 10px 20px; border-radius: 20px; font-size: 13px; max-width: 80vw; text-align: center; }

.sub-tabs { display: flex; gap: 6px; margin: 14px 0 10px; }
.sub-tab { flex: 1; text-align: center; padding: 9px 0; border-radius: 10px; font-size: 13px; font-weight: 700; color: var(--text-secondary); background: var(--surface); border: 1px solid var(--border); }
.sub-tab.active { background: linear-gradient(135deg, #4a97dd, #2a6fc4); color: #fff; border-color: transparent; }

.cat-tabs { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 10px; margin: 2px -2px 4px; scrollbar-width: none; }
.cat-tabs::-webkit-scrollbar { display: none; }
.cat-tab { flex-shrink: 0; padding: 7px 16px; border-radius: 18px; font-size: 12.5px; font-weight: 700; color: var(--text-secondary); background: var(--surface); border: 1px solid var(--border); white-space: nowrap; }
.cat-tab.active { background: linear-gradient(135deg, #4a97dd, #2a6fc4); color: #fff; border-color: transparent; }

.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 10px; font-size: 10.5px; font-weight: 700; }
.badge-gold { background: var(--gold-light); color: var(--gold); }
.badge-gray { background: var(--surface); color: var(--text-secondary); }
.badge-green { background: #eaf7e6; color: var(--success); }
.badge-primary { background: var(--primary-light); color: var(--primary); }

.list-row { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.list-row:last-child { border-bottom: none; }
.avatar-circle { width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, #4a97dd, #2a6fc4); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0; font-size: 14px; }

.stepper { display: flex; align-items: center; gap: 0; border: 1.5px solid var(--border); border-radius: 12px; overflow: hidden; width: fit-content; }
.stepper button { width: 38px; height: 38px; border: none; background: var(--surface); font-size: 17px; color: var(--text); }
.stepper input { width: 60px; height: 38px; border: none; text-align: center; font-size: 15px; font-weight: 700; background: transparent; color: var(--text); }
.quick-qty { display: flex; gap: 8px; margin: 10px 0; }
.quick-qty button { flex: 1; height: 32px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); font-size: 12px; color: var(--text); }

.verify-box { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; font-size: 12px; margin-bottom: 10px; }
.verify-box .k { color: var(--text-secondary); margin-bottom: 3px; }
.verify-box .v { font-family: monospace; word-break: break-all; color: var(--text); }

/* ===== 桌面端"手机壳"模拟 ===== */
/* 这个H5站只按手机宽度设计过，桌面端打开如果让内容撑满整个浏览器窗口会完全变形（字特别大、
   一行塞几十个字、底部Tab贴到屏幕两侧...）。所以宽屏时把内容限制在手机宽度内、居中显示，
   两侧露出中性背景，视觉上像个"手机壳"——不管屏幕多宽，看到的始终是手机H5排版。 */
@media (min-width: 640px) {
  body { background: radial-gradient(circle at 50% 15%, #cfe6f8, #eef5fb 70%); }
  .app-root {
    max-width: 480px; margin: 0 auto; min-height: 100vh;
    box-shadow: 0 0 0 1px rgba(47,127,209,0.1), 0 30px 80px rgba(47,127,209,0.22);
  }
  .tabbar, .buy-bar, .toast-wrap {
    left: 50%; right: auto; width: 100%; max-width: 480px; transform: translateX(-50%);
  }
  .sheet-mask .sheet {
    left: 50%; right: auto; width: 100%; max-width: 480px; transform: translateX(-50%) translateY(100%);
  }
  .sheet-mask.show .sheet { transform: translateX(-50%) translateY(0); }
}
