/* ============================================================
   CARLENE CHENG 女装 · H5 商城
   极简黑白风格，与小程序 / 管理后台保持一致
   ============================================================ */

:root {
  --ink: #1a1a1a;
  --sub: #999999;
  --sub-2: #c4c4c4;
  --line: #eeeeee;
  --bg: #ffffff;
  --bg-soft: #f5f5f5;
  --price: #c0392b;
  --app-max: 480px;
}

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

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC",
    "Helvetica Neue", "Microsoft YaHei", sans-serif;
  background: var(--bg-soft);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

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

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

input {
  font: inherit;
  color: inherit;
  border: none;
  outline: none;
  background: none;
}

/* ---------- 应用容器 ---------- */
.app {
  max-width: var(--app-max);
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  padding-bottom: 72px;
  position: relative;
  overflow-x: hidden;
}

/* ---------- 顶部栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: #fff;
  padding: 12px 16px 10px;
  border-bottom: 1px solid var(--line);
}

.topbar .shop-name {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar .back {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  font-size: 18px;
  line-height: 1;
}

/* ---------- 搜索栏 ---------- */
.search-bar {
  padding: 12px 16px;
  background: #fff;
}

.search-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-soft);
  border-radius: 18px;
  padding: 0 14px;
  height: 36px;
}

.search-inner input {
  flex: 1;
  font-size: 13px;
  height: 100%;
}

.search-inner input::placeholder {
  color: var(--sub-2);
}

.search-inner .go {
  font-size: 13px;
  color: var(--sub);
  padding-left: 8px;
  border-left: 1px solid var(--line);
  flex: 0 0 auto;
}

/* ---------- Banner ---------- */
.banner {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 2;
  overflow: hidden;
  background: linear-gradient(135deg, #f7f7f7, #efefef);
}

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

.banner-track img {
  width: 100%;
  height: 100%;
  flex: 0 0 100%;
  object-fit: cover;
}

.banner-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--sub);
  font-size: 14px;
  letter-spacing: 0.04em;
}

.banner-dots {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 10px;
  display: flex;
  justify-content: center;
  gap: 5px;
}

.banner-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.45);
}

.banner-dots span.on {
  background: #fff;
  width: 12px;
  border-radius: 3px;
}

/* ---------- 品牌标签 ---------- */
.tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 18px;
  padding: 16px 16px 4px;
}

.tags span {
  font-size: 11px;
  color: var(--sub);
  letter-spacing: 0.1em;
}

/* ---------- Tab 切换 ---------- */
.tabs {
  display: flex;
  justify-content: center;
  gap: 26px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--line);
}

.tabs button {
  font-size: 14px;
  color: var(--sub);
  padding-bottom: 6px;
  position: relative;
  transition: color 0.2s;
}

.tabs button.on {
  color: var(--ink);
  font-weight: 600;
}

.tabs button.on::after {
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 20px;
  height: 2px;
  background: var(--ink);
  border-radius: 1px;
}

/* ---------- 商品网格 ---------- */
.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--line);
  border-bottom: 1px solid var(--line);
}

.card {
  background: #fff;
  padding-bottom: 10px;
  cursor: pointer;
}

.card .thumb {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  background: #f2f2f2;
}

.card .info {
  padding: 8px 10px 0;
}

.card .name {
  font-size: 13px;
  line-height: 1.4;
  height: 2.8em;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  word-break: break-all;
}

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

.card .price {
  font-size: 14px;
  color: var(--price);
  font-weight: 600;
}

.card .price-original {
  font-size: 11px;
  color: var(--sub-2);
  text-decoration: line-through;
}

/* ---------- 空状态 / 加载 ---------- */
.state {
  padding: 80px 20px;
  text-align: center;
  color: var(--sub);
  font-size: 13px;
}

.state .icon {
  font-size: 34px;
  margin-bottom: 12px;
  opacity: 0.5;
}

/* ---------- 分类页 ---------- */
.cat-wrap {
  display: flex;
  min-height: calc(100vh - 120px);
}

.cat-side {
  flex: 0 0 92px;
  background: var(--bg-soft);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  max-height: calc(100vh - 120px);
  position: sticky;
  top: 55px;
}

.cat-side button {
  display: block;
  width: 100%;
  padding: 15px 8px;
  font-size: 13px;
  color: var(--sub);
  text-align: center;
  position: relative;
  border-bottom: 1px solid #f0f0f0;
}

.cat-side button.on {
  background: #fff;
  color: var(--ink);
  font-weight: 600;
}

.cat-side button.on::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 2px;
  height: 16px;
  background: var(--ink);
}

.cat-main {
  flex: 1;
  min-width: 0;
  padding: 10px;
}

