/* =====================================================================
   LLOGGIA — tema "carbon & lime"
   Fundo quase preto, painéis flutuantes arredondados, verde-limão como
   cor de ação e lilás como cor de apoio.
   ===================================================================== */

:root {
  /* superfícies */
  --bg:        #0b0b0f;   /* pano de fundo da página */
  --panel:     #15151b;   /* colunas e cartões */
  --panel-2:   #1d1d25;   /* inputs, hovers */
  --panel-3:   #26262f;   /* ativo */
  --line:      #26262e;

  /* identidade */
  --lime:      #d9fb50;   /* ação primária */
  --lime-soft: rgba(217, 251, 80, .12);
  --on-lime:   #141508;   /* texto sobre limão */
  --violet:    #a595f9;   /* apoio */
  --violet-2:  #8d7bf1;
  --violet-soft: rgba(165, 149, 249, .16);

  /* texto */
  --text:      #e8e8ee;
  --text-dim:  #8b8b9a;
  --text-hi:   #ffffff;

  /* estados */
  --green:     #d9fb50;
  --red:       #ff5e6b;
  --radius:    18px;
  --radius-sm: 12px;
}

/* Fonte própria, servida daqui mesmo (a CSP bloqueia CDNs de propósito). */
@font-face {
  font-family: "Manrope";
  src: url("../fonts/manrope.woff2") format("woff2");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; overflow: hidden; }

body {
  font-family: "Manrope", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
svg { width: 20px; height: 20px; fill: currentColor; display: block; }
.hidden { display: none !important; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #26262f; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #32323d; }
::-webkit-scrollbar-track { background: transparent; }

/* ================= app instalado (moldura própria) ================= */
/*
 * Quando o PWA/desktop roda com window-controls-overlay, o navegador tira
 * a barra de título dele e deixa o app desenhar ali — só os botões nativos
 * (minimizar/fechar) ficam sobrepostos no canto. A classe .wco entra via
 * JS quando esse modo está ativo.
 */
.wco-drag { display: none; }

html.wco .wco-drag {
  display: flex;
  align-items: center;
  position: fixed;
  left: env(titlebar-area-x, 0);
  top: env(titlebar-area-y, 0);
  width: env(titlebar-area-width, 100%);
  height: env(titlebar-area-height, 36px);
  -webkit-app-region: drag; /* segurar e arrastar move a janela */
  app-region: drag;
  z-index: 900;
  padding: 0 14px;
  background: var(--bg);
}
.wco-drag span {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: -.02em;
  color: var(--text-dim);
  user-select: none;
}
.wco-drag span i { font-style: normal; color: var(--violet); }

/* o conteúdo desce para não ficar embaixo da faixa de arrastar */
html.wco .app { padding-top: calc(env(titlebar-area-height, 36px) + 6px); }
html.wco .login { padding-top: env(titlebar-area-height, 36px); }

/* ============================ login =========================== */
.login {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background:
    radial-gradient(600px 400px at 85% 15%, rgba(141, 123, 241, .28), transparent 70%),
    radial-gradient(500px 380px at 10% 85%, rgba(217, 251, 80, .10), transparent 70%),
    var(--bg);
  z-index: 100;
}

.login-card {
  width: min(420px, calc(100vw - 32px));
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 36px 32px;
  border-radius: 24px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, .55);
  text-align: center;
}

/* --------------------- abertura (sem piscar) --------------------- */
/*
 * O app só sabe se existe sessão depois de duas idas ao servidor
 * (/auth/eu e o login do socket). Até lá mostramos a marca; sem isso,
 * quem já está logado via o formulário de e-mail e senha aparecer e
 * sumir a cada F5.
 */
.login-splash {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.login.booting .login-splash { display: flex; }
/*
 * "visibility" e não "opacity": opacidade é animada na GPU e, numa aba que
 * o navegador não está compondo (segundo plano, janela minimizada), a
 * transição pode não avançar — e o formulário ficaria invisível para
 * sempre. Visibilidade é decidida no layout, então nunca trava.
 */
.login.booting .login-card { visibility: hidden; }

.splash-bar {
  width: 148px;
  height: 3px;
  margin-top: 12px;
  border-radius: 2px;
  background: var(--panel-2);
  overflow: hidden;
}
.splash-bar span {
  display: block;
  width: 40%;
  height: 100%;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--violet), var(--lime));
  animation: splash-slide 1.1s ease-in-out infinite;
}
@keyframes splash-slide {
  0%   { transform: translateX(-110%); }
  100% { transform: translateX(360%); }
}

/*
 * Válvula de escape: se o JavaScript não carregar (rede ruim, bloqueador),
 * ninguém pode ficar preso numa tela de marca eterna — o formulário volta
 * sozinho depois de 8 s, mesmo sem nenhum script rodar.
 */
.login.booting #login-form { animation: splash-liberar 0s linear 8s forwards; }
@keyframes splash-liberar { to { visibility: visible; } }
.login.booting .login-splash { animation: splash-esconder 0s linear 8s forwards; }
@keyframes splash-esconder { to { visibility: hidden; } }

.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  margin-bottom: 14px;
}
.brand-mark { width: 60px; height: 60px; filter: drop-shadow(0 6px 18px rgba(122, 92, 255, .35)); }
.brand-word {
  font-size: 29px;
  font-weight: 800;
  letter-spacing: -.03em;
  color: var(--text-hi);
  line-height: 1;
}
.brand-word i { font-style: normal; color: var(--violet); }
.brand-tag {
  /* Um respiro a mais além do gap da coluna: o nome tem line-height 1 e
     sem isso a tagline parece grudada na base do "lloggia." */
  margin-top: 7px;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .3em;
  text-transform: uppercase;
  color: var(--text-dim);
  white-space: nowrap;
  /*
   * O letter-spacing deixa um espaço fantasma DEPOIS do último caractere,
   * dentro da caixa do texto — centralizada, ela parece deslocada para a
   * esquerda. A margem negativa devolve exatamente esse espaço.
   * (Antes era margin-left positivo, que empurrava para o outro lado.)
   */
  margin-right: -.3em;
}
.brand-tag b { color: var(--violet); font-weight: 700; margin: 0 .1em; }
.login-card h1 {
  font-size: 23px;
  color: var(--text-hi);
  letter-spacing: -.01em;
  line-height: 1.2;
}
.login-sub { color: var(--text-dim); margin: 7px 0 26px; font-size: 14.5px; line-height: 1.5; }
.login-sub.small { font-size: 12px; margin-top: -14px; }

