/* ---------------------------------------------------------------- base */
:root {
  --bg: #0b0d12;
  --panel: #12151d;
  --panel-2: #171b25;
  --raise: #1d2230;
  --line: #242a3a;
  --txt: #e7eaf3;
  --muted: #8b93a7;
  --dim: #7b8398;
  --accent: #6c8cff;
  --accent-2: #9d7bff;
  --ok: #3ddc97;
  --warn: #ffb547;
  --danger: #ff6b6b;
  --radius: 12px;
  --sidebar-w: 284px;
  color-scheme: dark;

  --txt-body: #d7dcea;
  --on-accent: #0b0d12;
  --line-soft: #33405e;
  --scroll: #2a3145;
  --scroll-hover: #3a4460;
  --live-line: #3a2c46;
  --voice-line: #24402f;
}

/* Tema claro. O JavaScript resolve "sistema" e sempre grava dark ou light aqui,
   entao o CSS so precisa conhecer os dois estados concretos. */
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f6fb;
  --panel: #ffffff;
  --panel-2: #eef1f8;
  --raise: #e3e8f4;
  --line: #d7dced;
  --txt: #171a23;
  --muted: #545c70;
  --dim: #636a7c;
  --accent: #4059e0;
  --accent-2: #7b4ddb;
  --ok: #0d7c55;
  --warn: #a86b00;
  --danger: #d13b3b;

  --txt-body: #262b38;
  --on-accent: #ffffff;
  --line-soft: #b9c2dc;
  --scroll: #c3cadd;
  --scroll-hover: #a7b0c9;
  --live-line: #d5c9ee;
  --voice-line: #b6e0cd;
}


/* Temas de cor, todos sobre fundo escuro. Mudam fundo, linhas e destaque; o
   texto continua claro, entao a legibilidade nao depende do tom escolhido. */
:root[data-theme="azul"] {
  color-scheme: dark;
  --bg: #070c18;
  --panel: #0d1526;
  --panel-2: #121c31;
  --raise: #17233d;
  --line: #1f2d4a;
  --txt: #e4ebfa;
  --muted: #9aabce;
  --dim: #8194b9;
  --accent: #4d8dff;
  --accent-2: #6ba6ff;
  --ok: #3ddc97;
  --warn: #ffb547;
  --danger: #ff6b6b;

  --txt-body: #d2dcf0;
  --on-accent: #06101f;
  --line-soft: #2c4370;
  --scroll: #22304f;
  --scroll-hover: #31436b;
  --live-line: #2b3a5e;
  --voice-line: #1f4038;
}

:root[data-theme="vermelho"] {
  color-scheme: dark;
  --bg: #150708;
  --panel: #1f0d0f;
  --panel-2: #291316;
  --raise: #35191d;
  --line: #442127;
  --txt: #f6e6e8;
  --muted: #cfa4aa;
  --dim: #bd9098;
  --accent: #ff5d6c;
  --accent-2: #ff8a7a;
  --ok: #45dd9d;
  --warn: #ffb547;
  --danger: #ff4d4d;

  --txt-body: #ecd8db;
  --on-accent: #1a0708;
  --line-soft: #5d2f36;
  --scroll: #402025;
  --scroll-hover: #572c33;
  --live-line: #4d2630;
  --voice-line: #244034;
}

:root[data-theme="amarelo"] {
  color-scheme: dark;
  --bg: #141005;
  --panel: #1e1809;
  --panel-2: #27200d;
  --raise: #332a12;
  --line: #423619;
  --txt: #f7efdc;
  --muted: #d0ba8d;
  --dim: #bda87e;
  --accent: #ffc043;
  --accent-2: #ffd97a;
  --ok: #4bd39a;
  --warn: #ffcd6b;
  --danger: #ff7b6b;

  --txt-body: #ede2c9;
  --on-accent: #1a1405;
  --line-soft: #5a4a22;
  --scroll: #3d331a;
  --scroll-hover: #524526;
  --live-line: #4a3c1c;
  --voice-line: #26402e;
}

:root[data-theme="cinza"] {
  color-scheme: dark;
  --bg: #0e0e0f;
  --panel: #161617;
  --panel-2: #1c1c1e;
  --raise: #242426;
  --line: #2e2e31;
  --txt: #eaeaec;
  --muted: #aaaab0;
  --dim: #91919a;
  --accent: #9aa0aa;
  --accent-2: #c3c8d2;
  --ok: #4bd39a;
  --warn: #ffb547;
  --danger: #ff6b6b;

  --txt-body: #dcdcdf;
  --on-accent: #0e0e0f;
  --line-soft: #3c3c40;
  --scroll: #303034;
  --scroll-hover: #414147;
  --live-line: #3a3a3e;
  --voice-line: #2b3a34;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--txt);
  font: 16px/1.55 "Segoe UI", system-ui, -apple-system, sans-serif;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  user-select: text;
  -webkit-user-select: text;
}

