@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── Discord-inspired Theme ── */
:root {
  --bg-primary: #313338;
  --bg-secondary: #2b2d31;
  --bg-tertiary: #1e1f22;
  --bg-surface: #383a40;
  --bg-surface-hover: #3e4047;
  --bg-input: #1e1f22;
  --bg-modifier-hover: rgba(255, 255, 255, 0.04);
  --bg-modifier-active: rgba(255, 255, 255, 0.08);
  --bg-modifier-selected: rgba(255, 255, 255, 0.12);
  --text-normal: #dbdee1;
  --text-muted: #949ba4;
  --text-link: #00a8fc;
  --text-positive: #23a55a;
  --text-warning: #f0b232;
  --text-danger: #f23f42;
  --accent: #5865f2;
  --accent-hover: #4752c4;
  --accent-active: #3c45a5;
  --accent-soft: rgba(88, 101, 242, 0.15);
  --green: #23a55a;
  --green-bg: rgba(35, 165, 90, 0.15);
  --red: #da373c;
  --red-bg: rgba(218, 55, 60, 0.15);
  --yellow: #f0b232;
  --yellow-bg: rgba(240, 178, 50, 0.15);
  --border-color: rgba(255, 255, 255, 0.06);
  --border-lighter: rgba(255, 255, 255, 0.1);
  --divider: rgba(255, 255, 255, 0.06);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --font-primary: 'Inter', 'gg sans', 'Helvetica Neue', 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Consolas', 'Courier New', monospace;
  --header-height: 48px;
  --sidebar-width: 240px;
  --server-bar-width: 72px;
  --members-width: 240px;
}

/* ── Light theme (Discord-like light) ── */
body[data-theme='light'] {
  --bg-primary: #ffffff;
  --bg-secondary: #f2f3f5;
  --bg-tertiary: #e3e5e8;
  --bg-surface: #ebedef;
  --bg-surface-hover: #e3e5e8;
  --bg-input: #e3e5e8;
  --bg-modifier-hover: rgba(0, 0, 0, 0.04);
  --bg-modifier-active: rgba(0, 0, 0, 0.08);
  --bg-modifier-selected: rgba(0, 0, 0, 0.12);
  --text-normal: #2e3035;
  --text-muted: #747f8d;
  --text-link: #0068e0;
  --border-color: rgba(0, 0, 0, 0.08);
  --border-lighter: rgba(0, 0, 0, 0.12);
  --divider: rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.16);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-primary);
  font-size: 14px;
  color: var(--text-normal);
  background: var(--bg-primary);
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

a {
  color: var(--text-link);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: var(--bg-surface);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--bg-surface-hover);
}

/* ── App Shell ── */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Server Bar (Discord-style narrow left bar) ── */
.server-bar {
  width: var(--server-bar-width);
  background: var(--bg-tertiary);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 0;
  gap: 8px;
  overflow-y: auto;
  flex-shrink: 0;
}

.server-bar-list {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.server-bar-item {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--bg-surface);
  border: none;
  color: var(--text-normal);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  transition: border-radius 0.15s ease, background 0.15s ease;
  position: relative;
  flex-shrink: 0;
}

.server-bar-item:hover {
  border-radius: 16px;
  background: var(--accent);
  color: #fff;
}

.server-bar-item.active {
  border-radius: 16px;
  background: var(--accent);
  color: #fff;
}

.server-bar-item.active::before,
.server-bar-item:hover::before {
  content: '';
  position: absolute;
  left: -12px;
  width: 4px;
  height: 20px;
  background: #fff;
  border-radius: 0 4px 4px 0;
}

.server-bar-divider {
  width: 32px;
  height: 2px;
  background: var(--bg-surface);
  border-radius: 1px;
  flex-shrink: 0;
}

.server-bar-home {
  background: var(--accent);
  color: #fff;
  border-radius: 16px;
}

.server-bar-home:hover {
  border-radius: 16px;
}

.server-bar-add {
  color: var(--green);
  font-size: 24px;
  font-weight: 300;
  background: var(--bg-surface);
  transition: border-radius 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.server-bar-add:hover {
  border-radius: 16px;
  background: var(--green);
  color: #fff;
}

/* ── Sidebar (Channel list area) ── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
}

/* ── Server Dropdown (Discord-style) ── */
.server-dropdown {
  position: absolute;
  top: var(--header-height);
  left: 0;
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 100;
  padding: 6px 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.server-dropdown-header {
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.server-dropdown-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-normal);
}

.server-dropdown-role {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.server-dropdown-divider {
  height: 1px;
  background: var(--border-color);
  margin: 4px 8px;
}

.server-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-normal);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease;
  text-align: left;
  width: 100%;
}

