:root {
  --mint: #04c294;
  --mint-2: #01c08d;
  --text: #f3f5f7;
  --muted: #7a8494;
  --green: #04c294;
  --red: #f6465d;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  max-width: 100%;
  background: #010206;
  color: var(--text);
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
a { color: inherit; text-decoration: none; }
button, input { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0);
}
.app { height: 100%; }

.is-pos { color: var(--green); }
.is-neg { color: var(--red); }
.ca-copy { cursor: pointer; }

/* Stream tiles (popup + page) */
.stream-tile {
  position: relative;
  margin: 0;
  overflow: hidden;
  border-radius: 8px;
  background: #111;
}
.stream-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: filter 0.45s ease, transform 0.45s ease;
}
.stream-tile::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 42%;
  pointer-events: none;
  background: linear-gradient(transparent, rgba(0,0,0,0.58));
  z-index: 1;
}
.stream-tile figcaption {
  position: absolute;
  left: 8px;
  bottom: 8px;
  z-index: 2;
  display: flex;
  flex-direction: column;
  font-weight: 700;
  font-size: 11px;
  line-height: 1.25;
  text-shadow: 0 1px 4px #000;
}
.stream-tile figcaption code {
  color: #c5c5c5;
  font-size: 0.85em;
  font-weight: 500;
}
.eq {
  position: absolute;
  right: 8px;
  bottom: 8px;
  z-index: 2;
  width: 16px;
  height: 12px;
  background:
    linear-gradient(var(--mint), var(--mint)) 0 100%/2.5px 40% no-repeat,
    linear-gradient(var(--mint), var(--mint)) 4px 100%/2.5px 80% no-repeat,
    linear-gradient(var(--mint), var(--mint)) 8px 100%/2.5px 55% no-repeat,
    linear-gradient(var(--mint), var(--mint)) 12px 100%/2.5px 70% no-repeat;
  animation: eq 0.7s ease-in-out infinite alternate;
}
@keyframes eq {
  to {
    background:
      linear-gradient(var(--mint), var(--mint)) 0 100%/2.5px 80% no-repeat,
      linear-gradient(var(--mint), var(--mint)) 4px 100%/2.5px 40% no-repeat,
      linear-gradient(var(--mint), var(--mint)) 8px 100%/2.5px 95% no-repeat,
      linear-gradient(var(--mint), var(--mint)) 12px 100%/2.5px 50% no-repeat;
  }
}
.tile-buffer {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  background: rgba(0, 8, 12, 0.28);
  transition: opacity 0.3s ease;
  z-index: 3;
}
.stream-tile .holder-gif {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  pointer-events: none;
  z-index: 2;
  transition: opacity 0.28s ease;
}
.stream-tile.is-connecting .holder-gif { opacity: 1; }
.stream-tile.is-connecting > img:not(.holder-gif):not(.dev-gif):not(.dev-thumb) {
  filter: blur(6px) brightness(0.48);
  transform: scale(1.03);
}
.ax-live-dev .holder-gif { display: none; }
.stream-tile.is-buffering img:not(.holder-gif) { filter: blur(7px) brightness(0.55); transform: scale(1.04); }
.stream-tile.is-buffering .tile-buffer { opacity: 1; }
.stream-tile.is-buffering .tile-buffer::after {
  content: "";
  position: absolute; left: -40%; top: 0; bottom: 0; width: 40%;
  background: linear-gradient(90deg, transparent, rgba(4,194,148,0.16), transparent);
  animation: scan 1.1s linear infinite;
}
@keyframes scan { to { left: 110%; } }

html.popup-deferred .popup-root.is-open,
html.popup-deferred body.popup-open .popup-root { display: none !important; }
html.popup-deferred body.popup-open .app { pointer-events: auto; }
html.popup-deferred body.popup-open {
  overflow-x: hidden;
  overflow-y: auto;
}

.ax-live-dev .dev-thumb,
.ax-live-dev .dev-gif,
.ax-live-dev .dev-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.ax-live-dev .dev-thumb { z-index: 0; }
.ax-live-dev .dev-gif {
  z-index: 1;
  opacity: 0;
  pointer-events: none;
}
.ax-live-dev .dev-video {
  z-index: 1;
  opacity: 0;
  background: #000;
}
.ax-live-dev.is-connecting .dev-gif { opacity: 1; }
.ax-live-dev.is-playing .dev-video { opacity: 1; }
.ax-live-dev.is-stalled .dev-video { opacity: 0.35; filter: blur(5px); }
.ax-live-dev.is-connecting .ax-live-pill { visibility: hidden; }
.ax-live-dev.is-ended .eq { display: none; }
.ax-live-dev.is-ended .dev-video,
.ax-live-dev.is-ended .dev-gif { opacity: 0; pointer-events: none; }

