:root {
  --font-scale: 1;
  --brand-row-height: 2.625rem;
  /* Leave room for 12 full-width glyphs, row controls, and the scrollbar. */
  --sidebar-min-width: 18rem;
  --content-gutter: clamp(0.65rem, calc(1.8vw * var(--font-scale)), 1.25rem);
  font-size: calc(100% * var(--font-scale));
  overflow: hidden;
  overscroll-behavior: none;
  color-scheme: light;
  --rail: #16363a;
  --rail-text: #f2faf8;
  --rail-muted: #b9d1ce;
  --rail-border: #446467;
  --rail-selected: #30575b;
  --rail-accent: #a6ece0;
  --rail-on-accent: #123533;
  --surface: #fff;
  --surface-subtle: #f4f7f7;
  --text: #1d2c31;
  --muted: #51646c;
  --border: #d4dfe0;
  --input-border: #7b9296;
  --accent: #10675e;
  --on-accent: #fff;
  --badge: #ddf1ed;
}
:root[data-font-size="large"] { --font-scale: 1.125; }
:root[data-font-size="small"] { --font-scale: 0.875; }
:root[data-font-size="extra-small"] { --font-scale: 0.75; }
:root[data-theme="dark"] {
  color-scheme: dark;
  --rail: #102629;
  --rail-border: #3d595d;
  --rail-selected: #274d51;
  --surface: #172327;
  --surface-subtle: #1d2e33;
  --text: #edf5f5;
  --muted: #aabfc3;
  --border: #34484d;
  --input-border: #7b9499;
  --accent: #9be3d4;
  --on-accent: #102c2b;
  --badge: #264440;
}
:root[data-theme="contrast"] {
  color-scheme: dark;
  --rail: #000;
  --rail-text: #fff;
  --rail-muted: #fff;
  --rail-border: #fff;
  --rail-selected: #222;
  --rail-accent: #ffe84a;
  --rail-on-accent: #000;
  --surface: #000;
  --surface-subtle: #151515;
  --text: #fff;
  --muted: #fff;
  --border: #fff;
  --input-border: #fff;
  --accent: #ffe84a;
  --on-accent: #000;
  --badge: #222;
}

:root[data-accent-color="blue"] { --accent-hue: 207; --accent-saturation: 76%; }
:root[data-accent-color="indigo"] { --accent-hue: 234; --accent-saturation: 63%; }
:root[data-accent-color="violet"] { --accent-hue: 277; --accent-saturation: 62%; }
:root[data-accent-color="rose"] { --accent-hue: 325; --accent-saturation: 62%; }
:root[data-accent-color="red"] { --accent-hue: 351; --accent-saturation: 68%; }
:root[data-accent-color="orange"] { --accent-hue: 23; --accent-saturation: 78%; }
:root[data-accent-color="gold"] { --accent-hue: 43; --accent-saturation: 76%; }
:root[data-accent-color="green"] { --accent-hue: 131; --accent-saturation: 55%; }
:root[data-accent-color="slate"] { --accent-hue: 218; --accent-saturation: 22%; }

:root[data-accent-color]:not([data-accent-color="teal"]) {
  --rail-accent: hsl(var(--accent-hue) var(--accent-saturation) 83%);
  --accent: hsl(var(--accent-hue) var(--accent-saturation) 28%);
}
:root[data-accent-color]:not([data-accent-color="teal"], [data-theme="contrast"]) {
  --rail: hsl(var(--accent-hue) var(--accent-saturation) 17%);
  --rail-muted: hsl(var(--accent-hue) var(--accent-saturation) 82%);
  --rail-border: hsl(var(--accent-hue) var(--accent-saturation) 36%);
  --rail-selected: hsl(var(--accent-hue) var(--accent-saturation) 27%);
  --rail-on-accent: hsl(var(--accent-hue) var(--accent-saturation) 14%);
  --badge: hsl(var(--accent-hue) var(--accent-saturation) 93%);
}
:root[data-theme="dark"][data-accent-color]:not([data-accent-color="teal"]) {
  --rail: hsl(var(--accent-hue) var(--accent-saturation) 12%);
  --rail-selected: hsl(var(--accent-hue) var(--accent-saturation) 22%);
  --accent: var(--rail-accent);
  --on-accent: var(--rail-on-accent);
  --badge: hsl(var(--accent-hue) var(--accent-saturation) 23%);
}
:root[data-theme="contrast"][data-accent-color]:not([data-accent-color="teal"]) {
  --accent: var(--rail-accent);
}

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

body {
  display: grid;
  grid-template-columns: clamp(var(--sidebar-min-width), 22vw, 19.5rem) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) auto;
  height: 100vh;
  height: 100dvh;
  margin: 0;
  overflow: clip;
  background: var(--surface);
  color: var(--text);
  font: 0.9375rem/1.45 system-ui, sans-serif;
}
button, input, select, textarea { font: inherit; }
button, summary, select { cursor: pointer; }
button:disabled { opacity: 0.6; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
h1, h2, p { margin: 0; }

body:has(> #system-notice:not([hidden])) { grid-template-rows: auto minmax(0, 1fr) auto; }
#workspace-footer {
  grid-column: 1 / -1;
  padding: 0.05rem var(--content-gutter);
  background: #383838;
  color: #bcbcbc;
  font-size: 0.625rem;
  line-height: 1.2;
  text-align: center;
}
#system-notice {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.65rem;
  height: min(2.25rem, var(--brand-row-height));
  padding-inline: var(--content-gutter) 0.4rem;
  background: #205983;
  color: #fff;
}
#system-notice[data-level="urgent"] { background: #a4262c; }
#system-notice[data-level="important"] { background: #ffca65; color: #312100; }
#system-notice-viewport { overflow: hidden; width: 100%; white-space: nowrap; }
#system-notice-text { display: inline-block; }
#system-notice a { color: inherit; text-decoration: underline; }
#system-notice :focus-visible { outline-color: currentColor; outline-offset: -2px; }
#system-notice[data-overflow] #system-notice-text {
  animation: system-notice-scroll var(--notice-duration) linear var(--notice-delay) infinite;
}
#system-notice:is(:hover, :focus-within) #system-notice-text { animation-play-state: paused; }
@keyframes system-notice-scroll {
  from { transform: translateX(var(--notice-start)); }
  to { transform: translateX(-100%); }
}
#dismiss-system-notice {
  display: grid;
  place-items: center;
  width: 1.8rem;
  height: 1.8rem;
  padding: 0;
  border: 0;
  border-radius: 0.25rem;
  color: inherit;
  background: transparent;
}
#dismiss-system-notice:hover { background: rgb(0 0 0 / 16%); }
@media (prefers-reduced-motion: reduce) {
  #system-notice[data-overflow] #system-notice-text { animation: none; }
  #system-notice-viewport { overflow-x: auto; scrollbar-width: none; }
}

