/* ============================================================
   Color Room — Main Stylesheet
   ============================================================ */
* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Rubik', system-ui, -apple-system, sans-serif;
  font-weight: 400;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body { position: relative; }

/* ============================================================
   ATMOSPHERE — soft navy/cyan blooms, away from video zone
   ============================================================ */
.atmosphere {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.atmosphere::before,
.atmosphere::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
}

.atmosphere::before {
  width: 60vw;
  height: 60vw;
  max-width: 800px;
  max-height: 800px;
  top: -30vw;
  left: -15vw;
  background: radial-gradient(circle, var(--navy) 0%, transparent 60%);
  opacity: 0.10;
  animation: drift1 28s ease-in-out infinite alternate;
}

.atmosphere::after {
  width: 50vw;
  height: 50vw;
  max-width: 700px;
  max-height: 700px;
  bottom: -25vw;
  right: -15vw;
  background: radial-gradient(circle, #06b6d4 0%, transparent 60%);
  opacity: 0.08;
  animation: drift2 34s ease-in-out infinite alternate;
}

@keyframes drift1 {
  0%   { transform: translate(0, 0) scale(1); }
  100% { transform: translate(40px, 30px) scale(1.1); }
}
@keyframes drift2 {
  0%   { transform: translate(0, 0) scale(1); }
  100% { transform: translate(-30px, -40px) scale(1.05); }
}

/* ============================================================
   APP LAYOUT
   ============================================================ */
.app {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  animation: page-enter 0.55s var(--ease-out) both;
}

@keyframes page-enter {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.atmosphere {
  animation: atmosphere-enter 1.1s ease-out 0.15s both;
}

@keyframes atmosphere-enter {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ============================================================
   STAGGERED ENTRY ANIMATIONS
   Each major panel slides in with a small delay for a polished
   first-paint feel. Video frame gets a subtle scale-in.
   ============================================================ */
.app > .topbar   { animation: slide-down 0.55s var(--ease-out) 0.05s both; }
.app > .stage    { animation: stage-fade 0.65s var(--ease-out) 0.15s both; }
.app > .controls { animation: slide-up 0.55s var(--ease-out) 0.10s both; }

@keyframes slide-down {
  from { opacity: 0; transform: translateY(-14px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes slide-up {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes stage-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.video-frame {
  animation: video-frame-enter 0.65s var(--ease-out) 0.25s both;
}

@keyframes video-frame-enter {
  from { opacity: 0; transform: scale(0.985); }
  to   { opacity: 1; transform: scale(1); }
}

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 28px;
  flex-shrink: 0;
  gap: 16px;
  border-bottom: 1px solid var(--border-soft);
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-mark {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.25s var(--ease);
  -webkit-tap-highlight-color: transparent;
}

.brand-mark:hover {
  transform: scale(1.08);
}

.brand-mark:active {
  transform: scale(0.96);
}

.brand-mark img,
.brand-mark svg {
  width: 100%;
  height: 100%;
  display: block;
  animation: brand-idle-spin 60s linear infinite;
  transform-origin: center;
}

@keyframes brand-idle-spin {
  to { transform: rotate(360deg); }
}

/* During connection: keep the slow idle-spin running so the icon's
   rotation direction stays continuous. The fast spinner ring around
   the icon overlays on top — both rotate clockwise, no visual conflict. */

.brand-mark::after {
  content: '';
  position: absolute;
  inset: -6px;
  background: radial-gradient(circle, var(--navy-glow) 0%, transparent 65%);
  opacity: 0.28;
  z-index: -1;
  animation: glow-pulse 4s ease-in-out infinite;
}

/* Spinning ring around the logo while connecting */
.brand-mark .brand-spinner {
  position: absolute;
  inset: -4px;
  border: 1.5px solid transparent;
  border-top-color: var(--navy-bright);
  border-right-color: var(--navy-bright);
  border-radius: 50%;
  opacity: 0;
  transform: rotate(0deg);
  transition: opacity 0.35s var(--ease);
  pointer-events: none;
}

.brand-mark.connecting .brand-spinner {
  opacity: 0.85;
  animation: brand-spin 1.1s linear infinite;
}

@keyframes brand-spin {
  to { transform: rotate(360deg); }
}

@keyframes glow-pulse {
  0%, 100% { opacity: 0.18; transform: scale(1); }
  50%      { opacity: 0.36; transform: scale(1.1); }
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
  min-width: 0;
}

.brand-name {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--text);
  white-space: nowrap;
}

.brand-tag {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-mute);
  margin-top: 4px;
  white-space: nowrap;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
}

/* ============================================================
   STATUS PILL
   ============================================================ */
.status-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 13px 7px 14px;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid var(--border);
  border-radius: 100px;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-dim);
  transition: all 0.3s var(--ease);
}

.status-pill[data-state="live"] {
  border-color: rgba(220, 38, 38, 0.40);
  color: var(--text);
  background: rgba(220, 38, 38, 0.04);
  position: relative;
  overflow: hidden;
}

/* Subtle red sweep across the live pill every few seconds */
.status-pill[data-state="live"]::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    100deg,
    transparent 30%,
    rgba(220, 38, 38, 0.18) 50%,
    transparent 70%
  );
  transform: translateX(-100%);
  animation: pill-shimmer 3.5s ease-in-out infinite;
  pointer-events: none;
}

@keyframes pill-shimmer {
  0%   { transform: translateX(-100%); }
  60%  { transform: translateX(120%); }
  100% { transform: translateX(120%); }
}

.status-pill[data-state="connected"] {
  border-color: rgba(5, 150, 105, 0.40);
  color: var(--text);
  background: rgba(5, 150, 105, 0.04);
}

.status-pill[data-state="error"] {
  border-color: rgba(220, 38, 38, 0.40);
  color: var(--live);
  background: rgba(220, 38, 38, 0.06);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
  transition: all 0.2s;
}

.status-pill[data-state="live"] .status-dot {
  background: var(--live);
  box-shadow: 0 0 0 0 var(--live-glow);
  animation: live-pulse 1.6s ease-in-out infinite;
}

.status-pill[data-state="connected"] .status-dot {
  background: var(--ok);
  box-shadow: 0 0 6px var(--ok-glow);
}

.status-pill[data-state="error"] .status-dot { background: var(--live); }

@keyframes live-pulse {
  0%   { box-shadow: 0 0 0 0 var(--live-glow); transform: scale(1); }
  50%  { box-shadow: 0 0 0 6px rgba(220, 38, 38, 0); transform: scale(1.2); }
  100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); transform: scale(1); }
}

