* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: #0f172a;
  color: #e2e8f0;
}

.wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.card {
  width: 100%;
  max-width: 980px;
  background: #111827;
  border: 1px solid #334155;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
}

.card-narrow {
  max-width: 640px;
}

h1, h2 {
  margin-top: 0;
}

.muted,
.hint,
.note p {
  color: #94a3b8;
}

.stack {
  display: grid;
  gap: 12px;
}

input,
textarea,
button,
select {
  width: 100%;
  border-radius: 10px;
  border: 1px solid #334155;
  background: #020617;
  color: #e2e8f0;
  padding: 12px 14px;
  font-size: 16px;
}

textarea {
  min-height: 92px;
  resize: vertical;
}

button {
  cursor: pointer;
  background: #2563eb;
  border: 0;
  font-weight: 700;
}

button[disabled] {
  opacity: .6;
  cursor: not-allowed;
}

button.danger {
  background: #b91c1c;
}

.button-link {
  display: inline-block;
  text-decoration: none;
  background: #2563eb;
  color: #ffffff;
  border-radius: 10px;
  padding: 12px 16px;
  font-weight: 700;
  text-align: center;
  transition: background .2s ease;
}

.button-link:hover {
  background: #1d4ed8;
}

.button-link-secondary {
  background: #1e293b;
  color: #e2e8f0;
  border: 1px solid #334155;
}

.button-link-secondary:hover {
  background: #334155;
}

hr {
  border: 0;
  border-top: 1px solid #334155;
  margin: 24px 0;
}

.result {
  margin-top: 16px;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 20px 0;
}

.status-grid > div {
  background: #0b1220;
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 12px;
}

.single-status {
  grid-template-columns: 1fr;
  max-width: 320px;
  margin: 24px auto 0;
}

.label {
  display: block;
  font-size: 13px;
  color: #94a3b8;
  margin-bottom: 8px;
}

.badge {
  display: inline-block;
  font-size: 14px;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 999px;
}

.badge.ok {
  background: #14532d;
  color: #bbf7d0;
}

.badge.warn {
  background: #78350f;
  color: #fde68a;
}

.badge.bad {
  background: #7f1d1d;
  color: #fecaca;
}

.badge.idle {
  background: #1e293b;
  color: #cbd5e1;
}

.controls {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.topbar {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.panel {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid #334155;
}

.flash {
  margin: 12px 0 18px;
  padding: 12px 14px;
  border-radius: 10px;
  font-weight: 700;
}

.flash-success {
  background: #14532d;
  color: #bbf7d0;
}

.flash-error {
  background: #7f1d1d;
  color: #fecaca;
}

.table-wrap {
  overflow: auto;
}

.rooms-table {
  width: 100%;
  border-collapse: collapse;
}

.rooms-table th,
.rooms-table td {
  text-align: left;
  padding: 10px;
  border-bottom: 1px solid #334155;
  vertical-align: top;
}

.rooms-table code {
  color: #cbd5e1;
}

.mini-links textarea {
  min-height: 68px;
  margin: 6px 0 10px;
}

.center {
  text-align: center;
}

.icon-circle {
  width: 72px;
  height: 72px;
  margin: 0 auto 18px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 32px;
  background: rgba(37, 99, 235, 0.12);
  border: 1px solid #334155;
}

.room-message {
  max-width: 480px;
  margin: 0 auto;
  line-height: 1.6;
}

.message-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 24px;
  flex-wrap: wrap;
}

.small-note {
  margin-top: 18px;
  font-size: 14px;
}

@media (max-width: 720px) {
  .status-grid,
  .controls {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .message-actions {
    flex-direction: column;
  }

  .card-narrow {
    max-width: 100%;
  }
}


.topbar,
.room-topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.room-badges {
  display: flex;
  gap: 8px;
}

.name-entry {
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: 12px;
  margin: 20px 0;
}

.field-grow,
.field-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.room-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 20px;
}

.participant-list {
  display: grid;
  gap: 10px;
}

.participant-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 12px;
  background: #0b1220;
}

.participant-meta strong {
  display: block;
  margin-bottom: 4px;
}

.participant-sub {
  color: #94a3b8;
  font-size: 14px;
}

.participant-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.host-action-button {
  width: auto;
  min-width: 110px;
  padding: 10px 14px;
}

.remote-streams {
  display: grid;
  gap: 10px;
}

.remote-audio-card {
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 12px;
  background: #0b1220;
}

