/* MiniCord — visual inspirado no Discord (tema escuro) */

:root {
  --bg1: #313338;
  --bg2: #2b2d31;
  --bg3: #1e1f22;
  --bg4: #111214;
  --userpanel: #232428;
  --hover: #35373c;
  --active: #404249;
  --input: #383a40;
  --text: #dbdee1;
  --head: #f2f3f5;
  --muted: #949ba4;
  --faint: #6d6f78;
  --brand: #5865f2;
  --brand-h: #4752c4;
  --green: #23a55a;
  --green-h: #1a8a49;
  --red: #f23f43;
  --yellow: #f0b232;
  --line: #1f2023;
  --elev: #2f3136;
  --elev-h: #3b3d44;
  --btn2: #4e5058;
  --btn2-h: #6d6f78;
  --divider: #3f4147;
  --toast: #111214;
  --scroll: #1a1b1e;
  --chat-fs: 16px;
  --font: "gg sans", "Noto Sans", "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.375;
  color: var(--text);
  background: var(--bg3);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, select, textarea { font: inherit; color: var(--text); }
a { color: #00a8fc; text-decoration: none; }
a:hover { text-decoration: underline; }
kbd { background: var(--bg3); border-radius: 4px; padding: 1px 6px; font-size: 12px; border: 1px solid var(--divider); }
.grow { flex: 1; }

.ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ic.red { color: var(--red); }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--scroll); border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- controles de formulário ---------- */
.lbl { display: block; margin: 16px 0 8px; font-size: 12px; font-weight: 700; letter-spacing: .02em; color: var(--muted); }
.lbl .val { color: var(--head); font-weight: 600; margin-left: 4px; }
input:not([type]), input[type="text"], input[type="password"], select {
  width: 100%;
  height: 40px;
  background: var(--bg3);
  border: 0;
  border-radius: 3px;
  padding: 0 10px;
  outline: none;
}
select { cursor: pointer; }
input:not([type]):focus, input[type="password"]:focus, select:focus { box-shadow: 0 0 0 1px var(--brand); }
input[type="radio"], input[type="checkbox"] { accent-color: var(--brand); }
input[type="range"] { width: 100%; accent-color: var(--brand); cursor: pointer; }
input[type="range"]:disabled { opacity: .4; cursor: not-allowed; }
.error { margin: 10px 0 0; min-height: 1.2em; color: #ff8b8e; font-size: 13px; }
.hint { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.hint.strong { color: var(--text); background: var(--bg2); border-radius: 6px; padding: 10px 12px; margin-top: 16px; }

.btn { height: 38px; padding: 0 16px; border-radius: 3px; font-size: 14px; font-weight: 500; transition: background .15s; white-space: nowrap; }
.btn.big { height: 44px; width: 100%; margin-top: 20px; font-size: 16px; }
.btn.brand { background: var(--brand); color: #fff; }
.btn.brand:hover:not(:disabled) { background: var(--brand-h); }
.btn.green { background: var(--green); color: #fff; }
.btn.green:hover:not(:disabled) { background: var(--green-h); }
.btn.secondary { background: var(--btn2); color: #fff; }
.btn.secondary:hover:not(:disabled) { background: var(--btn2-h); }
.btn.danger { background: var(--red); color: #fff; }
.btn.danger:hover:not(:disabled) { background: #c93236; }
.btn.link { color: #fff; }
.btn.link:hover { text-decoration: underline; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0 0; }

.icon-btn { width: 32px; height: 32px; border-radius: 4px; display: grid; place-items: center; color: var(--muted); transition: background .12s, color .12s; flex: none; }
.icon-btn:hover { background: rgba(255, 255, 255, .08); color: var(--head); }
.icon-btn.on { color: var(--head); background: rgba(255, 255, 255, .12); }
.icon-btn.off { color: var(--red); }

.color-row { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { width: 34px; height: 34px; border-radius: 50%; border: 3px solid transparent; transition: transform .1s; }
.swatch:hover { transform: scale(1.1); }
.swatch.sel { border-color: #fff; }

/* interruptores */
.switch { position: relative; width: 40px; height: 24px; flex: none; }
.switch input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; z-index: 1; }
.switch i { position: absolute; inset: 0; background: #80848e; border-radius: 12px; transition: background .15s; }
.switch i::after { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + i { background: var(--green); }
.switch input:checked + i::after { transform: translateX(16px); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 14px 0; border-bottom: 1px solid var(--divider); }
.row-t { font-weight: 500; color: var(--head); }
.row-d { font-size: 13px; color: var(--muted); margin-top: 2px; }

/* controle segmentado */
.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg button { padding: 9px 16px; border-radius: 4px; background: var(--bg3); font-size: 14px; font-weight: 500; transition: background .12s; border: 1px solid transparent; }
.seg button:hover { background: var(--hover); }
.seg button.active { background: var(--brand); color: #fff; }

.check { display: flex; align-items: center; gap: 10px; font-size: 14px; margin-top: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; }

/* ---------- login ---------- */
#login {
  height: 100dvh;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    radial-gradient(900px 600px at 15% 10%, var(--brand) 0%, transparent 60%),
    radial-gradient(800px 600px at 90% 95%, var(--brand-h) 0%, transparent 60%),
    #23272f;
}
.login-card {
  width: min(480px, 100%);
  background: var(--bg1);
  border-radius: 6px;
  padding: 32px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .4);
}
.login-card h1 { margin: 12px 0 4px; font-size: 24px; text-align: center; color: var(--head); }
.login-sub { margin: 0 0 8px; text-align: center; color: var(--muted); }
#login.auto .login-card { visibility: hidden; } /* entrando com a sessão salva: não pisca o formulário */
.account-row { margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--line); }
.login-switch { margin: 12px 0 0; font-size: 14px; color: var(--muted); }
.link-btn { color: var(--link, #00a8fc); font: inherit; padding: 0; background: none; border: 0; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.login-logo { width: 64px; height: 64px; margin: 0 auto; border-radius: 20px; display: grid; place-items: center; background: var(--brand); color: #fff; font-size: 34px; font-weight: 800; }

/* ---------- layout do app ---------- */
#app { display: grid; grid-template-columns: 72px 240px minmax(0, 1fr); height: 100dvh; position: relative; }

#rail { background: var(--bg3); display: flex; flex-direction: column; align-items: center; padding: 12px 0; gap: 8px; overflow-y: auto; }
.rail-item { position: relative; width: 72px; display: grid; place-items: center; }
.server-icon { width: 48px; height: 48px; border-radius: 24px; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: 22px; font-weight: 800; transition: border-radius .15s, background .15s; }
.rail-item.active .server-icon { border-radius: 16px; }
.rail-item:hover .server-icon { border-radius: 16px; }
.server-icon.plus { background: var(--bg1); color: var(--green); }
.rail-item:hover .server-icon.plus { background: var(--green); color: #fff; }
.pill { position: absolute; left: 0; width: 4px; height: 40px; border-radius: 0 4px 4px 0; background: #fff; }
.rail-sep { width: 32px; height: 2px; border-radius: 1px; background: var(--bg1); }

#sidebar { background: var(--bg2); display: flex; flex-direction: column; min-height: 0; border-radius: 8px 0 0 0; }
.side-head { height: 48px; padding: 0 16px; display: flex; align-items: center; border-bottom: 1px solid var(--line); box-shadow: 0 1px 0 rgba(2, 2, 2, .2); }
.side-head h2 { margin: 0; font-size: 16px; font-weight: 700; color: var(--head); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

#channelList { flex: 1; overflow-y: auto; padding: 8px 8px 12px; min-height: 0; }
.cat { display: flex; align-items: center; justify-content: space-between; padding: 16px 8px 4px 2px; color: var(--muted); }
.cat-title { font-size: 12px; font-weight: 700; letter-spacing: .02em; }
.cat-add { width: 18px; height: 18px; display: grid; place-items: center; color: var(--muted); }
.cat-add:hover { color: var(--head); }
.cat-add .ic { width: 16px; height: 16px; }

.chan { display: flex; align-items: center; gap: 6px; height: 34px; padding: 0 8px; margin-top: 2px; border-radius: 4px; color: var(--muted); cursor: pointer; user-select: none; }
.chan:hover { background: var(--hover); color: var(--text); }
.chan.active { background: var(--active); color: var(--head); }
.chan.unread { color: var(--head); font-weight: 600; }
.chan.connected .chan-ic { color: var(--green); }
.chan-ic { color: var(--faint); }
.chan-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.chan-lock { width: 14px; height: 14px; color: var(--faint); }
.chan-edit { width: 18px; height: 18px; color: var(--muted); display: none; }
.chan-edit .ic { width: 16px; height: 16px; }
.chan:hover .chan-edit { display: grid; place-items: center; }
.chan-edit:hover { color: var(--head); }
.badge { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--red); color: #fff; font-size: 12px; font-weight: 700; display: grid; place-items: center; }

.vlist { padding: 0 0 4px 22px; }
.vmember { display: flex; align-items: center; gap: 8px; height: 30px; padding: 0 8px; border-radius: 4px; color: var(--muted); }
.vmember:hover { background: var(--hover); color: var(--text); }
.vavatar { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; color: #fff; flex: none; transition: box-shadow .1s; }
.vavatar.speaking { box-shadow: 0 0 0 2px var(--green); }
.vname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; font-weight: 500; }
.vicons { display: flex; gap: 4px; align-items: center; }
.vicons .ic { width: 15px; height: 15px; }
.live { background: var(--red); color: #fff; font-size: 10px; font-weight: 800; letter-spacing: .03em; padding: 2px 5px; border-radius: 4px; }

/* dock de voz + painel do usuário */
#voiceDock { background: var(--userpanel); border-top: 1px solid var(--line); padding: 8px 8px 6px; }
.dock-top { display: flex; align-items: center; gap: 8px; }
.dock-info { flex: 1; min-width: 0; }
.dock-status { display: flex; align-items: center; gap: 6px; color: var(--green); font-size: 14px; font-weight: 600; }
.dock-status .ic { width: 16px; height: 16px; }
.dock-time { margin-left: auto; color: var(--muted); font-weight: 500; font-size: 12px; font-variant-numeric: tabular-nums; }
.dock-chan { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dock-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 8px; }
.dock-btn { height: 32px; border-radius: 4px; background: var(--elev); display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 13px; font-weight: 500; color: var(--text); }
.dock-btn:hover { background: var(--elev-h); }
.dock-btn.active { background: var(--green); color: #fff; }
.dock-btn.off { color: #ff9a9c; }
.dock-btn .ic { width: 17px; height: 17px; }

#userPanel { height: 52px; flex: none; background: var(--userpanel); display: flex; align-items: center; gap: 2px; padding: 0 8px; }
.up-user { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; padding: 4px; border-radius: 4px; text-align: left; }
.up-user:hover { background: rgba(255, 255, 255, .06); }
.up-avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: #fff; flex: none; }
.up-text { min-width: 0; line-height: 1.15; }
.up-name { font-size: 14px; font-weight: 600; color: var(--head); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-status { font-size: 12px; color: var(--muted); }

/* ---------- área principal ---------- */
#main { background: var(--bg1); display: flex; flex-direction: column; min-width: 0; min-height: 0; }
#mainHeader { height: 48px; flex: none; display: flex; align-items: center; gap: 8px; padding: 0 12px 0 16px; border-bottom: 1px solid var(--line); box-shadow: 0 1px 0 rgba(2, 2, 2, .15); }
#mhIcon { display: grid; color: var(--faint); }
#mhName { margin: 0; font-size: 16px; font-weight: 700; color: var(--head); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mh-sub { color: var(--muted); font-size: 14px; padding-left: 10px; margin-left: 4px; border-left: 1px solid var(--divider); white-space: nowrap; }
.mh-sub:empty { display: none; }
.mh-actions { margin-left: auto; display: flex; gap: 4px; }
.only-mobile { display: none; }

#content { flex: 1; display: flex; min-height: 0; }
#emptyView { flex: 1; display: grid; place-items: center; color: var(--muted); }

#textView { flex: 1; display: flex; min-width: 0; }
#textMain { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
#membersPanel { width: 240px; flex: none; background: var(--bg2); padding: 8px 8px 16px; overflow-y: auto; }
.mp-title:first-child { padding-top: 12px; }
.mp-title { padding: 20px 8px 6px; font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: .02em; }
.member { display: flex; align-items: center; gap: 12px; padding: 6px 8px; border-radius: 4px; color: var(--muted); }
.member:hover { background: var(--hover); }
.member .vavatar { width: 32px; height: 32px; font-size: 14px; }
.member-text { min-width: 0; line-height: 1.2; }
.member-name { font-weight: 500; color: var(--head); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* chat */
.chatpane { display: flex; flex-direction: column; flex: 1; min-height: 0; min-width: 0; }
.ctitle { display: none; align-items: center; gap: 8px; height: 40px; padding: 0 16px; font-weight: 700; color: var(--head); border-bottom: 1px solid var(--line); flex: none; }
.chatpane.in-voice .ctitle { display: flex; }
#messages { flex: 1; overflow-y: auto; padding: 8px 0 8px; display: flex; flex-direction: column; min-height: 0; }
#messages::before { content: ""; flex: 1; } /* mensagens ficam coladas embaixo, como no Discord */
.msg { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 16px; padding: 2px 16px 2px 16px; }
.msg:not(.grouped) { margin-top: 16px; }
.msg:hover { background: rgba(2, 2, 2, .06); }
.m-av { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: #fff; margin-top: 2px; }
.m-av.ghost { visibility: hidden; height: 0; }
.m-head { display: flex; align-items: baseline; gap: 8px; }
.m-name { font-size: 16px; font-weight: 500; }
.m-head time { font-size: 12px; color: var(--muted); }
.m-text { overflow-wrap: anywhere; white-space: pre-wrap; color: var(--text); }
.chat-empty { margin: auto; padding: 24px; text-align: center; color: var(--muted); }

#chatForm { padding: 0 16px 24px; flex: none; }
#chatInput { height: 44px; background: var(--input); border-radius: 8px; padding: 0 16px; }
#chatInput:focus { box-shadow: none; }

/* ---------- chamada de voz ---------- */
#voiceView { flex: 1; display: flex; min-width: 0; background: #000; }
#voiceStage { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }
#voiceChatSlot { width: 340px; flex: none; display: flex; flex-direction: column; background: var(--bg1); border-left: 1px solid var(--line); min-height: 0; }

#voicePreview { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px; gap: 4px; background: var(--bg1); }
.vp-ic { width: 72px; height: 72px; border-radius: 50%; background: var(--bg3); display: grid; place-items: center; color: var(--muted); margin-bottom: 8px; }
.vp-ic .ic { width: 34px; height: 34px; }
#voicePreview h2 { margin: 0; font-size: 24px; color: var(--head); }
#voicePreview p { margin: 0; color: var(--muted); }
#vpAvatars { display: flex; gap: 8px; margin: 14px 0 8px; flex-wrap: wrap; justify-content: center; }
#vpAvatars .vavatar { width: 44px; height: 44px; font-size: 18px; }
#voicePreview .btn { width: auto; padding: 0 28px; margin-top: 12px; }

#grid { flex: 1; display: grid; gap: 10px; padding: 16px; min-height: 0; min-width: 0; }
/* palco: o fixado em cima, do tamanho exato do vídeo (sem faixa preta), e as pessoas numa fileira embaixo.
   --pw/--ph/--sw são calculados em layoutStage() */
#grid.has-pin { display: flex; flex-wrap: wrap; justify-content: center; align-content: center; overflow: hidden; }
#grid.has-pin .tile { flex: none; width: var(--sw, 200px); height: calc(var(--sw, 200px) * 9 / 16); }
#grid.has-pin .tile.pinned { order: -1; width: var(--pw, 100%); height: var(--ph, 70%); margin: 0 calc((100% - var(--pw, 100%)) / 2); }
#grid.has-pin .tile:not(.pinned) .label { font-size: 12px; padding: 2px 6px; left: 6px; bottom: 6px; }
#grid.has-pin .tile:not(.pinned) .stats { display: none; }
.tools .stop { width: auto; padding: 0 10px; background: var(--red); font-size: 13px; font-weight: 600; }
.tools .stop:hover { background: var(--red); filter: brightness(1.1); }

.tile { position: relative; background: var(--bg3); border-radius: 8px; overflow: hidden; min-width: 0; min-height: 0; }
.tile video { width: 100%; height: 100%; object-fit: cover; display: block; background: #000; }
.tile.screen video { object-fit: contain; }
.tile.local.cam video { transform: scaleX(-1); }
.tile.no-video video { visibility: hidden; }
.tile:not(.no-video) .avatar { display: none; }
.avatar { position: absolute; inset: 0; display: grid; place-items: center; background: var(--bg2); }
.avatar span { width: min(104px, 42%); aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; font-size: 44px; font-weight: 700; color: #fff; }
.tile::after { content: ""; position: absolute; inset: 0; border-radius: inherit; border: 3px solid transparent; pointer-events: none; transition: border-color .1s; }
.tile.speaking::after { border-color: var(--green); }

.label { position: absolute; left: 8px; bottom: 8px; max-width: calc(100% - 16px); display: flex; align-items: center; gap: 6px; background: rgba(0, 0, 0, .65); padding: 3px 8px; border-radius: 4px; font-size: 14px; font-weight: 500; color: #fff; }
.label .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.label .badges { display: inline-flex; }
.label .badges:empty { display: none; }
.label .ic { width: 15px; height: 15px; }

.stats { position: absolute; top: 8px; left: 8px; background: rgba(0, 0, 0, .7); color: #fff; padding: 3px 9px; border-radius: 4px; font-size: 12px; font-variant-numeric: tabular-nums; z-index: 2; }
.stats.warn { color: #ffd479; }

.tools { position: absolute; top: 8px; right: 8px; display: flex; gap: 4px; align-items: center; background: rgba(0, 0, 0, .65); padding: 4px 6px; border-radius: 6px; opacity: 0; transition: opacity .15s; z-index: 3; }
.tile:hover .tools, .tools:focus-within { opacity: 1; }
@media (hover: none) { .tools { opacity: .9; } }
.tools button { width: 26px; height: 26px; border-radius: 4px; display: grid; place-items: center; color: #fff; }
.tools button:hover, .tools button.active { background: rgba(255, 255, 255, .22); }
.tools .ic { width: 16px; height: 16px; }
.vol { width: 80px !important; height: auto !important; background: none !important; padding: 0 !important; }

#callBar { flex: none; display: flex; justify-content: center; gap: 12px; padding: 4px 16px 18px; }
.cb { width: 48px; height: 48px; border-radius: 50%; background: #2b2d31; display: grid; place-items: center; color: #fff; transition: background .15s, transform .1s; }
.cb:hover { background: #404249; }
.cb:active { transform: scale(.94); }
.cb.off { background: #fff; color: #1e1f22; }
.cb.off:hover { background: #e3e5e8; }
.cb.active { background: var(--green); color: #fff; }
.cb.leave { background: var(--red); color: #fff; width: 56px; border-radius: 24px; }
.cb.leave:hover { background: #c93236; }

/* ---------- toasts ---------- */
#toasts { position: fixed; top: 60px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 300; pointer-events: none; }
.toast { background: var(--toast); border: 1px solid var(--divider); padding: 9px 16px; border-radius: 8px; font-size: 14px; font-weight: 500; box-shadow: 0 8px 24px rgba(0, 0, 0, .45); animation: pop .2s ease-out; transition: opacity .4s; }
.toast.out { opacity: 0; }
@keyframes pop { from { transform: translateY(-8px); opacity: 0; } }

/* ---------- modais ---------- */
.modal { background: var(--bg1); color: var(--text); border: 0; border-radius: 6px; padding: 0; width: min(440px, 94vw); box-shadow: 0 8px 40px rgba(0, 0, 0, .6); }
.modal.small { width: min(400px, 94vw); }
.modal::backdrop { background: rgba(0, 0, 0, .7); }
.modal .m-head { display: block; padding: 20px 20px 4px; } /* o .m-head do chat é flex; nos diálogos o título fica em cima da descrição */
.modal .m-head h2 { margin: 0; font-size: 22px; color: var(--head); }
.modal .m-head p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.m-body { padding: 4px 20px 20px; }
.m-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 16px 20px; background: var(--bg2); }
.opt { display: flex; align-items: center; gap: 12px; padding: 12px; margin-bottom: 8px; border-radius: 6px; background: var(--bg2); cursor: pointer; }
.opt:hover { background: var(--elev); }
.opt:has(input:checked) { background: var(--active); }
.opt span { display: grid; line-height: 1.25; }
.opt small { color: var(--muted); font-size: 13px; }
.opt input { margin-left: auto; order: 3; width: 18px; height: 18px; }
.opt .ic { color: var(--muted); }

/* ---------- configurações ---------- */
#settings { position: fixed; inset: 0; z-index: 200; display: flex; background: var(--bg1); }
.st-nav { width: 30%; min-width: 218px; flex: none; background: var(--bg2); padding: 60px 6px 20px 20px; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; overflow-y: auto; }
.st-nav > * { width: 190px; max-width: 100%; }
.st-group { font-size: 12px; font-weight: 700; color: var(--muted); padding: 6px 10px; }
.st-nav button { text-align: left; padding: 7px 10px; border-radius: 4px; color: var(--muted); font-weight: 500; font-size: 15px; }
.st-nav button:hover { background: var(--hover); color: var(--text); }
.st-nav button.active { background: var(--active); color: var(--head); }
.st-body { flex: 1; position: relative; overflow-y: auto; padding: 60px 40px 80px; }
.st-body section { max-width: 700px; }
.st-body h1 { margin: 0 0 16px; font-size: 20px; color: var(--head); }
.st-body h3 { margin: 28px 0 4px; font-size: 14px; font-weight: 700; color: var(--head); text-transform: uppercase; letter-spacing: .02em; }
.st-close { position: fixed; top: 60px; right: 40px; width: 36px; display: grid; justify-items: center; gap: 4px; color: var(--muted); }
.st-close .ic { width: 36px; height: 36px; padding: 8px; border: 2px solid var(--muted); border-radius: 50%; }
.st-close span { font-size: 13px; font-weight: 700; }
.st-close:hover { color: var(--head); }
.st-close:hover .ic { border-color: var(--head); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

.profile-card { display: flex; align-items: flex-end; gap: 16px; background: var(--bg2); border-radius: 8px; padding: 16px; margin-bottom: 8px; }
.profile-card .lbl { margin-top: 0; }
.big-av { width: 80px; height: 80px; border-radius: 50%; display: grid; place-items: center; font-size: 36px; font-weight: 700; color: #fff; flex: none; }

.meter { position: relative; height: 12px; margin: 14px 0 4px; background: var(--bg3); border-radius: 6px; overflow: hidden; }
#meterFill { height: 100%; width: 0; background: var(--green); border-radius: 6px; transition: width .05s linear; }
#meterFill.closed { background: #5c5f66; }
#meterThresh { position: absolute; top: 0; bottom: 0; width: 3px; background: var(--yellow); left: 50%; }

.cam-box { margin-top: 12px; aspect-ratio: 16/9; max-width: 420px; background: #000; border-radius: 8px; display: grid; place-items: center; position: relative; overflow: hidden; color: var(--muted); }
.cam-box video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); display: none; }
.cam-box.live video { display: block; }
.cam-box.live #camHint { display: none; }

/* ---------- celular ---------- */
#navBackdrop { display: none; }
@media (max-width: 860px) {
  #app { grid-template-columns: minmax(0, 1fr); }
  #rail { display: none; }
  #sidebar { position: fixed; inset: 0 auto 0 0; width: min(320px, 86vw); z-index: 60; transform: translateX(-102%); transition: transform .2s; border-radius: 0; box-shadow: 4px 0 24px rgba(0, 0, 0, .5); }
  body.nav-open #sidebar { transform: none; }
  body.nav-open #navBackdrop { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .55); z-index: 50; }
  .only-mobile { display: grid; }
  #membersPanel { display: none; }
  #voiceChatSlot { position: absolute; inset: 0; width: auto; z-index: 20; }
  #voiceView { position: relative; }
  #grid { padding: 8px; gap: 8px; }
  #grid.has-pin { flex-flow: row wrap; align-content: flex-start; overflow-y: auto; }
  #grid.has-pin .tile { width: calc(50% - 4px); height: 110px; }
  #grid.has-pin .tile.pinned { width: 100%; height: 55%; margin: 0; }
  .st-nav { width: 100%; min-width: 0; padding: 12px; flex-direction: row; flex-wrap: wrap; align-items: center; position: absolute; top: 0; left: 0; right: 0; z-index: 2; }
  .st-nav > * { width: auto; }
  .st-group { display: none; }
  .st-body { padding: 110px 16px 60px; }
  .st-close { top: 12px; right: 12px; }
  .two { grid-template-columns: 1fr; gap: 0; }
  #settings { flex-direction: column; }
  .pf-preview { width: 100%; }
}

/* ================================================================
   Temas (o padrão é o "escuro" definido em :root)
   ================================================================ */
html[data-theme="midnight"] {
  --bg1: #000000; --bg2: #0b0b0d; --bg3: #000000; --bg4: #000000; --userpanel: #101012;
  --hover: #18181b; --active: #232328; --input: #151518;
  --text: #d4d6da; --head: #ffffff; --muted: #8b8f98; --faint: #5d6068;
  --line: #17171a; --elev: #16161a; --elev-h: #202026; --btn2: #2a2b30; --btn2-h: #3a3b42;
  --divider: #232328; --toast: #0b0b0d; --scroll: #232328;
}
html[data-theme="light"] {
  --bg1: #ffffff; --bg2: #f2f3f5; --bg3: #e3e5e8; --bg4: #d4d7dc; --userpanel: #ebedef;
  --hover: #e3e5e8; --active: #d4d7dc; --input: #e3e5e8;
  --text: #313338; --head: #060607; --muted: #5c5e66; --faint: #80848e;
  --line: #e1e2e6; --elev: #e3e5e8; --elev-h: #d4d7dc; --btn2: #4e5058; --btn2-h: #2e3338;
  --divider: #d9dbe0; --toast: #ffffff; --scroll: #c1c4cb;
}
html[data-theme="violet"] {
  --bg1: #1b1432; --bg2: #150f29; --bg3: #0e0a1e; --bg4: #0a0716; --userpanel: #120c24;
  --hover: #261d47; --active: #32265c; --input: #241b43;
  --text: #e4def5; --head: #ffffff; --muted: #a99ccf; --faint: #7d6fa6;
  --line: #0e0a1e; --elev: #261d47; --elev-h: #32265c; --btn2: #3d2f6e; --btn2-h: #55439a;
  --divider: #34296a; --toast: #0e0a1e; --scroll: #34296a;
  --brand: #7c4dff; --brand-h: #6a3de6;
}
html[data-theme="ocean"] {
  --bg1: #10243a; --bg2: #0c1c2e; --bg3: #07121f; --bg4: #050d17; --userpanel: #0a1828;
  --hover: #17324d; --active: #1f4163; --input: #163048;
  --text: #d9e6f5; --head: #ffffff; --muted: #8fa9c7; --faint: #637f9f;
  --line: #07121f; --elev: #17324d; --elev-h: #1f4163; --btn2: #285078; --btn2-h: #3a6c9f;
  --divider: #234a70; --toast: #07121f; --scroll: #234a70;
  --brand: #1c9cf6; --brand-h: #1580cc;
}
html[data-theme="forest"] {
  --bg1: #17261f; --bg2: #121f19; --bg3: #0b1511; --bg4: #08100d; --userpanel: #0f1a15;
  --hover: #1f3529; --active: #29452f; --input: #1d3226;
  --text: #dcebe2; --head: #ffffff; --muted: #94b3a1; --faint: #678675;
  --line: #0b1511; --elev: #1f3529; --elev-h: #29452f; --btn2: #335a40; --btn2-h: #46805a;
  --divider: #2b4a39; --toast: #0b1511; --scroll: #2b4a39;
  --brand: #2fa866; --brand-h: #238a52;
}
html[data-theme="light"] .tile { background: var(--bg3); }
html[data-theme="light"] .server-icon.plus { box-shadow: inset 0 0 0 1px var(--divider); }
html[data-theme="light"] .rail-sep { background: var(--divider); }

#messages .m-text { font-size: var(--chat-fs); }
#chatInput { font-size: var(--chat-fs); }

/* ================================================================
   Logo, avatares, perfil
   ================================================================ */
.login-logo { display: block; width: 72px; height: 72px; margin: 0 auto; border-radius: 20px; object-fit: contain; background: none; }
.server-icon.logo { background: none; overflow: hidden; }
.server-icon.logo img { width: 100%; height: 100%; display: block; object-fit: contain; }
.rail-item:hover .server-icon.logo { border-radius: 16px; }

textarea { width: 100%; background: var(--bg3); border: 0; border-radius: 3px; padding: 10px; outline: none; resize: vertical; min-height: 72px; line-height: 1.4; }
textarea:focus { box-shadow: 0 0 0 1px var(--brand); }
.btn.sm { height: 30px; padding: 0 12px; font-size: 13px; }
.saved { align-self: center; color: var(--green); font-size: 14px; font-weight: 500; }
.muted-s { font-weight: 400; opacity: .8; }

.av { position: relative; display: grid; place-items: center; border-radius: 50%; color: #fff; font-weight: 700; flex: none; background-size: cover; background-position: center; background-repeat: no-repeat; }
.av.has-img { background-size: cover !important; background-position: center !important; background-repeat: no-repeat !important; }
.sdot { position: absolute; right: -2px; bottom: -2px; width: 36%; height: 36%; min-width: 9px; min-height: 9px; border-radius: 50%; background: var(--green); border: 2px solid var(--bg2); }
.sdot.s-idle { background: var(--yellow); }
.sdot.s-dnd { background: var(--red); }
.sdot.s-off { background: #80848e; }
.member.offline { opacity: .38; }
.member.offline:hover { opacity: 1; }
.chan-ic.sm, .vmember .vname { cursor: default; }
.vmember, .member { cursor: pointer; }
.up-avatar .sdot { border-color: var(--userpanel); }
.vmember .vavatar .sdot { border-width: 2px; }
.member-sub.has-text { color: var(--text); }

/* cartão de perfil (prévia e janela flutuante) */
.pcard { width: 300px; background: var(--bg2); border-radius: 8px; overflow: hidden; border: 1px solid var(--line); box-shadow: 0 8px 28px rgba(0, 0, 0, .35); }
.pc-banner { height: 108px; background-size: cover; background-position: center; background-color: var(--brand); }
.pc-avwrap { position: relative; margin: -46px 0 0 16px; width: 92px; height: 92px; border-radius: 50%; background: var(--bg2); display: grid; place-items: center; }
.pc-avwrap .big-av { width: 80px; height: 80px; font-size: 34px; }
.pc-avwrap .sdot { right: 4px; bottom: 4px; width: 22px; height: 22px; border-width: 4px; border-color: var(--bg2); }
.pc-body { padding: 8px 16px 16px; }
.pc-name { font-size: 20px; font-weight: 700; color: var(--head); overflow-wrap: anywhere; }
.pc-status { color: var(--text); font-size: 14px; min-height: 1.2em; }
.pc-sec { margin-top: 12px; background: var(--bg1); border-radius: 8px; padding: 12px; }
.pc-h { font-size: 12px; font-weight: 700; color: var(--head); margin-bottom: 4px; letter-spacing: .02em; }
.pc-bio { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; color: var(--text); }
.pc-bio.empty { color: var(--muted); font-style: italic; }
#profilePop { position: fixed; z-index: 250; }

.pf-wrap { display: flex; gap: 28px; flex-wrap: wrap; align-items: flex-start; }
.pf-edit { flex: 1; min-width: 280px; }
.pf-preview { width: 300px; flex: none; }
.color-custom { display: flex; align-items: center; gap: 10px; margin-top: 12px; color: var(--muted); font-size: 14px; }
input[type="color"] { width: 38px; height: 34px; padding: 0; border: 0; border-radius: 6px; background: none; cursor: pointer; }

.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.theme-card { border: 2px solid var(--divider); border-radius: 8px; overflow: hidden; cursor: pointer; background: var(--bg2); text-align: left; transition: transform .1s, border-color .12s; }
.theme-card:hover { transform: translateY(-2px); }
.theme-card.sel { border-color: var(--brand); }
.theme-prev { display: flex; height: 56px; }
.theme-prev i { flex: 1; }
.theme-name { padding: 8px 10px; font-size: 14px; font-weight: 500; color: var(--head); }


/* ================================================================
   Servidores (lateral, convite)
   ================================================================ */
#guildList { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 100%; }
.rail-item { cursor: pointer; }
.server-icon.letter { color: #fff; font-size: 18px; letter-spacing: -.02em; }
.pill.small { height: 8px; }
.rail-item .pill { top: 50%; transform: translateY(-50%); }
.side-head { cursor: pointer; justify-content: space-between; gap: 8px; }
.side-head:hover { background: var(--hover); }
.side-head .chev { width: 18px; height: 18px; color: var(--muted); flex: none; }
.inline { display: flex; gap: 8px; }
.inline input { flex: 1; min-width: 0; }
.or { display: flex; align-items: center; gap: 10px; margin: 18px 0 4px; color: var(--faint); font-size: 12px; font-weight: 700; text-transform: uppercase; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--divider); }
#gdInvite { font-family: ui-monospace, Consolas, monospace; font-size: 18px; letter-spacing: .12em; font-weight: 700; }

/* personalização do servidor */
#guildDialog .m-body { max-height: 68vh; overflow-y: auto; }
.gd-row { align-items: center; margin-top: 8px; }
.gd-icon { width: 56px; height: 56px; border-radius: 18px; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 20px; background-size: cover; background-position: center; flex: none; }
.gd-banner { height: 80px; border-radius: 8px; background-size: cover; background-position: center; background-color: var(--brand); margin-top: 6px; }
.server-icon.img { background-size: cover; background-position: center; background-color: var(--bg2); }
.side-head.has-banner { height: 96px; align-items: flex-end; padding: 0 16px 10px; background-size: cover; background-position: center; position: relative; border-bottom: 0; }
.side-head.has-banner::before { content: ""; position: absolute; inset: 0; background: linear-gradient(to top, rgba(0, 0, 0, .65), rgba(0, 0, 0, 0) 70%); }
.side-head.has-banner > * { position: relative; }
.side-head.has-banner h2, .side-head.has-banner .chev { color: #fff; text-shadow: 0 1px 3px rgba(0, 0, 0, .7); }
.side-head.has-color:not(.has-banner) { box-shadow: inset 0 -3px 0 var(--gc); }

/* ---------- Início: DMs, amigos e "Ativo agora" ---------- */
.server-icon.home { background: var(--bg1); color: var(--text); }
.server-icon.home .ic { width: 24px; height: 24px; }
#homeBtn.active .server-icon.home, #homeBtn:hover .server-icon.home { background: var(--brand); color: #fff; border-radius: 16px; }
#homeBtn .pill { display: none; }
#homeBtn.active .pill { display: block; }
.rail-badge { position: absolute; right: 10px; bottom: -3px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: var(--red); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; border: 3px solid var(--bg3); }
.rail-badge[hidden] { display: none; }
.side-head.home-head { padding: 0 10px; }
.side-head.home-head h2 { font-size: 13px; font-weight: 500; color: var(--muted); background: var(--bg3); padding: 7px 10px; border-radius: 4px; width: 100%; text-align: center; }
.side-head.home-head .chev { display: none; }
.dm-nav { display: flex; align-items: center; gap: 12px; margin: 8px 8px 0; padding: 0 10px; height: 42px; border-radius: 4px; color: var(--muted); font-weight: 500; cursor: pointer; }
.dm-nav .ic { width: 22px; height: 22px; }
.dm-nav:hover { background: var(--hover); color: var(--text); }
.dm-nav.active { background: var(--active); color: var(--head); }
.dm-nav .badge { margin-left: auto; }
.dm-cat { margin-top: 12px; }
.dm-row { display: flex; align-items: center; gap: 12px; margin: 1px 8px; padding: 6px 8px; border-radius: 4px; color: var(--muted); cursor: pointer; position: relative; }
.dm-row:hover { background: var(--hover); color: var(--text); }
.dm-row.active { background: var(--active); color: var(--head); }
.dm-row.unread .dm-name { color: var(--head); font-weight: 700; }
.dm-row .vavatar { width: 32px; height: 32px; font-size: 14px; flex: none; }
.dm-text { min-width: 0; flex: 1; line-height: 1.25; }
.dm-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.dm-sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm-group { display: grid; place-items: center; color: #fff; }
.dm-group .ic { width: 16px; height: 16px; }
.dm-leave { display: none; width: 20px; height: 20px; color: var(--muted); border-radius: 4px; }
.dm-row:hover .dm-leave { display: grid; place-items: center; }
.dm-leave:hover { color: var(--head); }
.dm-leave .ic { width: 14px; height: 14px; }
.dm-empty { padding: 8px 18px; font-size: 13px; color: var(--muted); line-height: 1.4; }

.fr-tabs { display: flex; align-items: center; gap: 8px; margin-left: 16px; padding-left: 16px; border-left: 1px solid var(--line); min-width: 0; }
.fr-tabs[hidden] { display: none; }
.fr-tabs button { padding: 0 10px; height: 28px; border-radius: 4px; color: var(--muted); font-weight: 500; white-space: nowrap; display: inline-flex; align-items: center; }
.fr-tabs button:hover { background: var(--hover); color: var(--text); }
.fr-tabs button.active { background: var(--active); color: var(--head); }
.fr-tabs button.add { background: var(--brand); color: #fff; }
.fr-tabs button.add.active { background: none; color: var(--green); }
.tab-badge { background: var(--red); color: #fff; border-radius: 8px; padding: 0 5px; font-size: 11px; margin-left: 6px; line-height: 16px; }
.tab-badge[hidden] { display: none; }

#friendsView { flex: 1; display: flex; min-width: 0; min-height: 0; background: var(--bg1); }
#friendsView[hidden] { display: none; }
.fr-main { flex: 1; min-width: 0; padding: 16px 24px; overflow-y: auto; }
.fr-search { position: relative; margin-bottom: 16px; }
.fr-search[hidden] { display: none; }
.fr-search input { padding-right: 36px; }
.fr-search .ic { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.fr-title { font-size: 12px; font-weight: 700; color: var(--muted); padding: 8px 10px 14px; letter-spacing: .02em; }
.fr-row { display: flex; align-items: center; gap: 12px; padding: 10px; border-top: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.fr-title + .fr-row { border-top-color: transparent; }
.fr-row:hover { background: var(--hover); border-top-color: transparent; }
.fr-row:hover + .fr-row { border-top-color: transparent; }
.fr-row .vavatar { width: 32px; height: 32px; font-size: 14px; flex: none; }
.fr-text { flex: 1; min-width: 0; }
.fr-name { font-weight: 600; color: var(--head); }
.fr-user { font-weight: 400; color: var(--muted); font-size: 13px; visibility: hidden; }
.fr-row:hover .fr-user, .dm-opt .fr-user { visibility: visible; }
.fr-sub { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fr-actions { display: flex; gap: 10px; }
.fr-act { width: 36px; height: 36px; border-radius: 50%; background: var(--bg3); color: var(--muted); display: grid; place-items: center; }
.fr-act .ic { width: 18px; height: 18px; }
.fr-act:hover { color: var(--head); }
.fr-act.ok:hover { color: var(--green); }
.fr-act.no:hover { color: var(--red); }
.fr-empty { padding: 40px 10px; text-align: center; color: var(--muted); }
.fr-add[hidden] { display: none; }
.fr-add { padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.fr-add h2 { margin: 4px 0 8px; font-size: 16px; color: var(--head); }
.fr-add p { margin: 0 0 16px; color: var(--muted); font-size: 14px; }
.fr-add-box { display: flex; gap: 12px; align-items: center; background: var(--bg3); border-radius: 8px; padding: 6px 6px 6px 12px; border: 1px solid transparent; }
.fr-add-box:focus-within { border-color: var(--brand); }
.fr-add-box input { background: none; border: 0; flex: 1; box-shadow: none !important; padding-left: 0; }
.fr-add-box .btn { width: auto; padding: 0 16px; white-space: nowrap; height: 34px; }
.fr-add p.fr-add-msg { margin: 10px 0 0; font-size: 13px; min-height: 1.2em; }
.fr-add-msg.ok { color: var(--green) !important; }
.fr-add-msg.err { color: #ff8b8e !important; }

#activeNow { width: 340px; flex: none; border-left: 1px solid var(--line); padding: 16px; overflow-y: auto; }
#activeNow h3 { margin: 4px 0 16px; font-size: 20px; color: var(--head); }
.an-card { background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 14px; margin-bottom: 10px; cursor: pointer; }
.an-card:hover { background: var(--hover); }
.an-top { display: flex; gap: 10px; align-items: center; }
.an-top .vavatar { width: 40px; height: 40px; font-size: 16px; flex: none; }
.an-name { font-weight: 600; color: var(--head); }
.an-sub { font-size: 13px; color: var(--muted); }
.an-voice { display: flex; align-items: center; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 13px; color: var(--text); }
.an-voice .ic { width: 16px; height: 16px; color: var(--muted); flex: none; }
.an-avs { display: flex; margin-left: auto; padding-left: 6px; }
.av.mini-av { width: 22px; height: 22px; font-size: 10px; border: 2px solid var(--bg2); margin-left: -6px; }
.an-empty { text-align: center; color: var(--muted); padding: 24px 10px; font-size: 14px; line-height: 1.5; }
.an-empty b { color: var(--head); }

.dm-pick { max-height: 300px; overflow-y: auto; margin-top: 10px; }
.dm-opt { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 4px; cursor: pointer; }
.dm-opt:hover { background: var(--hover); }
.dm-opt .vavatar { width: 32px; height: 32px; font-size: 14px; flex: none; }
.dm-opt-name { flex: 1; color: var(--head); }
.dm-opt input { width: 20px; height: 20px; flex: none; }
.pcard .btn-row .btn.sm { flex: 1; }
@media (max-width: 1100px) { #activeNow { display: none; } }
@media (max-width: 860px) { .fr-tabs { margin-left: 8px; padding-left: 8px; gap: 2px; overflow-x: auto; } .fr-main { padding: 12px; } }
