:root {
  --bg: #07070a;
  --panel: rgba(255,255,255,.045);
  --panel2: rgba(255,255,255,.07);
  --line: rgba(255,255,255,.09);
  --fg: #f2f2f5;
  --dim: #9a9aa6;
  --accent: #7c5cff;
  --accent2: #00e0c6;
  --danger: #ff5577;
  --r: 16px;
}

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

html,
body {
  width: 100%;
  min-height: 100%;
}

body {
  background:
    radial-gradient(
      1200px 600px at 20% -10%,
      #1a1030 0,
      transparent 60%
    ),
    radial-gradient(
      900px 500px at 90% 0,
      #04282a 0,
      transparent 55%
    ),
    var(--bg);

  color: var(--fg);

  font:
    15px/1.5
    ui-sans-serif,
    system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    sans-serif;

  min-height: 100dvh;
}

button,
input,
select {
  font: inherit;
}

a {
  color: var(--accent2);
  text-decoration: none;
}

.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px;
}

.brand {
  font-weight: 700;
  letter-spacing: -.02em;
  font-size: 20px;
}

.brand span {
  background:
    linear-gradient(
      90deg,
      var(--accent),
      var(--accent2)
    );

  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  backdrop-filter: blur(14px);
  padding: 20px;
}

.btn {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  justify-content: center;

  border: 1px solid var(--line);
  background: rgba(255,255,255,.06);
  color: var(--fg);

  padding: 10px 16px;
  border-radius: 12px;

  cursor: pointer;
  font: inherit;
  font-weight: 600;

  transition: .18s;
}

.btn:hover {
  background: rgba(255,255,255,.12);
  transform: translateY(-1px);
}

.btn.primary {
  background:
    linear-gradient(
      90deg,
      var(--accent),
      #5b8cff
    );

  border-color: transparent;
}

.btn.ghost {
  background: transparent;
}

.btn:disabled {
  opacity: .45;
  cursor: not-allowed;
  transform: none;
}

.btn.danger {
  border-color: rgba(255,85,119,.35);
}

input,
select {
  background: rgba(0,0,0,.35);
  border: 1px solid var(--line);
  color: var(--fg);

  padding: 10px 12px;
  border-radius: 12px;

  width: 100%;
  outline: none;
}

input:focus,
select:focus {
  border-color: rgba(124,92,255,.7);
  box-shadow: 0 0 0 3px rgba(124,92,255,.12);
}

label {
  display: block;
  font-size: 12px;
  color: var(--dim);
  margin: 12px 0 6px;

  text-transform: uppercase;
  letter-spacing: .08em;
}

.row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.dim {
  color: var(--dim);
}

.sm {
  font-size: 13px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;

  padding: 14px 24px;

  border-bottom: 1px solid var(--line);

  min-height: 59px;
}

.avatar {
  width: 32px;
  height: 32px;

  border-radius: 50%;

  background:
    linear-gradient(
      135deg,
      var(--accent),
      var(--accent2)
    );

  display: grid;
  place-items: center;

  font-weight: 700;
  font-size: 13px;
}

.pill {
  font-size: 11px;
  font-weight: 700;

  letter-spacing: .08em;

  padding: 5px 10px;

  border-radius: 999px;

  border: 1px solid var(--line);
}

.pill.ok {
  color: #5df2c5;
  border-color: #5df2c544;
}

.pill.warn {
  color: #ffd166;
  border-color: #ffd16644;
}

.pill.bad {
  color: #ff7a90;
  border-color: #ff7a9044;
}


/* ============================================================
   WATCH LAYOUT
============================================================ */

.stage {
  display: grid;

  grid-template-columns:
    minmax(0, 1fr)
    360px;

  gap: 16px;

  padding: 16px;

  height: calc(100dvh - 59px);
}

.player-wrap {
  position: relative;

  background: #000;

  border-radius: var(--r);

  overflow: hidden;

  border: 1px solid var(--line);

  display: flex;
  flex-direction: column;

  min-width: 0;
  min-height: 0;
}

video#main,
#ytwrap,
#screenmain {
  width: 100%;
  flex: 1;

  min-height: 0;

  background: #000;

  object-fit: contain;
}

#screenmain {
  position: absolute;
  inset: 0;

  width: 100%;
  height: calc(100% - 58px);

  z-index: 4;

  object-fit: contain;

  background: #000;
}

#main {
  position: relative;
  z-index: 1;
}

#ytwrap {
  position: relative;
  z-index: 1;
}

.controls {
  display: flex;
  gap: 10px;
  align-items: center;

  padding: 10px 14px;

  background:
    linear-gradient(
      0deg,
      #000,
      rgba(0,0,0,.4)
    );

  z-index: 20;
}

