/* MK Messenger. Tokens first; dark mode follows the system unless the person
   picks a theme in Preferences (stored as data-theme on <html>). */
:root {
  --bg: #ffffff;
  --surface-2: #f8f8f8;
  --surface-3: #ededed;
  --text: #1d1c1d;
  --text-muted: #616061;
  --border: rgba(29, 28, 29, 0.13);
  --border-strong: rgba(29, 28, 29, 0.3);
  --hover: #f8f8f8;
  --hover-strong: rgba(29, 28, 29, 0.06);
  --link: #1264a3;
  --accent: #1d9bd1;
  --accent-strong: #1264a3;
  --primary: #007a5a;
  --primary-hover: #148567;
  --danger: #e01e5a;
  --danger-text: #c41a4f;
  --brand: #3b1356;
  --topbar-bg: #2b0d40;
  --sidebar-bg: #3b1356;
  --sidebar-fg: rgba(255, 255, 255, 0.72);
  --sidebar-strong: #ffffff;
  --sidebar-hover: rgba(255, 255, 255, 0.08);
  --sidebar-active: #1264a3;
  --sidebar-border: rgba(255, 255, 255, 0.13);
  --badge-bg: #cd2553;
  --mention-bg: rgba(29, 155, 209, 0.1);
  --mention-fg: #1264a3;
  --mention-me-bg: rgba(242, 199, 68, 0.45);
  --mention-row: #fdf8e7;
  --mention-bar: #e8a723;
  --highlight: #fff1bf;
  --pinned-bg: #fdfaf1;
  --code-bg: rgba(29, 28, 29, 0.04);
  --code-border: rgba(29, 28, 29, 0.13);
  --code-text: #c01343;
  --reaction-bg: rgba(29, 28, 29, 0.04);
  --reaction-mine-bg: rgba(29, 155, 209, 0.1);
  --focus-ring: rgba(29, 155, 209, 0.3);
  --shadow: 0 4px 14px rgba(0, 0, 0, 0.14);
  --shadow-strong: 0 18px 48px rgba(0, 0, 0, 0.3);
  --guest-bg: #fbe6c5;
  --guest-fg: #7a4b00;
  --online: #2bac76;
  --topbar-h: 44px;
  --sidebar-w: 260px;
  --panel-w: 420px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji';
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #1a1d21;
    --surface-2: #222529;
    --surface-3: #2e3135;
    --text: #d8d9da;
    --text-muted: #a3a4a6;
    --border: rgba(232, 232, 232, 0.13);
    --border-strong: rgba(232, 232, 232, 0.28);
    --hover: #222529;
    --hover-strong: rgba(232, 232, 232, 0.08);
    --link: #3aa3e3;
    --accent-strong: #1d9bd1;
    --topbar-bg: #121016;
    --sidebar-bg: #19171d;
    --mention-fg: #3aa3e3;
    --mention-row: rgba(242, 199, 68, 0.09);
    --highlight: rgba(242, 199, 68, 0.22);
    --pinned-bg: rgba(242, 199, 68, 0.05);
    --code-bg: rgba(232, 232, 232, 0.06);
    --code-border: rgba(232, 232, 232, 0.13);
    --code-text: #e8912d;
    --reaction-bg: rgba(232, 232, 232, 0.06);
    --reaction-mine-bg: rgba(29, 155, 209, 0.18);
    --shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
    --guest-bg: #5c3d0a;
    --guest-fg: #fbe6c5;
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --bg: #1a1d21;
  --surface-2: #222529;
  --surface-3: #2e3135;
  --text: #d8d9da;
  --text-muted: #a3a4a6;
  --border: rgba(232, 232, 232, 0.13);
  --border-strong: rgba(232, 232, 232, 0.28);
  --hover: #222529;
  --hover-strong: rgba(232, 232, 232, 0.08);
  --link: #3aa3e3;
  --accent-strong: #1d9bd1;
  --topbar-bg: #121016;
  --sidebar-bg: #19171d;
  --mention-fg: #3aa3e3;
  --mention-row: rgba(242, 199, 68, 0.09);
  --highlight: rgba(242, 199, 68, 0.22);
  --pinned-bg: rgba(242, 199, 68, 0.05);
  --code-bg: rgba(232, 232, 232, 0.06);
  --code-border: rgba(232, 232, 232, 0.13);
  --code-text: #e8912d;
  --reaction-bg: rgba(232, 232, 232, 0.06);
  --reaction-mine-bg: rgba(29, 155, 209, 0.18);
  --shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
  --guest-bg: #5c3d0a;
  --guest-fg: #fbe6c5;
  color-scheme: dark;
}

/* ----------------------------------------------------------------- base */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
  margin: 0;
}
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.46;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}
#app {
  height: 100%;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
}
button:disabled {
  cursor: default;
}
a {
  color: var(--link);
}
code,
kbd,
pre {
  font-family: var(--mono);
}
kbd {
  font-size: 12px;
  padding: 2px 6px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--surface-2);
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.icon {
  flex: none;
  display: block;
}
.muted {
  color: var(--text-muted);
}
.small {
  font-size: 13px;
}
.pad {
  padding: 8px 0;
}
.grow {
  flex: 1;
}
.hidden-input {
  display: none;
}
.center-fill {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
}

