/* ============ 设计变量 ============ */
:root {
  --bg-1: #eef4f8;
  --bg-2: #e2ecf2;
  --card: #ffffff;
  --ink: #14303d;
  --ink-2: #64808e;
  --ink-3: #93a7b2;
  --brand: #0e7490;
  --brand-2: #0b5e75;
  --brand-soft: #e3f2f7;
  --accent: #ff7a1a;
  --green: #16a34a;
  --green-2: #0e8a3e;
  --wechat: #07c160;
  --amber: #f59e0b;
  --r-lg: 22px;
  --r-md: 16px;
  --sh-1: 0 1px 2px rgba(16, 60, 80, .05), 0 8px 24px rgba(16, 60, 80, .07);
  --sh-2: 0 8px 20px rgba(16, 60, 80, .12), 0 24px 56px rgba(16, 60, 80, .14);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'HarmonyOS Sans SC',
    'Microsoft YaHei', 'Segoe UI', sans-serif;
  background: linear-gradient(160deg, var(--bg-1), var(--bg-2));
  color: var(--ink);
  overflow: hidden;
  touch-action: manipulation;
  user-select: none; -webkit-user-select: none;
}
#app { display: flex; flex-direction: column; height: 100%; }

/* ============ 顶栏 ============ */
.topbar {
  flex: none; position: relative; overflow: hidden;
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px clamp(16px, 3vw, 44px);
  background: linear-gradient(135deg, #0f7f9d, #0b5e75 60%, #0a5064);
  color: #fff; box-shadow: 0 4px 18px rgba(10, 80, 100, .28);
}
.topbar::after {
  content: ""; position: absolute; right: -60px; top: -90px;
  width: 250px; height: 250px; border-radius: 50%;
  background: rgba(255, 255, 255, .06); pointer-events: none;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo {
  width: 42px; height: 42px; border-radius: 13px; flex: none;
  background: rgba(255, 255, 255, .16); display: grid; place-items: center;
}
.brand-logo svg { width: 24px; height: 24px; }
.brand-name { font-size: 22px; font-weight: 700; letter-spacing: .5px; }
.brand-sub {
  font-size: 13px; opacity: .78; margin-left: 2px;
  padding-left: 14px; border-left: 1px solid rgba(255, 255, 255, .28);
}
.clock-pill {
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(255, 255, 255, .14); border: 1px solid rgba(255, 255, 255, .2);
  padding: 8px 16px; border-radius: 999px;
  font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.clock-pill svg { width: 17px; height: 17px; opacity: .9; }

.icp {
  font-size: 11px; font-weight: 400; opacity: .55;
  color: #fff; text-decoration: none; margin-right: 12px;
}
.icp:hover { opacity: .85; }

/* ============ 商品网格：一行三个 ============ */
.grid {
  flex: 1; overflow-y: auto;
  padding: 22px clamp(16px, 3vw, 44px) 24px;
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-auto-rows: minmax(min-content, auto);
  gap: 20px; align-content: start;
}
.grid::-webkit-scrollbar { width: 8px; }
.grid::-webkit-scrollbar-thumb { background: rgba(14, 116, 144, .18); border-radius: 999px; }
@media (max-width: 760px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; padding: 14px 14px 20px; }
  .brand-sub, .topbar::after { display: none; }
  .card-name { font-size: 17px; }
  .card-price { font-size: 22px; }
}

.card {
  background: var(--card); border-radius: var(--r-lg);
  border: 1px solid rgba(14, 116, 144, .06);
  box-shadow: var(--sh-1); overflow: hidden; cursor: pointer;
  transition: transform .22s ease, box-shadow .22s ease, border-color .22s ease;
}
.card:hover {
  transform: translateY(-6px);
  box-shadow: var(--sh-2);
  border-color: rgba(14, 116, 144, .18);
}
.card:active { transform: translateY(-2px) scale(.98); }
.card.pulse { animation: pulse .28s ease; }
@keyframes pulse { 0% { transform: scale(1); } 45% { transform: scale(1.035); } 100% { transform: scale(1); } }

.card-img {
  position: relative; overflow: hidden;
  height: clamp(150px, 22vh, 330px);
  background: #ffffff;
  border-bottom: 1px solid #f0f5f8;
}
.card-img img {
  position: absolute; inset: 0; margin: auto;
  max-width: 80%; max-height: 94%; width: auto; height: auto;
  pointer-events: none;
}
.card-img.noimg { font-size: 64px; }
.add-badge {
  position: absolute; right: 12px; bottom: 12px;
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff; font-size: 24px; font-weight: 600;
  display: grid; place-items: center; line-height: 1;
  box-shadow: 0 6px 14px rgba(14, 116, 144, .35);
  transition: transform .22s ease;
}
.card:hover .add-badge { transform: scale(1.14); }

.card-body { padding: 14px 18px 16px; display: flex; flex-direction: column; gap: 6px; }
.card-name {
  font-size: 19px; font-weight: 650; letter-spacing: .3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-meta { display: flex; align-items: center; justify-content: space-between; }
.card-price { color: var(--accent); font-size: 25px; font-weight: 800; font-variant-numeric: tabular-nums; }
.card-unit-tag {
  font-size: 12.5px; color: var(--brand); background: var(--brand-soft);
  padding: 4px 12px; border-radius: 999px; font-weight: 600;
}

/* ============ 底部购物车栏 ============ */
.cartbar {
  flex: none; display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: rgba(255, 255, 255, .93); backdrop-filter: blur(10px);
  border-top: 1px solid rgba(14, 116, 144, .08);
  padding: 12px clamp(16px, 3vw, 44px); min-height: 84px;
  box-shadow: 0 -8px 28px rgba(13, 60, 76, .10);
  cursor: pointer; position: relative; z-index: 31;
}
.cart-left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.cart-icon {
  position: relative; width: 50px; height: 50px; border-radius: 15px; flex: none;
  background: var(--brand-soft); color: var(--brand);
  display: grid; place-items: center;
}
.cart-icon svg { width: 25px; height: 25px; }
.cart-badge {
  position: absolute; top: -7px; right: -7px;
  min-width: 21px; height: 21px; padding: 0 6px; border-radius: 999px;
  background: var(--accent); color: #fff;
  font-size: 12.5px; font-weight: 700; font-style: normal;
  display: grid; place-items: center;
  box-shadow: 0 3px 8px rgba(255, 122, 26, .4);
}
.cart-info {
  font-size: 19px; color: var(--ink-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cart-info b { color: var(--accent); font-size: 24px; margin: 0 2px; }
.checkout-btn {
  flex: none; display: inline-flex; align-items: center; gap: 10px;
  border: 0; cursor: pointer; color: #fff;
  background: linear-gradient(135deg, #1cb75a, var(--green-2));
  font-size: 22px; font-weight: 700; letter-spacing: 1px;
  padding: 16px 46px; border-radius: 999px;
  box-shadow: 0 10px 22px rgba(22, 163, 74, .32);
  transition: transform .18s ease, box-shadow .18s ease, filter .18s ease;
}
.checkout-btn svg { width: 20px; height: 20px; }
.checkout-btn:not(:disabled):hover {
  filter: brightness(1.06); transform: translateY(-2px);
  box-shadow: 0 14px 28px rgba(22, 163, 74, .4);
}
.checkout-btn:not(:disabled):active { transform: scale(.96); }
.checkout-btn:disabled { background: #c7d6de; box-shadow: none; cursor: default; }

/* ============ 购物车明细弹层 ============ */
.sheet {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: 96px; width: min(96vw, 560px); z-index: 30;
  background: #fff; border-radius: 24px;
  box-shadow: var(--sh-2); padding: 10px 22px 16px;
  max-height: 52vh; overflow-y: auto;
  animation: sheetUp .25s ease;
}
@keyframes sheetUp {
  from { transform: translate(-50%, 18px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}
.grabber { width: 44px; height: 5px; border-radius: 999px; background: #dbe6ec; margin: 4px auto 10px; }
.sheet-head {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 20px; font-weight: 700; margin-bottom: 8px;
}
.sheet-actions button {
  border: 1px solid #dbe6ec; background: #f7fafb; color: var(--ink-2);
  border-radius: 999px; padding: 8px 16px; font-size: 14px;
  cursor: pointer; margin-left: 8px; transition: all .18s;
}
.sheet-actions button:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }
#cartList { list-style: none; }
#cartList li {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0; font-size: 18px; border-bottom: 1px dashed #e4edf1;
}
#cartList li:last-child { border-bottom: 0; }
.ci-name { font-weight: 600; }
.ci-ctrl { display: flex; align-items: center; }
.ci-ctrl button {
  width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid #d7e3ea; background: #fff; color: var(--brand);
  font-size: 20px; line-height: 1; cursor: pointer; margin: 0 8px;
  transition: all .15s;
}
.ci-ctrl button:hover { background: var(--brand-soft); border-color: var(--brand); }
.ci-ctrl b { font-size: 19px; min-width: 28px; text-align: center; font-variant-numeric: tabular-nums; }
.ci-sum { color: var(--accent); font-weight: 800; min-width: 78px; text-align: right; font-variant-numeric: tabular-nums; }

/* ============ 遮罩与弹窗 ============ */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(10, 30, 40, .55); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn .2s ease;
}
@keyframes fadeIn { from { opacity: 0; } }
.pay-panel, .success-panel {
  background: #fff; border-radius: 26px; text-align: center;
  width: min(92vw, 420px); overflow: hidden;
  box-shadow: 0 30px 80px rgba(6, 40, 55, .45);
  animation: popIn .28s cubic-bezier(.2, .9, .3, 1.15);
}
@keyframes popIn {
  from { transform: scale(.86) translateY(14px); opacity: 0; }
}

.pay-head {
  padding: 24px 28px 18px; position: relative;
  background: linear-gradient(160deg, #f0faf5, #ffffff);
  border-bottom: 1px solid #edf5f0;
  transition: background .2s ease;
}
.pay-panel[data-channel="alipay"] .pay-head { background: linear-gradient(160deg, #eef5ff, #ffffff); }
.pay-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(7, 193, 96, .1); color: var(--wechat);
  font-size: 13px; font-weight: 700;
  padding: 5px 12px; border-radius: 999px; margin-bottom: 10px;
  transition: background .2s ease, color .2s ease;
}
.pay-chip svg { width: 15px; height: 15px; }
.chip-icon { display: inline-flex; align-items: center; }
.chip-icon svg { width: 15px; height: 15px; }
.pay-panel[data-channel="alipay"] .pay-chip { background: rgba(22, 119, 255, .1); color: #1677ff; }
.pay-chip[data-hidden] { display: none; }
.pay-title { font-size: 22px; font-weight: 700; }
.pay-amount {
  color: var(--accent); font-size: 46px; font-weight: 800;
  margin-top: 6px; font-variant-numeric: tabular-nums;
}
.qr-frame {
  margin: 20px auto 4px; width: fit-content;
  padding: 14px; border-radius: 20px;
  border: 1.5px dashed #cfe0e9; background: #fff;
}
#qrcodeBox {
  display: flex; justify-content: center; align-items: center;
  min-height: 288px; min-width: 288px;
}
.qr-fallback { color: #ef4444; font-size: 17px; }
.pay-countdown { color: var(--ink-2); font-size: 15.5px; margin: 10px 0 16px; }
.pay-countdown span { color: var(--brand); font-weight: 700; font-variant-numeric: tabular-nums; }
.pay-actions { padding: 0 28px 24px; display: flex; flex-direction: column; gap: 10px; }
.pay-row { display: flex; gap: 10px; }
.pay-row .ghost-btn, .pay-row .cancel-btn { flex: 1; }
.ghost-btn.sm {
  font-size: 16.5px; padding: 12px;
  border-radius: 14px; border: 1.5px solid var(--brand);
}
.mock-btn {
  border: 0; cursor: pointer; color: #fff;
  background: linear-gradient(135deg, #fbbf24, var(--amber));
  font-size: 18px; font-weight: 700;
  padding: 14px; border-radius: 14px;
  box-shadow: 0 8px 18px rgba(245, 158, 11, .3);
  transition: transform .16s ease, filter .16s ease;
}
.mock-btn:hover { filter: brightness(1.05); }
.mock-btn:active { transform: scale(.97); }
.cancel-btn {
  border: 1.5px solid #dbe6ec; background: #fff; color: var(--ink-2);
  font-size: 17px; padding: 12px; border-radius: 14px; cursor: pointer;
  transition: all .18s;
}
.cancel-btn:hover { border-color: var(--ink-3); color: var(--ink); }

/* 支付方式选择 */
.choice-panel {
  background: #fff; border-radius: 26px; text-align: center;
  width: min(92vw, 470px); padding: 30px 30px 24px;
  box-shadow: 0 30px 80px rgba(6, 40, 55, .45);
  animation: popIn .28s cubic-bezier(.2, .9, .3, 1.15);
}
.choice-title { font-size: 23px; font-weight: 700; }
.choice-amount {
  color: var(--accent); font-size: 44px; font-weight: 800;
  margin: 10px 0 24px; font-variant-numeric: tabular-nums;
}
.choice-btns { display: flex; justify-content: center; gap: 16px; margin-bottom: 18px; }
.ch-btn {
  flex: 1; max-width: 190px; border: 0; cursor: pointer; color: #fff;
  border-radius: 20px; padding: 24px 10px;
  font-size: 19px; font-weight: 700; letter-spacing: 1px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  transition: transform .18s ease, box-shadow .18s ease, filter .18s ease;
}
.ch-btn svg { width: 40px; height: 40px; }
.ch-btn:hover { transform: translateY(-4px); filter: brightness(1.05); }
.ch-btn:active { transform: scale(.96); }
.ch-wechat {
  background: linear-gradient(135deg, #1ecb6b, #07a55a);
  box-shadow: 0 10px 24px rgba(7, 165, 90, .35);
}
.ch-alipay {
  background: linear-gradient(135deg, #3d8bff, #1677ff);
  box-shadow: 0 10px 24px rgba(22, 119, 255, .35);
}
.choice-panel .cancel-btn { width: 100%; }

/* 支付成功 */
.success-panel { padding: 34px 30px 28px; }
.success-icon-wrap { position: relative; width: 92px; height: 92px; margin: 0 auto 14px; }
.success-icon-wrap svg {
  position: relative; z-index: 1;
  width: 92px; height: 92px; border-radius: 50%;
  background: linear-gradient(135deg, #2ecc71, var(--green));
  padding: 22px; box-sizing: border-box; color: #fff;
  box-shadow: 0 12px 30px rgba(22, 163, 74, .35);
  animation: pop .45s cubic-bezier(.2, 1.4, .4, 1);
}
@keyframes pop {
  0% { transform: scale(.4); opacity: 0; }
  70% { transform: scale(1.08); }
  100% { transform: scale(1); opacity: 1; }
}
.ripple {
  position: absolute; inset: 0; border-radius: 50%;
  border: 2px solid rgba(22, 163, 74, .4);
  animation: ripple 1.2s ease-out infinite;
}
@keyframes ripple {
  from { transform: scale(1); opacity: .8; }
  to { transform: scale(1.55); opacity: 0; }
}
.success-title { font-size: 26px; font-weight: 800; }
.success-amount {
  color: var(--accent); font-size: 40px; font-weight: 800;
  margin: 6px 0; font-variant-numeric: tabular-nums;
}
.success-hint { color: var(--ink-2); font-size: 15.5px; margin-bottom: 18px; }
.success-hint span { color: var(--brand); font-weight: 700; }
.ghost-btn {
  border: 1.5px solid var(--brand); background: #fff; color: var(--brand);
  font-size: 17px; font-weight: 600; padding: 11px 44px;
  border-radius: 999px; cursor: pointer; transition: all .18s;
}
.ghost-btn:hover { background: var(--brand-soft); }

/* ============ 提示 ============ */
.toast {
  position: fixed; top: 96px; left: 50%; transform: translateX(-50%);
  z-index: 99; background: rgba(17, 42, 54, .92); color: #fff;
  padding: 13px 26px; border-radius: 999px; font-size: 16.5px;
  box-shadow: 0 12px 30px rgba(6, 40, 55, .35);
  backdrop-filter: blur(6px); animation: toastIn .25s ease;
  max-width: 86vw; text-align: center;
}
@keyframes toastIn {
  from { transform: translate(-50%, -12px); opacity: 0; }
}

.hidden { display: none !important; }