.controls .bar {
  flex: 1;

  height: 6px;

  border-radius: 999px;

  background: rgba(255,255,255,.15);

  cursor: pointer;

  position: relative;
}

.controls .bar i {
  position: absolute;

  inset: 0 auto 0 0;

  background:
    linear-gradient(
      90deg,
      var(--accent),
      var(--accent2)
    );

  border-radius: 999px;

  display: block;
}

.ico {
  background: none;

  border: 0;

  color: var(--fg);

  font-size: 17px;

  cursor: pointer;

  padding: 4px 6px;

  border-radius: 8px;
}

.ico:hover {
  background: rgba(255,255,255,.12);
}


/* ============================================================
   SIDE
============================================================ */

.side {
  display: flex;
  flex-direction: column;

  gap: 12px;

  min-height: 0;
}

.people-card {
  padding: 12px;
}

.people-header {
  display: flex;

  justify-content: space-between;
  align-items: flex-start;

  gap: 10px;
}

.participant-count {
  margin-top: 3px;

  font-size: 12px;

  color: var(--dim);
}

.people-list {
  margin-top: 10px;

  max-height: 210px;

  overflow-y: auto;

  display: flex;
  flex-direction: column;

  gap: 6px;
}

.person {
  display: flex;

  align-items: center;

  gap: 8px;

  padding: 7px 9px;

  border-radius: 10px;

  background: rgba(255,255,255,.035);

  font-size: 13px;
}

.person.me {
  background:
    rgba(124,92,255,.10);
}

.person-status {
  width: 7px;
  height: 7px;

  border-radius: 50%;

  background: #777;
}

.person-status.online {
  background: #5df2c5;
}

.person-name {
  flex: 1;

  min-width: 0;

  overflow: hidden;

  white-space: nowrap;

  text-overflow: ellipsis;
}

.person-icons {
  color: var(--dim);

  font-size: 12px;

  white-space: nowrap;
}


/* ============================================================
   PARTICIPANT VIDEO GRID
============================================================ */

.participant-layer {
  position: absolute;

  left: 14px;
  right: 14px;
  bottom: 76px;

  display: grid;

  grid-template-columns:
    repeat(
      auto-fit,
      minmax(150px, 220px)
    );

  gap: 10px;

  justify-content: end;

  align-content: end;

  z-index: 12;

  pointer-events: none;

  height: 25%;
  min-height: 112px;
  max-height: 25%;
  overflow-x: auto;
  overflow-y: hidden;
  grid-auto-flow: column;
  grid-auto-columns: minmax(150px, 220px);
  align-items: stretch;
}

.participant-tile {
  position: relative;

  width: 100%;

  aspect-ratio: 16 / 10;

  overflow: hidden;

  border-radius: 13px;

  border: 1px solid rgba(255,255,255,.14);

  background: #111;

  box-shadow:
    0 12px 35px rgba(0,0,0,.45);

  pointer-events: auto;
}

.participant-tile video {
  width: 100%;
  height: 100%;

  object-fit: cover;

  display: block;
}

.participant-placeholder-avatar {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 34px;
  font-weight: 800;
  color: rgba(255,255,255,.85);
  background: radial-gradient(circle at 50% 35%, rgba(124,92,255,.28), rgba(17,17,17,.96) 62%);
}

.participant-placeholder video {
  background: #111;
}

.participant-tile.mirrored video {
  transform: scaleX(-1);
}

.participant-label {
  position: absolute;

  left: 8px;
  right: 8px;
  bottom: 7px;

  display: flex;

  justify-content: space-between;

  align-items: center;

  gap: 8px;

  font-size: 11px;

  text-shadow:
    0 1px 4px #000;

  background:
    linear-gradient(
      0deg,
      rgba(0,0,0,.75),
      transparent
    );

  padding-top: 18px;
}

.participant-label-name {
  overflow: hidden;

  white-space: nowrap;

  text-overflow: ellipsis;
}

.participant-label-icons {
  white-space: nowrap;
}


/* ============================================================
   SCREEN SHARE
============================================================ */

.screen-badge {
  position: absolute;

  top: 14px;
  left: 14px;

  z-index: 15;

  display: flex;

  align-items: center;

  gap: 8px;

  padding: 7px 11px;

  border-radius: 999px;

  background:
    rgba(0,0,0,.72);

  backdrop-filter: blur(10px);

  font-size: 12px;

  border: 1px solid rgba(255,255,255,.12);
}