.login-card label {
  display: block;
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 8px;
  letter-spacing: .04em;
}

.login-card input {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  outline: none;
  margin-bottom: 18px;
  transition: border-color .15s;
}
.login-card input:focus { border-color: var(--violet); }
.login-card input[type="date"] { color-scheme: dark; }

/* lembrar e-mail e senha — .login-card label estiliza os rótulos dos
   campos (maiúsculas, bloco); esta linha é outra coisa, então desfaz. */
.login-card label.remember-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: -4px 0 16px;
  font-size: 13px;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
  text-align: left;
}
.login-card label.remember-row:hover { color: var(--text); }
.remember-row input {
  width: 15px;
  height: 15px;
  margin: 0;
  flex: none;
  accent-color: var(--lime);
  cursor: pointer;
}

.btn-primary {
  width: 100%;
  padding: 13px;
  background: var(--lime);
  color: var(--on-lime);
  border-radius: 999px;
  font-weight: 700;
  transition: filter .15s, transform .1s;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:active { transform: scale(.99); }

/* campo de senha com olho */
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 46px; }
.pw-eye {
  position: absolute;
  right: 6px;
  top: 5px;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  color: var(--text-dim);
  border-radius: 8px;
}
.pw-eye:hover { color: var(--text-hi); }
.pw-eye svg { width: 19px; height: 19px; }

/* aviso de senhas iguais/diferentes, atualiza enquanto digita */
.pw-match { text-align: left; font-size: 12px; margin: -12px 0 14px; }
.pw-match.ok { color: var(--lime); }
.pw-match.err { color: var(--red); }

.login-hint { margin-top: 14px; font-size: 13px; color: var(--text-dim); min-height: 16px; }
.login-hint.err { color: var(--red); }
.login-hint.ok { color: var(--lime); }

.login-alt { margin-top: 16px; font-size: 13px; color: var(--text-dim); }
.linkish { background: none; border: 0; color: var(--violet); cursor: pointer; font-size: 13px; padding: 0; }
.linkish:hover { text-decoration: underline; }

/* login social (Google / Facebook) */
.social-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0 14px;
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.social-divider::before,
.social-divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }

.social-buttons { display: flex; gap: 10px; }
.btn-social {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 11px 12px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  font-weight: 700;
  font-size: 14px;
  transition: background .12s, transform .1s;
}
.btn-social:hover { background: var(--panel-3); }
.btn-social:active { transform: scale(.98); }
.btn-social svg { width: 18px; height: 18px; }

.login-card input:disabled,
.login-card button:disabled { opacity: .6; cursor: wait; }

/* ============================= app ============================ */
.app {
  display: grid;
  grid-template-columns: 76px 248px 1fr auto;
  gap: 10px;
  height: 100vh;
  padding: 10px;
  background: var(--bg);
}

/* ---------------------------- rail ---------------------------- */
.rail {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  overflow-y: auto;
  scrollbar-width: none;
}
.rail::-webkit-scrollbar { display: none; }

.rail-item {
  width: 46px;
  height: 46px;
  border-radius: 16px;
  background: var(--panel-2);
  display: grid;
  place-items: center;
  font-size: 19px;
  font-weight: 600;
  cursor: pointer;
  flex: none;
  transition: background .15s, border-radius .15s, color .15s;
  position: relative;
  user-select: none;
}
.rail-item:hover { background: var(--violet-soft); }
.rail-item.active { background: var(--violet); color: #17131f; border-radius: 14px; }
.rail-item.active::before {
  content: "";
  position: absolute;
  left: -15px;
  width: 4px;
  height: 26px;
  background: var(--lime);
  border-radius: 0 4px 4px 0;
}

.rail-home { background: var(--panel-2); }
.rail-home.active, .rail-home:hover { background: var(--panel-3); }
.rail-mark { width: 30px; height: 30px; }
.rail-add { color: var(--lime); font-size: 26px; font-weight: 300; line-height: 1; }
.rail-add:hover { background: var(--lime); color: var(--on-lime); }
.rail-add::before { display: none !important; }
.rail-sep { width: 30px; height: 1px; background: var(--line); flex: none; }

/* -------------------------- sidebar --------------------------- */
.sidebar {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.sidebar-header {
  height: 54px;
  padding: 0 18px;
  display: flex;
  align-items: center;
  font-weight: 700;
  color: var(--text-hi);
  font-size: 15px;
  border-bottom: 1px solid var(--line);
  flex: none;
  letter-spacing: -.01em;
}

.channels { flex: 1; overflow-y: auto; padding: 14px 10px; min-height: 0; }

.cat {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 8px 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-dim);
}
.cat:first-child { padding-top: 0; }
.cat button { color: var(--text-dim); font-size: 17px; line-height: 1; padding: 0 4px; border-radius: 6px; }
.cat button:hover { color: var(--lime); }

.channel {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 999px;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 14px;
  margin-bottom: 3px;
  user-select: none;
  transition: background .12s, color .12s;
}
.channel:hover { background: var(--panel-2); color: var(--text); }
.channel.active { background: var(--lime); color: var(--on-lime); font-weight: 600; }
.channel.active .hash { opacity: 1; }
.channel .hash { font-size: 16px; opacity: .6; flex: none; width: 18px; text-align: center; }
.channel .cname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.channel .ch-muted { margin-left: auto; font-size: 11px; opacity: .7; flex: none; }
.channel .ch-muted + .live { margin-left: 6px; }
.channel .live {
  margin-left: auto;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--violet);
  color: #17131f;
}
.channel.active .live { background: var(--on-lime); color: var(--lime); }

