:root {
  color-scheme: dark;
  --canvas: #10131e;
  --ink: #f6f1eb;
  --muted: #adb3c4;
  --line: #363c4e;
  --amber: #ffb47f;
  --button-text: #2a170e;
  background: var(--canvas);
  color: var(--ink);
  font: 1rem/1.5 "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  background: radial-gradient(ellipse at 70% 0%, #242b43 0%, transparent 50%), var(--canvas);
}

.shell {
  width: min(100%, 52rem);
  margin-inline: auto;
  padding: max(1.25rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right))
    max(1.5rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
}

.topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: clamp(1rem, 4vw, 2rem);
}
.room-brand { display: flex; align-items: center; gap: .65rem; font-size: .95rem; font-weight: 700; }
.brand-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .16rem;
  width: 2rem;
  height: 2rem;
  border: 1px solid #675443;
  border-radius: .65rem;
  background: #372d34;
  color: var(--amber);
}
.brand-mark i { width: .14rem; height: .44rem; border-radius: 1rem; background: currentColor; }
.brand-mark i:nth-child(2) { height: .8rem; }
#capacity { color: var(--muted); font-size: .83rem; white-space: nowrap; }

.lobby, .call {
  border: 1px solid var(--line);
  border-radius: 1.65rem;
  box-shadow: 0 1.25rem 3.25rem #07091150;
}
.lobby {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, .98fr);
  align-items: center;
  min-height: 25rem;
  overflow: hidden;
  background: linear-gradient(128deg, #242a3d, #191d2b 66%);
}
.lobby-copy { position: relative; z-index: 1; padding: clamp(1.45rem, 5vw, 3rem); padding-right: 0; }
h1 { margin: 0; line-height: 1.15; font-weight: 750; letter-spacing: -.055em; }
.lobby h1 { font-size: clamp(2rem, 6.2vw, 3.6rem); }
.lobby-status {
  min-height: 1.5em;
  margin: .85rem 0 1.55rem;
  color: var(--muted);
  font-size: .94rem;
  overflow-wrap: anywhere;
}
button {
  min-height: 3rem;
  border: 1px solid transparent;
  border-radius: .85rem;
  padding: .65rem 1rem;
  background: #343b50;
  color: var(--ink);
  font: inherit;
  font-size: .86rem;
  font-weight: 700;
  cursor: pointer;
}
button:focus-visible { outline: 2px solid #ffe4aa; outline-offset: 3px; }
button:disabled { opacity: .55; cursor: wait; }
.primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .6rem;
  min-width: 9.5rem;
  background: var(--amber);
  color: var(--button-text);
}

