:root {
  color-scheme: dark;
  --rail: #121214;
  --sidebar: #121214;
  --main: #1a1a1e;
  --panel: #242429;
  --hover: #242429;
  --selected: #2d2d33;
  --text: #f2f3f5;
  --muted: #94949f;
  --line: #ffffff0d;
  --accent: #5865f2;
  --sidebar-width: 300px;
  --effective-sidebar-width: var(--sidebar-width);
  --message-size: 16px;
  font-family: Inter, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--rail);
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
button,
input,
select,
textarea {
  font: inherit;
}
button {
  cursor: pointer;
  border: 0;
  background: none;
  color: inherit;
}
button:disabled {
  opacity: 0.5;
  cursor: wait;
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid #00a8fc;
  outline-offset: 2px;
}
button svg {
  flex: none;
}
svg {
  vertical-align: middle;
  flex-shrink: 0;
}
input,
textarea,
select {
  background: #111114;
  border: 1px solid #ffffff12;
  border-radius: 4px;
  color: var(--text);
  padding: 11px 12px;
  min-width: 0;
}
textarea {
  resize: vertical;
}
input[type="checkbox"] {
  accent-color: var(--accent);
  width: 20px;
  height: 20px;
}
a {
  color: #00a8fc;
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}
[hidden] {
  display: none !important;
}
.muted,
.hint {
  color: var(--muted);
}
.hint {
  font-size: 12px;
  line-height: 1.6;
}
.primary,
.secondary,
.white-button {
  border-radius: 4px;
  padding: 11px 18px;
  font-weight: 600;
  transition: background 0.15s;
}
.primary {
  background: var(--accent);
  color: white;
}
.primary:hover {
  background: #4752c4;
}
.secondary {
  background: #38383e;
}
.secondary:hover {
  background: #46464f;
}
.white-button {
  background: #f2f3f5;
  color: #171719;
  font-size: 16px;
}
.wide {
  width: 100%;
  margin-top: 16px;
}
.link {
  color: #00a8fc;
  padding: 0;
}
.danger-text {
  color: #f23f42 !important;
}
.icon-button {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  color: #b5bac1;
  padding: 4px;
  flex: none;
}
.icon-button:hover,
.tiny-button:hover {
  background: var(--hover);
  color: var(--text);
}
.tiny-button {
  width: 18px;
  height: 28px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}
