*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

:root {
  --bg:          #0f0f13;
  --sidebar-bg:  #14141a;
  --chat-bg:     #1a1a24;
  --input-bg:    #1e1e2c;
  --card-bg:     #1e1e2c;
  --border:      rgba(255,255,255,.06);
  --text:        #e8e8f0;
  --text-muted:  #6b7280;
  --text-light:  #9ca3af;
  --accent:      #3b82f6;
  --accent-hover:#2563eb;
  --bubble-own:  #2563eb;
  --bubble-other:#232335;
  --online:      #22c55e;
  --danger:      #ef4444;
  --radius:      12px;
  --radius-sm:   8px;
  --transition:  .18s ease;
  --keyboard-offset: 0px;
}

html, body {
  height: 100%;
  height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; color: inherit; font: inherit; }
input, textarea { font: inherit; color: inherit; background: none; border: none; outline: none; }
img { display: block; max-width: 100%; }
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 4px; }

#app {
  display: flex;
  height: 100vh;
  height: 100dvh;
  height: calc(100dvh - var(--keyboard-offset, 0px));
  width: 100vw;
  overflow: hidden;
  position: relative;
}

.account-blocked-screen {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  color: var(--text);
  font-size: 28px;
  font-weight: 700;
  text-align: center;
  padding: 24px;
}

.account-freeze-banner {
  width: 100%;
  border: 1px solid rgba(245,158,11,.35);
  background: rgba(245,158,11,.12);
  color: #fbbf24;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}

#accountFreezeBanner {
  margin: 10px 12px 0;
  width: auto;
}

.chat-account-freeze {
  margin: 0 auto;
  max-width: 360px;
}

.peer-restriction {
  margin: 8px 12px 0;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  border: 1px solid rgba(148, 163, 184, 0.3);
  background: rgba(148, 163, 184, 0.12);
  color: var(--text-light);
}

.peer-restriction.banned {
  border-color: rgba(239, 68, 68, 0.35);
  background: rgba(239, 68, 68, 0.12);
  color: #fca5a5;
}

.peer-restriction.frozen {
  border-color: rgba(245, 158, 11, 0.35);
  background: rgba(245, 158, 11, 0.12);
  color: #fbbf24;
}

body[data-account-status="frozen"] #newChatBtn {
  opacity: .45;
  pointer-events: none;
}

.search-section-label {
  padding: 8px 14px 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
}

#loginScreen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  z-index: 100;
  padding:
    env(safe-area-inset-top, 0px)
    env(safe-area-inset-right, 0px)
    env(safe-area-inset-bottom, 0px)
    env(safe-area-inset-left, 0px);
}

.login-card {
  width: 360px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 40px 32px;
  text-align: center;
}

.login-logo {
  width: 56px;
  height: 56px;
  background: var(--accent);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  font-size: 26px;
}

.login-card h1 { font-size: 22px; font-weight: 700; margin-bottom: 8px; }
.login-card p  { color: var(--text-muted); margin-bottom: 28px; font-size: 13px; }

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 14px;
  transition: background var(--transition);
  width: 100%;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { transform: scale(.98); }

.login-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 14px;
  transition: background var(--transition), border-color var(--transition);
  width: 100%;
  cursor: pointer;
}
.btn-secondary:hover { background: var(--card-bg); border-color: var(--accent); }
.btn-secondary:active { transform: scale(.98); }

.phone-choice-card {
  width: min(420px, calc(100vw - 32px));
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 30px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 22px;
  background: rgba(30, 30, 44, 0.94);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.42);
}

.phone-choice-icon {
  width: 58px;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 18px;
  color: #bfdbfe;
  background: rgba(59, 130, 246, 0.16);
}

.phone-choice-title {
  font-size: 24px;
  line-height: 1.2;
  font-weight: 700;
  color: var(--text);
}

.phone-choice-subtitle {
  margin-top: -8px;
  color: var(--text-muted);
  font-size: 14px;
}

.phone-choice-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
}

.phone-choice-option {
  width: 100%;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid rgba(59, 130, 246, 0.28);
  border-radius: 14px;
  background: rgba(20, 20, 30, 0.86);
  color: var(--text);
  font-weight: 650;
  transition: background var(--transition), border-color var(--transition), transform var(--transition);
}

.phone-choice-option:hover {
  transform: translateY(-1px);
  border-color: rgba(59, 130, 246, 0.7);
  background: rgba(37, 99, 235, 0.18);
}

.phone-choice-option:disabled {
  cursor: wait;
  opacity: 0.62;
  transform: none;
}

.phone-choice-option span:first-child {
  min-width: 0;
  overflow-wrap: anywhere;
  letter-spacing: 0;
}

.phone-choice-arrow {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.2);
  color: #bfdbfe;
  font-size: 24px;
  line-height: 1;
}

.phone-choice-loading .phone-choice-option:not(:disabled) {
  pointer-events: none;
  opacity: 0.56;
}

#sidebar {
  width: 320px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}
.sidebar-body {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 16px 12px;
  border-bottom: 1px solid var(--border);
}
.sidebar-header h2 { font-size: 17px; font-weight: 700; }
#newChatBtn { position: relative; }

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: background var(--transition), color var(--transition);
}
.icon-btn:hover { background: rgba(255,255,255,.07); color: var(--text); }

.call-btn.call-btn-ringing {
  color: var(--accent);
  background: rgba(59,130,246,.14);
  animation: pulse 1.1s infinite;
}

.call-btn.call-btn-active {
  color: var(--danger);
  background: rgba(239,68,68,.16);
}

.search-wrap {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.search-wrap input {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px 8px 36px;
  font-size: 13px;
  transition: border-color var(--transition);
}
.search-wrap input:focus { border-color: var(--accent); }
.search-box { position: relative; }
.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.chat-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}

.chat-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background var(--transition);
  border-radius: 0;
  position: relative;
}
.chat-item:hover  { background: rgba(255,255,255,.04); }
.chat-item.active { background: rgba(59,130,246,.15); }

.avatar {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  overflow: hidden;
  position: relative;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar video { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 32px; height: 32px; font-size: 12px; }

.online-dot {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--online);
  border: 2px solid var(--sidebar-bg);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.05);
  pointer-events: none;
}

.avatar.avatar-with-presence {
  overflow: visible;
}
.avatar.avatar-with-presence > img,
.avatar.avatar-with-presence > video {
  border-radius: 50%;
}

.chat-item-info { flex: 1; min-width: 0; }
.chat-item-name {
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  overflow: hidden;
}
.chat-item-name-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.chat-item-preview {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 3px;
}
.chat-read-mark {
  font-size: 12px;
  flex-shrink: 0;
  line-height: 1;
}
.chat-read-mark.read   { color: var(--accent); }
.chat-read-mark.unread { color: var(--text-muted); }
.chat-preview-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-item-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}
.chat-item-time { font-size: 11px; color: var(--text-muted); }
.unread-badge {
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  border-radius: 10px;
  padding: 2px 6px;
  min-width: 18px;
  text-align: center;
}

.chat-list-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
}
.chat-list-empty svg { margin: 0 auto 16px; opacity: .4; }

#chatArea {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  background: var(--chat-bg);
  height: 100%;
  overflow: hidden;
}

.chat-placeholder {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  color: var(--text-muted);
  opacity: .5;
}
.chat-placeholder svg { opacity: .3; }

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--chat-bg);
  flex-shrink: 0;
}
.chat-header-info { flex: 1; min-width: 0; }
.chat-header-name {
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
}
.chat-header .avatar-sm {
  width: 40px;
  height: 40px;
  font-size: 14px;
}

.chat-header-name {
  font-size: 16px;
  font-weight: 700;
}

#messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.msg-row {
  display: flex;
  max-width: 72%;
  gap: 8px;
  align-items: flex-end;
}
.msg-row.system-row {
  max-width: 100%;
  justify-content: center;
}
.msg-system {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.04);
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
}

.msg-system-time {
  font-size: 11px;
  color: rgba(255,255,255,.52);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.msg-row.own {
  align-self: flex-end;
  justify-content: flex-end;
}
.msg-row.other { align-self: flex-start; }

.msg-row-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  overflow: hidden;
  cursor: pointer;
}
.msg-row-avatar img { width: 100%; height: 100%; object-fit: cover; }
.msg-row-avatar video { width: 100%; height: 100%; object-fit: cover; }
.msg-row-avatar-placeholder { width: 32px; flex-shrink: 0; }

.msg-stack {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
}
.own-stack { align-items: flex-end; }

.msg-bubble {
  display: block;
  padding: 8px 12px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  width: fit-content;
  max-width: min(72vw, 520px);
  min-width: 0;
  align-self: flex-start;
}
.msg-row.own .msg-bubble { align-self: flex-end; }
.msg-row.own   .msg-bubble { background: var(--bubble-own);   border-bottom-right-radius: 4px; color: #fff; }
.msg-row.other .msg-bubble { background: var(--bubble-other); border-bottom-left-radius: 4px; }

.msg-bubble-media-only {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  padding: 0;
  border-radius: 14px;
  overflow: hidden;
  background: transparent !important;
  width: fit-content;
  max-width: 100%;
  align-self: flex-start;
}
.msg-row.own .msg-bubble-media-only { align-self: flex-end; }
.msg-row.own .msg-bubble-media-only {
  padding: 0 4px;
  padding-top: 2px;
  background: var(--bubble-own) !important;
  border-bottom-right-radius: 6px;
}
.msg-bubble-media-only .msg-media,
.msg-bubble-media-only .msg-album {
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 0;
  flex-shrink: 0;
}
.msg-bubble-media-only > .msg-media:not([style]) {
  width: min(280px, 72vw);
}
.msg-bubble-media-only .msg-meta {
  position: absolute;
  right: 10px;
  bottom: 10px;
  float: none;
  margin: 0;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(0,0,0,.45);
  color: rgba(255,255,255,.92);
  line-height: 1.2;
  z-index: 2;
}
.msg-row.own .msg-bubble-media-only .msg-meta {
  right: 10px;
  bottom: 10px;
}

.msg-bubble-pending {
  position: relative;
  opacity: .92;
}
.msg-bubble-pending.msg-bubble-media-only {
  overflow: visible;
}
.msg-bubble.msg-bubble-pending.msg-bubble-has-media {
  padding: 0 4px 2px;
  padding-top: 2px;
  display: inline-flex;
  flex-direction: column;
  width: fit-content;
  max-width: min(280px, 100%);
  border-radius: 14px;
  overflow: visible;
  align-self: flex-end;
}
.msg-bubble-album-caption {
  display: inline-flex !important;
  flex-direction: column;
  padding: 0 0 6px 0;
  max-width: min(280px, 72vw);
}
.msg-bubble-album-caption .album-caption {
  padding-left: 8px;
  padding-right: 8px;
}
.msg-bubble-album-caption .msg-meta {
  padding-left: 8px;
  padding-right: 8px;
  align-self: flex-end;
}

.msg-bubble-upload-progress {
  padding-bottom: 40px;
}

.msg-upload-progress {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  min-height: 24px;
  display: none;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(0,0,0,.28);
}

.msg-upload-progress.active {
  display: inline-flex;
}

.msg-upload-progress-circle {
  width: 18px;
  height: 18px;
  display: inline-flex;
  flex-shrink: 0;
}

.msg-upload-progress-circle svg {
  width: 100%;
  height: 100%;
}

.msg-upload-progress-track,
.msg-upload-progress-bar {
  fill: none;
  stroke-width: 3.5;
}

.msg-upload-progress-track {
  stroke: rgba(255,255,255,.26);
}

.msg-upload-progress-bar {
  stroke: rgba(255,255,255,.95);
  stroke-linecap: round;
  stroke-dasharray: 87.9645943005;
  stroke-dashoffset: 87.9645943005;
  transform-origin: center;
  transform: rotate(-90deg);
  transition: stroke-dashoffset .14s linear;
}

.msg-upload-progress-info {
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.12;
  gap: 1px;
}

.msg-upload-progress-main {
  font-size: 11px;
  font-weight: 700;
  color: rgba(255,255,255,.96);
}

.msg-upload-progress-sub {
  font-size: 10px;
  color: rgba(255,255,255,.74);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.msg-upload-progress.indeterminate .msg-upload-progress-circle svg {
  animation: msg-upload-progress-spin 1s linear infinite;
}

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

.msg-upload-progress.active + .msg-upload-spinner {
  display: none;
}

.msg-upload-spinner {
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.msg-upload-spinner .loader {
  width: 14px;
  height: 14px;
  border-width: 2px;
  border-top-color: rgba(255,255,255,.95);
}

.msg-meta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: rgba(255,255,255,.5);
  white-space: nowrap;
  float: right;
  margin-left: 8px;
  margin-top: 2px;
  margin-bottom: -2px;
}
.msg-row.other .msg-meta { color: rgba(255,255,255,.92); }

.msg-checks {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,.55);
  transition: color var(--transition);
  margin-left: 2px;
}

.msg-checks.pending {
  opacity: .6;
}

.msg-checks.delivered {
  color: rgba(255,255,255,.75);
}

.msg-checks.read {
  color: #60a5fa;
}

.msg-sender {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 2px;
  padding: 0 4px;
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  overflow: hidden;
}
.msg-sender-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.msg-sender-link { cursor: pointer; }
.msg-sender-link:hover { text-decoration: underline; }

.msg-reply-ref {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin-bottom: 4px;
  padding: 5px 7px;
  border-radius: 10px;
  background: rgba(255,255,255,.08);
  white-space: normal;
  line-height: 1.3;
}
.msg-row.own .msg-reply-ref { background: rgba(255,255,255,.14); }
.msg-reply-ref-line {
  width: 3px;
  border-radius: 3px;
  background: rgba(255,255,255,.9);
  flex-shrink: 0;
}
.msg-reply-ref-content { min-width: 0; flex: 1; }
.msg-reply-ref-title {
  font-size: 11px;
  font-weight: 700;
  opacity: .95;
}
.msg-reply-ref-text {
  font-size: 12px;
  opacity: .9;
  display: -webkit-box;
  line-clamp: 2;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: normal;
  word-break: break-word;
}

.msg-avatar { display: none; }
.msg-sender-hidden { display: none; }

.msg-audio {
  width: min(360px, 100%);
  margin-bottom: 4px;
  display: flex;
  align-items: stretch;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.08);
  background: linear-gradient(180deg, rgba(35,35,53,.98), rgba(35,35,53,.9));
}