/* ----------------------------------------------------------- boot/spinner */
.boot-screen {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--sidebar-bg);
}
.boot-logo {
  font-weight: 900;
  font-size: 28px;
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  padding: 14px 18px;
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse {
  50% {
    opacity: 0.5;
  }
}
.spinner {
  display: flex;
  gap: 6px;
  justify-content: center;
  padding: 20px;
}
.spinner span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: blink 1s infinite ease-in-out;
}
.spinner span:nth-child(2) {
  animation-delay: 0.15s;
}
.spinner span:nth-child(3) {
  animation-delay: 0.3s;
}
@keyframes blink {
  0%,
  80%,
  100% {
    opacity: 0.25;
  }
  40% {
    opacity: 1;
  }
}

/* --------------------------------------------------------------- buttons */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
  text-decoration: none;
}
.button:hover:not(:disabled) {
  background: var(--hover-strong);
}
.button.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.button.primary:hover:not(:disabled) {
  background: var(--primary-hover);
}
.button.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
.button.danger-text {
  color: var(--danger-text);
}
.button.small {
  height: 28px;
  padding: 0 10px;
  font-size: 13px;
}
.button.big {
  height: 44px;
  width: 100%;
  font-size: 16px;
}
.button:disabled {
  opacity: 0.5;
}
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: none;
  color: var(--text-muted);
  position: relative;
  flex: none;
}
.icon-button:hover,
.icon-button.on {
  background: var(--hover-strong);
  color: var(--text);
}
.icon-button.light {
  color: rgba(255, 255, 255, 0.85);
}
.icon-button.light:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}
.link-button {
  background: none;
  border: none;
  padding: 0;
  color: var(--link);
  text-align: left;
}
.link-button:hover {
  text-decoration: underline;
}
.chip-button {
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 16px;
  padding: 4px 10px;
  font-size: 13px;
}
.chip-button:hover {
  background: var(--hover-strong);
}

/* ---------------------------------------------------------------- inputs */
.input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}
textarea.input {
  height: auto;
  padding: 10px 12px;
  resize: vertical;
}
.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}
.input.compact {
  height: 32px;
  width: auto;
  font-size: 13px;
  padding: 0 8px;
}
.input.big {
  height: 48px;
  font-size: 18px;
}
.input-prefix {
  display: flex;
  align-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--bg);
}
.input-prefix:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}
.input-prefix > span {
  padding-left: 12px;
  color: var(--text-muted);
}
.input-prefix .input {
  border: none;
  box-shadow: none;
  padding-left: 4px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}
.field-label {
  font-weight: 700;
  font-size: 14px;
}
.field-hint {
  font-size: 12px;
  color: var(--text-muted);
}
.field-error,
.form-error {
  color: var(--danger-text);
  font-size: 13px;
  margin: 4px 0;
}
.toggle-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 16px;
  cursor: pointer;
}
.toggle-row input {
  margin-top: 4px;
}

/* ----------------------------------------------------------------- auth */
.auth-screen {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: linear-gradient(135deg, #3b1356 0%, #251046 55%, #102a4c 100%);
}
.auth-card {
  width: min(440px, 100%);
  background: var(--bg);
  border-radius: 14px;
  padding: 32px;
  box-shadow: var(--shadow-strong);
}
.auth-card h1 {
  font-size: 26px;
  font-weight: 900;
  margin: 0 0 6px;
  line-height: 1.2;
}
.auth-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 18px;
  margin-bottom: 20px;
}
.brand-mark {
  background: var(--brand);
  color: #fff;
  border-radius: 8px;
  padding: 3px 8px;
  font-weight: 900;
  font-size: 15px;
}
.auth-form {
  margin-top: 20px;
}
.auth-footer {
  color: rgba(255, 255, 255, 0.8);
  margin-top: 18px;
  font-size: 14px;
}
.auth-footer a {
  color: #fff;
  font-weight: 700;
}

/* ---------------------------------------------------------------- layout */
.app-shell {
  height: 100%;
  display: grid;
  grid-template-rows: var(--topbar-h) minmax(0, 1fr);
}
.topbar {
  background: var(--topbar-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  gap: 8px;
  position: relative;
}
.menu-button {
  display: none;
  position: absolute;
  left: 8px;
}
.menu-button .dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--badge-bg);
}
.topbar-search {
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(720px, 100%);
  height: 28px;
  padding: 0 4px 0 10px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.18);
  color: rgba(255, 255, 255, 0.85);
}
.topbar-search:focus-within {
  background: #fff;
  color: #1d1c1d;
}
.topbar-search input {
  flex: 1;
  min-width: 0;
  border: none;
  background: none;
  outline: none;
  color: inherit;
  font-size: 14px;
}
.topbar-search input::placeholder {
  color: inherit;
  opacity: 0.85;
}
.kbd-hint {
  border: none;
  background: rgba(255, 255, 255, 0.16);
  color: inherit;
  border-radius: 4px;
  font-size: 11px;
  padding: 2px 6px;
}
.topbar-search:focus-within .kbd-hint {
  background: rgba(0, 0, 0, 0.08);
}
.workspace {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 0;
}
.workspace.has-panel {
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--panel-w);
}
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  position: relative;
  background: var(--bg);
}

