: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; }
.member-group { margin: 10px 8px 2px; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.02em; color: var(--muted); text-transform: uppercase; list-style: none; }
.role-dot { display: inline-block; flex: none; width: 12px; height: 12px; border-radius: 50%; }
.role-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 0.8rem; }
.role-preview { margin: 0; }
.role-row-name { font-weight: 600; }
.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-tabs { flex: none; }
.gif-pane { display: flex; flex: 1; flex-direction: column; gap: 8px; min-height: 0; }
.gif-pane[hidden] { display: none; }
.gif-choice video { display: block; width: 100%; height: 110px; object-fit: cover; }
.klipy-attribution { align-self: flex-end; color: var(--muted); font-size: 0.7rem; text-decoration: none; }
.klipy-gif { display: grid; gap: 2px; justify-items: start; }
.klipy-gif video, .klipy-gif img { max-width: min(320px, 100%); max-height: 300px; border-radius: 8px; }
.klipy-gif a { color: var(--muted); font-size: 0.7rem; text-decoration: none; }
.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: 80px; height: 80px; font-size: 1.6rem; }
.profile-card { width: 320px; margin: 0; padding: 0; overflow: hidden; border: 1px solid var(--border); border-radius: 16px; background: var(--panel); color: var(--text); box-shadow: var(--shadow); }
.profile-card:popover-open { display: block; }
.profile-card p { margin: 0; overflow-wrap: anywhere; }
.profile-banner { --banner: var(--accent); position: relative; height: 96px; background: linear-gradient(135deg, color-mix(in srgb, var(--banner) 82%, #fff), var(--banner) 55%, color-mix(in srgb, var(--banner) 70%, #000)); }
.profile-picture { position: absolute; left: 16px; bottom: -40px; padding: 5px; border-radius: 50%; background: var(--panel); }
.profile-picture .presence-dot { position: absolute; right: 6px; bottom: 6px; width: 18px; height: 18px; border: 4px solid var(--panel); }
.profile-body { display: grid; gap: 12px; padding: 48px 16px 16px; }
.profile-who { display: grid; gap: 2px; min-width: 0; overflow-wrap: anywhere; }
.profile-name { font-size: 1.25rem; line-height: 1.2; }
.profile-handle { display: flex; flex-wrap: wrap; gap: 6px; font-size: 0.85rem; color: var(--muted); }
.presence-dot.offline { background: var(--muted); }
.profile-status { position: relative; justify-self: start; max-width: 100%; padding: 6px 12px; border-radius: 12px; background: var(--hover); font-size: 0.875rem; }
.profile-section { display: grid; gap: 6px; padding-top: 10px; border-top: 1px solid var(--border); }
.profile-section h4 { margin: 0; font-size: 0.7rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.profile-bio { font-size: 0.875rem; white-space: pre-wrap; }
.profile-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.profile-badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; background: var(--hover); font-size: 0.8rem; font-weight: 600; }
.profile-badge.owner { background: color-mix(in srgb, #eab308 20%, transparent); color: color-mix(in srgb, #eab308 70%, var(--text)); }
.profile-badge.admin, .profile-badge.moderator { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }
.profile-servers { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.profile-server { width: 36px; height: 36px; min-height: 36px; padding: 0; border: none; border-radius: 12px; background: none; }
.profile-server .avatar { width: 36px; height: 36px; border-radius: 12px; font-size: 0.75rem; }
.profile-server:hover:not(:disabled) { background: none; filter: brightness(1.1); transform: translateY(-1px); }
.profile-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.profile-actions button { display: inline-flex; flex: 1 1 auto; align-items: center; justify-content: center; gap: 6px; }
.banner-preview { --banner: var(--accent); height: 44px; border-radius: 10px; background: linear-gradient(135deg, color-mix(in srgb, var(--banner) 82%, #fff), var(--banner) 55%, color-mix(in srgb, var(--banner) 70%, #000)); }

.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; }
}

/* ----- calendar */
.calendar-view { flex: 1 1 auto; display: flex; flex-direction: column; gap: 12px; min-height: 0; overflow-y: auto; padding: 16px; }
.calendar-section-head { display: flex; align-items: center; gap: 8px; }
.calendar-section-head h3 { margin: 0; }
.calendar-upcoming { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.calendar-upcoming-empty { margin: 0; padding: 18px; border: 1px dashed var(--border); border-radius: 14px; text-align: center; }
.event-cover { background-color: hsl(var(--event-hue, 240) 55% 50%); background-image: linear-gradient(135deg, hsl(var(--event-hue, 240) 70% 62%), hsl(calc(var(--event-hue, 240) + 50) 62% 42%)); background-size: cover; background-position: center; color: #fff; }
.event-card { display: grid; grid-template-rows: 120px auto; grid-template-columns: minmax(0, 1fr); justify-content: stretch; align-content: start; gap: 0; min-height: 0; padding: 0; overflow: hidden; border: 1px solid var(--border); border-radius: 14px; background: var(--panel); text-align: left; transition: transform 120ms ease, box-shadow 120ms ease; }
.event-card:hover:not(:disabled) { transform: translateY(-2px); box-shadow: var(--shadow); background: var(--panel); }
.event-card > .event-cover { display: grid; place-items: center; width: 100%; height: 100%; min-height: 120px; }
.event-card-body { display: grid; align-content: start; gap: 4px; padding: 10px 12px 12px; min-width: 0; }
.event-card-when { font-size: 0.8rem; font-weight: 600; color: var(--accent); }
.event-card-title { overflow: hidden; font-size: 1rem; text-overflow: ellipsis; white-space: nowrap; }
.event-card-meta { display: flex; align-items: center; gap: 4px; min-width: 0; font-size: 0.8rem; color: var(--muted); }
.event-card-meta span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.event-chip { justify-self: start; display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px; font-size: 0.72rem; font-weight: 700; background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }
.event-chip.invited { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.event-chip.going { background: color-mix(in srgb, var(--speaking) 18%, transparent); color: var(--speaking); }
.event-chip.big { padding: 6px 12px; font-size: 0.85rem; }

.calendar-toolbar { display: flex; align-items: center; gap: 6px; margin-top: 8px; }
.calendar-month { min-width: 190px; margin: 0; font-size: 1.15rem; text-align: center; text-transform: capitalize; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.calendar-weekday { padding: 2px 0; font-size: 0.72rem; font-weight: 700; color: var(--muted); text-align: center; text-transform: uppercase; letter-spacing: 0.04em; }
.calendar-day { position: relative; display: flex; flex-direction: column; gap: 3px; min-width: 0; min-height: clamp(78px, 13vh, 128px); padding: 4px; overflow: hidden; border: 1px solid var(--border); border-radius: 10px; background-color: var(--panel); cursor: pointer; }
.calendar-day:hover { border-color: var(--accent); }
.calendar-day > * { position: relative; z-index: 1; }
.calendar-day.event-cover { border-color: transparent; }
.calendar-day.event-cover::before { content: ""; position: absolute; inset: 0; background: linear-gradient(to bottom, rgb(0 0 0 / 28%), rgb(0 0 0 / 58%)); }
.calendar-day.other-month { opacity: 0.45; }
.calendar-day.past:not(.event-cover) .calendar-day-number { color: var(--muted); }
.calendar-day-number { align-self: flex-start; justify-content: center; min-width: 26px; height: 26px; min-height: 26px; padding: 0 7px; border: none; border-radius: 999px; background: none; color: inherit; font-size: 0.8rem; font-weight: 700; }
.calendar-day-number:hover:not(:disabled) { background: var(--hover); }
.calendar-day.event-cover .calendar-day-number:hover { background: rgb(255 255 255 / 22%); }
.calendar-day.today .calendar-day-number, .calendar-day.today .calendar-day-number:hover { background: var(--accent); color: var(--on-accent); }
.calendar-chips { display: grid; gap: 2px; min-width: 0; }
.calendar-chip { display: flex; align-items: center; justify-content: flex-start; gap: 4px; width: 100%; min-width: 0; min-height: 0; padding: 2px 6px; border: none; border-left: 3px solid var(--accent); border-radius: 6px; background: color-mix(in srgb, var(--accent) 14%, var(--panel)); color: var(--text); font-size: 0.72rem; text-align: left; white-space: nowrap; }
.calendar-chip svg { flex: none; }
.calendar-chip.invited { border-left-color: var(--warn); }
.calendar-chip.going { border-left-color: var(--speaking); }
.calendar-day.event-cover .calendar-chip { background: rgb(0 0 0 / 48%); color: #fff; }
.calendar-chip:hover:not(:disabled) { filter: brightness(1.1); }
.calendar-chip-time { flex: none; font-weight: 700; }
.calendar-chip-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.calendar-more { justify-self: start; min-height: 0; padding: 0 6px; border: none; background: none; color: inherit; font-size: 0.7rem; text-decoration: underline; }
.calendar-dots { display: none; gap: 3px; padding-left: 6px; }
.calendar-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.calendar-day.event-cover .calendar-dot { background: #fff; }

.event-day-list { display: grid; gap: 6px; }
.event-day-row { display: flex; align-items: center; justify-content: flex-start; gap: 10px; width: 100%; padding: 6px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); text-align: left; }
.event-day-row > .event-cover { flex: none; width: 56px; height: 40px; border-radius: 8px; }
.event-day-text { display: grid; min-width: 0; }
.event-day-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.event-form-dialog { width: min(480px, calc(100vw - 32px)); max-height: calc(100vh - 48px); overflow-y: auto; }
.event-time-row { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 8px; }
.event-visibility { grid-template-columns: 1fr 1fr; }
#event-visibility-hint { margin: -4px 0 0; }

.event-detail { width: min(580px, calc(100vw - 32px)); max-height: calc(100vh - 48px); }
.event-detail[open] { display: flex; flex-direction: column; overflow: hidden; }
.event-detail-body { position: relative; overflow-y: auto; }
#event-detail-cover { position: relative; display: grid; place-items: center; height: 210px; }
.event-credit, .event-cover-note { position: absolute; bottom: 8px; max-width: 75%; overflow: hidden; padding: 2px 8px; border-radius: 999px; background: rgb(0 0 0 / 58%); color: #fff; font-size: 0.7rem; text-overflow: ellipsis; white-space: nowrap; }
.event-credit { right: 8px; }
.event-cover-note { left: 8px; }
.event-detail-close { position: absolute; top: 8px; right: 8px; z-index: 2; background: rgb(0 0 0 / 45%); color: #fff; }
.event-detail-close:hover:not(:disabled) { background: rgb(0 0 0 / 65%); color: #fff; }
.event-detail-main { display: grid; gap: 10px; padding: 16px 20px 20px; }
.event-detail-main h3 { margin: 8px 0 0; }
.event-detail-head { display: flex; align-items: flex-start; gap: 8px; }
.event-detail-head h2 { margin: 0; font-size: 1.35rem; overflow-wrap: anywhere; }
.event-detail-tools { display: flex; gap: 2px; }
.event-facts { display: grid; gap: 6px; font-size: 0.9rem; }
.event-fact { display: flex; align-items: center; gap: 8px; }
.event-fact svg { flex: none; color: var(--muted); }
.event-description { margin: 0; font-size: 0.9rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.event-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.event-actions button { display: inline-flex; align-items: center; gap: 6px; }
.event-people { display: flex; flex-wrap: wrap; gap: 6px; }
.event-person { display: inline-flex; align-items: center; gap: 6px; min-height: 0; padding: 3px 10px 3px 3px; border: 1px solid var(--border); border-radius: 999px; background: var(--panel); font-size: 0.85rem; }
.event-person-label { font-size: 0.72rem; color: var(--muted); }
.event-person .icon-button { width: 20px; height: 20px; min-height: 20px; margin-right: -6px; }
.event-comments { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.event-comment { display: grid; gap: 2px; }
.event-comment-head { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; }
.event-comment-head .icon-button { width: 24px; height: 24px; min-height: 24px; }
.event-comment-body { margin: 0 0 0 32px; font-size: 0.9rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.event-comment-form { display: flex; align-items: flex-end; gap: 8px; }
.event-comment-form textarea { flex: 1 1 auto; min-height: 40px; resize: vertical; }
#event-comments-empty, #event-comment-note { margin: 0; }
.toast.clickable { cursor: pointer; }

@media (max-width: 759px) {
  .calendar-view { padding: 12px; }
  .calendar-upcoming { grid-auto-flow: column; grid-auto-columns: 78%; grid-template-columns: none; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 4px; }
  .event-card { scroll-snap-align: start; }
  .calendar-grid { gap: 3px; }
  .calendar-day { min-height: 54px; padding: 2px; border-radius: 8px; }
  .calendar-chips { display: none; }
  .calendar-dots { display: flex; }
  .calendar-month { min-width: 0; font-size: 1rem; }
  .event-time-row { grid-template-columns: 1fr 1fr; }
  .event-time-row label:first-child { grid-column: 1 / -1; }
}
.banner-field { display: grid; gap: 8px; }
.auto-swatch { background: conic-gradient(#ef4444, #eab308, #22c55e, #0ea5e9, #a855f7, #ef4444); }

/* ----- microphone permission */
.mic-banner { margin: 8px 16px 0; font-size: 0.85rem; }
.mic-banner .icon-button { width: 28px; height: 28px; min-height: 28px; }
.mic-permission-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.mic-permission-state { display: inline-flex; align-items: center; gap: 6px; font-size: 0.85rem; color: var(--muted); }
.mic-permission-state.granted { color: var(--speaking); }
.mic-permission-state.denied { color: var(--error); }
.mic-help-steps { display: grid; gap: 6px; margin: 0; padding-left: 20px; font-size: 0.9rem; }
.mic-help-steps:empty { display: none; }

/* ----- KLIPY */
.klipy-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 8px; }
.klipy-independent { font-size: 0.65rem; color: var(--muted); }
.klipy-attribution { margin-left: auto; }
.klipy-mark { font-weight: 800; letter-spacing: 0.04em; color: var(--text); }
.klipy-frame { position: relative; display: block; width: fit-content; max-width: min(320px, 100%); line-height: 0; }
.klipy-gif .klipy-frame video, .klipy-gif .klipy-frame img { display: block; max-width: 100%; min-width: 120px; min-height: 80px; object-fit: contain; }
.klipy-gif a.klipy-watermark { position: absolute; right: 6px; bottom: 6px; padding: 2px 6px; border-radius: 6px; background: rgb(0 0 0 / 55%); color: #fff; font-size: 0.6rem; font-weight: 800; letter-spacing: 0.05em; line-height: 1.2; white-space: nowrap; opacity: 0.85; }
.klipy-gif a.klipy-watermark:hover { opacity: 1; }
#mic-help { width: min(500px, calc(100vw - 32px)); }
#mic-help .dialog-actions { flex-wrap: wrap; }
#mic-help .dialog-actions button { white-space: nowrap; }

/* ----- command list */
.mention-list { max-height: min(45vh, 360px); overflow-y: auto; overscroll-behavior: contain; }
.suggestion-group { padding: 8px 8px 2px; font-size: 0.68rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.suggestion-group:first-child { padding-top: 2px; }
.command-group { margin-top: 10px; font-size: 0.7rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.command-group:first-child { margin-top: 0; }

/* ----- polls */
.poll { display: grid; gap: 6px; max-width: 460px; margin-top: 2px; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--panel); }
.poll-head { display: flex; align-items: flex-start; gap: 8px; }
.poll-head svg { flex: none; margin-top: 2px; color: var(--accent); }
.poll-question { overflow-wrap: anywhere; }
.poll-option { position: relative; justify-content: flex-start; gap: 8px; min-height: 38px; padding: 6px 10px; overflow: hidden; text-align: left; isolation: isolate; }
.poll-option::before { content: ""; position: absolute; inset: 0 auto 0 0; z-index: -1; width: var(--share, 0%); background: color-mix(in srgb, var(--accent) 16%, transparent); transition: width 200ms ease; }
.poll-option.chosen { border-color: var(--accent); }
.poll-option.chosen::before { background: color-mix(in srgb, var(--accent) 28%, transparent); }
.poll-option:disabled { opacity: 1; cursor: default; }
.poll-mark { display: grid; flex: none; place-items: center; width: 18px; height: 18px; border: 2px solid var(--border); border-radius: 50%; color: var(--on-accent); }
.poll-mark.square { border-radius: 5px; }
.poll-option.chosen .poll-mark { border-color: var(--accent); background: var(--accent); }
.poll-text { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.poll-count { flex: none; font-size: 0.75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.poll-foot { display: flex; align-items: center; gap: 8px; }
.poll.closed .poll-question::after { content: " 🔒"; }
.poll-options { display: grid; gap: 6px; }
.poll-option-field { display: flex; align-items: center; gap: 4px; }
.poll-option-field input { flex: 1 1 auto; }
.poll-options-box > .small { justify-self: start; }

/* ----- reminders */
.reminder-about { padding: 8px 10px; border-left: 3px solid var(--accent); border-radius: 6px; background: var(--hover); color: var(--text); overflow-wrap: anywhere; }
.reminder-quick { display: flex; flex-wrap: wrap; gap: 6px; }
.reminders-list { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; max-height: 50vh; overflow-y: auto; }
.reminder-row { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); }
.reminder-row > svg { flex: none; color: var(--accent); }
.reminder-row-text { display: grid; flex: 1 1 auto; min-width: 0; font-size: 0.875rem; overflow-wrap: anywhere; }

/* ----- watching together */
.watch-panel { display: grid; flex: none; gap: 10px; max-height: 70vh; margin: 8px 16px 0; padding: 12px; overflow-y: auto; border: 1px solid var(--border); border-radius: 14px; background: var(--panel); }
.watch-head { display: flex; align-items: center; gap: 8px; }
.watch-head > svg { color: var(--accent); }
.watch-empty { margin: 0; }
.watch-stage { display: grid; gap: 8px; }
.watch-video { position: relative; width: 100%; max-height: 46vh; aspect-ratio: 16 / 9; overflow: hidden; border-radius: 10px; background: #000; }
.watch-video iframe, #watch-frame, #watch-frame > div { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.watch-info { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; min-width: 0; }
.watch-info strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.watch-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.watch-controls input[type="range"] { flex: 1 1 160px; width: auto; min-width: 120px; }
.watch-controls input.watch-volume { flex: 0 0 90px; width: 90px; min-width: 0; }
.watch-time { min-width: 86px; font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.watch-form { display: flex; flex-wrap: wrap; gap: 6px; }
.watch-form input { flex: 1 1 220px; }
.watch-panel h3 { margin: 4px 0 0; }
.watch-queue { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.watch-queue-row { display: flex; align-items: center; gap: 10px; padding: 4px; border: 1px solid var(--border); border-radius: 10px; }
.watch-thumb { flex: none; width: 80px; height: 45px; border-radius: 6px; object-fit: cover; background: var(--hover); }
.watch-queue-text { display: grid; flex: 1 1 auto; min-width: 0; font-size: 0.85rem; }
.watch-queue-text span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.watch-banner { margin: 8px 16px 0; }

/* ----- voice messages */
.voice-record-bar { display: flex; align-items: center; gap: 10px; margin: 0 16px 6px; padding: 6px 10px; border: 1px solid var(--error); border-radius: 12px; background: color-mix(in srgb, var(--error) 8%, var(--panel)); }
.voice-record-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--error); animation: voice-pulse 1s ease-in-out infinite; }
@keyframes voice-pulse { 50% { opacity: 0.3; } }
.voice-record-time { min-width: 40px; font-variant-numeric: tabular-nums; font-weight: 600; }
.voice-record-level { --level: 0; height: 6px; border-radius: 3px; background: linear-gradient(to right, var(--error) calc(var(--level) * 100%), var(--hover) 0); }
.composer.recording #composer-voice { color: var(--error); }
.voice-note { display: flex; align-items: center; gap: 10px; width: min(340px, 100%); margin-top: 4px; padding: 8px 12px 8px 8px; border: 1px solid var(--border); border-radius: 999px; background: var(--panel); }
.voice-note-play { display: grid; flex: none; place-items: center; width: 36px; height: 36px; min-height: 36px; padding: 0; border: none; border-radius: 50%; background: var(--accent); color: var(--on-accent); }
.voice-note-play:hover:not(:disabled) { background: var(--accent); filter: brightness(1.1); }
.voice-note-wave { display: flex; flex: 1 1 auto; align-items: center; gap: 2px; height: 30px; cursor: pointer; }
.voice-note-bar { --peak: 0.15; flex: 1 1 0; min-width: 2px; height: calc(var(--peak) * 100%); border-radius: 2px; background: color-mix(in srgb, var(--muted) 55%, transparent); transition: height 200ms ease; }
.voice-note:not(.loaded) .voice-note-bar { animation: voice-pulse 1.2s ease-in-out infinite; }
.voice-note-bar.played { background: var(--accent); }
.voice-note-time { flex: none; min-width: 34px; font-size: 0.78rem; color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }
@media (max-width: 759px) {
  .watch-panel { margin: 6px 8px 0; padding: 8px; }
  .watch-volume, .watch-controls > span[data-icon] { display: none; }
}

/* Bigger and easier to read: the list of commands, people and emoji while typing. */
.mention-list { max-height: min(60vh, 520px); padding: 6px; border-radius: 12px; }
.mention-choice { gap: 12px; min-height: 44px; padding: 8px 12px; border-radius: 8px; font-size: 1rem; }
.suggestion-name { flex: none; font-size: 1.02rem; }
.suggestion-text { font-size: 0.9rem; }
.suggestion-group { padding: 10px 12px 4px; font-size: 0.78rem; }
.command-row { font-size: 0.95rem; }
.command-group { font-size: 0.78rem; }
/* The list keeps its own height; the messages above give way, not the list. */
.mention-list { flex: none; max-height: min(65vh, 560px); }

/* The player takes what the window can spare and the chat keeps its box for writing: the
   video shrinks instead of pushing the bottom of the app off the screen. */
.watch-panel { display: flex; flex-direction: column; flex: none; min-height: 0; max-height: none; overflow: hidden; }
.watch-panel.has-video { flex: 0 1 62%; }
.watch-panel > * { flex: none; }
.watch-panel .watch-stage { display: flex; flex: 1 1 auto; flex-direction: column; min-height: 0; }
.watch-panel .watch-stage > * { flex: none; }
.watch-panel .watch-video { flex: 1 1 auto; width: 100%; height: auto; min-height: 90px; max-height: none; aspect-ratio: auto; }
.watch-queue { max-height: 96px; overflow-y: auto; }
body.watching .chat { min-height: 150px; }
body.watching .stage { max-height: 22%; }
/* Short on room, the "no messages yet" note gives way to the box for writing. */
.chat > .empty { flex: 1 1 auto; min-height: 0; overflow: hidden; }

/* ----- the frame stays the size of the window
   Nothing inside the app may make it longer than the window: each part that can grow scrolls
   or shrinks inside its own place, and popups float above the rest instead of taking room. */
.app { height: 100%; height: 100dvh; overflow: hidden; grid-template-rows: minmax(0, 1fr); }
.app > * { min-height: 0; }
.sidebar { overflow: hidden; }
.content { overflow: hidden; }
.content > * { min-height: 0; }
.content > .content-head, .content > .banner { flex: none; }
.content > .stage { flex: 0 1 auto; }
.chat { flex: 1 1 auto; min-height: 150px; }
.chat > .messages { min-height: 0; }
.mention-list { position: absolute; left: 16px; right: 16px; z-index: 30; margin: 0; flex: none; }

/* ----- link previews */
.link-preview { display: flex; align-items: stretch; gap: 12px; max-width: 520px; margin-top: 6px; padding: 10px 12px; border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: 10px; background: var(--panel); color: var(--text); text-decoration: none; }
.link-preview:hover { background: color-mix(in srgb, var(--accent) 6%, var(--panel)); }
.link-preview-text { display: grid; flex: 1 1 auto; align-content: start; gap: 3px; min-width: 0; }
.link-preview-site { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.link-preview-title { color: var(--accent); overflow-wrap: anywhere; }
.link-preview-description { display: -webkit-box; overflow: hidden; font-size: 0.85rem; color: var(--muted); -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.link-preview-image { flex: none; width: 112px; height: 84px; border-radius: 8px; object-fit: cover; background: var(--hover); }
@media (max-width: 759px) {
  .link-preview.with-image { flex-direction: column-reverse; }
  .link-preview-image { width: 100%; height: auto; max-height: 180px; }
}

/* ----- gomoku */
.game { display: grid; gap: 8px; width: fit-content; max-width: 100%; margin-top: 4px; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--panel); }
.game-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.game-head > svg { color: var(--accent); }
.game-players { display: flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }
.game-player { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border: 1px solid var(--border); border-radius: 999px; font-size: 0.85rem; }
.game-player.turn { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); font-weight: 600; }
.game-player.winner { border-color: var(--speaking); background: color-mix(in srgb, var(--speaking) 16%, transparent); font-weight: 700; }
.game-board { --cell: min(30px, calc((100vw - 120px) / var(--size))); display: grid; grid-template-columns: repeat(var(--size), var(--cell)); gap: 2px; padding: 4px; border-radius: 8px; background: var(--border); }
.game-cell { display: grid; place-items: center; width: var(--cell); height: var(--cell); min-height: 0; padding: 0; border: none; border-radius: 4px; background: var(--bg); font-size: calc(var(--cell) * 0.62); line-height: 1; }
.game-cell:disabled { opacity: 1; cursor: default; }
.game-cell:not(:disabled):hover { background: color-mix(in srgb, var(--accent) 18%, var(--bg)); }
.game-cell.last { box-shadow: inset 0 0 0 2px var(--accent); }
.game-cell.line { background: color-mix(in srgb, var(--speaking) 30%, var(--bg)); }
.game-mark { font-weight: 800; }
.game-mark.x { color: #e11d48; }
.game-mark.o { color: #2563eb; }
.game-foot { display: flex; align-items: center; gap: 8px; }
.game-status { font-size: 0.875rem; color: var(--muted); }
.game-status.mine { color: var(--accent); font-weight: 700; }

/* ----- saved messages */
.saved-dialog .saved-list { display: grid; gap: 6px; margin: 0; padding: 8px 12px 12px; overflow-y: auto; list-style: none; }
.saved-row { display: flex; align-items: flex-start; gap: 6px; }
.saved-open { display: grid; flex: 1 1 auto; justify-content: stretch; gap: 4px; min-width: 0; padding: 8px 10px; text-align: left; }
.saved-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 0.85rem; }
.saved-text { overflow-wrap: anywhere; white-space: pre-wrap; font-size: 0.9rem; }
.saved-empty { margin: 0; padding: 16px; }
/* The chat takes what is left once the player and the call have their share, never the other
   way round: sized by its messages, it would squeeze them to nothing. */
.chat { flex: 1 1 0; }
.watch-panel.has-video { min-height: min(280px, 40%); }
.content > .stage { min-height: min(90px, 14%); }

/* ----- the handle between the player and the chat */
.watch-resizer { display: flex; flex: none; align-items: center; justify-content: center; height: 12px; margin: 0 16px; cursor: row-resize; touch-action: none; }
.watch-resizer::before { content: ""; width: 56px; height: 4px; border-radius: 2px; background: var(--border); transition: background 120ms ease, width 120ms ease; }
.watch-resizer:hover::before, .watch-resizer.dragging::before, .watch-resizer:focus-visible::before { width: 96px; background: var(--accent); }
.watch-resizer:focus-visible { outline: none; }
.watch-panel.has-video.sized { flex: 0 0 var(--watch-size); min-height: 0; }
body.resizing-watch { cursor: row-resize; user-select: none; }
/* The video's frame would swallow the pointer while dragging over it. */
body.resizing-watch iframe { pointer-events: none; }

/* ----- checklists */
.checklist { display: grid; gap: 6px; max-width: 460px; margin-top: 2px; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--panel); }
.checklist-head { display: flex; align-items: flex-start; gap: 8px; }
.checklist-head svg { flex: none; margin-top: 2px; color: var(--accent); }
.checklist-title { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.checklist-count { flex: none; font-size: 0.75rem; font-variant-numeric: tabular-nums; }
.checklist-progress { height: 4px; border-radius: 2px; background: var(--hover); overflow: hidden; }
.checklist-progress::before { content: ""; display: block; width: var(--done, 0%); height: 100%; background: var(--speaking); transition: width 200ms ease; }
.checklist-items { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }
.checklist-item { display: flex; align-items: center; gap: 2px; border-radius: 8px; }
.checklist-item:hover { background: var(--hover); }
.checklist-item > .icon-button { flex: none; width: 28px; height: 28px; min-height: 28px; opacity: 0; }
.checklist-item:hover > .icon-button, .checklist-item > .icon-button:focus-visible { opacity: 1; }
.checklist-toggle { flex: 1 1 auto; justify-content: flex-start; gap: 10px; min-width: 0; min-height: 34px; padding: 4px 8px; border: 0; background: none; text-align: left; }
.checklist-toggle:hover:not(:disabled) { background: none; }
.checklist-box { display: grid; flex: none; place-items: center; width: 18px; height: 18px; border: 2px solid var(--border); border-radius: 5px; color: #fff; }
.checklist-item.done .checklist-box { border-color: var(--speaking); background: var(--speaking); }
.checklist-text { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.checklist-item.done .checklist-text { color: var(--muted); text-decoration: line-through; }
.checklist-who { flex: none; max-width: 40%; overflow: hidden; font-size: 0.75rem; text-overflow: ellipsis; white-space: nowrap; }
.checklist-add { display: flex; align-items: center; gap: 4px; }
.checklist-add input { flex: 1 1 auto; min-width: 0; min-height: 34px; padding: 4px 10px; }
.checklist-add .icon-button { flex: none; }
@media (hover: none) { .checklist-item > .icon-button { opacity: 1; } }

/* ----- scheduled messages */
.scheduled-note { flex: none; justify-content: flex-start; gap: 6px; min-height: 28px; margin: 0 16px 4px; padding: 2px 10px; border: 0; border-radius: 8px; background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--text); font-size: 0.8rem; text-align: left; }
.scheduled-note svg { flex: none; color: var(--accent); }
.scheduled-row { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); }
.scheduled-row > svg { flex: none; color: var(--accent); }
.scheduled-row-text { display: grid; flex: 1 1 auto; justify-content: stretch; gap: 1px; min-width: 0; min-height: 0; padding: 2px 4px; border: 0; background: none; font-size: 0.875rem; text-align: left; }
.scheduled-row-text > span { overflow-wrap: anywhere; }
.scheduled-row-body { display: -webkit-box; overflow: hidden; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.scheduled-list { min-height: 0; }

/* ----- board */
.board-button.live { position: relative; color: var(--accent); }
.board-button.live::after { content: ""; position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.board-dialog { display: none; width: min(1280px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 12px; }
.board-dialog[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: 10px; }
.board-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.board-head h2 { min-width: 120px; margin: 0; font-size: 1.05rem; overflow-wrap: anywhere; }
.board-colors, .board-widths { display: flex; align-items: center; gap: 4px; padding: 3px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); }
.board-swatch, .board-width { width: 28px; height: 28px; min-height: 28px; padding: 0; border: 2px solid transparent; border-radius: 50%; background: none; }
.board-swatch::before { content: ""; width: 18px; height: 18px; border: 1px solid rgb(0 0 0 / 25%); border-radius: 50%; background: var(--swatch); }
.board-width > span { width: var(--dot); height: var(--dot); border-radius: 50%; background: var(--text); }
.board-swatch[aria-pressed="true"], .board-width[aria-pressed="true"] { border-color: var(--accent); }
#board-eraser[aria-pressed="true"] { background: color-mix(in srgb, var(--accent) 20%, transparent); color: var(--accent); }
.board-stage { position: relative; justify-self: center; width: min(100%, calc((100dvh - 150px) * 16 / 9)); aspect-ratio: 16 / 9; overflow: hidden; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.board-canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.board-empty { position: absolute; inset: 50% 16px auto; margin: 0; transform: translateY(-50%); color: #6b6b76; text-align: center; pointer-events: none; }
.board-who { position: absolute; padding: 1px 6px; transform: translate(8px, 8px); border-radius: 6px; background: rgb(28 28 34 / 80%); color: #fff; font-size: 0.75rem; white-space: nowrap; pointer-events: none; }
.board-note { margin: 0; font-size: 0.75rem; text-align: center; }
@media (max-width: 720px) {
  .board-dialog { width: calc(100vw - 8px); max-height: calc(100dvh - 8px); padding: 8px; }
  .board-head h2 { flex-basis: 100%; }
  .board-stage { width: 100%; }
}
