/* TikTok LIVE chat look — bottom feed, dark glass, bold usernames */

:root {
  --tiktok-pink: #fe2c55;
  --tiktok-cyan: #25f4ee;
  --glass: rgba(0, 0, 0, 0.45);
  --text: #ffffff;
  --text-dim: rgba(255, 255, 255, 0.75);
  --max-items: 6;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  background: #000;
}

/* ── Streamer overlay: full-screen camera + chat on top (TikTok LIVE style) ── */

.streamer-body {
  background: #000;
}

.layout-streamer-overlay {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.vdo-frame-wrap {
  position: absolute;
  inset: 0;
  background: #111;
}

.vdo-frame-wrap iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.vdo-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #111;
  color: rgba(255, 255, 255, 0.6);
  font-size: 15px;
  z-index: 1;
}

.vdo-loading[hidden] {
  display: none;
}

.streamer-hud {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.hud-top {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  right: max(10px, env(safe-area-inset-right));
  left: max(10px, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  pointer-events: auto;
}

.hud-left,
.hud-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hud-actions {
  margin-left: auto;
}

.hud-status {
  font-size: 11px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.75);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
  background: rgba(0, 0, 0, 0.35);
  padding: 4px 10px;
  border-radius: 999px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.hud-btn {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.hud-icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.hud-icon rect {
  fill: currentColor;
  stroke: none;
}

.hud-btn.off {
  opacity: 0.45;
}

.hud-icon.is-hidden {
  display: none;
}

.hud-btn-mute {
  position: relative;
}

.hud-btn.muted {
  background: #fe2c55;
  color: #fff;
  box-shadow:
    0 0 0 2px rgba(255, 255, 255, 0.28),
    0 0 16px rgba(254, 44, 85, 0.95),
    0 2px 8px rgba(0, 0, 0, 0.35);
}

.hud-btn.muted .mic-slash {
  stroke: #fff;
  stroke-width: 2.4;
  opacity: 1;
}

.hud-btn-danger {
  background: rgba(254, 44, 85, 0.88);
}

.hud-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.chat-panel {
  flex-shrink: 0;
  max-height: 42vh;
  min-height: 120px;
  padding: 8px 12px max(14px, env(safe-area-inset-bottom));
  background: linear-gradient(to top, rgba(0, 0, 0, 0.82) 0%, rgba(0, 0, 0, 0.35) 55%, transparent 100%);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.chat-panel.hidden {
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
}

.layout-streamer-overlay .chat-feed {
  padding: 0;
  gap: 5px;
  max-height: 42vh;
}

/* ── Standalone / director side panel ── */

.layout-panel {
  height: 100vh;
  background: #0f0f0f;
  display: flex;
  flex-direction: column;
}

.panel-header {
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-header .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #444;
}

.panel-header .dot.live {
  background: var(--tiktok-pink);
  box-shadow: 0 0 8px var(--tiktok-pink);
}

.panel-header .dot.ok {
  background: #3ddc84;
}

.chat-feed {
  flex: 1;
  overflow-x: hidden;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 8px 12px 12px;
  gap: 6px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

/* ── Message bubble ── */

.chat-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  animation: slideUp 0.35s cubic-bezier(0.22, 1, 0.36, 1);
  max-width: 100%;
}

.chat-item.fade-out {
  animation: fadeOut 0.8s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  pointer-events: none;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeOut {
  from {
    opacity: 1;
    transform: translateY(0);
    max-height: 120px;
  }
  to {
    opacity: 0;
    transform: translateY(-10px);
    max-height: 0;
    margin-top: 0;
    margin-bottom: 0;
    padding-top: 0;
    padding-bottom: 0;
  }
}

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--tiktok-pink), #ff6b9d);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  overflow: hidden;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.bubble {
  background: var(--glass);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 12px;
  padding: 6px 10px;
  max-width: calc(100% - 36px);
  line-height: 1.35;
  word-break: break-word;
}

.bubble .name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
  margin-right: 6px;
}

.bubble .name.mod {
  color: var(--tiktok-cyan);
}

.bubble .name.gift {
  color: #ffd700;
}

.bubble .text {
  font-size: 14px;
  color: var(--text);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

.bubble .badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  margin-right: 4px;
  vertical-align: middle;
}

.badge.tiktok {
  background: var(--tiktok-pink);
  color: #fff;
}

.badge.gift {
  background: rgba(255, 215, 0, 0.25);
  color: #ffd700;
}

/* Join / new viewer */
.chat-item.join {
  opacity: 0.92;
}

.avatar.join-avatar {
  background: linear-gradient(135deg, var(--tiktok-cyan), #5eead4);
  font-size: 14px;
}

.bubble.join-bubble {
  background: rgba(37, 244, 238, 0.12);
  border: 1px solid rgba(37, 244, 238, 0.25);
}

.bubble .join-text {
  font-size: 13px;
  color: var(--tiktok-cyan);
  font-weight: 600;
}

/* Event types */
.chat-item.system {
  opacity: 0.85;
}

.avatar.event-avatar {
  font-size: 12px;
  font-weight: 700;
}

.avatar.event-avatar-like {
  background: linear-gradient(135deg, #ff2d55, #ff6b8a);
}

.avatar.event-avatar-follow,
.avatar.event-avatar-subscribe {
  background: linear-gradient(135deg, #ffd700, #ffb347);
}

.avatar.event-avatar-share {
  background: linear-gradient(135deg, #7c3aed, #a78bfa);
}

.avatar.event-avatar-gift {
  background: linear-gradient(135deg, #f59e0b, #fcd34d);
}

.avatar.event-avatar-question {
  background: linear-gradient(135deg, #06b6d4, #22d3ee);
}

.avatar.event-avatar-viewer {
  background: rgba(255, 255, 255, 0.15);
}

.bubble.event-bubble-like {
  background: rgba(255, 45, 85, 0.12);
  border: 1px solid rgba(255, 45, 85, 0.25);
}

.bubble.event-bubble-follow,
.bubble.event-bubble-subscribe {
  background: rgba(255, 215, 0, 0.1);
  border: 1px solid rgba(255, 215, 0, 0.25);
}

.bubble.event-bubble-share {
  background: rgba(124, 58, 237, 0.12);
  border: 1px solid rgba(124, 58, 237, 0.25);
}

.bubble.event-bubble-question {
  background: rgba(6, 182, 212, 0.12);
  border: 1px solid rgba(6, 182, 212, 0.25);
}

.bubble.system-bubble {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.bubble .system-text {
  color: rgba(255, 255, 255, 0.75);
  font-size: 13px;
}

.badge.like {
  background: rgba(255, 45, 85, 0.25);
  color: #ff6b8a;
}

.badge.follow {
  background: rgba(255, 215, 0, 0.2);
  color: #ffd700;
}

.badge.share {
  background: rgba(124, 58, 237, 0.25);
  color: #c4b5fd;
}

.badge.question {
  background: rgba(6, 182, 212, 0.25);
  color: #67e8f9;
}

.status-bar {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.4);
  padding: 4px 14px 8px;
  text-align: center;
}
