@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap");

:root {
  --bg: #0f1116;
  --sidebar: #141821;
  --panel: #0c0f14;
  --border: #1c212d;
  --accent: #3da6ff;
  --accent-strong: #1f86ff;
  --text: #eef1f5;
  --muted: #9aa2b2;
  --danger: #ff5f87;
  --bubble-self: #13314b;
  --bubble-other: #151a23;
  --scrollbar-thumb: rgba(103, 146, 228, 0.58);
  --scrollbar-thumb-hover: rgba(132, 175, 255, 0.86);
  --scrollbar-track: rgba(11, 18, 30, 0.22);
}

html,
body {
  height: 100%;
}

* { box-sizing: border-box; }

body.telegram {
  margin: 0;
  min-height: 100dvh;
  height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  display: block;
  overflow: hidden;
}

.telegram .chat-list,
.telegram .chat-log,
.telegram .search-results,
.telegram .emoji-picker-grid,
.telegram .sticker-pack-tabs,
.telegram .sticker-picker-grid,
.telegram .sticker-pack-modal__grid,
.telegram .create-chat-member-list,
.telegram .settings-card,
.telegram .admin-list,
.telegram .admin-details,
.telegram .admin-audit-list {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

.telegram .chat-list::-webkit-scrollbar,
.telegram .chat-log::-webkit-scrollbar,
.telegram .search-results::-webkit-scrollbar,
.telegram .emoji-picker-grid::-webkit-scrollbar,
.telegram .sticker-pack-tabs::-webkit-scrollbar,
.telegram .sticker-picker-grid::-webkit-scrollbar,
.telegram .sticker-pack-modal__grid::-webkit-scrollbar,
.telegram .create-chat-member-list::-webkit-scrollbar,
.telegram .settings-card::-webkit-scrollbar,
.telegram .admin-list::-webkit-scrollbar,
.telegram .admin-details::-webkit-scrollbar,
.telegram .admin-audit-list::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.telegram .chat-list::-webkit-scrollbar-track,
.telegram .chat-log::-webkit-scrollbar-track,
.telegram .search-results::-webkit-scrollbar-track,
.telegram .emoji-picker-grid::-webkit-scrollbar-track,
.telegram .sticker-pack-tabs::-webkit-scrollbar-track,
.telegram .sticker-picker-grid::-webkit-scrollbar-track,
.telegram .sticker-pack-modal__grid::-webkit-scrollbar-track,
.telegram .create-chat-member-list::-webkit-scrollbar-track,
.telegram .settings-card::-webkit-scrollbar-track,
.telegram .admin-list::-webkit-scrollbar-track,
.telegram .admin-details::-webkit-scrollbar-track,
.telegram .admin-audit-list::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
  border-radius: 999px;
}

.telegram .chat-list::-webkit-scrollbar-thumb,
.telegram .chat-log::-webkit-scrollbar-thumb,
.telegram .search-results::-webkit-scrollbar-thumb,
.telegram .emoji-picker-grid::-webkit-scrollbar-thumb,
.telegram .sticker-pack-tabs::-webkit-scrollbar-thumb,
.telegram .sticker-picker-grid::-webkit-scrollbar-thumb,
.telegram .sticker-pack-modal__grid::-webkit-scrollbar-thumb,
.telegram .create-chat-member-list::-webkit-scrollbar-thumb,
.telegram .settings-card::-webkit-scrollbar-thumb,
.telegram .admin-list::-webkit-scrollbar-thumb,
.telegram .admin-details::-webkit-scrollbar-thumb,
.telegram .admin-audit-list::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 999px;
  border: 2px solid rgba(15, 23, 36, 0.95);
}

.telegram .chat-list::-webkit-scrollbar-thumb:hover,
.telegram .chat-log::-webkit-scrollbar-thumb:hover,
.telegram .search-results::-webkit-scrollbar-thumb:hover,
.telegram .emoji-picker-grid::-webkit-scrollbar-thumb:hover,
.telegram .sticker-pack-tabs::-webkit-scrollbar-thumb:hover,
.telegram .sticker-picker-grid::-webkit-scrollbar-thumb:hover,
.telegram .sticker-pack-modal__grid::-webkit-scrollbar-thumb:hover,
.telegram .create-chat-member-list::-webkit-scrollbar-thumb:hover,
.telegram .settings-card::-webkit-scrollbar-thumb:hover,
.telegram .admin-list::-webkit-scrollbar-thumb:hover,
.telegram .admin-details::-webkit-scrollbar-thumb:hover,
.telegram .admin-audit-list::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
}

.tg-root {
  width: 100%;
  min-height: 100dvh;
  height: 100dvh;
  display: grid;
  grid-template-columns: clamp(320px, 24vw, 420px) minmax(0, 1fr);
  background: var(--bg);
  overflow: hidden;
}

/* Sidebar */
.tg-sidebar {
  background: var(--sidebar);
  padding: 0.8rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  min-height: 0;
  height: 100dvh;
  overflow: hidden;
}
.sidebar-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.75rem; }
.header-stack { display: flex; flex-direction: column; gap: 0.6rem; }
.title-row { display: flex; align-items: center; gap: 0.5rem; }
.app-title-large { font-size: 1.1rem; font-weight: 700; letter-spacing: 0.08em; }
.menu-wrapper { display: flex; gap: 0.35rem; align-items: center; position: relative; }
.icon-button {
  width: 36px; height: 36px;
  border-radius: 0.65rem;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  display: grid; place-items: center;
  cursor: pointer;
}
.profile-chip { display: flex; align-items: center; gap: 0.6rem; }
.avatar { width: 44px; height: 44px; border-radius: 50%; background: linear-gradient(135deg,#252b3a,#191d29); display: grid; place-items: center; font-weight: 700; }
.profile-text { display: flex; flex-direction: column; gap: 0.1rem; }
.profile-name { font-weight: 700; }
.profile-status { color: #4ade80; font-size: 0.85rem; }
.ghost { border: 1px solid var(--border); background: transparent; color: var(--text); border-radius: 0.7rem; padding: 0.45rem 0.8rem; cursor: pointer; }
.ghost.mini { padding: 0.35rem 0.7rem; }

.download-actions {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-top: 1rem;
}

.download-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  text-decoration: none;
}

.mobile-card .secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  border-radius: 0.95rem;
  border: 1px solid rgba(83, 136, 219, 0.38);
  background: rgba(18, 28, 45, 0.92);
  color: #d7e7ff;
  text-decoration: none;
  font-weight: 600;
  padding: 0.85rem 1rem;
}

.mobile-card .secondary:hover {
  border-color: rgba(96, 152, 238, 0.58);
  background: rgba(24, 37, 59, 0.96);
}

.wide-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.auth-feature-list.compact {
  margin-top: 1rem;
}

.app-menu {
  position: absolute;
  top: calc(100% + 0.35rem);
  left: 0;
  right: auto;
  background: #0e121c;
  border: 1px solid var(--border);
  border-radius: 0.9rem;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  min-width: 190px;
  max-width: min(260px, calc(100vw - 1rem));
  z-index: 20;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.45);
}
.app-menu[hidden] { display: none; }
.app-menu .menu-item {
  border: none;
  background: transparent;
  color: var(--text);
  padding: 0.65rem 0.75rem;
  text-align: left;
  border-radius: 0.7rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 600;
  white-space: nowrap;
}
.app-menu .menu-item .menu-icon { opacity: 0.8; }
.app-menu .menu-item:hover { background: rgba(255,255,255,0.06); }
.app-menu .menu-item.danger { color: var(--danger); }

.sidebar-tabs { display: flex; gap: 0.4rem; }
.sidebar-tabs .tab {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 0.9rem;
  background: rgba(255,255,255,0.04);
  color: var(--text);
  padding: 0.55rem 0.8rem;
  cursor: default;
}
.sidebar-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
}
.sidebar-actions .wide {
  grid-column: 1 / -1;
}
.sidebar-actions .ghost.mini {
  width: 100%;
  border-radius: 0.8rem;
  font-size: 0.82rem;
  padding: 0.5rem 0.55rem;
  border: 1px solid rgba(77, 115, 176, 0.4);
  background: linear-gradient(180deg, rgba(23, 35, 56, 0.9), rgba(13, 22, 38, 0.88));
  color: #d9e8ff;
}
.sidebar-actions .ghost.mini:hover {
  border-color: rgba(98, 149, 229, 0.62);
  background: linear-gradient(180deg, rgba(29, 44, 71, 0.94), rgba(16, 27, 45, 0.9));
}

