/* =========================================================
   Live: TikTok-style vertical tutor layout
   Bean brand tokens — cream / gold / navy (same as rest of Social)
   ========================================================= */

.live-stage[hidden] {
  display: none !important;
}

.live-stage {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--cream);
  font-family: var(--font-body);
  overflow: hidden;
}

/* --- Top bar --- */
.live-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.9rem;
  padding-top: max(0.6rem, env(safe-area-inset-top));
  background: linear-gradient(to bottom, rgba(11, 15, 26, 0.88), transparent);
  pointer-events: none;
}
.live-top > * {
  pointer-events: auto;
}

.live-badge-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
  background: #e85a5a;
  color: #fff;
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
}
.live-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #fff;
  animation: pulse 1.4s infinite;
}
.live-viewers {
  color: var(--cream-dim);
  font-size: 0.82rem;
  font-weight: 500;
}

/* --- Main stage (camera + whiteboard) --- */
.live-main {
  flex: 1;
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.stage-whiteboard {
  position: absolute;
  inset: 0;
  z-index: 1;
}
.stage-whiteboard .whiteboard-canvas {
  width: 100%;
  height: 100%;
  background: var(--bg-alt);
  cursor: crosshair;
}

.wb-toolbar {
  position: absolute;
  left: 0.85rem;
  bottom: 0.85rem;
  right: 0.85rem;
  z-index: 6;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.55rem;
  background: rgba(11, 15, 26, 0.85);
  border: 1px solid var(--line);
  border-radius: 18px;
  backdrop-filter: blur(10px);
  width: max-content;
  max-width: calc(100% - 1.7rem);
}

.wb-tool-color {
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid transparent;
  background: var(--wb-swatch);
  padding: 0;
  cursor: pointer;
}

.wb-tool-color.is-active {
  border-color: var(--gold);
}

.wb-toolbar-divider {
  width: 1px;
  height: 18px;
  background: var(--line);
}

.wb-tool-btn {
  appearance: none;
  border: none;
  background: none;
  color: var(--cream);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.wb-tool-btn:hover,
.wb-tool-btn.is-active,
.wb-tool-btn[aria-pressed="true"] {
  background: rgba(231, 201, 138, 0.16);
  color: var(--gold);
}

.wb-tool-btn:disabled {
  opacity: 0.35;
  cursor: default;
  background: none;
  color: var(--cream);
}

.live-stage[data-layout="camera"] .wb-toolbar {
  display: none;
}

.stage-video {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(160deg, var(--bg-alt), var(--bg-card) 45%, var(--bg));
  display: grid;
  place-items: center;
}
.stage-video video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* --- PiP Camera --- */
.pip-camera {
  position: absolute;
  top: 3.2rem;
  right: 0.85rem;
  z-index: 8;
  width: 110px;
  height: 150px;
  border-radius: 14px;
  overflow: hidden;
  border: 2px solid rgba(231, 201, 138, 0.28);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.45);
  background: #000;
  cursor: grab;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}
.pip-camera:active {
  cursor: grabbing;
}
.pip-camera video,
.pip-camera canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* While the canvas pipeline is live (see buildOutputStream in
   social-live.js) the canvas is what's shown - it's the actual filtered
   frame, byte-for-byte what viewers/the recording get. The raw <video>
   stays attached (it's the canvas's draw source) but visually hidden. */
.pip-camera video.is-output-piped {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.pip-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--bg-alt), var(--bg-card));
  color: var(--muted);
  font-family: var(--font-body);
}
.pip-placeholder span:first-child {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--gold);
  color: var(--bg);
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
}
.pip-placeholder small {
  font-size: 0.65rem;
  margin-top: 0.3rem;
  color: var(--cream-dim);
}

.hand-badge {
  position: absolute;
  bottom: 6px;
  left: 6px;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: #e85a5a;
  color: #fff;
  font-family: var(--font-body);
  font-size: 0.68rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: pulse 1s infinite;
  cursor: pointer;
}

