:root {
  color-scheme: light dark;
  --accent-light: #4f46e5;
  --accent-dark: #818cf8;

  --bg: #f7f7f9;
  --panel: #ffffff;
  --sidebar: #eeeef2;
  --hover: rgb(0 0 0 / 6%);
  --text: #1c1c22;
  --muted: #62626e;
  --border: #d8d8e0;
  --accent: var(--accent-light);
  --on-accent: #ffffff;
  --speaking: #15803d;
  --error: #c81e1e;
  --warn: #b45309;
  --away: #f97316;
  --shadow: 0 8px 28px rgb(0 0 0 / 18%);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17171c;
    --panel: #24242c;
    --sidebar: #1e1e24;
    --hover: rgb(255 255 255 / 7%);
    --text: #ececf1;
    --muted: #a0a0ac;
    --border: #383842;
    --accent: var(--accent-dark);
    --on-accent: #15151a;
    --speaking: #4ade80;
    --error: #f87171;
    --warn: #fbbf24;
    --shadow: 0 8px 28px rgb(0 0 0 / 55%);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #17171c;
  --panel: #24242c;
  --sidebar: #1e1e24;
  --hover: rgb(255 255 255 / 7%);
  --text: #ececf1;
  --muted: #a0a0ac;
  --border: #383842;
  --accent: var(--accent-dark);
  --on-accent: #15151a;
  --speaking: #4ade80;
  --error: #f87171;
  --warn: #fbbf24;
  --shadow: 0 8px 28px rgb(0 0 0 / 55%);
}

:root[data-theme="light"] { color-scheme: light; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 1rem/1.45 system-ui, "Segoe UI", sans-serif;
}

svg { flex: none; display: block; }
a { color: var(--accent); }

h1 { margin: 0; font-size: 1.25rem; }
h2 { margin: 0; font-size: 1.15rem; }
h3 { margin: 24px 0 8px; font-size: 0.8rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }

label { display: grid; gap: 4px; font-size: 0.875rem; }
label:has(> input[type="checkbox"]),
label:has(> input[type="radio"]) { display: flex; align-items: center; gap: 10px; min-height: 28px; }

input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), select, textarea {
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  width: 100%;
}
input[type="range"] { width: 100%; accent-color: var(--accent); }
input[type="checkbox"], input[type="radio"] { flex: none; width: 16px; height: 16px; accent-color: var(--accent); }

button, .button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}
button:hover:not(:disabled) { background: var(--hover); }
button:disabled { cursor: default; opacity: 0.55; }
button.primary, .button-link.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
button.primary:hover:not(:disabled) { background: var(--accent); filter: brightness(1.1); }
button.primary.danger { background: var(--error); border-color: var(--error); color: #fff; }
button.danger:not(.primary) { color: var(--error); }
button.small, .button-link.small { min-height: 32px; padding: 4px 10px; font-size: 0.8rem; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: none;
  color: var(--muted);
  cursor: pointer;
}
.icon-button:hover:not(:disabled) { background: var(--hover); color: var(--text); }
.icon-button.primary { background: var(--accent); color: var(--on-accent); }
.icon-button.danger { color: var(--error); }
.icon-button[aria-pressed="true"] { color: var(--error); background: color-mix(in srgb, var(--error) 14%, transparent); }
#toggle-members[aria-pressed="true"], #screen-share[aria-pressed="true"], #camera[aria-pressed="true"] {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 16%, transparent);
}

.muted { color: var(--muted); font-size: 0.8rem; }
.error { margin: 0; color: var(--error); font-size: 0.875rem; }
.error:empty { display: none; }
.grow { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.stack { display: grid; gap: 12px; }
.mobile-only { display: none; }
.indented { display: grid; gap: 8px; padding-left: 26px; }

.link {
  min-height: 32px;
  border: none;
  background: none;
  color: var(--accent);
  text-decoration: underline;
}

/* A popover, because only the top layer can show above an open dialog. */
.toasts {
  inset: auto 16px 80px auto;
  width: fit-content;
  max-width: min(380px, calc(100vw - 32px));
  margin: 0;
  padding: 0;
  border: none;
  background: none;
  color: inherit;
  overflow: visible;
}
.toasts:popover-open { display: grid; gap: 8px; }
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: var(--shadow);
  font-size: 0.875rem;
  overflow-wrap: anywhere;
}
.toast.error svg { color: var(--error); }
.toast.info svg { color: var(--speaking); }

.avatar {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  user-select: none;
  position: relative;
  overflow: hidden;
}
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.avatar.small { width: 24px; height: 24px; font-size: 0.625rem; }
.avatar.large { width: 48px; height: 48px; font-size: 1rem; }

.brand { display: flex; align-items: center; gap: 10px; }
.logo { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--accent); color: var(--on-accent); }

