:root {
  --bg: #0b1020;
  --bg-soft: #11182e;
  --panel: rgba(15, 21, 38, 0.92);
  --panel-strong: rgba(13, 19, 34, 0.98);
  --surface: rgba(255, 255, 255, 0.04);
  --surface-strong: rgba(255, 255, 255, 0.07);
  --line: rgba(142, 162, 204, 0.16);
  --text: #eef3ff;
  --muted: #91a0bf;
  --accent: #6fd6ff;
  --accent-strong: #4ab4ff;
  --success: #8cffc4;
  --danger: #ff7b90;
  --warning: #f5d17a;
  --radius-sm: 16px;
  --radius-md: 22px;
  --radius-lg: 28px;
  --shadow-soft: 0 24px 70px rgba(0, 0, 0, 0.25);
  --shadow-strong: 0 40px 120px rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  height: 100%;
}

body {
  font-family: "Manrope", "Segoe UI", Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(74, 180, 255, 0.14), transparent 24%),
    radial-gradient(circle at top right, rgba(111, 214, 255, 0.12), transparent 26%),
    linear-gradient(180deg, #070b15 0%, #0b1020 48%, #090d1a 100%);
}

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

button,
input,
textarea,
select {
  font: inherit;
}

select,
option {
  color-scheme: dark;
}

.hidden {
  display: none !important;
}

.brand-pill,
.section-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(255, 255, 255, 0.03);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  padding: 12px 18px;
  border-radius: 15px;
  border: 1px solid transparent;
  cursor: pointer;
  transition:
    transform 0.18s ease,
    background 0.18s ease,
    border-color 0.18s ease,
    opacity 0.18s ease,
    box-shadow 0.18s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  color: #09111b;
  background: linear-gradient(135deg, #7de8ff, #baf4ff);
  box-shadow: 0 16px 34px rgba(111, 214, 255, 0.22);
}

.btn-secondary {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--line);
}

.btn-ghost {
  color: var(--muted);
  background: transparent;
  border-color: var(--line);
}

.btn-danger {
  color: #ffe8ec;
  background: rgba(255, 123, 144, 0.12);
  border-color: rgba(255, 123, 144, 0.24);
}

.btn-wide {
  width: 100%;
}

.btn-compact {
  min-height: 40px;
  padding: 10px 14px;
}

.icon-btn {
  width: 44px;
  height: 44px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.icon-btn:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.07);
}

input,
textarea,
select {
  width: 100%;
  min-height: 50px;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: rgba(111, 214, 255, 0.38);
  box-shadow: 0 0 0 4px rgba(111, 214, 255, 0.08);
}

input::placeholder,
textarea::placeholder {
  color: rgba(145, 160, 191, 0.74);
}

select option {
  color: var(--text);
  background: #131a2d;
}

textarea {
  min-height: 92px;
  resize: vertical;
}

.auth-page {
  display: grid;
  place-items: center;
  padding: 16px;
}

.auth-layout {
  width: min(100%, 430px);
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.auth-card,
.profile-card,
.search-card,
.dialogs-card,
.chat-panel,
.modal-card,
.admin-auth-card,
.admin-card {
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(17, 24, 44, 0.98), rgba(10, 15, 27, 0.98));
  box-shadow: var(--shadow-soft);
}

.auth-minimal-card {
  width: 100%;
  padding: 22px;
  display: grid;
  gap: 14px;
}

.auth-help {
  display: grid;
  gap: 8px;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid rgba(111, 214, 255, 0.14);
  background: linear-gradient(180deg, rgba(111, 214, 255, 0.08), rgba(255, 255, 255, 0.02));
}

.auth-help p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.auth-help strong {
  color: var(--text);
  font-weight: 700;
}

.auth-status,
.modal-status,
.composer-status,
.typing-line {
  min-height: 1.2em;
  margin-top: 6px;
  color: var(--muted);
}

.auth-status:empty,
.modal-status:empty,
.composer-status:empty,
.typing-line:empty {
  display: none;
}

.auth-status[data-state="error"],
.modal-status[data-state="error"] {
  color: #ffb9c3;
}

.auth-status[data-state="warning"],
.modal-status[data-state="warning"] {
  color: #ffe4a3;
}

.auth-status[data-state="pending"],
.auth-status[data-state="preview"],
.modal-status[data-state="pending"] {
  color: var(--accent);
}

.messenger-page {
  overflow: hidden;
}

.messenger-shell {
  width: min(100%, 1600px);
  height: 100dvh;
  margin: 0 auto;
  padding: 18px;
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 18px;
  min-height: 0;
  overflow: hidden;
}

.sidebar-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
  overflow: hidden;
}

.sidebar-brand-row {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 18px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(14, 20, 37, 0.98), rgba(10, 15, 27, 0.98));
  box-shadow: var(--shadow-soft);
}

.sidebar-brand-actions,
.admin-topbar-actions {
  display: flex;
  gap: 10px;
}

