/* ==================== ПЕРЕМЕННЫЕ ==================== */
:root {
  --bg-main: #000000;
  --bg-panel: #0a0a0a;
  --bg-elevated: #101010;
  --bg-input: #060606;
  --bg-hover: #161616;
  --bg-active: #1f1f1f;
  --bg-bubble-out: #1c1c1c;
  --bg-bubble-in: #0d0d0d;

  --text-main: #d4d4d4;
  --text-muted: #5a5a5a;
  --text-bright: #ffffff;

  --border-color: #1a1a1a;
  --border-bright: #262626;

  --accent-color: #ffffff;
  --accent-rgb: 255, 255, 255;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 22px;
  --radius-pill: 999px;

  --shadow-md: 0 8px 28px rgba(0,0,0,0.55);
  --shadow-lg: 0 24px 64px rgba(0,0,0,0.85);

  --transition-fast: 0.12s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-med: 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);

  --ui-scale: 1;
}

body[data-theme="gray"] {
  --bg-main: #0e1014;
  --bg-panel: #14171c;
  --bg-elevated: #1a1e24;
  --bg-input: #0a0c0f;
  --bg-hover: #1d2229;
  --bg-active: #262c35;
  --bg-bubble-out: #1f242c;
  --bg-bubble-in: #14181d;
  --text-main: #c8d1db;
  --text-muted: #5f6a76;
  --text-bright: #f0f6fc;
  --border-color: #1f252e;
  --border-bright: #2d353f;
  --accent-color: #58a6ff;
  --accent-rgb: 88, 166, 255;
}

body[data-theme="light"] {
  --bg-main: #f7f7f5;
  --bg-panel: #ffffff;
  --bg-elevated: #ffffff;
  --bg-input: #f2f2ef;
  --bg-hover: #ececea;
  --bg-active: #e2e2df;
  --bg-bubble-out: #e8e8e4;
  --bg-bubble-in: #ffffff;
  --text-main: #2b2b2b;
  --text-muted: #8a8a82;
  --text-bright: #111111;
  --border-color: #e4e4e0;
  --border-bright: #d5d5d0;
  --accent-color: #111111;
  --accent-rgb: 17, 17, 17;
  --shadow-md: 0 8px 28px rgba(0,0,0,0.09);
  --shadow-lg: 0 24px 64px rgba(0,0,0,0.14);
}

body[data-theme="lime"] {
  --bg-main: #0a110d;
  --bg-panel: #101c16;
  --bg-elevated: #14241c;
  --bg-input: #060d09;
  --bg-hover: #182a22;
  --bg-active: #203a2e;
  --bg-bubble-out: #1b3026;
  --bg-bubble-in: #101c16;
  --text-main: #c2e2d2;
  --text-muted: #4e7361;
  --text-bright: #dcfce7;
  --border-color: #16291f;
  --border-bright: #21392c;
  --accent-color: #4ade80;
  --accent-rgb: 74, 222, 128;
}

body[data-theme="purple"] {
  --bg-main: #0d0b14;
  --bg-panel: #16131f;
  --bg-elevated: #1c1828;
  --bg-input: #08060e;
  --bg-hover: #221c33;
  --bg-active: #2d2545;
  --bg-bubble-out: #251e38;
  --bg-bubble-in: #16131f;
  --text-main: #d5cfe8;
  --text-muted: #6d6288;
  --text-bright: #f3e8ff;
  --border-color: #1e1830;
  --border-bright: #2c2445;
  --accent-color: #c084fc;
  --accent-rgb: 192, 132, 252;
}

body[data-theme="red"] {
  --bg-main: #12090b;
  --bg-panel: #1c1013;
  --bg-elevated: #241418;
  --bg-input: #0d0506;
  --bg-hover: #291418;
  --bg-active: #3a1b21;
  --bg-bubble-out: #2f161b;
  --bg-bubble-in: #1c1013;
  --text-main: #e4cdd1;
  --text-muted: #835660;
  --text-bright: #ffe4e6;
  --border-color: #2a1116;
  --border-bright: #3b1d24;
  --accent-color: #fb7185;
  --accent-rgb: 251, 113, 133;
}

body[data-theme="yellow"] {
  --bg-main: #100d07;
  --bg-panel: #1a150c;
  --bg-elevated: #221b10;
  --bg-input: #0a0804;
  --bg-hover: #261e10;
  --bg-active: #352a17;
  --bg-bubble-out: #2a2013;
  --bg-bubble-in: #1a150c;
  --text-main: #e5ddca;
  --text-muted: #857650;
  --text-bright: #fef3c7;
  --border-color: #221a0c;
  --border-bright: #3d3118;
  --accent-color: #fbbf24;
  --accent-rgb: 251, 191, 36;
}

body[data-theme="pink"] {
  --bg-main: #110a0f;
  --bg-panel: #1c1019;
  --bg-elevated: #241520;
  --bg-input: #0c050a;
  --bg-hover: #291522;
  --bg-active: #3b1c30;
  --bg-bubble-out: #2f1826;
  --bg-bubble-in: #1c1019;
  --text-main: #e1cad9;
  --text-muted: #825375;
  --text-bright: #fce7f3;
  --border-color: #28101f;
  --border-bright: #3c1e35;
  --accent-color: #f472b6;
  --accent-rgb: 244, 114, 182;
}

body[data-theme="ukraine"] {
  --bg-main: #060c15;
  --bg-panel: #0c1521;
  --bg-elevated: #101c2c;
  --bg-input: #040810;
  --bg-hover: #142538;
  --bg-active: #1c3149;
  --bg-bubble-out: #172a40;
  --bg-bubble-in: #0c1521;
  --text-main: #d3dfed;
  --text-muted: #5b799c;
  --text-bright: #fef08a;
  --border-color: #132238;
  --border-bright: #1d3350;
  --accent-color: #eab308;
  --accent-rgb: 234, 179, 8;
}

