:root {
  --bg: #0b0d10;
  --bg-2: #111418;
  --bg-3: #181c21;
  --border: #252b33;
  --border-2: #2f3641;
  --fg: #e8ebef;
  --fg-2: #b5bbc3;
  --muted: #7b828c;
  --accent: #f0b200;
  --accent-2: #c89600;
  --speaker: #44d68f;
  --speaker-glow: rgba(68, 214, 143, 0.6);
  --danger: #e5484d;
  --danger-2: #a02b2f;
  --radius: 12px;
  --radius-sm: 8px;
  --max-w: 960px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
button { font: inherit; cursor: pointer; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-2);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}
.brand-mark {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, var(--accent), var(--accent-2));
  color: #000;
  font-size: 22px;
  font-weight: 700;
  display: grid;
  place-items: center;
  box-shadow: 0 0 0 2px var(--bg-2), 0 0 18px rgba(240,178,0,0.35);
}
.brand-title { font-weight: 600; font-size: 16px; }
.brand-title .accent { color: var(--accent); }
.brand-sub { font-size: 12px; color: var(--muted); }
.brand-link { color: inherit; }

.page {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 28px 20px 80px;
}

.hero {
  text-align: center;
  padding: 30px 0 20px;
}
.hero h1 { font-size: 34px; margin: 0 0 12px; line-height: 1.2; }
.hero .lede { color: var(--fg-2); max-width: 520px; margin: 0 auto 28px; }
.cta-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-2);
  background: var(--bg-3);
  color: var(--fg);
  font-weight: 500;
  text-decoration: none;
  transition: background 0.1s, border-color 0.1s, transform 0.05s;
}
.btn:hover { border-color: var(--accent); background: #1e2329; }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--accent);
  color: #0b0d10;
  border-color: var(--accent);
  font-weight: 600;
}
.btn-primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--bg-3); }
.btn-lg { padding: 12px 22px; font-size: 16px; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: var(--danger-2); border-color: var(--danger-2); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.identity-slot {
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.identity-slot .handle-chip {
  padding: 5px 11px;
  background: var(--bg-3);
  border: 1px solid var(--border-2);
  border-radius: 999px;
  cursor: pointer;
}
.identity-slot .handle-chip:hover { border-color: var(--accent); }

.rooms-section { margin-top: 12px; }
.rooms-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.rooms-header h2 { margin: 0; font-size: 18px; }
.rooms-list {
  display: grid;
  gap: 10px;
}
.room-card {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-2);
  cursor: pointer;
  transition: border-color 0.1s, transform 0.05s;
  display: grid;
  gap: 4px;
}
.room-card:hover { border-color: var(--accent); }
.room-card:active { transform: translateY(1px); }
.room-card-title {
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
.room-card .dot-live {
  width: 8px; height: 8px; border-radius: 50%;
  background: #e5484d;
  box-shadow: 0 0 8px rgba(229,72,77,0.8);
  animation: pulse 1.5s infinite;
  display: inline-block;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
.room-card-host { font-size: 13px; color: var(--fg-2); }
.room-card-desc { font-size: 13px; color: var(--muted); }
.rooms-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
  background: var(--bg-2);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.foot { margin-top: 50px; text-align: center; color: var(--muted); font-size: 12px; display: flex; justify-content: center; gap: 10px; }

/* modals */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  display: grid;
  place-items: center;
  z-index: 100;
  padding: 20px;
  backdrop-filter: blur(4px);
}
.modal-backdrop[hidden] { display: none; }
.modal {
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  padding: 22px;
  max-width: 420px;
  width: 100%;
}
.modal h3 { margin: 0 0 6px; font-size: 18px; }
.modal .muted { color: var(--muted); font-size: 13px; margin-bottom: 14px; }
.field {
  display: block;
  margin-bottom: 14px;
}
.field > span {
  display: block;
  margin-bottom: 4px;
  font-size: 13px;
  color: var(--fg-2);
}
.text-input {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-2);
  background: var(--bg);
  color: var(--fg);
  font: inherit;
}
.text-input:focus { outline: none; border-color: var(--accent); }
textarea.text-input { resize: vertical; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.error { color: var(--danger); font-size: 13px; margin-top: 8px; min-height: 18px; }

/* room page */
.page-room { padding-bottom: 100px; }
.room-top .brand-title { font-size: 15px; max-width: 50vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-top .brand-sub { font-size: 12px; }
.room-meta { display: flex; align-items: center; gap: 10px; }
.conn-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: #e5484d;
}
.conn-dot.connected { background: var(--speaker); box-shadow: 0 0 8px var(--speaker-glow); }

.room-page { padding-top: 16px; }
.stage-loading {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 0 auto 12px;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.section-title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 10px;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.section-title .count {
  background: var(--bg-3);
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11px;
  color: var(--fg-2);
}

.speakers-section { margin-bottom: 28px; }
.speakers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 16px 10px;
}
.speaker {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  cursor: default;
}
.speaker .avatar {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: var(--bg-3);
  border: 2px solid var(--border-2);
  display: grid;
  place-items: center;
  font-size: 22px;
  font-weight: 600;
  color: var(--accent);
  position: relative;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.speaker.is-speaking .avatar {
  border-color: var(--speaker);
  box-shadow: 0 0 0 3px var(--speaker-glow), 0 0 18px var(--speaker-glow);
}
.speaker.is-muted .avatar::after {
  content: "🔇";
  position: absolute;
  bottom: -4px; right: -4px;
  font-size: 13px;
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: 50%;
  width: 20px; height: 20px;
  display: grid;
  place-items: center;
}
.speaker.is-host .avatar {
  border-color: var(--accent);
}
.speaker.is-host .avatar::before {
  content: "★";
  position: absolute;
  top: -4px; left: -4px;
  font-size: 11px;
  background: var(--accent);
  color: #000;
  border-radius: 50%;
  width: 18px; height: 18px;
  display: grid;
  place-items: center;
}
.speaker .name {
  font-size: 12px;
  max-width: 86px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.speaker.is-clickable { cursor: pointer; }
.speaker.is-clickable:hover .avatar { border-color: var(--accent); }

.raised-hands-section { margin-bottom: 28px; }
.raised-hands-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.raised-hand-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
}
.raised-hand-item .name { flex: 1; font-size: 14px; }
.raised-hand-item .wave { font-size: 18px; }

.listeners-section { margin-bottom: 20px; }
.listeners-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.listener {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 4px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
  cursor: default;
}
.listener.is-clickable { cursor: pointer; }
.listener.is-clickable:hover { border-color: var(--accent); }
.listener .mini-avatar {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--bg);
  display: grid;
  place-items: center;
  font-size: 11px;
  color: var(--accent);
  font-weight: 600;
}
.listener.hand-raised { border-color: var(--accent); background: rgba(240,178,0,0.1); }
.listener.hand-raised::after { content: "✋"; margin-left: 4px; }

.dock {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 12px 16px 16px;
  background: linear-gradient(to top, var(--bg), rgba(11,13,16,0.85) 80%, transparent);
  z-index: 15;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}
.dock-btn {
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid var(--border-2);
  background: var(--bg-3);
  color: var(--fg);
  font-size: 15px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.dock-btn:hover { border-color: var(--accent); }
.dock-btn-mic.is-on {
  background: var(--speaker);
  color: #0b0d10;
  border-color: var(--speaker);
}
.dock-btn-mic.is-disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.dock-btn-hand.is-raised {
  background: var(--accent);
  color: #0b0d10;
  border-color: var(--accent);
}
.dock-btn-leave { background: transparent; }
.dock-btn-end { background: var(--danger); color: #fff; border-color: var(--danger); }
.dock-btn-end:hover { background: var(--danger-2); border-color: var(--danger-2); }

/* menu */
.menu-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 110;
  display: grid;
  place-items: end center;
  padding: 20px;
  padding-bottom: max(20px, env(safe-area-inset-bottom));
}
.menu-backdrop[hidden] { display: none; }
.menu {
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  min-width: 260px;
  max-width: 420px;
  overflow: hidden;
  padding: 6px;
}
.menu-title {
  padding: 12px 14px 8px;
  color: var(--muted);
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}
.menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  border: none;
  background: transparent;
  color: var(--fg);
  border-radius: var(--radius-sm);
  font-size: 14px;
}
.menu-item:hover { background: var(--bg-3); }
.menu-item-danger { color: var(--danger); }
.menu-item-danger:hover { background: rgba(229,72,77,0.12); }
.menu-close {
  margin-top: 6px;
  text-align: center;
  color: var(--muted);
  border-top: 1px solid var(--border);
}

/* desktop */
@media (min-width: 640px) {
  .hero h1 { font-size: 40px; }
  .speakers-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 20px 14px; }
  .speaker .avatar { width: 78px; height: 78px; font-size: 26px; }
  .speaker .name { max-width: 104px; }
}
