:root {
  --live: #ff2e4d;
  --ring-a: #00d2ff;
  --ring-b: #7b5cff;
  --ring-c: #ff4fd8;
  --glass: rgba(20, 20, 24, 0.42);
  --text-shadow: 0 1px 2px rgba(0, 0, 0, .55);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #000; overflow: hidden; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: #fff;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
[hidden] { display: none !important; }

/* Desktop: fundo desfocado com a foto do expert */
.backdrop {
  position: fixed; inset: -40px;
  background: #0b0b0f center/cover no-repeat;
  filter: blur(40px) brightness(.45) saturate(1.2);
  transform: scale(1.1);
}

.stage {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  background: #000;
}
@media (min-width: 700px) {
  .stage {
    width: min(calc(100dvh * 9 / 16), 480px);
    height: min(100dvh, 853px);
    top: 50%; transform: translateY(-50%);
    border-radius: 18px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, .6);
  }
}

video {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  background: #000;
}

.shade { position: absolute; left: 0; right: 0; pointer-events: none; }
.shade-top { top: 0; height: 140px; background: linear-gradient(rgba(0,0,0,.55), transparent); }
.shade-bottom { bottom: 0; height: 55%; background: linear-gradient(transparent, rgba(0,0,0,.65)); }

/* ---------- Topo ---------- */
.top {
  position: absolute; top: 0; left: 0; right: 0;
  padding: calc(14px + var(--safe-top)) 12px 0 12px;
  display: flex; align-items: center; gap: 8px;
  z-index: 5;
}
.host { display: flex; align-items: center; gap: 9px; min-width: 0; flex: 1; }
.ring {
  width: 38px; height: 38px; border-radius: 50%; padding: 2px; flex: none;
  background: conic-gradient(from 210deg, var(--ring-a), var(--ring-b), var(--ring-c), var(--ring-a));
}
.ring img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; border: 2px solid #000; display: block; background: #222; }
.host-text { min-width: 0; text-shadow: var(--text-shadow); }
.handle { display: flex; align-items: center; gap: 4px; font-weight: 700; font-size: 14px; line-height: 1.15; }
.handle span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.verified { width: 15px; height: 15px; color: #3d8bff; flex: none; }
.host-name { font-size: 12px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.badges { display: flex; align-items: center; gap: 6px; flex: none; }
.badge-live {
  background: var(--live);
  font-size: 11px; font-weight: 800; letter-spacing: .4px;
  padding: 4px 7px; border-radius: 5px;
  box-shadow: 0 0 0 0 rgba(255, 46, 77, .6);
  animation: livePulse 2s infinite;
}
@keyframes livePulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 46, 77, .55); }
  70% { box-shadow: 0 0 0 7px rgba(255, 46, 77, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 46, 77, 0); }
}
.badge-viewers {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--glass); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  font-size: 12px; font-weight: 700; padding: 4px 8px; border-radius: 5px;
  font-variant-numeric: tabular-nums;
}
.badge-viewers svg { width: 14px; height: 14px; }

.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; flex: none; }
.icon-btn svg { width: 24px; height: 24px; filter: drop-shadow(0 1px 2px rgba(0,0,0,.5)); }
.close svg { width: 22px; height: 22px; }

/* ---------- Som / status ---------- */
.unmute {
  position: absolute; top: calc(70px + var(--safe-top)); left: 50%; transform: translateX(-50%);
  z-index: 6; display: inline-flex; align-items: center; gap: 8px;
  background: rgba(0, 0, 0, .55); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  padding: 9px 14px; border-radius: 999px; font-size: 13px; font-weight: 600;
  animation: fadeIn .3s ease;
}
.unmute svg { width: 18px; height: 18px; }