.remote-audio-title {
  margin-bottom: 8px;
  font-weight: 700;
}

.remote-audio-card audio {
  width: 100%;
}

.speaker-stack {
  display: grid;
  gap: 6px;
}

@media (max-width: 900px) {
  .room-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .name-entry {
    grid-template-columns: 1fr;
  }
}


.controls-3 {
  grid-template-columns: repeat(3, 1fr);
}

.status-grid-4 {
  grid-template-columns: repeat(4, 1fr);
  margin-top: 0;
}

.participant-item {
  align-items: start;
}

.participant-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 220px;
}

.participant-volume {
  display: grid;
  gap: 4px;
}

.participant-volume label {
  font-size: 12px;
  color: #94a3b8;
}

.participant-volume input[type="range"] {
  width: 100%;
  padding: 0;
}

.participant-vu {
  height: 8px;
  background: #1e293b;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid #334155;
}

.participant-vu-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #22c55e, #eab308, #ef4444);
  transition: width .12s linear;
}

.remote-audio-card {
  display: grid;
  gap: 10px;
}

.remote-audio-title {
  font-weight: 700;
}

.ptt-active {
  outline: 2px solid #22c55e;
  box-shadow: 0 0 0 3px rgba(34,197,94,.2);
}

@media (max-width: 720px) {
  .status-grid-4,
  .controls-3 {
    grid-template-columns: 1fr;
  }
}


.floating-ptt {
  position: fixed;
  right: 18px;
  bottom: 22px;
  z-index: 60;
  width: 86px;
  height: 86px;
  border-radius: 999px;
  border: 2px solid #22c55e;
  background: #1d4ed8;
  color: #fff;
  font-weight: 800;
  font-size: 18px;
  box-shadow: 0 14px 30px rgba(0,0,0,.35);
  display: none;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.floating-ptt.is-visible {
  display: inline-flex;
}

.floating-ptt.ptt-active {
  background: #15803d;
  transform: scale(0.98);
}

@media (min-width: 721px) {
  .floating-ptt {
    display: none !important;
  }
}

@media (max-width: 720px) {
  #pttBtn {
    display: none;
  }
}


.obs-bus-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 12px;
}

.obs-bus-card {
  background: #0b1220;
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 12px;
  display: grid;
  gap: 8px;
}

.obs-bus-title {
  font-size: 18px;
  font-weight: 700;
}

.obs-bus-sub {
  color: #94a3b8;
  font-size: 13px;
}

.participant-route-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.participant-route-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #cbd5e1;
}

.participant-route-toggle input {
  width: auto;
  margin: 0;
}

@media (max-width: 720px) {
  .obs-bus-grid {
    grid-template-columns: 1fr;
  }
}