/* ==================== БАЗА ==================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'SF Mono', 'JetBrains Mono', 'Fira Code', ui-monospace, Menlo, Consolas, monospace;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  background: var(--bg-main);
  color: var(--text-main);
  height: 100%;
  height: 100dvh;
  width: 100vw;
  overflow: hidden;
  position: fixed;
  inset: 0;
  font-size: calc(13px * var(--ui-scale));
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color var(--transition-slow), color var(--transition-slow);
}

button {
  cursor: pointer;
  font-family: inherit;
  transition: background var(--transition-fast), color var(--transition-fast),
              border-color var(--transition-fast), transform var(--transition-fast),
              opacity var(--transition-fast);
}

button:active:not(:disabled) { transform: scale(0.97); }
button:disabled { opacity: 0.35; cursor: not-allowed; }

input, textarea { font-family: inherit; }
input::placeholder, textarea::placeholder { color: var(--text-muted); opacity: 0.6; }

.hidden { display: none !important; }

.screen {
  width: 100vw;
  height: 100%;
  height: 100dvh;
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 8px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text-bright);
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-bright); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
* { scrollbar-width: thin; scrollbar-color: var(--border-bright) transparent; }

/* ==================== АВТОРИЗАЦИЯ ==================== */
#auth-screen {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: env(safe-area-inset-top) 20px env(safe-area-inset-bottom);
  background: radial-gradient(circle at 30% 20%, rgba(255,255,255,0.04) 0%, transparent 50%),
              radial-gradient(circle at 70% 80%, rgba(255,255,255,0.03) 0%, transparent 50%);
}

.auth-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  animation: authIn 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes authIn {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}

.auth-logo-title {
  font-size: 42px;
  font-weight: 700;
  letter-spacing: 8px;
  color: var(--text-bright);
  cursor: pointer;
  user-select: none;
  margin-bottom: 2px;
}

.auth-logo-title:active { opacity: 0.5; }

.auth-tagline {
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 3px;
  text-transform: uppercase;
  margin-bottom: 20px;
  font-weight: 600;
}

.auth-input-row {
  display: flex;
  align-items: stretch;
  width: 340px;
  max-width: 100%;
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.auth-input-row:focus-within {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 4px rgba(var(--accent-rgb), 0.06);
}

#auth-input, #auth-pass-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-bright);
  padding: 16px 20px;
  font-size: 14px;
  outline: none;
  text-align: center;
  letter-spacing: 2px;
  min-width: 0;
}

#auth-input::placeholder, #auth-pass-input::placeholder {
  letter-spacing: 2px;
  font-size: 10px;
  font-weight: 600;
}

.auth-arrow-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-left: 1px solid var(--border-color);
}

.auth-arrow-btn:hover {
  background: var(--bg-hover);
  color: var(--accent-color);
}

#auth-error {
  color: #ef4444;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  letter-spacing: 1px;
  animation: shake 0.4s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

.auth-sub-hint {
  font-size: 11px;
  color: var(--text-muted);
}

/* ==================== ЭКРАН ==================== */
#app-screen {
  display: flex;
  height: 100%;
  height: 100dvh;
  position: relative;
}

/* ==================== САЙДБАР ==================== */
.sidebar {
  width: 340px;
  background: var(--bg-panel);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  position: relative;
  z-index: 10;
}

.sidebar-top {
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.user-profile-header {
  display: flex;
  align-items: center;
  gap: 12px;
  overflow: hidden;
  min-width: 0;
  flex: 1;
  padding: 4px 6px;
  background: transparent;
  border: none;
  text-align: left;
  border-radius: var(--radius-md);
}

.user-profile-header:hover { background: var(--bg-hover); }

.user-avatar-mini {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--bg-hover);
  border: 1px solid var(--border-bright);
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  color: var(--text-bright);
  overflow: hidden;
}

.user-profile {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  gap: 2px;
}

.user-display-name {
  font-size: 13.5px;
  color: var(--text-bright);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-fixed-cid {
  font-size: 10px;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-fixed-cid:hover { color: var(--text-bright); }

.sidebar-search-box {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.search-input-wrapper {
  display: flex;
  position: relative;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 14px;
  color: var(--text-muted);
  pointer-events: none;
}

#contact-search-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-bright);
  padding: 11px 36px 11px 38px;
  font-size: 12px;
  outline: none;
  border-radius: var(--radius-pill);
}

#contact-search-input:focus {
  border-color: var(--border-bright);
}

#search-clear-btn {
  position: absolute;
  right: 10px;
  background: var(--bg-hover);
  border: none;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 5px;
  border-radius: 50%;
  width: 20px;
  height: 20px;
}

#search-clear-btn:hover { color: var(--text-bright); }

.search-filters {
  display: flex;
  gap: 6px;
}

.search-filter-btn {
  flex: 1;
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 10px;
  padding: 7px 10px;
  border-radius: var(--radius-pill);
  letter-spacing: 1.2px;
  font-weight: 700;
}

.search-filter-btn.active {
  background: var(--bg-hover);
  color: var(--text-bright);
  border-color: var(--border-bright);
}

.sidebar-section-header {
  padding: 14px 18px 8px;
  display: flex;
  justify-content: space-between;
}

.sidebar-section-title {
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 2px;
  font-weight: 700;
  text-transform: uppercase;
}

.peers-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding: 0 8px 90px;
  gap: 2px;
  -webkit-overflow-scrolling: touch;
}