.auth { display: grid; place-items: center; min-height: 100%; padding: 16px; }
.incoming-call { inset: 16px auto auto 50%; transform: translateX(-50%); width: min(360px, calc(100vw - 32px)); margin: 0; padding: 12px 14px; border: 1px solid var(--border); border-radius: 14px; background: var(--panel); color: inherit; box-shadow: 0 8px 28px rgba(0, 0, 0, 0.25); }
.incoming-call:popover-open { display: flex; align-items: center; gap: 12px; }
.incoming-who { display: grid; min-width: 0; overflow-wrap: anywhere; font-size: 0.875rem; }
.incoming-call .accept { background: #15803d; color: #fff; }
.incoming-call .accept:hover { background: #166534; color: #fff; }
.section-head { display: flex; align-items: center; padding-right: 4px; }
.section-head .icon-button { width: 28px; height: 28px; min-height: 28px; color: var(--muted); }
.channel-category { display: flex; align-items: center; margin-top: 10px; }
.category-toggle { display: flex; flex: 1; justify-content: flex-start; align-items: center; gap: 4px; min-width: 0; min-height: 28px; padding: 0 4px; border: 0; background: none; color: var(--muted); font-size: 0.75rem; font-weight: 700; text-align: left; text-transform: uppercase; }
.category-toggle span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.category-toggle:hover { color: var(--text); }
.channel-category .icon-button { width: 28px; height: 28px; min-height: 28px; color: var(--muted); }
.channel-lock { flex: none; color: var(--muted); }
.category-admin { font-weight: 600; }
.people-choice { display: grid; gap: 4px; margin: 0; padding: 8px; border: 1px solid var(--border); border-radius: 8px; }
.people-choice legend { padding: 0 4px; font-size: 0.875rem; }
.people-choice > div { display: grid; gap: 2px; max-height: 180px; overflow-y: auto; }
.person-choice { display: flex; align-items: center; gap: 8px; padding: 4px; border-radius: 6px; cursor: pointer; }
.person-choice:hover { background: var(--hover); }
.group-icon { display: inline-grid; flex: none; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--hover); color: var(--muted); }
.pin-row { display: flex; align-items: center; gap: 4px; }
.pin-row .search-result { flex: 1; min-width: 0; }
.pins-title { margin: 0; font-size: 1rem; }
.pinned-note { display: flex; align-items: center; gap: 4px; margin-top: 2px; color: var(--muted); font-size: 0.75rem; }
.ai-note { color: var(--muted); font-style: italic; }
.elsewhere { position: fixed; inset: 0; z-index: 50; background: var(--bg); }
.auth-card {
  display: grid;
  gap: 16px;
  width: min(392px, 100%);
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--panel);
}
.password-field { display: flex; align-items: center; gap: 4px; }
.download-link { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-size: 0.875rem; }

.app { display: grid; grid-template-columns: 344px minmax(0, 1fr) 220px; height: 100%; }
.members-hidden .app { grid-template-columns: 344px minmax(0, 1fr); }
.members-hidden .members-panel { display: none; }

.sidebar { display: flex; min-height: 0; background: var(--sidebar); border-right: 1px solid var(--border); }
.sidebar-main { flex: 1 1 auto; display: flex; flex-direction: column; gap: 8px; min-width: 0; min-height: 0; padding: 12px; }

.server-rail { flex: none; display: flex; flex-direction: column; align-items: center; gap: 8px; width: 64px; padding: 8px 0; overflow-y: auto; border-right: 1px solid var(--border); }
.servers { display: grid; gap: 8px; justify-items: center; }
.server-item { position: relative; }
.server-item.selected::before { content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 4px; border-radius: 0 4px 4px 0; background: var(--text); }
.server-item.has-unread:not(.selected)::before { content: ""; position: absolute; left: -10px; top: 18px; bottom: 18px; width: 4px; border-radius: 0 4px 4px 0; background: var(--text); }
.server-button { position: relative; width: 44px; height: 44px; min-height: 44px; padding: 0; border: none; border-radius: 50%; background: none; }
.server-button:hover:not(:disabled) { background: none; filter: brightness(1.1); }
.server-icon { width: 44px; height: 44px; font-size: 0.875rem; transition: border-radius 0.12s ease; }
.server-item.selected .server-icon, .server-button:hover .server-icon { border-radius: 14px; }
.server-item .mention-badge { position: absolute; right: -4px; bottom: -2px; border: 2px solid var(--sidebar); box-sizing: content-box; }
.server-voice { position: absolute; left: -2px; bottom: -2px; display: grid; place-items: center; width: 18px; height: 18px; border: 2px solid var(--sidebar); border-radius: 50%; background: var(--speaking); color: #fff; }
.server-item.muted .server-icon { opacity: 0.6; }
.add-server { flex: none; width: 44px; height: 44px; min-height: 44px; padding: 0; border: 1px dashed var(--border); border-radius: 50%; background: none; color: var(--speaking); }
.add-server:hover:not(:disabled) { border-radius: 14px; }
.server-header { flex: 1 1 auto; justify-content: flex-start; gap: 6px; min-width: 0; min-height: 36px; padding: 4px 8px; border: none; background: none; font-size: 1rem; font-weight: 700; text-align: left; overflow-wrap: anywhere; }
.server-header:hover:not(:disabled) { background: var(--hover); }
.status-menu button.danger { color: var(--error); }
.context-menu { width: auto; min-width: 200px; max-width: 280px; }
.context-menu:focus-visible { outline: none; }
.context-menu button { gap: 10px; min-height: 34px; padding: 4px 10px; text-align: left; }
.context-menu button:focus-visible { outline-offset: -2px; }
.menu-divider { height: 1px; margin: 4px 6px; background: var(--border); }
.sidebar-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.section-title { margin: 8px 8px 6px; font-size: 0.75rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }

.banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  font-size: 0.8rem;
}
.banner.warn { background: color-mix(in srgb, var(--warn) 16%, transparent); }

