:root {
  --primary: #ff5000;
  --primary-light: #ff7e3f;
  --bg: #f5f5f5;
  --card: #fff;
  --text: #333;
  --text-light: #999;
  --price: #ff5000;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

body { padding-bottom: calc(56px + var(--safe-bottom)); }

img { display: block; max-width: 100%; }

/* ===== 顶部栏 ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  padding: 10px 12px calc(8px) 12px;
  padding-top: calc(10px + env(safe-area-inset-top, 0px));
  color: #fff;
}
.topbar-inner { display: flex; align-items: center; gap: 10px; }
.logo { font-size: 26px; flex-shrink: 0; }
.search { flex: 1; }
.search input {
  width: 100%;
  border: none;
  outline: none;
  border-radius: 18px;
  padding: 8px 14px;
  font-size: 13px;
  background: rgba(255, 255, 255, 0.95);
  color: var(--text);
}
.notice {
  margin-top: 8px;
  font-size: 12px;
  opacity: 0.95;
  display: flex;
  align-items: center;
  gap: 4px;
}
.notice::before { content: "📢"; }

/* ===== 视图切换 ===== */
.view { display: none; padding: 10px 12px; }
.view.active { display: block; animation: fade 0.2s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.page-title { font-size: 17px; font-weight: 600; margin: 6px 4px 12px; }

/* ===== 轮播 ===== */
.banner {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
  border-radius: 12px;
}
.banner::-webkit-scrollbar { display: none; }
.banner-item {
  scroll-snap-align: start;
  min-width: 100%;
  height: 140px;
  border-radius: 12px;
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 22px;
  background-size: cover;
  background-position: center;
}
.banner-item h3 { font-size: 22px; margin-bottom: 6px; }
.banner-item p { font-size: 13px; opacity: 0.95; }

/* ===== 分类 ===== */
.cats {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  margin: 14px 0 10px;
  padding-bottom: 2px;
}
.cats::-webkit-scrollbar { display: none; }
.cat {
  flex-shrink: 0;
  background: var(--card);
  border-radius: 16px;
  padding: 6px 14px;
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  transition: 0.15s;
}
.cat .ci { margin-right: 3px; }
.cat.active { background: var(--primary); color: #fff; }

/* ===== 商品网格 ===== */
.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.card {
  background: var(--card);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.card-img {
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 56px;
  background: #fafafa;
  background-size: cover;
  background-position: center;
}
.card-body { padding: 8px 9px 10px; }
.card-name {
  font-size: 13px;
  line-height: 1.4;
  height: 36px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.card-tags { display: flex; gap: 4px; flex-wrap: wrap; margin: 6px 0 4px; }
.tag {
  font-size: 10px;
  color: var(--primary);
  border: 1px solid var(--primary);
  border-radius: 4px;
  padding: 0 4px;
  line-height: 15px;
}
.card-foot { display: flex; align-items: baseline; justify-content: space-between; margin-top: 4px; }
.price { color: var(--price); font-weight: 700; }
.price .sym { font-size: 11px; }
.price .num { font-size: 17px; }
.old-price { color: var(--text-light); font-size: 11px; text-decoration: line-through; }
.sales { color: var(--text-light); font-size: 11px; }
.add-cart {
  border: none;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  width: 26px;
  height: 26px;
  font-size: 18px;
  line-height: 1;
  flex-shrink: 0;
}

.empty { text-align: center; color: var(--text-light); padding: 50px 0; }

/* 收藏按钮（卡片右上角） */
.card-img { position: relative; }
.fav-btn {
  position: absolute; top: 6px; right: 6px;
  width: 26px; height: 26px; border: none; border-radius: 50%;
  background: rgba(255,255,255,0.85); font-size: 14px; line-height: 26px;
  padding: 0; box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* ===== 详情页 ===== */
.back-btn { background: none; border: none; font-size: 16px; color: var(--text); padding: 4px 0 10px; }
.detail-img {
  width: 100%;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 130px;
  background: var(--card);
  border-radius: 12px;
  background-size: cover;
  background-position: center;
}
.detail-info { background: var(--card); border-radius: 12px; padding: 14px; margin-top: 10px; }
.detail-price { display: flex; align-items: baseline; gap: 8px; }
.detail-price .price .num { font-size: 26px; }
.detail-name { font-size: 16px; font-weight: 600; margin: 8px 0; }
.detail-meta { display: flex; gap: 14px; color: var(--text-light); font-size: 12px; }
.detail-section { background: var(--card); border-radius: 12px; padding: 14px; margin-top: 10px; }
.detail-section h4 { font-size: 14px; margin-bottom: 8px; }
.detail-section p { color: #666; font-size: 13px; line-height: 1.7; }
.detail-fav {
  margin-left: auto; border: 1px solid #ddd; background: #fff;
  border-radius: 16px; font-size: 12px; padding: 4px 12px; color: #666;
}
.detail-fav.on { color: var(--primary); border-color: var(--primary); }
.detail-qty { display: flex; align-items: center; gap: 10px; margin-top: 12px; font-size: 13px; color: #666; }
.detail-actions { display: flex; gap: 10px; margin: 14px 0 8px; }
.detail-actions button { flex: 1; border: none; border-radius: 22px; font-size: 15px; padding: 11px 0; }
.act-cart { background: #ffe9df; color: var(--primary); }
.act-buy { background: linear-gradient(135deg, var(--primary), var(--primary-light)); color: #fff; }

/* ===== 子页面通用：表单 / 按钮 ===== */
.form-card { background: var(--card); border-radius: 12px; padding: 14px; }
.form-card label { display: block; font-size: 13px; color: #666; margin-bottom: 14px; }
.form-card input, .form-card textarea {
  display: block; width: 100%; margin-top: 6px; border: 1px solid #eee; border-radius: 8px;
  padding: 10px; font-size: 14px; color: var(--text); outline: none; background: #fafafa;
  font-family: inherit; resize: vertical;
}
.form-card textarea { min-height: 64px; }
.primary-btn {
  width: 100%; border: none; border-radius: 22px; padding: 11px 0; font-size: 15px;
  color: #fff; background: linear-gradient(135deg, var(--primary), var(--primary-light));
}
.no-arrow::after { content: "" !important; }
.muted { color: var(--text-light); font-size: 12px; }

/* ===== 优惠券 ===== */
.coupon-card {
  display: flex; background: var(--card); border-radius: 12px; overflow: hidden;
  margin-bottom: 12px; border: 1px solid #ffe0d3;
}
.coupon-card.claimed { opacity: 0.55; }
.cp-left {
  width: 110px; flex-shrink: 0; background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 16px 0;
}
.cp-amount { font-size: 26px; font-weight: 700; }
.cp-cond { font-size: 11px; opacity: 0.95; margin-top: 4px; }
.cp-right { flex: 1; padding: 14px; display: flex; flex-direction: column; justify-content: center; gap: 10px; }
.cp-title { font-size: 15px; font-weight: 600; }
.cp-btn { align-self: flex-start; border: 1px solid var(--primary); color: var(--primary); background: #fff; border-radius: 14px; padding: 4px 16px; font-size: 13px; }
.coupon-card.claimed .cp-btn { border-color: #ccc; color: #999; }

/* ===== 订单 ===== */
.order-card { background: var(--card); border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; }
.o-head { display: flex; justify-content: space-between; align-items: center; padding-bottom: 10px; border-bottom: 1px solid #f2f2f2; }
.o-no { font-size: 12px; color: var(--text-light); }
.o-status { font-size: 13px; color: var(--primary); font-weight: 600; }
.o-item { display: flex; align-items: center; gap: 10px; padding: 8px 0; }
.o-emoji { width: 40px; height: 40px; border-radius: 6px; background: #fafafa; display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0; background-size: cover; background-position: center; }
.o-name { flex: 1; font-size: 13px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.o-qty { font-size: 12px; color: var(--text-light); }
.o-foot { display: flex; justify-content: space-between; align-items: center; padding-top: 10px; border-top: 1px solid #f2f2f2; font-size: 12px; color: var(--text-light); }
.o-total b { color: var(--price); font-size: 15px; }

/* ===== 弹窗 ===== */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center; z-index: 200;
}
.modal-mask[hidden] { display: none; }
.modal { background: #fff; border-radius: 14px; padding: 24px; width: 75%; max-width: 300px; text-align: center; }
.pay-box p { margin-top: 14px; font-size: 15px; color: var(--text); }
.pay-hint { margin-top: 4px !important; font-size: 12px !important; color: var(--text-light) !important; }

/* ===== 登录页 ===== */
.login-view { padding: 0 28px; min-height: 100vh; }
.login-back {
  position: absolute; top: calc(12px + env(safe-area-inset-top, 0px)); left: 14px;
  font-size: 26px; line-height: 1; padding: 0; width: 32px; height: 32px; color: var(--text);
}
.login-logo { font-size: 64px; text-align: center; margin-top: 90px; }
.login-title { text-align: center; font-size: 22px; font-weight: 700; margin-top: 10px; }
.login-sub { text-align: center; color: var(--text-light); font-size: 12px; margin: 8px 0 36px; }
.login-form { display: flex; flex-direction: column; gap: 16px; }
.login-field {
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid #eee; padding: 8px 2px;
}
.lf-prefix { font-size: 15px; color: var(--text); flex-shrink: 0; }
.login-field input {
  flex: 1; border: none; outline: none; font-size: 15px; background: transparent; color: var(--text);
  min-width: 0;
}
.lf-code {
  flex-shrink: 0; border: none; background: none; color: var(--primary);
  font-size: 13px; padding: 4px 0;
}
.lf-code.counting { color: var(--text-light); }
.login-submit { margin-top: 16px; }
.login-agree { text-align: center; font-size: 11px; color: var(--text-light); margin-top: 16px; }
.login-agree a { color: var(--primary); }

/* 支付宝授权登录按钮 */
.alipay-btn {
  width: 100%; border: none; border-radius: 24px; padding: 12px 0;
  font-size: 16px; color: #fff; background: #1677ff;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.ali-logo {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 5px; background: #fff; color: #1677ff;
  font-size: 14px; font-weight: 700;
}
.ali-logo.sm { width: 18px; height: 18px; font-size: 12px; }

/* ===== 授权底部抽屉 ===== */
.sheet-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  display: flex; align-items: flex-end; z-index: 210;
}
.sheet-mask[hidden] { display: none; }
.sheet {
  width: 100%; background: #fff; border-radius: 16px 16px 0 0;
  padding: 18px 18px calc(18px + var(--safe-bottom));
  animation: sheetUp 0.25s ease;
}
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.as-head { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 600; justify-content: center; padding-bottom: 14px; border-bottom: 1px solid #f2f2f2; }
.as-app { display: flex; align-items: center; gap: 12px; padding: 16px 0; }
.as-applogo { font-size: 38px; width: 48px; height: 48px; display: flex; align-items: center; justify-content: center; background: #f5f5f5; border-radius: 10px; }
.as-appname { font-size: 16px; font-weight: 600; }
.as-appdesc { font-size: 12px; color: var(--text-light); margin-top: 2px; }
.as-account { display: flex; align-items: center; gap: 12px; background: #f7f8fa; border-radius: 10px; padding: 12px; }
.as-avatar { font-size: 28px; width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; background: #fff; border-radius: 50%; }
.as-meta { flex: 1; min-width: 0; }
.as-nick { font-size: 15px; font-weight: 600; }
.as-phone { font-size: 12px; color: var(--text-light); margin-top: 2px; }
.as-switch { border: none; background: none; color: #1677ff; font-size: 13px; flex-shrink: 0; }
.as-scope { list-style: none; padding: 14px 2px; }
.as-scope li { font-size: 13px; color: #555; padding: 4px 0 4px 18px; position: relative; }
.as-scope li::before { content: "✓"; color: #1677ff; position: absolute; left: 0; }
.as-actions { display: flex; gap: 12px; margin-top: 6px; }
.as-actions button { flex: 1; border: none; border-radius: 22px; padding: 11px 0; font-size: 15px; }
.as-deny { background: #f2f2f2; color: #555; }
.as-allow { background: #1677ff; color: #fff; }

/* ===== 订单详情 ===== */
.od-status { background: linear-gradient(135deg, var(--primary), var(--primary-light)); color: #fff; border-radius: 12px; padding: 18px 16px; font-size: 18px; font-weight: 600; }
.od-addr { display: flex; gap: 10px; background: var(--card); border-radius: 12px; padding: 14px; margin-top: 10px; align-items: flex-start; }
.od-addr-ico { font-size: 18px; }
.od-addr-line { font-size: 14px; }
.od-addr-detail { font-size: 13px; color: #666; margin-top: 4px; line-height: 1.5; }
.od-addr-empty .od-addr-detail { color: var(--text-light); margin-top: 0; }
.od-card { background: var(--card); border-radius: 12px; padding: 12px 14px; margin-top: 10px; }
.od-item { display: flex; align-items: center; gap: 10px; padding: 8px 0; }
.od-img { width: 56px; height: 56px; border-radius: 8px; background: #fafafa; display: flex; align-items: center; justify-content: center; font-size: 30px; flex-shrink: 0; background-size: cover; background-position: center; }
.od-it-mid { flex: 1; min-width: 0; }
.od-it-name { font-size: 13px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.od-it-price { color: var(--price); font-weight: 600; margin-top: 4px; }
.od-it-qty { color: var(--text-light); font-size: 13px; }
.od-row { display: flex; justify-content: space-between; font-size: 13px; color: #666; padding: 6px 0; }
.od-paid { border-top: 1px solid #f2f2f2; margin-top: 4px; padding-top: 10px; color: var(--text); }
.od-paid-num { color: var(--price); font-size: 17px; font-weight: 700; }
.od-copy { color: var(--primary); }
.o-more { text-align: right; font-size: 12px; color: var(--text-light); padding-top: 8px; }
.order-card { cursor: pointer; }

/* ===== 协议页 ===== */
.legal-view { padding-bottom: 30px; }
.legal-title { font-size: 20px; font-weight: 700; margin: 4px 0; }
.legal-updated { font-size: 12px; color: var(--text-light); margin-bottom: 16px; }
.legal-h { font-size: 15px; font-weight: 600; margin: 16px 0 6px; }
.legal-p { font-size: 13px; color: #555; line-height: 1.8; }
.spinner {
  width: 42px; height: 42px; margin: 0 auto; border: 4px solid #eee;
  border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.pay-check {
  width: 48px; height: 48px; margin: 0 auto; border-radius: 50%;
  background: #2ecc71; color: #fff; font-size: 28px; line-height: 48px;
}
.modal-info h3 { font-size: 17px; margin-bottom: 12px; }
.modal-info p { font-size: 14px; color: #555; margin-bottom: 10px; line-height: 1.6; }
.modal-info b { font-size: 18px; color: var(--primary); }
.modal-info .primary-btn { margin-top: 8px; }

/* ===== 购物车 ===== */
.cart-item {
  display: flex;
  gap: 10px;
  background: var(--card);
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 10px;
  align-items: center;
}
.cart-item .ci-img {
  width: 64px; height: 64px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 34px; background: #fafafa; flex-shrink: 0;
  background-size: cover; background-position: center;
}
.cart-item .ci-mid { flex: 1; min-width: 0; }
.cart-item .ci-name { font-size: 13px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.cart-item .ci-price { color: var(--price); font-weight: 600; margin-top: 6px; }
.stepper { display: flex; align-items: center; gap: 0; }
.stepper button {
  width: 26px; height: 26px; border: 1px solid #ddd; background: #fff;
  font-size: 16px; line-height: 1; color: var(--text);
}
.stepper button:first-child { border-radius: 6px 0 0 6px; }
.stepper button:last-child { border-radius: 0 6px 6px 0; }
.stepper span { min-width: 34px; text-align: center; border-top: 1px solid #ddd; border-bottom: 1px solid #ddd; height: 26px; line-height: 26px; }

/* ===== 结算栏 ===== */
.checkout-bar {
  position: fixed;
  left: 0; right: 0;
  bottom: calc(56px + var(--safe-bottom));
  background: #fff;
  border-top: 1px solid #eee;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  z-index: 60;
}
.checkout-bar[hidden] { display: none; }
.checkout-info { font-size: 13px; }
.checkout-price { color: var(--price); font-size: 18px; font-weight: 700; }
.checkout-tip { color: var(--text-light); font-size: 11px; display: block; }
.checkout-btn {
  border: none;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
  font-size: 15px;
  padding: 10px 28px;
  border-radius: 22px;
}

/* ===== 头部 / 菜单显隐 ===== */
.hide-topbar .topbar { display: none; }
.hide-topbar { padding-top: env(safe-area-inset-top, 0px); }
.hide-tabbar .tabbar { display: none; }
.hide-tabbar { padding-bottom: 0; }

/* ===== 我的 ===== */
.mine-header {
  display: flex; align-items: center; gap: 14px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff; border-radius: 12px; padding: 20px 16px;
}
.mine-meta { flex: 1; min-width: 0; }
.mine-auth {
  border: 1px solid rgba(255,255,255,0.8); background: rgba(255,255,255,0.15);
  color: #fff; border-radius: 16px; padding: 5px 16px; font-size: 13px; flex-shrink: 0;
}
.mine-avatar { font-size: 46px; background: rgba(255,255,255,0.25); border-radius: 50%; width: 64px; height: 64px; display: flex; align-items: center; justify-content: center; }
.mine-name { font-size: 18px; font-weight: 600; }
.mine-sub { font-size: 12px; opacity: 0.9; margin-top: 4px; }
.mine-list { list-style: none; background: var(--card); border-radius: 12px; margin-top: 12px; overflow: hidden; }
.mine-list li { padding: 14px 16px; border-bottom: 1px solid #f2f2f2; font-size: 14px; }
.mine-list li:last-child { border-bottom: none; }
.mine-list li::after { content: "›"; float: right; color: var(--text-light); }

/* ===== 底部 Tab ===== */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: calc(56px + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: #fff;
  border-top: 1px solid #eee;
  display: flex;
  z-index: 70;
}
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--text-light);
  position: relative;
  text-decoration: none;
}
.tab span { font-size: 21px; line-height: 1; margin-bottom: 2px; }
.tab.active { color: var(--primary); }
.cart-badge {
  position: absolute;
  top: 4px;
  right: calc(50% - 22px);
  background: var(--primary);
  color: #fff;
  font-size: 10px;
  font-style: normal;
  min-width: 16px;
  height: 16px;
  line-height: 16px;
  text-align: center;
  border-radius: 8px;
  padding: 0 3px;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  left: 50%;
  top: 45%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 100;
  max-width: 70%;
  text-align: center;
}
.toast.show { opacity: 1; }