.msg-row.own .msg-audio {
  border-color: rgba(147,197,253,.35);
  background: linear-gradient(180deg, rgba(37,99,235,.5), rgba(37,99,235,.34));
}

.msg-audio-play {
  width: 34px;
  height: 34px;
  border: 0;
  padding: 0;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: center;
  color: rgba(255,255,255,.95);
  background: rgba(255,255,255,.18);
  flex-shrink: 0;
  cursor: pointer;
  transition: transform .18s ease, background .18s ease;
}

.msg-audio-play:hover {
  transform: scale(1.05);
  background: rgba(255,255,255,.28);
}

.msg-audio-play svg {
  width: 16px;
  height: 16px;
}

.msg-audio-wave {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 2px;
  flex: 1;
  min-width: 0;
  height: 24px;
  padding: 0 2px;
  cursor: pointer;
  touch-action: pan-y;
}

.msg-audio-wave.is-seeking {
  cursor: ew-resize;
}

.msg-audio-main {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.msg-audio-footer {
  min-height: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.msg-audio-bar {
  width: 4px;
  border-radius: 999px;
  background: #ffffff;
  opacity: .14;
  transition: opacity .08s linear;
}

.msg-audio.is-playing .msg-audio-bar {
  opacity: .14;
}

.msg-audio-bar.active {
  opacity: 1;
  box-shadow: 0 0 4px rgba(255,255,255,.36);
}

.msg-audio-time {
  min-width: 40px;
  text-align: left;
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  color: rgba(255,255,255,.82);
  flex-shrink: 0;
}

.msg-audio-msg-meta {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: rgba(255,255,255,.56);
  white-space: nowrap;
}

.msg-row.other .msg-audio-msg-meta {
  color: rgba(255,255,255,.92);
}

.msg-audio-msg-time {
  font-variant-numeric: tabular-nums;
}

.msg-audio-native {
  display: none;
}

.date-divider {
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  margin: 12px 0 8px;
  position: relative;
}
.date-divider::before, .date-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: calc(50% - 60px);
  height: 1px;
  background: var(--border);
}
.date-divider::before { left: 0; }
.date-divider::after  { right: 0; }

.msg-media {
  max-width: min(280px, 100%);
  border-radius: var(--radius-sm);
  box-sizing: border-box;
  border: 1px solid rgba(255,255,255,.14);
  overflow: hidden;
  cursor: pointer;
  margin-bottom: 0;
  line-height: 0;
  font-size: 0;
}
.msg-media img, .msg-media video {
  width: 100%;
  height: auto;
  max-width: 100%;
  display: block;
  border-radius: var(--radius-sm);
  object-fit: contain;
}

.msg-video-thumb {
  position: relative;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.4);
}
.msg-video-thumb-imgwrap {
  position: absolute;
  inset: 0;
  z-index: 1;
}
.msg-video-thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: var(--radius-sm);
}
.msg-video-thumb video {
  position: relative;
  z-index: 0;
}
.msg-video-thumb-btn {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  pointer-events: none;
}
.msg-round-wrap {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
}
.msg-round {
  position: relative;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  overflow: hidden;
  cursor: pointer;
  flex-shrink: 0;
  background: #fff;
  display: block;
  box-shadow: 0 2px 8px rgba(0,0,0,.22);
}
.msg-round-watermark {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  pointer-events: none;
  z-index: 0;
}
.msg-round-watermark span {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: rgba(160,160,185,.4);
  letter-spacing: .5px;
  user-select: none;
}
.msg-round-thumb {
  position: absolute;
  inset: 0;
  z-index: 2;
  transition: opacity .2s;
}
.msg-round-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.msg-round video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  z-index: 1;
}
.msg-round-play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
  transition: opacity .15s;
}
.msg-round-play svg { filter: drop-shadow(0 1px 3px rgba(0,0,0,.5)); }
.msg-round.playing .msg-round-play { opacity: 0; pointer-events: none; }
.msg-round-progress {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
  opacity: 0;
  transition: opacity .2s;
}
.msg-round.playing .msg-round-progress { opacity: 1; }
.msg-round-progress circle {
  fill: none;
  stroke: rgba(255,255,255,.85);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 659;
  stroke-dashoffset: 659;
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
  transition: stroke-dashoffset .1s linear;
}
.msg-round-duration {
  position: absolute;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,.7);
  pointer-events: none;
  white-space: nowrap;
  z-index: 5;
  opacity: 0;
  transition: opacity .2s;
}
.msg-round.playing .msg-round-duration { opacity: 1; }
.msg-round-meta {
  font-size: 11px;
  color: rgba(255,255,255,.7);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 0 2px;
}

.round-recorder {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.round-recorder-circle-wrap {
  position: relative;
  width: min(80vw, 360px);
  height: min(80vw, 360px);
  pointer-events: auto;
}
.round-recorder-preview {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  overflow: hidden;
  background: #0a0a0a;
}
.round-recorder-preview video,
.round-recorder-preview canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.round-recorder-ring {
  position: absolute;
  inset: -3px;
  width: calc(100% + 6px);
  height: calc(100% + 6px);
  pointer-events: none;
}
.round-recorder-ring circle {
  fill: none;
  stroke: rgba(255,255,255,.9);
  stroke-width: 3;
  stroke-linecap: butt;
  stroke-dasharray: 659;
  stroke-dashoffset: 659;
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
  transition: stroke-dashoffset .12s linear;
}
.round-recorder-flip {
  position: absolute;
  bottom: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(0,0,0,.5);
  border: 1px solid rgba(255,255,255,.15);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,.85);
  pointer-events: auto;
}
.round-recorder-flip svg { opacity: .85; }
.round-recorder-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 0;
  pointer-events: auto;
  background: rgba(15,15,20,.88);
  border-top: 1px solid rgba(255,255,255,.06);
}
.round-recorder-cancel {
  background: none;
  border: none;
  color: rgba(255,255,255,.55);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: .2px;
  cursor: pointer;
  padding: 10px 0;
  flex-shrink: 0;
}
.round-recorder-timer {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.round-recorder-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #e05050;
  animation: rr-blink 1s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes rr-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: .15; }
}
.round-recorder-time {
  color: rgba(255,255,255,.9);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  letter-spacing: .3px;
  font-weight: 400;
}
.round-recorder-send {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,.9);
  flex-shrink: 0;
}
.round-recorder-send:active { background: rgba(255,255,255,.2); }
.round-recorder.loading .round-recorder-preview video,
.round-recorder.loading .round-recorder-preview canvas { opacity: 0; }
.round-recorder.loading .round-recorder-preview::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: #0a0a0a;
  animation: rr-pulse .8s ease-in-out infinite;
}
@keyframes rr-pulse {
  0%, 100% { opacity: .6; }
  50% { opacity: 1; }
}

.msg-media-loading {
  min-width: 160px;
  min-height: 120px;
  position: relative;
  background: rgba(255,255,255,.06);
}
.msg-media-sized {
  min-width: 0;
  min-height: 0;
}
.msg-media-loading.msg-media-sized img,
.msg-media-loading.msg-media-sized video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.msg-media-loading::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,.1) 50%, transparent 100%);
  animation: media-shimmer 1.4s ease-in-out infinite;
  pointer-events: none;
}
@keyframes media-shimmer {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}
.msg-media-loading img,
.msg-media-loading video {
  opacity: 0;
  transition: opacity .2s ease;
}
.msg-media-loaded img,
.msg-media-loaded video {
  opacity: 1;
}
.msg-file {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  background: rgba(255,255,255,.06);
  border-radius: var(--radius-sm);
  font-size: 13px;
  min-width: 0;
  max-width: 100%;
  width: 280px;
  box-sizing: border-box;
}

