:root {
  --primary: #f2545b;
  --primary-dark: #e23a44;
  --primary-light: #ff8087;
  --bg-gray: #f5f5f5;
  --text-dark: #222;
  --text-gray: #999;
  --white: #fff;
  --app-max-width: 480px; /* H5设计稿定宽,真机(屏宽<480px)会自动铺满,桌面预览时居中显示成"手机屏幕"效果 */
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

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

html {
  /* 禁止桌面端出现横向滚动条把H5容器挤歪 */
  overflow-x: hidden;
  background: #e5e5e5; /* 桌面预览时容器外的背景,真机上不可见 */
  -webkit-text-size-adjust: 100%; /* 禁止iOS横屏时自动放大字号 */
  text-size-adjust: 100%;
  overscroll-behavior-y: contain;
}

body {
  margin: 0 auto;
  max-width: var(--app-max-width);
  min-height: 100vh;
  min-height: 100dvh; /* 移动端浏览器地址栏收起/展开时高度更准确 */
  position: relative;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg-gray);
  color: var(--text-dark);
  padding-bottom: calc(64px + var(--safe-bottom)); /* 留出底部导航 + 安全区空间 */
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain; /* 防止iOS下拉页面出现回弹露白 */
  box-shadow: 0 0 24px rgba(0, 0, 0, 0.12); /* 桌面预览时的"手机边框"阴影,真机上几乎不可见 */
}
a { text-decoration: none; color: inherit; -webkit-touch-callout: none; }
button {
  font-family: inherit;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
input, textarea, select {
  font-size: 16px; /* 小于16px会触发iOS Safari自动放大输入框,统一16px规避 */
}
img { -webkit-user-drag: none; user-select: none; }

/* 顶部标题栏 */
.topbar {
  background: var(--white);
  padding: 14px 16px;
  text-align: center;
  font-size: 17px;
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid #eee;
}
.topbar .back {
  position: absolute;
  left: 12px;
  top: 12px;
  font-size: 20px;
  color: var(--text-dark);
}

/* ============================================
   首页专属: 整体红底 + 居中品牌徽标(只在 body.home-fixed 下生效,不影响登录页等其他用 .hero-header 的页面)
   ============================================ */
body.home-fixed {
  background: #d4303d; /* 首页整体红底 */
}
body.home-fixed .hero-header {
  background: transparent;
  padding: 12px 16px 10px;
  text-align: center;
}

/* 品牌名装饰边框: 寓意发财的仿古铜钱造型四角点缀(圆形金币+中间方孔) */
.shop-badge {
  display: inline-block;
  position: relative;
  padding: 8px 32px;
  background: linear-gradient(135deg, rgba(255,215,130,0.18), rgba(255,255,255,0.05));
  border: 1.5px solid #ffd782;
  border-radius: 6px;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.25), 0 2px 10px rgba(0,0,0,0.15);
}
.shop-badge h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 4px;
  color: #fff8ec;
  text-shadow: 0 1px 3px rgba(0,0,0,0.25);
}
.shop-badge .coin {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 32%, #fff6d8, #ffd782 55%, #d99a2e 100%);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.5);
}
.shop-badge .coin::after {
  content: "";
  position: absolute;
  width: 5px;
  height: 5px;
  background: #d4303d; /* 和首页红底颜色对齐,让方孔看起来是镂空的 */
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}
.shop-badge .coin.tl { top: -7px; left: -7px; }
.shop-badge .coin.tr { top: -7px; right: -7px; }
.shop-badge .coin.bl { bottom: -7px; left: -7px; }
.shop-badge .coin.br { bottom: -7px; right: -7px; }

/* 筛选栏在红底上改成白色浮起的卡片 */
body.home-fixed .filter-bar {
  background: transparent;
  margin: 0 12px 4px;
  padding: 0;
}
body.home-fixed .filter-bar select,
body.home-fixed .filter-bar input {
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

/* banner在红底上加一圈白边,避免和背景颜色糊在一起 */
body.home-fixed .banner {
  border: 3px solid rgba(255,255,255,0.5);
}

/* 顶部固定区域本身透明,让红色背景透出来 */
body.home-fixed .home-top-fixed {
  background: transparent;
  padding-top: env(safe-area-inset-top, 0px);
}

/* 红色渐变头部 */
.hero-header {
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-light) 100%);
  padding: 20px 16px 28px;
  color: #fff;
}
.hero-header h1 {
  margin: 0 0 4px;
  font-size: 20px;
}

