:root {
  color-scheme: dark;
  --bg: #171815;
  --panel: #22231f;
  --panel-strong: #2b2d27;
  --line: #3b3d35;
  --text: #f6f5ef;
  --muted: #a7a99e;
  --green: #79d78b;
  --green-dark: #183f24;
  --cyan: #6bc8d2;
  --amber: #e9b85d;
  --red: #ff746a;
  --red-dark: #4a2220;
  font-family: Inter, "Segoe UI", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 72px;
  padding: 12px clamp(18px, 4vw, 48px);
  border-bottom: 1px solid var(--line);
  background: rgba(23, 24, 21, 0.94);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: max-content;
  color: var(--text);
  font-size: 18px;
  font-weight: 800;
  text-decoration: none;
}

.brand-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  background: var(--green);
}

.brand-mark span {
  width: 3px;
  border-radius: 2px;
  background: #122217;
}

.brand-mark span:nth-child(1) { height: 9px; }
.brand-mark span:nth-child(2) { height: 17px; }
.brand-mark span:nth-child(3) { height: 12px; }

.room-title,
.room-switcher {
  display: flex;
  align-items: center;
  min-width: 150px;
}

.room-switcher {
  gap: 10px;
  min-height: 48px;
  padding: 5px 11px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text);
  background: transparent;
  cursor: pointer;
}

.room-switcher:hover {
  border-color: var(--line);
  background: var(--panel);
}

.room-switcher > span {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 110px;
}

.room-switcher > svg {
  width: 15px;
  color: var(--muted);
}

.room-switcher strong {
  font-size: 15px;
}

.room-switcher small {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--amber);
}

.status-dot.online {
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(121, 215, 139, 0.12);
}

.status-dot.offline {
  background: var(--red);
}

.topbar > .icon-button {
  justify-self: end;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  cursor: pointer;
}

.icon-button:hover {
  border-color: var(--muted);
  background: var(--panel-strong);
}

.icon-button svg,
.member-count svg,
.control-button svg {
  width: 19px;
  height: 19px;
  stroke-width: 2;
}

main {
  width: min(1080px, calc(100% - 36px));
  margin: 0 auto;
  padding: 50px 0 140px;
}

.room-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.12;
  letter-spacing: 0;
}

.member-count {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 70px;
  height: 38px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  background: var(--panel);
}

.participant-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr));
  gap: 14px;
}

.input-panel {
  display: grid;
  grid-template-columns: 46px minmax(150px, 1fr) minmax(220px, 380px);
  align-items: center;
  gap: 15px;
  min-height: 78px;
  margin-bottom: 20px;
  padding: 15px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.input-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 6px;
  color: var(--green);
  background: var(--green-dark);
}

.input-copy strong,
.input-copy span {
  display: block;
}

.input-copy strong {
  margin-bottom: 5px;
  font-size: 14px;
}

.input-copy span {
  color: var(--muted);
  font-size: 12px;
}

.participant-card,
.connecting-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 15px;
  min-height: 98px;
  padding: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.participant-card {
  display: block;
}

.participant-identity {
  position: relative;
  display: flex;
  align-items: center;
  gap: 15px;
}

.participant-card.speaking {
  border-color: var(--green);
  box-shadow: inset 3px 0 0 var(--green);
}

.avatar {
  display: grid;
  flex: 0 0 54px;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  color: #171815;
  font-size: 20px;
  font-weight: 900;
}

.participant-copy {
  min-width: 0;
}

.participant-copy strong,
.participant-copy span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.participant-copy strong {
  margin-bottom: 6px;
  font-size: 15px;
}

.participant-copy span {
  color: var(--muted);
  font-size: 12px;
}

.participant-card .mic-state {
  position: absolute;
  right: 0;
  bottom: 0;
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  color: var(--green);
  background: var(--green-dark);
}

.volume-control {
  display: grid;
  grid-template-columns: 1fr 48px;
  align-items: center;
  gap: 12px;
}