.dev-hud {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: none;
  place-items: center;
  pointer-events: none;
  background: rgba(0, 6, 10, 0.28);
}
.ax-live-dev.is-stalled .dev-hud,
.ax-live-dev.is-paused-flash .dev-hud,
.ax-live-dev.is-play-flash .dev-hud { display: grid; }
.dev-spinner,
.dev-pause-ico,
.dev-play-ico { display: none; }
.dev-hud-label {
  position: absolute;
  top: calc(50% + 28px);
  left: 0;
  right: 0;
  text-align: center;
  font-size: 11px;
  font-weight: 650;
  color: #e8edf2;
  text-shadow: 0 1px 4px #000;
}
.ax-live-dev.is-connecting .dev-spinner,
.ax-live-dev.is-stalled .dev-spinner { display: block; }
.ax-live-dev.is-paused-flash .dev-pause-ico { display: block; }
.ax-live-dev.is-paused-flash .dev-spinner,
.ax-live-dev.is-play-flash .dev-spinner { display: none; }
.ax-live-dev.is-play-flash .dev-play-ico { display: block; }
.ax-live-dev.is-paused-flash .dev-hud-label::after { content: none; }
.ax-live-dev.is-paused-flash .dev-hud-label { visibility: hidden; }
.ax-live-dev.is-play-flash .dev-hud-label { visibility: hidden; }
.dev-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(255,255,255,0.22);
  border-top-color: var(--mint);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.dev-pause-ico,
.dev-play-ico {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: rgba(0,0,0,0.62);
  position: relative;
}
.dev-pause-ico::before,
.dev-pause-ico::after {
  content: "";
  position: absolute;
  top: 11px;
  width: 5px;
  height: 20px;
  background: #fff;
  border-radius: 1px;
}
.dev-pause-ico::before { left: 13px; }
.dev-pause-ico::after { right: 13px; }
.dev-play-ico::before {
  content: "";
  position: absolute;
  left: 16px;
  top: 11px;
  border-style: solid;
  border-width: 10px 0 10px 16px;
  border-color: transparent transparent transparent #fff;
}

.dev-ended-join {
  position: absolute;
  left: 50%;
  top: 54%;
  transform: translate(-50%, -50%);
  z-index: 6;
  display: none;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 0 16px;
  border-radius: 9px;
  background: var(--mint);
  color: #04140c;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
  box-shadow: 0 10px 28px rgba(0,0,0,0.5);
}
.ax-live-dev.is-ended .dev-ended-join { display: flex; }

