:root {
  --bg: #f7f8fb;
  --surface: #ffffff;
  --surface-strong: #f2f3f8;
  --text: #171827;
  --muted: #65677c;
  --soft: #8a8da3;
  --border: #dddfea;
  --purple: #43148c;
  --purple-2: #5d28bc;
  --green: #35b94b;
  --danger: #ee3340;
  --shadow: 0 18px 45px rgba(31, 28, 61, 0.11);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: 60px 1fr;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 22px;
  font-weight: 750;
  text-decoration: none;
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 17px;
  font-weight: 800;
  background: linear-gradient(145deg, var(--purple), var(--purple-2));
}

.status-pill {
  height: 36px;
  padding: 0 13px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  color: #3d3e55;
  font-weight: 600;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--green);
}

.dot.pending {
  background: #f0a623;
}

.dot.offline {
  background: var(--danger);
}

.divider {
  width: 1px;
  height: 20px;
  background: var(--border);
}

.role-tabs {
  margin-left: auto;
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.role-tab {
  min-width: 112px;
  height: 38px;
  border: 0;
  background: #fff;
  color: #2f3044;
  font-weight: 750;
  cursor: pointer;
}

.role-tab.active {
  background: linear-gradient(145deg, var(--purple), var(--purple-2));
  color: #fff;
}

.workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: 240px minmax(420px, 1fr) 350px;
  gap: 16px;
  padding: 16px;
}

.channels-panel,
.details-panel {
  min-width: 0;
}

.channels-panel {
  display: grid;
  grid-template-rows: auto 1fr auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.panel-heading {
  height: 50px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  color: #4d5068;
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.channel-list {
  overflow: auto;
}

.channel-row {
  width: 100%;
  height: 62px;
  display: grid;
  grid-template-columns: 42px 14px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.channel-row.active {
  background: linear-gradient(145deg, var(--purple), var(--purple-2));
  color: #fff;
}

.channel-number {
  color: var(--purple);
  font-size: 22px;
  font-weight: 850;
}

.channel-row.active .channel-number,
.channel-row.active .channel-meta,
.channel-row.active .occupancy {
  color: #fff;
}

.channel-state {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #a1a4b4;
}

.channel-state.live {
  background: var(--green);
}

.channel-state.receiver {
  background: #8f72cf;
}

.channel-label {
  font-weight: 700;
}

.occupancy {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.channel-help {
  padding: 12px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

code {
  color: var(--purple);
  font-weight: 750;
}

.stage-column {
  min-width: 0;
  display: grid;
  grid-template-rows: minmax(360px, 1fr) auto;
  gap: 10px;
}

.stage {
  position: relative;
  min-height: 500px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    #090b10;
  background-size: 34px 34px;
  box-shadow: var(--shadow);
}

#remoteVideo {
  width: 100%;
  height: 100%;
  min-height: inherit;
  display: none;
  object-fit: contain;
  background: #000;
}

#remoteVideo.live {
  display: block;
}

.stage-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 18px;
  color: #fff;
  text-align: center;
}

.stage-empty.hidden {
  display: none;
}

.screen-icon {
  width: 68px;
  height: 46px;
  border: 4px solid rgba(255, 255, 255, 0.72);
  border-radius: 7px;
  position: relative;
}

.screen-icon::before,
.screen-icon::after {
  content: "";
  position: absolute;
  background: rgba(255, 255, 255, 0.72);
}

.screen-icon::before {
  width: 8px;
  height: 18px;
  left: 28px;
  bottom: -20px;
}

.screen-icon::after {
  width: 38px;
  height: 4px;
  left: 12px;
  bottom: -24px;
}

.stage h1 {
  margin: 14px 0 0;
  font-size: clamp(20px, 2.5vw, 27px);
  line-height: 1.1;
}

.stage p {
  margin: 0;
  color: #c9c7d7;
}

.stage strong {
  display: inline-block;
  margin-left: 10px;
  padding: 8px 13px;
  border: 1px solid #8f65e8;
  border-radius: 7px;
  color: #b998ff;
  background: rgba(83, 45, 151, 0.2);
}

.stage-top-actions {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
}

.icon-button {
  width: 38px;
  height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  font-size: 20px;
  cursor: pointer;
}

.stage-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 6px;
}

.link-button {
  border: 0;
  background: transparent;
  color: var(--purple);
  font-weight: 800;
  cursor: pointer;
}

.media-status {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.details-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.info-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 14px;
}

.info-card h2 {
  margin: 0 0 12px;
  color: #4d5068;
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

dl {
  display: grid;
  gap: 12px;
  margin: 0;
}

dl div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

dt {
  color: var(--muted);
}

dd {
  margin: 0;
  color: #242538;
  font-weight: 750;
  text-align: right;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 11px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

input,
select {
  width: 100%;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 0 12px;
  background: #fff;
  color: var(--text);
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--purple-2);
  box-shadow: 0 0 0 3px rgba(93, 40, 188, 0.14);
}

.primary-button,
.danger-button {
  width: 100%;
  height: 44px;
  border-radius: 7px;
  font-weight: 850;
  cursor: pointer;
}

.primary-button {
  border: 0;
  background: linear-gradient(145deg, var(--purple), var(--purple-2));
  color: #fff;
}

.danger-button {
  margin-top: 8px;
  border: 1px solid rgba(238, 51, 64, 0.55);
  background: #fff;
  color: var(--danger);
}

.danger-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.small-muted {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.link-box {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.link-box button {
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-strong);
  color: var(--purple);
  font-weight: 850;
  cursor: pointer;
}

.participants {
  display: grid;
  gap: 8px;
}

.participant {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  gap: 8px;
  align-items: center;
}

.avatar {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #eee8ff;
  color: var(--purple);
  font-weight: 850;
}

.participant strong,
.participant span {
  display: block;
}

.participant span {
  color: var(--muted);
  font-size: 11px;
}

.live-label {
  color: var(--green);
  font-size: 11px;
  font-weight: 850;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 10;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: #171827;
  color: #fff;
  box-shadow: var(--shadow);
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 220px minmax(380px, 1fr);
  }

  .details-panel {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .app-shell {
    grid-template-rows: auto 1fr;
  }

  .topbar {
    flex-wrap: wrap;
    height: auto;
    padding: 14px;
  }

  .status-pill,
  .role-tabs {
    width: 100%;
  }

  .role-tab {
    flex: 1;
  }

  .workspace {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .channels-panel {
    max-height: 360px;
  }

  .stage {
    min-height: 360px;
  }

  .details-panel {
    display: flex;
  }
}