.sidebar-brand-actions {
  align-items: center;
  flex-wrap: nowrap;
  min-width: 0;
}

.sidebar-brand-actions #composeMenuBtn {
  order: 1;
}

.sidebar-brand-actions #accountStrip {
  order: 2;
}

.sidebar-brand-actions #openProfileBtn {
  order: 3;
}

.account-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.account-strip::-webkit-scrollbar {
  display: none;
}

.account-switch-btn {
  flex: 0 0 auto;
  overflow: hidden;
  padding: 0;
}

.sidebar-caption,
.dialog-subtitle,
.dialog-preview,
.chat-subtitle,
.admin-user-meta,
.admin-user-note,
.search-item-bio,
.search-item-tag,
.empty-note {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.floating-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 18px;
  z-index: 20;
  min-width: 200px;
  padding: 8px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(10, 14, 24, 0.98);
  box-shadow: var(--shadow-strong);
}

.floating-menu-item {
  width: 100%;
  padding: 12px 14px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.floating-menu-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.dialogs-card {
  padding: 16px;
}

.promo-card {
  padding: 16px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(17, 24, 44, 0.98), rgba(10, 15, 27, 0.98));
  box-shadow: var(--shadow-soft);
  display: grid;
  gap: 14px;
  min-height: 188px;
}

.profile-card-avatar,
.dialog-avatar,
.message-avatar,
.chat-avatar-circle,
.avatar-circle {
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
  border-radius: 50%;
  background-size: cover;
  background-position: center;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background-color: rgba(255, 255, 255, 0.06);
}

.dialog-avatar {
  width: 52px;
  height: 52px;
  flex-basis: 52px;
}

.chat-avatar-circle {
  width: 54px;
  height: 54px;
  flex-basis: 54px;
}

.avatar-fallback {
  display: grid;
  place-items: center;
  font-weight: 800;
  color: #e9f8ff;
  background-image: linear-gradient(135deg, rgba(111, 214, 255, 0.3), rgba(74, 180, 255, 0.22));
}

.search-box {
  position: relative;
  margin-top: 12px;
}

.search-box-inline {
  margin-top: 0;
}

.search-results {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  right: 0;
  z-index: 15;
  max-height: 320px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(9, 13, 24, 0.98);
  box-shadow: var(--shadow-soft);
}

.search-item,
.admin-conversation-card {
  width: 100%;
  padding: 14px 16px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  border: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.search-item:last-child,
.admin-conversation-card:last-child {
  border-bottom: 0;
}

.search-item:hover,
.admin-conversation-card:hover {
  background: rgba(255, 255, 255, 0.04);
}

.search-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.search-item-main {
  min-width: 0;
  flex: 1;
  display: grid;
  gap: 4px;
}

.search-item-avatar {
  width: 44px;
  height: 44px;
  flex-basis: 44px;
}

.search-empty {
  padding: 14px 16px;
  color: var(--muted);
}

.admin-conversation-card {
  display: grid;
  gap: 10px;
  align-items: initial;
}

.dialogs-card {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.dialogs-card-head,
.admin-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.conversation-list,
.admin-list {
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  display: grid;
  gap: 10px;
  align-content: start;
}

.promo-list {
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  display: grid;
  gap: 10px;
  align-content: start;
}

.dialog-item {
  width: 100%;
  min-width: 0;
  padding: 14px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
  text-align: left;
  overflow: visible;
  color: var(--text);
  transition: background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.promo-item {
  width: 100%;
  padding: 14px;
  display: flex;
  gap: 14px;
  align-items: flex-start;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
  text-align: left;
  overflow: visible;
  color: var(--text);
  transition: background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.dialog-main {
  min-width: 0;
  flex: 1;
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.promo-item:hover {
  background: rgba(255, 255, 255, 0.05);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.18);
}

.dialog-item:hover {
  background: rgba(255, 255, 255, 0.05);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.18);
}

.dialog-item.active {
  border-color: rgba(111, 214, 255, 0.28);
  background: linear-gradient(180deg, rgba(111, 214, 255, 0.12), rgba(74, 180, 255, 0.05));
}

.dialog-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow: visible;
}

.dialog-top-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 10px;
}

.dialog-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: flex-start;
  gap: 8px;
  flex: 0 0 auto;
  min-width: 42px;
  position: relative;
}

.dialog-menu-wrap,
.message-menu-wrap {
  position: relative;
  display: inline-flex;
}

.dialog-menu-wrap.menu-open,
.message-menu-wrap.menu-open {
  z-index: 1705;
}

.dialog-menu-trigger,
.message-menu-trigger {
  width: 30px;
  height: 30px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.message-menu-trigger {
  background: rgba(9, 14, 24, 0.86);
  border-color: rgba(255, 255, 255, 0.18);
  color: var(--text);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(8px);
}

.dialog-menu-trigger:hover,
.message-menu-trigger:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.mini-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 1600;
  min-width: 154px;
  padding: 6px;
  display: none;
  gap: 5px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #0c1220;
  box-shadow: var(--shadow-soft);
}