button, input, textarea, select { font: inherit; color: inherit; }
/* Textos da interface podem ser marcados e copiados. Só controles e imagens
   ficam fora para um arrasto no botão não parecer uma seleção quebrada. */
button, select, input[type="button"], input[type="submit"], input[type="range"],
svg, img, .avatar, .group-mark, .resizer {
  user-select: none;
  -webkit-user-select: none;
}
input:not([type="button"]):not([type="submit"]):not([type="range"]), textarea {
  user-select: text;
  -webkit-user-select: text;
}
.hidden { display: none !important; }

::selection {
  color: #fff;
  background: var(--accent);
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--scroll); border-radius: 6px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--scroll-hover); background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* --------------------------------------------------------------- marca */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 4px 14px rgba(108, 140, 255, 0.35);
}

.brand-mark svg { width: 20px; height: 20px; fill: none; stroke: #fff; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }

.brand-name {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.brand-lg { justify-content: center; font-size: 22px; }
.brand-lg .brand-mark { width: 42px; height: 42px; border-radius: 12px; }
.brand-lg .brand-mark svg { width: 27px; height: 27px; }

/* --------------------------------------------------------- tela entrada */
.gate {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(900px 500px at 20% -10%, rgba(108, 140, 255, 0.20), transparent 60%),
    radial-gradient(800px 500px at 90% 110%, rgba(157, 123, 255, 0.18), transparent 60%),
    var(--bg);
}

.gate-card {
  width: 100%;
  max-width: 380px;
  padding: 32px 28px 24px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}

.gate-sub {
  margin: 14px 0 24px;
  color: var(--muted);
  text-align: center;
  font-size: 14px;
}

.field { display: block; margin-bottom: 16px; }
.field > span { display: block; margin-bottom: 6px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }

.field input {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(108, 140, 255, 0.18);
}

/* Campo "sobre você": mesmo desenho do input, com altura para três linhas. */
.field textarea {
  width: 100%;
  min-height: 74px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
  color: inherit;
  font: inherit;
  line-height: 1.45;
  resize: vertical;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(108, 140, 255, 0.18);
}

/* O contador acompanha o botão Salvar na mesma linha, alinhado ao centro. */
#sobre-conta { align-self: center; white-space: nowrap; }

.btn-primary {
  width: 100%;
  padding: 12px;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s, transform 0.05s;
}

.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:active { transform: translateY(1px); }

.gate-hint { margin: 12px 0 0; min-height: 18px; text-align: center; font-size: 13px; color: var(--danger); }

/* -------------------------------------------------------------- layout */
.app { display: flex; height: 100%; }

.sidebar {
  position: relative;  /* ancora a alça de redimensionar */
  display: flex;
  flex-direction: column;
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  border-right: 1px solid var(--line);
  background: var(--panel);
}

/* Faixa fina na borda direita da lateral. Sem largura visível em repouso: só
   acende ao passar o cursor, para não virar uma linha permanente na tela. */
.resizer {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 6px;
  cursor: col-resize;
  z-index: 5;
  background: transparent;
  transition: background 0.12s;
}

.resizer:hover, .resizer.dragging { background: var(--accent); }

.sidebar > .brand { padding: 16px 18px; border-bottom: 1px solid var(--line); }

.pane { padding: 14px 10px; border-bottom: 1px solid var(--line); min-height: 0; }
.pane-grow { flex: 1; display: flex; flex-direction: column; border-bottom: 0; }

.pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px 8px;
  font-size: 12px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--dim);
}

.badge {
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--raise);
  font-size: 12px;
  color: var(--muted);
}

.room-list, .chan-list, .group-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; }
.group-list { max-height: 22vh; }
.chan-list { flex: 1; }

.room-list li, .chan-list li, .group-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 9px;
  color: var(--muted);
  cursor: default;
}

.room-list li, .chan-list li, .group-list li { cursor: pointer; }
.chan-list li:hover, .group-list li:hover { background: var(--panel-2); color: var(--txt); }
.chan-list li.active, .group-list li.active { background: var(--raise); color: var(--txt); font-weight: 600; }
.chan-list .hash { flex: 0 0 18px; color: var(--dim); font-weight: 700; font-size: 15px; }
.chan-list .count { margin-left: auto; font-size: 12px; color: var(--dim); }

