:root {
  --bg0: #0c0414;
  --bg1: #150a22;
  --bg2: #1f0e32;
  --card: rgba(255, 245, 255, 0.055);
  --card-border: rgba(180, 140, 210, 0.14);
  --text: #ede0f6;
  --muted: #b498c8;
  --accent: #a844e0;
  --accent2: #d954b8;
  --accent-text: #140820;
  --price: #e8bc70;
  --danger: #ff8fab;
  --shadow: 0 0.75rem 2.5rem rgba(30, 8, 55, 0.5);
  --radius: 4.5vw;
  --pad-x: 4vw;
  --pad-y: 3.2vw;
  --gap: 2.5vw;
  --touch: clamp(2.75rem, 12vw, 3.25rem);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html {
  /* 老年机小屏也放大字，大屏不无限涨 */
  font-size: clamp(17px, 4.6vw, 21px);
}
html, body {
  width: 100%;
  min-height: 100%;
  overflow-x: clip;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(80vw 45vh at 20% -10%, rgba(110, 45, 170, 0.16), transparent 55%),
    radial-gradient(70vw 40vh at 100% 10%, rgba(150, 50, 130, 0.1), transparent 50%),
    linear-gradient(180deg, var(--bg0), var(--bg1) 40%, #07030e);
  color: var(--text);
  line-height: 1.55;
}
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; height: auto; }
button, input, textarea { font: inherit; }

.app {
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: calc(18vw + var(--safe-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(14px);
  background: rgba(22, 8, 36, 0.78);
  border-bottom: 1px solid var(--card-border);
  padding: var(--pad-y) var(--pad-x);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 3%;
  width: 100%;
}
.brand {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}
.brand span { color: var(--accent2); }

.hero {
  display: block;
  margin: 3.5% 4% 2%;
  width: 92%;
  border-radius: 5.5vw;
  overflow: hidden;
  position: relative;
  min-height: 42vw;
  box-shadow: var(--shadow);
  border: 1px solid var(--card-border);
  cursor: pointer;
  color: inherit;
  text-decoration: none;
  background: #fff;
}
.hero:active { transform: scale(0.995); }
.hero img {
  width: 100%;
  height: 48vw;
  max-height: 40vh;
  object-fit: cover;
  object-position: center 40%;
  background: #fff;
}
.hero-scrim {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,.08) 0%, rgba(255,255,255,.02) 42%, rgba(22,8,36,.55) 72%, rgba(22,8,36,.88) 100%);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 5%;
}
.hero h1 {
  font-size: clamp(1.35rem, 6.2vw, 1.75rem);
  line-height: 1.25;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 1px 8px rgba(12, 4, 20, 0.45);
}
.hero p {
  margin-top: 2%;
  color: rgba(255, 245, 255, 0.88);
  font-size: 1.05rem;
  text-shadow: 0 1px 6px rgba(12, 4, 20, 0.4);
}

.cta-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3%;
  width: 92%;
  margin: 0 auto;
  padding: 3% 0 2%;
}
.cta-row-single {
  grid-template-columns: 1fr;
}
.cta-row-single .btn {
  text-align: center;
  padding: 4% 5%;
  font-size: 1.15rem;
}
.btn {
  appearance: none;
  border: none;
  border-radius: 999px;
  padding: 3.8% 4.5%;
  font-size: 1.1rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform .15s ease, opacity .15s ease;
}
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  box-shadow: 0 0.6rem 1.6rem rgba(196, 92, 255, 0.45);
}
.btn-secondary {
  background: rgba(255,255,255,0.08);
  color: var(--text);
  border: 1px solid var(--card-border);
}
.btn-block { width: 100%; }
/* 买产品找客服：白底红字 */
.btn-buy-cs {
  background: #fff !important;
  color: #e11d48 !important;
  border: 1px solid #e11d48;
  box-shadow: 0 0.45rem 1.2rem rgba(225, 29, 72, 0.22);
  font-size: 1.35rem !important;
  letter-spacing: 0.04em;
}
.cta-row-single .btn-buy-cs {
  font-size: 1.4rem !important;
  padding: 4.4% 5%;
}
.dock-single .btn-buy-cs {
  font-size: 1.32rem !important;
  padding: 4% 4%;
}