.mini-menu.open {
  display: grid;
}

.message-mini-menu {
  top: calc(100% + 8px);
  bottom: auto;
  left: auto;
  right: 0;
}

.mini-menu-item {
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 10px;
  background: #151f34;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.mini-menu-item:hover {
  background: #1b2740;
}

.mini-menu-item.danger {
  color: #ffd4dd;
  background: #40202b;
}

.mini-menu-reactions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 5px;
}

.mini-emoji-btn {
  width: 30px;
  height: 30px;
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: 10px;
  background: #151f34;
  cursor: pointer;
}

.mini-emoji-btn:hover {
  background: #1b2740;
}

.dialog-title,
.admin-user-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
  min-width: 0;
  max-width: 100%;
  line-height: 1.28;
  word-break: break-word;
  display: -webkit-box;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.dialog-subtitle,
.dialog-preview {
  min-width: 0;
  max-width: 100%;
  word-break: break-word;
}

.dialog-subtitle {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dialog-preview {
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  white-space: normal;
  overflow: hidden;
  word-break: break-word;
}

.admin-identity {
  color: var(--text) !important;
}

.dialog-badge,
.dialog-type,
.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.dialog-badge {
  background: rgba(255, 94, 114, 0.2);
  color: #ffe7eb;
  border: 1px solid rgba(255, 118, 136, 0.28);
}

.status-pill.success {
  background: rgba(140, 255, 196, 0.16);
  color: #d9ffe9;
}

.dialog-type,
.status-pill.info {
  background: rgba(111, 214, 255, 0.14);
  color: #dff6ff;
}

.status-pill.danger {
  background: rgba(255, 123, 144, 0.14);
  color: #ffe2e8;
}

.status-pill.muted {
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
}

.chat-panel {
  display: flex;
  min-height: 0;
  min-width: 0;
  height: calc(100dvh - 36px);
  overflow: hidden;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(16, 22, 40, 0.98), rgba(10, 15, 27, 0.98));
  box-shadow: var(--shadow-soft);
}

.chat-empty-state,
.chat-view {
  flex: 1;
  min-height: 0;
}

.chat-empty-state {
  display: grid;
  place-items: center;
  padding: 24px;
}

.chat-empty-card {
  width: min(100%, 560px);
  padding: 34px;
  text-align: center;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(17, 24, 44, 0.96), rgba(10, 15, 27, 0.96));
  box-shadow: var(--shadow-soft);
}

.chat-empty-card h2 {
  margin: 18px 0 12px;
  font-size: clamp(34px, 5vw, 60px);
  line-height: 0.96;
}

.chat-empty-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.chat-view {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(11, 16, 32, 0.88);
  backdrop-filter: blur(16px);
}