.peer-btn {
  background: transparent;
  color: var(--text-main);
  border: none;
  padding: 10px 12px;
  text-align: left;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-radius: var(--radius-md);
  position: relative;
  width: 100%;
}

.peer-btn:hover { background: var(--bg-hover); }
.peer-btn.active { background: var(--bg-hover); }

.peer-btn.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 40%;
  background: var(--accent-color);
  border-radius: 0 3px 3px 0;
}

.peer-avatar-thumb {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--bg-hover);
  border: 1px solid var(--border-bright);
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  color: var(--text-bright);
  overflow: hidden;
}

.peer-btn-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow: hidden;
  flex: 1;
  min-width: 0;
}

.peer-btn-name {
  font-weight: 700;
  color: var(--text-bright);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 13.5px;
}

.peer-btn-cid {
  font-size: 10.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.peer-btn-tag {
  font-size: 9px;
  color: #fbbf24;
  margin-top: 2px;
  letter-spacing: 1px;
  font-weight: 700;
  text-transform: uppercase;
}

.fab-button {
  position: absolute;
  bottom: calc(20px + env(safe-area-inset-bottom));
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent-color);
  color: var(--bg-main);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
  z-index: 100;
}

.fab-button:hover {
  filter: brightness(0.92);
  transform: scale(1.05);
}

.plus-dropdown-menu {
  position: absolute;
  bottom: calc(86px + env(safe-area-inset-bottom));
  right: 20px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-bright);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  min-width: 220px;
  z-index: 1200;
  padding: 6px;
  border-radius: var(--radius-lg);
  animation: dropdownIn var(--transition-med);
}

@keyframes dropdownIn {
  from { opacity: 0; transform: translateY(8px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.dropdown-item {
  background: transparent;
  border: none;
  color: var(--text-main);
  padding: 12px 14px;
  text-align: left;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  border-radius: var(--radius-md);
}

.dropdown-item:hover {
  background: var(--bg-hover);
  color: var(--text-bright);
}

/* ==================== ЧАТ ==================== */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-main);
  min-width: 0;
  height: 100%;
  height: 100dvh;
  position: relative;
}

.chat-topbar {
  min-height: 64px;
  padding: env(safe-area-inset-top) 20px 0;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text-bright);
  flex-shrink: 0;
  background: var(--bg-panel);
}

.chat-topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  overflow: hidden;
  flex: 1;
  min-width: 0;
  padding: 12px 0;
}

.chat-header-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--bg-hover);
  border: 1px solid var(--border-bright);
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  color: var(--text-bright);
  overflow: hidden;
}

.chat-header-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  gap: 2px;
}

#active-peer-header {
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.active-group-subtitle {
  font-size: 10.5px;
  color: var(--text-muted);
}

.chat-topbar-right {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.mobile-back-btn { display: none; }

.pinned-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-color);
  padding: 10px 20px;
  font-size: 11px;
  cursor: pointer;
  z-index: 2;
}

.pinned-bar:hover { background: var(--bg-hover); }

.pinned-info {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
  white-space: nowrap;
  flex: 1;
}

.pinned-label {
  color: var(--text-muted);
  font-weight: 700;
  font-size: 9px;
  letter-spacing: 1.2px;
  flex-shrink: 0;
  text-transform: uppercase;
}

.pinned-text {
  color: var(--text-main);
  text-overflow: ellipsis;
  overflow: hidden;
  font-size: 12px;
}

.antispam-banner {
  background: var(--bg-elevated);
  border-bottom: 1px solid rgba(251, 191, 36, 0.2);
  padding: 14px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  z-index: 2;
  animation: slideDown var(--transition-med);
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.antispam-text {
  color: #fef08a;
  font-size: 12px;
}

.antispam-actions { display: flex; gap: 8px; }

.antispam-btn-accept,
.antispam-btn-reject {
  padding: 8px 16px;
  font-size: 10px;
  border-radius: var(--radius-pill);
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  border: 1px solid;
  background: transparent;
}

.antispam-btn-accept { border-color: #22c55e; color: #22c55e; }
.antispam-btn-accept:hover { background: rgba(34, 197, 94, 0.1); }
.antispam-btn-reject { border-color: #ef4444; color: #ef4444; }
.antispam-btn-reject:hover { background: rgba(239, 68, 68, 0.1); }

/* ==================== СООБЩЕНИЯ ==================== */
.messages-viewport {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  -webkit-overflow-scrolling: touch;
}

.date-separator {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 20px 0 10px;
}

.date-separator span {
  background: var(--bg-elevated);
  padding: 5px 14px;
  font-size: 9.5px;
  color: var(--text-muted);
  letter-spacing: 2px;
  text-transform: uppercase;
  font-weight: 700;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-color);
}

.msg-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  padding: 2px 0;
  animation: msgIn 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg-avatar-col {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-hover);
  border: 1px solid var(--border-bright);
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: var(--text-bright);
  overflow: hidden;
}

.msg-body-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: 72%;
}

.msg-row.is-self {
  flex-direction: row-reverse;
}

.msg-row.is-self .msg-body-col {
  align-items: flex-end;
}

.msg-row.is-self .msg-avatar-col {
  display: none;
}

.msg-bubble {
  background: var(--bg-bubble-in);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  border-bottom-left-radius: 4px;
  padding: 10px 14px;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: relative;
}

.msg-row.is-self .msg-bubble {
  background: var(--bg-bubble-out);
  border-bottom-left-radius: var(--radius-lg);
  border-bottom-right-radius: 4px;
}

.msg-row.highlighted-msg .msg-bubble {
  outline: 2px solid var(--accent-color);
  box-shadow: 0 0 0 4px rgba(var(--accent-rgb), 0.1);
}