/* --------------------------------------------------------------- sidebar */
.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-fg);
  border-right: 1px solid var(--sidebar-border);
}
.sidebar-header {
  height: 49px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px 0 10px;
  border-bottom: 1px solid var(--sidebar-border);
}
.workspace-button {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  border: none;
  background: none;
  color: var(--sidebar-strong);
  font-weight: 900;
  font-size: 17px;
  padding: 4px 8px;
  border-radius: 6px;
}
.workspace-button:hover {
  background: var(--sidebar-hover);
}
.workspace-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-compose {
  color: var(--sidebar-strong);
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
}
.sidebar-compose:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}
.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 10px 0 16px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.25) transparent;
}
.sidebar-nav {
  margin-bottom: 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 28px;
  margin: 0 8px;
  padding: 0 10px 0 14px;
  width: calc(100% - 16px);
  border: none;
  border-radius: 6px;
  background: none;
  color: var(--sidebar-fg);
  text-decoration: none;
  font-size: 15px;
  text-align: left;
}
.nav-item:hover {
  background: var(--sidebar-hover);
}
.nav-item.unread {
  color: var(--sidebar-strong);
  font-weight: 700;
}
.nav-item.active {
  background: var(--sidebar-active);
  color: #fff;
}
.nav-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.muted-in-sidebar {
  opacity: 0.6;
  font-weight: 400;
}
.add-item {
  opacity: 0.85;
}
.invite-item {
  margin-top: 12px;
}
.status-mini {
  font-size: 13px;
}
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  border-radius: 9px;
  background: var(--badge-bg);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  flex: none;
}
.sidebar-section {
  margin-top: 12px;
}
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px 0 8px;
  height: 28px;
}
.section-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  border: none;
  background: none;
  color: var(--sidebar-fg);
  font-size: 15px;
  padding: 2px 6px;
  border-radius: 6px;
}
.section-toggle:hover {
  background: var(--sidebar-hover);
}
.section-add {
  display: inline-flex;
  border: none;
  background: none;
  color: var(--sidebar-fg);
  border-radius: 6px;
  padding: 4px;
  opacity: 0;
}
.sidebar-section:hover .section-add,
.section-add:focus-visible {
  opacity: 1;
}
.section-add:hover {
  background: var(--sidebar-hover);
}
.dm-avatar {
  position: relative;
  display: inline-flex;
  flex: none;
}
.dm-avatar .presence {
  position: absolute;
  right: -3px;
  bottom: -3px;
  border: 2px solid var(--sidebar-bg);
  width: 10px;
  height: 10px;
}
.nav-item.active .dm-avatar .presence {
  border-color: var(--sidebar-active);
}
.dm-count {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.notify-prompt {
  margin: 16px 12px 0;
  padding: 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 13px;
}
.notify-prompt p {
  margin: 0 0 8px;
}
.notify-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.notify-actions .link-button {
  color: var(--sidebar-fg);
  font-size: 13px;
  white-space: nowrap;
}
.sidebar-footer {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px;
  border-top: 1px solid var(--sidebar-border);
}
.me-button {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  border: none;
  background: none;
  color: var(--sidebar-fg);
  text-align: left;
  padding: 4px 6px;
  border-radius: 6px;
}
.me-button:hover {
  background: var(--sidebar-hover);
}
.me-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.25;
}
.me-text strong {
  color: var(--sidebar-strong);
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.me-status {
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.connection {
  color: #f2c744;
  display: inline-flex;
  padding: 4px;
  animation: pulse 1.4s ease-in-out infinite;
}
.sidebar-scrim {
  display: none;
}

/* --------------------------------------------------- avatars and presence */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.02em;
  flex: none;
  position: relative;
  user-select: none;
  line-height: 1;
}
.presence {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: none;
}
.presence.online {
  background: var(--online);
}
.avatar .presence {
  position: absolute;
  right: -3px;
  bottom: -3px;
  width: 9px;
  height: 9px;
  border: 2px solid var(--bg);
  box-sizing: content-box;
}
.avatar .presence.offline {
  box-shadow: inset 0 0 0 1.5px var(--text-muted);
}
.presence.offline {
  background: var(--bg);
  box-shadow: inset 0 0 0 1.5px var(--text-muted);
}
.sidebar .presence.offline {
  background: var(--sidebar-bg);
  box-shadow: inset 0 0 0 1.5px var(--sidebar-fg);
}
.tag {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--surface-3);
  color: var(--text-muted);
  vertical-align: middle;
  white-space: nowrap;
}
.tag-guest {
  background: var(--guest-bg);
  color: var(--guest-fg);
}
.tag-muted {
  background: var(--surface-3);
}

