:root {
  --primary: #c0392b;
  --primary-dark: #96281b;
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #2c3038;
  --text-2: #8a9099;
  --line: #eceef1;
  --radius: 12px;
}

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

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

body { display: flex; flex-direction: column; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 100;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  box-shadow: 0 2px 8px rgba(192, 57, 43, .25);
}
.topbar-inner {
  max-width: 760px; margin: 0 auto;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
}
.back-btn {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; margin-left: -6px;
  cursor: pointer; border-radius: 50%;
  transition: background .15s;
}
.back-btn:active { background: rgba(255,255,255,.18); }
.search-box {
  flex: 1; display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,.95);
  border-radius: 999px; padding: 8px 14px;
  color: var(--text-2);
}
.search-box input {
  border: none; outline: none; background: transparent;
  width: 100%; font-size: 14px; color: var(--text);
}
.topbar-title { font-size: 16px; font-weight: 600; white-space: nowrap; }

/* ---------- 主区域 ---------- */
main {
  flex: 1; width: 100%; max-width: 760px;
  margin: 0 auto;
  padding: 12px 12px calc(64px + env(safe-area-inset-bottom));
}

/* ---------- 类目页 ---------- */
.banner {
  border-radius: var(--radius);
  background: linear-gradient(135deg, #e74c3c, #c0392b 60%, #96281b);
  color: #fff; padding: 22px 20px; margin-bottom: 12px;
}
.banner h1 { font-size: 20px; margin-bottom: 6px; }
.banner p { font-size: 13px; opacity: .85; }

.section-title {
  font-size: 15px; font-weight: 600; margin: 16px 2px 10px;
  display: flex; align-items: center; gap: 6px;
}
.section-title::before {
  content: ""; width: 4px; height: 16px; border-radius: 2px;
  background: var(--primary);
}

.category-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
}
.category-card {
  background: var(--card); border-radius: var(--radius);
  padding: 16px 4px 12px; text-align: center; text-decoration: none;
  color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.04);
  transition: transform .15s, box-shadow .15s;
}
.category-card:active { transform: scale(.95); }
.category-card .icon {
  font-size: 30px; line-height: 1;
  width: 52px; height: 52px; margin: 0 auto 8px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 16px; background: #fdf1ef;
}
.category-card .name { font-size: 13px; font-weight: 500; }
.category-card .count { font-size: 11px; color: var(--text-2); margin-top: 2px; }

/* ---------- 列表页 ---------- */
.list-layout { display: flex; gap: 10px; }
.side-cats {
  width: 96px; flex-shrink: 0;
  background: var(--card); border-radius: var(--radius);
  overflow-y: auto; align-self: flex-start;
  position: sticky; top: 62px;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.side-cats a {
  display: block; padding: 14px 8px;
  font-size: 13px; text-align: center; text-decoration: none;
  color: var(--text); border-left: 3px solid transparent;
}
.side-cats a.active {
  color: var(--primary); font-weight: 600;
  background: #fdf1ef; border-left-color: var(--primary);
}
.product-list { flex: 1; display: flex; flex-direction: column; gap: 10px; min-width: 0; }

.product-card {
  display: flex; gap: 12px; text-decoration: none; color: var(--text);
  background: var(--card); border-radius: var(--radius); padding: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
  transition: transform .15s;
}
.product-card:active { transform: scale(.98); }
.product-thumb {
  width: 92px; height: 92px; flex-shrink: 0;
  border-radius: 10px; background: #fdf1ef;
  display: flex; align-items: center; justify-content: center;
  font-size: 44px;
}
.product-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.product-name {
  font-size: 14px; font-weight: 500; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.product-tags { margin-top: 4px; display: flex; gap: 4px; flex-wrap: wrap; }
.tag {
  font-size: 10px; color: var(--primary);
  border: 1px solid currentColor; border-radius: 4px; padding: 0 4px;
}
.product-meta { margin-top: auto; display: flex; align-items: baseline; gap: 8px; }
.product-price { color: var(--primary); font-size: 17px; font-weight: 700; }
.product-price small { font-size: 11px; font-weight: 400; }
.product-sales { font-size: 11px; color: var(--text-2); }

/* ---------- 详情页 ---------- */
.detail-hero {
  background: var(--card); border-radius: var(--radius);
  padding: 26px 0; text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.detail-hero .emoji {
  width: 150px; height: 150px; margin: 0 auto;
  background: #fdf1ef; border-radius: 28px;
  display: flex; align-items: center; justify-content: center;
  font-size: 84px;
}
.detail-card {
  background: var(--card); border-radius: var(--radius);
  margin-top: 10px; padding: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.detail-name { font-size: 17px; font-weight: 600; line-height: 1.45; }
.detail-price-row {
  display: flex; align-items: baseline; gap: 10px; margin-top: 12px;
  padding-top: 12px; border-top: 1px dashed var(--line);
}
.detail-price { color: var(--primary); font-size: 26px; font-weight: 700; }
.detail-price small { font-size: 13px; font-weight: 400; }
.detail-sales { font-size: 12px; color: var(--text-2); }
.detail-spec {
  margin-top: 14px; font-size: 13px;
  background: var(--bg); border-radius: 10px; padding: 12px 14px;
  line-height: 2; color: var(--text);
}
.detail-spec b { color: var(--text-2); font-weight: 400; margin-right: 10px; }
.detail-desc-title {
  font-size: 15px; font-weight: 600; margin: 4px 0 8px;
  display: flex; align-items: center; gap: 6px;
}
.detail-desc-title::before {
  content: ""; width: 4px; height: 15px; border-radius: 2px; background: var(--primary);
}
.detail-desc { font-size: 14px; line-height: 1.8; color: #555b64; }

/* ---------- 其他 ---------- */
.empty {
  text-align: center; padding: 60px 0; color: var(--text-2); font-size: 14px;
}
.empty .big { font-size: 46px; margin-bottom: 10px; }

/* ---------- 底部导航 ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  background: #fff; border-top: 1px solid var(--line);
  display: flex; justify-content: center;
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar-inner { display: flex; width: 100%; max-width: 760px; }
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  gap: 2px; padding: 7px 0 6px; text-decoration: none;
  color: var(--text-2); font-size: 11px;
}
.tab.active { color: var(--primary); }

@media (min-width: 700px) {
  .category-grid { grid-template-columns: repeat(6, 1fr); }
}