.screen-dot {
  width: 8px;
  height: 8px;

  border-radius: 50%;

  background: #ff5577;

  box-shadow:
    0 0 10px rgba(255,85,119,.7);
}


/* ============================================================
   SOURCE
============================================================ */

.source-card {
  position: absolute;

  inset: 0;

  margin: auto;

  height: fit-content;

  max-width: 460px;

  z-index: 30;
}

.error-text {
  color: #ff7a90;
}

.main-empty {
  position: absolute;

  inset: 0;

  z-index: 5;

  display: flex;

  flex-direction: column;

  justify-content: center;

  align-items: center;

  gap: 6px;

  color: #ddd;

  background:
    radial-gradient(
      circle at center,
      rgba(124,92,255,.12),
      transparent 45%
    );
}

.main-empty-icon {
  font-size: 44px;

  margin-bottom: 5px;
}


/* ============================================================
   CHAT
============================================================ */

.chat-card {
  flex: 1;

  display: flex;

  flex-direction: column;

  min-height: 240px;

  padding: 12px;
}

#chatlog {
  flex: 1;

  overflow-y: auto;

  display: flex;

  flex-direction: column;

  gap: 8px;

  padding-right: 4px;

  min-height: 0;
}

.msg {
  padding: 8px 11px;

  border-radius: 12px;

  background:
    rgba(255,255,255,.06);

  max-width: 92%;

  font-size: 14px;

  word-break: break-word;
}

.msg.me {
  align-self: flex-end;

  background:
    linear-gradient(
      90deg,
      rgba(124,92,255,.35),
      rgba(0,224,198,.22)
    );
}

.msg.sys {
  align-self: center;

  background: none;

  color: var(--dim);

  font-size: 12px;

  text-align: center;
}

.msg b {
  display: block;

  font-size: 11px;

  color: var(--dim);

  margin-bottom: 2px;
}

.chat-input-row {
  margin-top: 8px;

  flex-wrap: nowrap;
}

.chat-input-row input {
  min-width: 0;
}


/* ============================================================
   REACTIONS
============================================================ */

#reactions {
  position: absolute;

  inset: 0;

  pointer-events: none;

  overflow: hidden;

  z-index: 40;
}

.float {
  position: absolute;

  bottom: 80px;

  font-size: 34px;

  animation:
    rise 2.4s ease-out forwards;
}

@keyframes rise {
  to {
    transform:
      translateY(-320px)
      scale(1.5);

    opacity: 0;
  }
}


/* ============================================================
   TABS
============================================================ */

.tabs {
  display: none;
}


/* ============================================================
   HOST
============================================================ */

.host-settings {
  margin-top: 4px;
}


/* ============================================================
   MOBILE
============================================================ */

@media(max-width:900px) {

  .topbar {
    padding: 11px 14px;
  }

  .topbar .pill:first-of-type {
    display: none;
  }

  .stage {
    grid-template-columns: 1fr;

    height:
      calc(
        100dvh - 59px - 58px
      );

    padding: 8px;
  }

  .side {
    display: flex;
  }

  .side.hide {
    display: none;
  }

  .player-wrap.hide {
    display: none;
  }

  .tabs {
    display: flex;

    gap: 8px;

    position: fixed;

    left: 0;
    right: 0;
    bottom: 0;

    padding: 8px;

    background:
      rgba(7,7,10,.92);

    border-top:
      1px solid var(--line);

    z-index: 100;
  }

  .tabs .btn {
    flex: 1;

    padding:
      10px 6px;

    font-size: 13px;
  }

  .participant-layer {
    left: 8px;
    right: 8px;

    bottom: 65px;

    grid-template-columns:
      repeat(
        auto-fit,
        minmax(110px, 1fr)
      );

    max-height: 42%;
  }

  .participant-tile {
    aspect-ratio: 16 / 10;
  }

  .controls {
    gap: 5px;

    padding:
      8px 8px;
  }

  .controls .bar {
    min-width: 60px;
  }

  .source-card {
    margin: 12px;

    max-width:
      calc(100% - 24px);
  }

  .people-list {
    max-height: 170px;
  }
}


/* ============================================================
   SMALL MOBILE
============================================================ */

@media(max-width:520px) {

  .brand {
    font-size: 17px;
  }

  .topbar .btn {
    padding:
      7px 10px;
  }

  .topbar .sm.dim {
    display: none;
  }

  .stage {
    padding: 4px;
  }

  .participant-layer {
    grid-template-columns:
      repeat(2, 1fr);
  }

  .participant-label {
    font-size: 10px;
  }

  #time {
    display: none;
  }

  #rate {
    display: none;
  }
}