/* Reserva o espaco sempre (visibility, nao display) para a linha nao pular
   quando o cursor passa por cima. */
.room-del {
  visibility: hidden;
  display: grid;
  place-items: center;
  flex: 0 0 21px;
  width: 21px;
  height: 21px;
  margin-left: 6px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--dim);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.chan-list li:hover .room-del, .group-list li:hover .room-del { visibility: visible; }
/* O mesmo × de dois cliques dos canais, agora na mensagem: aparece no hover e
   acompanha a primeira linha, na mesma altura do avatar. */
.msg:hover .room-del { visibility: visible; }
.msg .room-del { align-self: flex-start; margin-top: 3px; }
.room-del:hover { background: var(--danger); color: #fff; }

.inline-new {
  width: calc(100% - 18px);
  margin: 6px 9px 2px;
  padding: 9px 11px;
  border: 1px solid var(--accent);
  border-radius: 9px;
  background: var(--panel-2);
  outline: none;
  font-size: 14.5px;
}

.inline-new::placeholder { color: var(--dim); }


.avatar {
  display: grid;
  place-items: center;
  flex: 0 0 29px;
  width: 29px;
  height: 29px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  position: relative;
}

/* Estado atual no canto do avatar: verde, vermelho, amarelo ou cinza offline. */
.avatar[data-status]::after {
  content: "";
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 9px;
  height: 9px;
  border: 2px solid var(--panel-2);
  border-radius: 50%;
  background: var(--ok);
  box-sizing: content-box;
}
.avatar[data-status="dnd"]::after { background: var(--danger); }
.avatar[data-status="away"]::after { background: var(--warn); }
.avatar[data-status="offline"]::after { background: var(--dim); }

.me {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  background: var(--panel-2);
}

.me-nick { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }

.presence-choices {
  display: flex;
  align-items: center;
  gap: 5px;
  flex: 0 0 auto;
}

.presence-choice {
  width: 13px;
  height: 13px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 50%;
  background: var(--dim);
  background-clip: padding-box;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease;
}
.presence-choice.online { background-color: var(--ok); }
.presence-choice.dnd { background-color: var(--danger); }
.presence-choice.away { background-color: var(--warn); }
.presence-choice:hover { transform: scale(1.22); }
.presence-choice[aria-pressed="true"] {
  border-color: var(--txt);
  box-shadow: 0 0 0 2px var(--panel-2);
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
}

.icon-btn:hover { background: var(--raise); color: var(--txt); }

/* Apagado quando não há grupo aberto: criar canal não faria sentido. */
.icon-btn:disabled { opacity: 0.3; cursor: default; }
.icon-btn:disabled:hover { background: transparent; color: var(--muted); }

.icon-btn svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Mudo: o ícone riscado já diz, a cor reforça de relance. */
.voicebar[data-mic="off"] #voice-mute { color: var(--danger); }
.voicebar #voice-mute { color: var(--ok); }
.voicebar #voice-mute:hover { background: var(--raise); }
/* So ouvindo: o botao de mudo nao tem o que ligar. */
.voicebar #voice-mute:disabled { opacity: 0.55; cursor: default; background: none; }

/* O fone acompanha o microfone: verde ouvindo, vermelho quando calado. */
.voicebar #voice-surdo { color: var(--ok); }
.voicebar #voice-surdo.cortado { color: var(--danger); }
.voicebar #voice-surdo:hover { background: var(--raise); }


/* ------------------------------------------------------- foto ampliada
   Acima de tudo (menu do botão direito está em 70): abrir a foto tem que
   cobrir até o cartão de perfil que os dois cliques deixaram aberto. */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.78);
  cursor: zoom-out;
}

/* O teto acompanha o que a foto tem de verdade: 640px de origem. Passar disso
   só esticaria pixel, e é justamente o borrão que se quer evitar. */
.lightbox img {
  width: min(82vw, 82vh, 640px);
  height: auto;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.7);
}

.profile-card {
  position: fixed;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 262px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--raise);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
}

.profile-avatar {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  font-size: 18px;
}

/* No cartão a foto é clicável: um clique amplia. Sem foto não há o que
   ampliar, então o cursor não promete nada. */
.profile-avatar.com-foto { cursor: zoom-in; }