.tiny-button svg {
  width: 13px;
}
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  flex: none;
  font-size: 16px;
  position: relative;
}
.avatar.small {
  width: 24px;
  height: 24px;
  font-size: 12px;
}
.avatar.large {
  width: 80px;
  height: 80px;
  font-size: 38px;
}
.auth {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  background: #5865f2;
  padding: 24px;
  position: relative;
  overflow: hidden;
}
.auth-background {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 10% 100%, #a4aaff88, transparent 40%),
    radial-gradient(ellipse at 100% 0, #2b247e, transparent 60%);
  pointer-events: none;
}
.auth-card {
  width: 480px;
  max-width: 100%;
  background: #313338;
  padding: 32px;
  border-radius: 6px;
  box-shadow: 0 8px 30px #0004;
  z-index: 1;
}
.auth-brand {
  font-size: 12px;
  letter-spacing: 3px;
  color: #b8befb;
  text-align: center;
  margin-bottom: 24px;
  font-weight: 800;
}
.auth h1 {
  text-align: center;
  font-size: 24px;
  margin: 0 0 8px;
}
.auth-description {
  text-align: center;
  color: #b5bac1;
  margin: 0 0 20px;
}
.auth label,
.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  color: #b5bac1;
  margin: 20px 0;
}
.auth label b {
  color: #fa777c;
}
.auth label span {
  font-weight: 400;
}
.auth input {
  background: #1e1f22;
  border: 0;
  font-size: 16px;
}
.auth-switch {
  color: #949ba4;
  font-size: 14px;
}
.auth-switch button {
  margin-left: 4px;
}
.auth-back {
  margin-top: 18px;
}
.form-error {
  color: #fa777c;
}
.titlebar {
  position: fixed;
  inset: 0 0 auto;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  background: var(--rail);
  z-index: 5;
  user-select: none;
}
.title-logo {
  position: absolute;
  left: 15px;
  font-size: 10px;
  letter-spacing: 0.8px;
  font-weight: 900;
  color: #b5bac1;
}
.title-status {
  position: absolute;
  right: 12px;
  color: #faa61a;
}
.server-rail {
  position: fixed;
  left: 0;
  top: 32px;
  bottom: 0;
  width: 72px;
  display: flex;
  align-items: center;
  flex-direction: column;
  gap: 8px;
  padding-top: 8px;
  overflow: auto;
  scrollbar-width: none;
}
.server-icon {
  position: relative;
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: #242429;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  transition:
    border-radius 0.15s,
    background 0.15s;
}
.server-icon:hover,
.server-icon.selected {
  background: var(--accent);
  border-radius: 14px;
  color: white;
}
.server-icon.selected:before {
  content: "";
  position: fixed;
  left: 0;
  height: 36px;
  width: 4px;
  border-radius: 0 4px 4px 0;
  background: white;
}
.home-icon {
  border-radius: 16px;
  background: #2d2d33;
}
.add-server {
  color: #3ba55c;
}
.add-server:hover {
  background: #248046;
}
.rail-separator {
  height: 2px;
  width: 32px;
  background: #ffffff0e;
  margin: 0 0 2px;
}
#server-icons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sidebar {
  position: fixed;
  left: 72px;
  top: 32px;
  bottom: 68px;
  width: var(--effective-sidebar-width);
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  border-radius: 10px 0 0 0;
  display: flex;
  flex-direction: column;
}
.server-header {
  height: 50px;
  min-height: 50px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  text-align: left;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  font-size: 16px;
  box-shadow: 0 1px 2px #0003;
}
.server-header:hover {
  background: var(--hover);
}
.channel-list {
  overflow: auto;
  padding: 12px 8px 150px;
  scrollbar-width: thin;
}
.category-label {
  color: #94949f;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 700;
  margin: 16px 4px 5px;
  gap: 4px;
}
.category-collapse {
  text-align: left;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 5px;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  font-size: 11px;
  font-weight: 700;
}
.category-collapse:hover {
  color: var(--text);
}
.channel-wrap {
  position: relative;
}
.channel-row {
  width: 100%;
  height: 34px;
  display: flex;
  align-items: center;
  text-align: left;
  gap: 8px;
  color: #94949f;
  border-radius: 5px;
  padding: 0 8px;
  font-size: 15px;
  margin: 2px 0;
}
.channel-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.channel-row svg {
  color: #80848e;
}
.channel-row:hover,
.channel-row.active {
  background: var(--hover);
  color: #dbdee1;
}
.channel-row.active {
  background: var(--selected);
  color: white;
}
.channel-row-tools {
  display: none;
  position: absolute;
  right: 4px;
  top: 3px;
  background: var(--hover);
  padding-left: 4px;
}
/* On iOS, revealing display:none descendants on hover consumes the first tap. */
@media (hover: hover) and (pointer: fine) {
  .channel-wrap:hover .channel-row-tools { display: flex; }
  .channel-wrap:hover .channel-name { padding-right: 32px; }
}
@media (hover: none), (pointer: coarse) {
  .channel-row-tools { display: flex; }
  .channel-wrap .channel-name { padding-right: 44px; }
}
.voice-member {
  display: flex;
  align-items: center;
  gap: 8px;
  width: calc(100% - 25px);
  height: 32px;
  margin-left: 25px;
  padding: 4px 6px;
  border-radius: 4px;
  color: #94949f;
  text-align: left;
}
.voice-member:hover {
  background: var(--hover);
  color: white;
}
.voice-member > span:nth-child(2) {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}
.live-badge {
  background: #f23f42;
  color: white;
  font-size: 9px;
  border-radius: 3px;
  padding: 2px 4px;
  white-space: nowrap;
  margin-left: 6px;
}
.dm-row {
  height: 42px;
}
.sidebar-resize {
  position: absolute;
  top: 0;
  right: -3px;
  width: 6px;
  height: 100%;
  cursor: col-resize;
  z-index: 9;
}
.user-panel {
  position: fixed;
  bottom: 8px;
  left: 8px;
  width: calc(var(--effective-sidebar-width) + 56px);
  z-index: 10;
  border: 1px solid #ffffff08;
  background: var(--panel);
  border-radius: 8px;
  box-shadow: 0 2px 8px #0003;
}
.profile-controls {
  display: flex;
  align-items: center;
  padding: 8px;
  gap: 6px;
  height: 56px;
}
.my-profile {
  display: flex;
  gap: 8px;
  align-items: center;
  flex: 1;
  min-width: 0;
  text-align: left;
  border-radius: 4px;
  padding: 0 4px;
  height: 40px;
}
.my-profile:hover {
  background: #ffffff0b;
}
.my-profile > span:last-child {
  min-width: 0;
}
.my-profile strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}
.my-profile small {
  font-size: 10px;
  color: #b5bac1;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.profile-buttons {
  display: flex;
  align-items: center;
}
.profile-buttons .icon-button {
  width: 30px;
}
.profile-buttons .tiny-button {
  width: 12px;
}
.off {
  color: #f23f42 !important;
}
.voice-status-row {
  display: flex;
  align-items: center;
  padding: 10px 8px 3px;
}
.connection-details {
  flex: 1;
  display: flex;
  gap: 8px;
  align-items: center;
  text-align: left;
  min-width: 0;
}
.connection-details strong {
  color: #43b581;
  font-size: 12px;
  display: block;
}
.connection-details small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  max-width: 230px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.connection-details svg {
  color: #43b581;
  width: 18px;
}
.connection-actions {
  display: flex;
  gap: 6px;
  padding: 5px 8px 10px;
  border-bottom: 1px solid #ffffff0a;
}
.connection-actions button {
  background: #333339;
  border-radius: 4px;
  height: 30px;
  flex: 1;
}
.connection-actions button:hover {
  background: #404047;
}
.connection-actions svg {
  width: 18px;
}
.workspace {
  position: fixed;
  left: calc(72px + var(--effective-sidebar-width));
  right: 0;
  top: 32px;
  bottom: 0;
  background: var(--main);
  border-radius: 10px 0 0 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid #ffffff0a;
}
.channel-header {
  height: 50px;
  min-height: 50px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 2px #0002;
  z-index: 2;
}
.channel-header > span:first-of-type {
  color: #94949f;
}
.channel-header strong {
  font-size: 15px;
  white-space: nowrap;
}
.header-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}
.header-tools .icon-button {
  width: 24px;
}
#header-topic {
  border-left: 1px solid #ffffff14;
  margin-left: 8px;
  padding-left: 16px;
  font-size: 13px;
  color: #94949f;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#header-topic:empty {
  display: none;
}
#mobile-sidebar {
  display: none;
}
.friends-view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.friends-toolbar {
  height: 52px;
  padding: 10px 20px;
  display: flex;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  align-items: center;
}
.friends-toolbar button {
  padding: 5px 9px;
  font-weight: 600;
  color: #b5bac1;
  border-radius: 4px;
}
.friends-toolbar button:hover,
.friends-toolbar button.active {
  background: var(--selected);
  color: var(--text);
}
.friends-toolbar .add-friend-tab {
  background: #248046;
  color: white;
}
.friends-toolbar .add-friend-tab.active {
  background: none;
  color: #43b581;
}
.friends-body {
  display: flex;
  flex: 1;
  min-height: 0;
}
.friends-content {
  padding: 20px 30px;
  flex: 1;
  overflow: auto;
}
.friends-content > h3 {
  font-size: 12px;
  color: #b5bac1;
  margin: 0 0 20px;
}
.activity-panel {
  width: 300px;
  border-left: 1px solid var(--line);
  padding: 8px 16px;
}
.activity-panel h2 {
  font-size: 20px;
}
.activity-panel h3 {
  font-size: 15px;
  text-align: center;
  margin: 30px 0 8px;
}
.activity-panel p {
  text-align: center;
  font-size: 13px;
  line-height: 1.5;
}
.friend-row {
  display: flex;
  align-items: center;
  padding: 12px 4px;
  border-top: 1px solid var(--line);
  gap: 10px;
  border-radius: 8px;
}
.friend-row:hover {
  background: var(--hover);
}
.friend-info {
  display: grid;
  grid-template-columns: 36px 1fr;
  column-gap: 10px;
  text-align: left;
  flex: 1;
  align-items: center;
}
.friend-info .avatar {
  grid-row: 1/3;
}
.friend-info small {
  font-size: 11px;
  color: var(--muted);
}
.friend-row > .icon-button {
  border-radius: 50%;
  background: #111114;
  width: 36px;
  height: 36px;
}
.empty-friends {
  height: 50vh;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  color: var(--muted);
}
.empty-friends svg {
  color: #5865f266;
}
.empty-friends h2 {
  margin-top: 30px;
  font-size: 19px;
}
.empty-friends p {
  font-size: 13px;
}
.add-friend-form {
  display: flex;
  padding: 8px;
  background: #111114;
  border: 1px solid #ffffff1a;
  border-radius: 8px;
  margin-top: 20px;
  gap: 12px;
}
.add-friend-form input {
  flex: 1;
  border: 0;
  background: none;
}
.chat-view {
  display: flex;
  flex: 1;
  min-height: 0;
}
.chat-main {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  min-height: 0;
}
.messages {
  overflow: auto;
  flex: 1;
  min-height: 0;
  scrollbar-width: thin;
  padding-bottom: 16px;
  overscroll-behavior: contain;
}
.channel-welcome {
  padding: 28px 16px 12px;
}
.channel-welcome > svg {
  padding: 10px;
  border-radius: 50%;
  background: #3f4147;
  width: 68px;
  height: 68px;
}
.channel-welcome h1 {
  font-size: 30px;
  margin: 16px 0 8px;
  letter-spacing: -0.5px;
}
.channel-welcome p {
  color: #94949f;
  font-size: 14px;
}
.date-divider {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: #94949f;
  margin: 16px;
}
.date-divider:before,
.date-divider:after {
  content: "";
  height: 1px;
  background: #ffffff10;
  flex: 1;
}
.message {
  position: relative;
  display: flex;
  gap: 16px;
  padding: 3px 48px 3px 16px;
  margin-top: 12px;
  font-size: var(--message-size);
  min-width: 0;
}
.message > .avatar {
  width: 40px;
  height: 40px;
  margin-top: 2px;
}
.message:hover {
  background: #00000012;
}
.message-content {
  flex: 1;
  min-width: 0;
}
.message-heading {
  display: flex;
  align-items: baseline;
  gap: 8px;
  height: 23px;
}
.message-author {
  padding: 0;
  font-size: 15px;
  font-weight: 600;
}
.message-author:hover {
  text-decoration: underline;
}
.message-heading time,
.message-heading small {
  font-size: 10px;
  color: #94949f;
}
.message-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.5;
  color: #dbdee1;
}
.message-reply {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.message-actions {
  position: absolute;
  top: -20px;
  right: 16px;
  background: #242429;
  border: 1px solid #ffffff12;
  border-radius: 5px;
  display: none;
  box-shadow: 0 2px 6px #0005;
}
.message:hover .message-actions,
.message:focus-within .message-actions {
  display: flex;
}
.message-form {
  display: flex;
  gap: 10px;
  align-items: center;
  background: #242429;
  border: 1px solid #ffffff0c;
  border-radius: 8px;
  min-height: 56px;
  margin: 0 16px;
  padding: 8px 12px;
}
.message-form textarea {
  border: 0;
  background: none;
  flex: 1;
  padding: 7px 0;
  resize: none;
  max-height: 150px;
  color: #dbdee1;
  font-size: var(--message-size);
  line-height: 1.4;
  min-height: 30px;
}
.message-form textarea::placeholder {
  color: #80848e;
}
.typing-status {
  height: 24px;
  padding: 4px 20px;
  font-size: 11px;
  color: #b5bac1;
}
.reply-bar {
  margin: 0 16px;
  padding: 4px 12px;
  background: #2d2d33;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-radius: 6px 6px 0 0;
  color: var(--muted);
}
.member-list {
  width: 240px;
  min-width: 190px;
  overflow: auto;
  background: #17171b;
  padding: 12px 8px;
}
.member-list h3 {
  font-size: 10px;
  color: var(--muted);
  margin: 16px 8px 8px;
}
.member-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  width: 100%;
  border-radius: 4px;
  text-align: left;
  color: #b5bac1;
  font-weight: 500;
}
.member-row:hover {
  background: var(--hover);
  color: white;
}
.member-row.offline {
  opacity: 0.5;
}
.attachment {
  display: flex;
  gap: 12px;
  padding: 12px;
  border: 1px solid #ffffff12;
  border-radius: 6px;
  max-width: 480px;
  margin-top: 8px;
  background: #242429;
  width: fit-content;
}
.attachment:has(img) {
  padding: 0;
  overflow: hidden;
}
.attachment img {
  max-width: 100%;
  max-height: 350px;
  object-fit: contain;
}
.reactions {
  display: flex;
  gap: 4px;
  margin-top: 5px;
}
.reactions button {
  background: #25252b;
  border: 1px solid transparent;
  padding: 3px 7px;
  border-radius: 5px;
  font-size: 12px;
}
.reactions button.selected {
  border-color: #5865f2;
  background: #5865f233;
}
#attachment-progress {
  padding: 8px 20px;
  color: var(--muted);
  font-size: 12px;
}
.voice-view {
  position: relative;
  flex: 1;
  min-height: 0;
  background: #000;
  display: flex;
  flex-direction: column;
}
.voice-empty {
  position: absolute;
  inset: 0;
  background: radial-gradient(
    ellipse at 50% 30%,
    #3c438d 0,
    #25284a 38%,
    #1a1a2b 78%
  );
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  padding: 32px;
  text-align: center;
}
.voice-empty > div > svg {
  width: 90px;
  height: 90px;
  color: #c5c9ff;
  padding: 20px;
  background: #ffffff12;
  border-radius: 25px;
}
.voice-empty h1 {
  font-size: 30px;
  margin: 8px;
}
.voice-empty p {
  color: #b5bac1;
  margin: 0 0 16px;
}
.voice-empty .link {
  font-size: 12px;
  margin-top: 8px;
}
.call-stage {
  position: absolute;
  inset: 12px 12px 98px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}