.server-dropdown-item:hover {
  background: var(--bg-modifier-hover);
}

.server-dropdown-item-danger {
  color: var(--red);
}

.server-dropdown-item-danger:hover {
  background: var(--red-bg);
}

/* ── Sidebar User Panel (Discord-style bottom) ── */
.sidebar-user-panel {
  position: relative;
  height: 52px;
  padding: 0 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-tertiary);
  flex-shrink: 0;
  transition: background 0.15s ease;
}

.sidebar-user-panel:hover {
  background: var(--bg-modifier-hover);
}

.sidebar-user-avatar {
  position: relative;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  font-size: 16px;
  flex-shrink: 0;
}

.sidebar-user-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  cursor: pointer;
}

.sidebar-user-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-normal);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-user-status {
  font-size: 11px;
  color: var(--text-positive);
  font-weight: 500;
}

.sidebar-user-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.sidebar-user-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: background 0.15s ease, color 0.15s ease;
}

.sidebar-user-btn:hover {
  background: var(--bg-modifier-hover);
  color: var(--text-normal);
}

.sidebar-header {
  height: var(--header-height);
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  flex-shrink: 0;
}

.sidebar-header.no-dropdown {
  cursor: default;
}

.sidebar-header.no-dropdown .collapse-icon {
  display: none;
}

.sidebar-header h2 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-normal);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-header:hover {
  background: var(--bg-modifier-hover);
}

.sidebar-sections {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.sidebar-channels {
  padding: 4px 0;
}

.sidebar-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 4px;
  cursor: pointer;
  user-select: none;
}

.sidebar-section-header h3 {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.sidebar-section-header:hover h3 {
  color: var(--text-normal);
}

.sidebar-section-header .collapse-icon {
  color: var(--text-muted);
  font-size: 10px;
  transition: transform 0.15s ease;
}

.sidebar-section-header.collapsed .collapse-icon {
  transform: rotate(-90deg);
}

/* ── #channelList overrides for Discord-style ── */
#channelList {
  display: flex;
  flex-direction: column;
}

/* ── Channel Items ── */
.channel-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  margin: 1px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-muted);
  font-size: 15px;
  font-weight: 500;
  border: none;
  background: transparent;
  width: calc(100% - 16px);
  text-align: left;
  transition: none;
}

.channel-item:hover {
  background: var(--bg-modifier-hover);
  color: var(--text-normal);
}

.channel-item.active {
  background: var(--bg-modifier-selected);
  color: var(--text-normal);
}

.channel-item .channel-icon {
  font-size: 18px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.channel-item .channel-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Server Info / Brand (moved to sidebar header area) ── */
.brand {
  display: none;
}

/* ── Server Card (moved to server bar) ── */
.server-card {
  display: none;
}

/* ── Server Switcher ── */
.server-switcher {
  display: none;
}

/* ── Channel List ── */
.channel-list {
  display: none;
}

/* ── Chat Panel ── */
.chat-panel {
  flex: 1;
  display: flex;
  min-width: 0;
  background: var(--bg-primary);
}

#chatView,
.admin-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  background: var(--bg-primary);
}

/* ── Chat Header ── */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
  flex-shrink: 0;
}

.chat-header h2 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-normal);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-header h2::before {
  content: '#';
  color: var(--text-muted);
  font-weight: 500;
}

.chat-header p {
  display: none;
}

.helper-text {
  display: none;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.settings-sidebar-heading h3 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-normal);
  margin-top: 4px;
}

.settings-eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.settings-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.settings-nav-item {
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-normal);
  border-radius: var(--radius-md);
  padding: 11px 12px;
  text-align: left;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.settings-nav-item:hover {
  background: var(--bg-modifier-hover);
}

.settings-nav-item.is-active {
  background: var(--accent-soft);
  border-color: rgba(88, 101, 242, 0.25);
  color: #fff;
}

.settings-close-btn {
  margin-top: auto;
}