.camera-filter-toggle {
  position: absolute;
  top: 6px;
  left: 6px;
  z-index: 3;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: rgba(11, 15, 26, 0.7);
  color: var(--cream);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.camera-filter-toggle:hover,
.camera-filter-toggle[aria-pressed="true"] {
  background: rgba(231, 201, 138, 0.3);
  color: var(--gold);
}

.camera-filter-panel {
  position: absolute;
  top: 3.2rem;
  right: calc(0.85rem + 110px + 0.5rem);
  z-index: 9;
  width: 190px;
  padding: 0.65rem;
  background: rgba(11, 15, 26, 0.92);
  border: 1px solid var(--line);
  border-radius: 14px;
  backdrop-filter: blur(10px);
}

.camera-filter-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-bottom: 0.55rem;
}
.camera-filter-preset {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--cream);
  font-family: var(--font-body);
  font-size: 0.72rem;
  padding: 0.25rem 0.6rem;
  cursor: pointer;
}
.camera-filter-preset.is-active {
  background: var(--gold);
  border-color: var(--gold);
  color: var(--bg);
  font-weight: 700;
}

.camera-filter-slider {
  display: block;
  margin-bottom: 0.45rem;
}
.camera-filter-slider span {
  display: block;
  font-size: 0.68rem;
  color: var(--muted);
  margin-bottom: 0.15rem;
}
.camera-filter-slider input[type="range"] {
  width: 100%;
}

.camera-filter-reset {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: none;
  color: var(--cream-dim);
  font-family: var(--font-body);
  font-size: 0.72rem;
  padding: 0.25rem 0.7rem;
  cursor: pointer;
}

.live-stage[data-layout="camera"] .camera-filter-panel {
  right: 0.85rem;
}

/* --- Layout modes --- */
.live-stage[data-layout="camera"] .stage-whiteboard {
  position: absolute;
  right: 0.85rem;
  bottom: 5.5rem;
  top: auto;
  left: auto;
  width: 130px;
  height: 100px;
  border-radius: 12px;
  overflow: hidden;
  border: 2px solid rgba(231, 201, 138, 0.22);
  z-index: 7;
}
.live-stage[data-layout="camera"] .stage-whiteboard .whiteboard-canvas {
  border-radius: 12px;
}
.live-stage[data-layout="camera"] .pip-camera {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 0;
  border: 0;
  z-index: 1;
}
.live-stage[data-layout="camera"] .pip-placeholder {
  border-radius: 0;
}

/* --- Right-side rail (TikTok-style: plain icons, no pill chips) --- */
.live-rail {
  position: absolute;
  right: 0.5rem;
  bottom: 5.5rem;
  z-index: 8;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  align-items: center;
}

/* Each rail group is its own small "box" (matching TikTok Studio's
   Scenes/Sources/Tools panels) instead of one flat strip - Interact
   (Likes/Chat) is a separate place from Teach (Code/Calm), not just
   more of the same rail. */
.live-rail-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
  padding: 0.6rem 0.4rem 0.7rem;
  background: rgba(11, 15, 26, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  backdrop-filter: blur(6px);
}

.live-rail-label {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.55);
}

/* Other live rooms - a thin strip across the bottom of the stage so
   viewers can hop between rooms without leaving Live, like TikTok's
   "Recommended LIVE streams" rail. */
.viewer-other-rooms {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9;
  padding: 0.6rem 0.75rem calc(0.6rem + env(safe-area-inset-bottom));
  background: linear-gradient(to top, rgba(11, 15, 26, 0.9), transparent);
}

.viewer-other-rooms-label {
  display: block;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.4rem;
}

.viewer-other-rooms-list {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  scrollbar-width: none;
}

.viewer-other-rooms-list::-webkit-scrollbar {
  display: none;
}

.viewer-other-room {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  max-width: 12rem;
  padding: 0.4rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(17, 23, 38, 0.85);
  color: var(--cream);
  cursor: pointer;
  text-align: left;
}

.viewer-other-room-glyph {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  background: var(--gold);
  color: var(--bg);
  font-size: 0.7rem;
  font-weight: 700;
}

.viewer-other-room-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.viewer-other-room-copy b {
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.viewer-other-room-copy small {
  font-size: 0.68rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Who's here */
.viewer-who-toggle {
  position: absolute;
  left: 0.75rem;
  top: 3.4rem;
  z-index: 9;
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(11, 15, 26, 0.65);
  color: var(--cream);
  border-radius: 999px;
  padding: 0.3rem 0.65rem;
  font-size: 0.72rem;
  cursor: pointer;
}

.viewer-who-panel {
  position: absolute;
  left: 0.75rem;
  top: 4.6rem;
  z-index: 12;
  width: 12rem;
  max-height: 14rem;
  overflow-y: auto;
  background: rgba(20, 26, 44, 0.96);
  backdrop-filter: blur(16px);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.5rem;
}

.viewer-who-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--cream);
  font-size: 0.78rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
}