.chat-header-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-header-tools {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-search-inline,
.chat-search-mobile {
  min-width: 0;
}

.chat-search-inline input,
.chat-search-mobile input {
  width: 240px;
  max-width: 100%;
}

.chat-search-mobile {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-search-mobile.hidden,
.chat-search-inline.hidden {
  display: none;
}

.mobile-back-btn {
  display: none;
}

.chat-profile-trigger {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  padding: 8px 10px;
  border-radius: 18px;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.chat-profile-trigger:hover {
  background: rgba(255, 255, 255, 0.04);
}

.chat-title-group {
  display: flex;
  align-items: center;
  min-width: 0;
}

.chat-subtitle {
  display: grid;
  gap: 2px;
}

.chat-subtitle-main {
  color: var(--muted);
}

.chat-subtitle-status {
  color: rgba(111, 214, 255, 0.92);
  font-size: 13px;
}

.chat-header h1 {
  margin: 0;
  font-size: clamp(20px, 3vw, 28px);
  line-height: 1;
  color: var(--text);
}

.public-profile-title-row,
.search-item-head {
  color: var(--text);
}

.message-list {
  flex: 1;
  min-height: 0;
  max-height: 100%;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.message-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.message-row.mine {
  justify-content: flex-end;
}

.message-bubble {
  position: relative;
  max-width: min(700px, 82%);
  min-width: 220px;
  padding: 14px 16px 42px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.18);
  overflow-wrap: anywhere;
}

.message-reply-quote {
  display: grid;
  gap: 4px;
  margin-bottom: 10px;
  padding: 10px 12px;
  border-radius: 16px;
  border-left: 3px solid rgba(111, 214, 255, 0.82);
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
}

.message-reply-quote strong {
  font-size: 12px;
  color: var(--accent);
}

.message-reply-quote span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.message-bubble.mine {
  background: linear-gradient(135deg, rgba(111, 214, 255, 0.16), rgba(74, 180, 255, 0.08));
  border-color: rgba(111, 214, 255, 0.2);
}

.message-bubble.has-visual {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  width: fit-content;
  max-width: min(460px, 82%);
  min-width: 170px;
  padding: 10px 10px 40px;
  background: rgba(17, 24, 44, 0.92);
  border-color: rgba(255, 255, 255, 0.08);
}

.message-bubble.has-visual.only-visual {
  padding: 6px;
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

.message-bubble.has-visual .message-meta,
.message-bubble.has-visual .message-text {
  padding-left: 4px;
  padding-right: 4px;
}

.message-bubble.has-visual.only-visual .message-meta {
  margin-bottom: 6px;
}

.message-meta {
  position: absolute;
  right: 12px;
  bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
  min-width: 0;
  max-width: calc(100% - 56px);
}

.message-meta.align-end {
  justify-content: flex-end;
}

.message-meta.direct-meta {
  gap: 6px;
}

.message-meta.group-meta {
  gap: 6px;
}

.message-meta-identity {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  max-width: 170px;
  overflow: hidden;
}

.message-meta-identity > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-menu-wrap {
  position: absolute;
  left: 12px;
  bottom: 8px;
  z-index: 4;
}

.message-state {
  font-weight: 800;
  letter-spacing: -0.14em;
  color: rgba(145, 160, 191, 0.92);
}

.message-state.read {
  color: var(--accent);
}

.message-text {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.65;
}

.message-forwarded-note {
  margin-bottom: 8px;
  color: var(--accent);
  font-size: 12px;
  line-height: 1.4;
}

.message-reactions {
  position: absolute;
  left: 52px;
  bottom: 8px;
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
  max-width: none;
  white-space: nowrap;
}

.message-jump-target {
  box-shadow:
    0 0 0 1px rgba(111, 214, 255, 0.5),
    0 0 0 6px rgba(111, 214, 255, 0.08);
}

.reaction-pill {
  min-width: 34px;
  min-height: 26px;
  padding: 3px 8px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  cursor: pointer;
}

.reaction-pill.active {
  border-color: rgba(111, 214, 255, 0.32);
  background: rgba(111, 214, 255, 0.14);
}

.system-message-row {
  display: flex;
  justify-content: center;
}

.system-message-pill {
  max-width: 70%;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  text-align: center;
}

.message-bubble.search-hit {
  border-color: rgba(111, 214, 255, 0.24);
}

.message-bubble.search-current {
  border-color: rgba(111, 214, 255, 0.56);
  box-shadow: 0 0 0 1px rgba(111, 214, 255, 0.22), 0 12px 28px rgba(0, 0, 0, 0.18);
}

.message-attachment {
  margin-top: 10px;
  overflow: hidden;
  border-radius: 18px;
  background: rgba(7, 11, 21, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.06);
  display: inline-flex;
  width: fit-content;
  max-width: 100%;
}

.message-attachment img,
.message-attachment video {
  width: 100%;
  max-width: min(440px, 100%);
  border-radius: 18px;
  border: 0;
  background: transparent;
  display: block;
  cursor: zoom-in;
}

.message-attachment video.circle {
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  object-fit: cover;
}

.message-attachment audio {
  width: min(360px, 100%);
}

.voice-attachment {
  display: block;
  width: min(420px, 100%);
  background: rgba(255, 255, 255, 0.04);
}

.voice-player {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.05);
}

.voice-player-btn {
  width: 54px;
  height: 54px;
  flex: 0 0 54px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  background: rgba(12, 18, 30, 0.55);
  color: var(--text);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  display: grid;
  place-items: center;
}

.voice-player-wave {
  min-width: 0;
  flex: 1 1 auto;
  height: 42px;
  display: flex;
  align-items: flex-end;
  gap: 2px;
  overflow: hidden;
  cursor: pointer;
  touch-action: none;
  user-select: none;
}

.voice-player-bar {
  flex: 1 1 0;
  min-width: 2px;
  height: var(--voice-bar-height, 42%);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.28);
  transition: background 0.16s ease, transform 0.16s ease;
  transform-origin: center bottom;
}

.voice-player-bar.active {
  background: linear-gradient(180deg, rgba(125, 232, 255, 0.96), rgba(93, 153, 255, 0.92));
  transform: translateY(-1px);
}

.voice-player-time {
  flex: 0 0 auto;
  min-width: 48px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.voice-player-audio {
  display: none;
}

.message-file {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.typing-line {
  padding: 0 22px 10px;
}

.channel-action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 22px;
  border-top: 1px solid var(--line);
  background: rgba(9, 14, 26, 0.88);
  flex-wrap: wrap;
}

.channel-action-copy {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 4px;
  color: var(--muted);
  line-height: 1.6;
}

.channel-action-line {
  color: var(--text);
}

.channel-action-note {
  font-style: italic;
}

.composer-panel {
  padding: 18px 22px 24px;
  border-top: 1px solid var(--line);
  background: rgba(9, 14, 26, 0.9);
}

.composer-reply {
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.composer-reply-copy {
  min-width: 0;
  flex: 1;
  display: grid;
  gap: 3px;
}

.composer-reply-copy strong {
  font-size: 13px;
  color: var(--accent);
}

.composer-reply-copy span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.composer-reply-close {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  cursor: pointer;
}

.composer-preview {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  display: flex;
  align-items: center;
  gap: 12px;
}

.composer-preview-media {
  width: 56px;
  height: 56px;
  flex: 0 0 56px;
  overflow: hidden;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(7, 11, 21, 0.92);
  display: grid;
  place-items: center;
}

.composer-preview-media img,
.composer-preview-media video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.composer-preview-icon {
  font-size: 24px;
}

.composer-preview-meta {
  min-width: 0;
  flex: 1;
  display: grid;
  gap: 4px;
}

.composer-preview-meta strong,
.composer-preview-meta span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.composer-preview-meta span {
  color: var(--muted);
  font-size: 13px;
}

.composer-preview-remove {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  cursor: pointer;
}

.composer-box {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto auto;
  gap: 12px;
  align-items: center;
}

.composer-box.voice-recording-mode {
  grid-template-columns: auto minmax(0, 1fr) auto auto auto;
}

.composer-box input[type="text"] {
  min-height: 44px;
  height: 44px;
  padding-top: 0;
  padding-bottom: 0;
}

.voice-recorder {
  min-width: 0;
  min-height: 44px;
  height: 44px;
  padding: 0 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.045);
  display: flex;
  align-items: center;
  gap: 14px;
  overflow: hidden;
}

.voice-recorder-wave {
  min-width: 0;
  flex: 1 1 auto;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 1px;
  overflow: hidden;
}

.voice-wave-bar {
  flex: 1 1 0;
  min-width: 2px;
  height: calc(8px + var(--voice-bar-scale, 0.14) * 24px);
  border-radius: 3px;
  background: linear-gradient(180deg, rgba(125, 232, 255, 0.96), rgba(93, 153, 255, 0.92));
  opacity: 0.94;
  transform-origin: center;
  transition: height 0.09s linear, opacity 0.09s linear;
}

.voice-recorder-time {
  flex: 0 0 auto;
  min-width: 52px;
  text-align: right;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
}

.voice-recording-active #messageInput,
.voice-recording-active #recordVoiceBtn,
.voice-recording-active #recordCircleBtn {
  display: none !important;
}

.voice-recorder-toggle {
  font-size: 18px;
  line-height: 1;
}

.voice-recording-active .voice-recorder-toggle,
.voice-recording-active #voiceRecorderDeleteBtn {
  display: inline-grid !important;
}

.voice-recording-active #voiceRecorderToggleBtn,
.voice-recording-active #voiceRecorderDeleteBtn {
  width: 48px;
  min-width: 48px;
  height: 48px;
  flex: 0 0 48px;
  border-radius: 16px;
  font-size: 18px;
  padding: 0;
}