.call-grid {
  display: grid;
  grid-template-columns: repeat(var(--tiles, 2), minmax(0, 1fr));
  grid-auto-rows: minmax(0, 1fr);
  gap: 8px;
  flex: 1;
  min-height: 0;
  align-content: center;
}
.call-tile {
  border-radius: 10px;
  background: #202024;
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  border: 2px solid transparent;
  isolation: isolate;
}
.call-tile.speaking {
  border-color: #43b581;
}
.rtc-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  min-height: 0;
}
.call-tile.camera .rtc-video {
  object-fit: cover;
}
.tile-label {
  position: absolute;
  bottom: 10px;
  left: 10px;
  padding: 4px 6px;
  background: #0009;
  border-radius: 4px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 2;
}
.tile-actions {
  position: absolute;
  right: 8px;
  top: 8px;
  display: none;
  background: #111d;
  border-radius: 6px;
  z-index: 3;
}
.call-tile:hover .tile-actions,
.call-tile:focus-within .tile-actions {
  display: flex;
}
.stream-poster {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 24px;
  gap: 16px;
  max-width: 330px;
  text-align: center;
}
.stream-poster svg {
  color: #94949f;
}
.stream-poster strong {
  font-size: 15px;
}
.stream-poster .wide {
  margin: 0;
}
.stream-stats {
  position: absolute;
  bottom: 10px;
  right: 10px;
  background: #0009;
  border-radius: 4px;
  font-size: 10px;
  padding: 4px;
  color: #b5bac1;
  pointer-events: none;
}
.focus-stage {
  flex: 1;
  min-height: 0;
  display: flex;
}
.focus-stage > .call-tile {
  flex: 1;
}
.call-strip {
  height: 110px;
  min-height: 80px;
  display: flex;
  gap: 8px;
  justify-content: center;
  overflow: auto;
}
.call-strip > .call-tile {
  width: 180px;
  flex-shrink: 0;
}
.call-strip .avatar.large {
  width: 42px;
  height: 42px;
  font-size: 20px;
}
.call-strip .stream-poster {
  gap: 4px;
  padding: 5px;
  font-size: 10px;
}
.call-strip .stream-poster svg {
  width: 20px;
  height: 20px;
}
.call-strip .stream-poster strong {
  font-size: 10px;
}
.call-strip .primary {
  padding: 4px;
  font-size: 10px;
}
.call-strip .tile-label {
  font-size: 9px;
  bottom: 2px;
  left: 2px;
}
.call-controls {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  align-items: center;
  z-index: 3;
}
.call-control-group {
  display: flex;
  background: #2b2d31;
  border-radius: 16px;
  overflow: hidden;
}
.call-button {
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  color: white;
}
.call-button:hover,
.call-dropdown:hover {
  background: #41434a;
}
.call-button.on {
  background: #248046;
}
.call-dropdown {
  width: 22px;
  padding: 0 4px 0 0;
  color: #b5bac1;
}
.call-dropdown svg {
  width: 12px;
}
.call-button.disconnect {
  background: #da373c;
  border-radius: 16px;
}
.call-button.disconnect:hover {
  background: #a12828;
}
.call-layout-tools {
  position: absolute;
  bottom: 32px;
  right: 16px;
  display: flex;
  gap: 8px;
}
.call-notice {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: #5e2529;
  border: 1px solid #f23f4266;
  padding: 12px;
  border-radius: 6px;
  max-width: 90%;
  z-index: 4;
  text-align: center;
}
.voice-chat {
  position: absolute;
  right: 0;
  top: 50px;
  bottom: 0;
  width: 340px;
  background: var(--main);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}
