:root {
  --bg: #0b0d12;
  --bg-elev: #141820;
  --bg-elev-2: #1c222d;
  --line: rgba(246, 243, 236, 0.1);
  --text: #f6f3ec;
  --muted: #a39e94;
  --faint: #6f6a62;
  --accent: #e7b008;
  --accent-ink: #1c1503;
  --teal: #3ddec4;
  --danger: #ff5a6a;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
  --font: "Outfit", "Segoe UI", sans-serif;
  --serif: "Fraunces", Georgia, serif;
  --radius: 18px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  background:
    radial-gradient(900px 480px at -10% -10%, rgba(231, 176, 8, 0.16), transparent 55%),
    radial-gradient(700px 420px at 110% 0%, rgba(61, 222, 196, 0.08), transparent 50%),
    var(--bg);
  color: var(--text);
  min-height: 100%;
}
body.in-call { overflow: hidden; height: var(--app-height, 100dvh); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 680;
  letter-spacing: -0.03em;
}
.brand-sm { font-size: 15px; }
.mark {
  width: 18px;
  height: 18px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  position: relative;
  box-shadow: inset 0 0 0 4px var(--bg), inset 0 0 0 6px var(--teal);
}

.lobby {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(280px, 0.9fr);
  gap: 48px;
  align-items: center;
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 48px 40px 64px;
}
.eyebrow {
  margin: 28px 0 8px;
  color: var(--accent);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 680;
}
h1 {
  font-family: var(--serif);
  font-weight: 560;
  font-size: clamp(42px, 5vw, 68px);
  line-height: 1.02;
  letter-spacing: -0.035em;
  margin: 0 0 16px;
}
.lede { margin: 0; color: var(--muted); font-size: 18px; max-width: 46ch; line-height: 1.45; }
.points { margin: 28px 0 0; padding: 0; list-style: none; }
.points li {
  position: relative;
  padding: 8px 0 8px 18px;
  color: var(--text);
}
.points li::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  position: absolute;
  left: 0;
  top: 15px;
}
.online { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(255, 90, 106, 0.15);
}
.dot[data-on="yes"] {
  background: var(--teal);
  box-shadow: 0 0 0 4px rgba(61, 222, 196, 0.15);
}