.msg-author {
  color: var(--text-bright);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.2px;
  margin-bottom: 2px;
}

.msg-text {
  color: var(--text-main);
  font-size: 13.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg-time {
  color: var(--text-muted);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  align-self: flex-end;
  margin-top: 2px;
  letter-spacing: 0.3px;
}

.msg-edited-tag {
  color: var(--text-muted);
  font-size: 10px;
  font-style: italic;
  opacity: 0.7;
  margin-left: 4px;
}

.msg-reactions-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.reaction-badge {
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  padding: 2px 9px;
  font-size: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  user-select: none;
  border-radius: var(--radius-pill);
}

.reaction-badge.my-active {
  border-color: var(--accent-color);
  background: rgba(var(--accent-rgb), 0.1);
}

.reaction-badge:hover { background: var(--bg-hover); }

.msg-image-wrap {
  display: block;
  margin: 4px 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  max-width: 100%;
}

.msg-image {
  max-width: 100%;
  max-height: 320px;
  display: block;
  object-fit: cover;
  cursor: pointer;
  border-radius: var(--radius-md);
}

.edit-state-bar {
  background: var(--bg-elevated);
  border-top: 1px solid var(--border-color);
  padding: 10px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  animation: slideDown var(--transition-med);
}

.edit-state-label {
  color: var(--text-bright);
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
}

.cancel-edit-btn {
  background: transparent;
  border: none;
  color: #ef4444;
  font-size: 10px;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
}

.cancel-edit-btn:hover { background: rgba(239, 68, 68, 0.1); }

.message-form {
  padding: 12px 18px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 8px;
  background: var(--bg-panel);
  flex-shrink: 0;
  align-items: center;
}

.attach-icon-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 10px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  flex-shrink: 0;
}

.attach-icon-btn:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text-bright);
}

.message-form input[type="text"] {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-bright);
  padding: 12px 18px;
  outline: none;
  font-size: 13.5px;
  border-radius: var(--radius-pill);
  min-width: 0;
}

.message-form input[type="text"]:focus {
  border-color: var(--border-bright);
}

.message-form input[type="text"]:disabled {
  background: var(--bg-hover);
  color: var(--text-muted);
}

.send-icon-btn {
  background: var(--accent-color);
  color: var(--bg-main);
  border: none;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.send-icon-btn:hover:not(:disabled) { filter: brightness(0.9); }

/* ==================== МОБИЛЬНАЯ НАВИГАЦИЯ ==================== */
.mobile-nav {
  display: none;
}

/* ==================== МОДАЛКИ ==================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  padding: 16px;
  animation: overlayIn var(--transition-med);
}

@keyframes overlayIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-card, .admin-window, .confirm-window, .call-window, .grp-call-window {
  animation: modalIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-bright);
  width: 100%;
  max-width: 460px;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  max-height: 88vh;
}

.modal-card.large { max-width: 560px; }

.modal-card-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-bright);
  letter-spacing: 2px;
  text-transform: uppercase;
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 15px;
  padding: 6px 10px;
  border-radius: var(--radius-md);
  font-weight: 700;
}

.modal-close-btn:hover {
  color: var(--text-bright);
  background: var(--bg-hover);
}

.modal-card-body {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
}

.modal-card-actions {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.input-field-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.8px;
  font-weight: 700;
}

.text-input {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-bright);
  padding: 12px 16px;
  font-size: 13px;
  outline: none;
  width: 100%;
  border-radius: var(--radius-md);
}

.text-input:focus { border-color: var(--border-bright); }

.input-row-flex { display: flex; gap: 8px; }

.btn-primary {
  background: var(--accent-color);
  color: var(--bg-main);
  border: none;
  padding: 12px 22px;
  font-size: 11px;
  font-weight: 700;
  border-radius: var(--radius-md);
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.btn-primary:hover { filter: brightness(0.9); }

.btn-secondary {
  background: transparent;
  color: var(--text-bright);
  border: 1px solid var(--border-color);
  padding: 11px 18px;
  font-size: 11px;
  border-radius: var(--radius-md);
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
}

.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--border-bright);
}

.btn-small-accent {
  background: transparent;
  color: var(--text-bright);
  border: 1px solid var(--border-bright);
  font-size: 10px;
  padding: 7px 14px;
  border-radius: var(--radius-pill);
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.btn-ghost-danger {
  background: transparent;
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #f87171;
  padding: 11px 18px;
  font-size: 11px;
  border-radius: var(--radius-md);
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
}

.btn-ghost-danger:hover { background: rgba(239, 68, 68, 0.1); }

.group-gid-badge {
  background: var(--bg-input);
  border: 1px dashed var(--border-bright);
  padding: 12px;
  font-size: 11px;
  color: var(--text-bright);
  cursor: pointer;
  user-select: none;
  border-radius: var(--radius-md);
  text-align: center;
}

.group-gid-badge:hover { background: var(--bg-hover); }

.section-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.members-list-box, .invite-candidates-list {
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  max-height: 220px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-md);
}

.group-member-item, .invite-candidate-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-color);
  font-size: 11.5px;
  gap: 10px;
}

.group-member-item:last-child, .invite-candidate-item:last-child { border-bottom: none; }

.member-role-badge {
  font-size: 9px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.role-owner {
  background: transparent;
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.4);
}

.role-member {
  background: var(--bg-hover);
  color: var(--text-muted);
}

.danger-zone-group {
  margin-top: 8px;
  border-top: 1px solid var(--border-color);
  padding-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-danger-outline {
  background: transparent;
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #f87171;
  padding: 12px;
  font-size: 10.5px;
  border-radius: var(--radius-md);
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.btn-danger-outline:hover { background: rgba(239, 68, 68, 0.08); }

.btn-danger-solid {
  background: #7f1d1d;
  border: 1px solid #991b1b;
  color: #fff;
  padding: 12px;
  font-size: 10.5px;
  border-radius: var(--radius-md);
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.btn-danger-solid:disabled { opacity: 0.35; }

.sub-hint-text {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.55;
}

/* ==================== НАСТРОЙКИ ==================== */
.settings-fullscreen {
  background: var(--bg-main);
  width: 100%;
  height: 100%;
  height: 100dvh;
  display: flex;
  overflow: hidden;
  animation: settingsIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes settingsIn {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}

.settings-sidebar {
  width: 260px;
  background: var(--bg-panel);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  padding-top: env(safe-area-inset-top);
}

.settings-sidebar-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-bright);
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.settings-nav {
  flex: 1;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.settings-nav-btn {
  background: transparent;
  border: none;
  color: var(--text-main);
  padding: 12px 14px;
  text-align: left;
  font-size: 12.5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  border-radius: var(--radius-md);
  font-weight: 600;
  width: 100%;
}

.settings-nav-btn:hover {
  background: var(--bg-hover);
  color: var(--text-bright);
}

.settings-nav-btn.active {
  background: var(--bg-hover);
  color: var(--text-bright);
}

.settings-nav-btn svg { color: var(--text-muted); flex-shrink: 0; }
.settings-nav-btn.active svg { color: var(--text-bright); }

.settings-sidebar-footer {
  padding: 14px;
  border-top: 1px solid var(--border-color);
  padding-bottom: calc(14px + env(safe-area-inset-bottom));
}

.logout-btn-full {
  background: transparent;
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #f87171;
  padding: 12px;
  width: 100%;
  border-radius: var(--radius-md);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.logout-btn-full:hover { background: rgba(239, 68, 68, 0.1); }

.settings-content {
  flex: 1;
  overflow-y: auto;
  padding: 32px 40px 40px;
}

.settings-panel {
  display: none;
  animation: panelIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  max-width: 620px;
}

.settings-panel.active { display: block; }

@keyframes panelIn {
  from { opacity: 0; transform: translateX(12px); }
  to { opacity: 1; transform: translateX(0); }
}

.settings-panel-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-bright);
  letter-spacing: 1px;
  margin-bottom: 24px;
}

.settings-block {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.settings-block-title {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.8px;
  font-weight: 700;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.settings-row-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1;
}

.settings-row-label {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  font-weight: 700;
}

.settings-row-value {
  font-size: 13.5px;
  color: var(--text-bright);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-avatar-section {
  display: flex;
  align-items: center;
  gap: 20px;
}

.profile-avatar-large {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: var(--bg-hover);
  border: 2px solid var(--border-bright);
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 32px;
  color: var(--text-bright);
  overflow: hidden;
}

.profile-avatar-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.btn-group-row { display: flex; gap: 8px; flex-wrap: wrap; }

.password-inputs-box {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.attempts-selector-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  flex-wrap: wrap;
}

.attempts-input {
  width: 70px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-bright);
  padding: 10px;
  text-align: center;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 13px;
}

.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  cursor: pointer;
  padding: 6px 0;
  user-select: none;
}

.checkbox-row input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--accent-color);
  cursor: pointer;
  flex-shrink: 0;
  margin-top: 2px;
}

