/* ============================================================
   布团集市 · H5 商城
   与 knitly 官网同一套设计变量（css/style.css 的 :root），保持视觉统一。
   ============================================================ */
:root {
  --bg: #f4f4f8;
  --ink: #14141b;
  --ink-soft: #6e6e78;
  --ink-faint: #a0a0a8;
  --card: #ffffff;
  --line: rgba(20, 20, 27, 0.08);
  --radius: 20px;
  --price: #d7263d;
  --maxw: 1120px;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
/* ⚠️ 必须显式声明：`.mask { display: flex }` 会盖掉 HTML 的 hidden 属性，
   导致登录浮层一进页面就显示出来（第一版就踩了这个坑） */
[hidden] { display: none !important; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC",
    "Helvetica Neue", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button { font: inherit; color: inherit; border: none; background: none; cursor: pointer; }

/* ================= 顶部 ================= */
.nav {
  position: sticky; top: 0; z-index: 20;
  height: 52px; padding: 0 16px;
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(244, 244, 248, 0.86);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; font-size: 15px; font-weight: 500; }
.brand img { width: 26px; height: 26px; border-radius: 7px; }
.user-btn {
  font-size: 13px; color: var(--ink-soft);
  padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--card);
}

/* ================= 视图 ================= */
.view { max-width: var(--maxw); margin: 0 auto; padding: 0 16px 32px; }
.hero { padding: 28px 0 20px; }
.hero h1 { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; }
.hero p { margin-top: 6px; font-size: 13px; color: var(--ink-soft); }
.h2 { font-size: 17px; font-weight: 600; margin: 8px 0 14px; }
.back {
  margin: 14px 0 4px; font-size: 13px; color: var(--ink-soft);
  padding: 6px 0;
}
.muted { color: var(--ink-soft); font-size: 13px; }
.small { font-size: 12px; }

/* ================= 商品网格 ================= */
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 720px) { .grid { grid-template-columns: repeat(3, 1fr); gap: 16px; } }
@media (min-width: 1024px) { .grid { grid-template-columns: repeat(4, 1fr); } }

.card {
  background: var(--card); border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--line);
  transition: transform 0.25s var(--ease);
}
.card:active { transform: scale(0.985); }
.card-img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; background: #ececf2; }
.card-body { padding: 10px 12px 14px; }
.card-title {
  font-size: 13.5px; line-height: 1.35; min-height: 2.7em;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-meta { margin-top: 8px; display: flex; align-items: baseline; justify-content: space-between; }
.price { color: var(--price); font-size: 16px; font-weight: 600; }
.price small { font-size: 11px; font-weight: 400; margin-right: 1px; }
.card-cat { font-size: 11px; color: var(--ink-faint); }
.empty { padding: 60px 0; text-align: center; color: var(--ink-faint); font-size: 14px; }

/* ================= 商品详情 ================= */
.detail-cover {
  width: 100%; aspect-ratio: 1 / 1; object-fit: cover;
  border-radius: var(--radius); background: #ececf2;
}
.detail-title { margin-top: 16px; font-size: 19px; font-weight: 600; line-height: 1.35; }
.detail-price { margin-top: 8px; font-size: 24px; font-weight: 600; color: var(--price); }
.detail-price small { font-size: 14px; }
.detail-desc { margin-top: 14px; font-size: 14px; color: #3a3a44; line-height: 1.7; }
.detail-facts { margin-top: 18px; border-top: 1px solid var(--line); }
.fact {
  display: flex; justify-content: space-between; gap: 16px;
  padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 13px;
}
.fact dt { color: var(--ink-soft); flex: 0 0 auto; }
.fact dd { text-align: right; }

/* ================= 结算 ================= */
.co-product {
  display: flex; gap: 12px; padding: 12px; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius);
}
.co-product img { width: 72px; height: 90px; object-fit: cover; border-radius: 12px; flex: 0 0 auto; }
.co-product .t { font-size: 13.5px; line-height: 1.4; }
.co-product .p { margin-top: 8px; font-size: 15px; font-weight: 600; color: var(--price); }

.form { margin-top: 16px; display: grid; gap: 12px; }
.form label { display: block; font-size: 12px; color: var(--ink-soft); }
.form input, .form textarea {
  display: block; width: 100%; margin-top: 6px;
  padding: 12px 14px; font-size: 14px; font-family: inherit; color: var(--ink);
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  outline: none; resize: none;
}
.form input:focus, .form textarea:focus { border-color: rgba(20, 20, 27, 0.28); }
.code-row { display: flex; gap: 8px; margin-top: 6px; }
.code-row input { margin-top: 0; flex: 1 1 auto; }
.code-row .btn-ghost { flex: 0 0 auto; white-space: nowrap; }

.paybar {
  position: sticky; bottom: 0; margin-top: 20px;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0 calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 70%, rgba(244, 244, 248, 0));
}
.paybar-sum { flex: 1 1 auto; font-size: 13px; color: var(--ink-soft); }
.paybar-sum strong { display: block; margin-top: 2px; font-size: 20px; color: var(--price); }

/* ================= 按钮 ================= */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 46px; padding: 0 22px; border-radius: 999px;
  background: var(--ink); color: #fff; font-size: 15px; font-weight: 500;
  transition: opacity 0.2s var(--ease);
}
.btn-primary:disabled { opacity: 0.4; }
.btn-primary.block { display: flex; width: 100%; margin-top: 18px; }
.btn-ghost {
  min-height: 42px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--card);
  font-size: 13px; color: var(--ink);
}
.btn-ghost:disabled { color: var(--ink-faint); }
.btn-text { display: block; width: 100%; margin-top: 10px; padding: 10px; font-size: 13px; color: var(--ink-soft); }

/* ================= 完成页 ================= */
.done { padding: 64px 0 40px; text-align: center; }
.done-icon { display: flex; justify-content: center; }
.done h2 { margin-top: 18px; font-size: 21px; font-weight: 600; }
.done-amount { margin-top: 10px; font-size: 30px; font-weight: 600; }
.done .muted { margin-top: 8px; }

/* ================= 登录浮层 ================= */
.mask {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(11, 11, 18, 0.42);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  width: 100%; max-width: 480px;
  background: var(--bg); border-radius: 22px 22px 0 0;
  padding: 22px 18px calc(22px + env(safe-area-inset-bottom));
}
.sheet h3 { font-size: 17px; font-weight: 600; }
@media (min-width: 640px) {
  .mask { align-items: center; }
  .sheet { border-radius: 22px; padding-bottom: 22px; }
}

/* ================= 轻提示 ================= */
.toast {
  position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%);
  z-index: 80; max-width: 80vw;
  padding: 10px 16px; border-radius: 12px;
  background: rgba(20, 20, 27, 0.9); color: #fff;
  font-size: 13px; text-align: center;
}

/* ================= 页脚 ================= */
.foot { padding: 28px 16px 40px; text-align: center; color: var(--ink-faint); font-size: 12px; }
.foot .small { margin-top: 6px; }
.foot a { color: var(--ink-soft); }
.foot span { margin: 0 6px; }
