:root {
  --bg: #050505;
  --ink: #fff;
  --muted: rgba(255, 255, 255, 0.62);
  --pill: rgba(22, 22, 22, 0.72);
  --live: #ff2d55;
  --vvw: 100%;
  --vvh: 100%;
  --frame-max-h: min(var(--vvh), 100dvh, 100svh, 100vh);
  --frame-w: min(var(--vvw), calc(var(--frame-max-h) * 9 / 16));
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --kb: 0px;
  --actions-h: 0px;
  --nick-h: 0px;
  --font: "Plus Jakarta Sans", "Segoe UI", sans-serif;
  --chat-max: min(34vh, 260px);
}

*, *::before, *::after { box-sizing: border-box; }

html {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  height: -webkit-fill-available;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
  position: fixed;
  inset: 0;
}

body,
body.lock-scroll,
html.lock-scroll body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  height: -webkit-fill-available;
  position: fixed;
  inset: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

.stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  height: -webkit-fill-available;
  max-width: none;
  max-height: none;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #000;
  touch-action: none;
}

.blur-plane {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  display: none;
  background: #050505;
  pointer-events: none;
}
.blur-canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.18);
  filter: blur(28px) saturate(1.1) brightness(0.55);
}
.blur-dim {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
}

@media (min-width: 820px) {
  .blur-plane { display: block; }
  :root { --chat-max: min(38vh, 320px); }
}

.phone-frame {
  position: relative;
  z-index: 1;
  width: var(--frame-w);
  height: calc(var(--frame-w) * 16 / 9);
  max-width: 100%;
  max-height: var(--frame-max-h);
  aspect-ratio: 9 / 16;
  background: #000;
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.06), 0 24px 80px rgba(0,0,0,0.55);
  touch-action: none;
}

@media (max-width: 819px) {
  :root {
    --chat-max: min(32dvh, 240px);
  }
  .stage {
    inset: 0;
    width: 100% !important;
    height: 100% !important;
    height: 100dvh !important;
    height: -webkit-fill-available !important;
    place-items: stretch;
    overflow: hidden;
    overscroll-behavior: none;
  }
  .phone-frame {
    /* Full-bleed immersive — fills screen, fixed bottom bar */
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    aspect-ratio: auto;
    box-shadow: none;
    border-radius: 0;
    overflow: hidden;
    touch-action: none;
  }
  .video-shell {
    overflow: hidden;
    border-radius: 0;
    touch-action: none;
  }
  .live-video {
    object-fit: cover;
    object-position: center center;
    touch-action: none;
  }
  .top-bar {
    padding-top: max(0.85rem, calc(0.55rem + var(--safe-t)));
    padding-left: max(0.75rem, env(safe-area-inset-left, 0px));
    padding-right: max(0.75rem, env(safe-area-inset-right, 0px));
  }
  .bottom-bar {
    bottom: var(--kb);
    padding-bottom: max(0.9rem, calc(0.75rem + var(--safe-b)));
    padding-left: max(0.65rem, env(safe-area-inset-left, 0px));
    padding-right: max(0.65rem, env(safe-area-inset-right, 0px));
    transition: bottom 0.18s ease;
    will-change: bottom;
  }
  .chat-layer {
    left: max(0.65rem, env(safe-area-inset-left, 0px));
    bottom: calc(4.7rem + var(--safe-b) + var(--kb) + var(--actions-h) + var(--nick-h));
    transition: bottom 0.18s ease;
  }
  .hearts-layer {
    top: max(5.2rem, calc(4rem + var(--safe-t)));
    bottom: calc(4.9rem + var(--safe-b) + var(--kb) + var(--actions-h) + var(--nick-h));
    height: auto;
    width: 90px;
    right: 0.2rem;
    overflow: hidden;
    z-index: 9;
    transition: bottom 0.18s ease;
  }
  .unmute-btn {
    top: 46%;
    width: 52px;
    height: 52px;
  }
  .host-avatar { width: 32px; height: 32px; }
  .host-name { font-size: 0.88rem; }
}