.checkbox-row-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.checkbox-row-title {
  font-size: 13px;
  color: var(--text-bright);
  font-weight: 600;
}

.checkbox-row-desc {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.5;
}

.theme-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.theme-select-btn {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 12px 10px;
  font-size: 11px;
  text-align: center;
  border-radius: var(--radius-md);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.theme-select-btn.active {
  border-color: var(--accent-color);
  background: var(--bg-hover);
  color: var(--text-bright);
}

.theme-select-btn:hover { background: var(--bg-hover); }

.theme-swatch {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid var(--border-bright);
  flex-shrink: 0;
}

.scale-options { display: flex; gap: 6px; flex-wrap: wrap; }

.scale-btn {
  flex: 1;
  min-width: 60px;
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 10px;
  font-size: 11px;
  border-radius: var(--radius-md);
  font-weight: 700;
}

.scale-btn.active {
  background: var(--bg-hover);
  border-color: var(--accent-color);
  color: var(--text-bright);
}

.custom-theme-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.color-picker-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  padding: 4px 0;
}

.color-picker-item input[type="color"] {
  background: transparent;
  border: 1px solid var(--border-color);
  width: 50px;
  height: 34px;
  cursor: pointer;
  border-radius: var(--radius-md);
  padding: 2px;
}

.vpn-promo {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
}

.vpn-promo-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-bright);
}

.vpn-promo-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.6;
  max-width: 380px;
}