.sidebar {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-height: 0;
  background: var(--rail);
  color: var(--rail-text);
  overflow: auto;
}
.sidebar :focus-visible { outline-color: var(--rail-accent); }
.brand {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  height: var(--brand-row-height);
  padding: 0.35rem 0.75rem;
  border-bottom: 1px solid var(--rail-border);
}
.brand h1 { font-size: 1rem; }
.brand-version { color: var(--rail-muted); font-size: 0.75rem; white-space: nowrap; }
#organization-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.75rem;
  border-bottom: 1px solid var(--rail);
  font-weight: 650;
  overflow-wrap: anywhere;
}
#organization-brand-logo { width: 1.75rem; height: 1.75rem; flex: none; object-fit: contain; }
#open-system-settings {
  display: grid;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  margin-inline-start: auto;
  padding: 0;
  border: 0;
  border-radius: 0.3rem;
  background: transparent;
  color: var(--rail-text);
}
#open-system-settings:hover { background: var(--rail-selected); }
.settings-sliders { display: grid; width: 1.125rem; gap: 0.25rem; }
.settings-sliders > span { position: relative; border-top: max(1px, 0.08rem) solid; }
.settings-sliders > span::after {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  height: 0.3rem;
  border-left: max(2px, 0.125rem) solid;
  border-radius: 1px;
  transform: translate(-50%, -60%);
}
.settings-sliders > span:first-child::after { left: 28%; }
.settings-sliders > span:nth-child(2)::after { left: 72%; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 1.375rem;
  height: 1.375rem;
  border-radius: 0.45rem 0.45rem 0.45rem 0.15rem;
  background: var(--rail-accent);
  color: var(--rail-on-accent);
  font-size: 0.8rem;
  font-weight: 750;
}
#system-settings {
  --settings-border: #c7c7c7;
  --surface: #fff;
  --surface-subtle: #ededed;
  --text: #262626;
  --input-border: #777;
  --accent: #4e4e4e;
  --on-accent: #fff;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: #f5f5f5;
  color: #262626;
  color-scheme: light;
}
main:has(#system-settings:not([hidden])) > :is(#workspace, #schedule-calendar, #status),
main:has(> #schedule-calendar:not([hidden])) > #workspace,
.sidebar:has(#system-settings-navigation:not([hidden])) > :is(.conversation-nav, .sidebar-settings) {
  display: none;
}
.sidebar:has(#system-settings-navigation:not([hidden])) {
  --rail: #eaeaea;
  --rail-text: #262626;
  --rail-muted: #555;
  --rail-border: #c7c7c7;
  --rail-accent: #505050;
  --rail-on-accent: #fff;
  --rail-selected: #d7d7d7;
  border-inline-end: 1px solid var(--rail-border);
  color-scheme: light;
}
#open-system-settings[aria-expanded="true"] { background: var(--rail-selected); }
.system-settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: var(--brand-row-height);
  padding: 0.3rem var(--content-gutter);
  border-bottom: 1px solid var(--settings-border);
  background: #e4e4e4;
}
.system-settings-header h2 { font-size: 1rem; }
.system-settings-header button {
  flex: none;
  padding: 0.25rem 0.5rem;
  border: 1px solid #a8a8a8;
  border-radius: 0.25rem;
  background: transparent;
  color: inherit;
}
#system-settings-navigation { padding: 0.4rem; overflow: auto; }
#system-settings-navigation summary {
  padding: 0.45rem;
  border-radius: 0.25rem;
  font-weight: 650;
}
#system-settings-navigation summary:focus-visible { outline-offset: -2px; }
.system-settings-header button:hover { background: #d7d7d7; }
#system-settings-navigation summary:hover,
#system-settings-navigation details[open] > summary { background: var(--rail-selected); }
.system-settings-submenu { display: grid; margin: 0.2rem 0 0.3rem 0.9rem; }
.system-settings-submenu button {
  border: 0;
  border-radius: 0.25rem;
  padding: 0.4rem 0.55rem;
  background: transparent;
  color: var(--rail-text);
  text-align: start;
}
.system-settings-submenu button:is(:hover, [aria-current]) { background: var(--rail-selected); }
#system-channel-list button { overflow-wrap: anywhere; }
.channel-feature-controls { margin: 0; padding: 0; border: 0; min-width: 0; }
#channel-feature-feedback { margin-top: 0.5rem; }
#channel-feature-feedback:empty { display: none; }
.system-settings-values { overflow: auto; padding: clamp(0.75rem, 3vw, 1.5rem); }
.system-settings-panel h3 { margin: 0; font-size: 1rem; }
.system-settings-panel dl { margin: 0.75rem 0 0; }
.system-settings-panel dt { color: #555; }
.system-settings-panel dd { margin: 0.15rem 0 0.8rem; overflow-wrap: anywhere; }
#edit-organization fieldset {
  display: grid;
  gap: 0.65rem;
  min-width: 0;
  max-width: 26rem;
  margin: 0.65rem 0 0;
  padding: 0;
  border: 0;
}
#edit-organization fieldset > label { display: grid; gap: 0.25rem; }
#edit-organization input:not([type="checkbox"]), #edit-organization button {
  min-width: 0;
  border: 1px solid #a8a8a8;
  border-radius: 0.25rem;
  padding: 0.3rem 0.5rem;
  background: #fff;
  color: inherit;
}
#edit-organization button { justify-self: start; }
#edit-organization .feature-settings { margin: 0; }
#organization-feedback { margin-top: 0.5rem; }
#organization-feedback:empty { display: none; }
#organization-saved-logo { width: 4rem; height: 4rem; object-fit: contain; }
#system-account-list { max-width: 38rem; margin: 0.6rem 0 0; padding: 0; list-style: none; }
#system-account-list li {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.2rem 1rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--settings-border);
  overflow-wrap: anywhere;
}
#system-accounts-status { color: #555; }
.account-role-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-inline-size: 7rem;
}
.account-role-switch input {
  appearance: none;
  display: flex;
  align-items: center;
  inline-size: 2.15rem;
  block-size: 1.2rem;
  margin: 0;
  padding: 0.1rem;
  border: 1px solid transparent;
  border-radius: 1rem;
  background-color: #656565;
  cursor: pointer;
}
.account-role-switch input::before {
  content: "";
  inline-size: 0.85rem;
  block-size: 0.85rem;
  border-radius: 50%;
  background-color: white;
}
.account-role-switch input:checked { justify-content: flex-end; background-color: #245bc1; }
.account-role-switch input:focus-visible { outline: 2px solid #245bc1; outline-offset: 2px; }
.account-role-switch input:disabled { opacity: 0.6; cursor: wait; }
.account-role-switch input:checked ~ .account-role-member,
.account-role-switch input:not(:checked) ~ .account-role-admin { display: none; }
@media (forced-colors: active) {
  .account-role-switch input { appearance: auto; display: inline-block; }
  .account-role-switch input::before { content: none; }
}
#edit-channel-address { display: flex; flex-wrap: wrap; align-items: end; gap: 0.5rem; margin-top: 0.75rem; max-width: 26rem; }
#edit-channel-address label { display: grid; gap: 0.25rem; flex: 1 1 12rem; }
#edit-channel-address input { width: 100%; }
#system-accounts-status:empty { display: none; }
#publish-system-notice { display: grid; gap: 0.6rem; max-width: 36rem; margin: 0.75rem 0; }
#publish-system-notice label { display: grid; gap: 0.2rem; }
#system-notice-target-fields { display: grid; gap: 0.4rem; border: 0; padding: 0; margin: 0; min-width: 0; }
#publish-system-notice :is(input, select, textarea, button), #system-notice-list button {
  min-width: 0;
  border: 1px solid #a8a8a8;
  border-radius: 0.25rem;
  padding: 0.3rem 0.55rem;
  background: #fff;
  color: inherit;
}
#publish-system-notice textarea { resize: vertical; }
#publish-system-notice > button { justify-self: start; }
#system-notice-list { max-width: 36rem; margin: 0.5rem 0 0; padding: 0; list-style: none; }
#system-notice-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.25rem 0.75rem;
  padding: 0.5rem 0;
  border-top: 1px solid var(--settings-border);
  overflow-wrap: anywhere;
}
#system-notice-list p { grid-column: 1 / -1; white-space: pre-wrap; }
#more-system-accounts {
  margin-top: 0.65rem;
  border: 1px solid #a8a8a8;
  border-radius: 0.25rem;
  padding: 0.25rem 0.5rem;
  background: transparent;
  color: inherit;
}
.feature-settings { max-width: 26rem; margin: 0.75rem 0 0; padding: 0; list-style: none; }
.feature-settings li { border-bottom: 1px solid var(--settings-border); }
.feature-settings label {
  display: grid;
  grid-template-columns: 1fr auto minmax(3ch, auto);
  align-items: center;
  gap: 0.55rem;
  padding: 0.65rem 0;
}
.feature-settings label:has(input:enabled) { cursor: pointer; }
.feature-settings input {
  appearance: none;
  display: grid;
  align-items: center;
  width: 2.25rem;
  height: 1.3rem;
  margin: 0;
  padding: 0.12rem;
  border: 1px solid #777;
  border-radius: 1rem;
  background: #ddd;
}
.feature-settings input:checked { justify-items: end; background: #505050; }
.feature-settings input::before {
  content: "";
  width: 0.9rem;
  height: 0.9rem;
  border: 1px solid #777;
  border-radius: 50%;
  background: #fff;
}
.conversation-nav { padding: 0.55rem 0.45rem; overflow: auto; }
.direct-nav, #schedule-navigation { margin-top: 0.65rem; }
#schedule-label {
  margin: 0 0.25rem 0.25rem 0.3rem;
  color: var(--rail-muted);
  font-size: 0.8125rem;
  font-weight: 650;
}
.schedule-more {
  margin-inline-start: 0.3rem;
  padding: 0.2rem 0.15rem;
  border: 0;
  background: transparent;
  color: var(--rail-muted);
  font-size: 0.75rem;
  text-decoration: underline;
}
.schedule-more:hover { color: var(--rail-text); }
.conversation-group { position: relative; }
.conversation-group summary {
  min-height: 1.8rem;
  margin: 0 2.2rem 0.25rem 0.3rem;
  padding-block: 0.25rem;
  color: var(--rail-muted);
  font-size: 0.8125rem;
  font-weight: 650;
}
.conversation-group > .conversation-add { position: absolute; inset-block-start: 0; inset-inline-end: 0.25rem; }
.conversation-more {
  margin-inline-start: 0.3rem;
  padding: 0.2rem 0.15rem;
  border: 0;
  background: transparent;
  color: var(--rail-muted);
  font-size: 0.75rem;
  text-decoration: underline;
}
.conversation-nav ul { display: grid; gap: 0.125rem; margin: 0; padding: 0; list-style: none; }
.conversation-nav li { display: flex; align-items: center; gap: 0.2rem; }
.conversation-draggable .channel-select { cursor: grab; }
.conversation-draggable .channel-select:active { cursor: grabbing; }
.conversation-pin {
  flex: none;
  width: 1.2rem;
  height: 1.65rem;
  border: 0;
  border-radius: 0.25rem;
  padding: 0;
  background: transparent;
  color: var(--rail-text);
  font-size: 0.8rem;
  line-height: 1;
}
.conversation-pin[aria-pressed="false"] { opacity: 0.55; }
.conversation-pin:hover, .conversation-pin[aria-pressed="true"] { background: var(--rail); opacity: 1; }
.conversation-nav .channel-select {
  flex: 1;
  min-width: 0;
  border: 0;
  padding: 0.25rem 0.4rem;
  background: transparent;
  color: var(--rail-text);
  text-align: left;
  overflow-wrap: anywhere;
}
.conversation-nav .channel-select:has(.dm-avatar) { display: flex; align-items: center; gap: 0.4rem; }
.dm-avatar {
  display: grid;
  flex: none;
  place-items: center;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 0.3rem;
  background: var(--badge);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 750;
  overflow: hidden;
}
.dm-avatar img { width: 100%; height: 100%; object-fit: cover; }
.conversation-nav .channel-select[data-unread] { position: relative; padding-inline-end: 1.85em; }
.conversation-nav .channel-select[data-unread]::after {
  content: attr(data-unread);
  position: absolute;
  inset-inline-end: 0.3em;
  top: 0.25rem;
  color: var(--rail-accent);
  font-size: 0.8em;
  font-weight: 700;
  white-space: nowrap;
}
.conversation-nav li:is(:hover, :has(> [aria-current="true"])) {
  background: var(--rail-selected);
}
.conversation-add {
  border: 1px solid var(--rail-border);
  border-radius: 0.4rem;
  background: transparent;
  color: var(--rail-text);
}
.conversation-add:hover:enabled { background: var(--rail-selected); }
.conversation-nav .channel-menu-button { border: 0; color: var(--rail-text); }
.conversation-nav .channel-menu-button:hover { background: var(--rail); }
.conversation-nav .has-channel-wiki { flex-wrap: wrap; }
.conversation-nav .channel-wiki { flex-basis: 100%; min-width: 0; padding-inline: 0.9rem 0.3rem; }
.channel-wiki-header { position: relative; }
.channel-wiki-header summary { min-height: 1.8rem; padding: 0.25rem 2.15rem 0.25rem 0; }
.channel-wiki-header > .conversation-add { position: absolute; inset-block-start: 0; inset-inline-end: 0; }
.conversation-nav .channel-wiki ul { display: grid; overflow: visible; }
.channel-wiki-link {
  flex: 1;
  min-width: 0;
  padding: 0.25rem 0.4rem;
  border: 0;
  background: transparent;
  color: var(--rail-text);
  text-align: start;
  overflow-wrap: anywhere;
}
.channel-wiki-link:hover { background: var(--rail); }
.conversation-add {
  padding: 0;
  width: 1.8rem;
  height: 1.8rem;
  font-size: 1.15rem;
  line-height: 1;
}
.channel-menu-button {
  flex: none;
  width: 1.65rem;
  height: 1.65rem;
  padding: 0;
  border: 1px solid var(--input-border);
  border-radius: 0.4rem;
  background: transparent;
  color: var(--muted);
  font-size: 1.15rem;
  line-height: 1;
}
#chat .thread-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-content: center;
  gap: 0.15rem 0;
}
#chat .channel-icon { grid-column: 1; grid-row: 1; margin-inline-end: 0.45rem; }
.conversation-title-line, #conversation-address { grid-column: 2; }
.conversation-title-line { display: flex; align-items: center; gap: 0.45rem; }
#chat .thread-header h2 { max-width: 48%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#conversation-subtitle, #conversation-address {
  min-width: 0;
  color: var(--muted);
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#conversation-subtitle a { color: var(--accent); }
#show-favorite-messages {
  flex: none;
  margin-inline-start: auto;
  padding: 0.12rem 0.4rem;
  border: 1px solid var(--input-border);
  border-radius: 0.3rem;
  background: var(--surface);
  color: var(--text);
  font-size: 0.75rem;
}
#show-favorite-messages[aria-pressed="true"] { background: var(--badge); color: var(--accent); }
.channel-popover {
  position: fixed;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.65rem;
  width: 22rem;
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--input-border);
  border-radius: 0.75rem;
  padding: 0.8rem;
  background: var(--surface);
  color: var(--text);
  font-size: 0.8125rem;
  box-shadow: 0 0.65rem 2rem rgba(12, 32, 34, 0.24);
}
#create-channel, #create-direct-message, #current-user-profile { width: 17rem; }
#current-user-profile dl { margin: 0; }
#current-user-profile dt { color: var(--muted); }
#current-user-profile dd { margin: 0.1rem 0 0.5rem; overflow-wrap: anywhere; }
#current-user-profile button { justify-self: start; }
#edit-current-user label { display: grid; gap: 0.25rem; }
.file-drop {
  position: relative;
  display: grid;
  gap: 0.2rem;
  min-width: 0;
  padding: 0.55rem 0.4rem;
  border: 1px dashed var(--input-border);
  border-radius: 0.4rem;
  text-align: center;
  font-size: 0.75rem;
}
.file-drop > input[type="file"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.file-drop > input::file-selector-button { width: 100%; height: 100%; cursor: pointer; }
.file-drop:has(input:disabled) { opacity: 0.55; }
.file-drop:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.file-drop:not(:has(input:disabled)):hover, .file-dragging { background: var(--badge); border-color: var(--accent); }
.file-drop-filename { overflow-wrap: anywhere; font-weight: 650; }
.file-drop-filename:empty, .file-drop-feedback:empty { display: none; }
.file-drop-feedback { font-size: 0.75rem; }
textarea.file-dragging { outline: 2px dashed var(--accent); outline-offset: -2px; }
.edit-current-status fieldset { display: grid; gap: 0.3rem; margin: 0; padding: 0; border: 0; min-width: 0; }
.edit-current-status label { display: grid; gap: 0.2rem; }
.edit-current-status :is([data-status-label], [data-status-feedback]), .message-presence { color: var(--muted); font-size: 0.75rem; }
.edit-current-status [data-status-feedback]:empty { display: none; }
#appearance-current-status {
  border-top: 1px solid var(--rail-border);
  margin-top: 0.15rem;
  padding-top: 0.4rem;
  font-size: 0.8125rem;
}
#appearance-current-status :is([data-status-label], [data-status-feedback]) { color: var(--rail-muted); }
.account-presence { --presence-color: #888; }
.account-presence[data-presence="online"] { --presence-color: #2ba66b; }
.account-presence[data-presence="away"] { --presence-color: #d5962e; }
.account-presence[data-presence="vacation"] { --presence-color: #9070cf; }
.account-presence::before {
  content: "";
  display: inline-block;
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--presence-color);
  vertical-align: 0.08em;
}
.dm-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.dm-presence { flex: none; margin-inline-start: auto; color: var(--rail-muted); font-size: 0.625rem; }
:is(.dm-presence, .message-presence)::before { margin-inline-end: 0.25rem; }
.image-file-limit { color: var(--muted); font-size: 0.75rem; }
#system-settings .image-file-limit, #system-settings .image-preview figcaption { color: #555; }
.image-preview { display: flex; align-items: center; gap: 0.5rem; margin: 0.25rem 0; }
.image-preview img {
  width: 4rem;
  height: 4rem;
  border-radius: 0.5rem;
  object-fit: contain;
}
.image-preview figcaption { color: var(--muted); }
#avatar-preview img { object-fit: cover; }
#current-user-profile-status:empty { display: none; }
#direct-message-candidates { display: grid; gap: 0.2rem; margin: 0; padding: 0; list-style: none; }
#direct-message-candidates button { width: 100%; text-align: left; overflow-wrap: anywhere; }
#direct-message-status:empty { display: none; }
.channel-popover h2 { font-size: 1rem; }
.channel-popover h3 { margin: 0; font-size: 0.875rem; }
.channel-popover form { display: grid; gap: 0.35rem; }
.channel-popover input, .channel-popover button, .channel-popover select {
  min-width: 0;
  border: 1px solid var(--input-border);
  border-radius: 0.4rem;
  padding: 0.25rem 0.5rem;
  background: var(--surface);
  color: var(--text);
}
.channel-popover button { justify-self: end; }
.channel-members-editor { display: grid; gap: 0.45rem; border-top: 1px solid var(--border); padding-top: 0.7rem; }
.channel-members-editor ul { display: grid; gap: 0.25rem; margin: 0; padding: 0; list-style: none; }
.channel-members-editor li { display: flex; align-items: center; justify-content: space-between; gap: 0.45rem; }
.channel-members-editor li span { min-width: 0; overflow-wrap: anywhere; }
.channel-invitation-actions { display: flex; flex-wrap: wrap; gap: 0.35rem; }
#channel-invitation-result { display: grid; gap: 0.35rem; }
#channel-invitation-expiry { margin: 0; color: var(--muted); }
.channel-member-controls { flex: none; display: flex; align-items: center; gap: 0.25rem; }
.channel-member-controls select { max-width: 7rem; }
.channel-fixed-role { color: var(--muted); }
#delete-channel {
  justify-self: start;
  color: var(--text);
  border-color: var(--input-border);
}
#create-channel-status:empty, #manage-channel-status:empty { display: none; }
.sidebar-settings {
  display: grid;
  gap: 0.4rem;
  padding: 0.5rem 0.75rem;
  border-top: 1px solid var(--rail-border);
}
.sidebar-settings summary, .appearance-control { font-size: 0.8125rem; color: var(--rail-muted); }
.appearance-controls { display: grid; gap: 0.4rem; padding-top: 0.65rem; }
.appearance-control { display: flex; align-items: center; justify-content: space-between; gap: 0.65rem; }
#local-login-feedback { margin-top: 0.5rem; }
#local-login-feedback:empty { display: none; }
.sidebar input, .sidebar select {
  min-width: 0;
  border: 1px solid var(--rail-border);
  border-radius: 0.35rem;
  padding: 0.34rem 0.5rem;
  background: var(--rail);
  color: var(--rail-text);
}
.sidebar select { max-width: 100%; }
#passkey-settings summary { margin-bottom: 0.35rem; }
#passkey-registration-status:not(:empty) { margin-top: 0.25rem; }
.account-entry {
  width: min(100% - 2rem, 28rem);
  max-height: calc(100dvh - 2rem);
  margin: auto;
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: 0.65rem;
  background: var(--surface);
  color: var(--text);
}
.account-entry::backdrop { background: rgb(0 0 0 / 0.42); }
.login-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.account-entry h2 { font-size: 1.2rem; margin-bottom: 0.65rem; }
.account-entry form, #invitation-domains fieldset { display: grid; gap: 0.6rem; }
.account-entry label, #invitation-domains fieldset > label { display: grid; gap: 0.25rem; }
.account-entry :is(input, button), #invitation-domains :is(input:not([type="checkbox"]), button) {
  min-width: 0;
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--input-border);
  border-radius: 0.35rem;
  color: inherit;
  background: var(--surface);
}
.account-entry button, #invitation-domains button { justify-self: start; }
.account-entry button { margin-top: 0.3rem; }
.account-entry [role="status"]:not(:empty), #invitation-domains-status:not(:empty) { margin-top: 0.55rem; }
#restart-setup { margin-top: 0.4rem; }
.edition-label { font-size: 0.85rem; font-weight: 700; }
#system-license .edition-label { margin-top: 0.45rem; }
#system-license-expiration { margin-top: 0.2rem; font-size: 0.8rem; }
#account-dialog[data-edition="community"] { background: color-mix(in srgb, var(--surface) 68%, #83a6d4); }
#account-dialog[data-edition="professional"] { background: color-mix(in srgb, var(--surface) 68%, #58b59b); }
#login-edition { margin-bottom: 0.3rem; }
.network-form { margin-top: 0.75rem; max-width: 33rem; }
.network-form fieldset { display: grid; gap: 0.6rem; border: 0; padding: 0; margin: 0; min-width: 0; }
.network-form fieldset > label { display: grid; gap: 0.25rem; }
.network-form [role="status"]:not(:empty) { margin-top: 0.5rem; }
.network-form button { justify-self: start; }
#tls-registration-state { margin-bottom: 0.5rem; }
#invitation-domains .feature-settings { margin-top: 0; }
.network-form :is(input:not([type="checkbox"]), textarea, select, button) {
  min-width: 0;
  padding: 0.35rem 0.6rem;
  border: 1px solid #a8a8a8;
  border-radius: 0.35rem;
  background: #fff;
  color: inherit;
}