.voice-chat > header {
  height: 48px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
}
.with-voice-chat .voice-view {
  margin-right: 340px;
}
.voice-chat .message-form {
  margin: 8px;
  min-height: 48px;
}
.voice-chat .channel-welcome h1 {
  font-size: 22px;
}
.voice-chat .message {
  padding-left: 12px;
  gap: 8px;
}
.voice-chat .message > .avatar {
  width: 30px;
  height: 30px;
}
.settings {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: var(--main);
  display: flex;
}
.settings-nav {
  width: calc(50% - 260px);
  min-width: 240px;
  background: var(--sidebar);
  display: flex;
  justify-content: flex-end;
  overflow: auto;
}
.settings-nav-inner {
  width: 218px;
  padding: 48px 8px 24px;
}
.settings-profile {
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 0 8px 30px;
}
.settings-nav h3 {
  font-size: 10px;
  color: #94949f;
  padding: 0 10px;
  margin: 20px 0 8px;
}
.settings-nav button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 9px 10px;
  border-radius: 4px;
  color: #b5bac1;
  font-size: 14px;
  margin: 2px 0;
}
.settings-nav button.active,
.settings-nav button:hover {
  background: var(--selected);
  color: white;
}
.settings-separator {
  height: 1px;
  background: var(--line);
  margin: 12px 10px;
}
.version-label {
  display: block;
  font-size: 10px;
  color: #6d6f78;
  margin: 16px 10px;
}
.settings-main {
  flex: 1;
  overflow: auto;
  padding: 46px 72px 60px 40px;
}
.settings-main > div {
  max-width: 660px;
}
.settings-main h2 {
  font-size: 21px;
  margin: 0 0 28px;
}
.settings-main h3 {
  font-size: 12px;
  color: #b5bac1;
  margin: 32px 0 16px;
}
.settings-main p {
  line-height: 1.6;
}
.settings-main > .wide {
  max-width: 300px;
}
.settings-main .volume-control {
  margin: 24px 0;
}
.settings-close {
  position: absolute;
  top: 45px;
  right: max(22px, calc(50% - 490px));
  border: 2px solid #72767d;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  color: #b5bac1;
}
.settings-close:after {
  content: "ESC";
  position: absolute;
  top: 44px;
  font-size: 11px;
  font-weight: 600;
}
.settings-close:hover {
  background: var(--hover);
}
.account-card {
  background: var(--panel);
  border-radius: 8px;
  padding: 24px;
  margin-bottom: 32px;
}
.account-card h2 {
  margin: 16px 0 4px;
}
.account-card .primary {
  width: auto;
}
.field input,
.field select,
.field textarea {
  font-size: 14px;
  font-weight: 400;
}
.field textarea {
  height: 100px;
}
.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.toggle-row small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  margin-top: 6px;
}
.toggle-row input {
  flex: none;
}
.volume-control {
  display: block;
  padding: 8px 0 14px;
  color: #b5bac1;
}
.volume-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
  font-size: 12px;
  font-weight: 600;
  gap: 10px;
}
.volume-control input {
  width: 100%;
  height: 7px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  appearance: none;
  background: linear-gradient(
    to right,
    #5865f2 var(--volume),
    #4b4b55 var(--volume)
  );
  cursor: pointer;
  display: block;
  margin: 0;
}
.volume-control input::-webkit-slider-thumb {
  appearance: none;
  background: #f2f3f5;
  width: 10px;
  height: 22px;
  border-radius: 3px;
  box-shadow: 0 0 2px #0009;
}
.volume-control input::-moz-range-thumb {
  background: white;
  width: 10px;
  height: 22px;
  border: 0;
  border-radius: 3px;
}
.input-meter {
  height: 12px;
  background: #44454b;
  border-radius: 8px;
  overflow: hidden;
  margin: 16px 0;
}
.input-meter i {
  display: block;
  height: 100%;
  background: #43b581;
  width: 0;
  transition: width 0.08s;
}
.diagnostic-json {
  background: #111114;
  border: 1px solid #ffffff10;
  border-radius: 6px;
  padding: 16px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 12px;
  line-height: 1.6;
  color: #b5bac1;
}
.context-menu {
  position: fixed;
  z-index: 80;
  background: #111114;
  border: 1px solid #ffffff10;
  box-shadow: 0 8px 24px #0008;
  border-radius: 6px;
  padding: 6px;
  width: 260px;
  max-height: calc(100dvh - 16px);
  overflow: auto;
}
.context-menu > button,
.device-menu > button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 8px;
  text-align: left;
  border-radius: 3px;
  font-size: 13px;
  color: #b5bac1;
}
.context-menu > button:hover,
.device-menu > button:hover {
  background: #5865f2;
  color: white;
}
.context-menu hr {
  border: 0;
  border-top: 1px solid #ffffff12;
  margin: 4px;
}
.participant-volume {
  padding: 10px 8px 4px;
}
.participant-volume > strong {
  display: block;
  font-size: 13px;
  margin-bottom: 8px;
}
.device-menu {
  padding: 4px 6px;
}
.device-menu h3 {
  font-size: 10px;
  color: #94949f;
}
.context-menu .volume-control {
  margin: 12px 0 0;
}
dialog {
  color: var(--text);
  background: #313338;
  border: 0;
  border-radius: 8px;
  padding: 28px 28px 24px;
  width: 460px;
  max-width: calc(100vw - 32px);
  max-height: 90dvh;
  box-shadow: 0 12px 40px #0008;
}
dialog::backdrop {
  background: #000b;
}
dialog h2 {
  font-size: 22px;
  margin: 0 24px 18px 0;
}
dialog .muted {
  line-height: 1.5;
}
.modal-close {
  position: absolute;
  right: 14px;
  top: 14px;
  color: #b5bac1;
  padding: 4px;
}
.type-option {
  display: grid;
  grid-template-columns: 30px 1fr;
  text-align: left;
  background: #2b2d31;
  padding: 14px;
  border-radius: 5px;
  width: 100%;
  margin: 8px 0;
  column-gap: 10px;
}
.type-option svg {
  grid-row: 1/3;
  color: #b5bac1;
}
.type-option small {
  color: #94949f;
  margin-top: 4px;
  line-height: 1.4;
}
.type-option.selected {
  background: #43454d;
  outline: 1px solid #5865f2;
}
.friend-invite,
.discover-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 12px;
  border-radius: 4px;
  text-align: left;
}
.friend-invite:hover,
.discover-row:hover {
  background: #ffffff0b;
}
.friend-invite span {
  color: #43b581;
  font-size: 12px;
}
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #111114;
  border: 1px solid #ffffff22;
  border-radius: 6px;
  padding: 14px 20px;
  z-index: 100;
  max-width: 90vw;
  box-shadow: 0 5px 20px #0008;
  line-height: 1.5;
}
#audio-unlock {
  position: fixed;
  top: 40px;
  left: 50%;
  transform: translateX(-50%);
  background: #38354a;
  padding: 12px 18px;
  border-radius: 6px;
  z-index: 90;
  display: flex;
  gap: 16px;
  align-items: center;
}
#cinema {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: #000;
  color: #fff;
}
#cinema-grid {
  position: absolute;
  inset: 0;
  display: flex;
  gap: 2px;
}
#cinema-grid.vertical {
  flex-direction: column;
}
.cinema-cell {
  flex: 1;
  min-height: 0;
  min-width: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cinema-cell video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.cinema-remove {
  position: absolute;
  top: 12px;
  right: 12px;
  border-radius: 50%;
  background: #111b;
  padding: 8px;
}
.cinema-remove svg {
  width: 18px;
}
#cinema-bar {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  z-index: 2;
  padding: 8px;
  background: #16161bd9;
  border: 1px solid #ffffff15;
  border-radius: 12px;
  transition: opacity 0.2s;
}
.cinema-button {
  width: 44px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 6px;
}
.cinema-button:hover {
  background: #ffffff18;
}
#cinema.idle {
  cursor: none;
}
#cinema.idle #cinema-bar,
#cinema.idle .cinema-remove {
  opacity: 0;
  pointer-events: none;
}
#cinema-panel {
  position: absolute;
  bottom: 86px;
  right: 20px;
  background: #171719f5;
  border: 1px solid #ffffff1a;
  border-radius: 10px;
  padding: 18px;
  width: 350px;
  max-height: 75dvh;
  overflow: auto;
  z-index: 3;
}
#cinema-panel h3 {
  font-size: 14px;
  margin: 0 0 16px;
}
.cinema-user {
  border-top: 1px solid #ffffff15;
  padding: 16px 0;
}
.cinema-user > strong {
  font-size: 14px;
}
.cinema-user .secondary {
  margin: 4px 0 0;
}
.cinema-user .volume-control {
  margin: 12px 0;
}
.titlebar #title-name {
  max-width: 50vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
