:root {
  --primary: #e4393c;
  --primary-dark: #c1272d;
  --primary-light: #ff6b6e;
  --bg: #f5f5f5;
  --white: #ffffff;
  --text: #333333;
  --text-light: #999999;
  --text-mid: #666666;
  --border: #e8e8e8;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --radius: 8px;
  --max-width: 1200px;
  --header-height: 60px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }

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

/* ===== Header ===== */
.header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--white);
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  height: var(--header-height);
}

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  align-items: center;
  height: 100%;
  gap: 24px;
}

.logo {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
  white-space: nowrap;
  flex-shrink: 0;
}

.logo span { color: var(--text); font-weight: 400; font-size: 13px; margin-left: 8px; }

.search-box {
  flex: 1;
  max-width: 500px;
  position: relative;
}

.search-box input {
  width: 100%;
  height: 36px;
  border: 2px solid var(--primary);
  border-radius: 18px;
  padding: 0 44px 0 16px;
  font-size: 14px;
  outline: none;
  transition: box-shadow 0.2s;
}

.search-box input:focus { box-shadow: 0 0 0 3px rgba(228,57,60,0.15); }

.search-box button {
  position: absolute;
  right: 0;
  top: 0;
  width: 44px;
  height: 36px;
  background: var(--primary);
  border: none;
  border-radius: 0 18px 18px 0;
  color: white;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-shrink: 0;
}

.cart-btn {
  position: relative;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: 20px;
  transition: background 0.2s;
  color: var(--text);
  background: none;
  border: none;
}

.cart-btn:hover { background: var(--bg); }

.cart-badge {
  position: absolute;
  top: 0;
  right: 2px;
  background: var(--primary);
  color: white;
  font-size: 11px;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text);
}

/* ===== Navigation ===== */
.nav-bar {
  background: var(--white);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.nav-inner::-webkit-scrollbar { display: none; }

.nav-inner a {
  padding: 10px 18px;
  font-size: 14px;
  white-space: nowrap;
  color: var(--text);
  transition: color 0.2s, border-bottom 0.2s;
  border-bottom: 2px solid transparent;
}

.nav-inner a:hover, .nav-inner a.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* ===== Banner Carousel ===== */
.banner-section {
  max-width: var(--max-width);
  margin: 16px auto;
  padding: 0 16px;
}

.banner-carousel {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 3/1;
  background: #ddd;
}

.banner-track {
  display: flex;
  transition: transform 0.5s ease;
  height: 100%;
}

.banner-slide {
  min-width: 100%;
  position: relative;
  overflow: hidden;
}

.banner-slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.banner-text {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 40px 32px 24px;
  background: linear-gradient(transparent, rgba(0,0,0,0.7));
  color: white;
}

.banner-text h2 { font-size: 28px; margin-bottom: 4px; }
.banner-text p { font-size: 16px; opacity: 0.9; }

.banner-dots {
  position: absolute;
  bottom: 12px;
  right: 16px;
  display: flex;
  gap: 6px;
}

.banner-dots span {
  width: 8px;
  height: 8px;
  border-radius: 4px;
  background: rgba(255,255,255,0.5);
  cursor: pointer;
  transition: all 0.3s;
}

.banner-dots span.active { background: white; width: 24px; }

/* ===== Category Grid ===== */
.section {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 20px 16px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-header h2 {
  font-size: 20px;
  font-weight: 600;
}

.section-header a {
  font-size: 14px;
  color: var(--text-light);
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 12px;
}

.category-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px 8px;
  text-align: center;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: var(--shadow);
}

.category-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}

.category-icon {
  font-size: 36px;
  margin-bottom: 8px;
}

.category-name { font-size: 13px; font-weight: 500; }

/* ===== Product Grid ===== */
.product-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.product-card {
  background: var(--white);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: var(--shadow);
  position: relative;
}

.product-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
}

.product-img {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  background: #f0f0f0;
}

.product-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s;
}

.product-card:hover .product-img img { transform: scale(1.05); }