.msg-file-main {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.msg-file-icon {
  flex-shrink: 0;
  font-size: 17px;
  line-height: 1;
}

.msg-file-meta {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.msg-file-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.msg-file-size {
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.msg-file-download-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(255,255,255,.03);
  color: var(--text);
  flex-shrink: 0;
  transition: border-color .15s ease, background .15s ease, opacity .15s ease;
}

.msg-file-download-btn:hover {
  border-color: rgba(255,255,255,.32);
  background: rgba(255,255,255,.08);
}

.msg-file-download-btn:disabled {
  opacity: .85;
  cursor: default;
}

.msg-file-download-text {
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}

.msg-file-download-progress {
  width: 18px;
  height: 18px;
  display: none;
  align-items: center;
  justify-content: center;
}

.msg-file.show-progress .msg-file-download-progress {
  display: inline-flex;
}

.msg-file-download-progress svg {
  width: 100%;
  height: 100%;
}

.msg-file-download-track,
.msg-file-download-bar {
  fill: none;
  stroke-width: 3.5;
}

.msg-file-download-track {
  stroke: rgba(255,255,255,.2);
}

.msg-file-download-bar {
  stroke: var(--accent);
  stroke-linecap: round;
  stroke-dasharray: 87.9645943005;
  stroke-dashoffset: 87.9645943005;
  transform-origin: center;
  transform: rotate(-90deg);
  transition: stroke-dashoffset .14s linear;
}

.msg-file-download-progress.indeterminate svg {
  animation: msg-file-progress-spin 1s linear infinite;
}

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

.chat-input-wrap {
  padding: 12px 16px;
  padding-bottom: calc(12px + constant(safe-area-inset-bottom));
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: var(--chat-bg);
  flex-shrink: 0;
  position: relative;
}

.rec-hud {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: space-between;
  margin-bottom: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(239,68,68,.08);
}
.rec-hud.locked {
  background: rgba(59,130,246,.08);
  border-color: rgba(59,130,246,.3);
}

.rec-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ef4444;
  flex-shrink: 0;
  animation: pulse 1s infinite;
}
.rec-hud.locked .rec-dot {
  background: #3b82f6;
  animation: none;
}

.rec-duration {
  font-size: 12px;
  font-weight: 700;
  color: #fca5a5;
  min-width: 38px;
}
.rec-hud.locked .rec-duration {
  color: #60a5fa;
}

.rec-hint {
  font-size: 12px;
  color: var(--text-light);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rec-cancel {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  border-radius: 8px;
  color: var(--text-muted);
}

.rec-cancel:hover {
  color: var(--text);
  background: rgba(255,255,255,.08);
}

.reply-preview-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,.05);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 8px;
  margin-bottom: 8px;
}
.reply-preview-line {
  width: 3px;
  align-self: stretch;
  border-radius: 3px;
  background: var(--accent);
}
.reply-preview-content { min-width: 0; flex: 1; }
.reply-preview-title { font-size: 11px; color: var(--accent); font-weight: 700; }
.reply-preview-text {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.reply-preview-close { width: 28px; height: 28px; }

.msg-ctx-wrapper {
  position: fixed;
  z-index: 12000;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.msg-ctx-reactions {
  display: flex;
  gap: 2px;
  background: #1f2430;
  border: 1px solid #3e4961;
  border-radius: 24px;
  padding: 5px 8px;
  box-shadow: 0 6px 20px rgba(0,0,0,.4);
  align-self: flex-start;
}
.msg-ctx-reaction-btn {
  font-size: 22px;
  line-height: 1;
  padding: 3px 4px;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: 8px;
  transition: transform 0.12s, background 0.12s;
}
.msg-ctx-reaction-btn:hover { transform: scale(1.3); background: rgba(255,255,255,.08); }
.msg-context-menu {
  min-width: 130px;
  background: #1f2430;
  border: 1px solid #3e4961;
  border-radius: 10px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .45);
  padding: 3px;
}

.msg-context-menu-item {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: #eef2ff;
  padding: 7px 10px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 13px;
}

.msg-context-menu-item:hover {
  background: #313a4f;
}
.msg-context-menu-item-danger {
  color: #fecaca;
}
.msg-context-menu-item-danger:hover {
  background: #5f2b35;
  color: #ffe4e6;
}

.member-context-menu {
  min-width: 170px;
}

.msg-row-highlight {
  animation: msg-highlight 1.5s ease;
}
@keyframes msg-highlight {
  0%   { background: rgba(59,130,246,.3); }
  100% { background: transparent; }
}

@keyframes msg-in-own {
  from { opacity: 0; transform: translateX(14px) translateY(8px) scale(0.92); }
  to   { opacity: 1; transform: none; }
}
@keyframes msg-in-other {
  from { opacity: 0; transform: translateX(-14px) translateY(8px) scale(0.92); }
  to   { opacity: 1; transform: none; }
}
@keyframes msg-in-system {
  from { opacity: 0; transform: translateY(6px) scale(0.93); }
  to   { opacity: 1; transform: none; }
}
@keyframes msg-out {
  from { opacity: 1; transform: scale(1); }
  to   { opacity: 0; transform: scale(0.88) translateY(4px); }
}

.msg-row-enter.own        { animation: msg-in-own    0.22s cubic-bezier(0.34,1.18,0.64,1) both; }
.msg-row-enter.other      { animation: msg-in-other  0.22s cubic-bezier(0.34,1.18,0.64,1) both; }
.msg-row-enter.system-row { animation: msg-in-system 0.18s ease both; }

.msg-row-exit {
  animation: msg-out 0.17s ease forwards;
  pointer-events: none;
  overflow: hidden;
}

.chat-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 6px 8px 6px 14px;
  transition: border-color var(--transition);
}
.chat-input-row:focus-within { border-color: var(--accent); }

#msgInput {
  flex: 1;
  resize: none;
  max-height: 120px;
  min-height: 24px;
  line-height: 1.4;
  font-size: 14px;
  padding: 5px 0;
  overflow-y: auto;
}

.input-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  padding-bottom: 0;
}

.send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), transform var(--transition);
  flex-shrink: 0;
}
.send-btn:hover  { background: var(--accent-hover); }
.send-btn:active { transform: scale(.92); }
.send-btn svg    { color: #fff; }

.input-actions-left {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.attach-btn { color: var(--text-muted); padding: 6px; border-radius: 8px; }
.attach-btn:hover { background: rgba(255,255,255,.07); color: var(--text); }

.emoji-btn { color: var(--text-muted); padding: 6px; border-radius: 8px; }
.emoji-btn:hover { background: rgba(255,255,255,.07); color: var(--text); }
.emoji-btn.active { color: var(--accent); }

.emoji-panel {
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  width: 352px;
  height: 360px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 12px 32px rgba(0,0,0,.5);
  z-index: 500;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.emoji-panel-tabs {
  display: flex;
  flex-shrink: 0;
  gap: 0;
  padding: 6px 6px 0;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.emoji-panel-tabs::-webkit-scrollbar { display: none; }

.emoji-tab {
  flex-shrink: 0;
  width: 40px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px 8px 0 0;
  font-size: 20px;
  background: transparent;
  border: 0;
  cursor: pointer;
  opacity: .55;
  transition: opacity .15s, background .15s;
}
.emoji-tab:hover { opacity: 1; background: rgba(255,255,255,.06); }
.emoji-tab.active {
  opacity: 1;
  background: rgba(255,255,255,.08);
  box-shadow: inset 0 -2px 0 var(--accent);
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 0;
  padding: 6px;
  overflow-y: auto;
  flex: 1;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.15) transparent;
}

.emoji-item {
  font-size: 26px;
  line-height: 1;
  text-align: center;
  padding: 4px 0;
  border-radius: 8px;
  cursor: pointer;
  border: 0;
  background: transparent;
  transition: background .1s, transform .1s;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.emoji-item:hover {
  background: rgba(255,255,255,.1);
  transform: scale(1.15);
}


@media (max-width: 900px), (hover: none) and (pointer: coarse) {
  :root {
    --emoji-panel-height: min(390px, 45dvh);
  }

  .chat-input-wrap.emoji-open {
    padding-bottom: calc(var(--emoji-panel-height) + env(safe-area-inset-bottom, 0px));
  }

  .chat-input-wrap.emoji-open .emoji-panel {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: calc(var(--emoji-panel-height) + env(safe-area-inset-bottom, 0px));
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -12px 32px rgba(0,0,0,.42);
    z-index: 600;
  }

  .chat-input-wrap.emoji-open .emoji-grid {
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  }
}
#uploadPreviewModal {
  position: fixed;
  inset: 0;
  z-index: 250;
  background: rgba(3,6,12,.76);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex !important;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
#uploadPreviewModal[style*="display: none"] {
  display: none !important;
}
.upload-preview-shell {
  width: min(520px, 100%);
  max-height: calc(100dvh - 28px);
  background: var(--card-bg);
  border-radius: 16px;
  box-shadow: 0 20px 40px rgba(0,0,0,.6);
  padding: 16px;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 0;
}
.upload-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.upload-preview-title {
  font-size: 16px;
  font-weight: 700;
}
.upload-preview-footer {
  display: flex;
  align-items: center;
  gap: 10px;
}
.upload-preview-caption-wrap {
  flex: 1;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  transition: border-color var(--transition);
}
.upload-preview-caption-wrap:focus-within {
  border-color: var(--accent);
}
.upload-preview-caption-wrap input {
  width: 100%;
  font-size: 14px;
}
.upload-preview-main {
  position: relative;
  width: 100%;
  min-height: 132px;
  max-height: min(46vh, 280px);
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  overflow: hidden;
  background: #0d1117;
  display: flex;
  align-items: center;
  justify-content: center;
}
.upload-preview-main img,
.upload-preview-main video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.upload-preview-main-fallback,
.upload-preview-item-fallback {
  width: 100%;
  height: 100%;
  background: linear-gradient(145deg, rgba(93,108,143,.28), rgba(39,50,78,.45));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px;
  text-align: center;
}
.upload-preview-fallback-icon {
  font-size: 26px;
  line-height: 1;
}
.upload-preview-fallback-name {
  font-size: 11px;
  line-height: 1.2;
  color: #dbe3ff;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.upload-preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
}
.upload-preview-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.upload-preview-meta {
  font-size: 12px;
  color: var(--text-muted);
}
.upload-add-btn,
.upload-crop-btn {
  flex-shrink: 0;
}
.upload-preview-grid {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 8px 0 2px;
}
.upload-preview-item {
  position: relative;
  width: 74px;
  height: 74px;
  border-radius: 10px;
  overflow: hidden;
  background: #0d1117;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  cursor: pointer;
}
.upload-preview-item.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(139,92,246,.35);
}
.upload-preview-item img,
.upload-preview-item video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.upload-preview-item.uploading { opacity: .75; }
.upload-file-thumb { font-size: 22px; }
.upload-file-name {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  font-size: 9px;
  padding: 2px 3px;
  background: rgba(0,0,0,.55);
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.upload-group-badge {
  position: absolute;
  left: 5px;
  bottom: 5px;
  font-size: 9px;
  font-weight: 700;
  color: #fff;
  background: rgba(0,0,0,.6);
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 999px;
  padding: 1px 5px;
  pointer-events: none;
}
.upload-remove-btn {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(0,0,0,.6);
  color: #fff;
  font-size: 14px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
  transition: background var(--transition);
  z-index: 3;
}
.upload-remove-btn:hover { background: rgba(239,68,68,.8); }
.upload-remove-btn:disabled { opacity: .4; cursor: not-allowed; }
.upload-item-spinner {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,.35);
  z-index: 2;
}

.upload-crop-overlay {
  position: fixed;
  inset: 0;
  z-index: 260;
  background: rgba(3,6,12,.76);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
}
.upload-crop-modal {
  width: min(520px, 100%);
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 14px 44px rgba(0,0,0,.5);
  padding: 12px;
}
.upload-crop-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.upload-crop-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}
.upload-crop-stage-wrap {
  border-radius: 12px;
  padding: 8px;
  background: rgba(255,255,255,.03);
}
.upload-crop-stage {
  position: relative;
  width: min(76vw, 360px);
  max-width: 100%;
  aspect-ratio: 1;
  margin: 0 auto;
  border-radius: 10px;
  overflow: hidden;
  background: #0d1117;
  cursor: grab;
  touch-action: none;
}
.upload-crop-stage.is-dragging { cursor: grabbing; }
.upload-crop-stage.is-crop-adjusting { cursor: default; }
.upload-crop-stage img {
  position: absolute;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}
.upload-crop-grid {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  border: 1px solid rgba(255,255,255,.72);
  box-shadow: 0 0 0 9999px rgba(0,0,0,.33);
  pointer-events: auto;
  touch-action: none;
}
.upload-crop-grid::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to right,
      transparent 33.15%,
      rgba(255,255,255,.33) 33.15%,
      rgba(255,255,255,.33) 33.45%,
      transparent 33.45%,
      transparent 66.45%,
      rgba(255,255,255,.33) 66.45%,
      rgba(255,255,255,.33) 66.75%,
      transparent 66.75%),
    linear-gradient(to bottom,
      transparent 33.15%,
      rgba(255,255,255,.33) 33.15%,
      rgba(255,255,255,.33) 33.45%,
      transparent 33.45%,
      transparent 66.45%,
      rgba(255,255,255,.33) 66.45%,
      rgba(255,255,255,.33) 66.75%,
      transparent 66.75%);
  pointer-events: none;
}
.upload-crop-handle {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid rgba(0,0,0,.55);
  box-shadow: 0 2px 8px rgba(0,0,0,.35);
  pointer-events: auto;
}
.upload-crop-handle.tl {
  left: 0;
  top: 0;
  transform: translate(-50%, -50%);
  cursor: nwse-resize;
}
.upload-crop-handle.tr {
  right: 0;
  top: 0;
  transform: translate(50%, -50%);
  cursor: nesw-resize;
}
.upload-crop-handle.bl {
  left: 0;
  bottom: 0;
  transform: translate(-50%, 50%);
  cursor: nesw-resize;
}
.upload-crop-handle.br {
  right: 0;
  bottom: 0;
  transform: translate(50%, 50%);
  cursor: nwse-resize;
}
.upload-crop-controls {
  margin-top: 10px;
  padding: 0 4px;
}
.upload-crop-tools-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.upload-crop-tool {
  min-width: 88px;
  padding: 6px 10px;
}
.upload-crop-zoom-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 12px;
}
.upload-crop-zoom-row input[type="range"] {
  flex: 1;
}
.upload-crop-hint {
  margin-top: 7px;
  font-size: 11px;
  color: var(--text-muted);
  opacity: .88;
}
.upload-crop-actions {
  margin-top: 10px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.msg-album {
  display: grid;
  gap: 2px;
  border-radius: var(--radius-sm);
  box-sizing: border-box;
  border: 1px solid rgba(255,255,255,.14);
  overflow: hidden;
  max-width: 280px;
  margin-bottom: 0;
  line-height: 0;
  font-size: 0;
}
.msg-album.album-1  { grid-template-columns: 1fr; }
.msg-album.album-2  { grid-template-columns: 1fr 1fr; }
.msg-album.album-3  { grid-template-columns: 1fr 1fr; }
.msg-album.album-3 .album-item:first-child { grid-column: span 2; }
.msg-album.album-4  { grid-template-columns: 1fr 1fr; }
.msg-album.album-many { grid-template-columns: repeat(3, 1fr); }
.album-item {
  position: relative;
  overflow: hidden;
  background: rgba(255,255,255,.06);
  cursor: pointer;
  line-height: 0;
  font-size: 0;
}
.album-item img, .album-item video {
  width: 100%;
  height: auto;
  display: block;
  transition: opacity .2s ease;
}
.album-item.loading img { opacity: 0; }
.album-item.loaded  img { opacity: 1; }

.album-caption {
  margin-top: 4px;
  font-size: 13.5px;
  word-break: break-word;
}

.msg-album-fallbacks {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
}

.msg-album-fallbacks .msg-file {
  width: min(320px, 100%);
}

.msg-album-pending {
  display: grid;
  gap: 2px;
  border-radius: var(--radius-sm);
  box-sizing: border-box;
  border: 1px solid rgba(255,255,255,.14);
  overflow: hidden;
  max-width: 280px;
  margin-bottom: 0;
  line-height: 0;
  font-size: 0;
}
.msg-album-pending.album-1  { grid-template-columns: 1fr; }
.msg-album-pending.album-2  { grid-template-columns: 1fr 1fr; }
.msg-album-pending.album-3  { grid-template-columns: 1fr 1fr; }
.msg-album-pending.album-3 .album-item-p:first-child { grid-column: span 2; }
.msg-album-pending.album-4  { grid-template-columns: 1fr 1fr; }
.msg-album-pending.album-many { grid-template-columns: repeat(3, 1fr); }
.album-item-p {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  background: rgba(255,255,255,.06);
  line-height: 0;
  font-size: 0;
}
.album-item-p img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: .85; }

