:root {
  --rail: #1e1f22; --side: #2b2d31; --main: #313338; --panel: #232428; --input: #383a40; --hover: #35373c; --active: #404249;
  --text: #f2f3f5; --text2: #dbdee1; --muted: #949ba4; --accent: #5865f2; --red: #da373c; --green: #23a55a; --live: #ed4245;
  --tile: #2b2d31;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--rail); color: var(--text);
  font: 15px/1.375 "gg sans", "Segoe UI", "Noto Sans", system-ui, sans-serif; overflow: hidden; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.tiny { font-size: 12px; }
.grow { flex: 1; }
svg.ic { width: 20px; height: 20px; fill: currentColor; flex: none; display: block; }

/* ---------- Entrada ---------- */
.join { height: 100%; display: grid; place-items: center; padding: 16px;
  background: linear-gradient(135deg, #404eed 0%, #2b2d84 50%, #1e1f22 100%); }
.join-card { width: 100%; max-width: 440px; background: var(--main); padding: 32px; border-radius: 8px;
  display: flex; flex-direction: column; gap: 16px; box-shadow: 0 8px 40px #0007; }
.join-card h1 { margin: 0; font-size: 24px; text-align: center; }
.join-card p { margin: -8px 0 4px; text-align: center; }
.logo { display: flex; align-items: center; justify-content: center; gap: 10px; font-weight: 800; font-size: 20px; }
.logo-mark { width: 26px; height: 26px; border-radius: 8px; background: var(--accent); position: relative; }
.logo-mark::after { content: ''; position: absolute; inset: 7px; border-radius: 50%; background: #fff; }
label { display: flex; flex-direction: column; gap: 8px; font-size: 12px; font-weight: 700; color: var(--text2); text-transform: uppercase; letter-spacing: .02em; }
input, select { background: #1e1f22; border: 0; border-radius: 4px; padding: 10px; outline: none; text-transform: none; font-weight: 400; font-size: 15px; letter-spacing: 0; min-width: 0; }
input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); }
.btn { border: 0; border-radius: 4px; padding: 8px 16px; background: var(--input); font-weight: 600; font-size: 14px; }
.btn:hover { filter: brightness(1.12); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.big { padding: 12px 20px; font-size: 16px; }
.btn.link { background: none; }
.btn.link:hover { text-decoration: underline; }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: 72px 240px 1fr; height: 100%; }

.rail { background: var(--rail); display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 12px 0; }
.server-icon { width: 48px; height: 48px; border-radius: 50%; background: var(--main); display: grid; place-items: center; font-weight: 700;
  border: 0; transition: border-radius .15s, background .15s; position: relative; color: var(--text); font-size: 18px; }
.server-icon.active, .server-icon:hover { border-radius: 16px; background: var(--accent); }
.server-icon.active::before { content: ''; position: absolute; left: -16px; width: 8px; height: 40px; border-radius: 0 4px 4px 0; background: #fff; }
.server-icon.add { color: var(--green); font-size: 26px; font-weight: 400; }
.server-icon.add:hover { background: var(--green); color: #fff; }
.rail-sep { width: 32px; height: 2px; background: var(--input); border-radius: 1px; }

.channels { background: var(--side); display: flex; flex-direction: column; min-height: 0; }
.channels-head { height: 48px; padding: 0 12px 0 16px; display: flex; align-items: center; justify-content: space-between; font-weight: 700;
  box-shadow: 0 1px 0 #0003, 0 2px 0 #0000000d; flex: none; }
.channels-head span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.channel-scroll { flex: 1; overflow-y: auto; padding: 8px 8px 16px; }
.cat { font-size: 12px; font-weight: 700; color: var(--muted); padding: 16px 8px 4px; letter-spacing: .02em; }
.channel { width: 100%; display: flex; align-items: center; gap: 6px; padding: 6px 8px; border: 0; border-radius: 4px; background: none;
  color: var(--muted); font-weight: 500; text-align: left; margin: 1px 0; }
.channel span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.channel:hover { background: var(--hover); color: var(--text2); }
.channel.active { background: var(--active); color: #fff; }
.unread { background: var(--red); color: #fff; border-radius: 8px; font-size: 12px; padding: 0 6px; min-width: 16px; text-align: center; }

.voice-list, .online-list { list-style: none; margin: 0; padding: 0 0 0 24px; }
.online-list { padding-left: 0; }
.voice-list li, .online-list li { display: flex; align-items: center; gap: 8px; padding: 4px 8px; border-radius: 4px; color: var(--muted); font-size: 14px; }
.voice-list li:hover, .online-list li:hover { background: var(--hover); color: var(--text2); }
.voice-list .nm, .online-list .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.voice-list .flags { display: flex; gap: 2px; color: var(--muted); }
.voice-list .flags svg { width: 16px; height: 16px; }
.voice-list .flags .off { color: var(--red); }

.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; color: #fff; flex: none;
  font-size: 14px; position: relative; transition: box-shadow .1s; }
.avatar.sm { width: 32px; height: 32px; }
.avatar.xs { width: 24px; height: 24px; font-size: 11px; }
.speaking .avatar.xs, .avatar.speaking { box-shadow: 0 0 0 2px var(--side), 0 0 0 4px var(--green); }
.badge-live { background: var(--live); color: #fff; font-size: 10px; font-weight: 800; padding: 1px 5px; border-radius: 4px; letter-spacing: .03em; flex: none; line-height: 16px; }
button.badge-live { border: 0; }

.icon-btn { width: 32px; height: 32px; border: 0; border-radius: 4px; background: none; color: var(--muted); display: grid; place-items: center; flex: none; }
.icon-btn:hover { background: var(--hover); color: var(--text2); }
.icon-btn.off { color: var(--red); }

.voice-panel { background: var(--panel); border-bottom: 1px solid #ffffff0f; padding: 8px; flex: none; }
.vp-top { display: flex; align-items: center; justify-content: space-between; padding: 0 0 8px 4px; }
.vp-status { color: var(--green); font-weight: 700; font-size: 14px; }
.vp-status.bad { color: #f0b232; }
.vp-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.vp-btn { border: 0; border-radius: 4px; background: var(--input); color: var(--text2); height: 32px; display: grid; place-items: center; }
.vp-btn:hover { background: #4e5058; }
.vp-btn.on { background: var(--green); color: #fff; }
.vp-btn.on.live { background: var(--live); }

.user-panel { background: var(--panel); height: 52px; padding: 0 8px; display: flex; align-items: center; gap: 2px; flex: none; }
.up-me { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; padding: 4px; border-radius: 4px; }
.up-names { min-width: 0; }
.up-name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Centro ---------- */
.center { background: var(--main); display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.center-head { height: 48px; flex: none; display: flex; align-items: center; gap: 8px; padding: 0 12px 0 16px; font-weight: 700;
  box-shadow: 0 1px 0 #0003, 0 2px 0 #0000000d; z-index: 1; }
.center-head > i { color: var(--muted); }
.center-head .menu { display: none; }
.center-body { flex: 1; display: flex; min-height: 0; }

.voice-view { flex: 1; position: relative; background: #000; display: flex; flex-direction: column; min-width: 0; }
.view-text .voice-view { display: none; }
.view-voice .chat { width: 340px; flex: none; border-left: 1px solid #0003; }
.view-voice.chat-closed .chat { display: none; }
.view-text .center-head #btnChat { display: none; }

.voice-intro { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 8px; padding: 24px; background: var(--rail); }
.voice-intro h2 { margin: 4px 0 0; }
.vi-icon svg { width: 56px; height: 56px; color: var(--muted); }
.vi-avatars { display: flex; gap: 8px; margin: 8px 0 12px; flex-wrap: wrap; justify-content: center; }
.vi-avatars .avatar { width: 48px; height: 48px; font-size: 18px; }

.stage { flex: 1; display: grid; gap: 8px; padding: 16px; min-height: 0; overflow-y: auto; align-content: center;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }
.stage:empty { display: none; }
.stage.focus { display: flex; flex-wrap: wrap; align-content: flex-start; gap: 8px; }
.stage.focus .tile { flex: 0 0 200px; height: 112px; aspect-ratio: auto; }
.stage.focus .tile.big { flex: 1 0 100%; height: calc(100% - 128px); order: -1; }

.tile { position: relative; background: var(--tile); border-radius: 8px; overflow: hidden; aspect-ratio: 16 / 9; cursor: pointer; min-height: 0; }
.tile::after { content: ''; position: absolute; inset: 0; border-radius: 8px; pointer-events: none; transition: box-shadow .1s; }
.tile.speaking::after { box-shadow: inset 0 0 0 3px var(--green); }
.tile video { position: absolute; inset: 0; width: 100%; height: 100%; display: block; background: #000; }
.tile video.cam { object-fit: cover; }
.tile video.screen { object-fit: contain; }
.tile video.mirror { transform: scaleX(-1); }
.tile .t-avatar { position: absolute; inset: 0; display: grid; place-items: center; }
.tile .t-avatar .avatar { width: 80px; height: 80px; font-size: 32px; }
.stage.focus .tile:not(.big) .t-avatar .avatar { width: 44px; height: 44px; font-size: 18px; }
.tile .t-name { position: absolute; left: 8px; bottom: 8px; display: flex; align-items: center; gap: 4px; background: #000000a0; padding: 2px 8px; border-radius: 4px;
  font-size: 13px; font-weight: 600; max-width: calc(100% - 16px); }
.tile .t-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .t-name svg { width: 16px; height: 16px; color: var(--red); }
.tile .t-live { position: absolute; left: 8px; top: 8px; }
.tile .t-stats { position: absolute; right: 8px; top: 8px; background: #000000a0; padding: 2px 8px; border-radius: 4px; font-size: 12px; color: #ccc; }
.tile .t-stats:empty { display: none; }
.tile .t-watch { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  background: radial-gradient(circle, #3b3d4a 0%, #1e1f22 100%); }
.tile .t-watch .btn { background: #ffffff1f; backdrop-filter: blur(4px); }
.tile .t-watch .btn:hover { background: #ffffff33; }
.stage.focus .tile:not(.big) .t-watch .btn { padding: 4px 10px; font-size: 12px; }
.stage.focus .tile:not(.big) .t-watch .sub { display: none; }
.tile .t-bar { position: absolute; right: 8px; bottom: 8px; display: flex; gap: 6px; align-items: center; opacity: 0; transition: opacity .15s; }
.tile:hover .t-bar, .tile .t-bar:focus-within { opacity: 1; }
.tile .t-bar button { width: 32px; height: 32px; border: 0; border-radius: 50%; background: #000000b0; display: grid; place-items: center; color: #fff; }
.tile .t-bar button:hover { background: #000; }
.tile .t-bar svg { width: 18px; height: 18px; }
.tile .t-bar input[type=range] { width: 90px; padding: 0; accent-color: #fff; background: none; }
.tile .t-unmute { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); }

.call-bar { position: absolute; left: 50%; bottom: 20px; transform: translateX(-50%); display: flex; gap: 12px; padding: 8px; border-radius: 32px;
  background: #000000b0; backdrop-filter: blur(8px); opacity: .25; transition: opacity .2s; z-index: 2; }
.voice-view:hover .call-bar, .call-bar:focus-within { opacity: 1; }
.cb { width: 52px; height: 52px; border-radius: 50%; border: 0; background: #2b2d31; color: #fff; display: grid; place-items: center; }
.cb:hover { background: #404249; }
.cb svg { width: 24px; height: 24px; }
.cb.on { background: #fff; color: #000; }
.cb.on.live { background: var(--live); color: #fff; }
.cb.off { background: #fff; color: var(--red); }
.cb.red { background: var(--red); }
.cb.red:hover { background: #a12828; }


/* ---------- Chat ---------- */
.chat { flex: 1; display: flex; flex-direction: column; background: var(--main); min-width: 0; }
.messages { flex: 1; overflow-y: auto; padding: 16px 0 8px; display: flex; flex-direction: column; }
.chat-welcome { padding: 16px; margin-top: auto; }
.chat-welcome h2 { margin: 8px 0 4px; font-size: 26px; }
.cw-icon { width: 64px; height: 64px; border-radius: 50%; background: #41434a; display: grid; place-items: center; }
.cw-icon svg { width: 36px; height: 36px; }
.msg { display: flex; gap: 14px; padding: 2px 16px; margin-top: 14px; }
.msg.cont { margin-top: 0; }
.msg.cont .avatar { visibility: hidden; height: 0; }
.msg:hover { background: #2e3035; }
.msg .avatar { width: 40px; height: 40px; font-size: 16px; margin-top: 2px; }
.msg .body { min-width: 0; }
.msg .who { font-weight: 600; }
.msg .time { color: var(--muted); font-size: 12px; margin-left: 6px; font-weight: 400; }
.msg .text { color: var(--text2); overflow-wrap: anywhere; white-space: pre-wrap; }
.msg .text a { color: #00a8fc; }
.sys { color: var(--muted); font-size: 13px; padding: 6px 16px 0 70px; }
.chat-form { padding: 0 16px 20px; }
.chat-form input { width: 100%; background: var(--input); border-radius: 8px; padding: 12px 16px; }

/* ---------- Modais ---------- */
.modal { position: fixed; inset: 0; background: #000000b0; display: grid; place-items: center; z-index: 20; padding: 16px; }
.modal-card { width: 100%; max-width: 480px; background: var(--main); border-radius: 8px; padding: 24px; display: flex; flex-direction: column; gap: 16px;
  max-height: calc(100vh - 32px); overflow-y: auto; }
.modal-card h2 { margin: 0; }
.modal-card p { margin: 0; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.live-txt { color: var(--live); }
.tip { background: #2b2d31; border-radius: 6px; padding: 10px 12px; font-size: 13px; color: var(--text2); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.check { flex-direction: row; align-items: center; gap: 10px; text-transform: none; font-weight: 500; font-size: 15px; color: var(--text2); letter-spacing: 0; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.meter-wrap { display: flex; flex-direction: column; gap: 8px; }
.meter { position: relative; height: 24px; background: #1e1f22; border-radius: 4px; overflow: hidden; }
.meter-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: var(--green); transition: width .06s; }
.meter input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; background: none; padding: 0; accent-color: #f0b232; opacity: .9; }
.meter input:disabled { opacity: .35; }

.toast { position: fixed; left: 50%; top: 16px; transform: translate(-50%, -60px); opacity: 0; background: #111214; padding: 10px 16px;
  border-radius: 8px; transition: .25s; pointer-events: none; z-index: 30; max-width: calc(100% - 32px); box-shadow: 0 8px 24px #0008; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Celular ---------- */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .rail { display: none; }
  .channels { position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); z-index: 10; transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 40px #000a; }
  .app.menu-open .channels { transform: none; }
  .center-head .menu { display: grid; }
  .view-voice .chat { position: fixed; inset: 48px 0 0 0; width: auto; z-index: 5; }
  .stage { padding: 8px; grid-template-columns: 1fr; }
  .stage.focus .tile { flex-basis: 120px; height: 68px; }
  .stage.focus .tile.big { height: calc(100% - 84px); }
  .call-bar { opacity: 1; bottom: 12px; gap: 8px; }
  .cb { width: 46px; height: 46px; }
  .row { grid-template-columns: 1fr; }
}

[hidden] { display: none !important; }
.stage { padding-bottom: 92px; }
@media (max-width: 860px) { .stage { padding-bottom: 76px; } }

/* Teste de internet na janela de transmitir */
.net { background: #2b2d31; border-radius: 6px; padding: 12px; display: flex; flex-direction: column; gap: 6px; border-left: 4px solid #4e5058; }
.net.ok { border-left-color: var(--green); }
.net.warn { border-left-color: #f0b232; }
.net.bad { border-left-color: var(--red); }
.net-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.net-actions { display: flex; gap: 8px; align-items: center; }
.net-actions .btn { padding: 6px 12px; }

.frog { font-size: 30px; line-height: 1; }

/* Registro de conexão */
.diag { display: flex; flex-direction: column; gap: 6px; }
.diag-log { margin: 0; background: #1e1f22; border-radius: 4px; padding: 8px 10px; max-height: 180px; overflow: auto; font: 12px/1.45 Consolas, "Cascadia Mono", monospace; color: var(--text2); white-space: pre-wrap; }

.server-icon svg { width: 24px; height: 24px; }

/* ---------- Perfil (foto) ---------- */
.avatar { overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 50%; }
.pf { display: flex; align-items: center; gap: 16px; background: #2b2d31; border-radius: 8px; padding: 12px; }
.pf-foto { position: relative; border: 0; padding: 0; background: none; border-radius: 50%; flex: none; }
.pf-foto .pf-av { width: 80px; height: 80px; font-size: 32px; }
.pf-cam { position: absolute; right: -2px; bottom: -2px; width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; border: 3px solid #2b2d31; }
.pf-cam svg { width: 15px; height: 15px; }
.pf-foto:hover .pf-av { filter: brightness(.8); }
.pf-txt { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.pf-acoes { display: flex; gap: 6px; margin-top: 4px; }
.pf-acoes .btn { padding: 6px 12px; }
.up-me { cursor: pointer; }
.up-me:hover { background: var(--hover); }

/* ---------- Entrada: coluna com o cartão e os downloads ---------- */
.join { overflow-y: auto; }
.join-col { width: 100%; max-width: 440px; display: flex; flex-direction: column; gap: 16px; margin: auto; }
.join-card { max-width: none; }
.dl-card { background: #2b2d31e6; border-radius: 8px; padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.dl-card p { margin: 0; }
.dl-top { display: flex; align-items: center; gap: 8px; font-size: 16px; }
.dl-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.dl-btn { position: relative; display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border-radius: 8px; background: var(--input);
  color: var(--text); text-decoration: none; border: 1px solid transparent; transition: background .15s, border-color .15s; }
.dl-btn:hover, .dl-btn:focus-visible { background: #404249; border-color: var(--accent); outline: none; }
.dl-btn > span { color: var(--muted); font-size: 12px; }
.dl-tip { position: absolute; left: 50%; bottom: calc(100% + 10px); transform: translateX(-50%) translateY(4px); width: 240px; padding: 10px 12px;
  background: #111214; color: var(--text2) !important; font-size: 13px !important; line-height: 1.4; border-radius: 8px; box-shadow: 0 8px 24px #000a;
  opacity: 0; pointer-events: none; transition: opacity .15s, transform .15s; z-index: 5; }
.dl-tip b { color: #fff; }
.dl-tip::after { content: ''; position: absolute; left: 50%; top: 100%; transform: translateX(-50%); border: 7px solid transparent; border-top-color: #111214; }
.dl-btn:hover .dl-tip, .dl-btn:focus-visible .dl-tip { opacity: 1; transform: translateX(-50%) translateY(0); }
@media (max-width: 860px) { .dl-btns { grid-template-columns: 1fr; } .dl-tip { width: 220px; } }