.send-btn {
  min-width: 48px;
  width: 48px;
  height: 48px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  font-size: 22px;
  line-height: 1;
  border-radius: 16px;
}

.composer-secondary-row {
  display: flex;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(10px);
  overflow: auto;
  overscroll-behavior: contain;
}

.modal-card {
  width: min(100%, 560px);
  position: relative;
  padding: 28px;
  max-height: calc(100dvh - 40px);
  overflow: auto;
}

.modal-card h3,
.admin-auth-card h1 {
  margin: 16px 0 0;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 0.98;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  cursor: pointer;
}

.form-stack {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.form-stack label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
  flex-wrap: wrap;
}

.profile-actions {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 10px;
  width: 100%;
}

.profile-actions #saveProfileBtn,
.profile-actions #openSupportBtn {
  grid-column: span 2;
}

.profile-actions #openAppSettingsBtn {
  grid-column: span 4;
}

.profile-actions #logoutBtn,
.profile-actions #deleteAccountBtn {
  grid-column: span 4;
}

.profile-actions #openAdminPanelBtn {
  grid-column: 1 / -1;
}

.profile-actions .btn {
  width: 100%;
  justify-content: center;
  white-space: nowrap;
}

.devices-block {
  margin-top: 20px;
  display: grid;
  gap: 12px;
}

.device-list,
.forward-list {
  display: grid;
  gap: 10px;
}

.forward-list {
  max-height: min(58vh, 520px);
  overflow: auto;
  margin-top: 12px;
  padding-right: 4px;
}

.device-item,
.forward-item {
  width: 100%;
  padding: 12px 14px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
}