.settings-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.status-pill {
  display: none;
}

.presence-pill {
  font-size: 12px;
  color: var(--text-muted);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  white-space: nowrap;
}

.toggle-members-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: background 0.15s ease, color 0.15s ease;
}

.toggle-members-btn:hover {
  background: var(--bg-modifier-hover);
  color: var(--text-normal);
}

/* ── Message List ── */
.message-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  background: var(--bg-primary);
}

/* ── Message Card (Discord-style) ── */
.message-card {
  display: flex;
  gap: 16px;
  padding: 2px 16px;
  align-items: flex-start;
  border: none;
  border-radius: 0;
  background: transparent;
  position: relative;
}

.message-card:hover {
  background: var(--bg-modifier-hover);
}

.message-card + .message-card {
  margin-top: 0;
}

/* Group consecutive messages from same author */
.message-card.same-author {
  padding-top: 1px;
  padding-bottom: 1px;
}

.message-card.same-author .message-avatar {
  visibility: hidden;
  width: 40px;
  height: 0;
}

.message-card.same-author .message-meta {
  display: none;
}

.message-card.same-author .message-content {
  margin-top: 0;
  padding-left: 56px;
}

.message-card.same-author .message-controls {
  top: 0;
}

.message-card.action-message .message-content {
  font-style: italic;
  color: var(--text-normal);
}

.message-card.action-message .message-meta {
  gap: 8px;
}

.message-avatar {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  margin-top: 0;
  cursor: pointer;
  transition: border-radius 0.15s ease;
}

.status-dot {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--bg-surface);
  box-sizing: content-box;
}

.sidebar-user-avatar .status-dot {
  right: -2px;
  bottom: -2px;
}

.status-dot.status-online {
  background: var(--text-positive);
}

.status-dot.status-away {
  background: var(--text-warning);
}

.status-dot.status-busy {
  background: var(--text-danger);
}

.status-dot.status-offline {
  background: var(--text-muted);
}

.status-picker-menu {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 8px;
  flex-direction: column;
  gap: 2px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 6px;
  min-width: 160px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  z-index: 20;
}

.status-picker-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-normal);
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}

.status-picker-option:hover {
  background: var(--bg-surface-hover);
}

.status-picker-option.is-active {
  background: var(--accent-soft);
  font-weight: 600;
}

.status-picker-option .status-dot {
  position: static;
  border: none;
  width: 8px;
  height: 8px;
}

.channel-title-status-dot {
  position: static;
  border: none;
  width: 9px;
  height: 9px;
  flex-shrink: 0;
}

.message-avatar:hover {
  border-radius: 12px;
}

.message-body {
  flex: 1;
  min-width: 0;
}

.message-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 2px;
  font-size: 12px;
}

.message-author {
  color: var(--text-normal);
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
}

.message-author:hover {
  text-decoration: underline;
}

.message-timestamp {
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 400;
}

.message-content {
  font-size: 15px;
  line-height: 1.4;
  color: var(--text-normal);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  margin-top: 0;
}

.mention-chip {
  display: inline;
  padding: 0 2px;
  border-radius: 3px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
}

.mention-chip:hover {
  background: var(--accent);
  color: #fff;
}

.message-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-size: 11px;
  background: var(--accent-soft);
  color: var(--accent);
  border: none;
  cursor: default;
}

[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-primary);
  color: var(--text-normal);
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.1s ease;
  z-index: 1300;
  box-shadow: var(--shadow-md);
}

[data-tooltip]:hover::after {
  opacity: 1;
}

.badge-employee {
  background: rgba(88, 101, 242, 0.2) !important;
  color: var(--accent) !important;
}

.badge-moderator {
  background: rgba(88, 101, 242, 0.2) !important;
  color: var(--accent) !important;
}

.badge-server-owner {
  background: var(--yellow-bg) !important;
  color: var(--yellow) !important;
}

.badge-server-admin {
  background: rgba(88, 101, 242, 0.2) !important;
  color: var(--accent) !important;
}

.badge-supporter {
  background: var(--green-bg) !important;
  color: var(--green) !important;
}

.message-controls {
  position: absolute;
  right: 16px;
  top: -12px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.1s ease;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 2px;
  box-shadow: var(--shadow-md);
  z-index: 10;
}

.message-card:hover .message-controls {
  opacity: 1;
}

