.live-wrap {
  max-width: 100%;
}

.live-main {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  align-items: start;
}

.live-left {
  min-width: 0;
}

.live-header {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.live-header-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 0.75rem;
}

.live-header-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  min-width: 0;
}

.live-header-meta .muted {
  flex: 0 1 auto;
}

.muted {
  color: #9ca3af;
  margin: 0;
  flex: 1 1 auto;
}

.live-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.live-actions--toolbar {
  flex-wrap: nowrap;
  gap: 0.35rem;
}

.live-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 10px;
  border: 1px solid #4b5563;
  background: #1f2937;
  color: #e5e7eb;
  cursor: pointer;
  touch-action: manipulation;
  flex-shrink: 0;
}

.live-icon-btn:hover {
  background: #374151;
}

.live-icon-btn:disabled {
  cursor: wait;
  opacity: 0.6;
}

.live-icon-btn--leave {
  border-color: #b91c1c;
  background: #450a0a;
  color: #fecaca;
}

.live-icon-btn--leave:hover {
  background: #7f1d1d;
}

.live-icon-svg {
  width: 22px;
  height: 22px;
  display: block;
}

.link-home {
  color: #a78bfa;
  text-decoration: none;
  margin-right: 0.25rem;
}

.link-home:hover {
  text-decoration: underline;
}

button.secondary {
  background: #374151;
}

button.danger {
  background: #b91c1c;
}

.video-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

.video-tile {
  position: relative;
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 12px;
  overflow: hidden;
  aspect-ratio: 16 / 9;
}

/* Fill the tile: nested wrapper had no height, so video height:100% collapsed to 0 */
.video-media {
  position: absolute;
  inset: 0;
}

.video-media video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: #000;
}

.gate-title {
  margin: 0 0 0.75rem;
  font-size: 1.1rem;
}

.gate-steps {
  margin: 0;
  padding-left: 1.25rem;
  color: #d1d5db;
}

.gate-steps li {
  margin-bottom: 1.25rem;
}

.gate-steps li:last-child {
  margin-bottom: 0;
}

.raw-wrap {
  margin-top: 0.75rem;
}

.raw-wrap video {
  width: 100%;
  max-width: 420px;
  max-height: 280px;
  border-radius: 8px;
  border: 1px solid #30363d;
  background: #000;
  display: block;
}

.broadcast-gate {
  background: #161b22;
  border: 1px solid #7c3aed;
  border-radius: 12px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
}

.broadcast-gate p {
  margin: 0 0 1rem;
  color: #d1d5db;
  font-size: 0.95rem;
  line-height: 1.5;
}

.live-diag {
  font-size: 0.75rem;
  color: #9ca3af;
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 8px;
  padding: 0.75rem;
  margin-bottom: 1rem;
  white-space: pre-wrap;
  word-break: break-word;
}

button.primary {
  background: #7c3aed;
  font-size: 1rem;
  padding: 0.75rem 1.25rem;
}

.video-label {
  position: absolute;
  left: 0.5rem;
  bottom: 0.5rem;
  z-index: 1;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.65);
  font-size: 0.75rem;
}

.broadcast-tab-menu {
  display: none;
}

.broadcast-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0.55rem 0.8rem;
  border: 1px solid #30363d;
  border-bottom-color: #1f2937;
  border-radius: 8px 8px 0 0;
  background: #111827;
  color: #e5e7eb;
  font-size: 0.84rem;
  font-weight: 700;
  line-height: 1.1;
  text-decoration: none;
  white-space: nowrap;
}

.broadcast-tab:hover,
.broadcast-tab:focus-visible {
  background: #1f2937;
  border-color: #4b5563;
}

.broadcast-tab.is-active {
  background: #161b22;
  border-color: #7c3aed;
  border-bottom-color: #161b22;
  color: #ffffff;
}

.broadcast-tab--primary {
  color: #f5f3ff;
  background: #2e1065;
  border-color: #7c3aed;
}

.broadcast-tab--primary:hover,
.broadcast-tab--primary:focus-visible {
  background: #4c1d95;
  border-color: #8b5cf6;
}

.broadcast-link-panel {
  display: none;
}

.broadcast-panel-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0.65rem 0.95rem;
  border-radius: 8px;
  background: #374151;
  color: #ffffff;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
}

.broadcast-panel-link:hover,
.broadcast-panel-link:focus-visible {
  background: #4b5563;
}

.broadcast-panel-link--primary {
  background: #7c3aed;
}

.broadcast-panel-link--primary:hover,
.broadcast-panel-link--primary:focus-visible {
  background: #8b5cf6;
}

.chat-panel {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 12px;
  padding: 0.9rem;
  max-width: 100%;
  overflow-x: hidden;
}

.tip-panel {
  background: #1a1025;
  border: 1px solid #7c3aed;
  border-radius: 10px;
  padding: 0.75rem;
  margin-bottom: 1rem;
}

.tip-panel h3 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
}