.profile-info { min-width: 0; }
.profile-nick { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-meta {
  margin-top: 4px;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--muted);
  /* Texto escrito por gente: respeita as quebras e não estoura o cartão. */
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* Bolinha com foto: a imagem preenche o círculo e a inicial sai de cena.
   Vale para pessoa e para grupo - o desenho é o mesmo. */
.avatar.com-foto, .group-mark.com-foto {
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  color: transparent;
}

.group-mark {
  display: grid;
  place-items: center;
  flex: 0 0 25px;
  width: 25px;
  height: 25px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

/* Canal de voz conectado fica verde: o estado precisa ser lido de relance. */
.chan-list li.connected { color: var(--ok); }
.chan-list li.connected .hash { color: var(--ok); }

.voice-member:hover { background: var(--panel-2); }

.voice-member {
  padding-left: 26px !important;
  font-size: 14px;
  cursor: default !important;
}

.voice-member .avatar { flex: 0 0 21px; width: 21px; height: 21px; font-size: 10px; }

/* Quem está falando: anel verde no avatar, como no Discord. A transição curta
   no apagar evita pisca-pisca entre sílabas. */
.voice-member.speaking .avatar {
  box-shadow: 0 0 0 2px var(--ok), 0 0 10px rgba(61, 220, 151, 0.55);
}

.voice-member.speaking .nick { color: var(--ok); }

/* Microfone calado: anel vermelho em volta da foto, visível para todos na
   chamada. Vem depois do anel verde de propósito - falando e mudo ao mesmo
   tempo não existe, e aqui o vermelho manda. É box-shadow e não borda para
   não empurrar o layout nem encolher a imagem dentro do círculo. */
.voice-member .avatar.mudo,
.voice-member.speaking .avatar.mudo {
  box-shadow: 0 0 0 2px var(--danger);
}
.voice-member .avatar { transition: box-shadow 0.12s ease-out; }
.voicebar.speaking .call-dot { animation: pulse 0.9s infinite; }

.chan-new { padding: 4px 0 2px; }
.chan-kind {
  display: flex;
  gap: 14px;
  padding: 7px 12px 2px;
  font-size: 13px;
  color: var(--muted);
}
.chan-kind label { display: flex; align-items: center; gap: 5px; cursor: pointer; }
.chan-kind input { accent-color: var(--accent); }

.voicebar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 14px;
  border-top: 1px solid var(--line);
  background: rgba(61, 220, 151, 0.08);
  font-size: 14px;
}

.voicebar[data-mic="off"] { background: rgba(255, 107, 107, 0.10); }
.voicebar[data-mic="off"] .call-dot { background: var(--danger); box-shadow: 0 0 8px var(--danger); }
.voice-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--txt); }

/* ------------------------------------------------ painel de áudio */
.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.6);
}

.modal-card {
  width: 100%;
  max-width: 420px;
  /* Sem o teto e a rolagem o card cresce além da tela, e o excesso some pelas
     duas pontas: centralizado, ele estoura em cima e embaixo ao mesmo tempo.
     O desconto é o padding do .modal (20px de cada lado). */
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
  padding: 22px 24px 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}

/* Navegadores sem dvh (o dvh acompanha a barra do navegador no celular). */
@supports not (height: 100dvh) {
  .modal-card { max-height: calc(100vh - 40px); }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 17px;
  font-weight: 600;
  /* Fica preso no topo enquanto o resto rola: o X precisa estar sempre à mão.
     As margens negativas desfazem o padding do card, para a faixa de fundo ir
     de borda a borda e não deixar o conteúdo aparecer por baixo. */
  position: sticky;
  top: -22px;
  z-index: 1;
  margin: -22px -24px 18px;
  padding: 22px 24px 12px;
  background: var(--panel);
}

.modal .field select,
.modal .field input[type="range"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
  outline: none;
}

.modal .field input[type="range"] { padding: 0; accent-color: var(--accent); }

/* A lista suspensa e desenhada pelo sistema, fora do alcance do estilo do
   select. Pintar as opcoes garante legibilidade onde o color-scheme nao basta. */
.modal .field select option {
  background: var(--panel);
  color: var(--txt);
}
.modal .field span b { color: var(--txt); font-weight: 600; }

/* Endereco do servidor: campo e botao lado a lado. */
.field-row { display: flex; gap: 8px; align-items: stretch; }
.field-row input { flex: 1 1 auto; min-width: 0; }
.btn-inline { width: auto; flex: 0 0 auto; padding: 11px 16px; }

.modal-hint { margin: 6px 0 18px; font-size: 12.5px; color: var(--dim); min-height: 16px; }