.channels, .members, .rows, #people, .messages, .in-channel, .servers { margin: 0; padding: 0; list-style: none; }
.channels { display: grid; gap: 2px; }

.channel {  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  border-radius: 8px;
}
.channel:hover { background: var(--hover); }
.channel.selected { background: var(--hover); }
.channel-name {
  justify-content: flex-start;
  gap: 8px;
  min-height: 38px;
  padding: 6px 8px;
  border: none;
  background: none;
  color: var(--muted);
  text-align: left;
  overflow-wrap: anywhere;
}
.channel-name:hover:not(:disabled) { background: none; color: var(--text); }
.channel.selected .channel-name { color: var(--text); font-weight: 600; }
.channel.in-voice .channel-name, .channel.in-voice .channel-name svg { color: var(--speaking); }
.channel .join { width: 32px; height: 32px; min-height: 32px; color: var(--muted); opacity: 0; }
.channel:hover .join, .channel.selected .join, .channel.in-voice .join, .channel .join:focus-visible { opacity: 1; }
.channel.in-voice .join { color: var(--error); }
.unread-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.mention-badge { flex: none; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--error); color: #fff; font-size: 0.7rem; font-weight: 700; line-height: 18px; text-align: center; }
.channel.has-unread .channel-name { color: var(--text); font-weight: 600; }
.in-channel { grid-column: 1 / -1; display: grid; gap: 2px; padding: 0 8px 6px 34px; }
.voice-person { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 0.8rem; overflow-wrap: anywhere; }
.voice-person .avatar { outline: 2px solid transparent; outline-offset: 1px; }
.voice-person.speaking .avatar { outline-color: var(--speaking); }
.status-icon { display: inline-flex; color: var(--muted); }
.status-icon.warn { color: var(--warn); }

.voice-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
}
.voice-bar-info { flex: 1 1 auto; display: grid; min-width: 0; overflow-wrap: anywhere; font-size: 0.875rem; }
.voice-channel { justify-content: flex-start; min-height: 0; padding: 0; color: var(--speaking); font-weight: 700; text-align: left; text-decoration: none; overflow-wrap: anywhere; }
.voice-channel:hover:not(:disabled) { background: none; text-decoration: underline; }

.user-panel { display: flex; align-items: center; gap: 2px; padding: 4px; border-radius: 10px; }
.user-panel #whoami { padding-left: 8px; font-size: 0.875rem; font-weight: 600; }
.status-button { flex: none; min-height: 0; padding: 2px; border: none; border-radius: 50%; background: none; }
.status-button .presence { border-color: var(--sidebar); }
.status-menu { width: 180px; margin: 0; padding: 6px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); color: var(--text); box-shadow: var(--shadow); }
.status-menu button { justify-content: flex-start; width: 100%; min-height: 36px; border: none; background: none; font-size: 0.875rem; }
.status-menu button:hover:not(:disabled) { background: var(--hover); }
.status-menu button[aria-current="true"] { font-weight: 700; }
.presence-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.presence-dot.online { background: var(--speaking); }
.presence-dot.away { background: var(--away); }
.presence-dot.dnd { background: var(--error); }

