:root {
  --bg: #0e1116;
  --bg-elev: #161b22;
  --line: #2a323d;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #3d9cf0;
  --danger: #f85149;
  --radius: 10px;
  --font: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --display: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(1200px 600px at 10% -10%, #1a2740 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #132018 0%, transparent 50%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
}

body {
  display: flex;
  justify-content: center;
}

#app {
  width: min(1100px, 100%);
  min-height: 100vh;
  padding: 1.5rem;
}

.top {
  margin-bottom: 1.5rem;
}

.brand {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(2rem, 4vw, 2.75rem);
  letter-spacing: -0.03em;
  font-weight: 600;
}

.tag {
  margin: 0.25rem 0 0;
  color: var(--muted);
}

.panel {
  max-width: 420px;
  background: color-mix(in srgb, var(--bg-elev) 92%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
  backdrop-filter: blur(8px);
}

.panel-title {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
}

label {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 0.85rem;
  font-size: 0.9rem;
  color: var(--muted);
}

input, select, textarea {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #0b0e13;
  color: var(--text);
  font: inherit;
}

input:focus, select:focus, textarea:focus {
  outline: 1px solid var(--accent);
  border-color: var(--accent);
}

.actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

button {
  border: 0;
  border-radius: 8px;
  padding: 0.6rem 0.9rem;
  background: var(--accent);
  color: #041018;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

button.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}

button.danger {
  background: var(--danger);
  color: #fff;
}

button.small {
  padding: 0.35rem 0.55rem;
  font-size: 0.8rem;
  font-weight: 500;
}

.error {
  color: var(--danger);
  font-size: 0.85rem;
}

.shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 1rem;
  min-height: 70vh;
}

.sidebar, .main {
  background: color-mix(in srgb, var(--bg-elev) 90%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
}

.sidebar h2 {
  margin: 1rem 0 0.5rem;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
}

.sidebar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.75rem;
}

.me {
  display: grid;
  gap: 0.2rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--line);
}

.muted { color: var(--muted); }
.small { font-size: 0.8rem; }

#room-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

#room-list li.room-item {
  padding: 0.45rem 0.5rem;
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
}

#room-list li.room-item:hover,
#room-list li.room-item.active {
  background: #0b0e13;
}

#room-list li.room-item.active {
  outline: 1px solid var(--line);
}

.main.chat {
  display: flex;
  flex-direction: column;
  min-height: 70vh;
  padding: 0;
  overflow: hidden;
}

.placeholder {
  color: var(--muted);
  margin: 0;
  padding: 1rem;
}

.chat-active {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.chat-header {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--line);
}

.chat-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.chat-header h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.voice-controls {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.voice-status {
  margin: 0.35rem 0 0;
  min-height: 1.1em;
}

.voice-peers {
  list-style: none;
  margin: 0.25rem 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.voice-peers li {
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #0b0e13;
  font-size: 0.75rem;
}

.screen-panel {
  border-bottom: 1px solid var(--line);
  padding: 0.65rem 1rem;
  background: #0b0e13;
}

.screen-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.screen-label {
  font-size: 0.85rem;
  color: var(--text);
}

.screen-stage {
  margin-top: 0.65rem;
  display: grid;
  gap: 0.5rem;
}

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

.screen-stage video {
  width: 100%;
  max-height: min(50vh, 420px);
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #000;
  object-fit: contain;
}

button.ghost.active-toggle {
  border-color: var(--accent);
  color: var(--accent);
}

.voice-hint {
  margin: 0.2rem 0 0;
}

.voice-audio-root {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
  pointer-events: none;
}

.messages {
  flex: 1;
  overflow: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.msg {
  max-width: 85%;
  align-self: flex-start;
}

.msg.mine {
  align-self: flex-end;
}

.msg-meta {
  display: flex;
  gap: 0.5rem;
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 0.2rem;
}

.msg-body {
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  background: #0b0e13;
  border: 1px solid var(--line);
  white-space: pre-wrap;
  word-break: break-word;
}

.msg.mine .msg-body {
  background: color-mix(in srgb, var(--accent) 18%, #0b0e13);
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
}

.composer {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--line);
}

.composer input {
  flex: 1;
}

#chat-error {
  margin: 0 1rem 0.75rem;
}

dialog {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-elev);
  color: var(--text);
  padding: 0;
  max-width: 420px;
  width: calc(100% - 2rem);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

.dlg {
  padding: 1.1rem;
}

.dlg h3 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
}

.hidden { display: none !important; }

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

.turnstile-slot {
  margin: 0.5rem 0 0.25rem;
  min-height: 65px;
}
