/* Windows has no flag emoji: Twemoji flags (CC-BY 4.0, see fonts/LICENSE-TwemojiCountryFlags.md), only for flag code points. */
@font-face {
  font-family: "Twemoji Country Flags";
  src: url("/fonts/TwemojiCountryFlags.woff2") format("woff2");
  unicode-range: U+1F1E6-1F1FF, U+1F3F4, U+E0062-E0063, U+E0065, U+E0067, U+E006C, U+E006E, U+E0073-E0074, U+E0077, U+E007F;
  font-display: swap;
}

:root {
  --bg-rail: #1e1f22;
  --bg-sidebar: #2b2d31;
  --bg-chat: #313338;
  --bg-input: #383a40;
  --bg-hover: rgba(78, 80, 88, 0.3);
  --bg-active: rgba(78, 80, 88, 0.6);
  --bg-modal: #313338;
  --bg-floating: #111214;
  --bg-panel: #2b2d31;
  --bg-panel-alt: #232428;
  --bg-deep: #1e1f22;
  --bg-strong: #404249;
  --bg-button: #4e5058;
  --scroll-thumb: #1a1b1e;
  --app-bg: #313338;
  --text: #dbdee1;
  --text-strong: #f2f3f5;
  --text-muted: #949ba4;
  --text-faint: #6d6f78;
  --accent: #5865f2;
  --accent-hover: #4752c4;
  --danger: #da373c;
  --success: #23a55a;
  --mention-bg: rgba(250, 168, 26, 0.08);
  --mention-bar: #f0b232;
  --border: rgba(0, 0, 0, 0.25);
  --radius: 8px;
  color-scheme: dark;
  font-family: 'Twemoji Country Flags', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--app-bg); background-attachment: fixed; color: var(--text); font-size: 15px; overflow: hidden; }