/* ------------------------------------------------------ conversation head */
.conv-header {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 49px;
  flex: none;
  padding: 0 12px 0 14px;
  border-bottom: 1px solid var(--border);
  min-width: 0;
}
.conv-title {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  max-width: 60%;
  border: none;
  background: none;
  padding: 4px 6px;
  border-radius: 6px;
  font-weight: 900;
  font-size: 18px;
  color: var(--text);
}
.conv-title:not(.static):hover {
  background: var(--hover-strong);
}
.conv-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.conv-topic {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: none;
  background: none;
  text-align: left;
  color: var(--text-muted);
  font-size: 13px;
  padding: 4px 0;
}
.conv-tools {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  flex: none;
}
.member-stack {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: none;
  color: var(--text);
  font-weight: 700;
  font-size: 13px;
}
.member-stack:hover {
  background: var(--hover-strong);
}

/* ---------------------------------------------------------- message list */
.message-list-wrap {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  flex-direction: column;
}
.message-list {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
}
.message-list-inner {
  padding: 8px 0 12px;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.list-loading {
  min-height: 24px;
}
.conversation-intro {
  padding: 24px 20px 12px;
}
.conversation-intro h2 {
  font-size: 26px;
  font-weight: 900;
  margin: 8px 0 4px;
}
.conversation-intro p {
  margin: 4px 0;
}
.intro-icon {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  background: var(--surface-3);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}
.intro-avatars {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}
.intro-actions {
  margin-top: 12px;
  display: flex;
  gap: 8px;
}
.day-divider {
  position: relative;
  display: flex;
  justify-content: center;
  margin: 18px 0 6px;
}
.day-divider::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  border-top: 1px solid var(--border);
}
.day-divider span {
  position: relative;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 2px 14px;
  font-size: 13px;
  font-weight: 700;
}
.new-divider {
  position: relative;
  display: flex;
  justify-content: flex-end;
  margin: 6px 0;
  padding-right: 16px;
}
.new-divider::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  border-top: 1px solid var(--danger);
}
.new-divider span {
  position: relative;
  background: var(--bg);
  color: var(--danger);
  font-size: 12px;
  font-weight: 700;
  padding: 0 4px;
}
.jump-latest {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  border-radius: 18px;
  padding: 7px 14px;
  background: var(--accent-strong);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  box-shadow: var(--shadow);
  z-index: 3;
}

/* --------------------------------------------------------------- message */
.message {
  position: relative;
  padding: 7px 20px 7px 16px;
}
.message.compact {
  padding-top: 2px;
  padding-bottom: 2px;
}
.message:hover,
.message.menu-open {
  background: var(--hover);
}
.message.pinned,
.message.saved {
  background: var(--pinned-bg);
}
.message.mentions-me {
  background: var(--mention-row);
  box-shadow: inset 3px 0 0 var(--mention-bar);
}
.message.highlighted {
  animation: flash 2.4s ease-out;
}
@keyframes flash {
  0%,
  40% {
    background: var(--highlight);
  }
}
.message.pending {
  opacity: 0.55;
}
.message.failed {
  opacity: 1;
}
.message-flags {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--text-muted);
  padding-left: 44px;
  margin-bottom: 2px;
}
.message-flags span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.reply-context {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--text-muted);
  padding-left: 44px;
  margin-bottom: 2px;
  min-width: 0;
  white-space: nowrap;
}
.reply-context .link-button {
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.message-inner {
  display: flex;
  gap: 8px;
}
.message-gutter {
  width: 36px;
  flex: none;
  display: flex;
  justify-content: center;
}
.avatar-button {
  border: none;
  background: none;
  padding: 0;
  height: 36px;
  border-radius: 6px;
  margin-top: 2px;
}
.gutter-time {
  visibility: hidden;
  font-size: 11px;
  color: var(--text-muted);
  line-height: 22px;
  white-space: nowrap;
}
.message:hover .gutter-time {
  visibility: visible;
}
.message-main {
  flex: 1;
  min-width: 0;
}
.message-header {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px;
  line-height: 1.3;
}
.author {
  border: none;
  background: none;
  padding: 0;
  font-weight: 900;
  font-size: 15px;
  color: var(--text);
}
.author:hover {
  text-decoration: underline;
}
.status-emoji {
  font-size: 13px;
}
.timestamp {
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: none;
}
.timestamp:hover {
  text-decoration: underline;
}
.message-body {
  overflow-wrap: anywhere;
  word-break: break-word;
}
.message-body.jumbo {
  font-size: 32px;
  line-height: 1.25;
}
.message-body.deleted {
  color: var(--text-muted);
  font-style: italic;
}
.edited {
  font-size: 12px;
  color: var(--text-muted);
}
.md-p {
  margin: 0;
}
.md-p + .md-p,
.md-p + .md-list,
.md-list + .md-p,
.md-quote + .md-p,
.md-p + .md-quote,
.md-pre + .md-p,
.md-p + .md-pre {
  margin-top: 6px;
}
.md-pre {
  margin: 4px 0;
  padding: 8px 10px;
  border: 1px solid var(--code-border);
  border-radius: 6px;
  background: var(--code-bg);
  font-size: 12.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-x: auto;
}
.md-code {
  font-size: 12.5px;
  padding: 1px 4px;
  border: 1px solid var(--code-border);
  border-radius: 4px;
  background: var(--code-bg);
  color: var(--code-text);
}
.md-quote {
  margin: 2px 0;
  padding-left: 12px;
  border-left: 4px solid var(--border-strong);
}
.md-list {
  margin: 2px 0;
  padding-left: 26px;
}
.md-link {
  color: var(--link);
  text-decoration: none;
}
.md-link:hover {
  text-decoration: underline;
}
.mention,
.channel-link {
  display: inline;
  border: none;
  padding: 0 2px;
  border-radius: 3px;
  background: var(--mention-bg);
  color: var(--mention-fg);
  font-weight: 500;
}
.mention:hover,
.channel-link:hover {
  text-decoration: underline;
}
.mention-me {
  background: var(--mention-me-bg);
  color: var(--text);
}
mark {
  background: var(--mention-me-bg);
  color: inherit;
  border-radius: 2px;
}
.emoji {
  font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif;
}
.send-failed {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
  font-size: 13px;
  color: var(--danger-text);
}
.also-sent {
  margin-top: 2px;
}

/* actions */
.message-actions {
  position: absolute;
  top: -14px;
  right: 16px;
  display: none;
  align-items: center;
  gap: 1px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  z-index: 2;
}
.message:hover .message-actions,
.message.menu-open .message-actions,
.message-actions:has(:focus-visible) {
  display: flex;
}
.action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 30px;
  border: none;
  border-radius: 6px;
  background: none;
  color: var(--text-muted);
  font-size: 16px;
}
.action-button:hover {
  background: var(--hover-strong);
  color: var(--text);
}
.action-button.on {
  color: var(--danger);
}