/* ============================================================
   LANG SWITCH
   ============================================================ */
.lang-switch {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 3px;
  position: relative;
}

.lang-btn {
  background: transparent;
  border: none;
  color: var(--text-mute);
  font-family: 'Rubik', sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  padding: 5px 12px;
  cursor: pointer;
  border-radius: 100px;
  transition: color 0.2s var(--ease);
  position: relative;
  z-index: 2;
  -webkit-tap-highlight-color: transparent;
}

.lang-btn.active { color: #fff; }
.lang-btn:not(.active):hover { color: var(--text); }

.lang-pill {
  position: absolute;
  top: 3px;
  bottom: 3px;
  background: var(--navy);
  border-radius: 100px;
  transition: all 0.35s var(--ease);
  z-index: 1;
  pointer-events: none;
}

/* ============================================================
   STAGE — neutral grey surround for color-correct viewing
   ============================================================ */
.stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  background: var(--surround);
  position: relative;
  min-height: 0;
}

.video-frame {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  position: relative;
  border-radius: 4px;
  /* Note: overflow:hidden moved to .video-frame > video / .plyr so the
     ::after rainbow glow during Color Show can render outside the frame. */
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.10),
    0 30px 60px -20px rgba(15, 23, 42, 0.35),
    0 50px 100px -30px rgba(30, 58, 138, 0.18);
  transition: box-shadow 0.5s var(--ease);
}

.video-frame.has-stream {
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.12),
    0 30px 60px -20px rgba(15, 23, 42, 0.45),
    0 50px 100px -30px rgba(30, 58, 138, 0.28);
}

/* The <video> element fills the frame with letterboxing, never crops */
.video-frame video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: #000;
  object-fit: contain;
  display: block;
}

/* ============================================================
   PLYR PLAYER STYLING (themed to Color Room)
   ============================================================ */

/* Plyr container fills the frame */
.video-frame .plyr {
  width: 100%;
  height: 100%;
  border-radius: 4px;
  overflow: hidden;
  --plyr-control-spacing: 12px;
}

.plyr--video,
.plyr__poster { background-color: #000 !important; }

/* Big centered play button (when paused) */
.plyr__control--overlaid {
  background: rgba(37, 99, 235, 0.95) !important;
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.55),
              0 0 0 1px rgba(255, 255, 255, 0.10);
  transition: all 0.3s var(--ease);
}

.plyr__control--overlaid:hover,
.plyr__control--overlaid:focus {
  background: var(--navy-bright) !important;
  transform: translate(-50%, -50%) scale(1.06);
}

/* Bottom control bar */
.plyr--video .plyr__controls {
  padding: 14px 16px 12px;
  background: linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.85) 100%);
}

.plyr--video .plyr__control:hover {
  background: var(--navy-bright) !important;
  color: #fff !important;
}

.plyr--full-ui input[type=range] { color: var(--navy-bright); }

.plyr--full-ui input[type=range]::-webkit-slider-thumb {
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.4);
}

.plyr__progress__buffer { color: rgba(255, 255, 255, 0.22); }

.plyr__menu__container {
  border: 1px solid var(--border);
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.18);
}

/* Make sure the underlying <video> never crops */
.video-frame video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

/* ============================================================
   GO LIVE button — injected into Plyr's bottom control bar.
   Visible only when the player is more than ~2s behind the live edge.
   By using Plyr's own `.plyr__control` class, the button inherits the
   look (size, focus ring, animations) of the other Plyr buttons.
   ============================================================ */
.plyr__control--live {
  /* Hidden by default; revealed via .show class when behind live edge */
  display: none;
  align-items: center;
  gap: 6px;
  padding: 0 10px !important;       /* override Plyr's default square padding */
  margin: 0 4px;
  height: 32px;
  border-radius: 16px !important;
  background: rgba(220, 38, 38, 0.92) !important;
  color: #fff !important;
  font-family: 'Rubik', sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.10) inset;
  transition: background 0.18s var(--ease), transform 0.15s var(--ease);
  -webkit-tap-highlight-color: transparent;
}

.plyr__control--live.show {
  display: inline-flex;
}

.plyr__control--live:hover {
  background: rgba(220, 38, 38, 1) !important;
  color: #fff !important;
  transform: translateY(-1px);
}

.plyr__control--live:active {
  transform: translateY(0);
}

.plyr__control--live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #fff;
  flex-shrink: 0;
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.7);
  animation: live-btn-pulse 1.4s ease-in-out infinite;
}

.plyr__control--live-text {
  display: inline-block;
  line-height: 1;
}

@keyframes live-btn-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.55; transform: scale(0.85); }
}

/* ============================================================
   UNMUTE BANNER (after muted autoplay fallback)
   ============================================================ */
.unmute-banner {
  position: absolute;
  top: 14px;
  left: 14px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 8px 14px 8px 12px;
  background: rgba(15, 23, 42, 0.85);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 100px;
  font-family: 'Rubik', sans-serif;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  cursor: pointer;
  z-index: 10;
  opacity: 0;
  transform: translateY(-8px) scale(0.92);
  pointer-events: none;
  transition:
    opacity 0.35s var(--ease),
    transform 0.45s var(--ease-out),
    background 0.2s var(--ease);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.40);
  -webkit-tap-highlight-color: transparent;
}

.unmute-banner.show {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
  /* Subtle attention-grabber — once on first show */
  animation: unmute-attention 1.6s ease-out 0.4s 1;
}

@keyframes unmute-attention {
  0%, 100% { transform: translateY(0) scale(1); }
  20%      { transform: translateY(0) scale(1.04); }
  40%      { transform: translateY(0) scale(1); }
  60%      { transform: translateY(0) scale(1.02); }
}

.unmute-banner:hover {
  background: rgba(15, 23, 42, 0.95);
  transform: translateY(-1px) scale(1.02);
}

.unmute-banner svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  color: rgba(255, 255, 255, 0.7);
  z-index: 5;
  background: #000;
  transition: opacity 0.5s var(--ease);
}

.empty-state.hidden {
  opacity: 0;
  pointer-events: none;
}