/* 搜索/筛选条 */
.filter-bar {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  background: var(--bg-gray);
}
.filter-bar select,
.filter-bar input {
  border: none;
  border-radius: 20px;
  padding: 10px 12px;
  background: var(--white);
  font-size: 16px; /* >=16px避免iOS Safari输入框聚焦时自动放大整页 */
  min-width: 0; /* 关键: flex子元素默认不会缩小到低于内容宽度,不加这个搜索框会把屏幕撑爆 */
}
.filter-bar select { flex: 1 1 0; max-width: 96px; }
.filter-bar input { flex: 2 1 0; }

/* 商品卡片: 单列布局,无图,价格做成右上角角标 */
.product-list {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.product-card {
  background: var(--white);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  display: block;
}
.product-card .info {
  padding: 14px 16px;
}
.product-card .title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}
.product-card .title {
  font-size: 15px;
  font-weight: 500;
  line-height: 1.35;
  flex: 1;
  min-width: 0;
}
.product-card .price-badge {
  flex-shrink: 0;
  border: 1px solid #ffd9db;
  background: #fff6f6;
  border-radius: 8px;
  padding: 4px 10px;
  text-align: center;
}
.product-card .subtitle {
  font-size: 12px;
  color: var(--primary);
  margin-bottom: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.product-card .meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.publish-time {
  font-size: 11px;
  color: #bbb;
}
.price {
  color: var(--primary);
  font-weight: 700;
  font-size: 20px;
}
.price::before { content: "¥"; font-size: 13px; margin-right: 1px; }
.original-price {
  display: block;
  color: var(--text-gray);
  font-size: 11px;
  text-decoration: line-through;
  margin-top: 1px;
}
.sales-count {
  font-size: 11px;
  color: var(--text-gray);
  flex-shrink: 0;
}

/* 通用卡片容器 */
.card {
  background: var(--white);
  border-radius: 12px;
  margin: 12px;
  overflow: hidden;
}
.card-pad { padding: 16px; }

/* 列表行(设置项 / 菜单项) */
.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid #f0f0f0;
  background: var(--white);
  font-size: 15px;
}
.list-row:last-child { border-bottom: none; }
.list-row .left { display: flex; align-items: center; gap: 10px; }
.list-row .arrow { color: #ccc; }
.list-row .value { color: var(--text-gray); font-size: 13px; }

/* 表单 */
.form-group {
  background: var(--white);
  border-radius: 12px;
  margin: 12px;
  overflow: hidden;
}
.form-item {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid #f0f0f0;
}
.form-item:last-child { border-bottom: none; }
.form-item label {
  width: 78px;
  flex-shrink: 0;
  font-size: 15px;
  color: var(--text-dark);
}
.form-item input,
.form-item textarea,
.form-item select {
  flex: 1;
  border: none;
  outline: none;
  font-size: 16px; /* >=16px避免iOS Safari聚焦时自动放大整页 */
  background: transparent;
}
textarea.full {
  width: 100%;
  min-height: 120px;
  border: none;
  border-radius: 12px;
  padding: 16px;
  margin: 12px;
  width: calc(100% - 24px);
  font-size: 16px;
  resize: vertical;
}

.btn-primary {
  display: block;
  width: calc(100% - 24px);
  margin: 12px;
  padding: 14px;
  border: none;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  text-align: center;
}
.btn-primary:disabled { opacity: 0.6; }
.btn-outline {
  display: block;
  width: calc(100% - 24px);
  margin: 12px;
  padding: 14px;
  border: 1px solid var(--primary);
  border-radius: 10px;
  background: #fff;
  color: var(--primary);
  font-size: 16px;
  text-align: center;
}

/* 底部导航栏 */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--app-max-width); /* 和body容器同宽,桌面预览时不会铺满整个窗口 */
  height: 58px;
  padding-bottom: var(--safe-bottom); /* iPhone底部小白条安全区 */
  background: #fff;
  border-top: 1px solid #eee;
  display: flex;
  z-index: 100;
}
.bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--text-gray);
  gap: 2px;
}
.bottom-nav a.active { color: var(--primary); }
.bottom-nav .icon { display: flex; }
.bottom-nav .icon svg { width: 22px; height: 22px; }

/* 我的页面头部 */
.profile-header {
  background: linear-gradient(180deg, var(--primary) 0%, #fff 100%);
  padding: 20px 16px 60px;
  display: flex;
  align-items: center;
  gap: 14px;
  color: #fff;
}
.profile-header .avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #ddd;
  object-fit: cover;
}
.profile-header .name { font-size: 17px; font-weight: 600; }
.profile-header .sub { font-size: 12px; opacity: 0.85; }