.product-tag {
  position: absolute;
  top: 8px;
  left: 8px;
  background: var(--primary);
  color: white;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
}

.product-info { padding: 12px; }

.product-name {
  font-size: 14px;
  line-height: 1.4;
  height: 2.8em;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.product-price-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-top: 8px;
}

.product-price {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
}

.product-price::before { content: "¥"; font-size: 13px; }

.product-original {
  font-size: 12px;
  color: var(--text-light);
  text-decoration: line-through;
}

.product-original::before { content: "¥"; }

.product-sales {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 4px;
}

/* ===== Product Detail Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-overlay.active { display: flex; }

.modal-content {
  background: var(--white);
  border-radius: 12px;
  max-width: 900px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.06);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}

.modal-close:hover { background: rgba(0,0,0,0.12); }

.detail-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}

.detail-img {
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 12px 0 0 12px;
  background: #f0f0f0;
}

.detail-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.detail-info {
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
}

.detail-info h2 { font-size: 20px; line-height: 1.4; margin-bottom: 16px; }

.detail-price-box {
  background: linear-gradient(135deg, #fff5f5, #ffe8e8);
  padding: 16px;
  border-radius: var(--radius);
  margin-bottom: 20px;
}

.detail-price {
  font-size: 32px;
  font-weight: 700;
  color: var(--primary);
}

.detail-price::before { content: "¥"; font-size: 18px; }

.detail-original {
  font-size: 14px;
  color: var(--text-light);
  text-decoration: line-through;
  margin-left: 12px;
}

.detail-discount {
  display: inline-block;
  background: var(--primary);
  color: white;
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 8px;
}

.detail-meta {
  font-size: 14px;
  color: var(--text-mid);
  line-height: 2;
}

.detail-actions {
  margin-top: auto;
  padding-top: 20px;
  display: flex;
  gap: 12px;
}

.btn-primary {
  flex: 1;
  padding: 12px 24px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 24px;
  font-size: 16px;
  cursor: pointer;
  transition: background 0.2s;
  font-weight: 600;
}

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

.btn-secondary {
  flex: 1;
  padding: 12px 24px;
  background: var(--white);
  color: var(--primary);
  border: 2px solid var(--primary);
  border-radius: 24px;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 600;
}

.btn-secondary:hover { background: #fff5f5; }

/* ===== Cart Sidebar ===== */
.cart-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 3000;
  display: none;
}

.cart-overlay.active { display: block; }

.cart-sidebar {
  position: fixed;
  top: 0;
  right: 0;
  width: 400px;
  max-width: 100vw;
  height: 100vh;
  background: var(--white);
  z-index: 3001;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s ease;
}

.cart-sidebar.active { transform: translateX(0); }

.cart-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cart-header h3 { font-size: 18px; }

.cart-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-light);
}

.cart-items {
  flex: 1;
  overflow-y: auto;
  padding: 12px 20px;
}

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

.cart-item-img {
  width: 72px;
  height: 72px;
  border-radius: 6px;
  overflow: hidden;
  flex-shrink: 0;
  background: #f0f0f0;
}

.cart-item-img img { width: 100%; height: 100%; object-fit: cover; }

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

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

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

.cart-item-qty {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.cart-item-qty button {
  width: 26px;
  height: 26px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--white);
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cart-item-qty button:hover { background: var(--bg); }

.cart-item-qty span { font-size: 14px; min-width: 24px; text-align: center; }

.cart-item-del {
  background: none;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  font-size: 18px;
  padding: 4px;
}

.cart-item-del:hover { color: var(--primary); }

.cart-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-light);
}

.cart-empty-icon { font-size: 64px; margin-bottom: 12px; }

.cart-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  background: var(--white);
}

.cart-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.cart-total-label { font-size: 14px; color: var(--text-mid); }

.cart-total-price { font-size: 22px; font-weight: 700; color: var(--primary); }

.cart-total-price::before { content: "¥"; font-size: 14px; }

