:root {
  --bg-rail: #1e1f22;
  --bg-side: #2b2d31;
  --bg-main: #313338;
  --bg-input: #383a40;
  --bg-hover: #35373c;
  --bg-active: #404249;
  --bg-float: #111214;
  --text: #dbdee1;
  --text-strong: #f2f3f5;
  --muted: #949ba4;
  --accent: #5865f2;
  --accent-hover: #4752c4;
  --green: #23a55a;
  --red: #da373c;
  --yellow: #f0b232;
  --radius: 8px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg-main); color: var(--text); font: 15px/1.4 "Segoe UI", system-ui, sans-serif; overflow: hidden; }
button { font: inherit; color: var(--text); background: var(--bg-active); border: 0; border-radius: 4px; padding: 8px 14px; cursor: pointer; }
button:hover { filter: brightness(1.15); }
button.primary { background: var(--accent); color: #fff; }
button.primary:hover { background: var(--accent-hover); filter: none; }
button.danger { background: var(--red); color: #fff; }
button.ghost { background: transparent; padding: 6px; }
button.wide { width: 100%; }
button:disabled { opacity: .5; cursor: default; }
input, textarea, select { font: inherit; color: var(--text); background: var(--bg-rail); border: 0; border-radius: 4px; padding: 10px; width: 100%; outline: none; }
input:focus, textarea:focus, select:focus { box-shadow: 0 0 0 2px var(--accent); }
label { display: block; font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--muted); margin: 12px 0 4px; }
label input, label select { margin-top: 6px; text-transform: none; font-weight: 400; font-size: 15px; }
label.check { display: flex; align-items: center; gap: 8px; text-transform: none; font-weight: 400; font-size: 14px; color: var(--text); }
label.check input { width: auto; margin: 0; }
a { color: #00a8fc; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 13px; }
.error { color: #fa777c; min-height: 1.2em; font-size: 14px; }
.row { display: flex; gap: 8px; margin-top: 16px; }
.row > * { flex: 1; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #1a1b1e; border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---- conexão ---- */
.screen { height: 100%; display: flex; align-items: center; justify-content: center; background: radial-gradient(circle at 30% 20%, #3c45a5 0, #1e1f22 60%); padding: 16px; }
.card { background: var(--bg-main); border-radius: 8px; padding: 28px; width: 440px; max-width: 100%; box-shadow: 0 8px 30px rgba(0,0,0,.4); }
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { margin: 0; color: var(--text-strong); }
.logo { width: 44px; height: 44px; border-radius: 14px; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 22px; }
.tabs { display: flex; gap: 4px; margin: 16px 0 4px; background: var(--bg-rail); padding: 4px; border-radius: 6px; }
.tab { flex: 1; background: transparent; font-size: 14px; }
.tab.active { background: var(--bg-active); color: var(--text-strong); }
.server-line { font-size: 14px; }

/* ---- layout principal ---- */
#main { display: flex; height: 100%; }
#rail { width: 72px; background: var(--bg-rail); padding: 12px 0; display: flex; flex-direction: column; align-items: center; gap: 8px; overflow-y: auto; flex-shrink: 0; }
#rail .sep { width: 32px; height: 2px; background: var(--bg-active); border-radius: 1px; }
.rail-btn { position: relative; width: 48px; height: 48px; border-radius: 50%; background: var(--bg-main); display: grid; place-items: center; cursor: pointer; font-weight: 600; color: var(--text-strong); transition: border-radius .15s, background .15s; user-select: none; font-size: 15px; flex-shrink: 0; }
.rail-btn:hover, .rail-btn.active { border-radius: 16px; background: var(--accent); color: #fff; }
.rail-btn.add { color: var(--green); font-size: 26px; }
.rail-btn.add:hover { background: var(--green); color: #fff; }
.rail-btn .pill { position: absolute; left: -16px; width: 8px; border-radius: 0 4px 4px 0; background: #fff; height: 0; transition: height .15s; }
.rail-btn.unread .pill { height: 8px; }
.rail-btn:hover .pill { height: 20px; }
.rail-btn.active .pill { height: 40px; }
.badge { position: absolute; right: -4px; bottom: -4px; background: var(--red); color: #fff; font-size: 11px; font-weight: 700; border-radius: 8px; padding: 0 5px; border: 3px solid var(--bg-rail); }

#sidebar { width: 240px; background: var(--bg-side); display: flex; flex-direction: column; flex-shrink: 0; }
#sb-head { height: 48px; padding: 0 16px; display: flex; align-items: center; justify-content: space-between; font-weight: 600; color: var(--text-strong); border-bottom: 1px solid #1f2023; cursor: default; }
#sb-head.clickable { cursor: pointer; }
#sb-head.clickable:hover { background: var(--bg-hover); }
#sb-list { flex: 1; overflow-y: auto; padding: 8px; }
.cat { display: flex; justify-content: space-between; align-items: center; font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--muted); padding: 16px 4px 4px; }
.cat button { background: none; padding: 0 4px; color: var(--muted); font-size: 18px; line-height: 1; }
.chan { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 4px; color: var(--muted); cursor: pointer; margin: 1px 0; }
.chan:hover { background: var(--bg-hover); color: var(--text); }
.chan.active { background: var(--bg-active); color: var(--text-strong); }
.chan.unread { color: var(--text-strong); font-weight: 600; }
.chan .icon { width: 20px; text-align: center; opacity: .8; }
.chan .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chan .x { visibility: hidden; background: none; padding: 0 4px; color: var(--muted); }
.chan:hover .x { visibility: visible; }
.vmembers { margin: 0 0 4px 28px; }
.vmember { display: flex; align-items: center; gap: 8px; padding: 3px 6px; border-radius: 4px; color: var(--muted); font-size: 14px; }
.vmember .flags { margin-left: auto; font-size: 12px; display: flex; gap: 3px; }
.tag-live { background: var(--red); color: #fff; font-size: 10px; font-weight: 700; padding: 0 4px; border-radius: 3px; }

.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; flex-shrink: 0; position: relative; font-size: 14px; }
.avatar.sm { width: 22px; height: 22px; font-size: 11px; }
.avatar.lg { width: 80px; height: 80px; font-size: 32px; }
.avatar .dot { position: absolute; right: -2px; bottom: -2px; width: 12px; height: 12px; border-radius: 50%; border: 3px solid var(--bg-side); background: #80848e; }
.avatar .dot.on { background: var(--green); }
.speaking > .avatar, .avatar.speaking { box-shadow: 0 0 0 2px var(--bg-side), 0 0 0 4px var(--green); }

#voice-panel { background: #232428; border-bottom: 1px solid #1f2023; padding: 8px 10px; }
#voice-panel .vp-top { display: flex; align-items: center; justify-content: space-between; }
#voice-panel .vp-status { color: var(--green); font-weight: 700; font-size: 14px; }
#voice-panel .vp-where { color: var(--muted); font-size: 12px; cursor: pointer; }
#voice-panel .vp-where:hover { text-decoration: underline; }
#voice-panel .vp-btns { display: flex; gap: 6px; margin-top: 8px; }
#voice-panel .vp-btns button { flex: 1; padding: 6px; font-size: 13px; }
#user-panel { height: 56px; background: #232428; display: flex; align-items: center; padding: 0 8px; gap: 8px; }
#user-panel .who { flex: 1; min-width: 0; }
#user-panel .who b { display: block; color: var(--text-strong); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#user-panel .who span { font-size: 12px; color: var(--muted); }
.icon-btn { background: none; padding: 6px; border-radius: 4px; font-size: 16px; line-height: 1; color: var(--text); }
.icon-btn:hover { background: var(--bg-active); filter: none; }
.icon-btn.off { color: var(--red); }

#content { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--bg-main); }
#content-head { height: 48px; padding: 0 16px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid #26282c; flex-shrink: 0; }
#content-head .title { font-weight: 600; color: var(--text-strong); }
#content-head .sub { color: var(--muted); font-size: 14px; border-left: 1px solid var(--bg-active); padding-left: 10px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
#content-head .spacer { flex: 1; }
#content-body { flex: 1; display: flex; flex-direction: column; min-height: 0; }

#members { width: 240px; background: var(--bg-side); overflow-y: auto; padding: 8px; flex-shrink: 0; }
.member { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 4px; cursor: pointer; }
.member:hover { background: var(--bg-hover); }
.member.offline { opacity: .4; }
.member .crown { color: var(--yellow); font-size: 12px; }

/* ---- chat ---- */
.messages { flex: 1; overflow-y: auto; padding: 16px 0 8px; }
.msg { display: flex; gap: 16px; padding: 2px 16px; position: relative; }
.msg:hover { background: #2e3035; }
.msg.head { margin-top: 14px; }
.msg .gutter { width: 40px; flex-shrink: 0; }
.msg .avatar { width: 40px; height: 40px; }
.msg .time-mini { visibility: hidden; font-size: 11px; color: var(--muted); padding-top: 3px; text-align: right; display: block; }
.msg:hover .time-mini { visibility: visible; }
.msg .body { min-width: 0; flex: 1; }
.msg .author { font-weight: 600; color: var(--text-strong); margin-right: 6px; }
.msg .time { font-size: 12px; color: var(--muted); }
.msg .text { white-space: pre-wrap; word-wrap: break-word; }
.msg .actions { position: absolute; right: 16px; top: -12px; display: none; background: var(--bg-main); border: 1px solid #26282c; border-radius: 4px; }
.msg:hover .actions { display: flex; }
.msg .actions button { background: none; padding: 4px 8px; }
.msg.system .text { color: var(--muted); font-style: italic; }
.attach-img { max-width: 400px; max-height: 300px; border-radius: 6px; display: block; margin-top: 6px; cursor: pointer; }
.attach-file { display: inline-flex; gap: 10px; align-items: center; background: var(--bg-side); border: 1px solid #26282c; border-radius: 6px; padding: 10px 14px; margin-top: 6px; }
.attach-video { max-width: 480px; border-radius: 6px; margin-top: 6px; display: block; }
.empty-chan { padding: 16px; }
.empty-chan h2 { color: var(--text-strong); margin: 0 0 4px; }
.composer { padding: 0 16px 20px; }
.composer .typing { height: 18px; font-size: 12px; color: var(--muted); padding: 2px 4px; }
.composer .box { display: flex; align-items: flex-end; background: var(--bg-input); border-radius: 8px; padding: 0 8px; }
.composer textarea { background: transparent; resize: none; max-height: 200px; box-shadow: none !important; padding: 11px 6px; }
.composer .attach-btn { background: none; font-size: 20px; padding: 8px; color: var(--muted); }
.pending-files { display: flex; gap: 8px; flex-wrap: wrap; padding: 8px 0; }
.pending-files .pf { background: var(--bg-input); border-radius: 6px; padding: 6px 10px; font-size: 13px; display: flex; gap: 6px; align-items: center; }
.drop-hint { position: fixed; inset: 0; background: rgba(88,101,242,.4); display: grid; place-items: center; font-size: 24px; font-weight: 700; color: #fff; z-index: 50; pointer-events: none; }

/* ---- amigos ---- */
.friends { padding: 16px 24px; overflow-y: auto; flex: 1; }
.ftabs { display: flex; gap: 8px; align-items: center; }
.ftabs button { background: none; padding: 4px 10px; color: var(--muted); }
.ftabs button.active { background: var(--bg-active); color: var(--text-strong); }
.ftabs button.addf { background: var(--green); color: #fff; }
.ftabs button.addf.active { background: none; color: var(--green); }
.fsection { font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--muted); margin: 20px 0 8px; }
.frow { display: flex; align-items: center; gap: 12px; padding: 10px 8px; border-top: 1px solid #3f4147; border-radius: 6px; }
.frow:hover { background: var(--bg-hover); }
.frow .info { flex: 1; }
.frow .info b { color: var(--text-strong); }
.frow .info div { font-size: 13px; color: var(--muted); }
.frow .acts { display: flex; gap: 8px; }
.round { width: 36px; height: 36px; border-radius: 50%; background: var(--bg-side); padding: 0; display: grid; place-items: center; }
.addbox { display: flex; gap: 8px; background: var(--bg-rail); border-radius: 8px; padding: 6px; margin-top: 10px; }
.addbox input { background: transparent; box-shadow: none !important; }

/* ---- chamada ---- */
#stage { background: #000; display: flex; flex-direction: column; min-height: 0; }
#stage.full { flex: 1; }
#stage.split { height: 52%; flex-shrink: 0; }
.tiles { flex: 1; display: grid; gap: 8px; padding: 12px; min-height: 0; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); grid-auto-rows: minmax(140px, 1fr); overflow: auto; }
.tiles.focused { grid-template-columns: 1fr; }
.tile { position: relative; background: var(--bg-side); border-radius: 8px; overflow: hidden; display: grid; place-items: center; min-height: 140px; cursor: pointer; }
.tile.speaking { box-shadow: inset 0 0 0 3px var(--green); }
.tile video { width: 100%; height: 100%; object-fit: contain; background: #000; position: absolute; inset: 0; }
.tile.cam video { object-fit: cover; }
.tile.self.cam video { transform: scaleX(-1); }
.tile .label { position: absolute; left: 8px; bottom: 8px; background: rgba(0,0,0,.6); padding: 2px 8px; border-radius: 4px; font-size: 13px; color: #fff; z-index: 2; display: flex; gap: 6px; align-items: center; }
.tiles.focused .tile:not(.focus) { display: none; }
.controls { display: flex; justify-content: center; gap: 12px; padding: 12px; }
.controls button { width: 52px; height: 52px; border-radius: 50%; background: var(--bg-active); font-size: 20px; padding: 0; }
.controls button.on { background: #fff; color: #000; }
.controls button.off { background: var(--red); color: #fff; }
.controls button.hang { background: var(--red); color: #fff; }

/* ---- modais / toasts ---- */
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: grid; place-items: center; z-index: 100; padding: 16px; }
.modal { background: var(--bg-main); border-radius: 8px; width: 460px; max-width: 100%; max-height: 90vh; overflow: auto; padding: 20px; }
.modal h2 { margin: 0 0 8px; color: var(--text-strong); }
.modal .foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.modal.wide { width: 760px; }
.choice { display: flex; gap: 12px; align-items: center; border: 1px solid var(--bg-active); border-radius: 8px; padding: 14px; margin-top: 10px; cursor: pointer; }
.choice:hover { background: var(--bg-hover); }
.radio-row { display: flex; gap: 10px; margin-top: 6px; }
.radio-row label { flex: 1; margin: 0; display: flex; align-items: center; gap: 8px; background: var(--bg-side); padding: 12px; border-radius: 6px; cursor: pointer; text-transform: none; font-size: 15px; color: var(--text); font-weight: 400; }
.radio-row input { width: auto; }
.sources { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; margin-top: 10px; }
.source { background: var(--bg-side); border-radius: 6px; padding: 8px; cursor: pointer; border: 2px solid transparent; }
.source.sel { border-color: var(--accent); }
.source img { width: 100%; border-radius: 4px; display: block; background: #000; }
.source div { font-size: 13px; margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.invite-code { display: flex; gap: 8px; background: var(--bg-rail); padding: 6px; border-radius: 6px; margin-top: 6px; align-items: center; }
.invite-code code { flex: 1; font-size: 16px; padding-left: 6px; color: var(--text-strong); }
.ringing { text-align: center; }
.ringing .avatar { margin: 10px auto; animation: pulse 1.2s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(35,165,90,.6); } 50% { box-shadow: 0 0 0 14px rgba(35,165,90,0); } }
.menu { position: fixed; background: var(--bg-float); border-radius: 6px; padding: 6px; z-index: 120; min-width: 200px; box-shadow: 0 8px 16px rgba(0,0,0,.4); }
.menu div { padding: 8px 10px; border-radius: 3px; cursor: pointer; font-size: 14px; }
.menu div:hover { background: var(--accent); color: #fff; }
.menu div.danger { color: #fa777c; }
.menu div.danger:hover { background: var(--red); color: #fff; }
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { background: var(--bg-float); padding: 10px 16px; border-radius: 6px; box-shadow: 0 4px 12px rgba(0,0,0,.4); max-width: 360px; }
.toast.err { border-left: 4px solid var(--red); }
#offline-bar { position: fixed; top: 0; left: 0; right: 0; background: var(--red); color: #fff; text-align: center; padding: 4px; font-size: 13px; z-index: 300; }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.85); display: grid; place-items: center; z-index: 150; cursor: zoom-out; }
.lightbox img { max-width: 92vw; max-height: 92vh; }
.hostbox { background: var(--bg-rail); border-radius: 6px; padding: 10px; margin-top: 8px; font-size: 14px; }
.hostbox code { color: var(--text-strong); }

/* ---- volume individual / ações no quadro ---- */
.vmember { cursor: default; }
.vmember[title] { cursor: pointer; }
.vmember[title]:hover { background: var(--bg-hover); }
.tile-acts { position: absolute; right: 8px; top: 8px; display: flex; gap: 6px; z-index: 3; opacity: 0; transition: opacity .15s; }
.tile:hover .tile-acts { opacity: 1; }
.tile-acts button { background: rgba(0,0,0,.65); color: #fff; padding: 4px 10px; font-size: 13px; }
.vol-pop { padding: 12px; min-width: 260px; }
.vol-pop > div:hover, .vol-pop .vol-row:hover { background: none; color: inherit; }
.vol-pop .vol-title { font-weight: 700; color: var(--text-strong); padding: 0 0 8px; cursor: default; }
.vol-pop .vol-row { display: flex; align-items: center; gap: 10px; padding: 0; cursor: default; }
.vol-pop .vol-row b { width: 44px; text-align: right; }
.vol-range { padding: 0; accent-color: var(--accent); box-shadow: none !important; background: transparent; }
.vol-check { margin: 10px 0 4px; }
.vol-pop .vol-reset { color: var(--muted); font-size: 13px; padding: 6px 0 0; }
.vol-pop .vol-reset:hover { color: var(--text-strong); background: none; text-decoration: underline; }
.source-name { display: flex; align-items: center; gap: 6px; }
.source-icon { width: 16px !important; height: 16px; border-radius: 0 !important; background: none !important; flex-shrink: 0; }
.share-opts label { margin-top: 14px; }
.q-tag { background: var(--accent); color: #fff; border-radius: 3px; padding: 0 4px; font-size: 11px; margin-left: 6px; }
.vol-pop .vol-sep { height: 1px; background: var(--bg-active); margin: 8px 0 4px; padding: 0; }
.vol-pop .vol-item { padding: 8px 10px; border-radius: 3px; cursor: pointer; }
.vol-pop .vol-item:hover { background: var(--accent); color: #fff; }