.delete-btn {
  border: none;
  color: var(--text-muted);
  background: transparent;
  border-radius: var(--radius-sm);
  padding: 4px 6px;
  cursor: pointer;
  font-size: 12px;
  transition: background 0.15s ease, color 0.15s ease;
}

.delete-btn:hover {
  background: var(--red-bg);
  color: var(--red);
}

.react-trigger-btn {
  border: none;
  color: var(--text-muted);
  background: transparent;
  border-radius: var(--radius-sm);
  padding: 4px 6px;
  cursor: pointer;
  font-size: 12px;
  transition: background 0.15s ease, color 0.15s ease;
}

.react-trigger-btn:hover {
  background: var(--bg-modifier-hover);
  color: var(--text-normal);
}

.message-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.reaction-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--border-color);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
  background: var(--bg-surface);
  color: var(--text-normal);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.reaction-chip:hover {
  background: var(--bg-surface-hover);
}

.reaction-chip.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.reaction-picker-popover {
  position: fixed;
  z-index: 1150;
  display: flex;
  gap: 4px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 999px;
  box-shadow: var(--shadow-md), 0 12px 32px rgba(0, 0, 0, 0.35);
  padding: 6px;
  animation: settings-pop 0.12s ease-out;
}

.reaction-picker-option {
  border: none;
  background: transparent;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, transform 0.1s ease;
}

.reaction-picker-option:hover {
  background: var(--bg-modifier-hover);
  transform: scale(1.15);
}

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 15px;
  border: none;
  background: transparent;
}

.chat-command-notice {
  position: fixed;
  left: 50%;
  bottom: 88px;
  transform: translateX(-50%) translateY(12px);
  min-width: min(560px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-normal);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 1200;
  white-space: pre-line;
}

.chat-command-notice.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.chat-command-notice[data-tone='warn'] {
  border-color: rgba(240, 178, 50, 0.35);
}

.chat-command-notice[data-tone='error'] {
  border-color: rgba(218, 55, 60, 0.35);
}

/* ── Composer (Message Input) ── */
.composer {
  padding: 0 16px 24px;
  display: flex;
  gap: 0;
  background: transparent;
  border: none;
  box-shadow: none;
  flex-shrink: 0;
}

.composer-inner {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0 8px;
  width: 100%;
  transition: border-color 0.15s ease;
}

.composer-inner:focus-within {
  border-color: var(--accent);
}

#messageInput {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-normal);
  padding: 10px 8px;
  outline: none;
  font-size: 15px;
  font-weight: 400;
}

#messageInput::placeholder {
  color: var(--text-muted);
}

.composer button {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px 10px;
  font-size: 16px;
  border-radius: var(--radius-sm);
  transition: color 0.15s ease, background 0.15s ease;
  flex-shrink: 0;
}

.composer button:hover {
  color: var(--text-normal);
  background: var(--bg-modifier-hover);
}

.composer button[type="submit"] {
  color: var(--accent);
}

.composer button[type="submit"]:hover {
  background: var(--accent-soft);
}

/* ── Pending Attachment / Typing Indicator ── */
.pending-attachment-bar {
  padding: 8px 16px 0;
  display: flex;
  gap: 8px;
}

.pending-attachment-chip {
  position: relative;
  display: inline-flex;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 6px;
}

.pending-attachment-chip img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  display: block;
}

.pending-attachment-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: none;
  background: var(--red);
  color: #fff;
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.message-attachment {
  display: block;
  max-width: 360px;
  max-height: 300px;
  border-radius: var(--radius-md);
  margin-top: 6px;
  object-fit: cover;
}

.message-attachment-file,
.pending-attachment-chip .message-attachment-file {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  padding: 8px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-normal);
  text-decoration: none;
  font-size: 13px;
}

.message-attachment-file:hover {
  border-color: var(--accent);
}

.typing-indicator {
  min-height: 18px;
  padding: 0 16px;
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}

/* ── Icon Upload Styles ── */
.icon-upload-editor {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.icon-upload-preview {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--bg-surface);
  border: 2px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.icon-upload-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.icon-upload-preview span {
  font-size: 40px;
  color: var(--text-muted);
}

.icon-upload-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.user-icon-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

/* ── Poll Styles ── */
.poll-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px;
  margin: 8px 0;
  max-width: 600px;
}