.viewer-who-close {
  appearance: none;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

.viewer-who-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.viewer-who-chip {
  font-size: 0.7rem;
  color: var(--cream);
  background: rgba(255, 255, 255, 0.06);
  border-radius: 999px;
  padding: 0.2rem 0.5rem;
}
.rail-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  cursor: pointer;
  padding: 0;
  font-family: var(--font-body);
}
.rail-icon {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  color: #fff;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.55));
  transition: transform var(--motion, 220ms) var(--ease, ease);
}
.rail-btn[aria-pressed="true"] .rail-icon {
  color: var(--gold);
}
.rail-icon.is-saved {
  color: var(--gold);
}
.rail-icon svg {
  display: block;
}
.rail-icon.is-saved svg {
  fill: currentColor;
}
.rail-btn:active .rail-icon {
  transform: scale(0.85);
  transition-duration: 0.1s;
}
.rail-count {
  font-size: 0.7rem;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.55);
}

/* --- Hand raise panel --- */
.hand-panel {
  position: absolute;
  top: 3.2rem;
  right: 130px;
  width: 190px;
  background: rgba(17, 23, 38, 0.96);
  backdrop-filter: blur(16px);
  border-radius: 14px;
  border: 1px solid var(--line);
  z-index: 12;
  padding: 10px;
  opacity: 0;
  transform: translateX(8px);
  pointer-events: none;
  transition: all 0.22s ease;
  font-family: var(--font-body);
}
.hand-panel.is-open {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}
.hand-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  color: var(--cream);
  font-size: 0.85rem;
  font-weight: 600;
}
.hand-head button {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.1rem;
  cursor: pointer;
}
.hand-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 8px;
  margin-bottom: 4px;
}
.hand-row:hover {
  background: rgba(231, 201, 138, 0.08);
}
.hand-row-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(231, 201, 138, 0.2);
  color: var(--gold);
  display: grid;
  place-items: center;
  font-size: 0.7rem;
  font-weight: 700;
}
.hand-row-name {
  color: var(--cream);
  font-size: 0.82rem;
  flex: 1;
}
.hand-row-btn {
  background: var(--gold);
  border: none;
  border-radius: 6px;
  padding: 4px 10px;
  color: var(--bg);
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 700;
  cursor: pointer;
}

/* --- Floating reactions --- */
.reactions-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 15;
}
.reaction-float {
  position: absolute;
  font-size: 1.5rem;
  animation: reaction-rise 2.4s ease-out forwards;
  pointer-events: none;
}
@keyframes reaction-rise {
  0% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
  100% {
    transform: translateY(-260px) scale(0.4);
    opacity: 0;
  }
}

.bean-float {
  position: absolute;
  width: 34px;
  height: 34px;
  animation: bean-rise 2.2s cubic-bezier(0.15, 0.7, 0.3, 1) forwards;
  pointer-events: none;
}
.bean-float img {
  width: 100%;
  height: 100%;
  display: block;
}
@keyframes bean-rise {
  0% {
    transform: translate(0, 0) scale(0.6) rotate(0deg);
    opacity: 0;
  }
  12% {
    opacity: 1;
    transform: translate(0, -20px) scale(1) rotate(0deg);
  }
  100% {
    transform: translate(var(--bean-drift, 0px), -320px) scale(0.7) rotate(var(--bean-spin, 20deg));
    opacity: 0;
  }
}

.tip-balance {
  margin: 0 0 0.9rem;
  padding: 0 0.85rem;
  font-size: 0.88rem;
  color: rgba(242, 238, 230, 0.65);
}
.tip-amounts {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.6rem;
  padding: 0 0.85rem;
}
.tip-amount-btn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: #f2eee6;
  font: inherit;
  font-weight: 700;
  font-size: 1.05rem;
  min-height: 3.1rem;
  border-radius: 12px;
  cursor: pointer;
}
.tip-amount-btn:hover,
.tip-amount-btn:focus-visible {
  border-color: #e7c98a;
  color: #e7c98a;
}
.tip-amount-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.tip-buy-more-btn {
  display: block;
  margin: 1rem auto 0.2rem;
  background: none;
  border: 0;
  color: #e7c98a;
  font: inherit;
  font-size: 0.85rem;
  text-decoration: underline;
  cursor: pointer;
}