.lobby-card {
  background: rgba(20, 24, 32, 0.92);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 16px;
  box-shadow: var(--shadow);
  min-width: 0;
  max-width: 100%;
}
.preview {
  position: relative;
  aspect-ratio: 16 / 10;
  border-radius: 18px;
  overflow: hidden;
  background: #090b10;
}
.preview video, .tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
  display: block;
}
.preview video { transform: scaleX(-1); }
.preview-fallback, .avatar {
  display: grid;
  place-items: center;
  background: #3d4a42;
  color: white;
  font-weight: 680;
}
.preview-fallback { position: absolute; inset: 0; font-size: 42px; }
.preview-gate {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  border: 0;
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: 999px;
  padding: 10px 16px;
  font-weight: 680;
}
.preview-note {
  position: absolute;
  left: 12px;
  right: 12px;
  top: 12px;
  margin: 0;
  font-size: 13px;
  color: white;
  text-shadow: 0 1px 8px #000;
}
.preview-toggles { display: flex; gap: 8px; margin: 12px 0; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; font-size: 13px; color: var(--muted); min-width: 0; }
.field input, .field select, .composer input, .relay input {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  height: 46px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #0e1117;
  padding: 0 12px;
  font-size: 16px;
  color: var(--text);
}
.field select { text-overflow: ellipsis; }
.room-row, .device-grid { display: flex; gap: 8px; }
.room-row input { flex: 1; }
.device-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.device-grid .field { margin: 0; }
#lobbySpeakerField, #speakerFields { grid-column: 1 / -1; }
.invite-line {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  margin: -4px 0 12px;
}
.invite-line code {
  color: var(--faint);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.form-error { min-height: 1.2em; margin: 4px 0 8px; color: #ff8d98; font-size: 14px; }
.fine { color: var(--faint); font-size: 12px; line-height: 1.45; margin: 10px 0 0; }
.btn-primary {
  width: 100%;
  height: 48px;
  border: 0;
  border-radius: 14px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 680;
}
.btn-primary:disabled { opacity: 0.55; }
.btn-ghost, .text-btn, .mini {
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 12px;
  color: var(--text);
}
.btn-ghost { padding: 0 14px; }
.text-btn, .mini { border: 0; background: transparent; color: var(--accent); padding: 0; font-size: 13px; }
.mini {
  background: rgba(8, 10, 14, 0.7);
  color: white;
  border-radius: 999px;
  padding: 4px 8px;
}

.btn-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--bg-elev-2);
  color: var(--text);
  display: grid;
  place-items: center;
  position: relative;
  flex: none;
}
.btn-icon svg { width: 22px; height: 22px; }
.btn-icon.is-off { background: rgba(255, 90, 106, 0.16); color: #ffb4bc; }
.btn-icon.is-live { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn-quiet { width: 36px; height: 36px; background: transparent; }
.btn-emoji { font-size: 20px; }
.btn-icon[data-tip]:hover::after, .btn-icon[data-tip]:focus-visible::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: #0e1117;
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 8px;
  white-space: nowrap;
  pointer-events: none;
}

.call {
  position: relative;
  height: var(--app-height, 100dvh);
  overflow: hidden;
  background: #000;
}
.call:fullscreen { width: 100%; height: 100%; background: #000; }
.topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.62), transparent);
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.room-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 8px 6px 14px;
  font-weight: 560;
}
.top-meta {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}
.chip, .presence {
  border-radius: 999px;
  padding: 4px 8px;
  background: rgba(231, 176, 8, 0.15);
  color: var(--accent);
}
.presence[data-state="good"] { background: rgba(61, 222, 196, 0.12); color: var(--teal); }
.presence[data-state="bad"] { background: rgba(255, 90, 106, 0.15); color: #ff8d98; }
.speaker-label { color: var(--text); min-height: 1em; }

.call-body { position: absolute; inset: 0; min-height: 0; }
.call.chat-open .call-body { display: block; }
.stage {
  position: absolute;
  inset: 0;
  min-width: 0;
  min-height: 0;
  padding: 0;
  display: block;
}
.alone {
  position: absolute;
  z-index: 4;
  top: 68px;
  left: 12px;
  right: 12px;
  background: rgba(8, 10, 14, 0.72);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 14px;
}
.hear {
  position: absolute;
  z-index: 5;
  left: 50%;
  top: 54px;
  transform: translateX(-50%);
  border: 0;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 680;
  border-radius: 999px;
  padding: 10px 14px;
}
.grid {
  position: absolute;
  inset: 0;
  min-height: 0;
  display: grid;
  gap: 0;
  align-content: stretch;
}
.grid.single { display: block; }
.grid.single .tile,
.grid.feature > .tile,
.call .tile {
  width: 100%;
  height: 100%;
  max-height: none;
  border-radius: 0;
}
.grid.feature { display: block; }
.filmstrip {
  height: 128px;
  display: flex;
  gap: 10px;
  overflow-x: auto;
  flex: none;
}
.filmstrip .tile { width: 220px; height: 128px; flex: none; }

.tile {
  position: relative;
  overflow: hidden;
  border-radius: 18px;
  background: #090b10;
  min-width: 0;
  min-height: 0;
  outline: 2px solid transparent;
}
.tile.speaking { outline-color: var(--teal); }
.tile video.mirror { transform: scaleX(-1); }
.tile.video-off video { opacity: 0; }
.avatar {
  position: absolute;
  inset: 0;
  font-size: 42px;
  opacity: 0;
}
.tile.video-off .avatar { opacity: 1; }
.tile-status {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.55);
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 13px;
}
.tile-top, .tile-name { position: absolute; z-index: 2; }
.tile-top {
  top: 8px;
  left: 8px;
  right: 8px;
  display: flex;
  align-items: flex-start;
  gap: 6px;
}
.tile-actions { margin-left: auto; display: flex; gap: 4px; opacity: 0; }
.tile:hover .tile-actions, .tile:focus-within .tile-actions { opacity: 1; }
.hand { font-size: 18px; filter: drop-shadow(0 2px 4px #000); }
.quality {
  width: 8px;
  height: 8px;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--faint);
}
.quality[data-level="good"] { background: var(--teal); }
.quality[data-level="ok"] { background: var(--accent); }
.quality[data-level="poor"] { background: var(--danger); }
.tile-name {
  left: 10px;
  bottom: 10px;
  display: flex;
  gap: 8px;
  align-items: center;
  max-width: calc(100% - 20px);
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(8, 10, 14, 0.72);
  backdrop-filter: blur(8px);
  font-size: 13px;
}
.mic-badge, .share-badge { color: #ffb4bc; font-size: 12px; }
.share-badge { color: var(--accent); }
.label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.floats { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.float-emoji {
  position: absolute;
  bottom: 48px;
  font-size: 32px;
  animation: floatUp 1.4s ease forwards;
}
@keyframes floatUp {
  from { transform: translateY(8px) scale(0.8); opacity: 0; }
  20% { opacity: 1; }
  to { transform: translateY(-90px) scale(1.25); opacity: 0; }
}

.sidebar {
  display: none;
  position: absolute;
  z-index: 5;
  left: 10px;
  right: 10px;
  bottom: 78px;
  height: min(40%, 300px);
  min-height: 0;
  min-width: 0;
  border: 0;
  border-radius: 18px;
  flex-direction: column;
  background: transparent;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
}
.call.chat-open .sidebar { display: flex; }
@media (min-width: 900px) {
  .call.chat-open .sidebar {
    left: auto;
    right: 16px;
    top: 72px;
    bottom: 88px;
    width: min(380px, 34vw);
    height: auto;
    background: transparent;
  }
}
.tabs { display: flex; align-items: center; gap: 6px; padding: 10px; }
.tab-close {
  flex: none;
  height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid rgba(186, 214, 255, 0.45);
  background: rgba(8, 18, 36, 0.45);
  color: #fff;
  font-weight: 680;
}
.chat-fab {
  display: none;
  position: absolute;
  z-index: 7;
  right: 12px;
  bottom: calc(78px + env(safe-area-inset-bottom));
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 16px 0 12px;
  border: 1px solid rgba(186, 214, 255, 0.5);
  border-radius: 999px;
  background: rgba(70, 140, 220, 0.72);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  color: #fff;
  font-weight: 680;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
.call:not(.chat-open) .chat-fab { display: inline-flex; }
.chat-fab .ico { display: grid; }
.chat-fab svg { width: 20px; height: 20px; }
.chat-fab .count-badge { top: -6px; right: -4px; }
.tab {
  flex: 1;
  height: 36px;
  border-radius: 999px;
  border: 0;
  background: transparent;
  color: var(--muted);
}
.tab[aria-selected="true"] { background: rgba(150, 196, 245, 0.35); color: var(--text); }
.panel { display: flex; flex-direction: column; min-height: 0; flex: 1; position: relative; }
.messages { flex: 1; overflow: auto; padding: 4px 12px 12px; display: flex; flex-direction: column; gap: 8px; }
.msg {
  max-width: 92%;
  padding: 8px 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.16);
}
.msg.mine { margin-left: auto; background: rgba(120, 176, 235, 0.32); border-color: rgba(190, 220, 255, 0.28); }
.msg.system {
  margin: 0 auto;
  background: transparent;
  color: var(--faint);
  font-size: 12px;
  padding: 2px;
}
.msg .who { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 12px; }
.msg .text { margin-top: 2px; white-space: pre-wrap; overflow-wrap: anywhere; }
.composer { display: flex; gap: 8px; padding: 10px; }
.composer input {
  flex: 1;
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(186, 214, 255, 0.4);
}
.btn-send { width: auto; padding: 0 16px; }
.new-msgs {
  position: absolute;
  bottom: 68px;
  left: 50%;
  transform: translateX(-50%);
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 680;
  padding: 6px 10px;
}
.people-list { list-style: none; margin: 0; padding: 6px 12px 16px; overflow: auto; }
.people-list li {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-rows: auto auto;
  gap: 2px 10px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.mini-avatar {
  grid-row: 1 / span 2;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 680;
}
.person-name { font-weight: 560; }
.person-flags { grid-column: 2; color: var(--muted); font-size: 12px; }
.people-list .text-btn { grid-column: 3; grid-row: 1 / span 2; }

.dock {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 6;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  padding: 8px 12px calc(12px + env(safe-area-inset-bottom));
  flex-wrap: wrap;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.55), transparent);
}
.dock-group {
  display: flex;
  gap: 8px;
  padding: 6px;
  background: rgba(20, 24, 32, 0.92);
  border: 1px solid var(--line);
  border-radius: 999px;
}
#micBtn { width: auto; padding: 0 8px 0 12px; display: flex; align-items: center; gap: 6px; border-radius: 999px; }
#micMeter { width: 36px; height: 18px; }
.btn-leave {
  height: 48px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  background: var(--danger);
  color: white;
  font-weight: 680;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.btn-leave svg { width: 18px; height: 18px; }
.react-wrap { position: relative; }
.pop {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
  padding: 6px;
  background: #0e1117;
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow);
}
.pop button { width: 36px; height: 36px; border: 0; border-radius: 50%; background: transparent; font-size: 20px; }
.count-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--danger);
  color: white;
  font-size: 11px;
  display: grid;
  place-items: center;
}
.scrim-btn { display: none; border: 0; padding: 0; }