.poll-content {
  margin-top: 8px;
}

.poll-question {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-normal);
  margin-bottom: 12px;
  line-height: 1.4;
}

.poll-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.poll-option {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 10px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-normal);
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
  text-align: left;
  width: 100%;
  overflow: hidden;
}

.poll-option:hover {
  background: var(--bg-surface-hover);
  border-color: var(--accent);
}

.poll-option:disabled,
.poll-option.is-voted {
  cursor: default;
}

.poll-option:disabled:hover {
  background: var(--bg-surface);
  border-color: var(--border-color);
}

.poll-option-text {
  font-weight: 500;
  position: relative;
  z-index: 1;
  word-break: break-word;
}

.poll-option-votes {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  position: relative;
  z-index: 1;
}

.poll-option-bar {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
  transition: width 0.3s ease;
  z-index: 0;
}

.poll-total {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  text-align: right;
}

.badge-poll {
  background: var(--green-bg) !important;
  color: var(--green) !important;
}

/* ── Members Panel ── */
.members-panel {
  width: var(--members-width);
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-color);
  padding: 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  flex-shrink: 0;
  transition: width 0.2s ease, padding 0.2s ease, opacity 0.2s ease;
}

.members-panel.hidden {
  width: 0;
  padding: 0;
  overflow: hidden;
  opacity: 0;
  border-left: none;
}

.members-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 8px 12px;
}

.members-panel-header h3 {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin: 0;
}

.members-close-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: background 0.15s ease, color 0.15s ease;
}

.members-close-btn:hover {
  background: var(--bg-modifier-hover);
  color: var(--text-normal);
}

.members-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.members-section-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding: 16px 8px 4px;
}

.server-user-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  cursor: pointer;
  transition: background 0.15s ease;
}

.server-user-item:hover {
  background: var(--bg-modifier-hover);
}

.server-user-item.self {
  background: var(--bg-modifier-selected);
}

.server-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

.server-user-name {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-normal);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.server-user-role {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  font-size: 11px;
  border-radius: 50%;
  background: var(--bg-surface);
  color: var(--text-muted);
  border: none;
  flex-shrink: 0;
}

.server-user-role.member {
  display: none;
}

.server-user-role.owner {
  background: var(--yellow-bg);
  color: var(--yellow);
}

.server-user-role.admin {
  background: var(--accent-soft);
  color: var(--accent);
}

.message-author.user-clickable {
  cursor: pointer;
}

.message-author.user-clickable:hover {
  text-decoration: underline;
}

/* ── User Info Popover ── */
.user-info-popover {
  position: fixed;
  z-index: 1100;
  width: 260px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: var(--shadow-md), 0 12px 32px rgba(0, 0, 0, 0.35);
  padding: 16px;
  animation: settings-pop 0.12s ease-out;
}

.user-info-popover-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-info-popover-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 18px;
  flex-shrink: 0;
  overflow: hidden;
}

.user-info-popover-titles {
  min-width: 0;
}

.user-info-popover-titles h4 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-normal);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-info-popover-handle {
  font-size: 12px;
  color: var(--text-muted);
}

.user-info-popover-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.user-info-popover-badges:empty {
  display: none;
}

.user-info-popover-badges .message-badge {
  font-size: 11px;
}

.user-info-popover-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
}

.user-info-popover-actions:empty {
  display: none;
}

.user-info-popover-action,
.user-info-popover-action-danger {
  width: 100%;
  text-align: center;
}

.user-info-popover-action-danger {
  background: var(--red-bg);
  color: var(--red);
}

/* ── Direct Messages Sidebar List ── */
.dm-sidebar-item-avatar {
  width: 24px;
  height: 24px;
  font-size: 11px;
  flex-shrink: 0;
}

/* ── Search Modal ── */
.search-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(12px);
  display: grid;
  place-items: center;
  z-index: 1000;
  padding: 16px;
}

.search-dialog {
  width: min(640px, 100%);
  height: min(600px, calc(100vh - 32px));
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.45);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: settings-pop 0.18s ease-out;
}

.search-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.search-dialog-header h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-normal);
}

.search-input-row {
  padding: 12px 20px;
  flex-shrink: 0;
}

#searchInput {
  width: 100%;
  background: var(--bg-surface);
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text-normal);
  font-size: 14px;
}