.gray-bars {
  display: flex;
  width: clamp(180px, 35vw, 320px);
  aspect-ratio: 4 / 1;
  margin-bottom: 32px;
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}

.gray-bars::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.06) 50%, transparent 100%);
  animation: scan 4s ease-in-out infinite;
}

@keyframes scan {
  0%, 100% { transform: translateX(-100%); }
  50%      { transform: translateX(100%); }
}

.gray-bars div { flex: 1; }
.gray-bars div:nth-child(1) { background: #f5f5f5; }
.gray-bars div:nth-child(2) { background: #c8c8c8; }
.gray-bars div:nth-child(3) { background: #999999; }
.gray-bars div:nth-child(4) { background: #707070; }
.gray-bars div:nth-child(5) { background: #4a4a4a; }
.gray-bars div:nth-child(6) { background: #2a2a2a; }
.gray-bars div:nth-child(7) { background: #0a0a0a; }

.empty-title {
  font-size: clamp(15px, 2.4vw, 19px);
  font-weight: 500;
  letter-spacing: -0.005em;
  color: #fff;
  margin-bottom: 10px;
}

.empty-sub {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.5);
  text-align: center;
  padding: 0 20px;
}

/* ============================================================
   CONTROLS PANEL
   ============================================================ */
.controls {
  border-top: 1px solid var(--border-soft);
  background: linear-gradient(180deg, var(--bg-soft), var(--bg-deep));
  padding: 18px 28px 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex-shrink: 0;
  position: relative;
}

.controls::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, var(--navy-bright) 50%, transparent 100%);
  opacity: 0.30;
}

.url-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.url-input-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 0 14px;
  transition: all 0.25s var(--ease);
  min-width: 0;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.02), inset 0 1px 2px rgba(0, 0, 0, 0.02);
}

.url-input-wrap:focus-within {
  border-color: var(--navy-bright);
  box-shadow: 0 0 0 3px var(--navy-soft), inset 0 1px 2px rgba(0, 0, 0, 0.02);
}

.url-icon {
  color: var(--navy-bright);
  font-size: 14px;
  line-height: 1;
  user-select: none;
  flex-shrink: 0;
}

.url-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: 'Rubik', sans-serif;
  font-size: 13.5px;
  font-weight: 400;
  padding: 12px 0;
  min-width: 0;
}

.url-input::placeholder { color: var(--text-mute); }
.url-input::selection { background: var(--navy-soft); }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  background: #fff;
  border: 1px solid var(--border-strong);
  color: var(--text);
  font-family: 'Rubik', sans-serif;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.005em;
  padding: 11px 20px;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s var(--ease);
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}

.btn:hover {
  border-color: var(--text-dim);
  background: var(--bg-soft);
  transform: translateY(-1px);
  box-shadow: 0 3px 6px rgba(15, 23, 42, 0.08);
}

.btn:active { transform: translateY(0); box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05); }

.btn-primary {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 4px 14px -4px var(--navy-glow), 0 1px 0 rgba(255, 255, 255, 0.15) inset;
}

.btn-primary:hover {
  background: var(--navy-bright);
  border-color: var(--navy-bright);
  box-shadow: 0 6px 18px -4px var(--navy-glow), 0 1px 0 rgba(255, 255, 255, 0.2) inset;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.btn-icon svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* ============================================================
   STATS ROW
   ============================================================ */
.stats-row {
  display: flex;
  align-items: center;
  gap: 22px;
  flex-wrap: wrap;
  padding-top: 4px;
}

.stat {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.stat-label {
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-mute);
}

.stat-value {
  color: var(--text);
  font-size: 12.5px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.005em;
  transition: color 0.4s var(--ease);
}

.stat-value.pulse {
  animation: stat-pulse 0.7s var(--ease-out);
}

@keyframes stat-pulse {
  0%   { color: var(--navy-bright); transform: translateY(-1px); }
  100% { color: var(--text);        transform: translateY(0); }
}

.stats-spacer { flex: 1; min-width: 0; }

/* ============================================================
   TOAST
   ============================================================ */
.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(24px) scale(0.95);
  background: var(--text);
  color: var(--bg);
  padding: 12px 22px;
  font-family: 'Rubik', sans-serif;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.005em;
  border-radius: 100px;
  opacity: 0;
  transition:
    opacity 0.35s var(--ease-out),
    transform 0.55s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
  z-index: 1000;
  box-shadow:
    0 20px 50px -10px rgba(15, 23, 42, 0.30),
    0 0 0 1px rgba(255, 255, 255, 0.05);
  max-width: calc(100vw - 40px);
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0) scale(1);
}

/* ============================================================
   FULLSCREEN
   ============================================================ */
:fullscreen .video-frame,
:-webkit-full-screen .video-frame {
  border-radius: 0;
  box-shadow: none;
  aspect-ratio: auto;
}

/* ============================================================
   RESPONSIVE: TABLET
   ============================================================ */
@media (max-width: 900px) {
  .topbar { padding: 14px 18px; }
  .stage { padding: 18px; }
  .controls { padding: 14px 18px 16px; gap: 12px; }
  .brand-tag { display: none; }
  .stats-row { gap: 16px; }
}

/* ============================================================
   RESPONSIVE: MOBILE
   ============================================================ */
