/* ============ 基础 ============ */
:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --primary: #ff6b35;
  --primary-dark: #e85a26;
  --text: #22242a;
  --text-sub: #8a8f9c;
  --border: #eceef3;
  --danger: #e5484d;
  --radius: 14px;
  --shadow: 0 2px 12px rgba(20, 22, 30, 0.06);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.hidden { display: none !important; }

/* ============ 头部 ============ */
.header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1024px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 19px;
  font-weight: 700;
}

.logo-mark { font-size: 22px; }

.cart-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 50%;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s;
}

.cart-btn:active { background: var(--border); }

.cart-badge {
  position: absolute;
  top: -4px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  line-height: 18px;
  text-align: center;
}

/* ============ 主体 ============ */
.main {
  max-width: 1024px;
  margin: 0 auto;
  padding: 16px 16px 120px;
}

.hero { padding: 6px 2px 14px; }

.hero h1 { font-size: 24px; letter-spacing: 0.5px; }

.hero p { color: var(--text-sub); font-size: 13px; margin-top: 2px; }

/* ============ 商品网格 ============ */
.product-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.product-card {
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  transition: transform 0.15s;
}

.product-card:active { transform: scale(0.98); }

.product-img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
  background: var(--border);
}

.product-img-wrap { position: relative; }

.weight-tag {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(255, 107, 53, 0.94);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  pointer-events: none;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
}

.product-body { padding: 10px 12px 12px; display: flex; flex-direction: column; flex: 1; }

.product-name {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 38px;
}

.product-desc {
  font-size: 12px;
  color: var(--text-sub);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: 4px;
  flex: 1;
}

.product-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.price {
  color: var(--primary);
  font-weight: 700;
  font-size: 16px;
  white-space: nowrap;
}

.price::before { content: "¥"; font-size: 12px; margin-right: 1px; }

.price-unit { font-size: 11px; font-weight: 600; color: var(--primary); }

.add-btn {
  border: none;
  background: var(--primary);
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(255, 107, 53, 0.35);
  transition: transform 0.12s, background 0.15s;
}

.add-btn:active { transform: scale(0.92); background: var(--primary-dark); }

.empty-state {
  text-align: center;
  color: var(--text-sub);
  padding: 60px 0;
}

/* ============ 购物车抽屉 ============ */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 40;
}

.cart-panel {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  background: var(--card);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -6px 30px rgba(0, 0, 0, 0.12);
  transform: translateY(105%);
  transition: transform 0.28s ease;
  display: flex;
  flex-direction: column;
  max-height: 82vh;
}

.cart-panel.open { transform: translateY(0); }

.cart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 10px;
}

.cart-head h2 { font-size: 17px; }

.icon-btn {
  border: none;
  background: var(--bg);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-sub);
}

.cart-items {
  overflow-y: auto;
  padding: 4px 18px;
  flex: 1;
}

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

.cart-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.cart-item-img {
  width: 62px;
  height: 62px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--border);
}

.cart-item-info { flex: 1; min-width: 0; }

.cart-item-name {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cart-item-price { color: var(--primary); font-size: 14px; font-weight: 700; margin-top: 2px; }

.cart-item-op { display: flex; align-items: center; gap: 10px; }

.qty-btn {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
}

.qty-btn:active { background: var(--bg); }

.qty-num { min-width: 22px; text-align: center; font-size: 14px; font-weight: 600; }

.del-btn {
  border: none;
  background: none;
  color: var(--text-sub);
  font-size: 12px;
  cursor: pointer;
  text-decoration: underline;
}

.cart-foot {
  padding: 14px 18px calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.cart-total { display: flex; flex-direction: column; }

.cart-total span:first-child { font-size: 12px; color: var(--text-sub); }

.total-amount { color: var(--primary); font-weight: 800; font-size: 20px; }

.total-amount::before { content: "¥"; font-size: 13px; margin-right: 1px; }

.btn-primary {
  border: none;
  background: var(--primary);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  padding: 12px 34px;
  border-radius: 999px;
  cursor: pointer;
}

.btn-primary:active { background: var(--primary-dark); }

/* ============ Toast ============ */
.toast {
  position: fixed;
  left: 50%;
  bottom: 40px;
  transform: translateX(-50%);
  background: rgba(20, 22, 30, 0.88);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  z-index: 99;
  max-width: 80vw;
  text-align: center;
}

/* ============ PC 适配 ============ */
@media (min-width: 640px) {
  .product-grid { grid-template-columns: repeat(3, 1fr); gap: 16px; }
  .main { padding-top: 24px; }
  .cart-panel {
    left: auto;
    right: 16px;
    bottom: 16px;
    width: 380px;
    max-height: 560px;
    border-radius: 18px;
    transform: translateX(calc(100% + 20px));
  }
  .cart-panel.open { transform: translateX(0); }
  .cart-head { padding-top: 18px; }
}

@media (min-width: 900px) {
  .product-grid { grid-template-columns: repeat(4, 1fr); }
}