.sidebar-search {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.sidebar-search form { display: flex; gap: 0.45rem; }
.sidebar-search input {
  flex: 1; padding: 0.65rem 0.85rem;
  border-radius: 0.85rem; border: 1px solid var(--border);
  background: #101622; color: var(--text);
}
.sidebar-search button {
  border: 1px solid var(--border);
  border-radius: 0.85rem;
  background: rgba(255,255,255,0.05);
  color: var(--text);
  padding: 0.65rem 0.9rem;
  cursor: pointer;
}
.search-results {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  max-height: 220px;
  overflow-y: auto;
  padding-right: 0.2rem;
}
.search-results .chat-item {
  width: 100%;
}
.search-item .chat-item__avatar {
  width: 38px;
  height: 38px;
}

.token-card {
  border: 1px solid var(--border);
  border-radius: 0.9rem;
  padding: 0.75rem;
  background: #111622;
  font-size: 0.9rem;
  color: var(--muted);
}
.token-box {
  margin-top: 0.45rem;
  background: #0d111a;
  border: 1px solid var(--border);
  border-radius: 0.65rem;
  padding: 0.65rem;
  word-break: break-all;
  color: var(--text);
}

.chat-list-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.04);
  border-radius: 1rem;
  background: rgba(255,255,255,0.015);
  padding: 0.4rem;
}
.chat-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 0.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  overscroll-behavior: contain;
}
.chat-list::-webkit-scrollbar { width: 10px; }
.chat-list::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 999px;
  border: 2px solid rgba(15, 23, 36, 0.95);
}

.chat-item {
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  border-radius: 0.85rem;
  padding: 0.6rem 0.7rem;
  display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; gap: 0.6rem; align-items: center;
  cursor: pointer;
}
.chat-item:hover { background: rgba(255,255,255,0.04); }
.chat-item--active { background: linear-gradient(135deg, rgba(61,166,255,0.2), rgba(28,130,255,0.2)); border-color: rgba(61,166,255,0.4); }
.chat-item__avatar { width: 48px; height: 48px; border-radius: 50%; background: linear-gradient(135deg,#252b3a,#191d29); display: grid; place-items: center; font-weight: 700; position: relative; }
.chat-item__channel-badge { position: absolute; bottom: -2px; right: -2px; width: 18px; height: 18px; background: var(--accent); border-radius: 50%; display: grid; place-items: center; font-size: 0.65rem; }
.chat-item__body { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.chat-item__name-row { display: flex; align-items: center; gap: 0.4rem; min-width: 0; }
.chat-item__name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.verified-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  border: 1px solid rgba(61, 166, 255, 0.45);
  background: rgba(61, 166, 255, 0.12);
  color: #d8ecff;
  font-size: 0.72rem;
  line-height: 1;
  white-space: nowrap;
}
.verified-badge[hidden] {
  display: none !important;
}
.verified-badge[data-badge-kind="bot"] {
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.92);
}
.verified-badge::before {
  content: "✓";
  display: inline-grid;
  place-items: center;
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  background: rgba(61, 166, 255, 0.95);
  color: #06101f;
  font-weight: 800;
  font-size: 0.72rem;
}
.verified-badge[data-badge-kind="bot"]::before {
  content: none;
}
.verified-badge--small {
  padding: 0.08rem 0.35rem;
  font-size: 0.66rem;
}
.verified-badge--small::before {
  width: 0.9rem;
  height: 0.9rem;
  font-size: 0.68rem;
}
.chat-item__preview { color: var(--muted); font-size: 0.9rem; display: block; min-width: 0; width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item__meta {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.role-badge {
  border: 1px solid rgba(86, 138, 226, 0.6);
  color: #cde2ff;
  font-size: 0.68rem;
  border-radius: 999px;
  padding: 0.05rem 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.role-badge.role-owner {
  border-color: rgba(255, 190, 94, 0.65);
  color: #ffd79f;
}
.role-badge.role-admin {
  border-color: rgba(122, 181, 255, 0.65);
  color: #cfe8ff;
}
.role-badge.role-muted {
  border-color: rgba(255, 126, 153, 0.5);
  color: #ffb3c5;
}
.chat-item__time { color: var(--muted); font-size: 0.82rem; }
.badge { background: var(--accent); color: #06101f; border-radius: 999px; padding: 0.1rem 0.5rem; font-size: 0.75rem; }

/* Dialog */
.tg-dialog {
  background: var(--panel);
  display: flex;
  flex-direction: column;
  height: 100dvh;
  min-height: 100dvh;
  min-width: 0;
  padding: 0.6rem 0.8rem 0.8rem;
  gap: 0.6rem;
  position: relative;
  overflow: hidden;
}

.dialog-wallpaper {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.03;
  background-image:
    repeating-linear-gradient(
      45deg,
      transparent,
      transparent 35px,
      rgba(255, 255, 255, 0.02) 35px,
      rgba(255, 255, 255, 0.02) 70px
    );
  background-size: 100px 100px;
}
.dialog-header {
  display: flex;
  position: relative;
  z-index: 12;
  flex: 0 0 auto;
  align-items: center;
  gap: 0.85rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: 0.8rem;
  background: rgba(255,255,255,0.03);
}
.dialog-avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: linear-gradient(135deg,#252b3a,#191d29);
  display: grid;
  place-items: center;
  font-weight: 700;
  flex: 0 0 auto;
  background-size: cover;
  background-position: center;
}
.sidebar-toggle {
  display: none;
  flex: 0 0 auto;
}
.sidebar-overlay {
  display: none;
}
.dialog-title {
  flex: 1 1 auto;
  min-width: 0;
}
.dialog-title-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}
.dialog-actions {
  position: relative;
  display: flex;
  align-items: center;
  margin-left: auto;
  z-index: 1;
}
#room-actions-menu {
  right: 0;
  left: auto;
  z-index: 120;
}
.dialog-header.hidden { display: none; }
.dialog-header h2 { margin: 0; font-size: 1.05rem; }
.dialog-header p { margin: 0; font-size: 0.9rem; color: #4ade80; }
.call-overlay {
  position: fixed;
  inset: 0;
  z-index: 260;
  display: grid;
  place-items: center;
  padding: 1rem;
}
.call-overlay[hidden] {
  display: none;
}
.call-overlay__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 8, 16, 0.78);
  backdrop-filter: blur(8px);
}
.call-overlay__card {
  position: relative;
  z-index: 1;
  width: min(100%, 720px);
  padding: 1rem;
  border: 1px solid rgba(88, 128, 208, 0.5);
  border-radius: 1rem;
  background: linear-gradient(180deg, rgba(16, 25, 40, 0.96), rgba(10, 16, 28, 0.96));
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}
.call-overlay__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}
.call-overlay__title {
  margin: 0;
  font-size: 1.25rem;
}
.call-overlay__subtitle,
.call-overlay__status {
  margin: 0.2rem 0 0;
}
.call-overlay__media {
  position: relative;
  margin-top: 1rem;
  min-height: min(54vh, 420px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 1rem;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(14, 21, 34, 0.92), rgba(8, 13, 22, 0.95));
}
.call-overlay__remote,
.call-overlay__local {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: rgba(0, 0, 0, 0.28);
}
.call-overlay__placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 1rem;
  font-size: 1.05rem;
}
.call-overlay__local {
  position: absolute;
  right: 1rem;
  bottom: 1rem;
  width: min(28vw, 190px);
  height: min(20vw, 134px);
  border-radius: 0.85rem;
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
.call-overlay__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
}
.call-action-end {
  border-color: rgba(244, 63, 94, 0.45);
  color: #ffd3db;
}
.call-action-end:hover {
  border-color: rgba(244, 63, 94, 0.65);
  background: rgba(244, 63, 94, 0.12);
}
.pinned-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
  padding: 0.65rem 0.85rem;
  border: 1px solid rgba(90, 132, 208, 0.46);
  border-radius: 0.8rem;
  background: linear-gradient(180deg, rgba(18, 29, 48, 0.92), rgba(12, 20, 35, 0.88));
  position: relative;
  z-index: 1;
  flex: 0 0 auto;
}
.pinned-banner[hidden] { display: none; }
.pinned-banner__body { min-width: 0; }
.pinned-banner__title {
  margin: 0;
  font-size: 0.75rem;
  color: #89b5ff;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.pinned-banner__text {
  margin: 0.2rem 0 0;
  color: #d6e6ff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: min(56vw, 660px);
}
.pinned-banner__actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}
.chat-log {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 1rem 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  background: rgba(255, 255, 255, 0.015);
  border: 1px solid var(--border);
  border-radius: 0.9rem;
  position: relative;
  z-index: 1;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}
