:root {
  --bg: #0f1115;
  --panel: #181b22;
  --panel-2: #1f232c;
  --border: #2a2f3a;
  --text: #e6e8ec;
  --muted: #9aa3b2;
  --accent: #4f8cff;
  --danger: #ff5d5d;
  --ok: #3ddc84;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
.view { height: 100vh; display: flex; flex-direction: column; }
.hidden { display: none !important; }
button {
  background: var(--accent); color: #fff; border: none; border-radius: 8px;
  padding: 10px 16px; font-size: 14px; cursor: pointer; font-weight: 600;
}
button:hover { filter: brightness(1.08); }
button.secondary { background: var(--panel-2); border: 1px solid var(--border); }
button.danger { background: var(--danger); }
input {
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 10px 12px; font-size: 14px; outline: none; width: 100%;
}
input:focus { border-color: var(--accent); }

/* Join screen */
#join-view { align-items: center; justify-content: center; }
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 16px;
  padding: 28px; width: 360px; max-width: 92vw; box-shadow: 0 12px 40px rgba(0,0,0,.4);
}
.card h1 { margin: 0 0 20px; font-size: 26px; text-align: center; }
.card label { display: block; font-size: 12px; color: var(--muted); margin: 14px 0 6px; }
.row { display: flex; gap: 8px; }
.row input { flex: 1; }
.row button { white-space: nowrap; }
.divider { text-align: center; color: var(--muted); margin: 18px 0 4px; position: relative; }
.divider span { background: var(--panel); padding: 0 10px; position: relative; z-index: 1; font-size: 12px; }
.divider::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: var(--border); }
.error { color: var(--danger); font-size: 13px; min-height: 18px; margin: 12px 0 0; }

/* Room screen */
header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px; border-bottom: 1px solid var(--border); background: var(--panel);
}
.room-meta { display: flex; align-items: center; gap: 12px; }
.badge { font-size: 12px; color: var(--muted); background: var(--panel-2); padding: 4px 8px; border-radius: 6px; }
#room-code { color: var(--text); font-weight: 700; letter-spacing: 2px; }
.status { font-size: 12px; color: var(--muted); }
.status.live { color: var(--ok); }
.controls { display: flex; gap: 8px; }
.mic-off { background: var(--panel-2); border: 1px solid var(--border); }
.mic-on { background: var(--ok); color: #06210f; }

main { flex: 1; display: flex; min-height: 0; }
aside { width: 240px; border-right: 1px solid var(--border); padding: 16px; overflow-y: auto; }
aside h3 { margin: 0 0 12px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
#members { list-style: none; margin: 0; padding: 0; }
#members li { display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: 8px; }
#members li.me { background: var(--panel-2); }
#members .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
#members .dot.talking { background: var(--ok); box-shadow: 0 0 0 3px rgba(61,220,132,.25); }
#members .mic-icon { margin-left: auto; font-size: 13px; opacity: .8; }

.chat { flex: 1; display: flex; flex-direction: column; min-width: 0; }
#messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 70%; }
.msg .who { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.msg .bubble { background: var(--panel-2); padding: 8px 12px; border-radius: 10px; display: inline-block; word-break: break-word; }
.msg.mine { align-self: flex-end; text-align: right; }
.msg.mine .bubble { background: var(--accent); color: #fff; }
.msg.system { align-self: center; color: var(--muted); font-size: 12px; font-style: italic; }
#chat-form { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); }
#chat-form input { flex: 1; }

#audio-hint {
  position: fixed;
  left: 50%;
  bottom: 84px;
  transform: translateX(-50%);
  background: var(--accent);
  z-index: 1000;
  box-shadow: 0 6px 24px rgba(0,0,0,.45);
}

/* Video grid */
#videos { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 16px 0; }
#videos:empty { display: none; }
.tile {
  position: relative; width: 200px; height: 150px; background: #000;
  border-radius: 10px; overflow: hidden; border: 1px solid var(--border);
}
.tile video { width: 100%; height: 100%; object-fit: cover; background: #000; }
.tile-label {
  position: absolute; left: 6px; bottom: 6px; background: rgba(0,0,0,.55);
  color: #fff; font-size: 12px; padding: 2px 6px; border-radius: 6px;
}
.cam-off { background: var(--panel-2); border: 1px solid var(--border); }
.cam-on { background: var(--ok); color: #06210f; }

/* Buttons */
.block { width: 100%; margin-top: 14px; }

/* Lobby */
.lobby { flex: 1; overflow-y: auto; display: flex; justify-content: center; }
.lobby-inner { width: 560px; max-width: 92vw; padding: 24px 16px; }
.create-row { display: flex; gap: 8px; margin-bottom: 22px; }
.create-row input { flex: 1; }
.list-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.list-head h3 { margin: 0; font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
#room-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.room-item {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 16px; cursor: pointer;
}
.room-item:hover { border-color: var(--accent); background: var(--panel-2); }
.room-nm { font-weight: 600; font-size: 15px; }
.room-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.room-count { font-size: 13px; color: var(--muted); background: var(--panel-2); padding: 6px 10px; border-radius: 999px; white-space: nowrap; }
.room-count.active { color: var(--ok); font-weight: 700; }
.muted-note { color: var(--muted); text-align: center; padding: 20px; }

/* Member rows + moderation */
#members li { flex-direction: column; align-items: stretch; gap: 6px; }
.m-row { display: flex; align-items: center; gap: 8px; }
.m-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-icons { font-size: 12px; opacity: .85; white-space: nowrap; }
.mod-actions { display: flex; flex-wrap: wrap; gap: 4px; }
.mod-actions button {
  font-size: 11px; padding: 3px 7px; border-radius: 6px;
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text); font-weight: 500;
}
.mod-actions button:hover { border-color: var(--accent); }