@media (max-width: 640px) {
  .topbar {
    padding: 11px 14px;
    gap: 8px;
  }

  .brand-mark { width: 28px; height: 28px; }
  .brand-name { font-size: 14px; }

  .toolbar { gap: 6px; }
  .status-pill {
    padding: 5px 11px 5px 11px;
    font-size: 9.5px;
    letter-spacing: 0.12em;
    gap: 6px;
  }
  /* Keep status text visible on mobile, just compact it */
  .status-pill .status-text {
    max-width: 90px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .lang-btn { padding: 4px 9px; font-size: 10px; }

  .stage { padding: 8px; }

  .controls {
    padding: 12px 14px 14px;
    gap: 12px;
    padding-bottom: max(14px, env(safe-area-inset-bottom));
  }

  .url-row { flex-wrap: wrap; gap: 8px; }

  .url-input-wrap { width: 100%; order: 1; padding: 0 12px; }
  .url-input { font-size: 16px; padding: 11px 0; }   /* 16px prevents iOS zoom on focus */

  .btn {
    flex: 1;
    padding: 11px 14px;
    font-size: 13px;
    order: 2;
  }

  /* On mobile, share button shows only icon to save space */
  #share-btn span { display: none; }
  #share-btn { flex: 0 0 auto; padding: 11px 14px; }
  #share-btn svg { width: 16px; height: 16px; margin: 0; }

  .stats-row {
    gap: 10px 16px;
    padding-top: 2px;
  }
  .stat-label { font-size: 9px; letter-spacing: 0.18em; }
  .stat-value { font-size: 11.5px; }

  /* On mobile call-enabled pages we have a "Show video call" button
     in the same row — hide the Codec stat to keep the button on the
     same line. Codec is rarely actionable info on a phone anyway.
     Single-stream pages keep all stats since they have no button. */
  .controls:has([data-action="toggle-pane"]) .stat[data-key="codec"] {
    display: none;
  }

  .stats-spacer { flex-basis: 100%; height: 0; }

  .gray-bars { width: 220px; margin-bottom: 24px; }
  .empty-title { font-size: 16px; }
  .empty-sub { font-size: 9px; letter-spacing: 0.20em; }

  /* Plyr — compact controls on mobile */
  .plyr--video .plyr__controls { padding: 10px 10px 8px; }
  .plyr__control { padding: 6px !important; }
  .plyr--video .plyr__volume input[type=range] { display: none; }   /* mute toggle is enough */

  /* Unmute banner */
  .unmute-banner { top: 10px; left: 10px; padding: 7px 12px 7px 10px; font-size: 10.5px; gap: 7px; }
  .unmute-banner svg { width: 13px; height: 13px; }

  /* GO LIVE button — slightly more compact on mobile */
  .plyr__control--live { height: 28px; padding: 0 9px !important; font-size: 10px; gap: 5px; }
  .plyr__control--live-dot { width: 6px; height: 6px; }
}

@media (max-width: 420px) {
  .topbar { padding: 10px 12px; }
  /* Brand-text and FPS stat stay visible at all sizes — user requested. */
  /* For very small screens we make brand-text more compact instead. */
  .brand-name { font-size: 14px; }
  .brand-tag { font-size: 10px; }
  /* Compact stats so they don't overflow */
  .stat { padding: 6px 8px; }
  .stat-label { font-size: 9.5px; }
  .stat-value { font-size: 13px; }
}

@media (max-width: 360px) {
  .stat[data-key="latency"] { display: none; }
}

/* Landscape mobile — prioritize video real estate */
@media (max-width: 900px) and (orientation: landscape) and (max-height: 500px) {
  .topbar { padding: 6px 14px; }
  .brand-tag { display: none; }
  .stage { padding: 4px; }
  .controls { padding: 6px 14px; gap: 6px; }
  .stats-row { display: none; }
  .url-row { flex-wrap: nowrap; }
  .url-row > .btn:not(.btn-primary) { display: none; }
  .url-input-wrap { width: auto; flex: 1; }
}

/* ============================================================
   COLOR SHOW — epic rainbow easter egg
   Body gets `.color-show` class, optionally `.color-show-fading`
   during the final 0.9s fade-out.
   ============================================================ */

/* ---- Fireworks canvas (always present, but dormant outside show) ---- */
.cs-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 9999;       /* above everything */
}

/* ---- Topbar shake on activation (subtle impact, doesn't disturb video) ---- */
body.color-show .topbar {
  animation: cs-shake 0.55s var(--ease-out) 1;
}
@keyframes cs-shake {
  0%, 100% { transform: translate(0, 0); }
  10%      { transform: translate(-3px, 1px); }
  20%      { transform: translate(4px, -2px); }
  35%      { transform: translate(-3px, 2px); }
  50%      { transform: translate(3px, 1px); }
  70%      { transform: translate(-2px, -1px); }
  85%      { transform: translate(1px, 1px); }
}

/* ---- Brand mark: aggressive spin + heartbeat pulse + drop-shadow ---- */
body.color-show .brand-mark {
  animation:
    cs-spin 2.8s linear infinite,
    cs-heartbeat 0.8s var(--ease) infinite;
  cursor: pointer;
}
body.color-show .brand-mark:hover { transform: none; }
body.color-show .brand-mark img,
body.color-show .brand-mark svg {
  /* Override the slow idle-spin (60s) — the .brand-mark wrapper is
     already spinning fast via cs-spin, and stacking both rotations
     would cancel/conflict. Keep only the rainbow shadow cycle. */
  animation: cs-shadow-cycle 2s linear infinite;
}

