/* =============================================================================
   Мессенджер — стили
   ========================================================================== */
:root {
  --bg: #0b131b;
  --panel: #16202b;
  --panel-2: #1a2531;
  --elevated: #212e3c;
  --elevated-2: #2a3949;
  --line: #223040;
  --text: #f2f5f8;
  --muted: #8b9aab;
  --muted-2: #6c7a8a;
  --accent: #2a9dd6;
  --accent-dark: #1e88bd;
  --accent-soft: rgba(42, 157, 214, .18);
  --accent-line: rgba(42, 157, 214, .45);
  --ok: #23a55a;
  --danger: #e64a5c;
  --gold: #f0b90b;
  --purple: #8b5cf6;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 18px 50px rgba(0, 0, 0, .55);
  --shadow-soft: 0 4px 16px rgba(0, 0, 0, .28);
  --sidebar-width: 320px;
  --bubble-radius: 14px;
  --msg-font-size: 14.5px;
  --hover: rgba(255, 255, 255, .05);
  --own-bubble: linear-gradient(135deg, #26506f, #2b5278);
  --own-text: #ffffff;
  --scroll-thumb: #2a3949;
}
html[data-density="compact"] {
  --radius: 12px;
  --radius-sm: 9px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  font-family: 'Segoe UI', Roboto, -apple-system, 'Helvetica Neue', sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; color: inherit; }
input, textarea, select { font-family: inherit; }
a { color: var(--accent); }
::selection { background: rgba(42, 157, 214, .35); }

/* Скроллбары */
* { scrollbar-width: thin; scrollbar-color: var(--scroll-thumb) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--scroll-thumb); border-radius: 8px; }
*::-webkit-scrollbar-thumb:hover { background: var(--elevated-2); }

/* ============================ Кнопки и поля ============================== */
.btn {
  width: 100%;
  padding: 13px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  background: var(--elevated);
  color: var(--text);
  transition: transform .12s ease, background .15s ease, opacity .15s;
  margin-top: 8px;
}
.btn:hover { background: var(--elevated-2); }
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--accent); }
.btn.primary:hover { background: var(--accent-dark); }
.btn.ghost { background: rgba(255, 255, 255, .06); }
.btn.ghost:hover { background: rgba(255, 255, 255, .12); }
.btn.admin { background: var(--purple); }
.btn.admin:hover { background: #7c4ceb; }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #cf3d4e; }
.btn.small { width: auto; padding: 9px 14px; font-size: 13px; }

.field { display: block; margin-bottom: 10px; }
.field-label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
  padding-left: 4px;
}
input[type="text"], input[type="password"], input[type="number"], input[type="date"],
input:not([type]), textarea, select {
  width: 100%;
  padding: 12px 14px;
  background: var(--elevated);
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color .15s, background .15s;
  resize: vertical;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); background: var(--panel-2); }
input::placeholder, textarea::placeholder { color: var(--muted-2); }
select option { background: var(--panel); color: var(--text); }
input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(.7); cursor: pointer; }

.form-error { color: var(--danger); font-size: 13px; min-height: 16px; text-align: center; padding: 2px 0; }
.hint { color: var(--muted); font-size: 12px; margin-bottom: 10px; }

