:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --ink: #1f2330;
  --muted: #8a90a2;
  --brand: #e63946;
  --brand2: #ff7a45;
  --line: #eceef3;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
}
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
  padding: 14px 20px; background: #fff; border-bottom: 1px solid var(--line);
}
.brand { font-size: 20px; font-weight: 800; }
.brand span { color: var(--brand); }
.search { display: flex; gap: 8px; flex: 1; min-width: 240px; }
.search input {
  flex: 1; padding: 10px 14px; border: 1px solid var(--line);
  border-radius: 999px; outline: none; font-size: 14px;
}
.search button, .co-row select, .primary, .chat-input button, .chat-toggle {
  cursor: pointer; border: none; font-size: 14px;
}
.search button, .primary {
  background: linear-gradient(135deg, var(--brand), var(--brand2));
  color: #fff; padding: 10px 18px; border-radius: 999px; font-weight: 600;
}
.cats { display: flex; gap: 8px; flex-wrap: wrap; }
.cats button {
  border: 1px solid var(--line); background: #fff; color: var(--muted);
  padding: 6px 12px; border-radius: 999px; cursor: pointer; font-size: 13px;
}
.cats button.active { background: var(--ink); color: #fff; border-color: var(--ink); }

main { max-width: 1280px; margin: 18px auto; padding: 0 16px; }
.masonry { column-count: 4; column-gap: 16px; }
@media (max-width: 1100px) { .masonry { column-count: 3; } }
@media (max-width: 760px) { .masonry { column-count: 2; } }
@media (max-width: 460px) { .masonry { column-count: 1; } }

.card {
  break-inside: avoid; margin: 0 0 16px; background: var(--card);
  border-radius: 16px; overflow: hidden; box-shadow: 0 4px 18px rgba(20,24,40,.06);
  transition: transform .15s ease, box-shadow .15s ease;
}
.card:hover { transform: translateY(-3px); box-shadow: 0 10px 28px rgba(20,24,40,.12); }
.card .media { position: relative; width: 100%; display: block; background: #eee; }
.card .media img, .card .media video { width: 100%; display: block; object-fit: cover; }
.card .badge {
  position: absolute; left: 10px; top: 10px; background: rgba(0,0,0,.55);
  color: #fff; font-size: 11px; padding: 3px 8px; border-radius: 999px;
}
.card .body { padding: 12px 14px; }
.card .title { font-size: 14px; line-height: 1.45; margin: 0 0 8px; }
.card .meta { display: flex; align-items: baseline; gap: 8px; }
.card .price { color: var(--brand); font-weight: 800; font-size: 18px; }
.card .price small { font-size: 12px; font-weight: 600; }
.card .origin { color: var(--muted); text-decoration: line-through; font-size: 12px; }
.card .coupon {
  margin-left: auto; background: #fff0ee; color: var(--brand);
  font-size: 11px; padding: 2px 8px; border-radius: 6px;
}
.card .shop { color: var(--muted); font-size: 12px; margin-top: 6px; }
.card .buy {
  width: 100%; margin-top: 10px; padding: 9px; border: none; border-radius: 10px;
  background: linear-gradient(135deg, var(--brand), var(--brand2)); color: #fff;
  font-weight: 600; cursor: pointer;
}
.empty { text-align: center; color: var(--muted); padding: 60px 0; }

.modal { position: fixed; inset: 0; background: rgba(10,12,20,.5); display: grid; place-items: center; z-index: 50; }
.modal-box { background: #fff; width: min(420px, 92vw); border-radius: 18px; padding: 22px; position: relative; }
.modal-box .close { position: absolute; right: 14px; top: 10px; background: none; border: none; font-size: 24px; color: var(--muted); cursor: pointer; }
.modal-box h3 { margin: 0 0 14px; }
.co-items { max-height: 220px; overflow: auto; margin-bottom: 12px; }
.co-items .ci { display: flex; justify-content: space-between; font-size: 13px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.co-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; }
.co-row select { padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); }
.co-result { margin-top: 12px; font-size: 13px; line-height: 1.6; }
.co-result .addr { word-break: break-all; background: #f6f7fb; padding: 8px; border-radius: 10px; margin-top: 6px; }

.chat { position: fixed; right: 18px; bottom: 18px; z-index: 60; }
.chat-toggle { background: linear-gradient(135deg, var(--brand), var(--brand2)); color: #fff; padding: 12px 16px; border-radius: 999px; box-shadow: 0 8px 22px rgba(230,57,70,.35); }
.chat-panel { width: min(340px, 92vw); height: 440px; background: #fff; border-radius: 16px; box-shadow: 0 12px 40px rgba(20,24,40,.2); display: flex; flex-direction: column; overflow: hidden; margin-bottom: 10px; }
.chat-head { background: var(--ink); color: #fff; padding: 12px 14px; font-weight: 600; }
.chat-log { flex: 1; overflow: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.chat-log .b { max-width: 85%; padding: 9px 12px; border-radius: 12px; font-size: 13px; line-height: 1.5; }
.chat-log .me { align-self: flex-end; background: var(--brand); color: #fff; border-bottom-right-radius: 4px; }
.chat-log .bot { align-self: flex-start; background: #f0f1f6; color: var(--ink); border-bottom-left-radius: 4px; }
.chat-input { display: flex; border-top: 1px solid var(--line); }
.chat-input input { flex: 1; border: none; padding: 12px; outline: none; font-size: 13px; }
.chat-input button { background: var(--ink); color: #fff; padding: 0 16px; border: none; }

/* 支付宝支付区（下单弹窗内） */
.co-result .qr { text-align: center; margin: 10px 0; }
.co-result .qr img {
  width: 180px; height: 180px; object-fit: contain; background: #fff;
  border: 1px solid var(--line); border-radius: 12px; padding: 6px;
}
.co-result .pay-go { display: block; text-align: center; text-decoration: none; margin-top: 10px; }
.co-result .hint { color: var(--muted); font-size: 12px; margin-top: 8px; line-height: 1.6; }

/* 支付结果页 */
.result-wrap { max-width: 520px; margin: 60px auto; padding: 0 16px; }
.result-card {
  background: #fff; border-radius: 18px; padding: 32px 24px; text-align: center;
  box-shadow: 0 8px 30px rgba(20,24,40,.08);
}
.result-ico { font-size: 44px; line-height: 1; }
.result-card h2 { margin: 14px 0 8px; font-size: 20px; }
.result-msg { color: var(--muted); font-size: 14px; line-height: 1.7; margin: 0 0 14px; }
.result-oid {
  font-size: 12px; color: var(--muted); background: var(--bg);
  border-radius: 10px; padding: 8px 10px; word-break: break-all;
}
.result-actions { display: flex; gap: 10px; justify-content: center; margin-top: 18px; }
.result-actions .ghost {
  display: inline-flex; align-items: center; padding: 10px 18px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--ink); text-decoration: none; font-size: 14px;
}