.upload-preview {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; background: var(--input-bg);
  border-radius: var(--radius-sm); margin-bottom: 8px; font-size: 13px;
}
.upload-preview img { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; }
.upload-preview .remove { margin-left: auto; color: var(--text-muted); }
.upload-preview .remove:disabled { opacity: .45; cursor: not-allowed; }
.upload-preview.uploading { opacity: .92; }
.upload-spinner {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  margin-right: 6px;
}
.upload-spinner .loader {
  width: 14px;
  height: 14px;
  border-width: 2px;
}

#msgInput:disabled,
#sendBtn:disabled {
  opacity: .6;
  cursor: not-allowed;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  backdrop-filter: blur(4px);
}
.modal {
  width: 420px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px 24px;
}
.modal h3 { font-size: 17px; font-weight: 700; margin-bottom: 20px; }

.call-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4,7,12,.66);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 140;
  backdrop-filter: blur(6px);
}

.call-modal-overlay.call-modal-overlay-soft {
  background: rgba(4,7,12,.56);
}

.call-modal {
  width: min(420px, calc(100vw - 24px));
  border-radius: 24px;
  border: 1px solid rgba(255,255,255,.12);
  background:
    radial-gradient(120% 120% at 100% 0%, rgba(59,130,246,.2), transparent 54%),
    radial-gradient(140% 120% at 0% 100%, rgba(34,197,94,.12), transparent 58%),
    #171b25;
  box-shadow: 0 22px 54px rgba(0,0,0,.5);
  padding: 22px 20px 20px;
  text-align: center;
}

.call-modal-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  letter-spacing: .04em;
  font-weight: 700;
  text-transform: uppercase;
  color: rgba(255,255,255,.8);
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.2);
  background: rgba(255,255,255,.08);
}

.call-modal-avatar {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  margin: 16px auto 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 800;
  color: #fff;
  box-shadow: 0 0 0 4px rgba(255,255,255,.1), 0 16px 32px rgba(0,0,0,.3);
}

.call-modal-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.call-modal-avatar video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.call-modal-title {
  font-size: 22px;
  font-weight: 800;
  line-height: 1.3;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px 6px;
  width: 100%;
  text-align: center;
}

.call-modal-subtitle {
  font-size: 13px;
  color: rgba(232,232,240,.72);
  margin-bottom: 16px;
}

.call-modal-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 8px;
}

.call-action-btn {
  min-width: 134px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  transition: transform .14s ease, filter .14s ease, border-color .14s ease;
}

.call-action-btn:hover { filter: brightness(1.06); }
.call-action-btn:active { transform: translateY(1px) scale(.99); }
.call-action-btn:disabled { opacity: .58; cursor: not-allowed; }

.call-action-btn.decline {
  background: rgba(239,68,68,.85);
  border-color: rgba(248,113,113,.65);
}

.call-action-btn.accept {
  background: rgba(34,197,94,.88);
  border-color: rgba(74,222,128,.62);
}

.call-modal-incoming {
  animation: callModalPulse 1.4s ease-in-out infinite;
}

@keyframes callModalPulse {
  0%, 100% { box-shadow: 0 22px 54px rgba(0,0,0,.5); }
  50% { box-shadow: 0 24px 58px rgba(0,0,0,.6), 0 0 0 1px rgba(59,130,246,.25); }
}

@media (max-width: 520px) {
  .call-modal {
    width: calc(100vw - 18px);
    padding: 18px 14px 14px;
  }

  .call-modal-title {
    font-size: 20px;
  }

  .call-modal-actions {
    flex-direction: column;
  }

  .call-action-btn {
    width: 100%;
    min-width: 0;
  }
}

.call-active-overlay {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: radial-gradient(ellipse at 50% 20%, rgba(30,40,70,.98) 0%, #0d1117 100%);
  overflow: hidden;
}

.call-remote-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  z-index: 0;
  background: #000;
}

.call-local-video {
  position: absolute;
  bottom: 110px;
  right: 16px;
  width: 100px;
  height: 140px;
  object-fit: contain;
  border-radius: 12px;
  z-index: 2;
  border: 2px solid rgba(255,255,255,.3);
  background: #111;
  cursor: pointer;
}

.call-active-overlay.call-video-mode .call-active-ui {
  background: linear-gradient(to bottom, rgba(0,0,0,.55) 0%, transparent 100%);
  border-radius: 0;
}

.call-active-overlay.call-video-mode .call-active-controls {
  background: linear-gradient(to top, rgba(0,0,0,.55) 0%, transparent 100%);
}

.call-active-ui {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  width: 100%;
  padding: 72px 24px 0;
  text-align: center;
  position: relative;
  z-index: 1;
}

.call-active-avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: 800;
  color: #fff;
  margin-bottom: 20px;
  box-shadow: 0 0 0 6px rgba(255,255,255,.08), 0 16px 40px rgba(0,0,0,.5);
  animation: callAvatarPulse 2.2s ease-in-out infinite;
}

@keyframes callAvatarPulse {
  0%, 100% { box-shadow: 0 0 0 6px rgba(255,255,255,.08), 0 16px 40px rgba(0,0,0,.5); }
  50% { box-shadow: 0 0 0 12px rgba(255,255,255,.04), 0 16px 40px rgba(0,0,0,.5); }
}

.call-active-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.call-active-avatar video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.call-active-name {
  font-size: 24px;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 6px;
  color: #fff;
}

.call-active-status {
  font-size: 13px;
  color: rgba(232,232,240,.55);
  min-height: 18px;
}

.call-active-timer {
  font-size: 18px;
  font-weight: 500;
  letter-spacing: .06em;
  color: rgba(232,232,240,.85);
  min-height: 26px;
  margin-top: 4px;
}

.call-peer-status {
  width: 100%;
  text-align: center;
  font-size: 12px;
  color: rgba(255,255,255,.65);
  background: rgba(0,0,0,.35);
  padding: 6px 16px;
  position: relative;
  z-index: 1;
}

.call-active-controls {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 28px 16px calc(36px + env(safe-area-inset-bottom, 0px));
  position: relative;
  z-index: 1;
  flex-wrap: wrap;
}

.call-ctrl-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 50%;
  width: 54px;
  height: 54px;
  color: #fff;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .1s;
  padding: 0;
  justify-content: center;
  flex-shrink: 0;
}

