:root{
  --bg0:#191a21;
  --bg1:#21222c;
  --bg2:#282a36;
  --fg:#f8f8f2;
  --muted:#6272a4;
  --line:rgba(248,248,242,0.12);
  --cyan:#8be9fd;
  --green:#50fa7b;
  --red:#ff5555;
  --yellow:#f1fa8c;
  --pink:#ff79c6;
}
*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  background:linear-gradient(180deg,var(--bg0),#15161c 60%);
  color:var(--fg);
  font:14px/1.4 ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,Helvetica,Arial,"Apple Color Emoji","Segoe UI Emoji";
}
a{color:var(--cyan);text-decoration:none}
a:hover{text-decoration:underline}
.wrap{
  max-width:980px;
  margin:0 auto;
  padding:24px 14px;
}
.center{
  min-height:100vh;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:24px 14px;
}
.card.compact{
  display:inline-block;
  padding:14px;
  width:fit-content;
  max-width:min(640px, calc(100vw - 28px));
}
.card.compact.wide{
  width:min(760px, calc(100vw - 28px));
}
.row.nowrap{flex-wrap:nowrap}
.row.tight{gap:8px}
.status.compact{
  max-width:240px;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.inp.compact{
  width:min(320px, 62vw);
}
.wrap.wrap-room{
  max-width:none;
  width:100%;
  /* Use a real viewport height on mobile (avoid "scroll a bit"). */
  min-height:100vh; /* fallback */
  height:100vh; /* fallback */
  margin:0;
  padding:14px 14px;
}
@supports (height: 100dvh) {
  .wrap.wrap-room{
    min-height:100dvh;
    height:100dvh;
    padding:
      calc(12px + env(safe-area-inset-top))
      calc(12px + env(safe-area-inset-right))
      calc(12px + env(safe-area-inset-bottom))
      calc(12px + env(safe-area-inset-left));
  }
}
.card{
  background:var(--bg1);
  border:1px solid var(--line);
  padding:16px;
}
.row{display:flex;align-items:center;gap:10px;flex-wrap:wrap}
.title{font-size:16px;font-weight:800}
.muted{color:var(--muted)}
.btn{
  height:34px;
  padding:0 12px;
  border:1px solid var(--line);
  background:var(--bg2);
  color:var(--fg);
  cursor:pointer;
}
.btn:hover{border-color:rgba(139,233,253,0.55)}
.btn.primary{border-color:rgba(80,250,123,0.45)}
.btn.danger{border-color:rgba(255,85,85,0.45)}
.inp{
  height:34px;
  padding:0 10px;
  border:1px solid var(--line);
  background:var(--bg2);
  color:var(--fg);
  outline:none;
  width:min(360px,100%);
}
.inp:focus{border-color:rgba(139,233,253,0.55)}
.hr{height:1px;background:var(--line);margin:14px 0}
.pill{
  padding:6px 8px;
  border:1px solid var(--line);
  background:rgba(40,42,54,0.6);
  display:inline-flex;
  align-items:center;
  gap:8px;
  max-width:100%;
}
.pill code{
  font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;
  font-size:12px;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  max-width:76vw;
}
.pill.pill-link{
  width:100%;
  max-width:100%;
}
.pill.pill-link .linkcode{
  white-space:normal;
  overflow:visible;
  text-overflow:clip;
  word-break:break-all;
  max-width:none;
}

/* Room */
.room{
  height:100%;
  display:flex;
  flex-direction:column;
  gap:10px;
}
.stage{
  position:relative;
  flex:1;
  min-height:0;
}

.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}
.top-left{
  display:flex;
  align-items:baseline;
  gap:10px;
  min-width:0;
}
.wsdot{
  width:8px;
  height:8px;
  border-radius:999px;
  border:1px solid rgba(248,248,242,0.22);
  background:rgba(255,85,85,0.65);
  align-self:center;
}
.wsdot.on{background:rgba(80,250,123,0.70)}
.top-right{
  display:flex;
  align-items:center;
  gap:8px;
  flex:0 0 auto;
}
.gain{
  width:100%;
  accent-color:rgba(80,250,123,0.85);
  opacity:0.9;
}
.gain:disabled{opacity:0.45}
.ico{font-size:14px;line-height:1}
.iconbtn.danger{border-color:rgba(255,85,85,0.45)}
.iconbtn.danger:hover{border-color:rgba(255,85,85,0.85)}

