#room {
  display: flex;
  flex-direction: column;
  height: 100%;
}

#topbar {
  display: flex;
  flex: none;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 1rem;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

#topbar-actions {
  display: flex;
  gap: 0.5rem;
}

#brand {
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
}

#status {
  color: #e8b34b;
  font-size: 0.85em;
}

.spacer {
  flex: 1;
}

#layout {
  display: flex;
  flex: 1;
  min-height: 0;
}

#stage {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 0.75rem;
  min-width: 0;
  padding: 0.75rem;
  overflow-y: auto;
}

#side {
  display: flex;
  flex: none;
  flex-direction: column;
  width: 340px;
  min-height: 0;
  background: var(--panel);
  border-left: 1px solid var(--border);
}

#users-root {
  flex: none;
  max-height: 40%;
  overflow-y: auto;
  padding: 0.75rem;
}

#chat-root {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  border-top: 1px solid var(--border);
}

.panel-title {
  margin: 0 0 0.5rem;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.user-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0 0 0.6rem;
  padding: 0;
  list-style: none;
}

.user {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.2rem 0.4rem;
  border-radius: 6px;
}

.user.offline {
  opacity: 0.45;
}

.user-name {
  overflow: hidden;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-you {
  color: var(--muted);
  font-size: 0.8em;
}

.user-busy {
  width: 12px;
  height: 12px;
  border: 2px solid var(--border);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

#toasts {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  max-width: 320px;
  padding: 0.6rem 0.9rem;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 6px 20px #0008;
}

@media (max-width: 900px) {
  #room {
    height: auto;
    min-height: 100%;
  }

  #layout {
    flex-direction: column;
  }

  #stage {
    overflow: visible;
  }

  #side {
    width: auto;
    border-top: 1px solid var(--border);
    border-left: 0;
  }

  #users-root {
    max-height: none;
  }

  #chat-root {
    height: 420px;
    flex: none;
  }
}

.user.clickable {
  cursor: pointer;
}

.user.clickable:hover {
  background: var(--panel-2);
}

.user-role {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.75em;
}

.group-dot {
  flex: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.group-dot.viewer {
  background: #8a8a8a;
}

.group-dot.moderator {
  background: #be8b2b;
}

.group-dot.owner {
  background: #d23a3a;
}

.user-actions {
  display: flex;
  gap: 0.35rem;
  padding: 0.25rem 0.4rem 0.45rem 1.5rem;
}

.user-actions button {
  flex: 1;
  padding: 0.2em 0.4em;
  font-size: 0.85em;
}

dialog {
  min-width: 340px;
  padding: 1.25rem;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

dialog::backdrop {
  background: #000a;
}

dialog h2 {
  margin: 0 0 0.25rem;
  font-size: 1.15rem;
}

.dialog-hint {
  margin: 0 0 0.75rem;
  color: var(--muted);
  font-size: 0.9em;
}

dialog form {
  display: flex;
  justify-content: flex-end;
  margin-top: 1rem;
}

.permissions {
  width: 100%;
  border-collapse: collapse;
}

.permissions th,
.permissions td {
  padding: 0.3rem 0.6rem;
  border-bottom: 1px solid var(--border);
  text-align: center;
}

.permissions th[scope='row'] {
  font-weight: 500;
  text-align: left;
}

.permissions input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}