@media (max-width: 980px) {
  .wrap {
    padding: 12px;
  }

  .card {
    max-width: 100%;
    padding: 16px;
    border-radius: 12px;
  }

  .topbar,
  .room-header {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .status-grid,
  .status-grid-4,
  .controls,
  .controls-3,
  .obs-bus-grid {
    grid-template-columns: 1fr !important;
  }

  .participant-item {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .participant-actions {
    min-width: 0;
    width: 100%;
  }

  .participant-route-grid {
    grid-template-columns: 1fr 1fr;
  }

  .panel-grid,
  .content-grid,
  .two-col {
    grid-template-columns: 1fr !important;
  }

  .remote-audio-card audio,
  .obs-bus-card audio {
    width: 100%;
  }

  input, textarea, button, select {
    font-size: 16px;
  }
}

@media (max-width: 640px) {
  body {
    font-size: 15px;
  }

  .card {
    padding: 14px;
  }

  h1, h2 {
    line-height: 1.15;
  }

  .participant-route-grid {
    grid-template-columns: 1fr;
  }

  .participant-actions .host-action-button,
  .participant-actions button,
  .controls button,
  .controls-3 button {
    width: 100%;
  }

  .floating-ptt {
    width: 78px;
    height: 78px;
    right: 14px;
    bottom: 16px;
    font-size: 17px;
  }
}


.controls,
.controls-3 {
  gap: 14px !important;
  margin-top: 14px;
  margin-bottom: 14px;
}

.controls button,
.controls-3 button {
  min-height: 58px;
}

.floating-ptt {
  opacity: 0;
  pointer-events: none;
}

.floating-ptt.is-visible {
  opacity: 1;
  pointer-events: auto;
}

@media (max-width: 980px) {
  .controls,
  .controls-3 {
    gap: 12px !important;
  }

  .card {
    padding-bottom: 110px;
  }
}

@media (max-width: 720px) {
  .controls,
  .controls-3 {
    display: grid;
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  .controls button,
  .controls-3 button {
    width: 100%;
    min-height: 56px;
    border-radius: 14px;
  }

  .floating-ptt {
    display: inline-flex !important;
    right: 16px;
    bottom: 18px;
  }

  .floating-ptt:disabled {
    opacity: .45;
  }
}


.mobile-ptt-bar {
  display: none;
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 14px;
  z-index: 70;
  min-height: 58px;
  border-radius: 16px;
  border: 2px solid #22c55e;
  background: #1d4ed8;
  color: #fff;
  font-weight: 800;
  box-shadow: 0 14px 30px rgba(0,0,0,.35);
}

.mobile-ptt-bar.is-visible {
  display: none;
}

.mobile-ptt-bar.ptt-active {
  background: #15803d;
}

@media (max-width: 720px) {
  .floating-ptt {
    display: none !important;
  }

  .mobile-ptt-bar.is-visible {
    display: block !important;
  }

  .card {
    padding-bottom: 120px !important;
  }
}


.guest-hidden {
  display: none !important;
}

.guest-quick-help {
  margin-bottom: 14px;
}

.guest-status-box {
  margin-bottom: 12px;
}

body.role-guest .panel h2 {
  letter-spacing: 0;
}

body.role-guest .obs-bus-grid,
body.role-guest .participant-route-grid,
body.role-guest .participant-volume,
body.role-guest .remote-audio-card,
body.role-guest #remoteStreams .muted,
body.role-guest #programMixMonitor,
body.role-guest #intercomMixMonitor,
body.role-guest .participant-actions button {
  display: none !important;
}

body.role-guest .participant-actions {
  min-width: 0;
  width: auto;
}

body.role-guest .participant-item {
  grid-template-columns: 1fr auto;
}

body.role-guest .panel:has(#programMixMonitor),
body.role-guest .panel:has(.obs-bus-grid) {
  display: none !important;
}

.mobile-ptt-bar {
  font-size: 17px;
}

body.role-guest .mobile-ptt-bar {
  display: none;
}

body.role-guest .mobile-ptt-bar.is-visible {
  display: block !important;
}

@media (max-width: 720px) {
  body.role-guest .card {
    padding-bottom: 132px !important;
  }

  body.role-guest .controls-3 {
    grid-template-columns: 1fr !important;
  }

  body.role-guest #pttBtn,
  body.role-guest .floating-ptt {
    display: none !important;
  }

  body.role-guest .mobile-ptt-bar {
    display: none;
  }

  body.role-guest .mobile-ptt-bar.is-visible {
    display: block !important;
  }

  body.role-guest .participant-item {
    grid-template-columns: 1fr;
  }
}


body.role-guest .mobile-ptt-bar {
  display: none;
}

body.role-guest .mobile-ptt-bar.is-visible {
  display: block !important;
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: max(14px, env(safe-area-inset-bottom));
  z-index: 9999;
  min-height: 60px;
  border-radius: 16px;
  border: 2px solid #22c55e;
  background: #1d4ed8;
  color: #fff;
  font-weight: 800;
  font-size: 17px;
  box-shadow: 0 14px 30px rgba(0,0,0,.35);
}

body.role-guest .mobile-ptt-bar.ptt-active {
  background: #15803d;
}

body.role-guest .floating-ptt,
body.role-guest #pttBtn {
  display: none !important;
}

body.role-guest .card {
  padding-bottom: 140px !important;
}

@media (orientation: landscape) and (max-width: 980px) {
  body.role-guest .mobile-ptt-bar.is-visible {
    left: 16px;
    right: 16px;
    min-height: 54px;
  }
  body.role-guest .card {
    padding-bottom: 120px !important;
  }
}


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

.status-grid-3 {
  grid-template-columns: repeat(3, 1fr);
  margin-top: 0;
}

#pttBtn,
.floating-ptt,
.mobile-ptt-bar {
  display: none !important;
}

@media (max-width: 720px) {
  .controls-2,
  .status-grid-3 {
    grid-template-columns: 1fr !important;
  }

  .card {
    padding-bottom: 24px !important;
  }
}


.controls-guest {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 14px;
  margin-bottom: 14px;
}

.guest-primary {
  min-height: 58px;
}

.guest-mini-grid {
  grid-template-columns: repeat(3, 1fr);
}

.guest-hidden-panel {
}

body.role-guest .guest-hidden-panel,
body.role-guest .room-layout > .panel:nth-child(2) {
  display: none !important;
}

body.role-guest .card {
  max-width: 760px;
}

body.role-guest .room-layout {
  grid-template-columns: 1fr !important;
}

body.role-guest .participant-item {
  grid-template-columns: 1fr auto;
}

body.role-guest .participant-actions {
  min-width: 0;
  width: auto;
}

body.role-guest .participant-volume,
body.role-guest .participant-route-grid,
body.role-guest .participant-actions button {
  display: none !important;
}

body.role-guest .guest-status-grid {
  margin-top: 0;
}

/* keep mute visible */
body.role-guest #muteBtn_hidden_fix_removed,
body.role-guest #hangupBtn,
body.role-guest #talkModeStatus,
body.role-guest #reconnectStatus,
body.role-guest #remoteStatus,
body.role-guest #uploadRate,
body.role-guest #downloadRate,
body.role-guest #forcedMuteStatus,
body.role-guest #programMixMonitor,
body.role-guest #intercomMixMonitor,
body.role-guest #remoteStreams {
  display: none !important;
}

@media (max-width: 720px) {
  .controls-guest,
  .guest-mini-grid {
    grid-template-columns: 1fr !important;
  }

  body.role-guest .card {
    padding-bottom: 24px !important;
  }

  body.role-guest .participant-item {
    grid-template-columns: 1fr;
  }
}


.guest-room-header {
  grid-template-columns: 1fr 220px;
  gap: 12px;
}

.compact-status-grid {
  margin-top: 14px;
}

body.role-guest .guest-topbar .muted,
body.role-guest .guest-hidden-panel,
body.role-guest .obs-bus-grid,
body.role-guest #programMixMonitor,
body.role-guest #intercomMixMonitor,
body.role-guest #remoteStreams,
body.role-guest .participant-volume,
body.role-guest .participant-route-grid,
body.role-guest .participant-actions button,
body.role-guest .participant-actions .host-action-button,
body.role-guest .guest-quick-help,
body.role-guest #startBtnGuest,
body.role-guest #hangupBtnGuest {
  display: none !important;
}

body.role-guest .card {
  max-width: 760px;
}

body.role-guest .participant-item {
  grid-template-columns: 1fr auto;
}

body.role-guest .participant-actions {
  min-width: 0;
  width: auto;
}

body.role-guest .participant-sub {
  margin-top: 2px;
}

@media (max-width: 720px) {
  .guest-room-header {
    grid-template-columns: 1fr;
  }

  body.role-guest .participant-item {
    grid-template-columns: 1fr;
  }
}


body.role-guest .name-entry {
  grid-template-columns: 1fr 220px;
}

@media (max-width: 720px) {
  body.role-guest .name-entry {
    grid-template-columns: 1fr;
  }
}


.field-actions button + button {
  margin-top: 8px;
}


/* Guest layout fixes */
body.role-guest .room-layout {
  grid-template-columns: 1fr;
}

body.role-guest .panel {
  width: 100%;
}

body.role-guest .card {
  max-width: 860px;
}

body.role-guest .name-entry {
  grid-template-columns: minmax(0, 1fr) 220px;
  align-items: end;
}

body.role-guest .field-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

body.role-guest #muteBtn {
  display: block !important;
}

body.role-guest #startBtn,
body.role-guest #muteBtn {
  width: 100%;
  min-height: 52px;
}

body.role-guest .participant-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

body.role-guest .participant-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 90px;
}

body.role-guest .participant-actions .badge {
  white-space: nowrap;
}

@media (max-width: 720px) {
  body.role-guest .name-entry {
    grid-template-columns: 1fr;
  }

  body.role-guest .participant-item {
    align-items: flex-start;
  }

  body.role-guest .participant-actions {
    width: auto;
    margin-top: 8px;
  }
}


.obs-help-box {
  margin: 14px 0 18px;
  padding: 14px 16px;
  border: 1px solid #334155;
  border-radius: 12px;
  background: #0b1220;
}

.obs-help-title {
  font-weight: 700;
  margin-bottom: 8px;
}

.obs-help-box p {
  margin: 0 0 10px;
}

.obs-help-list {
  margin: 0;
  padding-left: 20px;
  color: #cbd5e1;
}

.obs-help-list li + li {
  margin-top: 6px;
}