.content { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.content-head {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
}
.content-head h2 { color: var(--text); font-size: 1rem; }

.stage { flex: none; max-height: 55%; overflow-y: auto; padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--sidebar); }
.screens { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); margin-bottom: 12px; }
.screens:empty { display: none; }
.screen { min-width: 0; border-radius: 10px; overflow: hidden; background: #000; }
.screen video { display: block; width: 100%; max-height: 40vh; object-fit: contain; background: #000; }
/* Your own camera behaves like a mirror, which is what people expect to see. */
.screen.own-camera video { transform: scaleX(-1); }
.screen-caption { display: flex; align-items: center; gap: 8px; padding: 4px 8px; background: var(--panel); font-size: 0.8rem; }
.screen-caption span { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
#people { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr)); }

.person {
  display: grid;
  gap: 8px;
  padding: 10px;
  border-radius: 12px;
  background: var(--panel);
  border: 2px solid var(--border);
}
.person.speaking { border-color: var(--speaking); }
.person-head { display: flex; align-items: center; gap: 10px; min-width: 0; }
.who { min-width: 0; overflow-wrap: anywhere; }
.who .name { font-weight: 600; font-size: 0.875rem; }
.status-icons { display: flex; gap: 6px; min-height: 16px; margin-top: 2px; }
.person-controls { display: flex; align-items: center; gap: 4px; color: var(--muted); }
.person-controls input { flex: 1 1 auto; min-width: 40px; }
.person-controls .icon-button { width: 28px; height: 28px; min-height: 28px; }
.volume-value { flex: none; min-width: 42px; font-size: 0.75rem; font-variant-numeric: tabular-nums; text-align: right; }
.volume-value.boosted { color: var(--warn); font-weight: 700; }

.chat { position: relative; display: flex; flex: 1 1 auto; flex-direction: column; min-height: 0; }
.content { position: relative; }
.content.dropping::after {
  content: attr(data-drop-text);
  z-index: 5;
  position: absolute;
  inset: 8px;
  display: grid;
  place-items: center;
  border: 2px dashed var(--accent);
  border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 12%, var(--bg));
  font-weight: 600;
  pointer-events: none;
}
#older { align-self: center; margin: 8px; }
.messages { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 12px 16px; }
.empty { flex: 1 1 auto; display: grid; place-content: center; justify-items: center; gap: 8px; padding: 24px; color: var(--muted); text-align: center; }
.empty p { margin: 0; font-size: 0.875rem; }
.chat:has(.empty:not([hidden])) .messages { flex: none; padding: 0; }

.day { display: flex; align-items: center; gap: 12px; margin: 16px 0 8px; color: var(--muted); font-size: 0.75rem; font-weight: 600; }
.day::before, .day::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.message { position: relative; display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: 12px; padding: 2px 6px; margin: 8px -6px 0; border-radius: 8px; }
.message.grouped { margin-top: 0; }
.message:hover { background: var(--hover); }
.side-time { display: none; color: var(--muted); font-size: 0.65rem; text-align: right; line-height: 1.8; }
.message:hover .side-time { display: block; }
.message-main { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; min-width: 0; }
.meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; }
.author { font-weight: 600; font-size: 0.875rem; overflow-wrap: anywhere; }
.body { white-space: pre-wrap; overflow-wrap: anywhere; }
.edited { color: var(--muted); font-size: 0.7rem; }
.mention { padding: 0 3px; border-radius: 4px; background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); font-weight: 600; }
.mention.me { background: color-mix(in srgb, var(--warn) 24%, transparent); color: var(--warn); }
.message.mentions-me { background: color-mix(in srgb, var(--warn) 9%, transparent); box-shadow: inset 2px 0 0 var(--warn); }
.message.highlighted { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.day.new-messages { color: var(--error); }
.day.new-messages::before, .day.new-messages::after { background: var(--error); }

.reply-quote { justify-content: flex-start; gap: 6px; width: fit-content; max-width: 100%; min-height: 0; padding: 0 4px; border: none; background: none; color: var(--muted); font-size: 0.75rem; text-align: left; }
.reply-quote:hover:not(:disabled) { color: var(--text); }
.reply-author { flex: none; max-width: 40%; overflow: hidden; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.reply-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.reactions { display: flex; flex-wrap: wrap; gap: 4px; }
.reaction { gap: 4px; min-height: 24px; padding: 0 6px; border-radius: 12px; font-size: 0.8rem; line-height: 1; }
.reaction.mine { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, transparent); }
.reaction-count { color: var(--muted); font-size: 0.7rem; font-weight: 600; }
.reaction.mine .reaction-count { color: var(--text); }

.message-actions { position: absolute; top: -10px; right: 4px; z-index: 1; display: none; padding: 1px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel); box-shadow: 0 2px 6px rgb(0 0 0 / 15%); }
.message-actions .icon-button { width: 28px; height: 28px; min-height: 28px; }
.message.active .message-actions { display: flex; }
/* A tap counts as hovering, which would put the buttons under the finger of that same tap. */
@media (hover: hover) {
  .message:hover .message-actions, .message:focus-within .message-actions { display: flex; }
}
.message:first-child .message-actions { top: 0; }

.emoji-picker { width: 344px; height: 340px; max-width: calc(100vw - 16px); margin: 0; padding: 0; border: 1px solid var(--border); border-radius: 12px; background: var(--panel); color: var(--text); box-shadow: var(--shadow); }
.emoji-picker:popover-open { display: flex; flex-direction: column; }
.emoji-nav { flex: none; display: flex; justify-content: space-between; padding: 4px 8px; border-bottom: 1px solid var(--border); }
.emoji-jump { width: 36px; height: 32px; min-height: 32px; padding: 0; border: none; background: none; font-size: 1.05rem; }
.emoji-scroll { position: relative; flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 4px 8px 8px; }
.emoji-section h4 { margin: 8px 0 4px; color: var(--muted); font-size: 0.7rem; font-weight: 700; text-transform: uppercase; }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; }
.emoji-choice { min-height: 34px; padding: 0; border: none; background: none; font-size: 1.15rem; }

.to-latest { position: absolute; right: 24px; bottom: 96px; z-index: 2; border: 1px solid var(--border); border-radius: 50%; background: var(--panel); box-shadow: var(--shadow); }
.typing { min-height: 18px; margin: 0 20px; color: var(--muted); font-size: 0.75rem; line-height: 18px; }
.composer-context { display: flex; align-items: center; gap: 8px; margin: 0 16px 4px; padding: 2px 4px 2px 10px; border-radius: 8px; background: var(--hover); color: var(--muted); font-size: 0.8rem; overflow-wrap: anywhere; }
.composer-context .icon-button { width: 28px; height: 28px; min-height: 28px; }
#composer-context-icon { display: inline-flex; }
.mention-list { display: grid; gap: 2px; margin: 0 16px 4px; padding: 4px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); box-shadow: var(--shadow); }
.mention-choice { justify-content: flex-start; min-height: 34px; padding: 4px 8px; border: none; background: none; font-size: 0.875rem; text-align: left; }
.mention-choice.active { background: var(--hover); font-weight: 600; }

