/* ============================================
   CHATLY — Whiteboard & Blackboard Theme
   ============================================ */

/* ---------- CSS Custom Properties ---------- */
:root {
  /* Typography */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-size-base: 15px;
  --font-size-sm: 13px;
  --font-size-xs: 12px;
  --font-size-lg: 18px;
  --line-height: 1.46;

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 50%;

  /* Transitions */
  --transition-fast: 120ms ease;
  --transition-base: 180ms ease;
  --transition-slow: 300ms ease;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);

  /* Theme-aware semantic colors (overridden per theme) */
  --accent-rgb: 74, 111, 165;
  --color-success: #5A9A5A;
  --color-warning: #B89840;
  --color-danger: #C45050;

  /* Syntax highlighting */
  --hl-string: #98c379;
  --hl-number: #d19a66;
}

/* ---- Light Mode (Light Wooden Board with Chalk) ---- */
[data-bs-theme="light"] {
  --bg-app: #E8E2D8;
  --bg-rail: #3A3530;
  --bg-rail-icon: rgba(255, 255, 255, 0.12);
  --bg-rail-icon-active: #FFFFFF;
  --rail-text: rgba(255, 255, 255, 0.7);
  --rail-text-active: #3A3530;

  --bg-chrome: #F0EBE2;
  --bg-sidebar: #F0EBE2;
  --bg-sidebar-hover: #E5E0D7;
  --bg-sidebar-active: #DAD5CC;
  --sidebar-text: #2C2824;
  --sidebar-text-muted: #7A756C;

  --bg-main: #F5F0E8;
  --bg-main-alt: #F0EBE2;
  --text-primary: #2C2824;
  --text-secondary: #5C5850;
  --text-muted: #8E8A82;

  --bg-message-hover: #EDE8E0;
  --bg-code: #EBE6DE;
  --border-code: #DAD5CC;

  --accent: #5A7FA8;
  --accent-hover: #4A6C92;
  --accent-subtle: #E0E8F0;
  --accent-text: #FFFFFF;
  --accent-rgb: 90, 127, 168;

  --bg-input: #F5F0E8;
  --border-input: #CCC7BE;
  --border-input-focus: #5A7FA8;

  --border-light: #DAD5CC;
  --border-subtle: #E5E0D7;

  --bg-reaction: #E5E0D7;
  --bg-reaction-active: #D5DDE8;
  --border-reaction: transparent;
  --border-reaction-active: #5A7FA8;

  --bg-attachment: #F0EBE2;
  --border-attachment: #DAD5CC;

  --badge-bg: #C45050;
  --badge-text: #FFFFFF;

  --mention-bg: #D5DDE8;
  --mention-text: #5A7FA8;

  --scrollbar-thumb: #CCC7BE;
  --scrollbar-track: transparent;

  --date-divider-bg: #F5F0E8;
  --date-divider-text: #8E8A82;
  --date-divider-line: #DAD5CC;

  --shadow-header: 0 1px 0 rgba(0, 0, 0, 0.06);

  --send-bg: #5A7FA8;
  --send-bg-hover: #4A6C92;
  --send-disabled: #CCC7BE;

  --bg-thread: #EDE8E0;
  --thread-text: #5A7FA8;

  --typing-dot: #8E8A82;

  --color-success: #5A9A5A;
  --color-warning: #B89840;
  --color-danger: #C45050;

  --hl-string: #5A9A5A;
  --hl-number: #B89840;
}

/* ---- Dark Mode (Dark Wooden Board with Chalk) ---- */
[data-bs-theme="dark"] {
  --bg-app: #1C1916;
  --bg-rail: #151210;
  --bg-rail-icon: rgba(255, 255, 255, 0.08);
  --bg-rail-icon-active: rgba(255, 255, 255, 0.15);
  --rail-text: rgba(255, 255, 255, 0.4);
  --rail-text-active: rgba(255, 255, 255, 0.9);

  --bg-chrome: #1F1C19;
  --bg-sidebar: #1F1C19;
  --bg-sidebar-hover: #272420;
  --bg-sidebar-active: #2E2B27;
  --sidebar-text: #DDD8CE;
  --sidebar-text-muted: #7E7A72;

  --bg-main: #23201C;
  --bg-main-alt: #272420;
  --text-primary: #DDD8CE;
  --text-secondary: #A8A39A;
  --text-muted: #6E6A62;

  --bg-message-hover: #282520;
  --bg-code: #1A1714;
  --border-code: #302C28;

  --accent: #7CB4D8;
  --accent-hover: #94C6E4;
  --accent-subtle: #1E2A34;
  --accent-text: #151210;
  --accent-rgb: 124, 180, 216;

  --bg-input: #272420;
  --border-input: #3A3632;
  --border-input-focus: #7CB4D8;

  --border-light: #302C28;
  --border-subtle: #272420;

  --bg-reaction: #2E2B27;
  --bg-reaction-active: #1E2A34;
  --border-reaction: transparent;
  --border-reaction-active: #7CB4D8;

  --bg-attachment: #272420;
  --border-attachment: #302C28;

  --badge-bg: #D47070;
  --badge-text: #FFFFFF;

  --mention-bg: #1E2A34;
  --mention-text: #7CB4D8;

  --scrollbar-thumb: #3A3632;
  --scrollbar-track: transparent;

  --date-divider-bg: #23201C;
  --date-divider-text: #6E6A62;
  --date-divider-line: #302C28;

  --shadow-header: 0 1px 0 rgba(0, 0, 0, 0.3);
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);

  --send-bg: #7CB4D8;
  --send-bg-hover: #94C6E4;
  --send-disabled: #3A3632;

  --bg-thread: #1F1C19;
  --thread-text: #7CB4D8;

  --typing-dot: #6E6A62;

  --color-success: #7BC47B;
  --color-warning: #D4B85A;
  --color-danger: #D47070;

  --hl-string: #98C379;
  --hl-number: #D4B87A;
}

/* ---------- Base Reset ---------- */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  font-size: var(--font-size-base);
}

body {
  font-family: var(--font-family);
  line-height: var(--line-height);
  margin: 0;
  background: var(--bg-app);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { text-decoration: none; color: inherit; }

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}
::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ---------- App Shell ---------- */
.app-shell {
  background: var(--bg-app);
}

/* ---------- Sidebar ---------- */
.sidebar {
  width: 268px;
  min-width: 268px;
  background: var(--bg-chrome);
  z-index: 15;
  transition: transform var(--transition-slow);
}

.sidebar-title {
  color: var(--sidebar-text);
  font-size: var(--font-size-lg);
}

/* Search */
.search-box {
  position: relative;
}
.search-box i {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: var(--font-size-sm);
}
.search-box .form-control {
  background: var(--bg-sidebar-hover);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 6px 12px 6px 32px;
  font-size: var(--font-size-sm);
  color: var(--sidebar-text);
  transition: all var(--transition-base);
}
.search-box .form-control::placeholder {
  color: var(--text-muted);
}
.search-box .form-control:focus {
  background: var(--bg-input);
  border-color: var(--border-input-focus);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.15);
}

/* Nav Items */
.sidebar-nav .nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 12px;
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  color: var(--sidebar-text-muted);
  transition: all var(--transition-fast);
  cursor: pointer;
}
.sidebar-nav .nav-item:hover {
  background: var(--bg-sidebar-hover);
  color: var(--sidebar-text);
}
.sidebar-nav .nav-item.active {
  background: var(--bg-sidebar-active);
  color: var(--sidebar-text);
  font-weight: 500;
}
.sidebar-nav .nav-item.active:hover {
  background: var(--bg-sidebar-active);
  color: var(--sidebar-text);
}
.sidebar-nav .nav-item i {
  font-size: 1rem;
  width: 20px;
  text-align: center;
}

/* Sidebar Divider */
.sidebar-divider {
  border-color: var(--border-light);
  opacity: 1;
  margin: 4px 0;
}

.sidebar-header {
  flex-shrink: 0;
  background: var(--bg-chrome);
}

.sidebar-scroll-region {
  min-height: 0;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.sidebar-section {
  min-height: 0;
  overscroll-behavior: contain;
}

/* Section Header — layout via Bootstrap utilities */
.section-header {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  padding: 5px 12px;
  border: none;
  background: none;
  font-size: var(--font-size-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--sidebar-text-muted);
  cursor: pointer;
  transition: color var(--transition-fast);
}
.section-header:hover {
  color: var(--sidebar-text);
}
.section-header .chevron {
  font-size: 10px;
  transition: transform var(--transition-base);
}
.section-header.collapsed .chevron {
  transform: rotate(-90deg);
}

/* Channel Items — layout via Bootstrap utilities */
.channel-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  color: var(--sidebar-text-muted);
  transition: all var(--transition-fast);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.channel-item i {
  font-size: 1rem;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}
.channel-item-name {
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
  min-width: 0;
  flex: 1;
}
.channel-item:hover {
  background: var(--bg-sidebar-hover);
  color: var(--sidebar-text);
}
.channel-item.active {
  background: var(--bg-sidebar-active);
  color: var(--sidebar-text);
  font-weight: 500;
}
.channel-item i {
  font-size: 1rem;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}
.channel-item-icon {
  width: 18px;
  text-align: center;
  flex-shrink: 0;
  font-size: var(--font-size-sm);
}

.dm-item {
  min-width: 0;
  min-height: 30px;
}

.dm-item .channel-item-name {
  font-weight: 500;
  line-height: 1.2;
}

.dm-compose-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  padding: 2px 8px;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity var(--transition-fast), color var(--transition-fast);
}
.dm-compose-btn:hover {
  opacity: 1;
  color: var(--sidebar-text);
}

/* Unread Badge */
.unread-badge {
  margin-left: auto;
  background: var(--badge-bg);
  color: var(--badge-text);
  font-size: 11px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
  flex-shrink: 0;
}

.unread-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  margin-left: auto;
  background: var(--accent);
  flex-shrink: 0;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent);
}

.channel-item-unread .channel-item-name {
  color: var(--sidebar-text);
  font-weight: 600;
}

/* Avatar Sizes */
.avatar-tiny {
  position: relative;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}
.avatar-tiny img {
  width: 22px;
  height: 22px;
  border-radius: var(--radius-sm);
  object-fit: cover;
}
.avatar-small {
  position: relative;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}
.avatar-small img {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  object-fit: cover;
}

.identity-avatar {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.identity-avatar-medium {
  width: 36px;
  height: 36px;
}

.identity-avatar-small {
  width: 32px;
  height: 32px;
}

.identity-avatar-tiny {
  width: 22px;
  height: 22px;
}

.identity-avatar-xs {
  width: 18px;
  height: 18px;
}

.identity-status-badge {
  position: absolute;
  right: -3px;
  bottom: -3px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: 999px;
  z-index: 2;
  pointer-events: none;
}

.identity-status-emoji {
  background: color-mix(in srgb, var(--bg-main-alt) 94%, transparent);
  line-height: 1;
}

.identity-status-dot {
  background: var(--text-muted);
}

.identity-status-badge-md {
  min-width: 16px;
  height: 16px;
  padding: 0 3px;
  font-size: 10px;
}

.identity-status-badge-sm {
  min-width: 14px;
  height: 14px;
  padding: 0 2px;
  font-size: 9px;
}

.identity-status-badge-tiny {
  min-width: 12px;
  height: 12px;
  padding: 0 2px;
  font-size: 8px;
}

.identity-status-badge-xs {
  min-width: 10px;
  height: 10px;
  padding: 0 1px;
  font-size: 7px;
}

.identity-status-dot.identity-status-badge-md,
.identity-status-dot.identity-status-badge-sm,
.identity-status-dot.identity-status-badge-tiny,
.identity-status-dot.identity-status-badge-xs {
  padding: 0;
  min-width: auto;
  box-shadow: 0 0 0 2px var(--bg-main);
}

.identity-status-dot.identity-status-badge-md {
  width: 10px;
  height: 10px;
}

.identity-status-dot.identity-status-badge-sm {
  width: 8px;
  height: 8px;
}

.identity-status-dot.identity-status-badge-tiny {
  width: 7px;
  height: 7px;
  right: -1px;
  bottom: -1px;
}

.identity-status-dot.identity-status-badge-xs {
  width: 6px;
  height: 6px;
  right: -1px;
  bottom: -1px;
}

.identity-status-dot.status-online {
  background: var(--color-success);
}

.identity-status-dot.status-away {
  background: var(--color-warning);
}

.identity-status-dot.status-busy {
  background: var(--color-danger);
}

.identity-status-dot.status-offline {
  background: var(--text-muted);
}

/* Status Dots */
.avatar-tiny::after,
.avatar-small::after {
  content: '';
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 9px;
  height: 9px;
  border-radius: var(--radius-full);
  border: 2px solid var(--bg-sidebar);
}
.avatar-tiny.online::after,
.avatar-small.online::after {
  background: var(--color-success);
}
.avatar-tiny.away::after,
.avatar-small.away::after {
  background: var(--color-warning);
}
.avatar-tiny.busy::after,
.avatar-small.busy::after {
  background: var(--color-danger);
}
.avatar-tiny.offline::after,
.avatar-small.offline::after {
  background: var(--text-muted);
}

.min-w-0 { min-width: 0; }

/* ---------- Chat Main ---------- */
.chat-main {
  --chat-rail-x: 24px;
  background: var(--bg-main);
  min-width: 0;
}

/* Chat Header */
.chat-header {
  height: 52px;
  min-height: 52px;
  padding: 0 var(--chat-rail-x);
  border-bottom: 1px solid var(--border-light);
  box-shadow: var(--shadow-header);
  gap: 12px;
  flex-wrap: nowrap;
  background: var(--bg-chrome);
  z-index: 5;
}

.title-with-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--text-primary);
}

.title-with-badge-glyph,
.title-with-badge-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  line-height: 1;
}

.title-with-badge-glyph {
  color: inherit;
}

.title-with-badge-glyph i {
  font-size: 1em;
}

.title-with-badge-badge {
  color: inherit;
  font-size: 1em;
  white-space: nowrap;
}

.title-with-badge-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.title-with-badge-panel {
  font-size: var(--font-size-lg);
  font-weight: 600;
}

.topbar-bell-btn {
  position: relative;
}

.topbar-room-info-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  height: 32px;
  padding: 0 10px 0 6px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: color-mix(in srgb, var(--bg-main-alt) 72%, transparent);
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.topbar-room-info-btn:hover:not(:disabled) {
  color: var(--text-primary);
  background: color-mix(in srgb, var(--bg-sidebar-hover) 88%, transparent);
  border-color: color-mix(in srgb, var(--border-light) 72%, transparent);
}

.topbar-room-info-btn:active:not(:disabled) {
  transform: scale(0.97);
}

.topbar-room-info-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.topbar-room-info-btn.panel-active {
  background: color-mix(in srgb, var(--accent-subtle) 92%, var(--bg-main));
  border-color: color-mix(in srgb, var(--accent) 22%, var(--border-light));
}

.topbar-room-info-icon {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--bg-main) 65%, transparent);
  color: inherit;
  flex-shrink: 0;
}

.topbar-room-info-icon i {
  font-size: 0.9rem;
  line-height: 1;
}

.topbar-room-info-label {
  font-size: var(--font-size-sm);
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}

.topbar-room-info-count {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--text-primary) 10%, transparent);
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
}

.topbar-notification-badge {
  position: absolute;
  top: -4px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--badge-bg);
  color: var(--badge-text);
  font-size: 10px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 2px var(--bg-main);
}

.message-body p {
  margin: 0;
  word-wrap: break-word;
  color: var(--text-primary);
}
.message-body p + p {
  margin-top: 4px;
}

/* Inline Code */
.message-body code {
  background: var(--bg-code);
  border: 1px solid var(--border-code);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.88em;
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  color: var(--text-primary);
}

.code-block pre {
  margin: 0;
  padding: 12px;
  overflow-x: auto;
  font-size: var(--font-size-sm);
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  line-height: 1.5;
  color: var(--text-primary);
}

/* ═══════════════════════════════════════════════════════════════
   CHATLY APP-SPECIFIC STYLES
   ═══════════════════════════════════════════════════════════════ */

/* chatly — chat app styles on chatly-theme.css */

/* ── Layout ── */

/* Lock document to viewport — no document-level scroll */
html, body {
  height: 100%;
  overflow: hidden;
  /* Faster taps on mobile — removes 300ms delay */
  touch-action: manipulation;
}

.app-shell {
  height: 100vh;
  height: 100svh; /* small viewport height — stable, no recalc on browser chrome animation */
  overflow: hidden;
}

.chat-main {
  height: 100vh;
  height: 100svh;
  overflow: hidden;
}