/* attachments */
.attachments {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 8px;
  margin-top: 6px;
}
.attachment-image {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0;
  background: var(--surface-2);
  overflow: hidden;
  max-width: min(360px, 100%);
}
.attachment-image img {
  display: block;
  max-width: 100%;
  max-height: 260px;
  object-fit: contain;
}
.attachment-file {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 220px;
  max-width: min(380px, 100%);
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  text-decoration: none;
}
.attachment-file:hover {
  border-color: var(--border-strong);
}
.file-icon {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  background: var(--accent-strong);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.file-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}
.file-name {
  font-weight: 700;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-download {
  color: var(--text-muted);
}

/* reactions */
.reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}
.reaction {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 24px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: var(--reaction-bg);
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
}
.reaction:hover:not(:disabled) {
  border-color: var(--border-strong);
  background: var(--bg);
}
.reaction.mine {
  background: var(--reaction-mine-bg);
  border-color: var(--accent);
  color: var(--link);
}
.reaction-emoji {
  font-size: 15px;
}
.add-reaction {
  color: var(--text-muted);
  opacity: 0;
}
.message:hover .add-reaction {
  opacity: 1;
}

/* thread summary */
.thread-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(560px, 100%);
  margin-top: 4px;
  padding: 4px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: none;
  text-align: left;
  font-size: 13px;
}
.thread-summary:hover {
  background: var(--bg);
  border-color: var(--border);
}
.thread-avatars {
  display: flex;
  gap: 3px;
}
.thread-count {
  color: var(--link);
  font-weight: 700;
}
.thread-summary.unread .thread-count::after {
  content: ' • new';
  color: var(--danger);
}
.thread-view {
  margin-left: auto;
  display: none;
  align-items: center;
  color: var(--text-muted);
}
.thread-summary:hover .thread-view {
  display: inline-flex;
}
.thread-summary:hover .thread-last {
  display: none;
}

/* inline edit */
.edit-box {
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--bg);
  padding: 6px;
  margin: 2px 0;
}
.edit-input {
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  background: none;
  padding: 4px 6px;
  font-size: 15px;
  line-height: 1.46;
}
.edit-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}
.edit-actions .muted {
  margin-right: auto;
}