.banner{
  display:flex;
  align-items:center;
  gap:10px;
  padding:10px;
  border:1px solid rgba(255,184,108,0.28);
  background:rgba(40,42,54,0.65);
}

.hidden{display:none !important}

.devpanel{
  display:grid;
  grid-template-columns:1fr;
  gap:8px;
  border:1px solid var(--line);
  background:rgba(33,34,44,0.7);
  padding:10px;
}
.devrow{
  display:grid;
  grid-template-columns:96px 1fr;
  gap:10px;
  align-items:center;
}
.devlabel{color:var(--muted);font-size:12px}
.devinline{
  display:flex;
  align-items:center;
  gap:8px;
}
.devinline .sel{flex:1 1 auto;min-width:0}
.sel{
  height:34px;
  border:1px solid var(--line);
  background:var(--bg2);
  color:var(--fg);
  padding:0 10px;
  outline:none;
}
.sel:focus{border-color:rgba(139,233,253,0.55)}
.grid{
  height:100%;
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(240px,1fr));
  gap:10px;
  align-content:stretch;
}
.tile{
  position:relative;
  background:var(--bg1);
  border:1px solid var(--line);
  overflow:hidden;
  min-height:160px;
}
.tile.local{cursor:pointer}
.tile.local:hover{border-color:rgba(139,233,253,0.55)}
.tile.speaking{
  border-color:rgba(80,250,123,0.6);
  box-shadow:0 0 0 1px rgba(80,250,123,0.20) inset;
}
.tile.local{opacity:0.95}
.tile video{
  width:100%;
  height:100%;
  object-fit:cover;
  background:#000;
}
.badge{
  position:absolute;
  left:8px;
  bottom:8px;
  font-size:12px;
  background:rgba(25,26,33,0.75);
  border:1px solid rgba(248,248,242,0.10);
  padding:4px 6px;
}
.diag{
  position:absolute;
  left:8px;
  bottom:34px;
  max-width:calc(100% - 140px);
  font-size:11px;
  color:rgba(248,248,242,0.90);
  background:rgba(25,26,33,0.60);
  border:1px solid rgba(248,248,242,0.08);
  padding:3px 6px;
  border-radius:6px;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.vol{
  position:absolute;
  right:8px;
  bottom:8px;
  width:120px;
  accent-color:var(--cyan);
  opacity:0.9;
}

.dock{
  position:absolute;
  left:10px;
  bottom:10px;
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  max-width:calc(100% - 20px);
  z-index:5;
  pointer-events:auto;
}
.puck{
  width:72px;
  height:72px;
  display:flex;
  flex-direction:column;
  justify-content:flex-end;
  gap:6px;
  padding:8px;
  background:rgba(33,34,44,0.92);
  border:1px solid var(--line);
  backdrop-filter:blur(6px);
}
.puck:hover{border-color:rgba(139,233,253,0.55)}
.puck .pname{
  font-size:12px;
  color:var(--fg);
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.puck .pvol{
  width:100%;
  accent-color:var(--cyan);
  opacity:0.95;
}
.puck.speaking{
  border-color:rgba(80,250,123,0.6);
  box-shadow:0 0 0 1px rgba(80,250,123,0.20) inset;
}
.puck.self{
  cursor:pointer;
}
.controls{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}
.iconbtn{
  height:34px;
  width:34px;
  padding:0;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  border:1px solid var(--line);
  background:var(--bg2);
  color:var(--fg);
  cursor:pointer;
}
.iconbtn:hover{border-color:rgba(139,233,253,0.55)}
.iconbtn.on{border-color:rgba(80,250,123,0.5);color:var(--green)}
.iconbtn.off{border-color:rgba(255,85,85,0.5);color:var(--red)}
.status{font-size:12px;color:var(--muted)}

.overlay{
  position:fixed;
  inset:0;
  background:rgba(25,26,33,0.75);
  display:flex;
  align-items:center;
  justify-content:center;
  padding:18px;
}
.overlayCard{
  width:min(520px,100%);
  background:var(--bg1);
  border:1px solid var(--line);
  padding:18px;
}
.overlayTitle{font-size:16px;font-weight:800}
.overlaySub{margin-top:6px}
.overlayRow{margin-top:14px}

@media (max-width: 720px){
  .wrap{padding:14px 10px}
  .room{height:100%}
  .devrow{grid-template-columns:84px 1fr}
  .vol{width:96px}
  .puck{width:64px;height:64px}
  .status.compact{max-width:140px}
}