.device-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.device-item-copy,
.forward-item-copy {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.device-item-copy span,
.forward-item-copy span {
  color: var(--muted);
  line-height: 1.4;
}

.forward-item {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  text-align: left;
  color: var(--text);
}

.forward-item-copy strong {
  color: var(--text);
}

.profile-preview-card,
.public-profile-card {
  margin-top: 18px;
  padding: 18px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
}

.profile-preview-card {
  display: grid;
  place-items: center;
  cursor: pointer;
  justify-self: center;
  width: max-content;
  margin-left: auto;
  margin-right: auto;
}

.form-stack > .profile-preview-card {
  margin-top: 0;
  margin-bottom: 4px;
}

.profile-preview-avatar {
  width: 90px;
  height: 90px;
  flex-basis: 90px;
  font-size: 34px;
}

.public-profile-head {
  display: flex;
  align-items: center;
  gap: 16px;
}

.public-profile-avatar {
  width: 72px;
  height: 72px;
  flex-basis: 72px;
}

.public-profile-meta {
  display: grid;
  gap: 6px;
}

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

.public-profile-meta span,
.public-profile-bio {
  color: var(--muted);
  line-height: 1.6;
}

.public-profile-bio {
  margin-top: 18px;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.public-profile-members {
  margin-top: 18px;
  display: grid;
  gap: 10px;
}

.public-member-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
}

.public-member-link {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.public-member-avatar {
  width: 42px;
  height: 42px;
  flex-basis: 42px;
}

.public-member-meta {
  display: grid;
  gap: 4px;
}

.public-member-meta span {
  color: var(--muted);
  font-size: 13px;
}

.public-member-remove {
  min-height: 34px;
  padding: 8px 12px;
  flex: 0 0 auto;
}

.public-profile-card {
  overflow: hidden;
}

.public-profile-card .avatar-circle {
  width: 72px;
  height: 72px;
  flex-basis: 72px;
}

.entity-avatar-trigger .profile-preview-avatar,
.profile-avatar-trigger .profile-preview-avatar {
  background-size: cover;
  background-position: center;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 80;
  display: none;
  padding: 14px 18px;
  border-radius: 18px;
  background: #eef5ff;
  color: #08101c;
  box-shadow: var(--shadow-strong);
  transform: translateX(-50%) translateY(calc(100% + 80px));
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: transform 0.22s ease, opacity 0.22s ease, visibility 0.22s ease;
}

.toast.visible {
  display: flex;
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  visibility: visible;
}

.profile-open-btn {
  overflow: hidden;
  padding: 0;
}

.profile-open-avatar {
  width: 42px;
  height: 42px;
  flex-basis: 42px;
}

.account-switch-modal {
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(10px);
}

.modal-card-compact {
  width: min(100%, 430px);
}

.media-viewer-modal {
  z-index: 120;
  background: rgba(4, 8, 18, 0.88);
}

.media-viewer-shell {
  position: relative;
  width: min(100%, 1100px);
  max-height: 90vh;
  display: grid;
  place-items: center;
}

.media-viewer-close {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: rgba(9, 14, 26, 0.9);
  color: #fff;
  cursor: pointer;
}

.media-viewer-content {
  width: 100%;
  max-height: 90vh;
  display: grid;
  place-items: center;
}

.media-viewer-content img,
.media-viewer-content video {
  max-width: 100%;
  max-height: 90vh;
  border-radius: 22px;
  display: block;
}

.admin-page {
  padding: 20px;
  height: 100vh;
  overflow: hidden;
}

.admin-shell {
  width: min(100%, 1480px);
  height: calc(100vh - 40px);
  margin: 0 auto;
  display: grid;
  align-items: stretch;
}

.admin-auth-card {
  width: min(100%, 460px);
  padding: 24px;
  display: grid;
  gap: 14px;
  height: auto;
  align-self: center;
  justify-self: center;
  align-content: start;
}

.admin-dashboard {
  width: 100%;
  display: grid;
  gap: 16px;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  grid-template-rows: auto auto auto minmax(0, 1fr);
}

.admin-topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 18px 20px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(15, 21, 38, 0.98), rgba(10, 15, 27, 0.98));
}

.admin-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.summary-chip {
  padding: 14px 16px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  display: grid;
  gap: 4px;
}

.summary-chip span {
  color: var(--muted);
  font-size: 14px;
}

.summary-chip strong {
  font-size: 24px;
}

.admin-grid {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 16px;
  min-height: 0;
  height: 100%;
}

.admin-grid-three {
  grid-template-columns: minmax(320px, 0.92fr) minmax(260px, 0.78fr) minmax(360px, 1fr);
  min-height: 0;
}

.admin-card {
  padding: 16px;
  display: grid;
  gap: 12px;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  grid-template-rows: auto auto minmax(0, 1fr);
}

.admin-card .admin-list {
  min-height: 0;
}

.admin-card-wide {
  grid-column: 1 / -1;
}

.admin-users-panel .admin-list,
.admin-conversations-panel .admin-list,
.admin-messages-panel .admin-list {
  height: 100%;
  min-height: 0;
}

.admin-users-panel .admin-list {
  gap: 8px;
}

.admin-promo-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.admin-user-card,
.admin-message-card,
.admin-conversation-card {
  padding: 14px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  display: grid;
  gap: 10px;
}

