/* ============================================================ tokens ==== */
/* Identidade PlingChat: grafite frio + vidro + violeta-orquídea, detalhe em
   teal. Substitui a antiga paleta blurple/Discord. --green/--yellow mantêm
   o nome por compatibilidade com o resto da folha, mas agora carregam
   teal (sucesso/online) e âmbar (ausente) — ver o mockup em design/. */
:root {
  --bg-0: #08080b;
  --bg-1: #0c0c10;
  --bg-2: #0a0a0d;
  --bg-3: #16161b;
  --bg-4: #1e1e25;
  --line: rgba(255,255,255,.08);
  --text: #f4f4f7;
  --text-dim: #8d8d99;
  --text-mute: #61616b;
  --brand: #9b4dff;
  --brand-2: #d94fc0;
  --brand-gradient: linear-gradient(150deg, var(--brand), var(--brand-2));
  --glass: rgba(255,255,255,.045);
  --glass-border: rgba(255,255,255,.09);
  --green: #5eead4;
  --yellow: #f0c264;
  --red: #ff7a7a;
  --pink: #e04fb0;
  --radius: 10px;
  --rail-w: 74px;
  --side-w: 250px;
  --members-w: 232px;
  --font: 'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
  --scrollbar: #302f38;
}
:root[data-theme="light"] { --scrollbar: #c7cbd6; }
@media (prefers-color-scheme: light) { :root[data-theme="auto"] { --scrollbar: #c7cbd6; } }

/* Claro — só entra com escolha explícita (data-theme="light") ou, no modo
   "automático", quando o sistema também estiver em claro. O padrão de todo
   mundo continua escuro, igual sempre foi. */
:root[data-theme="light"] {
  --bg-0: #f5f4f8;
  --bg-1: #ffffff;
  --bg-2: #ffffff;
  --bg-3: #f0eef5;
  --bg-4: #e6e2f0;
  --line: #e1ddea;
  --text: #18161d;
  --text-dim: #514e5c;
  --text-mute: #837f8f;
  --glass: rgba(20,10,30,.03);
  --glass-border: rgba(20,10,30,.08);
}
:root[data-theme="auto"] {
  color-scheme: light dark;
}
@media (prefers-color-scheme: light) {
  :root[data-theme="auto"] {
    --bg-0: #f5f4f8;
    --bg-1: #ffffff;
    --bg-2: #ffffff;
    --bg-3: #f0eef5;
    --bg-4: #e6e2f0;
    --line: #e1ddea;
    --text: #18161d;
    --text-dim: #514e5c;
    --text-mute: #837f8f;
    --glass: rgba(20,10,30,.03);
    --glass-border: rgba(20,10,30,.08);
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg-0);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button, input, textarea, select { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

[hidden] { display: none !important; }

/* ---------------------------------------------------------- loading ---- */
.loading { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg-0); }
.loading .logo { animation: loading-pulse 1.4s ease-in-out infinite; }
@keyframes loading-pulse { 0%,100% { opacity: .5; transform: scale(.94); } 50% { opacity: 1; transform: scale(1); } }

/* selo da marca: quadrado arredondado com gradiente violeta-orquídea */
.brand-mark {
  display: inline-grid; place-items: center; flex: none;
  width: 26px; height: 26px; border-radius: 32%;
  background: var(--brand-gradient); box-shadow: 0 6px 16px -8px rgba(155,77,255,.7);
}
.brand-mark svg { width: 55%; height: 55%; }
.loading .brand-mark { width: 56px; height: 56px; border-radius: 26%; }

/* ============================================================== auth ==== */
.auth { position: fixed; inset: 0; display: grid; place-items: center; padding: 20px; overflow: auto; }
.auth-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(900px 500px at 15% 10%, rgba(155,77,255,.22), transparent 60%),
    radial-gradient(800px 500px at 85% 85%, rgba(217,79,192,.16), transparent 60%),
    linear-gradient(160deg, var(--bg-0), var(--bg-1));
}
.auth-card {
  position: relative; width: min(430px, 100%);
  background: var(--glass); backdrop-filter: blur(20px); border: 1px solid var(--glass-border);
  border-radius: 20px; padding: 32px;
  box-shadow: 0 30px 60px -34px rgba(0,0,0,.7);
}
.auth-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; color: var(--text); margin-bottom: 18px; }
.auth-card h1 { font-size: 22px; margin-bottom: 6px; }
.auth-sub { color: var(--text-dim); font-size: 14px; margin-bottom: 22px; }
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font: 500 10.5px var(--font-mono); letter-spacing: .09em; text-transform: uppercase; color: var(--text-mute); margin-bottom: 7px; }
.field input, .field textarea, .field select {
  width: 100%; padding: 11px 12px; background: var(--glass);
  border: 1px solid var(--line); border-radius: 11px; outline: none; color: var(--text);
}
.field input:focus, .field textarea:focus, .field select:focus {
  border-color: rgba(155,77,255,.5); box-shadow: 0 0 0 3px rgba(155,77,255,.14);
}
.auth-error { background: rgba(237,66,69,.12); border: 1px solid rgba(237,66,69,.4); color: #ffb3b4; padding: 9px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 14px; }
.auth-ok { background: rgba(59,165,93,.12); border: 1px solid rgba(59,165,93,.4); color: #9ae6b4; padding: 9px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 14px; }
.auth-forgot { margin-top: 12px; text-align: center; font-size: 13px; }
.turnstile { margin-bottom: 14px; display: flex; justify-content: center; min-height: 0; }

.verify-banner { background: rgba(250,166,26,.12); border-bottom: 1px solid rgba(250,166,26,.35); color: #ffd591; padding: 9px 16px; display: flex; align-items: center; gap: 12px; font-size: 13px; flex: none; }
.verify-banner .link { color: #ffd591; text-decoration: underline; }
.verify-banner .icon-btn { margin-left: auto; width: 26px; height: 26px; color: #ffd591; }

.invite-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.invite-row code { background: var(--bg-0); padding: 4px 9px; border-radius: 6px; font-family: var(--font-mono); letter-spacing: .04em; }
.invite-row .used { color: var(--text-mute); text-decoration: line-through; }
.invite-row .acts { margin-left: auto; display: flex; gap: 4px; }

.auth-divider { margin-top: 18px; display: grid; justify-items: center; gap: 12px; }
.auth-divider > span { position: relative; width: 100%; text-align: center; font-size: 12px; color: var(--text-mute); }
.auth-divider > span::before, .auth-divider > span::after { content: ''; position: absolute; top: 50%; width: 42%; height: 1px; background: var(--line); }
.auth-divider > span::before { left: 0; }
.auth-divider > span::after { right: 0; }

.auth-switch { margin-top: 16px; font-size: 13px; color: var(--text-dim); }
.link { color: var(--brand-2); font-weight: 600; }
.link:hover { text-decoration: underline; }

.btn { padding: 10px 16px; border-radius: 8px; font-weight: 600; font-size: 14px; transition: filter .15s, background .15s; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn:hover { filter: brightness(1.12); }
.btn-primary { background: var(--brand-gradient); color: #fff; box-shadow: 0 8px 20px -12px rgba(155,77,255,.85); }
.btn-ghost { background: var(--bg-4); color: var(--text); }
.btn-danger { background: var(--red); color: #fff; }
.btn-success { background: var(--green); color: #fff; }
.btn-block { width: 100%; }

/* =============================================================== app ==== */
.app { display: grid; grid-template-columns: var(--rail-w) var(--side-w) 1fr auto; height: 100%; }

/* ------------------------------------------------------------- rail ---- */
.rail { background: var(--bg-0); display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 16px 0; overflow-y: auto; }
.rail::-webkit-scrollbar { width: 0; }

/* seletor pessoal/organização, estilo Canva */
.ws-switcher { flex: none; padding-bottom: 4px; margin-bottom: 2px; border-bottom: 1px solid var(--line); width: 48px; display: flex; justify-content: center; }
.ws-trigger {
  width: 40px; height: 40px; border-radius: 12px; background: var(--bg-3); color: var(--text);
  display: grid; place-items: center; font-weight: 700; font-size: 14px; transition: border-radius .15s;
}
.ws-trigger:hover { border-radius: 10px; }
.ws-avatar { display: grid; place-items: center; }
.ws-menu {
  position: fixed; z-index: 70; width: 240px; background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 12px; padding: 6px; box-shadow: 0 16px 40px rgba(0,0,0,.4);
}
.ws-row {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border-radius: 8px;
  text-align: left; color: var(--text-dim); transition: background .12s, color .12s;
}
.ws-row:hover { background: var(--bg-3); color: var(--text); }
.ws-row.active { background: var(--bg-4); color: var(--text); }
.ws-row.active .ws-row-avatar { background: var(--brand); color: #fff; }
.ws-row-avatar {
  width: 30px; height: 30px; border-radius: 9px; background: var(--bg-4); color: var(--text);
  display: grid; place-items: center; font-size: 12px; font-weight: 700; flex: none;
}
.ws-row strong { display: block; font-size: 13.5px; font-weight: 600; }
.ws-row small { display: block; font-size: 11px; color: var(--text-mute); }
.rail-guilds { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.rail-item {
  position: relative; width: 48px; height: 48px; border-radius: 14px;
  background: var(--bg-3); color: var(--text); font-weight: 700; font-size: 17px;
  display: grid; place-items: center; transition: border-radius .18s, background .18s, box-shadow .18s;
  overflow: hidden; flex: none;
  box-shadow: 0 1px 2px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.05);
}
.rail-item:hover, .rail-item.active { border-radius: 12px; }
.rail-item.active { background: var(--brand-gradient); box-shadow: 0 0 0 3px rgba(155,77,255,.22), inset 0 1px 0 rgba(255,255,255,.08); }
.rail-home.active { background: var(--brand-gradient); }
.rail-glyph svg { width: 20px; height: 20px; }
.rail-add { color: var(--green); }
.rail-add:hover { background: var(--green); color: #fff; }
.rail-sep { width: 22px; height: 1px; background: var(--line); border-radius: 2px; margin: 2px 0; }
.rail-pill { position: absolute; left: -14px; width: 4px; height: 0; background: #fff; border-radius: 0 4px 4px 0; transition: height .18s cubic-bezier(.2,.8,.3,1); }
.rail-item:hover .rail-pill { height: 10px; }
.rail-item.active .rail-pill { height: 26px; }
.rail-badge { position: absolute; right: -2px; bottom: -2px; background: var(--brand); color: #fff; font-size: 11px; min-width: 18px; height: 18px; border-radius: 9px; display: grid; place-items: center; border: 3px solid var(--bg-0); padding: 0 4px; }
.rail-badge.mentioned { background: var(--yellow); color: #402c00; }

/* ---------------------------------------------------------- sidebar ---- */
.sidebar { background: var(--bg-1); display: flex; flex-direction: column; min-width: 0; border-right: 1px solid var(--line); }
.sidebar-header {
  height: 50px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; font-weight: 700; font-size: 15px;
  border-bottom: 1px solid var(--line); box-shadow: 0 1px 0 rgba(0,0,0,.2); cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: background .15s;
}
.sidebar-header:hover { background: var(--bg-2); }
.sidebar-body { flex: 1; overflow-y: auto; padding: 10px 8px 20px; }

.side-section { margin-top: 18px; padding-top: 12px; border-top: 1px solid rgba(255,255,255,.04); }
.side-section:first-child { margin-top: 6px; padding-top: 0; border-top: 0; }
.side-label { display: flex; align-items: center; justify-content: space-between; padding: 4px 8px 6px; font: 500 10.5px var(--font-mono); text-transform: uppercase; letter-spacing: .1em; color: var(--text-mute); }
.side-label button { color: var(--text-mute); font-size: 16px; line-height: 1; border-radius: 4px; transition: color .15s, background .15s; }
.side-label button:hover { color: var(--text); background: var(--bg-3); }

.channel {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 7px 8px; border-radius: 6px; color: var(--text-dim);
  font-size: 14px; text-align: left; position: relative;
  transition: background .12s, color .12s;
}
.channel::before {
  content: ''; position: absolute; left: -8px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 0; background: #fff; border-radius: 0 3px 3px 0; transition: height .15s;
}
.channel:hover { background: var(--bg-2); color: var(--text); }
.channel.active { background: var(--bg-4); color: #fff; }
.channel.active::before { height: 20px; }
.channel .glyph { color: var(--text-mute); flex: none; font-size: 15px; }
.channel .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.channel .badge { background: var(--brand); color: #fff; font-size: 11px; min-width: 17px; height: 17px; border-radius: 9px; display: grid; place-items: center; padding: 0 5px; font-weight: 700; }
.channel .badge.mentioned { background: var(--yellow); color: #402c00; }
.channel .del { opacity: 0; color: var(--text-mute); transition: opacity .12s, color .12s; }
.channel:hover .del { opacity: 1; }
.channel .del:hover { color: var(--red); }

.voice-members { padding: 2px 0 4px 26px; display: flex; flex-direction: column; gap: 4px; }
.voice-member { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-dim); }
.voice-member .avatar { width: 20px; height: 20px; font-size: 9px; }
.voice-member .flags { margin-left: auto; display: flex; gap: 3px; font-size: 11px; }
.voice-member.speaking .avatar { box-shadow: 0 0 0 2px var(--green); }

/* avatar — quadrado arredondado, não círculo; é a assinatura visual do PlingChat */
.avatar {
  width: 32px; height: 32px; border-radius: 32%; flex: none;
  display: inline-grid; place-items: center; font-size: 13px; font-weight: 700;
  color: #fff; background: var(--brand-gradient); position: relative; text-transform: uppercase;
}
.avatar.big { width: 76px; height: 76px; font-size: 28px; border-radius: 24%; }
/* A foto segue a mesma moldura arredondada-quadrada do avatar de cor+inicial
   (border-radius: inherit pega o 32% normal ou o 24% do .big automaticamente),
   nunca um círculo — senão a moldura do avatar e a foto dentro dela não batem. */
.avatar img { width: 100%; height: 100%; border-radius: inherit; object-fit: cover; display: block; }
.avatar[data-status]::after {
  content: ''; position: absolute; right: -1px; bottom: -1px;
  width: 11px; height: 11px; border-radius: 50%; border: 3px solid var(--bg-1); background: var(--text-mute);
}
.avatar[data-status="online"]::after { background: var(--green); }
.avatar[data-status="idle"]::after { background: var(--yellow); }
.avatar[data-status="dnd"]::after { background: var(--red); }

/* painel de voz */
.voice-panel { background: var(--bg-2); border-top: 1px solid var(--line); padding: 9px 10px; display: flex; align-items: center; gap: 8px; }
.voice-info { flex: 1; min-width: 0; cursor: pointer; }
.voice-info:hover .voice-channel { color: var(--text); }
.voice-status { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; color: var(--green); }
.voice-status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); animation: pulse 1.6s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
.voice-channel { font-size: 12px; color: var(--text-mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.voice-actions { display: flex; gap: 2px; }

/* painel do usuário */
.user-panel { background: var(--bg-2); padding: 8px; display: flex; align-items: center; gap: 6px; border-top: 1px solid var(--line); }
.user-info { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; padding: 4px; border-radius: 6px; }
.user-info:hover { background: var(--bg-3); }
.user-text { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; }
.user-text strong { font-size: 13px; line-height: 1.2; max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-text small { font-size: 11px; color: var(--text-mute); }
.user-actions { display: flex; }

.icon-btn { width: 32px; height: 32px; border-radius: 6px; display: grid; place-items: center; color: var(--text-dim); font-size: 15px; }
.icon-btn:hover { background: var(--bg-4); color: var(--text); }
.icon-btn.off { color: var(--red); position: relative; }
.icon-btn.off::after { content: ''; position: absolute; width: 22px; height: 2px; background: var(--red); transform: rotate(-45deg); border-radius: 2px; }
.icon-btn.danger { color: var(--red); }
.icon-btn.active { color: var(--green); background: rgba(59,165,93,.14); }
.icon-btn.send { color: var(--brand-2); }

/* ------------------------------------------------------------- main ---- */
.main { background: var(--bg-2); display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.chat-header {
  height: 50px; display: flex; align-items: center; gap: 10px; padding: 0 16px;
  border-bottom: 1px solid var(--line); box-shadow: 0 1px 0 rgba(0,0,0,.2); flex: none;
}
.chat-title { font-weight: 700; white-space: nowrap; }
.chat-topic { color: var(--text-mute); font-size: 13px; border-left: 1px solid var(--line); padding-left: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.chat-actions { margin-left: auto; display: flex; gap: 2px; }
.only-mobile { display: none; }

.content { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.messages { flex: 1; overflow-y: auto; padding: 16px 16px 8px; display: flex; flex-direction: column; gap: 2px; }

/* ------------------------------------------------------------ palco ---- */
.stage {
  background: #06070a; border-bottom: 1px solid var(--line); display: flex; flex-direction: column;
  height: var(--stage-h, 68vh); min-height: 220px; max-height: 88vh;
}
/* auto-fit sem teto pequeno: com poucos participantes, a coluna cresce (1fr)
   em vez de travar num tamanho minusculo -- mas quem trava o tamanho de
   verdade e o proprio .tile (max-width/max-height), centralizado na coluna;
   senao, com 1-2 pessoas, a coluna vira gigante e o vídeo estica demais. */
.stage-grid {
  flex: 1; display: grid; gap: 10px; padding: 10px; overflow: auto;
  grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
  grid-auto-rows: minmax(160px, 1fr); justify-content: center; align-content: center;
  justify-items: center; align-items: center;
}
.tile {
  position: relative; background: var(--bg-1); border-radius: 10px; overflow: hidden;
  width: 100%; height: 100%; max-width: 720px; max-height: 460px; min-height: 140px;
  aspect-ratio: 16/9; display: grid; place-items: center; border: 2px solid transparent;
}
.tile.speaking { border-color: var(--green); }

/* Modo "spotlight" (igual Zoom/Meet): quando alguem compartilha a tela, ela
   ocupa a area principal e as cameras encolhem numa faixa lateral. */
.stage-grid.spotlight {
  display: grid; grid-template-columns: 1fr 190px; grid-template-rows: 1fr;
  align-items: stretch; justify-items: stretch; align-content: stretch; justify-content: stretch;
}
.spotlight-main { display: flex; align-items: center; justify-content: center; min-width: 0; min-height: 0; overflow: hidden; }
.spotlight-main .tile { width: 100%; height: 100%; max-width: none; max-height: none; aspect-ratio: auto; }
.spotlight-side { display: flex; flex-direction: column; gap: 8px; overflow-y: auto; min-height: 0; }
.spotlight-side .tile { width: 100%; max-width: none; flex: none; height: auto; max-height: 130px; }
@media (max-width: 860px) {
  .stage-grid.spotlight { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .spotlight-side { flex-direction: row; overflow-x: auto; overflow-y: hidden; }
  .spotlight-side .tile { width: 130px; flex: none; }
}
.tile video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.tile .tile-avatar { display: grid; place-items: center; }
.tile .tile-name { position: absolute; left: 8px; bottom: 8px; background: rgba(0,0,0,.65); padding: 3px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; display: flex; align-items: center; gap: 5px; }
.tile .tile-tag { position: absolute; right: 8px; top: 8px; background: rgba(0,0,0,.6); padding: 3px 8px; border-radius: 5px; font-size: 11px; display: flex; align-items: center; gap: 4px; }
#stage.is-fullscreen { height: 100vh; max-height: none; border-bottom: 0; }
#stage.is-fullscreen .stage-grid { padding: 24px; }
.stage-bar { display: flex; gap: 8px; justify-content: center; padding: 10px; background: var(--bg-1); flex-wrap: wrap; }

/* alça pra redimensionar a chamada manualmente, arrastando pra cima/baixo */
.stage-resize-handle {
  height: 7px; flex: none; cursor: row-resize; background: var(--bg-1);
  position: relative; touch-action: none; border-bottom: 1px solid var(--line);
}
.stage-resize-handle::after {
  content: ''; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 36px; height: 3px; border-radius: 2px; background: var(--line); transition: background .15s;
}
.stage-resize-handle:hover::after, .stage-resize-handle.dragging::after { background: var(--brand); }
#stage[hidden] + .stage-resize-handle, #stage.is-fullscreen + .stage-resize-handle { display: none; }
.pill-btn { background: var(--bg-4); padding: 8px 14px; border-radius: 20px; font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 7px; }
.icon { flex: none; display: block; }
.pill-btn:hover { background: #333b4d; }
.pill-btn.active { background: var(--green); color: #fff; }
.pill-btn.danger { background: var(--red); color: #fff; }
.pill-btn.ghost { background: transparent; border: 1px solid var(--line); }

/* --------------------------------------------------------- mensagens --- */
.msg { display: grid; grid-template-columns: 42px 1fr; gap: 12px; padding: 4px 8px; border-radius: 6px; position: relative; }
.msg:hover { background: rgba(255,255,255,.025); }
.msg.grouped { padding-top: 1px; padding-bottom: 1px; }
.msg-avatar { padding-top: 2px; }
.msg-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.msg-author { font-weight: 600; font-size: 15px; }
.msg-author.bot-name { color: var(--brand-2); }
.bot-badge { background: var(--brand); color: #fff; font-size: 10px; padding: 1px 5px; border-radius: 4px; font-weight: 700; letter-spacing: .03em; }
.msg-time { font-size: 11px; color: var(--text-mute); }
.msg-body { font-size: 15px; line-height: 1.45; word-wrap: break-word; overflow-wrap: anywhere; white-space: pre-wrap; }
.msg-body code { background: var(--bg-0); padding: 1px 5px; border-radius: 4px; font-family: ui-monospace, 'Cascadia Code', Consolas, monospace; font-size: 13px; }
.msg-body pre { background: var(--bg-0); border: 1px solid var(--line); padding: 10px 12px; border-radius: 8px; margin: 6px 0; overflow-x: auto; }
.msg-body pre code { background: none; padding: 0; }
.msg-body a { color: var(--brand-2); }
.msg-body .mention { background: rgba(88,101,242,.25); color: #c7cbff; padding: 1px 4px; border-radius: 4px; font-weight: 600; }
.msg-body.has-mention { background: rgba(250,166,26,.08); margin: 0 -8px; padding: 4px 8px; border-radius: 6px; border-left: 2px solid var(--yellow); }
.msg-body h1, .msg-body h2, .msg-body h3 { margin: 4px 0; font-size: 18px; }
.msg-edited { font-size: 10px; color: var(--text-mute); margin-left: 4px; }
.msg-reply { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-mute); margin-bottom: 2px; }
.msg-reply .avatar { width: 16px; height: 16px; font-size: 8px; }
.msg-tools { position: absolute; right: 10px; top: -12px; display: none; gap: 2px; background: var(--bg-3); border: 1px solid var(--line); border-radius: 8px; padding: 2px; }
.msg:hover .msg-tools { display: flex; }
.msg-tools .icon-btn { width: 28px; height: 28px; font-size: 13px; }
.reactions { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 5px; }
.reaction { background: var(--bg-3); border: 1px solid var(--line); border-radius: 8px; padding: 2px 7px; font-size: 13px; display: flex; gap: 5px; align-items: center; }
.reaction.mine { border-color: var(--brand); background: rgba(88,101,242,.18); }

.divider { text-align: center; color: var(--text-mute); font-size: 12px; margin: 14px 0; position: relative; }
.divider::before { content: ''; position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: var(--line); }
.divider span { position: relative; background: var(--bg-2); padding: 0 12px; }

/* embeds do bot */
.embed { border-left: 4px solid var(--brand); background: var(--bg-3); border-radius: 6px; padding: 12px 14px; margin-top: 4px; max-width: 560px; }
.embed-title { font-weight: 700; margin-bottom: 6px; }
.embed-desc { font-size: 14px; color: #d3d8e3; line-height: 1.5; white-space: pre-wrap; }
.embed-fields { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 10px; }
.embed-field { grid-column: span 3; }
.embed-field.inline { grid-column: span 1; }
.embed-field-name { font-size: 12px; font-weight: 700; color: #fff; margin-bottom: 2px; }
.embed-field-value { font-size: 13px; color: var(--text-dim); white-space: pre-wrap; }
.embed-footer { margin-top: 10px; font-size: 11px; color: var(--text-mute); }
.embed-avatar { display: flex; justify-content: center; padding: 8px 0; }
.embed-music { margin-top: 10px; }
.embed-music audio { width: 100%; }
.invite-embed-actions { display: flex; gap: 8px; margin-top: 4px; flex-wrap: wrap; }
.invite-embed-resolved { font-size: 13px; font-weight: 600; margin-top: 4px; }
.invite-embed-resolved.accepted { color: var(--green); }
.invite-embed-resolved.declined { color: var(--text-mute); }

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

/* ---------------------------------------------------------- composer --- */
.composer { padding: 0 16px 20px; flex: none; }
.reply-bar { background: var(--bg-3); border-radius: 8px 8px 0 0; padding: 6px 12px; font-size: 12px; color: var(--text-dim); display: flex; align-items: center; justify-content: space-between; }
.composer-row { background: var(--bg-3); border-radius: 10px; display: flex; align-items: flex-end; padding: 4px 6px; gap: 4px; }
.composer-row textarea { flex: 1; background: none; border: 0; outline: none; resize: none; padding: 11px 4px; max-height: 200px; line-height: 1.4; }

/* ---------------------------------------------------------- membros ---- */
.members { width: var(--members-w); background: var(--bg-1); border-left: 1px solid var(--line); display: flex; flex-direction: column; }
.members-head { flex: none; padding: 14px 12px 10px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.members-head-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.members-head strong { font-size: 13px; color: var(--text-dim); }
.members-head-top .icon-btn { width: 26px; height: 26px; flex: none; }
.members-head input {
  background: var(--bg-0); border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 10px; font-size: 13px; color: var(--text); outline: none;
}
.members-head input:focus { border-color: var(--brand); }
#membersList { flex: 1; overflow-y: auto; padding: 10px 8px; }
.member-row { display: flex; align-items: center; gap: 9px; padding: 6px 8px; border-radius: 6px; width: 100%; text-align: left; transition: background .12s; }
.member-row:hover { background: var(--bg-2); }
.member-row .meta { min-width: 0; }
.member-row .nm { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-row .sub { font-size: 11px; color: var(--text-mute); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-row.offline { opacity: .45; }
.role-tag { font-size: 10px; padding: 2px 7px; border-radius: 4px; font-weight: 700; margin-left: auto; text-transform: uppercase; letter-spacing: .03em; }
.role-tag.role-owner { background: rgba(250,166,26,.16); color: var(--yellow); }
.role-tag.role-admin { background: rgba(237,66,69,.16); color: var(--red); }
.role-tag.role-mod { background: rgba(59,165,93,.16); color: var(--green); }
.role-owner { background: rgba(250,166,26,.18); color: var(--yellow); }
.role-admin { background: rgba(237,66,69,.16); color: #ff8285; }
.role-mod { background: rgba(88,101,242,.18); color: var(--brand-2); }

/* ------------------------------------------------------------ listas --- */
.empty { display: grid; place-items: center; height: 100%; text-align: center; color: var(--text-mute); gap: 10px; padding: 40px; }
.empty .big-icon { font-size: 48px; opacity: .5; }
.empty h3 { color: var(--text); font-size: 18px; }
.empty-badge {
  width: 68px; height: 68px; border-radius: 28%; display: grid; place-items: center;
  background: var(--brand-gradient); color: #fff; box-shadow: 0 14px 34px -12px rgba(155,77,255,.55);
  margin-bottom: 4px;
}
.empty-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 8px; }

.friend-tabs { display: flex; gap: 6px; padding: 12px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.friend-tab { padding: 5px 12px; border-radius: 6px; font-size: 14px; font-weight: 600; color: var(--text-dim); }
.friend-tab:hover { background: var(--bg-3); color: var(--text); }
.friend-tab.active { background: var(--bg-4); color: #fff; }
.friend-tab.cta { background: var(--green); color: #fff; }
.friend-list { padding: 8px 16px 24px; overflow-y: auto; flex: 1; }
.friend-row { display: flex; align-items: center; gap: 12px; padding: 10px 8px; border-bottom: 1px solid var(--line); }
.friend-row .meta { flex: 1; min-width: 0; }
.friend-row .nm { font-weight: 600; }
.friend-row .sub { font-size: 12px; color: var(--text-mute); }
.friend-row .acts { display: flex; gap: 6px; }

/* ------------------------------------------------------------ modal ---- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.72); display: grid; place-items: center; z-index: 60; padding: 20px; }
.modal { background: var(--bg-1); border: 1px solid var(--glass-border); border-radius: 18px; width: min(560px, 100%); max-height: 86vh; overflow: auto; box-shadow: 0 30px 70px -30px rgba(0,0,0,.7); }
.modal-head { padding: 20px 22px 6px; }
.modal-head h2 { font-size: 20px; }
.modal-head p { color: var(--text-dim); font-size: 13px; margin-top: 5px; }
.modal-body { padding: 16px 22px; }
.modal-foot { padding: 14px 22px 20px; display: flex; gap: 10px; justify-content: flex-end; background: var(--bg-1); border-top: 1px solid var(--line); position: sticky; bottom: 0; }
.modal .tabs { display: flex; gap: 4px; padding: 0 22px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.modal .tab { padding: 9px 12px; font-size: 13px; font-weight: 600; color: var(--text-dim); border-bottom: 2px solid transparent; }
.modal .tab.active { color: #fff; border-color: var(--brand); }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.switch-row .txt strong { display: block; font-size: 14px; }
.switch-row .txt small { color: var(--text-mute); font-size: 12px; }
.switch { width: 42px; height: 24px; border-radius: 12px; background: var(--bg-4); position: relative; flex: none; transition: background .18s; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .18s; }
.switch.on { background: var(--green); }
.switch.on::after { transform: translateX(18px); }

.cmd-group { margin-bottom: 18px; }
.cmd-group h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--brand-2); margin-bottom: 8px; }
.cmd { display: flex; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.cmd code { background: var(--bg-0); padding: 2px 7px; border-radius: 5px; color: var(--brand-2); flex: none; align-self: flex-start; font-family: var(--font-mono); }
.cmd span { color: var(--text-dim); }

.theme-picker { display: flex; gap: 8px; }
.theme-option {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 12px 8px; border-radius: 10px; background: var(--bg-0); border: 1px solid var(--line);
  color: var(--text-dim); font-size: 12px; transition: border-color .15s, color .15s;
}
.theme-option:hover { color: var(--text); }
.theme-option.active { border-color: var(--brand); color: var(--brand-2); }
.guild-options { display: flex; flex-direction: column; gap: 10px; }
.guild-option {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  padding: 14px; border-radius: 10px; background: var(--bg-1); border: 1px solid var(--line);
  color: var(--brand-2); transition: background .15s, border-color .15s;
}
.guild-option:hover { background: var(--bg-3); border-color: var(--brand); }
.guild-option strong { display: block; color: var(--text); font-size: 14px; }
.guild-option span:last-child { display: block; color: var(--text-mute); font-size: 12px; margin-top: 2px; }
.invite-friend-list { max-height: 200px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.invite-friend-row { display: flex; align-items: center; gap: 10px; padding: 6px 4px; }
.invite-friend-row .name { flex: 1; font-size: 14px; }
.invite-friend-row.done { color: var(--green); font-size: 13px; padding: 8px 4px; }
.invite-box { display: flex; gap: 8px; }
.invite-box input { flex: 1; background: var(--bg-0); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-family: var(--font-mono); color: var(--text); }

/* -------------------------------------------------------- avatar source - */
.avatar-source-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

/* --------------------------------------------------- editor de foto --- */
.photo-editor, .camera-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.82); display: grid; place-items: center; z-index: 85; padding: 20px; }
.photo-editor-card, .camera-card { background: var(--bg-2); border: 1px solid var(--line); border-radius: 16px; padding: 22px; width: min(420px, 100%); display: grid; gap: 16px; animation: rise .2s ease; }
.photo-editor-card h3, .camera-card h3 { font-size: 17px; }
.photo-editor-canvas-wrap {
  /* Mesma moldura arredondada-quadrada do avatar de verdade (nao um
     circulo) — senao o recorte mostrado aqui nao bate com o resultado. */
  position: relative; width: 260px; height: 260px; margin: 0 auto; border-radius: 28%;
  overflow: hidden; border: 2px solid var(--line); cursor: grab; touch-action: none; background: var(--bg-0);
}
.photo-editor-canvas-wrap:active { cursor: grabbing; }
.photo-editor-canvas-wrap canvas { width: 100%; height: 100%; display: block; }
.photo-editor-controls { display: flex; flex-direction: column; gap: 12px; }
.photo-editor-row { display: flex; align-items: center; gap: 10px; }
.photo-editor-row input[type="range"] {
  flex: 1; -webkit-appearance: none; appearance: none; height: 4px; border-radius: 2px;
  background: var(--bg-4); outline: none; cursor: pointer;
}
.photo-editor-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%;
  background: var(--brand-gradient); border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.4);
  cursor: pointer; margin-top: -1px;
}
.photo-editor-row input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%; background: var(--brand-gradient);
  border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.4); cursor: pointer;
}
.photo-editor-row input[type="range"]::-moz-range-track { background: var(--bg-4); height: 4px; border-radius: 2px; }
.photo-editor-row .lbl { font-size: 12px; color: var(--text-mute); width: 46px; flex: none; }
.filter-row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.filter-swatch { width: 44px; height: 44px; border-radius: 50%; overflow: hidden; border: 2px solid transparent; padding: 0; background: var(--bg-0); flex: none; }
.filter-swatch.active { border-color: var(--brand); }
.filter-swatch img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-editor-actions, .camera-actions { display: flex; gap: 10px; justify-content: flex-end; }
.camera-card video { width: 100%; border-radius: 12px; background: #000; display: block; transform: scaleX(-1); }
.camera-actions { justify-content: center; }

/* -------------------------------------------------------- ring/toast --- */
.ring { position: fixed; inset: 0; background: rgba(0,0,0,.8); display: grid; place-items: center; z-index: 80; }
.ring-card { background: var(--bg-2); border: 1px solid var(--line); border-radius: 16px; padding: 32px 40px; text-align: center; display: grid; justify-items: center; gap: 10px; animation: rise .25s ease; }
@keyframes rise { from { transform: translateY(14px); opacity: 0; } }
.ring-card h2 { font-size: 20px; }
.ring-card p { color: var(--text-dim); font-size: 14px; }
.ring-actions { display: flex; gap: 12px; margin-top: 12px; }

.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 90; }
.toast { background: var(--bg-3); border: 1px solid var(--line); border-left: 3px solid var(--brand); padding: 11px 16px; border-radius: 8px; font-size: 13px; max-width: 330px; animation: rise .2s ease; box-shadow: 0 8px 24px rgba(0,0,0,.4); }
.toast.err { border-left-color: var(--red); }
.toast.ok { border-left-color: var(--green); }

/* ------------------------------------------------------------ mobile --- */
@media (max-width: 860px) {
  .app { grid-template-columns: var(--rail-w) 1fr; }
  .sidebar { position: absolute; left: var(--rail-w); top: 0; bottom: 0; width: var(--side-w); z-index: 20; }
  .app.chat-open .sidebar { display: none; }
  .app:not(.chat-open) .main { display: none; }
  .members { position: absolute; right: 0; top: 0; bottom: 0; z-index: 25; }
  .only-mobile { display: grid; }
}
