/* MPLive — mobile-first, Bigo-style. Desktop gets a centered phone-width column until the web layout ships. */
:root {
  --bg: #0b1624;
  --bg2: #12233a;
  --card: #16283f;
  --accent: #00ebd2;
  --accent2: #5ddbff;
  --grad: linear-gradient(90deg, #00ebd2, #5ddbff);
  --text: #fff;
  --muted: #8aa0b8;
  --danger: #ff4d6d;
  --glass: rgba(10, 18, 30, .42);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: 'Nunito', ui-rounded, 'SF Pro Rounded', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body { background: #05080d; color: var(--text); font-family: var(--font); overscroll-behavior: none; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
i[data-icon], i.ic { display: inline-flex; line-height: 0; }
.av-fallback { display: grid; place-items: center; color: #fff; font-weight: 800; }
.toast { position: fixed; left: 50%; bottom: calc(130px + var(--safe-b)); transform: translate(-50%, 10px); background: rgba(0, 0, 0, .82); color: #fff; padding: 10px 16px; border-radius: 999px; font-size: 14px; opacity: 0; pointer-events: none; transition: .2s; z-index: 99; max-width: 86vw; text-align: center; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, .2); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ================= Discover ================= */
.app { max-width: 480px; margin: 0 auto; min-height: 100dvh; background: var(--bg); position: relative; padding-bottom: calc(76px + var(--safe-b)); }
.hdr { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; padding: calc(var(--safe-t) + 10px) 16px 6px; background: linear-gradient(var(--bg) 70%, transparent); }
.tabs { display: flex; gap: 22px; }
.tabs button { background: none; border: 0; padding: 6px 0; font-size: 19px; font-weight: 800; color: var(--muted); position: relative; }
.tabs button.on { color: #fff; }
.tabs button.on::after { content: ''; position: absolute; left: 50%; bottom: -2px; width: 18px; height: 4px; margin-left: -9px; border-radius: 2px; background: var(--grad); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 8px 16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 0; padding: 7px 15px; border-radius: 999px; background: rgba(255, 255, 255, .09); font-size: 14px; color: #cfdbe8; }
.chip.on { background: var(--grad); color: #03323a; font-weight: 800; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 6px 12px; }
.tile { position: relative; display: block; aspect-ratio: 3 / 4; border-radius: 14px; overflow: hidden; background: var(--card); }
.tile img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.tile .ph { position: absolute; inset: 0; display: grid; place-items: center; font-size: 44px; font-weight: 800; color: rgba(255, 255, 255, .85); }
.tile .shade { position: absolute; inset: 0; background: linear-gradient(transparent 52%, rgba(0, 0, 0, .78)); }
.badge { position: absolute; top: 8px; display: flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; background: rgba(0, 0, 0, .42); font-size: 12px; font-weight: 700; backdrop-filter: blur(6px); }
.badge.l { left: 8px; }
.badge.r { right: 8px; }
.bars { display: inline-flex; align-items: flex-end; gap: 2px; height: 11px; }
.bars span { width: 3px; background: var(--accent); border-radius: 2px; animation: eq 1s ease-in-out infinite; }
.bars span:nth-child(1) { height: 5px; }
.bars span:nth-child(2) { height: 11px; animation-delay: .2s; }
.bars span:nth-child(3) { height: 7px; animation-delay: .4s; }
@keyframes eq { 50% { transform: scaleY(.45); } }
.tile .meta { position: absolute; left: 10px; right: 10px; bottom: 9px; }
.tile .meta b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .meta small { display: block; font-size: 12px; color: rgba(255, 255, 255, .75); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .tag { position: absolute; right: 8px; bottom: 44px; font-size: 11px; padding: 2px 8px; border-radius: 999px; background: rgba(0, 0, 0, .4); }
.state { grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 70px 20px; line-height: 1.6; }
.state a { color: var(--accent); font-weight: 700; }
.state .spinner { margin: 0 auto 14px; }
.tabbar { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: min(100%, 480px); height: calc(62px + var(--safe-b)); padding-bottom: var(--safe-b); display: flex; justify-content: space-around; align-items: center; background: rgba(11, 22, 36, .94); backdrop-filter: blur(14px); border-top: 1px solid rgba(255, 255, 255, .06); z-index: 6; }
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; color: var(--muted); min-width: 64px; }
.tabbar a.on { color: var(--accent); }
.tabbar .fab { width: 58px; height: 58px; margin-top: -24px; border-radius: 50%; background: var(--grad); color: #03323a; justify-content: center; box-shadow: 0 6px 22px rgba(0, 235, 210, .4); }

/* ================= Full-screen pages (studio + room) ================= */
.screen { position: relative; width: 100%; max-width: 480px; height: 100dvh; margin: 0 auto; overflow: hidden; background: #000; }
@media (min-width: 700px) { .screen { margin-top: calc((100dvh - min(100dvh, 900px)) / 2); height: min(100dvh, 900px); border-radius: 22px; box-shadow: 0 0 0 1px rgba(255, 255, 255, .08), 0 30px 80px rgba(0, 0, 0, .6); } }
.screen video, .screen canvas { display: block; }
.mirror { transform: scaleX(-1); }
.fit-contain { object-fit: contain !important; background: #000; }
.close-btn, .x, .round { border: 0; color: #fff; display: grid; place-items: center; background: rgba(0, 0, 0, .35); backdrop-filter: blur(8px); }
.close-btn, .x { width: 34px; height: 34px; border-radius: 50%; }
.round { width: 42px; height: 42px; border-radius: 50%; position: relative; flex: none; }
.round.sm { width: 32px; height: 32px; }
.round.off { background: rgba(255, 77, 109, .75); }
.round.heart { background: linear-gradient(135deg, #ff7aa5, #ff3d77); }
.backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .45); opacity: 0; pointer-events: none; transition: .2s; z-index: 10; }
.backdrop.on { opacity: 1; pointer-events: auto; }
.sheet { position: absolute; left: 0; right: 0; bottom: var(--kb, 0px); z-index: 11; background: #14233a; color: #fff; border-radius: 22px 22px 0 0; padding: 20px 18px calc(22px + var(--safe-b)); transform: translateY(110%); transition: transform .25s ease; max-height: 80%; overflow: auto; }
.sheet.open { transform: none; }
.sheet h3 { margin: 0 0 14px; font-size: 18px; }
.sheet.light { background: #fff; color: #1c2430; padding-top: 14px; }
.btn { display: block; width: 100%; border: 0; border-radius: 26px; padding: 14px; font-size: 17px; font-weight: 800; background: var(--grad); color: #03323a; }
.btn.ghost { background: rgba(255, 255, 255, .1); color: #fff; margin-top: 10px; }
.btn.danger { background: var(--danger); color: #fff; }

/* ================= Studio ================= */
.page-studio .cam { position: absolute; inset: 0; background: #111; }
.cam video, .cam canvas { width: 100%; height: 100%; object-fit: cover; }
.veil { position: absolute; inset: 0; pointer-events: none; background: linear-gradient(rgba(0, 0, 0, .35), transparent 30%, transparent 55%, rgba(0, 0, 0, .55)); }
.close-btn { position: absolute; top: calc(var(--safe-t) + 12px); right: 14px; z-index: 3; }
.top-card { position: absolute; z-index: 2; left: 14px; right: 14px; top: calc(var(--safe-t) + 56px); padding: 14px; border-radius: 22px; background: rgba(18, 22, 34, .5); backdrop-filter: blur(16px); }
.top-card .row { display: flex; gap: 14px; align-items: flex-start; }
.cover { flex: none; position: relative; width: 84px; height: 84px; padding: 0; border: 0; border-radius: 14px; overflow: hidden; background: var(--card); }
.cover .cover-ic { position: absolute; left: 0; right: 0; top: 24px; justify-content: center; color: rgba(255, 255, 255, .6); }
.cover img { position: relative; width: 100%; height: 100%; object-fit: cover; display: block; }
.cover span { position: absolute; left: 0; right: 0; bottom: 0; padding: 4px 0; text-align: center; font-size: 11px; background: rgba(0, 0, 0, .5); }
.title-input { flex: 1; min-width: 0; background: none; border: 0; outline: 0; color: #fff; font: 800 20px/1.3 var(--font); padding: 4px 0; caret-color: var(--accent); }
.title-input::placeholder { color: rgba(255, 255, 255, .6); font-weight: 600; }
.tags { display: flex; gap: 8px; margin-top: 12px; overflow-x: auto; scrollbar-width: none; }
.tags::-webkit-scrollbar { display: none; }
.tags .tag { flex: none; border: 0; padding: 7px 13px; border-radius: 999px; background: rgba(255, 255, 255, .16); font-size: 14px; }
.tags .tag.on { background: var(--grad); color: #03323a; font-weight: 800; }
.notify { display: flex; align-items: center; gap: 10px; margin-top: 12px; font-size: 14px; color: #e6f0f8; }
.notify input { width: 20px; height: 20px; accent-color: var(--accent); }
.tools { position: absolute; z-index: 2; left: 0; right: 0; bottom: calc(var(--safe-b) + 140px); display: flex; justify-content: space-around; padding: 0 20px; }
.tool { background: none; border: 0; display: flex; flex-direction: column; align-items: center; gap: 5px; font-size: 12px; color: #fff; text-shadow: 0 1px 4px rgba(0, 0, 0, .5); min-width: 60px; }
.tool.off { color: #ff8da1; }
.go-btn { position: absolute; z-index: 2; left: 24px; right: 24px; bottom: calc(var(--safe-b) + 66px); height: 52px; border: 0; border-radius: 26px; background: var(--grad); color: #03323a; font-size: 20px; font-weight: 800; box-shadow: 0 8px 26px rgba(0, 235, 210, .35); }
.go-btn:disabled { opacity: .6; }
.modes { position: absolute; z-index: 2; left: 0; right: 0; bottom: calc(var(--safe-b) + 14px); display: flex; justify-content: center; align-items: flex-start; gap: 18px; padding: 0 8px; }
.modes button { background: none; border: 0; padding: 4px 0; font-size: 14px; white-space: nowrap; color: rgba(255, 255, 255, .65); text-shadow: 0 1px 4px rgba(0, 0, 0, .5); }
.modes button.on { color: #fff; font-size: 19px; font-weight: 800; }
.modes button.on::after { content: ''; display: block; width: 6px; height: 6px; margin: 5px auto 0; border-radius: 50%; background: #fff; }
.perm { position: absolute; inset: 0; z-index: 20; background: rgba(5, 10, 18, .94); display: grid; place-content: center; text-align: center; padding: 30px; gap: 16px; }
.perm p { margin: 0; color: #cfdbe8; line-height: 1.5; }
.slider { margin: 0 0 18px; }
.slider label { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 8px; color: #cfdbe8; }
input[type=range] { width: 100%; accent-color: var(--accent); }

/* ================= Room ================= */
.stage { position: absolute; inset: 0; background: #070d16; }
.stage video, .stage canvas { width: 100%; height: 100%; object-fit: cover; }
.connecting { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 14px; color: #9fb4c9; text-align: center; padding: 30px; line-height: 1.5; }
.connecting a { color: var(--accent); font-weight: 700; }
.shade-top, .shade-bot { position: absolute; left: 0; right: 0; pointer-events: none; }
.shade-top { top: 0; height: 130px; background: linear-gradient(rgba(0, 0, 0, .5), transparent); }
.shade-bot { bottom: 0; height: 320px; background: linear-gradient(transparent, rgba(0, 0, 0, .6)); }
.top { position: absolute; z-index: 3; left: 10px; right: 10px; top: calc(var(--safe-t) + 10px); display: flex; align-items: center; gap: 8px; }
.host-pill { display: flex; align-items: center; gap: 8px; min-width: 0; max-width: 54%; padding: 3px 14px 3px 3px; border-radius: 999px; background: var(--glass); backdrop-filter: blur(8px); }
.host-pill .ha { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; flex: none; font-size: 13px; }
.host-pill div { min-width: 0; }
.host-pill b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.host-pill small { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--accent); }
.viewers-row { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.v-avs { display: flex; flex-direction: row-reverse; }
.v-avs .va { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; border: 2px solid rgba(0, 0, 0, .35); margin-left: -8px; font-size: 11px; }
.count { display: flex; align-items: center; gap: 4px; height: 30px; padding: 0 10px; border: 0; border-radius: 15px; background: var(--glass); color: #fff; font-size: 12px; font-weight: 700; }
.info-row { position: absolute; z-index: 3; left: 10px; right: 10px; top: calc(var(--safe-t) + 58px); display: flex; align-items: center; gap: 8px; }
.info-row .tchip { min-width: 0; padding: 6px 12px; border-radius: 999px; background: var(--glass); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.info-row .round { margin-left: auto; }
.chat { position: absolute; z-index: 3; left: 10px; bottom: calc(var(--safe-b) + 70px); width: 78%; max-height: 38%; overflow-y: auto; scrollbar-width: none; -webkit-mask-image: linear-gradient(transparent, #000 28px); mask-image: linear-gradient(transparent, #000 28px); }
.chat::-webkit-scrollbar { display: none; }
.line { display: block; }
.msg { display: inline-block; max-width: 100%; margin: 3px 0; padding: 6px 12px; border-radius: 16px; background: var(--glass); font-size: 14px; line-height: 1.4; word-break: break-word; }
.msg b { color: #7fe9ff; margin-right: 6px; font-weight: 700; }
.msg .host-tag { display: inline-block; margin-right: 6px; padding: 0 7px; border-radius: 8px; background: #ff8a1f; font-size: 11px; font-weight: 800; line-height: 18px; }
.msg.sys { color: rgba(255, 255, 255, .85); }
.msg.sys.welcome { color: var(--accent2); }
.msg.join b { color: #ffd36b; }
.bar { position: absolute; z-index: 4; left: 10px; right: 10px; bottom: calc(var(--safe-b) + 12px); display: flex; align-items: center; gap: 9px; }
.say { flex: 1; min-width: 0; height: 42px; padding: 0 16px; border: 0; border-radius: 21px; background: rgba(0, 0, 0, .4); color: rgba(255, 255, 255, .8); text-align: left; font-size: 14px; backdrop-filter: blur(8px); }
body:not(.host) .host-only, body.host .viewer-only { display: none !important; }
.hearts { position: absolute; z-index: 3; right: 8px; bottom: calc(var(--safe-b) + 66px); width: 90px; height: 320px; pointer-events: none; }
.heart-fly { position: absolute; bottom: 0; right: 24px; color: #ff4f86; animation: floatUp 2.2s ease-out forwards; }
@keyframes floatUp { 0% { transform: translate(0, 0) scale(.5); opacity: 1; } 100% { transform: translate(var(--dx), -280px) scale(1.25); opacity: 0; } }
.unmute { position: absolute; z-index: 6; top: 50%; left: 50%; transform: translate(-50%, -50%); padding: 12px 20px; border-radius: 999px; background: rgba(0, 0, 0, .7); font-weight: 700; }
.chat-form { display: flex; gap: 10px; align-items: center; }
.chat-form input { flex: 1; min-width: 0; height: 44px; padding: 0 16px; border: 0; border-radius: 22px; background: #eef1f5; font: 16px var(--font); color: #1c2430; outline: 0; }
.chat-form button { flex: none; width: 44px; height: 44px; border: 0; border-radius: 50%; background: var(--grad); color: #03323a; display: grid; place-items: center; }
.emojis { display: flex; justify-content: space-between; padding: 12px 4px 0; }
.emojis button { background: none; border: 0; font-size: 28px; padding: 4px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px 8px; text-align: center; }
.stats b { display: block; font-size: 22px; }
.stats span { font-size: 12px; color: var(--muted); }
.ended { position: absolute; inset: 0; z-index: 20; display: grid; place-content: center; justify-items: center; gap: 12px; text-align: center; padding: 30px; background: rgba(5, 10, 18, .94); backdrop-filter: blur(14px); }
.ended[hidden], .unmute[hidden], .connecting[hidden], .perm[hidden] { display: none; }
.ended .big { width: 92px; height: 92px; border-radius: 50%; object-fit: cover; font-size: 30px; border: 3px solid var(--accent); }
.ended h2 { margin: 6px 0 0; font-size: 24px; }
.ended p { margin: 0; color: var(--muted); }
.ended .stats { width: 100%; margin: 18px 0 10px; }
.ended .btn { max-width: 280px; }