.video-shell {
  position: absolute;
  inset: 0;
  background: #0a0a0a;
  overflow: hidden;
}
.live-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  background: #000;
}
.unmute-btn {
  position: absolute;
  left: 50%;
  top: 48%;
  transform: translate(-50%, -50%);
  z-index: 7;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  width: 58px;
  height: 58px;
  padding: 0;
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  cursor: pointer;
  backdrop-filter: blur(4px);
}
.unmute-btn .unmute-icon {
  width: 28px;
  height: 28px;
  fill: currentColor;
  display: block;
}
.unmute-btn[hidden] { display: none !important; }
.unmute-btn:hover { background: rgba(0, 0, 0, 0.88); }
.video-fade {
  pointer-events: none;
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(0,0,0,0.55) 0%, transparent 18%, transparent 62%, rgba(0,0,0,0.55) 100%);
}
.offline-mask {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
  gap: 0.35rem;
  padding: 1rem;
  background: radial-gradient(circle at 50% 40%, #1a1a1a, #050505 70%);
  z-index: 2;
}
.offline-mask[hidden] { display: none; }
.offline-title { margin: 0; font-size: 1.25rem; font-weight: 800; letter-spacing: 0.02em; }
.offline-sub { margin: 0; color: var(--muted); font-size: 0.9rem; }

.bottom-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: var(--kb);
  z-index: 6;
  padding: 0.5rem 0.65rem calc(0.55rem + var(--safe-b));
  transition: bottom 0.12s ease;
  touch-action: manipulation;
}
.top-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: max(0.7rem, calc(0.45rem + var(--safe-t))) 0.75rem 0.45rem;
  touch-action: manipulation;
}
.host {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
}
.host-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  background: #111;
  border: 1.5px solid rgba(255,255,255,0.85);
  flex: 0 0 auto;
}
.host-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.host-name {
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 1px 3px rgba(0,0,0,0.55);
}
.host-title {
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 42vw;
}
.top-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex: 0 0 auto;
}
.live-badge {
  background: var(--live);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  padding: 0.28rem 0.45rem;
  border-radius: 4px;
  line-height: 1;
}
.viewer-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  background: rgba(20, 20, 20, 0.72);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 650;
  padding: 0.32rem 0.55rem;
  border-radius: 6px;
  backdrop-filter: blur(8px);
}
.viewer-pill[hidden],
.viewer-pill:not(.is-mod-visible) {
  display: none !important;
}
.viewer-pill.is-mod-visible {
  display: inline-flex !important;
}
.icon-close {
  appearance: none;
  border: 0;
  background: transparent;
  color: #fff;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  cursor: pointer;
  opacity: 0.92;
}