.chat-log--empty {
  justify-content: center;
  align-items: center;
  text-align: center;
  color: var(--muted);
  font-size: 1.1rem;
}
.chat-log::-webkit-scrollbar { width: 10px; }
.chat-log::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 999px;
  border: 2px solid rgba(15, 23, 36, 0.95);
}
.scroll-bottom-btn {
  position: absolute;
  right: 1.35rem;
  bottom: 6.1rem;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 999px;
  border: 1px solid rgba(90, 140, 230, 0.6);
  background: linear-gradient(180deg, rgba(18, 33, 58, 0.96), rgba(12, 22, 40, 0.92));
  color: #d8e8ff;
  font-size: 1.2rem;
  display: grid;
  place-items: center;
  cursor: pointer;
  z-index: 15;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.35);
  transition: transform 0.16s ease, opacity 0.16s ease;
}
.scroll-bottom-btn:hover {
  transform: translateY(-1px);
}
.scroll-bottom-btn[hidden] {
  display: none;
}

/* Telegram-style message bubbles */
.message {
  max-width: min(58%, 520px);
  width: fit-content;
  padding: 0.6rem 0.85rem 0.7rem 0.85rem;
  border-radius: 1.1rem;
  background: linear-gradient(135deg, rgba(42, 46, 57, 0.95), rgba(38, 42, 51, 0.92));
  backdrop-filter: blur(8px);
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.2),
    0 2px 8px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
  position: relative;
  color: var(--text);
  margin-right: auto;
  margin-bottom: 0.35rem;
  align-self: flex-start;
  border: 1px solid rgba(255, 255, 255, 0.03);
  transition: all 0.15s ease;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.message:hover {
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.25),
    0 4px 12px rgba(0, 0, 0, 0.2);
  transform: translateY(-1px);
}

/* Tail (хвостик) - убран */
.message::before {
  content: none !important;
  display: none;
}

.message--self::before {
  content: none !important;
  display: none;
}

.message--flash {
  box-shadow:
    0 0 0 2px rgba(120, 174, 255, 0.9),
    0 0 28px rgba(59, 130, 246, 0.4),
    0 4px 16px rgba(0, 0, 0, 0.3);
  animation: flash-pulse 1.5s ease-in-out;
}

@keyframes flash-pulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(120, 174, 255, 0.9), 0 0 28px rgba(59, 130, 246, 0.4); }
  50% { box-shadow: 0 0 0 3px rgba(120, 174, 255, 1), 0 0 36px rgba(59, 130, 246, 0.6); }
}

.message--self {
  margin-left: auto;
  margin-right: 0;
  align-self: flex-end;
  align-items: flex-end;
  padding-right: 1.8rem;
  background: linear-gradient(135deg, rgba(40, 120, 220, 0.85), rgba(30, 100, 200, 0.8));
  border: 1px solid rgba(80, 150, 255, 0.25);
}

.message--self:hover {
  background: linear-gradient(135deg, rgba(45, 125, 225, 0.9), rgba(35, 105, 205, 0.85));
}

/* Группировка сообщений от одного пользователя */
.message.message--grouped {
  margin-top: 0.15rem;
  margin-bottom: 0.15rem;
}

.message.message--grouped-first {
  border-bottom-left-radius: 0.5rem;
  border-bottom-right-radius: 0.5rem;
  margin-bottom: 0.15rem;
}

.message--self.message--grouped-first {
  border-bottom-left-radius: 0.5rem;
  border-bottom-right-radius: 0.5rem;
}

.message.message--grouped-middle {
  border-radius: 0.5rem;
  margin-top: 0.15rem;
  margin-bottom: 0.15rem;
}

.message.message--grouped-last {
  border-top-left-radius: 0.5rem;
  border-top-right-radius: 0.5rem;
  margin-top: 0.15rem;
}

.message--self.message--grouped-last {
  border-top-left-radius: 0.5rem;
  border-top-right-radius: 0.5rem;
}

/* Метаинформация сообщения */
.message__meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: rgba(255, 255, 255, 0.55);
  font-size: 0.75rem;
  font-weight: 500;
  width: 100%;
  padding-bottom: 0.3rem;
  margin-bottom: 0.1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.message__meta span:first-child {
  font-weight: 600;
  color: rgba(100, 180, 255, 0.95);
  flex-shrink: 0;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.message--self .message__meta span:first-child {
  color: rgba(255, 255, 255, 0.95);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

.message__meta span:last-child {
  margin-left: auto;
  font-size: 0.7rem;
  opacity: 0.65;
  font-weight: 400;
  padding-left: 0.45rem;
  border-left: 1px solid rgba(255, 255, 255, 0.28);
}

.message--self .message__meta span:last-child {
  border-left-color: rgba(255, 255, 255, 0.36);
}

/* Текст сообщения */
.message__body {
  font-size: 0.95rem;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.95);
  word-break: break-word;
  white-space: pre-wrap;
  width: 100%;
  padding-bottom: 0.15rem;
}

/* Для своих сообщений - добавляем отступ справа для статуса */
.message--self .message__body {
  padding-right: 3.5rem;
  padding-bottom: 0.2rem;
}

/* Ссылки в сообщениях */
.message-link {
  color: #6bb6ff;
  text-decoration: none;
  border-bottom: 1px solid rgba(107, 182, 255, 0.3);
  transition: all 0.2s ease;
  word-break: break-all;
}

.message-link:hover {
  color: #89c9ff;
  border-bottom-color: rgba(137, 201, 255, 0.6);
  background: rgba(107, 182, 255, 0.1);
  padding: 0 2px;
  margin: 0 -2px;
  border-radius: 3px;
}

.message--self .message-link {
  color: #e0f2ff;
  border-bottom-color: rgba(224, 242, 255, 0.4);
}

.message--self .message-link:hover {
  color: #ffffff;
  border-bottom-color: rgba(255, 255, 255, 0.6);
  background: rgba(255, 255, 255, 0.15);
}

/* Медиа контент */
.message__media {
  background: rgba(10, 13, 18, 0.6);
  border-radius: 0.75rem;
  padding: 0.3rem;
  margin-top: 0.25rem;
  overflow: hidden;
}

.message__media img,
.message__media video,
.message__media audio {
  width: 100%;
  max-width: 520px;
  border-radius: 0.65rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: #0c0f16;
  display: block;
}

.message__sticker {
  margin-top: 0.25rem;
}

.message__sticker img {
  display: block;
  width: min(220px, 100%);
  max-width: 220px;
  border-radius: 1rem;
  background: transparent;
}

.message__sticker-placeholder {
  width: min(220px, 100%);
  max-width: 220px;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 1rem;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.78);
  font-size: 2rem;
}

.message--sticker-only {
  background: transparent;
  border: 0;
  box-shadow: none;
  backdrop-filter: none;
  padding: 0.15rem 0.2rem 0.35rem;
}

.message--sticker-only:hover {
  background: transparent;
  box-shadow: none;
  transform: none;
}

.message--sticker-only .message__meta {
  width: auto;
  border-bottom: 0;
  padding-bottom: 0;
  margin-bottom: 0;
  gap: 0.35rem;
}

.message--sticker-only .message__meta span:last-child {
  border-left: 0;
  padding-left: 0;
}

.message--sticker-only .message__sticker {
  margin-top: 0;
}

/* Статус сообщения (галочки) */
.message__status {
  position: absolute;
  bottom: 6px;
  right: 10px;
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.7);
  display: flex;
  align-items: center;
  gap: 2px;
  font-weight: 500;
  background: rgba(0, 0, 0, 0.15);
  padding: 2px 5px;
  border-radius: 4px;
  backdrop-filter: blur(4px);
}

.message--self .message__status {
  color: rgba(255, 255, 255, 0.95);
  background: rgba(0, 0, 0, 0.2);
}

/* Пометка "edited" */
.message__edited {
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.45);
  font-style: italic;
  margin-left: 0.4rem;
}

/* View count for channel messages */
.message__views {
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.45);
  margin-left: 0.4rem;
}

/* Inline редактор сообщений */
.message-edit-textarea {
  width: 100%;
  min-height: 60px;
  padding: 0.5rem;
  background: rgba(20, 25, 35, 0.8);
  border: 1px solid rgba(107, 182, 255, 0.4);
  border-radius: 0.5rem;
  color: rgba(255, 255, 255, 0.95);
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.45;
  resize: vertical;
  margin-top: 0.25rem;
}

.message-edit-textarea:focus {
  outline: none;
  border-color: rgba(107, 182, 255, 0.7);
  box-shadow: 0 0 0 2px rgba(107, 182, 255, 0.15);
}

.message-edit-controls {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
  justify-content: flex-end;
}

.message[data-editing="true"] {
  border-color: rgba(107, 182, 255, 0.5);
  box-shadow: 0 0 0 2px rgba(107, 182, 255, 0.15);
}