.vpn-open-btn {
  margin-top: 6px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* ==================== КОНТЕКСТНОЕ МЕНЮ ==================== */
.context-menu {
  position: fixed;
  z-index: 2000;
  background: var(--bg-elevated);
  border: 1px solid var(--border-bright);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 220px;
  border-radius: var(--radius-lg);
  animation: modalIn 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.context-reactions-row {
  display: flex;
  gap: 2px;
  padding: 6px;
  overflow-x: auto;
  justify-content: space-between;
}

.reaction-emoji-btn {
  font-size: 20px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--radius-md);
}

.reaction-emoji-btn:hover {
  transform: scale(1.25);
  background: var(--bg-hover);
}

.context-menu-divider {
  height: 1px;
  background: var(--border-color);
  margin: 4px 0;
}

.context-menu-item {
  background: transparent;
  border: none;
  color: var(--text-main);
  text-align: left;
  padding: 10px 14px;
  font-size: 12px;
  width: 100%;
  border-radius: var(--radius-md);
}

.context-menu-item:hover {
  background: var(--bg-hover);
  color: var(--text-bright);
}

.context-menu-item.danger { color: #ef4444; }
.context-menu-item.danger:hover { background: rgba(239, 68, 68, 0.1); }

/* ==================== ЗВОНКИ ==================== */
.call-window {
  background: var(--bg-elevated);
  border: 1px solid var(--border-bright);
  width: 100%;
  max-width: 380px;
  padding: 36px 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 20px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.call-title, .call-status {
  font-size: 10.5px;
  color: var(--text-muted);
  letter-spacing: 2.5px;
  font-weight: 700;
  text-transform: uppercase;
}

.call-peer-info {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-bright);
}

.call-timer {
  font-size: 32px;
  font-weight: 700;
  color: var(--text-bright);
  letter-spacing: 4px;
  font-variant-numeric: tabular-nums;
}

.call-actions { display: flex; gap: 10px; width: 100%; }

.call-actions button {
  flex: 1;
  padding: 14px;
  font-size: 11px;
  border: 1px solid;
  border-radius: var(--radius-pill);
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  background: transparent;
}

.call-btn-accept { color: #22c55e; border-color: #22c55e; }
.call-btn-accept:hover { background: rgba(34, 197, 94, 0.1); }
.call-btn-reject { color: #ef4444; border-color: #ef4444; }
.call-btn-reject:hover { background: rgba(239, 68, 68, 0.1); }
.call-btn-mute { color: var(--text-bright); border-color: var(--border-bright); }
.call-btn-mute:hover { background: var(--bg-hover); }

.grp-call-window {
  background: var(--bg-elevated);
  border: 1px solid var(--border-bright);
  width: 100%;
  max-width: 420px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.grp-call-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  gap: 10px;
}

.grp-call-title {
  font-size: 10.5px;
  color: var(--text-muted);
  letter-spacing: 2.5px;
  font-weight: 700;
  flex: 1;
  text-transform: uppercase;
}

.grp-call-timer {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-bright);
  font-variant-numeric: tabular-nums;
  letter-spacing: 2px;
}

.grp-participants {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.grp-participant {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px;
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.grp-participant.self { border-color: var(--border-bright); }

.grp-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-hover);
  border: 1px solid var(--border-bright);
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  color: var(--text-bright);
  overflow: hidden;
}

.grp-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.grp-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-bright);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.grp-status { font-size: 10.5px; }

.grp-level-bar {
  height: 3px;
  background: var(--bg-main);
  border-radius: 2px;
  overflow: hidden;
  width: 100%;
}

.grp-level-fill {
  height: 100%;
  width: 0%;
  background: var(--accent-color);
  transition: width 0.1s linear;
}

.grp-mute-btn {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-bright);
  padding: 8px 14px;
  font-size: 10px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
  letter-spacing: 1px;
  text-transform: uppercase;
  font-weight: 700;
}

.grp-call-actions { display: flex; gap: 10px; width: 100%; }

.grp-call-actions button {
  flex: 1;
  padding: 13px;
  font-size: 11px;
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-pill);
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  background: transparent;
  color: var(--text-bright);
}

.grp-call-actions button.call-btn-reject {
  color: #ef4444;
  border-color: #ef4444;
}

.grp-call-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 6px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.grp-call-close-btn:hover {
  background: var(--bg-hover);
  color: var(--text-bright);
}

/* ==================== РЕДАКТОР ==================== */
#image-editor-modal {
  padding: 0;
  background: rgba(0, 0, 0, 0.98);
  z-index: 1500;
}

.editor-window {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: #050505;
  overflow: hidden;
}

.editor-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: #0a0a0a;
  border-bottom: 1px solid var(--border-color);
  gap: 8px;
  flex-wrap: wrap;
  padding-top: calc(10px + env(safe-area-inset-top));
  flex-shrink: 0;
}

.tool-group { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.tool-btn {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 8px 14px;
  font-size: 10px;
  border-radius: var(--radius-md);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
}

.tool-btn.active {
  background: var(--bg-hover);
  border-color: var(--accent-color);
  color: var(--text-bright);
}

.tool-btn.danger { color: #ef4444; border-color: rgba(239, 68, 68, 0.3); }

.editor-subbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: #070707;
  border-bottom: 1px solid var(--border-color);
  gap: 12px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.brush-size-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 1px;
  text-transform: uppercase;
  font-weight: 700;
}

.brush-size-wrap input[type="range"] {
  width: 100px;
  accent-color: #fff;
  cursor: pointer;
}

.color-presets { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.palette-dot {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  cursor: pointer;
  border: 1px solid transparent;
}

.palette-dot.active {
  transform: scale(1.15);
  box-shadow: 0 0 0 2px #fff;
}

#editor-color-picker {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border-bright);
  background: transparent;
  cursor: pointer;
  border-radius: 50%;
  padding: 0;
}

.editor-canvas-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #000;
  touch-action: none;
  user-select: none;
}

.editor-viewport {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transform-origin: center center;
  will-change: transform;
}

#editor-canvas {
  display: block;
  max-width: none;
  max-height: none;
  background: transparent;
  box-shadow: 0 0 24px rgba(0, 0, 0, 0.9);
  cursor: crosshair;
  touch-action: none;
}

.editor-zoom-indicator {
  position: absolute;
  bottom: 14px;
  right: 14px;
  background: rgba(0, 0, 0, 0.7);
  color: #ddd;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 700;
  pointer-events: none;
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.editor-zoom-indicator.visible { opacity: 1; }

.crop-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}