.call-ctrl-btn svg {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.call-ctrl-btn span {
  display: none;
}

.call-ctrl-btn:hover { background: rgba(255,255,255,.16); }
.call-ctrl-btn:active { transform: scale(.92); }

.call-ctrl-btn.call-ctrl-active {
  background: rgba(239,68,68,.85);
  border-color: rgba(248,113,113,.5);
}

.call-ctrl-btn.call-ctrl-active:hover {
  background: rgba(220,38,38,.9);
}

.call-ctrl-speaker.call-ctrl-active {
  background: rgba(59,130,246,.85);
  border-color: rgba(96,165,250,.5);
}

.call-ctrl-speaker.call-ctrl-active:hover {
  background: rgba(37,99,235,.9);
}

.call-ctrl-hangup {
  background: rgba(239,68,68,.88);
  border-color: rgba(248,113,113,.5);
  width: 62px;
  height: 62px;
}

.call-ctrl-hangup svg {
  width: 26px;
  height: 26px;
}

.call-ctrl-hangup:hover { background: rgba(220,38,38,.9); }

.call-active-name { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.top-emoji-call { width: 22px; height: 22px; flex-shrink: 0; vertical-align: middle; }

.call-minimize-btn {
  position: absolute;
  top: calc(14px + env(safe-area-inset-top, 0px));
  left: 14px;
  z-index: 3;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(0,0,0,.4);
  border: 1px solid rgba(255,255,255,.15);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .15s, opacity .25s;
}
.call-minimize-btn:hover { background: rgba(0,0,0,.6); }
.call-minimize-btn svg { width: 22px; height: 22px; }

.call-active-overlay.call-video-mode .call-active-ui,
.call-active-overlay.call-video-mode .call-active-controls,
.call-active-overlay.call-video-mode .call-minimize-btn,
.call-active-overlay.call-video-mode .call-peer-status {
  transition: opacity .3s;
  opacity: 1;
}
.call-active-overlay.call-video-mode.call-idle .call-active-ui,
.call-active-overlay.call-video-mode.call-idle .call-active-controls,
.call-active-overlay.call-video-mode.call-idle .call-minimize-btn,
.call-active-overlay.call-video-mode.call-idle .call-peer-status {
  opacity: 0;
  pointer-events: none;
  transition: opacity .5s;
}
.call-active-overlay.call-video-mode.call-idle {
  background: #000;
}
.call-active-overlay.call-video-mode.call-idle .call-remote-video {
  pointer-events: none;
}
.call-active-overlay.call-video-mode.call-idle::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 10;
  cursor: pointer;
}
.call-active-overlay:not(.call-video-mode).call-idle {
  background: radial-gradient(ellipse at 50% 20%, rgba(30,40,70,.98) 0%, #0d1117 100%);
}

.has-call-mini-bar .chat-input-wrap {
  padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px));
}

.call-mini-bar {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 160;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(17,22,34,.97);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 16px;
  box-shadow: 0 8px 28px rgba(0,0,0,.5);
  padding: 10px 12px;
  cursor: pointer;
}
.call-mini-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
  overflow: hidden;
}
.call-mini-avatar img { width: 100%; height: 100%; object-fit: cover; }
.call-mini-avatar video { width: 100%; height: 100%; object-fit: cover; }
.call-mini-info { flex: 1; min-width: 0; }
.call-mini-name {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 5px;
}
.call-mini-name span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.call-mini-timer {
  font-size: 11px;
  color: rgba(255,255,255,.6);
  letter-spacing: .04em;
}
.call-mini-expand {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.15);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.call-mini-expand svg { width: 16px; height: 16px; }
.call-mini-expand:hover { background: rgba(255,255,255,.18); }
.call-mini-hangup {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(239,68,68,.9);
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.call-mini-hangup svg { width: 18px; height: 18px; }
.call-mini-hangup:hover { background: rgba(220,38,38,1); }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 6px; font-weight: 500; }
.field input {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 14px;
  transition: border-color var(--transition);
}
.field input:focus { border-color: var(--accent); }

.user-search-results { margin-top: 8px; max-height: 180px; overflow-y: auto; }
.user-result-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
}
.user-result-item:hover { background: rgba(255,255,255,.05); }
.user-result-name { font-size: 14px; font-weight: 500; }
.user-result-login { font-size: 12px; color: var(--text-muted); }

.modal-actions { display: flex; gap: 8px; margin-top: 20px; justify-content: flex-end; }

.new-chat-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,.45);
  z-index: 200;
  min-width: 210px;
  overflow: hidden;
}
.new-chat-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  font-size: 14px;
  transition: background var(--transition);
}
.new-chat-menu-item:hover { background: rgba(255,255,255,.06); }
.new-chat-menu-item-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.new-chat-menu-item-icon.direct { background: rgba(59,130,246,.18); color: #60a5fa; }
.new-chat-menu-item-icon.group  { background: rgba(16,185,129,.18); color: #34d399; }
.new-chat-menu-item-icon.channel{ background: rgba(168,85,247,.18); color: #c084fc; }

.member-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  min-height: 10px;
}
.member-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(59,130,246,.15);
  border: 1px solid rgba(59,130,246,.3);
  border-radius: 20px;
  padding: 3px 6px 3px 10px;
  font-size: 12px;
  color: #93c5fd;
}
.member-chip-remove {
  cursor: pointer;
  opacity: .6;
  font-size: 15px;
  line-height: 1;
  padding: 0 2px;
}
.member-chip-remove:hover { opacity: 1; }

.gc-modal { width: 460px; max-width: 95vw; }

.gc-steps {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 24px;
}
.gc-step {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--text-muted);
}
.gc-step-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}
.gc-step.gc-step-active { color: var(--accent); }
.gc-step.gc-step-active .gc-step-num { border-color: var(--accent); background: var(--accent); color: #fff; }
.gc-step.gc-step-done .gc-step-num { border-color: var(--accent); background: transparent; color: var(--accent); }
.gc-step-line { flex: 1; height: 2px; background: var(--border); margin: 0 10px; }

.gc-avatar-upload {
  display: flex;
  align-items: center;
  gap: 16px;
  cursor: pointer;
  padding: 12px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  transition: border-color .15s;
}
.gc-avatar-upload:hover { border-color: var(--accent); }
.gc-avatar-preview {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--sidebar-bg);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
  color: var(--text-muted);
}
.gc-avatar-preview img { width: 100%; height: 100%; object-fit: cover; }
.gc-avatar-hint { font-size: 13px; color: var(--text-muted); line-height: 1.5; }
.gc-avatar-hint small { font-size: 11px; opacity: .7; }

.gc-members-count {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
  font-weight: 600;
}
.gc-search {
  width: 100%;
  background: var(--sidebar-bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  outline: none;
  margin-bottom: 8px;
}
.gc-search:focus { border-color: var(--accent); }
.gc-section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
  padding: 4px 4px 6px;
}
.gc-added { opacity: .6; }
.gc-check {
  color: var(--accent);
  font-weight: 700;
  font-size: 14px;
  margin-left: auto;
  flex-shrink: 0;
}

.chat-item-type-icon {
  font-size: 13px;
  opacity: .7;
  margin-right: 2px;
}
.btn-secondary {
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  transition: background var(--transition);
}
.btn-secondary:hover { background: rgba(255,255,255,.07); color: var(--text); }
.btn-primary-sm {
  padding: 10px 18px;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  transition: background var(--transition);
}
.btn-primary-sm:hover { background: var(--accent-hover); }
.btn-secondary-sm {
  padding: 10px 18px;
  background: rgba(255,255,255,.06);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  transition: background var(--transition), color var(--transition);
}
.btn-secondary-sm:hover { background: rgba(255,255,255,.1); color: var(--text); }


.loader {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255,255,255,.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-msgs {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  color: var(--text-muted);
}

.push-notif-banner {
  position: fixed;
  bottom: -100px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 500px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 900;
  box-shadow: 0 4px 24px rgba(0,0,0,.35);
  transition: bottom .35s cubic-bezier(.34,1.56,.64,1);
  font-size: 13px;
}
.push-notif-banner--show { bottom: 16px; }
@media (max-width: 600px) {
  .push-notif-banner { width: calc(100% - 20px); padding: 11px 12px; }
  .push-notif-banner--show { bottom: 10px; }
}
.push-notif-icon { font-size: 18px; flex-shrink: 0; }
.push-notif-text { flex: 1; color: var(--text-main); line-height: 1.4; }
.push-notif-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
.push-notif-btn:active { opacity: .85; }
.push-notif-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
  flex-shrink: 0;
}

#toast {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 20px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, transform .25s;
  z-index: 999;
  white-space: nowrap;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 8px 12px;
  background: var(--bubble-other);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  width: fit-content;
}
.typing-dot {
  width: 6px; height: 6px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: bounce .8s infinite;
}
.typing-dot:nth-child(2) { animation-delay: .15s; }
.typing-dot:nth-child(3) { animation-delay: .3s; }
@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); }
  40%           { transform: translateY(-6px); }
}

.ws-status {
  position: absolute;
  top: 8px;
  left: 12px;
  right: 12px;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  margin: 0;
  border-radius: 10px;
  border: 1px solid transparent;
  font-size: 12px;
  font-weight: 500;
  transform: translateY(-10px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .28s ease, transform .28s ease;
}
.ws-status.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.ws-status.ws-global {
  position: fixed;
  top: 8px;
  left: 50%;
  width: min(460px, calc(100vw - 20px));
  margin: 0;
  z-index: 40;
  transform: translate(-50%, -10px);
}
.ws-status.ws-global.is-visible {
  transform: translate(-50%, 0);
}
.ws-status.ws-clickable {
  cursor: pointer;
}
.ws-status.ws-clickable:active {
  transform: translateY(0) scale(.995);
}
.ws-status.ws-global.ws-clickable:active {
  transform: translate(-50%, 0) scale(.995);
}
.ws-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 0 currentColor;
}
.ws-connecting {
  color: #60a5fa;
  background: rgba(96,165,250,.12);
  border-color: rgba(96,165,250,.35);
}
.ws-connecting .ws-status-dot,
.ws-authorizing .ws-status-dot,
.ws-reconnecting .ws-status-dot {
  animation: wsPulse 1.4s infinite;
}
.ws-authorizing {
  color: #93c5fd;
  background: rgba(147,197,253,.12);
  border-color: rgba(147,197,253,.35);
}
.ws-reconnecting {
  color: #fbbf24;
  background: linear-gradient(90deg, rgba(251,191,36,.18), rgba(251,191,36,.08), rgba(251,191,36,.18));
  border-color: rgba(251,191,36,.35);
  background-size: 220% 100%;
  animation: wsShimmer 1.6s linear infinite;
}
.ws-error {
  color: #f87171;
  background: rgba(248,113,113,.14);
  border-color: rgba(248,113,113,.36);
}
.ws-connected {
  color: #34d399;
  background: rgba(52,211,153,.12);
  border-color: rgba(52,211,153,.34);
}
@keyframes wsPulse {
  0% { box-shadow: 0 0 0 0 rgba(255,255,255,.35); }
  70% { box-shadow: 0 0 0 8px rgba(255,255,255,0); }
  100% { box-shadow: 0 0 0 0 rgba(255,255,255,0); }
}
@keyframes wsShimmer {
  0% { background-position: 0% 50%; }
  100% { background-position: 220% 50%; }
}

.back-btn { display: none; }