main {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 0;
}
#wiki-panel { display: grid; grid-template-rows: auto minmax(0, 1fr); min-width: 0; min-height: 0; }
.wiki-heading { flex: 1; min-width: 0; overflow-wrap: anywhere; }
#wiki-channel-name { color: var(--muted); font-size: 0.75rem; }
#close-wiki { flex: none; }
#wiki-actions { width: 8rem; gap: 0.2rem; padding: 0.25rem; }
#wiki-actions button { justify-self: stretch; text-align: start; }
.wiki-content { min-width: 0; overflow: auto; padding: var(--content-gutter); }
#wiki-status:empty { display: none; }
#create-wiki { display: grid; gap: 0.75rem; max-width: 46rem; }
#create-wiki label { display: grid; gap: 0.3rem; }
#create-wiki :is(input, textarea, button) {
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 0.3rem;
  background: var(--surface);
  color: var(--text);
}
#create-wiki textarea { resize: vertical; }
#create-wiki button { justify-self: start; }
#wiki-body { overflow-wrap: anywhere; }
#schedule-calendar {
  --schedule-saturday: #3549b0;
  --schedule-sunday: #b5232c;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
}
:root:is([data-theme="dark"], [data-theme="contrast"]) #schedule-calendar {
  --schedule-saturday: #a2acff;
  --schedule-sunday: #ff9b9b;
}
#schedule-month-title {
  display: flex;
  align-items: center;
  height: var(--brand-row-height);
  padding-inline: var(--content-gutter);
  border-bottom: 1px solid var(--border);
  font-size: 1.1rem;
}
.schedule-calendar-content { overflow: auto; padding: var(--content-gutter); }
.schedule-calendar-content table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.schedule-calendar-content :is(th, td) { border: 1px solid var(--border); padding: 0.4rem; }
.schedule-calendar-content th { background: var(--surface-subtle); font-weight: 650; }
.schedule-calendar-content td { height: clamp(2.5rem, 11vh, 5.5rem); vertical-align: top; }
.schedule-calendar-content td:first-child { --schedule-weekend: var(--schedule-sunday); }
.schedule-calendar-content td:last-child { --schedule-weekend: var(--schedule-saturday); }
.schedule-calendar-content time { color: var(--schedule-weekend, var(--text)); }
.schedule-calendar-content time[aria-current="date"] {
  display: inline-grid;
  place-items: center;
  min-width: 1.5rem;
  min-height: 1.5rem;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
}
.schedule-calendar-content td:is(:first-child, :last-child) time[aria-current="date"] {
  background: var(--surface-subtle);
  color: var(--schedule-weekend);
  box-shadow: inset 0 0 0 1px currentColor;
}
#empty-state { place-self: center; padding: 1rem; color: var(--muted); text-align: center; }
#chat, #thread { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; min-height: 0; }
#chat { grid-template-rows: auto auto minmax(0, 1fr) auto; }
.chat-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max(50%, 12ic) minmax(0, 1fr);
  align-items: center;
  height: var(--brand-row-height);
  border-bottom: 1px solid var(--border);
}
#message-search { position: relative; grid-column: 2; display: flex; min-width: 0; }
#message-query, #message-search button, #more-message-results {
  min-width: 0;
  border: 1px solid var(--input-border);
  border-radius: 0.4rem;
  padding: 0.3rem 0.55rem;
  background: var(--surface);
  color: var(--text);
}
#message-query { flex: 1; }
#message-query::placeholder { color: var(--muted); }
#message-search:has(#clear-message-search:not([hidden])) #message-query { padding-inline-end: 4.2rem; }
#clear-message-search {
  position: absolute;
  inset-inline-end: 0.25rem;
  top: 50%;
  transform: translateY(-50%);
}
#clear-message-search, #more-message-results { color: var(--accent); }
#message-search-results {
  min-height: 0;
  overflow: auto;
  padding: 0.45rem var(--content-gutter);
}
#message-search-status { color: var(--muted); }
#message-search-blocker {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  cursor: progress;
  background: rgb(0 0 0 / 15%);
}
#message-search-blocker p {
  padding: 0.55rem 0.85rem;
  border-radius: 0.45rem;
  background: var(--surface);
  color: var(--text);
}
#matched-messages { margin: 0; padding: 0; list-style: none; }
#matched-messages li { padding: 0.4rem 0; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }
.search-result-meta { color: var(--muted); font-size: 0.8rem; }
.search-result-open {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--accent);
  font-weight: 650;
  text-align: start;
  overflow-wrap: anywhere;
}
.search-result-open:hover { text-decoration: underline; }
.search-result-text { white-space: pre-wrap; }
#more-message-results { margin-top: 0.6rem; }
.thread-header {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 2.625rem;
  padding: 0.35rem var(--content-gutter);
  border-bottom: 1px solid var(--border);
}
.thread-header .channel-icon { color: var(--accent); font-size: 1.5rem; line-height: 1; }
.thread-header h2 { min-width: 0; font-size: 1.1rem; overflow-wrap: anywhere; }
#message-timeline { display: grid; grid-template-rows: auto minmax(0, 1fr); min-height: 0; }
#message-timeline.favorites-only { grid-template-rows: minmax(0, 1fr); }
#marked-messages { grid-row: 1; max-height: min(28dvh, 15rem); overflow: auto; }
#marked-messages:not([hidden]) { border-bottom: 1px solid var(--border); }
.favorites-only #marked-messages { max-height: none; border-bottom: 0; }
#marked-messages-title, #marked-messages-empty {
  margin: 0.35rem var(--content-gutter);
  color: var(--muted);
  font-size: 0.85rem;
}
#messages { grid-row: 2; }
:is(#messages, #marked-message-list) {
  margin: 0;
  padding: 0.4rem var(--content-gutter);
  overflow-y: auto;
  list-style: none;
}
#messages:focus-visible { outline-offset: -3px; }
.message-row[data-pinned] {
  --pinned-background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  background: var(--pinned-background);
}
.message-row[data-pinned]:hover { background: color-mix(in srgb, var(--accent) 16%, var(--surface)); }
.message-mark-icon { display: block; width: 0.9rem; height: 0.9rem; }
.day-marker {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.25rem 0 0.5rem;
  color: var(--muted);
  font-size: 0.75rem;
}
.day-marker::before, .day-marker::after {
  flex: 1;
  height: 1px;
  background: var(--border);
  content: "";
}
.message-row {
  display: grid;
  grid-template-columns: 1.875rem minmax(0, 1fr);
  align-items: start;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
}
.message-avatar, #current-user-avatar {
  display: grid;
  place-items: center;
  width: 1.875rem;
  height: 1.875rem;
  border-radius: 0.5rem;
  background: var(--badge);
  color: var(--accent);
  font-size: 0.875rem;
  font-weight: 750;
}
#current-user-avatar {
  position: relative;
  grid-column: 3;
  justify-self: end;
  margin-inline-end: var(--content-gutter);
  padding: 0;
  border: 0;
}
#current-user-avatar img, .message-avatar img {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: cover;
}
#current-user-avatar img {
  position: absolute;
  inset: 0;
}
:is(.dm-avatar, .message-avatar, #current-user-avatar):has(> img:not([hidden])) {
  background: transparent;
}
#current-user-avatar:has(> img:not([hidden])) > span { visibility: hidden; }
.message-meta { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 0.55rem; }
.message-meta time { color: var(--muted); font-size: 0.75rem; }
.message-edited { color: var(--muted); font-size: 0.75rem; }
.message-content { overflow-wrap: anywhere; }
.message-removed { color: var(--muted); }
.message-editor { display: grid; gap: 0.35rem; margin-top: 0.3rem; }
.message-editor textarea {
  width: 100%;
  min-height: 3.5rem;
  resize: vertical;
  border: 1px solid var(--input-border);
  border-radius: 0.45rem;
  padding: 0.5rem;
  background: var(--surface);
  color: var(--text);
}
.message-editor-actions { display: flex; justify-content: flex-end; gap: 0.35rem; }
.message-editor-actions button {
  border: 1px solid var(--input-border);
  border-radius: 0.4rem;
  padding: 0.2rem 0.5rem;
  background: var(--surface);
  color: var(--text);
}
.message-editor-actions .edit-save {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
}
.message-markdown > * { margin-block: 0.3rem; }
.message-markdown > :first-child { margin-block-start: 0; }
.message-markdown > :last-child { margin-block-end: 0; }
.message-markdown :is(h1, h2, h3, h4, h5, h6) { font-size: 1.05rem; }
.message-markdown :is(ul, ol) { padding-inline-start: 1.5rem; }
.message-markdown a { color: var(--accent); text-underline-offset: 0.12em; }
.message-markdown blockquote {
  margin-inline: 0;
  border-inline-start: 3px solid var(--border);
  padding-inline-start: 0.7rem;
  color: var(--muted);
}
.message-markdown code {
  border-radius: 0.25rem;
  padding: 0.1em 0.25em;
  background: var(--surface-subtle);
}
.message-markdown pre {
  overflow-x: auto;
  padding: 0.5rem 0.7rem;
  background: var(--surface-subtle);
  border-radius: 0.35rem;
}
.message-markdown pre code { padding: 0; }
.message-markdown table { border-collapse: collapse; }
.message-markdown :is(th, td) { border: 1px solid var(--border); padding: 0.2rem 0.4rem; }
.message-link-preview {
  max-inline-size: 32rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 0.4rem;
  background: var(--surface-subtle);
}
.message-link-preview button {
  padding: 0.15rem 0.25rem;
  border: 0;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
}
.message-link-domain {
  margin-inline-start: 0.4rem;
  color: var(--muted);
  overflow-wrap: anywhere;
}
.message-page-preview {
  display: grid;
  justify-items: start;
  gap: 0.3rem;
  margin-block-start: 0.35rem;
  overflow-wrap: anywhere;
}
.message-page-preview p { margin: 0; }
.message-page-preview img { max-inline-size: 100%; max-block-size: 10rem; object-fit: contain; }
.message-link-frame {
  display: block;
  inline-size: 100%;
  margin-block-start: 0.35rem;
  border: 0;
}
.message-link-frame-youtube { aspect-ratio: 16 / 9; min-block-size: 200px; }
.message-link-frame-x { block-size: min(30rem, 70vh); background: #fff; }
.message-attachments, .composer-attachments {
  margin: 0;
  padding: 0;
  list-style: none;
}
.message-attachments { display: grid; gap: 0.45rem; margin-top: 0.4rem; }
.message-attachments img {
  display: block;
  border-radius: 0.45rem;
  max-width: 100%;
  max-height: 22rem;
  margin-bottom: 0.25rem;
  object-fit: contain;
}
.composer-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  max-height: 6rem;
  overflow-y: auto;
  padding: 0.35rem 0.55rem;
}
.composer-attachments li { min-width: 0; max-width: 100%; }
.attachment-chip, .attachment-download {
  border: 1px solid var(--input-border);
  border-radius: 0.4rem;
  padding: 0.2rem 0.45rem;
  color: var(--accent);
  background: var(--surface);
  font-size: 0.8125rem;
  overflow-wrap: anywhere;
  max-width: 100%;
}