.crop-overlay.active { pointer-events: auto; }

.crop-shade {
  position: absolute;
  background: rgba(0, 0, 0, 0.65);
  pointer-events: none;
}

.crop-shade-top    { top: 0; left: 0; right: 0; }
.crop-shade-bottom { bottom: 0; left: 0; right: 0; }
.crop-shade-left   { left: 0; }
.crop-shade-right  { right: 0; }

.crop-selection-box {
  position: absolute;
  border: 1.5px solid #ffffff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5);
  cursor: move;
  pointer-events: auto;
  box-sizing: border-box;
}

.crop-grid-line {
  position: absolute;
  background: rgba(255, 255, 255, 0.3);
  pointer-events: none;
}

.crop-grid-v1 { left: 33.333%; top: 0; bottom: 0; width: 1px; }
.crop-grid-v2 { left: 66.666%; top: 0; bottom: 0; width: 1px; }
.crop-grid-h1 { top: 33.333%; left: 0; right: 0; height: 1px; }
.crop-grid-h2 { top: 66.666%; left: 0; right: 0; height: 1px; }

.crop-handle {
  position: absolute;
  width: 24px;
  height: 24px;
  background: transparent;
  pointer-events: auto;
  z-index: 3;
}

.crop-handle::after {
  content: "";
  position: absolute;
  background: #fff;
  border-radius: 2px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

.crop-handle-nw { top: -12px; left: -12px; cursor: nwse-resize; }
.crop-handle-ne { top: -12px; right: -12px; cursor: nesw-resize; }
.crop-handle-sw { bottom: -12px; left: -12px; cursor: nesw-resize; }
.crop-handle-se { bottom: -12px; right: -12px; cursor: nwse-resize; }
.crop-handle-n { top: -12px; left: 50%; transform: translateX(-50%); cursor: ns-resize; }
.crop-handle-s { bottom: -12px; left: 50%; transform: translateX(-50%); cursor: ns-resize; }
.crop-handle-w { left: -12px; top: 50%; transform: translateY(-50%); cursor: ew-resize; }
.crop-handle-e { right: -12px; top: 50%; transform: translateY(-50%); cursor: ew-resize; }

.crop-handle-nw::after { top: 8px; left: 8px; width: 12px; height: 3px; }
.crop-handle-nw::before {
  content: ""; position: absolute; top: 8px; left: 8px; width: 3px; height: 12px;
  background: #fff; border-radius: 2px; box-shadow: 0 1px 3px rgba(0,0,0,0.6);
}
.crop-handle-ne::after { top: 8px; right: 8px; width: 12px; height: 3px; }
.crop-handle-ne::before {
  content: ""; position: absolute; top: 8px; right: 8px; width: 3px; height: 12px;
  background: #fff; border-radius: 2px; box-shadow: 0 1px 3px rgba(0,0,0,0.6);
}
.crop-handle-sw::after { bottom: 8px; left: 8px; width: 12px; height: 3px; }
.crop-handle-sw::before {
  content: ""; position: absolute; bottom: 8px; left: 8px; width: 3px; height: 12px;
  background: #fff; border-radius: 2px; box-shadow: 0 1px 3px rgba(0,0,0,0.6);
}
.crop-handle-se::after { bottom: 8px; right: 8px; width: 12px; height: 3px; }
.crop-handle-se::before {
  content: ""; position: absolute; bottom: 8px; right: 8px; width: 3px; height: 12px;
  background: #fff; border-radius: 2px; box-shadow: 0 1px 3px rgba(0,0,0,0.6);
}

.crop-handle-n::after { top: 10px; left: 50%; transform: translateX(-50%); width: 18px; height: 3px; }
.crop-handle-s::after { bottom: 10px; left: 50%; transform: translateX(-50%); width: 18px; height: 3px; }
.crop-handle-w::after { left: 10px; top: 50%; transform: translateY(-50%); width: 3px; height: 18px; }
.crop-handle-e::after { right: 10px; top: 50%; transform: translateY(-50%); width: 3px; height: 18px; }

.editor-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  background: #0a0a0a;
  border-top: 1px solid var(--border-color);
  gap: 10px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.editor-actions button {
  padding: 12px 18px;
  font-size: 10.5px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-weight: 700;
  letter-spacing: 1.5px;
  flex: 1;
  min-width: 100px;
  text-transform: uppercase;
  background: transparent;
  color: var(--text-bright);
}

.editor-btn-primary {
  background: var(--accent-color) !important;
  color: var(--bg-main) !important;
  border-color: var(--accent-color) !important;
}

/* ==================== ПРОСМОТР ==================== */
#image-viewer-modal {
  background: rgba(0, 0, 0, 0.97);
  padding: 0;
  flex-direction: column;
  overflow: hidden;
}

.viewer-stage {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  cursor: grab;
}

#viewer-img {
  max-width: none;
  max-height: none;
  display: block;
  transform-origin: center center;
  will-change: transform;
  user-select: none;
  pointer-events: none;
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.95);
  border-radius: var(--radius-md);
}

.viewer-close-btn {
  position: absolute;
  top: calc(20px + env(safe-area-inset-top));
  right: 20px;
  z-index: 10;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 10px 18px;
  border-radius: var(--radius-pill);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 1.5px;
  backdrop-filter: blur(8px);
  text-transform: uppercase;
}