/* Reply Preview (над полем ввода) */
.reply-preview {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: rgba(30, 35, 50, 0.8);
  border-left: 3px solid #6bb6ff;
  border-radius: 0.5rem;
  margin: 0 0.5rem 0.5rem;
}

.reply-preview__content {
  flex: 1;
  min-width: 0;
}

.reply-preview__sender {
  font-size: 0.8rem;
  font-weight: 600;
  color: #6bb6ff;
  margin-bottom: 0.15rem;
}

.reply-preview__text {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.7);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reply-preview__close {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.5);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.reply-preview__close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.9);
}

/* Reply Quote (в сообщении) */
.message__reply-quote {
  align-self: flex-start;
  padding: 0.4rem 0.6rem;
  background: rgba(0, 0, 0, 0.2);
  border-left: 3px solid rgba(107, 182, 255, 0.6);
  border-radius: 0.4rem;
  margin-bottom: 0.4rem;
  margin-right: auto;
  max-width: 100%;
  cursor: pointer;
  transition: all 0.2s ease;
}

.message__reply-quote:hover {
  background: rgba(0, 0, 0, 0.3);
  border-left-color: rgba(107, 182, 255, 0.9);
}

.message__reply-sender {
  font-size: 0.75rem;
  font-weight: 600;
  color: rgba(107, 182, 255, 0.9);
  margin-bottom: 0.15rem;
}

.message__reply-text {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.6);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Media player */
.player-shell {
  background: #0e141f;
  border: 1px solid var(--border);
  border-radius: 0.9rem;
  padding: 0.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  width: 100%;
  position: relative;
}
.player-frame {
  overflow: hidden;
  border-radius: 0.8rem;
  background: #0b0f17;
}
.player-controls {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.45rem 0.6rem;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 0.7rem;
  backdrop-filter: blur(4px);
}
.player-controls.overlay {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
}
.player-play {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #06101f;
  font-weight: 700;
  cursor: pointer;
}
.player-progress {
  flex: 1;
  accent-color: var(--accent);
}
.player-time {
  font-size: 0.82rem;
  color: #dbe6ff;
}

/* Composer */
.message-form {
  padding: 0.75rem 0.5rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  background: #0b0d12;
  position: relative;
  z-index: 1;
  flex: 0 0 auto;
}
.message-form.hidden { display: none; }
.composer-bar { display: flex; align-items: center; gap: 0.4rem; color: var(--muted); }
.ghost.icon { width: 38px; height: 38px; border-radius: 0.8rem; border: 1px solid var(--border); background: rgba(255,255,255,0.05); color: var(--text); }
.recording-pill { color: var(--danger); font-size: 0.9rem; }
.preview-pill { font-size: 0.85rem; color: var(--muted); }
.sticker-bot-tools {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 0.8rem 0.9rem;
  border: 1px solid rgba(83, 135, 228, 0.28);
  border-radius: 0.95rem;
  background: rgba(23, 39, 70, 0.5);
}
.sticker-bot-tools__hint {
  color: #b8cff5;
  font-size: 0.86rem;
}
.sticker-bot-tools__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}
.sticker-bot-tools__actions .ghost.mini {
  border-color: rgba(83, 135, 228, 0.35);
  background: rgba(255,255,255,0.04);
}
#sticker-picker-panel {
  align-items: flex-end;
  justify-content: flex-start;
  padding: 0 0 108px 14px;
  z-index: 45;
}
.composer-picker-overlay {
  position: absolute;
  inset: 0;
  background: transparent;
}
.composer-picker-card {
  position: relative;
  width: min(420px, calc(100vw - 28px));
  height: min(56vh, 460px);
  max-height: min(56vh, 460px);
  background: #0f131c;
  border: 1px solid rgba(84, 118, 189, 0.32);
  border-radius: 1.05rem;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  pointer-events: auto;
  overflow: hidden;
}
.composer-picker-modes {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem;
  background: rgba(255,255,255,0.04);
  border-radius: 999px;
  align-self: flex-start;
}
.composer-picker-mode {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0.42rem 0.85rem;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
}
.composer-picker-mode.active {
  background: rgba(83, 135, 228, 0.18);
  color: var(--text);
}
.emoji-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(42px, 1fr));
  gap: 0.45rem;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
  align-content: start;
}
.emoji-picker-grid[hidden] {
  display: none !important;
}
.emoji-picker-tile {
  border: 0;
  border-radius: 0.85rem;
  background: rgba(255,255,255,0.04);
  color: var(--text);
  min-height: 42px;
  font-size: 1.35rem;
  cursor: pointer;
}
.emoji-picker-tile:hover {
  background: rgba(255,255,255,0.08);
}
.composer-sticker-pane[hidden] {
  display: none !important;
}
.composer-sticker-pane {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  overflow: hidden;
  flex: 1 1 auto;
  height: 100%;
}
.sticker-pack-tabs {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.55rem;
  border: 1px solid rgba(84, 118, 189, 0.24);
  border-radius: 1rem;
  background: rgba(255,255,255,0.03);
  scrollbar-width: thin;
  scrollbar-color: rgba(100, 141, 224, 0.6) transparent;
}
.sticker-pack-tab {
  width: 48px;
  height: 48px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.05);
  color: var(--text);
  border-radius: 1rem;
  padding: 3px;
  cursor: pointer;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  overflow: hidden;
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}
.sticker-pack-tab.active {
  border-color: rgba(83, 135, 228, 0.5);
  background: rgba(83, 135, 228, 0.16);
  transform: translateY(-1px);
}
.sticker-pack-tab:hover {
  background: rgba(255,255,255,0.09);
}
.sticker-pack-tab.is-recent {
  background: rgba(91, 122, 190, 0.08);
}
.sticker-pack-tab__icon {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border-radius: 0.8rem;
  background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.015));
}
.sticker-pack-tab__icon svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: #d7e8ff;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sticker-pack-tab img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 0.8rem;
  display: block;
}
.sticker-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 0.55rem;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  flex: 1 1 auto;
  max-height: none;
  padding: 0.6rem;
  border: 1px solid rgba(84, 118, 189, 0.24);
  border-radius: 1rem;
  background: rgba(255,255,255,0.02);
  align-content: start;
  scrollbar-width: thin;
  scrollbar-color: rgba(100, 141, 224, 0.65) transparent;
}
.sticker-picker-tile {
  border: 0;
  background: transparent;
  border-radius: 1rem;
  padding: 0.45rem;
  cursor: pointer;
  min-height: 80px;
  transition: transform 0.16s ease;
}
.sticker-picker-tile:hover {
  transform: translateY(-1px);
}
.sticker-picker-tile img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
}
.sticker-pack-tabs::-webkit-scrollbar,
.sticker-picker-grid::-webkit-scrollbar,
.emoji-picker-grid::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
.sticker-pack-tabs::-webkit-scrollbar-track,
.sticker-picker-grid::-webkit-scrollbar-track,
.emoji-picker-grid::-webkit-scrollbar-track {
  background: transparent;
}
.sticker-pack-tabs::-webkit-scrollbar-thumb,
.sticker-picker-grid::-webkit-scrollbar-thumb,
.emoji-picker-grid::-webkit-scrollbar-thumb {
  background: rgba(100, 141, 224, 0.55);
  border-radius: 999px;
  border: 2px solid rgba(15, 19, 28, 0.95);
}
.sticker-pack-tabs::-webkit-scrollbar-thumb:hover,
.sticker-picker-grid::-webkit-scrollbar-thumb:hover,
.emoji-picker-grid::-webkit-scrollbar-thumb:hover {
  background: rgba(126, 166, 246, 0.8);
}
.settings-pack-group {
  margin-top: 14px;
}
.settings-pack-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-weight: 700;
}
.settings-pack-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.settings-pack-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.06);
  background: rgba(8, 14, 25, 0.44);
  cursor: pointer;
  transition: border-color 140ms ease, transform 140ms ease, background 140ms ease;
}
.settings-pack-card:hover,
.settings-pack-card:focus-visible {
  border-color: rgba(108, 154, 234, 0.58);
  background: rgba(12, 20, 35, 0.72);
  transform: translateY(-1px);
}
.settings-pack-card.is-preview {
  cursor: default;
}
.settings-pack-card.is-preview:hover,
.settings-pack-card.is-preview:focus-visible {
  background: rgba(8, 14, 25, 0.44);
  transform: none;
}
.settings-pack-cover {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: rgba(61, 166, 255, 0.14);
  font-weight: 800;
  flex-shrink: 0;
}
.settings-pack-meta {
  min-width: 0;
  flex: 1;
}
.settings-pack-name {
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.settings-pack-sub {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.9rem;
}
.settings-pack-description {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.85rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.settings-pack-stickers {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 8px;
  max-height: min(42vh, 360px);
  overflow-y: auto;
  padding-right: 4px;
  align-content: start;
}
.settings-pack-preview-actions {
  margin-top: 10px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.settings-pack-sticker {
  border-radius: 12px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  padding: 8px;
}
.settings-pack-sticker img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
}
.sticker-pack-modal {
  position: fixed;
  inset: 0;
  background: rgba(5, 10, 18, 0.72);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 9999;
}
.sticker-pack-modal__card {
  width: min(560px, 100%);
  max-height: min(82vh, 760px);
  overflow: hidden;
  border-radius: 24px;
  border: 1px solid rgba(89, 115, 170, 0.24);
  background: #0f1724;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.42);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: relative;
}
.sticker-pack-modal__close {
  position: absolute;
  top: 14px;
  right: 14px;
  border: 0;
  background: rgba(255,255,255,0.06);
  color: #fff;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}
.sticker-pack-modal__title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-right: 40px;
}
.sticker-pack-modal__title {
  font-size: 1.55rem;
  font-weight: 800;
}
.sticker-pack-modal__subtitle,
.sticker-pack-modal__description {
  color: var(--muted);
}
.sticker-pack-modal__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 10px;
  overflow-y: auto;
  padding-right: 4px;
  min-height: 0;
  flex: 1 1 auto;
  align-content: start;
}
.sticker-pack-modal__tile {
  border: 0;
  padding: 8px;
  background: rgba(255,255,255,0.03);
  border-radius: 16px;
  min-height: 84px;
}
.sticker-pack-modal__tile img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
}
.sticker-pack-modal__action {
  align-self: stretch;
  justify-content: center;
}

