:root {
  --yellow: #ffd200;
  --yellow-deep: #f5b800;
  --ink: #1b1b1b;
  --ink-2: #5a5a5a;
  --ink-3: #8c8c8c;
  --line: #ececec;
  --bg: #f5f5f5;
  --card: #fff;
  --red: #e5342b;
  --green: #16a34a;
  --radius: 14px;
  --shadow: 0 4px 18px rgba(0, 0, 0, .06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
img { display: block; max-width: 100%; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 16px;
  padding: 12px clamp(12px, 4vw, 40px);
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--yellow); color: #111; font-weight: 800; font-size: 12px;
}
.brand-name { font-size: 18px; font-weight: 800; letter-spacing: .5px; }
.brand-badge {
  font-size: 11px; color: #7a5b00; background: #fff5c2;
  border: 1px solid #ffe57a; padding: 1px 6px; border-radius: 999px;
}
.search { flex: 1; display: flex; max-width: 620px; background: #f4f4f4; border: 1px solid #eee; border-radius: 999px; overflow: hidden; }
.search input { flex: 1; border: 0; background: transparent; padding: 9px 16px; font-size: 14px; outline: none; }
.search button {
  border: 0; background: var(--yellow); color: #111; font-weight: 700;
  padding: 0 18px; font-size: 14px;
}
.cart-link { position: relative; display: inline-flex; color: var(--ink); padding: 4px; }
.cart-badge {
  position: absolute; top: -4px; right: -8px; min-width: 18px; height: 18px;
  border-radius: 999px; background: var(--red); color: #fff;
  font-size: 11px; line-height: 18px; text-align: center; padding: 0 4px;
}

/* ---------- layout ---------- */
.app { max-width: 1180px; margin: 0 auto; padding: 18px clamp(12px, 3vw, 28px) 96px; }
.section { margin-bottom: 28px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin: 0 0 12px; }
.section-head h2 { font-size: 18px; margin: 0; }
.section-head .more { font-size: 13px; color: var(--ink-3); }

/* ---------- home ---------- */
.hero {
  position: relative; overflow: hidden; border-radius: 18px;
  background: linear-gradient(120deg, #ffe56b, #ffd200 55%, #ffc400);
  padding: clamp(20px, 4vw, 40px); color: #241c00; margin-bottom: 22px;
}
.hero h1 { font-size: clamp(22px, 4vw, 34px); margin: 0 0 8px; letter-spacing: .5px; }
.hero p { margin: 0; font-size: 14px; opacity: .8; }
.hero .hero-tag {
  display: inline-block; margin-top: 16px; padding: 6px 12px; border-radius: 999px;
  background: rgba(0, 0, 0, .82); color: #ffe45c; font-size: 12px;
}
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  padding: 9px 16px; border-radius: 999px; background: #fff; border: 1px solid var(--line);
  font-size: 14px; transition: .15s;
}
.chip:hover { border-color: var(--yellow-deep); background: #fffbe6; }

/* ---------- product grid ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.card {
  background: var(--card); border-radius: var(--radius); overflow: hidden;
  border: 1px solid #f0f0f0; transition: transform .15s, box-shadow .15s;
  display: flex; flex-direction: column;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.card .thumb { aspect-ratio: 1 / 1; background: #fafafa; display: flex; align-items: center; justify-content: center; }
.card .thumb img { width: 100%; height: 100%; object-fit: contain; }
.card .body { padding: 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card .name { font-size: 14px; line-height: 1.45; min-height: 2.9em; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .meta { font-size: 12px; color: var(--ink-3); display: flex; gap: 8px; flex-wrap: wrap; }
.price { color: var(--red); font-weight: 800; font-size: 17px; }
.price small { font-size: 12px; font-weight: 500; margin-left: 4px; }
.stock-ok { color: var(--green); }
.stock-no { color: var(--ink-3); }

/* ---------- category ---------- */
.cat-layout { display: grid; grid-template-columns: 150px 1fr; gap: 16px; }
.cat-rail { background: #fff; border-radius: var(--radius); padding: 8px; align-self: start; position: sticky; top: 86px; }
.cat-rail button {
  display: block; width: 100%; text-align: left; border: 0; background: transparent;
  padding: 12px 10px; border-radius: 10px; font-size: 14px; color: var(--ink-2);
}
.cat-rail button.active { background: #fff6cc; color: #8a6a00; font-weight: 700; }
.cat-panel { background: #fff; border-radius: var(--radius); padding: 18px; min-height: 320px; }
.cat-group { margin-bottom: 22px; }
.cat-group h3 { font-size: 15px; margin: 0 0 12px; }
.cat-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }
.cat-card { text-align: center; border: 1px solid #f2f2f2; border-radius: 12px; padding: 10px 8px; transition: .15s; }
.cat-card:hover { border-color: #ffd200; background: #fffdf2; }
.cat-card img { width: 84px; height: 84px; object-fit: contain; margin: 0 auto 8px; }
.cat-card span { font-size: 13px; color: var(--ink-2); }

/* ---------- breadcrumb / page head ---------- */
.crumb { font-size: 13px; color: var(--ink-3); margin-bottom: 12px; }
.crumb a:hover { color: var(--ink); }
.page-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.page-head h1 { font-size: 20px; margin: 0; }
.page-head .count { color: var(--ink-3); font-size: 13px; }
.btn-more {
  display: block; margin: 20px auto 0; padding: 10px 28px; border-radius: 999px;
  border: 1px solid var(--line); background: #fff; font-size: 14px;
}
.btn-more:hover { border-color: var(--yellow-deep); }

/* ---------- detail ---------- */
.detail { display: grid; grid-template-columns: minmax(0, 460px) minmax(0, 1fr); gap: 28px; align-items: start; }
.gallery { background: #fff; border-radius: var(--radius); padding: 12px; }
.gallery .main { aspect-ratio: 1 / 1; display: flex; align-items: center; justify-content: center; }
.gallery .main img { max-height: 100%; object-fit: contain; }
.gallery .thumbs { display: flex; gap: 8px; margin-top: 10px; overflow-x: auto; }
.gallery .thumbs img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; border: 2px solid transparent; }
.gallery .thumbs img.active { border-color: var(--yellow-deep); }
.detail-info { background: #fff; border-radius: var(--radius); padding: 22px; }
.detail-info h1 { font-size: 21px; line-height: 1.4; margin: 0 0 8px; }
.detail-info .desc { color: var(--ink-2); font-size: 14px; margin-bottom: 14px; }
.detail-info .rank { display: inline-block; background: #fff4d6; color: #9a6b00; font-size: 12px; padding: 3px 8px; border-radius: 6px; margin-bottom: 12px; }
.detail-info .price-row { display: flex; align-items: baseline; gap: 10px; margin: 10px 0 16px; }
.detail-info .price-row .price { font-size: 28px; }
.detail-info .suggest { color: var(--ink-3); font-size: 13px; text-decoration: line-through; }
.specs { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 6px; font-size: 14px; color: var(--ink-2); display: grid; gap: 8px; }
.specs b { color: var(--ink); font-weight: 600; }
.sku-title { font-size: 14px; margin: 18px 0 8px; }
.sku-list { display: flex; flex-wrap: wrap; gap: 8px; }
.sku {
  border: 1px solid #ddd; background: #fff; border-radius: 8px; padding: 8px 12px; font-size: 13px;
}
.sku.active { border-color: var(--yellow-deep); background: #fffbe6; font-weight: 700; }
.sku:disabled { opacity: .4; cursor: not-allowed; }
.buy-row { display: flex; align-items: center; gap: 12px; margin-top: 20px; flex-wrap: wrap; }
.stepper { display: inline-flex; align-items: center; border: 1px solid #ddd; border-radius: 8px; overflow: hidden; }
.stepper button { width: 34px; height: 36px; border: 0; background: #fafafa; font-size: 18px; }
.stepper input { width: 56px; height: 36px; border: 0; text-align: center; font-size: 14px; outline: none; }
.btn-primary {
  border: 0; background: var(--yellow); color: #111; font-weight: 800;
  padding: 12px 28px; border-radius: 999px; font-size: 15px;
}
.btn-primary:hover { background: var(--yellow-deep); }
.btn-ghost { border: 1px solid #ddd; background: #fff; padding: 11px 22px; border-radius: 999px; font-size: 14px; }
.detail-desc { background: #fff; border-radius: var(--radius); padding: 22px; margin-top: 22px; }
.detail-desc h2 { font-size: 16px; margin: 0 0 12px; }
.detail-desc img { margin: 0 auto; }
.detail-desc table { border-collapse: collapse; width: 100%; }
.detail-desc td, .detail-desc th { border: 1px solid #eee; padding: 8px; font-size: 13px; }

/* ---------- cart ---------- */
.cart-list { background: #fff; border-radius: var(--radius); overflow: hidden; }
.cart-item { display: grid; grid-template-columns: 84px 1fr auto; gap: 14px; padding: 16px; border-bottom: 1px solid #f4f4f4; align-items: center; }
.cart-item:last-child { border-bottom: 0; }
.cart-item img { width: 84px; height: 84px; object-fit: contain; background: #fafafa; border-radius: 8px; }
.cart-item .name { font-size: 14px; margin-bottom: 4px; }
.cart-item .prop { font-size: 12px; color: var(--ink-3); }
.cart-item .price { font-size: 15px; margin-top: 6px; }
.cart-item .ops { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.cart-item .remove { border: 0; background: none; color: var(--ink-3); font-size: 12px; }
.cart-summary {
  position: sticky; bottom: 0; background: #fff; border-radius: var(--radius);
  margin-top: 16px; padding: 16px 20px; display: flex; align-items: center; gap: 16px; justify-content: flex-end;
  border: 1px solid #f0f0f0;
}
.cart-summary .total { font-size: 14px; color: var(--ink-2); }
.cart-summary .total b { color: var(--red); font-size: 22px; margin-left: 6px; }
.empty { text-align: center; color: var(--ink-3); padding: 70px 20px; background: #fff; border-radius: var(--radius); }
.empty .big { font-size: 46px; margin-bottom: 10px; }

/* ---------- checkout / orders ---------- */
.panel { background: #fff; border-radius: var(--radius); padding: 22px; }
.form { display: grid; gap: 14px; max-width: 560px; }
.field { display: grid; gap: 6px; }
.field label { font-size: 13px; color: var(--ink-2); }
.field input, .field textarea {
  border: 1px solid #ddd; border-radius: 10px; padding: 10px 12px; font-size: 14px; outline: none;
  font-family: inherit;
}
.field input:focus, .field textarea:focus { border-color: var(--yellow-deep); }
.order-summary { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; font-size: 14px; }
.order-summary .line { display: flex; justify-content: space-between; padding: 4px 0; color: var(--ink-2); }
.order-summary .line b { color: var(--ink); }
.order-card { background: #fff; border-radius: var(--radius); padding: 18px; margin-bottom: 14px; border: 1px solid #f0f0f0; }
.order-card .head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 13px; color: var(--ink-3); margin-bottom: 10px; }
.order-card .no { color: var(--ink); font-weight: 600; }
.order-card .items { display: grid; gap: 8px; }
.order-card .row { display: flex; gap: 10px; font-size: 13px; }
.order-card .row img { width: 44px; height: 44px; object-fit: contain; background: #fafafa; border-radius: 6px; }
.order-card .foot { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; font-size: 14px; }
.badge-status { background: #e8f7ee; color: var(--green); padding: 3px 8px; border-radius: 999px; font-size: 12px; }

/* ---------- login ---------- */
.login-link { font-size: 13px; color: var(--ink-2); padding: 6px 4px; white-space: nowrap; }
.login-link:hover { color: var(--ink); }
.login-wrap { max-width: 430px; margin: 36px auto 0; }
.login-card h1 { font-size: 22px; margin: 0 0 6px; }
.login-card .form { max-width: none; }

/* ---------- misc ---------- */
.skeleton { background: linear-gradient(90deg, #f0f0f0 25%, #f7f7f7 37%, #f0f0f0 63%); background-size: 400% 100%; animation: shimmer 1.2s infinite; border-radius: 8px; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
.toast {
  position: fixed; left: 50%; bottom: 88px; transform: translateX(-50%);
  background: rgba(0, 0, 0, .86); color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: 14px; z-index: 200; max-width: 80vw;
}
.tabbar { display: none; }
.error { background: #fff3f2; border: 1px solid #ffd9d6; color: #a12a22; padding: 14px 16px; border-radius: 12px; font-size: 14px; }

@media (max-width: 860px) {
  .topbar { gap: 10px; padding: 10px 12px; }
  .brand-name { font-size: 16px; }
  .brand-badge { display: none; }
  .search button { padding: 0 14px; }
  .app { padding-bottom: 120px; }
  .detail { grid-template-columns: 1fr; gap: 16px; }
  .cat-layout { grid-template-columns: 104px 1fr; }
  .cat-rail { position: static; }
  .cat-rail button { padding: 10px 6px; font-size: 13px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .card .body { padding: 10px; }
  .cart-item { grid-template-columns: 70px 1fr; }
  .cart-item .ops { grid-column: 1 / -1; flex-direction: row; justify-content: space-between; align-items: center; }
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    background: #fff; border-top: 1px solid var(--line); padding: 6px 0 max(6px, env(safe-area-inset-bottom));
  }
  .tabbar a { flex: 1; text-align: center; font-size: 12px; color: var(--ink-3); padding: 6px 0; }
  .tabbar a.active { color: #111; font-weight: 700; }
  .tabbar a.active::before { content: ""; display: block; width: 18px; height: 3px; background: var(--yellow); border-radius: 3px; margin: 0 auto 3px; }
  .toast { bottom: 96px; }
}