.viewer-zoom-indicator {
  position: absolute;
  bottom: calc(24px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  background: rgba(0, 0, 0, 0.7);
  color: #ddd;
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 700;
  pointer-events: none;
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.viewer-zoom-indicator.visible { opacity: 1; }

/* ==================== АДМИНКА ==================== */
.admin-window {
  background: var(--bg-elevated);
  border: 1px solid var(--border-bright);
  width: 100%;
  max-width: 620px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-height: 90vh;
  overflow-y: auto;
}

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 16px;
  color: var(--text-bright);
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.admin-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  flex-wrap: wrap;
}

.admin-controls button {
  background: transparent;
  color: var(--text-bright);
  border: 1px solid var(--border-color);
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 10.5px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
}

.admin-cid-list {
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  padding: 8px;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--bg-main);
  border-radius: var(--radius-md);
}

.admin-cid-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-color);
  gap: 8px;
}

.admin-del-btn {
  background: transparent;
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #f87171;
  font-size: 9.5px;
  padding: 5px 10px;
  border-radius: var(--radius-pill);
  font-weight: 700;
  text-transform: uppercase;
}

/* ==================== ПОДТВЕРЖДЕНИЯ ==================== */
.confirm-window {
  background: var(--bg-elevated);
  border: 1px solid rgba(239, 68, 68, 0.3);
  width: 100%;
  max-width: 460px;
  padding: 26px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.confirm-title {
  color: #f87171;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.confirm-desc {
  font-size: 12.5px;
  color: var(--text-main);
  line-height: 1.65;
}

#delete-phrase-input {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-bright);
  padding: 12px 14px;
  outline: none;
  font-size: 13px;
  border-radius: var(--radius-md);
}

.confirm-actions { display: flex; gap: 10px; }

.confirm-actions button {
  flex: 1;
  padding: 13px;
  font-size: 11px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  background: transparent;
}

#confirm-delete-btn { color: #f87171; border-color: rgba(239, 68, 68, 0.5); }
#cancel-delete-btn { color: var(--text-main); }

.modal-window {
  background: var(--bg-elevated);
  border: 1px solid var(--border-bright);
  padding: 8px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
}

#admin-pass-input {
  background: transparent;
  border: none;
  color: var(--text-bright);
  padding: 14px 20px;
  outline: none;
  font-size: 14px;
  width: 260px;
  text-align: center;
  letter-spacing: 3px;
}

#admin-pass-input::placeholder {
  color: var(--text-muted);
  letter-spacing: 2px;
  font-size: 11px;
}

/* ==================== МОБИЛЬНАЯ ВЁРСТКА ==================== */
@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    border-right: none;
    padding-bottom: calc(72px + env(safe-area-inset-bottom));
  }

  .chat-area {
    position: absolute;
    inset: 0;
    z-index: 20;
    transform: translateX(100%);
    transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1);
    padding-bottom: calc(64px + env(safe-area-inset-bottom));
  }

  #app-screen.chat-opened .chat-area {
    transform: translateX(0);
  }

  .mobile-back-btn { display: flex; }
  .mobile-nav { display: flex; }

  .fab-button {
    bottom: calc(86px + env(safe-area-inset-bottom));
  }

  .plus-dropdown-menu {
    bottom: calc(150px + env(safe-area-inset-bottom));
  }

  .chat-topbar {
    padding-left: 8px;
    padding-right: 14px;
  }

  .chat-topbar-left { gap: 6px; }

  .messages-viewport {
    padding: 14px 14px 10px;
    gap: 6px;
  }

  .msg-body-col { max-width: 78%; }

  .msg-avatar-col {
    width: 32px;
    height: 32px;
    font-size: 13px;
  }

  .message-form {
    padding: 10px 12px;
    gap: 6px;
  }

  .message-form input[type="text"] {
    padding: 11px 16px;
    font-size: 13px;
  }

  .send-icon-btn, .attach-icon-btn {
    width: 40px;
    height: 40px;
  }

  .msg-image { max-height: 260px; }

  .call-window, .grp-call-window {
    padding: 24px 20px;
    max-width: 100%;
  }

  .theme-grid { grid-template-columns: repeat(2, 1fr); }

  .modal-card, .admin-window, .confirm-window {
    max-height: 92vh;
    max-width: 100%;
  }

  .modal-card-header, .modal-card-body, .modal-card-actions {
    padding-left: 18px;
    padding-right: 18px;
  }

  .settings-fullscreen {
    flex-direction: column;
  }

  .settings-sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    max-height: none;
    flex-shrink: 0;
  }

  .settings-nav {
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 8px;
    gap: 4px;
  }

  .settings-nav-btn {
    flex-shrink: 0;
    padding: 10px 14px;
    font-size: 11px;
    white-space: nowrap;
    width: auto;
  }

  .settings-content { padding: 20px; }
  .settings-panel-title { font-size: 18px; margin-bottom: 18px; }
  .profile-avatar-large { width: 72px; height: 72px; font-size: 26px; }

  .settings-row {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .settings-row .btn-secondary {
    align-self: flex-start;
  }

  .auth-input-row { width: 300px; }
  .auth-logo-title { font-size: 36px; letter-spacing: 6px; }

  /* Мобильная навигация внизу */
  .mobile-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-panel);
    border-top: 1px solid var(--border-color);
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
    z-index: 60;
    justify-content: space-around;
    gap: 4px;
  }

  .mobile-nav-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 8px 4px;
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: 0.8px;
    text-transform: uppercase;
  }

  .mobile-nav-btn.active {
    color: var(--text-bright);
    background: var(--bg-hover);
  }
}

@media (max-width: 380px) {
  .tool-group .tool-btn {
    padding: 6px 8px;
    font-size: 9px;
  }

  .auth-logo-title { font-size: 32px; }
  .auth-input-row { width: 280px; }
}

/* На десктопе мобильная навигация скрыта */
@media (min-width: 769px) {
  .mobile-nav { display: none !important; }
}

button:focus-visible, input:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
}