:root {
  --bg0: #0d0f14; --bg1: #13161d; --bg2: #191d26; --bg3: #222735; --line: #2a3040;
  --text: #e6e9f0; --muted: #8b93a7; --accent: #2ee59d; --accent-ink: #062018;
  --danger: #ff5c72; --online: #2ee59d; --radius: 10px;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg0); color: var(--text); font-size: 15px; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea { font: inherit; color: var(--text); }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.error { color: var(--danger); min-height: 1.2em; margin: 4px 0; font-size: 13px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn { border: 0; border-radius: 8px; padding: 9px 16px; background: var(--bg3); font-weight: 600; }
.btn:hover { filter: brightness(1.15); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.danger { background: var(--danger); color: #fff; }
.icon-btn { background: none; border: 0; color: var(--muted); font-size: 18px; width: 34px; height: 34px; border-radius: 8px; flex: none; }
.icon-btn:hover { color: var(--text); background: var(--bg3); }

/* auth */
.auth { min-height: 100%; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(1200px 600px at 20% 0%, #10392b55, transparent), var(--bg0); }
.auth-card { width: min(400px, 100%); background: var(--bg1); border: 1px solid var(--line); border-radius: 16px; padding: 32px; display: grid; gap: 12px; }
.auth-card h1 { margin: 0; font-size: 22px; text-align: center; }
.auth-card > p { margin: 0; text-align: center; }
.auth-logo { width: 56px; margin: 0 auto; }
label { display: grid; gap: 6px; font-size: 12px; font-weight: 600; text-transform: uppercase; color: var(--muted); letter-spacing: .03em; }
label input, .modal input, .modal select { background: var(--bg0); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; text-transform: none; font-size: 15px; color: var(--text); }

/* layout */
.app { display: grid; grid-template-columns: 72px 240px 1fr 240px; height: 100vh; position: relative; }
.rail { background: var(--bg0); padding: 12px 0; display: flex; flex-direction: column; align-items: center; gap: 8px; overflow-y: auto; }
.rail-list { display: flex; flex-direction: column; gap: 8px; align-items: center; }
.rail-btn { width: 48px; height: 48px; border-radius: 50%; border: 0; background: var(--bg2); font-weight: 700; font-size: 16px;
  transition: border-radius .15s, background .15s; position: relative; flex: none; }
.rail-btn:hover, .rail-btn.active { border-radius: 16px; background: var(--accent); color: var(--accent-ink); }
.rail-btn.add { color: var(--accent); font-size: 24px; font-weight: 400; }
.rail-btn.unread::before { content: ""; position: absolute; left: -12px; top: 50%; width: 6px; height: 8px; margin-top: -4px; border-radius: 0 4px 4px 0; background: var(--text); }

.sidebar { background: var(--bg1); display: flex; flex-direction: column; min-width: 0; }
.sidebar-head { position: relative; border-bottom: 1px solid var(--line); }
.guild-name { width: 100%; height: 52px; padding: 0 16px; background: none; border: 0; display: flex; justify-content: space-between; align-items: center; font-weight: 700; }
.guild-name span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.guild-name:hover { background: var(--bg2); }
.menu { position: absolute; z-index: 10; top: 56px; left: 8px; right: 8px; background: var(--bg0); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px; display: grid; }
.menu button { background: none; border: 0; text-align: left; padding: 8px 10px; border-radius: 6px; }
.menu button:hover { background: var(--accent); color: var(--accent-ink); }
.menu .danger { color: var(--danger); }
.menu .danger:hover { background: var(--danger); color: #fff; }

.channels { flex: 1; overflow-y: auto; padding: 12px 8px; }
.cat { font-size: 11.5px; font-weight: 700; text-transform: uppercase; color: var(--muted); padding: 12px 8px 4px; letter-spacing: .04em; }
.chan { display: flex; align-items: center; gap: 6px; width: 100%; padding: 7px 8px; border: 0; background: none; border-radius: 6px; color: var(--muted); text-align: left; }
.chan:hover { background: var(--bg2); color: var(--text); }
.chan.active { background: var(--bg3); color: var(--text); }
.chan.unread { color: var(--text); font-weight: 700; }
.chan .ic { width: 18px; text-align: center; opacity: .7; }
.chan .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chan .del { visibility: hidden; font-size: 13px; opacity: .6; }
.chan:hover .del { visibility: visible; }

.me { display: flex; align-items: center; gap: 10px; padding: 10px; background: var(--bg0); }
.me-info { flex: 1; min-width: 0; display: grid; line-height: 1.2; }
.me-info strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: #0b0d12; flex: none; position: relative; font-size: 14px; }
.avatar.dot::after { content: ""; position: absolute; right: -2px; bottom: -2px; width: 12px; height: 12px; border-radius: 50%; border: 3px solid var(--bg1); background: #4a5165; }
.avatar.dot.on::after { background: var(--online); }

.chat { display: flex; flex-direction: column; min-width: 0; background: var(--bg2); }
.chat-head { height: 52px; display: flex; align-items: center; gap: 8px; padding: 0 16px; border-bottom: 1px solid var(--line); flex: none; }
.hash { color: var(--muted); font-size: 20px; }
.messages { flex: 1; overflow-y: auto; padding: 16px 0 8px; }
.msg { display: grid; grid-template-columns: 40px 1fr; gap: 0 14px; padding: 2px 16px; position: relative; }
.msg.first { margin-top: 14px; }
.msg:hover { background: #ffffff06; }
.msg .avatar { width: 40px; height: 40px; grid-row: span 2; }
.msg .head { display: flex; gap: 8px; align-items: baseline; }
.msg .head strong { font-weight: 600; }
.msg .body { white-space: pre-wrap; word-wrap: break-word; line-height: 1.45; min-width: 0; }
.msg:not(.first) .body { grid-column: 2; }
.msg .tools { position: absolute; right: 16px; top: -12px; display: none; background: var(--bg1); border: 1px solid var(--line); border-radius: 8px; }
.msg:hover .tools { display: flex; }
.msg .tools button { background: none; border: 0; padding: 4px 8px; color: var(--muted); }
.msg .tools button:hover { color: var(--danger); }
.att img, .att video { max-width: min(420px, 100%); max-height: 320px; border-radius: 8px; display: block; margin-top: 6px; }
.att .file { display: inline-flex; gap: 10px; align-items: center; margin-top: 6px; padding: 10px 14px; background: var(--bg1); border: 1px solid var(--line); border-radius: 8px; text-decoration: none; color: var(--text); }
.day { display: flex; align-items: center; gap: 8px; margin: 18px 16px 4px; color: var(--muted); font-size: 12px; }
.day::before, .day::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.typing { height: 20px; padding: 0 16px; }
.composer { display: flex; align-items: flex-end; gap: 8px; margin: 0 16px 20px; background: var(--bg3); border-radius: var(--radius); padding: 6px 8px; }
.composer-main { flex: 1; min-width: 0; }
.composer textarea { width: 100%; background: none; border: 0; resize: none; padding: 7px 4px; max-height: 40vh; outline: none; line-height: 1.4; }
.pending { display: flex; align-items: center; gap: 8px; padding: 8px; margin-bottom: 4px; background: var(--bg2); border-radius: 8px; font-size: 13px; }
.pending .x { margin-left: auto; }

.members { background: var(--bg1); overflow-y: auto; padding: 16px 8px; }
.members h3 { font-size: 11.5px; text-transform: uppercase; color: var(--muted); margin: 8px 8px 6px; letter-spacing: .04em; }
.member { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 6px; }
.member:hover { background: var(--bg2); }
.member.off { opacity: .45; }
.member .crown { color: #f5c542; font-size: 12px; }

.empty { position: absolute; inset: 0 0 0 72px; background: var(--bg2); display: grid; place-content: center; justify-items: center; text-align: center; gap: 4px; padding: 16px; }

.modal { background: var(--bg1); color: var(--text); border: 1px solid var(--line); border-radius: 14px; padding: 24px; width: min(440px, calc(100% - 32px)); }
.modal::backdrop { background: #000a; }
.modal h2 { margin: 0 0 14px; font-size: 19px; }
.modal #modalBody { display: grid; gap: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.copy-row { display: flex; gap: 8px; }
.copy-row input { flex: 1; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--bg0); border: 1px solid var(--line); padding: 10px 18px; border-radius: 10px; z-index: 50; }

@media (max-width: 1000px) { .app { grid-template-columns: 72px 220px 1fr; } .members { display: none; } }
@media (max-width: 640px) {
  .app { grid-template-columns: 60px 1fr; grid-template-rows: auto 1fr; }
  .rail { grid-row: span 2; }
  .sidebar { max-height: 38vh; }
  .rail-btn { width: 42px; height: 42px; }
  .empty { inset: 0 0 0 60px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- entrada ---------- */
.splash { position: fixed; inset: 0; z-index: 100; display: grid; place-content: center; justify-items: center; gap: 18px; background: var(--bg0); transition: opacity .6s ease, visibility .6s; }
.splash.out { opacity: 0; visibility: hidden; }
.splash-glow { position: absolute; width: 420px; height: 420px; border-radius: 50%; background: radial-gradient(circle, #2ee59d40, transparent 65%); animation: glow 2.4s ease-out both; }
.splash-logo { width: 112px; height: 112px; position: relative; animation: pop .9s cubic-bezier(.2,1.4,.4,1) both; }
.sl-bg { fill: var(--accent); }
.sl-bubble { fill: var(--accent-ink); }
.sl-wave { stroke: var(--accent); stroke-width: 3; stroke-linecap: round; fill: none; transform-box: fill-box; transform-origin: center; animation: wave 1s ease-in-out .5s infinite alternate; }
.sl-wave.w2 { animation-delay: .62s; } .sl-wave.w3 { animation-delay: .74s; } .sl-wave.w4 { animation-delay: .86s; }
.splash-word { position: relative; font-size: 34px; font-weight: 800; letter-spacing: -.02em; animation: rise .8s ease-out .45s both; }
.splash-word span { color: var(--accent); margin-left: 6px; }
@keyframes pop { from { transform: scale(.2) rotate(-18deg); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes rise { from { transform: translateY(14px); opacity: 0; filter: blur(6px); } to { transform: none; opacity: 1; filter: none; } }
@keyframes glow { from { transform: scale(.3); opacity: 0; } 60% { opacity: 1; } to { transform: scale(1.15); opacity: .8; } }
@keyframes wave { to { transform: scaleY(1.6); } }

/* ---------- rail ---------- */
.rail-btn.home { background: var(--bg2); padding: 0; overflow: hidden; }
.rail-btn.home img { width: 100%; height: 100%; }
.rail-btn.home.active, .rail-btn.home:hover { background: var(--bg2); }
.rail-sep { width: 32px; height: 2px; background: var(--line); border-radius: 2px; flex: none; }
.rail-btn img.gi { width: 100%; height: 100%; border-radius: inherit; object-fit: cover; }

/* ---------- canais de voz ---------- */
.chan .lock { font-size: 11px; opacity: .6; }
.vusers { padding: 0 0 4px 30px; display: grid; gap: 2px; }
.vuser { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); padding: 3px 4px; border-radius: 6px; }
.vuser .avatar { width: 22px; height: 22px; font-size: 10px; }
.vuser .avatar.speaking, .tile.speaking { box-shadow: 0 0 0 2px var(--accent); }
.vuser .flags { margin-left: auto; font-size: 11px; display: flex; gap: 4px; }
.live { background: var(--danger); color: #fff; font-size: 10px; font-weight: 800; padding: 1px 5px; border-radius: 4px; }

/* ---------- painel de voz ---------- */
.voice-panel { border-top: 1px solid var(--line); background: var(--bg1); padding: 8px 10px; display: grid; gap: 8px; }
.vp-status { display: flex; align-items: center; gap: 8px; }
.vp-status > div { flex: 1; min-width: 0; display: grid; line-height: 1.2; }
.vp-status strong { color: var(--accent); font-size: 13px; }
.vp-status span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vp-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px var(--accent); }
#vpLeave { color: var(--danger); }
.vp-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.vp-btn { display: grid; justify-items: center; gap: 2px; background: var(--bg2); border: 0; border-radius: 8px; padding: 6px 4px; font-size: 15px; }
.vp-btn span { font-size: 11px; color: var(--muted); }
.vp-btn:hover, .vp-btn.on { background: var(--bg3); }
.vp-btn.on span { color: var(--accent); }
.icon-btn[aria-pressed="true"] { color: var(--danger); }

/* ---------- FiveM ---------- */
.fivem { margin: 0 8px 8px; padding: 10px; border-radius: var(--radius); background: var(--bg2); border: 1px solid var(--line); font-size: 13px; display: grid; gap: 4px; cursor: pointer; }
.fivem .fv-top { display: flex; align-items: center; gap: 8px; }
.fivem .fv-top strong { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fivem .on { color: var(--accent); } .fivem .off { color: var(--danger); }
.fivem ul { margin: 4px 0 0; padding: 0; list-style: none; max-height: 160px; overflow-y: auto; display: grid; gap: 2px; }
.fivem li { display: flex; justify-content: space-between; color: var(--muted); }

/* ---------- palco (voz / vídeo) ---------- */
.stage { display: flex; flex-direction: column; min-width: 0; background: #07080b; }
.tiles { flex: 1; display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); grid-auto-rows: minmax(180px, 1fr); gap: 10px; padding: 14px; overflow-y: auto; }
.tiles.focus { grid-template-columns: 1fr; grid-auto-rows: auto; }
.tiles.focus .tile:not(.focused) { display: none; }
.tile { position: relative; background: var(--bg2); border-radius: 12px; overflow: hidden; display: grid; place-items: center; cursor: pointer; min-height: 180px; }
.tile.focused { min-height: calc(100vh - 90px); }
.tile video { width: 100%; height: 100%; object-fit: contain; background: #000; position: absolute; inset: 0; }
.tile .avatar { width: 80px; height: 80px; font-size: 28px; }
.tile .label { position: absolute; left: 10px; bottom: 10px; background: #000a; padding: 4px 10px; border-radius: 6px; font-size: 13px; display: flex; gap: 6px; align-items: center; z-index: 1; }
.tile .fs { position: absolute; right: 8px; top: 8px; z-index: 1; background: #000a; }

/* ---------- mensagens: extras ---------- */
.msg.mention { background: #2ee59d12; }
.msg.ephemeral { background: #5ab0ff10; }
.msg .eph { font-size: 11px; color: #5ab0ff; }
.msg .edited { font-size: 11px; color: var(--muted); margin-left: 4px; }
.msg .bot { background: var(--accent); color: var(--accent-ink); font-size: 10px; font-weight: 800; padding: 1px 5px; border-radius: 4px; }
.msg .tools button:hover { color: var(--text); }
.msg .tools button.del:hover { color: var(--danger); }
.reacts { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.react { border: 1px solid var(--line); background: var(--bg1); border-radius: 8px; padding: 2px 8px; font-size: 13px; }
.react.mine { border-color: var(--accent); background: #2ee59d1a; }
.edit-box { width: 100%; background: var(--bg3); border: 1px solid var(--line); border-radius: 8px; padding: 8px; color: var(--text); resize: vertical; }
.avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }

/* ---------- membros ---------- */
.member { cursor: pointer; }
.member .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app.no-members { grid-template-columns: 72px 240px 1fr; }
.app.no-members .members { display: none; }
.popover { position: fixed; z-index: 40; width: 280px; background: var(--bg0); border: 1px solid var(--line); border-radius: 12px; padding: 16px; display: grid; gap: 10px; box-shadow: 0 12px 40px #0008; }
.popover .ph { display: flex; gap: 12px; align-items: center; }
.popover .ph .avatar { width: 56px; height: 56px; font-size: 20px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 3px 8px; border-radius: 999px; background: var(--bg2); border: 1px solid var(--line); }
.chip i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
button.chip.off { opacity: .45; }
.pop-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.pop-actions .btn { padding: 6px 10px; font-size: 13px; }

/* ---------- modais com abas ---------- */
.modal.wide { width: min(760px, calc(100% - 32px)); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tabs button { background: none; border: 0; padding: 8px 12px; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs button.on { color: var(--text); border-color: var(--accent); }
.modal select, .modal textarea { background: var(--bg0); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; color: var(--text); font: inherit; text-transform: none; }
.role-row { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 8px; background: var(--bg2); }
.role-row strong { flex: 1; }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px; }
.check { display: flex; align-items: center; gap: 8px; text-transform: none; font-size: 14px; color: var(--text); font-weight: 400; letter-spacing: 0; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.row { display: flex; gap: 8px; align-items: end; }
.row > * { flex: 1; }
.sources { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; max-height: 50vh; overflow-y: auto; }
.source { background: var(--bg2); border: 2px solid transparent; border-radius: 10px; padding: 6px; display: grid; gap: 4px; font-size: 12px; text-align: left; }
.source img { width: 100%; aspect-ratio: 16/9; object-fit: cover; border-radius: 6px; background: #000; }
.source.on { border-color: var(--accent); }
.source span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grow { flex: 1; }
.incoming { position: fixed; right: 20px; bottom: 20px; z-index: 60; background: var(--bg0); border: 1px solid var(--accent); border-radius: 14px; padding: 16px; display: grid; gap: 10px; box-shadow: 0 12px 40px #000a; }
.me { gap: 6px; }
.me .icon-btn { width: 30px; font-size: 16px; }
.me-info span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