.toast {
  position: fixed;
  z-index: 60;
  left: 50%;
  bottom: 108px;
  transform: translateX(-50%);
  max-width: min(520px, calc(100% - 24px));
  background: #0e1117;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 14px;
  box-shadow: var(--shadow);
  text-align: center;
}
.modal {
  width: min(460px, calc(100% - 24px));
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--bg-elev);
  color: var(--text);
  padding: 16px;
}
.modal::backdrop { background: rgba(0, 0, 0, 0.62); }
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.modal h2 { font-family: var(--serif); font-weight: 560; margin: 0; }
.keys { list-style: none; padding: 0; margin: 8px 0 12px; }
.keys li { display: flex; gap: 12px; align-items: center; padding: 6px 0; }
kbd {
  min-width: 28px;
  text-align: center;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 6px;
  padding: 2px 6px;
  background: var(--bg-elev-2);
  font-family: ui-monospace, monospace;
}
.check { display: flex; gap: 8px; align-items: center; margin: 8px 0 14px; }
.relay { border: 1px solid var(--line); border-radius: 14px; margin: 0 0 14px; padding: 8px 12px 12px; }
.relay legend { padding: 0 6px; color: var(--muted); }

.messages::-webkit-scrollbar, .people-list::-webkit-scrollbar, .filmstrip::-webkit-scrollbar { width: 10px; height: 10px; }
.messages::-webkit-scrollbar-thumb, .people-list::-webkit-scrollbar-thumb, .filmstrip::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.16);
  border-radius: 99px;
}

