/* ========== 基础 ========== */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: #e9ebf0;
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}
:root {
  --brand: #ff2e63;
  --brand-2: #ff6a3d;
  --accent: #ffd166;
  --bg: #f4f5f8;
  --card: #ffffff;
  --text: #16171c;
  --sub: #8b9099;
  --line: #eceef3;
  --ok: #12b886;
  --warn: #f59f00;
  --radius: 16px;
  --shadow: 0 6px 22px rgba(20, 22, 40, .08);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
.app {
  position: relative;
  max-width: 480px;
  min-height: 100vh;
  margin: 0 auto;
  background: var(--bg);
  overflow-x: hidden;
  box-shadow: 0 0 40px rgba(0, 0, 0, .08);
}
img, svg { display: block; max-width: 100%; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font-family: inherit; font-size: 15px; }

/* ========== 通用组件 ========== */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
.row { display: flex; align-items: center; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--sub); }
.small { font-size: 12px; }
.mono { font-variant-numeric: tabular-nums; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hide { display: none !important; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 44px; padding: 0 18px; border-radius: 22px;
  font-size: 15px; font-weight: 600; color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  transition: transform .12s ease, opacity .12s ease;
}
.btn:active { transform: scale(.96); }
.btn:disabled { opacity: .5; }
.btn.ghost { background: #fff; color: var(--text); border: 1px solid var(--line); }
.btn.soft { background: #fff2f5; color: var(--brand); }
.btn.block { display: flex; width: 100%; }
.btn.sm { height: 34px; padding: 0 14px; font-size: 13px; border-radius: 17px; }

.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600;
  background: #f0f2f6; color: var(--sub);
}
.tag.live { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; }
.tag.warn { background: #fff4e0; color: var(--warn); }
.tag.ok { background: #e6fbf4; color: var(--ok); }

.field { margin-bottom: 14px; }
.field > label { display: block; font-size: 13px; color: var(--sub); margin-bottom: 6px; font-weight: 600; }
.input {
  width: 100%; height: 46px; padding: 0 14px; border-radius: 12px;
  border: 1px solid var(--line); background: #fff; color: var(--text); outline: none;
}
.input:focus { border-color: var(--brand); }
textarea.input { height: auto; padding: 12px 14px; resize: vertical; }

.chkline {
  display: flex; align-items: flex-start; gap: 8px;
  min-height: 46px; padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: #fff;
  font-size: 13px; color: var(--text); line-height: 1.5; cursor: pointer;
}
.chkline input { width: 16px; height: 16px; margin: 2px 0 0; flex: none; accent-color: var(--brand); }

.guide {
  margin: 0 0 14px; border: 1px solid var(--line); border-radius: 12px;
  background: #fafbfc; overflow: hidden;
}
.guide > summary {
  padding: 12px 14px; font-size: 13px; font-weight: 600; color: var(--brand); cursor: pointer;
}
.guide[open] > summary { border-bottom: 1px solid var(--line); }
.guide ol { margin: 0; padding: 12px 14px 4px 32px; font-size: 12.5px; line-height: 1.7; color: var(--text); }
.guide li { margin-bottom: 6px; }
.guide .hint { margin: 4px 14px 12px; font-size: 12px; color: var(--sub); line-height: 1.6; }

/* ========== 顶部导航 ========== */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(255, 255, 255, .92); backdrop-filter: blur(12px);
  padding: 12px 16px 10px;
}
.brand { display: flex; align-items: center; gap: 8px; font-size: 19px; font-weight: 800; letter-spacing: -.5px; }
.brand-dot {
  width: 26px; height: 26px; border-radius: 9px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  display: grid; place-items: center; color: #fff; font-size: 14px;
}
.search {
  margin-top: 10px; height: 38px; border-radius: 19px; background: #f0f2f6;
  display: flex; align-items: center; padding: 0 14px; gap: 8px; color: var(--sub); font-size: 13px;
}
.search input {
  flex: 1; min-width: 0; border: none; outline: none; background: transparent;
  font-size: 13px; color: var(--text);
}

/* ========== 分类 ========== */
.tabs { display: flex; gap: 8px; overflow-x: auto; padding: 12px 16px 4px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: none; padding: 7px 14px; border-radius: 999px; background: #fff;
  font-size: 13px; font-weight: 600; color: var(--sub); box-shadow: var(--shadow);
}
.tab.on { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; }

/* ========== 直播卡片 ========== */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 12px 16px 96px; }
.room {
  background: #fff; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
  transition: transform .12s ease;
}
.room:active { transform: scale(.98); }
.cover {
  position: relative; height: 150px; display: grid; place-items: center; font-size: 54px;
  background: linear-gradient(160deg, #ffd9e2, #ffe9d6);
}
.cover.c1 { background: linear-gradient(160deg, #ffd9e2, #ffe9d6); }
.cover.c2 { background: linear-gradient(160deg, #d9e4ff, #e8dcff); }
.cover.c3 { background: linear-gradient(160deg, #ffe3c7, #fff3d6); }
.cover.c4 { background: linear-gradient(160deg, #d7f5e9, #dcf3ff); }
.cover-mask {
  position: absolute; inset: auto 0 0 0; height: 54px;
  background: linear-gradient(transparent, rgba(0, 0, 0, .45));
}
.cover-top { position: absolute; top: 8px; left: 8px; right: 8px; display: flex; justify-content: space-between; align-items: center; }
.pill {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 700; background: rgba(0, 0, 0, .45); color: #fff; backdrop-filter: blur(4px);
}
.pill.hot { background: linear-gradient(135deg, var(--brand), var(--brand-2)); }
.room-body { padding: 10px 12px 12px; }
.room-title { font-size: 14px; font-weight: 700; line-height: 1.35; height: 38px; overflow: hidden; }
.room-meta { margin-top: 6px; display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--sub); }

/* ========== 底部 tabbar ========== */
.tabbar {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; z-index: 40;
  width: 100%; max-width: 480px; display: flex;
  background: rgba(255, 255, 255, .96); backdrop-filter: blur(14px);
  border-top: 1px solid var(--line); padding-bottom: var(--safe-b);
}
.tabbar a {
  flex: 1; height: 56px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; font-size: 11px; color: var(--sub); text-decoration: none; font-weight: 600;
}
.tabbar a .ic { font-size: 20px; line-height: 1; }
.tabbar a.on { color: var(--brand); }
.fab {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 76px; z-index: 41;
  width: 100%; max-width: 480px; display: flex; justify-content: center; pointer-events: none;
}
.fab button {
  pointer-events: auto; height: 44px; padding: 0 22px; border-radius: 22px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); box-shadow: 0 8px 20px rgba(255, 46, 99, .35);
}

/* ========== 空状态 / 加载 ========== */
.empty { padding: 60px 20px; text-align: center; color: var(--sub); }
.empty .em { font-size: 44px; margin-bottom: 10px; }
.spin {
  width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--brand);
  border-radius: 50%; animation: sp .7s linear infinite; margin: 0 auto;
}
@keyframes sp { to { transform: rotate(360deg); } }

/* ========== Toast ========== */
#toast {
  position: fixed; left: 50%; top: 84px; transform: translateX(-50%); z-index: 999;
  display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none;
}
.toast {
  padding: 10px 18px; border-radius: 999px; background: rgba(20, 22, 30, .92); color: #fff;
  font-size: 13px; font-weight: 600; box-shadow: 0 8px 20px rgba(0, 0, 0, .2);
  animation: tin .2s ease;
}
@keyframes tin { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* ========== 直播间（暗色） ========== */
.stage {
  position: relative; max-width: 480px; margin: 0 auto; height: 100vh; height: 100dvh;
  background: #0c0d12; color: #fff; overflow: hidden; display: flex; flex-direction: column;
}
.stage .video-wrap { position: absolute; inset: 0; background: #000; }
.stage video { width: 100%; height: 100%; object-fit: cover; }
.video-fallback {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center;
  background: radial-gradient(120% 80% at 50% 0%, #2a1830, #0c0d12 70%); color: #cfd2dc;
}
.video-fallback .big { font-size: 60px; }
.stage-head {
  position: relative; z-index: 5; display: flex; align-items: center; gap: 10px;
  padding: 14px 14px 10px; background: linear-gradient(rgba(0, 0, 0, .55), transparent);
}
.avatar {
  width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); font-size: 20px;
}
.anchor-name { font-weight: 700; font-size: 15px; }
.follow-btn {
  padding: 5px 14px; border-radius: 999px; font-size: 12px; font-weight: 700;
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff;
}
.viewers-chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 999px;
  background: rgba(255, 255, 255, .16); font-size: 12px; font-weight: 600; backdrop-filter: blur(6px);
}
.icon-btn {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(255, 255, 255, .14); font-size: 15px; backdrop-filter: blur(6px);
}

.stage-mid { position: relative; z-index: 5; flex: 1; display: flex; flex-direction: column; justify-content: flex-end; padding: 0 14px; min-height: 0; }
.notice {
  align-self: flex-start; margin-bottom: 8px; padding: 8px 12px; border-radius: 12px;
  background: rgba(0, 0, 0, .42); font-size: 12.5px; color: #ffe8ee; backdrop-filter: blur(6px);
  animation: tin .25s ease;
}
.chat-list { flex: 1; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; gap: 6px; padding-bottom: 8px; min-height: 0; }
.chat-item { animation: tin .2s ease; max-width: 78%; }
.chat-bubble {
  display: inline-block; padding: 6px 11px; border-radius: 14px; font-size: 13px; line-height: 1.45;
  background: rgba(0, 0, 0, .38); color: #fff; backdrop-filter: blur(4px); word-break: break-word;
}
.chat-bubble .who { color: #ffb3c8; font-weight: 700; margin-right: 4px; }
.chat-item.gift .chat-bubble { background: linear-gradient(135deg, rgba(255, 46, 99, .88), rgba(255, 106, 61, .88)); }
.chat-item.order .chat-bubble { background: linear-gradient(135deg, rgba(18, 184, 134, .85), rgba(38, 166, 154, .85)); }
.chat-item.system .chat-bubble { background: rgba(255, 255, 255, .14); color: #ffd166; }

.stage-foot { position: relative; z-index: 6; padding: 10px 12px calc(12px + var(--safe-b)); display: flex; align-items: center; gap: 8px; }
.chat-input {
  flex: 1; height: 40px; border-radius: 20px; border: none; outline: none; padding: 0 14px;
  background: rgba(255, 255, 255, .14); color: #fff; backdrop-filter: blur(6px);
}
.chat-input::placeholder { color: rgba(255, 255, 255, .5); }
.foot-btn { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-size: 19px; background: rgba(255, 255, 255, .14); position: relative; }
.badge {
  position: absolute; top: -3px; right: -3px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--brand); color: #fff; font-size: 10px; font-weight: 700;
  display: grid; place-items: center;
}

/* 点赞飘心 */
.hearts { position: absolute; right: 16px; bottom: 120px; width: 90px; height: 260px; z-index: 7; pointer-events: none; }
.heart {
  position: absolute; right: 0; bottom: 0; font-size: 22px; opacity: 0;
  animation: floatUp 2.6s cubic-bezier(.2, .6, .3, 1) forwards;
}
@keyframes floatUp {
  0% { opacity: 0; transform: translate(0, 0) scale(.6); }
  12% { opacity: 1; transform: translate(0, -20px) scale(1.1); }
  100% { opacity: 0; transform: translate(var(--dx, -10px), -230px) scale(.9); }
}

/* 礼物特效 */
.gift-fx {
  position: absolute; left: 12px; bottom: 150px; z-index: 8; display: flex; align-items: center; gap: 10px;
  padding: 8px 14px 8px 10px; border-radius: 999px;
  background: linear-gradient(135deg, rgba(255, 46, 99, .95), rgba(255, 140, 60, .95));
  box-shadow: 0 10px 26px rgba(255, 46, 99, .4); animation: fxIn 2.8s ease forwards;
}
.gift-fx .g-em { font-size: 28px; }
.gift-fx .g-tx { font-size: 13px; font-weight: 800; }
.gift-fx .g-sub { font-size: 11px; opacity: .9; }
@keyframes fxIn {
  0% { opacity: 0; transform: translateX(-40px) scale(.8); }
  10% { opacity: 1; transform: translateX(10px) scale(1); }
  80% { opacity: 1; transform: translateX(10px) scale(1); }
  100% { opacity: 0; transform: translateX(10px) scale(.95); }
}
.combo {
  font-size: 26px; font-weight: 900; font-style: italic; color: var(--accent);
  text-shadow: 0 2px 0 #ff2e63, 0 0 18px rgba(255, 209, 102, .7);
}

/* 大额礼物全屏特效 */
.mega {
  position: absolute; inset: 0; z-index: 9; display: grid; place-items: center; text-align: center;
  background: radial-gradient(60% 50% at 50% 50%, rgba(255, 46, 99, .45), rgba(0, 0, 0, .1) 70%, transparent);
  animation: mega 3.2s ease forwards; pointer-events: none;
}
.mega-em { font-size: 96px; animation: megaBounce 1.2s ease-in-out infinite alternate; }
.mega-tx { margin-top: 10px; font-size: 20px; font-weight: 900; color: #fff; text-shadow: 0 2px 12px rgba(255, 46, 99, .9); }
@keyframes mega { 0% { opacity: 0; } 12% { opacity: 1; } 82% { opacity: 1; } 100% { opacity: 0; } }
@keyframes megaBounce { from { transform: translateY(0) scale(1); } to { transform: translateY(-18px) scale(1.12); } }

/* ========== 底部弹层 ========== */
.sheet-mask {
  position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, .5);
  display: flex; align-items: flex-end; justify-content: center; animation: fade .18s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.sheet {
  width: 100%; max-width: 480px; max-height: 74vh; overflow-y: auto;
  background: #fff; color: var(--text); border-radius: 20px 20px 0 0; padding: 16px 16px calc(20px + var(--safe-b));
  animation: up .24s cubic-bezier(.2, .8, .3, 1);
}
@keyframes up { from { transform: translateY(100%); } to { transform: none; } }
.sheet.dark { background: #171922; color: #fff; }
.sheet.dark .muted { color: #9aa0ad; }
.sheet.dark .input { background: #232733; border-color: #2f3542; color: #fff; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.sheet-title { font-size: 16px; font-weight: 800; }

/* 礼物网格 */
.gift-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.gift-cell {
  border: 2px solid transparent; border-radius: 14px; padding: 12px 6px; text-align: center; background: #f6f7fa;
}
.gift-cell.on { border-color: var(--brand); background: #fff2f5; }
.gift-cell .ge { font-size: 30px; }
.gift-cell .gn { font-size: 13px; font-weight: 700; margin-top: 2px; }
.gift-cell .gp { font-size: 11px; color: var(--brand); font-weight: 700; }
.sheet.dark .gift-cell { background: #232733; }
.combo-row { display: flex; gap: 8px; margin: 14px 0; }
.combo-row button { flex: 1; height: 40px; border-radius: 12px; background: #f6f7fa; font-weight: 700; font-size: 14px; }
.combo-row button.on { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; }
.sheet.dark .combo-row button { background: #232733; }

/* 购物车 */
.prod { display: flex; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); align-items: center; }
.sheet.dark .prod { border-color: #2a2f3b; }
.prod-em { width: 54px; height: 54px; border-radius: 12px; display: grid; place-items: center; font-size: 28px; background: #f6f7fa; flex: none; }
.sheet.dark .prod-em { background: #232733; }
.price { color: var(--brand); font-weight: 800; font-size: 16px; }
.price-old { color: var(--sub); text-decoration: line-through; font-size: 12px; margin-left: 4px; }
.stepper { display: flex; align-items: center; gap: 10px; }
.stepper button { width: 26px; height: 26px; border-radius: 50%; background: #f0f2f6; font-weight: 700; }
.sheet.dark .stepper button { background: #2f3542; }

/* 转发 */
.share-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; text-align: center; }
.share-grid button .si { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; font-size: 24px; margin: 0 auto 6px; }
.share-grid button .sl { font-size: 12px; color: var(--sub); }
.qr-box { margin-top: 14px; display: flex; justify-content: center; }

/* ========== 后台 ========== */
.admin-wrap { padding: 14px 16px 40px; }
.kpi-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.kpi { padding: 14px; border-radius: var(--radius); background: #fff; box-shadow: var(--shadow); }
.kpi .kv { font-size: 24px; font-weight: 800; letter-spacing: -.5px; }
.kpi .kl { font-size: 12px; color: var(--sub); margin-top: 2px; }
.kpi .kd { font-size: 11px; margin-top: 6px; color: var(--ok); font-weight: 700; }
.panel { margin-top: 14px; padding: 14px; border-radius: var(--radius); background: #fff; box-shadow: var(--shadow); }
.panel h3 { margin: 0 0 12px; font-size: 15px; font-weight: 800; }
.chart { width: 100%; height: 150px; }
.rank { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.rank .rb { flex: 1; height: 8px; border-radius: 4px; background: #f0f2f6; overflow: hidden; }
.rank .rf { height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--brand), var(--brand-2)); }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th, .tbl td { padding: 9px 6px; text-align: left; border-bottom: 1px solid var(--line); }
.tbl th { color: var(--sub); font-weight: 600; font-size: 12px; }
.tbl td { font-variant-numeric: tabular-nums; }
.seg { display: inline-flex; background: #f0f2f6; border-radius: 10px; padding: 3px; }
.seg button { padding: 6px 12px; border-radius: 8px; font-size: 12px; font-weight: 700; color: var(--sub); }
.seg button.on { background: #fff; color: var(--text); box-shadow: 0 2px 6px rgba(0, 0, 0, .08); }

/* ========== 开播页 ========== */
.host-wrap { padding: 14px 16px 110px; }
.panel-np { padding: 14px; border-radius: var(--radius); background: #fff; box-shadow: var(--shadow); margin-bottom: 14px; }
.panel-np h3 { margin: 0 0 4px; font-size: 15px; font-weight: 800; }
.panel-np .ph { font-size: 12px; color: var(--sub); margin-bottom: 12px; }
.kv-row { display: flex; align-items: center; gap: 8px; padding: 9px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.kv-row:last-child { border-bottom: none; }
.kv-row .kk { color: var(--sub); width: 74px; flex: none; }
.kv-row .vv { flex: 1; word-break: break-all; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }
.copy { flex: none; padding: 4px 10px; border-radius: 8px; background: #fff2f5; color: var(--brand); font-size: 12px; font-weight: 700; }
.steps { counter-reset: s; }
.step { display: flex; gap: 10px; margin-bottom: 10px; font-size: 13px; }
.step .sn { flex: none; width: 20px; height: 20px; border-radius: 50%; background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; font-size: 11px; display: grid; place-items: center; font-weight: 700; }
.emoji-pick { display: flex; gap: 8px; flex-wrap: wrap; }
.emoji-pick button { width: 44px; height: 44px; border-radius: 12px; background: #f6f7fa; font-size: 22px; border: 2px solid transparent; }
.emoji-pick button.on { border-color: var(--brand); background: #fff2f5; }

.banner {
  margin: 12px 16px 0; padding: 10px 14px; border-radius: 12px; font-size: 13px; font-weight: 600;
  background: #fff4e0; color: #a05a00;
}
.banner.err { background: #ffe9ec; color: #b3223c; }