.input-row {
  display: grid;
  grid-template-columns: 1fr auto;
  background: #0f131c;
  border: 1px solid var(--border);
  border-radius: 0.9rem;
  align-items: center;
}
.input-row input {
  border: none;
  background: transparent;
  color: var(--text);
  padding: 0.9rem 1rem;
  font-size: 0.95rem;
}
.input-row input:focus { outline: none; }
.input-row button {
  border: none;
  background: transparent;
  color: var(--accent);
  padding: 0 1rem;
  font-size: 1.2rem;
  cursor: pointer;
}
.input-row button:disabled { opacity: 0.5; }

/* Toasts */
.toast-root { position: absolute; top: 1rem; right: 1rem; display: flex; flex-direction: column; gap: 0.4rem; }
.toast { background: #0f131a; border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 0.8rem; padding: 0.6rem 0.8rem; color: var(--text); opacity: 0; transform: translateX(120%); transition: all 0.2s ease; }
.toast.visible { opacity: 1; transform: translateX(0); }

.msg-menu {
  position: fixed;
  background: #111622;
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  padding: 0.25rem;
  box-shadow: 0 12px 30px rgba(0,0,0,0.35);
  z-index: 50;
}
.msg-menu button {
  border: none;
  background: transparent;
  color: var(--text);
  padding: 0.55rem 0.75rem;
  border-radius: 0.5rem;
  cursor: pointer;
  white-space: nowrap;
}
.msg-menu button:hover { background: rgba(255,255,255,0.06); }

.create-chat-panel {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.create-chat-panel[hidden] { display: none; }
.create-chat-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
}
.create-chat-card {
  position: relative;
  width: min(430px, 96vw);
  background: #0f131c;
  border: 1px solid var(--border);
  border-radius: 1.1rem;
  box-shadow: 0 25px 60px rgba(0,0,0,0.55);
  padding: 1rem 1rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: min(92dvh, 760px);
  overflow: hidden;
  pointer-events: auto;
}
.create-chat-card.is-members-step {
  min-height: min(78dvh, 680px);
}
.create-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.create-chat-header h3 { margin: 0; }
.create-chat-content {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  min-height: 0;
}
.create-chat-step {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}
.create-chat-step[hidden] {
  display: none;
}
.create-chat-hero {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 0.8rem;
  align-items: start;
}
.create-chat-avatar {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  border: 1px solid rgba(115, 164, 255, 0.35);
  background: linear-gradient(135deg, #4ca5ff, #2a6ec8);
  color: #eaf4ff;
  font-size: 1.8rem;
  display: grid;
  place-items: center;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.22);
}
.create-chat-avatar span {
  line-height: 1;
  transform: translateY(1px);
}
.create-chat-channel-fields {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.create-chat-line-field {
  display: flex;
  flex-direction: column;
  gap: 0.32rem;
  min-width: 0;
}
.create-chat-line-field span {
  color: #8fb8ea;
  font-size: 0.96rem;
  font-weight: 500;
}
.create-chat-line-field input,
.create-chat-line-field textarea {
  border: 0;
  border-bottom: 2px solid rgba(112, 161, 242, 0.58);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  padding: 0.35rem 0.05rem 0.5rem;
  font: inherit;
  resize: none;
}
.create-chat-line-field input:focus,
.create-chat-line-field textarea:focus {
  outline: none;
  border-color: rgba(76, 184, 255, 0.95);
}
.create-chat-members-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
}
.create-chat-members-head h4 {
  margin: 0;
  font-size: 1.2rem;
}
.create-chat-members-head span {
  color: #88a9d2;
  font-size: 0.95rem;
}
.create-chat-search-field {
  display: block;
}
.create-chat-search-field input {
  width: 100%;
  border: 1px solid rgba(88, 125, 189, 0.45);
  border-radius: 0.75rem;
  background: rgba(9, 14, 25, 0.72);
  color: var(--text);
  padding: 0.64rem 0.72rem;
  font: inherit;
}
.create-chat-search-field input:focus {
  outline: none;
  border-color: rgba(61,166,255,0.8);
  box-shadow: 0 0 0 3px rgba(61,166,255,0.12);
}
.create-chat-member-list {
  flex: 1 1 auto;
  min-height: 240px;
  max-height: min(58dvh, 500px);
  overflow-y: auto;
  border: 1px solid rgba(67, 90, 133, 0.45);
  border-radius: 0.85rem;
  background: rgba(6, 11, 21, 0.45);
  padding: 0.35rem;
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}
.create-chat-member-list::-webkit-scrollbar {
  width: 10px;
}
.create-chat-member-list::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
  border-radius: 999px;
}
.create-chat-member-list::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 999px;
  border: 2px solid rgba(15, 23, 36, 0.95);
}
.create-chat-member-item {
  width: 100%;
  border: 0;
  border-radius: 0.75rem;
  background: transparent;
  color: var(--text);
  text-align: left;
  display: grid;
  grid-template-columns: 42px 1fr auto;
  align-items: center;
  gap: 0.65rem;
  padding: 0.5rem;
  cursor: pointer;
  transition: background 140ms ease, transform 140ms ease;
}
.create-chat-member-item:hover {
  background: rgba(66, 106, 181, 0.25);
}
.create-chat-member-item.is-selected {
  background: rgba(55, 143, 255, 0.27);
}
.create-chat-member-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(140deg, #365383, #294064);
  font-weight: 700;
}
.create-chat-member-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.create-chat-member-name {
  font-weight: 600;
}
.create-chat-member-sub {
  color: #7f9ac2;
  font-size: 0.86rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.create-chat-member-check {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid rgba(124, 158, 219, 0.55);
  display: grid;
  place-items: center;
  font-size: 0.82rem;
  color: transparent;
  transition: color 120ms ease, border-color 120ms ease, background-color 120ms ease;
}
.create-chat-member-item.is-selected .create-chat-member-check {
  color: #ecf7ff;
  border-color: rgba(100, 201, 255, 0.88);
  background: rgba(57, 170, 255, 0.55);
}
.create-chat-hint {
  margin: 0;
  padding: 0.9rem 0.7rem;
  color: #86a3ce;
  text-align: center;
  font-size: 0.92rem;
}
.create-chat-error {
  margin: 0;
  color: #ff8ea8;
  font-size: 0.88rem;
  min-height: 1.1rem;
}
.create-chat-error[hidden] { display: none; }
.create-chat-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  border-top: 1px solid rgba(63, 90, 139, 0.45);
  padding-top: 0.75rem;
}
.member-manage-card {
  width: min(520px, 96vw);
}
.member-manage-selected {
  margin: 0;
  color: #a8c2e6;
  font-size: 0.92rem;
}
.member-manage-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}
.member-manage-actions .ghost.mini {
  flex: 1 1 calc(50% - 0.3rem);
  min-width: 170px;
}
.member-manage-actions .ghost.mini.danger {
  border-color: rgba(255, 98, 125, 0.42);
  color: #ff8fa8;
}
.member-manage-actions .ghost.mini.danger:hover {
  background: rgba(255, 92, 118, 0.18);
}
.action-confirm-card {
  width: min(420px, 94vw);
}
.action-confirm-card.is-danger #action-confirm-submit {
  border-color: rgba(255, 98, 125, 0.42);
  color: #ff8fa8;
}
.action-confirm-card.is-danger #action-confirm-submit:hover {
  background: rgba(255, 92, 118, 0.18);
}
@media (max-width: 640px) {
  .create-chat-card {
    width: min(420px, 100vw - 0.8rem);
    border-radius: 0.95rem;
    padding: 0.8rem 0.75rem 0.7rem;
  }
  .create-chat-hero {
    grid-template-columns: 74px minmax(0, 1fr);
    gap: 0.65rem;
  }
  .create-chat-avatar {
    width: 74px;
    height: 74px;
    font-size: 1.55rem;
  }
  .create-chat-member-list {
    min-height: 220px;
  }
  .member-manage-actions .ghost.mini {
    flex-basis: 100%;
    min-width: 0;
  }
}