.search-dialog { width: min(640px, calc(100vw - 32px)); max-height: min(640px, calc(100vh - 64px)); margin-top: 32px; }
.search-dialog[open] { display: flex; flex-direction: column; }
.search-head { flex: none; display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 16px; border-bottom: 1px solid var(--border); color: var(--muted); }
.search-head input { border: none !important; background: none !important; }
.search-head input:focus-visible { outline: none; }
.search-head input::-webkit-search-cancel-button { display: none; }
.search-results { min-height: 0; overflow-y: auto; }
.search-result { display: flex; justify-content: flex-start; align-items: flex-start; gap: 12px; width: 100%; padding: 10px 16px; border: none; border-bottom: 1px solid var(--border); border-radius: 0; background: none; text-align: left; }
.search-text { display: grid; gap: 2px; min-width: 0; }
.search-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; }
.search-body { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow-wrap: anywhere; white-space: pre-wrap; font-size: 0.875rem; }
.search-note { margin: 0; padding: 16px; text-align: center; }

.server-status { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; margin: 0; font-size: 0.875rem; }
.server-status dt { color: var(--muted); }
.server-status dd { margin: 0; font-variant-numeric: tabular-nums; }

.body strong { font-weight: 700; }
.body code, .command-row code { padding: 1px 4px; border-radius: 4px; background: var(--hover); font: 0.875em ui-monospace, Consolas, monospace; }
.body pre { margin: 4px 0; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--sidebar); overflow-x: auto; white-space: pre; }
.body pre code { padding: 0; background: none; }
.body blockquote { margin: 2px 0; padding-left: 10px; border-left: 3px solid var(--border); color: var(--muted); }
.body ul { margin: 2px 0; padding-left: 20px; }
.body.jumbo { font-size: 2.2rem; line-height: 1.2; }
.spoiler { border-radius: 4px; background: var(--text); color: transparent; cursor: pointer; }
.spoiler * { color: transparent !important; background: none !important; }
.spoiler.revealed { background: var(--hover); color: inherit; cursor: auto; }
.spoiler.revealed * { color: inherit !important; }