.wallet-card {
  margin: -44px 12px 0;
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  box-shadow: 0 2px 10px rgba(0,0,0,0.06);
  position: relative;
  z-index: 2;
}
.wallet-card .balance { font-size: 22px; font-weight: 700; margin: 8px 0; }

/* tabs */
.tabs {
  display: flex;
  background: #fff;
  border-bottom: 1px solid #eee;
}
.tabs .tab {
  flex: 1;
  text-align: center;
  padding: 14px 0;
  font-size: 15px;
  color: var(--text-gray);
  position: relative;
}
.tabs .tab.active {
  color: var(--primary);
  font-weight: 600;
}
.tabs .tab.active::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 28px;
  height: 3px;
  background: var(--primary);
  border-radius: 2px;
}

.empty-tip {
  text-align: center;
  color: var(--text-gray);
  font-size: 13px;
  padding: 40px 0;
}

.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.75);
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 999;
  display: none;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text-gray);
}
.checkbox-row a { color: var(--primary); }

.cart-item {
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  background: #fff;
  border-bottom: 1px solid #f0f0f0;
  align-items: center;
}
.cart-item img { width: 64px; height: 64px; border-radius: 8px; object-fit: cover; background: #f0f0f0; }
.cart-item .body { flex: 1; }
.cart-item .qty-control { display: flex; align-items: center; gap: 8px; }
.cart-item .qty-control button {
  width: 26px; height: 26px; border: 1px solid #ddd; border-radius: 50%; background: #fff;
}
.cart-item .remove { color: var(--text-gray); font-size: 13px; }

.checkout-bar {
  position: fixed;
  bottom: calc(58px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--app-max-width);
  background: #fff;
  border-top: 1px solid #eee;
  display: flex;
  align-items: center;
  padding: 10px 16px;
  z-index: 90;
}
.checkout-bar .total { flex: 1; font-size: 14px; }
.checkout-bar button {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 20px;
  padding: 10px 24px;
  font-size: 15px;
  font-weight: 600;
}

.order-card {
  background: #fff;
  border-radius: 12px;
  margin: 12px;
  padding: 14px 16px;
}
.order-card .order-head {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-gray);
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid #f5f5f5;
}
.order-card .order-item { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 6px; }
.status-tag { color: var(--primary); font-weight: 600; }

/* 虚拟卡密展示(打码/查看切换) */
.card-code-box {
  margin-top: 8px;
  background: #fafafa;
  border-radius: 8px;
  padding: 10px 12px;
}
.card-code-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  flex-wrap: wrap;
}
.card-code-line .code-text {
  flex: 1;
  font-family: "SFMono-Regular", Consolas, monospace;
  color: var(--text-dark);
  word-break: break-all;
}
.card-code-line .reveal-btn {
  color: var(--primary);
  font-size: 12px;
  border: 1px solid var(--primary);
  border-radius: 12px;
  padding: 2px 10px;
  flex-shrink: 0;
}

/* 首页图片banner框(后台自己换图: 替换 public/img/banner-1.svg,或改成任意图片URL) */
.banner {
  margin: 12px 12px 12px; /* 正常间距,不再往上叠压顶部红色区域 */
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  position: relative;
  z-index: 5;
}
.banner img {
  width: 100%;
  display: block;
  aspect-ratio: 700 / 187; /* 高度缩小约1/3(原280→187) */
  object-fit: cover;
}

/* 首页专用: 顶部(banner+筛选栏)固定不滚动,商品列表单独滚动 */
body.home-fixed {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  padding-bottom: 0; /* 覆盖掉body默认给底部导航留的padding,这里改由.home-scroll自己处理 */
  display: flex;
  flex-direction: column;
}
.home-top-fixed {
  flex-shrink: 0; /* 顶部区域高度固定,不参与压缩 */
}
.home-scroll {
  flex: 1;
  min-height: 0; /* flex子元素要能正常出现内部滚动条,必须显式清零这个默认值 */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  scrollbar-width: none; /* Firefox: 隐藏滚动条外观,不影响滚动功能 */
  -ms-overflow-style: none; /* 旧版Edge/IE */
}
.home-scroll::-webkit-scrollbar {
  display: none; /* Chrome/Safari: 隐藏滚动条外观,不影响滚动功能 */
}
.home-scroll .product-list {
  padding-bottom: calc(64px + var(--safe-bottom) + 12px); /* 留出底部导航高度,最后一条商品不被遮住 */
}