.settings-panel {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
  pointer-events: none;
}
.settings-panel[hidden] { display: none; }
.settings-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
}
.settings-card {
  position: relative;
  width: min(500px, 96vw);
  background: #0f131c;
  border: 1px solid var(--border);
  border-radius: 1rem;
  box-shadow: 0 25px 70px rgba(0,0,0,0.6);
  padding: 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  pointer-events: auto;
  max-height: min(92dvh, 920px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}
.settings-card::-webkit-scrollbar {
  width: 10px;
}
.settings-card::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
  border-radius: 999px;
}
.settings-card::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 999px;
  border: 2px solid rgba(15, 19, 28, 0.95);
}
.settings-card::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
}
.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.settings-header-main {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}
.settings-header h3 { margin: 0; }
.settings-card .icon-button {
  border-radius: 50%;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.05);
}
.settings-back[hidden] { display: none !important; }
.settings-home {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.settings-home[hidden] { display: none !important; }
.settings-profile {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  min-height: 168px;
  justify-content: flex-end;
  padding: 5.1rem 1rem 1rem;
  border: 1px solid rgba(89, 115, 170, 0.22);
  border-radius: 1.1rem;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(10, 16, 28, 0.2), rgba(10, 16, 28, 0.92)),
    var(--settings-banner, linear-gradient(135deg, rgba(61, 166, 255, 0.28), rgba(16, 24, 36, 0.98)));
  background-size: cover;
  background-position: center;
}
.settings-profile::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(11, 17, 30, 0.12) 0%, rgba(11, 17, 30, 0.8) 58%, rgba(11, 17, 30, 0.98) 100%);
  pointer-events: none;
}
.settings-profile > * {
  position: relative;
  z-index: 1;
}
.settings-profile-meta {
  display: flex;
  align-items: flex-end;
  gap: 0.9rem;
  width: 100%;
  min-width: 0;
}
.settings-profile-copy {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
  flex: 1;
}
.settings-avatar {
  width: 78px;
  height: 78px;
  border-radius: 50%;
  background: linear-gradient(135deg,#273044,#1a1f2b);
  border: 3px solid rgba(15, 19, 28, 0.96);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 1.5rem;
  color: var(--text);
  background-size: cover;
  background-position: center;
}
.settings-name {
  font-weight: 800;
  font-size: 1.08rem;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.settings-status { color: #4ade80; font-size: 0.95rem; }
.settings-profile .ghost {
  margin-top: 0;
  align-self: flex-start;
  border-color: rgba(61,166,255,0.3);
  background: rgba(61,166,255,0.08);
}
.settings-list { display: flex; flex-direction: column; gap: 0.65rem; }
.settings-item {
  width: 100%;
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 0.65rem;
  align-items: center;
  padding: 0.55rem 0.6rem;
  border-radius: 0.75rem;
  background: rgba(255,255,255,0.02);
  transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
}
.settings-item > span:last-child {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.12rem;
}
.settings-item:hover {
  background: rgba(255,255,255,0.055);
  transform: translateY(-1px);
}
.settings-item.is-active {
  border-color: rgba(61,166,255,0.62);
  background: linear-gradient(135deg, rgba(61,166,255,0.18), rgba(28,130,255,0.08));
  box-shadow: inset 0 0 0 1px rgba(61,166,255,0.2), 0 10px 24px rgba(7, 12, 24, 0.35);
}
.settings-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 1.1rem;
  color: var(--text);
}
.settings-icon.blue { background: rgba(61,166,255,0.18); }
.settings-icon.yellow { background: rgba(255, 210, 63, 0.18); }
.settings-icon.violet { background: rgba(143, 94, 255, 0.18); }
.settings-icon.green { background: rgba(58, 196, 128, 0.18); }
.settings-icon.orange { background: rgba(255, 161, 94, 0.18); }
.settings-icon.teal { background: rgba(94, 212, 204, 0.18); }
.settings-title { font-weight: 700; }
.settings-sub { color: var(--muted); font-size: 0.9rem; }
.settings-section-shell {
  display: flex;
  flex-direction: column;
  gap: 0.95rem;
  border: 1px solid rgba(89, 115, 170, 0.22);
  border-radius: 1rem;
  padding: 0.95rem;
  background:
    linear-gradient(180deg, rgba(17, 25, 40, 0.82), rgba(11, 17, 30, 0.72));
}
.settings-section-shell[hidden] { display: none !important; }
.settings-section-head {
  display: flex;
  flex-direction: column;
  gap: 0.22rem;
  padding-bottom: 0.15rem;
}
.settings-section-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text);
}
.settings-section-subtitle {
  font-size: 0.92rem;
  line-height: 1.4;
}
.settings-sections {
  display: grid;
  gap: 0.8rem;
}
.settings-empty {
  margin: 0;
  border: 1px dashed rgba(148, 163, 184, 0.35);
  border-radius: 0.8rem;
  padding: 0.85rem 0.95rem;
  background: rgba(15, 23, 42, 0.4);
  text-align: center;
  font-size: 0.9rem;
}
.settings-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  border: 1px solid rgba(89, 115, 170, 0.22);
  border-radius: 0.9rem;
  padding: 0.9rem;
  background:
    linear-gradient(180deg, rgba(19, 27, 44, 0.72), rgba(11, 17, 30, 0.58));
}
.settings-section[hidden] { display: none !important; }
.settings-field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.settings-field span {
  color: #d8e7ff;
  font-size: 0.9rem;
  font-weight: 600;
}
.settings-field input,
.settings-field select {
  width: 100%;
  border: 1px solid rgba(91, 119, 179, 0.45);
  border-radius: 0.75rem;
  background: rgba(9, 14, 25, 0.85);
  color: var(--text);
  padding: 0.72rem 0.85rem;
}
.settings-field input:focus,
.settings-field select:focus {
  outline: none;
  border-color: rgba(61, 166, 255, 0.8);
  box-shadow: 0 0 0 3px rgba(61, 166, 255, 0.14);
}
.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}
.settings-upload-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}
.settings-toggle {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--text);
  border: 1px solid rgba(89, 115, 170, 0.24);
  border-radius: 0.75rem;
  padding: 0.55rem 0.7rem;
  background: rgba(12, 20, 36, 0.55);
}
.settings-toggle input {
  accent-color: var(--accent);
  width: 17px;
  height: 17px;
}
.settings-note {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.45;
}
.logout-wide {
  border: 1px solid rgba(255,95,135,0.3);
  background: rgba(255,95,135,0.1);
  color: var(--danger);
  border-radius: 0.85rem;
  padding: 0.85rem 1rem;
  font-weight: 700;
  cursor: pointer;
}
.settings-footer {
  text-align: center;
  font-size: 0.85rem;
}
.color-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.35rem;
  margin-top: 0.5rem;
}
.color-chip {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid transparent;
  background: var(--chip-color, rgba(255,255,255,0.1));
  cursor: pointer;
}
.color-chip[data-bubble-color="default"] {
  grid-column: span 2;
  border-radius: 0.7rem;
  width: 100%;
  height: 36px;
  border: 1px dashed var(--muted);
  color: var(--text);
  background: transparent;
}
.color-chip.active,
.color-chip:hover {
  border-color: var(--accent);
}