/* Barra de nível: confirma que o microfone escolhido está mesmo captando. */
.meter {
  position: relative;
  height: 8px;
  margin-top: 8px;
  border-radius: 6px;
  background: var(--panel-2);
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  width: 0%;
  border-radius: 6px;
  background: var(--dim);
  transition: width 0.08s linear, background 0.1s;
}

/* Verde = portão aberto, o áudio está saindo. Cinza = cortado. */
.meter-fill.passando { background: linear-gradient(90deg, var(--ok), var(--accent)); }

/* Marca onde está o limiar: sem ela o controle vira adivinhação. */
.meter-mark {
  position: absolute;
  top: -3px;
  bottom: -3px;
  width: 2px;
  border-radius: 2px;
  background: var(--txt);
  opacity: 0.75;
}

.meter-mark.hidden { display: none; }

/* -------------------------------------------------------------- centro */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 18px;
  height: 62px;
  flex: 0 0 62px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.room-title { margin: 0; font-size: 18px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.status {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--muted);
}

.status::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warn);
}

.status[data-state="on"]::before { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.status[data-state="dnd"]::before { background: var(--danger); box-shadow: 0 0 8px var(--danger); }
.status[data-state="away"]::before { background: var(--warn); box-shadow: 0 0 8px var(--warn); }
.status[data-state="off"]::before { background: var(--danger); }
.status[data-state="connecting"]::before { animation: pulse 1.1s infinite; }

@keyframes pulse { 50% { opacity: 0.25; } }

/* ------------------------------------------------- transmissao de tela */
.share-btn {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 14.5px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.share-btn svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.share-btn:hover { color: var(--txt); border-color: var(--line-soft); background: var(--raise); }

.share-btn[data-on="1"] {
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
}

.share-btn:disabled { opacity: 0.45; cursor: default; }

.live-dot {
  flex: 0 0 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 8px var(--danger);
  animation: pulse 1.4s infinite;
}

/* .live agora empilha uma .live-row por pessoa transmitindo que ainda não
   estou assistindo - várias podem aparecer juntas, uma por linha. */
.live {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 12px 18px 0;
}

.live-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--live-line);
  border-radius: 12px;
  background: linear-gradient(90deg, rgba(157, 123, 255, 0.16), rgba(108, 140, 255, 0.08));
  font-size: 13.5px;
}

.live-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.live-watch {
  padding: 6px 14px;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.live-watch:hover { filter: brightness(1.1); }

/* .stage é a grade: um .stage-tile por transmissão que estou assistindo, mais
   a minha própria quando estou transmitindo. Uma coluna com uma tela só; duas
   lado a lado a partir da segunda - a única tela nunca fica pequena à toa. */
.stage {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin: 12px 18px 0;
}

@media (min-width: 900px) {
  .stage:has(.stage-tile:nth-child(2)) { grid-template-columns: 1fr 1fr; }
}

.stage-tile {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #05070b;  /* letterbox escuro nos dois temas, de proposito */
  overflow: hidden;
}

.stage-tile video {
  width: 100%;
  max-height: 46vh;
  min-height: 160px;
  background: #05070b;
  object-fit: contain;
  display: block;
}

.stage-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-top: 1px solid var(--line);
  background: var(--panel);
  font-size: 13px;
}

.stage-who { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }

.stage-btn {
  padding: 7px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 13.5px;
  cursor: pointer;
}

.stage-btn:hover { color: var(--txt); background: var(--raise); }
.stage-btn.danger:hover { color: var(--danger); border-color: var(--danger); }

/* Dois botoes seguidos: so o primeiro empurra; o segundo cola ao lado. */
.share-btn + .share-btn { margin-left: 8px; }

.call-dot {
  flex: 0 0 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 8px var(--ok);
}

.callbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 18px 0;
  padding: 9px 14px;
  border: 1px solid var(--voice-line);
  border-radius: 12px;
  background: linear-gradient(90deg, rgba(61, 220, 151, 0.14), rgba(61, 220, 151, 0.04));
  font-size: 13.5px;
}

.call-who { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.share-btn[data-mic="off"] {
  border-color: transparent;
  background: var(--danger);
  color: #fff;
}

/* Um contêiner só para as etiquetas: com margin-left:auto em cada uma, duas
   etiquetas dividiriam o espaço livre e ficariam separadas no meio da linha. */
.tags {
  flex: 0 0 auto;
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 7px;
}

.tag {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  white-space: nowrap;
}

.tag.voz { color: var(--ok); }
.tag.tela { color: var(--accent); }
/* Silenciado só para mim: apagado de propósito, é um estado meu, não da pessoa. */
.tag.mudo { color: var(--dim); }

/* O código é para ser lido em voz alta e digitado por outra pessoa: fonte de
   largura fixa e letras espaçadas evitam confundir 0 com O, 1 com l. */
#meu-codigo {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 16px;
  letter-spacing: 0.14em;
  text-align: center;
  cursor: text;
}