/* ------------------------------------------------------------- composer */
.composer {
  flex: none;
  padding: 0 20px 2px;
}
.panel .composer {
  padding: 0 16px 2px;
}
.composer-box {
  position: relative;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--bg);
}
.composer-box.focused {
  border-color: var(--text-muted);
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.08);
}
.composer-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px 6px;
}
.composer-toolbar.top {
  background: var(--surface-2);
  border-radius: 8px 8px 0 0;
  opacity: 0.85;
}
.composer-box:not(.focused) .composer-toolbar.top {
  opacity: 0.55;
}
.tool {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 4px;
  background: none;
  color: var(--text-muted);
}
.tool:hover {
  background: var(--hover-strong);
  color: var(--text);
}
.tool-sep {
  width: 1px;
  height: 18px;
  background: var(--border);
  margin: 0 4px;
}
.toolbar-spacer {
  flex: 1;
}
.composer-hint {
  margin-right: 8px;
}
.composer-input {
  display: block;
  width: 100%;
  min-height: 40px;
  max-height: 40vh;
  padding: 10px 12px 4px;
  border: none;
  outline: none;
  resize: none;
  background: none;
  font-size: 15px;
  line-height: 1.46;
}
.send-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 30px;
  border: none;
  border-radius: 6px;
  background: none;
  color: var(--text-muted);
}
.send-button.ready {
  background: var(--primary);
  color: #fff;
}
.send-button.ready:hover {
  background: var(--primary-hover);
}
.suggest {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 100%;
  margin: 0 0 6px;
  padding: 6px 0;
  list-style: none;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  max-height: 300px;
  overflow-y: auto;
  z-index: 5;
}
.suggest-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 14px;
  border: none;
  background: none;
  text-align: left;
  font-size: 14px;
}
.suggest-item.active {
  background: var(--accent-strong);
  color: #fff;
}
.suggest-item.active .muted {
  color: rgba(255, 255, 255, 0.8);
}
.suggest-at {
  width: 22px;
  text-align: center;
  font-weight: 700;
}
.suggest-emoji {
  font-size: 18px;
}
.upload-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 10px 6px;
}
.upload-chip {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 280px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  overflow: hidden;
  font-size: 13px;
}
.upload-chip.error {
  border-color: var(--danger);
  color: var(--danger-text);
}
.upload-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  font-weight: 600;
}
.upload-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: var(--border);
}
.upload-bar span {
  display: block;
  height: 100%;
  background: var(--accent);
  transition: width 0.15s;
}
.chip-x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border: none;
  border-radius: 4px;
  background: none;
  color: var(--text-muted);
  padding: 0;
  flex: none;
}
.chip-x:hover {
  background: var(--hover-strong);
  color: var(--text);
}
.also-send {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  font-size: 13px;
  color: var(--text-muted);
}
.typing-line {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 20px;
  font-size: 12px;
  color: var(--text-muted);
  padding: 0 2px;
}
.typing-dots {
  display: inline-flex;
  gap: 2px;
}
.typing-dots span {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: blink 1s infinite;
}
.typing-dots span:nth-child(2) {
  animation-delay: 0.15s;
}
.typing-dots span:nth-child(3) {
  animation-delay: 0.3s;
}
.join-bar {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin: 0 20px 20px;
  padding: 16px 20px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}
.join-bar p {
  margin: 0;
}
.join-actions {
  display: flex;
  gap: 8px;
}
.drop-overlay {
  position: absolute;
  inset: 8px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  border: 3px dashed var(--accent);
  border-radius: 12px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  color: var(--text);
  pointer-events: none;
}
.drop-overlay div {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ---------------------------------------------------------------- panels */
.panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  background: var(--bg);
  border-left: 1px solid var(--border);
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  height: 49px;
  flex: none;
  padding: 0 8px 0 16px;
  border-bottom: 1px solid var(--border);
}
.panel-header h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 900;
  line-height: 1.2;
}
.panel-header > div:first-child {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}
.panel-tools {
  display: flex;
  align-items: center;
  gap: 4px;
}
.panel-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}
.panel-scroll.padded {
  padding: 16px;
}
.panel-scroll .message-card {
  margin-bottom: 10px;
}
.replies-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 16px;
  font-size: 13px;
  color: var(--text-muted);
}
.replies-divider::after {
  content: '';
  flex: 1;
  border-top: 1px solid var(--border);
}

/* ------------------------------------------------------------ profile */
.profile-card h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 900;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.profile-card.compact h3 {
  font-size: 17px;
}
.profile-card p {
  margin: 2px 0;
}
.profile-top {
  display: flex;
  align-items: center;
  gap: 14px;
}
.profile-card:not(.compact) .profile-top {
  flex-direction: column;
  align-items: flex-start;
}
.presence-line {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
}
.profile-status {
  margin: 12px 0 0 !important;
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--surface-2);
}
.profile-facts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  margin: 14px 0;
  font-size: 14px;
}
.profile-facts dt {
  color: var(--text-muted);
}
.profile-facts dd {
  margin: 0;
  overflow-wrap: anywhere;
}
.profile-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.profile-popover {
  width: 320px;
  padding: 16px;
}

/* ---------------------------------------------------------------- pages */
.page-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px 32px;
}
.card-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.message-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  overflow: hidden;
}
.card-unread .message-card {
  box-shadow: inset 3px 0 0 var(--accent-strong);
}
.card-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 12px 0;
}
.card-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}
.card-time {
  margin-left: auto;
}
.card-body {
  display: flex;
  gap: 10px;
  width: 100%;
  padding: 8px 12px 12px;
  border: none;
  background: none;
  text-align: left;
  color: var(--text);
}
.card-body:hover {
  background: var(--hover);
}
.card-text {
  min-width: 0;
  flex: 1;
}
.card-extra {
  display: flex;
  justify-content: flex-end;
  padding: 0 12px 10px;
}
.channel-label {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 6px;
  border: none;
  border-radius: 4px;
  background: var(--surface-3);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  max-width: 260px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.channel-label:hover {
  color: var(--text);
}
.thread-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 16px;
  overflow: hidden;
}
.thread-card.unread {
  border-color: var(--accent);
}
.thread-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px 8px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.thread-card-head .button {
  margin-left: auto;
}
.more-replies {
  display: block;
  padding: 2px 16px 2px 60px;
  font-size: 13px;
}
.empty-state {
  max-width: 440px;
  margin: 48px auto;
  text-align: center;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
}
.empty-state.small {
  margin: 24px auto;
}
.empty-state h3 {
  color: var(--text);
  margin: 12px 0 4px;
}
.empty-state p {
  margin: 4px 0;
}
.search-page-form {
  display: flex;
  gap: 8px;
  max-width: 720px;
}
.search-tips code {
  background: var(--code-bg);
  border-radius: 4px;
  padding: 0 4px;
}