@keyframes cs-spin {
  to { transform: rotate(360deg); }
}
@keyframes cs-heartbeat {
  0%, 100%  { transform: scale(1) rotate(var(--cs-r, 0)); }
  20%       { transform: scale(1.18); }
  40%       { transform: scale(0.95); }
  60%       { transform: scale(1.10); }
}
@keyframes cs-shadow-cycle {
  0%   { filter: drop-shadow(0 0 12px #ef4444) drop-shadow(0 0 24px rgba(239,68,68,0.5)); }
  16%  { filter: drop-shadow(0 0 12px #f59e0b) drop-shadow(0 0 24px rgba(245,158,11,0.5)); }
  33%  { filter: drop-shadow(0 0 12px #22c55e) drop-shadow(0 0 24px rgba(34,197,94,0.5)); }
  50%  { filter: drop-shadow(0 0 12px #06b6d4) drop-shadow(0 0 24px rgba(6,182,212,0.5)); }
  66%  { filter: drop-shadow(0 0 12px #3b82f6) drop-shadow(0 0 24px rgba(59,130,246,0.5)); }
  83%  { filter: drop-shadow(0 0 12px #a855f7) drop-shadow(0 0 24px rgba(168,85,247,0.5)); }
  100% { filter: drop-shadow(0 0 12px #ef4444) drop-shadow(0 0 24px rgba(239,68,68,0.5)); }
}

/* The pulsing glow halo around the logo cycles through the rainbow */
body.color-show .brand-mark::after {
  animation: cs-glow-cycle 2s linear infinite !important;
  opacity: 1 !important;
  inset: -14px !important;
  filter: blur(10px);
}

@keyframes cs-glow-cycle {
  0%   { background: radial-gradient(circle, #ef4444 0%, transparent 65%); }
  16%  { background: radial-gradient(circle, #f59e0b 0%, transparent 65%); }
  33%  { background: radial-gradient(circle, #22c55e 0%, transparent 65%); }
  50%  { background: radial-gradient(circle, #06b6d4 0%, transparent 65%); }
  66%  { background: radial-gradient(circle, #3b82f6 0%, transparent 65%); }
  83%  { background: radial-gradient(circle, #a855f7 0%, transparent 65%); }
  100% { background: radial-gradient(circle, #ef4444 0%, transparent 65%); }
}

/* ---- Atmospheric blobs go full rainbow ---- */
body.color-show .atmosphere::before {
  animation: cs-blob1 4.5s ease-in-out infinite !important;
  opacity: 0.55 !important;
  filter: blur(80px) saturate(1.8);
}
body.color-show .atmosphere::after {
  animation: cs-blob2 4.5s ease-in-out infinite !important;
  opacity: 0.45 !important;
  filter: blur(80px) saturate(1.8);
}

@keyframes cs-blob1 {
  0%   { background: radial-gradient(circle, #ef4444 0%, transparent 60%); transform: translate(0, 0) scale(1); }
  25%  { background: radial-gradient(circle, #f59e0b 0%, transparent 60%); transform: translate(80px, 50px) scale(1.25); }
  50%  { background: radial-gradient(circle, #22c55e 0%, transparent 60%); transform: translate(50px, 90px) scale(1.15); }
  75%  { background: radial-gradient(circle, #a855f7 0%, transparent 60%); transform: translate(-30px, 70px) scale(1.3); }
  100% { background: radial-gradient(circle, #ef4444 0%, transparent 60%); transform: translate(0, 0) scale(1); }
}
@keyframes cs-blob2 {
  0%   { background: radial-gradient(circle, #06b6d4 0%, transparent 60%); transform: translate(0, 0) scale(1); }
  25%  { background: radial-gradient(circle, #3b82f6 0%, transparent 60%); transform: translate(-60px, -70px) scale(1.2); }
  50%  { background: radial-gradient(circle, #a855f7 0%, transparent 60%); transform: translate(-90px, -30px) scale(1.25); }
  75%  { background: radial-gradient(circle, #ec4899 0%, transparent 60%); transform: translate(-40px, -80px) scale(1.1); }
  100% { background: radial-gradient(circle, #06b6d4 0%, transparent 60%); transform: translate(0, 0) scale(1); }
}

/* ---- Video frame: no rainbow glow during Color Show (user request).
   The page-wide rainbow on text, buttons and atmosphere is enough. */

/* ---- Primary button: animated rainbow gradient ----
   Multiple selector variants ensure this beats the base .btn:hover,
   :focus, :active, and any transition that might absorb the
   background-position animation. */
body.color-show .btn-primary,
body.color-show .btn-primary:hover,
body.color-show .btn-primary:focus,
body.color-show .btn-primary:active,
body.color-show #load-btn,
body.color-show #load-btn:hover,
body.color-show #load-btn:focus,
body.color-show #load-btn:active {
  /* The gradient is rendered as a tile that repeats horizontally so
     animating background-position produces a seamless rainbow river
     with no gaps. The keyframes cycle one tile width (200%) so the
     animation loops perfectly without the start-position flashing
     through transparent space. */
  background-image: linear-gradient(
    90deg,
    #ef4444 0%, #f59e0b 16%, #22c55e 33%, #06b6d4 50%,
    #3b82f6 66%, #a855f7 83%, #ef4444 100%
  ) !important;
  background-color: #ef4444 !important;       /* fallback so we never see white */
  background-size: 200% 100% !important;
  background-repeat: repeat !important;
  border-color: transparent !important;
  color: #fff !important;
  animation: cs-btn-flow 3s linear infinite !important;
  box-shadow: 0 4px 24px -4px rgba(168, 85, 247, 0.55),
              0 1px 0 rgba(255, 255, 255, 0.2) inset !important;
  transition: none !important;
  transform: none !important;
}
@keyframes cs-btn-flow {
  0%   { background-position:   0% 50%; }
  100% { background-position: 200% 50%; }
}

/* ---- Brand title: rainbow text ---- */
body.color-show .brand-name {
  background: linear-gradient(
    90deg,
    #ef4444, #f59e0b, #22c55e, #06b6d4, #3b82f6, #a855f7, #ef4444
  );
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  animation: cs-text-flow 3.5s linear infinite;
}
@keyframes cs-text-flow {
  0%   { background-position:   0% 0; }
  100% { background-position: 200% 0; }
}

/* ---- Stat values: cycle colour ---- */
body.color-show .stat-value {
  animation: cs-stat-tint 3s linear infinite;
}
@keyframes cs-stat-tint {
  0%   { color: #ef4444; }
  16%  { color: #f59e0b; }
  33%  { color: #22c55e; }
  50%  { color: #06b6d4; }
  66%  { color: #3b82f6; }
  83%  { color: #a855f7; }
  100% { color: #ef4444; }
}

/* ---- Pills/inputs: rainbow border ---- */
body.color-show .status-pill,
body.color-show .lang-switch,
body.color-show .url-input-wrap {
  animation: cs-pill-border 3s linear infinite;
}
@keyframes cs-pill-border {
  0%   { border-color: rgba(239, 68, 68, 0.65); }
  16%  { border-color: rgba(245, 158, 11, 0.65); }
  33%  { border-color: rgba(34, 197, 94, 0.65); }
  50%  { border-color: rgba(6, 182, 212, 0.65); }
  66%  { border-color: rgba(59, 130, 246, 0.65); }
  83%  { border-color: rgba(168, 85, 247, 0.65); }
  100% { border-color: rgba(239, 68, 68, 0.65); }
}

/* ---- Soft fade-out as the show ends ---- */
body.color-show.color-show-fading .brand-mark,
body.color-show.color-show-fading .brand-mark::after,
body.color-show.color-show-fading .atmosphere::before,
body.color-show.color-show-fading .atmosphere::after,
body.color-show.color-show-fading .btn-primary,
body.color-show.color-show-fading .brand-name,
body.color-show.color-show-fading .stat-value,
body.color-show.color-show-fading .status-pill,
body.color-show.color-show-fading .lang-switch,
body.color-show.color-show-fading .url-input-wrap,
body.color-show.color-show-fading .video-frame {
  transition: all 0.9s var(--ease-out);
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================================
   WHEP source — bitrate, codec, fps come from getStats() in
   source-whep.js. Latency is hidden because WebRTC is
   inherently low-latency and the computed value (jitter buffer
   delay + RTT/2) drifts in ways that mislead more than inform.
   ============================================================ */
.video-frame[data-kind="whep"] ~ .controls .stat[data-key="latency"],
.stage:has(.video-frame[data-kind="whep"]) ~ .controls .stat[data-key="latency"] {
  display: none;
}

/* ============================================================
   HOST PAGE — guest link generator (index.html)
   ============================================================ */
body.host-page .topbar { border-bottom: none; }

.host-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  min-height: 0;
}

.host-card {
  background: #ffffff;
  border-radius: 16px;
  padding: 36px 36px 32px;
  width: 100%;
  max-width: 560px;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04),
              0 30px 60px -20px rgba(15, 23, 42, 0.12),
              0 50px 100px -30px rgba(30, 58, 138, 0.08);
}

.host-title {
  margin: 0 0 8px;
  font-family: 'Rubik', sans-serif;
  font-size: 26px;
  font-weight: 700;
  color: var(--navy);
  letter-spacing: -0.5px;
}

.host-sub {
  margin: 0 0 22px;
  font-family: 'Rubik', sans-serif;
  font-size: 14px;
  font-weight: 400;
  color: #475569;
  line-height: 1.5;
}

.host-input-row {
  display: flex;
  margin-bottom: 14px;
}

.host-input-row .url-input-wrap {
  flex: 1;
}

.host-detect {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 10px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  font-family: 'Rubik', sans-serif;
  font-size: 13px;
  margin-bottom: 18px;
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease);
}

.host-detect-label {
  color: #64748b;
  font-weight: 500;
}

.host-detect-value {
  color: #94a3b8;
  font-weight: 600;
}

.host-detect[data-state="hls"] {
  background: #eff6ff;
  border-color: #bfdbfe;
}
.host-detect[data-state="hls"] .host-detect-value {
  color: #1e3a8a;
}

.host-detect[data-state="whep"] {
  background: #f0fdf4;
  border-color: #bbf7d0;
}
.host-detect[data-state="whep"] .host-detect-value {
  color: #15803d;
}

.host-detect[data-state="invalid"] {
  background: #fef2f2;
  border-color: #fecaca;
}
.host-detect[data-state="invalid"] .host-detect-value {
  color: #b91c1c;
  font-weight: 500;
  font-size: 12.5px;
}

.host-link-row {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.host-link-input {
  flex: 1;
  min-width: 0;
  padding: 11px 14px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #f8fafc;
  font-family: 'Rubik', sans-serif;
  font-size: 13px;
  color: #1e293b;
  cursor: text;
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease);
}

.host-link-input:focus,
.host-link-input:hover {
  outline: none;
  border-color: var(--navy-bright);
  background: #ffffff;
}

.host-link-row .btn {
  flex-shrink: 0;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.btn-secondary {
  background: #f1f5f9;
  color: var(--navy);
  border: 1px solid #cbd5e1;
}
.btn-secondary:hover {
  background: #e2e8f0;
  border-color: #94a3b8;
}

.host-hint {
  margin: 0;
  font-family: 'Rubik', sans-serif;
  font-size: 12px;
  font-weight: 400;
  color: #94a3b8;
  line-height: 1.5;
}

@media (max-width: 640px) {
  .host-card { padding: 24px 18px; }
  .host-title { font-size: 22px; }
  .host-sub { font-size: 13px; }
  .host-link-row { flex-direction: column; }
  .host-link-row .btn { width: 100%; justify-content: center; }
}

/* ============================================================
   GSAP-STYLE EFFECTS
   ============================================================ */

/* ---- SMPTE Colour Bars in empty state ---- */
.smpte-bars {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  pointer-events: none;
  opacity: 0.32;             /* sit behind the No Signal text */
  z-index: 0;
  /* Subtle scanline shimmer */
  background:
    repeating-linear-gradient(
      0deg,
      rgba(0,0,0,0) 0,
      rgba(0,0,0,0) 2px,
      rgba(0,0,0,0.06) 2px,
      rgba(0,0,0,0.06) 3px
    );
}
.smpte-bars-top { flex: 0 0 66%; display: flex; }
.smpte-bars-mid { flex: 0 0  9%; display: flex; }
.smpte-bars-bot { flex: 0 0 25%; display: flex; }
.smpte-bars-top > *,
.smpte-bars-mid > *,
.smpte-bars-bot > * { flex: 1 1 0; }

/* The overlaid No-Signal text needs to sit above the bars */
.empty-state > *:not(.smpte-bars) { position: relative; z-index: 1; }

/* Make the empty state plate transparent so bars show through */
.empty-state {
  background: rgba(0, 0, 0, 0.55) !important;
}

@media (max-width: 640px) {
  .smpte-bars { opacity: 0.28; }
}

/* ---- Breathing frame while live (extremely subtle) ---- */
.video-frame.breathing {
  animation: frame-breathe 4.5s ease-in-out infinite;
}
@keyframes frame-breathe {
  0%, 100% {
    box-shadow:
      0 0 0 1px rgba(0, 0, 0, 0.12),
      0 30px 60px -20px rgba(15, 23, 42, 0.45),
      0 50px 100px -30px rgba(30, 58, 138, 0.28);
  }
  50% {
    box-shadow:
      0 0 0 1px rgba(0, 0, 0, 0.12),
      0 32px 66px -20px rgba(15, 23, 42, 0.50),
      0 56px 110px -30px rgba(30, 58, 138, 0.34);
  }
}

/* ---- Status pill state-change ripple ---- */
.status-pill {
  position: relative;
}
.status-pill.state-change::after {
  content: '';
  position: absolute;
  left: 8px;
  top: 50%;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: currentColor;
  opacity: 0.7;
  pointer-events: none;
  animation: status-ripple 0.7s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
@keyframes status-ripple {
  0%   { transform: translate(-50%, -50%) scale(0.8); opacity: 0.7; }
  100% { transform: translate(-50%, -50%) scale(4.5); opacity: 0;   }
}
/* Smooth tween between state colours on the pill border/background */
.status-pill {
  transition:
    background 0.45s cubic-bezier(0.16, 1, 0.3, 1),
    color 0.45s cubic-bezier(0.16, 1, 0.3, 1),
    border-color 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}
.status-pill .status-dot {
  transition: background 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ---- Reduced motion — kill everything decorative ---- */
@media (prefers-reduced-motion: reduce) {
  .video-frame.breathing,
  .status-pill.state-change::after {
    animation: none !important;
  }
}

/* ============================================================
   HOST CALL TOGGLE — "with call" switch + Jitsi URL field
   ============================================================ */
.host-call-toggle {
  margin: 16px 0 18px;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
  font-family: 'Rubik', sans-serif;
  font-size: 14px;
  color: #475569;
}

.toggle-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle-track {
  position: relative;
  flex-shrink: 0;
  width: 38px;
  height: 22px;
  background: #cbd5e1;
  border-radius: 12px;
  transition: background 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.2);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1),
              background 0.3s ease;
}
.toggle-input:checked + .toggle-track {
  background: var(--navy-bright);
}
.toggle-input:checked + .toggle-track .toggle-thumb {
  transform: translateX(16px);
}
.toggle-input:focus-visible + .toggle-track {
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.25);
}

.toggle-label {
  flex: 1;
  line-height: 1.4;
}

.host-call-url-wrap {
  margin-top: 12px;
  margin-bottom: 14px;
  animation: call-url-reveal 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}
@keyframes call-url-reveal {
  from { opacity: 0; transform: translateY(-6px); max-height: 0; }
  to   { opacity: 1; transform: translateY(0); max-height: 100px; }
}

/* ============================================================
   DUAL PANE — viewer-call / viewer-whep-call layouts
   ============================================================ */
.dual-pane {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  overflow: hidden;
}

.pane {
  position: relative;
  flex: 1 1 50%;
  min-width: 0;
  height: 100%;
  transition: flex-basis 0.45s cubic-bezier(0.16, 1, 0.3, 1),
              opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}

.pane[data-pane="player"] {
  /* Player pane keeps the existing video-frame styles; nothing extra */
}

.pane[data-pane="call"] {
  background: #0f172a;
  border-radius: 4px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.pane[data-pane="call"] .jitsi-container {
  flex: 1;
  width: 100%;
  height: 100%;
  background: #0f172a;
}
.pane[data-pane="call"] .jitsi-container iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}
.pane[data-pane="call"] .call-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 14px;
  color: rgba(255, 255, 255, 0.7);
  font-family: 'Rubik', sans-serif;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.4s ease;
}
.pane[data-pane="call"].loaded .call-loading {
  opacity: 0;
}
.call-loading-dot {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: rgba(255, 255, 255, 0.7);
  border-radius: 50%;
  animation: brand-spin 1.1s linear infinite;
}

/* ---- Desktop: side-by-side split with toggle ---- */
.dual-pane-desktop .pane[data-pane="player"] { flex: 1 1 65%; }
.dual-pane-desktop .pane[data-pane="call"]   { flex: 1 1 35%; margin-left: 12px; }

.dual-pane-desktop.split-collapsed .pane[data-pane="player"] { flex: 1 1 100%; }
.dual-pane-desktop.split-collapsed .pane[data-pane="call"]   {
  flex: 0 0 0%;
  margin-left: 0;
  opacity: 0;
  pointer-events: none;
}

/* ---- Mobile: tabs (one pane visible, other off-screen) ---- */
.dual-pane-mobile {
  width: 100%;
  position: relative;
}
.dual-pane-mobile .pane {
  position: absolute;
  inset: 0;
  flex: 1 1 100%;
  transition: transform 0.45s cubic-bezier(0.16, 1, 0.3, 1),
              opacity 0.4s ease;
}
.dual-pane-mobile.pane-player-active .pane[data-pane="player"] {
  transform: translateX(0);
  opacity: 1;
}
.dual-pane-mobile.pane-player-active .pane[data-pane="call"] {
  transform: translateX(100%);
  opacity: 0;
  pointer-events: none;
}
.dual-pane-mobile.pane-call-active .pane[data-pane="player"] {
  transform: translateX(-100%);
  opacity: 0;
  pointer-events: none;
}
.dual-pane-mobile.pane-call-active .pane[data-pane="call"] {
  transform: translateX(0);
  opacity: 1;
}

/* ---- Pane toggle button (in stats bar) ---- */
.pane-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px 6px 10px;
  background: var(--navy);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 100px;
  font-family: 'Rubik', sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.2s var(--ease), transform 0.15s var(--ease);
  flex-shrink: 0;
}
.pane-toggle-btn:hover {
  background: var(--navy-bright);
  transform: translateY(-1px);
}
.pane-toggle-btn:active {
  transform: translateY(0);
}
.pane-toggle-btn-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* ============================================================
   NAME MODAL — first-visit ask-for-name dialog
   ============================================================ */
.name-modal-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  z-index: 9000;
  transition: opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
.name-modal-overlay.show { opacity: 1; }
.name-modal-overlay.hide { opacity: 0; }

.name-modal-card {
  background: #fff;
  border-radius: 18px;
  padding: 28px 28px 24px;
  width: min(420px, 92vw);
  box-shadow: 0 30px 60px -15px rgba(15, 23, 42, 0.4),
              0 50px 100px -30px rgba(30, 58, 138, 0.25);
  transform: translateY(14px) scale(0.96);
  transition: transform 0.45s cubic-bezier(0.16, 1, 0.3, 1);
  font-family: 'Rubik', sans-serif;
}
.name-modal-overlay.show .name-modal-card {
  transform: translateY(0) scale(1);
}
.name-modal-overlay.hide .name-modal-card {
  transform: translateY(-8px) scale(0.97);
}

.name-modal-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--navy);
  letter-spacing: -0.5px;
  margin-bottom: 6px;
}
.name-modal-sub {
  font-size: 13.5px;
  font-weight: 400;
  color: #64748b;
  line-height: 1.5;
  margin-bottom: 18px;
}
.name-modal-input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #f8fafc;
  font-family: 'Rubik', sans-serif;
  font-size: 16px;          /* prevent iOS zoom */
  font-weight: 500;
  color: #1e293b;
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease);
  -webkit-appearance: none;
}
.name-modal-input:focus,
.name-modal-input:hover {
  outline: none;
  border-color: var(--navy-bright);
  background: #fff;
}
.name-modal-input.shake {
  animation: name-shake 0.4s ease-out;
  border-color: #dc2626;
}
@keyframes name-shake {
  0%, 100% { transform: translateX(0); }
  25%      { transform: translateX(-5px); }
  50%      { transform: translateX(5px); }
  75%      { transform: translateX(-3px); }
}

.name-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}
.name-modal-actions .btn {
  min-width: 120px;
}

/* Mic toggle inside the name modal — a square button with an
   animated mic glyph. No physical switch; the button itself is
   the control. State is reflected via aria-pressed. */
.name-modal-mic-row {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.name-modal-mic-label {
  font-family: 'Rubik', sans-serif;
  font-size: 13.5px;
  font-weight: 500;
  color: #334155;
  letter-spacing: 0.01em;
  transition: color 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* The square mic button itself.
   Default (off): subtle red tint to convey "muted".
   Pressed (on): navy accent + soft glow + pulse on the glyph.
*/
.mic-toggle {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: #fef2f2;
  border: 1.5px solid #fecaca;
  border-radius: 12px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition:
    background 0.35s cubic-bezier(0.16, 1, 0.3, 1),
    border-color 0.35s cubic-bezier(0.16, 1, 0.3, 1),
    transform 0.18s cubic-bezier(0.16, 1, 0.3, 1),
    box-shadow 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  color: #b91c1c;          /* mic glyph color when off */
}

.mic-toggle:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px -4px rgba(185, 28, 28, 0.25);
}

.mic-toggle:active {
  transform: translateY(0) scale(0.96);
}

.mic-toggle:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.25);
}

/* Pressed (microphone on) state */
.mic-toggle[aria-pressed="true"] {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: var(--navy-bright);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.08);
}
.mic-toggle[aria-pressed="true"]:hover {
  box-shadow:
    0 0 0 4px rgba(37, 99, 235, 0.10),
    0 4px 12px -4px rgba(37, 99, 235, 0.30);
}
.name-modal-mic-row:has(.mic-toggle[aria-pressed="true"]) .name-modal-mic-label {
  color: var(--navy);
}

/* The icon: line-draw slash on/off + breathing pulse when on */
.mic-icon {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.mic-icon svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}
.mic-icon .mic-slash {
  stroke-dasharray: 24;
  stroke-dashoffset: 0;     /* drawn = visible (off / muted state) */
  transition: stroke-dashoffset 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}

.mic-toggle[aria-pressed="true"] .mic-icon .mic-slash {
  stroke-dashoffset: 24;    /* line-draw retract → invisible */
}
.mic-toggle[aria-pressed="true"] .mic-icon .mic-body {
  animation: mic-pulse 2.2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
  transform-origin: 12px 8.5px;
}

@keyframes mic-pulse {
  0%, 100% { transform: scale(1);     opacity: 1;   }
  50%      { transform: scale(1.06);  opacity: 0.85; }
}

@media (prefers-reduced-motion: reduce) {
  .mic-toggle[aria-pressed="true"] .mic-icon .mic-body { animation: none; }
  .mic-icon .mic-slash { transition: none; }
  .mic-toggle { transition: none; }
}

/* Mobile-specific tweaks */
@media (max-width: 640px) {
  .pane-toggle-btn {
    padding: 5px 10px 5px 9px;
    font-size: 10px;
    gap: 5px;
  }
  .name-modal-card {
    padding: 22px 20px 20px;
  }
  .name-modal-title { font-size: 19px; }
  .name-modal-sub { font-size: 13px; }
  .toggle-label { font-size: 13px; }
}

/* ============================================================
   HOST TABS — three-mode selector
   ============================================================ */
.host-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  margin-bottom: 16px;
}

.host-tab {
  flex: 1;
  padding: 9px 12px;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-family: 'Rubik', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: #64748b;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition:
    background 0.3s cubic-bezier(0.16, 1, 0.3, 1),
    color 0.3s cubic-bezier(0.16, 1, 0.3, 1),
    box-shadow 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.host-tab:hover {
  color: var(--navy);
}
.host-tab.active {
  background: #ffffff;
  color: var(--navy);
  font-weight: 600;
  box-shadow:
    0 1px 2px rgba(15, 23, 42, 0.04),
    0 4px 10px -2px rgba(15, 23, 42, 0.06);
}
.host-tab:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.25);
}

/* host-detect "call" state — green-ish like whep */
.host-detect[data-state="call"] {
  background: #f0fdf4;
  border-color: #bbf7d0;
}
.host-detect[data-state="call"] .host-detect-value {
  color: #15803d;
}

@media (max-width: 640px) {
  .host-tabs { gap: 2px; padding: 3px; }
  .host-tab { padding: 8px 8px; font-size: 11.5px; }
}

/* ============================================================
   CALL PAGE (call.html) — Jitsi only, no player
   ============================================================ */
body.call-page .stage,
body.call-page .controls { display: none; }

.call-stage {
  flex: 1;
  display: flex;
  position: relative;
  min-height: 0;
  padding: 8px 16px 16px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}
@media (max-width: 640px) {
  .call-stage { padding: 8px; padding-bottom: max(8px, env(safe-area-inset-bottom)); }
}

.call-fullscreen {
  flex: 1;
  width: 100%;
  height: 100%;
  background: #0f172a;
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}
.call-fullscreen iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

/* Centered loading state — fades out once Jitsi joins */
body.call-page .call-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 14px;
  color: rgba(255, 255, 255, 0.7);
  font-family: 'Rubik', sans-serif;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  pointer-events: none;
  transition: opacity 0.4s ease;
  z-index: 2;
}

body.call-page .call-error {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ef4444;
  font-family: 'Rubik', sans-serif;
  font-size: 14px;
  font-weight: 500;
  background: #0f172a;
  z-index: 3;
}

/* ============================================================
   FIX: [hidden] attribute must override display:flex/grid

   By default the user agent stylesheet has `[hidden] { display: none }`
   with very low specificity, so any class rule with `display: flex`
   wins and a hidden=true element stays visible. We override here.
   ============================================================ */
[hidden] { display: none !important; }

/* Disabled action buttons in host link row — when no valid link
   is ready yet. Visually subdued, no pointer events. */
.host-link-row .btn:disabled,
.host-link-row .btn.btn-disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
  filter: grayscale(0.4);
}
