/* =========================================================================
   DISCORDIA - estilos (tema Discord escuro/claro, responsivo)
   ========================================================================= */
:root {
  --bg1: #313338; --bg2: #2b2d31; --bg3: #1e1f22; --panel: #232428; --floating: #111214;
  --text: #dbdee1; --muted: #949ba4; --header: #f2f3f5;
  --brand: #5865f2; --brand-h: #4752c4; --green: #23a55a; --red: #f23f43; --yellow: #f0b232; --link: #00a8fc;
  --hover: rgba(78, 80, 88, .3); --sel: rgba(78, 80, 88, .6); --border: rgba(255, 255, 255, .07);
  --input: #383a40; --shadow: 0 8px 16px rgba(0, 0, 0, .35);
  --call-bg: #0e0f11;
  color-scheme: dark;
}
[data-theme="light"] {
  --bg1: #ffffff; --bg2: #f2f3f5; --bg3: #e3e5e8; --panel: #ebedef; --floating: #ffffff;
  --text: #313338; --muted: #5c5e66; --header: #060607;
  --hover: rgba(116, 124, 138, .16); --sel: rgba(116, 124, 138, .3); --border: rgba(0, 0, 0, .08);
  --input: #ebedef; --shadow: 0 8px 16px rgba(0, 0, 0, .18);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: "gg sans", "Noto Sans", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  font-size: 16px; color: var(--text); background: var(--bg3);
  overflow: hidden; overscroll-behavior: none; -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
a { color: var(--link); text-decoration: none; cursor: pointer; }
a:hover { text-decoration: underline; }
.hidden { display: none !important; }
.icon { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.ic { display: block; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(128, 132, 142, .35); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(128, 132, 142, .6); }
input[type="range"] { accent-color: var(--brand); }

/* ---------- Layout ---------- */
#app { display: flex; height: 100vh; height: 100dvh; overflow: hidden; }
#drawer { display: flex; flex-shrink: 0; }
#backdrop { display: none; }
#main { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg1); }
#content { flex: 1; min-height: 0; display: flex; }
#view { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; position: relative; }
#connBanner { background: var(--yellow); color: #111; text-align: center; font-size: 13px; font-weight: 600; padding: 4px 8px; }

/* ---------- Rail ---------- */
#rail { width: 72px; background: var(--bg3); display: flex; flex-direction: column; align-items: center; padding: 12px 0; gap: 8px; flex-shrink: 0; }
.rail-item { position: relative; width: 48px; height: 48px; cursor: pointer; }
.rail-icon { width: 48px; height: 48px; border-radius: 16px; background: var(--brand); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 20px; user-select: none; }
.rail-pill { position: absolute; left: -12px; top: 4px; width: 8px; height: 40px; background: var(--header); border-radius: 0 4px 4px 0; }
.rail-sep { width: 32px; height: 2px; background: var(--border); border-radius: 1px; }

/* ---------- Barra lateral ---------- */
#sidebar { width: 240px; background: var(--bg2); display: flex; flex-direction: column; min-width: 0; flex: 1; }
#sbHeader { height: 48px; flex-shrink: 0; display: flex; align-items: center; justify-content: space-between; padding: 0 16px; font-weight: 600; color: var(--header); border-bottom: 1px solid rgba(0, 0, 0, .25); cursor: pointer; }
#sbHeader:hover { background: var(--hover); }
#channels { flex: 1; overflow-y: auto; padding: 8px; }
.cat { display: flex; align-items: center; gap: 2px; padding: 16px 4px 4px; font-size: 12px; font-weight: 600; color: var(--muted); cursor: pointer; user-select: none; }
.cat:hover { color: var(--header); }
.cat .icon { transition: transform .15s; }
.cat.closed .icon { transform: rotate(-90deg); }
.cat-gap { height: 4px; }
.chan { position: relative; display: flex; align-items: center; gap: 6px; height: 34px; padding: 0 8px; margin: 1px 0; border-radius: 4px; color: var(--muted); cursor: pointer; user-select: none; }
.chan:hover { background: var(--hover); color: var(--text); }
.chan.active { background: var(--sel); color: var(--header); }
.chan.muted:not(.active) { opacity: .5; }
.chan.connected .icon:first-of-type { color: var(--green); }
.chan-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chan-pip { position: absolute; left: -8px; top: 13px; width: 4px; height: 8px; background: var(--header); border-radius: 0 4px 4px 0; display: none; }
.chan.unread { color: var(--header); }
.chan.unread .chan-name { font-weight: 600; }
.chan.unread .chan-pip { display: block; }
.badge { background: var(--red); color: #fff; font-size: 12px; font-weight: 700; min-width: 16px; padding: 0 5px; border-radius: 8px; text-align: center; line-height: 16px; }

.vuser { display: flex; align-items: center; gap: 8px; margin: 1px 0 1px 20px; padding: 3px 8px; border-radius: 4px; color: var(--muted); cursor: pointer; font-size: 15px; }
.vuser:hover { background: var(--hover); color: var(--text); }
.vuser-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vuser-icons { display: flex; align-items: center; gap: 4px; color: var(--muted); }

.avatar { position: relative; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 600; flex-shrink: 0; user-select: none; }
[data-speak].speaking .avatar { box-shadow: 0 0 0 2px var(--green); }
.status-dot { position: absolute; right: -2px; bottom: -2px; width: 34%; height: 34%; min-width: 9px; min-height: 9px; border-radius: 50%; box-shadow: 0 0 0 2.5px var(--bg2); background: #80848e; }
.status-dot.online { background: var(--green); }
.status-dot.idle { background: var(--yellow); }
.status-dot.dnd { background: var(--red); }
.live-badge { background: var(--red); color: #fff; font-size: 10px; font-weight: 700; letter-spacing: .3px; padding: 1px 5px; border-radius: 4px; text-transform: uppercase; white-space: nowrap; }

#sbBottom { background: var(--panel); flex-shrink: 0; padding-bottom: env(safe-area-inset-bottom); }
#voiceBar { padding: 8px 8px 6px; border-bottom: 1px solid var(--border); }
.vb-top { display: flex; align-items: center; gap: 4px; }
.vb-info { flex: 1; min-width: 0; cursor: pointer; padding: 2px 4px; border-radius: 4px; }
.vb-info:hover { background: var(--hover); }
.vb-status { display: flex; align-items: center; gap: 4px; color: var(--green); font-size: 14px; font-weight: 600; }
.vb-chan { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.signal { display: inline-flex; color: var(--green); }
.signal.ok { color: var(--yellow); }
.signal.bad { color: var(--red); }
.vb-btns { display: flex; gap: 6px; margin-top: 6px; }
.vb-btn { flex: 1; height: 32px; border-radius: 4px; background: var(--bg2); color: var(--text); display: flex; align-items: center; justify-content: center; }
.vb-btn:hover { background: var(--hover); }
.vb-btn.on { background: var(--header); color: var(--bg3); }

#userPanel { height: 52px; display: flex; align-items: center; padding: 0 8px; gap: 2px; }
.upanel-user { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; padding: 4px; border-radius: 4px; cursor: pointer; }
.upanel-user:hover { background: var(--hover); }
.upanel-text { min-width: 0; }
.upanel-name { font-size: 14px; font-weight: 600; color: var(--header); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 16px; }
.upanel-status { font-size: 12px; color: var(--muted); line-height: 13px; }
.ubtn { width: 32px; height: 32px; border-radius: 4px; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; }
.ubtn:hover { background: var(--hover); color: var(--text); }
.ubtn.off { color: var(--red); }
.split { display: inline-flex; align-items: center; }
.ubtn.chev { width: 14px; height: 24px; border-radius: 4px; margin-left: -4px; }

/* ---------- Barra superior ---------- */
#topbar { height: 48px; flex-shrink: 0; display: flex; align-items: center; gap: 8px; padding: 0 12px 0 16px; border-bottom: 1px solid rgba(0, 0, 0, .25); box-shadow: 0 1px 0 rgba(0, 0, 0, .05); font-weight: 600; color: var(--header); }
#topbar h2 { margin: 0; font-size: 16px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tb-icon { color: var(--muted); display: inline-flex; }
.spacer { flex: 1; }
.icon-btn { position: relative; width: 32px; height: 32px; border-radius: 4px; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.icon-btn:hover { color: var(--text); }
.icon-btn.on { color: var(--header); }
.dot-badge { position: absolute; top: 2px; right: 2px; width: 10px; height: 10px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 2px var(--bg1); }
.mobile-only { display: none; }

/* ---------- Painel lateral direito ---------- */
#side { width: 0; overflow: hidden; background: var(--bg2); border-left: 1px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; }
#side.open { width: 240px; }
#side.open:has(.chat) { width: 360px; background: var(--bg1); }
.side-head { height: 48px; flex-shrink: 0; display: flex; align-items: center; justify-content: space-between; padding: 0 8px 0 16px; font-weight: 600; color: var(--header); border-bottom: 1px solid rgba(0, 0, 0, .25); }
.members { flex: 1; overflow-y: auto; padding: 8px; }
.member-cat { padding: 16px 8px 4px; font-size: 12px; font-weight: 600; text-transform: uppercase; color: var(--muted); }
.member { display: flex; align-items: center; gap: 12px; padding: 4px 8px; border-radius: 4px; cursor: pointer; color: var(--muted); }
.member:hover { background: var(--hover); color: var(--text); }
.member-text { min-width: 0; }
.member-name { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.member-sub { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); }

/* ---------- Chat ---------- */
.chat { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.chat-scroll { flex: 1; min-height: 0; overflow-y: auto; }
.chat-intro { padding: 16px 16px 8px; }
.intro-icon { width: 68px; height: 68px; border-radius: 50%; background: #41434a; color: #fff; display: flex; align-items: center; justify-content: center; }
.chat-intro h1 { margin: 8px 0 4px; font-size: 30px; color: var(--header); }
.chat-intro p { margin: 0; color: var(--muted); }
.msgs { padding-bottom: 12px; }
.date-div { position: relative; height: 0; margin: 20px 16px 8px; border-top: 1px solid var(--border); }
.date-div span { position: absolute; left: 50%; top: -9px; transform: translateX(-50%); background: var(--bg1); padding: 0 8px; font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.msg { position: relative; display: grid; grid-template-columns: 56px minmax(0, 1fr); padding: 2px 16px 2px 0; margin-top: 17px; }
.msg.grouped { margin-top: 0; }
.msg:hover { background: rgba(2, 2, 2, .06); }
.msg.mentioned { background: rgba(250, 166, 26, .1); box-shadow: inset 2px 0 0 var(--yellow); }
.msg.mentioned:hover { background: rgba(250, 166, 26, .14); }
.msg.flash { animation: flash 1.8s; }
@keyframes flash { 0%, 60% { background: rgba(88, 101, 242, .25); } 100% { background: transparent; } }
.msg-reply { grid-column: 2; display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 14px; color: var(--muted); margin-bottom: 2px; cursor: pointer; }
.msg-reply:hover .reply-text { color: var(--text); }
.reply-name { font-weight: 600; color: var(--text); white-space: nowrap; }
.reply-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-avatar { grid-column: 1; padding-left: 16px; cursor: pointer; margin-top: 2px; }
.msg-hover-time { grid-column: 1; text-align: right; padding-right: 8px; font-size: 11px; line-height: 22px; color: var(--muted); visibility: hidden; align-self: start; }
.msg:hover .msg-hover-time { visibility: visible; }
.msg-body { grid-column: 2; min-width: 0; }
.msg-head { display: flex; align-items: baseline; gap: 8px; }
.msg-name { font-weight: 500; color: var(--header); cursor: pointer; }
.msg-name:hover { text-decoration: underline; }
.msg-time { font-size: 12px; color: var(--muted); }
.msg-text { line-height: 1.375; word-break: break-word; overflow-wrap: anywhere; }
.msg-text.jumbo { font-size: 40px; line-height: 1.15; }
.edited { font-size: 10px; color: var(--muted); }
.md-code { background: var(--bg2); border-radius: 3px; padding: .1em .3em; font-family: Consolas, "Courier New", monospace; font-size: 85%; }
.md-pre { background: var(--bg2); border: 1px solid var(--border); border-radius: 4px; padding: 8px; margin: 4px 0; overflow-x: auto; white-space: pre-wrap; font-family: Consolas, "Courier New", monospace; font-size: 14px; }
.md-quote { border-left: 4px solid #4e5058; padding-left: 12px; margin: 2px 0; }
.spoiler { background: #202225; color: transparent; border-radius: 3px; padding: 0 2px; cursor: pointer; user-select: none; }
.spoiler.revealed { background: var(--hover); color: inherit; user-select: text; }
.mention { background: rgba(88, 101, 242, .3); color: #c9cdfb; border-radius: 3px; padding: 0 2px; font-weight: 500; }
[data-theme="light"] .mention { color: #3c45a5; }
.mention.me { background: rgba(250, 166, 26, .18); color: var(--yellow); }
.reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.rx { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 8px; border: 1px solid transparent; background: var(--hover); font-size: 14px; }
.rx:hover { border-color: var(--muted); }
.rx.me { background: rgba(88, 101, 242, .25); border-color: var(--brand); }
.rx-n { font-weight: 600; font-size: 13px; color: var(--muted); }
.msg-tools { position: absolute; right: 16px; top: -16px; display: none; background: var(--bg1); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); padding: 2px; gap: 2px; z-index: 2; }
.msg:hover .msg-tools, .msg:focus-within .msg-tools { display: flex; }
.tool { width: 32px; height: 28px; border-radius: 4px; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; }
.tool:hover { background: var(--hover); color: var(--text); }
.tool.emo { font-size: 16px; }
.msg.editing { background: rgba(2, 2, 2, .06); }
.edit-ta { width: 100%; background: var(--input); border: 0; border-radius: 8px; padding: 10px 12px; resize: none; outline: none; font-size: 16px; line-height: 1.375; }
.edit-hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.jump-btn { position: absolute; left: 50%; bottom: 84px; transform: translateX(-50%); z-index: 3; display: none; align-items: center; gap: 6px; padding: 5px 14px; border-radius: 16px; background: var(--brand); color: #fff; font-size: 13px; font-weight: 600; box-shadow: var(--shadow); }
.jump-btn.show { display: inline-flex; }

.chat-bottom { flex-shrink: 0; padding: 0 16px; }
.composer { position: relative; }
.composer-box { display: flex; align-items: flex-end; gap: 4px; background: var(--input); border-radius: 8px; padding: 0 6px 0 16px; }
.composer-ta { flex: 1; min-width: 0; background: transparent; border: 0; outline: 0; resize: none; padding: 11px 0; line-height: 22px; font-size: 16px; max-height: 40vh; color: var(--text); }
.composer-ta::placeholder { color: var(--muted); }
.composer-box .icon-btn { width: 36px; height: 44px; }
.reply-bar { display: flex; align-items: center; justify-content: space-between; background: var(--bg2); border-radius: 8px 8px 0 0; padding: 4px 8px 4px 16px; font-size: 13px; color: var(--muted); }
.reply-bar + .composer-box { border-radius: 0 0 8px 8px; }
.typing { height: 24px; display: flex; align-items: center; gap: 6px; padding: 0 4px; font-size: 13px; color: var(--header); overflow: hidden; white-space: nowrap; }
.dots { display: inline-flex; gap: 3px; }
.dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--header); animation: blink 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: .2s; }
.dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 60%, 100% { opacity: .25; } 30% { opacity: 1; } }
.ac { position: absolute; left: 0; right: 0; bottom: calc(100% + 8px); background: var(--floating); border-radius: 8px; box-shadow: var(--shadow); padding: 8px; z-index: 20; max-height: 40vh; overflow-y: auto; }
.ac-title { font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--muted); padding: 4px 8px; }
.ac-item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 4px; cursor: pointer; }
.ac-item.on, .ac-item:hover { background: var(--hover); }
.ac-all { width: 22px; height: 22px; border-radius: 50%; background: var(--brand); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 13px; }

/* ---------- Canal de voz: previa ---------- */
.voice-preview { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 24px; text-align: center; color: #fff;
  background: radial-gradient(ellipse 90% 70% at 50% 115%, #5563e6 0%, #3037a8 35%, #1e2058 65%, #14142c 100%); }
.voice-preview h1 { margin: 0; font-size: 32px; font-weight: 700; }
.voice-preview p { margin: 0; font-size: 14px; color: rgba(255, 255, 255, .7); }
.vp-people { display: flex; flex-wrap: wrap; gap: 24px; justify-content: center; max-width: 640px; }
.vp-person { display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: 14px; max-width: 96px; }
.vp-person span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.vp-person.speaking .avatar { box-shadow: 0 0 0 3px var(--green); }

/* ---------- Canal de voz: chamada ---------- */
.voice-view { flex: 1; min-height: 0; position: relative; display: flex; flex-direction: column; background: var(--call-bg); }
#callArea { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 12px; padding: 12px 12px 92px; overflow: hidden; }
#callStage { display: none; }
#callArea.has-focus #callStage { display: flex; flex: 1; min-height: 0; }
#callStage .tile { width: 100%; height: 100%; aspect-ratio: auto; }
#callGrid { flex: 1; min-height: 0; display: grid; gap: 12px; overflow-y: auto; align-content: center; justify-content: center; grid-template-columns: minmax(0, 900px); }
#callGrid[data-n="2"] { grid-template-columns: repeat(2, minmax(0, 520px)); }
#callGrid[data-n="3"], #callGrid[data-n="4"] { grid-template-columns: repeat(2, minmax(0, 480px)); }
#callGrid[data-n="5"], #callGrid[data-n="6"] { grid-template-columns: repeat(3, minmax(0, 360px)); }
#callGrid[data-n="7"], #callGrid[data-n="8"], #callGrid[data-n="9"] { grid-template-columns: repeat(3, minmax(0, 300px)); }
#callGrid[data-n="10"] { grid-template-columns: repeat(4, minmax(0, 260px)); }
#callArea.has-focus #callGrid { flex: none; display: flex; gap: 8px; overflow-x: auto; overflow-y: hidden; height: 112px; justify-content: flex-start; }
#callArea.has-focus #callGrid .tile { height: 100%; aspect-ratio: 16 / 9; flex: none; }

.tile { position: relative; aspect-ratio: 16 / 9; background: #1e1f22; border-radius: 8px; overflow: hidden; display: flex; align-items: center; justify-content: center; cursor: pointer; color: #fff; outline: none; }
.tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.tile.is-stream video { object-fit: contain; background: #000; }
.tile.is-stream { background: #16171a; }
.tile.speaking { box-shadow: inset 0 0 0 3px var(--green); }
.tile:focus-visible { box-shadow: inset 0 0 0 3px var(--brand); }
.tile-ph { position: relative; display: flex; align-items: center; justify-content: center; color: rgba(255, 255, 255, .5); }
.tile-cta { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; text-align: center; padding: 12px; background: linear-gradient(160deg, #23253a, #16171a); }
.cta-title { font-weight: 600; font-size: 15px; }
.tile-banner { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px; background: rgba(0, 0, 0, .65); font-size: 13px; z-index: 2; }
.tile-pill { position: absolute; left: 8px; bottom: 8px; max-width: calc(100% - 16px); display: flex; align-items: center; gap: 6px; padding: 3px 8px; border-radius: 4px; background: rgba(0, 0, 0, .65); font-size: 13px; font-weight: 500; z-index: 1; }
.tile-icons { display: inline-flex; gap: 4px; color: #fff; }
.tile-icons:empty { display: none; }
.tile-name-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-tools { position: absolute; top: 8px; right: 8px; display: none; gap: 4px; z-index: 2; }
.tile:hover .tile-tools, .tile:focus-within .tile-tools { display: flex; }
.tile-tools .tool { width: 30px; height: 30px; background: rgba(0, 0, 0, .65); color: #fff; }
.tile-tools .tool:hover { background: rgba(0, 0, 0, .85); }
.spinner { width: 30px; height: 30px; border: 3px solid rgba(255, 255, 255, .25); border-top-color: #fff; border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.call-controls { position: absolute; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; gap: 10px; padding: 8px; z-index: 5; }
.cbtn { width: 48px; height: 48px; border-radius: 50%; background: rgba(60, 62, 68, .9); color: #fff; display: inline-flex; align-items: center; justify-content: center; transition: background .15s; }
.cbtn:hover { background: rgba(90, 93, 102, .95); }
.cbtn.on { background: #fff; color: #111; }
.cbtn.off { color: var(--red); }
.cbtn.hangup { background: var(--red); color: #fff; }
.cbtn.hangup:hover { background: #d83c3e; }
.only-mobile { display: none; }

/* ---------- Botoes / campos ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border-radius: 4px; padding: 8px 16px; font-size: 14px; font-weight: 500; color: #fff; transition: background .15s; }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.btn.primary { background: var(--brand); }
.btn.primary:hover { background: var(--brand-h); }
.btn.secondary { background: #4e5058; }
.btn.secondary:hover { background: #6d6f78; }
[data-theme="light"] .btn.secondary { background: #e3e5e8; color: var(--text); }
.btn.danger { background: var(--red); }
.btn.danger:hover { background: #d83c3e; }
.btn.link { background: transparent; color: var(--text); }
.btn.link:hover { text-decoration: underline; }
.btn.white { background: #fff; color: #111; padding: 10px 20px; font-size: 15px; }
.btn.white:hover { background: #e6e6e6; }
.input, .select { width: 100%; background: var(--bg3); border: 1px solid rgba(0, 0, 0, .3); border-radius: 4px; padding: 10px; outline: none; font-size: 16px; }
.input:focus, .select:focus { border-color: var(--brand); }
.select option { background: var(--bg3); color: var(--text); }

/* ---------- Menus / popovers ---------- */
.ctx { position: fixed; z-index: 1000; min-width: 188px; max-width: min(320px, 92vw); background: var(--floating); border-radius: 4px; padding: 6px 8px; box-shadow: var(--shadow), 0 0 0 1px var(--border); font-size: 14px; }
.ctx-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 8px; margin: 2px 0; border-radius: 2px; cursor: pointer; color: var(--muted); }
[data-theme="dark"] .ctx-item { color: #b5bac1; }
.ctx-item:hover { background: var(--brand); color: #fff; }
.ctx-item.danger { color: var(--red); }
.ctx-item.danger:hover { background: var(--red); color: #fff; }
.ctx-item.disabled { opacity: .5; pointer-events: none; }
.ctx-label { flex: 1; }
.ctx-check { width: 18px; height: 18px; border: 1px solid var(--muted); border-radius: 3px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.ctx-check.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.ctx-sep { height: 1px; background: rgba(78, 80, 88, .48); margin: 4px; }
.ctx-slider { padding: 6px 8px 8px; }
.ctx-slider-top { display: flex; justify-content: space-between; font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.ctx-slider input { width: 100%; margin: 0; }
.pop { position: fixed; z-index: 1000; background: var(--floating); border-radius: 8px; box-shadow: var(--shadow), 0 0 0 1px var(--border); overflow: hidden; }
.profile { width: 300px; }
.profile-banner { height: 60px; }
.profile-av { margin: -46px 0 0 14px; padding: 6px; background: var(--floating); border-radius: 50%; width: fit-content; }
.profile-av .status-dot { box-shadow: 0 0 0 4px var(--floating); }
.profile-body { padding: 8px 16px 16px; }
.profile-name { font-size: 20px; font-weight: 700; color: var(--header); }
.profile-status { color: var(--muted); font-size: 14px; }
.profile-box { background: var(--bg2); border-radius: 8px; padding: 12px; margin-top: 12px; }
.profile-h { font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.profile-voice { display: flex; align-items: center; gap: 6px; }
.profile-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.profile-vol { margin-top: 14px; }
.profile-vol label { display: block; font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.profile-vol input { width: 100%; margin: 0; }
.emoji-picker { width: 320px; max-width: 94vw; height: 340px; display: flex; flex-direction: column; }
.emoji-tabs { display: flex; gap: 2px; padding: 8px 8px 0; overflow-x: auto; flex-shrink: 0; }
.emoji-tab { padding: 4px 10px; font-size: 13px; border-radius: 4px; color: var(--muted); white-space: nowrap; }
.emoji-tab.on { background: var(--sel); color: var(--header); }
.emoji-grid { flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; padding: 8px; align-content: start; }
.emoji-btn { font-size: 24px; line-height: 1; padding: 5px 0; border-radius: 4px; }
.emoji-btn:hover { background: var(--hover); }

/* ---------- Modais ---------- */
.modal-overlay { position: fixed; inset: 0; z-index: 900; background: rgba(0, 0, 0, .7); display: flex; align-items: center; justify-content: center; }
.dialog { background: var(--bg1); border-radius: 8px; padding: 16px; width: min(440px, 92vw); box-shadow: var(--shadow); }
.dialog h3 { margin: 0 0 8px; font-size: 20px; color: var(--header); }
.dialog p { margin: 0; white-space: pre-wrap; color: var(--muted); word-break: break-word; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin: 16px -16px -16px; padding: 16px; background: var(--bg2); border-radius: 0 0 8px 8px; }
.qs { width: min(540px, 92vw); align-self: flex-start; margin-top: 12vh; background: var(--bg1); border-radius: 8px; padding: 16px; box-shadow: var(--shadow); }
.qs-title { font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.qs-list { margin-top: 8px; max-height: 50vh; overflow-y: auto; }
.qs-item { display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: 4px; cursor: pointer; color: var(--text); }
.qs-item.on, .qs-item:hover { background: var(--sel); }
.qs-kind { margin-left: auto; font-size: 12px; color: var(--muted); }

.settings-overlay { background: var(--bg1); align-items: stretch; justify-content: stretch; }
.settings { display: flex; width: 100%; height: 100%; }
.set-nav { width: 280px; flex-shrink: 0; background: var(--bg2); padding: 60px 8px 24px 32px; display: flex; flex-direction: column; gap: 2px; align-items: stretch; overflow-y: auto; }
.set-nav-title { font-size: 12px; font-weight: 700; color: var(--muted); padding: 6px 10px; }
.set-tab { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 4px; color: var(--muted); text-align: left; font-weight: 500; }
.set-tab:hover { background: var(--hover); color: var(--text); }
.set-tab.on { background: var(--sel); color: var(--header); }
.set-main { flex: 1; min-width: 0; overflow-y: auto; padding: 60px 40px 80px; position: relative; }
.set-body { max-width: 740px; }
.set-body h2 { margin: 0 0 20px; font-size: 20px; color: var(--header); }
.set-body h3 { margin: 24px 0 8px; font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--muted); }
.set-close { position: fixed; top: 24px; right: 32px; width: 36px; height: 36px; border-radius: 50%; border: 2px solid var(--muted); color: var(--muted); display: inline-flex; align-items: center; justify-content: center; z-index: 2; }
.set-close:hover { color: var(--header); border-color: var(--header); background: var(--hover); }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 0; }
.set-row.col { flex-direction: column; align-items: stretch; gap: 8px; }
.set-label { font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--muted); display: flex; justify-content: space-between; }
.set-row.switch .set-label { font-size: 16px; font-weight: 500; text-transform: none; color: var(--header); }
.set-desc { font-size: 14px; color: var(--muted); margin-top: 2px; }
.set-val { color: var(--text); }
.set-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
.toggle { position: relative; width: 40px; height: 24px; flex-shrink: 0; }
.toggle input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; z-index: 1; }
.toggle i { position: absolute; inset: 0; border-radius: 12px; background: #80848e; transition: background .15s; }
.toggle i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s; }
.toggle input:checked + i { background: var(--green); }
.toggle input:checked + i::after { transform: translateX(16px); }
.meter-row { display: flex; align-items: center; gap: 12px; }
.meter { flex: 1; height: 8px; background: var(--bg3); border-radius: 4px; overflow: hidden; }
.meter-fill { height: 100%; width: 0; background: var(--green); transition: width .06s; }
.cam-prev { width: 100%; max-width: 420px; border-radius: 8px; background: #000; margin-top: 4px; }
.radio { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--bg2); border-radius: 4px; margin-bottom: 8px; cursor: pointer; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { width: 36px; height: 36px; border-radius: 50%; border: 3px solid transparent; color: #fff; font-weight: 700; }
.swatch.on { border-color: var(--header); }
.acc-preview { display: flex; align-items: center; gap: 16px; padding: 16px; background: var(--bg2); border-radius: 8px; margin-bottom: 8px; }
.acc-name { font-size: 20px; font-weight: 700; color: var(--header); }
.key-row { display: flex; align-items: center; gap: 16px; padding: 8px 0; border-bottom: 1px solid var(--border); }
kbd { background: var(--bg3); border-radius: 4px; padding: 3px 8px; min-width: 150px; font: inherit; font-size: 14px; }

/* ---------- Toasts ---------- */
#toasts { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); z-index: 2000; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { background: #111214; color: #fff; padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow); font-size: 14px; max-width: 92vw; animation: toast-in .2s; transition: opacity .35s; }
.toast.error { border-left: 4px solid var(--red); }
.toast.out { opacity: 0; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

/* ---------- Modo compacto ---------- */
body.compact .msg { margin-top: 8px; }
body.compact .msg.grouped { margin-top: 0; }

/* ---------- Dispositivos sem hover (toque) ---------- */
@media (hover: none) {
  .msg-tools { display: none !important; }
  .tile-tools { display: flex; }
}

/* ---------- Celular / tablet pequeno ---------- */
@media (max-width: 767px) {
  #drawer {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 40; width: min(88vw, 320px);
    transform: translateX(-100%); transition: transform .22s ease; box-shadow: 0 0 40px rgba(0, 0, 0, .6);
    padding-top: env(safe-area-inset-top);
  }
  #rail { padding-top: 12px; }
  body.nav-open #drawer { transform: none; }
  #backdrop { position: fixed; inset: 0; z-index: 30; background: rgba(0, 0, 0, .6); }
  body.nav-open #backdrop { display: block; }
  .mobile-only { display: inline-flex; }
  .only-mobile { display: inline-flex; }
  #topbar { padding-top: env(safe-area-inset-top); box-sizing: content-box; padding-left: 8px; }
  #side.open { position: fixed; inset: 0; width: 100% !important; z-index: 35; padding-top: env(safe-area-inset-top); }
  .chan { height: 44px; font-size: 16px; }
  .vuser { padding: 8px; }
  .composer-ta, .edit-ta, .input, .select { font-size: 16px; }
  .chat-bottom { padding: 0 8px env(safe-area-inset-bottom); }
  .msg { grid-template-columns: 52px minmax(0, 1fr); padding-right: 12px; }
  .msg-avatar { padding-left: 12px; }
  #callArea { padding: 8px 8px 84px; gap: 8px; }
  #callGrid, #callGrid[data-n] { gap: 8px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #callGrid[data-n="1"], #callGrid[data-n="2"] { grid-template-columns: minmax(0, 1fr); }
  .call-controls { gap: 8px; }
  .cbtn { width: 44px; height: 44px; }
  .set-grid { grid-template-columns: 1fr; }
  .settings { flex-direction: column; }
  .set-nav { width: auto; flex-direction: row; padding: 12px 56px 8px 12px; overflow-x: auto; gap: 4px; }
  .set-nav-title { display: none; }
  .set-tab { white-space: nowrap; }
  .set-main { padding: 16px 16px 60px; }
  .set-close { top: 10px; right: 10px; width: 32px; height: 32px; }
  .profile { width: min(300px, 92vw); }
  #toasts { bottom: 110px; }
}

/* celular deitado */
@media (max-height: 480px) {
  #topbar { height: 40px; }
  #callArea { padding-bottom: 72px; }
  .cbtn { width: 40px; height: 40px; }
  .avatar.big { display: none; }
}

/* ---------- Contas: cadastro / login / recuperacao ---------- */
body.auth-pending #app { display: none; }
#authRoot:empty { display: none; }
.auth-bg { position: fixed; inset: 0; z-index: 800; overflow-y: auto; display: flex; align-items: center; justify-content: center; padding: 24px 16px;
  background: radial-gradient(ellipse 80% 60% at 20% 10%, #4b56d8 0%, transparent 60%), radial-gradient(ellipse 70% 60% at 90% 100%, #7a45c9 0%, transparent 60%), #1c1d3f; }
.auth-card { width: min(480px, 100%); background: #313338; color: var(--text); border-radius: 8px; padding: 32px; box-shadow: 0 2px 10px rgba(0, 0, 0, .35); margin: auto; }
.auth-card.small { width: min(360px, 100%); text-align: center; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.auth-logo { width: 56px; height: 56px; border-radius: 16px; background: url(icons/icon-192.png) center / cover no-repeat; color: transparent; font-size: 0; display: flex; align-items: center; justify-content: center; margin: 0 auto 12px; }
.auth-card h1 { margin: 0 0 8px; text-align: center; font-size: 24px; font-weight: 600; color: #f2f3f5; }
.auth-sub { margin: 0 0 20px; text-align: center; color: #b5bac1; font-size: 15px; line-height: 1.4; }
.auth-card.small .auth-sub { margin: 0; }
.auth-text { color: #b5bac1; font-size: 15px; line-height: 1.5; text-align: center; margin: 4px 0 16px; }
.auth-text b { color: #f2f3f5; overflow-wrap: anywhere; }
.auth-mail { display: flex; justify-content: center; color: #b5bac1; margin: 4px 0 8px; }
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-field { display: flex; flex-direction: column; gap: 8px; }
.auth-field > span { font-size: 12px; font-weight: 700; text-transform: uppercase; color: #b5bac1; letter-spacing: .02em; }
.auth-field small { font-size: 12px; color: #949ba4; }
.auth-card .input { background: #1e1f22; border: 1px solid #1e1f22; color: #dbdee1; padding: 11px 12px; }
.auth-card .input:focus { border-color: var(--brand); }
.pw { position: relative; }
.pw .input { padding-right: 44px; }
.pw-eye { position: absolute; right: 4px; top: 0; bottom: 0; width: 40px; color: #949ba4; display: flex; align-items: center; justify-content: center; }
.pw-eye:hover { color: #fff; }
.btn.big { width: 100%; padding: 12px 16px; font-size: 16px; min-height: 44px; margin-top: 4px; }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.auth-error { background: rgba(242, 63, 67, .12); border: 1px solid rgba(242, 63, 67, .5); color: #ffb3b5; border-radius: 4px; padding: 10px 12px; font-size: 14px; line-height: 1.4; }
.auth-error a { color: #fff; font-weight: 600; text-decoration: underline; cursor: pointer; }
.auth-ok { background: rgba(35, 165, 90, .14); border: 1px solid rgba(35, 165, 90, .55); color: #a7f0c6; border-radius: 4px; padding: 10px 12px; font-size: 14px; line-height: 1.4; margin-bottom: 8px; }
.auth-foot { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; font-size: 14px; color: #949ba4; }
.auth-links { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.auth-switch { color: #949ba4; }
.auth-link { color: var(--link); cursor: pointer; }
.auth-link:hover { text-decoration: underline; }
.spinner.light { width: 34px; height: 34px; }
.auth-card > .btn.big + .btn.big, .auth-card > .auth-ok + .btn.big { margin-top: 10px; }
@media (max-width: 520px) { .auth-card { padding: 24px 18px; } }

/* ---------- Supressao de ruido ---------- */
.nsopt { align-items: flex-start; }
.nsopt span { display: flex; flex-direction: column; gap: 2px; }
.nsopt small { color: var(--muted); font-size: 13px; line-height: 1.35; }
.set-desc.tight { margin: -4px 0 10px; }
.listen { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); margin-top: 8px; cursor: pointer; }

/* ---------- Cargos e painel de usuarios ---------- */
.tab-btn { display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 12px; margin-right: 6px; border-radius: 6px; color: var(--muted); font-weight: 600; font-size: 14px; background: var(--hover); white-space: nowrap; }
.tab-btn:hover { color: var(--text); background: var(--sel); }
.tab-btn.on { background: var(--brand); color: #fff; }
.role-badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border: 1px solid var(--muted); border-radius: 12px; font-size: 12px; font-weight: 700; color: var(--muted); white-space: nowrap; }
.profile-role { margin: 6px 0 2px; }
.member-role-ic, .msg-role-ic { display: inline-flex; vertical-align: -2px; margin-left: 5px; }
.dash { flex: 1; min-height: 0; overflow-y: auto; padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.dash-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.dash-head h2 { margin: 0; font-size: 24px; color: var(--header); }
.dash-hint { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.dash-note { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 6px; background: rgba(88, 101, 242, .15); border: 1px solid rgba(88, 101, 242, .5); font-size: 14px; }
.dash-card { background: var(--bg2); border-radius: 8px; padding: 16px; }
.dash-card h3 { margin: 0 0 4px; font-size: 16px; color: var(--header); }
.dash-tools { display: flex; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.dash-search { flex: 1; min-width: 200px; }
.dash-filter { width: 200px; max-width: 100%; }
.dash-table { display: flex; flex-direction: column; }
.dash-row { display: grid; grid-template-columns: minmax(180px, 2fr) minmax(150px, 1.2fr) 100px 110px; gap: 12px; align-items: center; padding: 10px 8px; border-bottom: 1px solid var(--border); }
.dash-table.with-email .dash-row { grid-template-columns: minmax(170px, 1.6fr) minmax(170px, 1.6fr) minmax(150px, 1.1fr) 100px 110px; }
.dash-th { font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--muted); border-bottom: 2px solid var(--border); }
.dash-row:not(.dash-th):hover { background: var(--hover); border-radius: 6px; }
.dash-user { display: flex; align-items: center; gap: 12px; min-width: 0; }
.dash-user-text { min-width: 0; }
.dash-name { font-weight: 600; color: var(--header); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-name .you { color: var(--muted); font-weight: 400; }
.owner-tag { margin-left: 6px; font-size: 10px; font-weight: 700; text-transform: uppercase; color: var(--muted); border: 1px solid currentColor; border-radius: 4px; padding: 1px 5px; vertical-align: middle; }
.dash-sub { font-size: 12px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; }
.dash-sub .pending { color: var(--yellow); }
.dash-email, .dash-date { font-size: 14px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.role-select { padding: 6px 8px; font-size: 14px; }
.dash-empty { padding: 24px; text-align: center; color: var(--muted); }
.matrix { display: grid; gap: 0; margin-top: 12px; overflow-x: auto; }
.matrix > div { padding: 9px 8px; border-bottom: 1px solid var(--border); display: flex; align-items: center; }
.mx-head { justify-content: center; }
.mx-head.mx-perm, .mx-perm { justify-content: flex-start; font-size: 14px; }
.mx-head.mx-perm { font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--muted); }
.mx-cell { justify-content: center; color: var(--muted); }
.mx-cell.yes { color: var(--green); }
.role-legend { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.role-legend-item { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); flex-wrap: wrap; }
@media (max-width: 900px) {
  .dash { padding: 12px; }
  .dash-th { display: none; }
  .dash-row, .dash-table.with-email .dash-row { grid-template-columns: 1fr 1fr; gap: 6px 12px; padding: 12px 8px; }
  .dash-row .dash-user { grid-column: 1 / -1; }
  .dash-row [data-label]:not(.dash-user)::before { content: attr(data-label) ": "; font-size: 11px; text-transform: uppercase; font-weight: 700; color: var(--muted); display: block; }
  .dash-email { grid-column: 1 / -1; }
  .dash-role { grid-column: 1 / -1; }
  .tab-btn .tab-label { display: none; }
  .tab-btn { padding: 0 8px; }
  .matrix { font-size: 13px; }
}

/* ---------- Servidores ---------- */
#rail { overflow-y: auto; overflow-x: hidden; scrollbar-width: none; }
#rail::-webkit-scrollbar { display: none; }
.rail-item { flex-shrink: 0; }
.rail-icon { transition: border-radius .15s, background .15s; }
.rail-item:hover .rail-icon, .rail-item.active .rail-icon { border-radius: 12px; }
.rail-pill { display: none; }
.rail-item.active .rail-pill { display: block; }
.rail-item.unread::before { content: ""; position: absolute; left: -12px; top: 20px; width: 8px; height: 8px; background: var(--header); border-radius: 0 4px 4px 0; }
.rail-badge { position: absolute; right: -4px; bottom: -4px; background: var(--red); color: #fff; font-size: 11px; font-weight: 700; min-width: 16px; padding: 0 4px; border-radius: 8px; text-align: center; line-height: 16px; border: 2px solid var(--bg3); }
.rail-add .rail-icon { background: var(--bg1); color: var(--green, #3ba55d); }
.rail-add:hover .rail-icon { background: var(--green, #3ba55d); color: #fff; }
.cat { position: relative; }
.cat-add { margin-left: auto; background: none; border: 0; color: var(--muted); cursor: pointer; padding: 0 2px; display: inline-flex; }
.cat-add:hover { color: var(--header); }
.vp-server { color: var(--muted); font-size: 14px; margin-bottom: 4px; }
.dash-kick { margin-left: 6px; color: var(--muted); }
.dash-kick:hover { color: var(--red); }
.dash-role { display: flex; align-items: center; }
.dialog .set-row, .dialog .invite-out { margin-top: 12px; }
.dialog .dlg-sub { margin-bottom: 8px; }
.dialog .input { margin-top: 8px; }
.choice { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; margin-top: 12px; padding: 14px; border-radius: 8px; background: var(--bg2); color: var(--header); border: 1px solid var(--border); cursor: pointer; }
.choice:hover { background: var(--hover); }
.choice b { display: block; font-size: 16px; }
.choice small { color: var(--muted); font-size: 13px; }
.invite-row { display: flex; gap: 8px; align-items: center; }
.invite-row .input { margin-top: 0; }
.dialog.wide { width: min(600px, 94vw); max-height: 88vh; overflow-y: auto; }
.srv-head { display: flex; align-items: center; justify-content: space-between; }
.srv-head h3 { margin: 0; }
.set-close.inline { position: static; }
.srv-settings h3 { margin: 18px 0 8px; font-size: 15px; color: var(--header); }
.srv-settings .srv-head h3 { margin: 0; font-size: 20px; }
.srv-chan { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; color: var(--muted); }
.srv-chan:hover { background: var(--hover); }
.srv-chan-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.srv-chan-name small { color: var(--muted); }
.srv-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.danger-ic:hover { color: var(--red); }
.dialog .auth-error { margin-top: 10px; }

/* ---------- Administracao da plataforma ---------- */
.admin-table .dash-row { grid-template-columns: minmax(200px, 2fr) minmax(160px, 1.2fr) 160px; }
.admin-tabs { display: flex; gap: 8px; }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn.secondary.on { background: var(--brand); }
.admin-actions { display: flex; gap: 6px; }
.srv-icon-sm { width: 36px; height: 36px; border-radius: 10px; color: #fff; font-weight: 700; font-size: 13px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
@media (max-width: 700px) {
  .admin-table .dash-row { grid-template-columns: 1fr 1fr; }
}

/* ---------- Fotos, amigos e mensagens diretas ---------- */
.avatar-img { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.rail-icon { position: relative; overflow: hidden; }
.rail-icon .avatar-img, .srv-icon-sm .avatar-img { border-radius: 0; }
.srv-icon-sm { position: relative; overflow: hidden; }
.srv-icon-prev { width: 56px; height: 56px; flex-shrink: 0; }
.rail-friends .rail-icon { background: var(--bg1); color: var(--header); }
.rail-friends.active .rail-icon, .rail-friends:hover .rail-icon { background: var(--brand); color: #fff; border-radius: 12px; }
.rail-friends .rail-badge { z-index: 2; }
.fr-cat { font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--muted); margin: 14px 0 4px; }
.fr-row { display: flex; align-items: center; gap: 12px; padding: 10px 8px; border-bottom: 1px solid var(--border); border-radius: 6px; cursor: pointer; }
.fr-row:hover { background: var(--hover); }
.fr-text { flex: 1; min-width: 0; }
.fr-name { font-weight: 600; color: var(--header); display: flex; align-items: center; gap: 8px; }
.fr-sub { font-size: 13px; color: var(--muted); }
.fr-actions { display: flex; gap: 4px; }
.fr-ok { margin-top: 10px; padding: 10px 12px; border-radius: 6px; background: rgba(35, 165, 90, .15); color: var(--green); font-size: 14px; }
.dm-view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.dm-head { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid rgba(0, 0, 0, .25); flex-shrink: 0; }
.dm-head .icon-btn svg { transform: rotate(180deg); }
.dm-view .chat { flex: 1; min-height: 0; }

/* ---------- Foto ampliada ---------- */
.zoomable { cursor: zoom-in; }
.img-viewer { display: flex; flex-direction: column; align-items: center; gap: 12px; cursor: zoom-out; max-width: 94vw; }
.iv-img { min-width: min(80vw, 380px); max-width: min(94vw, 760px); max-height: 82vh; object-fit: contain; border-radius: 14px; background: var(--bg2); box-shadow: 0 10px 40px rgba(0, 0, 0, .6); }
.iv-cap { color: #fff; font-weight: 600; font-size: 16px; text-shadow: 0 1px 6px #000; }

/* ---------- Alerta de mensagem direta + convite para amigos ---------- */
.dm-alert { position: relative; color: #fff; background: var(--red); border-radius: 50%; margin-right: 6px; animation: dm-pulse 1.3s ease-in-out infinite; }
.dm-alert:hover { background: #d83c3e; }
.dm-alert svg { animation: dm-shake 1.3s ease-in-out infinite; transform-origin: 50% 85%; }
.dm-alert-badge { position: absolute; top: -5px; right: -5px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: #fff; color: var(--red); font-size: 11px; font-weight: 800; line-height: 17px; text-align: center; }
@keyframes dm-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(242, 63, 67, .75); transform: scale(1); } 50% { box-shadow: 0 0 0 11px rgba(242, 63, 67, 0); transform: scale(1.14); } }
@keyframes dm-shake { 0%, 60%, 100% { transform: rotate(0); } 10% { transform: rotate(-18deg); } 20% { transform: rotate(16deg); } 30% { transform: rotate(-12deg); } 40% { transform: rotate(9deg); } 50% { transform: rotate(-4deg); } }
@media (prefers-reduced-motion: reduce) { .dm-alert, .dm-alert svg { animation: none; } }
.invite-friends { margin-top: 14px; }
.if-list { margin-top: 8px; max-height: 210px; overflow-y: auto; border-radius: 6px; background: var(--bg2); padding: 4px 8px; }
.if-row { display: flex; align-items: center; gap: 10px; padding: 6px 2px; }
.if-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; color: var(--header); font-weight: 600; }
.if-name small { color: var(--muted); font-weight: 400; }

/* ---------- Grade de privilegios completa ---------- */
.matrix > .mx-group { grid-column: 1 / -1; background: var(--bg2); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--header); padding: 7px 8px; }
.mx-cell.txt { font-size: 12px; line-height: 1.25; text-align: center; padding: 6px 6px; }
.dash > * { flex-shrink: 0; }              /* os cartoes nunca encolhem: quem rola e a tela toda (.dash) */
.matrix-wrap { overflow-x: auto; }
.matrix-wrap .matrix { min-width: 760px; overflow: visible; }

/* diagnostico */
.diag-pre { background: var(--bg-3, #1e1f22); padding: 12px; border-radius: 8px; font: 12px/1.5 Consolas, monospace; white-space: pre-wrap; max-height: 320px; overflow: auto; margin: 12px 0; user-select: text; }
.row-gap { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- app de desktop: barra de titulo propria (mesma cor do sistema, sem bordas) ---------- */
#deskTitle { position: fixed; top: 0; left: 0; right: 0; height: 32px; z-index: 10000; display: flex; align-items: center; background: var(--bg3); color: var(--muted); -webkit-app-region: drag; user-select: none; }
#deskTitle .dt-logo { width: 18px; height: 18px; margin: 0 8px 0 12px; border-radius: 4px; pointer-events: none; }
#deskTitle .dt-name { font-size: 12px; font-weight: 600; letter-spacing: .2px; color: var(--text); }
#deskTitle .dt-fill { flex: 1; }
#deskTitle .dt-btn { -webkit-app-region: no-drag; width: 46px; height: 32px; display: flex; align-items: center; justify-content: center; color: var(--muted); }
#deskTitle .dt-btn:hover { background: var(--sel); color: var(--header); }
#deskTitle .dt-close:hover { background: #e81123; color: #fff; }
body.desktop-app #app { height: calc(100vh - 32px); height: calc(100dvh - 32px); margin-top: 32px; }
body.desktop-app .auth-bg { top: 32px; }
body.desktop-app #dlBox { display: none; }

/* ---------- caixa de download do app (so no navegador, canto inferior direito) ---------- */
#dlBox { position: fixed; right: 16px; bottom: 16px; z-index: 60; display: flex; align-items: center; gap: 10px; max-width: 340px; padding: 10px 10px 10px 12px; background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); }
#dlBox img { width: 36px; height: 36px; border-radius: 9px; flex-shrink: 0; }
#dlBox .dl-text { display: flex; flex-direction: column; min-width: 0; font-size: 12px; line-height: 1.3; color: var(--muted); }
#dlBox .dl-text strong { font-size: 13px; color: var(--header); }
#dlBox .dl-btn { background: var(--brand); color: #fff; padding: 7px 12px; border-radius: 8px; font-size: 13px; font-weight: 600; white-space: nowrap; }
#dlBox .dl-btn:hover { background: var(--brand-h); text-decoration: none; }
#dlBox .dl-x { width: 24px; height: 24px; border-radius: 6px; color: var(--muted); font-size: 18px; line-height: 1; }
#dlBox .dl-x:hover { background: var(--hover); color: var(--header); }
body.auth-pending #dlBox { display: none; }
@media (max-width: 800px) { #dlBox { display: none; } }

/* botao Atualizar do app de desktop */
#deskTitle .dt-upd-text { -webkit-app-region: no-drag; font-size: 12px; color: var(--muted); margin-right: 6px; max-width: 46vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#deskTitle .dt-upd-text.err { color: var(--red); }
#deskTitle .dt-upd { position: relative; width: 40px; }
#deskTitle .dt-upd:disabled { cursor: default; }
#deskTitle .dt-upd.has-update { color: var(--green); }
#deskTitle .dt-upd.has-update::after { content: ""; position: absolute; top: 7px; right: 10px; width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
#deskTitle .dt-upd.spin svg { animation: dt-spin 1s linear infinite; }
@keyframes dt-spin { to { transform: rotate(360deg); } }