@media (max-width: 640px) {
  .ws-status {
    font-size: 11px;
    padding: 7px 10px;
    border-radius: 9px;
  }
  #sidebar {
    width: 100%;
    position: absolute;
    inset: 0;
    z-index: 10;
    transform: translateX(0);
    transition: transform var(--transition);
  }
  #sidebar.hidden { transform: translateX(-100%); }
  #chatArea {
    width: 100%;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
  }
  .profile-panel {
    position: absolute;
    inset: 0;
    z-index: 20;
    width: 100%;
    transform: translateX(100%);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
  }
  .profile-panel.pp-open {
    transform: translateX(0);
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }
  #messages {
    padding: 12px;
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .sidebar-header {
    padding-top: calc(20px + env(safe-area-inset-top, 0px));
  }
  .chat-header {
    padding: calc(12px + env(safe-area-inset-top, 0px)) 14px 12px;
    flex-shrink: 0;
  }
  .pp-header {
    padding-top: calc(16px + env(safe-area-inset-top, 0px));
  }
  .sp-head {
    padding-top: calc(28px + env(safe-area-inset-top, 0px));
  }
  .sp-head-edit-btn {
    top: calc(12px + env(safe-area-inset-top, 0px));
  }
  .chat-list {
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .chat-input-wrap {
    flex-shrink: 0;
    padding-bottom: calc(16px + constant(safe-area-inset-bottom));
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
  }
  .has-call-mini-bar .chat-input-wrap {
    padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  }
  .back-btn { display: flex; }
}

@media (max-width: 900px), (hover: none) and (pointer: coarse) {
  .back-btn { display: flex; }
}

.mic-btn { color: var(--text-muted); padding: 6px; border-radius: 8px; transition: color var(--transition), background var(--transition); touch-action: none; will-change: transform; }
.mic-btn:hover { background: rgba(255,255,255,.07); color: var(--text); }
.mic-btn.recording { color: var(--danger); background: rgba(239,68,68,.15); animation: pulse 1s infinite; }
.mic-btn.locked { color: #3b82f6; background: rgba(59,130,246,.15); animation: none; box-shadow: 0 0 0 1px rgba(59,130,246,.45) inset; }
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:.5; } }

.channel-panel { width: 460px; max-height: 85vh; overflow-y: auto; padding: 0; }
.channel-panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 20px 16px; border-bottom: 1px solid var(--border); position: sticky; top: 0;
  background: var(--card-bg); z-index: 1;
}
.channel-panel-title { display: flex; align-items: center; gap: 12px; }
.channel-panel-name { font-size: 16px; font-weight: 700; }
.channel-panel-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.channel-panel-close { flex-shrink: 0; }
.channel-panel-section {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.channel-panel-section:last-child { border-bottom: none; }
.channel-panel-section-title {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-muted); margin-bottom: 10px;
}
.channel-invite-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--input-bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 8px 12px;
}
.channel-invite-link {
  font-size: 12px; color: var(--text-muted); flex: 1; word-break: break-all;
  font-family: monospace;
}
.channel-admin-row {
  display: flex; align-items: center; gap: 10px; padding: 6px 0;
}
.channel-admin-info { flex: 1; }
.channel-admin-name { font-size: 14px; font-weight: 500; }
.channel-admin-role { font-size: 12px; color: var(--text-muted); }
.channel-admin-remove {
  background: none; border: none; color: var(--text-muted); font-size: 16px; cursor: pointer;
  padding: 4px 8px; border-radius: 6px; transition: color var(--transition), background var(--transition);
}
.channel-admin-remove:hover { color: #f87171; background: rgba(248,113,113,.1); }
.group-admin-perms {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}
.group-admin-perm-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  user-select: none;
}
.group-admin-perm-item input[type="checkbox"] {
  width: auto;
}

.role-badge {
  display: inline-block; font-size: 10px; font-weight: 600;
  padding: 1px 7px; border-radius: 8px; margin-left: 6px;
  vertical-align: middle; letter-spacing: .02em; line-height: 1.6;
}
.role-badge.role-owner { background: rgba(245,158,11,.18); color: #f59e0b; }
.role-badge.role-admin { background: rgba(59,130,246,.18); color: #60a5fa; }

.chat-pinned-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px 7px 14px; border-bottom: 1px solid var(--border);
  background: var(--card-bg); cursor: pointer; transition: background var(--transition);
  user-select: none; flex-shrink: 0;
}
.chat-pinned-bar:hover { background: var(--hover); }
.chat-pinned-bar-icon { color: var(--accent); flex-shrink: 0; display: flex; align-items: center; }
.chat-pinned-bar-body { flex: 1; min-width: 0; overflow: hidden; }
.chat-pinned-bar-label {
  font-size: 11px; font-weight: 600; color: var(--accent); margin-bottom: 1px;
}
.pinned-bar-counter { font-weight: 400; opacity: .75; }
.chat-pinned-bar-text {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 13px; color: var(--text);
}
.chat-pinned-bar-close {
  flex-shrink: 0; background: none; border: none; color: var(--text-muted); font-size: 18px; cursor: pointer;
  padding: 4px 6px; border-radius: 6px; line-height: 1;
  transition: color var(--transition), background var(--transition);
}
.chat-pinned-bar-close:hover { color: var(--danger); background: rgba(239,68,68,.1); }

/* Message reactions */
.msg-reactions {
  display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px;
}
.msg-reaction {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 7px; border-radius: 20px; font-size: 13px; line-height: 1.5;
  cursor: pointer; border: 1px solid var(--border); background: var(--bg);
  transition: background var(--transition), border-color var(--transition), transform 0.1s;
  user-select: none;
}
.msg-reaction:hover { background: var(--hover); border-color: var(--accent); }
.msg-reaction.my { background: rgba(var(--accent-rgb,99,102,241),.12); border-color: var(--accent); }
.msg-reaction-count { font-size: 11px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* Forward message header */
.msg-forward-header {
  display: flex; align-items: center; gap: 6px;
  padding: 3px 0 5px; border-left: 3px solid var(--accent);
  padding-left: 8px; margin-bottom: 4px; font-size: 12px;
}
.msg-forward-icon { color: var(--accent); flex-shrink: 0; }
.msg-forward-from { color: var(--accent); font-weight: 600; }

/* Forward chat selector modal */
.forward-modal {
  width: 400px; max-height: 80vh; display: flex; flex-direction: column;
}
.forward-modal-search {
  padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.forward-modal-search input {
  width: 100%; padding: 8px 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg);
  color: var(--text); font-size: 14px; outline: none;
}
.forward-modal-search input:focus { border-color: var(--accent); }
.forward-modal-list {
  flex: 1; overflow-y: auto; padding: 8px 0;
}
.forward-modal-item {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 16px; cursor: pointer; transition: background var(--transition);
}
.forward-modal-item:hover { background: var(--hover); }
.forward-modal-item-avatar {
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
  background: var(--accent); display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700; color: #fff;
}
.forward-modal-item-name { font-size: 14px; font-weight: 500; }

.cs-modal {
  width: 520px; max-height: 90vh; overflow: hidden;
  display: flex; flex-direction: column; padding: 0;
}
.cs-header {
  display: flex; align-items: center; gap: 14px;
  padding: 18px 20px 14px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--card-bg); z-index: 2; flex-shrink: 0;
}
.cs-avatar {
  width: 52px; height: 52px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 700; color: #fff; overflow: hidden; cursor: pointer;
  position: relative;
}
.cs-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.cs-header-info { flex: 1; min-width: 0; }
.cs-chat-name { font-size: 16px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cs-chat-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.cs-close-btn { flex-shrink: 0; }

.cs-tabs {
  display: flex; gap: 4px; padding: 10px 16px;
  border-bottom: 1px solid var(--border); overflow-x: auto; flex-shrink: 0;
  scrollbar-width: none;
}
.cs-tabs::-webkit-scrollbar { display: none; }
.cs-tab {
  white-space: nowrap; padding: 5px 12px; border-radius: 20px; font-size: 12px; font-weight: 600;
  cursor: pointer; border: 1px solid var(--border); background: none; color: var(--text-muted);
  transition: all var(--transition); flex-shrink: 0;
}
.cs-tab:hover { background: var(--hover); color: var(--text); }
.cs-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.cs-body { flex: 1; overflow-y: auto; }
.cs-section { padding: 14px 20px; border-bottom: 1px solid var(--border); }
.cs-section:last-child { border-bottom: none; }
.cs-section-title {
  font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-muted); margin-bottom: 10px;
}
.cs-card {
  background: var(--input-bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
  overflow: hidden;
}
.cs-card-row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-bottom: 1px solid var(--border);
  transition: background var(--transition); min-height: 44px;
}
.cs-card-row:last-child { border-bottom: none; }
.cs-card-row:hover { background: var(--hover); }
.cs-card-row-label { font-size: 13px; color: var(--text-muted); flex-shrink: 0; width: 160px; }
.cs-card-row-value { flex: 1; font-size: 13px; }
.cs-card-row-toggle { flex-shrink: 0; }

.cs-toggle-switch {
  position: relative; width: 38px; height: 22px; cursor: pointer; display: inline-block;
}
.cs-toggle-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.cs-toggle-slider {
  position: absolute; inset: 0; border-radius: 22px;
  background: var(--border); transition: background .2s;
}
.cs-toggle-slider::before {
  content: ''; position: absolute; width: 16px; height: 16px;
  left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform .2s;
}
.cs-toggle-switch input:checked + .cs-toggle-slider { background: var(--accent); }
.cs-toggle-switch input:checked + .cs-toggle-slider::before { transform: translateX(16px); }

.cs-admin-row {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 14px; border-bottom: 1px solid var(--border); cursor: pointer;
  transition: background var(--transition);
}
.cs-admin-row:last-child { border-bottom: none; }
.cs-admin-row:hover { background: var(--hover); }
.cs-admin-info { flex: 1; min-width: 0; }
.cs-admin-name { font-size: 13px; font-weight: 500; }
.cs-admin-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.cs-admin-custom-title { font-size: 11px; color: var(--accent); margin-top: 2px; font-style: italic; }
.cs-admin-perms { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 6px; }
.cs-admin-perm { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; color: var(--text-muted); }

.cs-member-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px; border-bottom: 1px solid var(--border); transition: background var(--transition);
}
.cs-member-row:last-child { border-bottom: none; }
.cs-member-row:hover { background: var(--hover); }
.cs-member-info { flex: 1; min-width: 0; }
.cs-member-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cs-member-sub { font-size: 11px; color: var(--text-muted); }
.cs-member-actions { display: flex; gap: 6px; flex-shrink: 0; }
.cs-member-btn {
  background: none; border: none; cursor: pointer; padding: 3px 7px; border-radius: 5px;
  font-size: 11px; font-weight: 600; transition: all var(--transition);
}
.cs-member-btn.kick { color: var(--text-muted); }
.cs-member-btn.kick:hover { color: var(--danger); background: rgba(239,68,68,.1); }
.cs-member-btn.ban { color: var(--text-muted); }
.cs-member-btn.ban:hover { color: #f87171; background: rgba(248,113,113,.1); }

.cs-invite-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-bottom: 1px solid var(--border);
}
.cs-invite-row:last-child { border-bottom: none; }
.cs-invite-info { flex: 1; min-width: 0; }
.cs-invite-name { font-size: 13px; font-weight: 500; }
.cs-invite-meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.cs-invite-link { font-size: 11px; color: var(--accent); font-family: monospace; word-break: break-all; }
.cs-invite-revoked { opacity: .45; }
.cs-invite-actions { display: flex; gap: 6px; flex-shrink: 0; }