.chat-layer {
  position: absolute;
  left: 0.65rem;
  right: 4.2rem;
  bottom: calc(4.2rem + var(--safe-b) + var(--kb) + var(--actions-h) + var(--nick-h));
  z-index: 4;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 0.5rem;
  height: var(--chat-max);
  max-height: var(--chat-max);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
  mask-image: linear-gradient(180deg, transparent 0%, #000 22%, #000 100%);
  -webkit-mask-image: linear-gradient(180deg, transparent 0%, #000 22%, #000 100%);
  pointer-events: auto;
  touch-action: pan-y;
}
.chat-layer::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}
.chat-layer.is-mod {
  pointer-events: auto;
}
.chat-row {
  display: flex;
  align-items: flex-start;
  gap: 0.45rem;
  animation: chat-in 0.28s ease-out both;
  position: relative;
  flex: 0 0 auto;
}
.chat-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: #cfd8dc;
  border: 0;
  overflow: hidden;
  display: grid;
  place-items: center;
  color: #fff;
}
.chat-avatar svg {
  width: 100%;
  height: 100%;
  display: block;
}
.chat-copy {
  min-width: 0;
  text-shadow: 0 1px 2px rgba(0,0,0,0.65);
  flex: 1;
}
.chat-user {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.15;
}
.chat-body {
  display: block;
  font-size: 0.78rem;
  font-weight: 500;
  color: rgba(255,255,255,0.92);
  line-height: 1.25;
  word-break: break-word;
}
.chat-row.is-deleted .chat-body { color: rgba(255,255,255,0.55); font-style: italic; }
.chat-row.is-info .chat-user { color: #ffe566; }
.chat-row.is-ban .chat-body,
.chat-row.is-unban .chat-body { color: #ffb4b4; font-weight: 600; }
.chat-row.is-unban .chat-body { color: #9dffb6; }

.chat-mod-actions {
  display: none;
  flex-direction: column;
  gap: 0.25rem;
  flex: 0 0 auto;
  pointer-events: auto;
}
.chat-layer.is-mod .chat-row:hover .chat-mod-actions,
.chat-layer.is-mod .chat-row:focus-within .chat-mod-actions {
  display: flex;
}
.chat-mod-btn {
  appearance: none;
  border: 0;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  padding: 0.22rem 0.4rem;
  cursor: pointer;
  font: inherit;
  font-size: 0.68rem;
  font-weight: 700;
  white-space: nowrap;
}
.chat-mod-btn-icon {
  width: 12px;
  height: 12px;
  display: grid;
  place-items: center;
}
.chat-mod-btn-icon svg { width: 12px; height: 12px; display: block; }
.chat-mod-btn--ban { color: #ff9e9e; }
.chat-mod-btn--unban { color: #8ddea8; }
.chat-mod-btn:hover { background: rgba(0, 0, 0, 0.9); }

@keyframes chat-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.hearts-layer {
  position: absolute;
  right: 0.3rem;
  top: 14%;
  bottom: calc(4.55rem + var(--safe-b) + var(--kb) + var(--actions-h) + var(--nick-h));
  width: 88px;
  z-index: 9;
  pointer-events: none;
  overflow: hidden;
  /* Soft clip so hearts fade out before hitting the top edge */
  -webkit-mask-image: linear-gradient(180deg, transparent 0%, #000 14%, #000 100%);
  mask-image: linear-gradient(180deg, transparent 0%, #000 14%, #000 100%);
}
.float-heart {
  position: absolute;
  bottom: 4px;
  right: 10px;
  width: var(--heart-size, 26px);
  height: var(--heart-size, 26px);
  color: #ff2d55;
  animation: float-heart var(--heart-dur, 1.85s) ease-out forwards;
  filter: drop-shadow(0 2px 5px rgba(255, 45, 85, 0.4));
  will-change: transform, opacity;
  transform-origin: center bottom;
}
.float-heart svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}
@keyframes float-heart {
  0% {
    opacity: 0;
    transform: translate3d(0, 6px, 0) scale(0.45) rotate(-10deg);
  }
  14% {
    opacity: 1;
    transform: translate3d(calc(var(--dx, 0px) * 0.25), -28px, 0) scale(1) rotate(-4deg);
  }
  62% {
    opacity: 0.96;
    transform: translate3d(calc(var(--dx, 0px) * 0.75), calc(var(--heart-rise, -220px) * 0.62), 0) scale(1.08) rotate(8deg);
  }
  100% {
    opacity: 0;
    transform: translate3d(var(--dx, 0px), var(--heart-rise, -220px), 0) scale(1.12) rotate(14deg);
  }
}

.comment-form {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}
.comment-pill {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(40, 40, 40, 0.72);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 999px;
  padding: 0.1rem 0.2rem 0.1rem 0.35rem;
  backdrop-filter: blur(10px);
}
.comment-profile {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: #cfd8dc;
  color: #fff;
  overflow: hidden;
  display: grid;
  place-items: center;
  pointer-events: none;
}
.comment-profile svg {
  width: 100%;
  height: 100%;
  display: block;
}
.comment-pill input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: #fff;
  font: inherit;
  font-size: 16px !important; /* prevent iOS auto-zoom */
  line-height: 1.25;
  padding: 0.6rem 0;
  outline: none;
  touch-action: manipulation;
  transform: translateZ(0);
}
.comment-pill input::placeholder { color: rgba(255,255,255,0.45); }
.more-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: rgba(255,255,255,0.8);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
  flex: 0 0 auto;
  transition: background 0.15s ease, color 0.15s ease, transform 0.12s ease;
  position: relative;
}
.more-btn .more-icon {
  display: block;
}
.more-btn .more-icon--send {
  display: none;
}
.more-btn.is-send {
  background: var(--live);
  color: #fff;
}
.more-btn.is-send .more-icon--share {
  display: none;
}
.more-btn.is-send .more-icon--send {
  display: block;
}
.more-btn.is-send:active {
  transform: scale(0.92);
}
.like-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: #fff;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  cursor: pointer;
  flex: 0 0 auto;
  transition: transform 0.15s ease;
}
.like-btn:active { transform: scale(0.88); }
.like-btn.is-hot svg path {
  fill: var(--live);
  stroke: var(--live);
}
.chat-hint {
  margin: 0.3rem 0.2rem 0;
  font-size: 0.75rem;
  color: #ff8a9b;
}
.chat-hint[hidden] { display: none !important; }

.action-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin: 0 0 0.45rem;
  touch-action: manipulation;
}
.action-toolbar[hidden] { display: none !important; }
.action-chip {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 0.48rem 0.9rem;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: #fff;
  background: var(--live);
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.action-chip:active { transform: scale(0.96); }

body.has-actions {
  --actions-h: 2.55rem;
}
body.is-nick {
  --nick-h: 2.7rem;
}

.nick-toolbar {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0 0 0.45rem;
  padding: 0.35rem 0.4rem 0.35rem 0.7rem;
  border-radius: 999px;
  background: rgba(22, 22, 22, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  touch-action: manipulation;
}
.nick-toolbar[hidden] { display: none !important; }
.nick-label {
  flex: 0 0 auto;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.nick-toolbar input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: #fff;
  font: inherit;
  font-size: 16px !important;
  line-height: 1.25;
  padding: 0.45rem 0.2rem;
  outline: none;
}
.nick-toolbar input::placeholder { color: rgba(255, 255, 255, 0.4); }
.nick-save,
.nick-cancel {
  appearance: none;
  border: 0;
  flex: 0 0 auto;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
}
.nick-save {
  background: var(--live);
  color: #fff;
  border-radius: 999px;
  padding: 0.45rem 0.85rem;
  font-size: 0.82rem;
}
.nick-save:active { transform: scale(0.96); }
.nick-cancel {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.75);
  display: grid;
  place-items: center;
  font-size: 0.85rem;
  line-height: 1;
}
.nick-cancel:active { background: rgba(255, 255, 255, 0.14); }

.sheet {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: end center;
  background: rgba(0,0,0,0.45);
  padding: 1rem;
  touch-action: none;
  overflow: hidden;
}
.sheet[hidden] { display: none !important; }
.sheet-card {
  width: min(100%, 360px);
  background: #161616;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 18px;
  padding: 1.1rem 1rem 1rem;
  margin-bottom: calc(0.4rem + var(--safe-b));
  touch-action: manipulation;
  max-height: min(70vh, 520px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
}
.sheet-card::-webkit-scrollbar { display: none; width: 0; height: 0; }
.sheet-card h2 { margin: 0 0 0.25rem; font-size: 1.05rem; }
.sheet-card p { margin: 0 0 0.85rem; color: var(--muted); font-size: 0.85rem; }
.sheet-card input {
  width: 100%;
  border: 1px solid rgba(255,255,255,0.12);
  background: #0f0f0f;
  color: #fff;
  border-radius: 10px;
  padding: 0.75rem 0.85rem;
  font: inherit;
  font-size: 16px !important;
  margin-bottom: 0.7rem;
}
.sheet-save, .sheet-cancel {
  width: 100%;
  border: 0;
  border-radius: 10px;
  padding: 0.75rem;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.sheet-save { background: var(--live); color: #fff; }
.sheet-cancel { background: transparent; color: var(--muted); margin-top: 0.35rem; }

.share-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
  margin-bottom: 0.35rem;
}
.share-item {
  appearance: none;
  border: 1px solid rgba(255,255,255,0.1);
  background: #101010;
  color: #fff;
  border-radius: 12px;
  padding: 0.75rem 0.55rem;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  text-align: left;
}
.share-item img,
.share-item .share-icon {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  border-radius: 5px;
  object-fit: contain;
  display: block;
}
.share-item .share-icon {
  color: #fff;
}
.share-item:hover { background: #1c1c1c; }
.share-item[data-share="copy"] {
  grid-column: 1 / -1;
}