.buy-beans-notice {
  margin: 0 0.85rem 1.1rem;
  padding: 0.85rem 1rem;
  background: rgba(231, 201, 138, 0.08);
  border: 1px solid rgba(231, 201, 138, 0.2);
  border-radius: 10px;
  font-size: 0.82rem;
  line-height: 1.45;
  color: rgba(242, 238, 230, 0.72);
}

.bean-pack-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.85rem;
  padding: 0 0.85rem 0.85rem;
}
@media (max-width: 420px) {
  .bean-pack-grid {
    grid-template-columns: 1fr;
  }
}

.bean-pack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding: 1.1rem 0.8rem 0.9rem;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.03);
  text-align: center;
}

.bean-pack-coin {
  width: 46px;
  height: 46px;
  display: block;
  margin-bottom: 0.2rem;
}
.bean-pack-coin img {
  width: 100%;
  height: 100%;
  display: block;
}
.bean-pack--bronze .bean-pack-coin img {
  filter: sepia(0.35) saturate(1.4) brightness(0.82);
}
.bean-pack--gold .bean-pack-coin img {
  width: 56px;
  height: 56px;
  margin: -5px auto 0.2rem;
}
.bean-pack--rose .bean-pack-coin {
  width: 62px;
  height: 62px;
}
.bean-pack--rose .bean-pack-coin img {
  filter: hue-rotate(-18deg) saturate(1.15) brightness(1.04);
}
.bean-pack--platinum .bean-pack-coin {
  width: 70px;
  height: 70px;
}
.bean-pack--platinum .bean-pack-coin img {
  filter: grayscale(0.5) brightness(1.3);
}

.bean-pack-amount {
  font-size: 0.94rem;
  color: #f2eee6;
}
.bean-pack-price {
  font-size: 0.82rem;
  color: rgba(242, 238, 230, 0.55);
}
.bean-pack-btn {
  appearance: none;
  margin-top: 0.5rem;
  width: 100%;
  min-height: 2.3rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.03);
  color: rgba(242, 238, 230, 0.5);
  font: inherit;
  font-size: 0.8rem;
  cursor: default;
}

/* --- Bottom area --- */
.live-bottom {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10;
  padding: 0.6rem 0.85rem calc(0.6rem + env(safe-area-inset-bottom));
  background: linear-gradient(to top, rgba(11, 15, 26, 0.75) 10%, transparent);
  font-family: var(--font-body);
  pointer-events: none;
}
.live-bottom > * {
  pointer-events: auto;
}
.live-chat-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0.6rem;
  max-width: 74%;
}
.live-stage .chat-log {
  max-height: 34vh;
  overflow-y: auto;
  mask-image: linear-gradient(transparent 0%, black 16%);
  display: flex;
  flex-direction: column;
  gap: 6px;
  scrollbar-width: none;
}
.live-stage .chat-log::-webkit-scrollbar {
  display: none;
}
.live-stage .chat-line {
  background: none;
  padding: 0;
  border-radius: 0;
  color: #fff;
  font-size: 0.86rem;
  line-height: 1.35;
  word-break: break-word;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}
.live-stage .chat-line .who {
  color: var(--gold);
  font-weight: 700;
  margin-right: 4px;
}

.live-stage .chat-form {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}
.live-stage .chat-form input {
  flex: 1;
  background: rgba(17, 23, 38, 0.85);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.5rem 0.9rem;
  color: var(--cream);
  font-family: var(--font-body);
  font-size: 0.9rem;
  outline: none;
}
.live-stage .chat-form input::placeholder {
  color: var(--muted);
}
.live-stage .chat-form button {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--gold);
  color: var(--bg);
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
  font-family: var(--font-body);
  font-weight: 700;
}

.live-toolbar {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
}
.live-toolbar button {
  white-space: nowrap;
  min-height: 2.4rem;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(17, 23, 38, 0.85);
  color: var(--cream);
  font-family: var(--font-body);
  font-size: 0.82rem;
  cursor: pointer;
  backdrop-filter: blur(6px);
}
.live-toolbar .btn-end {
  background: #e85a5a;
  border-color: #e85a5a;
  color: #fff;
  margin-left: auto;
}

.live-toolbar button[aria-pressed="true"] {
  background: #e85a5a;
  border-color: #e85a5a;
  color: #fff;
}

#btn-mute svg {
  display: block;
}