.broadcast-earnings-stats {
  list-style: none;
  margin: 0.5rem 0 0.35rem;
  padding: 0;
  font-size: 0.88rem;
}

.broadcast-earnings-stats li {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.35rem 0.75rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid #1e293b;
}

.broadcast-earnings-stats li:last-child {
  border-bottom: none;
}

.broadcast-earnings-k {
  color: #94a3b8;
}

.broadcast-earnings-v {
  color: #86efac;
  font-weight: 600;
}

.broadcast-earnings-eligible {
  margin: 0.5rem 0 0;
  color: #fde68a;
}

.bcast-recent-tips {
  margin-top: 0.65rem;
}

.bcast-recent-label {
  margin: 0 0 0.35rem;
}

.bcast-tip-list {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.82rem;
  color: #cbd5e1;
  line-height: 1.45;
}

.bcast-tip-who {
  color: #e2e8f0;
}

.nav-drawer-broadcast-earnings {
  margin: 0.35rem 0 0.5rem;
  padding: 0.5rem 0.65rem;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 8px;
}

.nav-drawer-broadcast-earnings[hidden] {
  display: none !important;
}

.nav-drawer-earnings-stats {
  font-size: 0.82rem;
}

.nav-drawer-hint {
  margin: 0.35rem 0 0.25rem;
  font-size: 0.78rem;
}

.tip-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.35rem;
}

.tip-form input {
  flex: 1;
  min-width: 80px;
  max-width: 120px;
  background: #0d1117;
  border: 1px solid #30363d;
  color: #e5e7eb;
  border-radius: 8px;
  padding: 0.5rem;
  font-size: 16px;
}

.tip-quick-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.6rem;
}

.tip-quick-label {
  font-size: 0.8rem;
  color: #9ca3af;
  margin-right: 0.25rem;
}

.tip-quick {
  padding: 0.35rem 0.65rem;
  font-size: 0.85rem;
}

.tip-received-banner {
  flex: 1 1 100%;
  margin: 0.35rem 0 0;
  padding: 0.45rem 0.75rem;
  border-radius: 8px;
  background: rgba(124, 58, 237, 0.25);
  border: 1px solid #7c3aed;
  color: #e9d5ff;
  font-size: 0.9rem;
  font-weight: 600;
}

.chat-panel h2,
.chat-panel h3 {
  margin: 0 0 0.6rem;
}

.chat-messages {
  min-height: 280px;
  max-height: 420px;
  overflow-y: auto;
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 8px;
  padding: 0.6rem;
  margin-bottom: 0.9rem;
}

.chat-item {
  margin-bottom: 0.6rem;
}

.chat-item:last-child {
  margin-bottom: 0;
}

.chat-meta {
  color: #9ca3af;
  font-size: 0.78rem;
}

.chat-body {
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-form {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.7rem;
  width: 100%;
  max-width: 100%;
  align-items: stretch;
}

.chat-form input {
  flex: 1;
  min-width: 0;
  background: #0d1117;
  border: 1px solid #30363d;
  color: #e5e7eb;
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  font-size: 16px;
  min-height: 44px;
  margin-bottom: 0;
  -webkit-appearance: none;
  appearance: none;
}

.chat-form button {
  flex-shrink: 0;
  min-height: 44px;
  touch-action: manipulation;
}

.chat-send-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  padding: 0;
}

.chat-send-icon {
  display: block;
  width: 20px;
  height: 20px;
}

.participant-list {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 180px;
  overflow-y: auto;
}

.participant-list li {
  padding: 0.25rem 0;
  border-bottom: 1px solid #1f2937;
}

.participant-list li:last-child {
  border-bottom: 0;
}

.live-badge {
  color: #fee2e2;
  background: #991b1b;
  border-radius: 999px;
  padding: 0.2rem 0.5rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  animation: livePulse 2s infinite ease-in-out;
}

.private-broadcast-share {
  padding: 0.75rem;
  border: 1px solid #fb7185;
  border-radius: 8px;
  background: #2a0f18;
}

.private-broadcast-share-title {
  margin: 0 0 0.25rem;
  color: #fecdd3;
  font-weight: 700;
}

.private-broadcast-share-row {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}

.private-broadcast-share-row input {
  margin-bottom: 0;
}

.private-broadcast-share-row button {
  flex-shrink: 0;
}

.autostart-media-prompt {
  margin: 0 0 0.75rem;
  padding: 0.85rem;
  border: 1px solid #7c3aed;
  border-radius: 8px;
  background: #161b22;
}

.autostart-media-prompt[hidden] {
  display: none !important;
}

.autostart-media-title {
  margin: 0 0 0.25rem;
  font-weight: 700;
  color: #f5f3ff;
}