[hidden] { display: none !important; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.muted { color: var(--text-muted); }
.small { font-size: 13px; }

/* ---------- buttons & inputs ---------- */
.btn {
  border: 0; border-radius: 4px; padding: 9px 16px; background: var(--bg-input);
  color: var(--text-strong); font-weight: 500; transition: background 0.15s;
}
.btn:hover { background: var(--bg-button); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.danger:hover { background: #a12828; }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.link { background: none; border: 0; padding: 0; color: #00a8fc; }
.link:hover { text-decoration: underline; }
.icon-btn {
  display: grid; place-items: center; width: 32px; height: 32px; border: 0; border-radius: 4px;
  background: transparent; color: var(--text-muted);
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.icon-btn svg { width: 20px; height: 20px; }

label { display: block; font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--text-muted); margin: 0 0 16px; letter-spacing: 0.02em; }
label .muted { text-transform: none; font-weight: 400; }
label input, label textarea {
  display: block; width: 100%; margin-top: 8px; padding: 10px; border: 0; border-radius: 4px;
  background: var(--bg-rail); color: var(--text-strong); font-size: 15px; text-transform: none; font-weight: 400;
}
input:focus-visible, textarea:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.form-error { color: #fa777c; font-size: 14px; min-height: 1em; margin: 0 0 12px; }

/* ---------- auth ---------- */
.auth {
  height: 100%; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(circle at 20% 20%, #4752c4 0, transparent 45%), radial-gradient(circle at 80% 90%, #eb459e 0, transparent 40%), var(--bg-deep);
}
.auth-card { width: min(440px, 100%); background: var(--bg-modal); padding: 32px; border-radius: var(--radius); box-shadow: 0 8px 32px rgba(0,0,0,.4); text-align: center; }
.auth-card label { text-align: left; }
.auth-card h1 { margin: 12px 0 4px; font-size: 24px; color: var(--text-strong); }
.auth-card > p.muted { margin: 0 0 20px; }
.auth-logo { border-radius: 16px; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 72px 240px minmax(0, 1fr) 240px; height: 100%; }

.rail { background: var(--bg-rail); padding: 12px 0; display: flex; flex-direction: column; align-items: center; gap: 8px; overflow-y: auto; scrollbar-width: none; }
.rail-sep { width: 32px; height: 2px; border-radius: 1px; background: var(--bg-input); margin: 2px 0; }
.rail-item { position: relative; display: flex; justify-content: center; width: 100%; }
.rail-btn {
  width: 48px; height: 48px; border-radius: 50%; border: 0; display: grid; place-items: center;
  background: var(--bg-chat); color: var(--text); font-weight: 600; font-size: 16px;
  transition: border-radius 0.15s, background 0.15s, color 0.15s; overflow: hidden; padding: 0;
}
.rail-btn:hover, .rail-item.active .rail-btn { border-radius: 16px; background: var(--accent); color: #fff; }
.rail-btn.action { color: var(--success); font-size: 24px; font-weight: 400; }
.rail-btn.action:hover { background: var(--success); color: #fff; }
.rail-btn img { width: 100%; height: 100%; }
.rail-item::before {
  content: ''; position: absolute; left: 0; top: 50%; width: 4px; height: 0; border-radius: 0 4px 4px 0;
  background: var(--text-strong); transform: translateY(-50%); transition: height 0.15s;
}
.rail-item.unread::before { height: 8px; }
.rail-item:hover::before { height: 20px; }
.rail-item.active::before { height: 40px; }
.badge {
  position: absolute; right: 10px; bottom: -2px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
  background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center;
  border: 3px solid var(--bg-rail); box-sizing: content-box;
}

.sidebar { background: var(--bg-sidebar); display: flex; flex-direction: column; min-height: 0; }
.server-header {
  height: 48px; padding: 0 8px 0 16px; display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border); font-weight: 600; color: var(--text-strong); flex-shrink: 0;
}
.server-header .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.channels { flex: 1; overflow-y: auto; padding: 12px 8px; }
.channels-title { display: flex; align-items: center; justify-content: space-between; padding: 6px 4px 6px 8px; font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--text-muted); }
.channels-title .icon-btn { width: 20px; height: 20px; }
.channels-title .icon-btn svg { width: 16px; height: 16px; }
.channel {
  display: flex; align-items: center; gap: 6px; width: 100%; padding: 6px 8px; margin: 1px 0; border: 0; border-radius: 4px;
  background: transparent; color: var(--text-muted); text-align: left; position: relative;
}
.channel .hash { font-size: 20px; line-height: 1; color: var(--text-faint); width: 20px; text-align: center; }
.channel .label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.channel:hover { background: var(--bg-hover); color: var(--text); }
.channel.active { background: var(--bg-active); color: var(--text-strong); }
.channel.unread { color: var(--text-strong); font-weight: 600; }
.channel.unread::before { content: ''; position: absolute; left: -8px; width: 4px; height: 8px; border-radius: 0 4px 4px 0; background: var(--text-strong); }
.channel .mention { background: var(--danger); color: #fff; border-radius: 8px; font-size: 11px; font-weight: 700; padding: 0 5px; }
.channel .settings { display: none; width: 20px; height: 20px; color: var(--text-muted); }
.channel:hover .settings, .channel.active .settings { display: grid; }
.channel .settings svg { width: 14px; height: 14px; }

.userbar { height: 52px; padding: 0 8px; background: var(--bg-panel-alt); display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.userbar .who { flex: 1; min-width: 0; line-height: 1.2; }
.userbar .who strong { display: block; font-size: 14px; color: var(--text-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.userbar .who span { font-size: 12px; color: var(--text-muted); }

.avatar {
  position: relative; flex-shrink: 0; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  color: #fff; font-weight: 600; font-size: 14px; user-select: none;
}
.avatar.lg { width: 40px; height: 40px; font-size: 16px; }
.avatar .status {
  position: absolute; right: -2px; bottom: -2px; width: 14px; height: 14px; border-radius: 50%;
  border: 3px solid var(--bg-sidebar); background: #80848e;
}
.avatar .status.on { background: var(--success); }
.userbar .avatar .status { border-color: var(--bg-panel-alt); }

/* ---------- chat ---------- */
.chat { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg-chat); }
.chat-header {
  height: 48px; padding: 0 16px; display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--border);
  font-weight: 600; color: var(--text-strong); flex-shrink: 0;
}
.chat-header .hash { font-size: 24px; color: var(--text-faint); font-weight: 400; }
.chat-header .spacer { flex: 1; }

.messages { flex: 1; overflow-y: auto; padding: 16px 0 8px; outline: none; }
.messages-start { padding: 16px; margin-bottom: 8px; }
.messages-start .big-hash { width: 68px; height: 68px; border-radius: 50%; background: var(--bg-strong); display: grid; place-items: center; font-size: 40px; color: var(--text-strong); }
.messages-start h2 { margin: 8px 0 4px; font-size: 32px; color: var(--text-strong); }
.load-more { display: block; margin: 0 auto 8px; }
.day-sep { display: flex; align-items: center; gap: 8px; margin: 16px 16px 8px; font-size: 12px; font-weight: 600; color: var(--text-muted); }
.day-sep::before, .day-sep::after { content: ''; flex: 1; height: 1px; background: var(--bg-strong); }

.msg { position: relative; display: grid; grid-template-columns: 40px minmax(0, 1fr); column-gap: 16px; padding: 2px 48px 2px 16px; margin-top: 16px; }
.msg.compact { margin-top: 0; }
.msg:hover { background: rgba(2, 2, 2, 0.06); }
.msg.mentioned { background: var(--mention-bg); box-shadow: inset 2px 0 0 var(--mention-bar); }
.msg .gutter { color: transparent; font-size: 11px; text-align: right; padding-top: 4px; }
.msg.compact:hover .gutter { color: var(--text-faint); }
.msg .meta { display: flex; align-items: baseline; gap: 8px; }
.msg .author { font-weight: 600; color: var(--text-strong); }
.msg time { font-size: 12px; color: var(--text-faint); }
.msg .content { white-space: pre-wrap; word-wrap: break-word; line-height: 1.375; color: var(--text); }
.msg .edited { font-size: 11px; color: var(--text-faint); margin-left: 4px; }
.msg .content code { background: var(--bg-panel); padding: 1px 4px; border-radius: 4px; font-family: Consolas, monospace; font-size: 0.875em; }
.msg .content pre { background: var(--bg-panel); border: 1px solid var(--bg-deep); border-radius: 4px; padding: 8px; margin: 4px 0; overflow-x: auto; font-family: Consolas, monospace; font-size: 0.875em; white-space: pre-wrap; }
.msg .content a { color: #00a8fc; }
.msg .content .mention-tag { background: rgba(88, 101, 242, 0.3); color: #c9cdfb; border-radius: 3px; padding: 0 2px; font-weight: 500; }
.msg .actions {
  position: absolute; right: 16px; top: -16px; display: none; background: var(--bg-sidebar);
  border: 1px solid var(--border); border-radius: 4px; box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.msg:hover .actions { display: flex; }
.msg .actions .icon-btn.danger:hover { color: var(--danger); }
.msg .edit-box textarea { width: 100%; min-height: 44px; padding: 10px; border: 0; border-radius: 8px; background: var(--bg-input); color: var(--text); resize: vertical; }
.msg .edit-box .hint { font-size: 12px; color: var(--text-muted); }

.composer-wrap { padding: 0 16px 0; flex-shrink: 0; }
.composer { background: var(--bg-input); border-radius: var(--radius); padding: 0 8px 0 16px; }
.composer textarea {
  width: 100%; max-height: 50vh; padding: 11px 0; border: 0; outline: none; resize: none;
  background: transparent; color: var(--text); line-height: 1.375;
}
.typing { height: 24px; font-size: 13px; color: var(--text-muted); display: flex; align-items: center; gap: 6px; }
.typing strong { color: var(--text); }
.dots { display: inline-flex; gap: 3px; }
.dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--text-muted); 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: .3; } 30% { opacity: 1; } }

.empty { flex: 1; display: grid; place-items: center; text-align: center; padding: 32px; }
.empty h2 { color: var(--text-strong); margin-bottom: 8px; }
.empty .row { display: flex; gap: 8px; justify-content: center; margin-top: 16px; }

/* ---------- members ---------- */
.members { background: var(--bg-sidebar); overflow-y: auto; padding: 16px 8px; }
.members h3 { font-size: 12px; text-transform: uppercase; color: var(--text-muted); margin: 8px 8px 4px; letter-spacing: .02em; }
.member { display: flex; align-items: center; gap: 12px; padding: 6px 8px; border-radius: 4px; }
.member:hover { background: var(--bg-hover); }
.member .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-muted); }
.member.on .name { color: var(--text); }
.member.off { opacity: .45; }
.member .crown { color: #f0b232; font-size: 12px; }

/* ---------- menus, modals, toasts ---------- */
.menu {
  position: fixed; z-index: 30; min-width: 200px; padding: 6px 8px; background: var(--bg-floating); border-radius: 4px;
  box-shadow: 0 8px 16px rgba(0,0,0,.24);
}
.menu button { display: block; width: 100%; text-align: left; padding: 8px; border: 0; border-radius: 2px; background: transparent; color: var(--text); font-size: 14px; }
.menu button:hover { background: var(--accent); color: #fff; }
.menu button.danger { color: #fa777c; }
.menu button.danger:hover { background: var(--danger); color: #fff; }
.menu hr { border: 0; border-top: 1px solid var(--bg-panel); margin: 4px 0; }

.modal-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.7); display: grid; place-items: center; padding: 16px; animation: fade .12s; }
.modal { width: min(440px, 100%); background: var(--bg-modal); border-radius: var(--radius); overflow: hidden; animation: pop .15s; }
.modal .body { padding: 24px 16px 8px; }
.modal h2 { margin: 0 0 8px; text-align: center; color: var(--text-strong); font-size: 22px; }
.modal .lead { text-align: center; margin: 0 0 20px; color: var(--text-muted); }
.modal footer { display: flex; justify-content: flex-end; gap: 8px; padding: 16px; background: var(--bg-sidebar); }
.modal footer .left { margin-right: auto; }
.copy-row { display: flex; gap: 8px; background: var(--bg-rail); border-radius: 4px; padding: 4px; margin-top: 8px; }
.copy-row input { flex: 1; min-width: 0; margin: 0; background: transparent; border: 0; padding: 6px; color: var(--text-strong); font-size: 15px; }
.copy-row .btn { padding: 6px 16px; }
.choice { display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px 16px; margin-bottom: 8px; border: 1px solid var(--bg-button); border-radius: 8px; background: transparent; color: var(--text-strong); font-weight: 600; text-align: left; }
.choice:hover { background: var(--bg-hover); }
.choice span { font-size: 24px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: scale(.95); opacity: 0; } }

.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 50; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--bg-floating); color: var(--text-strong); padding: 10px 16px; border-radius: 6px; box-shadow: 0 8px 16px rgba(0,0,0,.3);
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); }
.connection { position: fixed; top: 0; left: 50%; transform: translateX(-50%); z-index: 45; background: #f0b232; color: #000; font-size: 13px; font-weight: 600; padding: 4px 12px; border-radius: 0 0 6px 6px; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--scroll-thumb); border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }
.channels::-webkit-scrollbar, .members::-webkit-scrollbar { width: 4px; }

@media (max-width: 1000px) { .app { grid-template-columns: 72px 220px minmax(0, 1fr); } .members { display: none; } }

/* ---------- voice & video ---------- */
.icon-btn.off { color: var(--danger); }
.icon-btn.danger:hover { color: var(--danger); }
.avatar.sm { width: 24px; height: 24px; font-size: 11px; }
.avatar.xl { width: 88px; height: 88px; font-size: 36px; }
.avatar { transition: box-shadow .1s; }
.speaking > .avatar, .me.speaking .avatar { box-shadow: 0 0 0 2px var(--bg-sidebar), 0 0 0 4px var(--success); }
.section-gap { height: 12px; }

.channel.voice .hash { display: grid; place-items: center; }
.channel.voice .hash svg { width: 18px; height: 18px; }
.channel.voice.connected { color: var(--text-strong); }
.voice-users { padding: 0 0 4px 30px; }
.voice-user { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 4px; color: var(--text-muted); font-size: 14px; cursor: default; }
.voice-user:hover { background: var(--bg-hover); color: var(--text); }
.voice-user .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.voice-user.speaking .name { color: var(--text-strong); }
.state-icon { display: grid; color: var(--text-muted); }
.state-icon svg { width: 16px; height: 16px; }
.state-icon.off { color: var(--danger); }
.live { background: var(--danger); color: #fff; font-size: 10px; font-weight: 800; letter-spacing: .03em; padding: 1px 5px; border-radius: 4px; }

.voice-panel { background: var(--bg-panel-alt); border-bottom: 1px solid var(--bg-deep); padding: 8px; flex-shrink: 0; }
.vp-top { display: flex; align-items: center; gap: 4px; }
.vp-info { flex: 1; min-width: 0; text-align: left; background: none; border: 0; padding: 2px 4px; border-radius: 4px; line-height: 1.25; }
.vp-info:hover span { text-decoration: underline; }
.vp-info strong { display: block; font-size: 14px; color: #f0b232; }
.vp-info strong.ok { color: var(--success); }
.vp-info span { display: block; font-size: 12px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vp-actions { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; margin-top: 8px; }
.vp-btn { height: 32px; border: 0; border-radius: 4px; background: var(--bg-panel); color: var(--text); display: grid; place-items: center; }
.vp-btn:hover:not(:disabled) { background: var(--bg-button); }
.vp-btn.on { background: var(--success); color: #fff; }
.vp-btn svg { width: 20px; height: 20px; }
.vp-btn:disabled { opacity: .5; cursor: not-allowed; }
.userbar .icon-btn { width: 30px; }
.userbar .me { border-radius: 50%; }

.call { flex: 1; min-height: 0; display: flex; flex-direction: column; background: #000; }
.call-stage { flex: 1; min-height: 0; padding: 16px; display: flex; }
.call-stage .empty { color: var(--text); }
.call-grid { flex: 1; display: grid; gap: 8px; grid-template-columns: repeat(var(--cols, 1), minmax(0, 1fr)); grid-auto-rows: minmax(0, 1fr); align-content: center; }
.call-stage.focus { flex-direction: column; gap: 8px; }
.focus-main { flex: 1; min-height: 0; display: flex; }
/* The highlighted stream uses all the space; the picture is letterboxed, never cropped. */
.focus-main { overflow: hidden; }
.focus-main .tile { flex: 1; width: 100%; height: 100%; aspect-ratio: auto; max-height: none; max-width: none; margin: 0; }
.focus-strip { display: flex; gap: 8px; height: 120px; overflow-x: auto; justify-content: center; flex-shrink: 0; }
.focus-strip:empty { display: none; }
.tile {
  position: relative; min-height: 0; border-radius: 8px; overflow: hidden; background: var(--bg-panel); cursor: pointer;
  display: grid; place-items: center; aspect-ratio: 16 / 9; max-height: 100%; max-width: 100%; margin: auto; width: 100%;
  transition: box-shadow .1s;
}
.tile.small { width: 200px; height: 100%; flex-shrink: 0; }
.tile.speaking { box-shadow: inset 0 0 0 3px var(--success); }
/* Absolutely positioned so the video can never grow the tile (a grid row used to stretch to the
   video's 1080 px and the bottom of the shared screen was clipped). */
.tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; }
.tile.screen video, .focus-main .tile video, .tile:fullscreen video { object-fit: contain; }
.tile video.mirror { transform: scaleX(-1); }
.tile.small .avatar.xl { width: 48px; height: 48px; font-size: 20px; }
.tile-label {
  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, .6); color: #fff; font-size: 13px; font-weight: 600;
}
.tile-label span:not(.live) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-label svg { width: 16px; height: 16px; color: #fa777c; flex-shrink: 0; }
.tile:fullscreen { border-radius: 0; aspect-ratio: auto; }

.call-controls { display: flex; justify-content: center; gap: 12px; padding: 12px 16px 20px; }
.round {
  width: 52px; height: 52px; border-radius: 50%; border: 0; display: grid; place-items: center;
  background: var(--bg-panel); color: var(--text-strong); transition: background .15s;
}
.round:hover:not(:disabled) { background: var(--bg-strong); }
.round svg { width: 24px; height: 24px; }
.round.on { background: var(--success); color: #fff; }
.round.off { background: #4e2b2d; color: #fa777c; }
.round.hangup { background: var(--danger); color: #fff; }
.round.hangup:hover { background: #a12828; }
.round:disabled { opacity: .5; cursor: not-allowed; }

.volume-menu { min-width: 240px; padding: 12px; }
.vol-title { font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--text-muted); margin-bottom: 8px; }
.vol-row { display: flex; align-items: center; gap: 10px; }
.vol-row input { flex: 1; accent-color: var(--accent); }
.vol-value { width: 40px; text-align: right; font-variant-numeric: tabular-nums; font-size: 13px; }

.modal.wide { width: min(720px, 100%); }
.picker-title { font-size: 12px; text-transform: uppercase; color: var(--text-muted); margin: 8px 0; }
.source-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; max-height: 300px; overflow-y: auto; margin-bottom: 8px; }
.source { border: 2px solid transparent; border-radius: 8px; background: var(--bg-rail); padding: 6px; text-align: left; color: var(--text); }
.source:hover { border-color: var(--bg-button); }
.source.selected { border-color: var(--accent); }
.source img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: contain; background: #000; border-radius: 4px; }
.source span { display: flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 13px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.source .src-icon { width: 16px; height: 16px; aspect-ratio: auto; background: none; flex-shrink: 0; }
.picker-options { display: flex; gap: 16px; align-items: flex-end; flex-wrap: wrap; margin-top: 12px; }
.picker-options > label:first-child { flex: 1; min-width: 200px; margin-bottom: 0; }
label select {
  display: block; width: 100%; margin-top: 8px; padding: 10px; border: 0; border-radius: 4px;
  background: var(--bg-rail); color: var(--text-strong); font-size: 15px; text-transform: none; font-weight: 400;
}
label.check { display: flex; align-items: center; gap: 10px; text-transform: none; font-size: 15px; font-weight: 400; color: var(--text); margin-bottom: 12px; }
label.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }

.type-options { display: grid; gap: 8px; margin-bottom: 16px; }
.type-option { display: flex; align-items: center; gap: 12px; padding: 10px 12px; margin: 0; border-radius: 6px; background: var(--bg-sidebar); cursor: pointer; text-transform: none; font-weight: 400; }
.type-option:has(input:checked) { background: var(--bg-strong); }
.type-option input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }
.type-option .type-emoji { width: 28px; text-align: center; font-size: 22px; color: var(--text-muted); }
.type-option strong { display: block; color: var(--text-strong); font-size: 15px; }
.type-option small { color: var(--text-muted); font-size: 13px; }

/* ---------- Go Live ---------- */
.live-btn { border: 0; cursor: pointer; font-family: inherit; }
.live-btn:hover { filter: brightness(1.15); }
.stream-card { position: relative; background: var(--bg-deep); }
.stream-preview { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; filter: blur(6px) brightness(.55); transform: scale(1.05); }
.stream-cta { position: relative; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; color: #fff; padding: 12px; }
.stream-cta strong { font-size: 16px; text-shadow: 0 1px 4px rgba(0,0,0,.6); }
.tile.small .stream-cta .btn { padding: 4px 10px; font-size: 13px; }
.tile-top { position: absolute; top: 8px; right: 8px; display: flex; gap: 6px; align-items: center; opacity: 0; transition: opacity .15s; }
.tile:hover .tile-top, .tile:focus-within .tile-top { opacity: 1; }
.tile-btn { border: 0; border-radius: 4px; padding: 5px 10px; background: rgba(0,0,0,.7); color: #fff; font-size: 13px; font-weight: 600; }
.tile-btn:hover { background: rgba(0,0,0,.9); }
.tile-btn.danger:hover { background: var(--danger); }
.viewers { display: flex; align-items: center; gap: 4px; padding: 4px 8px; border-radius: 4px; background: rgba(0,0,0,.7); color: #fff; font-size: 13px; font-weight: 600; }
.viewers svg { width: 16px; height: 16px; }
.tile.screen .viewers { opacity: 1; }
.audio-mode { font-weight: 400; opacity: .85; font-size: 12px; }
label.check .hint { display: block; color: var(--text-muted); font-size: 12px; margin-top: 2px; }

/* ---------- video stats ---------- */
.call-stage { position: relative; }
.stats-panel {
  position: absolute; top: 24px; left: 24px; z-index: 5; max-width: min(560px, calc(100% - 48px));
  background: rgba(17, 18, 20, .9); border-radius: 8px; padding: 10px 12px; font-size: 12px; color: var(--text);
  pointer-events: none; font-variant-numeric: tabular-nums;
}
.stats-title { font-weight: 700; text-transform: uppercase; color: var(--text-muted); margin-bottom: 6px; letter-spacing: .02em; }
.stats-row { padding: 4px 0; border-top: 1px solid var(--bg-panel); }
.stats-row strong { display: block; color: var(--text-strong); }
.stats-row small { display: block; color: var(--text-faint); }
.picker-options > label:nth-child(2) { flex: 1; min-width: 200px; margin-bottom: 0; }

/* ---------- avatars & server icons ---------- */
.avatar > img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
.rail-btn img { width: 100%; height: 100%; object-fit: cover; }
.icon-editor { display: flex; align-items: center; gap: 20px; margin-bottom: 20px; }
.icon-upload { position: relative; width: 100px; height: 100px; border: 0; padding: 0; border-radius: 30px; background: var(--bg-rail); overflow: hidden; flex-shrink: 0; }
.icon-upload.round { border-radius: 50%; }
.icon-upload .avatar.xl { width: 100px; height: 100px; font-size: 40px; }
.icon-preview { width: 100%; height: 100%; display: grid; place-items: center; font-size: 32px; font-weight: 600; color: var(--text-strong); }
.icon-preview img { width: 100%; height: 100%; object-fit: cover; }
.icon-upload-hint { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,.55); color: #fff; font-size: 11px; font-weight: 700; opacity: 0; transition: opacity .15s; text-align: center; }
.icon-upload:hover .icon-upload-hint, .icon-upload:focus-visible .icon-upload-hint { opacity: 1; }
.crop-wrap { display: grid; place-items: center; background: var(--bg-deep); border-radius: 8px; padding: 12px; }
.crop-canvas { width: 300px; height: 300px; cursor: grab; touch-action: none; border-radius: 4px; }
.crop-canvas:active { cursor: grabbing; }
.crop-zoom { display: flex; align-items: center; gap: 10px; margin: 16px 8px 8px; }
.crop-zoom input { flex: 1; accent-color: var(--accent); }
.crop-zoom .big { font-size: 22px; }

/* ---------- composer tools ---------- */
.composer { display: flex; align-items: flex-start; gap: 6px; }
.composer-field { flex: 1; min-width: 0; display: flex; align-items: flex-start; gap: 6px; }
.composer textarea { flex: 1; min-width: 0; }
.composer .emoji-btn { margin-top: 6px; }
.composer .gif-btn { order: 2; margin-top: 11px; }
.send-btn { display: none; }
.tool-btn { height: 32px; min-width: 32px; border: 0; border-radius: 4px; background: transparent; color: var(--text-muted); display: grid; place-items: center; }
.tool-btn:hover { color: var(--text-strong); }
.gif-btn { height: 22px; min-width: 0; padding: 0 3px; border: 2px solid currentColor; font-size: 11px; font-weight: 800; letter-spacing: .02em; }
.emoji-btn { font-size: 22px; filter: grayscale(1); opacity: .75; transition: filter .15s, transform .15s, opacity .15s; }
.emoji-btn:hover { filter: none; opacity: 1; transform: scale(1.15); }
.composer-wrap { position: relative; }

/* ---------- emoji picker ---------- */
.emoji-picker, .gif-picker {
  position: fixed; z-index: 35; background: var(--bg-panel); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.4);
  display: flex; flex-direction: column; overflow: hidden;
}
.emoji-picker { width: 420px; height: 440px; }
.ep-head { position: relative; display: flex; gap: 8px; padding: 12px; border-bottom: 1px solid var(--border); }
.ep-search, .gp-search { flex: 1; min-width: 0; border: 0; border-radius: 4px; padding: 8px 10px; background: var(--bg-deep); color: var(--text-strong); }
.ep-tone { width: 36px; border: 0; border-radius: 4px; background: transparent; font-size: 20px; }
.ep-tone:hover { background: var(--bg-hover); }
.ep-tone-menu { position: absolute; right: 12px; top: 48px; z-index: 2; display: flex; flex-direction: column; background: var(--bg-floating); border-radius: 6px; padding: 4px; }
.ep-tone-menu button { border: 0; background: transparent; font-size: 20px; padding: 4px 6px; border-radius: 4px; }
.ep-tone-menu button:hover { background: var(--bg-hover); }
.ep-main { flex: 1; min-height: 0; display: flex; }
.ep-nav { width: 44px; background: var(--bg-panel-alt); display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0; overflow-y: auto; scrollbar-width: none; }
.ep-nav button { width: 32px; height: 32px; border: 0; border-radius: 4px; background: transparent; font-size: 18px; filter: grayscale(1); opacity: .7; }
.ep-nav button:hover { filter: none; opacity: 1; background: var(--bg-hover); }
.ep-body { flex: 1; overflow-y: auto; padding: 0 8px 8px; position: relative; }
.ep-body h4 { position: sticky; top: 0; z-index: 1; margin: 0; padding: 10px 4px 6px; background: var(--bg-panel); font-size: 12px; text-transform: uppercase; color: var(--text-muted); }
.ep-grid { display: grid; grid-template-columns: repeat(9, 1fr); }
.ep-cell { aspect-ratio: 1; border: 0; border-radius: 4px; background: transparent; font-size: 24px; line-height: 1; padding: 0; cursor: pointer; }
.ep-cell:hover { background: var(--bg-hover); }
.ep-empty, .gp-empty { padding: 40px 16px; text-align: center; color: var(--text-muted); }
.ep-preview { display: flex; align-items: center; gap: 10px; padding: 8px 14px; background: var(--bg-panel-alt); min-height: 48px; }
.ep-preview-emoji { font-size: 28px; }
.ep-preview-name { font-weight: 600; color: var(--text-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- ":name" autocomplete ---------- */
.ac-box { position: absolute; left: 16px; right: 16px; bottom: calc(100% - 4px); z-index: 20; background: var(--bg-panel); border-radius: 8px 8px 0 0; padding: 8px; box-shadow: 0 -4px 16px rgba(0,0,0,.25); }
.ac-title { font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--text-muted); padding: 2px 8px 8px; }
.ac-item { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 4px; color: var(--text); cursor: pointer; }
.ac-item.active, .ac-item:hover { background: var(--bg-strong); color: var(--text-strong); }
.ac-emoji { font-size: 20px; width: 24px; text-align: center; }
.ac-box { max-height: min(320px, 45vh); overflow-y: auto; }
.mention-item .avatar { flex-shrink: 0; }
.ac-name { color: var(--text-strong); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ac-user { margin-left: auto; padding-left: 12px; font-size: 13px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ac-at { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--bg-input); color: var(--text-strong); font-weight: 700; flex-shrink: 0; }

/* ---------- GIF picker & embeds ---------- */
.gif-picker { width: 430px; height: 460px; }
.gp-head { display: flex; gap: 8px; padding: 12px; border-bottom: 1px solid var(--border); }
.gp-back { border: 0; border-radius: 4px; background: transparent; color: var(--text-strong); font-size: 18px; width: 32px; }
.gp-back:hover { background: var(--bg-hover); }
.gp-body { flex: 1; overflow-y: auto; padding: 8px; }
.gp-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.gp-card { position: relative; height: 96px; border: 0; border-radius: 6px; overflow: hidden; background: var(--bg-button); color: #fff; font-weight: 700; font-size: 15px; }
.gp-card.cat { text-transform: capitalize; }
.gp-card video, .gp-card img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; filter: brightness(.55); }
.gp-card span { position: relative; text-shadow: 0 1px 4px rgba(0,0,0,.7); }
.gp-card:hover { outline: 2px solid var(--accent); }
.gp-grid { columns: 2; column-gap: 8px; }
.gp-tile { position: relative; display: block; width: 100%; margin: 0 0 8px; padding: 0; border: 0; border-radius: 6px; overflow: hidden; background: var(--bg-deep); break-inside: avoid; }
.gp-tile video, .gp-tile img { display: block; width: 100%; height: 100%; object-fit: cover; }
.gp-tile:hover { outline: 2px solid var(--accent); }
.gp-star { position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; border: 0; border-radius: 50%; background: rgba(0,0,0,.6); color: #fff; font-size: 16px; opacity: 0; transition: opacity .15s; }
.gp-tile:hover .gp-star, .gp-star.on { opacity: 1; }
.gp-star.on { color: #f0b232; }
.gp-footer { padding: 6px 12px; font-size: 11px; color: var(--text-faint); text-align: right; background: var(--bg-panel-alt); min-height: 24px; }
.gp-sentinel { height: 1px; }
.gif-embed { position: relative; display: inline-block; margin-top: 4px; max-width: min(400px, 100%); border-radius: 8px; overflow: hidden; background: var(--bg-panel); vertical-align: top; }
.gif-media { display: block; max-width: 100%; max-height: 300px; }
.gif-badge { position: absolute; left: 6px; top: 6px; padding: 1px 5px; border-radius: 3px; background: rgba(0,0,0,.6); color: #fff; font-size: 11px; font-weight: 800; opacity: 0; transition: opacity .15s; }
.gif-embed:hover .gif-badge { opacity: 1; }

/* ---------- jumbo emoji & reactions ---------- */
.msg .content.jumbo { font-size: 48px; line-height: 1.15; }
.reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.reaction {
  display: flex; align-items: center; gap: 6px; height: 26px; padding: 0 8px; border: 1px solid transparent; border-radius: 8px;
  background: var(--bg-panel); color: var(--text-muted); font-size: 14px; font-weight: 600;
}
.reaction:hover { border-color: var(--bg-button); background: var(--bg-button); }
.reaction.me { background: rgba(88, 101, 242, .15); border-color: var(--accent); color: #c9cdfb; }
.reaction .r-emoji { font-size: 16px; }
.reaction.add { opacity: 0; color: var(--text-muted); }
.reaction.add svg { width: 18px; height: 18px; }
.msg:hover .reaction.add { opacity: 1; }

/* ---------- volume & sensitivity ---------- */
.volume-menu { min-width: 260px; }
.vol-who { display: flex; align-items: center; gap: 8px; padding: 0 0 10px; margin-bottom: 8px; border-bottom: 1px solid var(--bg-panel); color: var(--text-strong); }
.vol-mute { display: flex; align-items: center; justify-content: space-between; margin: 10px 0 0; padding: 8px 0 0; border-top: 1px solid var(--bg-panel); font-size: 14px; text-transform: none; font-weight: 500; color: var(--text); cursor: pointer; }
.vol-mute input { width: 18px; height: 18px; margin: 0; accent-color: var(--danger); display: inline-block; }
label .vol-row { margin-top: 8px; }
label .vol-row input { margin: 0; padding: 0; background: none; }
.settings-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
.sensitivity { background: var(--bg-sidebar); border-radius: 8px; padding: 12px 14px; margin-bottom: 16px; }
.sens-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; color: var(--text-strong); font-size: 14px; }
.sens-head label.check { margin: 0; font-size: 14px; }
.meter { position: relative; height: 10px; border-radius: 5px; background: var(--bg-deep); overflow: hidden; margin-bottom: 8px; }
.meter-fill { height: 100%; width: 0; background: #f0b232; transition: width .06s linear; }
.meter-fill.open { background: var(--success); }
.meter-mark { position: absolute; top: -2px; bottom: -2px; width: 3px; background: #fff; border-radius: 2px; }
.sensitivity input[type=range] { width: 100%; accent-color: var(--accent); margin: 0; padding: 0; background: none; }
.sensitivity input[type=range]:disabled { opacity: .4; }
@media (max-width: 640px) { .settings-cols { grid-template-columns: 1fr; } .emoji-picker, .gif-picker { width: calc(100vw - 16px); } }

/* ---------- colour choice (avatar / server icon) ---------- */
.rail-btn.colored, .rail-btn.colored:hover, .rail-item.active .rail-btn.colored { background: var(--icon-bg); color: #fff; }
.field { margin: 0 0 16px; }
.field-label { font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--text-muted); margin-bottom: 8px; letter-spacing: 0.02em; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch {
  position: relative; width: 32px; height: 32px; padding: 0; margin: 0; border: 0; border-radius: 6px; cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.08); display: grid; place-items: center;
}
.swatch:hover { transform: scale(1.08); }
.swatch.selected { box-shadow: 0 0 0 2px var(--bg-modal), 0 0 0 4px #fff; }
.swatch.default { background: repeating-linear-gradient(45deg, var(--bg-button) 0 6px, var(--bg-panel) 6px 12px); }
.swatch.custom { background: conic-gradient(#ed4245, #faa61a, #f1c40f, #3ba55d, #00a8fc, #5865f2, #eb459e, #ed4245); font-size: 15px; overflow: hidden; }
.swatch.custom input[type=color] { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0; border: 0; opacity: 0; cursor: pointer; }

.code-input { text-transform: uppercase; letter-spacing: .15em; font-family: Consolas, monospace; }

/* ---------- desktop download & update ---------- */
.rail-btn.action svg { width: 24px; height: 24px; }
.rail-btn.update { color: #fff; background: var(--success); animation: pulse 2s infinite; }
.rail-btn.update:hover { background: #1f8b4c; border-radius: 16px; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(35,165,90,.5); } 50% { box-shadow: 0 0 0 6px rgba(35,165,90,0); } }
.download-card { display: flex; align-items: center; gap: 14px; padding: 14px; border-radius: 8px; background: var(--bg-sidebar); }
.download-card img { border-radius: 14px; }
.download-info { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.download-info strong { color: var(--text-strong); font-size: 16px; }
.download-card .btn { text-decoration: none; }
.download-alt { margin: 12px 2px 0; }
.download-alt a { color: #00a8fc; }

/* ---------- member list toggle (Discord: "Mostrar lista de membros") ---------- */
.icon-btn.toggled { color: var(--text-strong); }
.mobile-only { display: none !important; }
.members-head { display: flex; align-items: center; justify-content: space-between; padding: 0 0 8px 8px; font-weight: 600; color: var(--text-strong); }
@media (min-width: 1001px) {
  .app.hide-members { grid-template-columns: 72px 240px minmax(0, 1fr); }
  .app.hide-members > .members { display: none; }
}
@media (max-width: 1000px) {
  .app.show-members > .members {
    display: block; position: fixed; top: 0; right: 0; bottom: 0; z-index: 26; width: min(300px, 100%);
    padding-top: max(16px, env(safe-area-inset-top)); box-shadow: -8px 0 24px rgba(0,0,0,.4); animation: slide-in .15s;
  }
  .members-head.mobile-only { display: flex !important; }
}
@keyframes slide-in { from { transform: translateX(40px); opacity: 0; } }

/* ---------- touch: no hover, so message actions come from a long press (like Discord mobile) ---------- */
.msg.show-actions .actions { display: flex; }
@media (hover: none) {
  .msg:hover { background: none; }
  .msg:hover .actions { display: none; }
  .msg.show-actions { background: rgba(2, 2, 2, 0.12); }
  .msg.show-actions .actions { display: flex; }
  .msg .actions .icon-btn { width: 40px; height: 40px; }
}

/* Touch screens: holding a finger on the interface must not select or copy it, nor open the browser's
   menu (copy / search with Google / save image). Only text fields keep it; messages have "Copiar texto". */
@media (pointer: coarse) {
  body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
  input, textarea { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
  img, video { -webkit-user-drag: none; }
}

/* ---------- phones: Discord mobile layout ----------
   Two screens: the server rail + channel list, and the chat. Picking a channel slides to the chat;
   the ☰ button, the back gesture or a swipe to the right goes back to the channels. */
@media (max-width: 768px) {
  body { font-size: 16px; }
  .app { height: var(--app-h, 100dvh); grid-template-columns: 72px minmax(0, 1fr); }
  .app > .chat, .app > .members { display: none; }
  .app.mobile-chat { grid-template-columns: minmax(0, 1fr); }
  .app.mobile-chat > .rail, .app.mobile-chat > .sidebar { display: none; }
  .app.mobile-chat > .chat { display: flex; }
  .app.show-members > .members { width: 100%; }
  .mobile-only { display: grid !important; }

  .rail { padding-top: max(12px, env(safe-area-inset-top)); padding-bottom: env(safe-area-inset-bottom); }
  .server-header, .chat-header { height: calc(52px + env(safe-area-inset-top)); padding-top: env(safe-area-inset-top); }
  .chat-header { padding-left: 4px; padding-right: 8px; gap: 4px; }
  .chat-header > span:not(.hash):not(.spacer) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
  .chat-header .icon-btn { width: 40px; height: 40px; flex-shrink: 0; }
  .chat-header .icon-btn svg { width: 22px; height: 22px; }
  .userbar { height: calc(56px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); }
  .channel { padding: 9px 8px; font-size: 16px; }
  .channel .settings { display: grid; }

  .messages { padding-top: 8px; }
  .messages-start h2 { font-size: 24px; }
  .msg { padding: 2px 12px; column-gap: 12px; }
  .msg .actions { right: 8px; }

  /* Composer like Discord mobile: round GIF button, rounded field with the emoji button inside,
     and a round send button that appears once there is text. Enter makes a new line. */
  .composer-wrap { display: flex; flex-direction: column; padding: 6px 8px calc(8px + env(safe-area-inset-bottom)); }
  .composer-wrap:focus-within { padding-bottom: 8px; }
  .composer { background: transparent; padding: 0; gap: 8px; align-items: flex-end; }
  .composer .gif-btn {
    order: 0; margin: 0; width: 40px; height: 40px; flex-shrink: 0; border: 0; border-radius: 50%;
    background: var(--bg-input); color: var(--text-muted); font-size: 12px;
  }
  .composer-field { background: var(--bg-input); border-radius: 20px; padding: 0 4px 0 14px; align-items: flex-end; min-height: 40px; }
  .composer textarea { font-size: 16px; padding: 9px 0; max-height: 35vh; }
  .composer .emoji-btn { margin: 4px 0; width: 32px; }
  .send-btn {
    width: 40px; height: 40px; flex-shrink: 0; border: 0; border-radius: 50%; background: var(--accent); color: #fff;
    place-items: center; animation: pop .12s;
  }
  .send-btn:not([hidden]) { display: grid; }
  .send-btn svg { width: 20px; height: 20px; }
  .typing { order: -1; height: 20px; font-size: 12px; padding: 0 6px; }
  .typing:empty { height: 0; }

  /* Pickers become bottom sheets. */
  .emoji-picker, .gif-picker {
    left: 0 !important; right: 0 !important; top: auto !important; bottom: 0 !important; width: 100% !important;
    height: min(62dvh, 460px) !important; border-radius: 12px 12px 0 0; padding-bottom: env(safe-area-inset-bottom);
  }
  .ep-grid { grid-template-columns: repeat(8, 1fr); }
  .ep-cell { font-size: 28px; }

  .call-stage { padding: 8px; }
  .call-controls { flex-wrap: wrap; gap: 10px; padding: 10px 8px calc(14px + env(safe-area-inset-bottom)); }
  .round { width: 48px; height: 48px; }
  .tile.small { width: 120px; }
  .modal-backdrop { padding: 8px; }
  .toast { bottom: calc(80px + env(safe-area-inset-bottom)); max-width: calc(100vw - 32px); }
}

/* ---------- install as app (PWA) ---------- */
.install-steps { margin: 0 0 8px; padding-left: 20px; line-height: 1.6; }
.install-steps strong { color: var(--text-strong); }
.offline-page {
  min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  padding: 24px; text-align: center; background: var(--bg-chat);
}
.offline-page img { border-radius: 20px; margin-bottom: 8px; }
.offline-page h1 { margin: 0; color: var(--text-strong); font-size: 22px; }
.offline-page .btn { margin-top: 16px; text-decoration: none; }
.ac-box .avatar .status { border-color: var(--bg-panel); }

/* ---------- floating call window (phones) ---------- */
.call-overlay {
  position: fixed; z-index: 28; width: 176px; border-radius: 12px; overflow: hidden; background: var(--bg-floating);
  box-shadow: 0 8px 24px rgba(0,0,0,.5); touch-action: none; -webkit-user-select: none; user-select: none;
  transition: left .2s, top .2s; animation: pop .15s;
}
.call-overlay.dragging { transition: none; opacity: .9; }
.ov-stage { position: relative; height: 100px; display: grid; place-items: center; background: #000; cursor: pointer; }
.ov-stage video { width: 100%; height: 100%; object-fit: contain; display: block; pointer-events: none; }
.ov-label { position: absolute; left: 6px; bottom: 6px; max-width: calc(100% - 12px); display: flex; align-items: center; gap: 4px; font-size: 11px; color: #fff; background: rgba(0,0,0,.6); padding: 1px 6px; border-radius: 4px; white-space: nowrap; overflow: hidden; }
.ov-label .live { font-size: 9px; padding: 0 4px; }
.ov-people { display: flex; align-items: center; gap: 8px; }
.ov-person .avatar { width: 40px; height: 40px; font-size: 16px; }
.ov-person.speaking > .avatar { box-shadow: 0 0 0 2px #000, 0 0 0 4px var(--success); }
.ov-more { color: var(--text-muted); font-size: 13px; font-weight: 600; }
.ov-bar { display: flex; align-items: center; gap: 4px; padding: 6px; background: var(--bg-deep); }
.ov-title { flex: 1; min-width: 0; display: flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; color: var(--success); }
.ov-title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ov-title svg { width: 14px; height: 14px; flex-shrink: 0; }
.ov-btn { width: 30px; height: 30px; flex-shrink: 0; border: 0; border-radius: 50%; background: var(--bg-panel); color: var(--text-strong); display: grid; place-items: center; padding: 0; }
.ov-btn svg { width: 17px; height: 17px; }
.ov-btn.off { color: #f23f43; }
.ov-btn.hangup { background: var(--danger); color: #fff; }
.pip-source { position: fixed; left: 0; top: 0; width: 2px; height: 2px; opacity: 0; pointer-events: none; }

/* ---------- home: friends & direct messages ---------- */
.rail-btn.home { background: var(--bg-chat); }
.rail-btn.home img { width: 32px; height: 32px; object-fit: contain; }
.rail-item.active .rail-btn.home, .rail-btn.home:hover { background: var(--accent); }
.channel.friends-link { margin-bottom: 8px; padding: 9px 8px; color: var(--text); font-weight: 500; }
.channel.friends-link .hash svg { width: 20px; height: 20px; }
.channel.dm { gap: 10px; padding: 6px 8px; }
.channel.dm .avatar.sm { width: 32px; height: 32px; font-size: 14px; }
.channel.dm .dm-call { color: var(--success); display: grid; }
.channel.dm .dm-call svg { width: 16px; height: 16px; }
.dm-empty { padding: 4px 8px; }
.chat-header .hash.at { font-size: 22px; font-weight: 600; }
.presence-dot { width: 10px; height: 10px; border-radius: 50%; background: #80848e; flex-shrink: 0; }
.presence-dot.on { background: var(--success); }
.header-sep { width: 1px; height: 24px; background: var(--bg-strong); margin: 0 8px; flex-shrink: 0; }
.friend-tabs { display: flex; align-items: center; gap: 8px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.friend-tab { border: 0; border-radius: 4px; padding: 2px 10px; background: transparent; color: var(--text-muted); font-weight: 500; white-space: nowrap; display: flex; align-items: center; gap: 6px; }
.friend-tab:hover { background: var(--bg-hover); color: var(--text); }
.friend-tab.active { background: var(--bg-active); color: var(--text-strong); }
.friend-tab.add { background: var(--success); color: #fff; }
.friend-tab.add.active { background: transparent; color: #2dc770; }
.friend-tab .mention, .channel .mention { background: var(--danger); color: #fff; border-radius: 8px; font-size: 11px; font-weight: 700; padding: 0 5px; }
.friends-page { padding: 8px 24px 24px; }
.friends-title { font-size: 12px; text-transform: uppercase; color: var(--text-muted); letter-spacing: .02em; margin: 8px 0; }
.friends-empty { text-align: center; padding: 64px 16px; }
.friend-row { display: flex; align-items: center; gap: 12px; padding: 10px 10px; border-top: 1px solid var(--bg-strong); border-radius: 8px; }
.friend-row.clickable { cursor: pointer; }
.friend-row:hover { background: var(--bg-hover); border-top-color: transparent; }
.friend-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.friend-info strong { color: var(--text-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.friend-user { display: none; margin-left: 6px; font-weight: 400; color: var(--text-muted); font-size: 13px; }
.friend-row:hover .friend-user { display: inline; }
.friend-actions { display: flex; gap: 8px; }
.round-btn { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--bg-sidebar); color: var(--text-muted); display: grid; place-items: center; padding: 0; }
.round-btn svg { width: 20px; height: 20px; }
.round-btn:hover { color: var(--text-strong); }
.round-btn.ok:hover { color: var(--success); }
.round-btn.danger:hover { color: var(--danger); }
.add-friend-title { margin: 12px 0 4px; font-size: 16px; text-transform: uppercase; color: var(--text-strong); }
.add-friend { margin-top: 16px; }
.add-friend-row { display: flex; gap: 8px; align-items: center; background: var(--bg-rail); border: 1px solid var(--bg-rail); border-radius: 8px; padding: 6px 6px 6px 12px; }
.add-friend.ok .add-friend-row { border-color: var(--success); }
.add-friend.error .add-friend-row { border-color: var(--danger); }
.add-friend-input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; color: var(--text-strong); font-size: 16px; padding: 6px 0; }
.add-friend-result { margin: 8px 0 0; font-size: 14px; min-height: 1em; }
.add-friend.ok .add-friend-result { color: #2dc770; }
.add-friend.error .add-friend-result { color: #fa777c; }
.member.clickable, .member { cursor: pointer; }
.dm-profile { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 24px 8px; }
.dm-profile h3 { margin: 12px 0 0; color: var(--text-strong); font-size: 20px; text-transform: none; letter-spacing: 0; }
.dm-profile p { margin: 4px 0 0; }
.messages-start .avatar.xl { margin-bottom: 8px; }
@media (max-width: 768px) {
  .friend-tabs { gap: 2px; }
  .friend-tab { padding: 4px 8px; }
  .friend-tab .long, .chat-header .friends-heading, .chat-header .header-sep { display: none; }
  .chat-header .friend-tabs ~ * { display: none; }
  .friends-page { padding: 8px 12px 24px; }
  .add-friend-row { flex-direction: column; align-items: stretch; }
  .add-friend-row .btn { width: 100%; }
  .friend-user { display: none !important; }
}

/* ---------- incoming private call ---------- */
.incoming-call {
  position: fixed; z-index: 45; top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(260px, calc(100vw - 32px));
  background: var(--bg-floating); border-radius: 12px; padding: 24px 16px 20px; box-shadow: 0 16px 48px rgba(0,0,0,.6);
  display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; animation: pop .15s;
}
.incoming-call strong { color: var(--text-strong); font-size: 18px; margin-top: 12px; }
.ic-avatar .avatar { animation: ring-pulse 1.4s infinite; }
@keyframes ring-pulse { 0% { box-shadow: 0 0 0 0 rgba(35,165,90,.6); } 100% { box-shadow: 0 0 0 18px rgba(35,165,90,0); } }
.ic-actions { display: flex; gap: 32px; margin-top: 20px; }
.ic-btn { width: 56px; height: 56px; border-radius: 50%; border: 0; display: grid; place-items: center; color: #fff; }
.ic-btn svg { width: 26px; height: 26px; }
.ic-btn.decline { background: var(--danger); }
.ic-btn.accept { background: var(--success); }

/* ---------- theme editor ("Personalize o seu tema") ---------- */
.theme-panel {
  position: fixed; z-index: 42; top: 0; right: 0; bottom: 0; width: 300px; display: flex; flex-direction: column;
  background: var(--bg-floating); color: var(--text); box-shadow: -8px 0 32px rgba(0,0,0,.45); animation: slide-in .15s;
}
.tp-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 12px 8px 16px; }
.tp-head h2 { margin: 0; font-size: 16px; color: var(--text-strong); }
.tp-body { flex: 1; overflow-y: auto; padding: 0 16px 16px; display: flex; flex-direction: column; gap: 10px; }
.tp-body h3 { margin: 10px 0 0; font-size: 13px; font-weight: 600; color: var(--text-muted); }
.tp-modes { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: 8px; background: var(--bg-deep); }
.tp-mode { height: 36px; border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--text-muted); font-size: 18px; }
.tp-mode:hover { color: var(--text-strong); }
.tp-mode.active { background: var(--bg-panel); border-color: var(--bg-strong); color: var(--text-strong); }
.tp-presets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.tp-preset { aspect-ratio: 1; border: 2px solid transparent; border-radius: 10px; padding: 0; }
.tp-preset:hover { border-color: var(--text-strong); }
.tp-bar { position: relative; height: 48px; border-radius: 8px; display: flex; align-items: center; justify-content: space-between; padding: 0 10px; }
.tp-stop { width: 28px; height: 28px; border-radius: 6px; border: 2px solid rgba(255,255,255,.85); padding: 0; box-shadow: 0 1px 4px rgba(0,0,0,.4); }
.tp-stop.active { border-color: #fff; outline: 2px solid rgba(0,0,0,.35); transform: scale(1.12); }
.tp-picker { display: flex; flex-direction: column; gap: 10px; }
.tp-sv {
  position: relative; height: 150px; border-radius: 8px; cursor: crosshair; touch-action: none;
  background-image: linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, transparent);
}
.tp-sv-knob { position: absolute; width: 18px; height: 18px; border-radius: 50%; border: 3px solid #fff; transform: translate(-50%, -50%); box-shadow: 0 0 2px rgba(0,0,0,.6); pointer-events: none; }
.tp-hue {
  -webkit-appearance: none; appearance: none; width: 100%; height: 14px; border-radius: 7px; margin: 0;
  background: linear-gradient(to right, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00);
}
.tp-hue::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; border: 3px solid #fff; background: transparent; box-shadow: 0 0 2px rgba(0,0,0,.6); }
.tp-hex { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; background: var(--bg-panel); }
.tp-hex-swatch { width: 24px; height: 24px; border-radius: 4px; flex-shrink: 0; }
.tp-hex-input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; color: var(--text-strong); font: 500 15px Consolas, monospace; text-transform: uppercase; }
.tp-icon-btn { width: 28px; height: 28px; border: 0; border-radius: 4px; background: transparent; color: var(--text-muted); font-size: 15px; }
.tp-icon-btn:hover { background: var(--bg-hover); color: var(--text-strong); }
.tp-hint { margin: 0; font-size: 13px; color: var(--text-muted); }
.tp-btn { width: 100%; padding: 10px; border: 0; border-radius: 8px; background: var(--bg-panel); color: var(--text-strong); font-weight: 600; }
.tp-btn:hover:not(:disabled) { background: var(--bg-strong); }
.tp-btn:disabled { opacity: .5; cursor: not-allowed; }
.tp-slider { display: flex; flex-direction: column; gap: 6px; margin: 0; text-transform: none; font-size: 14px; font-weight: 500; color: var(--text-strong); letter-spacing: 0; }
.tp-slider-head { display: flex; justify-content: space-between; }
.tp-value { color: var(--text-strong); }
.tp-slider input[type=range] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 6px; border-radius: 3px; margin: 6px 0;
  background: linear-gradient(to right, var(--accent) var(--fill, 50%), var(--bg-strong) var(--fill, 50%));
}
.tp-slider input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.4); }
.tp-foot { padding: 12px 16px; border-top: 1px solid var(--border); }
@media (max-width: 768px) {
  .theme-panel { width: 100%; padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); }
}
/* light appearance: a few details that assume a dark background */
:root[data-theme="light"] .msg .content .mention-tag { color: #4752c4; }
:root[data-theme="light"] .rail-btn { color: var(--text); }
:root[data-theme="light"] .btn { color: var(--text-strong); }
:root[data-theme="light"] .btn.primary, :root[data-theme="light"] .btn.danger { color: #fff; }