.media-attachment { display: grid; gap: 4px; width: min(480px, 100%); padding: 8px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); }
.media-head { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 0.8rem; }
.media-head .file-name { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.media-head .icon-button { width: 28px; height: 28px; min-height: 28px; }
.media-attachment audio { display: block; width: 100%; height: 40px; }
.media-attachment video { display: block; width: 100%; max-height: 360px; border-radius: 6px; background: #000; }
.presentation-slot:not(:empty) { margin-top: 4px; }
.media-attachment:has(.slide-viewer) { width: min(640px, 100%); }

.slide-viewer { display: grid; gap: 4px; background: var(--panel); }
.slide-viewer:focus-visible { outline: none; }
.slide-stage { position: relative; width: 100%; overflow: hidden; border: 1px solid var(--border); border-radius: 6px; background: #fff; color: #000; container-type: inline-size; }
.slide-content { position: absolute; inset: 0; background: #fff; }
.slide-shape { position: absolute; display: flex; flex-direction: column; justify-content: flex-start; padding: 0.5cqw 1cqw; overflow: hidden; }
.slide-image { display: block; padding: 0; object-fit: contain; }
.slide-line { margin: 0 0 0.4cqw; overflow-wrap: anywhere; white-space: pre-wrap; }
.slide-line.bullet::before { content: "• "; }
.slide-missing { align-items: center; justify-content: center; border: 1px dashed #999; background: #f2f2f2; color: #555; font-size: 1.6cqw; text-align: center; }
.slide-bar { display: flex; align-items: center; gap: 4px; }
.slide-counter { flex: none; min-width: 48px; font-size: 0.8rem; font-variant-numeric: tabular-nums; text-align: center; }
.slide-note { font-size: 0.7rem; }
.slide-viewer:fullscreen { display: flex; flex-direction: column; justify-content: center; padding: 16px; background: #000; color: #fff; }
.slide-viewer:fullscreen .slide-stage { width: auto; max-width: 100%; max-height: calc(100vh - 80px); flex: 0 1 auto; margin: 0 auto; }
.slide-viewer:fullscreen .slide-stage { width: min(100%, calc((100vh - 80px) * 1.78)); }

.format-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; margin: 0 16px 4px; padding: 2px 6px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel); }
.format-bar .icon-button { width: 30px; height: 30px; min-height: 30px; }
.format-hint { margin-left: auto; font-size: 0.7rem; }
#format-toggle[aria-pressed="true"] { color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, transparent); }
.suggestion-name { font-weight: 600; }
.suggestion-text { font-size: 0.75rem; }

.gif-picker { width: 360px; height: 380px; max-width: calc(100vw - 16px); margin: 0; padding: 8px; border: 1px solid var(--border); border-radius: 12px; background: var(--panel); color: var(--text); box-shadow: var(--shadow); }
.gif-picker:popover-open { display: flex; flex-direction: column; gap: 8px; }
.gif-head { display: flex; align-items: center; gap: 8px; font-size: 0.875rem; }
.gif-picker p { margin: 8px 0; text-align: center; }
.gif-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; min-height: 0; overflow-y: auto; }
.gif-choice { min-height: 80px; padding: 0; overflow: hidden; border-radius: 8px; }
.gif-choice img { display: block; width: 100%; height: 110px; object-fit: cover; }

.custom-emoji { display: inline-block; width: 1.4em; height: 1.4em; vertical-align: -0.35em; object-fit: contain; }
.body.jumbo .custom-emoji { width: 2.4rem; height: 2.4rem; vertical-align: middle; }
.reaction .custom-emoji { width: 1.2em; height: 1.2em; vertical-align: middle; }
.emoji-choice .custom-emoji { width: 24px; height: 24px; vertical-align: middle; }
.blocked-message { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 0.8rem; }
.blocked-message button { min-height: 0; padding: 0; border: none; background: none; color: var(--accent); font-size: inherit; text-decoration: underline; }
.member.blocked { opacity: 0.45; }
.person.blocked { opacity: 0.55; }

.screen-view { position: relative; overflow: hidden; background: #000; }
.screen-view.can-zoom { touch-action: none; }
.screen-view.zoomed { cursor: grab; }
.screen-view.dragging { cursor: grabbing; }
.screen-view video { transform-origin: 0 0; }
.screen-view:fullscreen { display: flex; align-items: center; justify-content: center; }
.screen-view:fullscreen video { width: 100%; height: 100%; max-height: none; }
.zoom-level { flex: none !important; font-size: 0.75rem; font-variant-numeric: tabular-nums; }
.volume-menu { display: grid; gap: 2px; padding: 4px 10px; font-size: 0.8rem; }
.volume-menu div { display: flex; justify-content: space-between; gap: 12px; }

.home-button { display: grid; place-items: center; }
.home-button .logo { width: 44px; height: 44px; border-radius: 50%; transition: border-radius 0.12s ease; }
.home-button:hover .logo, .home-button.selected .logo { border-radius: 14px; }
.home-button .mention-badge { position: absolute; right: -4px; bottom: -2px; border: 2px solid var(--sidebar); box-sizing: content-box; }
.home-contacts { justify-content: flex-start; width: 100%; margin-bottom: 8px; border: none; background: none; color: var(--muted); }
.home-contacts.selected { background: var(--hover); color: var(--text); font-weight: 600; }
.home-contacts .mention-badge { margin-left: auto; }
.dm-row { padding: 0; }
.dm-row .dm-open { flex: 1; width: 100%; min-width: 0; }
.dm-row.selected { background: var(--hover); }
.dm-open { flex: 1 1 auto; justify-content: flex-start; min-width: 0; min-height: 40px; padding: 4px 8px; border: none; background: none; text-align: left; font-size: 0.875rem; }
.dm-empty { padding: 4px 8px; }
.contacts-view { flex: 1 1 auto; display: flex; flex-direction: column; gap: 12px; min-height: 0; overflow-y: auto; padding: 16px; }
.contacts-tabs { flex: none; max-width: 420px; }
.contacts-tabs button { gap: 6px; }
.contact-form { flex: none; max-width: 520px; }
.contacts-list { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }
.contact-row { display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 6px 10px; border-radius: 10px; cursor: default; opacity: 1 !important; }
.contact-row:hover { background: var(--hover); }
.contact-row .avatar.server-icon { width: 36px; height: 36px; }
.contact-actions { display: flex; flex: none; gap: 2px; margin-left: auto; }
.contacts-empty { margin: 24px 0; text-align: center; }
.home-open:not(.group-open) .app { grid-template-columns: 344px minmax(0, 1fr); }
.home-open:not(.group-open) .members-panel, .home-open:not(.group-open) #toggle-members, .home-open #composer-gif { display: none !important; }

.compact .message-actions { top: -8px; }
.channels-head { display: flex; align-items: center; }
.channels-head .icon-button { width: 26px; height: 26px; min-height: 26px; margin-right: 4px; }
.channel-actions { display: flex; align-items: center; }
.channel .channel-gear { width: 32px; height: 32px; min-height: 32px; opacity: 0; }
.channel:hover .channel-gear, .channel-gear:focus-visible { opacity: 1; }

.user-names { display: grid; min-width: 0; padding-left: 8px; line-height: 1.2; }
.user-names #whoami { padding-left: 0; }
#my-status-text { overflow: hidden; font-size: 0.7rem; text-overflow: ellipsis; white-space: nowrap; }
.member-names { display: grid; flex: 1 1 auto; min-width: 0; line-height: 1.2; }
.member-status { overflow: hidden; color: var(--muted); font-size: 0.7rem; text-overflow: ellipsis; white-space: nowrap; }
.member { cursor: pointer; }
.member:hover { background: var(--hover); }
[data-user] { cursor: pointer; }
.author[data-user]:hover { text-decoration: underline; }

.avatar.huge { width: 72px; height: 72px; font-size: 1.4rem; }
.profile-card { width: 300px; margin: 0; padding: 14px; border: 1px solid var(--border); border-radius: 14px; background: var(--panel); color: var(--text); box-shadow: var(--shadow); }
.profile-card:popover-open { display: grid; gap: 8px; }
.profile-card p { margin: 0; overflow-wrap: anywhere; }
.profile-head { display: flex; align-items: center; gap: 12px; }
.profile-who { display: grid; gap: 4px; min-width: 0; overflow-wrap: anywhere; }
.profile-presence { display: flex; align-items: center; gap: 6px; }
.presence-dot.offline { background: var(--muted); }
.profile-status { font-size: 0.875rem; font-weight: 600; }
.profile-bio { font-size: 0.875rem; white-space: pre-wrap; }

.soundboard-panel { width: 320px; max-width: calc(100vw - 16px); margin: 0; padding: 8px; border: 1px solid var(--border); border-radius: 12px; background: var(--panel); color: var(--text); box-shadow: var(--shadow); }
.soundboard-panel:popover-open { display: grid; gap: 8px; }
.soundboard-panel p { margin: 8px 0; text-align: center; }
.soundboard-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; max-height: 300px; overflow-y: auto; }
.soundboard-grid:empty { display: none; }
.soundboard-volume { display: flex; align-items: center; gap: 8px; margin: 0; padding: 0 4px; font-size: 13px; }
.soundboard-volume input { flex: 1; min-width: 0; }
.soundboard-volume span { min-width: 38px; text-align: right; font-variant-numeric: tabular-nums; }
.sound-button { display: grid; justify-items: center; gap: 2px; min-height: 64px; padding: 6px 4px; }
.sound-emoji { font-size: 1.3rem; line-height: 1.2; }
.sound-name { font-size: 0.7rem; overflow-wrap: anywhere; text-align: center; }
.inline-fields { display: flex; flex-wrap: wrap; gap: 8px; }
.emoji-input { width: 72px !important; text-align: center; }

.settings-title { padding: 4px 14px 8px; overflow-wrap: anywhere; font-size: 0.875rem; }
.panel-head { display: flex; align-items: center; gap: 8px; }
.kind-choice { display: grid; gap: 6px; }
.kind-choice label { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); cursor: pointer; }
.kind-choice label:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--panel)); }
.kind-choice label > span:last-child { display: grid; }
.kind-choice input { position: absolute; opacity: 0; }
.kind-choice label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 1px; }
.segmented { display: flex; gap: 2px; padding: 2px; border-radius: 10px; background: var(--hover); }
.segmented button { flex: 1 1 0; min-height: 34px; border: none; background: none; color: var(--muted); }
.segmented button.active { background: var(--panel); color: var(--text); font-weight: 600; }
.commands-help { width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 64px); overflow-y: auto; }
.commands-help h3 { margin: 8px 0 0; }
.command-list { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; }
.command-row { display: grid; grid-template-columns: minmax(150px, 40%) minmax(0, 1fr); gap: 12px; align-items: baseline; font-size: 0.875rem; }
.command-row code { width: fit-content; }