.viewer .live-main {
  background: var(--bg);
}

/* Viewer chat is closed by default - it only fills the bottom half of the
   stage once the Chat rail button opens it, instead of sitting docked
   over the video permanently. */
.viewer-bottom {
  top: 50%;
  bottom: 0;
  padding: 0.85rem 0.85rem calc(0.8rem + env(safe-area-inset-bottom));
  background: rgba(11, 15, 26, 0.96);
  border-top: 1px solid var(--line);
  border-radius: 16px 16px 0 0;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.22s ease;
  pointer-events: none;
}
.viewer-bottom.is-open {
  transform: translateY(0);
  pointer-events: auto;
}
.viewer-bottom .chat-log {
  flex: 1;
  max-height: none;
}
.viewer-bottom .chat-form {
  margin-top: 0.5rem;
}
.viewer-chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}
.viewer-chat-head span {
  font-weight: 700;
  color: var(--cream);
}
.viewer-chat-close {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: var(--cream);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}
.wb-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  background: rgba(11, 15, 26, 0.92);
  display: grid;
  place-items: center;
}
.wb-overlay canvas {
  width: 90%;
  height: 80%;
  background: var(--bg-alt);
  border-radius: 12px;
  border: 1px solid var(--line);
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.45;
  }
}

.live-badge.is-paused {
  background: var(--muted);
}

.video-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  text-align: center;
  color: var(--cream-dim);
  font-family: var(--font-body);
  background: linear-gradient(160deg, var(--bg-alt), var(--bg-card) 45%, var(--bg));
}

.live-tool-panel--stage {
  position: absolute;
  left: 0.75rem;
  right: 4.5rem;
  bottom: 7.5rem;
  z-index: 9;
  max-height: 42vh;
  overflow: auto;
  padding: 0.75rem;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(17, 23, 38, 0.96);
  backdrop-filter: blur(12px);
  color: var(--cream);
  font-family: var(--font-body);
}
.live-tool-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--cream-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.live-tool-panel-close {
  appearance: none;
  border: none;
  background: none;
  color: var(--cream-dim);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
}
.live-tool-panel-close:active {
  transform: scale(0.9);
}
.live-tool-panel-label {
  margin: 0.6rem 0 0.3rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--cream-dim);
}

.live-stage .text-back {
  color: var(--cream);
  background: transparent;
  border: 0;
  font-family: var(--font-body);
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0.35rem 0.25rem;
  min-height: 2.4rem;
}

.live-stage .icon-btn {
  width: 2.4rem;
  height: 2.4rem;
  border: 0;
  border-radius: 999px;
  background: rgba(17, 23, 38, 0.75);
  border: 1px solid var(--line);
  color: var(--cream);
  display: grid;
  place-items: center;
  cursor: pointer;
}

body.live-stage-open .bottom-nav,
body.live-stage-open .social-top {
  visibility: hidden;
  pointer-events: none;
}

/* Host studio only, wide screens: chat moves from docked-over-video at
   the bottom to its own column on the right, the same layout TikTok's
   own LIVE Studio uses - the video/whiteboard area gets a matching
   right margin so nothing sits underneath the chat column. */
@media (min-width: 1000px) {
  #studio.live-stage {
    flex-direction: row;
  }
  #studio .live-top {
    position: absolute;
    top: 0;
    left: 0;
    right: 320px;
  }
  #studio .live-main {
    margin-top: 3.4rem;
    margin-right: 320px;
  }
  #studio .live-rail {
    right: calc(320px + 0.85rem);
  }
  #studio .pip-camera {
    right: calc(320px + 0.85rem);
  }
  #studio .hand-panel {
    right: calc(320px + 130px);
  }
  #studio .live-tool-panel--stage {
    right: calc(320px + 0.85rem);
  }
  #studio .live-bottom {
    top: 3.4rem;
    left: auto;
    right: 0;
    width: 320px;
    background: rgba(11, 15, 26, 0.9);
    border-left: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
  }
  #studio .live-chat-wrap {
    max-width: 100%;
    flex: 1;
    min-height: 0;
  }
  #studio .live-toolbar {
    flex-wrap: wrap;
  }
}

@media (min-width: 540px) {
  .live-rail {
    right: calc(50% - 220px + 0.75rem);
  }
  .pip-camera {
    right: calc(50% - 220px + 0.85rem);
  }
  .hand-panel {
    right: calc(50% - 220px + 130px);
  }
}