.chat-container {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

.chat-timeline-shell {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.chat-composer-shell {
  position: relative;
  flex-shrink: 0;
}

.messages-area {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

/* ── Empty states ── */

.chat-empty {
  height: 100%;
  padding: 32px;
  animation: empty-float-in 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes empty-float-in {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.chat-empty-icon {
  font-size: 48px;
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: 16px;
  opacity: 0.3;
  animation: empty-icon-float 3s ease-in-out infinite;
}

@keyframes empty-icon-float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}

.chat-empty-title {
  color: var(--text-primary);
  font-size: var(--font-size-lg);
  font-weight: 600;
  margin-bottom: 4px;
}

.chat-empty-subtitle {
  color: var(--text-muted);
  font-size: var(--font-size-sm);
}

.chat-empty-cta {
  color: var(--accent);
  font-size: var(--font-size-sm);
  margin-top: 16px;
  opacity: 0.7;
  animation: empty-cta-pulse 2s ease-in-out infinite;
}

@keyframes empty-cta-pulse {
  0%, 100% { opacity: 0.5; }
  50%      { opacity: 1; }
}

/* ── Messages ── */

.messages-area {
  padding: 16px var(--chat-rail-x) 8px;
  overscroll-behavior: contain;
}

.messages-area.messages-area-settling {
  visibility: hidden;
}

.message-list {
  padding: 0;
  display: flex;
  flex-direction: column;
}

/* Message Groups */
.message-group {
  margin-bottom: 2px;
}
.message-list > .message-group:last-child {
  margin-bottom: 0;
}
.message-group:not(.compact) {
  margin-top: 16px;
}

.message {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 6px 0;
  border-radius: var(--radius-md);
  position: relative;
  transition: background var(--transition-fast);
}

.message:hover {
  background: var(--bg-message-hover);
}

/* Compact spacing for related messages */
.compact .message {
  padding-top: 1px;
  padding-bottom: 1px;
}

/* Consecutive messages */
.consecutive .timestamp {
  display: none;
}
.message:hover .consecutive .timestamp,
.consecutive .message:hover .message-content::before {
  content: none;
}

.placeholder-avatar {
  background: transparent !important;
}

.placeholder-avatar .timestamp-hover {
  visibility: visible;
  opacity: 0;
  transition: opacity 0.1s;
}

.message-group.consecutive:hover .placeholder-avatar .timestamp-hover {
  opacity: 1;
}

/* ── Avatar ── */

.avatar-medium {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  position: relative;
}
.avatar-medium img {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  object-fit: cover;
}
.avatar-inner {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-text);
  flex-shrink: 0;
  text-transform: uppercase;
}
.avatar-agent .avatar-inner {
  font-size: 28px;
  line-height: 1;
  background: transparent;
}

.chat-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-text);
  flex-shrink: 0;
  text-transform: uppercase;
}

.chat-avatar-agent {
  font-size: 28px;
  line-height: 1;
  background: transparent;
}

.chat-avatar-sm {
  width: 24px;
  height: 24px;
  font-size: 11px;
}

.chat-avatar-sm.chat-avatar-agent {
  font-size: 20px;
}

.chat-avatar-xs {
  width: 18px;
  height: 18px;
  font-size: 9px;
}

.chat-avatar-xs.chat-avatar-agent {
  font-size: 16px;
}

/* ── Message body ── */

.message-content {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.message-content > * {
  min-width: 0;
}

.message-header {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
  line-height: 1.35;
  margin-bottom: 2px;
}

.username {
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
}
.identity-name-clickable {
  cursor: pointer;
}

.identity-name-clickable:hover {
  text-decoration: underline;
}

.identity-avatar-clickable {
  cursor: pointer;
}

.timestamp {
  color: var(--text-muted);
  font-size: var(--font-size-xs);
  flex-shrink: 0;
  white-space: nowrap;
}

.message-body {
  color: var(--text-primary);
  font-size: var(--font-size-base);
  line-height: var(--line-height);
  word-break: break-word;
  overflow-wrap: anywhere;
}

.chat-link {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s;
}

.chat-link:hover {
  border-bottom-color: var(--accent);
}

/* ── Link Previews ── */

.link-preview {
  display: flex;
  gap: 10px;
  margin-top: 6px;
  padding: 8px 10px;
  background: var(--bg-code);
  border: 1px solid var(--border-light);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-md);
  max-width: 450px;
  overflow: hidden;
  transition: border-color 0.2s, background 0.2s;
  cursor: pointer;
}

.link-preview:hover {
  border-color: var(--accent);
  background: var(--bg-sidebar);
}

.link-preview-img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}

.link-preview-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  overflow: hidden;
}

.link-preview-site {
  font-size: 10px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-weight: 600;
}

.link-preview-title {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-preview-desc {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Markdown ── */

.md-italic {
  font-style: italic;
}

.md-strike {
  text-decoration: line-through;
  opacity: 0.7;
}

.inline-code {
  background: var(--bg-code);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 0.88em;
  color: var(--accent);
}

.code-block {
  background: var(--bg-code);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 8px 16px;
  margin: 4px 0;
  overflow-x: auto;
  position: relative;
}

.code-block code {
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: var(--font-size-sm);
  color: var(--text-primary);
  white-space: pre;
}

.code-lang {
  position: absolute;
  top: 4px;
  right: 8px;
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  pointer-events: none;
  user-select: none;
}

/* Syntax highlighting */
.hl-kw { color: var(--accent); font-weight: 600; }
.hl-str { color: var(--hl-string); }
.hl-cmt { color: var(--text-muted); font-style: italic; }
.hl-num { color: var(--hl-number); }

/* ── Date dividers ── */

.date-divider {
  padding: 8px 16px;
  margin: 16px 0;
}

.date-divider-line {
  flex: 1;
  height: 1px;
  background: var(--border-light);
}

.date-divider-text {
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--date-divider-text);
  letter-spacing: 0.05em;
  white-space: nowrap;
  padding: 4px 12px;
  border: 1px solid var(--date-divider-line);
  border-radius: 20px;
  background: var(--date-divider-bg);
}

/* ── Edited tag ── */

.edited-tag {
  color: var(--text-muted);
  font-size: var(--font-size-xs);
  font-style: italic;
  cursor: help;
}
.msg-word-count {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Permalink highlight */
.permalink-highlight {
  animation: permalink-flash 2s ease;
}
@keyframes permalink-flash {
  0%, 30% { background: var(--accent-subtle); }
  100% { background: transparent; }
}

/* ── Edit mode ── */

.message-edit {
  gap: 2px;
}

.edit-input {
  font-size: var(--font-size-base) !important;
  padding: 4px 8px !important;
}

.edit-hint {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

/* ── Reactions ── */

.message-reactions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.reaction {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border: 1px solid var(--border-reaction);
  background: var(--bg-reaction);
  border-radius: 20px;
  font-size: var(--font-size-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.reaction:hover {
  background: var(--bg-reaction-active);
  border-color: var(--border-reaction-active);
}

.reaction.active {
  background: var(--bg-reaction-active);
  border-color: var(--border-reaction-active);
}

.reaction .count {
  font-size: var(--font-size-xs);
  font-weight: 500;
  color: var(--text-secondary);
}

.reaction {
  position: relative;
  overflow: visible;
}

.reaction-emoji {
  font-size: 14px;
  line-height: 1;
}

.reaction-count {
  font-size: 11px;
  font-weight: 600;
}

.reaction-detail-popup {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-main-alt);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 8px 10px;
  min-width: 140px;
  max-width: 200px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  z-index: 100;
  animation: reaction-detail-in 0.12s ease;
}

@keyframes reaction-detail-in {
  from { opacity: 0; transform: translateX(-50%) translateY(4px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.reaction-detail-popup::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--border-light);
}

.reaction-wrap:hover .reaction-detail-popup {
  display: block;
}

.reaction-detail-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 6px;
}

.reaction-detail-emoji {
  font-size: 18px;
}

.reaction-detail-count {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  font-weight: 600;
}

.reaction-detail-list {
  max-height: 120px;
  overflow-y: auto;
}

.reaction-detail-user {
  gap: 6px;
}

.reaction-detail-avatar {
  width: 18px;
  height: 18px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  color: var(--accent-text);
  flex-shrink: 0;
}

.reaction-detail-name {
  font-size: var(--font-size-xs);
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Message hover actions ── */

.message-actions {
  position: absolute;
  top: -12px;
  right: 8px;
  display: none;
  gap: 1px;
  background: var(--bg-main);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 2px;
  align-items: center;
  z-index: 2;
  max-width: none;
  overflow: visible;
  white-space: nowrap;
}

.message:hover > .message-actions,
.message:focus-within > .message-actions {
  display: flex;
}

.message-action-emoji,
.message-action-btn {
  background: none;
  border: none;
  cursor: pointer;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  transition: all var(--transition-fast);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
}

.message-action-emoji:hover,
.message-action-btn:hover {
  background: var(--bg-sidebar-hover);
  color: var(--text-primary);
}

.message-action-emoji {
  font-size: 15px;
}

.message-action-more-react {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-muted);
}

.message-action-more {
  font-size: 16px;
  letter-spacing: 1px;
  font-weight: 700;
  color: var(--text-muted);
}

/* ── Pinned messages ── */

.message.is-pinned {
  background: rgba(var(--accent-rgb), 0.04);
  border-left: 2px solid var(--accent);
  margin-left: -2px;
}

.message.is-pinned:hover {
  background: rgba(var(--accent-rgb), 0.06);
}

.pin-indicator {
  position: absolute;
  top: 2px;
  right: 8px;
  font-size: 10px;
  opacity: 0.5;
}

/* ── Reply reference (in message) ── */

.msg-reply-ref {
  padding: 2px 0;
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  border-left: 2px solid var(--border-light);
  padding-left: 8px;
  margin-bottom: 2px;
}

.msg-reply-icon {
  font-size: 10px;
  opacity: 0.6;
}

.msg-reply-sender {
  font-weight: 600;
  font-size: var(--font-size-xs);
  flex-shrink: 0;
}

.msg-reply-text {
  max-width: 300px;
}

/* ── Reply bar (above input) ── */

/* Selection bar */
.msg-selected {
  background: var(--accent-subtle) !important;
  border-left: 3px solid var(--accent);
}
.selection-bar {
  padding: 4px 16px;
  background: var(--accent-subtle);
  border-top: 1px solid var(--border-light);
}
.selection-bar-count {
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--accent);
  flex: 1;
}

.chat-reply-bar {
  padding: 4px 16px;
  border-top: 1px solid var(--border-light);
  border-left: 3px solid var(--accent);
  background: rgba(var(--accent-rgb), 0.05);
  font-size: var(--font-size-sm);
}

.chat-reply-bar-icon {
  color: var(--accent);
  font-size: 12px;
}

.chat-reply-bar-sender {
  font-weight: 600;
  font-size: var(--font-size-xs);
  flex-shrink: 0;
}

.chat-reply-bar-text {
  color: var(--text-secondary);
  font-size: var(--font-size-xs);
}

.chat-reply-bar-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 6px;
  font-size: 14px;
  border-radius: 3px;
  line-height: 1;
  transition: color 0.1s, background 0.1s;
  flex-shrink: 0;
}

.chat-reply-bar-close:hover {
  color: var(--text-primary);
  background: var(--bg-message-hover);
}

/* ── Typing indicator ── */

.typing-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  min-height: 24px;
  transition: opacity 0.2s;
}

.typing-indicator.hidden {
  opacity: 0;
  height: 0;
  min-height: 0;
  padding: 0;
  overflow: hidden;
}

.typing-dots {
  display: flex;
  gap: 3px;
  align-items: center;
  padding: 4px 0;
}

.typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--typing-dot);
  animation: typing-bounce 1.4s ease-in-out infinite;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing-bounce {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

.typing-text {
  color: var(--text-muted);
  font-size: var(--font-size-xs);
  font-style: italic;
}

.typing-avatars {
  display: flex;
  flex-shrink: 0;
}

.typing-avatar {
  width: 18px;
  height: 18px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  color: var(--accent-text);
  margin-right: -4px;
  border: 1.5px solid var(--bg-main);
  flex-shrink: 0;
}

.typing-avatar:last-child {
  margin-right: 0;
}

.typing-info {
  display: flex;
  align-items: baseline;
  gap: 4px;
  min-width: 0;
  overflow: hidden;
}

.typing-names {
  display: flex;
  gap: 4px;
  min-width: 0;
  overflow: hidden;
}

.typing-user-entry {
  display: inline-flex;
  align-items: baseline;
  gap: 3px;
  min-width: 0;
}

.typing-name {
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.typing-preview {
  color: var(--text-muted);
  font-size: 11px;
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

.typing-label {
  color: var(--text-muted);
  font-size: 11px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Input wrapper (positioning context for autocomplete popups) ── */

.message-input-area {
  position: relative;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0 var(--chat-rail-x) 12px;
}

/* ── Composer shell ── */

.input-container {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-input);
  border-radius: var(--radius-lg);
  background: var(--bg-input);
  flex-shrink: 0;
  transition: border-color var(--transition-base), box-shadow var(--transition-base);
  overflow: hidden;
}

.input-container:focus-within {
  border-color: var(--border-input-focus);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.12);
}

.composer-meta {
  display: flex;
  align-items: center;
  padding: 10px 10px 0;
}

.composer-mode-chip {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  color: var(--text-primary);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.composer-staging {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 14px 0;
}

.composer-upload-row {
  display: flex;
  align-items: center;
}

.composer-format-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 1px;
  padding: 4px 8px;
  border-bottom: 1px solid var(--border-subtle);
}

.composer-format-bar .btn-icon,
.composer-tools .btn-icon,
.composer-leading .btn-icon {
  width: 28px;
  height: 28px;
  font-size: var(--font-size-sm);
}

.composer-main {
  padding: 8px 14px;
}

.composer-editor {
  min-height: 24px;
  max-height: 160px;
  overflow-y: auto;
}

.composer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px;
}

.composer-tools {
  display: flex;
  align-items: center;
  gap: 1px;
  flex-wrap: wrap;
}

.message-textarea {
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  font-size: var(--font-size-base);
  line-height: var(--line-height);
  color: var(--text-primary);
  resize: none;
  font-family: inherit;
  min-height: 24px;
  padding: 0;
}

.message-textarea::placeholder {
  color: var(--text-muted);
}

/* ── Unified toolbar button ── */

.btn.btn-icon {
  background: none;
  border: none;
  color: var(--text-secondary);
  padding: 0;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 32px;
  height: 32px;
}

.btn.btn-icon:hover {
  color: var(--text-primary);
  background: var(--bg-sidebar-hover);
}

.btn.btn-icon:active {
  transform: scale(0.95);
}

.btn.btn-icon:disabled {
  opacity: 0.3;
  cursor: default;
}

.btn.btn-icon:disabled:hover {
  background: none;
  color: var(--text-muted);
}

.btn-inline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 36px;
  padding: 7px 12px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--bg-main-alt);
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
  font-family: inherit;
  line-height: 1.3;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}

.btn-inline:hover {
  background: var(--bg-sidebar-hover);
  color: var(--text-primary);
  border-color: var(--accent);
}

.btn-inline:disabled {
  opacity: 0.45;
  cursor: default;
}

.btn-inline:disabled:hover {
  background: var(--bg-main-alt);
  color: var(--text-secondary);
  border-color: var(--border-light);
}

.btn-inline-danger {
  color: var(--color-danger);
}

.btn-inline-danger:hover {
  background: color-mix(in srgb, var(--color-danger) 10%, transparent);
  color: var(--color-danger);
  border-color: color-mix(in srgb, var(--color-danger) 32%, var(--border-light));
}

.panel-back-btn {
  margin-left: auto;
}

i {
  display: block;
}

i.spin {
  animation: tb-spin 1s linear infinite;
}

@keyframes tb-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Recording state */

.btn.btn-icon.recording {
  color: var(--color-danger);
  animation: pulse-record 1s ease-in-out infinite;
}

@keyframes pulse-record {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.recording-icon {
  color: var(--color-danger);
}

/* Send button accent — always filled like Slack */

.send-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--radius-md);
  background: var(--send-bg);
  color: var(--accent-text);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: var(--font-size-sm);
}

.send-btn:hover:not(:disabled) {
  background: var(--send-bg-hover);
  transform: scale(1.05);
}

.send-btn:disabled {
  background: var(--send-disabled);
  color: var(--text-muted);
  cursor: not-allowed;
}

/* ── Scroll to bottom / new messages pill ── */

.scroll-bottom-btn {
  position: absolute;
  bottom: 16px;
  left: 50%;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: var(--bg-main);
  border: 1px solid var(--border-light);
  border-radius: 20px;
  cursor: pointer;
  color: var(--text-secondary);
  box-shadow: var(--shadow-md);
  z-index: 3;
  pointer-events: auto;
  opacity: 1;
  transform: translateX(-50%);
  transition: all var(--transition-base);
}