#searchInput:focus {
  outline: 2px solid var(--accent);
}

.search-results-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.search-result-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  cursor: pointer;
  transition: background 0.15s ease;
}

.search-result-item:hover {
  background: var(--bg-modifier-hover);
}

.search-result-context {
  font-size: 12px;
  color: var(--text-muted);
}

.search-result-snippet {
  font-size: 14px;
  color: var(--text-normal);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-results-truncated {
  padding: 10px 12px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

.search-highlight {
  background: rgba(88, 101, 242, 0.35);
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}

.search-empty-state {
  padding: 32px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

.create-server-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.create-server-body label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 8px;
}

.create-server-body label:first-child {
  margin-top: 0;
}

.create-server-body input,
.create-server-body textarea {
  width: 100%;
  background: var(--bg-surface);
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text-normal);
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
}

.create-server-body input:focus,
.create-server-body textarea:focus {
  outline: 2px solid var(--accent);
}

.create-server-body textarea {
  min-height: 60px;
}

.create-server-body .secondary-btn {
  margin-top: 8px;
  align-self: flex-start;
}

.message-card.message-highlight {
  background: rgba(88, 101, 242, 0.25);
  transition: background 1.6s ease;
}

/* ── Unread Indicators ── */
.unread-dot {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--red);
  border: 2px solid var(--bg-tertiary);
  pointer-events: none;
}

.unread-badge {
  margin-left: auto;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--red);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ── Admin View ── */
.admin-view {
  background: var(--bg-primary);
}

.admin-panel {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  flex: 1;
  background: transparent;
  border: none;
  box-shadow: none;
}

.admin-group {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px;
  background: var(--bg-secondary);
}

.admin-group h3 {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin: 0 0 12px;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
}

.admin-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.admin-section label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.admin-section input,
.admin-section select {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-normal);
  padding: 8px 10px;
  outline: none;
  font-size: 14px;
  transition: border-color 0.15s ease;
}

.admin-section input:focus,
.admin-section select:focus {
  border-color: var(--accent);
}

.admin-section input::placeholder {
  color: var(--text-muted);
}

.admin-actions-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.admin-section button {
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 500;
  background: var(--accent);
  color: #fff;
  transition: background 0.15s ease;
}

.admin-section button:hover {
  background: var(--accent-hover);
}

.admin-section button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Status Board ── */
.status-board {
  padding: 16px;
  background: transparent;
  border: none;
  box-shadow: none;
}

.status-board-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.status-board-header h3 {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin: 0;
}

.status-lists-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
}

.status-list-card {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px;
  background: var(--bg-secondary);
}

.status-list-card h4 {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin: 0 0 8px;
}

.status-list {
  margin: 0;
  padding-left: 16px;
  max-height: 148px;
  overflow-y: auto;
  color: var(--text-normal);
  font-size: 14px;
}

.status-list li {
  margin-bottom: 4px;
}

.status-list-item-btn {
  width: 100%;
  text-align: left;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-normal);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.15s ease;
}

.status-list-item-btn:hover {
  background: var(--bg-surface-hover);
}

/* ── Settings Modal ── */
.settings-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(12px);
  display: grid;
  place-items: center;
  z-index: 1000;
  padding: 16px;
}

.settings-dialog {
  width: min(980px, 100%);
  height: min(820px, calc(100vh - 32px));
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.45);
  overflow: hidden;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  animation: settings-pop 0.18s ease-out;
}

.settings-sidebar {
  background: var(--bg-tertiary);
  border-right: 1px solid var(--border-color);
  padding: 20px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.settings-sidebar-heading {
  padding: 0 6px;
}

.settings-sidebar-heading h3 {
  margin-top: 4px;
  font-size: 24px;
  line-height: 1.1;
  font-weight: 700;
  color: var(--text-normal);
}

.settings-sidebar-user {
  margin-top: 6px;
  color: var(--text-muted);
  font-size: 13px;
}

.settings-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.settings-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 4px;
  padding: 9px 10px;
  text-align: left;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}

.settings-nav-item::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--text-muted);
  opacity: 0.5;
  flex-shrink: 0;
}

.settings-nav-item:hover {
  background: var(--bg-modifier-hover);
  color: var(--text-normal);
}

.settings-nav-item.is-active {
  background: var(--bg-modifier-active);
  color: var(--text-normal);
}

