:root {
  --bg: #0b0d12;
  --bg2: #14171f;
  --panel: #1a1e28;
  --line: #272c3a;
  --text: #eef1f6;
  --muted: #8a92a6;
  --accent: #4f7cff;
  --accent2: #2f54d0;
  --gold: #ffcf5c;
  --danger: #ff5c6c;
  --radius: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: 40px;
}

/* 顶栏 */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(11, 13, 18, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; min-width: 0; }
.logo {
  width: 28px; height: 28px; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-radius: 8px; color: #fff; font-size: 13px;
}
.site-name { font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }

.member-box { display: flex; align-items: center; gap: 8px; }
.member-name { font-size: 13px; color: var(--text); max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-balance { font-size: 12px; color: var(--gold); font-weight: 600; }

/* 搜索与分类导航 */
.search-nav { max-width: 800px; margin: 0 auto; padding: 12px 14px 4px; }
.search-bar { display: flex; gap: 8px; margin-bottom: 10px; }
.search-bar input {
  flex: 1 1 auto; min-width: 0;
  padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg2); color: var(--text); font-size: 15px; outline: none;
}
.search-bar input:focus { border-color: var(--accent); }
.nav-cats { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; -webkit-overflow-scrolling: touch; }
.nav-cats::-webkit-scrollbar { display: none; }
.cat-btn {
  flex: 0 0 auto;
  padding: 7px 16px; border-radius: 18px; border: 1px solid var(--line);
  background: transparent; color: var(--muted); font-size: 14px; cursor: pointer; white-space: nowrap;
}
.cat-btn.active { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; border-color: transparent; font-weight: 600; }

/* 按钮 */
.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 14px;
  cursor: pointer;
  color: var(--text);
  background: var(--panel);
  transition: transform .06s ease, opacity .2s;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; font-weight: 600; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn-small { padding: 4px 10px; font-size: 12px; }
.btn-block { display: block; width: 100%; margin-top: 14px; padding: 12px; font-size: 15px; }

/* 瀑布流 */
main { max-width: 800px; margin: 0 auto; padding: 16px 12px; }
.wall {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.card {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 1;
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  background: var(--bg2);
  box-shadow: 0 2px 12px rgba(0,0,0,.4);
}
.card img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: var(--bg2);
}
.card-title {
  position: absolute;
  left: 0; right: 0; top: 50%;
  transform: translateY(-50%);
  padding: 0 20px;
  text-align: center;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.4;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 1px 4px rgba(0,0,0,.65);
  pointer-events: none;
}

.loading, .empty { text-align: center; color: var(--muted); padding: 40px 0; font-size: 14px; }

/* 弹窗 */
.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0,0,0,.6);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}
.modal {
  width: 100%;
  max-width: 440px;
  background: var(--panel);
  border-radius: 18px 18px 0 0;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp .22s ease;
}
@keyframes slideUp { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }

.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 16px; font-weight: 700; margin-bottom: 14px;
}
.close {
  border: none; background: var(--bg2); color: var(--muted);
  width: 30px; height: 30px; border-radius: 50%; font-size: 14px; cursor: pointer;
}

.video-modal { max-width: 640px; }
.video-title { font-size: 16px; font-weight: 700; flex: 1; margin-right: 8px; word-break: break-word; }
.video-stage video { width: 100%; border-radius: 12px; background: #000; max-height: 62vh; display: block; }

.unlock-box { text-align: center; padding: 24px 8px; }
.unlock-price { font-size: 18px; margin-bottom: 6px; }
.unlock-price b { color: var(--gold); }
.unlock-hint { color: var(--muted); font-size: 13px; margin-bottom: 8px; }

/* 充值 */
.rate-tip { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 14px; }
.currency-toggle { display: flex; gap: 10px; margin-bottom: 14px; }
.cur-btn {
  flex: 1; padding: 10px; border-radius: 10px; border: 1px solid var(--line);
  background: transparent; color: var(--text); font-size: 15px; font-weight: 600; cursor: pointer;
}
.cur-btn.active { border-color: var(--accent); background: rgba(79,124,255,.15); color: var(--accent); }
.amount-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 6px; }
.amount-btn {
  padding: 14px 6px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg2); color: var(--text); cursor: pointer; display: flex; flex-direction: column; gap: 4px; align-items: center;
}
.amount-btn b { font-size: 22px; }
.amount-btn span { font-size: 11px; color: var(--muted); }
.amount-btn.active { border-color: var(--gold); background: rgba(255,207,92,.1); }