@media (hover: none) {
  .tile-actions { opacity: 1; }
}
@media (max-width: 980px) {
  .lobby { grid-template-columns: minmax(0, 1fr); padding: 24px 16px 40px; gap: 20px; }
  h1 { font-size: 40px; }
  .top-meta .speaker-label { display: none; }
}
.grid.pip { display: block; }
.grid.pip .tile:not([data-peer="local"]) { width: 100%; height: 100%; }
.grid.pip .tile[data-peer="local"] {
  position: absolute;
  width: 96px;
  height: 132px;
  top: 72px;
  right: 12px;
  z-index: 4;
  border-radius: 14px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
  touch-action: none;
  cursor: grab;
}
.grid.pip .tile[data-peer="local"]:active { cursor: grabbing; }
.grid.pip .tile[data-peer="local"] .tile-actions,
.grid.pip .tile[data-peer="local"] .tile-top { display: none; }
.call.typing .dock { display: none; }
.call.typing .sidebar { bottom: 8px; height: min(46%, 320px); }

@media (max-width: 860px) {
  .call.chat-open .scrim-btn { display: none; }
  .alone { font-size: 13px; padding: 8px 10px; }
  .tabs { padding: 8px 8px 0; }
  .composer { padding: 8px; }
  .composer input, .btn-send { height: 44px; }
  .topbar { padding: 8px 10px; gap: 8px; }
  #countLabel { display: none; }
  .dock {
    flex-wrap: nowrap;
    overflow-x: auto;
    justify-content: flex-start;
    gap: 8px;
    padding: 6px 8px calc(8px + env(safe-area-inset-bottom));
  }
  .dock-group { padding: 4px; gap: 4px; }
  .btn-icon { width: 42px; height: 42px; }
  .btn-leave { height: 42px; padding: 0 12px; }
  .room-pill span { max-width: 34vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
@media (min-width: 900px) {
  .grid.pip .tile[data-peer="local"] {
    top: auto;
    right: auto;
    left: 16px;
    bottom: 96px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