.cs-log-row {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 14px; border-bottom: 1px solid var(--border);
}
.cs-log-row:last-child { border-bottom: none; }
.cs-log-info { flex: 1; min-width: 0; }
.cs-log-actor { font-size: 13px; font-weight: 500; }
.cs-log-action { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.cs-log-time { font-size: 11px; color: var(--text-muted); flex-shrink: 0; }

.cs-field { margin-bottom: 12px; }
.cs-field:last-child { margin-bottom: 0; }
.cs-field label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); display: block; margin-bottom: 5px; }
.cs-field input[type="text"], .cs-field textarea, .cs-field select {
  width: 100%; padding: 9px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--input-bg); color: var(--text);
  font-size: 13px; transition: border-color var(--transition); box-sizing: border-box;
}
.cs-field input[type="text"]:focus, .cs-field textarea:focus { border-color: var(--accent); outline: none; }
.cs-field textarea { resize: vertical; min-height: 72px; }
.cs-field .cs-hint { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

.cs-perm-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; margin-top: 4px;
}
.cs-perm-item {
  display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-muted); user-select: none;
}
.cs-perm-item input { width: auto; margin: 0; }

@media (max-width: 600px) {
  .cs-modal { width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0; }
  .cs-perm-grid { grid-template-columns: 1fr; }
  .cs-card-row-label { width: 120px; }
}

.cs-header-avatar {
  width: 52px; height: 52px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 700; color: #fff; overflow: hidden;
  background: var(--accent);
}
.cs-header-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.cs-header-name { font-size: 16px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cs-header-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.cs-close { flex-shrink: 0; }
.cs-tab-active { background: var(--accent) !important; color: #fff !important; border-color: var(--accent) !important; }

.cs-header-ava {
  width: 48px; height: 48px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; font-weight: 700; color: #fff; overflow: hidden;
}
.cs-header-ava img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }

.cs-avatar-hero {
  display: flex; justify-content: center; padding: 20px 0 8px; cursor: pointer;
}
.cs-avatar-preview {
  width: 86px; height: 86px; border-radius: 50%; position: relative; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.cs-avatar-preview img { width: 100%; height: 100%; object-fit: cover; }
.cs-avatar-overlay {
  position: absolute; inset: 0; background: rgba(0,0,0,.45);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; opacity: 0; transition: opacity .18s; color: #fff; font-size: 10px; font-weight: 600;
}
.cs-avatar-hero:hover .cs-avatar-overlay { opacity: 1; }

.cs-section { padding: 0 16px 10px; }
.cs-section-label {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-muted); padding: 10px 2px 6px;
}

.cs-card2 {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: 12px; overflow: hidden;
}

.cs-field2 {
  padding: 10px 14px; border-bottom: 1px solid var(--border);
}
.cs-field2-last { border-bottom: none; }
.cs-field2-sm { padding: 8px 0; }
.cs-field-label { font-size: 11px; color: var(--text-muted); display: block; margin-bottom: 4px; }
.cs-field-input {
  width: 100%; background: none; border: none; outline: none;
  color: var(--text); font-size: 14px; font-family: inherit; padding: 0; box-sizing: border-box;
}
.cs-field-input:disabled { opacity: .55; }
.cs-field-textarea {
  width: 100%; background: none; border: none; outline: none; resize: none;
  color: var(--text); font-size: 14px; font-family: inherit; padding: 0; box-sizing: border-box; min-height: 52px;
}
.cs-field-textarea:disabled { opacity: .55; }
.cs-field-hint { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.cs-field-readonly { font-size: 14px; color: var(--text); opacity: .7; }

.cs-username-row { display: flex; align-items: center; gap: 4px; }
.cs-username-at { font-size: 14px; color: var(--text-muted); flex-shrink: 0; }

.cs-toggle-row {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  border-bottom: 1px solid var(--border); cursor: pointer; user-select: none;
}
.cs-toggle-row-last { border-bottom: none; }
.cs-toggle-info { flex: 1; min-width: 0; }
.cs-toggle-title { font-size: 14px; color: var(--text); }
.cs-toggle-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.cs-switch { position: relative; width: 42px; height: 24px; flex-shrink: 0; display: inline-block; }
.cs-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.cs-switch-track {
  position: absolute; inset: 0; border-radius: 24px;
  background: var(--border); transition: background .2s;
}
.cs-switch-track::before {
  content: ''; position: absolute; width: 18px; height: 18px;
  left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.cs-switch input:checked + .cs-switch-track { background: var(--accent); }
.cs-switch input:checked + .cs-switch-track::before { transform: translateX(18px); }

.cs-radio-row {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px;
  border-bottom: 1px solid var(--border); cursor: pointer; user-select: none;
}
.cs-radio-row-last { border-bottom: none; }
.cs-radio-row input { width: auto; margin: 0; accent-color: var(--accent); }
.cs-radio-label { font-size: 14px; color: var(--text); }

.cs-select-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--border);
}
.cs-select-row:last-child { border-bottom: none; }
.cs-select-label { font-size: 13px; color: var(--text); flex: 1; }
.cs-select2 {
  background: var(--input-bg); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); font-size: 13px; font-family: inherit; padding: 5px 8px; cursor: pointer;
}

.cs-perm2-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 11px 14px; border-bottom: 1px solid var(--border); cursor: pointer; user-select: none;
}
.cs-perm2-row-last { border-bottom: none; }
.cs-perm2-compact { padding: 8px 0; border-bottom-color: rgba(255,255,255,.05); }
.cs-perm2-label { font-size: 13px; color: var(--text); flex: 1; }
.cs-perm2-cb { width: auto; margin: 0; accent-color: var(--accent); }