.compact .message { grid-template-columns: 24px minmax(0, 1fr); gap: 8px; margin-top: 2px; padding-block: 0; }
.compact .message .avatar { width: 24px; height: 24px; font-size: 0.625rem; }
.compact .side-time { display: none !important; }
.compact .message-main { gap: 0; }

.image-attachment { display: block; width: fit-content; max-width: min(420px, 100%); min-height: 0; padding: 0; border-radius: 8px; overflow: hidden; }
.image-attachment:hover:not(:disabled) { filter: brightness(0.95); }
.image-attachment img { display: block; max-width: 100%; max-height: 320px; }
.file-attachment {
  display: flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  max-width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  text-decoration: none;
}
.file-attachment:hover { background: var(--hover); }
.file-info { display: grid; min-width: 0; }
.file-name { font-size: 0.875rem; overflow-wrap: anywhere; }

.upload-progress { display: flex; align-items: center; gap: 12px; margin: 0 16px 8px; font-size: 0.8rem; overflow-wrap: anywhere; }
.upload-progress progress { flex: none; width: 120px; accent-color: var(--accent); }

.composer {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  margin: 0 16px 16px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
}
.composer textarea {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 36px;
  max-height: 160px;
  padding: 7px 4px;
  border: none;
  background: none;
  resize: none;
  field-sizing: content;
}
.composer textarea:focus-visible { outline: none; }
.composer textarea::placeholder { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.composer:focus-within { border-color: var(--accent); }

.members-panel { min-height: 0; overflow-y: auto; padding: 12px; background: var(--sidebar); border-left: 1px solid var(--border); }
.members { display: grid; gap: 2px; margin-bottom: 12px; }
.member { display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 4px 8px; border-radius: 8px; font-size: 0.875rem; overflow-wrap: anywhere; }
.member:not(.online) { opacity: 0.6; }
.member-avatar { position: relative; display: inline-flex; }
.member-avatar .presence { position: absolute; right: -2px; bottom: -2px; width: 10px; height: 10px; border: 2px solid var(--sidebar); border-radius: 50%; background: var(--muted); }
.member.online .presence, .status-online .presence { background: var(--speaking); }
.member.online.status-away .presence, .status-away .presence { background: var(--away); }
.member.online.status-dnd .presence, .status-dnd .presence { background: var(--error); }
.role-badge { display: inline-flex; color: var(--warn); }

dialog {
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg);
  color: var(--text);
  box-shadow: var(--shadow);
}
dialog::backdrop { background: rgb(0 0 0 / 55%); }