.section-title {
  padding: 4% 4% 2.5%;
  font-size: 1.25rem;
  font-weight: 800;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 3vw;
  row-gap: 3vw;
  width: 92%;
  margin: 0 auto;
  padding: 0 0 6%;
  align-items: stretch;
}
.card {
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  width: 100%;
  min-width: 0;
  position: relative;
  z-index: 0;
  height: 100%;
  color: #222;
}
.card-no {
  position: absolute;
  top: 0.55rem;
  left: 0.55rem;
  z-index: 2;
  min-width: 1.65rem;
  height: 1.65rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: rgba(225, 29, 72, 0.95);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 800;
  line-height: 1.65rem;
  text-align: center;
  box-shadow: 0 0.25rem 0.7rem rgba(0, 0, 0, 0.28);
}
/* 统一图框：白底版；图片完整放入不裁切 */
.card-cover {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: #ffffff !important;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  padding: 3%;
  box-sizing: border-box;
}
.card-cover img,
.card > img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  background: #ffffff !important;
  flex-shrink: 0;
}
.card-body {
  padding: 0.75rem 0.8rem 1rem;
  flex: 1 1 auto;
  background: #fff;
}
.card-name {
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.7em;
  color: #1a1a1a;
}
.card-price {
  margin-top: 0.45rem;
  color: #e11d48;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  line-height: 1.2;
}
.card-price small {
  font-size: 0.85rem;
  margin-right: 0.15em;
}

.dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  padding: 2.5% 4% calc(2.5% + var(--safe-bottom));
  background: rgba(22, 8, 36, 0.92);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--card-border);
  display: grid;
  grid-template-columns: 45% 52%;
  justify-content: space-between;
  column-gap: 3%;
  z-index: 30;
  box-sizing: border-box;
}
.dock-single {
  grid-template-columns: 1fr;
  column-gap: 0;
}
.dock-single .btn {
  text-align: center;
  padding: 3.6% 4%;
  font-size: 1.12rem;
}

.detail-gallery {
  width: 100%;
  background: #ffffff !important;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4% 0;
  box-sizing: border-box;
}
.detail-gallery img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: contain;
  background: #ffffff !important;
}
.detail-panel {
  padding: 4% 4% 28%;
  width: 100%;
}
.detail-name {
  font-size: clamp(1.4rem, 6.5vw, 1.7rem);
  font-weight: 800;
  line-height: 1.3;
}
.detail-price {
  margin-top: 3%;
  color: var(--price);
  font-size: clamp(1.6rem, 7.5vw, 2rem);
  font-weight: 800;
}
.detail-desc {
  margin-top: 4%;
  color: var(--muted);
  font-size: 1.1rem;
  white-space: pre-wrap;
}
.back {
  width: var(--touch);
  height: var(--touch);
  flex: 0 0 var(--touch);
  border-radius: 50%;
  border: 1px solid var(--card-border);
  background: rgba(255,255,255,0.08);
  color: #fff;
  font-size: 1.15rem;
  cursor: pointer;
}

/* chat sheet */
.sheet-mask {
  position: fixed;
  inset: 0;
  background: rgba(8, 2, 16, 0.55);
  z-index: 40;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}
