:root {
  --primary: #e8590c;
  --primary-dark: #d9480f;
  --primary-light: #fff4e6;
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #212529;
  --text-2: #6c757d;
  --text-3: #adb5bd;
  --border: #e9ecef;
  --price: #e03131;
  --radius: 12px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}
img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; border: none; background: none; cursor: pointer; }
input, textarea, select { font-family: inherit; font-size: 14px; outline: none; }

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  position: relative;
  padding-bottom: calc(56px + env(safe-area-inset-bottom));
}

.page-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--primary);
  color: #fff;
  padding: calc(12px + env(safe-area-inset-top)) 14px 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}
.page-header .header-title {
  font-size: 18px;
  font-weight: 700;
  text-align: center;
}
.page-header .header-back {
  position: absolute;
  left: 12px;
  top: calc(12px + env(safe-area-inset-top));
  font-size: 20px;
  line-height: 24px;
  width: 30px;
  text-align: center;
}
.page-header .header-side {
  position: absolute;
  right: 12px;
  top: calc(12px + env(safe-area-inset-top));
  font-size: 15px;
  line-height: 24px;
  border: none;
  background: none;
  color: #fff;
  padding: 0;
  cursor: pointer;
}

.search-box {
  display: flex;
  align-items: center;
  background: #fff;
  border-radius: 20px;
  padding: 8px 14px;
  margin-top: 10px;
  color: var(--text-3);
  gap: 6px;
}
.search-box input {
  flex: 1;
  border: none;
  color: var(--text);
  background: transparent;
  font-size: 14px;
}
.search-box input::placeholder { color: var(--text-3); }

.notice-bar {
  background: var(--primary-light);
  color: var(--primary-dark);
  font-size: 13px;
  padding: 8px 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-bottom: 1px solid var(--border);
}

.cat-strip {
  background: var(--card);
  padding: 12px 8px;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-bottom: 1px solid var(--border);
}
.cat-strip::-webkit-scrollbar { display: none; }
.cat-strip .cat-item {
  flex: 0 0 auto;
  padding: 6px 14px;
  border-radius: 16px;
  background: var(--bg);
  color: var(--text-2);
  font-size: 13px;
  white-space: nowrap;
}
.cat-strip .cat-item.active {
  background: var(--primary);
  color: #fff;
  font-weight: 600;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 8px;
  font-size: 16px;
  font-weight: 700;
}
.section-title .more {
  font-size: 13px;
  font-weight: 400;
  color: var(--text-3);
}

.goods-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 0 10px 10px;
}
.goods-card {
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.goods-card .thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: #f1f3f5;
}
.goods-card .info {
  padding: 8px 10px 10px;
}
.goods-card .name {
  font-size: 14px;
  line-height: 1.4;
  height: 39px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-all;
}
.goods-card .price-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-top: 6px;
}
.goods-card .price {
  color: var(--price);
  font-size: 17px;
  font-weight: 700;
}
.goods-card .price small { font-size: 12px; font-weight: 600; }
.goods-card .market-price {
  color: var(--text-3);
  font-size: 12px;
  text-decoration: line-through;
}
.goods-card .sale {
  margin-left: auto;
  color: var(--text-3);
  font-size: 11px;
}

.load-more {
  text-align: center;
  padding: 16px 0 24px;
  color: var(--text-3);
  font-size: 13px;
}
.load-more button {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 8px 28px;
  color: var(--text-2);
}

.tabbar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: 480px;
  height: calc(52px + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(255, 255, 255, 0.97);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 200;
}
.tabbar a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 11px;
  color: var(--text-3);
}
.tabbar a .icon { font-size: 21px; line-height: 1; }
.tabbar a.active { color: var(--primary); font-weight: 600; }

.empty {
  text-align: center;
  color: var(--text-3);
  padding: 60px 20px;
  font-size: 14px;
}
.empty .icon { font-size: 44px; margin-bottom: 10px; opacity: 0.4; }

/* 分类页 */
.category-layout {
  display: flex;
  height: calc(100vh - 58px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
}
.cat-side {
  width: 92px;
  flex: 0 0 92px;
  background: #f1f3f5;
  overflow-y: auto;
}
.cat-side .cat {
  padding: 16px 8px;
  text-align: center;
  font-size: 13px;
  color: var(--text-2);
  border-left: 3px solid transparent;
}
.cat-side .cat.active {
  background: var(--card);
  color: var(--primary);
  font-weight: 700;
  border-left-color: var(--primary);
}
.cat-main {
  flex: 1;
  background: var(--card);
  overflow-y: auto;
  padding: 12px;
}
.cat-main .sub-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.cat-main .sub {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 14px 8px;
  text-align: center;
  font-size: 13px;
}
.cat-main .sub .img {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: 12px;
  margin: 0 auto 6px;
  background: #e9ecef;
}
.cat-main .sub-all {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--primary);
  background: var(--primary-light);
  border-radius: var(--radius);
  padding: 10px;
  font-size: 13px;
  font-weight: 600;
}

/* 列表页 */
.sort-bar {
  position: sticky;
  top: calc(54px + env(safe-area-inset-top));
  z-index: 90;
  display: flex;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}
.sort-bar .sort {
  flex: 1;
  padding: 10px 4px;
  text-align: center;
  font-size: 13px;
  color: var(--text-2);
}
.sort-bar .sort.active { color: var(--primary); font-weight: 700; }

/* 详情页 */
.detail-page { padding-bottom: 0; }
.detail-swiper {
  background: #fff;
  position: relative;
}
.detail-swiper .imgs {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}
.detail-swiper .imgs img {
  width: 100%;
  flex: 0 0 100%;
  scroll-snap-align: center;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: #f1f3f5;
}
.detail-swiper .dots {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 5px;
}
.detail-swiper .dots i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.25);
}
.detail-swiper .dots i.active { background: var(--primary); }
.detail-main {
  background: var(--card);
  padding: 14px;
  margin-top: 8px;
}
.detail-main .price-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.detail-main .price { color: var(--price); font-size: 26px; font-weight: 800; }
.detail-main .price small { font-size: 15px; }
.detail-main .market-price { color: var(--text-3); font-size: 13px; text-decoration: line-through; }
.detail-main .name {
  font-size: 17px;
  font-weight: 700;
  margin-top: 8px;
  line-height: 1.4;
}
.detail-main .subtitle { color: var(--text-2); font-size: 13px; margin-top: 4px; }
.detail-meta {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  color: var(--text-2);
  font-size: 12px;
  flex-wrap: wrap;
}
.detail-meta .tag {
  background: var(--bg);
  border-radius: 6px;
  padding: 3px 8px;
}
.detail-cats {
  margin-top: 12px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.detail-cats a {
  background: var(--primary-light);
  color: var(--primary-dark);
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 12px;
}
.detail-desc {
  background: var(--card);
  margin-top: 8px;
  padding: 14px;
}
.detail-desc .desc-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 10px;
  padding-left: 8px;
  border-left: 3px solid var(--primary);
}
.detail-desc .content { font-size: 14px; line-height: 1.7; word-break: break-all; }
.detail-desc .content img { max-width: 100%; margin: 6px auto; border-radius: 8px; }
.detail-desc .content p { margin: 6px 0; }

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