.scroll-bottom-btn.scroll-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.scroll-bottom-btn:hover {
  box-shadow: var(--shadow-lg);
  color: var(--text-primary);
}

.scroll-bottom-btn:active:not(:disabled) {
  transform: translateX(-50%);
}

.scroll-bottom-btn.has-new {
  background: var(--bg-main);
  color: var(--text-primary);
  border-color: var(--border-light);
  gap: 6px;
  box-shadow: var(--shadow-md);
}

.scroll-bottom-btn.has-new:hover {
  box-shadow: var(--shadow-lg);
}

.new-msg-count {
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  font-family: inherit;
  letter-spacing: 0.01em;
}

.scroll-arrow {
  flex-shrink: 0;
}

/* ── Sidebar rooms ── */

/* ── Sidebar group header with action ── */

.sidebar-collapse-btn {
  background: none;
  border: none;
  color: inherit;
  font: inherit;
  font-size: var(--font-size-xs);
  letter-spacing: 0.05em;
  color: var(--text-muted);
  cursor: pointer;
}

.sidebar-collapse-btn:hover {
  color: var(--text-secondary);
}

.sidebar-chevron {
  display: inline-block;
  font-size: 10px;
  transition: transform 0.15s ease;
  line-height: 1;
}

.sidebar-chevron.collapsed {
  transform: rotate(-90deg);
}

.create-room-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  font-weight: 600;
  line-height: 1;
  padding: 0 4px;
  border-radius: var(--radius-sm);
  transition: color 0.15s, background 0.15s;
}

.create-room-btn:hover {
  color: var(--accent);
  background: var(--bg-message-hover);
}

/* ── Create room modal ── */

.create-room-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  animation: fade-in 0.15s ease;
}

.create-room-modal {
  background: var(--bg-main-alt);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  width: 420px;
  max-width: 90vw;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4);
  animation: modal-slide-in 0.2s ease;
  display: flex;
  flex-direction: column;
}

@keyframes modal-slide-in {
  from { opacity: 0; transform: translateY(-16px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.create-room-modal-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-light);
}

.create-room-modal-title {
  font-weight: 600;
  font-size: var(--font-size-base);
  color: var(--text-primary);
}

.create-room-modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: color 0.15s, background 0.15s;
}

.create-room-modal-close:hover {
  color: var(--text-primary);
  background: var(--bg-sidebar);
}

.create-room-modal-body {
  padding: 24px;
}

.create-room-label {
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--text-muted);
}

.create-room-optional {
  color: var(--text-muted);
  font-weight: 400;
}

.create-room-desc-input {
  resize: vertical;
  min-height: 60px;
  font-family: var(--font-family);
}

.create-room-modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-light);
  flex-wrap: wrap;
}

/* ── DM items ── */

/* .dm-item-content — layout via Bootstrap utilities */

.dm-avatar-wrap {
  position: relative;
  flex-shrink: 0;
}

.dm-status-dot {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 2px solid var(--bg-sidebar);
}

.dm-status-online { background: var(--color-success); }
.dm-status-away { background: var(--color-warning); }
.dm-status-busy { background: var(--color-danger); }
.dm-status-offline { background: var(--text-secondary); opacity: 0.4; }

.sidebar-dm-header {
  margin-top: 24px !important;
}

/* ── Online users in sidebar ── */

.sidebar-online-header {
  margin-top: 24px !important;
}


.online-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-success);
  flex-shrink: 0;
}

.online-dot.status-online { background: var(--color-success); }
.online-dot.status-away { background: var(--color-warning); }
.online-dot.status-busy { background: var(--color-danger); }
.online-dot.status-bot {
  background: none;
  width: auto;
  height: auto;
  font-size: 10px;
  line-height: 1;
}


.status-select {
  background: var(--bg-code);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: var(--font-size-xs);
  padding: 2px 4px;
  cursor: pointer;
  outline: none;
  flex: 0 0 auto;
}

/* ── Sidebar footer ── */

/* Sidebar filter */
.sidebar-filter {
  padding: 0 8px 4px;
}
.sidebar-filter-input {
  width: 100%;
  background: var(--bg-main) !important;
  border: 1px solid var(--border-light) !important;
  font-size: var(--font-size-xs) !important;
  padding: 4px 8px !important;
}

.sidebar-footer {
  border-top: 1px solid var(--border-light);
  background: var(--bg-chrome);
  padding: 8px 12px;
}

.sidebar-footer-main {
  position: relative;
  min-width: 0;
  flex: 1 1 auto;
}

.sidebar-footer-identity {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.sidebar-status-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-width: 0;
  padding: 5px 6px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--bg-sidebar-hover) 72%, transparent);
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.sidebar-status-trigger:hover:not(:disabled),
.sidebar-status-trigger.is-open {
  background: color-mix(in srgb, var(--bg-sidebar-active) 84%, transparent);
  border-color: color-mix(in srgb, var(--border-light) 72%, transparent);
}

.sidebar-status-trigger:disabled {
  cursor: default;
  opacity: 0.6;
}

.sidebar-status-copy {
  min-width: 0;
}

.sidebar-status-name {
  font-size: var(--font-size-sm);
  font-weight: 600;
  line-height: 1.15;
}

.sidebar-status-text {
  color: var(--text-secondary);
  font-size: var(--font-size-xs);
  line-height: 1.2;
}

.sidebar-status-menu {
  position: absolute;
  left: 0;
  right: auto;
  bottom: calc(100% + 10px);
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 228px;
  max-width: min(260px, calc(100vw - 32px));
  padding: 8px;
  background: color-mix(in srgb, var(--bg-main-alt) 98%, transparent);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 20;
}

.sidebar-status-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 40px;
  padding: 10px 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
}

.sidebar-status-option:hover {
  background: var(--bg-sidebar-hover);
}

.sidebar-status-option.is-active {
  background: rgba(var(--accent-rgb), 0.1);
}

.sidebar-status-option-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.sidebar-status-option-label {
  font-size: var(--font-size-sm);
  font-weight: 500;
}

.sidebar-footer-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  padding: 2px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--bg-sidebar-hover) 58%, transparent);
}

.sidebar-footer-actions .btn.btn-icon {
  width: 26px;
  height: 26px;
}

.sidebar-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.sidebar-status-dot.online {
  background: var(--color-success);
}

.sidebar-status-dot.away {
  background: var(--color-warning);
}

.sidebar-status-dot.busy {
  background: var(--color-danger);
}

.sidebar-status-dot.offline {
  background: var(--text-muted);
}

.connection-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-danger);
  flex-shrink: 0;
  transition: background 0.3s;
}

.connection-dot.connected {
  background: var(--color-success);
}


.status-text {
  font-size: 11px;
  color: var(--text-muted);
}

/* ── Auth modal ── */

.auth-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100vw;
  height: 100vh;
  height: 100svh;
  padding: 24px 16px;
  background: var(--bg-main);
}

.auth-modal {
  width: min(420px, 100%);
  max-width: 420px;
  background: color-mix(in srgb, var(--bg-main-alt) 92%, transparent);
  border: 1px solid var(--border-light);
  border-radius: calc(var(--radius-lg) + 2px);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
  padding: 24px 24px 20px;
  backdrop-filter: blur(10px);
  animation: auth-bounce-in 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes auth-bounce-in {
  0%   { opacity: 0; transform: scale(0.9) translateY(20px); }
  60%  { opacity: 1; transform: scale(1.02) translateY(-4px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-logo {
  margin-bottom: 8px;
  line-height: 1;
  display: flex;
  justify-content: center;
}

.modal-logo-img {
  width: 72px;
  height: 72px;
  object-fit: contain;
}

.auth-modal-header {
  font-size: clamp(1.4rem, 1.1rem + 1vw, 1.9rem);
  font-weight: 700;
  color: var(--text-primary);
  text-align: center;
  line-height: 1.1;
  margin-bottom: 8px;
}

.auth-subtitle {
  margin: 0 0 12px;
  color: var(--text-secondary);
  text-align: center;
  font-size: var(--font-size-sm);
}

.auth-status {
  margin: 0 0 12px;
  padding: 10px 12px;
  text-align: center;
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
  border-radius: var(--radius-md);
  background: var(--bg-code);
  border: 1px solid var(--border-light);
}

.sidebar-logo {
  width: 24px;
  height: 24px;
  object-fit: contain;
  margin-right: 6px;
  vertical-align: middle;
}

.auth-tabs {
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 24px;
  gap: 4px;
}

.auth-tab {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: var(--font-size-sm);
  font-weight: 500;
  padding: 8px 16px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.auth-tab:hover {
  color: var(--text-primary);
  background: var(--bg-message-hover);
}

.auth-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.auth-form {
  text-align: left;
}

.auth-form .form-control {
  font-size: var(--font-size-base) !important;
  padding: 12px 16px !important;
  border-radius: var(--radius-lg) !important;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.auth-form .btn-primary {
  padding: 12px 24px !important;
  font-size: var(--font-size-base) !important;
  border-radius: var(--radius-lg) !important;
  transition: transform 0.15s, box-shadow 0.15s;
}

.auth-form .btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(var(--accent-rgb), 0.3);
}

.auth-form .btn-primary:active {
  transform: translateY(0);
}

.auth-error {
  color: var(--color-danger);
  font-size: var(--font-size-xs);
  text-align: center;
  min-height: 18px;
}

.auth-error.hidden {
  visibility: hidden;
}

.auth-modal-footer {
  margin-top: 8px;
}

.auth-modal-footer .btn {
  width: 100%;
}

/* ── Sidebar logout ── */

.sidebar-logout-btn {
  flex-shrink: 0;
  color: var(--text-muted) !important;
  opacity: 0.7;
  transition: opacity 0.15s, color 0.15s !important;
}

.sidebar-logout-btn:hover {
  opacity: 1;
  color: var(--color-danger) !important;
}

/* ── Emoji Picker ── */

.emoji-picker-backdrop {
  position: fixed;
  inset: 0;
  z-index: 999;
}

.emoji-picker-centered {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1000;
}

.emoji-picker-centered .emoji-picker {
  position: static;
  margin-bottom: 0;
}

.emoji-picker {
  position: absolute;
  bottom: 100%;
  left: 0;
  margin-bottom: 8px;
  width: 320px;
  max-height: 360px;
  background: var(--bg-sidebar);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  z-index: 1000;
  animation: emoji-in 0.15s ease-out;
}

@keyframes emoji-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.emoji-picker-search {
  padding: 8px;
  border-bottom: 1px solid var(--border-light);
}

.emoji-picker-input {
  width: 100%;
  border: 1px solid var(--border-light);
  background: var(--bg-code);
  color: var(--text-primary);
  font-size: var(--font-size-sm);
  padding: 4px 8px;
  border-radius: var(--radius-md);
  outline: none;
  font-family: inherit;
  box-sizing: border-box;
}

.emoji-picker-input::placeholder {
  color: var(--text-muted);
}

.emoji-picker-grid {
  overflow-y: auto;
  padding: 4px 8px;
  flex: 1;
}

.emoji-cat-header {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  padding: 4px 0;
  margin-top: 4px;
}

.emoji-cat-header:first-child {
  margin-top: 0;
}

.emoji-cat-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
}

.emoji-item {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  font-size: 20px;
  line-height: 1;
  border-radius: var(--radius-md);
  transition: background 0.1s;
  text-align: center;
}

.emoji-item:hover {
  background: var(--bg-message-hover);
}

.emoji-empty {
  padding: 24px;
  color: var(--text-muted);
  font-size: var(--font-size-sm);
}

/* ── Audio player in messages ── */

.msg-audio-icon {
  font-size: 16px;
  flex-shrink: 0;
}

.msg-audio-player {
  height: 32px;
  max-width: 300px;
  border-radius: var(--radius-md);
}

/* ── Attachments in messages ── */

.msg-attachments {
  gap: 6px;
  margin-top: 4px;
}

.msg-attachment-image {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.msg-attachment-image img {
  max-width: 400px;
  max-height: 300px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  cursor: pointer;
  object-fit: contain;
}

.msg-attachment-image img:hover {
  border-color: var(--accent);
}

.msg-attachment-meta {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

.attachment-card {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg-code);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  transition: border-color 0.15s;
}

.attachment-card:hover {
  border-color: var(--accent);
}

.attachment-icon {
  font-size: 20px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.attachment-info {
  flex: 1;
  min-width: 0;
}

.attachment-name {
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.attachment-card .btn-icon {
  color: var(--text-muted);
  padding: 4px;
  text-decoration: none;
}
.attachment-card .btn-icon:hover {
  color: var(--accent);
}

.msg-file-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--bg-code);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  text-decoration: none;
  font-size: var(--font-size-sm);
  transition: border-color 0.15s;
}

.msg-file-link:hover {
  border-color: var(--accent);
}

.msg-file-icon {
  font-size: 16px;
}

.msg-file-name {
  font-weight: 500;
}

.msg-file-size {
  color: var(--text-muted);
  font-size: var(--font-size-xs);
}

/* ── Pending attachments bar ── */

.pending-attachments {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  overflow: visible;
  box-shadow: none;
}

.pending-attachment {
  gap: 6px;
  padding: 5px 9px;
  background: color-mix(in srgb, var(--bg-main-alt) 82%, transparent);
  border: 1px solid color-mix(in srgb, var(--border-light) 78%, transparent);
  border-radius: 999px;
  font-size: var(--font-size-xs);
  white-space: nowrap;
}

.upload-progress-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  font-weight: 500;
  white-space: nowrap;
  background: linear-gradient(90deg,
    var(--bg-main-alt) 25%,
    var(--accent-subtle) 50%,
    var(--bg-main-alt) 75%);
  background-size: 200% 100%;
  animation: upload-shimmer 1.5s ease-in-out infinite;
  border: 1px solid color-mix(in srgb, var(--accent) 20%, var(--border-light));
}

@keyframes upload-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.pending-thumb {
  width: 32px;
  height: 32px;
  object-fit: cover;
  border-radius: 4px;
}

.pending-file-icon {
  font-size: 16px;
}

.pending-name {
  color: var(--text-primary);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pending-size {
  color: var(--text-muted);
}

.pending-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 2px;
  font-size: 14px;
  line-height: 1;
}

.pending-remove:hover {
  color: var(--color-danger);
}

/* ── Command Palette ── */

.cmd-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  justify-content: center;
  padding: max(24px, env(safe-area-inset-top, 0px)) 16px 24px;
  animation: cmd-overlay-in 0.15s ease-out;
}

@keyframes cmd-overlay-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.cmd-palette {
  width: 520px;
  max-height: min(540px, calc(100vh - 48px));
  background: var(--bg-main-alt);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4);
  overflow: hidden;
  animation: cmd-in 0.15s ease-out;
  align-self: flex-start;
  display: flex;
  flex-direction: column;
}

@keyframes cmd-in {
  from {
    opacity: 0;
    transform: scale(0.98) translateY(-4px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.cmd-header {
  padding: 8px 16px;
  border-bottom: 1px solid var(--border-light);
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--bg-main-alt);
}

.cmd-search-icon {
  flex-shrink: 0;
  color: var(--text-muted);
}

.cmd-input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: var(--font-size-base);
  outline: none;
  font-family: inherit;
  min-width: 0;
}

.cmd-input::placeholder {
  color: var(--text-muted);
}

.cmd-kbd {
  flex-shrink: 0;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border-light);
  background: var(--bg-code);
  color: var(--text-muted);
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  line-height: 1.4;
}

.cmd-results {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 0;
  overscroll-behavior: contain;
}

.cmd-item {
  padding: 4px 16px;
  cursor: pointer;
  transition: background 0.1s;
  min-width: 0;
}

.cmd-item:hover,
.cmd-item-active {
  background: var(--bg-message-hover);
}

.cmd-item-icon {
  width: 20px;
  text-align: center;
  font-weight: 600;
  color: var(--text-muted);
  flex-shrink: 0;
  font-size: var(--font-size-sm);
}

.cmd-item-name {
  font-size: var(--font-size-sm);
  color: var(--text-primary);
  font-weight: 500;
  flex: 1;
  min-width: 0;
}

.cmd-item-desc {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  margin-left: auto;
  max-width: 200px;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cmd-item-badge {
  flex-shrink: 0;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border-light);
  background: var(--bg-code);
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.cmd-empty {
  padding: 24px 16px;
  color: var(--text-muted);
  font-size: var(--font-size-sm);
}

/* ── Mobile ── */

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 14;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--transition-slow), visibility var(--transition-slow);
}

@media (max-width: 991.98px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-100%);
    z-index: 15;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.show {
    transform: translateX(0);
  }
  .sidebar-overlay.show {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    backdrop-filter: blur(2px);
  }
  .chat-main {
    margin-left: 0 !important;
  }
  .cmd-palette {
    width: calc(100% - 2 * 16px);
  }
}