.cs-btn-primary {
  display: block; width: 100%; padding: 12px; border-radius: 10px;
  background: var(--accent); color: #fff; font-size: 14px; font-weight: 600;
  border: none; cursor: pointer; text-align: center; transition: opacity .15s;
}
.cs-btn-primary:hover { opacity: .88; }
.cs-btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.cs-btn-sm { width: auto; padding: 7px 14px; font-size: 13px; border-radius: 8px; }
.cs-btn-ghost {
  background: none; border: 1px solid var(--border); color: var(--text-muted); border-radius: 8px;
  padding: 7px 14px; font-size: 13px; cursor: pointer; transition: background .15s, color .15s;
}
.cs-btn-ghost:hover { background: var(--hover); color: var(--text); }
.cs-btn-xs { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.cs-btn-danger {
  display: block; width: 100%; padding: 12px; border-radius: 10px;
  background: rgba(239,68,68,.12); color: #f87171; font-size: 14px; font-weight: 600;
  border: 1px solid rgba(239,68,68,.2); cursor: pointer; text-align: center; transition: background .15s;
}
.cs-btn-danger:hover { background: rgba(239,68,68,.2); }
.cs-btn-danger-sm {
  padding: 4px 10px; border-radius: 6px; font-size: 12px; font-weight: 600; cursor: pointer;
  background: rgba(239,68,68,.12); color: #f87171; border: 1px solid rgba(239,68,68,.2);
}
.cs-btn-icon {
  background: none; border: none; cursor: pointer; padding: 6px; border-radius: 6px;
  color: var(--text-muted); display: flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s; flex-shrink: 0;
}
.cs-btn-icon:hover { background: var(--hover); color: var(--accent); }
.cs-btn-icon:disabled { opacity: .35; cursor: not-allowed; }

.cs-link2-row {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.cs-link2-row-last { border-bottom: none; }
.cs-link2-icon { flex-shrink: 0; color: var(--text-muted); }
.cs-link2-body { flex: 1; min-width: 0; }
.cs-link2-label { font-size: 11px; color: var(--text-muted); margin-bottom: 2px; }
.cs-link2-url { font-size: 12px; color: var(--text); font-family: monospace; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.cs-admin2-row {
  display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.cs-admin2-row:last-child { border-bottom: none; }
.cs-admin2-body { flex: 1; min-width: 0; }
.cs-admin2-name { font-size: 14px; font-weight: 500; }
.cs-admin2-title { font-size: 12px; color: var(--accent); margin-top: 2px; }
.cs-expand-btn {
  background: none; border: none; padding: 0; margin-top: 6px;
  font-size: 12px; color: var(--text-muted); cursor: pointer; text-align: left;
  transition: color .15s;
}
.cs-expand-btn:hover { color: var(--accent); }
.cs-admin2-perms { margin-top: 10px; }
.cs-perms-list { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; margin-top: 6px; }
.cs-admin2-actions { display: flex; gap: 8px; margin-top: 10px; }

.cs-member2-row {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px;
  border-bottom: 1px solid var(--border); transition: background .15s;
}
.cs-member2-row-last { border-bottom: none; }
.cs-member2-info { flex: 1; min-width: 0; }
.cs-member2-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cs-member2-role { font-size: 11px; color: var(--text-muted); margin-top: 1px; }
.cs-member-you { color: var(--text-muted); font-weight: 400; }
.cs-member2-actions { display: flex; gap: 6px; flex-shrink: 0; }

.cs-inv2-row {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.cs-inv2-row-last { border-bottom: none; }
.cs-inv2-body { flex: 1; min-width: 0; }
.cs-inv2-name { font-size: 13px; font-weight: 500; }
.cs-inv2-meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.cs-inv2-url { font-size: 11px; color: var(--text-muted); font-family: monospace; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.cs-inv2-actions { display: flex; gap: 4px; flex-shrink: 0; }

.cs-log2-row {
  display: flex; align-items: flex-start; gap: 10px; padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.cs-log2-row-last { border-bottom: none; }
.cs-log2-body { flex: 1; min-width: 0; }
.cs-log2-actor { font-size: 13px; font-weight: 500; }
.cs-log2-action { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.cs-log2-time { font-size: 11px; color: var(--text-muted); flex-shrink: 0; white-space: nowrap; }

.cs-user-results2 {
  margin-top: 4px; border-radius: 10px; overflow: hidden;
  border: 1px solid var(--border); background: var(--card-bg);
}
.cs-user2-result {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; cursor: pointer;
  border-bottom: 1px solid var(--border); transition: background .15s;
}
.cs-user2-result:last-child { border-bottom: none; }
.cs-user2-result:hover { background: var(--hover); }
.cs-user2-name { font-size: 13px; font-weight: 500; }
.cs-user2-login { font-size: 11px; color: var(--text-muted); }

@media (max-width: 600px) {
  .cs-modal { width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0; }
  .cs-section { padding-left: 12px; padding-right: 12px; }
}

.cs-label { font-size: 12px; font-weight: 600; color: var(--text-muted); flex-shrink: 0; min-width: 100px; }
.cs-sublabel { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.cs-input {
  width: 100%; padding: 8px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--input-bg); color: var(--text);
  font-size: 13px; transition: border-color var(--transition); box-sizing: border-box;
  font-family: inherit;
}
.cs-input:focus { border-color: var(--accent); outline: none; }
.cs-textarea {
  width: 100%; padding: 8px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--input-bg); color: var(--text);
  font-size: 13px; resize: vertical; min-height: 66px;
  transition: border-color var(--transition); box-sizing: border-box; font-family: inherit;
}
.cs-textarea:focus { border-color: var(--accent); outline: none; }
.cs-select {
  padding: 8px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--input-bg); color: var(--text);
  font-size: 13px; font-family: inherit; cursor: pointer;
}
.cs-toggle {
  position: relative; width: 38px; height: 22px; flex-shrink: 0; cursor: pointer; display: inline-block;
}
.cs-toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.cs-toggle input:checked + .cs-toggle-slider { background: var(--accent); }
.cs-toggle input:checked + .cs-toggle-slider::before { transform: translateX(16px); }
.cs-actions { padding: 12px 0; display: flex; justify-content: flex-end; gap: 8px; }
.cs-link-row { display: flex; align-items: center; gap: 8px; }
.cs-link-text { flex: 1; font-size: 12px; color: var(--text-muted); font-family: monospace; word-break: break-all; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cs-danger-card { margin-top: 8px; }
.cs-empty { padding: 14px; color: var(--text-muted); font-size: 13px; text-align: center; }
.cs-perm-radio-item {
  display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); user-select: none;
  padding: 8px 14px; cursor: pointer;
}
.cs-perm-radio-item input { width: auto; margin: 0; }
.cs-admin-role { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.cs-admin-expand-toggle { font-size: 12px; color: var(--accent); cursor: pointer; margin-top: 4px; }
.cs-admin-title-input { margin-bottom: 6px; }
.cs-user-results { margin-top: 6px; max-height: 160px; overflow-y: auto; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--input-bg); }
.cs-user-result {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px; cursor: pointer;
  transition: background var(--transition);
}
.cs-user-result:hover { background: var(--hover); }
.cs-user-name { font-size: 13px; font-weight: 500; }
.cs-user-login { font-size: 11px; color: var(--text-muted); }
.cs-member-role { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.btn-danger-sm {
  padding: 4px 10px; border-radius: 6px; font-size: 12px; font-weight: 600; cursor: pointer;
  background: rgba(239,68,68,.12); color: #f87171; border: 1px solid rgba(239,68,68,.25);
  transition: background var(--transition), color var(--transition);
}
.btn-danger-sm:hover { background: rgba(239,68,68,.22); }

.cs-body { padding: 12px 16px; display: flex; flex-direction: column; gap: 8px; }
.cs-body .cs-card { margin-bottom: 0; }

.mention { color: var(--accent); cursor: pointer; }
.mention:hover { text-decoration: underline; }
.msg-row.own .mention { color: rgba(255,255,255,.85); }
.cmd-link { color: var(--accent); cursor: pointer; }
.cmd-link:hover { text-decoration: underline; }
.msg-row.own .cmd-link { color: rgba(255,255,255,.85); }
.msg-link { color: inherit; text-decoration: underline; cursor: pointer; word-break: break-all; }
.msg-row.own .msg-link { color: rgba(255,255,255,.9); }
.msg-row.other .msg-link { color: var(--accent); }
.md-code { font-family: 'Courier New', monospace; font-size: .88em; background: rgba(0,0,0,.15); border-radius: 4px; padding: 1px 5px; }
.msg-row.own .md-code { background: rgba(0,0,0,.25); }
.md-pre { margin: 4px 0; padding: 8px 10px; background: rgba(0,0,0,.18); border-radius: 6px; overflow-x: auto; font-family: 'Courier New', monospace; font-size: .85em; white-space: pre; }
.msg-row.own .md-pre { background: rgba(0,0,0,.28); }
.msg-bubble b { font-weight: 700; }
.msg-bubble em { font-style: italic; }
.msg-bubble s { text-decoration: line-through; opacity: .75; }

.channel-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

.bot-start-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}
.bot-start-btn {
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: opacity 0.15s;
}
.bot-start-btn:hover { opacity: 0.85; }
.channel-sub-btn, .channel-unsub-btn { min-width: 160px; }

.btn-danger {
  display: block; width: 100%; padding: 10px 18px; border-radius: var(--radius-sm);
  background: rgba(239,68,68,.12); color: #f87171; font-size: 14px; font-weight: 600;
  border: 1px solid rgba(239,68,68,.25); cursor: pointer; transition: background var(--transition), color var(--transition);
  text-align: center;
}
.btn-danger:hover { background: rgba(239,68,68,.22); color: #fca5a5; }

.settings-panel {
  position: absolute; inset: 0; z-index: 20;
  background: var(--sidebar-bg);
  transform: translateX(-100%);
  transition: transform .22s cubic-bezier(.4,0,.2,1);
  display: flex; flex-direction: column; overflow: hidden;
}
.settings-panel.sp-open { transform: translateX(0); }

.sp-head {
  position: relative;
  display: flex; flex-direction: column; align-items: center;
  padding: 28px 24px 20px;
  background: linear-gradient(160deg, #1e2a4a 0%, #14141a 100%);
}

.sp-head-edit-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  color: #dbe7ff;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.15);
}
.sp-head-edit-btn:hover {
  background: rgba(255,255,255,.15);
}

.sp-avatar {
  width: 80px; height: 80px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; font-weight: 700; color: #fff;
  overflow: hidden; flex-shrink: 0; margin-bottom: 12px;
  border: 3px solid rgba(255,255,255,.12);
}
.sp-avatar img { width: 100%; height: 100%; object-fit: cover; }
.sp-avatar video { width: 100%; height: 100%; object-fit: cover; }

.sp-name {
  font-size: 18px; font-weight: 700; color: var(--text); text-align: center;
}
.sp-status {
  font-size: 12px; color: var(--online); margin-top: 4px;
}

.sp-body { flex: 1; overflow-y: auto; padding: 8px 0; }

.sp-row {
  display: flex; align-items: flex-start; gap: 16px;
  padding: 12px 20px; cursor: default;
  transition: background var(--transition);
}
.sp-row:hover { background: rgba(255,255,255,.04); }
.sp-row-icon {
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(59,130,246,.15); color: var(--accent);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  margin-top: 2px;
}
.sp-row-val { font-size: 14px; color: var(--text); font-weight: 500; }
.sp-row-label { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.sp-row-editable { cursor: pointer; }
.sp-edit-hint { color: var(--accent); font-size: 10px; }
.sp-edit-form {
  padding: 10px 20px 14px; border-bottom: 1px solid var(--border);
}
.sp-edit-inner {
  display: flex; align-items: center;
  background: var(--input-bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 6px 10px; gap: 4px;
  transition: border-color var(--transition);
}
.sp-edit-inner:focus-within { border-color: var(--accent); }
.sp-edit-prefix { color: var(--text-muted); font-size: 14px; user-select: none; }
.sp-edit-input { flex: 1; font-size: 14px; background: none; border: none; outline: none; color: var(--text); }
.sp-edit-hint-text { font-size: 11px; color: var(--text-muted); margin-top: 6px; }
.sp-edit-actions { display: flex; gap: 8px; margin-top: 10px; }

.sp-tabs {
  display: flex; border-bottom: 1px solid var(--border);
  padding: 0 12px; flex-shrink: 0;
}
.sp-tab {
  flex: 1; padding: 10px 8px; font-size: 13px; font-weight: 600;
  color: var(--text-muted); border-bottom: 2px solid transparent;
  cursor: pointer; transition: color var(--transition), border-color var(--transition);
  background: none; border-top: none; border-left: none; border-right: none;
  margin-bottom: -1px;
}
.sp-tab:hover { color: var(--text); }
.sp-tab-active { color: var(--accent); border-bottom-color: var(--accent); }
.sp-section-title {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-muted); padding: 14px 20px 6px;
}

.sp-toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; gap: 12px;
  border-bottom: 1px solid var(--border);
}
.sp-toggle-row:last-child { border-bottom: none; }
.sp-toggle-info { flex: 1; }
.sp-toggle-label { font-size: 14px; font-weight: 500; color: var(--text); }
.sp-toggle-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.sp-toggle { position: relative; display: inline-block; width: 42px; height: 24px; flex-shrink: 0; }
.sp-toggle input { opacity: 0; width: 0; height: 0; }
.sp-toggle-slider {
  position: absolute; inset: 0; background: rgba(255,255,255,.15);
  border-radius: 12px; cursor: pointer;
  transition: background var(--transition);
}
.sp-toggle-slider::before {
  content: ''; position: absolute;
  width: 18px; height: 18px; border-radius: 50%; background: #fff;
  left: 3px; top: 3px;
  transition: transform .18s;
}
.sp-toggle input:checked + .sp-toggle-slider { background: var(--accent); }
.sp-toggle input:checked + .sp-toggle-slider::before { transform: translateX(18px); }

.profile-panel {
  position: absolute; top: 0; right: 0; bottom: 0; left: auto;
  width: 300px;
  background: var(--sidebar-bg);
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow: hidden;
  transform: translate3d(100%, 0, 0);
  transition: transform .22s cubic-bezier(.4,0,.2,1);
  z-index: 5;
}
.profile-panel.pp-open { transform: translate3d(0, 0, 0); }

.pp-header {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.pp-close { color: var(--text-muted); }
.pp-title { font-size: 15px; font-weight: 700; }

.pp-head {
  display: flex; flex-direction: column; align-items: center;
  padding: 24px 20px 18px;
  background: linear-gradient(160deg, #1e2a4a 0%, #14141a 100%);
  flex-shrink: 0;
}
.pp-avatar {
  width: 80px; height: 80px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; font-weight: 700; color: #fff; overflow: hidden;
  margin-bottom: 12px; border: 3px solid rgba(255,255,255,.12);
}
.pp-avatar img { width: 100%; height: 100%; object-fit: cover; }
.pp-avatar video { width: 100%; height: 100%; object-fit: cover; }
.pp-name { font-size: 17px; font-weight: 700; text-align: center; }
.top-emoji { display: inline-block; object-fit: contain; vertical-align: middle; }
.top-emoji-pp { width: 20px; height: 20px; margin-left: 5px; }
.top-emoji-msg { width: 16px; height: 16px; flex-shrink: 0; }
.top-emoji-header { width: 18px; height: 18px; margin-left: 5px; vertical-align: middle; flex-shrink: 0; }
.top-emoji-list { width: 14px; height: 14px; margin-left: 4px; vertical-align: middle; flex-shrink: 0; }
.pp-login { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.pp-lastseen { font-size: 12px; color: var(--online); margin-top: 4px; min-height: 16px; }

.pp-body { flex: 1; overflow-y: auto; padding: 8px 0; }
.pp-bio-row {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.pp-bio-row:last-child { border-bottom: none; }
.pp-member-main {
  flex: 1;
  min-width: 0;
}
.pp-member-role-line {
  display: flex;
  align-items: center;
  margin-bottom: 4px;
}
.pp-member-role-line .pp-role-badge {
  margin-left: 0;
}
.pp-member-menu-trigger {
  margin-left: auto;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.03);
  color: #cfd6ea;
  font-size: 18px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
}
.pp-member-menu-trigger:hover {
  background: rgba(255,255,255,.09);
  border-color: rgba(255,255,255,.22);
  color: #f1f5ff;
}
.pp-member-menu-trigger:active {
  transform: scale(.97);
}
.pp-member-menu-trigger:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.pp-member-menu-hint {
  margin-left: auto;
  font-size: 18px;
  line-height: 1;
  color: var(--text-muted);
  opacity: .75;
  user-select: none;
}
.pp-role-badge {
  display: inline-flex;
  align-items: center;
  margin-left: 8px;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .02em;
  text-transform: uppercase;
  vertical-align: middle;
}
.pp-role-owner {
  color: #fde68a;
  background: rgba(245,158,11,.18);
  border: 1px solid rgba(245,158,11,.35);
}
.pp-role-admin {
  color: #93c5fd;
  background: rgba(59,130,246,.18);
  border: 1px solid rgba(59,130,246,.35);
}
.pp-role-member {
  color: var(--text-muted);
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.08);
}

.pp-actions { padding: 16px; border-top: 1px solid var(--border); flex-shrink: 0; }
.pp-actions .btn-primary {
  width: 100%; padding: 10px; font-size: 14px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.pp-loading {
  flex: 1; display: flex; align-items: center; justify-content: center;
}

@media (max-width: 640px) {
  .profile-panel {
    position: fixed;
    inset: 0;
    width: 100%;
    z-index: 20;
    transform: translate3d(100%, 0, 0);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
  }
  .profile-panel.pp-open {
    transform: translate3d(0, 0, 0);
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }
}