/* ============================== Тосты =================================== */
.toasts {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 400;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(360px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  background: var(--elevated);
  color: var(--text);
  border-left: 4px solid var(--accent);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 14px;
  line-height: 1.35;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateX(24px);
  transition: opacity .2s ease, transform .2s ease;
  word-break: break-word;
}
.toast.show { opacity: 1; transform: translateX(0); }
.toast.ok { border-left-color: var(--ok); }
.toast.error { border-left-color: var(--danger); }
.toast.gift {
  border-left-color: var(--gold);
  background: linear-gradient(135deg, rgba(240, 185, 11, .18), var(--elevated));
}

/* ============================ Авторизация =============================== */
.auth-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 16px;
  overflow-y: auto;
  background:
    radial-gradient(circle at 15% 15%, rgba(42, 157, 214, .25), transparent 45%),
    radial-gradient(circle at 85% 80%, rgba(139, 92, 246, .22), transparent 45%),
    linear-gradient(160deg, #0d1a26, #0b131b 60%);
  z-index: 30;
}
.auth-card {
  width: 380px;
  max-width: 100%;
  background: rgba(22, 32, 43, .92);
  backdrop-filter: blur(12px);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 30px 26px;
  box-shadow: var(--shadow);
  margin: auto;
}
.auth-logo { font-size: 46px; text-align: center; line-height: 1; }
.auth-card h1 { text-align: center; font-size: 23px; margin: 6px 0 4px; }
.auth-sub { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 20px; }
.auth-tabs {
  display: flex;
  gap: 4px;
  background: var(--elevated);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 18px;
}
.auth-tab {
  flex: 1;
  padding: 10px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  border-radius: 9px;
  transition: all .18s;
}
.auth-tab.active { background: var(--accent); color: #fff; }
.auth-form { display: flex; flex-direction: column; }

/* ==================== Консоль разработчика (левый верх) ================== */
.dev-console {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 900;
  width: min(560px, calc(100vw - 20px));
  max-height: 62vh;
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  border: 1px solid rgba(120, 200, 255, .35);
  background: rgba(8, 12, 18, .93);
  backdrop-filter: blur(6px);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .65);
  font: 12px/1.45 ui-monospace, Consolas, monospace;
  color: #cfe6ff;
  overflow: hidden;
}
.dc-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 7px 9px;
  background: rgba(30, 45, 62, .95);
  border-bottom: 1px solid rgba(120, 200, 255, .25);
  cursor: default;
}
.dc-title { font-weight: 700; color: #fff; }
.dc-tabs { display: flex; gap: 4px; }
.dc-tab {
  padding: 2px 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted, #8fa3b8);
  font: inherit;
  cursor: pointer;
}
.dc-tab.active { background: var(--accent, #2b8cff); color: #fff; }
.dc-actions { margin-left: auto; display: flex; gap: 4px; }
.dc-btn {
  width: 26px;
  height: 24px;
  border: 0;
  border-radius: 6px;
  background: rgba(255, 255, 255, .08);
  color: #fff;
  font: inherit;
  cursor: pointer;
}
.dc-btn:hover { background: rgba(255, 255, 255, .2); }
.dc-body { flex: 1; overflow-y: auto; padding: 6px 9px; }
.dc-line { white-space: pre-wrap; word-break: break-word; padding: 1px 0; }
.dc-time { color: #5f7691; margin-right: 6px; }
.dc-err { color: #ff8f8f; }
.dc-warn { color: #ffd479; }
.dc-in { color: #9be89b; }
.dc-out { color: #8fc6ff; }
.dc-foot {
  padding: 5px 9px;
  border-top: 1px solid rgba(120, 200, 255, .2);
  background: rgba(20, 30, 42, .95);
  color: #9fb6cc;
}
@media (max-width: 600px) {
  .dev-console { width: calc(100vw - 12px); left: 6px; top: 6px; max-height: 50vh; }
}

/* ============================ Каркас приложения ========================== */
.app { display: flex; height: 100vh; height: 100dvh; width: 100vw; }
/* Зона перетаскивания файлов: показана, пока файл держат над окном */
.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 14, 20, .72);
  backdrop-filter: blur(3px);
  pointer-events: none;
}
.drop-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 34px 46px;
  border-radius: 22px;
  border: 3px dashed var(--accent);
  background: rgba(22, 32, 43, .92);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .55);
  animation: modal-in .18s ease;
}
.drop-icon { font-size: 54px; line-height: 1; }
.drop-title { font-size: 19px; font-weight: 700; color: #fff; }
.drop-hint { font-size: 13px; color: var(--muted); }
@media (max-width: 768px) {
  .drop-card { padding: 24px 26px; }
  .drop-icon { font-size: 40px; }
  .drop-title { font-size: 16px; }
}
.drawer-overlay { display: none; }

/* --------------------------- Сайдбар ------------------------------------ */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.me-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.me-avatar-btn { background: none; border: none; padding: 0; border-radius: 50%; }
.me-avatar-btn:hover .avatar { box-shadow: 0 0 0 2px var(--accent); }
.me-info { flex: 1; min-width: 0; }
.me-name {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.me-sub {
  color: var(--accent);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.silver-badge {
  border: none;
  background: linear-gradient(135deg, var(--gold), #d99a00);
  color: #1b2430;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 20px;
  white-space: nowrap;
  transition: transform .15s;
}
.silver-badge:hover { transform: translateY(-1px); }

.sidebar-search { position: relative; padding: 10px 12px 4px; }
.sidebar-search .search-ico {
  position: absolute;
  left: 24px;
  top: 50%;
  transform: translateY(-30%);
  font-size: 13px;
  opacity: .7;
  pointer-events: none;
}
.sidebar-search input {
  padding-left: 34px;
  padding-right: 34px;
  border-radius: 20px;
  background: var(--elevated);
}
.sidebar-search .mini {
  position: absolute;
  right: 18px;
  top: 50%;
  transform: translateY(-38%);
  font-size: 13px;
}
.search-results {
  position: absolute;
  left: 12px;
  right: 12px;
  top: calc(100% - 2px);
  background: var(--elevated);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 6px;
  max-height: 320px;
  overflow-y: auto;
  z-index: 25;
  box-shadow: var(--shadow);
}
.search-item {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px;
  border-radius: 10px;
  cursor: pointer;
}
.search-item:hover, .search-item.active { background: var(--accent-soft); }
.search-name { font-size: 14px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.search-sub { font-size: 12px; color: var(--muted); }
.search-empty { padding: 14px; text-align: center; color: var(--muted); font-size: 13px; }

.nav-actions {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
}
.side-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 7px 4px;
  border-radius: 10px;
  font-size: 11px;
  transition: background .15s, color .15s;
}
.side-btn:hover { background: var(--elevated); color: var(--text); }
/* Кнопку игр выделяем, чтобы её было легко найти */
#open-games { color: var(--accent); }
#open-games:hover { background: var(--accent-soft); color: var(--accent); }

.sidebar-scroll { flex: 1; overflow-y: auto; min-height: 0; padding-bottom: 6px; }
.section { padding: 6px 0; }
.section-title {
  padding: 8px 16px 4px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--muted-2);
  font-weight: 700;
}
.chat-list { list-style: none; }
.chat-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background .15s;
}
.chat-item:hover { background: var(--panel-2); }
.chat-item.active { background: var(--accent-soft); border-left-color: var(--accent); }
.chat-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  color: var(--muted);
}
.chat-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.chat-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.chat-title {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-time { font-size: 11px; color: var(--muted-2); flex-shrink: 0; }
.chat-preview {
  flex: 1;
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.unread {
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.online-dot {
  position: absolute;
  right: 14px;
  top: 14px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 3px var(--panel);
}
.empty-row { padding: 12px 16px; color: var(--muted); font-size: 13px; }
.sidebar-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 14px;
  border-top: 1px solid var(--line);
  background: var(--panel);
}
.conn { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--ok); }
.conn .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse-dot 2.4s infinite;
}
.conn.offline { color: var(--gold); }
@keyframes pulse-dot { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

/* ------------------------------- Чат ------------------------------------ */
.chat {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background-color: var(--bg);
  background-image:
    radial-gradient(circle at 20% 0%, var(--accent-soft), transparent 45%),
    radial-gradient(circle at 90% 90%, rgba(139, 92, 246, .07), transparent 45%);
  background-repeat: no-repeat;
  background-size: cover;
  /* Как в телеграме: чат — отдельная скруглённая карточка, а не во весь экран */
  border-radius: 16px;
  margin: 8px 8px 8px 0;
  overflow: hidden;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .28);
}
@media (max-width: 860px) {
  .chat { border-radius: 0; margin: 0; box-shadow: none; }
}
/* Фон чата: пресеты или своё изображение (--chat-wallpaper) */
html[data-wallpaper="plain"] .chat { background-image: none; }
html[data-wallpaper="grid"] .chat {
  background-image:
    linear-gradient(var(--hover) 1px, transparent 1px),
    linear-gradient(90deg, var(--hover) 1px, transparent 1px);
  background-size: 28px 28px;
}
html[data-wallpaper="dots"] .chat {
  background-image: radial-gradient(var(--hover) 1.5px, transparent 1.5px);
  background-size: 22px 22px;
}
html[data-wallpaper="custom"] .chat {
  background-image: linear-gradient(rgba(6, 12, 18, .78), rgba(6, 12, 18, .78)), var(--chat-wallpaper);
  background-size: cover;
  background-position: center;
}
html[data-theme="light"][data-wallpaper="custom"] .chat {
  background-image: linear-gradient(rgba(255, 255, 255, .82), rgba(255, 255, 255, .82)), var(--chat-wallpaper);
}
.chat-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  background: rgba(22, 32, 43, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  z-index: 5;
}
.chat-peer {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  background: none;
  border: none;
  text-align: left;
  padding: 4px;
  border-radius: 10px;
}
.chat-peer:hover { background: rgba(255, 255, 255, .04); }
.chat-info { display: flex; flex-direction: column; min-width: 0; }
.chat-name {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-status {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-status.accent { color: var(--accent); }
.chat-actions { display: flex; gap: 2px; }
.icon-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 17px;
  padding: 7px 9px;
  border-radius: 10px;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--elevated); color: var(--text); }
.back-btn { display: none; font-size: 20px; }

.messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 22px 26px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  outline: none;
  scroll-behavior: smooth;
}
/* Сообщения не прилипают к краям чата, как в телеграме */
@media (max-width: 760px) {
  .messages { padding: 14px 16px 8px; }
}
@media (max-width: 420px) {
  .messages { padding: 12px 12px 6px; }
  .msg { max-width: min(58%, 32ch); }
  .msg:has(.msg-image),
  .msg:has(.vp-video),
  .msg:has(.gift-card),
  .msg:has(.msg-sticker),
  .msg:has(.msg-file),
  .msg:has(.msg-media-lost) { max-width: 88%; }
}
.empty-chat { margin: auto; color: var(--muted); font-size: 14px; text-align: center; }
.day-sep { display: flex; justify-content: center; margin: 10px 0 4px; }
.day-sep span {
  background: rgba(255, 255, 255, .07);
  color: var(--muted);
  font-size: 11.5px;
  padding: 4px 12px;
  border-radius: 12px;
}
.msg {
  display: flex;
  gap: 8px;
  /* Текст занимает не больше половины чата и переносится примерно после
     46 знаков в строке — одной длинной строки на весь чат больше не будет. */
  max-width: min(50%, 46ch);
  align-self: flex-start;
  animation: msg-in .18s ease;
}
/* Картинки, видео, файлы, подарки и стикеры могут быть шире текста */
.msg:has(.msg-image),
.msg:has(.vp-video),
.msg:has(.gift-card),
.msg:has(.msg-sticker),
.msg:has(.msg-file),
.msg:has(.msg-media-lost) { max-width: min(78%, 760px); }
/* Цветная полоска у своих сообщений — её цвет берётся из темы в настройках */
.msg.mine .bubble::after {
  content: '';
  position: absolute;
  top: 6px;
  bottom: 6px;
  right: 0;
  width: 3px;
  border-radius: 3px;
  background: var(--accent);
}
@keyframes msg-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.msg.mine { align-self: flex-end; flex-direction: row-reverse; }
.msg.grouped { margin-top: -2px; }
.msg-avatar { cursor: pointer; align-self: flex-end; }
.bubble {
  position: relative;
  background: var(--panel-2);
  padding: 8px 12px 6px;
  border-radius: var(--bubble-radius);
  border-top-left-radius: calc(var(--bubble-radius) / 3);
  min-width: 70px;
  max-width: 100%;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .25);
}
.msg.mine .bubble {
  background: var(--own-bubble);
  color: var(--own-text);
  border-top-left-radius: var(--bubble-radius);
  border-top-right-radius: calc(var(--bubble-radius) / 3);
}
.msg.grouped:not(.mine) .bubble { border-top-left-radius: var(--bubble-radius); }
.msg-author {
  font-size: 12.5px;
  font-weight: 700;
  margin-bottom: 3px;
  color: var(--accent);
  cursor: pointer;
  display: inline-block;
}
.msg-author:hover { text-decoration: underline; }
.msg-text { font-size: var(--msg-font-size); line-height: 1.45; white-space: pre-wrap; word-break: break-word; }
.msg-text mark {
  background: rgba(240, 185, 11, .35);
  color: inherit;
  border-radius: 4px;
  padding: 0 2px;
}
.msg.search-active .bubble { box-shadow: 0 0 0 2px var(--accent), var(--shadow-soft); }
.msg-image {
  display: block;
  max-width: 100%;
  max-height: 340px;
  border-radius: 10px;
  margin-bottom: 4px;
  cursor: zoom-in;
  background: #0a0f14;
}
.msg-time { font-size: 10.5px; color: var(--muted-2); text-align: right; margin-top: 2px; }
/* Вложение потерялось на сервере — показываем подпись вместо «битой» картинки */
/* Заметный блок покупки премиума в магазине */
.premium-buy {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 14px; margin-bottom: 12px; border-radius: 14px;
  background: linear-gradient(150deg, rgba(120, 90, 255, .26), rgba(110, 231, 255, .1));
  border: 1px solid rgba(160, 140, 255, .45);
}
.premium-buy-ico { font-size: 27px; line-height: 1; }
.premium-buy-text { flex: 1; min-width: 180px; display: flex; flex-direction: column; gap: 2px; }
.premium-buy-text b { font-size: 14.5px; }
.premium-buy-note { font-size: 12px; color: var(--muted); }
.premium-buy .btn { margin: 0; white-space: nowrap; }
@media (max-width: 560px) {
  .premium-buy { gap: 8px; padding: 11px 12px; }
  .premium-buy-ico { font-size: 22px; }
  .premium-buy .btn { flex: 1 1 100%; min-height: 40px; }
}
/* Карточка премиума в магазине — стоит первой, выделяется фоном */
.shop-card.premium-card {
  background: linear-gradient(160deg, rgba(120, 90, 255, .28), rgba(110, 231, 255, .12));
  border: 1px solid rgba(160, 140, 255, .45);
}
.shop-card.premium-card .shop-card-art { font-size: 34px; }
.shop-card.premium-card .shop-card-name { font-weight: 700; }
.msg-media-lost {
  display: inline-flex; align-items: center; gap: 6px; margin-bottom: 4px;
  padding: 10px 12px; border-radius: 10px; font-size: 12.5px;
  background: var(--elevated); color: var(--muted); border: 1px dashed var(--line);
}
.msg.mine .msg-time { color: var(--own-muted, rgba(255, 255, 255, .6)); }
.msg-copy {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(0, 0, 0, .45);
  border: none;
  border-radius: 8px;
  font-size: 12px;
  padding: 3px 6px;
  opacity: 0;
  transition: opacity .15s;
}
.bubble:hover .msg-copy { opacity: 1; }
.system {
  align-self: center;
  background: rgba(255, 255, 255, .07);
  backdrop-filter: blur(6px);
  color: #ffffff;
  font-size: 12.5px;
  font-weight: 500;
  padding: 6px 16px;
  border-radius: 16px;
  margin: 6px auto;
  text-align: center;
  max-width: 90%;
  border: 1px solid rgba(255, 255, 255, .08);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .25);
  letter-spacing: .1px;
}
.typing { height: 18px; padding: 0 22px 2px; font-size: 12.5px; color: var(--accent); font-style: italic; }
.scroll-bottom {
  position: absolute;
  right: 20px;
  bottom: 96px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: var(--elevated-2);
  color: var(--text);
  font-size: 18px;
  box-shadow: var(--shadow);
  z-index: 6;
}
.scroll-bottom .badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ----------------------------- Композер --------------------------------- */
.composer {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 10px 14px 14px;
  background: rgba(22, 32, 43, .92);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
}
/* Обёртка кнопок вложений: на широком экране не влияет на раскладку,
   на телефоне превращается в отдельную строку значков */
.composer-tools { display: contents; }
.attach-btn {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 19px;
  transition: background .15s, color .15s;
}
.attach-btn:hover { background: var(--elevated); color: var(--text); }
.attach-btn:disabled { opacity: .4; cursor: not-allowed; }
.attach-btn:disabled:hover { background: transparent; color: var(--muted); }
.composer textarea {
  flex: 1;
  min-height: 42px;
  max-height: 160px;
  padding: 11px 16px;
  border-radius: 21px;
  background: var(--elevated);
  border: 2px solid transparent;
  font-size: 14.5px;
  line-height: 1.35;
  resize: none;
  overflow-y: auto;
}
.composer textarea:focus { border-color: var(--accent); background: var(--panel-2); }
.composer textarea:disabled { opacity: .6; }
.send-btn {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 18px;
  transition: background .15s, transform .12s;
}
.send-btn:hover { background: var(--accent-dark); }
.send-btn:active { transform: scale(.94); }
.send-btn:disabled { opacity: .5; }

.emoji-picker {
  position: absolute;
  bottom: calc(100% - 4px);
  left: 14px;
  width: 330px;
  max-width: calc(100vw - 28px);
  max-height: 250px;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  box-shadow: var(--shadow);
  z-index: 20;
}
.emoji-item {
  background: transparent;
  border: none;
  font-size: 20px;
  padding: 6px;
  border-radius: 8px;
}
.emoji-item:hover { background: var(--elevated); }

/* ============================== Модалки ================================= */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(4, 8, 12, .72);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px 14px;
  overflow-y: auto;
  z-index: 100;
  animation: fade-in .15s ease;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal-box {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 22px;
  width: 480px;
  max-width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  margin: auto;
  animation: modal-in .18s ease;
}
@keyframes modal-in { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-box.narrow { width: 420px; }
.modal-box.wide { width: 660px; }
.modal-box.tiny { width: 380px; }
.modal-box h2 { font-size: 18px; text-align: center; margin-bottom: 14px; }
.modal-close-row { display: flex; justify-content: flex-end; margin: -8px -8px 0 0; }
.modal-x { font-size: 15px; }

.tabs {
  display: flex;
  gap: 4px;
  background: var(--elevated);
  padding: 4px;
  border-radius: 12px;
  margin-bottom: 16px;
  overflow-x: auto;
}
.tab {
  flex: 1;
  white-space: nowrap;
  padding: 9px 10px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  border-radius: 9px;
  transition: all .15s;
}
.tab.active { background: var(--accent); color: #fff; }

/* --------------------------- Профиль ------------------------------------ */
.profile-hero { text-align: center; }
.big-avatar { width: 96px; height: 96px; font-size: 38px; margin: 0 auto 12px; display: flex; }
.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  background-size: cover;
  background-position: center;
  background-color: var(--elevated);
  flex-shrink: 0;
  overflow: hidden;
}
.profile-username-line { color: var(--muted); font-size: 14px; margin-bottom: 8px; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-bottom: 12px; }
.tag {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 8px;
  background: var(--elevated);
  color: var(--muted);
  white-space: nowrap;
}
.tag.owner { background: linear-gradient(135deg, var(--gold), #d99a00); color: #1b2430; }
.tag.premium { background: linear-gradient(135deg, rgba(150,120,255,.45), rgba(110,231,255,.35)); color: #e9e2ff; }
.tag.rank { background: rgba(139, 92, 246, .22); color: #c4b5fd; }
.tag.skam { background: rgba(139, 0, 0, .3); color: #ff8a8a; }
.tag.danger { background: rgba(230, 74, 92, .2); color: #ff92a0; }
.tag.warn { background: rgba(240, 185, 11, .18); color: #f5cf5b; }
.profile-bio {
  background: var(--elevated);
  padding: 12px 14px;
  border-radius: 12px;
  color: #dbe3ea;
  font-size: 14px;
  margin-bottom: 14px;
  min-height: 22px;
  white-space: pre-wrap;
  word-break: break-word;
}
.profile-stats { display: flex; gap: 10px; margin-bottom: 14px; }
.stat { flex: 1; background: var(--elevated); padding: 12px 8px; border-radius: 12px; text-align: center; }
.stat-val { font-size: 20px; font-weight: 700; color: var(--gold); }
.stat-label { font-size: 10.5px; color: var(--muted); text-transform: uppercase; margin-top: 3px; letter-spacing: .3px; }
.profile-field {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  margin-bottom: 12px;
}
.profile-field label { color: var(--muted); }
.avatar-edit { display: flex; flex-direction: column; align-items: center; margin-bottom: 14px; }

.gifts-row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 14px; }
.gift-chip {
  position: relative;
  font-size: 26px;
  padding: 8px 10px;
  background: var(--elevated);
  border-radius: 12px;
  cursor: pointer;
  transition: transform .15s;
  border: 2px solid var(--muted-2);
}
.gift-chip:hover { transform: scale(1.08); }
.gift-count {
  position: absolute;
  right: -4px;
  bottom: -4px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 8px;
}
.gift-chip.rarity-uncommon { border-color: var(--ok); box-shadow: 0 0 8px rgba(35, 165, 90, .35); }
.gift-chip.rarity-rare { border-color: var(--accent); box-shadow: 0 0 10px rgba(42, 157, 214, .45); }
.gift-chip.rarity-epic { border-color: var(--purple); box-shadow: 0 0 12px rgba(139, 92, 246, .5); }
.gift-chip.rarity-legendary { border-color: var(--gold); box-shadow: 0 0 14px rgba(240, 185, 11, .55); }
.gift-chip.rarity-mythic { border-color: #ff2d55; box-shadow: 0 0 18px rgba(255, 45, 85, .7); animation: mythic-pulse 2s infinite; }
@keyframes mythic-pulse {
  0%, 100% { box-shadow: 0 0 18px rgba(255, 45, 85, .7); }
  50% { box-shadow: 0 0 28px rgba(255, 45, 85, 1); }
}

/* --------------------------- Модерация ---------------------------------- */
.target-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--elevated);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 12px;
}
.target-name { font-weight: 600; font-size: 15px; }
.target-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.mod-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin-bottom: 10px; }
.mod-act {
  border: none;
  border-radius: 12px;
  padding: 12px 10px;
  font-size: 13.5px;
  font-weight: 600;
  background: var(--elevated);
  color: var(--text);
  transition: background .15s, transform .12s;
}
.mod-act:hover { background: var(--elevated-2); }
.mod-act:active { transform: scale(.97); }
.mod-act[data-action="warn"] { background: rgba(240, 185, 11, .18); color: #f5cf5b; }
.mod-act[data-action="mute"] { background: rgba(230, 126, 34, .2); color: #f0a868; }
.mod-act[data-action="kick"] { background: rgba(139, 92, 246, .22); color: #c4b5fd; }
.mod-act.danger { background: rgba(230, 74, 92, .2); color: #ff92a0; }
.mod-act.grant { background: rgba(35, 165, 90, .2); color: #7ee2a8; }
.mod-field { margin-bottom: 10px; }
.mod-field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
  border: 1px solid var(--line);
  background: var(--elevated);
  color: var(--text);
  font-size: 12px;
  padding: 6px 11px;
  border-radius: 14px;
  transition: background .15s, border-color .15s;
}
.chip:hover { background: var(--elevated-2); border-color: var(--accent); }

/* ---------------------------- Магазин ----------------------------------- */
.shop-balance { text-align: center; color: var(--muted); font-size: 14px; margin-bottom: 14px; }
.shop-balance b { color: var(--gold); font-size: 18px; }
.shop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
  max-height: 46vh;
  overflow-y: auto;
  padding: 2px;
}
.shop-card {
  border: 2px solid transparent;
  border-radius: 14px;
  padding: 12px 8px;
  background: var(--elevated);
  text-align: center;
  color: var(--text);
  transition: transform .15s, border-color .15s, background .15s;
}
.shop-card:hover { transform: translateY(-3px); background: var(--elevated-2); }
.shop-card.selected { border-color: var(--accent); background: rgba(42, 157, 214, .18); }
.shop-card.unaffordable { opacity: .5; }
.shop-card-emoji { font-size: 34px; }
.shop-card-name { font-size: 13px; font-weight: 600; margin: 4px 0; }
.shop-card-price { font-size: 12px; color: var(--gold); }
.rarity-badge {
  display: inline-block;
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: .4px;
  padding: 2px 7px;
  border-radius: 6px;
  margin-top: 6px;
}
.rarity-badge-common { background: var(--muted-2); color: #fff; }
.rarity-badge-uncommon { background: var(--ok); color: #fff; }
.rarity-badge-rare { background: var(--accent); color: #fff; }
.rarity-badge-epic { background: var(--purple); color: #fff; }
.rarity-badge-legendary { background: var(--gold); color: #1b2430; }
.rarity-badge-mythic { background: #ff2d55; color: #fff; }
.shop-recipient { margin-bottom: 10px; }
.shop-recipient label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }

/* --------------------------- Админ-панель ------------------------------- */
.admin-pane { display: flex; flex-direction: column; gap: 10px; }
.admin-search { margin-bottom: 2px; }
.admin-users-list {
  max-height: 44vh;
  overflow-y: auto;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 6px;
}
.admin-user-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  transition: background .15s;
}
.admin-user-row:hover { background: var(--elevated); }
.au-main { flex: 1; min-width: 0; }
.au-name { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.au-sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.au-side { display: flex; align-items: center; gap: 10px; }
.au-silver { color: var(--gold); font-weight: 700; font-size: 13px; white-space: nowrap; }
.au-actions { display: flex; gap: 4px; }
.mini-btn {
  background: var(--elevated);
  border: none;
  border-radius: 9px;
  padding: 6px 9px;
  font-size: 14px;
  transition: background .15s;
}
.mini-btn:hover { background: var(--elevated-2); }
.mini-btn.ok { background: rgba(35, 165, 90, .2); }

/* ---------------------------- Правила ----------------------------------- */
.rules-content { font-size: 14px; line-height: 1.55; color: #dbe3ea; max-height: 52vh; overflow-y: auto; padding-right: 4px; }
.rules-content h3 { font-size: 15px; margin-bottom: 10px; color: #fff; }
.rules-content ol { padding-left: 20px; display: flex; flex-direction: column; gap: 8px; }
.rules-content li { margin-bottom: 2px; }
.rules-content b { color: #fff; }
.rules-note { color: var(--muted); font-size: 13px; margin-bottom: 12px; }
.support-admin-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.support-admin-row:hover { background: var(--elevated); border-color: var(--accent); }
.support-name { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.support-sub { font-size: 12px; color: var(--muted); }

/* ---------------------------- Настройки --------------------------------- */
.settings-group { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }
.settings-title { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted-2); font-weight: 700; margin-bottom: 10px; }
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 4px;
  font-size: 14px;
  cursor: pointer;
}
.switch-row input[type="checkbox"] {
  appearance: none;
  width: 44px;
  height: 24px;
  border-radius: 12px;
  background: var(--elevated-2);
  position: relative;
  cursor: pointer;
  transition: background .18s;
  flex-shrink: 0;
}
.switch-row input[type="checkbox"]::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform .18s;
}
.switch-row input[type="checkbox"]:checked { background: var(--accent); }
.switch-row input[type="checkbox"]:checked::after { transform: translateX(20px); }
.shortcuts { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.shortcuts li { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.shortcuts li span { margin-left: auto; }
kbd {
  background: var(--elevated);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 11.5px;
  font-family: inherit;
  color: var(--text);
}

/* ------------------------- Подтверждение -------------------------------- */
.confirm-text { color: var(--muted); font-size: 14px; text-align: center; margin-bottom: 16px; line-height: 1.45; }
.confirm-actions { display: flex; gap: 8px; }
.confirm-actions .btn { margin-top: 0; }

/* --------------------------- Просмотр фото ------------------------------ */
.photo-preview { width: 100%; max-height: 46vh; object-fit: contain; border-radius: 12px; background: #0a0f14; margin-bottom: 12px; }
.image-viewer {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .93);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 20px 20px;
  cursor: zoom-out;
}
.image-viewer img { max-width: 100%; max-height: 100%; border-radius: 10px; transition: transform .2s; }
.image-viewer.zoomed img { transform: scale(1.6); cursor: zoom-out; }
.image-viewer-top { position: absolute; top: 14px; right: 16px; display: flex; gap: 8px; }
.imgv-btn {
  background: rgba(255, 255, 255, .12);
  border: none;
  color: #fff;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  font-size: 18px;
  transition: background .15s;
}
.imgv-btn:hover { background: rgba(255, 255, 255, .24); }

/* Полноэкранный просмотр видео */
.video-viewer {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .96);
  z-index: 310;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 12px 20px;
}
.vv-player {
  width: 100%;
  max-width: 1100px;
  max-height: 100%;
  background: #000;
  border-radius: 12px;
  outline: none;
}
.video-viewer .image-viewer-top { z-index: 2; }
@media (max-width: 768px) {
  /* На телефоне видео занимает весь экран, поворачивать не нужно */
  .video-viewer { padding: calc(52px + env(safe-area-inset-top)) 6px calc(10px + env(safe-area-inset-bottom)); }
  .vv-player { max-height: 100%; border-radius: 8px; }
  .video-viewer .imgv-btn { width: 38px; height: 38px; font-size: 16px; }
}
@media (orientation: landscape) and (max-height: 500px) {
  .video-viewer { padding: 6px; }
  .video-viewer .image-viewer-top { top: 6px; right: 8px; }
}

/* ------------------------------- Звонки --------------------------------- */
.call-box { text-align: center; }
.call-label { color: var(--muted); font-size: 14px; margin-bottom: 8px; }
.call-timer { font-variant-numeric: tabular-nums; font-size: 15px; color: var(--text); margin-bottom: 12px; }
.call-actions { display: flex; gap: 16px; justify-content: center; margin-top: 18px; }
.call-btn {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: none;
  font-size: 21px;
  background: var(--elevated-2);
  color: #fff;
  transition: background .15s, transform .12s;
}
.call-btn:hover { background: #35485c; }
.call-btn:active { transform: scale(.94); }
.call-btn.accept { background: var(--ok); }
.call-btn.reject { background: var(--danger); }
.pulse { animation: call-pulse 1.8s infinite; }
@keyframes call-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(42, 157, 214, .5); }
  50% { box-shadow: 0 0 0 16px rgba(42, 157, 214, 0); }
}
.video-wrap { position: relative; margin-bottom: 12px; }
.video-remote {
  width: 100%;
  max-height: 46vh;
  border-radius: 14px;
  background: #05090d;
  display: none;
}
.video-remote.visible { display: block; }
.video-local {
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 108px;
  border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, .25);
  background: #05090d;
  transform: scaleX(-1);
  display: none;
}
.video-local.visible { display: block; }
.call-avatar-overlay { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); }
.video-remote.visible + .video-local ~ .call-avatar-overlay,
.video-remote.visible ~ .call-avatar-overlay { display: none; }
/* Своя картинка зеркалится только с фронтальной камеры */
.video-local.rear { transform: none; }
.call-hint { font-size: 13px; color: var(--accent); margin-bottom: 8px; }
.video-local.visible ~ .call-avatar-overlay { display: none; }

/* Полноэкранный режим звонка (кнопка ⛶) */
.call-box.call-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 60;
  max-width: none;
  width: 100%;
  height: 100%;
  border-radius: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.call-box.call-fullscreen .video-remote.visible { max-height: none; height: 100%; object-fit: contain; }

/* Телефон: звонок на весь экран, кнопки внизу, с учётом «чёлки» */
@media (max-width: 768px) {
  #active-call .modal-box.call-box {
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: none;
    border-radius: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: calc(10px + env(safe-area-inset-top)) 12px calc(14px + env(safe-area-inset-bottom));
  }
  #active-call .video-wrap {
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  #active-call .video-remote { max-height: none; width: 100%; height: 100%; object-fit: contain; }
  #active-call .video-local {
    top: calc(10px + env(safe-area-inset-top));
    right: 12px;
    bottom: auto;
    width: 92px;
    z-index: 3;
  }
  #active-call .call-actions { flex-wrap: wrap; gap: 12px; margin-top: 8px; }
  #active-call h2 { font-size: 19px; margin-bottom: 2px; }
}

/* ===================== Права, реестр админов, журнал ===================== */
.tag.perm {
  background: rgba(42, 157, 214, .16);
  color: #8fd0f0;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
}
.perm-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.perm-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 6px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px;
}
.perm-row {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
  transition: background .15s;
}
.perm-row:hover { background: var(--elevated); }
.perm-row.disabled { opacity: .45; cursor: not-allowed; }
.perm-row input[type="checkbox"] {
  appearance: none;
  width: 20px;
  height: 20px;
  min-width: 20px;
  border-radius: 6px;
  background: var(--elevated-2);
  border: 2px solid transparent;
  position: relative;
  margin-top: 1px;
  transition: background .15s, border-color .15s;
}
.perm-row input[type="checkbox"]:checked { background: var(--accent); }
.perm-row input[type="checkbox"]:checked::after {
  content: '✓';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}
.perm-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.perm-text b { font-size: 13.5px; font-weight: 600; }
.perm-text i { font-size: 11.5px; color: var(--muted); font-style: normal; }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.registry-head { padding: 2px 4px 8px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.registry-row { align-items: flex-start; }
.registry-row .au-actions { flex-wrap: wrap; justify-content: flex-end; }
.registry-log { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
.log-row {
  display: flex;
  gap: 8px;
  align-items: baseline;
  padding: 5px 6px;
  border-radius: 8px;
  font-size: 12.5px;
}
.log-row:nth-child(odd) { background: rgba(255, 255, 255, .03); }
.log-action {
  flex-shrink: 0;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .3px;
  padding: 2px 7px;
  border-radius: 7px;
  background: var(--elevated-2);
  color: var(--muted);
}
.log-action.grant { background: rgba(35, 165, 90, .22); color: #7ee2a8; }
.log-action.update { background: rgba(240, 185, 11, .2); color: #f5cf5b; }
.log-action.revoke { background: rgba(230, 74, 92, .22); color: #ff92a0; }
.log-text { color: var(--muted); word-break: break-word; }

.history-body { display: flex; flex-direction: column; gap: 8px; max-height: 56vh; overflow-y: auto; }
.history-row {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
}
.history-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.history-date { font-size: 11.5px; color: var(--muted); }
.history-by, .history-note { font-size: 12.5px; color: var(--muted); }
.history-note { margin-top: 3px; }
.mini-btn.danger { background: rgba(230, 74, 92, .2); }

/* ---------------------- Подгрузка истории и данные ------------------------ */
.load-older {
  align-self: center;
  margin: 4px auto 8px;
  padding: 7px 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--elevated);
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 600;
  transition: background .15s, border-color .15s;
}
.load-older:hover { background: var(--elevated-2); border-color: var(--accent); }
.load-older:disabled { opacity: .6; cursor: default; }

.data-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}
.data-cell {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
}
.data-cell-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.data-cell-title { font-size: 11px; color: var(--muted); margin-top: 3px; text-transform: uppercase; letter-spacing: .3px; }
a.mini-btn { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; color: var(--text); }

/* --------------------- Ответы, реакции, правка, удаление ------------------ */
.composer-box { display: flex; flex-direction: column; background: rgba(22, 32, 43, .92); backdrop-filter: blur(8px); border-top: 1px solid var(--line); }
html[data-theme="light"] .composer-box { background: rgba(255, 255, 255, .92); }
.composer-box .composer { border-top: none; background: transparent; backdrop-filter: none; }
.reply-box {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 14px 0;
  padding: 8px 12px;
  background: var(--elevated);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  animation: fade-in .15s ease;
}
.reply-icon { font-size: 15px; color: var(--accent); }
.reply-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.reply-label { font-size: 12px; font-weight: 700; color: var(--accent); }
.reply-text { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.msg-reply {
  border-left: 3px solid var(--accent-line);
  padding: 3px 0 3px 8px;
  margin-bottom: 5px;
  cursor: pointer;
  border-radius: 3px;
  background: rgba(127, 127, 127, .08);
}
.msg-reply-author { font-size: 11.5px; font-weight: 700; color: var(--accent); }
.msg-reply-text { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 320px; }
.msg.mine .msg-reply-text { color: var(--own-muted, rgba(255, 255, 255, .75)); }
.msg.mine .msg-reply-author { color: var(--own-text, #fff); }

.msg-reply-btn {
  align-self: center;
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  opacity: 0;
  transition: opacity .15s, background .15s;
}
.msg:hover .msg-reply-btn { opacity: 1; }
.msg-reply-btn:hover { background: var(--elevated); color: var(--accent); }

.msg-reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.msg.mine .msg-reactions { justify-content: flex-end; }
.reaction {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--line);
  background: var(--elevated);
  color: var(--text);
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 12.5px;
  transition: background .15s, border-color .15s;
}
.reaction:hover { background: var(--elevated-2); }
.reaction.mine { border-color: var(--accent); background: var(--accent-soft); }
.reaction-count { font-size: 11px; font-weight: 700; color: var(--muted); }
.reaction.mine .reaction-count { color: var(--accent); }

.msg.deleted .bubble { background: transparent; border: 1px dashed var(--line); box-shadow: none; }
.msg-deleted-bubble { min-width: 120px; }
.msg-deleted { font-size: 13px; font-style: italic; color: var(--muted-2); }
.msg.flash .bubble { animation: flash-msg 1.2s ease; }
@keyframes flash-msg {
  0%, 100% { box-shadow: 0 1px 2px rgba(0, 0, 0, .25); }
  30% { box-shadow: 0 0 0 3px var(--accent-line); }
}

.msg-menu {
  position: fixed;
  z-index: 250;
  min-width: 210px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 6px;
  box-shadow: var(--shadow);
  animation: modal-in .12s ease;
}
.menu-reactions { display: flex; gap: 4px; padding: 4px 4px 8px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.menu-emoji {
  flex: 1;
  border: none;
  background: var(--elevated);
  border-radius: 10px;
  font-size: 17px;
  padding: 6px 0;
  transition: transform .12s, background .15s;
}
.menu-emoji:hover { transform: scale(1.12); background: var(--elevated-2); }
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 9px 10px;
  border-radius: 9px;
  font-size: 13.5px;
  transition: background .15s;
}
.menu-item:hover { background: var(--elevated); }
.menu-item.danger { color: var(--danger); }
.menu-item.danger:hover { background: rgba(230, 74, 92, .14); }
.menu-icon { width: 18px; text-align: center; }

/* ---------------------- Стикеры и гифки в композере ---------------------- */
.media-picker {
  position: absolute;
  bottom: calc(100% - 4px);
  left: 14px;
  width: 360px;
  max-width: calc(100vw - 28px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 8px;
  box-shadow: var(--shadow);
  z-index: 21;
}
.media-tabs { margin-bottom: 8px; }
.media-body { max-height: 260px; overflow-y: auto; }
.media-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.media-item {
  border: none;
  background: transparent;
  border-radius: 10px;
  font-size: 26px;
  padding: 6px 0;
  cursor: pointer;
  transition: background .15s, transform .12s;
}
.media-item:hover { background: var(--elevated); transform: scale(1.08); }
.media-gif { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.media-gif img {
  width: 100%;
  border-radius: 10px;
  background: var(--elevated);
  cursor: pointer;
  transition: transform .15s;
}
.media-gif img:hover { transform: scale(1.04); }
.media-import { display: flex; gap: 6px; margin-top: 8px; }
.media-import input {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--elevated);
  border: 2px solid transparent;
  color: var(--text);
  font-size: 12.5px;
}
.media-import input:focus { border-color: var(--accent); }
.media-import .btn { margin-top: 0; width: auto; padding: 8px 12px; font-size: 13px; }

.msg-sticker { font-size: 64px; line-height: 1.05; user-select: none; }
.msg.sticker .bubble { background: transparent; box-shadow: none; padding: 0; }
.msg.sticker .msg-time { color: var(--muted-2); }
html.no-anim .msg-sticker { font-size: 64px; }

/* Поле с адресом в окне помощи по микрофону */
.code-field {
  width: 100%;
  margin-top: 8px;
  padding: 9px 11px;
  border-radius: 10px;
  background: var(--elevated);
  border: 1px solid var(--line);
  color: var(--accent);
  font-size: 13px;
  font-family: ui-monospace, Consolas, 'Courier New', monospace;
  text-align: center;
}
.code-field::placeholder { color: var(--muted-2); text-align: center; }
.au-name.mono { font-family: ui-monospace, Consolas, 'Courier New', monospace; letter-spacing: .5px; }
.admin-user-row.dim { opacity: .55; }

/* -------------------------- ЗБТ: экран с кодом --------------------------- */
.access-gate .modal-box { text-align: center; max-width: 420px; }
.access-logo { font-size: 56px; line-height: 1.1; margin-bottom: 6px; }
.access-gate h2 { margin-bottom: 8px; }
.access-who { margin: 10px 0; font-size: 13px; color: var(--muted); }
.access-gate .btn { width: 100%; margin-top: 10px; }
.access-gate .code-field { font-size: 18px; letter-spacing: 3px; text-transform: uppercase; padding: 12px; }

/* Строка с галочкой (настройки ЗБТ и прочее) */
.check-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 4px;
  font-size: 13.5px;
  color: var(--text);
  cursor: pointer;
}
.check-row input { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }
.check-row span { line-height: 1.35; }


/* ------------------------- Боксы и коллекция ----------------------------- */
.box-block { display: flex; gap: 14px; align-items: center; background: var(--panel-2); border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin-bottom: 10px; }
.box-visual { font-size: 54px; line-height: 1; transition: transform .2s; }
.box-visual.shaking { animation: boxShake .18s linear infinite; }
@keyframes boxShake {
  0% { transform: rotate(-9deg) scale(1); }
  50% { transform: rotate(9deg) scale(1.08); }
  100% { transform: rotate(-9deg) scale(1); }
}
.box-info { flex: 1; min-width: 0; }
.box-price { font-size: 14px; margin-bottom: 4px; }
.box-price b { color: var(--gold); }
.box-rarities { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.rarity-chip { font-size: 10.5px; padding: 2px 7px; border-radius: 8px; background: var(--elevated); color: var(--muted); }
.rarity-chip.rarity-common { color: #9fb3c0; }
.rarity-chip.rarity-rare { color: #4fc3f7; }
.rarity-chip.rarity-epic { color: #d47bff; }
.rarity-chip.rarity-legendary { color: var(--gold); }
.box-reveal { display: flex; flex-direction: column; align-items: center; gap: 8px; margin: 10px 0; }
.box-result { font-size: 13.5px; font-weight: 600; }
.box-result.rarity-legendary { color: var(--gold); }
.box-result.rarity-epic { color: #d47bff; }
.box-result.rarity-rare { color: #4fc3f7; }
.items-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.item-card { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 4px; border-radius: 14px; border: 2px solid transparent; background: transparent; }
.item-card.rarity-common { border-color: rgba(143, 179, 199, .5); }
.item-card.rarity-rare { border-color: #4fc3f7; box-shadow: 0 0 10px rgba(79, 195, 247, .35); }
.item-card.rarity-epic { border-color: #d47bff; box-shadow: 0 0 10px rgba(212, 123, 255, .35); }
.item-card.rarity-legendary { border-color: var(--gold); box-shadow: 0 0 12px rgba(255, 214, 80, .45); }
.item-card svg { display: block; border-radius: 14px; }
/* Картинки подарков */
.gift-img { width: 56px; height: 56px; border-radius: 14px; display: block; flex: 0 0 auto; }
.gift-img-fallback { display: flex; align-items: center; justify-content: center; font-size: 30px; }
.gift-chip-img { width: 34px; height: 34px; border-radius: 10px; display: block; }
.celebrate-img { width: 132px; height: 132px; border-radius: 24px; display: block; }
.shop-card-art { display: flex; justify-content: center; margin-bottom: 4px; }
.shop-card-img { width: 76px; height: 76px; border-radius: 18px; display: block; transition: transform .16s ease; }
.shop-card:hover .shop-card-img { transform: scale(1.06) rotate(-2deg); }
.gift-card .gift-img { box-shadow: 0 6px 18px rgba(0, 0, 0, .35); }
.item-label { font-size: 11px; color: var(--muted); max-width: 92px; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.items-row { margin: 8px 0 12px; }

/* ==================== Подарки: карточки, редкости, праздник =============== */
.gift-card {
  position: relative;
  display: flex;
  gap: 12px;
  align-items: center;
  min-width: 230px;
  max-width: 100%;
  margin-top: 4px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: linear-gradient(140deg, rgba(255, 255, 255, .08), rgba(255, 255, 255, .02));
  overflow: hidden;
  cursor: pointer;
  transition: transform .16s ease, box-shadow .16s ease;
}
.gift-card:hover { transform: translateY(-2px); }
.gift-glow { position: absolute; inset: -40% -10% auto -10%; height: 120%; opacity: .28; filter: blur(22px); pointer-events: none; }
.gift-emoji { font-size: 40px; line-height: 1; position: relative; z-index: 1; animation: gift-pop .5s ease; }
.gift-emoji.big { font-size: 70px; }
.gift-body { position: relative; z-index: 1; min-width: 0; }
.gift-name { font-size: 15px; font-weight: 600; }
.gift-rarity { font-size: 12px; color: var(--muted); }
.gift-from { font-size: 12px; color: var(--accent); margin-top: 2px; }
.gift-uid { font-size: 10.5px; color: var(--muted); font-family: ui-monospace, Consolas, monospace; margin-top: 2px; }
@keyframes gift-pop {
  0% { transform: scale(.4) rotate(-18deg); opacity: 0; }
  60% { transform: scale(1.15) rotate(6deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); }
}
.rarity-common { border-color: #6b7c8c; }
.rarity-common .gift-glow { background: #6b7c8c; }
.rarity-uncommon { border-color: #3ecf8e; }
.rarity-uncommon .gift-glow { background: #3ecf8e; }
.rarity-rare { border-color: #3aa0ff; box-shadow: 0 0 0 1px rgba(58, 160, 255, .35); }
.rarity-rare .gift-glow { background: #3aa0ff; }
.rarity-epic { border-color: #a06bff; box-shadow: 0 0 0 1px rgba(160, 107, 255, .4); }
.rarity-epic .gift-glow { background: #a06bff; }
.rarity-legendary { border-color: #ffb340; box-shadow: 0 0 14px rgba(255, 179, 64, .35); }
.rarity-legendary .gift-glow { background: #ffb340; }
.rarity-mythic {
  border-color: #ff5fa2;
  box-shadow: 0 0 18px rgba(255, 95, 162, .45);
  animation: mythic-shine 2.4s linear infinite;
}
.rarity-mythic .gift-glow { background: linear-gradient(90deg, #ff5fa2, #ffd166, #7b61ff); }
@keyframes mythic-shine {
  0% { box-shadow: 0 0 12px rgba(255, 95, 162, .35); }
  50% { box-shadow: 0 0 22px rgba(123, 97, 255, .55); }
  100% { box-shadow: 0 0 12px rgba(255, 95, 162, .35); }
}
.celebrate-layer { position: fixed; inset: 0; z-index: 90; pointer-events: none; overflow: hidden; transition: opacity .6s ease; }
.celebrate-layer.fade-out { opacity: 0; }
.confetti { position: absolute; top: -14px; width: 9px; height: 14px; border-radius: 2px; animation: confetti-fall 2s linear forwards; }
@keyframes confetti-fall {
  0% { transform: translateY(-20px) rotate(0); opacity: 1; }
  100% { transform: translateY(105vh) rotate(520deg); opacity: .1; }
}
.celebrate-card {
  position: absolute;
  left: 50%;
  top: 34%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 22px 30px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: rgba(14, 22, 30, .92);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
  animation: celebrate-in .6s ease;
}
@keyframes celebrate-in {
  0% { transform: translate(-50%, -50%) scale(.6); opacity: 0; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}
.celebrate-title { font-size: 18px; font-weight: 700; }
.celebrate-sub { font-size: 13px; color: var(--muted); }
.gift-summary { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.gift-chip-mini { padding: 3px 9px; border-radius: 10px; font-size: 11.5px; border: 1px solid var(--line); background: var(--elevated); }
.gift-chip-mini.rarity-mythic { border-color: #ff5fa2; color: #ff9ec4; }
.gift-chip-mini.rarity-legendary { border-color: #ffb340; color: #ffd191; }
.gift-chip-mini.rarity-epic { border-color: #a06bff; color: #c9aaff; }
.gift-chip-mini.rarity-rare { border-color: #3aa0ff; color: #9ad0ff; }
.gift-chip-mini.total { border-color: var(--accent); color: var(--accent); }
.gift-row { display: flex; flex-wrap: wrap; gap: 6px; }
.birthday-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: linear-gradient(90deg, rgba(255, 179, 64, .18), rgba(255, 95, 162, .18));
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.birthday-banner .bb-text { flex: 1; }

/* ==================== Живость интерфейса ================================= */
.msg { animation: msg-in .18s ease; }
@keyframes msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
.btn, .icon-btn, .attach-btn, .call-btn, .mini-btn, .tab, .chip { transition: transform .12s ease, background .15s ease, border-color .15s ease, color .15s ease; }
.btn:active, .icon-btn:active, .call-btn:active, .mini-btn:active { transform: scale(.94); }
.modal:not(.hidden) .modal-box { animation: modal-in .2s ease; }
@keyframes modal-in {
  from { opacity: 0; transform: translateY(10px) scale(.98); }
  to { opacity: 1; transform: none; }
}
.unread-badge { animation: badge-pop .3s ease; }
@keyframes badge-pop {
  0% { transform: scale(.5); }
  70% { transform: scale(1.15); }
  100% { transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .msg, .modal:not(.hidden) .modal-box, .unread-badge, .gift-emoji, .confetti { animation: none !important; }
  .messages { scroll-behavior: auto; }
}

/* ==================== Свои плееры: голос и видео ========================== */
/* Голосовое сообщение */
.ap {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 210px;
  max-width: 100%;
  padding: 6px 10px 6px 6px;
  border-radius: 14px;
  background: rgba(255, 255, 255, .06);
}
.ap-play {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ap-play:active { transform: scale(.94); }
.ap-bar {
  flex: 1 1 auto;
  height: 6px;
  min-width: 60px;
  border-radius: 4px;
  background: rgba(255, 255, 255, .18);
  cursor: pointer;
  overflow: hidden;
}
.ap-fill { height: 100%; width: 0; background: var(--accent); border-radius: 4px; }
.ap-time { flex: 0 0 auto; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* Видеосообщение */
.vp { position: relative; max-width: 100%; margin-top: 4px; }
.vp-video {
  display: block;
  width: 100%;
  max-width: 320px;
  max-height: 260px;
  border-radius: 14px;
  background: #05090d;
}
.vp-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  max-width: 320px;
}
.vp-play {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.vp-bar { flex: 1 1 auto; height: 5px; border-radius: 4px; background: rgba(255, 255, 255, .18); cursor: pointer; overflow: hidden; }
.vp-fill { height: 100%; width: 0; background: var(--accent); border-radius: 4px; }
.vp-time { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.vp-full { flex: 0 0 auto; border: none; background: transparent; color: var(--muted); font-size: 15px; }

/* Кружок (видеосообщение-кружок, как в Telegram) */
.vp-round {
  width: 200px;
  height: 200px;
  max-width: 62vw;
  max-height: 62vw;
  border-radius: 50%;
  overflow: hidden;
  position: relative;
  --ring: 0%;
  background: #05090d;
  flex: 0 0 auto;
}
.vp-round .vp-video {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  border-radius: 50%;
  object-fit: cover;
}
.vp-round .vp-play {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 54px;
  height: 54px;
  font-size: 18px;
  background: rgba(0, 0, 0, .45);
  backdrop-filter: blur(4px);
}
.vp-round .vp-play.hidden { display: none; }
.vp-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  pointer-events: none;
  z-index: 2;
  background: conic-gradient(var(--accent) var(--ring), transparent var(--ring));
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3px));
}

/* Реакции: компактно под сообщением, как в Telegram */
.msg-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 5px;
  justify-content: flex-start;
}
.msg.mine .msg-reactions { justify-content: flex-end; }
.reaction {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  border-radius: 10px;
  background: rgba(255, 255, 255, .09);
  border: 1px solid transparent;
  font-size: 12.5px;
  line-height: 1.5;
  cursor: pointer;
}
.reaction.mine { background: var(--accent-soft); border-color: var(--accent); }
.reaction-count { font-size: 11px; color: var(--muted); }
.reaction.mine .reaction-count { color: var(--accent); }

/* Панель записи: превью камеры и кнопки */
.recording-bar { flex-direction: column; align-items: stretch; height: auto; padding: 8px; }
.recording-bar.video { background: var(--elevated-2); }
.rec-preview {
  width: 100%;
  max-height: 220px;
  border-radius: 12px;
  background: #05090d;
  object-fit: cover;
  margin-bottom: 8px;
  transform: none;
}
.rec-preview.rear { transform: none; }
.rec-row { display: flex; align-items: center; gap: 8px; }
.rec-row .btn:first-of-type { margin-left: auto; }

/* ==================== Рамки и мобильная раскладка ========================= */
*, *::before, *::after { box-sizing: border-box; }
img, video, canvas, audio { max-width: 100%; }
.msg, .bubble, .admin-user-row, .modal-box, .settings-group { max-width: 100%; }
.modal-box { overflow-wrap: anywhere; }
.bubble { min-width: 0; overflow-wrap: anywhere; word-break: break-word; }
.chat, .messages, .sidebar { overflow-x: hidden; }
/* Панели загрузки и записи позиционируются относительно поля ввода */
.composer { position: relative; }
.composer textarea { flex: 1 1 auto; min-width: 0; }
/* Меню вложений (телефон): фото/файл, голосовое, кружок */
.attach-sheet {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: calc(100% + 8px);
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  padding: 10px;
  border-radius: 16px;
  background: var(--elevated-2);
  border: 1px solid var(--line);
  box-shadow: 0 12px 32px rgba(0, 0, 0, .35);
}
.sheet-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 10px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--elevated);
  color: var(--text);
  font-size: 13.5px;
}
.sheet-item:active { transform: scale(.97); }
.sheet-ico { font-size: 19px; }
#attach-any { display: none; }

@media (max-width: 768px) {
  .vp-video { max-width: 100%; }
  .vp-controls { max-width: 100%; }
  .ap { min-width: 0; width: 100%; }
  .vp-round { width: 170px; height: 170px; }
  .bubble { max-width: calc(100vw - 76px); }
  .modal-box { width: calc(100vw - 20px); max-width: none; padding: 14px; }

  /* Ничего не должно вылезать за экран по горизонтали */
  html, body { overflow-x: hidden; max-width: 100%; }

  /* --- Поле ввода: кнопки отдельной строкой, все видимые --- */
  .composer {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px;
    padding: 8px;
    align-items: center;
  }
  .composer-tools {
    display: flex;
    grid-column: 1 / -1;
    gap: 4px;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 2px;
  }
  .composer-tools::-webkit-scrollbar { display: none; }
  #photo-btn, #voice-btn, #video-msg-btn, #attach-any { display: flex; }
  .attach-btn { width: 38px; height: 38px; font-size: 18px; flex: 0 0 auto; }
  .composer textarea { grid-column: 1; min-width: 0; font-size: 15px; padding: 10px 12px; }
  .send-btn { grid-column: 2; flex: 0 0 auto; width: 42px; height: 42px; }
  #emoji-picker, #media-picker, #attach-sheet { max-height: 52vh; overflow-y: auto; }
  .rec-preview { max-height: 180px; }
  .ap-time, .vp-time { font-size: 11px; }

  /* --- Навигация: кнопки-значки, все четыре помещаются --- */
  .nav-actions { gap: 4px; padding: 6px 8px; }
  .side-btn {
    flex: 1 1 0;
    min-width: 0;
    padding: 9px 2px;
    font-size: 20px;
    gap: 0;
  }
  .side-btn span { display: none; }
  .side-btn::after { content: none; }

  /* --- Шапка чата: иконки компактнее, название сжимается --- */
  .chat-header { gap: 4px; padding: 6px 8px; }
  .icon-btn { width: 34px; height: 34px; font-size: 15px; }
  .chat-peer { min-width: 0; flex: 1 1 auto; overflow: hidden; }
  .chat-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .chat-actions { flex: 0 0 auto; gap: 2px; }
}

/* Очень узкие экраны: уменьшаем значки, но ничего не прячем */
@media (max-width: 380px) {
  .attach-btn { width: 34px; height: 34px; font-size: 16px; }
  .side-btn { font-size: 18px; }
  .icon-btn { width: 32px; height: 32px; font-size: 14px; }
  .composer { padding: 6px; gap: 4px; }
}
.msg-audio { max-width: 240px; height: 40px; display: block; margin-top: 4px; }
.msg-video { max-width: 320px; max-height: 240px; border-radius: 12px; display: block; margin-top: 4px; background: #05090d; }
.msg-file {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 6px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--elevated);
  border: 1px solid var(--line);
  color: var(--text);
  text-decoration: none;
  max-width: 280px;
}
.msg-file:hover { border-color: var(--accent); }
/* Кнопка скачивания у вложения */
.msg-file-dl {
  margin-left: auto;
  padding-left: 8px;
  font-size: 17px;
  color: var(--accent);
  flex: 0 0 auto;
}
.ap-dl, .vp-dl, .vp-round-dl {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--elevated-2);
  color: var(--text);
  font-size: 14px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .12s;
}
.ap-dl:hover, .vp-dl:hover, .vp-round-dl:hover { border-color: var(--accent); background: var(--accent-soft); }
.ap-dl:active, .vp-dl:active, .vp-round-dl:active { transform: scale(.9); }
.vp-round-dl {
  position: absolute;
  right: 8px;
  bottom: 8px;
  z-index: 3;
  background: rgba(10, 16, 22, .75);
  backdrop-filter: blur(4px);
}
.msg-file-icon { font-size: 22px; }
.msg-file-body { display: flex; flex-direction: column; overflow: hidden; }
.msg-file-name { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-file-size { font-size: 11.5px; color: var(--muted); }
.msg-forward { font-size: 12px; color: var(--accent); margin-bottom: 4px; }
.upload-bar, .recording-bar {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: calc(100% + 8px);
  height: 34px;
  border-radius: 12px;
  background: var(--elevated-2);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  overflow: hidden;
  z-index: 5;
}
.upload-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: var(--accent-soft); transition: width .2s; }
.upload-text { position: relative; padding: 0 12px; font-size: 12.5px; }
.recording-bar { gap: 10px; padding: 0 12px; justify-content: flex-start; }
.recording-bar .btn { margin-left: auto; }
.recording-bar .btn + .btn { margin-left: 6px; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: rec-blink 1s infinite; }@keyframes rec-blink { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
.pin-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--elevated);
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.pin-body { flex: 1; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-flash { animation: msg-flash 1.4s ease; }
@keyframes msg-flash { 0%, 100% { background: transparent; } 40% { background: var(--accent-soft); } }
.outbox-badge {
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--elevated-2);
  font-size: 11.5px;
  color: var(--warn, #e0a83a);
}
.invite-link { display: flex; gap: 8px; margin: 12px 0; align-items: center; }
.invite-link input { flex: 1; }
.empty-row { padding: 14px; text-align: center; color: var(--muted); font-size: 13px; }
.mini-btn.danger { color: var(--danger); }
.inv-chip, .use-chip { font-weight: 600; }
.pin-icon { font-size: 15px; }
.session-current { border-color: var(--ok); }
.session-online { border-left: 3px solid var(--ok); }
.session-summary { border-left: 3px solid var(--accent); }
.sessions-anchor { display: block; }
.admin-search { width: 100%; margin-bottom: 8px; padding: 9px 11px; border-radius: 10px; border: 1px solid var(--line); background: var(--elevated); color: var(--text); }
.ci-actions { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.ci-actions .admin-search { margin-bottom: 0; flex: 1 1 180px; }
/* QR-код приглашения: всегда на белом фоне, иначе сканер не прочитает */
.qr-box { display: flex; flex-direction: column; align-items: center; gap: 8px; margin: 10px 0; }
.qr-holder { width: 190px; height: 190px; background: #fff; border-radius: 14px; padding: 8px; }
.qr-svg { width: 100%; height: 100%; display: block; }
/* Опрос */
.poll { min-width: 220px; max-width: 100%; margin-top: 4px; }
.poll-question { font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.poll-row {
  position: relative;
  display: block;
  width: 100%;
  text-align: left;
  margin-bottom: 5px;
  padding: 7px 9px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  overflow: hidden;
  cursor: pointer;
}
.poll-row.mine { border-color: var(--accent); }
.poll-fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent-soft); transition: width .25s; }
.poll-text { position: relative; display: flex; justify-content: space-between; gap: 10px; font-size: 13px; }
.poll-count { color: var(--muted); font-size: 12px; }
.poll-total { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.poll-option-row { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.poll-option-row .poll-input { flex: 1; }
.poll-input { width: 100%; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--elevated); color: var(--text); }
.poll-label { position: relative; }
.rep-chip { font-weight: 600; }
.admin-user-row .mini-btn + .au-sub { display: none; }
@media (max-width: 768px) { .admin-user-row .au-sub { font-size: 11.5px; } }

/* ------------------------ Группы и каналы -------------------------------- */
.mod-act.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.chip.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.mod-field { margin-top: 12px; }
.mod-field > label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.mod-field input { width: 100%; margin-top: 8px; }
.admin-chat-row { cursor: pointer; }
.rules-editor {
  width: 100%;
  min-height: 160px;
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--elevated);
  border: 1px solid var(--line);
  color: var(--text);
  font-family: ui-monospace, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.5;
  resize: vertical;
}
.rules-editor:focus { border-color: var(--accent); outline: none; }
/* Метка «только для владельца»: такие вкладки прячутся, если ты не владелец */
.owner-only.hidden { display: none !important; }
.ban-chip { font-weight: 600; }
.admin-chat-row.active { border-color: var(--accent); background: var(--accent-soft); }
.admin-split { display: grid; grid-template-columns: 300px 1fr; gap: 12px; min-height: 300px; }
.admin-split .admin-users-list { max-height: 420px; overflow-y: auto; }
.admin-chat-view { max-height: 420px; overflow-y: auto; padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2); }
.admin-msg { padding: 6px 8px; border-radius: 10px; margin-bottom: 6px; background: var(--elevated); }
.admin-msg-head { font-size: 11.5px; color: var(--muted); margin-bottom: 3px; }
.admin-msg-text { font-size: 13.5px; white-space: pre-wrap; word-break: break-word; }
.admin-msg.deleted .admin-msg-text { opacity: .5; font-style: italic; }
.admin-msg-image { max-width: 140px; border-radius: 8px; margin-top: 4px; display: block; }
@media (max-width: 768px) { .admin-split { grid-template-columns: 1fr; } }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12.5px;
}
.chip-x {
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 13px;
  padding: 0;
  line-height: 1;
}
.search-results-inline {
  position: static;
  margin-top: 4px;
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}
.search-results-inline:empty { display: none; }
.ci-actions { display: flex; gap: 8px; margin-top: 12px; }
.ci-actions .btn { flex: 1; margin-top: 0; }

/* --------------------------------- Игры ---------------------------------- */
.games-balance { text-align: center; font-size: 14px; color: var(--muted); margin-bottom: 12px; }
.games-balance b { color: var(--gold); font-size: 18px; }
.games-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.game-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 6px;
  border: 2px solid transparent;
  border-radius: 14px;
  background: var(--elevated);
  color: var(--text);
  transition: transform .15s, border-color .15s, background .15s;
}
.game-card:hover { transform: translateY(-2px); background: var(--elevated-2); }
.game-card.active { border-color: var(--accent); background: var(--accent-soft); }
.game-card-icon { font-size: 26px; }
.game-card-title { font-size: 12px; text-align: center; line-height: 1.25; }
.game-stage { background: var(--panel-2); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 12px; }
.game-vs { display: flex; align-items: center; justify-content: center; gap: 14px; }
.game-side { flex: 1; text-align: center; min-width: 0; }
.game-role { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; }
.game-move { font-size: 22px; font-weight: 700; margin-top: 4px; }
.game-vs-mark { font-size: 13px; font-weight: 700; color: var(--muted-2); }
.game-result { text-align: center; font-size: 15px; font-weight: 700; min-height: 22px; margin: 10px 0 4px; }
.game-result.win { color: var(--ok); }
.game-result.lose { color: var(--danger); }
.game-result.draw { color: var(--muted); }
.game-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 8px; }
.game-actions .btn { margin-top: 0; flex: 0 1 auto; min-width: 120px; }
@media (max-width: 768px) {
  .games-grid { gap: 6px; }
  .game-card { padding: 10px 4px; }
  .game-card-icon { font-size: 22px; }
  .game-move { font-size: 18px; }
}

/* Гонки и очко: игровое поле внутри окна игр */
.game-session { margin: 6px 0 4px; }
.race-round { text-align: center; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; margin-bottom: 8px; }
.race-lane { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.race-icon { font-size: 18px; }
.race-track { flex: 1; height: 12px; background: var(--elevated); border-radius: 8px; overflow: hidden; }
.race-track i { display: block; height: 100%; border-radius: 8px; transition: width .35s ease; }
.race-lane.player .race-track i { background: linear-gradient(90deg, var(--accent), var(--accent-dark)); }
.race-lane.bot .race-track i { background: linear-gradient(90deg, var(--danger), #b03a48); }
.race-lane b { width: 28px; text-align: right; font-size: 13px; }
.race-log { margin-top: 8px; font-size: 11.5px; color: var(--muted-2); text-align: center; }
.bj-row { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin: 6px 0 4px; }
.bj-label { color: var(--muted); }
.bj-value { color: var(--accent); font-weight: 700; }
.bj-hand { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.card {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 52px;
  border-radius: 8px;
  background: #f7fafc;
  color: #16202b;
  font-weight: 700;
  box-shadow: var(--shadow-soft);
}
.card.red { color: #d3304a; }
.card-rank { font-size: 15px; line-height: 1; }
.card-suit { font-size: 14px; line-height: 1; }

@media (max-width: 768px) {
  .card { width: 32px; height: 44px; }
  .card-rank { font-size: 13px; }
}

/* =============================== Мобильный =============================== */
@media (max-width: 768px) {
  :root { --sidebar-width: 100%; }

  .auth-card { width: 100%; padding: 22px 18px; }
  .auth-card h1 { font-size: 21px; }
  .auth-logo { font-size: 40px; }
  input, textarea, select { font-size: 16px; }

  .app { position: relative; }
  .sidebar { width: 100%; min-width: 0; height: 100dvh; }
  .chat {
    position: absolute;
    inset: 0;
    z-index: 8;
    height: 100dvh;
    transform: translateX(100%);
    transition: transform .26s cubic-bezier(.4, 0, .2, 1);
    will-change: transform;
  }
  .app.chat-open .chat { transform: translateX(0); }
  .back-btn { display: block; }

  .messages { padding: 12px 10px 4px; }
  .msg { max-width: 86%; }
  .msg-image { max-height: 260px; }
  .msg-copy { opacity: 1; background: rgba(0, 0, 0, .3); }
  .composer { padding: 8px; gap: 6px; }
  .composer textarea { padding: 10px 12px; }
  .attach-btn { width: 38px; height: 38px; font-size: 18px; }
  .send-btn { width: 40px; height: 40px; }
  .emoji-picker { left: 8px; right: 8px; width: auto; grid-template-columns: repeat(7, 1fr); max-height: 42vh; }
  .scroll-bottom { right: 12px; bottom: 124px; }

  .modal { padding: 0; align-items: flex-end; }
  .modal-box {
    width: 100%;
    max-width: 100%;
    border-radius: 18px 18px 0 0;
    max-height: 94dvh;
    padding: 18px 16px 22px;
  }
  .modal-box.narrow, .modal-box.wide, .modal-box.tiny { width: 100%; }
  .toasts { left: 12px; right: 12px; top: 12px; max-width: none; }
  .mod-grid { grid-template-columns: repeat(2, 1fr); }
  .shop-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); max-height: 40vh; }
  .admin-users-list { max-height: 40vh; }
  .call-btn { width: 54px; height: 54px; }
  .image-viewer { padding: 56px 10px 10px; }
}

@media (min-width: 769px) and (max-width: 1024px) {
  html:not([style*="--sidebar-width"]) { --sidebar-width: 270px; }
}

/* =============================================================================
   КАСТОМИЗАЦИЯ: светлая тема, плотность, обои, новые компоненты
   ========================================================================== */

/* ------------------------------- Светлая тема ----------------------------- */
html[data-theme="light"] {
  --bg: #eef2f7;
  --panel: #ffffff;
  --panel-2: #f3f7fb;
  --elevated: #e9eff6;
  --elevated-2: #dbe4ee;
  --line: #dbe3ec;
  --text: #12202c;
  --muted: #61748a;
  --muted-2: #8595a8;
  --hover: rgba(18, 32, 44, .05);
  --shadow: 0 18px 50px rgba(23, 43, 63, .18);
  --shadow-soft: 0 4px 16px rgba(23, 43, 63, .12);
  --scroll-thumb: #c9d5e2;
  --purple: #7c4ceb;
}
html[data-theme="light"] .chat-header,
html[data-theme="light"] .composer,
html[data-theme="light"] .sidebar-foot { background: rgba(255, 255, 255, .92); }
html[data-theme="light"] .modal { background: rgba(24, 40, 56, .38); }
html[data-theme="light"] .toast { box-shadow: var(--shadow-soft); }
html[data-theme="light"] .system { background: rgba(18, 32, 44, .07); color: #51667c; }
html[data-theme="light"] .day-sep span { background: rgba(18, 32, 44, .07); color: var(--muted); }
html[data-theme="light"] .msg-copy { background: rgba(255, 255, 255, .75); }
html[data-theme="light"] .auth-screen {
  background:
    radial-gradient(circle at 15% 15%, var(--accent-soft), transparent 45%),
    radial-gradient(circle at 85% 80%, rgba(139, 92, 246, .16), transparent 45%),
    linear-gradient(160deg, #dfe9f4, #eef2f7 60%);
}
html[data-theme="light"] .auth-card { background: rgba(255, 255, 255, .95); }
html[data-theme="light"] .modal-box input,
html[data-theme="light"] .modal-box textarea,
html[data-theme="light"] .modal-box select { background: var(--elevated); color: var(--text); }
html[data-theme="light"] .image-viewer { background: rgba(12, 20, 28, .88); }
html[data-theme="light"] .video-remote,
html[data-theme="light"] .video-local { background: #101a24; }
html[data-theme="light"] .tag.perm { background: var(--accent-soft); color: #1b6f9c; }

/* -------------------------------- Плотность ------------------------------- */
html[data-density="compact"] .chat-item { padding: 6px 12px; }
html[data-density="compact"] .chat-item .avatar,
html[data-density="compact"] .chat-icon { width: 38px; height: 38px; font-size: 15px; }
html[data-density="compact"] .sidebar-scroll .section { padding: 3px 0; }
html[data-density="compact"] .me-header { padding: 9px 12px; }
html[data-density="compact"] .messages { padding: 12px 14px 4px; gap: 3px; }
html[data-density="compact"] .bubble { padding: 6px 10px 4px; }
html[data-density="compact"] .msg-avatar { width: 28px; height: 28px; font-size: 12px; }
html[data-density="compact"] .msg { gap: 6px; }
html[data-density="compact"] .composer { padding: 8px 12px 10px; }
html[data-density="compact"] .side-btn { padding: 6px 4px; }

/* ------------------------- Отключение анимаций и аватаров ------------------ */
html.no-anim *, html.no-anim *::before, html.no-anim *::after {
  animation-duration: .001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: .001ms !important;
}
html.no-anim .messages { scroll-behavior: auto; }
html.no-avatars .msg-avatar,
html.no-avatars .preview-avatar { display: none; }

/* ------------------------------ Поиск по чату ----------------------------- */
.chat-search {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  animation: fade-in .15s ease;
}
.chat-search .search-ico { font-size: 13px; opacity: .7; }
.chat-search input {
  flex: 1;
  min-width: 0;
  padding: 8px 12px;
  border-radius: 18px;
  background: var(--elevated);
  border: 2px solid transparent;
  color: var(--text);
  font-size: 13.5px;
}
.chat-search input:focus { border-color: var(--accent); }
.chat-search-count { font-size: 12px; color: var(--muted); min-width: 46px; text-align: right; }
.icon-btn.mini { font-size: 13px; padding: 5px 7px; }
.icon-btn.active { color: var(--accent); background: var(--accent-soft); }
.chat-item.pinned .chat-title::after { content: ' 📌'; font-size: 11px; }
.online-dot.inline { position: static; box-shadow: none; width: 8px; height: 8px; }
.search-info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.reason-chip, .silver-chip { font-size: 11.5px; padding: 5px 10px; }

/* ----------------------------- Палитра команд ----------------------------- */
#palette-modal { align-items: flex-start; padding-top: 9vh; }
.palette-box {
  width: 620px;
  max-width: 100%;
  padding: 0;
  overflow: hidden;
  border-radius: 16px;
}
.palette-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.palette-input-row .search-ico { font-size: 16px; color: var(--accent); }
.palette-input-row input {
  flex: 1;
  min-width: 0;
  border: none !important;
  background: transparent !important;
  color: var(--text);
  font-size: 16px;
  padding: 2px;
  outline: none;
}
.palette-input-row kbd {
  background: var(--elevated);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 11px;
  color: var(--muted);
}
.palette-list { max-height: 52vh; overflow-y: auto; padding: 6px; }
.palette-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 10px;
  cursor: pointer;
}
.palette-item.active { background: var(--accent-soft); }
.palette-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.palette-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.palette-title { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette-empty { padding: 20px; text-align: center; color: var(--muted); font-size: 14px; }
.palette-foot {
  padding: 8px 14px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--muted-2);
  text-align: center;
}

/* ------------------------------- Оформление ------------------------------- */
.appearance-layout { display: grid; grid-template-columns: 1fr 300px; gap: 20px; }
.appearance-controls { min-width: 0; }
.appearance-preview { min-width: 0; }
.settings-group.first { margin-top: 0; border-top: none; padding-top: 0; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.swatch {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
  transition: transform .15s ease, border-color .15s ease;
}
.swatch:hover { transform: scale(1.1); }
.swatch.active { border-color: var(--text); }
.range-row { display: flex; align-items: center; gap: 10px; padding: 8px 2px; font-size: 13.5px; }
.range-row span { width: 148px; color: var(--text); }
.range-row input[type="range"] { flex: 1; min-width: 0; accent-color: var(--accent); }
.range-row b { width: 36px; text-align: right; color: var(--accent); font-variant-numeric: tabular-nums; }
input[type="color"] {
  width: 52px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--elevated);
  cursor: pointer;
}
.appearance-actions { margin-top: 18px; }
.ui-version { margin-top: 10px; font-size: 11.5px; color: var(--muted-2); text-align: center; }
.preview-chat {
  background-color: var(--bg);
  background-image: radial-gradient(circle at 20% 0%, var(--accent-soft), transparent 45%);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 170px;
}
.preview-msg { display: flex; gap: 8px; align-items: flex-end; }
.preview-msg.mine { justify-content: flex-end; }
.preview-msg .bubble { background: var(--panel-2); color: var(--text); }
.preview-msg.mine .bubble { background: var(--own-bubble); color: var(--own-text); }
.preview-msg .msg-author { font-size: 12px; font-weight: 600; color: var(--accent); margin-bottom: 2px; }
.preview-msg .msg-text { font-size: var(--msg-font-size); }
.preview-msg .msg-time { font-size: 10.5px; color: var(--muted); text-align: right; margin-top: 3px; }
.preview-avatar { width: 30px; height: 30px; font-size: 13px; }

@media (max-width: 980px) {
  .appearance-layout { grid-template-columns: 1fr; gap: 14px; }
  .preview-chat { min-height: 130px; }
}
@media (max-width: 768px) {
  #palette-modal { align-items: flex-end; padding-top: 0; }
  .palette-box { width: 100%; border-radius: 18px 18px 0 0; max-height: 84dvh; }
  .palette-list { max-height: 46vh; }
  .palette-foot { display: none; }
  .range-row span { width: 118px; font-size: 12.5px; }
  .swatch { width: 28px; height: 28px; }
  .chat-search { padding: 6px 8px; gap: 4px; }
  .chat-search input { font-size: 13px; }
  .chat-search-count { min-width: 38px; }
}

/* ------------- Аккуратность на телефоне: настройки, игры, статусы -------------
   Мелкие кнопки на телефоне трудно нажимать, а длинные подписи ломали строки. */
@media (max-width: 768px) {
  /* Настройки: разделы выше и просторнее, содержимое не липнет к краям */
  .set-nav { padding-bottom: 6px; scroll-padding: 0 6px; }
  .set-tab { min-height: 38px; padding: 9px 13px; }
  .set-body { padding-left: 2px; padding-right: 2px; }
  .set-pane { gap: 10px; }
  .set-pane .btn, .set-pane button { min-height: 40px; }
  .settings-title { margin: 12px 0 6px; }
  .row, .field-row, .settings-row { flex-wrap: wrap; }
  /* Игры: карточки и кнопки крупнее, подписи переносятся по словам */
  .games-grid { gap: 8px; }
  .game-card { min-height: 74px; padding: 10px 6px; }
  .game-card-title { font-size: 12.5px; overflow-wrap: anywhere; }
  .game-actions .btn { flex: 1 1 46%; min-width: 0; min-height: 40px; }
  .game-vs { gap: 8px; }
  .game-move { font-size: 19px; }
  .games-balance { font-size: 13.5px; }
}
@media (max-width: 420px) {
  .games-grid { grid-template-columns: repeat(2, 1fr); }
  .game-vs { gap: 6px; }
  .game-role { font-size: 11.5px; }
  .game-move { font-size: 17px; }
  .game-actions .btn { flex: 1 1 100%; }
}