/* ── Search Panel ── */

.search-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  padding: max(24px, env(safe-area-inset-top, 0px)) 16px 24px;
  backdrop-filter: blur(4px);
}

.search-panel {
  width: min(560px, 90vw);
  max-height: min(78vh, 720px);
  background: var(--bg-main-alt);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.3);
  align-self: flex-start;
  animation: panel-drop 0.2s ease;
  display: flex;
  flex-direction: column;
}

@keyframes panel-drop {
  from { opacity: 0; transform: translateY(-8px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.search-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg-main-alt);
}

.search-icon {
  flex-shrink: 0;
  opacity: 0.5;
}

.search-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: var(--font-size-base);
  font-family: inherit;
}

.search-input::placeholder {
  color: var(--text-muted);
}

.search-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 18px;
  padding: 0 4px;
  line-height: 1;
}

.search-close:hover {
  color: var(--text-primary);
}

.search-results {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  overscroll-behavior: contain;
}

.search-empty {
  padding: 24px 16px;
  color: var(--text-muted);
  font-size: var(--font-size-sm);
}

.search-result {
  display: block;
  width: 100%;
  text-align: left;
  padding: 12px 16px;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  color: var(--text-primary);
  font-family: inherit;
  font-size: var(--font-size-sm);
  transition: background 0.1s;
}

.search-result:hover,
.search-result-selected {
  background: var(--bg-message-hover);
}

.search-result:last-child {
  border-bottom: none;
}

.search-result-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin-bottom: 4px;
  min-width: 0;
}

.search-result-sender {
  font-size: var(--font-size-sm);
}

.search-result-room {
  color: var(--text-muted);
  font-size: var(--font-size-xs);
  min-width: 0;
}

.search-result-time {
  margin-left: auto;
  color: var(--text-muted);
  font-size: var(--font-size-xs);
  white-space: nowrap;
}

.search-result-content {
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
  line-height: 1.45;
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.search-match {
  background: rgba(var(--accent-rgb), 0.25);
  color: var(--accent);
  border-radius: 2px;
  padding: 0 1px;
}

.search-filter-chips {
  padding: 8px 16px 0;
  background: var(--bg-main-alt);
}

.search-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: rgba(var(--accent-rgb), 0.15);
  border-radius: 12px;
  padding: 2px 6px 2px 8px;
  font-size: 11px;
}

.search-filter-key {
  color: var(--accent);
  font-weight: 600;
}

.search-filter-val {
  color: var(--text-primary);
}

.search-filter-remove {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 10px;
  cursor: pointer;
  padding: 0 2px;
  border-radius: 50%;
  line-height: 1;
}

.search-filter-remove:hover {
  color: var(--text-primary);
  background: var(--bg-message-hover);
}

.search-quick-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 16px 10px;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-main-alt);
}

.search-quick-btn {
  background: none;
  border: 1px solid var(--border-light);
  border-radius: 12px;
  color: var(--text-secondary);
  font-size: 11px;
  padding: 3px 10px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  font-family: inherit;
}

.search-quick-btn:hover {
  background: var(--bg-message-hover);
  color: var(--text-primary);
  border-color: var(--accent);
}

.search-result-count {
  padding: 6px 16px;
  font-size: 11px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-main-alt);
}

.search-result-badges {
  display: flex;
  gap: 6px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.search-result-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border-light);
  background: var(--bg-code);
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.search-empty-title {
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.search-empty-hint {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  font-family: monospace;
}

/* ── Saved Items ── */

.bookmarks-main-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bookmarks-empty {
  padding: 32px 16px;
  color: var(--text-muted);
}

.bookmarks-empty-hint {
  font-size: var(--font-size-xs);
  margin-top: 4px;
}

.bookmark-actions {
  flex-wrap: wrap;
  margin-top: 8px;
}

.bookmark-item {
  padding: 14px 16px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  background: var(--bg-main);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bookmark-item:hover {
  border-color: var(--accent);
}

.bookmark-item-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 8px;
  margin-bottom: 0;
}

.bookmark-sender {
  font-size: var(--font-size-sm);
}

.bookmark-room {
  color: var(--text-muted);
  font-size: var(--font-size-xs);
}

.bookmark-time {
  margin-left: auto;
  color: var(--text-muted);
  font-size: var(--font-size-xs);
  white-space: nowrap;
}

.bookmark-content {
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
  line-height: 1.5;
  margin-bottom: 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.bookmark-jump,
.bookmark-remove {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: var(--font-size-xs);
  padding: 4px 8px;
  border-radius: var(--radius-md);
  transition: all 0.1s;
}

.bookmark-jump {
  color: var(--accent);
  background: rgba(var(--accent-rgb), 0.08);
}

.bookmark-jump:hover {
  background: rgba(var(--accent-rgb), 0.1);
}

.bookmark-remove {
  color: var(--text-muted);
  background: var(--bg-sidebar);
}

.bookmark-remove:hover {
  color: var(--color-danger);
  background: color-mix(in srgb, var(--color-danger) 10%, transparent);
}

/* ── Role badges ── */

.badge-role {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--accent-subtle);
  color: var(--accent);
}


.chat-empty-content {
  max-width: 420px;
}

/* ── Mentions ── */

.mention {
  background: var(--mention-bg);
  color: var(--mention-text);
  padding: 1px 4px;
  border-radius: 4px;
  font-weight: 500;
}
.mention:hover {
  background: var(--mention-bg);
  color: var(--mention-text);
}

/* ── Mention Autocomplete ── */

.mention-autocomplete {
  display: flex;
  flex-direction: column;
  background: var(--bg-main-alt);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 4px 0;
  margin: 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  max-height: 200px;
  overflow-y: auto;
  flex-shrink: 0;
  width: 100%;
}

.mention-item {
  padding: 6px 16px;
  background: none;
  border: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: var(--font-size-sm);
  cursor: pointer;
  text-align: left;
  transition: background 0.1s;
}

.room-autocomplete-hash {
  font-weight: 600;
  color: var(--accent);
  font-size: 14px;
}

.mention-item:hover,
.mention-item-active {
  background: var(--bg-message-hover);
}

.mention-avatar-wrap {
  position: relative;
  flex-shrink: 0;
}

.mention-presence {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1.5px solid var(--bg-main-alt);
}

.mention-special-icon {
  width: 20px;
  height: 20px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--bg-main);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

.mention-bot-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.mention-item-info {
  gap: 1px;
}

.mention-item-name {
  font-size: var(--font-size-sm);
  color: var(--accent);
}

.mention-item-desc {
  font-size: 11px;
  color: var(--text-secondary);
}

/* ── Shortcuts Panel ── */

.shortcuts-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  justify-content: center;
  padding: max(24px, env(safe-area-inset-top, 0px)) 16px 24px;
}

.shortcuts-panel {
  width: min(480px, 90vw);
  max-height: min(78vh, 700px);
  background: var(--bg-main-alt);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.3);
  align-self: flex-start;
  display: flex;
  flex-direction: column;
}

.shortcuts-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-light);
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--bg-main-alt);
}

.shortcuts-title {
  font-size: var(--font-size-base);
}

.shortcuts-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 18px;
  padding: 0 4px;
  line-height: 1;
}

.shortcuts-close:hover {
  color: var(--text-primary);
}

.shortcuts-body {
  overflow-y: auto;
  padding: 16px;
  min-height: 0;
  overscroll-behavior: contain;
}

.shortcut-section {
  margin-bottom: 16px;
}

.shortcut-section:last-child {
  margin-bottom: 0;
}

.shortcut-section-title {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.shortcut-row {
  padding: 5px 0;
}

.shortcut-keys {
  flex-wrap: wrap;
  min-width: 0;
}

.shortcut-kbd {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 4px;
  border: 1px solid var(--border-light);
  background: var(--bg-code);
  color: var(--text-secondary);
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.4;
  min-width: 20px;
  text-align: center;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

.shortcut-desc {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

/* ── Profile modal ── */

.profile-overlay {
  position: fixed;
  inset: 0;
  z-index: 250;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  padding: 16px;
}

.profile-modal {
  --profile-accent: var(--accent);
  width: min(420px, 92vw);
  max-height: min(80vh, 760px);
  background: var(--bg-main-alt);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4);
  animation: cmd-in 0.15s ease-out;
  display: flex;
  flex-direction: column;
}

.profile-header {
  padding: 24px 16px 16px;
  border-top: 3px solid var(--profile-accent);
}

.profile-avatar {
  position: relative;
  overflow: hidden;
  width: 56px;
  height: 56px;
  border-radius: var(--radius-lg);
  font-size: 22px;
  color: var(--accent-text);
}

.profile-display-name {
  font-size: var(--font-size-lg);
  color: var(--text-primary);
}

.profile-username {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
}

.profile-close {
  position: absolute;
  top: 8px;
  right: 8px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  padding: 4px 8px;
  border-radius: var(--radius-md);
  transition: color 0.15s, background 0.15s;
}

.profile-close:hover {
  color: var(--text-primary);
  background: var(--bg-message-hover);
}

.profile-body {
  padding: 16px;
  border-top: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  min-height: 0;
}

.profile-names {
  flex: 1;
  min-width: 0;
  gap: 2px;
}

.profile-bio {
  font-size: var(--font-size-sm);
  color: var(--text-primary);
  line-height: 1.5;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.profile-bio-empty {
  color: var(--text-muted);
  font-style: italic;
}

.profile-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.profile-section-title {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.profile-meta {
  font-size: var(--font-size-xs);
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--bg-main);
}

.profile-meta-label {
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.profile-meta-value {
  color: var(--text-secondary);
}

.profile-edit-form {
  padding: 16px;
  border-top: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  min-height: 0;
}

.profile-actions,
.profile-edit-actions {
  flex-wrap: wrap;
  margin-top: 0;
}

.profile-action-btn {
  flex: 1 1 140px;
  justify-content: center;
}

.profile-action-btn-primary {
  min-height: 36px;
}

.profile-textarea {
  resize: vertical;
  min-height: 96px;
}

/* ── History loading ── */

.history-loading {
  padding: 8px 16px;
}

.history-loading-text {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  background: var(--bg-main-alt);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 4px 14px;
  display: inline-block;
}

.readonly-notice {
  padding: 8px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: var(--font-size-xs);
  border-top: 1px solid var(--border-light);
  background: var(--bg-code);
  flex-shrink: 0;
}

/* ── Content area (chat + room info side panel) ── */

.chat-container .chat-container {
  flex: 1;
  min-width: 0;
}

/* ── Lightbox ── */

.lightbox-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.9);
  cursor: zoom-out;
  animation: lightbox-in 0.15s ease;
}
.lightbox-toolbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.6);
  z-index: 10000;
}
.lightbox-filename {
  color: rgba(255, 255, 255, 0.7);
  font-size: var(--font-size-sm);
  flex: 1;
}
.lightbox-download {
  color: rgba(255, 255, 255, 0.8);
  text-decoration: none;
  font-size: var(--font-size-sm);
  padding: 4px 12px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: var(--radius-md);
  transition: all 0.15s;
}
.lightbox-download:hover {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

@keyframes lightbox-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.lightbox-img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: var(--radius-md);
  cursor: default;
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.5);
}

.lightbox-close {
  position: fixed;
  top: 16px;
  right: 16px;
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: var(--accent-text);
  font-size: 20px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.15s;
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* ── Thread navigation ── */

.msg-reply-clickable {
  cursor: pointer;
  transition: background 0.15s;
  border-radius: var(--radius-md);
}

.msg-reply-clickable:hover {
  background: var(--bg-message-hover);
}

@keyframes msg-highlight-flash {
  0% { background: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
  100% { background: transparent; box-shadow: none; }
}

.msg-highlight {
  animation: msg-highlight-flash 1.5s ease-out;
}


@keyframes thread-glow {
  0% { background: rgba(var(--accent-rgb), 0.15); }
  100% { background: transparent; }
}

/* ── Thread Panel ── */

.thread-panel {
  height: 100%;
  background: var(--bg-main);
  border-left: 1px solid var(--border-light);
  animation: panel-slide-right 0.2s ease;
}

.thread-panel-maximized {
  min-width: 0;
  border-left: none;
}

.thread-resize-handle {
  width: 4px;
  cursor: col-resize;
  background: transparent;
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 10;
  transition: background 0.15s;
}
.thread-resize-handle:hover,
.thread-resize-handle.resizing {
  background: var(--accent);
}
.thread-panel-header {
  padding: 8px 16px;
  border-bottom: 1px solid var(--border-light);
}

.thread-panel-title {
  font-size: var(--font-size-base);
}

.thread-panel-icon {
  font-size: 16px;
}

.thread-panel-count {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  font-weight: 400;
}

.thread-panel-actions {
  flex-shrink: 0;
}

.thread-panel-action,
.thread-panel-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 16px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--radius-md);
  transition: background 0.15s, color 0.15s;
}

.thread-panel-action:hover,
.thread-panel-close:hover {
  background: var(--bg-message-hover);
  color: var(--text-primary);
}

.thread-panel-messages {
  overflow-y: auto;
  padding: 16px;
}

/* Thread messages reuse .message / .message-content / .message-header / .message-body */
.thread-panel-messages .message {
  animation: none;
}

.thread-divider {
  padding: 8px 0;
}

.thread-divider-line {
  flex: 1;
  height: 1px;
  background: var(--border-light);
}

.thread-divider-text {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.thread-input-area {
  border-top: 1px solid var(--border-light);
}

.thread-msg-textarea {
  min-height: 28px;
}

/* Thread messages inherit .message hover actions */

.thread-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.thread-loading-text {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

/* ── Thread preview block (inline in message list) ── */

.thread-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  padding: 4px 8px;
  background: var(--bg-thread);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  max-width: min(100%, 560px);
}

.thread-indicator:hover {
  background: var(--bg-sidebar-hover);
}

.thread-count {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--thread-text);
  white-space: nowrap;
}

.thread-count-icon {
  font-size: 0.9rem;
  line-height: 1;
}

.thread-snippet {
  flex: 1;
  min-width: 0;
  color: var(--text-secondary);
}

.thread-sender {
  font-weight: 600;
  margin-right: 4px;
}

.thread-text {
  color: var(--text-secondary);
}

.thread-last {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  flex-shrink: 0;
  white-space: nowrap;
}