.status {
  position: absolute; top: 38%; left: 50%; transform: translate(-50%, -50%);
  z-index: 4; display: flex; flex-direction: column; align-items: center; gap: 12px;
  font-size: 13px; font-weight: 600; text-shadow: var(--text-shadow);
}
.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,.25); border-top-color: #fff;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Offline ---------- */
.offline {
  position: absolute; inset: 0; z-index: 3;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 30px; text-align: center;
  background: radial-gradient(120% 80% at 50% 30%, #1d1830 0%, #07070a 70%);
}
.offline-ring {
  width: 112px; height: 112px; border-radius: 50%; padding: 4px;
  background: conic-gradient(from 210deg, var(--ring-a), var(--ring-b), var(--ring-c), var(--ring-a));
  animation: ringSpin 6s linear infinite;
}
.offline-ring img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; border: 4px solid #0b0a12; display: block; animation: ringSpin 6s linear infinite reverse; background: #222; }
@keyframes ringSpin { to { transform: rotate(360deg); } }
.offline h1 { font-size: 21px; margin: 22px 0 8px; line-height: 1.25; }
.offline p { font-size: 14px; opacity: .72; margin: 0; max-width: 320px; line-height: 1.45; }
.waiting { display: flex; gap: 6px; margin-top: 24px; }
.waiting span { width: 8px; height: 8px; border-radius: 50%; background: #fff; opacity: .3; animation: dot 1.2s infinite; }
.waiting span:nth-child(2) { animation-delay: .2s; }
.waiting span:nth-child(3) { animation-delay: .4s; }
.waiting-count { margin-top: 14px; font-size: 13px; font-weight: 600; opacity: .7; }
@keyframes dot { 0%, 100% { opacity: .25; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-4px); } }

/* ---------- Base: comentários, CTA, composer ---------- */
.bottom {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 5;
  padding: 0 12px calc(10px + var(--safe-bottom));
  display: flex; flex-direction: column; gap: 10px;
  transition: opacity .25s;
}
.stage.clean .comments, .stage.clean .pinned { opacity: 0; pointer-events: none; }

.pinned {
  align-self: flex-start; max-width: 88%;
  display: flex; gap: 8px; align-items: flex-start;
  background: rgba(255, 255, 255, .16); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  padding: 8px 12px; border-radius: 14px; font-size: 13px; font-weight: 600; line-height: 1.35;
}
.pinned svg { width: 14px; height: 14px; flex: none; margin-top: 2px; transform: rotate(45deg); }

.comments {
  list-style: none; margin: 0; padding: 0;
  max-height: 34vh; max-height: 34dvh;
  overflow-y: auto; scrollbar-width: none;
  display: flex; flex-direction: column; gap: 10px;
  -webkit-mask-image: linear-gradient(transparent 0, #000 22%);
          mask-image: linear-gradient(transparent 0, #000 22%);
  padding-top: 40px;
  transition: opacity .25s;
  overscroll-behavior: contain;
}
.comments::-webkit-scrollbar { display: none; }
.comment {
  display: flex; gap: 9px; align-items: flex-start;
  font-size: 13.5px; line-height: 1.33; text-shadow: var(--text-shadow);
  max-width: 86%;
  animation: commentIn .28s cubic-bezier(.2, .9, .3, 1.2);
}
@keyframes commentIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.comment .av {
  width: 30px; height: 30px; border-radius: 50%; flex: none; object-fit: cover;
  display: grid; place-items: center; font-size: 12px; font-weight: 800; text-shadow: none;
}
.comment b { font-weight: 700; display: block; font-size: 13px; }
.comment .tag {
  display: inline-block; margin-left: 5px; font-size: 10px; font-weight: 800;
  background: linear-gradient(90deg, var(--ring-b), var(--ring-c)); padding: 1px 6px; border-radius: 4px;
  text-shadow: none; vertical-align: 1px;
}
.comment.host .av { box-shadow: 0 0 0 2px var(--ring-b); }
.comment.system { opacity: .8; font-size: 12.5px; }

.cta {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 12px 18px; border-radius: 14px;
  margin-bottom: 40px; /* espaço extra acima da caixa de comentário */
  color: #fff; text-decoration: none; font-weight: 800; font-size: 16px; text-align: center;
  background: var(--cta, #22c55e);
  box-shadow: 0 10px 26px -6px var(--cta, #22c55e);
  animation: ctaIn .45s cubic-bezier(.2, .9, .3, 1.3), ctaPulse 2.2s 1s infinite;
  text-shadow: 0 1px 1px rgba(0,0,0,.25);
}
.cta svg { width: 18px; height: 18px; }
@keyframes ctaIn { from { opacity: 0; transform: translateY(16px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes ctaPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.025); } }

.composer { display: flex; align-items: center; gap: 4px; }
.input-wrap {
  flex: 1; display: flex; align-items: center;
  border: 1.5px solid rgba(255, 255, 255, .55); border-radius: 999px;
  background: rgba(0, 0, 0, .18);
  height: 44px; padding: 0 6px 0 16px; min-width: 0;
}
.input-wrap input {
  flex: 1; min-width: 0; background: transparent; border: 0; outline: 0; color: #fff;
  font-size: 16px; /* evita zoom no iOS */
}
.input-wrap input::placeholder { color: rgba(255, 255, 255, .85); }
.send { font-weight: 700; color: #6fb6ff; padding: 0 10px; font-size: 14px; }
.composer.disabled .input-wrap { opacity: .5; pointer-events: none; }
.heart.on svg path { fill: var(--live); stroke: var(--live); }
.heart:active svg { transform: scale(.85); }

/* ---------- Corações flutuantes ---------- */
.hearts { position: absolute; right: 8px; bottom: 180px; width: 70px; height: 60%; pointer-events: none; z-index: 6; }
.fh {
  position: absolute; bottom: 0; left: 50%; width: 30px; height: 30px;
  animation: floatUp var(--d, 2.6s) ease-out forwards;
}
.fh svg { width: 100%; height: 100%; filter: drop-shadow(0 2px 4px rgba(0,0,0,.3)); }
@keyframes floatUp {
  0% { transform: translate(-50%, 0) scale(.3); opacity: 0; }
  12% { transform: translate(calc(-50% + var(--x1)), -30px) scale(1.05); opacity: 1; }
  60% { transform: translate(calc(-50% + var(--x2)), -55%) scale(1); opacity: .95; }
  100% { transform: translate(calc(-50% + var(--x3)), -100%) scale(.85); opacity: 0; }
}

/* ---------- Sheet de nome ---------- */
.sheet {
  position: absolute; inset: 0; z-index: 20;
  background: rgba(0, 0, 0, .5); display: flex; align-items: flex-end;
  animation: fadeIn .2s;
}
.sheet-card {
  width: 100%; background: #16161b; border-radius: 22px 22px 0 0;
  padding: 22px 20px calc(22px + var(--safe-bottom));
  animation: slideUp .3s cubic-bezier(.2, .9, .3, 1);
}
.sheet-card h3 { margin: 0 0 4px; font-size: 18px; }
.sheet-card p { margin: 0 0 16px; font-size: 14px; opacity: .65; }
.sheet-card input {
  width: 100%; height: 48px; border-radius: 12px; border: 1px solid #2c2c35;
  background: #0e0e12; color: #fff; padding: 0 14px; font-size: 16px; outline: 0;
}
.sheet-card input:focus { border-color: var(--ring-b); }
.sheet-card button {
  width: 100%; height: 48px; margin-top: 12px; border-radius: 12px;
  background: linear-gradient(90deg, var(--ring-b), var(--ring-c)); font-weight: 800; font-size: 15px;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.toast {
  position: absolute; left: 50%; bottom: 130px; transform: translateX(-50%); z-index: 30;
  background: rgba(0,0,0,.8); padding: 9px 14px; border-radius: 10px; font-size: 13px; font-weight: 600;
  white-space: nowrap; animation: fadeIn .2s;
}
.notfound { position: absolute; inset: 0; z-index: 40; background: #07070a; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px; }
.notfound h1 { font-size: 22px; margin: 0 0 8px; }
.notfound p { opacity: .6; margin: 0; }