#send, #reply {
  margin: 0 var(--content-gutter) 0.5rem;
  overflow: auto;
  border: 1px solid var(--input-border);
  border-radius: 0.65rem;
  background: var(--surface-subtle);
}
#message, #reply-message {
  display: block;
  width: 100%;
  min-height: 3rem;
  max-height: 30dvh;
  resize: vertical;
  border: 0;
  padding: 0.4rem 0.55rem;
  background: var(--surface);
  color: var(--text);
}
:is(#message, #reply-message):focus-visible { outline: none; }
:is(#message, #reply-message)::placeholder { color: var(--muted); }
.composer-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.25rem 0.35rem;
  border-top: 1px solid var(--border);
}
.composer-actions button[type="submit"] {
  border: 0;
  border-radius: 0.4rem;
  padding: 0.34rem 0.75rem;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 650;
}
.composer-actions span { margin-inline-start: 0.25rem; }
.composer-toolbar, .composer-formatting, .composer-options, .composer-mentions, .message-mentions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  align-items: center;
}
.composer-options, .composer-mentions { padding: 0.45rem 0.55rem; }
.composer-options { max-height: 8rem; overflow: auto; }
.composer-command-menu {
  position: fixed;
  z-index: 8;
  display: grid;
  width: max-content;
  padding: 0.35rem;
  border: 1px solid var(--input-border);
  border-radius: 0.55rem;
  background: var(--surface);
  box-shadow: 0 6px 20px #0003;
}
.composer-command-menu .composer-option { text-align: start; }
.message-mentions { margin: 0.2rem 0; }
.composer-toolbar button, .composer-option, .mention-tag {
  border: 1px solid var(--input-border);
  border-radius: 0.4rem;
  padding: 0.2rem 0.45rem;
  background: var(--surface);
  color: var(--text);
  font-size: 0.8125rem;
}
.composer-toolbar button[aria-expanded="true"], .composer-option[aria-pressed="true"],
.mention-tag {
  background: var(--badge);
  color: var(--accent);
}
.composer-toolbar button {
  display: grid;
  place-items: center;
  width: 1.8rem;
  height: 1.8rem;
  padding: 0;
  font-size: 1rem;
  line-height: 1;
}
.compose-mention { font-weight: 700; }
.composer-formatting { margin-inline-end: 0.25rem; }
.composer-formatting .format-bold { font-weight: 750; }
.composer-formatting .format-italic { font-style: italic; }
.composer-formatting .format-underline { text-decoration: underline; }
.composer-formatting .format-strike { text-decoration: line-through; }
.composer-formatting .compose-code { font: 650 0.78rem ui-monospace, monospace; }
.mention-tag { overflow-wrap: anywhere; max-width: 100%; }
.mention-mine { border-color: var(--accent); font-weight: 700; }
#status { padding: 0.3rem 1rem 0.75rem; color: var(--muted); }
#status:empty { padding: 0; }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (max-width: 36rem) {
  body {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto;
  }
  body:has(> #system-notice:not([hidden])) { grid-template-rows: auto auto minmax(0, 1fr) auto; }
  .sidebar { grid-template-rows: auto auto auto; max-height: 40dvh; }
  .conversation-nav ul { display: flex; gap: 0.25rem; padding: 0.1rem; overflow-x: auto; }
  .conversation-nav li { flex: 0 0 auto; max-width: max(80vw, var(--sidebar-min-width)); }
  .conversation-group ul { display: grid; max-height: 24dvh; overflow: auto; }
  .conversation-group li { max-width: none; }
}

#workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  min-height: 0;
}
#workspace:has(> :is(#thread, #wiki-panel):not([hidden])) {
  grid-template-columns: minmax(0, 1fr) minmax(19rem, 37%);
}
#thread, #wiki-panel { border-inline-start: 1px solid var(--border); }
#thread .thread-header { justify-content: space-between; }
#close-thread, #close-wiki, .message-actions button {
  border: 1px solid var(--border);
  border-radius: 0.45rem;
  background: var(--surface);
  color: var(--muted);
}
#close-thread, #close-wiki { min-width: 2rem; font-size: 1.15rem; line-height: 1.45; }
#thread-content { overflow-y: auto; padding: 0.5rem var(--content-gutter); }
#thread-root { border-bottom: 1px solid var(--border); margin-bottom: 0.45rem; }
#replies { margin: 0; padding: 0; list-style: none; }
.message-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.25rem 0.55rem;
  margin-top: 0.2rem;
}
.message-reactions, .message-action-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}
.message-reactions { flex: 1 1 min-content; }
.message-action-buttons {
  flex: none;
  justify-content: flex-end;
  margin-inline-start: auto;
  max-width: 100%;
}
.message-actions button { padding: 0.15rem 0.45rem; font-size: 0.75rem; }
.message-actions button:hover, #close-thread:hover { background: var(--surface-subtle); }
.message-actions button[aria-pressed="true"], .message-actions button[aria-expanded="true"] {
  background: var(--badge);
  border-color: var(--accent);
  color: var(--accent);
}
.message-actions .thread-trigger { color: var(--accent); }
.thread-reply-count {
  margin-top: 0.2rem;
  padding: 0.12rem 0.4rem;
  border: 0;
  border-radius: 0.3rem;
  background: var(--badge);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 650;
}
.thread-reply-count:hover { text-decoration: underline; }
.message-actions .reaction-picker, .message-actions .reaction-choice { min-width: 1.8rem; }