.pay-info { margin-top: 14px; border-top: 1px dashed var(--line); padding-top: 14px; }
.pay-line { font-size: 14px; margin-bottom: 10px; }
.pay-addr {
  display: flex; align-items: center; gap: 8px; background: var(--bg2);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px;
}
.pay-addr span { flex: 1; font-size: 12px; word-break: break-all; color: var(--muted); }
.pay-note { font-size: 12px; color: var(--muted); margin-top: 10px; line-height: 1.6; }

.my-orders { margin-top: 16px; }
.order-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; font-size: 13px;
}
.order-status { font-weight: 600; }
.st-pending { color: var(--gold); }
.st-confirmed { color: #37d67a; }
.st-rejected { color: var(--danger); }

/* 表单 */
.field { display: block; margin-bottom: 12px; }
.field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input {
  width: 100%; padding: 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg2); color: var(--text); font-size: 15px; outline: none;
}
.field input:focus { border-color: var(--accent); }
.form-tip { color: var(--muted); font-size: 13px; margin-bottom: 12px; line-height: 1.5; }
.form-tip.small { font-size: 12px; }
.form-tip.warn { color: var(--gold); }

/* 账号 */
.cred-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 10px; font-size: 14px;
}
.cred-row span { color: var(--muted); }
.cred-row b { word-break: break-all; text-align: right; margin-left: 12px; }

/* 欢迎弹窗 */
.welcome { text-align: center; }
.welcome-icon { font-size: 42px; margin: 6px 0 8px; }
.welcome-title { font-size: 18px; margin-bottom: 10px; }
.welcome .cred-row { text-align: left; }

/* 客服悬浮按钮 */
.kefu-fab {
  position: fixed;
  right: 14px;
  bottom: 20px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: 56px;
  height: 56px;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(79,124,255,.4);
}
.kefu-fab-icon { font-size: 20px; line-height: 1; }
.kefu-fab-label { font-size: 11px; font-weight: 600; }

.kefu-badge {
  position: absolute;
  top: 2px; right: 2px;
  min-width: 18px; height: 18px;
  background: var(--danger);
  color: #fff; font-size: 11px; font-weight: 700;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 5px;
}

/* 聊天窗口 */
.chat-modal {
  display: flex;
  flex-direction: column;
  height: 78vh;
  max-height: 640px;
  padding-bottom: 0;
  overflow: hidden;
}
.chat-modal .modal-head { flex: 0 0 auto; }
.kefu-extra {
  flex: 0 0 auto;
  font-size: 12px; color: var(--muted);
  padding: 0 0 10px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 10px;
  word-break: break-all;
}
.kefu-extra a { color: var(--accent); }
.chat-messages {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 8px 2px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.chat-msg { max-width: 78%; padding: 9px 12px; border-radius: 14px; font-size: 14px; line-height: 1.5; word-break: break-word; }
.chat-msg.mine { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.chat-msg.theirs { align-self: flex-start; background: var(--bg2); color: var(--text); border-bottom-left-radius: 4px; }
.chat-img { display: block; max-width: 200px; max-height: 200px; border-radius: 10px; cursor: pointer; }
.chat-input {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 0 calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
}
.chat-img-btn {
  flex: 0 0 auto;
  width: 40px; height: 40px; border: none; border-radius: 10px;
  background: var(--bg2); color: var(--text); font-size: 18px; cursor: pointer;
}
.chat-input input[type="text"] {
  flex: 1 1 auto; min-width: 0;
  padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg2); color: var(--text); font-size: 15px; outline: none;
}
.chat-send-btn {
  flex: 0 0 auto;
  padding: 0 16px; height: 40px; border: none; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; font-size: 15px; font-weight: 600; cursor: pointer;
}

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%);
  background: rgba(30,34,46,.96); color: var(--text); border: 1px solid var(--line);
  padding: 10px 18px; border-radius: 10px; font-size: 14px; z-index: 300; max-width: 88vw; text-align: center;
}

/* 响应式 */
@media (min-width: 768px) {
  .modal-mask { align-items: center; padding: 20px; }
  .modal { border-radius: 18px; }
  .topbar { padding: 12px 22px; }
  main { padding: 20px; }
  .card-title { font-size: 18px; }
}