.thread-unread {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

/* ── Message group collapse ── */

.msg-group-collapse {
  display: flex;
  align-items: center;
  padding: 2px 0 2px 52px;
}

.msg-group-collapse-btn {
  background: none;
  border: 1px solid var(--border-light);
  color: var(--text-muted);
  cursor: pointer;
  font-size: var(--font-size-xs);
  padding: 2px 10px;
  border-radius: 999px;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.msg-group-collapse-btn:hover {
  color: var(--accent);
  background: var(--bg-sidebar);
  border-color: var(--accent);
}

.collapsed-msg-hidden {
  display: none;
}

/* ── Room info panel ── */

.room-info-panel {
  width: 280px;
  min-width: 280px;
  border-left: 1px solid var(--border-light);
  background: var(--bg-main);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  animation: room-info-slide 0.15s ease;
}

.room-info-panel-dm {
  background:
    linear-gradient(
      180deg,
      color-mix(in srgb, var(--bg-main-alt) 78%, transparent),
      var(--bg-main) 220px
    );
}

@keyframes room-info-slide {
  from { opacity: 0; transform: translateX(10px); }
  to { opacity: 1; transform: translateX(0); }
}

.room-info-header {
  padding: 16px;
  border-bottom: 1px solid var(--border-light);
}

.dm-profile-hero {
  padding: 22px 16px 18px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.dm-profile-identity {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.dm-profile-avatar {
  position: relative;
  overflow: hidden;
  width: 64px;
  height: 64px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: var(--accent-text);
  background: var(--accent-subtle);
  flex-shrink: 0;
}

.dm-profile-avatar-bot {
  background:
    linear-gradient(180deg, rgba(39, 174, 96, 0.18), rgba(39, 174, 96, 0.08)),
    var(--bg-main-alt);
  color: #256947;
}

.dm-profile-avatar-agent {
  background:
    linear-gradient(180deg, rgba(52, 152, 219, 0.18), rgba(52, 152, 219, 0.08)),
    var(--bg-main-alt);
  color: #2b6f9c;
}

.dm-profile-avatar-dm {
  background:
    linear-gradient(180deg, rgba(var(--accent-rgb), 0.16), rgba(var(--accent-rgb), 0.06)),
    var(--bg-main-alt);
  color: var(--accent);
}

.dm-profile-avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.dm-profile-names {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dm-profile-name-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.dm-profile-name {
  font-size: var(--font-size-lg);
  line-height: 1.2;
  color: var(--text-primary);
  font-weight: 700;
}

.dm-profile-handle {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
}

.dm-profile-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 22px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.dm-profile-badge-self {
  background: rgba(var(--accent-rgb), 0.14);
  color: var(--accent);
}

.dm-profile-badge-user {
  background: var(--bg-main-alt);
  color: var(--text-secondary);
}

.dm-profile-badge-bot {
  background: rgba(39, 174, 96, 0.14);
  color: #2e8b57;
}

.dm-profile-badge-agent {
  background: rgba(52, 152, 219, 0.14);
  color: #2f7fb2;
}

.dm-profile-status-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.dm-profile-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dm-profile-status-label {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

.dm-profile-detail-text {
  margin: 0;
  font-size: var(--font-size-xs);
  line-height: 1.5;
  color: var(--text-muted);
}

.room-info-title {
  font-size: var(--font-size-sm);
  color: var(--text-primary);
}

.room-info-subtitle {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

.room-info-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  padding: 2px 6px;
  border-radius: var(--radius-md);
  transition: all 0.15s;
}

.room-info-close:hover {
  color: var(--text-primary);
  background: var(--bg-message-hover);
}

.room-info-section {
  padding: 16px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dm-profile-section {
  gap: 14px;
}

.dm-profile-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.dm-profile-bio {
  font-size: var(--font-size-sm);
  line-height: 1.6;
  color: var(--text-primary);
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.dm-profile-bio-empty {
  color: var(--text-muted);
  font-style: italic;
}

.dm-profile-meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.dm-profile-meta-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--bg-main-alt) 72%, transparent);
  min-width: 0;
}

.dm-profile-meta-card-wide {
  grid-column: 1 / -1;
}

.dm-profile-meta-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.dm-profile-meta-value {
  font-size: var(--font-size-sm);
  color: var(--text-primary);
  line-height: 1.45;
  word-break: break-word;
}

.dm-profile-code {
  display: block;
  font-size: 11px;
  line-height: 1.45;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
}

.dm-profile-code-break {
  word-break: break-all;
}

.dm-profile-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dm-profile-edit-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dm-profile-edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.dm-profile-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.dm-profile-field-label,
.dm-profile-section-title {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.dm-profile-chip-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dm-profile-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.dm-profile-chip {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--bg-main-alt);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  font-size: var(--font-size-xs);
  line-height: 1.3;
}

.room-info-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.room-info-label {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.room-info-desc {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  margin: 0;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.room-info-desc-empty {
  color: var(--text-muted);
  font-style: italic;
}

.room-info-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.room-info-desc-btn {
  width: 100%;
  padding: 10px 12px;
  border: 1px dashed var(--border-light);
  border-radius: var(--radius-md);
  background: var(--bg-main-alt);
  color: var(--text-secondary);
  font: inherit;
  line-height: 1.5;
  text-align: left;
  white-space: pre-wrap;
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}

.room-info-desc-btn:hover {
  background: var(--bg-message-hover);
  border-color: var(--accent);
  color: var(--text-primary);
}

.room-info-desc-input {
  resize: vertical;
  min-height: 88px;
}

.room-info-edit-actions {
  justify-content: flex-end;
  flex-wrap: wrap;
}

.room-info-actions {
  margin-top: 4px;
}

.room-info-action-btn {
  width: 100%;
  justify-content: flex-start;
}

.notification-section-copy {
  margin-bottom: 14px;
}

.notification-mode-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.notification-mode-card {
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  background: var(--bg-main-alt);
  padding: 14px 15px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color var(--transition-fast), background var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
}

.notification-mode-card:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border-light));
  background: color-mix(in srgb, var(--accent-subtle) 35%, var(--bg-main-alt));
}

.notification-mode-card.active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent-subtle) 65%, var(--bg-main-alt));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 30%, transparent);
}

.notification-mode-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.notification-mode-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-primary);
}

.notification-mode-indicator {
  width: 20px;
  height: 20px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--text-muted) 45%, var(--border-light));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  background: transparent;
  flex-shrink: 0;
  transition: border-color var(--transition-fast), background var(--transition-fast), color var(--transition-fast);
}

.notification-mode-card.active .notification-mode-indicator {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-text);
}

.notification-mode-copy {
  font-size: var(--font-size-xs);
  line-height: 1.45;
  color: var(--text-secondary);
  padding-left: 28px;
  max-width: 54ch;
}

.notification-toggle-list {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.notification-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--bg-main-alt);
  border: 1px solid var(--border-light);
}

.notification-toggle-copy-block {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.notification-toggle-title {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-primary);
}

.notification-toggle-copy {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  line-height: 1.4;
}

.notification-toggle-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.room-info-pinned-msg {
  padding: 4px 0;
  border-bottom: 1px solid var(--border-light);
}

.room-info-pinned-msg:last-child {
  border-bottom: none;
}

.room-info-pinned-header {
  margin-bottom: 2px;
}

.room-info-pinned-header span:first-child {
  font-size: var(--font-size-xs);
  font-weight: 600;
}

.room-info-pinned-time {
  font-size: 10px;
  color: var(--text-muted);
}

.room-info-pinned-text {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  margin: 0;
  line-height: 1.4;
}

.room-info-member {
  padding: 4px 0;
  font-size: var(--font-size-sm);
  color: var(--text-primary);
  border-radius: var(--radius-md);
}

.room-info-member-clickable {
  cursor: pointer;
}

.room-info-member-clickable:hover {
  background: var(--bg-message-hover);
}

.room-info-member-name {
  flex: 1;
  min-width: 0;
}

.room-info-role-badge {
  font-size: 12px;
}

.room-info-avatar-wrap {
  width: 24px;
  height: 24px;
}

.room-info-danger-btn {
  color: var(--color-danger);
}

.room-info-danger-btn:hover {
  background: color-mix(in srgb, var(--color-danger) 10%, transparent);
  color: var(--color-danger);
}

/* Presence indicators */
.presence-dot {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 2px solid var(--bg-main-alt);
}
.presence-online { background: var(--color-success); }
.presence-away { background: var(--color-warning); }
.presence-busy { background: var(--color-danger); }

.role-select {
  font-size: 10px;
  padding: 1px 4px;
  background: var(--bg-main-alt);
  color: var(--text-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  cursor: pointer;
  flex-shrink: 0;
  margin-left: auto;
}
.role-select:hover {
  border-color: var(--accent);
}

@media (max-width: 991.98px) {
  .room-info-panel {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: 200;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.3);
  }
}


.status-text-input {
  flex: 1 1 100%;
  font-size: 11px !important;
  padding: 3px 6px !important;
  opacity: 0.7;
  transition: opacity 0.15s;
}

.status-text-input:focus {
  opacity: 1;
}

/* ── GIF Picker ── */

.gif-picker-backdrop {
  position: fixed;
  inset: 0;
  z-index: 999;
}

.gif-picker {
  position: absolute;
  bottom: 100%;
  left: 0;
  width: 340px;
  max-height: 420px;
  background: var(--bg-sidebar);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  margin-bottom: 8px;
  animation: gif-picker-in 0.15s ease;
}

@keyframes gif-picker-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.gif-picker-header {
  padding: 8px;
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}

.gif-search-input {
  width: 100%;
}

.gif-picker-grid {
  flex: 1;
  overflow-y: auto;
  padding: 4px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
  min-height: 200px;
}

.gif-item {
  width: 100%;
  height: auto;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: transform 0.1s, opacity 0.1s;
  object-fit: cover;
  aspect-ratio: 16/9;
}

.gif-item:hover {
  transform: scale(1.03);
  opacity: 0.9;
}

.gif-loading, .gif-empty {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: var(--text-muted);
  font-size: var(--font-size-sm);
}

.gif-picker-footer {
  padding: 4px 8px;
  border-top: 1px solid var(--border-light);
  flex-shrink: 0;
}

.gif-powered-by {
  font-size: 10px;
  color: var(--text-muted);
}

/* ── Inline images in messages ── */

.msg-inline-image {
  margin: 4px 0;
}

.msg-inline-image img {
  max-width: 320px;
  max-height: 240px;
  border-radius: var(--radius-md);
  display: block;
}

/* ── Spoiler text ── */

.md-spoiler {
  background: var(--text-muted);
  color: transparent;
  border-radius: 3px;
  padding: 0 4px;
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
}

.md-spoiler.revealed {
  background: var(--bg-message-hover);
  color: var(--text-primary);
  user-select: auto;
}

/* ── YouTube embed ── */

.msg-youtube-embed {
  margin: 4px 0;
  border-radius: var(--radius-lg);
  overflow: hidden;
  max-width: 420px;
}

.msg-youtube-embed iframe {
  display: block;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
}

/* ── Read receipts ── */

.read-receipt-indicator {
  font-size: 10px;
  color: var(--text-muted);
  margin-left: 4px;
  letter-spacing: 0;
  transition: color 0.15s;
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  min-width: 0;
}

.seen-by {
  color: var(--accent);
  cursor: default;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
}

.seen-by-count {
  font-size: 9px;
  background: var(--accent-subtle);
  color: var(--accent);
  border-radius: 6px;
  padding: 0 3px;
  letter-spacing: 0;
  font-weight: 600;
  line-height: 1.4;
}

.receipt-sent {
  opacity: 0.5;
}

.receipt-avatars {
  display: inline-flex;
  align-items: center;
  margin-left: 2px;
  flex-wrap: wrap;
}

.receipt-avatar {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 7px;
  font-weight: 700;
  color: var(--accent-text);
  margin-left: -3px;
  border: 1px solid var(--bg-main);
  flex-shrink: 0;
}

.receipt-avatar:first-child {
  margin-left: 0;
}

.receipt-extra {
  font-size: 8px;
  color: var(--text-secondary);
  margin-left: 2px;
}

/* ── Animations & micro-interactions ── */

/* New message slide-in */
@keyframes msg-slide-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Button press effect */
.btn:active {
  transform: scale(0.95);
}

/* New message entry animation */
.message:last-child {
  animation: msg-enter 0.15s ease-out;
}

@keyframes msg-enter {
  from { opacity: 0.7; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}


/* Unread badge pop-in */
@keyframes badge-pop {
  0% { transform: scale(0); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

/* Profile modal entrance */
.profile-modal,
.search-panel,
.shortcuts-panel {
  animation: modal-entrance 0.2s ease;
}

@keyframes modal-entrance {
  from { opacity: 0; transform: translateY(-10px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Date divider fade-in */
.date-divider {
  animation: fade-in 0.3s ease;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ── Drag-and-drop overlay ── */

.drop-overlay {
  position: absolute;
  inset: 0;
  z-index: 100;
  background: rgba(var(--accent-rgb), 0.12);
  backdrop-filter: blur(4px);
  border: 2.5px dashed var(--accent);
  border-radius: var(--radius-lg);
  animation: drop-pulse 1.2s ease-in-out infinite alternate;
  pointer-events: none;
}

@keyframes drop-pulse {
  from { background: rgba(var(--accent-rgb), 0.08); border-color: var(--accent); }
  to   { background: rgba(var(--accent-rgb), 0.2); border-color: var(--accent-subtle); }
}

.drop-overlay-icon {
  font-size: 48px;
  animation: drop-bounce 0.6s ease infinite alternate;
}

@keyframes drop-bounce {
  from { transform: translateY(0); }
  to   { transform: translateY(-8px); }
}

.drop-overlay-text {
  font-size: var(--font-size-base);
  color: var(--accent);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.drop-overlay-hint {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Muted room indicator ── */

.muted-icon {
  font-size: 10px;
  opacity: 0.5;
  margin-left: auto;
}

.muted-icon-partial {
  opacity: 0.7;
}

.unread-badge-muted {
  opacity: 0.6;
  background: var(--text-secondary) !important;
}

.mention-badge {
  background: color-mix(in srgb, var(--color-danger) 15%, transparent) !important;
  color: var(--color-danger);
  font-size: 9px;
  letter-spacing: -0.3px;
}

/* Message that mentions the current user */
.message.mentions-me {
  background: var(--mention-bg);
  border-left: 2px solid var(--color-danger);
  padding-left: calc(8px - 2px);
}

.room-info-mute-btn {
  width: 100%;
}

/* ── Poll widget ── */

.poll-widget {
  margin-top: 4px;
  padding: 8px;
  background: var(--bg-main-alt);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  max-width: 400px;
}

.poll-question {
  font-weight: 600;
  margin-bottom: 8px;
  font-size: var(--font-size-sm);
}

.poll-options {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.poll-option {
  position: relative;
  display: flex;
  align-items: center;
  padding: 8px 12px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: transparent;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: var(--text-primary);
  transition: border-color 0.15s, background 0.15s;
  overflow: hidden;
}

.poll-option:hover {
  border-color: var(--accent);
}

.poll-option.poll-voted {
  border-color: var(--accent);
}

.poll-option-bar {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  background: var(--accent);
  opacity: 0.12;
  border-radius: var(--radius-sm);
  transition: width 0.3s ease;
}

.poll-option-text {
  position: relative;
  z-index: 1;
  flex: 1;
  font-size: var(--font-size-sm);
}

.poll-option-count {
  position: relative;
  z-index: 1;
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  margin-left: 8px;
  min-width: 16px;
  text-align: right;
}

.poll-check {
  position: relative;
  z-index: 1;
  color: var(--accent);
  font-size: 12px;
  margin-left: 4px;
}

.poll-footer {
  margin-top: 4px;
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
}

/* ── System messages ── */

.system-message {
  padding: 4px 0;
}

.system-message-block {
  flex-direction: column;
  align-items: flex-start;
  padding: 8px 16px;
}

.system-message-content {
  background: var(--bg-main-alt);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 8px 16px;
  font-size: var(--font-size-xs);
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  width: 100%;
  max-width: 500px;
  animation: fade-in 0.3s ease;
}

.system-help-line {
  padding: 2px 0;
  color: var(--text-secondary);
}

.system-message-text {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  font-style: italic;
  background: var(--bg-main-alt);
  padding: 2px 12px;
  border-radius: 12px;
  animation: fade-in 0.3s ease;
}

/* ── Forwarded banner ── */

.forwarded-banner {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  padding: 2px 0;
  margin-bottom: 2px;
}

.forwarded-icon {
  font-size: 10px;
}

.forwarded-text {
  font-style: italic;
}

/* ── Forward modal ── */

.forward-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.5);
  animation: fade-in 0.15s ease;
}

.forward-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 201;
  background: var(--bg-main);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  width: 320px;
  max-height: 400px;
  display: flex;
  flex-direction: column;
  animation: modal-entrance 0.2s ease;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.3);
}

.forward-modal-header {
  padding: 8px 16px;
  border-bottom: 1px solid var(--border-light);
  font-weight: 600;
  font-size: var(--font-size-sm);
}

.forward-modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 6px;
}

.forward-modal-close:hover {
  color: var(--text-primary);
}

.forward-modal-list {
  overflow-y: auto;
  padding: 4px;
}

.forward-room-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font: inherit;
  font-size: var(--font-size-sm);
  cursor: pointer;
  border-radius: var(--radius-sm);
  text-align: left;
  transition: background 0.1s;
}

.forward-room-item:hover {
  background: var(--bg-main-alt);
}

.forward-room-icon {
  color: var(--text-secondary);
  font-weight: 600;
}

/* ── Clickable mentions ── */

.mention-special {
  background: rgba(var(--accent-rgb), 0.2);
  color: var(--accent) !important;
  padding: 1px 4px;
  border-radius: 3px;
  font-weight: 700;
  cursor: default;
}

.mention-special:hover {
  background: rgba(var(--accent-rgb), 0.2);
}

/* ── Emoji-only messages ── */

.message-body.emoji-only {
  font-size: 36px;
  line-height: 1.2;
  padding: 4px 0;
}

/* ── Avatar hover card ── */

.avatar-medium {
  position: relative;
}

.avatar-medium .chat-avatar.identity-avatar-clickable {
  cursor: pointer;
}

.avatar-hover-card {
  display: none;
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  background: var(--bg-main);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  white-space: nowrap;
  z-index: 50;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  animation: hover-card-in 0.15s ease;
  min-width: 200px;
}

@keyframes hover-card-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.avatar-hover-card::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 16px;
  border: 5px solid transparent;
  border-top-color: var(--border-light);
}

.avatar-medium:hover .avatar-hover-card {
  display: block;
}

.hover-card-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.hover-card-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: var(--accent-text);
  flex-shrink: 0;
}

.hover-card-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.avatar-hover-name {
  font-weight: 600;
  font-size: var(--font-size-sm);
}

.hover-card-status-row {
  display: flex;
  align-items: center;
  gap: 5px;
}

.hover-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.hover-status-online { background: var(--color-success); }
.hover-status-away { background: var(--color-warning); }
.hover-status-busy { background: var(--color-danger); }
.hover-status-offline { background: var(--text-secondary); }

.avatar-hover-status {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
}

.hover-card-custom-status {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  padding: 4px 0;
  border-top: 1px solid var(--border-light);
  margin-top: 4px;
}

.hover-card-role {
  font-size: 10px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding-top: 4px;
}

.hover-card-hint {
  font-size: 10px;
  color: var(--text-secondary);
  opacity: 0.6;
  margin-top: 6px;
  border-top: 1px solid var(--border-light);
  padding-top: 6px;
}

/* ── Loading skeleton ── */

.chat-loading {
  min-height: 220px;
  gap: 12px;
  color: var(--text-secondary);
}

.chat-loading-spinner {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  font-size: 18px;
}

.chat-loading-text {
  font-size: var(--font-size-sm);
  font-weight: 500;
}

.chat-skeleton {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.skeleton-msg {
  display: flex;
  gap: 8px;
}

.skeleton-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--bg-main-alt);
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
}

.skeleton-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.skeleton-line {
  height: 12px;
  border-radius: 6px;
  background: var(--bg-main-alt);
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  width: 100%;
}

.skeleton-line-short {
  width: 30%;
}

.skeleton-line-medium {
  width: 65%;
}

@keyframes skeleton-shimmer {
  0% { opacity: 0.4; }
  50% { opacity: 0.7; }
  100% { opacity: 0.4; }
}

/* ── Big text ── */

.md-big {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.3;
}

/* ── Scroll to bottom badge ── */

.scroll-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  background: var(--accent);
  color: white;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  animation: badge-pop 0.2s ease;
}