/* Popup ? solid card, no blur, no stacked/ghost text */
.popup-root {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
  align-items: center;
  justify-content: center;
}
.popup-root.is-open,
body.popup-open .popup-root { display: flex; }
body.popup-open {
  overflow: hidden;
}
body.popup-open .app {
  pointer-events: none;
  filter: none;
}
.popup-dim {
  position: absolute;
  inset: 0;
  background: rgba(0, 2, 8, 0.58);
  opacity: 1;
}
.popup-card {
  position: relative;
  z-index: 2;
  width: min(416px, calc(100vw - 24px));
  max-height: min(92dvh, 720px);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 16px max(14px, env(safe-area-inset-bottom));
  border-radius: 14px;
  background: #0c1016;
  color: #f3f5f7;
  border: 1px solid #1c2430;
  box-shadow: 0 24px 70px rgba(0,0,0,0.85);
  isolation: isolate;
  opacity: 1;
}
.pop-head {
  display: flex;
  align-items: center;
  gap: 8px;
}
.pop-live {
  background: #e11d2e;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  border-radius: 4px;
  padding: 2px 6px;
}
.pop-now { font-size: 13px; font-weight: 600; color: #e8edf2; }
.pop-wave {
  width: 26px;
  height: 10px;
  background:
    radial-gradient(circle at 4px 5px, #e11d2e 2px, transparent 2.4px),
    radial-gradient(circle at 12px 5px, #e11d2e 2px, transparent 2.4px),
    radial-gradient(circle at 20px 5px, #e11d2e 2px, transparent 2.4px);
  opacity: 0.95;
}
#closePopup {
  margin-left: auto;
  width: 28px;
  height: 28px;
  border: 0;
  background: none;
  color: #9aa3ae;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.popup-card h2 {
  margin-top: 10px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: #fff;
}
.pop-sub {
  margin-top: 3px;
  color: #9aa3ae;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pop-grid {
  display: grid;
  grid-template-columns: 1.72fr 1fr;
  gap: 8px;
  margin-top: 12px;
  height: 186px;
}
.pop-holders {
  display: grid;
  grid-template-rows: 1fr 1fr 1fr;
  gap: 8px;
  min-height: 0;
}
.pop-dev, .pop-h1, .pop-h2, .pop-h3 { height: 100%; min-height: 0; }
.popup-card .stream-tile figcaption {
  font-size: 10px;
  left: 7px;
  bottom: 6px;
  line-height: 1.2;
  max-width: calc(100% - 28px);
  overflow: hidden;
}
.popup-card .stream-tile.is-buffering img:not(.holder-gif),
#popupStream .stream-tile.is-buffering img:not(.holder-gif) {
  filter: none !important;
  transform: none !important;
}
.popup-card .stream-tile.is-connecting > img:not(.holder-gif) {
  filter: blur(5px) brightness(0.5) !important;
}
.popup-card .tile-buffer { display: none; }

.popup-chat {
  margin-top: 10px;
  height: 78px;
  overflow: hidden;
  background: #080b10;
  border: 1px solid #151c24;
  border-radius: 8px;
  padding: 0 10px;
  font-size: 12px;
}
.popup-chat .pop-line {
  display: grid;
  grid-template-columns: 16px max-content minmax(0, 1fr) 56px;
  gap: 6px;
  align-items: center;
  white-space: nowrap;
  overflow: hidden;
  height: 26px;
  line-height: 1;
}
.popup-chat .pop-av {
  width: 14px;
  height: 14px;
  border-radius: 50%;
}
.popup-chat b {
  font-size: 12px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 92px;
}
.popup-chat b.c0 { color: #04c294; }
.popup-chat b.c1 { color: #a78bfa; }
.popup-chat b.c2 { color: #60a5fa; }
.popup-chat span {
  color: #d1d5db;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.popup-chat .tok { color: #04c294; font-style: normal; font-weight: 650; }
.popup-chat .t {
  color: #6b7280;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

#joinSessionChat {
  display: block;
  text-align: center;
  margin: 8px 0 10px;
  color: var(--mint);
  font-size: 13px;
  font-weight: 650;
}

.pop-stats {
  display: grid;
  grid-template-columns: 1fr 1.15fr 1fr;
  gap: 0;
  border-top: 1px solid #1a222c;
  border-bottom: 1px solid #1a222c;
  padding: 8px 0;
  margin-bottom: 12px;
}
.pop-stats .ps {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 8px;
  min-width: 0;
  text-align: left;
  font-size: 11px;
  color: #9aa3ae;
  background: none;
  border: 0;
  line-height: 1.2;
}
.pop-stats .ps + .ps { border-left: 1px solid #1a222c; }
.pop-stats .ps svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  color: #9aa3ae;
}
.pop-stats .ps img {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  object-fit: cover;
  flex: 0 0 auto;
}
.pop-stats .ps span {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  min-width: 0;
}
.pop-stats .ps b {
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}
.pop-stats .ps small,
.pop-stats .ps em {
  color: #9aa3ae;
  font-size: 11px;
  font-style: normal;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.pop-stats button { cursor: pointer; }

#joinLiveSession {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 42px;
  border-radius: 10px;
  background: var(--mint);
  color: #04140c;
  font-size: 15px;
  font-weight: 800;
}
#joinLiveSession svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}
#goToAxiom {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 38px;
  margin-top: 8px;
  border-radius: 10px;
  border: 1px solid var(--mint);
  color: var(--mint);
  font-size: 14px;
  font-weight: 700;
  background: transparent;
}
.pop-note {
  margin-top: 10px;
  text-align: center;
  color: #6b7280;
  font-size: 11px;
  line-height: 1.3;
}

@media (max-width: 1100px) {
  html, body {
    height: auto;
    min-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
  }
  .app { height: auto; min-height: 100dvh; }
  body.popup-open {
    height: 100%;
    overflow: hidden;
  }
}

@media (max-width: 480px) {
  .popup-card {
    width: calc(100vw - 16px);
    padding: 14px 12px max(12px, env(safe-area-inset-bottom));
  }
  .pop-stats .ps { padding: 0 4px; gap: 5px; }
  .pop-grid { height: 158px; }
  .popup-chat { height: 64px; }
  #joinLiveSession, #goToAxiom, #closePopup {
    min-height: 44px;
  }
  #closePopup { width: 44px; }
}

@media (max-width: 380px) {
  .pop-grid {
    grid-template-columns: 1fr;
    height: auto;
  }
  .pop-dev { height: 148px; }
  .pop-holders {
    grid-template-rows: none;
    grid-template-columns: 1fr 1fr 1fr;
    height: 92px;
  }
}