@media (hover: hover) and (pointer: fine) {
  .message-row:hover {
    background-color: color-mix(in srgb, var(--text) 3%, var(--surface));
  }
  .message-action-buttons {
    opacity: 0;
    pointer-events: none;
  }
  body:not(:has(.reaction-picker[aria-expanded="true"], .message-action-buttons :focus-visible))
    .message-row:hover .message-action-buttons,
  body:not(:has(.reaction-picker[aria-expanded="true"]))
    .message-action-buttons:has(:focus-visible),
  .message-action-buttons:has(.reaction-picker[aria-expanded="true"]) {
    opacity: 1;
    pointer-events: auto;
  }
}

.composer-options:has(.emoji-catalog) { max-height: none; overflow: visible; }
.emoji-catalog {
  display: grid;
  gap: 0.55rem;
  width: min(100%, 20rem);
  max-height: min(14rem, 30dvh);
  overflow-y: auto;
  border: 1px solid var(--input-border);
  border-radius: 0.5rem;
  padding: 0.4rem 0.5rem;
  background: var(--surface);
}
.emoji-category-name {
  margin-bottom: 0.2rem;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 650;
}
.emoji-choices {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(1.65rem, 1fr));
  gap: 0.2rem;
}
button.emoji-option {
  border: 1px solid transparent;
  border-radius: 0.35rem;
  padding: 0.2rem 0;
  color: var(--text);
  background: var(--surface-subtle);
  font-size: 1rem;
}
button.emoji-option:hover, button.emoji-option[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--badge);
}

