:root {
  --bg: #f3f6f4;
  --surface: #ffffff;
  --ink: #14201a;
  --muted: #6b7c72;
  --accent: #0f8f6a;
  --accent-dark: #0a6b50;
  --danger: #d64545;
  --line: #e2ebe6;
  --tab-h: 56px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: "DIN Alternate", "Avenir Next", "PingFang SC", "Microsoft YaHei", sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink); font-family: var(--font); }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
.page { min-height: 100vh; padding-bottom: calc(var(--tab-h) + var(--safe-b) + 12px); }
.page-head {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 10px; background: linear-gradient(180deg, #e8f5ef 0%, var(--bg) 100%);
}
.page-head h1 { margin: 0; font-size: 22px; letter-spacing: 0.02em; }
.page-head .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }

/* App 顶部导航（带返回） */
.app-nav {
  position: sticky;
  top: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  min-height: 48px;
  padding: calc(8px + env(safe-area-inset-top, 0px)) 8px 8px;
  background: rgba(243, 246, 244, .92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid transparent;
}
.app-nav .nav-back {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--ink);
}
.app-nav .nav-back:active { background: rgba(15, 143, 106, .08); }
.app-nav .nav-back .chevron {
  display: block;
  width: 10px;
  height: 10px;
  border-left: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
  transform: rotate(45deg);
  margin-left: 4px;
}
.app-nav .nav-title {
  text-align: center;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.app-nav .nav-right { width: 40px; height: 40px; }

.live-tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  height: calc(var(--tab-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  display: flex; background: rgba(255,255,255,.96);
  border-top: 1px solid var(--line); backdrop-filter: blur(8px);
}
.live-tabbar .tab-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--muted); font-size: 11px; gap: 2px;
}
.live-tabbar .tab-item .ico {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.live-tabbar .tab-item .ico svg {
  width: 22px;
  height: 22px;
  display: block;
}
.live-tabbar .tab-item.active { color: var(--accent); font-weight: 600; }
.live-tabbar .tab-item.active .ico svg { filter: drop-shadow(0 1px 0 rgba(15,143,106,.15)); }

.room-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 0 12px 12px; }
.room-card {
  background: var(--surface); border-radius: 14px; overflow: hidden;
  border: 1px solid var(--line);
  transform: translateY(8px); opacity: 0;
  animation: rise .45s ease forwards;
}
.room-card:nth-child(2) { animation-delay: .05s; }
.room-card:nth-child(3) { animation-delay: .1s; }
.room-card:nth-child(4) { animation-delay: .15s; }
@keyframes rise { to { transform: none; opacity: 1; } }
.room-cover {
  position: relative; aspect-ratio: 3/4; background:
    radial-gradient(circle at 30% 20%, #1f9d76 0%, transparent 45%),
    linear-gradient(160deg, #12352b, #0b1c17);
}
.room-cover img { width: 100%; height: 100%; object-fit: cover; }
.room-cover .live-badge {
  position: absolute; left: 8px; top: 8px;
  background: rgba(15,143,106,.92); color: #fff; font-size: 11px;
  padding: 3px 8px; border-radius: 999px;
}
.room-cover .viewers {
  position: absolute; right: 8px; bottom: 8px; color: #fff; font-size: 11px;
  background: rgba(0,0,0,.35); padding: 2px 6px; border-radius: 6px;
}
.room-meta { padding: 10px; }
.room-meta .title { font-size: 14px; font-weight: 600; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.room-meta .anchor { margin-top: 6px; color: var(--muted); font-size: 12px; }

.empty {
  margin: 40px 20px; text-align: center; color: var(--muted); padding: 36px 16px;
  background: var(--surface); border-radius: 16px; border: 1px dashed var(--line);
}

.panel { margin: 12px; background: var(--surface); border-radius: 16px; border: 1px solid var(--line); overflow: hidden; }
.menu-list a, .menu-list .row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px; border-bottom: 1px solid var(--line); font-size: 15px;
}
.menu-list a:last-child, .menu-list .row:last-child { border-bottom: none; }
.menu-list .arrow { color: #a9b8af; }

.profile-card {
  margin: 12px; padding: 18px; border-radius: 18px; color: #fff;
  background: linear-gradient(135deg, #0f8f6a 0%, #146b8a 100%);
  display: flex; gap: 14px; align-items: center;
  box-shadow: 0 10px 30px rgba(15,143,106,.25);
}
.profile-card .av {
  width: 58px; height: 58px; border-radius: 50%; background: rgba(255,255,255,.2);
  overflow: hidden; flex-shrink: 0;
}
.profile-card .av img { width: 100%; height: 100%; object-fit: cover; }
.profile-card .name { font-size: 18px; font-weight: 700; }
.profile-card .meta { opacity: .85; font-size: 12px; margin-top: 4px; }

.form-box { padding: 16px; }
.form-box label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 6px; }
.form-box input, .form-box textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
  font-size: 15px; outline: none; background: #fff; font-family: inherit;
}
.form-box input:focus, .form-box textarea:focus { border-color: var(--accent); }
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 100%; border: 0; border-radius: 12px; padding: 13px 16px;
  background: var(--accent); color: #fff; font-size: 16px; font-weight: 600; cursor: pointer;
}
.btn:active { background: var(--accent-dark); }
.btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.btn + .btn { margin-top: 10px; }
.sms-row { display: flex; gap: 8px; }
.sms-row input { flex: 1; }
.sms-row button { width: auto; white-space:nowrap; padding: 0 14px; font-size: 13px; }

.avatar-edit {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 0 4px;
}
.avatar-pick {
  position: relative;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  overflow: hidden;
  cursor: pointer;
  background: #e8f5ef;
  border: 3px solid #fff;
  box-shadow: 0 4px 14px rgba(15, 143, 106, .18);
}
.avatar-pick img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.avatar-pick .avatar-mask {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,.45);
  color: #fff;
  font-size: 12px;
}
.avatar-pick.uploading { opacity: .6; pointer-events: none; }
.avatar-tip {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}