.voice-members { margin: 2px 0 8px 20px; }
.voice-member {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 13px;
  color: var(--text-dim);
}
.voice-member:hover { background: var(--panel-2); }
.voice-member .avatar { width: 22px; height: 22px; font-size: 9px; }

/*
 * Quem está falando pulsa, como no Discord: o anel verde fica fixo e uma
 * onda suave se expande e some, num loop. É box-shadow + scale — nada de
 * layout, então o navegador anima isso na composição, de graça.
 */
@keyframes falando-pulso {
  0% {
    box-shadow: 0 0 0 2px var(--lime), 0 0 0 2px rgba(217, 251, 80, .55);
    transform: scale(1);
  }
  35% { transform: scale(1.08); }
  70% {
    box-shadow: 0 0 0 2px var(--lime), 0 0 0 8px rgba(217, 251, 80, 0);
    transform: scale(1);
  }
  100% {
    box-shadow: 0 0 0 2px var(--lime), 0 0 0 2px rgba(217, 251, 80, 0);
    transform: scale(1);
  }
}

.voice-member.speaking .avatar {
  box-shadow: 0 0 0 2px var(--lime);
  animation: falando-pulso 1.15s ease-out infinite;
}

/* Quem prefere menos movimento fica só com o anel, sem pulso. */
@media (prefers-reduced-motion: reduce) {
  .voice-member.speaking .avatar,
  .tile.speaking .tile-avatar {
    animation: none !important;
  }
}
.voice-member .tag { margin-left: auto; display: flex; gap: 4px; align-items: center; }
.voice-member .tag svg { width: 14px; height: 14px; }
.voice-member .tag .muted { color: var(--red); font-size: 11px; }
.voice-member .tag .sharing {
  color: #17131f;
  background: var(--violet);
  font-size: 9px;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 999px;
}

/* painel de voz conectada */
.voice-panel {
  background: var(--violet-soft);
  border-top: 1px solid var(--line);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}