#reaction-overlay {
  position: fixed;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  gap: 0.6rem;
  width: 23rem;
  height: 22rem;
  overflow: hidden;
  border: 1px solid var(--input-border);
  border-radius: 0.75rem;
  padding: 0.65rem;
  background: var(--surface);
  box-shadow: 0 0.65rem 2rem rgba(12, 32, 34, 0.24);
}
#reaction-search, .composer-emoji-search {
  min-width: 0;
  border: 1px solid var(--input-border);
  border-radius: 0.4rem;
  padding: 0.4rem 0.55rem;
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
}
:is(#reaction-search, .composer-emoji-search)::placeholder { color: var(--muted); }
.composer-emoji-search { width: min(100%, 20rem); margin-block-end: 0.35rem; }
.composer-emoji-empty { margin: 0.35rem 0 0; color: var(--muted); }
#reaction-results, #reaction-empty { grid-area: 2 / 1; }
#reaction-results { min-height: 0; }
#reaction-results .emoji-catalog {
  width: 100%;
  max-height: 100%;
  border: 0;
  padding: 0.1rem 0.15rem;
  overscroll-behavior: contain;
}
#reaction-empty { padding: 0.5rem; color: var(--muted); }

:is(.account-entry, .channel-popover, .system-settings-panel, #create-wiki)
  :is(input:not(:where([type="checkbox"], [type="file"])), textarea, select) {
  border-color: var(--input-border);
  background: var(--surface);
  color: var(--text);
}
:is(.account-entry, .channel-popover, .system-settings-panel, #create-wiki) select {
  background: var(--surface-subtle);
}
:is(.account-entry, .channel-popover, .system-settings-panel, #create-wiki) button {
  padding: 0.32rem 0.65rem;
  border: 1px solid var(--input-border);
  border-radius: 0.35rem;
  background: transparent;
  color: var(--accent);
  font-weight: 650;
}
:is(.account-entry, .channel-popover, .system-settings-panel, #create-wiki) button:not(:disabled):hover {
  background: var(--surface-subtle);
}
:is(.account-entry, .channel-popover, .system-settings-panel, #create-wiki)
  button:is([type="submit"], .primary-action) {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
}
:is(.account-entry, .channel-popover, .system-settings-panel, #create-wiki)
  button:is([type="submit"], .primary-action):not(:disabled):hover {
  background: color-mix(in srgb, var(--accent) 86%, var(--on-accent));
}

@media (max-width: 63rem) {
  #workspace:has(> :is(#thread, #wiki-panel):not([hidden])) {
    grid-template-columns: minmax(0, 1fr);
  }
  #workspace > :is(#chat, #thread, #wiki-panel) { grid-area: 1 / 1; }
  #workspace:has(> :is(#thread, #wiki-panel):not([hidden])):not(:has(#message-search-results:not([hidden]))) > #chat,
  #workspace:has(#message-search-results:not([hidden])) > :is(#thread, #wiki-panel) { visibility: hidden; }
  #thread, #wiki-panel { border: 0; }
}