/* Auth screens */
body[data-page="login"], body[data-page="register"] {
  background:
    radial-gradient(circle at top, rgba(61, 166, 255, 0.16), transparent 34%),
    linear-gradient(180deg, #101521, #0b0f17);
  display: grid;
  place-items: center;
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  margin: 0;
  padding: 1rem;
}

.auth-shell {
  width: min(1180px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 420px);
  gap: 1.25rem;
  align-items: stretch;
}

.auth-shell--compact {
  grid-template-columns: minmax(0, 0.95fr) minmax(320px, 420px);
}

.auth-copy {
  border: 1px solid rgba(61, 166, 255, 0.16);
  background:
    linear-gradient(180deg, rgba(16, 24, 36, 0.92), rgba(11, 16, 24, 0.96)),
    rgba(255, 255, 255, 0.02);
  border-radius: 1.4rem;
  padding: 1.35rem 1.4rem;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.22);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.auth-kicker {
  display: inline-flex;
  align-self: flex-start;
  border: 1px solid rgba(61, 166, 255, 0.28);
  background: rgba(61, 166, 255, 0.08);
  color: #b9dbff;
  padding: 0.32rem 0.62rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.auth-copy h1 {
  margin: 0;
  font-size: clamp(1.9rem, 2.8vw, 3rem);
  line-height: 1.08;
}

.auth-copy h2 {
  margin: 0 0 0.22rem;
  font-size: 1rem;
}

.auth-lead {
  margin: 0;
  color: #d7deea;
  line-height: 1.6;
  font-size: 1rem;
}

.auth-meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
}

.auth-meta-grid article {
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.025);
  border-radius: 1rem;
  padding: 0.9rem 0.95rem;
}

.auth-meta-grid p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.auth-feature-list {
  margin: 0;
  padding-left: 1.15rem;
  display: grid;
  gap: 0.45rem;
  color: #dbe4f4;
}

.auth-card {
  width: min(420px, 92vw);
  background: var(--sidebar);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1.75rem;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}
.auth-card h1,
.auth-card h2 { margin: 0 0 0.4rem; }
.auth-card p { color: var(--muted); line-height: 1.5; }
.auth-card form { display: flex; flex-direction: column; gap: 0.9rem; margin: 1rem 0; }
.auth-card label { display: flex; flex-direction: column; gap: 0.35rem; color: var(--muted); }
.auth-card input {
  padding: 0.75rem 0.9rem;
  border-radius: 0.75rem;
  border: 1px solid var(--border);
  background: #0f131c;
  color: var(--text);
}
.auth-card button {
  padding: 0.85rem 1rem;
  border-radius: 0.85rem;
  border: none;
  background: var(--accent);
  color: #06101f;
  font-weight: 700;
  cursor: pointer;
}
.auth-card .status { min-height: 1.2rem; color: var(--muted); }
.auth-card a { color: var(--accent); text-decoration: none; }
.auth-card a:hover { text-decoration: underline; }

@media (max-width: 900px) {
  .auth-shell,
  .auth-shell--compact {
    grid-template-columns: 1fr;
  }

  .auth-copy {
    padding: 1.15rem;
  }

  .auth-meta-grid {
    grid-template-columns: 1fr;
  }
}

.mobile-blocker {
  min-height: 100vh;
  background: radial-gradient(circle at top, #1b2030, #0c0f16);
  display: grid;
  place-items: center;
  color: var(--text);
  padding: 1rem;
}
.mobile-card {
  background: var(--sidebar);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1.4rem;
  max-width: 420px;
  width: 100%;
  text-align: center;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
}
.mobile-card a.primary {
  display: inline-block;
  margin: 0.8rem 0;
  padding: 0.8rem 1.2rem;
  border-radius: 0.9rem;
  background: var(--accent);
  color: #06101f;
  font-weight: 700;
  text-decoration: none;
}
.mobile-card .small { font-size: 0.9rem; color: var(--muted); }

.muted { color: var(--muted); }
.list-empty { color: var(--muted); }

@media (max-width: 1040px) {
  .tg-root { grid-template-columns: 1fr; }
  .sidebar-toggle { display: grid; }
  .tg-dialog { padding: 0.55rem 0.55rem 0.7rem; }

  .tg-sidebar {
    display: flex;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(420px, 92vw);
    max-width: 92vw;
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    z-index: 100;
    overflow-y: auto;
    padding-bottom: 1rem;
  }
  .sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(2px);
    z-index: 90;
  }
  .tg-root.sidebar-open .tg-sidebar {
    transform: translateX(0);
  }
  .tg-root.sidebar-open .sidebar-overlay {
    display: block;
  }
  body.sidebar-open {
    overflow: hidden;
  }
  .message {
    max-width: min(86%, 520px);
  }
  .pinned-banner__text {
    max-width: min(70vw, 560px);
  }
}
.admin-root {
  min-height: 100vh;
  display: flex;
  background: #0c111b;
  color: #e6edf7;
}

.admin-login-screen {
  min-height: 100vh;
  width: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
}

.admin-login-screen[hidden],
.admin-app[hidden] {
  display: none !important;
}

.admin-login-card,
.admin-list-card,
.admin-details-card {
  background: #121a28;
  border: 1px solid #21324a;
  border-radius: 22px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

.admin-login-card {
  width: min(100%, 420px);
  padding: 28px;
}

.admin-kicker {
  font-size: 12px;
  letter-spacing: 0.18em;
  color: #6ab1ff;
  margin-bottom: 12px;
}

.admin-login-form {
  display: grid;
  gap: 12px;
  margin-top: 20px;
}

.admin-login-form input,
.admin-toolbar input {
  width: 100%;
  border-radius: 14px;
  border: 1px solid #284160;
  background: #0e1521;
  color: #e6edf7;
  padding: 14px 16px;
}

.admin-login-form button {
  border: 0;
  border-radius: 14px;
  padding: 14px 16px;
  font-weight: 700;
  background: linear-gradient(135deg, #3b8cff, #56d6ff);
  color: #06101c;
  cursor: pointer;
}

.admin-app {
  display: grid;
  grid-template-columns: 280px 1fr;
  width: 100%;
  min-height: 100vh;
}

.admin-sidebar {
  border-right: 1px solid #21324a;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  background: #0f1724;
}

.admin-current-user {
  font-size: 20px;
  font-weight: 700;
}

.admin-sidebar-audit {
  margin-top: auto;
  display: grid;
  gap: 10px;
}

.admin-audit-list {
  display: grid;
  gap: 8px;
}

.admin-audit-item {
  border: 1px solid #233955;
  border-radius: 14px;
  background: #101827;
  padding: 12px;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.admin-audit-summary {
  font-weight: 600;
  line-height: 1.45;
  margin-bottom: 6px;
}

.admin-nav {
  display: grid;
  gap: 10px;
}

.admin-content {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.admin-toolbar {
  display: flex;
  gap: 12px;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 18px;
  min-height: calc(100vh - 120px);
}

.admin-list-card,
.admin-details-card {
  padding: 18px;
  overflow: auto;
}

.admin-list {
  display: grid;
  gap: 10px;
}

.admin-list-item {
  width: 100%;
  border: 1px solid #233955;
  background: #101827;
  color: #e6edf7;
  border-radius: 16px;
  padding: 14px;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  text-align: left;
  cursor: pointer;
}

.admin-list-title {
  font-weight: 700;
}

.admin-list-sub,
.admin-list-meta,
.admin-meta-line,
.admin-list-empty {
  color: #9bb2ce;
}

.admin-details {
  display: grid;
  gap: 18px;
}

.admin-details.empty {
  display: grid;
  place-items: center;
  color: #8fa7c6;
  min-height: 280px;
}

.admin-section {
  border: 1px solid #233955;
  border-radius: 18px;
  background: #0f1724;
  padding: 18px;
  display: grid;
  gap: 10px;
}

.admin-actions-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.admin-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: 999px;
  border: 1px solid #2d6ec7;
  color: #9cd4ff;
  font-size: 12px;
  padding: 2px 8px;
}

.admin-badge.danger {
  border-color: #b34561;
  color: #ff9eb1;
}

@media (max-width: 980px) {
  .admin-app,
  .admin-grid {
    grid-template-columns: 1fr;
  }
}


/* Admin panel overrides */
.admin-root {
  min-height: 100dvh;
  height: 100dvh;
  overflow: hidden;
}

.admin-app {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  width: 100%;
  min-height: 100dvh;
  height: 100dvh;
  overflow: hidden;
}

.admin-sidebar {
  min-height: 0;
  overflow: hidden;
  padding: 22px;
  gap: 18px;
}

.admin-brand {
  display: grid;
  gap: 8px;
}

.admin-brand-subtitle {
  color: #8ea4c3;
  font-size: 0.92rem;
  line-height: 1.45;
}

.admin-nav {
  display: grid;
  gap: 10px;
}

.admin-nav .tab {
  border: 1px solid rgba(67, 100, 146, 0.5);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(18, 28, 43, 0.95), rgba(12, 19, 31, 0.95));
  color: #d9e8ff;
  padding: 12px 14px;
  text-align: left;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease, transform 140ms ease, box-shadow 140ms ease;
}

.admin-nav .tab:hover {
  border-color: rgba(96, 149, 235, 0.7);
  background: linear-gradient(180deg, rgba(23, 37, 59, 0.98), rgba(14, 24, 40, 0.98));
  transform: translateY(-1px);
}

.admin-nav .tab.active {
  border-color: rgba(104, 182, 255, 0.78);
  background: linear-gradient(135deg, rgba(34, 92, 181, 0.75), rgba(47, 168, 255, 0.62));
  box-shadow: 0 12px 24px rgba(19, 46, 89, 0.34);
  color: #f7fbff;
}

.admin-sidebar-actions {
  display: flex;
}

.admin-sidebar-audit {
  margin-top: auto;
  min-height: 0;
  overflow: hidden;
}

.admin-audit-list {
  display: grid;
  gap: 8px;
  overflow: auto;
  overflow-x: hidden;
  min-height: 0;
  max-height: min(34dvh, 360px);
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

.admin-audit-list::-webkit-scrollbar {
  width: 10px;
}

.admin-audit-list::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}

.admin-audit-list::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 999px;
  border: 2px solid rgba(15, 23, 36, 0.95);
}

.admin-audit-list::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
}