.admin-user-card.selected,
.admin-conversation-card.active {
  border-color: rgba(111, 214, 255, 0.28);
  background: linear-gradient(180deg, rgba(111, 214, 255, 0.12), rgba(74, 180, 255, 0.05));
}

.admin-user-card.compact {
  gap: 7px;
  padding: 10px 12px;
  border-radius: 16px;
}

.admin-user-main {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.admin-user-avatar {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border-radius: 10px;
}

.admin-user-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.admin-user-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.admin-user-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.admin-user-badges,
.admin-user-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.admin-user-actions .btn,
.admin-user-actions .status-pill {
  width: auto;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  box-shadow: none;
}

.admin-user-actions .btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.admin-user-actions .status-pill.info,
.admin-user-actions .status-pill.success,
.admin-user-actions .status-pill.danger,
.admin-user-actions .status-pill.muted {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

.admin-user-card.compact .admin-user-actions {
  gap: 6px;
}

.admin-user-card.compact .btn-compact,
.admin-user-card.compact .status-pill {
  min-height: 28px;
  padding: 5px 8px;
  font-size: 11px;
  line-height: 1;
}

.admin-user-card.compact .admin-user-meta,
.admin-user-card.compact .admin-user-note {
  font-size: 11px;
  line-height: 1.2;
}

.admin-user-card.compact .admin-user-title {
  font-size: 15px;
  line-height: 1.05;
}

.admin-user-card.compact .admin-user-actions {
  padding-top: 2px;
}

.admin-user-card.compact .admin-user-badges,
.admin-user-card.compact .admin-user-actions {
  gap: 5px;
}

.promo-item .dialog-preview {
  display: none;
}

.admin-message-text {
  margin-top: 10px;
  color: var(--text);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.admin-message-attachment {
  margin-top: 12px;
  overflow: hidden;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.03);
}

.admin-message-attachment img,
.admin-message-attachment video {
  width: min(100%, 360px);
  display: block;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
}

.admin-message-attachment video.circle {
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  object-fit: cover;
}

.admin-message-attachment audio {
  width: min(100%, 360px);
}

body.theme-light {
  --bg: #eef3fb;
  --bg-soft: #ffffff;
  --panel: rgba(255, 255, 255, 0.92);
  --panel-strong: rgba(255, 255, 255, 0.98);
  --surface: rgba(16, 24, 40, 0.04);
  --surface-strong: rgba(16, 24, 40, 0.07);
  --line: rgba(16, 24, 40, 0.1);
  --text: #101828;
  --muted: #5b6477;
  --shadow-soft: 0 18px 48px rgba(12, 25, 45, 0.1);
  --shadow-strong: 0 28px 80px rgba(12, 25, 45, 0.18);
  background:
    radial-gradient(circle at top left, rgba(74, 180, 255, 0.12), transparent 24%),
    radial-gradient(circle at top right, rgba(111, 214, 255, 0.1), transparent 24%),
    linear-gradient(180deg, #f4f8ff 0%, #edf3fb 50%, #f8fbff 100%);
}

body.theme-light .auth-card,
body.theme-light .profile-card,
body.theme-light .search-card,
body.theme-light .dialogs-card,
body.theme-light .promo-card,
body.theme-light .chat-panel,
body.theme-light .modal-card,
body.theme-light .admin-auth-card,
body.theme-light .admin-card,
body.theme-light .sidebar-brand-row,
body.theme-light .admin-topbar,
body.theme-light .chat-empty-card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 251, 255, 0.98));
}

body.theme-light .btn-secondary,
body.theme-light .btn-ghost,
body.theme-light .icon-btn,
body.theme-light input,
body.theme-light textarea,
body.theme-light select,
body.theme-light .dialog-item,
body.theme-light .summary-chip,
body.theme-light .admin-user-card,
body.theme-light .admin-message-card,
body.theme-light .admin-conversation-card {
  background: rgba(16, 24, 40, 0.03);
}

body.theme-light .chat-header,
body.theme-light .composer-panel,
body.theme-light .channel-action-bar {
  background: rgba(247, 250, 255, 0.96);
}

body.theme-light .message-bubble {
  background: rgba(255, 255, 255, 0.92);
}

body.theme-light .message-bubble.mine {
  background: linear-gradient(135deg, rgba(111, 214, 255, 0.26), rgba(74, 180, 255, 0.16));
}

body.theme-light .message-bubble.has-visual {
  background: rgba(241, 245, 255, 0.96);
}

body.theme-light .composer-preview {
  background: rgba(17, 24, 44, 0.04);
}

body.theme-light .composer-preview-media {
  background: rgba(17, 24, 44, 0.08);
}

body.theme-light .message-attachment,
body.theme-light .admin-message-attachment {
  background: rgba(241, 245, 255, 0.96);
}

body.theme-light select,
body.theme-light select option {
  color: #101828;
}