.volume-control input[type="range"] {
  height: 20px;
  padding: 0;
  border: 0;
  accent-color: var(--green);
  box-shadow: none;
  cursor: pointer;
}

.volume-control output {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.participant-volume {
  grid-template-columns: 18px 1fr 43px;
  gap: 8px;
  margin-top: 16px;
  padding-top: 13px;
  border-top: 1px solid var(--line);
}

.participant-volume svg {
  width: 16px;
  color: var(--muted);
}

.participant-card .mic-state.muted {
  color: var(--red);
  background: var(--red-dark);
}

.mic-state svg {
  width: 14px;
  height: 14px;
}

.connecting-card {
  color: var(--muted);
}

.loader {
  width: 26px;
  height: 26px;
  border: 3px solid var(--line);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.control-bar {
  position: fixed;
  z-index: 20;
  right: 50%;
  bottom: 24px;
  display: flex;
  gap: 7px;
  max-width: calc(100% - 24px);
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #10110f;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.38);
  transform: translateX(50%);
}

.control-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 78px;
  height: 62px;
  padding: 5px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
}

.control-button:hover {
  background: var(--panel-strong);
}

.control-button span {
  max-width: 68px;
  overflow: hidden;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.control-button.active {
  color: var(--red);
  background: var(--red-dark);
}

.control-button.danger {
  color: var(--red);
}

.control-button.danger:hover {
  background: var(--red-dark);
}

.toast {
  position: fixed;
  z-index: 30;
  top: 86px;
  right: 20px;
  max-width: min(360px, calc(100% - 40px));
  padding: 12px 15px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-strong);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

dialog {
  width: min(420px, calc(100% - 32px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--panel);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(5px);
}

dialog form {
  padding: 22px;
}

.dialog-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  margin-bottom: 24px;
}

.dialog-heading h2 {
  margin-bottom: 0;
  font-size: 22px;
  letter-spacing: 0;
}

.room-input-row {
  display: grid;
  grid-template-columns: 1fr 46px;
  gap: 8px;
}

.room-input-row .icon-button {
  width: 46px;
  height: 46px;
}

.recent-rooms {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 14px;
}

.recent-rooms > span {
  width: 100%;
  color: var(--muted);
  font-size: 12px;
}

.recent-rooms button {
  max-width: 150px;
  min-height: 32px;
  padding: 0 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  background: var(--bg);
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.recent-rooms button:hover {
  border-color: var(--green);
  color: var(--text);
}

label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input {
  width: 100%;
  height: 46px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: none;
  color: var(--text);
  background: var(--bg);
}

input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(121, 215, 139, 0.12);
}

.primary-button {
  width: 100%;
  min-height: 46px;
  margin-top: 14px;
  border: 0;
  border-radius: 6px;
  color: #102016;
  background: var(--green);
  font-weight: 800;
  cursor: pointer;
}

@media (max-width: 600px) {
  .topbar {
    grid-template-columns: auto 1fr auto;
    min-height: 64px;
    padding: 10px 14px;
  }

  .brand > span:last-child {
    display: none;
  }

  .room-title,
  .room-switcher {
    min-width: 0;
  }

  .room-switcher > span {
    min-width: 90px;
  }

  main {
    width: calc(100% - 28px);
    padding-top: 34px;
  }

  .room-heading {
    align-items: center;
  }

  h1 {
    font-size: 28px;
  }

  .participant-grid {
    grid-template-columns: 1fr;
  }

  .input-panel {
    grid-template-columns: 42px 1fr;
    padding: 14px;
  }

  .input-volume {
    grid-column: 1 / -1;
  }

  .control-bar {
    bottom: 10px;
    gap: 2px;
    width: calc(100% - 20px);
    justify-content: space-between;
  }

  .control-button {
    width: min(76px, 23vw);
    height: 58px;
  }
}