.voice-panel-info { flex: 1; min-width: 0; }
.voice-status { display: block; font-size: 13px; font-weight: 700; color: var(--lime); }
.voice-channel-name {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.voice-panel-actions { display: flex; gap: 2px; }
.vbtn { padding: 7px; border-radius: 10px; color: var(--text-dim); }
.vbtn:hover { background: var(--panel-2); color: var(--text-hi); }
.vbtn.on { color: var(--lime); }
.vbtn.danger:hover { background: var(--red); color: #fff; }

/* painel do usuário */
.user-panel {
  background: var(--bg);
  margin: 8px;
  border-radius: var(--radius-sm);
  padding: 5px 6px;
  display: flex;
  align-items: center;
  gap: 2px;
  flex: none;
}

/* chip do usuário: avatar + nome, com hover, abre o menu da conta */
.user-panel-id {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  border-radius: 10px;
  text-align: left;
  transition: background .12s;
}
.user-panel-id:hover { background: var(--panel-2); }

.user-panel-name { flex: 1; min-width: 0; line-height: 1.2; }
.user-panel-name span {
  display: block;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-hi);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-panel-name small {
  display: block;
  font-size: 10.5px;
  color: var(--lime);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ubtn { padding: 6px; border-radius: 10px; color: var(--text-dim); flex: none; }
.ubtn svg { width: 18px; height: 18px; }
.ubtn:hover { background: var(--panel-2); color: var(--text-hi); }
.ubtn.off { color: var(--red); }

.avatar {
  position: relative;
  overflow: hidden; /* a foto respeita o arredondado */
  width: 32px;
  height: 32px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
  color: #17131f;
  flex: none;
  user-select: none;
}

/* foto de perfil por cima das iniciais (que ficam de reserva se falhar) */
.avatar-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}

/* ---------------------------- main ---------------------------- */
.main {
  position: relative; /* âncora do .empty-state */
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

/* -------- boas-vindas: conta sem nenhum servidor ainda --------- */
.empty-state {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(480px 320px at 80% 10%, rgba(141, 123, 241, .14), transparent 70%),
    radial-gradient(420px 300px at 10% 90%, rgba(217, 251, 80, .07), transparent 70%),
    var(--panel);
}
.empty-card {
  max-width: 380px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.empty-mark { width: 76px; height: 76px; filter: drop-shadow(0 8px 24px rgba(122, 92, 255, .35)); }
.empty-card h2 { font-size: 24px; font-weight: 800; letter-spacing: -.02em; color: var(--text-hi); }
.empty-card p { color: var(--text-dim); font-size: 15px; line-height: 1.5; }
.empty-card .btn-primary { width: auto; padding: 13px 28px; margin-top: 8px; }
.empty-hint { font-size: 12px; color: var(--text-dim); opacity: .8; }

.topbar {
  height: 54px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  flex: none;
  z-index: 2;
}
.topbar-icon { color: var(--violet); font-size: 20px; font-weight: 700; }
.topbar-name { font-weight: 700; color: var(--text-hi); letter-spacing: -.01em; }
.topbar-divider { width: 1px; height: 22px; background: var(--line); }
.topbar-topic {
  font-size: 13px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar-spacer { flex: 1; }

/* --------------------------- texto ---------------------------- */
.view-text { flex: 1; display: flex; flex-direction: column; min-height: 0; }

.messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-anchor: none;
  padding: 18px 18px 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.channel-intro { padding: 12px 0 24px; }
.channel-intro .big {
  width: 64px;
  height: 64px;
  border-radius: 22px;
  background: var(--violet-soft);
  display: grid;
  place-items: center;
  font-size: 30px;
  color: var(--violet);
  margin-bottom: 12px;
}
.channel-intro h2 { color: var(--text-hi); font-size: 26px; letter-spacing: -.02em; }
.channel-intro p { color: var(--text-dim); margin-top: 6px; }

.msg { display: flex; gap: 12px; padding: 4px 10px; border-radius: var(--radius-sm); }
.msg:hover { background: rgba(255, 255, 255, .025); }
.msg.grouped { padding-top: 1px; }
.msg.grouped .avatar { visibility: hidden; height: 0; }
.msg-body { min-width: 0; flex: 1; }
.msg-head { display: flex; align-items: baseline; gap: 8px; }
.msg-author { font-weight: 700; color: var(--text-hi); font-size: 14px; }
.msg-time { font-size: 11px; color: var(--text-dim); }
.msg-text { color: var(--text); line-height: 1.45; word-wrap: break-word; white-space: pre-wrap; }
.msg-text code {
  background: var(--bg);
  border: 1px solid var(--line);
  padding: 1px 6px;
  border-radius: 6px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  color: var(--lime);
}
.msg-text a { color: var(--violet); text-decoration: none; }
.msg-text a:hover { text-decoration: underline; }
.msg-text .mention {
  background: var(--violet-soft);
  color: var(--violet);
  border-radius: 6px;
  padding: 0 4px;
  font-weight: 600;
}

.date-sep {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 8px 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.date-sep::before, .date-sep::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.load-more {
  align-self: center;
  margin: 8px 0 16px;
  padding: 8px 18px;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--text-dim);
  font-size: 13px;
  transition: background .15s, color .15s;
}
.load-more:hover { background: var(--violet-soft); color: var(--violet); }

.typing { height: 24px; padding: 0 24px; font-size: 13px; color: var(--violet); }

.composer { padding: 0 14px 14px; flex: none; }
.composer form {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 6px 4px 16px;
  transition: border-color .15s;
}
.composer form:focus-within { border-color: var(--violet); }
.composer input { flex: 1; background: none; border: 0; outline: none; padding: 10px 6px; }
.composer input::placeholder { color: var(--text-dim); }
.composer-plus { color: var(--text-dim); font-size: 22px; line-height: 1; padding: 0 6px; }
.composer-plus:hover { color: var(--lime); }
/* enquanto comprime e envia: gira e não aceita outro clique */
.composer-plus.busy {
  color: var(--lime);
  pointer-events: none;
  animation: plus-spin .8s linear infinite;
}
@keyframes plus-spin { to { transform: rotate(360deg); } }

/* imagem dentro da mensagem */
.msg-image {
  display: block;
  max-width: min(400px, 100%);
  max-height: 320px;
  width: auto;
  height: auto;
  margin-top: 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  cursor: zoom-in;
  background: var(--panel-2);
}
.msg-image:hover { border-color: var(--violet); }

/* imagem em tamanho grande */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-items: center;
  padding: 32px;
  background: rgba(0, 0, 0, .82);
  cursor: zoom-out;
  animation: modal-fade .18s ease;
}
.lightbox img {
  max-width: 100%;
  max-height: 100%;
  border-radius: var(--radius-sm);
  box-shadow: 0 24px 64px rgba(0, 0, 0, .6);
}
.composer-send {
  background: var(--lime);
  color: var(--on-lime);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: none;
  transition: filter .15s;
}
.composer-send:hover { filter: brightness(1.08); }
.composer-send svg { width: 17px; height: 17px; }

/* -------------------------- voz/tela -------------------------- */
.view-voice { flex: 1; display: flex; flex-direction: column; min-height: 0; background: var(--bg); }

.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  overflow: hidden;
  min-height: 0;
}

/* grade padrão: todo mundo do mesmo tamanho */
.stage-focus {
  flex: 1;
  min-height: 0;
  display: grid;
  gap: 12px;
  overflow: auto;
  place-content: center;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  align-content: center;
}
.stage.has-video .stage-focus { place-content: stretch; }
.stage-focus .tile { cursor: pointer; }

/* destaque: um quadro grande + tira com os demais */
.stage.spotlight .stage-focus { display: flex; overflow: hidden; }
.stage.spotlight .stage-focus .tile {
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  min-height: 0;
  cursor: default;
}

.stage-strip {
  display: none;
  flex: none;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 2px;
}
.stage.spotlight .stage-strip { display: flex; }
.stage-strip .tile {
  flex: none;
  width: 168px;
  min-height: 0;
  aspect-ratio: 16 / 9;
  cursor: pointer;
}
.stage-strip .tile .tile-avatar { width: 40px; height: 40px; font-size: 14px; border-radius: 14px; }
.stage-strip .tile .tile-label {
  left: 6px;
  bottom: 6px;
  padding: 2px 8px;
  font-size: 10px;
  max-width: calc(100% - 12px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* controles do quadro em destaque */
.tile-controls {
  position: absolute;
  right: 10px;
  top: 10px;
  display: flex;
  gap: 6px;
  opacity: 0;
  transition: opacity .15s;
  z-index: 3;
}
.tile:hover .tile-controls,
.tile:focus-within .tile-controls { opacity: 1; }
/* Sem mouse não existe hover: no toque os controles ficam sempre à vista. */
@media (hover: none) {
  .tile-controls { opacity: 1; }
}
.tile-controls button {
  background: rgba(11, 11, 15, .78);
  color: #fff;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}
.tile-controls button:hover { background: rgba(11, 11, 15, .95); }

.tile:fullscreen { border-radius: 0; border: 0; }
.tile:fullscreen video { object-fit: contain; }

/*
 * Quadro que está sendo assistido no popup: fica com um véu e um aviso,
 * para ninguém achar que a transmissão travou no palco.
 */
.tile.popped video { opacity: .25; filter: saturate(.4); }
.tile-popped-hint {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  gap: 8px;
  align-content: center;
  color: var(--text-hi);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  padding: 12px;
  pointer-events: none;
  z-index: 2;
}
.tile-popped-hint span { color: var(--text-dim); font-weight: 600; font-size: 12px; }

/* ------------------ popup da transmissão (popout) ------------------ */
/*
 * Janela flutuante com a live: arrasta pelo cabeçalho, redimensiona
 * pelo canto e continua na tela enquanto a pessoa conversa nos canais
 * de texto. Posição e tamanho ficam guardados entre as sessões.
 */
.stage-popup {
  position: fixed;
  z-index: 120;              /* acima do app, abaixo de modais e toasts */
  display: flex;
  flex-direction: column;
  background: #000;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0, 0, 0, .6);
  animation: popup-in .18s cubic-bezier(.2, .9, .3, 1.1);
}
.stage-popup.closing { animation: popup-out .14s ease forwards; }
@keyframes popup-in  { from { opacity: 0; transform: scale(.96); } }
@keyframes popup-out { to   { opacity: 0; transform: scale(.97); } }

/* enquanto arrasta/redimensiona: nada de seleção nem transição atrapalhando */
.stage-popup.dragging { user-select: none; }
body.popup-dragging { user-select: none; cursor: grabbing; }

.stage-popup-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px 7px 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  cursor: grab;
  touch-action: none;        /* o dedo arrasta a janela, não a página */
  flex: none;
}
.stage-popup.dragging .stage-popup-head { cursor: grabbing; }
.stage-popup-title {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-hi);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.stage-popup-title .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--lime);
  flex: none;
  animation: popup-live 1.6s ease-in-out infinite;
}
@keyframes popup-live { 50% { opacity: .35; } }

.stage-popup-btn {
  flex: none;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--text-dim);
}
.stage-popup-btn:hover { background: var(--panel-2); color: var(--text-hi); }
.stage-popup-btn.close:hover { background: var(--red); color: #fff; }
.stage-popup-btn svg { width: 15px; height: 15px; }

.stage-popup-body { flex: 1; min-height: 0; position: relative; background: #000; }
.stage-popup-body video { width: 100%; height: 100%; object-fit: contain; display: block; }

/* aviso de quem parou de transmitir, por cima do último quadro */
.stage-popup-off {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  text-align: center;
  font-size: 13px;
  color: var(--text-dim);
  background: rgba(11, 11, 15, .82);
}

.stage-popup-resize {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 22px;
  height: 22px;
  cursor: nwse-resize;
  touch-action: none;
  z-index: 3;
}
/* riscos diagonais discretos, como alça de redimensionar de janela */
.stage-popup-resize::after {
  content: "";
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 10px;
  height: 10px;
  border-right: 2px solid rgba(255, 255, 255, .45);
  border-bottom: 2px solid rgba(255, 255, 255, .45);
  border-radius: 0 0 3px 0;
}

.tile {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 16 / 9;
  display: grid;
  place-items: center;
  min-height: 160px;
}
.tile.speaking { border-color: var(--lime); box-shadow: 0 0 0 1px var(--lime); }
/* No palco o avatar é grande: o mesmo pulso, só que mais contido. */
.tile.speaking .tile-avatar { animation: falando-pulso 1.15s ease-out infinite; }
.tile video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.tile .tile-avatar { width: 76px; height: 76px; font-size: 26px; border-radius: 26px; }
.tile-label {
  position: absolute;
  left: 10px;
  bottom: 10px;
  background: rgba(11, 11, 15, .82);
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}
.tile-label .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--lime); }
.stage-empty { color: var(--text-dim); text-align: center; grid-column: 1 / -1; }

/*
 * Barra da chamada como um "dock" de vidro: uma pílula flutuante com
 * blur, brilho sutil no topo e sombra profunda — os controles dentro
 * são fantasmas que acendem no hover. Estados fortes (transmitindo,
 * mutado, sair) ganham cor de verdade.
 */
.stage-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  flex: none;
  align-self: center;
  max-width: calc(100% - 24px);
  margin: 10px auto 16px;
  padding: 9px 10px;
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .05), rgba(255, 255, 255, 0) 55%),
    rgba(18, 18, 24, .82);
  border: 1px solid rgba(255, 255, 255, .07);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow:
    0 18px 44px rgba(0, 0, 0, .5),
    0 2px 8px rgba(0, 0, 0, .35);
}
.sbtn {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .04);
  border: 1px solid transparent;
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: .01em;
  white-space: nowrap;
  transition: background .16s, color .16s, border-color .16s, transform .16s, box-shadow .16s;
}
.sbtn svg { width: 18px; height: 18px; opacity: .9; }
.sbtn:hover {
  background: rgba(255, 255, 255, .09);
  border-color: rgba(255, 255, 255, .08);
  color: var(--text-hi);
  transform: translateY(-1px);
}
.sbtn:active { transform: translateY(0) scale(.97); }