:root[data-theme="dark"] {
  --rail: #1e1f22;
  --sidebar: #2b2d31;
  --main: #313338;
  --panel: #232428;
  --hover: #35373c;
  --selected: #404249;
}
:root[data-theme="light"] {
  color-scheme: light;
  --rail: #e3e5e8;
  --sidebar: #f2f3f5;
  --main: #fff;
  --panel: #ebedef;
  --hover: #e3e5e8;
  --selected: #d4d7dc;
  --text: #242429;
  --muted: #666a73;
  --line: #00000010;
}
:root[data-theme="light"] input,
:root[data-theme="light"] textarea,
:root[data-theme="light"] select {
  background: #e3e5e8;
}
:root[data-theme="light"] .message-text {
  color: #313338;
}
:root[data-theme="light"] .member-list {
  background: #f2f3f5;
}
@media (min-width: 1500px) {
  .activity-panel {
    width: 360px;
  }
}
@media (max-width: 1100px) {
  .activity-panel {
    display: none;
  }
  .header-tools {
    gap: 6px;
  }
  .call-layout-tools {
    bottom: 90px;
  }
  .with-voice-chat .voice-view {
    margin-right: 290px;
  }
  .voice-chat {
    width: 290px;
  }
  .member-list {
    width: 200px;
  }
  .settings-nav {
    min-width: 210px;
  }
  .settings-main {
    padding-left: 28px;
  }
  .profile-buttons .tiny-button {
    display: none;
  }
}
@media (max-width: 850px) {
  :root {
    --effective-sidebar-width: 240px;
  }
  .member-list {
    display: none;
  }
  .call-button {
    width: 44px;
    height: 48px;
  }
  .call-dropdown {
    width: 18px;
  }
  .call-controls {
    gap: 7px;
  }
  .call-control-group,
  .call-button.disconnect {
    border-radius: 12px;
  }
  .header-tools {
    gap: 3px;
  }
  #header-topic {
    display: none;
  }
  .with-voice-chat .voice-view {
    margin-right: 0;
  }
  .voice-chat {
    width: min(340px, 90%);
    box-shadow: -8px 0 20px #0008;
    z-index: 6;
  }
  .settings-nav {
    min-width: 190px;
    width: 190px;
  }
  .settings-nav-inner {
    width: 190px;
  }
  .settings-main {
    padding: 32px 50px 50px 24px;
  }
  .settings-close {
    top: 24px;
    right: 12px;
  }
  .settings-profile {
    margin-bottom: 20px;
  }
  .profile-controls {
    padding: 6px;
  }
  .profile-buttons .icon-button {
    width: 26px;
  }
  .my-profile small {
    font-size: 9px;
  }
  .my-profile .avatar {
    width: 28px;
    height: 28px;
  }
  .call-grid {
    grid-template-columns: repeat(min(var(--tiles), 2), minmax(0, 1fr));
  }
}
@media (max-width: 650px) {
  .titlebar {
    height: 26px;
  }
  .title-logo {
    font-size: 8px;
    left: 10px;
  }
  .workspace {
    left: 0;
    top: 26px;
    border-radius: 0;
  }
  .server-rail,
  .sidebar,
  .user-panel {
    display: none;
  }
  .sidebar-open .server-rail {
    display: flex;
    z-index: 22;
    top: 26px;
    background: var(--rail);
  }
  .sidebar-open .sidebar {
    display: flex;
    z-index: 21;
    top: 26px;
    bottom: 68px;
    width: calc(100vw - 72px);
    box-shadow: 0 0 40px #0009;
  }
  .sidebar-open .user-panel {
    display: block;
    z-index: 23;
    width: calc(100vw - 16px);
  }
  .sidebar-open .workspace {
    visibility: hidden;
  }
  #mobile-sidebar {
    display: inline-flex;
  }
  .channel-header {
    padding: 0 10px;
    gap: 6px;
  }
  .header-tools {
    gap: 4px;
  }
  .channel-header strong {
    max-width: 40vw;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .friends-toolbar {
    padding: 8px;
    gap: 4px;
    overflow: auto;
    white-space: nowrap;
  }
  .friends-toolbar button {
    font-size: 12px;
  }
  .friends-content {
    padding: 18px 14px;
  }
  .friend-row {
    gap: 6px;
  }
  .add-friend-form {
    flex-direction: column;
  }
  .message {
    padding-right: 12px;
    padding-left: 12px;
    gap: 10px;
  }
  .message > .avatar {
    width: 32px;
    height: 32px;
  }
  .message-form {
    margin: 0 8px;
    padding: 8px;
    gap: 4px;
  }
  .message-form .icon-button {
    width: 26px;
  }
  .channel-welcome h1 {
    font-size: 24px;
  }
  .call-grid {
    grid-template-columns: repeat(min(var(--tiles), 2), minmax(0, 1fr));
  }
  .call-stage {
    inset: 8px 8px 100px;
  }
  .stream-poster {
    padding: 12px;
    gap: 10px;
  }
  .stream-poster svg {
    width: 28px;
    height: 28px;
  }
  .stream-poster strong {
    font-size: 12px;
  }
  .stream-poster .primary {
    font-size: 12px;
    padding: 9px;
  }
  .tile-actions {
    display: flex;
    opacity: 0.8;
  }
  .tile-actions .icon-button {
    width: 27px;
    height: 27px;
  }
  .stream-stats {
    font-size: 8px;
    bottom: 32px;
    left: 6px;
    right: auto;
  }
  .tile-label {
    font-size: 10px;
    left: 5px;
    bottom: 5px;
  }
  .call-strip {
    height: 85px;
    min-height: 85px;
  }
  .call-strip > .call-tile {
    width: 130px;
  }
  .call-controls {
    bottom: 24px;
    gap: 6px;
  }
  .call-layout-tools {
    bottom: 83px;
    right: 8px;
  }
  .settings {
    flex-direction: column;
  }
  .settings-nav {
    min-width: 0;
    width: 100%;
    height: auto;
    max-height: 145px;
    flex: none;
    overflow: auto;
  }
  .settings-nav-inner {
    width: 100%;
    padding: 10px 48px 8px 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
  }
  .settings-profile,
  .settings-nav h3,
  .settings-separator,
  .version-label {
    display: none;
  }
  .settings-nav button {
    width: auto;
    padding: 7px 8px;
    font-size: 11px;
  }
  .settings-main {
    padding: 24px 20px 40px;
  }
  .settings-close {
    top: 10px;
    right: 10px;
    width: 30px;
    height: 30px;
  }
  .settings-close:after {
    display: none;
  }
  .auth-card {
    padding: 24px;
  }
  .auth {
    padding: 14px;
  }
  .cinema-cell {
    overflow: hidden;
  }
  #cinema-panel {
    right: 8px;
    bottom: 80px;
    width: calc(100vw - 16px);
    max-height: 65dvh;
  }
  .toast {
    bottom: 18px;
    width: max-content;
  }
  .context-menu {
    max-width: calc(100vw - 16px);
  }
  .empty-friends {
    height: 45vh;
  }
  .empty-friends p {
    text-align: center;
  }
  .call-tile .avatar.large {
    width: 54px;
    height: 54px;
    font-size: 28px;
  }
}
@media (hover: none) {
  .tile-actions {
    display: flex;
  }
}
.context-menu > .field {
  margin: 10px 8px;
}