/* -------------------------------------------------------------- popovers */
.popover {
  position: fixed;
  z-index: 60;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  max-width: calc(100vw - 16px);
}
.menu {
  padding: 6px 0;
  min-width: 240px;
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 7px 16px;
  border: none;
  background: none;
  text-align: left;
  font-size: 14px;
}
.menu-item:hover:not(:disabled) {
  background: var(--accent-strong);
  color: #fff;
}
.menu-item.danger {
  color: var(--danger-text);
}
.menu-item.danger:hover {
  background: var(--danger);
  color: #fff;
}
.menu-hint {
  margin-left: auto;
  font-size: 12px;
  opacity: 0.7;
}
.menu-sep {
  height: 1px;
  background: var(--border);
  margin: 6px 0;
}
.emoji-picker {
  width: 352px;
  height: 380px;
  display: flex;
  flex-direction: column;
  padding: 10px 0 0;
}
.emoji-search {
  margin: 0 10px 8px;
  width: calc(100% - 20px);
  height: 34px;
}
.emoji-tabs {
  display: flex;
  justify-content: space-between;
  padding: 0 8px 6px;
  border-bottom: 1px solid var(--border);
}
.emoji-tab {
  border: none;
  background: none;
  font-size: 17px;
  border-radius: 6px;
  padding: 3px 5px;
  opacity: 0.6;
}
.emoji-tab.active,
.emoji-tab:hover {
  opacity: 1;
  background: var(--hover-strong);
}
.emoji-grid-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px 8px;
}
.emoji-cat-title {
  margin: 8px 4px 4px;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 700;
}
.emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
}
.emoji-cell {
  height: 38px;
  border: none;
  border-radius: 6px;
  background: none;
  font-size: 23px;
  line-height: 1;
  padding: 0;
}
.emoji-cell:hover {
  background: var(--hover-strong);
}

/* ---------------------------------------------------------------- modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.45);
}
.modal {
  width: min(540px, 100%);
  max-height: min(88vh, 800px);
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  background: var(--bg);
  box-shadow: var(--shadow-strong);
}
.modal-wide {
  width: min(740px, 100%);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 20px 8px 24px;
}
.modal-header h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 900;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
}
.modal-body {
  padding: 8px 24px 22px;
  overflow-y: auto;
}
.modal-body > p:first-child {
  margin-top: 0;
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 24px;
  border-top: 1px solid var(--border);
}
.section-title {
  margin: 22px 0 8px;
  font-size: 15px;
}
.tabs {
  display: flex;
  gap: 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.tab {
  border: none;
  background: none;
  padding: 8px 2px;
  font-weight: 700;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab.active {
  color: var(--text);
  border-bottom-color: var(--accent-strong);
}
.detail-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
  overflow-wrap: anywhere;
}
.detail-label {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 2px;
}
.detail-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 16px;
}
.row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 8px;
  flex: none;
}
.member-list {
  list-style: none;
  padding: 0;
  margin: 8px 0;
}
.member-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 0;
}
.member-row.deactivated {
  opacity: 0.55;
}
.member-main {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  padding: 5px 6px;
  border: none;
  border-radius: 6px;
  background: none;
  text-align: left;
  color: var(--text);
}
button.member-main:hover {
  background: var(--hover-strong);
}
.member-main > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.admin-placeholder {
  width: 92px;
}
.add-people,
.add-people-button {
  margin-bottom: 12px;
}
.browse-top {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.browse-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.browse-item {
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
}
.browse-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 10px 6px;
  border: none;
  background: none;
  text-align: left;
  color: var(--text);
}
.browse-main:hover .browse-name {
  text-decoration: underline;
}
.browse-name {
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 700;
}
.browse-main .muted {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
.joined {
  color: var(--primary);
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.user-picker {
  margin-bottom: 8px;
}
.chips-input {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  min-height: 40px;
  padding: 5px 8px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
}
.chips-input:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 4px 2px 2px;
  border-radius: 5px;
  background: var(--reaction-mine-bg);
  font-size: 13px;
  font-weight: 600;
}
.chips-field {
  flex: 1;
  min-width: 140px;
  border: none;
  outline: none;
  background: none;
  height: 28px;
}
.picker-list {
  list-style: none;
  margin: 6px 0 0;
  padding: 4px 0;
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.picker-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 10px;
  border: none;
  background: none;
  text-align: left;
  color: var(--text);
}
.picker-item:hover {
  background: var(--hover-strong);
}
.picker-name {
  font-weight: 700;
}
.profile-edit {
  display: flex;
  gap: 24px;
}
.profile-edit-main {
  flex: 1;
  min-width: 0;
}
.profile-edit-side {
  width: 140px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.status-input {
  display: flex;
  gap: 6px;
}
.status-emoji-button {
  flex: none;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--bg);
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}
.status-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.password-section {
  border-top: 1px solid var(--border);
  padding-top: 14px;
  margin-top: 8px;
}
.password-section summary {
  font-weight: 700;
  cursor: pointer;
}
.pw-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.pw-grid .input {
  flex: 1;
  min-width: 200px;
}
.segmented {
  display: inline-flex;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  overflow: hidden;
}
.segmented button {
  border: none;
  background: none;
  padding: 8px 14px;
  font-weight: 600;
}
.segmented button + button {
  border-left: 1px solid var(--border-strong);
}
.segmented button.active {
  background: var(--accent-strong);
  color: #fff;
}
.shortcut-list {
  margin: 0;
}
.shortcut-list div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.shortcut-list dd {
  margin: 0;
  color: var(--text-muted);
  text-align: right;
}
.invite-form {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
}
.invite-row {
  display: flex;
  gap: 12px;
}
.invite-row .field {
  flex: 1;
}
.channel-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.check-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  font-size: 13px;
  cursor: pointer;
}
.check-chip:has(input:checked) {
  border-color: var(--accent);
  background: var(--reaction-mine-bg);
}
.invite-result {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 10px;
  background: var(--reaction-mine-bg);
}
.invite-result p {
  margin: 0 0 8px;
}
.copy-row {
  display: flex;
  gap: 8px;
}
.invite-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.invite-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.invite-list .row-actions {
  margin: 0;
}
.file-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.file-list .attachment-file {
  max-width: none;
}
.switcher .modal-body {
  padding-top: 4px;
}
.switcher-list {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  max-height: 50vh;
  overflow-y: auto;
}
.switcher-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  border-radius: 6px;
  background: none;
  text-align: left;
  font-size: 15px;
}
.switcher-item.active {
  background: var(--accent-strong);
  color: #fff;
}
.switcher-item.active .muted {
  color: rgba(255, 255, 255, 0.8);
}
.switcher-item .badge {
  margin-left: auto;
}

/* --------------------------------------------------------------- lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.88);
  outline: none;
}
.lightbox img {
  max-width: 92vw;
  max-height: 82vh;
  border-radius: 6px;
  box-shadow: var(--shadow-strong);
}
.lightbox-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  color: #fff;
}
.lightbox-bar > span {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

/* ----------------------------------------------------------------- toasts */
.toasts {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(480px, calc(100vw - 32px));
}
.toast {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 8px 10px 16px;
  border-radius: 8px;
  background: #1d1c1d;
  color: #fff;
  box-shadow: var(--shadow-strong);
  font-size: 14px;
  animation: rise 0.18s ease-out;
}
.toast.error {
  background: #a0103f;
}
@keyframes rise {
  from {
    transform: translateY(8px);
    opacity: 0;
  }
}

