* { box-sizing: border-box; }
:root {
  --bg-rail: #1e1f22;
  --bg-side: #2b2d31;
  --bg-main: #313338;
  --bg-panel: #232428;
  --bg-input: #383a40;
  --bg-hover: #35373c;
  --bg-active: #404249;
  --bg-stage: #000;
  --text: #dbdee1;
  --text-strong: #f2f3f5;
  --text-muted: #949ba4;
  --text-faint: #80848e;
  --brand: #5865f2;
  --brand-hover: #4752c4;
  --green: #23a55a;
  --red: #da373c;
  --divider: #3f4147;
  --font: "Noto Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
}
html, body { height: 100%; }
body { margin: 0; font-family: var(--font); background: var(--bg-main); color: var(--text); font-size: 15px; overflow: hidden; -webkit-font-smoothing: antialiased; }
button { font-family: inherit; }
svg { width: 20px; height: 20px; flex: none; }
.hidden { display: none !important; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #1a1b1e; border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Botões ---------- */
.btn-primary { background: var(--brand); color: #fff; border: 0; border-radius: 4px; padding: 10px 16px; font-size: 15px; font-weight: 500; cursor: pointer; transition: background .15s; }
.btn-primary:hover { background: var(--brand-hover); }
.icon-btn { display: grid; place-items: center; width: 32px; height: 32px; border: 0; border-radius: 4px; background: transparent; color: var(--text-muted); cursor: pointer; flex: none; }
.icon-btn:hover { background: var(--bg-active); color: var(--text); }
.icon-btn.off { color: var(--red); }
.icon-btn.active { color: var(--text-strong); }

/* ---------- Entrada ---------- */
.join {
  height: 100%; display: grid; place-items: center; padding: 16px;
  background:
    radial-gradient(circle at 15% 20%, #7a83ff55 0, transparent 40%),
    radial-gradient(circle at 85% 80%, #eb459e44 0, transparent 40%),
    radial-gradient(circle at 70% 15%, #23a55a33 0, transparent 35%),
    #404eed;
}
.join-card { background: var(--bg-main); width: min(480px, 100%); padding: 32px; border-radius: 8px; box-shadow: 0 8px 24px #0006; display: grid; gap: 20px; }
.join-head { text-align: center; }
.join-head h1 { margin: 0 0 8px; color: var(--text-strong); font-size: 24px; font-weight: 700; }
.join-head p { margin: 0; color: var(--text-muted); }
.join-card label { display: grid; gap: 8px; }
.join-card label span { font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--text-muted); letter-spacing: .02em; }
.join-card label em { color: var(--red); font-style: normal; }
.join-card input { background: var(--bg-rail); border: 0; border-radius: 4px; padding: 10px; color: var(--text); font-size: 16px; font-family: inherit; outline: none; }
.join-card .btn-primary { padding: 12px; font-size: 16px; }
.join-hint { margin: -8px 0 0; font-size: 13px; color: var(--text-faint); }

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

/* Barra de servidores */
.rail { width: 72px; background: var(--bg-rail); display: flex; flex-direction: column; align-items: center; padding: 12px 0; gap: 8px; flex: none; }
.rail-item { position: relative; width: 72px; display: flex; justify-content: center; background: none; border: 0; padding: 0; cursor: pointer; }
.rail-icon { width: 48px; height: 48px; border-radius: 50%; background: var(--bg-main); color: var(--text); display: grid; place-items: center; font-weight: 600; font-size: 16px; transition: border-radius .15s, background .15s, color .15s; }
.rail-item:hover .rail-icon, .rail-item.active .rail-icon { border-radius: 16px; background: var(--brand); color: #fff; }
.rail-item.add .rail-icon { color: var(--green); }
.rail-item.add:hover .rail-icon { background: var(--green); color: #fff; }
.pill { position: absolute; left: 0; top: 50%; width: 4px; height: 40px; margin-top: -20px; background: #fff; border-radius: 0 4px 4px 0; }
.rail-sep { width: 32px; height: 2px; background: var(--bg-active); border-radius: 1px; }

/* Canais */
.channels { width: 240px; background: var(--bg-side); display: flex; flex-direction: column; flex: none; }
.guild-header { height: 48px; padding: 0 16px; display: flex; align-items: center; font-weight: 600; color: var(--text-strong); box-shadow: 0 1px 0 #0003, 0 2px 0 #0000000d; flex: none; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.channel-scroll { flex: 1; overflow-y: auto; padding: 8px 8px 16px; }
.category { padding: 18px 8px 4px; font-size: 12px; font-weight: 600; text-transform: uppercase; color: var(--text-muted); letter-spacing: .02em; }
.channels ul { list-style: none; margin: 0; padding: 0; }
.channel { display: flex; align-items: center; gap: 6px; padding: 6px 8px; margin: 1px 0; border-radius: 4px; color: var(--text-faint); cursor: pointer; position: relative; }
.channel .ch-icon { color: var(--text-faint); }
.channel:hover { background: var(--bg-hover); color: var(--text); }
.channel.active { background: var(--bg-active); color: #fff; }
.channel.unread { color: #fff; font-weight: 600; }
.channel.unread::before { content: ""; position: absolute; left: -8px; width: 4px; height: 8px; background: #fff; border-radius: 0 4px 4px 0; }
.ch-name { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

.voice-users { padding-left: 28px !important; }
.voice-user { display: flex; align-items: center; gap: 8px; padding: 4px 8px; border-radius: 4px; color: var(--text-muted); font-size: 14px; }
.voice-user:hover { background: var(--bg-hover); color: var(--text); }
.voice-user .vu-name { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.voice-user .vu-icons { display: flex; gap: 2px; align-items: center; color: var(--text-muted); }
.voice-user .vu-icons svg { width: 16px; height: 16px; }
.live { background: var(--red); color: #fff; font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: 8px; letter-spacing: .02em; }

/* Painel de voz conectada */
.rtc-panel { background: var(--bg-panel); border-bottom: 1px solid var(--divider); padding: 8px; }
.rtc-top { display: flex; align-items: center; justify-content: space-between; }
.rtc-status { display: flex; gap: 8px; align-items: center; color: var(--green); min-width: 0; }
.rtc-title { font-weight: 600; font-size: 14px; }
.rtc-sub { font-size: 12px; color: var(--text-muted); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.rtc-actions { display: grid; grid-template-columns: 1fr; gap: 8px; margin-top: 8px; }
.rtc-btn { display: flex; align-items: center; justify-content: center; gap: 6px; height: 32px; border: 0; border-radius: 4px; background: var(--bg-input); color: var(--text); cursor: pointer; font-size: 13px; }
.rtc-btn:hover { background: var(--bg-active); }
.rtc-btn.on { background: var(--green); color: #fff; }

/* Painel do usuário */
.user-panel { height: 52px; background: var(--bg-panel); padding: 0 8px; display: flex; align-items: center; gap: 2px; flex: none; }
.me { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; padding: 4px; border-radius: 4px; }
.me:hover { background: var(--bg-active); }
.me-text { min-width: 0; line-height: 1.2; }
.me-name { font-size: 14px; font-weight: 600; color: var(--text-strong); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.me-status { font-size: 12px; color: var(--text-muted); }

/* Avatares */
.avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 600; flex: none; position: relative; user-select: none; transition: box-shadow .1s; }
.avatar.sm { width: 32px; height: 32px; font-size: 14px; }
.avatar.xs { width: 24px; height: 24px; font-size: 11px; }
.avatar.xl { width: 80px; height: 80px; font-size: 32px; }
.avatar.status::after { content: ""; position: absolute; right: -2px; bottom: -2px; width: 10px; height: 10px; border-radius: 50%; background: var(--green); border: 3px solid var(--bg-side); }
.speaking .avatar.xs, .speaking.avatar { box-shadow: 0 0 0 2px var(--green); }

/* Área principal */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--bg-main); }
.topbar { height: 48px; padding: 0 8px 0 16px; display: flex; align-items: center; gap: 8px; box-shadow: 0 1px 0 #0003, 0 2px 0 #0000000d; flex: none; z-index: 2; }
.topbar-icon { color: var(--text-faint); width: 24px; height: 24px; }
.topbar-title { font-weight: 600; color: var(--text-strong); white-space: nowrap; }
.topbar-sep { width: 1px; height: 24px; background: var(--divider); margin: 0 8px; }
.topbar-topic { flex: 1; color: var(--text-muted); font-size: 14px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.content { flex: 1; display: flex; min-height: 0; }
.mobile-only { display: none; }

/* Chat */
.chat { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.messages { flex: 1; overflow-y: auto; padding: 16px 0 8px; display: flex; flex-direction: column; }
.welcome { padding: 16px 16px 24px; margin-top: auto; }
.welcome .big-icon { width: 68px; height: 68px; border-radius: 50%; background: var(--bg-active); display: grid; place-items: center; margin-bottom: 8px; }
.welcome .big-icon svg { width: 40px; height: 40px; color: #fff; }
.welcome h2 { margin: 8px 0; color: var(--text-strong); font-size: 30px; font-weight: 800; }
.welcome p { margin: 0; color: var(--text-muted); }
.msg { display: flex; gap: 16px; padding: 2px 48px 2px 16px; position: relative; }
.msg:hover { background: #2e3035; }
.msg.head { margin-top: 17px; padding-top: 2px; }
.msg .gutter { width: 40px; flex: none; }
.msg .stamp-hover { display: none; font-size: 11px; color: var(--text-faint); width: 40px; text-align: right; padding-top: 4px; }
.msg:not(.head):hover .stamp-hover { display: block; }
.msg:not(.head):hover .gutter-empty { display: none; }
.msg-body { min-width: 0; flex: 1; }
.msg-meta { display: flex; align-items: baseline; gap: 8px; }
.msg-author { font-weight: 500; color: var(--text-strong); }
.msg-time { font-size: 12px; color: var(--text-faint); }
.msg-text { color: var(--text); line-height: 1.375; white-space: pre-wrap; word-wrap: break-word; }
.msg-text a { color: #00a8fc; text-decoration: none; }
.msg-text a:hover { text-decoration: underline; }
.sys-msg { padding: 2px 16px 2px 72px; color: var(--text-muted); font-size: 14px; margin-top: 8px; display: flex; gap: 8px; align-items: center; }
.sys-msg::before { content: "→"; color: var(--green); font-weight: 700; position: absolute; left: 40px; }
.sys-msg { position: relative; }
.composer { padding: 0 16px; flex: none; }
.composer input { width: 100%; background: var(--bg-input); border: 0; border-radius: 8px; padding: 11px 16px; color: var(--text); font-size: 15px; font-family: inherit; outline: none; }
.composer input::placeholder { color: var(--text-faint); }
.typing { height: 24px; line-height: 24px; padding: 0 16px; font-size: 13px; color: var(--text); flex: none; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.typing b { font-weight: 700; }

/* Membros */
.members { width: 240px; background: var(--bg-side); overflow-y: auto; padding: 8px 8px 16px; flex: none; }
.members ul { list-style: none; margin: 0; padding: 0; }
.member { display: flex; align-items: center; gap: 12px; padding: 6px 8px; border-radius: 4px; color: var(--text-muted); cursor: default; }
.member:hover { background: var(--bg-hover); color: var(--text); }
.member .avatar.status::after { border-color: var(--bg-side); }
.member:hover .avatar.status::after { border-color: var(--bg-hover); }
.member .m-name { font-weight: 500; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.member .m-sub { font-size: 12px; color: var(--text-muted); display: flex; align-items: center; gap: 4px; }
.member .m-sub svg { width: 12px; height: 12px; }
body.hide-members .members { display: none; }

/* Palco de voz */
.voice-stage { flex: 1; background: var(--bg-stage); position: relative; display: flex; flex-direction: column; min-width: 0; }
.stage-empty { margin: auto; text-align: center; color: var(--text-muted); padding: 16px; }
.stage-empty > svg { width: 64px; height: 64px; color: var(--text-faint); }
.stage-empty h2 { color: var(--text-strong); margin: 8px 0; font-size: 24px; }
.stage-empty p { margin: 0 0 20px; }
.tiles { flex: 1; display: grid; gap: 8px; padding: 16px 16px 96px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); grid-auto-rows: minmax(160px, 1fr); align-content: center; overflow-y: auto; }
.tiles:empty { display: none; }
.tile { position: relative; background: var(--bg-side); border-radius: 8px; overflow: hidden; display: grid; place-items: center; min-height: 160px; cursor: pointer; outline: 2px solid transparent; transition: outline-color .1s; }
.tile.speaking { outline: 2px solid var(--green); outline-offset: -2px; }
.tile video { width: 100%; height: 100%; object-fit: contain; background: #000; position: absolute; inset: 0; }
.tile .t-name { position: absolute; left: 8px; bottom: 8px; background: #000a; color: #fff; padding: 4px 8px; border-radius: 4px; font-size: 13px; font-weight: 500; display: flex; align-items: center; gap: 6px; max-width: calc(100% - 16px); }
.tile .t-name svg { width: 14px; height: 14px; color: var(--red); }
.tile .t-live { position: absolute; left: 8px; top: 8px; }
.tile .t-actions { position: absolute; right: 8px; top: 8px; display: flex; gap: 6px; opacity: 0; transition: opacity .15s; }
.tile .t-actions .icon-btn { background: #000a; color: #fff; }
.tile .t-actions .icon-btn:hover { background: #000d; }
.tile.watching:hover .t-actions { opacity: 1; }
.tile.screen video { display: none; }
.tile.screen.watching video { display: block; }
.tile.screen.watching .screen-cover { display: none; }
.screen-cover { display: grid; justify-items: center; gap: 12px; padding: 24px; text-align: center;
  background: radial-gradient(circle at 50% 35%, #ffffff12, transparent 60%), var(--bg-side); position: absolute; inset: 0; align-content: center; }
.cover-title { color: var(--text-strong); font-weight: 600; font-size: 16px; }
.tile.screen:not(.watching) { cursor: default; }
.tiles.focused { grid-template-columns: 1fr; grid-auto-rows: auto; align-content: start; }
.tiles.focused .tile { display: none; }
.tiles.focused .tile.focus { display: grid; height: calc(100vh - 48px - 120px); }
.tiles.focused::after { content: "Clique para voltar à grade"; position: absolute; top: 24px; left: 50%; transform: translateX(-50%); color: #fffa; font-size: 12px; background: #0008; padding: 4px 10px; border-radius: 12px; pointer-events: none; }
.stage-bar { position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; gap: 16px; padding: 8px; }
.round { width: 56px; height: 56px; border-radius: 50%; border: 0; background: var(--bg-input); color: #fff; display: grid; place-items: center; cursor: pointer; transition: background .15s; }
.round svg { width: 24px; height: 24px; }
.round:hover { background: var(--bg-active); }
.round.off { background: #fff; color: var(--red); }
.round.on { background: var(--green); }
.round.danger { background: var(--red); }
.round.danger:hover { background: #a12d2f; }

/* Toast */
.toast { position: fixed; left: 50%; top: 16px; transform: translateX(-50%); background: var(--bg-rail); color: var(--text-strong); padding: 10px 16px; border-radius: 6px; box-shadow: 0 8px 16px #0006; font-size: 14px; z-index: 50; }

/* ---------- Responsivo ---------- */
@media (max-width: 1100px) {
  .members { display: none; }
  body.show-members .members { display: block; position: absolute; right: 0; top: 48px; bottom: 0; z-index: 5; box-shadow: -4px 0 12px #0005; }
}
@media (max-width: 760px) {
  .rail { display: none; }
  .mobile-only { display: grid; }
  .channels { position: fixed; left: 0; top: 0; bottom: 0; z-index: 10; transform: translateX(-100%); transition: transform .2s; box-shadow: 4px 0 16px #0006; }
  body.show-channels .channels { transform: none; }
  .topbar-sep, .topbar-topic { display: none; }
  .topbar-title { flex: 1; }
  .msg { padding-right: 16px; }
  .tiles { grid-template-columns: 1fr; padding: 8px 8px 96px; }
}

/* ---------- Login com Discord / perfil ---------- */
.avatar { overflow: visible; }
.avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
.avatar.lg { width: 56px; height: 56px; font-size: 22px; }
.avatar.clickable, .msg-author { cursor: pointer; }
.msg-author:hover { text-decoration: underline; }
.member, .voice-user { cursor: pointer; }
.me { cursor: pointer; }

.btn-discord { display: flex; align-items: center; justify-content: center; gap: 10px; background: var(--brand); color: #fff; text-decoration: none; border-radius: 4px; padding: 12px; font-size: 16px; font-weight: 600; transition: background .15s; }
.btn-discord:hover { background: var(--brand-hover); }
.btn-discord svg { width: 22px; height: 22px; }

.whoami { display: flex; align-items: center; gap: 12px; background: var(--bg-side); border-radius: 8px; padding: 12px; }
.whoami > div { flex: 1; min-width: 0; }
.who-name { color: var(--text-strong); font-weight: 700; font-size: 16px; }
.who-user { color: var(--text-muted); font-size: 13px; }
.whoami a { color: #00a8fc; font-size: 13px; text-decoration: none; white-space: nowrap; }
.whoami a:hover { text-decoration: underline; }

.profile-card { position: fixed; z-index: 60; width: 300px; background: var(--bg-rail); border-radius: 8px; overflow: hidden; box-shadow: 0 8px 24px #000a; }
.pc-banner { height: 105px; background-size: cover; background-position: center; }
.pc-avatar { position: absolute !important; top: 61px; left: 16px; border: 6px solid var(--bg-rail); box-sizing: content-box; background-clip: padding-box; }
.pc-avatar.status::after { width: 16px; height: 16px; right: 0; bottom: 0; border: 5px solid var(--bg-rail); }
.pc-body { padding: 52px 16px 16px; }
.pc-name { color: var(--text-strong); font-size: 20px; font-weight: 700; }
.pc-user { color: var(--text); font-size: 14px; }
.pc-section { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--divider); }
.pc-label { font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--text-strong); margin-bottom: 4px; }
.pc-text { font-size: 14px; color: var(--text); }
.pc-logout { margin-top: 12px; width: 100%; background: transparent; border: 1px solid var(--red); color: var(--red); border-radius: 4px; padding: 8px; cursor: pointer; font-size: 14px; }
.pc-logout:hover { background: var(--red); color: #fff; }