.admin-content {
  padding: 22px;
  min-height: 0;
  overflow: hidden;
}

.admin-toolbar {
  flex: 0 0 auto;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(340px, 420px) minmax(0, 1fr);
  gap: 18px;
  min-height: 0;
  height: 100%;
}

.admin-list-card,
.admin-details-card {
  padding: 18px;
  overflow: hidden;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.admin-list-header {
  flex: 0 0 auto;
}

.admin-list,
.admin-details {
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
}

.admin-list {
  display: grid;
  gap: 10px;
}

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

.admin-list-item.is-selected {
  border-color: rgba(104, 182, 255, 0.78);
  background: linear-gradient(135deg, rgba(24, 51, 90, 0.95), rgba(17, 31, 50, 0.98));
  box-shadow: inset 0 0 0 1px rgba(80, 162, 255, 0.18);
}

.admin-list-main {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.admin-list-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.admin-list-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-list-badges {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.admin-list-meta {
  text-align: right;
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-details {
  display: grid;
  gap: 18px;
}

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

.admin-device-list {
  display: grid;
  gap: 12px;
}

.admin-device-card {
  border: 1px solid #233955;
  border-radius: 16px;
  background: #101827;
  padding: 14px;
  display: grid;
  gap: 10px;
}

.admin-device-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.admin-device-title {
  font-size: 1rem;
  font-weight: 700;
}

.admin-device-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.admin-device-body {
  display: grid;
  gap: 6px;
}

.admin-warning-list {
  display: grid;
  gap: 12px;
}

.admin-warning-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid #233955;
  border-radius: 14px;
  background: #101827;
}

.admin-warning-main {
  min-width: 0;
  flex: 1 1 auto;
}

.admin-badge.is-official {
  border-color: #2d6ec7;
  color: #9cd4ff;
}

.admin-badge.is-bot {
  border-color: rgba(255, 255, 255, 0.16);
  color: #dde8f5;
}

.admin-badge.is-admin {
  border-color: rgba(140, 113, 255, 0.45);
  color: #cfbcff;
}

.admin-badge.is-danger,
.admin-badge.danger {
  border-color: #b34561;
  color: #ff9eb1;
}

.admin-badge.is-warn {
  border-color: rgba(255, 191, 94, 0.42);
  color: #ffd49b;
}

.admin-badge.is-ok {
  border-color: rgba(72, 201, 143, 0.42);
  color: #b8f3d6;
}

.admin-badge.is-sync {
  border-color: rgba(91, 176, 255, 0.42);
  color: #b8dcff;
}

.admin-badge.is-push {
  border-color: rgba(126, 136, 255, 0.42);
  color: #c8ceff;
}

.admin-badge.is-platform {
  border-color: rgba(255, 255, 255, 0.18);
  color: #dfe9f7;
}

@media (max-width: 1180px) {
  .admin-app,
  .admin-grid {
    grid-template-columns: 1fr;
  }

  .admin-sidebar {
    border-right: 0;
    border-bottom: 1px solid #21324a;
  }

  .admin-audit-list {
    max-height: 220px;
  }
}

.friends-card {
  width: min(720px, calc(100vw - 32px));
}

.friends-panel-body {
  display: grid;
  gap: 16px;
  min-height: min(64vh, 680px);
}

.friends-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 6px;
  border: 1px solid rgba(76, 107, 150, 0.26);
  border-radius: 18px;
  background: rgba(13, 23, 39, 0.78);
}

.friends-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 16px;
  border-radius: 14px;
  border: 1px solid transparent;
  background: transparent;
  color: #9cb4d2;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.friends-tab:hover {
  color: #eef6ff;
  border-color: rgba(91, 157, 255, 0.22);
  background: rgba(29, 47, 74, 0.72);
}

.friends-tab.is-active {
  color: #eef6ff;
  border-color: rgba(92, 159, 255, 0.34);
  background: linear-gradient(135deg, rgba(31, 58, 97, 0.96), rgba(20, 37, 60, 0.98));
  box-shadow: inset 0 0 0 1px rgba(116, 180, 255, 0.16);
}

.friends-tab-count {
  min-width: 24px;
  height: 24px;
  padding: 0 7px;
  border-radius: 999px;
  background: rgba(122, 174, 255, 0.16);
  color: #bfe0ff;
  font-size: 0.8rem;
  font-weight: 800;
  line-height: 24px;
  text-align: center;
}

.friends-view {
  min-height: 0;
}

.friends-list {
  display: grid;
  gap: 12px;
  max-height: min(54vh, 520px);
  overflow: auto;
  padding-right: 4px;
}

.friends-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid rgba(57, 82, 117, 0.38);
  background: linear-gradient(180deg, rgba(17, 27, 43, 0.96), rgba(13, 21, 35, 0.98));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

.friends-avatar {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: rgba(61, 166, 255, 0.22);
  color: #eef6ff;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 1.05rem;
  background-size: cover;
  background-position: center;
}

.friends-item-copy {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.friends-item-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

.friends-item-head strong {
  min-width: 0;
  font-size: 1rem;
}

.friends-item-name {
  color: #eef6ff;
  font-weight: 700;
}

.friends-item-subtitle {
  color: #8ea8c8;
  line-height: 1.45;
}

.friends-item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.friends-action {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid rgba(90, 123, 170, 0.28);
  background: rgba(19, 29, 45, 0.82);
  color: #e8f3ff;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease, opacity 0.18s ease;
}

.friends-action:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: rgba(117, 176, 255, 0.4);
  background: rgba(31, 49, 78, 0.96);
}

.friends-action:disabled {
  opacity: 0.58;
  cursor: progress;
}

.friends-action.primary {
  border-color: rgba(78, 156, 255, 0.36);
  background: linear-gradient(135deg, rgba(48, 119, 221, 0.96), rgba(60, 176, 255, 0.92));
}

.friends-action.primary:hover:not(:disabled) {
  border-color: rgba(133, 197, 255, 0.6);
  background: linear-gradient(135deg, rgba(61, 133, 235, 1), rgba(79, 189, 255, 0.96));
}

.friends-action.danger {
  border-color: rgba(203, 87, 113, 0.34);
  background: rgba(73, 22, 34, 0.78);
  color: #ffc4ce;
}

.friends-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #dce8f8;
  font-size: 0.78rem;
  font-weight: 700;
}

.friends-badge.official {
  border-color: rgba(74, 145, 255, 0.36);
  color: #a7d4ff;
}

.friends-add-box {
  display: grid;
  gap: 14px;
  padding: 16px;
  border-radius: 18px;
  border: 1px solid rgba(57, 82, 117, 0.38);
  background: linear-gradient(180deg, rgba(17, 27, 43, 0.96), rgba(13, 21, 35, 0.98));
}

.friends-add-box .settings-actions {
  margin-top: 0;
}

.friends-panel-body .muted {
  margin: 0;
}

.friends-panel.is-busy .friends-list {
  opacity: 0.78;
}

@media (max-width: 720px) {
  .friends-card {
    width: min(100vw - 16px, 720px);
  }

  .friends-tabs {
    gap: 8px;
  }

  .friends-tab {
    flex: 1 1 calc(50% - 8px);
  }

  .friends-list {
    max-height: min(50vh, 460px);
  }
}