.sheet-mask.open { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 82%;
  max-height: 82vh;
  background: linear-gradient(180deg, #2a1540, #1a0b2e);
  border-radius: 5.5vw 5.5vw 0 0;
  border: 1px solid rgba(232, 190, 255, 0.22);
  z-index: 50;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(110%);
  transition: transform .25s ease;
}
.sheet.open { transform: translateY(0); }
.sheet-hd {
  padding: 3.5% 4%;
  border-bottom: 1px solid var(--card-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 3%;
  font-size: 1.15rem;
  font-weight: 800;
  width: 100%;
}
.sheet-bd, .chat-page-bd {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 3.5% 3.5%;
  display: flex;
  flex-direction: column;
  gap: 3%;
  background: transparent;
  width: 100%;
}

.msg-row {
  display: flex;
  align-items: flex-start;
  gap: 2.2%;
  max-width: 100%;
  width: 100%;
}
.msg-row.me { flex-direction: row-reverse; }
.msg-row.sys { justify-content: center; }
.msg-avatar {
  width: 11%;
  max-width: 2.6rem;
  min-width: 2.2rem;
  aspect-ratio: 1;
  height: auto;
  border-radius: 22%;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  font-size: 0.7rem;
  font-weight: 800;
  color: #fff;
  overflow: hidden;
}
.msg-avatar.cs { background: linear-gradient(135deg, #7b2ff2, #c45cff); }
.msg-avatar.me { background: linear-gradient(135deg, #c45cff, #ff6ad5); }
.msg-avatar.has-img { padding: 0; background: rgba(255,255,255,0.12); }
.msg-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.msg-bubble {
  max-width: 78%;
  width: fit-content;
  padding: 2.8% 3.5%;
  font-size: 1.05rem;
  line-height: 1.45;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.msg-row.them .msg-bubble {
  background: rgba(255, 255, 255, 0.10);
  color: var(--text);
  border: 1px solid var(--card-border);
  border-radius: 0.3em 1em 1em 1em;
}
.msg-row.me .msg-bubble {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  border-radius: 1em 0.3em 1em 1em;
  box-shadow: 0 0.5rem 1.25rem rgba(196, 92, 255, 0.28);
}
.msg-row.sys .msg-bubble {
  background: rgba(255,255,255,0.08);
  color: var(--muted);
  border-radius: 999px;
  font-size: 0.9rem;
  padding: 1.5% 3.5%;
  max-width: 92%;
  text-align: center;
  border: none;
  box-shadow: none;
}
.msg-bubble img {
  max-width: 55vw;
  width: 100%;
  border-radius: 0.6em;
  display: block;
}
.msg-bubble.product {
  padding: 0;
  overflow: hidden;
  width: min(72vw, 16.5rem);
  max-width: min(78%, 16.5rem);
  min-width: 13.5rem;
  background: rgba(255, 255, 255, 0.12) !important;
  border: 1px solid var(--card-border);
}
.product-card-link {
  display: block;
  color: inherit;
  text-decoration: none;
}
.product-card {
  display: grid;
  grid-template-columns: 4.4rem minmax(0, 1fr);
  gap: 0.7rem;
  padding: 0.7rem 0.75rem;
  align-items: center;
  box-sizing: border-box;
}
.product-card img {
  width: 4.4rem;
  height: 4.4rem;
  object-fit: cover;
  border-radius: 0.5em;
  background: rgba(255,255,255,0.08);
}
.product-card-bd {
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.22rem;
}
.product-card-name {
  font-weight: 800;
  font-size: 1rem;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.product-card-price {
  color: var(--price);
  font-weight: 800;
  font-size: 1.08rem;
  line-height: 1.2;
  white-space: nowrap;
}
.product-card-tip {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 独立客服页：白色界面 */
body.chat-only {
  height: 100%;
  width: 100%;
  overflow: hidden;
  background: #ededed;
  color: #111;
  --card-border: #e5e5e5;
  --text: #111;
  --muted: #888;
  --accent: #c45cff;
  --accent2: #ff6ad5;
  --price: #c45cff;
}
html:has(body.chat-only) {
  height: 100%;
  width: 100%;
  overflow: hidden;
  background: #ededed;
}
.chat-page {
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  height: 100%;
  height: 100dvh;
  max-height: 100%;
  overflow: hidden;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  background: #ededed;
  color: #111;
}
.chat-page-hd {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 3%;
  width: 100%;
  padding: 3% 3.5%;
  border-bottom: 1px solid #e8e8e8;
  background: #f7f7f7;
  backdrop-filter: none;
  z-index: 10;
  color: #111;
}
.chat-page-hd .title {
  flex: 1;
  text-align: center;
  font-size: 1.15rem;
  font-weight: 800;
  color: #111;
}
.chat-page-hd .back {
  border: 1px solid #ddd;
  background: #fff;
  color: #333;
}
.chat-page-hd > div[style] {
  width: var(--touch) !important;
  flex: 0 0 var(--touch);
}

body.chat-only .chat-page-bd {
  background: #ededed;
}
body.chat-only .msg-row.them .msg-bubble {
  background: #fff;
  color: #111;
  border: none;
  box-shadow: 0 1px 0.5px rgba(0,0,0,.08);
}
body.chat-only .msg-row.me .msg-bubble {
  background: #95ec69;
  color: #111;
  box-shadow: 0 1px 0.5px rgba(0,0,0,.08);
}
body.chat-only .msg-row.sys .msg-bubble {
  background: rgba(0,0,0,.06);
  color: #888;
}
body.chat-only .msg-bubble.product {
  background: #fff !important;
  border: 1px solid #eee;
  width: min(72vw, 16.5rem);
  max-width: min(78%, 16.5rem);
  min-width: 13.5rem;
}
body.chat-only .product-card-price { color: #e02e24; }
body.chat-only .product-card-tip { color: #999; }
body.chat-only .msg-avatar.cs { background: linear-gradient(135deg, #8b2fd6, #c45cff); }
body.chat-only .msg-avatar.me { background: #07c160; }

/* 咨询商品条（从详情进客服） */
.consult-bar {
  flex-shrink: 0;
  padding: 2.2% 3%;
  background: #fff;
  border-top: 1px solid #eee;
}
.consult-bar[hidden] { display: none !important; }
.consult-card {
  display: flex;
  align-items: center;
  gap: 3%;
  padding: 2.5% 3%;
  background: #f7f7f7;
  border-radius: 3vw;
}
.consult-card img {
  width: 16%;
  max-width: 3.6rem;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 2vw;
  background: #eee;
  flex-shrink: 0;
}
.consult-card-bd {
  flex: 1;
  min-width: 0;
}
.consult-card-name {
  font-size: 0.95rem;
  color: #222;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
}
.consult-card-price {
  margin-top: 0.2rem;
  color: #e02e24;
  font-weight: 700;
  font-size: 1rem;
}
.consult-send {
  flex-shrink: 0;
  padding: 0.55rem 0.85rem !important;
  font-size: 0.88rem !important;
  white-space: nowrap;
  box-shadow: none !important;
}

/* 商品选择器 */
.product-picker-mask {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.product-picker-mask[hidden] { display: none !important; }
.product-picker-sheet {
  width: 100%;
  max-width: 480px;
  max-height: 72vh;
  background: #fff;
  border-radius: 4.5vw 4.5vw 0 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: pickerUp .22s ease;
}
@keyframes pickerUp {
  from { transform: translateY(12%); opacity: .6; }
  to { transform: translateY(0); opacity: 1; }
}
.product-picker-hd {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 3.5% 4%;
  border-bottom: 1px solid #eee;
  color: #222;
  font-size: 1.05rem;
}
.product-picker-close {
  border: none;
  background: transparent;
  color: #888;
  font-size: 0.95rem;
  padding: 0.4rem 0.2rem;
  cursor: pointer;
}
.product-picker-bd {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 2% 0 calc(3% + var(--safe-bottom));
}
.product-picker-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 3.5%;
  padding: 3% 4%;
  border: none;
  border-bottom: 1px solid #f2f2f2;
  background: #fff;
  text-align: left;
  cursor: pointer;
  color: #222;
}
.product-picker-item:active { background: #f5f5f5; }
.product-picker-item img {
  width: 18%;
  max-width: 4rem;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 2vw;
  background: #f0f0f0;
  flex-shrink: 0;
}
.product-picker-item .name {
  font-size: 0.98rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 62vw;
}
.product-picker-item .price {
  margin-top: 0.25rem;
  color: #e02e24;
  font-weight: 700;
}
.product-picker-bd .empty {
  color: #999;
  padding: 12% 5%;
}

/* 底部：商品+图 | 输入自适应 | 发送 —— 全程百分比，不会挤出屏 */
.chat-page-ft,
.sheet-ft {
  flex-shrink: 0;
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  border-top: 1px solid #e8e8e8;
  padding: 2.2% 2.5% calc(2.2% + var(--safe-bottom));
  display: flex;
  align-items: center;
  gap: 1.8%;
  background: #f7f7f7;
}
.sheet-ft {
  background: transparent;
}
.chat-page-ft .icon-btn,
.sheet-ft .icon-btn {
  flex: 0 0 11.5%;
  width: 11.5%;
  max-width: 11.5%;
  aspect-ratio: 1;
  height: auto;
  font-size: 0.78rem;
  border-radius: 50%;
  padding: 0;
  line-height: 1.1;
}
.chat-page-ft input,
.sheet-ft input[type="text"] {
  flex: 1 1 0;
  min-width: 0;
  width: 0;
  box-sizing: border-box;
  border: 1px solid #e0e0e0;
  background: #fff;
  color: #111;
  border-radius: 999px;
  padding: 2.8% 3.5%;
  outline: none;
  font-size: 1rem;
}
.chat-page-ft input::placeholder {
  color: #aaa;
}
.chat-page-ft .btn,
.sheet-ft .btn {
  flex: 0 0 18%;
  width: 18%;
  max-width: 18%;
  padding: 2.8% 0;
  font-size: 0.95rem;
  white-space: nowrap;
  line-height: 1.2;
  text-align: center;
  box-shadow: 0 0.35rem 0.9rem rgba(196, 92, 255, 0.28);
}
body.chat-only .chat-page-ft .icon-btn,
body.chat-only .icon-btn {
  border: 1px solid #ddd;
  background: #fff;
  color: #444;
  cursor: pointer;
  flex-shrink: 0;
  display: grid;
  place-items: center;
}
.icon-btn {
  border: 1px solid var(--card-border);
  background: rgba(255,255,255,0.08);
  color: #fff;
  cursor: pointer;
  flex-shrink: 0;
  display: grid;
  place-items: center;
}

.empty {
  padding: 10% 5%;
  text-align: center;
  color: var(--muted);
}

/* 极窄老年机：发送略收，保证列都在屏内 */
@media (max-width: 360px) {
  html { font-size: clamp(16px, 4.8vw, 18px); }
  .chat-page-ft .icon-btn,
  .sheet-ft .icon-btn { flex-basis: 11%; width: 11%; max-width: 11%; font-size: 0.72rem; }
  .chat-page-ft .btn,
  .sheet-ft .btn { flex-basis: 17%; width: 17%; max-width: 17%; font-size: 0.9rem; }
}