.settings-nav-item.is-active::before {
  background: var(--accent);
  opacity: 1;
}

.settings-sidebar-footer {
  margin-top: auto;
  padding: 0 6px;
}

.settings-close-btn {
  width: 100%;
}

.settings-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-primary);
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
  background: var(--bg-secondary);
}

.settings-header h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-normal);
  margin: 0;
}

.settings-subtitle {
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 13px;
}

.settings-close-x {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 999px;
  background: var(--bg-surface);
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
}

.settings-close-x:hover {
  background: var(--bg-surface-hover);
  color: var(--text-normal);
}

.settings-panels {
  padding: 24px;
  overflow-y: auto;
  display: grid;
  gap: 16px;
}

.settings-panel {
  display: none;
  gap: 12px;
}

.settings-panel.is-active {
  display: grid;
}

.settings-profile-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  border-radius: 12px;
  background: linear-gradient(180deg, var(--bg-surface), var(--bg-secondary));
  border: 1px solid var(--border-color);
}

.settings-profile-avatar {
  width: 56px;
  height: 56px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  font-size: 24px;
  background: linear-gradient(135deg, rgba(88, 101, 242, 0.25), rgba(88, 101, 242, 0.08));
  border: 1px solid var(--border-color);
  flex-shrink: 0;
}

.settings-profile-card strong {
  display: block;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-normal);
}

.settings-profile-card p {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 13px;
}

.settings-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-radius: 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
}

.settings-item-stack {
  flex-direction: column;
  align-items: flex-start;
}

.settings-item-stack > div:first-child {
  width: 100%;
}

.settings-item strong {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-normal);
}

.settings-item p {
  margin: 2px 0 0;
  color: var(--text-muted);
  font-size: 13px;
}

.settings-actions {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

@keyframes settings-pop {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.display-name-editor {
  width: 100%;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.display-name-editor label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.display-name-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
}

.display-name-row input {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-secondary);
  color: var(--text-normal);
  padding: 8px 10px;
  outline: none;
  font-size: 14px;
  transition: border-color 0.15s ease;
}

.display-name-row input:focus {
  border-color: var(--accent);
}

.display-name-row input::placeholder {
  color: var(--text-muted);
}

.twofactor-editor {
  width: 100%;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.twofactor-editor input[type='text'],
.twofactor-editor input[type='password'] {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-secondary);
  color: var(--text-normal);
  padding: 8px 10px;
  outline: none;
  font-size: 14px;
  transition: border-color 0.15s ease;
}

.twofactor-editor input:focus {
  border-color: var(--accent);
}

.twofactor-qr-wrap {
  display: flex;
  justify-content: center;
  padding: 12px;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid var(--border-color);
}

.twofactor-qr-wrap img {
  width: 176px;
  height: 176px;
  image-rendering: pixelated;
}

.link-btn {
  align-self: flex-start;
  border: none;
  background: none;
  padding: 0;
  color: var(--accent);
  font-size: 13px;
  cursor: pointer;
  text-decoration: underline;
}

.link-btn:hover {
  opacity: 0.85;
}

.twofactor-secret-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  align-items: center;
}

.twofactor-secret-row code {
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  font-size: 13px;
  letter-spacing: 0.04em;
  word-break: break-all;
}

.twofactor-confirm-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 6px;
}

.twofactor-recovery-codes {
  padding: 10px;
  border-radius: 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-all;
}

.twofactor-recovery-actions {
  display: flex;
  gap: 6px;
}

.twofactor-recovery-remaining {
  font-size: 13px;
  color: var(--text-muted);
}

/* ── Buttons ── */
.logout-btn,
.secondary-btn {
  border: none;
  border-radius: 8px;
  cursor: pointer;
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 600;
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.logout-btn {
  width: 100%;
  background: var(--red-bg);
  color: #fff;
}

.logout-btn:hover {
  background: rgba(218, 55, 60, 0.25);
}

.secondary-btn {
  background: var(--bg-surface);
  color: var(--text-normal);
}

.secondary-btn {
  background: var(--bg-surface);
  color: var(--text-normal);
}

.secondary-btn:hover {
  background: var(--bg-surface-hover);
}

.secondary-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Switch Toggle ── */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 999px;
  transition: 0.2s ease;
}