.checkout-btn {
  width: 100%;
  padding: 14px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 24px;
  font-size: 16px;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.2s;
}

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

/* ===== Footer ===== */
.footer {
  background: #2c2c2c;
  color: #ccc;
  margin-top: 40px;
}

.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 40px 16px 20px;
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 32px;
  margin-bottom: 32px;
}

.footer-col h4 { color: white; font-size: 15px; margin-bottom: 12px; }

.footer-col a {
  display: block;
  font-size: 13px;
  color: #999;
  padding: 3px 0;
  transition: color 0.2s;
}

.footer-col a:hover { color: white; }

.footer-bottom {
  border-top: 1px solid #444;
  padding-top: 16px;
  text-align: center;
  font-size: 12px;
  color: #777;
}

/* ===== Category Page ===== */
.filter-bar {
  background: var(--white);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.filter-bar span { font-size: 14px; color: var(--text-mid); white-space: nowrap; }

.filter-btn {
  padding: 6px 16px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--white);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text);
}

.filter-btn:hover, .filter-btn.active {
  border-color: var(--primary);
  color: var(--primary);
  background: #fff5f5;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: rgba(0,0,0,0.75);
  color: white;
  padding: 10px 24px;
  border-radius: 24px;
  font-size: 14px;
  z-index: 9999;
  opacity: 0;
  transition: all 0.3s;
  pointer-events: none;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== Mobile Bottom Nav ===== */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--white);
  border-top: 1px solid var(--border);
  z-index: 1000;
  padding: 6px 0;
  padding-bottom: env(safe-area-inset-bottom);
}

.mobile-nav-inner {
  display: flex;
  justify-content: space-around;
  align-items: center;
}

.mobile-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 10px;
  color: var(--text-mid);
  padding: 4px 0;
}

.mobile-nav a.active { color: var(--primary); }

.mobile-nav-icon { font-size: 22px; }

/* ===== Responsive ===== */
@media (max-width: 1024px) {
  .product-grid { grid-template-columns: repeat(3, 1fr); }
  .footer-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  :root { --header-height: 52px; }

  .logo span { display: none; }
  .search-box { max-width: none; }

  .mobile-menu-btn { display: flex; }

  .nav-bar { display: none; }
  .nav-bar.active {
    display: block;
    position: absolute;
    top: var(--header-height);
    left: 0;
    right: 0;
    background: var(--white);
    box-shadow: var(--shadow);
    z-index: 999;
  }

  .nav-bar.active .nav-inner {
    flex-direction: column;
    padding: 8px 0;
  }

  .nav-bar.active .nav-inner a {
    padding: 10px 20px;
    border-bottom: none;
  }

  .banner-text h2 { font-size: 18px; }
  .banner-text p { font-size: 13px; }

  .category-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
  }

  .category-card { padding: 12px 4px; }
  .category-icon { font-size: 28px; }
  .category-name { font-size: 12px; }

  .product-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }

  .product-info { padding: 8px; }
  .product-name { font-size: 13px; }
  .product-price { font-size: 16px; }

  .detail-layout { grid-template-columns: 1fr; }
  .detail-img { border-radius: 12px 12px 0 0; aspect-ratio: 4/3; }
  .detail-info { padding: 20px 16px; }
  .detail-price { font-size: 26px; }
  .detail-info h2 { font-size: 17px; }

  .cart-sidebar { width: 100vw; }

  .footer-grid { grid-template-columns: 1fr 1fr; gap: 20px; }

  .mobile-nav { display: block; }

  body { padding-bottom: 64px; }

  .section { padding: 12px 8px; }

  .filter-bar { padding: 10px 12px; }
}

@media (max-width: 480px) {
  .category-grid { grid-template-columns: repeat(4, 1fr); }
  .product-grid { grid-template-columns: repeat(2, 1fr); gap: 6px; }
  .product-price { font-size: 15px; }
  .product-original { display: none; }
  .product-sales { display: none; }
  .header-actions .user-text { display: none; }
}