.cat-main .cat-title {
  font-size: 13px;
  color: var(--sub);
  padding: 4px 2px 10px;
}

.cat-main .grid {
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  background: transparent;
  border: none;
}

.cat-main .card {
  border-radius: 2px;
  overflow: hidden;
}

/* ---------- 购物车 ---------- */
.cart-list {
  background: #fff;
}

.cart-item {
  display: flex;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  align-items: flex-start;
}

.cart-item .check {
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  border: 1px solid var(--sub-2);
  border-radius: 50%;
  margin-top: 26px;
  position: relative;
}

.cart-item .check.on {
  background: var(--ink);
  border-color: var(--ink);
}

.cart-item .check.on::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 2px;
  width: 6px;
  height: 10px;
  border-right: 1.5px solid #fff;
  border-bottom: 1.5px solid #fff;
  transform: rotate(42deg);
}

.cart-item .cover {
  flex: 0 0 72px;
  width: 72px;
  height: 96px;
  object-fit: cover;
  background: #f2f2f2;
}

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

.cart-item .title {
  font-size: 13px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cart-item .spec {
  font-size: 11px;
  color: var(--sub);
  margin-top: 6px;
  background: var(--bg-soft);
  display: inline-block;
  padding: 2px 8px;
  border-radius: 2px;
}

.cart-item .bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
}

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

.stepper {
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 2px;
  overflow: hidden;
}

.stepper button {
  width: 26px;
  height: 24px;
  font-size: 14px;
  color: var(--sub);
  display: flex;
  align-items: center;
  justify-content: center;
}

.stepper .num {
  min-width: 30px;
  text-align: center;
  font-size: 12px;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  line-height: 24px;
}

.cart-item .del {
  font-size: 11px;
  color: var(--sub);
  padding: 2px 0 0;
  align-self: flex-end;
}

/* ---------- 结算栏 ---------- */
.cart-bar {
  position: fixed;
  left: 50%;
  bottom: 56px;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--app-max);
  background: #fff;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  padding: 10px 16px;
  z-index: 35;
  gap: 10px;
}

.cart-bar .all {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--sub);
  flex: 0 0 auto;
}

.cart-bar .all .check {
  width: 18px;
  height: 18px;
  border: 1px solid var(--sub-2);
  border-radius: 50%;
  position: relative;
}

.cart-bar .all .check.on {
  background: var(--ink);
  border-color: var(--ink);
}

.cart-bar .all .check.on::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 2px;
  width: 6px;
  height: 10px;
  border-right: 1.5px solid #fff;
  border-bottom: 1.5px solid #fff;
  transform: rotate(42deg);
}

.cart-bar .sum {
  flex: 1;
  text-align: right;
  font-size: 12px;
  color: var(--sub);
}

.cart-bar .sum em {
  font-style: normal;
  color: var(--price);
  font-size: 16px;
  font-weight: 600;
  margin-left: 4px;
}

.cart-bar .btn {
  flex: 0 0 auto;
  background: var(--ink);
  color: #fff;
  font-size: 13px;
  padding: 10px 22px;
  border-radius: 20px;
  letter-spacing: 0.04em;
}

/* ---------- 详情页 ---------- */
.gallery {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  background: #f2f2f2;
}

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

.gallery-track img {
  width: 100%;
  height: 100%;
  flex: 0 0 100%;
  object-fit: cover;
}

.gallery-idx {
  position: absolute;
  right: 12px;
  bottom: 12px;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 10px;
}

.detail-head {
  background: #fff;
  padding: 16px;
}

.detail-head .d-name {
  font-size: 17px;
  font-weight: 600;
  line-height: 1.4;
}

.detail-head .d-price {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-top: 10px;
}

.detail-head .d-price .p {
  font-size: 22px;
  color: var(--price);
  font-weight: 600;
}

.detail-head .d-price .o {
  font-size: 12px;
  color: var(--sub-2);
  text-decoration: line-through;
}

.detail-head .d-desc {
  margin-top: 12px;
  font-size: 13px;
  line-height: 1.8;
  color: var(--sub);
  white-space: pre-wrap;
}

.sku-block {
  background: #fff;
  margin-top: 8px;
  padding: 16px;
}

.sku-block .label {
  font-size: 12px;
  color: var(--sub);
  margin-bottom: 10px;
}

.sku-opts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.sku-opts button {
  font-size: 12.5px;
  padding: 6px 16px;
  border: 1px solid var(--line);
  border-radius: 2px;
  color: var(--ink);
  background: #fff;
  transition: all 0.15s;
}

.sku-opts button.on {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.qty-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  background: #fff;
  padding: 14px 16px;
}

.qty-row .label {
  font-size: 12px;
  color: var(--sub);
}