/* ── Room stats ── */

.room-stat-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
}

.room-stat-label {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
}

/* ── Code block copy button ── */

.code-block {
  position: relative;
}

.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.code-copy-btn {
  background: var(--bg-main-alt);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  font-size: var(--font-size-xs);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  transition: color 0.15s, border-color 0.15s;
}

.code-copy-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* ── Confetti animation ── */

.confetti-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 100vh;
  pointer-events: none;
  z-index: 9999;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  top: -10px;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  animation: confetti-fall 2s ease-in forwards;
}

@keyframes confetti-fall {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(100vh) rotate(720deg);
    opacity: 0;
  }
}

/* ── More reactions button ── */

.message-action-more-react {
  font-size: 12px;
  opacity: 0.6;
  border: 1px dashed var(--border-light);
  border-radius: 3px;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.message-action-more-react:hover {
  opacity: 1;
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Unread separator ── */

.unread-separator {
  padding: 4px 0;
  margin: 4px 0;
}

.unread-separator-line {
  flex: 1;
  height: 1px;
  background: var(--color-danger);
}

.unread-separator-text {
  font-size: var(--font-size-xs);
  color: var(--color-danger);
  font-weight: 600;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ── Pinned messages bar ── */

.pinned-bar {
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-main-alt);
  cursor: pointer;
  flex-shrink: 0;
}

.pinned-bar-expanded {
  flex-direction: column;
  align-items: stretch !important;
  gap: 0 !important;
}

.pinned-bar-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

.pinned-bar-header:hover {
  color: var(--text-primary);
}

.pinned-bar-toggle {
  margin-left: auto;
  font-size: 10px;
  opacity: 0.5;
}

.pinned-bar-list {
  max-height: 200px;
  overflow-y: auto;
  padding: 0 16px 4px;
}

.pinned-bar-msg {
  padding: 4px 0;
  border-top: 1px solid var(--border-light);
  font-size: var(--font-size-xs);
}

.pinned-bar-msg:first-child {
  border-top: none;
}

.pinned-bar-sender {
  font-weight: 600;
  margin-right: 4px;
}

.pinned-bar-text {
  color: var(--text-secondary);
}

/* ── Pinned Messages Panel ── */

.pinned-panel {
  width: 340px;
  min-width: 340px;
  border-left: 1px solid var(--border-light);
  background: var(--bg-main);
  height: 100%;
  animation: panel-slide-in 0.15s ease;
}

@keyframes panel-slide-in {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

.pinned-panel-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
}

.pinned-panel-title {
  font-size: var(--font-size-sm);
  color: var(--text-primary);
}

.pinned-panel-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 14px;
  padding: 4px;
  border-radius: 4px;
  transition: background 0.15s, color 0.15s;
}

.pinned-panel-close:hover {
  background: var(--bg-sidebar);
  color: var(--text-primary);
}

.pinned-panel-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.pinned-panel-msg {
  position: relative;
  padding: 10px 12px;
  border-radius: 6px;
  background: var(--bg-main-alt);
  margin-bottom: 8px;
  border: 1px solid var(--border-light);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.pinned-panel-msg:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 20%, transparent);
}

.pinned-panel-msg-header {
  margin-bottom: 6px;
}

.pinned-panel-msg-avatar {
  width: 22px;
  height: 22px;
  border-radius: var(--radius-sm);
  font-size: 10px;
  color: var(--accent-text);
}

.pinned-panel-msg-sender {
  font-size: var(--font-size-sm);
}

.pinned-panel-msg-time {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  margin-left: auto;
}

.pinned-panel-msg-content {
  font-size: var(--font-size-sm);
  color: var(--text-primary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  transition: background 0.15s;
}

.pinned-panel-msg-content:hover {
  background: var(--bg-sidebar);
}

.pinned-panel-msg-attach {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  margin-top: 4px;
}

.pinned-panel-unpin-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 11px;
  padding: 2px 5px;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
}

.pinned-panel-msg:hover .pinned-panel-unpin-btn {
  opacity: 1;
}

.pinned-panel-unpin-btn:hover {
  background: var(--color-danger);
  color: var(--accent-text);
}

.pinned-panel-empty {
  padding: 40px 20px;
}

.pinned-panel-empty-icon {
  font-size: 32px;
  opacity: 0.3;
}

.pinned-panel-empty-text {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

.pinned-panel-empty-hint {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  opacity: 0.7;
}

.activity-panel {
  width: 360px;
  min-width: 360px;
  border-left: 1px solid var(--border-light);
  background:
    linear-gradient(
      180deg,
      color-mix(in srgb, var(--bg-main-alt) 82%, transparent),
      var(--bg-main) 180px
    );
  animation: panel-slide-in 0.15s ease;
}

.activity-panel-header {
  padding: 16px;
  border-bottom: 1px solid var(--border-light);
}

.activity-panel-title {
  font-size: var(--font-size-sm);
  font-weight: 700;
  color: var(--text-primary);
}

.activity-panel-subtitle {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
}

.activity-panel-action {
  white-space: nowrap;
}

.activity-push-card {
  margin: 12px 16px 0;
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--border-light));
  background: color-mix(in srgb, var(--accent-subtle) 18%, var(--bg-main-alt));
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.activity-push-card-action {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.activity-push-title {
  font-size: var(--font-size-sm);
  font-weight: 700;
  color: var(--text-primary);
}

.activity-push-body {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  line-height: 1.45;
}

.activity-panel-filters {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  flex-wrap: wrap;
}

.activity-filter-btn {
  border: 1px solid var(--border-light);
  background: var(--bg-main-alt);
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: var(--font-size-xs);
  font-weight: 600;
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}

.activity-filter-btn:hover {
  color: var(--text-primary);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border-light));
}

.activity-filter-btn.active {
  color: var(--accent-text);
  background: var(--accent);
  border-color: var(--accent);
}

.activity-panel-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  gap: 8px;
}

.activity-item {
  width: 100%;
  border: 1px solid var(--border-light);
  background: var(--bg-main-alt);
  border-radius: var(--radius-lg);
  padding: 12px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  text-align: left;
  transition: transform var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast);
}

.activity-item:hover {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border-light));
  background: color-mix(in srgb, var(--accent-subtle) 25%, var(--bg-main-alt));
}

.activity-item-read {
  opacity: 0.75;
}

.activity-item-leading {
  flex-shrink: 0;
}

.activity-item-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.activity-item-row {
  min-width: 0;
}

.activity-item-sender {
  font-size: var(--font-size-sm);
  font-weight: 700;
  color: var(--text-primary);
}

.activity-item-room {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.activity-item-time {
  margin-left: auto;
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  white-space: nowrap;
}

.activity-item-preview {
  font-size: var(--font-size-sm);
  color: var(--text-primary);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.activity-item-meta {
  flex-wrap: wrap;
}

.activity-kind-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  background: color-mix(in srgb, var(--accent-subtle) 75%, transparent);
  color: var(--accent);
}

.activity-read-label,
.activity-unread-indicator {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.activity-read-label {
  color: var(--text-muted);
}

.activity-unread-indicator {
  color: var(--color-danger);
}

.activity-empty {
  min-height: 220px;
  padding: 24px 16px;
  gap: 10px;
  color: var(--text-secondary);
}

.activity-empty-icon {
  font-size: 24px;
  color: var(--text-muted);
}

.activity-empty-title {
  font-size: var(--font-size-sm);
  font-weight: 700;
  color: var(--text-primary);
}

.activity-empty-body {
  font-size: var(--font-size-xs);
  line-height: 1.5;
  max-width: 240px;
}

.panel-active {
  color: var(--accent) !important;
}

/* ── Toast Notifications ── */

.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 10000;
  pointer-events: none;
  max-width: 360px;
}

.toast {
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--bg-main-alt);
  border: 1px solid var(--border-light);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  animation: toast-in 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  pointer-events: auto;
  backdrop-filter: blur(8px);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

.toast.toast-leaving {
  animation: toast-out 0.25s ease-in forwards;
}

@keyframes toast-out {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(48px); }
}

.toast-icon {
  font-size: 14px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
}

.toast-info .toast-icon {
  background: color-mix(in srgb, var(--accent) 20%, transparent);
  color: var(--accent);
}

.toast-success .toast-icon {
  background: color-mix(in srgb, var(--color-success) 15%, transparent);
  color: var(--color-success);
}

.toast-error .toast-icon {
  background: color-mix(in srgb, var(--color-danger) 15%, transparent);
  color: var(--color-danger);
}

.toast-warning .toast-icon {
  background: color-mix(in srgb, var(--color-warning) 15%, transparent);
  color: var(--color-warning);
}

.toast-message {
  font-size: var(--font-size-sm);
  color: var(--text-primary);
  flex: 1;
  line-height: 1.4;
}

.toast-dismiss {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 12px;
  padding: 2px;
  opacity: 0.5;
  transition: opacity 0.15s;
}

.toast-dismiss:hover {
  opacity: 1;
}

/* ── Message Age Fading ── */

.message[data-age="msg-age-day"] .message-body {
  opacity: 0.85;
}

.message[data-age="msg-age-old"] .message-body {
  opacity: 0.7;
}

.message[data-age="msg-age-day"]:hover .message-body,
.message[data-age="msg-age-old"]:hover .message-body {
  opacity: 1;
}

/* ── Edit History Modal ── */

.edit-history-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 8000;
}

.edit-history-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 480px;
  max-width: 90vw;
  max-height: 70vh;
  background: var(--bg-main-alt);
  border: 1px solid var(--border-light);
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  z-index: 8001;
  display: flex;
  flex-direction: column;
  animation: edit-history-in 0.15s ease;
}

@keyframes edit-history-in {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.95); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.edit-history-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
}

.edit-history-title {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-primary);
}

.edit-history-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 14px;
  padding: 4px;
  border-radius: 4px;
  transition: background 0.15s;
}

.edit-history-close:hover {
  background: var(--bg-sidebar);
}

.edit-history-list {
  overflow-y: auto;
  padding: 12px 16px;
  flex: 1;
}

.edit-history-entry {
  padding: 8px 10px;
  margin-bottom: 8px;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  background: var(--bg-code);
}

.edit-history-entry-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.edit-history-version {
  font-size: var(--font-size-xs);
  font-weight: 700;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  padding: 1px 6px;
  border-radius: 3px;
}

.edit-history-time {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
}

.edit-history-content {
  font-size: var(--font-size-sm);
  color: var(--text-primary);
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.edit-history-empty {
  text-align: center;
  padding: 24px;
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
}

.edited-tag-clickable {
  cursor: pointer;
  transition: color 0.15s;
}

.edited-tag-clickable:hover {
  color: var(--accent);
}

/* ── Spotlight Search ── */

.spotlight-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9000;
  backdrop-filter: blur(2px);
}

.spotlight {
  position: fixed;
  top: max(80px, 14vh);
  left: 50%;
  transform: translateX(-50%);
  width: 560px;
  max-width: 90vw;
  max-height: min(78vh, 720px);
  background: var(--bg-main-alt);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4);
  z-index: 9001;
  overflow: hidden;
  animation: spotlight-in 0.15s ease;
  display: flex;
  flex-direction: column;
}

@keyframes spotlight-in {
  from { opacity: 0; transform: translateX(-50%) scale(0.95) translateY(-10px); }
  to { opacity: 1; transform: translateX(-50%) scale(1) translateY(0); }
}

.spotlight-input-wrap {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-light);
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--bg-main-alt);
}

.spotlight-icon {
  font-size: 16px;
  opacity: 0.5;
  flex-shrink: 0;
}

.spotlight-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 16px;
  font-family: inherit;
}

.spotlight-input::placeholder {
  color: var(--text-secondary);
}

.spotlight-shortcut {
  font-size: 10px;
  padding: 2px 6px;
  background: var(--bg-code);
  border: 1px solid var(--border-light);
  border-radius: 4px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.spotlight-results {
  overflow-y: auto;
  max-height: none;
  flex: 1;
  min-height: 0;
  overscroll-behavior: contain;
}

.spotlight-empty {
  padding: 32px 20px;
}

.spotlight-empty-text {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

.spotlight-result {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  cursor: pointer;
  transition: background 0.1s;
}

.spotlight-result:hover,
.spotlight-result-selected {
  background: var(--bg-sidebar);
}

.spotlight-result-avatar {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-md);
  font-size: 11px;
  color: var(--accent-text);
  margin-top: 2px;
}

.spotlight-result-content {
  flex: 1;
  min-width: 0;
}

.spotlight-result-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 8px;
  margin-bottom: 4px;
  min-width: 0;
}

.spotlight-result-sender {
  font-size: var(--font-size-sm);
}

.spotlight-result-room {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  background: var(--bg-code);
  padding: 1px 6px;
  border-radius: 3px;
}

.spotlight-result-time {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  margin-left: auto;
  white-space: nowrap;
}