.signal-art {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 22rem;
  align-self: stretch;
  background: radial-gradient(ellipse at 52% 52%, #cf754845 0%, transparent 71%);
}
.signal-art::before {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(#f0ba8936 1px, transparent 1px);
  background-size: .85rem .85rem;
  mask-image: radial-gradient(ellipse at 54% 49%, black 6%, transparent 72%);
  content: "";
}
.record {
  position: relative;
  display: grid;
  place-items: center;
  width: min(85%, 17.5rem);
  aspect-ratio: 1;
  border: 1px solid #e2a77a52;
  border-radius: 50%;
  background:
    linear-gradient(152deg, #6e4e5e75, #34304518 48%, #ef9b5152 77%, #272b40),
    repeating-radial-gradient(circle, #1d2134 0 5px, #3e354d 6px 7px);
  box-shadow: 0 1rem 2.8rem #0d0d1a88, inset 0 0 0 .5rem #1d213979, inset 0 0 3rem #d178464a;
}
.record::before, .record::after, .record-light { position: absolute; border-radius: 50%; content: ""; }
.record::before { inset: -7%; border: 1px solid #ad829340; }
.record::after { inset: 12%; border: 1px solid #ffcb9152; }
.record-light {
  inset: 21%;
  border: 1px solid #b47c5d68;
  background: radial-gradient(circle at 50% 75%, #6f453f, #2d253a 74%);
  box-shadow: 0 0 1.8rem #231827b0;
}
.spectrum {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2.2%;
  width: 69%;
  height: 31%;
  filter: drop-shadow(0 0 .5rem #f4ae6770);
}
.spectrum i { width: 4%; height: var(--level); border-radius: 1rem; background: linear-gradient(#ffd4a3, #ff9b6e); }

.call {
  display: flex;
  flex-direction: column;
  min-height: min(35rem, 80svh);
  background: linear-gradient(158deg, #262b3e, #181d2b 55%);
}
.call-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .65rem .85rem;
  padding: clamp(1rem, 3vw, 1.65rem);
  border-bottom: 1px solid #34394c;
}
.call-heading h1 { font-size: clamp(1.55rem, 4.8vw, 2.25rem); }
.occupancy {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  border: 1px solid #54533c;
  border-radius: 1rem;
  padding: .24rem .65rem;
  background: #383333;
  color: #ffd6b1;
  font-size: .78rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.occupancy::before { width: .35rem; height: .35rem; border-radius: 50%; background: currentColor; content: ""; }
.call[data-reconnecting] .occupancy { background: #282d40; border-color: #4b5369; color: var(--muted); }

#members {
  --gap: clamp(.4rem, 2vw, .9rem);
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  align-content: center;
  justify-content: center;
  gap: var(--gap);
  list-style: none;
  margin: 0;
  padding: clamp(.8rem, 4vw, 2rem);
  min-height: 13.5rem;
}
.member {
  --avatar-bg: #673e36;
  --avatar-ink: #ffddc3;
  display: flex;
  flex: 0 0 calc((100% - 2 * var(--gap)) / 3);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  min-width: 0;
  max-width: 11.5rem;
  min-height: clamp(7.35rem, 19vw, 10rem);
  border: 1px solid #383e52;
  border-radius: clamp(.78rem, 2.5vw, 1.12rem);
  padding: .7rem .3rem .45rem;
  background: #282e42;
  text-align: center;
}
.member[data-tone="1"] { --avatar-bg: #433d71; --avatar-ink: #e6e0ff; }
.member[data-tone="2"] { --avatar-bg: #24525d; --avatar-ink: #c1f1fa; }
.member[data-tone="3"] { --avatar-bg: #633949; --avatar-ink: #ffd3e5; }
.member[data-tone="4"] { --avatar-bg: #414f3f; --avatar-ink: #dff1c9; }
.member.is-speaking { border-color: #ffb783; background: #403544; box-shadow: inset 0 0 0 1px #ffb7834d; }
.member-avatar {
  position: relative;
  display: grid;
  place-items: center;
  width: clamp(2.6rem, 10vw, 4rem);
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid #ffffff4f;
  border-radius: 50%;
  background: var(--avatar-bg);
  color: var(--avatar-ink);
  font-size: clamp(1.1rem, 4vw, 1.65rem);
  font-weight: 700;
}
.member-avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: var(--avatar-bg);
  object-fit: cover;
}
.member-name-line { display: flex; align-items: center; justify-content: center; gap: .25rem; width: 100%; }
.member-name {
  min-width: 0;
  overflow: hidden;
  font-size: clamp(.72rem, 3vw, .89rem);
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.member-self {
  flex: none;
  border-radius: .22rem;
  padding: .03rem .2rem;
  background: #42475e;
  color: #e4e2ee;
  font-size: .63rem;
}
.member-state { min-height: 1.2em; color: var(--muted); font-size: .72rem; }
.is-speaking .member-state { color: #ffd0a9; }

.call-footer {
  position: sticky;
  bottom: 0;
  z-index: 2;
  border-top: 1px solid #34394c;
  border-radius: 0 0 1.65rem 1.65rem;
  padding: .85rem clamp(.75rem, 3vw, 1.3rem);
  background: #202435;
}
.call-message { margin: 0 0 .65rem; color: var(--muted); text-align: center; overflow-wrap: anywhere; }
.call-message[data-tone="error"], .lobby-status[data-tone="error"] { color: #ffbaa7; }
.controls { display: flex; justify-content: center; gap: clamp(.35rem, 1.5vw, .7rem); }
.controls button { display: flex; align-items: center; justify-content: center; gap: .45rem; min-width: 0; white-space: nowrap; }
#invite { border-color: #59647f; background: #30384d; }
#mute { min-width: 6.5rem; background: var(--amber); color: var(--button-text); }
#mute[aria-pressed="true"] { border-color: #947b6d; background: #514445; color: #ffe0c4; }
#hangup { border-color: #825366; background: #653746; color: #ffe2e6; }
.audio-prompt { display: block; margin: 0 auto .7rem; border-color: #818aa7; }

.icon { position: relative; display: inline-block; flex: none; width: 1.05rem; height: 1.05rem; }
.icon-mic::before, .icon-mic::after, .icon-plus::before, .icon-plus::after,
.icon-leave::before, .icon-leave::after { position: absolute; content: ""; }
.icon-mic::before { inset: 0 30% 29%; border: 1.5px solid currentColor; border-radius: .45rem; }
.icon-mic::after { inset: 40% 12% 6%; border: 1.5px solid currentColor; border-top: 0; border-radius: 0 0 .5rem .5rem; }
#mute[aria-pressed="true"] .icon-mic i {
  position: absolute;
  z-index: 1;
  inset: .47rem -.07rem auto;
  height: 1.5px;
  background: currentColor;
  box-shadow: 0 -2px #514445;
  transform: rotate(43deg);
}
.icon-plus::before, .icon-plus::after { inset: 45% 10% auto; height: 1.5px; background: currentColor; border-radius: 1rem; }
.icon-plus::after { transform: rotate(90deg); }
.icon-leave::before { inset: 10% 38% 10% 2%; border: 1.5px solid currentColor; border-right: 0; border-radius: .25rem 0 0 .25rem; }
.icon-leave::after {
  inset: 32% 10% 32% auto;
  width: 37%;
  border: solid currentColor;
  border-width: 1.5px 1.5px 0 0;
  transform: rotate(45deg);
}
.icon-leave { background: linear-gradient(currentColor, currentColor) 70% center / 47% 1.5px no-repeat; }

@media (max-width: 34rem) {
  .lobby { grid-template-columns: 1fr; min-height: 0; text-align: center; }
  .signal-art { order: -1; min-height: clamp(11rem, 50vw, 15rem); }
  .record { width: clamp(8.8rem, 43vw, 12.3rem); }
  .lobby-copy { padding: .3rem 1.25rem 1.5rem; }
  .lobby-status { margin: .6rem 0 1rem; }
  .primary { width: min(100%, 19rem); }
  .call { min-height: min(31rem, 80svh); }
  .controls button { padding-inline: clamp(.55rem, 3vw, .85rem); }
}
@media (max-width: 22rem) {
  .shell { padding-inline: .65rem; }
  .controls button { gap: .3rem; }
  #mute { min-width: 5.6rem; }
}
@media (hover: hover) {
  button:not(:disabled):hover { filter: brightness(1.12); }
}