.detail-imgs {
  margin-top: 8px;
  background: #fff;
}

.detail-imgs img {
  width: 100%;
}

/* ---------- 底部操作条（详情页） ---------- */
.detail-bar {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--app-max);
  background: #fff;
  border-top: 1px solid var(--line);
  z-index: 35;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 16px;
  padding-bottom: calc(9px + env(safe-area-inset-bottom));
}

.detail-bar .ghost {
  flex: 0 0 46px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 10.5px;
  color: var(--sub);
  position: relative;
}

.detail-bar .ghost img {
  width: 21px;
  height: 21px;
}

.detail-bar .ghost .dot {
  position: absolute;
  top: -3px;
  right: 4px;
  min-width: 14px;
  height: 14px;
  padding: 0 3px;
  border-radius: 7px;
  background: #ff5a5f;
  color: #fff;
  font-size: 9.5px;
  line-height: 14px;
  text-align: center;
  font-style: normal;
  display: none;
}

.detail-bar .btn {
  flex: 1;
  width: auto;
  background: var(--ink);
  color: #fff;
  font-size: 14px;
  padding: 12px 0;
  border-radius: 24px;
  letter-spacing: 0.06em;
}

/* ---------- 底部 tabbar ---------- */
.tabbar {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--app-max);
  background: #fff;
  border-top: 1px solid var(--line);
  display: flex;
  z-index: 40;
  padding-bottom: env(safe-area-inset-bottom);
}

.tabbar a {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 7px 0 6px;
  gap: 3px;
}

.tabbar img {
  width: 24px;
  height: 24px;
}

.tabbar span {
  font-size: 11px;
  color: #999;
  letter-spacing: 0.02em;
}

.tabbar a.on span {
  color: #1a1a1a;
  font-weight: 600;
}

.tabbar .badge {
  position: absolute;
  top: 3px;
  left: 50%;
  margin-left: 4px;
  min-width: 15px;
  height: 15px;
  padding: 0 4px;
  border-radius: 8px;
  background: #ff5a5f;
  color: #fff;
  font-size: 10px;
  line-height: 15px;
  text-align: center;
  font-weight: 500;
  font-style: normal;
  display: none;
}

/* ---------- 页脚备案 ---------- */
.foot {
  padding: 22px 16px 26px;
  text-align: center;
  font-size: 11.5px;
  color: var(--sub);
  line-height: 1.9;
}

.foot a {
  color: var(--sub);
  border-bottom: 1px solid #ddd;
}

.foot .cr {
  color: var(--sub-2);
  margin-top: 4px;
}

/* ---------- 轻提示 ---------- */
.toast {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(0.96);
  background: rgba(0, 0, 0, 0.78);
  color: #fff;
  font-size: 13px;
  padding: 11px 20px;
  border-radius: 4px;
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  max-width: 70%;
  text-align: center;
}

.toast.on {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* ---------- SKU 弹层 ---------- */
.sheet-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 60;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}

.sheet-mask.on {
  opacity: 1;
  pointer-events: auto;
}

.sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translate(-50%, 100%);
  width: 100%;
  max-width: var(--app-max);
  background: #fff;
  z-index: 61;
  transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
  padding-bottom: env(safe-area-inset-bottom);
}

.sheet.on {
  transform: translate(-50%, 0);
}

.sheet .sheet-top {
  display: flex;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.sheet .sheet-top img {
  width: 76px;
  height: 100px;
  object-fit: cover;
  background: #f2f2f2;
}

.sheet .sheet-top .meta {
  flex: 1;
  min-width: 0;
  padding-top: 4px;
}

.sheet .sheet-top .meta .p {
  font-size: 18px;
  color: var(--price);
  font-weight: 600;
}

.sheet .sheet-top .meta .n {
  font-size: 12px;
  color: var(--sub);
  margin-top: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.sheet .sheet-body {
  padding: 4px 16px 16px;
  max-height: 52vh;
  overflow-y: auto;
}

.sheet .close-x {
  position: absolute;
  right: 14px;
  top: 12px;
  font-size: 18px;
  color: var(--sub);
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sheet .sheet-btn {
  margin: 4px 16px 16px;
  display: block;
  width: calc(100% - 32px);
  background: var(--ink);
  color: #fff;
  font-size: 14px;
  padding: 12px 0;
  border-radius: 24px;
  letter-spacing: 0.06em;
}

/* ---------- PC 端适配：留白边界 ---------- */
@media (min-width: 520px) {
  body {
    background: #ececec;
  }
  .app {
    box-shadow: 0 0 24px rgba(0, 0, 0, 0.06);
    min-height: 100vh;
  }
  .tabbar,
  .detail-bar,
  .cart-bar {
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.04);
  }
}