.spotlight-result-text {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  line-height: 1.45;
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Smooth transitions & polish ── */

.channel-item {
  transition: background 0.15s, opacity 0.15s;
}

.chat-reply-bar {
  animation: slide-up 0.15s ease;
}

@keyframes slide-up {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes sheet-slide-up {
  from { opacity: 0; transform: translateY(100%); }
  to { opacity: 1; transform: translateY(0); }
}

.room-info-panel {
  animation: slide-in-right 0.2s ease;
}

@keyframes slide-in-right {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

.mention-autocomplete,
.slash-autocomplete {
  animation: pop-up 0.12s ease;
}

@keyframes pop-up {
  from { opacity: 0; transform: translateY(8px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.forward-modal,
.search-panel,
.shortcuts-panel,
.profile-modal {
  animation: modal-in 0.15s ease;
}

@keyframes modal-in {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

/* ── Slash command autocomplete ── */

.slash-autocomplete {
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  background: var(--bg-main);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 4px;
  margin-bottom: 4px;
  max-height: 300px;
  overflow-y: auto;
  z-index: 50;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.3);
}

.slash-item {
  width: 100%;
  text-align: left;
  padding: 6px 10px;
  border: none;
  background: none;
  color: var(--text-primary);
  font-size: var(--font-size-sm);
  font-family: inherit;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.slash-item:hover,
.slash-item-active {
  background: var(--bg-main-alt);
}

.slash-item-cmd {
  font-weight: 600;
  color: var(--accent);
  min-width: 80px;
}

.slash-item-desc {
  color: var(--text-secondary);
  font-size: var(--font-size-xs);
}

/* ── Emoji shortcode autocomplete ── */

.emoji-sc-autocomplete {
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  background: var(--bg-main);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 4px;
  margin-bottom: 4px;
  max-height: 260px;
  overflow-y: auto;
  z-index: 50;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.3);
}

.emoji-sc-item {
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 6px 10px;
  border: none;
  background: none;
  color: var(--text-primary);
  font-size: var(--font-size-sm);
  font-family: inherit;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.emoji-sc-item:hover,
.emoji-sc-item-active {
  background: var(--bg-main-alt);
}

.emoji-sc-char {
  font-size: 20px;
  width: 28px;
  text-align: center;
}

.emoji-sc-name {
  color: var(--text-secondary);
  font-size: var(--font-size-xs);
}

/* ── Context menu ── */

.ctx-menu-overlay {
  position: fixed;
  inset: 0;
  z-index: 999;
}

.ctx-menu {
  position: fixed;
  z-index: 1000;
  background: var(--bg-main);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 4px;
  min-width: 180px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  animation: ctx-menu-in 0.1s ease;
}

@keyframes ctx-menu-in {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.ctx-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 6px 10px;
  border: none;
  background: none;
  color: var(--text-primary);
  font-size: var(--font-size-sm);
  font-family: inherit;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.1s;
}

.ctx-menu-item:hover {
  background: var(--bg-main-alt);
}

.ctx-menu-danger {
  color: var(--color-danger);
}

.ctx-menu-danger:hover {
  background: color-mix(in srgb, var(--color-danger) 10%, transparent);
}

.ctx-menu-sep {
  height: 1px;
  background: var(--border-light);
  margin: 4px 0;
}

/* ── Markdown table ── */

.md-table-wrap {
  overflow-x: auto;
  margin: 4px 0;
}

.md-table {
  border-collapse: collapse;
  font-size: var(--font-size-sm);
  width: auto;
  min-width: 200px;
}

.md-table th,
.md-table td {
  border: 1px solid var(--border-light);
  padding: 4px 10px;
  text-align: left;
}

.md-table th {
  background: var(--bg-main-alt);
  font-weight: 600;
  color: var(--text-primary);
}

.md-table td {
  color: var(--text-secondary);
}

.md-table tr:hover td {
  background: var(--bg-main-alt);
}

/* ── Blockquote, headings, lists, hr ── */

.md-blockquote {
  border-left: 3px solid var(--accent);
  padding: 4px 0 4px 12px;
  margin: 4px 0;
  color: var(--text-secondary);
  font-style: italic;
}

.md-h1 {
  font-size: 1.5em;
  font-weight: 700;
  margin: 8px 0 4px;
  color: var(--text-primary);
}
.md-h2 {
  font-size: 1.25em;
  font-weight: 600;
  margin: 6px 0 3px;
  color: var(--text-primary);
}
.md-h3 {
  font-size: 1.1em;
  font-weight: 600;
  margin: 4px 0 2px;
  color: var(--text-primary);
}

.md-list-item {
  display: flex;
  gap: 6px;
  padding: 1px 0;
}
.md-bullet {
  color: var(--accent);
  flex-shrink: 0;
}

.md-hr {
  border: none;
  border-top: 1px solid var(--border-light);
  margin: 8px 0;
}

/* ── Agent activity details ── */

.agent-details {
  margin: 4px 0;
  border: 1px solid var(--border-light);
  border-radius: 4px;
  overflow: hidden;
}
.agent-details-summary {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--bg-main-alt);
  cursor: pointer;
  user-select: none;
  font-size: 0.85em;
  color: var(--text-secondary);
}
.agent-details-summary:hover {
  background: var(--bg-message-hover);
}
.agent-details-toggle {
  font-size: 0.7em;
  width: 12px;
  text-align: center;
  flex-shrink: 0;
}
.agent-details-body {
  padding: 8px 12px;
  font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', monospace;
  font-size: 0.82em;
  line-height: 1.5;
  color: var(--text-secondary);
  background: var(--bg-main);
  white-space: pre-wrap;
}

/* ── Agent working indicator ── */

.agent-working-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  margin-left: 6px;
  animation: agent-pulse 1.5s ease-in-out infinite;
}
@keyframes agent-pulse {
  0%, 100% { opacity: 0.3; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.2); }
}

/* ── Agent structured tool calls ── */

.agent-tool-call {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 2px 0;
  font-size: 0.85em;
  line-height: 1.5;
}
.agent-tool-icon {
  flex-shrink: 0;
  width: 14px;
  text-align: center;
}
.agent-tool-name {
  flex-shrink: 0;
}
.agent-tool-name code {
  font-size: 0.9em;
  background: var(--bg-main-alt);
  padding: 1px 4px;
  border-radius: 3px;
}
.agent-tool-result {
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.agent-tool-running .agent-tool-icon {
  color: var(--accent);
  animation: agent-pulse 1.5s ease-in-out infinite;
}
.agent-tool-success .agent-tool-icon {
  color: var(--color-success);
}
.agent-tool-error .agent-tool-icon {
  color: var(--color-danger);
}
.agent-tool-skipped .agent-tool-icon {
  color: var(--text-muted);
}

/* ── Agent thinking placeholder ── */

.agent-thinking-placeholder {
  color: var(--text-secondary);
  font-style: italic;
}

/* ── Agent message parts layout ── */

.agent-message-parts {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* ── Agent artifacts ── */

.agent-artifact {
  border: 1px solid var(--border-light);
  border-radius: 6px;
  overflow: hidden;
  margin: 4px 0;
  max-width: 480px;
}
.agent-artifact-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--bg-main-alt);
  font-size: 0.85em;
}
.agent-artifact-icon {
  flex-shrink: 0;
}
.agent-artifact-name {
  color: var(--accent);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.agent-artifact-name:hover {
  text-decoration: underline;
}
.agent-artifact-size {
  color: var(--text-muted);
  flex-shrink: 0;
  font-size: 0.85em;
}

/* ── Avatar overlays (bot gear, agent sparkle) ── */

.avatar-overlay {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  border: 2px solid var(--bg-main);
}
.avatar-overlay-bot {
  background: var(--bg-sidebar);
  color: var(--text-secondary);
}
.avatar-overlay-agent {
  background: var(--accent-subtle, rgba(139, 92, 246, 0.15));
  color: var(--accent, #8b5cf6);
}

/* ── Bot badge (header) ── */

.bot-badge {
  background: var(--bg-message-hover, var(--bg-hover));
  color: var(--text-muted);
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 3px;
  margin-left: 4px;
  text-transform: uppercase;
  font-weight: 600;
}

/* ── Agent actions bar (copy button) ── */

.agent-actions-bar {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid var(--border-light);
}
.agent-copy-btn, .agent-stop-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  background: var(--bg-main);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 12px;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.agent-copy-btn:hover {
  background: var(--bg-message-hover);
  color: var(--text-primary);
}

/* ── Agent stop bar ── */

.agent-stop-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}
.agent-stop-btn {
  color: var(--color-danger, #ef4444);
  border-color: var(--color-danger, #ef4444);
}
.agent-stop-btn:hover {
  background: rgba(196, 80, 80, 0.1);
  color: var(--color-danger, #ef4444);
}

/* ── Canceled badge ── */

.agent-canceled-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  color: var(--color-warning, #f59e0b);
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(184, 152, 64, 0.1);
  margin-top: 6px;
}

/* ── Floating agent working pill ── */

.agent-working-pill {
  position: absolute;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--bg-sidebar);
  border: 1px solid var(--border-light);
  border-radius: 20px;
  box-shadow: var(--shadow-md);
  z-index: 10;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-primary);
  animation: slideUp 0.2s ease-out;
}
.agent-working-pill:hover {
  background: var(--bg-sidebar-hover);
}
@keyframes slideUp {
  from { transform: translateX(-50%) translateY(10px); opacity: 0; }
  to { transform: translateX(-50%) translateY(0); opacity: 1; }
}


/* ── Mobile responsive enhancements ── */

@media (max-width: 991.98px) {
  /* Safe area insets for status bar (notch / dynamic island) */
  .chat-main {
    --chat-rail-x: 16px;
  }

  .chat-header {
    padding-top: env(safe-area-inset-top, 0px);
    height: calc(52px + env(safe-area-inset-top, 0px));
    min-height: calc(52px + env(safe-area-inset-top, 0px));
  }

  .sidebar-header {
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
  }

  /* Input area: tighter margins on mobile */
  .input-container {
    margin: 0;
  }

  .message-textarea {
    font-size: 16px; /* Prevents iOS zoom on focus */
    min-height: 36px;
  }

  /* Instant scroll on mobile — smooth scrolling feels sluggish on touch */
  .messages-area {
    scroll-behavior: auto;
  }

  .btn.btn-icon {
    padding: 6px;
  }

  .topbar-room-info-btn {
    padding: 0 8px 0 6px;
    gap: 6px;
  }

  /* Bigger touch targets for message actions */
  .message-actions {
    gap: 2px;
    padding: 3px;
  }

  .message-action-btn,
  .message-action-emoji {
    width: 34px;
    height: 32px;
    font-size: 16px;
  }

  /* Reaction pills bigger touch targets */
  .reaction {
    padding: 4px 10px;
    font-size: 14px;
  }

  /* Chat messages: reduce padding */
  .message {
    padding: 6px 0;
  }

  .message-avatar {
    width: 32px;
    flex-shrink: 0;
  }

  .message-header {
    padding-right: 0;
  }

  .chat-avatar {
    width: 32px;
    height: 32px;
    font-size: 12px;
  }

  .chat-avatar-agent {
    font-size: 28px;
  }

  /* Context menu larger items */
  .ctx-menu-item {
    padding: 10px 14px;
    font-size: 15px;
  }

  /* Selection bar */
  .selection-bar {
    flex-wrap: wrap;
    gap: 4px;
  }

  /* Search panel full-width on mobile */
  .search-panel {
    width: 100vw;
    max-height: 80vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }

  /* Room info panel full overlay */
  .room-info-panel {
    width: 100% !important;
  }

  .auth-modal {
    padding: 20px 18px 16px;
  }

  .create-room-overlay,
  .avatar-picker-overlay,
  .profile-overlay {
    padding: 0;
    align-items: flex-end !important;
  }

  .create-room-modal,
  .avatar-picker-modal,
  .profile-modal {
    width: 100vw;
    max-width: 100%;
    max-height: 85vh;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    animation: sheet-slide-up 0.25s cubic-bezier(0.32, 0.72, 0, 1);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .create-room-modal::before,
  .avatar-picker-modal::before,
  .profile-modal::before {
    content: '';
    display: block;
    width: 36px;
    height: 4px;
    margin: 8px auto 0;
    border-radius: 999px;
    background: var(--text-muted);
    opacity: 0.3;
    flex-shrink: 0;
  }

  /* Reply bar mobile */
  .chat-reply-bar {
    font-size: var(--font-size-xs);
    padding: 4px 8px;
  }

  /* Emoji picker responsive */
  .emoji-picker {
    width: calc(100vw - 16px) !important;
    max-width: 360px;
  }

  /* Lightbox toolbar responsive */
  .lightbox-toolbar {
    flex-wrap: wrap;
    gap: 8px;
  }

  .lightbox-filename {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Pending attachments */
  .pending-attachments {
    flex-wrap: wrap;
  }

  .pending-attachment {
    max-width: calc(50% - 4px);
  }

  /* Avatar hover card position fix for mobile */
  .avatar-hover-card {
    left: 0;
    right: auto;
    min-width: 180px;
  }

  /* Word count badge */
  .msg-word-count {
    font-size: 10px;
  }

  /* Code blocks mobile */
  .code-block {
    max-height: 300px;
    overflow: auto;
  }

  /* Side panels: full-screen overlay on mobile.
     !important needed to override thread-panel's inline width/position (set by resize handle). */
  .thread-panel,
  .pinned-panel,
  .activity-panel {
    position: fixed !important;
    inset: 0 !important;
    width: 100% !important;
    min-width: 0 !important;
    z-index: 100;
    box-shadow: none;
  }

  .thread-resize-handle {
    display: none;
  }

  /* Context menu: bottom sheet on mobile */
  .ctx-menu-overlay {
    background: rgba(0, 0, 0, 0.4);
  }

  .ctx-menu {
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    top: auto !important;
    width: 100%;
    max-width: 100%;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 0px));
    animation: sheet-slide-up 0.25s cubic-bezier(0.32, 0.72, 0, 1);
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.3);
  }

  /* Bottom sheet drag handle */
  .ctx-menu::before,
  .search-panel::before {
    content: '';
    display: block;
    width: 36px;
    height: 4px;
    background: var(--text-muted);
    opacity: 0.3;
    border-radius: 2px;
  }
  .ctx-menu::before { margin: 0 auto 8px; }
  .search-panel::before { margin: 8px auto; flex-shrink: 0; }

  /* Search panel: bottom sheet on mobile */
  .search-overlay {
    padding-top: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
  }

  .search-panel {
    width: 100vw;
    max-height: 85vh;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    animation: sheet-slide-up 0.25s cubic-bezier(0.32, 0.72, 0, 1);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    align-self: stretch;
  }

  .shortcuts-overlay,
  .cmd-overlay {
    padding: 0;
    justify-content: flex-end;
  }

  .shortcuts-panel,
  .cmd-palette {
    width: 100vw;
    max-width: 100%;
    max-height: 85vh;
    height: auto;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    border-left: none;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.28);
    animation: sheet-slide-up 0.25s cubic-bezier(0.32, 0.72, 0, 1);
    align-self: stretch;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .spotlight {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    transform: none;
    width: 100vw;
    max-width: 100%;
    max-height: 85vh;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    animation: sheet-slide-up 0.25s cubic-bezier(0.32, 0.72, 0, 1);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .shortcuts-panel::before,
  .cmd-palette::before,
  .spotlight::before {
    content: '';
    display: block;
    width: 36px;
    height: 4px;
    margin: 8px auto 0;
    border-radius: 999px;
    background: var(--text-muted);
    opacity: 0.3;
    flex-shrink: 0;
  }

  /* Safe area insets for notched phones (iPhone X+) */
  .sidebar-footer {
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  }

  .input-container {
    margin-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  }

  .ai-agent-row,
  .ai-agent-tool-grid,
  .ai-agent-room-controls {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 575.98px) {
  .chat-main {
    --chat-rail-x: 12px;
  }

  .messages-area {
    padding-left: var(--chat-rail-x);
    padding-right: var(--chat-rail-x);
  }
  .message-input-area {
    padding-left: var(--chat-rail-x);
    padding-right: var(--chat-rail-x);
  }
  .composer-footer {
    padding-bottom: 10px;
  }
  .composer-meta {
    padding-top: 8px;
  }

  .thread-indicator {
    width: 100%;
    flex-wrap: wrap;
  }
}

@media (max-width: 480px) {
  /* Extra small: further adjustments */
  .message-header {
    flex-wrap: wrap;
    gap: 4px;
  }

  .link-preview {
    flex-direction: column;
  }

  .link-preview-img {
    max-width: 100%;
    max-height: 120px;
  }

  .msg-youtube-embed iframe {
    width: 100% !important;
    height: auto !important;
    aspect-ratio: 16/9;
  }

  .inline-image img,
  .msg-inline-image img {
    max-width: 100%;
  }

  /* Command palette full width */
  .cmd-palette {
    width: calc(100vw - 16px) !important;
  }
}

/* ── Focus styles ── */

/* Inputs: subtle focus ring from theme */
.form-control:focus,
.form-select:focus {
  border-color: var(--border-input-focus);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.15);
  outline: none;
}

/* Keyboard focus ring — buttons and nav only */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.form-control:focus-visible,
.form-select:focus-visible,
textarea:focus-visible {
  outline: none;
}

.btn:focus-visible,
.channel-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  box-shadow: 0 0 0 4px rgba(var(--accent-rgb), 0.15);
}

/* ── Mark all read button ── */

/* .sidebar-header-actions — layout via Bootstrap utilities */

.mark-all-read-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 11px;
  padding: 0 4px;
  border-radius: var(--radius-sm);
  transition: color 0.15s, background 0.15s;
  line-height: 1;
}

.mark-all-read-btn:hover {
  color: var(--accent);
  background: var(--bg-message-hover);
}

/* ── Text selection ── */

::selection {
  background: var(--accent);
  color: var(--accent-text);
}

::-moz-selection {
  background: var(--accent);
  color: var(--accent-text);
}

/* ── Global button transitions ── */

button {
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.1s, opacity 0.15s;
}

button:active:not(:disabled) {
  transform: scale(0.97);
}

/* ── Sidebar total unread badge ── */

.sidebar-total-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 10px;
  font-weight: 700;
  margin-left: 6px;
  animation: badge-pulse 2s ease-in-out infinite;
}

@keyframes badge-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* ── Sidebar fixed header/footer, scrollable content ── */

.sidebar {
  overflow-y: hidden;
}

.sidebar-footer {
  flex-shrink: 0;
}


.bots-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.bots-view-header {
  height: 52px;
  min-height: 52px;
  padding: 0 24px;
  border-bottom: 1px solid var(--border-light);
  box-shadow: var(--shadow-header);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: nowrap;
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg-chrome);
}

.bots-view-body {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 24px;
  padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
}

.bots-view-columns {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
  gap: 24px;
  align-items: start;
}

.bots-view-columns-single {
  grid-template-columns: minmax(0, 1fr);
}

@media (max-width: 860px) {
  .bots-view-columns {
    grid-template-columns: 1fr;
  }

  .bots-view-header {
    padding: 0 16px;
  }

  .bots-view-body {
    padding: 16px;
  }

  .bots-list-section,
  .bots-create-section {
    padding: 14px;
  }
}

.bots-list-section,
.bots-create-section {
  min-width: 0;
  background: var(--bg-main-alt);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.08);
}

.bots-section-title {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  letter-spacing: 0.05em;
  margin: 0 0 4px;
}

.bots-label {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  margin-bottom: -4px;
}

.bots-empty {
  color: var(--text-muted);
  font-size: var(--font-size-sm);
  padding: 24px 0;
}

.bot-row-no-rooms {
  color: var(--text-muted);
  font-size: 11px;
  font-style: italic;
}

.bot-row-webhook-label {
  color: var(--text-muted);
  flex-shrink: 0;
}

.bot-row {
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--bg-main);
  border: 1px solid var(--border-light);
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bot-row:hover {
  border-color: var(--accent);
}

.bot-row-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 12px;
  margin-bottom: 0;
}

