:root {
  --bg: #0d0e12;
  --bg-2: #15171d;
  --bg-3: #1d2028;
  --bg-4: #272b35;
  --line: #2c303b;
  --text: #eef0f5;
  --text-2: #a4a9b6;
  --text-3: #6f7584;
  --accent: #6d5dfc;
  --accent-2: #8b7dff;
  --green: #2fd17e;
  --gold: #ffc54d;
  --red: #f0444e;
  --radius: 14px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 15px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-2); }
.hidden { display: none !important; }
svg.i { width: 20px; height: 20px; flex: none; }

/* ---------- Buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 18px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg-3); cursor: pointer; font-weight: 600; transition: background .15s, transform .05s;
}
.btn:hover { background: var(--bg-4); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: #1b1400; }
.btn.gold:hover { filter: brightness(1.06); }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.ghost { background: transparent; }
.btn.sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn.block { width: 100%; }

label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 6px; font-weight: 500; }
.input {
  width: 100%; height: 44px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); outline: none; transition: border-color .15s;
}
textarea.input { height: auto; padding: 10px 14px; resize: vertical; }
.input:focus { border-color: var(--accent); }
.muted { color: var(--text-2); }
.small { font-size: 13px; }
.err { color: var(--red); font-size: 13px; min-height: 18px; }

/* ---------- Landing ---------- */
.landing { min-height: 100%; display: flex; flex-direction: column; }
.nav { display: flex; align-items: center; justify-content: space-between; padding: 18px 24px; max-width: 1180px; width: 100%; margin: 0 auto; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 19px; letter-spacing: -.02em; }
.logo-mark { width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg, var(--accent), #b25dfc); display: grid; place-items: center; }
img.logo-mark { background: none; border-radius: 7px; }
.hero { max-width: 1180px; width: 100%; margin: 0 auto; padding: 40px 24px 60px; display: grid; grid-template-columns: 1.1fr 1fr; gap: 56px; align-items: start; }
.hero h1 { font-size: clamp(34px, 5vw, 54px); line-height: 1.05; letter-spacing: -.035em; margin: 10px 0 18px; }
.hero h1 em { font-style: normal; background: linear-gradient(90deg, var(--accent-2), var(--gold)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p.lead { font-size: 18px; color: var(--text-2); max-width: 520px; }
.pill { display: inline-flex; gap: 8px; align-items: center; padding: 6px 12px; border-radius: 99px; background: var(--bg-3); border: 1px solid var(--line); font-size: 13px; color: var(--text-2); }
.features { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-top: 32px; }
.feature { display: flex; gap: 10px; align-items: flex-start; color: var(--text-2); font-size: 14px; }
.feature svg { color: var(--accent-2); margin-top: 1px; }
.feature b { color: var(--text); display: block; font-weight: 600; }
.card { background: var(--bg-2); border: 1px solid var(--line); border-radius: 18px; padding: 24px; }
.tabs { display: flex; gap: 4px; background: var(--bg); padding: 4px; border-radius: 12px; margin-bottom: 20px; }
.tabs button { flex: 1; height: 38px; border: 0; border-radius: 9px; background: transparent; color: var(--text-2); font-weight: 600; cursor: pointer; }
.tabs button.active { background: var(--bg-3); color: var(--text); }
details.more { margin: 4px 0 16px; border: 1px dashed var(--line); border-radius: 12px; padding: 10px 14px; }
details.more summary { cursor: pointer; color: var(--text-2); font-size: 14px; font-weight: 500; }
details.more[open] summary { margin-bottom: 12px; }

/* ---------- Pre-join ---------- */
.prejoin { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.prejoin-inner { width: 100%; max-width: 940px; display: grid; grid-template-columns: 1.4fr 1fr; gap: 28px; align-items: center; }
.preview { position: relative; aspect-ratio: 16/9; background: var(--bg-3); border-radius: var(--radius); overflow: hidden; }
.preview video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.preview .avatar-big { position: absolute; inset: 0; display: grid; place-items: center; }
.preview-controls { position: absolute; bottom: 14px; left: 0; right: 0; display: flex; justify-content: center; gap: 10px; }

/* ---------- Meeting ---------- */
.meeting { height: 100%; display: grid; grid-template-rows: 56px 1fr 76px; grid-template-columns: 1fr auto; grid-template-areas: "top top" "stage side" "bar bar"; }
.topbar { grid-area: top; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 16px; border-bottom: 1px solid var(--line); min-width: 0; }
.topbar .title { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .meta { display: flex; align-items: center; gap: 10px; color: var(--text-2); font-size: 13px; flex: none; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 99px; background: var(--bg-3); border: 1px solid var(--line); font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge.rec { color: #fff; background: var(--red); border-color: var(--red); }
.badge.rec::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #fff; animation: blink 1s infinite; }
.badge.tips { color: var(--gold); cursor: pointer; }
@keyframes blink { 50% { opacity: .2; } }

.stage { grid-area: stage; position: relative; padding: 12px; min-height: 0; min-width: 0; overflow: hidden; }
.grid { height: 100%; display: grid; gap: 10px; align-content: center; }
.speaker { height: 100%; display: grid; grid-template-rows: 1fr 120px; gap: 10px; }
.speaker .main { min-height: 0; display: grid; }
.speaker .strip { display: flex; gap: 10px; overflow-x: auto; }
.speaker .strip .tile { width: 200px; flex: none; }

.tile { position: relative; background: var(--bg-3); border-radius: var(--radius); overflow: hidden; min-height: 0; min-width: 0; outline: 3px solid transparent; outline-offset: -3px; transition: outline-color .2s; }
.grid .tile { aspect-ratio: 16/9; max-height: 100%; justify-self: center; width: 100%; }
.tile.speaking { outline-color: var(--green); }
.tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; }
.tile.self video { transform: scaleX(-1); }
.tile.self.sharing video, .tile.sharing video { object-fit: contain; transform: none; }
.tile.novideo video { opacity: 0; }
.tile .avatar { position: absolute; inset: 0; display: none; place-items: center; }
.tile.novideo .avatar { display: grid; }
.avatar-circle { width: clamp(48px, 22%, 110px); aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: clamp(18px, 3vw, 40px); color: #fff; }
.tile .label { position: absolute; left: 8px; bottom: 8px; display: flex; align-items: center; gap: 6px; padding: 4px 9px; border-radius: 8px; background: rgba(0,0,0,.6); font-size: 13px; font-weight: 500; max-width: calc(100% - 16px); backdrop-filter: blur(6px); }
.tile .label .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .label svg { width: 15px; height: 15px; color: var(--red); }
.tile .hand { position: absolute; top: 8px; left: 8px; font-size: 22px; display: none; animation: wave 1.2s ease-in-out infinite; }
.tile.hand-up .hand { display: block; }
@keyframes wave { 0%,100% { transform: rotate(0); } 50% { transform: rotate(14deg); } }
.tile .pin { position: absolute; top: 8px; right: 8px; width: 32px; height: 32px; border-radius: 8px; background: rgba(0,0,0,.55); border: 0; display: grid; place-items: center; cursor: pointer; opacity: 0; transition: opacity .15s; }
.tile:hover .pin, .tile.pinned .pin { opacity: 1; }
.tile.pinned .pin { background: var(--accent); }
.tile .float-emoji { position: absolute; bottom: 30px; font-size: 38px; pointer-events: none; animation: floatUp 2.4s ease-out forwards; }
@keyframes floatUp { 0% { transform: translateY(0) scale(.6); opacity: 0; } 15% { opacity: 1; transform: translateY(-10px) scale(1.1); } 100% { transform: translateY(-160px) scale(1); opacity: 0; } }

.sidebar { grid-area: side; width: 360px; border-left: 1px solid var(--line); background: var(--bg-2); display: flex; flex-direction: column; min-height: 0; }
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--line); gap: 8px; }
.side-head .tabs { margin: 0; flex: 1; }
.side-head .tabs button { height: 32px; font-size: 13px; }
.icon-btn { width: 36px; height: 36px; border-radius: 9px; border: 0; background: transparent; display: grid; place-items: center; cursor: pointer; color: var(--text-2); }
.icon-btn:hover { background: var(--bg-3); color: var(--text); }
.pane { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.chat-list { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.msg .who { font-size: 12px; color: var(--text-2); margin-bottom: 2px; }
.msg .who b { color: var(--text); font-weight: 600; }
.msg .who .dm { color: var(--accent-2); }
.msg .body { white-space: pre-wrap; word-wrap: break-word; }
.msg.system { font-size: 13px; color: var(--text-2); text-align: center; }
.msg.tipmsg { background: linear-gradient(135deg, rgba(255,197,77,.14), rgba(109,93,252,.12)); border: 1px solid rgba(255,197,77,.35); border-radius: 12px; padding: 10px 12px; }
.msg.tipmsg .amt { color: var(--gold); font-weight: 800; }
.chat-form { border-top: 1px solid var(--line); padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.chat-form select { height: 32px; border-radius: 8px; background: var(--bg); border: 1px solid var(--line); padding: 0 8px; font-size: 13px; }
.chat-form .row { display: flex; gap: 8px; }

.people { flex: 1; overflow-y: auto; padding: 8px; }
.host-tools { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.person { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; }
.person:hover { background: var(--bg-3); }
.person .avatar-circle { width: 34px; font-size: 14px; }
.person .pname { flex: 1; min-width: 0; }
.person .pname div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.person .pname small { color: var(--text-3); }
.person .status { display: flex; gap: 6px; color: var(--text-2); align-items: center; }
.person .status svg { width: 17px; height: 17px; }
.person .status .off { color: var(--red); }
.menu-wrap { position: relative; }
.menu { position: absolute; right: 0; top: 38px; z-index: 20; min-width: 170px; background: var(--bg-3); border: 1px solid var(--line); border-radius: 10px; padding: 4px; box-shadow: 0 12px 30px rgba(0,0,0,.5); }
.menu button { display: block; width: 100%; text-align: left; padding: 8px 10px; border: 0; background: transparent; border-radius: 7px; cursor: pointer; font-size: 14px; }
.menu button:hover { background: var(--bg-4); }
.menu button.danger { color: var(--red); }

.tips-pane { flex: 1; overflow-y: auto; padding: 16px; }
.tip-total { text-align: center; padding: 18px; border-radius: 14px; background: linear-gradient(135deg, rgba(255,197,77,.14), rgba(109,93,252,.14)); border: 1px solid var(--line); margin-bottom: 16px; }
.tip-total .n { font-size: 34px; font-weight: 800; color: var(--gold); letter-spacing: -.02em; }
.tip-section h4 { margin: 18px 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); }
.lb-row, .tip-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.lb-row .rank { width: 22px; color: var(--text-3); font-weight: 700; }
.lb-row .n, .tip-row .n { margin-left: auto; color: var(--gold); font-weight: 700; }
.tip-row .m { color: var(--text-2); font-size: 13px; }

/* ---------- Bottom bar ---------- */
.bar { grid-area: bar; display: flex; align-items: center; justify-content: space-between; padding: 0 16px; border-top: 1px solid var(--line); gap: 8px; }
.bar .group { display: flex; gap: 6px; align-items: center; }
.ctl { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-width: 64px; height: 60px; padding: 0 8px; border: 0; border-radius: 12px; background: transparent; cursor: pointer; color: var(--text); font-size: 11.5px; font-weight: 500; }
.ctl:hover { background: var(--bg-3); }
.ctl.off svg { color: var(--red); }
.ctl.on { color: var(--accent-2); }
.ctl.tipctl { color: var(--gold); }
.ctl .count { position: absolute; top: 4px; right: 10px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--red); color: #fff; font-size: 11px; line-height: 18px; text-align: center; }
.ctl svg.i { width: 22px; height: 22px; }
.reaction-pop { position: absolute; bottom: 70px; left: 50%; transform: translateX(-50%); display: flex; gap: 2px; padding: 6px; border-radius: 12px; background: var(--bg-3); border: 1px solid var(--line); box-shadow: 0 12px 30px rgba(0,0,0,.5); z-index: 30; }
.reaction-pop button { width: 42px; height: 42px; font-size: 24px; border: 0; background: transparent; border-radius: 9px; cursor: pointer; }
.reaction-pop button:hover { background: var(--bg-4); transform: scale(1.12); }

/* ---------- Tip modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.6); backdrop-filter: blur(4px); display: grid; place-items: center; z-index: 100; padding: 16px; }
.modal { width: 100%; max-width: 460px; max-height: calc(100vh - 32px); overflow-y: auto; background: var(--bg-2); border: 1px solid var(--line); border-radius: 18px; padding: 22px; }
.modal h3 { margin: 0 0 2px; font-size: 20px; }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 18px; }
.amounts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 10px; }
.amounts button { height: 48px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg-3); font-weight: 700; font-size: 16px; cursor: pointer; }
.amounts button.active { border-color: var(--gold); background: rgba(255,197,77,.12); color: var(--gold); }
.custom-amt { position: relative; margin-bottom: 14px; }
.custom-amt::before { content: "$"; position: absolute; left: 14px; top: 11px; color: var(--text-2); }
.custom-amt input { padding-left: 28px; }
#express-checkout { min-height: 48px; margin-bottom: 12px; }
.or { display: flex; align-items: center; gap: 10px; color: var(--text-3); font-size: 12px; margin: 14px 0; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.applepay-demo { height: 48px; width: 100%; border-radius: 10px; border: 0; background: #fff; color: #000; font-weight: 600; font-size: 17px; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 4px; }
.demo-note { font-size: 12px; color: var(--gold); background: rgba(255,197,77,.08); border: 1px solid rgba(255,197,77,.3); padding: 8px 10px; border-radius: 9px; margin-bottom: 14px; }
.crypto-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.crypto-opts select { height: 44px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); padding: 0 10px; }
.addr { display: flex; gap: 12px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; }
.addr img { width: 84px; height: 84px; border-radius: 8px; background: #fff; flex: none; }
.addr .info { min-width: 0; flex: 1; }
.addr .coin { font-weight: 700; margin-bottom: 2px; }
.addr code { display: block; font-size: 12px; color: var(--text-2); word-break: break-all; margin-bottom: 6px; }
.status-line { font-size: 13px; margin-top: 10px; min-height: 18px; }
.status-line.ok { color: var(--green); }
.status-line.bad { color: var(--red); }

/* ---------- Tip celebration ---------- */
.tip-toast { position: absolute; top: 18px; left: 50%; transform: translateX(-50%); z-index: 40; display: flex; align-items: center; gap: 12px; padding: 12px 20px 12px 14px; border-radius: 16px; background: linear-gradient(135deg, #2a2210, #1e1838); border: 1px solid var(--gold); box-shadow: 0 0 0 4px rgba(255,197,77,.12), 0 20px 50px rgba(0,0,0,.6); animation: toastIn .5s cubic-bezier(.2,1.4,.4,1), toastOut .4s ease-in 5.6s forwards; max-width: calc(100% - 32px); }
.tip-toast .big { font-size: 34px; }
.tip-toast .t1 { font-weight: 700; }
.tip-toast .t1 .amt { color: var(--gold); }
.tip-toast .t2 { color: var(--text-2); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@keyframes toastIn { from { transform: translate(-50%, -30px) scale(.8); opacity: 0; } }
@keyframes toastOut { to { transform: translate(-50%, -20px); opacity: 0; } }
.coin-rain { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 39; }
.coin-rain span { position: absolute; top: -40px; font-size: 26px; animation: fall 2.6s linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(540deg); } }

.toast { position: fixed; bottom: 92px; left: 50%; transform: translateX(-50%); background: var(--bg-4); border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; z-index: 200; font-size: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.5); animation: toastIn .25s; max-width: calc(100% - 32px); }

.overlay-msg { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 300; text-align: center; padding: 24px; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; gap: 32px; padding-top: 16px; }
  .prejoin-inner { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 56px 0 76px 0; width: auto; z-index: 50; border-left: 0; }
}
@media (max-width: 640px) {
  .features { grid-template-columns: 1fr; }
  .ctl { min-width: 40px; padding: 0 2px; font-size: 0; gap: 0; }
  #btn-leave { width: 44px; padding: 0; }
  #btn-leave .leave-txt { display: none; }
  .ctl .count { right: 2px; }
  .bar { padding: 0 6px; }
  .bar .group { gap: 0; }
  .hide-sm { display: none !important; }
  .topbar .meta .badge:not(.tips):not(.rec) { display: none; }
  .speaker .strip .tile { width: 130px; }
  .speaker { grid-template-rows: 1fr 90px; }
  .amounts { grid-template-columns: repeat(2, 1fr); }
  .crypto-opts { grid-template-columns: 1fr; }
}