/* Participant state stays aligned even for long names and live badges. */
.voice-member.speaking .avatar {
  outline: 2px solid #23a55a;
  outline-offset: 2px;
}
.voice-member .voice-member-name {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1;
}
.voice-nickname {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.voice-member .live-badge {
  flex: none;
  white-space: nowrap;
}
.voice-member-status {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-left: auto;
  flex: none;
  color: #949ba4;
}
.access-member {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 14px 0;
  border-bottom: 1px solid #ffffff16;
}
.access-member strong {
  overflow-wrap: anywhere;
}
.access-member .field,
.access-member > .muted {
  grid-column: 2;
  margin: 0;
}

.stream-audience {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 5;
  max-width: calc(100% - 120px);
}
.audience-button {
  display: flex;
  align-items: center;
  gap: 5px;
  background: #151519dd;
  padding: 5px 9px;
  border-radius: 20px;
  color: #fff;
}
.audience-button .avatar {
  width: 25px;
  height: 25px;
  font-size: 12px;
  margin-left: -3px;
  border: 2px solid #151519;
}
.audience-popover {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 220px;
  max-width: min(340px, 70vw);
  max-height: 280px;
  overflow: auto;
  padding: 16px;
  background: #111214;
  border: 1px solid #34343a;
  border-radius: 8px;
  box-shadow: 0 6px 20px #0008;
}
.stream-audience:hover .audience-popover,
.stream-audience:focus-within .audience-popover,
.stream-audience.open .audience-popover {
  display: grid;
  gap: 12px;
}
.audience-person {
  display: flex;
  align-items: center;
  gap: 9px;
  overflow-wrap: anywhere;
}

.avatar {
  overflow: hidden;
  flex-shrink: 0;
}
.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: inherit;
}
.avatar-editor {
  padding-bottom: 24px;
  margin-bottom: 24px;
  border-bottom: 1px solid #ffffff20;
}
.avatar-preview {
  display: flex;
  justify-content: center;
  margin: 16px 0;
}
.emoji-avatar-options {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 5px;
  margin: 10px 0;
}
.emoji-avatar-choice {
  font-size: 25px;
  padding: 6px;
  border-radius: 8px;
  background: #202024;
}
.emoji-avatar-choice:hover {
  background: #414149;
}
.discord-details {
  margin-top: 20px;
  padding: 16px;
  background: #202024;
  border-radius: 8px;
}
.discord-details .field input {
  font-family: monospace;
}