body.theme-light select option {
  background: #ffffff;
}

@media (max-width: 1180px) {
  .messenger-shell {
    grid-template-columns: 320px minmax(0, 1fr);
  }

  .admin-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .messenger-shell {
    grid-template-columns: 1fr;
    padding: 0;
    height: 100dvh;
    min-height: 100dvh;
  }

  .sidebar-panel,
  .chat-panel,
  .chat-view,
  .chat-empty-state {
    min-height: 0;
  }

  .sidebar-panel {
    height: 100dvh;
    padding: 12px;
    overflow: hidden;
  }

  .chat-panel {
    height: 100dvh;
    min-height: 100dvh;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
  }

  .messenger-page:not(.mobile-chat-open) .chat-panel {
    display: none;
  }

  .messenger-page.mobile-chat-open .sidebar-panel {
    display: none;
  }
}

@media (max-width: 720px) {
  .auth-layout,
  .admin-shell {
    width: 100%;
  }

  .admin-page {
    padding: 10px;
  }

  .chat-header,
  .composer-panel,
  .message-list {
    padding-left: 14px;
    padding-right: 14px;
  }

  .message-reactions {
    max-width: 134px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding-right: 2px;
  }

  .message-reactions::-webkit-scrollbar {
    display: none;
  }

  .reaction-pill {
    flex: 0 0 auto;
    min-width: 30px;
    min-height: 24px;
    padding: 2px 7px;
    gap: 3px;
    font-size: 13px;
  }

  .chat-header {
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
  }

  .chat-header-tools {
    margin-left: auto;
  }

  .chat-search-inline {
    display: none !important;
  }

  .chat-search-mobile {
    order: 3;
    width: 100%;
  }

  .chat-search-mobile input {
    width: 100%;
  }

  .mobile-back-btn {
    display: inline-grid;
    flex: 0 0 42px;
  }

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

  .composer-panel {
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
  }

  .composer-box {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .composer-box.voice-recording-mode {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto auto;
  }

  .composer-box .icon-btn {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    border-radius: 14px;
  }

  .composer-box input[type="text"] {
    flex: 1 1 auto;
    min-width: 0;
    width: auto;
    min-height: 42px;
    height: 42px;
  }

  .voice-recorder {
    min-height: 42px;
    height: 42px;
    padding: 0 12px;
    gap: 10px;
  }

  .voice-recorder-wave {
    gap: 1px;
  }

  .voice-wave-bar {
    min-width: 2px;
    height: calc(8px + var(--voice-bar-scale, 0.14) * 18px);
  }

  .voice-recorder-time {
    min-width: 46px;
    font-size: 12px;
  }

  .voice-recording-active #voiceRecorderToggleBtn,
  .voice-recording-active #voiceRecorderDeleteBtn {
    width: 42px;
    min-width: 42px;
    height: 42px;
    flex: 0 0 42px;
    border-radius: 14px;
    font-size: 16px;
  }

  .voice-player {
    width: 100%;
    gap: 10px;
    padding: 10px 12px;
  }

  .voice-player-btn {
    width: 46px;
    height: 46px;
    flex: 0 0 46px;
    font-size: 18px;
  }

  .voice-player-wave {
    height: 34px;
    gap: 2px;
  }

  .voice-player-bar {
    min-width: 2px;
    height: var(--voice-bar-height, 46%);
  }

  .voice-player-time {
    min-width: 44px;
    font-size: 12px;
  }

  .composer-box .send-btn {
    width: 46px;
    min-width: 46px;
    height: 46px;
    flex: 0 0 46px;
    font-size: 24px;
  }

  .message-bubble {
    min-width: 196px;
    max-width: 86%;
  }

  .mini-menu {
    min-width: 168px;
  }

  .modal {
    padding: 12px;
  }

  .modal-card {
    max-height: calc(100dvh - 24px);
    padding: 22px 18px;
  }

  .btn,
  .btn-compact {
    width: 100%;
  }

  .composer-box .btn,
  .composer-box .btn-compact,
  .composer-box .icon-btn {
    width: auto;
  }

  .sidebar-brand-row,
  .admin-topbar,
  .modal-actions,
  .admin-topbar-actions,
  .admin-user-actions,
  .composer-secondary-row {
    flex-wrap: wrap;
  }

  .sidebar-brand-actions {
    flex-wrap: nowrap;
    justify-content: flex-end;
  }

  .account-strip {
    gap: 8px;
  }

  .admin-summary-grid {
    grid-template-columns: 1fr;
  }

  .profile-actions {
    grid-template-columns: 1fr;
  }

  .profile-actions #saveProfileBtn,
  .profile-actions #openAppSettingsBtn,
  .profile-actions #openSupportBtn,
  .profile-actions #logoutBtn,
  .profile-actions #deleteAccountBtn,
  .profile-actions #openAdminPanelBtn {
    grid-column: auto;
  }
}