.bot-row-name {
  font-size: var(--font-size-sm);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.bot-row-delete {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 6px;
  border-radius: var(--radius-md);
}

.bot-row-delete:hover {
  background: color-mix(in srgb, var(--color-danger) 15%, transparent);
  color: var(--color-danger);
}

.bot-row-delete:disabled {
  opacity: 0.45;
  cursor: default;
}

.bot-row-delete:disabled:hover {
  background: none;
  color: var(--text-secondary);
}

.bot-row-rooms {
  margin-bottom: 6px;
}

.bot-room-chip {
  display: inline-block;
  padding: 2px 8px;
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  color: var(--accent);
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
}

.bot-row-webhook {
  font-size: 11px;
  color: var(--text-muted);
  flex-wrap: wrap;
  gap: 6px;
}

.bot-row-webhook code {
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  word-break: break-all;
}

.bot-row-outbound {
  font-size: 11px;
  color: var(--text-muted);
  flex-wrap: wrap;
  gap: 6px;
}

.bot-row-confirm {
  margin-top: 2px;
  padding-top: 8px;
  border-top: 1px solid var(--border-light);
  flex-wrap: wrap;
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
}

.bot-outbound-url {
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  word-break: break-all;
  color: var(--accent);
}

.bots-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin: 2px 0 8px 0;
  line-height: 1.4;
}

.bots-panel-divider {
  height: 1px;
  background: var(--border-light);
  margin: 8px 0 4px;
}

.admin-user-row-main {
  flex: 1;
  min-width: 0;
  align-items: flex-start;
}

.admin-user-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.admin-user-email {
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
}

.admin-user-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.bot-token-reveal {
  padding: 16px;
  border: 1px solid color-mix(in srgb, var(--color-warning) 40%, var(--border-light));
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--color-warning) 8%, var(--bg-main));
  margin-bottom: 24px;
}

.bot-token-warning {
  color: var(--color-warning);
  font-size: var(--font-size-sm);
  font-weight: 600;
  margin-bottom: 8px;
}

.bot-token-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
  margin-top: 4px;
}

.bot-token-box {
  padding: 8px 10px;
  background: var(--bg-main-alt);
  border: 1px solid color-mix(in srgb, var(--color-warning) 40%, var(--border-light));
  border-radius: var(--radius-md);
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 12px;
  color: var(--text-primary);
  word-break: break-all;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 8px;
}

.bot-token-box code {
  flex: 1;
  word-break: break-all;
}

.bot-token-copy {
  background: var(--bg-sidebar);
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: var(--font-size-xs);
  padding: 2px 8px;
  border-radius: var(--radius-md);
  flex-shrink: 0;
}

.bot-token-copy:hover {
  color: var(--accent);
}

.bot-token-done {
  margin-top: 8px;
}

.bots-error {
  color: var(--color-danger);
  font-size: var(--font-size-sm);
  padding: 4px 8px;
  background: color-mix(in srgb, var(--color-danger) 10%, transparent);
  border-radius: var(--radius-md);
}

.bots-room-checkbox {
  font-size: var(--font-size-sm);
  color: var(--text-primary);
  cursor: pointer;
}

.bots-room-checkbox input[type="checkbox"] {
  accent-color: var(--accent);
}

.bots-room-select {
  max-height: 220px;
  overflow-y: auto;
  padding: 8px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--bg-main);
}

.bot-row-delete-accent {
  color: var(--accent);
}

.bot-row-delete-accent:hover {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent);
}

/* ── Invite status badges ── */

.invite-status-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
  text-transform: lowercase;
  white-space: nowrap;
}

.invite-status-pending {
  background: color-mix(in srgb, var(--color-warning) 15%, transparent);
  color: var(--color-warning);
}

.invite-status-sent {
  background: rgba(var(--accent-rgb), 0.15);
  color: var(--accent);
}

.invite-status-delivered {
  background: color-mix(in srgb, var(--color-success) 15%, transparent);
  color: var(--color-success);
}

.invite-status-used {
  background: color-mix(in srgb, var(--color-success) 20%, transparent);
  color: var(--color-success);
}

.invite-status-bounced {
  background: color-mix(in srgb, var(--color-danger) 15%, transparent);
  color: var(--color-danger);
}

.invite-status-expired {
  background: rgba(155, 154, 155, 0.15);
  color: var(--text-secondary);
}

.invite-actions {
  margin-top: 6px;
}

.invite-cancel-btn {
  color: var(--color-danger) !important;
}

.invite-cancel-btn:hover {
  background: color-mix(in srgb, var(--color-danger) 10%, transparent) !important;
}

.invite-only-notice {
  text-align: center;
  font-size: var(--font-size-sm);
  padding: 8px 12px;
  margin-bottom: 8px;
  background: color-mix(in srgb, var(--color-warning) 10%, transparent);
  border-radius: var(--radius-md);
  color: var(--color-warning);
}

.form-control-readonly {
  opacity: 0.7;
  cursor: not-allowed;
}

/* ── Custom scrollbars ── */

* {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) transparent;
}

*:hover {
  scrollbar-color: var(--scrollbar-thumb) transparent;
}

/* ── Text selection ── */

/* .app-shell uses Bootstrap user-select-none in markup */

/* Allow text selection in content areas */
.messages-area,
.message-textarea,
.bots-view-body,
.form-control {
  user-select: text;
  -webkit-user-select: text;
}

/* ── Agents panel ── */

.ai-agent-disabled {
  opacity: 0.6;
}

.ai-agent-badge-disabled {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 400;
  font-style: italic;
}

.ai-agent-meta {
  margin-bottom: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.ai-agent-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.ai-agent-emoji {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  margin-right: 4px;
}

.ai-agent-chip {
  display: inline-block;
  padding: 2px 8px;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--text-secondary);
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
}

.ai-agent-confirm-delete {
  margin-top: 8px;
  padding: 8px;
  background: var(--mention-bg);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  color: var(--color-danger);
}

.ai-agent-textarea {
  resize: vertical;
  min-height: 80px;
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 12px;
}

.ai-agent-select {
  cursor: pointer;
}

.ai-agent-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  align-items: start;
}

.ai-agent-field {
  min-width: 0;
}

.ai-agent-field-primary {
  grid-column: span 1;
}

.ai-agent-field-avatar {
  max-width: 88px;
}

.ai-agent-toggle {
  font-size: var(--font-size-sm);
  color: var(--text-primary);
  cursor: pointer;
  margin: 4px 0;
}

.ai-agent-toggle input[type="checkbox"] {
  accent-color: var(--accent);
}

.ai-agent-form-actions {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
}

.ai-agent-avatar-button {
  width: 100%;
  height: 38px;
  border: 1px solid var(--border-light);
  background: var(--bg-main);
}

.ai-agent-avatar-preview {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
}

.ai-agent-model-list {
  margin: 4px 0 8px;
}

.ai-agent-model-chip {
  background: var(--bg-main-alt);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  cursor: pointer;
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  transition: border-color 0.15s, color 0.15s;
}

.ai-agent-model-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.ai-agent-section-title {
  margin-top: 16px;
}

.ai-agent-tool-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.ai-agent-room-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ai-agent-room-entry {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--bg-main);
}

.ai-agent-room-entry-header {
  min-width: 0;
}

.ai-agent-room-name {
  flex: 1;
  min-width: 0;
  color: var(--text-primary);
  font-size: var(--font-size-sm);
  font-weight: 600;
}

.ai-agent-room-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.ai-agent-room-control {
  min-width: 0;
}

.ai-agent-room-add {
  margin-top: 4px;
}

.btn-danger {
  background: var(--color-danger);
  color: var(--accent-text);
  border: none;
}

.btn-danger:hover {
  background: var(--color-danger);
}

/* ── Theme transition ── */

.theme-transitioning,
.theme-transitioning *,
.theme-transitioning *::before,
.theme-transitioning *::after {
  transition: background-color 400ms ease,
              color 400ms ease,
              border-color 400ms ease,
              box-shadow 400ms ease !important;
}

/* ── Avatar Picker ── */

.avatar-picker-overlay {
  position: fixed;
  inset: 0;
  z-index: 260;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

.avatar-picker-modal {
  width: min(440px, 92vw);
  max-height: 80vh;
  background: var(--bg-main-alt);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4);
  animation: cmd-in 0.15s ease-out;
  display: flex;
  flex-direction: column;
}

.avatar-picker-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-light);
}

.avatar-picker-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  padding: 4px 8px;
  border-radius: var(--radius-md);
  transition: color 0.15s, background 0.15s;
}

.avatar-picker-close:hover {
  color: var(--text-primary);
  background: var(--bg-message-hover);
}

.avatar-picker-tabs {
  padding: 8px 12px 0;
  flex-shrink: 0;
}

.avatar-picker-tab {
  padding: 6px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  background: transparent;
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.avatar-picker-tab:hover {
  background: var(--bg-hover);
}

.avatar-picker-tab.active {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
}

.avatar-picker-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  padding: 12px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.avatar-picker-item {
  width: 100%;
  aspect-ratio: 1;
  border-radius: var(--radius-md);
  border: 2px solid transparent;
  background: var(--bg-main);
  cursor: pointer;
  padding: 4px;
  transition: border-color 0.15s, transform 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.avatar-picker-item:hover {
  border-color: var(--accent);
  transform: scale(1.05);
}

.avatar-picker-item img {
  width: 100%;
  height: 100%;
  border-radius: var(--radius-sm);
  object-fit: cover;
}

.avatar-picker-actions {
  padding: 10px 12px;
  border-top: 1px solid var(--border-light);
  display: flex;
  gap: 8px;
}

.avatar-picker-action {
  flex: 1 1 0;
}

/* ── Avatar inner img (universal) ── */

.avatar-inner,
.chat-avatar {
  position: relative;
}

.avatar-inner img,
.chat-avatar img,
.profile-avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: cover;
  z-index: 1;
}

/* ── Avatar edit overlay (sidebar footer) ── */

.avatar-edit-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  border-radius: var(--radius-md);
  opacity: 0;
  transition: opacity 0.15s;
  color: white;
  font-size: 10px;
  pointer-events: none;
}

.sidebar-footer-avatar:hover .avatar-edit-overlay,
.avatar-small:hover .avatar-edit-overlay,
.identity-avatar-small:hover .avatar-edit-overlay {
  opacity: 1;
}

/* ── Agent avatar in admin list ── */

.ai-agent-avatar {
  width: 20px;
  height: 20px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  vertical-align: middle;
  margin-right: 4px;
}

/* ══════════════════════════════════════════════════════════════════
   TOUCH DEVICE OVERRIDES — prevents sticky :hover on tap
   ══════════════════════════════════════════════════════════════════ */

@media (hover: none) {
  /* ── Reset background hovers (grouped) ── */
  .message:hover,
  .channel-item:hover,
  .message-action-emoji:hover,
  .message-action-btn:hover,
  .ctx-menu-item:hover,
  .ctx-menu-danger:hover,
  .search-result:hover,
  .emoji-item:hover,
  .cmd-item:hover,
  .spotlight-result:hover,
  .bookmark-jump:hover,
  .room-info-member-clickable:hover,
  .pinned-panel-msg-content:hover,
  .forward-room-item:hover,
  .slash-item:hover,
  .md-table tr:hover td,
  .agent-details-summary:hover,
  .msg-reply-clickable:hover,
  .thread-indicator:hover { background: transparent; }

  /* ── Reset border-color hovers (grouped) ── */
  .pinned-panel-msg:hover,
  .attachment-card:hover,
  .link-preview:hover,
  .poll-option:hover,
  .bot-row:hover,
  .ai-agent-model-chip:hover,
  .role-select:hover { border-color: var(--border-light); }

  /* ── Non-transparent hover resets ── */
  .message.is-pinned:hover { background: rgba(var(--accent-rgb), 0.04); }
  .channel-item.active:hover { background: var(--bg-sidebar-active); }
  .sidebar-nav .nav-item:hover { background: transparent; color: var(--sidebar-text-muted); }
  .section-header:hover { color: inherit; }
  .reaction:hover { background: var(--bg-reaction); }
  .mention:hover { background: var(--mention-bg); color: var(--mention-text); }
  .mention-special:hover { background: rgba(var(--accent-rgb), 0.2); }
  .avatar-picker-item:hover { border-color: transparent; }
  .gif-item:hover { transform: none; }

  /* ── Reset button hovers ── */
  .btn.btn-icon:hover { color: var(--text-muted); background: transparent; }
  .input-toolbar .btn-icon:hover { color: var(--text-muted); background: transparent; }
  .send-btn:hover:not(:disabled) { background: var(--send-bg); }
  .scroll-bottom-btn:hover { box-shadow: var(--shadow-md); }
  .scroll-bottom-btn.has-new:hover { box-shadow: var(--shadow-md); }
  .sidebar-collapse-btn:hover { color: var(--text-muted); }
  .create-room-btn:hover { color: var(--text-muted); }
  .auth-form .btn-primary:hover { transform: none; }
  .sidebar-logout-btn:hover { opacity: 0.7; }
  .code-copy-btn:hover { color: inherit; }
  .mark-all-read-btn:hover { color: var(--text-muted); background: transparent; }

  /* ── Reset close button hovers ── */
  .search-close:hover,
  .shortcuts-close:hover,
  .profile-close:hover,
  .thread-panel-action:hover,
  .thread-panel-close:hover,
  .room-info-close:hover,
  .forward-modal-close:hover,
  .pinned-panel-close:hover,
  .edit-history-close:hover,
  .create-room-modal-close:hover,
  .chat-reply-bar-close:hover,
  .lightbox-close:hover,
  .lightbox-download:hover { color: inherit; background: transparent; }

  /* ── Reset reveal-on-hover elements ── */
  .message:hover > .message-actions {
    opacity: 0;
    pointer-events: none;
    transform: translateY(-4px);
  }
  .reaction-wrap:hover .reaction-detail-popup { display: none; }
  .pinned-panel-msg:hover .pinned-panel-unpin-btn { opacity: 0; }
  .avatar-medium:hover .avatar-hover-card { display: none; }
  .avatar-small:hover .avatar-edit-overlay,
  .identity-avatar-small:hover .avatar-edit-overlay { opacity: 0; }
  .message[data-age="msg-age-day"]:hover .message-body,
  .message[data-age="msg-age-old"]:hover .message-body { opacity: inherit; }

  /* ── Tap feedback via :active ── */
  .channel-item:active { background: var(--bg-sidebar-hover); }
  .sidebar-nav .nav-item:active { background: var(--bg-sidebar-hover); }
  .btn.btn-icon:active { color: var(--text-primary); background: var(--bg-sidebar-hover); }
  .reaction:active { transform: scale(0.92); }
  .ctx-menu-item:active { background: var(--bg-main-alt); }
  .ctx-menu-danger:active { background: color-mix(in srgb, var(--color-danger) 10%, transparent); }
  .message-action-btn:active,
  .message-action-emoji:active { background: var(--bg-sidebar-hover); }
  .search-result:active { background: var(--bg-message-hover); }
  .emoji-item:active { background: var(--bg-message-hover); }
  .bookmark-jump:active { background: rgba(var(--accent-rgb), 0.1); }
  .forward-room-item:active { background: var(--bg-main-alt); }
  .spotlight-result:active { background: var(--bg-message-hover); }
  .room-info-member:active { background: var(--bg-message-hover); }
  .bot-row:active { border-color: var(--accent); }
  .poll-option:active { border-color: var(--accent); }
  .pinned-panel-msg:active { border-color: var(--accent); }
  .thread-indicator:active { background: var(--bg-sidebar-hover); }

  /* ── Message actions on touch — toggled via .touch-active class ── */
  .message.touch-active > .message-actions {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
  }
}

/* ══════════════════════════════════════════════════════════════════
   REDUCED MOTION — respects user accessibility preference
   ══════════════════════════════════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