.upload-row { margin: 8px 0 4px; }
.upload-hint { margin-top: 8px; font-size: 12px; color: var(--muted); }
.cover-pick {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 14px;
  overflow: hidden;
  cursor: pointer;
  background: linear-gradient(160deg, #12352b, #0b1c17);
  border: 1px solid var(--line);
}
.cover-pick img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.cover-pick .cover-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,.75);
  font-size: 14px;
}
.cover-pick .cover-mask {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,.45);
  color: #fff;
  font-size: 12px;
}
.cover-pick.uploading { opacity: .6; pointer-events: none; }

.status-pill {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px;
  background: #e8f5ef; color: var(--accent);
}
.status-pill.warn { background: #fff4e5; color: #c47a00; }
.status-pill.danger { background: #fdecec; color: var(--danger); }

/* 直播间 */
body.room-page { background: #0b1210; color: #fff; }
.room-page .page { padding-bottom: 0; min-height: 100vh; }
.player-wrap {
  position: relative; width: 100%; height: 100vh; background: #000; overflow: hidden;
}
.player-wrap video, .player-wrap #live-player {
  width: 100%; height: 100%; object-fit: contain; background: #000;
  /* 禁止系统长按/点击唤起原生控件 */
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  pointer-events: none;
}
.player-mask {
  position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(180deg, rgba(0,0,0,.45) 0%, transparent 28%, transparent 60%, rgba(0,0,0,.55) 100%);
}
.unmute-btn {
  position: absolute; left: 50%; bottom: 28%; z-index: 8;
  transform: translateX(-50%);
  border: 0; border-radius: 999px;
  padding: 8px 14px;
  background: rgba(0,0,0,.55);
  color: #fff; font-size: 13px; font-weight: 600;
  backdrop-filter: blur(6px);
  cursor: pointer;
  pointer-events: auto;
}
.unmute-btn.hidden { display: none; }
.play-gate {
  position: absolute; inset: 0; z-index: 9;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; border: 0; background: rgba(0,0,0,.45);
  color: #fff; cursor: pointer; pointer-events: auto;
}
.play-gate.hidden { display: none; }
.play-gate-icon {
  width: 64px; height: 64px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.92); color: #111;
  font-size: 22px; padding-left: 4px;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
}
.play-gate-text { font-size: 14px; font-weight: 600; letter-spacing: .04em; }
.room-top {
  position: absolute; left: 0; right: 0; top: 0; z-index: 5;
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 12px 12px 0; pointer-events: none;
}
.room-top .back, .room-top .like-btn { pointer-events: auto; }
.anchor-chip {
  display: flex; align-items: center; gap: 8px; background: rgba(0,0,0,.35);
  padding: 6px 10px 6px 6px; border-radius: 999px; max-width: 70%;
}
.anchor-chip img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; background: #333; }
.anchor-chip .t { font-size: 13px; font-weight: 600; }
.anchor-chip .s { font-size: 11px; opacity: .8; }
.back {
  width: 34px; height: 34px; border-radius: 50%; border: 0; background: rgba(0,0,0,.4);
  color: #fff; font-size: 18px; cursor: pointer;
}
.chat-layer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  height: 35%;
  display: flex; flex-direction: column; justify-content: flex-end;
  padding: 0 10px calc(62px + var(--safe-b));
  pointer-events: none; box-sizing: border-box;
}
.chat-list {
  max-height: 100%; overflow-y: auto; pointer-events: auto;
  display: flex; flex-direction: column; align-items: flex-start;
  mask-image: linear-gradient(180deg, transparent, #000 18%);
}
.chat-item {
  display: flex; align-items: flex-start; gap: 8px;
  width: auto; max-width: 88%; margin: 5px 0; padding: 6px 10px 6px 6px;
  border-radius: 14px; background: rgba(0,0,0,.38); color: #fff;
  font-size: 13px; line-height: 1.35; animation: fadein .25s ease;
  box-sizing: border-box;
}
.chat-item .av {
  flex: 0 0 28px; width: 28px; height: 28px; border-radius: 50%;
  object-fit: cover; background: rgba(255,255,255,.15);
}
.chat-item .body { min-width: 0; flex: 1; padding-top: 2px; }
.chat-item .n {
  display: block; color: #8fe0c4; font-size: 11px; font-weight: 600;
  margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-item .c {
  display: block; color: #fff; word-break: break-word; white-space: pre-wrap;
}
.chat-item.gift { background: rgba(15,143,106,.42); }
.chat-item.gift .n { color: #ffe08a; }
.chat-item.system {
  max-width: 92%; padding: 5px 10px;
  background: rgba(255,255,255,.12); color: #d7e6df; font-size: 12px;
  align-items: center;
}
.chat-item.system .av { display: none; }
.chat-item.system .n { display: none; }
.chat-item.system .c { color: #d7e6df; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px);} to { opacity:1; transform:none;} }

.room-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; gap: 8px; align-items: center;
  padding: 10px 12px calc(10px + var(--safe-b));
  background: linear-gradient(180deg, transparent, rgba(0,0,0,.75));
}
.room-bar input {
  flex: 1; border: 0; border-radius: 999px; padding: 11px 14px;
  background: rgba(255,255,255,.14); color: #fff; outline: none;
}
.room-bar input::placeholder { color: rgba(255,255,255,.55); }
.room-bar .icon-btn {
  width: 42px; height: 42px; border-radius: 50%; border: 0;
  background: rgba(255,255,255,.14); color: #fff; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: transform .15s ease, background .15s ease;
}
.room-bar .icon-btn:active { transform: scale(.9); }
.room-bar .icon-btn svg { display: block; }
.room-bar .gift-btn {
  background: linear-gradient(145deg, #ff8a4c, #ff5c8a);
  color: #fff;
  box-shadow: 0 4px 12px rgba(255, 92, 138, .35);
}

.gift-sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: #15201b; border-radius: 18px 18px 0 0; padding: 14px 12px calc(14px + var(--safe-b));
  transform: translateY(110%); transition: transform .28s ease;
}
.gift-sheet.show { transform: none; }
.gift-sheet h3 { margin: 0 0 12px; font-size: 15px; font-weight: 600; }
.gift-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.gift-item {
  text-align: center; padding: 10px 4px; border-radius: 12px; border: 1px solid transparent;
  background: rgba(255,255,255,.06); cursor: pointer;
}
.gift-item.active { border-color: var(--accent); background: rgba(15,143,106,.2); }
.gift-item .emoji { font-size: 28px; line-height: 1.2; }
.gift-item .name { font-size: 12px; margin-top: 4px; }
.gift-item .price { font-size: 11px; color: #8fe0c4; margin-top: 2px; }
.gift-actions { display: flex; gap: 8px; margin-top: 12px; align-items: center; }
.gift-actions .money { flex: 1; color: #a9b8af; font-size: 13px; }
.gift-actions .btn { width: auto; padding: 10px 22px; }

.toast {
  position: fixed; left: 50%; top: 16%; transform: translate(-50%, -8px);
  max-width: 80%;
  background: rgba(20, 32, 26, .9); color: #fff;
  padding: 11px 16px; border-radius: 12px;
  font-size: 14px; line-height: 1.4; z-index: 120;
  opacity: 0; pointer-events: none;
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* App 确认弹层 */
.live-dialog-mask {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(10, 18, 14, .36);
  backdrop-filter: blur(4px);
  opacity: 0; visibility: hidden;
  transition: .2s;
}
.live-dialog-mask.show { opacity: 1; visibility: visible; }
.live-dialog {
  position: fixed; left: 50%; top: 50%; z-index: 101;
  width: calc(100% - 48px); max-width: 320px;
  transform: translate(-50%, -46%) scale(.96);
  opacity: 0; visibility: hidden;
  transition: .22s cubic-bezier(.22,.9,.3,1);
  padding: 0;
  pointer-events: none;
}
.live-dialog.show {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1; visibility: visible;
  pointer-events: auto;
}
.live-dialog .panel {
  margin: 0;
  background: #fff;
  border-radius: 20px;
  padding: 22px 18px 14px;
  border: none;
  box-shadow: 0 16px 40px rgba(0,0,0,.12);
}
.live-dialog .d-title {
  text-align: center;
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 6px;
}
.live-dialog .d-desc {
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 18px;
}
.live-dialog .d-actions {
  display: flex;
  gap: 10px;
}
.live-dialog .d-actions .btn {
  margin: 0;
  height: 44px;
  padding: 0 12px;
  font-size: 15px;
}
.live-dialog .d-actions .btn.ghost {
  background: #f3f6f4;
  color: #334;
  border: none;
}
.live-dialog .d-actions .btn.danger {
  background: #d64545;
}

@media (min-width: 768px) {
  body { max-width: 480px; margin: 0 auto; box-shadow: 0 0 40px rgba(0,0,0,.08); }
  .live-tabbar, .room-bar, .gift-sheet, .chat-layer { max-width: 480px; left: 50%; transform: translateX(-50%); }
  .gift-sheet { transform: translate(-50%, 110%); }
  .gift-sheet.show { transform: translate(-50%, 0); }
}