@keyframes livePulse {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.45); }
  70% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-card {
  width: min(560px, 92vw);
  background: #111827;
  border: 1px solid #374151;
  border-radius: 12px;
  padding: 1rem;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

@media (max-width: 980px) {
  .live-main {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .live-wrap {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    padding: 0.6rem 0.75rem 0.75rem;
  }

  .live-header {
    flex: 0 0 16dvh;
    min-height: 96px;
    max-height: 16dvh;
    margin-bottom: 0.6rem;
    padding: 0.55rem 0.65rem;
    border: 1px solid #30363d;
    border-radius: 10px;
    background: #111827;
    overflow: auto;
  }

  .live-main {
    flex: 1 1 auto;
    min-height: 0;
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 42dvh) minmax(0, 42dvh);
    gap: 0.6rem;
  }

  .live-left {
    min-height: 0;
    height: 100%;
    padding: 0 0.2rem;
  }

  .video-grid {
    height: 100%;
    gap: 0.6rem;
  }

  .video-tile {
    height: auto;
    max-height: 100%;
    aspect-ratio: 16 / 9;
    border-radius: 14px;
  }

  .chat-panel {
    min-height: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
  }

  .chat-messages {
    min-height: 0;
    max-height: none;
    flex: 1 1 auto;
  }
}

/* Host / broadcast: body id set in live.js when wantsPublish */
body#camme-live-broadcast main.container.live-wrap {
  padding: 0;
}

body#camme-live-broadcast .live-header {
  border-radius: 0;
}

body#camme-live-broadcast .live-left {
  padding: 0;
}

body#camme-live-broadcast .video-tile {
  border-radius: 0;
}

body#camme-live-broadcast .live-status-line {
  display: none;
}

body#camme-live-broadcast .live-viewer-count {
  font-size: 0.75rem;
  color: #9ca3af;
}

body#camme-live-broadcast .live-wrap {
  padding: 0;
}

body#camme-live-broadcast .live-main {
  grid-template-columns: 1fr;
  grid-template-rows: auto auto auto;
  gap: 0;
}

body#camme-live-broadcast .broadcast-tab-menu {
  display: flex;
  gap: 0.25rem;
  overflow-x: auto;
  padding: 0.55rem 0.7rem 0;
  background: #0d1117;
  border-top: 1px solid #30363d;
  scrollbar-width: thin;
}

body#camme-live-broadcast .chat-panel {
  margin: 0;
  padding: 0;
  border: 1px solid #30363d;
  border-top: 0;
  border-radius: 0;
  min-height: 100%;
  height: 100%;
  background: #0d1117;
  width: 100%;
}

body#camme-live-broadcast .broadcast-tab-panel {
  border-left: 1px solid #30363d;
  border-right: 1px solid #30363d;
  border-bottom: 1px solid #30363d;
}

body#camme-live-broadcast .broadcast-tab-panel[hidden] {
  display: none !important;
}

body#camme-live-broadcast .broadcast-link-panel {
  margin: 0;
  padding: 0;
  border-top: 0;
  border-radius: 0;
  background: #0d1117;
  min-height: 100%;
  height: 100%;
  width: 100%;
}

body#camme-live-broadcast .broadcast-link-panel:not([hidden]) {
  display: block;
}

body#camme-live-broadcast .broadcast-link-panel h2 {
  margin: 0 0 0.45rem;
  font-size: 1rem;
}

.broadcast-panel-frame {
  display: block;
  width: 100%;
  min-height: 360px;
  height: 42dvh;
  border: 0;
  background: #0e1117;
}

body#camme-live-broadcast .chat-panel > h2,
body#camme-live-broadcast #chatHint {
  display: none;
}

body#camme-live-broadcast .chat-panel > h3,
body#camme-live-broadcast .participant-list {
  display: none;
}

body#camme-live-broadcast .chat-messages {
  border-radius: 0;
  border: 0;
  margin: 0;
  min-height: 150px;
  max-height: 32dvh;
}

body#camme-live-broadcast .chat-form {
  margin-bottom: 0;
  border-radius: 0;
  gap: 0;
  border-top: 1px solid #30363d;
  border-bottom: 1px solid #30363d;
}

body#camme-live-broadcast .chat-form input,
body#camme-live-broadcast .chat-form button {
  border-radius: 0;
}

@media (max-width: 768px) {
  body#camme-live-broadcast .live-wrap {
    padding: 0;
  }

  body#camme-live-broadcast .live-header {
    border-radius: 0;
    margin-bottom: 0;
    border-left: none;
    border-right: none;
    max-height: none;
    flex: 0 0 auto;
  }

  body#camme-live-broadcast .live-main {
    grid-template-rows: auto auto minmax(0, 1fr);
    gap: 0;
  }

  body#camme-live-broadcast .broadcast-tab-menu {
    padding: 0.45rem 0.5rem 0;
  }

  .broadcast-tab {
    min-height: 38px;
    padding: 0.5rem 0.7rem;
    font-size: 0.8rem;
  }

  body#camme-live-broadcast .chat-messages {
    max-height: none;
    flex: 1 1 auto;
  }
}