/* ------------------------------------------------------------- amigos */
.amigo-list { list-style: none; margin: 0; padding: 0; }

.amigo {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 14px;
  cursor: default;
}

.amigo:hover { background: var(--panel-2); }
.amigo .nick { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.amigo .avatar { flex: 0 0 23px; width: 23px; height: 23px; font-size: 11px; }

/* Offline fica apagado, mas continua na lista: é a diferença entre "não está
   agora" e "não é seu amigo". */
.amigo.offline { opacity: 0.45; }

/* Conversa privada aberta: a linha do amigo funciona como um canal ativo. */
.amigo.active { background: var(--raise); }
.amigo.active .nick { color: var(--txt); font-weight: 600; }

/* Ponto de mensagem privada não lida. Fica antes dos botões, colado no nome. */
.dm-novo {
  flex: 0 0 7px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}

/* Não lida vence o apagado do offline: a mensagem chegou de qualquer jeito. */
.amigo.offline:has(.dm-novo) { opacity: 1; }

.amigo-btn {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}

.amigo-btn svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
.amigo-btn:hover { background: var(--raise); color: var(--txt); }
.amigo-btn.ok:hover { color: var(--ok); }
.amigo-btn.nao:hover { color: var(--danger); }
.amigo-btn.ligar:hover { color: var(--ok); }
.amigo-btn:disabled { opacity: 0.3; cursor: default; background: none; }

.pane-vazio { margin: 2px 12px 8px; font-size: 12.5px; color: var(--dim); }

/* ------------------------------------------ configurações de um grupo */
.gcfg-list { list-style: none; margin: 4px 0 0; padding: 0; }

.gcfg-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 2px;
  font-size: 14px;
}

.gcfg-item + .gcfg-item { border-top: 1px solid var(--line); }
.gcfg-item .nick { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gcfg-item .avatar { flex: 0 0 26px; width: 26px; height: 26px; font-size: 12px; }

/* Botão de linha: discreto, e vermelho só quando tira alguém. */
.btn-mini {
  flex: 0 0 auto;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--txt);
  font-size: 12.5px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.btn-mini:hover { background: var(--raise); }
.btn-mini.perigo { color: var(--danger); border-color: rgba(255, 107, 107, 0.35); }
.btn-mini.perigo:hover { background: var(--danger); border-color: var(--danger); color: #fff; }

/* Coluna de canais sem nenhum grupo: a dica ocupa o lugar da lista. Não é
   item clicável, então não herda o hover nem o cursor de canal. */
.chan-vazio {
  padding: 8px 12px;
  color: var(--dim);
  font-size: 12.5px;
  line-height: 1.4;
  white-space: normal;
  cursor: default;
}
.chan-list li.chan-vazio:hover { background: none; color: var(--dim); }

/* Compositor travado: sem canal aberto não há para quem falar. */
.composer textarea:disabled { opacity: 0.5; cursor: default; }

/* --------------------------------------------------- toque da ligação */
.toque-card {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 30px 34px 26px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  text-align: center;
}

.toque-avatar {
  flex: none;
  width: 76px;
  height: 76px;
  font-size: 30px;
  /* Pulsa enquanto toca: é o que faz a tela parecer uma chamada, e não um aviso. */
  animation: pulse 1.5s ease-in-out infinite;
}

.toque-nome { font-size: 19px; font-weight: 600; }
.toque-texto { font-size: 13.5px; color: var(--muted); }
.toque-botoes { display: flex; gap: 10px; margin-top: 8px; }

.toque-btn {
  padding: 11px 26px;
  border: 0;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
}

.toque-btn.atender { background: var(--ok); }
.toque-btn.recusar { background: var(--danger); }
.toque-btn:hover { filter: brightness(1.08); }

@media (prefers-reduced-motion: reduce) {
  .toque-avatar { animation: none; }
}

/* ------------------------------------------------- menu do botão direito
   Acima do modal (60): o menu pode ser aberto com as Configurações abertas. */
.menu-ctx {
  position: fixed;
  z-index: 70;
  /* Com muita gente online a lista de convidados cresce; rola em vez de
     estourar a tela. */
  max-height: 70vh;
  overflow-y: auto;
  min-width: 210px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  font-size: 13.5px;
}

.menu-titulo {
  padding: 6px 10px 8px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 7px;
  background: none;
  color: var(--txt);
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
}

.menu-item:hover { background: var(--raise); }

.menu-volume {
  padding: 7px 10px 10px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
}

.menu-volume-cabeca {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 7px;
  color: var(--txt);
  font-size: 13px;
}

.menu-volume-cabeca output {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.menu-volume input[type="range"] {
  display: block;
  width: 100%;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

/* Ação destrutiva: vermelha desde o começo, para não parecer inofensiva. */
.menu-item.perigo { color: var(--danger); }
.menu-item.perigo:hover { background: rgba(255, 107, 107, 0.12); }

.menu-item svg {
  flex: 0 0 15px;
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.menu-nota {
  padding: 4px 10px 6px;
  color: var(--dim);
  font-size: 12px;
  line-height: 1.35;
  white-space: normal;
}

.tag svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Embaixo do canal de voz só cabe o ícone; o nome do canal já dá o contexto. */
.voice-member .tag.tela { margin-left: auto; }

/* ----------------------------------------------------------- mensagens */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 18px 8px;
}

.msg { display: flex; gap: 11px; padding: 3px 0; }
.msg + .msg.grouped { padding-top: 1px; }
.msg .avatar { margin-top: 3px; }
.msg.grouped .avatar { visibility: hidden; height: 0; margin: 0; }
.msg-body { min-width: 0; flex: 1; }

.msg-head { display: flex; align-items: baseline; gap: 8px; }
.msg-head .who { font-weight: 600; font-size: 15px; }
.msg-head .when { font-size: 12px; color: var(--dim); }

.msg-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--txt-body);
}

.msg-text a { color: var(--accent); }
.msg.mine .msg-head .who { color: var(--accent); }

.msg.emote .msg-text { font-style: italic; color: var(--muted); }

.sys {
  margin: 8px 0;
  text-align: center;
  font-size: 12.5px;
  color: var(--dim);
}

.sys span {
  padding: 3px 12px;
  border-radius: 20px;
  background: var(--panel-2);
}

.daysep {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0 10px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dim);
}

.daysep::before, .daysep::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.jump {
  position: absolute;
  left: 50%;
  bottom: 86px;
  transform: translateX(-50%);
  padding: 7px 15px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--raise);
  color: var(--txt);
  font-size: 13px;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.45);
}