.slider::before {
  content: '';
  position: absolute;
  height: 18px;
  width: 18px;
  left: 2px;
  top: 2px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: 0.2s ease;
}

.switch input:checked + .slider {
  background: var(--accent);
  border-color: var(--accent);
}

.switch input:checked + .slider::before {
  transform: translateX(20px);
  background: #fff;
}

/* ── Login Page ── */
.login-page {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
  background: var(--bg-tertiary);
}

.login-container {
  width: 100%;
  max-width: 440px;
  padding: 32px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.login-container .brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 24px;
  gap: 8px;
}

.login-container .brand-badge {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  background: var(--accent);
  color: #fff;
}

.login-container h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-normal);
  margin: 0;
}

.login-container .brand p {
  font-size: 14px;
  color: var(--text-muted);
  margin: 0;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-form h2 {
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin: 0 0 4px;
}

.login-form input {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-normal);
  padding: 10px 12px;
  outline: none;
  font-size: 15px;
  transition: border-color 0.15s ease;
}

.login-form input:focus {
  border-color: var(--accent);
}

.login-form input::placeholder {
  color: var(--text-muted);
}

.login-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 4px;
}

.login-actions button {
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s ease;
}

.login-actions button:not(.secondary) {
  background: var(--accent);
  color: #fff;
}

.login-actions button:not(.secondary):hover {
  background: var(--accent-hover);
}

.login-actions button.secondary {
  background: var(--bg-surface);
  color: var(--text-normal);
}

.login-actions button.secondary:hover {
  background: var(--bg-surface-hover);
}

.error-message {
  margin: 4px 0 0;
  color: var(--red);
  font-size: 13px;
}

/* ── Employee Role Badge ── */
.employee-role-badge,
.server-role-badge {
  display: inline-block;
  width: fit-content;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  border: none;
}

.employee-role-badge {
  background: var(--accent-soft);
  color: var(--accent);
}

.server-role-badge {
  background: var(--bg-surface);
  color: var(--text-muted);
}

/* ── Hidden / Legacy ── */
.panel-card,
.panel-card label,
.panel-card input,
.panel-card button,
#dmButton,
#loginButton,
#registerButton,
.auth-actions,
.auth-status,
#usernameInput {
  display: none;
}

/* ── Responsive ── */
@media (max-width: 1160px) {
  :root {
    --sidebar-width: 220px;
    --members-width: 220px;
  }
}

@media (max-width: 900px) {
  .app-shell {
    flex-direction: column;
  }

  .server-bar {
    width: 100%;
    height: 56px;
    flex-direction: row;
    padding: 0 12px;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 4px;
  }

  .server-bar-item {
    width: 40px;
    height: 40px;
    font-size: 16px;
    flex-shrink: 0;
  }

  .server-bar-item.active::before,
  .server-bar-item:hover::before {
    display: none;
  }

  .server-bar-divider {
    width: 2px;
    height: 32px;
  }

  .sidebar {
    width: 100%;
    max-height: 40vh;
    border-bottom: 1px solid var(--border-color);
  }

  .members-panel {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    z-index: 500;
    box-shadow: var(--shadow-lg);
  }

  .members-panel.hidden {
    transform: translateX(100%);
    width: var(--members-width);
    padding: 16px 8px;
    opacity: 1;
    border-left: 1px solid var(--border-color);
  }

  .chat-panel {
    height: auto;
    min-height: 50vh;
  }

  .composer {
    padding: 0 12px 12px;
  }
}

@media (max-width: 560px) {
  .sidebar {
    max-height: 35vh;
  }

  .admin-grid,
  .status-lists-grid {
    grid-template-columns: 1fr;
  }

  .login-container {
    padding: 24px;
  }

  .settings-modal {
    padding: 10px;
  }

  .settings-dialog {
    grid-template-columns: 1fr;
    width: min(100%, calc(100vw - 20px));
    height: calc(100vh - 20px);
  }

  .settings-sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    padding: 16px;
  }

  .settings-nav {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .settings-nav-item {
    flex: 1 1 120px;
  }

  .settings-header,
  .settings-panels {
    padding: 16px;
  }

  .settings-item,
  .settings-profile-card {
    flex-direction: column;
    align-items: flex-start;
  }

  .settings-actions,
  .display-name-row,
  .twofactor-secret-row,
  .twofactor-confirm-row {
    grid-template-columns: 1fr;
  }
}