.small-dialog { display: none; width: min(420px, calc(100vw - 32px)); padding: 20px; }
.small-dialog[open] { display: grid; gap: 12px; }
#server-dialog h2 { padding-right: 36px; }
#create-server-form { padding-top: 12px; border-top: 1px solid var(--border); }
.dialog-text { margin: 0; font-size: 0.875rem; color: var(--muted); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.copy-field { display: flex; align-items: center; gap: 4px; }

/* Full size whatever the picture is, so the close button can't end up outside a tiny image. */
.lightbox { width: calc(100vw - 32px); height: calc(100vh - 32px); max-width: none; max-height: none; border: none; background: rgb(0 0 0 / 85%); }
.lightbox[open] { display: grid; place-items: center; }
.lightbox img { display: block; max-width: 100%; max-height: 100%; }
.close { position: absolute; top: 12px; right: 12px; z-index: 1; }
.lightbox .close { background: rgb(0 0 0 / 55%); color: #fff; }

.settings-dialog { width: min(860px, calc(100vw - 32px)); height: min(680px, calc(100vh - 32px)); overflow: hidden; }
.settings-layout { display: grid; grid-template-columns: 190px minmax(0, 1fr); height: 100%; }
.settings-tabs { display: grid; align-content: start; gap: 2px; padding: 12px; background: var(--sidebar); border-right: 1px solid var(--border); overflow-y: auto; }
.settings-tabs button { justify-content: flex-start; border: none; background: none; color: var(--muted); }
.settings-tabs button:hover:not(:disabled) { background: var(--hover); color: var(--text); }
.settings-tabs button.active { background: var(--hover); color: var(--text); font-weight: 600; }
.settings-body { position: relative; min-width: 0; overflow-y: auto; padding: 20px 24px; }
.panel { display: grid; gap: 10px; align-content: start; padding-right: 32px; }
.panel h3 { margin-bottom: 0; }
#keys-note { margin: 0; }
#update-status, .update-version { margin: 0; }
#update-status.error { color: var(--error); }

.mic-test { display: grid; gap: 8px; }
.mic-test > button { justify-self: start; }
.meter { position: relative; height: 12px; border-radius: 6px; background: var(--border); overflow: hidden; }
.meter-level { width: 0; height: 100%; background: var(--muted); }
.meter-level.open { background: var(--speaking); }
.meter-threshold { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--error); }

.key-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  font-size: 0.875rem;
}
.key-title { display: inline-flex; align-items: center; gap: 8px; flex: 1 1 100%; color: var(--muted); }

.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { width: 36px; height: 36px; min-height: 36px; padding: 0; border: 3px solid transparent; border-radius: 50%; }
.swatch:hover:not(:disabled) { filter: brightness(1.15); }
.swatch.active { border-color: var(--text); }

.account-card { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); overflow-wrap: anywhere; }
#account-avatar { display: inline-flex; }
.button-row { display: flex; flex-wrap: wrap; gap: 8px; }

.rows { display: grid; gap: 6px; }
.rows:empty { display: none; }
.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  font-size: 0.875rem;
}
.row .grow { flex: 1 1 120px; }
.row select { width: auto; min-width: 110px; }
.row.banned { opacity: 0.65; }

form.inline { display: flex; flex-wrap: wrap; align-items: end; gap: 8px; }
form.inline label { flex: 1 1 160px; }
.invite-result { margin: 4px 0; }

#stats { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; margin: 0; font-size: 0.875rem; }
#stats:empty::before { content: attr(data-empty); grid-column: 1 / -1; color: var(--muted); }
#stats dt { color: var(--muted); }
#stats dd { margin: 0; font-variant-numeric: tabular-nums; }

@media (max-width: 1099px) {
  .app { grid-template-columns: 344px minmax(0, 1fr); }
  .members-panel { position: fixed; z-index: 20; top: 52px; right: 0; bottom: 0; width: min(260px, 85vw); box-shadow: var(--shadow); }
  /* On narrow screens the panel covers the chat, so it starts closed and opens on request. */
  .members-hidden .members-panel { display: none; }
}

@media (max-width: 759px) {
  .mobile-only { display: inline-flex; }
  .app, .members-hidden .app, .home-open .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed;
    z-index: 30;
    inset: 0 auto 0 0;
    width: min(344px, 92vw);
    transform: translateX(-105%);
    transition: transform 0.18s ease;
    box-shadow: var(--shadow);
  }
  .drawer-open .sidebar { transform: none; }
  .channel .join { opacity: 1; }
  .to-latest { right: 16px; }
  .stage { max-height: 45%; }
  .settings-dialog { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0; border: none; }
  .settings-layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .settings-tabs { display: flex; padding: 8px 52px 8px 8px; border-right: none; border-bottom: 1px solid var(--border); overflow-x: auto; }
  .settings-tabs button { flex: none; }
  .settings-body { padding: 16px; }
  .close { position: fixed; top: 8px; right: 8px; background: var(--bg); }
  .panel { padding-right: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar { transition: none; }
}