.typing { height: 20px; padding: 0 20px; font-size: 12px; color: var(--dim); font-style: italic; }

/* ---------------------------------------------------------- compositor */
.composer {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin: 0 18px 18px;
  padding: 8px 8px 8px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  transition: border-color 0.15s;
}

.composer:focus-within { border-color: var(--line-soft); }

.composer textarea {
  flex: 1;
  max-height: 160px;
  padding: 8px 0;
  border: 0;
  background: transparent;
  outline: none;
  resize: none;
  overflow-y: auto;
  line-height: 1.45;
}

.composer textarea::placeholder { color: var(--dim); }

.send {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  cursor: pointer;
  transition: filter 0.15s, opacity 0.15s;
}

.send svg { width: 18px; height: 18px; fill: #fff; }
.send:hover { filter: brightness(1.1); }
.send:disabled { opacity: 0.4; cursor: default; filter: none; }

/* O microfone fica discreto ao lado do enviar; gravando, vira vermelho e
   pulsa, que é o único aviso de que o som está sendo captado. */
.send.mic { background: var(--line); }
.send.mic svg { fill: var(--muted); }
.send.mic:hover svg { fill: var(--txt); }
.send.mic.gravando { background: var(--danger); animation: pulsa 1.2s ease-in-out infinite; }
.send.mic.gravando svg { fill: #fff; }

@keyframes pulsa {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

@media (prefers-reduced-motion: reduce) {
  .send.mic.gravando { animation: none; }
}

/* O emote fica discreto como o microfone: quem manda mensagem procura o
   enviar, não o rostinho. */

/* O clipe fica discreto como o microfone e o emote: quem manda mensagem
   procura o enviar, não o anexo. */

/* ---------------------------------------------- arrastar para enviar
   Cobre a janela inteira enquanto um arquivo está sendo arrastado. O
   `pointer-events: none` é essencial: sem ele o próprio aviso viraria o alvo
   do arrasto e o `drop` nunca chegaria ao documento. */

/* ------------------------------------------ pergunta antes de apagar
   Acima de tudo (o menu do botão direito está em 70, a foto ampliada em 90):
   ela pode ser aberta a partir de qualquer um deles. */
#confirmar { z-index: 100; }

.conf-card { max-width: 360px; text-align: center; }

.conf-titulo {
  margin-bottom: 20px;
  font-size: 16.5px;
  font-weight: 600;
  overflow-wrap: anywhere;
}


.conf-botoes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.conf-btn {
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
  color: var(--txt);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, filter 0.15s;
}

.conf-btn:hover { background: var(--raise); }
.conf-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* O "sim" é o botão que faz algo irreversível: vermelho, e não o azul de
   sempre, para não ser clicado no automático. */
.conf-btn.sim { border-color: var(--danger); background: var(--danger); color: #fff; }
.conf-btn.sim:hover { background: var(--danger); filter: brightness(1.08); }

.solte {
  position: fixed;
  inset: 0;
  z-index: 95;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgba(11, 13, 18, 0.72);
  pointer-events: none;
}

.solte-caixa {
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 34px 48px;
  border: 2px dashed var(--accent);
  border-radius: 18px;
  background: var(--panel);
  color: var(--txt);
  font-size: 16px;
  font-weight: 600;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}

.solte-caixa svg {
  width: 38px;
  height: 38px;
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.send.anexo { background: var(--line); color: var(--muted); }
.send.anexo svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.send.anexo:hover { color: var(--txt); }

/* ------------------------------------------------ anexo na conversa */
/* Imagem: entra na conversa com um teto, para uma foto grande não empurrar
   o resto da tela. Um clique abre no tamanho cheio. */
.anexo-img { margin: 4px 0 2px; }

.anexo-img img {
  display: block;
  max-width: min(100%, 320px);
  max-height: 260px;
  width: auto;
  border-radius: 10px;
  border: 1px solid var(--line);
  cursor: zoom-in;
}

.anexo-img figcaption { margin-top: 4px; font-size: 12px; }
.anexo-img figcaption a { color: var(--dim); text-decoration: none; }
.anexo-img figcaption a:hover { color: var(--txt); text-decoration: underline; }

/* Arquivo que não é imagem: um cartão clicável, o mais parecido possível com
   o que qualquer outro app mostra. */
.anexo-arq {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  max-width: 320px;
  margin: 4px 0 2px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
  color: var(--txt);
  text-decoration: none;
}

.anexo-arq:hover { background: var(--raise); }

.anexo-arq svg {
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.8;
  stroke-linejoin: round;
}

.anexo-info { display: grid; min-width: 0; }
.anexo-nome { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; }
.anexo-tam { color: var(--dim); font-size: 11.5px; }

.send.emote { background: var(--line); color: var(--muted); }
.send.emote svg { fill: none; stroke: currentColor; stroke-width: 1.8; }
.send.emote:hover, .send.emote.aberto { color: var(--txt); }
.send.emote.aberto { background: var(--raise); }

/* Painel de emojis: flutua acima do compositor, posicionado pelo JS. */
.emote-painel {
  position: fixed;
  z-index: 70;
  display: grid;
  grid-template-columns: repeat(8, 34px);
  gap: 2px;
  max-height: 240px;
  overflow-y: auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}

.emote-item {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 7px;
  background: none;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.emote-item:hover { background: var(--raise); }

/* Em tela estreita o painel não cabe em 8 colunas. */
@media (max-width: 460px) {
  .emote-painel { grid-template-columns: repeat(6, 34px); }
}

/* Tocador do recado: ocupa a largura da mensagem, sem estourar em tela estreita. */
.recado { width: 100%; max-width: 340px; height: 36px; margin: 2px 0; vertical-align: middle; }

/* -------------------------------------------------------------- mobile */
.only-mobile { display: none; }
.scrim { display: none; }

@media (max-width: 760px) {
  .only-mobile { display: grid; }

  .sidebar {
    position: fixed;
    z-index: 20;
    top: 0;
    bottom: 0;
    left: 0;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.6);
  }

  .app.drawer .sidebar { transform: none; }

  .resizer { display: none; }  /* no celular a lateral é gaveta, não coluna */

  .app.drawer .scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 10;
    background: rgba(0, 0, 0, 0.55);
  }

  .messages { padding: 14px 12px 6px; }
  .composer { margin: 0 12px 12px; }

  .share-btn span { display: none; }  /* so o icone cabe ao lado do titulo */
  .share-btn { padding: 6px 9px; }
  .live, .stage { margin-left: 12px; margin-right: 12px; }
  .stage video { max-height: 38vh; }
}