.discord-status { font-size: 12px; font-weight: 600; border: 1px solid #5865f2; border-radius: 6px; padding: 4px 8px; color: #c8ccff; white-space: nowrap; }

/* Channel-admin Discord setup: readable on desktop and tablet. */
dialog:has(.discord-settings){width:720px;overflow-y:auto;}
.discord-section{margin-top:20px;padding-top:16px;border-top:1px solid #ffffff18;}
.discord-section h3{font-size:16px;margin:0 0 14px;}
.discord-state{padding:10px 12px;margin:14px 0;background:#202024;border-radius:6px;font-weight:600;}
.discord-bot-row{display:flex;flex-wrap:wrap;gap:8px 12px;align-items:center;padding:10px 0;border-bottom:1px solid #ffffff10;}
.discord-bot-row>span:first-child{font-weight:600;min-width:120px;}
.discord-bot-row>span:nth-child(2){flex:1;font-size:12px;min-width:160px;}
.discord-link{color:#aeb6ff;display:inline-block;margin:6px 12px 6px 0;}
.discord-warning{color:#ffd28a;}.discord-ok{color:#65d99b;}
.discord-guide{margin-top:22px;padding:14px;background:#202024;border-radius:8px;}
.discord-guide summary{cursor:pointer;font-weight:600;}.discord-guide ol{padding-left:22px;line-height:1.55;}.discord-guide li{margin:16px 0;}
.discord-command{display:block;overflow-wrap:anywhere;padding:10px;background:#111214;border-radius:5px;margin:12px 0;user-select:all;}
.discord-settings .primary{margin-top:12px;}.discord-settings .field{margin-top:12px;}

/* Size the shell to the usable screen; scroll only content panels. */
html, body { width: 100%; height: 100%; overflow: hidden; overscroll-behavior: none; }
body { -webkit-text-size-adjust: 100%; }
.auth { height: var(--viewport-height, 100dvh); min-height: 0; overflow-y: auto; }
.titlebar { top: var(--viewport-top, 0px); }
.workspace, .server-rail, .sidebar { top: calc(var(--viewport-top, 0px) + 32px); }
.workspace, .server-rail { bottom: var(--viewport-bottom, 0px); }
.sidebar { bottom: calc(var(--viewport-bottom, 0px) + 68px); min-height: 0; }
.user-panel { bottom: calc(var(--viewport-bottom, 0px) + 8px + env(safe-area-inset-bottom, 0px)); }
.channel-list { min-height: 0; flex: 1; }
.channel-header, .friends-toolbar { flex-shrink: 0; }
.settings { top: var(--viewport-top, 0px); bottom: var(--viewport-bottom, 0px); }
#mobile-friends { display: none; }
@media (max-width: 1180px) and (min-width: 651px) {
  :root { --effective-sidebar-width: clamp(200px, 24vw, 260px); }
  #header-topic { display: none; }
  .channel-header { padding: 0 10px; gap: 6px; }
  .call-controls { gap: 7px; }
}
@media (max-width: 650px) {
  .workspace, .sidebar-open .server-rail, .sidebar-open .sidebar {
    top: calc(var(--viewport-top, 0px) + 26px);
  }
  .sidebar-open .sidebar { bottom: calc(var(--viewport-bottom, 0px) + 68px); }
  .sidebar-open .workspace { visibility: visible; }
  .sidebar-open .channel-header { visibility: hidden; }
  #mobile-friends { display: inline-flex; flex-shrink: 0; }
  .channel-header strong { min-width: 0; max-width: none; flex: 1; }
  .header-tools { gap: 2px; }
  .header-tools .icon-button { width: 22px; }
  .discord-status { display: none; }
  .friends-toolbar { flex-wrap: wrap; white-space: normal; overflow: visible; }
  .friends-toolbar button { min-height: 36px; }
  .friend-row { min-width: 0; }
  .friend-info { min-width: 0; }
  .settings-main { min-height: 0; }
}
@media (max-height: 560px) and (pointer: coarse) {
  .call-stage { bottom: 76px; }
  .call-controls { bottom: 10px; }
  .call-button { height: 42px; }
  .call-layout-tools { bottom: 65px; }
  .voice-empty { gap: 4px; padding: 12px; }
  .voice-empty > div > svg { width: 48px; height: 48px; padding: 10px; }
  .voice-empty h1 { font-size: 22px; }
}

/* Touch voice-channel preview: explicit join instead of a second channel tap. */
dialog:has(.voice-preview) { width: 560px; background: #1e1f22; border-radius: 22px; }
.voice-preview-heading { display: flex; gap: 12px; align-items: center; }
.voice-preview-empty { padding: 28px 8px; text-align: center; color: var(--muted); line-height: 1.6; }
.voice-preview-members { display: grid; gap: 12px; max-height: 35dvh; overflow-y: auto; margin: 12px 0 24px; }
.voice-preview-member { display: flex; align-items: center; gap: 10px; }
.voice-preview-member > span:not(.avatar) { flex: 1; overflow-wrap: anywhere; }
.voice-preview-join { background: #209c59; min-height: 52px; white-space: normal; }
.voice-preview-join:hover { background: #187d47; }
.voice-preview-listen { min-height: 44px; margin-top: 8px; color: var(--muted); }
@media (max-width: 650px) {
  dialog:has(.voice-preview) { margin: auto 8px max(8px, env(safe-area-inset-bottom)); width: calc(100% - 16px); max-width: none; padding: 24px 20px 16px; }
}

#voice-join.joining::before {
  content: ""; display: inline-block; width: 16px; height: 16px;
  margin-right: 10px; vertical-align: -3px; border: 2px solid currentColor;
  border-right-color: transparent; border-radius: 50%; animation: joining-spin .7s linear infinite;
}
@keyframes joining-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { #voice-join.joining::before { animation: none; } }

.connection-quality svg { width: 100%; height: 130px; background: repeating-linear-gradient(0deg, #ffffff08 0 1px, transparent 1px 32px), #17171b; border-radius: 8px; }
.connection-metrics { display: grid; grid-template-columns: 1fr auto; gap: 12px; }
.connection-metrics dt { color: var(--muted); }
.connection-metrics dd { margin: 0; font-weight: 700; text-align: right; }

/* Short UI-only transitions; media surfaces are never transformed or faded. */
@media (prefers-reduced-motion: no-preference) {
  button, .channel-row, .friend-row, .voice-member {
    transition: background-color .16s ease, color .16s ease, border-color .16s ease, box-shadow .16s ease;
  }
  .server-icon { transition: border-radius .18s ease, background-color .18s ease, color .18s ease; }
  dialog[open], .settings:not([hidden]), .context-menu:not([hidden]) { animation: panel-appear .18s ease-out; }
  dialog[open]::backdrop { animation: backdrop-appear .16s ease-out; }
  @media (max-width: 650px) {
    .sidebar-open .sidebar { animation: drawer-appear .2s ease-out; }
  }
}
@keyframes panel-appear { from { opacity: 0; translate: 0 6px; } to { opacity: 1; translate: 0 0; } }
@keyframes drawer-appear { from { opacity: .5; translate: -10px 0; } to { opacity: 1; translate: 0 0; } }
@keyframes backdrop-appear { from { background: #0000; } to { background: #000b; } }

@media (min-width: 651px) {
  #modal:has(.connection-quality) {
    position: fixed; margin: 0; left: var(--quality-left, 12px); top: var(--quality-top, 12px);
    width: 420px; max-width: calc(100vw - 24px); max-height: calc(100dvh - 24px);
    overflow-y: auto; padding: 20px; border-radius: 14px; background: #242429;
  }
  #modal:has(.connection-quality)::backdrop { background: transparent; animation: none; }
  #modal:has(.connection-quality) h2 { font-size: 18px; }
  .connection-quality svg { height: 110px; }
  .connection-quality > .muted { font-size: 12px; }
}

/* Connection feedback and controls remain usable on narrow/touch screens. */
.stream-connection { display:grid; gap:12px; justify-items:center; text-align:center; max-width:calc(100% - 28px); padding:12px; line-height:1.45; color:var(--muted); }
.stream-connection .primary { min-height:44px; width:auto; padding:10px 20px; }
.stream-route-controls { padding:6px; min-width:0; }
.stream-route-status { color:#b5d8ff; line-height:1.45; overflow-wrap:anywhere; }
.stream-route-controls .primary { min-height:40px; white-space:normal; }
.context-menu > section { min-width:0; }
.tile-label { max-width:calc(100% - 16px); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
:where(button,a,input,select,textarea):focus-visible { outline:2px solid #a6afff; outline-offset:3px; }
@media (pointer:coarse) {
  .context-menu > button,.device-menu > button { min-height:44px; }
  .field select,.field input,.field textarea { min-height:44px; font-size:16px; }
}
@media (max-width:380px) {
  .call-controls { gap:4px; max-width:calc(100% - 12px); }
  .call-button { width:44px; height:48px; }
  .call-button.disconnect { width:48px; }
  .call-control-group { flex-shrink:0; }
  .context-menu { width:calc(100vw - 24px); }
}
@media (max-width:650px) {
  #app:has(#friends-view:not([hidden])) #mobile-friends { display:none; }
  .add-friend-form { flex-wrap:wrap; }
  .add-friend-form input { min-width:0; width:100%; }
  .add-friend-form button { min-height:44px; white-space:normal; }
}
.empty-friends > button { min-height:44px; padding:10px 20px; margin-top:10px; }
#client-update { position:fixed; z-index:60; right:16px; bottom:16px; display:flex; align-items:center; gap:12px; max-width:calc(100vw - 32px); padding:12px 14px; border:1px solid #727bf1; border-radius:12px; background:#242538; box-shadow:0 8px 24px #0005; font-size:13px; }
#client-update button { min-height:40px; padding:8px 12px; white-space:normal; }
@media (max-width:650px) { #client-update { left:12px; right:12px; bottom:max(88px,env(safe-area-inset-bottom)); max-width:none; } }
.technical-details { margin-top:18px; }
.technical-details > summary { cursor:pointer; padding:10px 0; color:var(--muted); }