/* ----------------------------------------------------------------- mobile */
@media (max-width: 1100px) {
  :root {
    --panel-w: 360px;
    --sidebar-w: 240px;
  }
}
@media (max-width: 860px) {
  .workspace.has-panel {
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  }
  .workspace.has-panel .panel {
    position: fixed;
    top: var(--topbar-h);
    right: 0;
    bottom: 0;
    width: min(var(--panel-w), 100vw);
    z-index: 30;
    box-shadow: var(--shadow-strong);
  }
}
@media (max-width: 767px) {
  body {
    font-size: 16px;
  }
  .workspace,
  .workspace.has-panel {
    grid-template-columns: minmax(0, 1fr);
  }
  .menu-button {
    display: inline-flex;
  }
  .topbar {
    padding-left: 48px;
  }
  .kbd-hint {
    display: none;
  }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(300px, 86vw);
    z-index: 45;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }
  .sidebar.open {
    transform: none;
    box-shadow: var(--shadow-strong);
  }
  .sidebar-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 44;
    background: rgba(0, 0, 0, 0.4);
  }
  .workspace.has-panel .panel {
    left: 0;
    width: 100vw;
  }
  .message {
    padding-left: 12px;
    padding-right: 12px;
  }
  .composer {
    padding: 0 10px 2px;
  }
  .composer-toolbar.top,
  .composer-hint {
    display: none;
  }
  .composer-input {
    font-size: 16px;
  }
  .join-bar {
    margin: 0 10px 10px;
  }
  .conv-topic {
    display: none;
  }
  .conv-title {
    max-width: none;
    flex: 1;
  }
  .member-stack span {
    display: none;
  }
  .page-scroll {
    padding: 12px;
  }
  .modal-backdrop {
    padding: 0;
    align-items: flex-end;
  }
  .modal,
  .modal-wide {
    width: 100%;
    max-height: 92vh;
    border-radius: 14px 14px 0 0;
  }
  .modal-header,
  .modal-body,
  .modal-footer {
    padding-left: 16px;
    padding-right: 16px;
  }
  .profile-edit {
    flex-direction: column-reverse;
  }
  .profile-edit-side {
    width: auto;
    flex-direction: row;
    gap: 12px;
    text-align: left;
  }
  .invite-row {
    flex-direction: column;
    gap: 0;
  }
  .message-actions {
    right: 8px;
  }
  .emoji-picker {
    width: min(352px, calc(100vw - 16px));
  }
}
@media (hover: none) {
  .add-reaction {
    opacity: 1;
  }
  .section-add {
    opacity: 1;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