/* transmitindo: limão com brilho, texto escuro */
.sbtn.on {
  background: linear-gradient(180deg, #e5ff70, #cdf03e);
  border-color: rgba(217, 251, 80, .5);
  color: var(--on-lime);
  box-shadow: 0 4px 16px rgba(217, 251, 80, .28);
}
.sbtn.on svg { opacity: 1; }
.sbtn.on:hover { filter: brightness(1.04); }

/* microfone mutado: vermelho contido, sem gritar */
.sbtn.off {
  background: rgba(255, 94, 107, .14);
  border-color: rgba(255, 94, 107, .38);
  color: #ff8b95;
}
.sbtn.off:hover { background: rgba(255, 94, 107, .22); color: #ffa2aa; }

/* sair: o único botão sólido — é a ação terminal da barra */
.sbtn.danger {
  background: linear-gradient(180deg, #ff6b77, #ef4351);
  border-color: rgba(255, 255, 255, .14);
  color: #fff;
  box-shadow: 0 6px 18px rgba(255, 94, 107, .32);
}
.sbtn.danger svg { opacity: 1; }
.sbtn.danger:hover { filter: brightness(1.06); transform: translateY(-1px); }

/* painel do Spotify */
.modal-icon.spotify-icon { background: rgba(29, 185, 84, .12); border-color: rgba(29, 185, 84, .3); }
.modal-icon.spotify-icon svg { width: 26px; height: 26px; }

.btn-spotify-connect {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 13px;
  border-radius: 999px;
  background: #1DB954;   /* verde oficial do Spotify */
  color: #fff;
  font-weight: 700;
  transition: filter .15s, transform .1s;
}
.btn-spotify-connect:hover { filter: brightness(1.08); }
.btn-spotify-connect:active { transform: scale(.99); }
.btn-spotify-connect svg { width: 20px; height: 20px; }
.btn-spotify-connect svg path { fill: #fff; }

/* Botão do seletor de qualidade — o dropdown é o .quality-menu. */
.squality {
  display: flex;
  align-items: center;
  gap: 9px;
  background: rgba(255, 255, 255, .04);
  border: 1px solid transparent;
  color: var(--text);
  border-radius: 999px;
  padding: 11px 16px;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: .01em;
  white-space: nowrap;
  cursor: pointer;
  outline: none;
  transition: background-color .16s, color .16s, border-color .16s, box-shadow .16s, transform .16s;
}
.squality svg { width: 17px; height: 17px; opacity: .9; }
.squality .qchev { width: 10px; height: 6px; opacity: .6; transition: transform .16s; }
.squality:hover {
  background-color: rgba(255, 255, 255, .09);
  border-color: rgba(255, 255, 255, .08);
  color: var(--text-hi);
  transform: translateY(-1px);
}
.squality.open {
  background-color: rgba(255, 255, 255, .1);
  border-color: rgba(255, 255, 255, .1);
  color: var(--text-hi);
}
.squality.open .qchev { transform: rotate(180deg); }
.squality:focus-visible {
  border-color: var(--violet);
  box-shadow: 0 0 0 3px var(--violet-soft);
}

/* O dropdown: mesmo vidro do dock, com nome + descrição por modo. */
.quality-menu {
  position: fixed;
  z-index: 210;
  width: 300px;
  padding: 8px;
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .05), rgba(255, 255, 255, 0) 55%),
    rgba(18, 18, 24, .92);
  border: 1px solid rgba(255, 255, 255, .08);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 18px 44px rgba(0, 0, 0, .55);
  animation: modal-pop .16s cubic-bezier(.2, .9, .3, 1.2);
}
.quality-menu-title {
  font-size: 10.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-dim);
  padding: 8px 12px 6px;
}
.quality-opt {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border-radius: 12px;
  text-align: left;
  transition: background .12s;
}
.quality-opt:hover { background: rgba(255, 255, 255, .07); }
.quality-opt.active { background: var(--lime-soft); }
.quality-opt-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.quality-opt-name { font-size: 13.5px; font-weight: 700; color: var(--text-hi); }
.quality-opt.active .quality-opt-name { color: var(--lime); }
.quality-opt-desc { font-size: 11.5px; color: var(--text-dim); line-height: 1.35; }
.quality-check { width: 16px; height: 16px; fill: var(--lime); flex: none; }

/* -------------------------- membros --------------------------- */
.members {
  width: 240px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 10px;
  overflow-y: auto;
  min-height: 0;
  flex: none;
}
.members-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 0 8px 10px;
  letter-spacing: .08em;
}
.member {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 999px;
  cursor: pointer;
}
.member:hover { background: var(--panel-2); }
.member-name { font-size: 14px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member:hover .member-name { color: var(--text); }
.member.me .member-name { color: var(--text-hi); font-weight: 600; }

/* nome + "ouvindo no Spotify" empilhados */
.member-name-box { min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.member-name-box .member-name { display: block; }
.member-listening {
  font-size: 11px;
  color: var(--lime);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* "Jogando X" — mesma linha do "ouvindo", em lilás para diferenciar */
.member-playing {
  font-size: 11px;
  color: var(--violet);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* bloco do jogo no cartão de perfil */
.playing-art {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  flex: none;
  display: grid;
  place-items: center;
  font-size: 22px;
  background: var(--violet-soft);
  border: 1px solid rgba(165, 149, 249, .25);
}

/* "ouvindo agora" no cartão de perfil */
.listening-row { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.listening-art { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; flex: none; }
.listening-text { min-width: 0; }
.listening-track {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-hi);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.listening-artist {
  font-size: 12.5px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.members-more { padding: 8px; font-size: 13px; color: var(--text-dim); font-style: italic; }
.member-avatar-wrap { position: relative; flex: none; }
.member-avatar-wrap::after {
  content: "";
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--lime);
  border: 3px solid var(--panel);
  box-sizing: content-box;
}

/* --------------------------- modais --------------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(6, 6, 10, .62);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: modal-fade .18s ease;
}
.modal-overlay.closing { animation: modal-fade-out .16s ease forwards; }

.modal-card {
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  width: min(440px, 100%);
  background:
    radial-gradient(320px 180px at 85% -10%, rgba(141, 123, 241, .16), transparent 70%),
    radial-gradient(280px 160px at -5% 110%, rgba(217, 251, 80, .07), transparent 70%),
    var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 28px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, .6), 0 0 0 1px rgba(255, 255, 255, .02) inset;
  animation: modal-pop .22s cubic-bezier(.2, .9, .3, 1.2);
}
.modal-overlay.closing .modal-card { animation: modal-pop-out .16s ease forwards; }

.modal-icon {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-size: 24px;
  margin-bottom: 16px;
  background: var(--violet-soft);
  border: 1px solid rgba(165, 149, 249, .25);
}
.modal-card.danger .modal-icon {
  background: rgba(255, 94, 107, .12);
  border-color: rgba(255, 94, 107, .3);
}

.modal-title {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -.02em;
  color: var(--text-hi);
}
.modal-sub { color: var(--text-dim); font-size: 14px; margin-top: 6px; line-height: 1.45; }

.modal-body { margin-top: 20px; }

.modal-body label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.modal-body input {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  outline: none;
  margin-bottom: 16px;
  transition: border-color .15s, box-shadow .15s;
}
.modal-body input:focus {
  border-color: var(--violet);
  box-shadow: 0 0 0 3px var(--violet-soft);
}
.modal-card.danger .modal-body input:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(255, 94, 107, .14);
}

/* grade de emojis sugeridos */
.emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
  margin-bottom: 16px;
}
.emoji-grid button {
  aspect-ratio: 1;
  border-radius: 10px;
  font-size: 19px;
  display: grid;
  place-items: center;
  background: var(--panel-2);
  border: 1px solid transparent;
  transition: background .12s, transform .1s, border-color .12s;
}
.emoji-grid button:hover { background: var(--panel-3); transform: scale(1.08); }
.emoji-grid button.picked {
  background: var(--lime-soft);
  border-color: var(--lime);
  box-shadow: 0 0 0 3px rgba(217, 251, 80, .08);
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 8px;
}
.modal-actions button {
  padding: 11px 22px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 14px;
  transition: filter .15s, transform .1s, background .12s;
}
.modal-actions button:active { transform: scale(.98); }

.modal-cancel { background: var(--panel-2); color: var(--text); }
.modal-cancel:hover { background: var(--panel-3); }

.modal-confirm { background: var(--lime); color: var(--on-lime); }
.modal-confirm:hover { filter: brightness(1.08); }
.modal-confirm:disabled { opacity: .45; cursor: not-allowed; filter: none; }

.modal-card.danger .modal-confirm { background: var(--red); color: #fff; }

/* cartão de perfil (aberto pelo menu de contexto de um membro) */
.profile-card { padding-top: 0; overflow: hidden; text-align: center; }
.profile-banner {
  height: 88px;
  margin: 0 -28px;
  opacity: .85;
}
.profile-avatar {
  width: 76px;
  height: 76px;
  border-radius: 26px;
  font-size: 26px;
  margin: -38px auto 14px;
  border: 5px solid var(--panel);
  box-sizing: content-box;
}
.profile-note {
  margin-top: 16px;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  text-align: left;
  font-size: 14px;
}
.profile-card .modal-actions { margin-top: 20px; justify-content: center; }

/* editor de perfil */
.pf-photo-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}
.pf-preview { width: 64px; height: 64px; border-radius: 20px; font-size: 20px; }
.pf-photo-btns { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.pf-photo-btns .user-menu-btn { margin-top: 0; }

.modal-body textarea {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  outline: none;
  margin-bottom: 16px;
  resize: vertical;
  min-height: 68px;
  font: inherit;
  color: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.modal-body textarea:focus {
  border-color: var(--violet);
  box-shadow: 0 0 0 3px var(--violet-soft);
}

@keyframes modal-fade { from { opacity: 0; } }
@keyframes modal-fade-out { to { opacity: 0; } }
@keyframes modal-pop { from { opacity: 0; transform: translateY(14px) scale(.96); } }
@keyframes modal-pop-out { to { opacity: 0; transform: translateY(10px) scale(.97); } }

/* -------------------------- convite --------------------------- */
.btn-invite {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 14px 0 11px;
  margin-right: 8px;
  border-radius: 999px;
  background: var(--lime-soft);
  border: 1px solid rgba(217, 251, 80, .28);
  color: var(--lime);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  transition: background .14s, border-color .14s, transform .1s;
}
.btn-invite svg { width: 17px; height: 17px; fill: currentColor; }
.btn-invite:hover { background: rgba(217, 251, 80, .18); border-color: var(--lime); }
.btn-invite:active { transform: scale(.97); }

/* variação violeta: amigos (o limão fica para a ação da sala) */
.btn-invite.friends {
  background: var(--violet-soft);
  border-color: rgba(165, 149, 249, .3);
  color: var(--violet);
}
.btn-invite.friends:hover { background: rgba(165, 149, 249, .24); border-color: var(--violet); }

.invite-card { width: min(480px, 100%); }
.invite-card .modal-icon { background: var(--lime-soft); border-color: rgba(217, 251, 80, .25); }

.invite-row { display: flex; gap: 8px; margin-bottom: 22px; }
.invite-row input {
  flex: 1;
  margin-bottom: 0;
  font-family: ui-monospace, 'Cascadia Code', Consolas, monospace;
  font-size: 12.5px;
  color: var(--text-dim);
}
.invite-row input:focus { border-color: var(--lime); box-shadow: 0 0 0 3px var(--lime-soft); }

.invite-copy {
  padding: 0 20px;
  border-radius: var(--radius-sm);
  background: var(--lime);
  color: var(--on-lime);
  font-weight: 700;
  font-size: 13.5px;
  white-space: nowrap;
  transition: filter .15s, background .2s, color .2s;
}
.invite-copy:hover { filter: brightness(1.08); }
.invite-copy.done { background: var(--violet); color: #fff; }

.invite-share {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 8px;
  margin-bottom: 20px;
}
.invite-share button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 14px 4px;
  border-radius: 14px;
  background: var(--panel-2);
  border: 1px solid transparent;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  transition: background .12s, border-color .12s, transform .12s;
}
.invite-share button:hover { background: var(--panel-3); border-color: var(--line); transform: translateY(-2px); }
.invite-share button:active { transform: translateY(0) scale(.97); }
.invite-share svg { width: 22px; height: 22px; fill: currentColor; }
.invite-share .wa svg { fill: #25d366; }
.invite-share .tg svg { fill: #2aabee; }
.invite-share .mail svg { fill: var(--violet); }
.invite-share .nativo svg { fill: var(--text-dim); }

.invite-note {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--panel-2);
  color: var(--text-dim);
  font-size: 12.5px;
  line-height: 1.5;
}

@media (max-width: 560px) {
  .btn-invite span { display: none; }
  .btn-invite { padding: 0 10px; }
}

/* --------------------------- toasts --------------------------- */
.toasts {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
}
.toast {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--lime);
  color: var(--text-hi);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .5);
  font-size: 14px;
  max-width: 320px;
  animation: slide-in .2s ease;
}
.toast.error { border-left-color: var(--red); }
@keyframes slide-in { from { opacity: 0; transform: translateX(20px); } }

/* ---------------------- aviso "também é app" ------------------- */
.install-banner {
  position: fixed;
  bottom: calc(20px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 190;                 /* abaixo dos toasts, acima do resto */
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 12px;
  max-width: min(440px, calc(100vw - 24px));
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(0, 0, 0, .55);
  animation: install-up .3s cubic-bezier(.2, .9, .3, 1.1);
}
.install-banner.closing { animation: install-down .22s ease forwards; }
@keyframes install-up   { from { opacity: 0; transform: translate(-50%, 16px); } }
@keyframes install-down { to   { opacity: 0; transform: translate(-50%, 16px); } }

.install-logo { width: 34px; height: 34px; }
.install-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.install-text strong { font-size: 14px; color: var(--text-hi); }
.install-text span   { font-size: 12.5px; color: var(--text-dim); }

.install-cta {
  background: var(--lime);
  color: var(--on-lime);
  font-weight: 700;
  font-size: 13px;
  padding: 9px 16px;
  border-radius: 999px;
  white-space: nowrap;
}
.install-cta:hover  { filter: brightness(1.08); }
.install-cta:active { transform: scale(.97); }

.install-x {
  color: var(--text-dim);
  font-size: 20px;
  line-height: 1;
  padding: 4px 6px;
  border-radius: 8px;
}
.install-x:hover { color: var(--text-hi); background: var(--panel-2); }

/* passo a passo p/ navegador sem instalação nativa (Opera, Safari…) */
.install-how {
  grid-column: 1 / -1;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  background: var(--panel-2);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

/* ------------------------- responsivo ------------------------- */
/* botão de menu (hambúrguer): só existe no celular */
.btn-menu { display: none; }

/* fundo escurecido atrás das gavetas */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(6, 6, 10, .55);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}
.drawer-backdrop.show { opacity: 1; pointer-events: auto; }

/*
 * Telas médias (tablet deitado): a lista de membros vira uma gaveta à
 * direita, aberta pelo botão de membros da barra superior.
 */
@media (max-width: 900px) {
  .members {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(300px, 82vw);
    z-index: 35;
    border-radius: 0;
    border-right: 0;
    padding-top: max(16px, env(safe-area-inset-top));
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    transform: translateX(110%);
    transition: transform .22s ease;
    box-shadow: -18px 0 44px rgba(0, 0, 0, .45);
  }
  .members.open { transform: none !important; }
  /* o esconder/mostrar do desktop não vale aqui: a gaveta é quem manda */
  .members.hidden { display: block !important; }
}

/* --------------------------- celular --------------------------- */
@media (max-width: 680px) {
  .app {
    grid-template-columns: 56px 1fr;
    gap: 8px;
    padding: 8px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
    height: 100dvh; /* teclado aberto não deixa área morta atrás dele */
  }

  .rail { padding: 10px 0; gap: 8px; }
  .rail-item { width: 44px; height: 44px; font-size: 17px; border-radius: 14px; }

  /* canais viram gaveta por cima do chat */
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: min(320px, 85vw);
    z-index: 35;
    border-radius: 0;
    border-left: 0;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    transform: translateX(-108%);
    transition: transform .22s ease;
    box-shadow: 18px 0 44px rgba(0, 0, 0, .45);
  }
  .sidebar.open { transform: none; }

  .btn-menu { display: block; }

  /* barra superior enxuta */
  .topbar { padding: 0 10px; gap: 8px; height: 52px; }
  .topbar-topic, .topbar-divider { display: none; }

  /* alvos de toque confortáveis */
  .ubtn { padding: 9px; }
  .channel { padding: 10px 12px; }
  .voice-member { padding: 8px 10px; }

  /* iOS dá zoom em campo com fonte < 16px — então 16px nos campos */
  .composer input,
  .login-card input,
  .modal-body input,
  .modal-body textarea { font-size: 16px; }

  .messages { padding: 12px 12px 0; }
  .composer { padding: 0 10px 10px; }

  /* palco: botões só com ícone, quebrando linha se precisar */
  .stage { padding: 10px; gap: 8px; }
  .stage-focus { grid-template-columns: 1fr; }
  .stage-strip .tile { width: 128px; }
  .stage-bar { flex-wrap: wrap; gap: 6px; padding: 10px; }
  .sbtn span { display: none; }
  .sbtn { padding: 12px 14px; }
  .squality { font-size: 12px; padding: 10px 12px; }
  .quality-menu { width: calc(100vw - 16px); left: 8px !important; }

  /* modais viram folha inferior, no alcance do polegar */
  .modal-overlay { place-items: end center; padding: 0; }
  .modal-card {
    width: 100%;
    border-radius: 22px 22px 0 0;
    padding-bottom: calc(24px + env(safe-area-inset-bottom));
    max-height: 92dvh;
    overflow-y: auto;
    animation: sheet-up .24s cubic-bezier(.2, .9, .3, 1.05);
  }
  .modal-overlay.closing .modal-card { animation: sheet-down .16s ease forwards; }

  /* menus de contexto também: folha fixa embaixo em vez de flutuar no dedo.
     (!important: vence o width fixo do settings.css e o left/top inline) */
  .user-menu {
    left: 8px !important;
    right: 8px !important;
    width: auto !important;
    top: auto !important;
    bottom: calc(8px + env(safe-area-inset-bottom)) !important;
    max-height: 78dvh;
    overflow-y: auto;
  }

  /* login rolável em tela baixa (teclado aberto) */
  .login { overflow-y: auto; padding: 16px 0; }

  /* toasts na largura da tela, acima da área de gesto */
  .toasts {
    left: 12px;
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom));
  }
  .toast { max-width: none; }

  /* estado vazio respira menos */
  .empty-card { padding: 0 8px; }

  /* popup da live: alça de redimensionar no tamanho do dedo */
  .stage-popup-resize { width: 30px; height: 30px; }
  .stage-popup-btn { width: 34px; height: 34px; }
}

@keyframes sheet-up { from { transform: translateY(48px); opacity: 0; } }
@keyframes sheet-down { to { transform: translateY(48px); opacity: 0; } }

/* volume da transmissão, dentro do dock da chamada */
.live-volume {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 14px 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .04);
  border: 1px solid transparent;
  transition: background .16s, border-color .16s;
}
.live-volume:hover { background: rgba(255, 255, 255, .09); border-color: rgba(255, 255, 255, .08); }
.live-volume svg { width: 17px; height: 17px; opacity: .75; flex: none; }
.live-volume input[type="range"] { width: 96px; height: 4px; }
.live-volume span {
  min-width: 40px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  text-align: right;
}
@media (max-width: 560px) {
  .live-volume input[type="range"] { width: 70px; }
  .live-volume span { display: none; }
}
