:root {
  --sidebar: #0b0d10;
  --chat-bg: #050607;
  --chat-bg-pattern:
    radial-gradient(ellipse 110% 70% at 8% -10%, rgba(232, 135, 58, 0.09), transparent 52%),
    radial-gradient(ellipse 90% 55% at 100% 110%, rgba(90, 120, 150, 0.07), transparent 48%),
    linear-gradient(180deg, #07090c 0%, #050607 40%, #06080b 100%);
  --item-hover: #14181d;
  --item-active: #1a222c;
  --stroke: #1c2229;
  --text: #b4bcc6;
  --text-dim: #5f6874;
  --accent: #e8873a;
  --brand: #e8873a;
  --brand-dim: #b86a2a;
  --brand-glow: rgba(232, 135, 58, 0.22);
  --surface: #0e1116;
  --surface-card: #12161d;
  --on-brand: #120d08;
  --bubble-in: #121820;
  --bubble-out: #1c2a38;
  --danger: #b84a4a;
  --font: "Avenir Next", "Segoe UI Variable", "Segoe UI", "Helvetica Neue", sans-serif;
  --font-display: "Avenir Next", "Segoe UI", sans-serif;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.2, 0.64, 1);
  --motion: 0.32s;
  --safe-top: env(safe-area-inset-top, 0px);
  --sidebar-top-inset: max(0.55rem, var(--safe-top));
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: var(--font);
  background: var(--chat-bg);
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.hidden {
  display: none !important;
}

/* ——— вход ——— */
.gate {
  min-height: 100dvh;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: calc(1.25rem + var(--safe-top)) calc(1.25rem + var(--safe-right))
    calc(1.25rem + var(--safe-bottom)) calc(1.25rem + var(--safe-left));
  background: var(--sidebar);
}

.gate-card {
  width: min(100%, 20rem);
  padding: 1.35rem 1.25rem 1.1rem;
  border-radius: 18px;
  background: linear-gradient(165deg, #0e1116 0%, #070809 100%);
  border: 1px solid rgba(232, 135, 58, 0.12);
  box-shadow:
    0 20px 48px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(232, 135, 58, 0.06);
}

.gate-card label {
  display: block;
  margin: 0.65rem 0 0.3rem;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.gate-card label:first-of-type {
  margin-top: 0.85rem;
}

#tab-register .btn-primary {
  margin-top: 0.9rem;
}

.gate-card input:not([type="checkbox"]) {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid transparent;
  border-radius: 10px;
  background: #13171c;
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
}

.gate-card input:focus {
  outline: none;
  border-color: rgba(232, 135, 58, 0.55);
  box-shadow: 0 0 0 3px rgba(232, 135, 58, 0.12);
}

.gate-card .auth-textarea {
  width: 100%;
  min-height: 4.5rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid transparent;
  border-radius: 10px;
  background: #13171c;
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
  resize: vertical;
}

.gate-card .auth-textarea:focus {
  outline: none;
  border-color: rgba(232, 135, 58, 0.55);
  box-shadow: 0 0 0 3px rgba(232, 135, 58, 0.12);
}

.auth-note {
  margin: 0 0 0.75rem;
  font-size: 0.82rem;
  line-height: 1.4;
  color: var(--text-dim);
}

.auth-link {
  display: block;
  width: 100%;
  margin-top: 0.65rem;
  padding: 0.35rem 0;
  border: none;
  background: transparent;
  color: var(--brand);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  text-align: center;
}

.auth-link:hover {
  text-decoration: underline;
}

.gate-footer {
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--stroke);
}

.gate-about-pill {
  width: 100%;
  margin: 0;
  padding: 0.55rem 0.85rem;
  border: 1px solid rgba(232, 135, 58, 0.28);
  border-radius: 999px;
  background: rgba(232, 135, 58, 0.07);
  color: var(--brand);
  font: inherit;
  font-size: 0.84rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition:
    background var(--motion) var(--ease-out),
    border-color var(--motion) var(--ease-out);
}

.gate-about-pill:hover {
  background: rgba(232, 135, 58, 0.12);
  border-color: rgba(232, 135, 58, 0.45);
}

.brand.center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.85rem;
}

.brand-name {
  margin: 0;
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: lowercase;
  color: var(--brand);
}

.brand-name-expanded {
  font-size: 1.05rem;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0.02em;
  line-height: 1.3;
  text-align: center;
  max-width: 17.5rem;
}

.brand-motto {
  margin: 0.3rem 0 0;
  font-size: 0.58rem;
  font-weight: 400;
  color: rgba(127, 145, 164, 0.38);
  letter-spacing: 0.06em;
  user-select: none;
}

.brand-acronym {
  margin: 0.35rem 0 0;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--brand);
}

.brand-word-btn {
  cursor: pointer;
}

.brand-word {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background: #15181d;
  border: 1px solid var(--brand-dim);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: none;
  color: var(--brand);
  -webkit-font-smoothing: subpixel-antialiased;
}

/* ——— мессенджер (2 колонки) ——— */
.messenger {
  display: grid;
  grid-template-columns: minmax(260px, min(34vw, 380px)) minmax(0, 1fr);
  height: 100dvh;
  height: 100svh;
  width: 100%;
  max-width: min(1600px, 100%);
  margin: 0 auto;
  background: var(--chat-bg);
}

.sidebar {
  background: var(--sidebar);
  border-right: 1px solid var(--stroke);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sidebar-toolbar {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: calc(0.7rem + var(--sidebar-top-inset)) 0.75rem 0.75rem;
  min-height: calc(3.45rem + var(--sidebar-top-inset));
  border-bottom: 1px solid var(--stroke);
}

.sidebar-user-block {
  flex: 1;
  min-width: 0;
}

.tg-avatar-btn {
  border: none;
  background: transparent;
  padding: 0;
  cursor: default;
  flex-shrink: 0;
}

.tg-icon-btn {
  width: 2.25rem;
  height: 2.25rem;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--brand);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}

.tg-icon-btn:hover {
  background: var(--item-hover);
}

.sidebar-foot {
  padding: 0.35rem 0.65rem 0.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}

body.modal-open {
  overflow: hidden;
}

.sidebar-me-name {
  font-weight: 600;
  font-size: 15px;
  line-height: 1.25;
  color: #c0c8d2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  -webkit-font-smoothing: subpixel-antialiased;
  text-rendering: optimizeSpeed;
}

.sidebar-me-login {
  margin-top: 0.12rem;
  font-size: 13px;
  line-height: 1.3;
  font-weight: 500;
  color: #7a8490;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  -webkit-font-smoothing: subpixel-antialiased;
}

.sidebar-search {
  padding: 0.35rem 0.75rem 0.2rem;
}

.search-hint {
  margin: 0.3rem 0.25rem 0;
  font-size: 0.75rem;
  color: #e8a070;
}

.search-hint:empty {
  display: none;
  margin: 0;
}

.sidebar-search input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: none;
  border-radius: 20px;
  background: #13171c;
  color: var(--text);
  font-size: 0.9rem;
}

.contacts-block {
  flex-shrink: 0;
  max-height: min(38dvh, 16rem);
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid var(--stroke);
  margin: 0 0 0.25rem;
}

.contacts-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.35rem 0.75rem 0.35rem;
}

.contacts-title {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--brand);
}

.contacts-add {
  width: 1.85rem;
  height: 1.85rem;
  font-size: 1.1rem;
}

.contact-list {
  list-style: none;
  margin: 0;
  padding: 0 0 0.35rem;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.contact-list-empty {
  margin: 0;
  padding: 0.35rem 0.85rem 0.55rem;
  font-size: 0.74rem;
  line-height: 1.35;
  color: var(--text-dim);
}

.contact-list-empty.hidden {
  display: none;
}

.contact-list-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.55rem;
  cursor: pointer;
  content-visibility: auto;
  contain-intrinsic-size: auto 2.75rem;
  contain: layout style paint;
}

.contact-list-item:hover {
  background: var(--item-hover);
}

.contact-list-item.active {
  background: var(--item-active);
}

.contact-list-item .avatar {
  width: 2.15rem;
  height: 2.15rem;
}

.contact-list-meta {
  flex: 1;
  min-width: 0;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.contact-list-item .avatar-wrap {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.contact-list-name {
  font-size: 0.88rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.contact-list-login {
  font-size: 0.72rem;
  color: var(--text-dim);
}

.contact-quick-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

.quick-call-cluster {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--stroke);
  border-radius: 10px;
  overflow: hidden;
  background: rgba(18, 22, 28, 0.92);
}

.quick-call-btn {
  display: inline-grid;
  place-items: center;
  width: 2.25rem;
  height: 2rem;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--brand);
  font: inherit;
  cursor: pointer;
  flex-shrink: 0;
  transition:
    background 0.15s ease,
    color 0.15s ease;
}

.quick-call-btn .call-ico {
  width: 1.05rem;
  height: 1.05rem;
  fill: currentColor;
}

.quick-call-btn + .quick-call-btn {
  border-left: 1px solid var(--stroke);
}

.quick-call-btn:hover {
  color: #ffb070;
  background: rgba(232, 135, 58, 0.14);
}

.quick-call-btn:active {
  transform: scale(0.97);
}

.quick-call-remove {
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--stroke);
  border-radius: 10px;
  background: rgba(18, 22, 28, 0.92);
  color: #9a8888;
  font-size: 0.82rem;
  font-weight: 600;
}

.quick-call-remove:hover {
  color: #e8a090;
  border-color: rgba(200, 120, 100, 0.35);
  background: rgba(80, 40, 36, 0.35);
}

.quick-call-cluster-text {
  border-radius: 999px;
}

.conv-call-seg {
  display: inline-grid;
  place-items: center;
  width: auto;
  height: auto;
  min-height: 2rem;
  margin: 0;
  padding: 0.38rem 0.62rem;
  border: none;
  border-radius: 0;
  background: transparent;
  font: inherit;
  font-size: 0.76rem;
  font-weight: 600;
  line-height: 1.1;
  white-space: nowrap;
  color: var(--text);
  cursor: pointer;
  transition:
    background 0.15s ease,
    color 0.15s ease;
}

.conv-call-seg + .conv-call-seg {
  border-left: 1px solid var(--stroke);
}

.conv-call-seg:hover {
  color: var(--brand);
  background: rgba(232, 135, 58, 0.12);
}

.conv-call-seg:active {
  transform: scale(0.98);
}

.conv-actions .quick-call-cluster-text {
  flex-shrink: 0;
}

.btn-call-icon {
  display: inline-grid;
  place-items: center;
  width: 2.125rem;
  height: 2.125rem;
  border: 1px solid var(--stroke);
  background: rgba(18, 22, 28, 0.92);
  color: var(--brand);
  border-radius: 10px;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease,
    transform 0.1s ease;
}

.btn-call-icon .call-ico {
  width: 1.1rem;
  height: 1.1rem;
  fill: currentColor;
  display: block;
}

.btn-call-icon:hover {
  color: #ffb070;
  border-color: var(--brand-dim);
  background: rgba(232, 135, 58, 0.16);
}

.btn-call-icon:active {
  transform: scale(0.94);
}

.conv-actions .btn-call-icon {
  width: 2.35rem;
  height: 2.35rem;
  border-radius: 11px;
}

.conv-actions .btn-call-icon .call-ico {
  width: 1.15rem;
  height: 1.15rem;
}


.sidebar-tabs {
  display: flex;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem 0;
}

.sidebar-tab {
  flex: 1;
  border: none;
  border-radius: 10px;
  padding: 0.45rem 0.65rem;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-dim);
  background: transparent;
  cursor: pointer;
}

.sidebar-tab.is-active {
  color: var(--text);
  background: rgba(232, 135, 58, 0.14);
}

.sidebar-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.sidebar-panel.hidden {
  display: none !important;
}

.calls-tab-note {
  margin: 0;
  padding: 0.35rem 0.75rem 0.65rem;
  font-size: 0.72rem;
  line-height: 1.35;
  color: var(--text-dim);
}

.calls-tab-list .chat-list-preview {
  font-size: 0.78rem;
}

.call-tab-dir {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
}

.chats-section-label {
  margin: 0.15rem 0 0;
  padding: 0.55rem 0.75rem 0.25rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.chat-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  flex: 1;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.chat-list-item {
  display: flex;
  gap: 0.65rem;
  padding: 0.55rem 0.75rem;
  cursor: pointer;
  align-items: center;
  content-visibility: auto;
  contain-intrinsic-size: auto 3.25rem;
  contain: layout style paint;
}

.chat-list-item:hover {
  background: var(--item-hover);
}

.chat-list-item.active {
  background: var(--item-active);
}

.chat-list-item .avatar {
  flex-shrink: 0;
}

.chat-list-meta {
  min-width: 0;
  flex: 1;
}

.chat-list-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}

.chat-list-name {
  font-weight: 500;
  font-size: 0.92rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.chat-list-time {
  font-size: 0.72rem;
  color: var(--text-dim);
  flex-shrink: 0;
}

.chat-list-item.active .chat-list-time {
  color: rgba(255, 255, 255, 0.75);
}

.chat-list-preview {
  font-size: 0.78rem;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 0.15rem;
}

.chat-list-empty {
  padding: 1rem 0.75rem;
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-dim);
  text-align: center;
}

.conversation {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--chat-bg-pattern);
  position: relative;
}

.conv-empty {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: var(--chat-bg-pattern);
}

.welcome-card {
  width: min(100%, 20rem);
  padding: 1.5rem 1.35rem 1.25rem;
  border-radius: 20px;
  text-align: center;
  background: linear-gradient(165deg, rgba(18, 22, 28, 0.96) 0%, rgba(8, 9, 11, 0.98) 100%);
  border: 1px solid rgba(232, 135, 58, 0.16);
  box-shadow:
    0 20px 48px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(232, 135, 58, 0.07);
}

.conv-welcome-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
}

.welcome-secure-line {
  margin: 0.55rem 0 0.85rem;
  font-size: 0.84rem;
  line-height: 1.45;
  color: var(--text-dim);
}

.conv-welcome-sub {
  margin: 0.65rem 0 0;
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--text-dim);
}

.conv-active {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.conv-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: calc(0.45rem + var(--safe-top)) calc(0.75rem + var(--safe-right)) 0.45rem
    calc(0.75rem + var(--safe-left));
  background: var(--sidebar);
  border-bottom: 1px solid var(--stroke);
  min-height: calc(3.25rem + var(--safe-top));
  position: relative;
  z-index: 2;
}

.conv-peer strong,
.peer-login,
.peer-status,
.btn-call-text {
  text-rendering: auto;
}

.conv-peer {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex: 1;
  min-width: 0;
}

.conv-peer strong,
.peer-display-name {
  display: block;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.2;
  color: #c4ccd6;
  letter-spacing: -0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  -webkit-font-smoothing: subpixel-antialiased;
  -moz-osx-font-smoothing: auto;
}

.peer-status {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.conv-actions {
  display: flex;
  gap: 0.35rem;
  align-items: center;
  flex-shrink: 0;
}

.btn-call-text {
  border: 1px solid var(--stroke);
  background: rgba(36, 47, 61, 0.75);
  color: var(--text);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.38rem 0.65rem;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  line-height: 1.2;
}

.btn-call-text:hover {
  color: var(--brand);
  border-color: var(--brand-dim);
  background: rgba(232, 135, 58, 0.12);
}

.btn-call-text:active {
  transform: scale(0.97);
}

.avatar-wrap {
  position: relative;
  flex-shrink: 0;
}

.avatar {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background: #15181d;
  border: 1px solid #2a2f36;
  color: var(--brand);
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 1rem;
  text-transform: uppercase;
}

.avatar.avatar-gen {
  padding: 0;
  overflow: hidden;
  color: transparent;
  font-size: 0;
  border-color: rgba(232, 135, 58, 0.22);
  background: #0c0e12;
}

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

.status-dot {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 50%;
  border: 2px solid var(--sidebar);
  background: #5a6470;
}

.status-dot.on {
  background: #4cd964;
}

.peer-status.on {
  color: #4cd964;
}

.thread {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 0.75rem max(1rem, var(--safe-right)) 1rem max(1rem, var(--safe-left));
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  scroll-behavior: auto;
  contain: layout style;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.9 0 0 0 0 0.85 0 0 0 0 0.75 0 0 0 0.035 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.day-sep {
  align-self: center;
  margin: 0.55rem 0 0.25rem;
  padding: 0.28rem 0.75rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #c8d0d8;
  background: rgba(12, 16, 22, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(8px);
}

.bubble {
  content-visibility: auto;
  contain-intrinsic-size: auto 2.25rem;
  contain: layout style paint;
  position: relative;
  max-width: min(78%, 28rem);
  padding: 0.5rem 0.75rem 0.4rem;
  border-radius: 16px;
  font-size: 0.94rem;
  line-height: 1.42;
  word-wrap: break-word;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.28),
    0 6px 16px rgba(0, 0, 0, 0.12);
}

.bubble.in {
  background: linear-gradient(165deg, #151c24 0%, var(--bubble-in) 100%);
  align-self: flex-start;
  border-bottom-left-radius: 5px;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.bubble.out {
  background: linear-gradient(165deg, #243446 0%, var(--bubble-out) 100%);
  align-self: flex-end;
  border-bottom-right-radius: 5px;
  border: 1px solid rgba(232, 135, 58, 0.1);
}

.bubble.bubble-has-media {
  max-width: min(92%, 22rem);
  padding: 0.35rem;
}

.bubble-sender {
  font-size: 0.72rem;
  font-weight: 650;
  color: var(--brand);
  margin: 0 0 0.2rem;
}

.bubble-reply {
  margin: 0 0 0.35rem;
  padding: 0.3rem 0.5rem;
  border-left: 2px solid var(--brand);
  border-radius: 0 8px 8px 0;
  background: rgba(0, 0, 0, 0.22);
  font-size: 0.78rem;
  color: var(--text-dim);
  line-height: 1.3;
  max-height: 3.2rem;
  overflow: hidden;
}

.bubble-body {
  display: block;
}

.bubble-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.28rem;
  margin-top: 0.2rem;
  font-size: 0.68rem;
  color: rgba(180, 190, 200, 0.72);
  line-height: 1;
  user-select: none;
}

.bubble.out .bubble-meta {
  color: rgba(200, 210, 220, 0.78);
}

.bubble-checks {
  letter-spacing: -0.08em;
  opacity: 0.85;
  color: #8eb8e8;
}

.bubble-checks.is-read {
  color: #6ec8ff;
}

.bubble.bubble-call {
  display: flex;
  align-items: center;
  font-size: 0.86rem;
  padding: 0.4rem 0.65rem;
  max-width: min(88%, 24rem);
}

.bubble.bubble-call-center {
  align-self: center;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.bubble-call-inner {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
}

.bubble-call-inner .call-ico {
  width: 1.05rem;
  height: 1.05rem;
  flex-shrink: 0;
  opacity: 0.9;
}

.bubble-call-text {
  line-height: 1.35;
}

.media-viewer {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: calc(1rem + var(--safe-top)) 0.75rem calc(1rem + var(--safe-bottom));
}

.media-viewer-scrim {
  position: absolute;
  inset: 0;
  border: none;
  background: rgba(0, 0, 0, 0.92);
  cursor: pointer;
}

.media-viewer-close {
  position: absolute;
  top: calc(0.65rem + var(--safe-top));
  right: max(0.75rem, var(--safe-right));
  z-index: 2;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(18, 22, 28, 0.85);
  color: #e8e0d6;
  border-radius: 50%;
  width: 2.5rem;
  height: 2.5rem;
  font-size: 1.1rem;
  cursor: pointer;
}

.media-viewer-body {
  position: relative;
  z-index: 1;
  width: min(100%, 42rem);
  max-height: min(78dvh, 36rem);
  display: grid;
  place-items: center;
}

.media-viewer-el {
  max-width: 100%;
  max-height: min(78dvh, 36rem);
  border-radius: 12px;
  object-fit: contain;
  background: #000;
}

.media-viewer-caption {
  position: relative;
  z-index: 1;
  margin: 0.65rem 0 0;
  max-width: min(100%, 42rem);
  text-align: center;
  font-size: 0.88rem;
  color: #c4ccd6;
}

.composer {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.15rem;
  padding: 0.45rem max(0.75rem, var(--safe-right)) calc(0.65rem + var(--safe-bottom))
    max(0.75rem, var(--safe-left));
  background: var(--sidebar);
  border-top: 1px solid var(--stroke);
}

.btn-attach {
  flex-shrink: 0;
  width: 2.5rem;
  height: 2.5rem;
  border: none;
  border-radius: 50%;
  background: transparent;
  font-size: 1.25rem;
  cursor: pointer;
  line-height: 1;
  padding: 0;
}

.btn-attach:hover {
  background: var(--item-hover);
}

.bubble-sender {
  font-size: 0.72rem;
  color: var(--accent);
  margin-bottom: 0.25rem;
}

.msg-media {
  max-width: 100%;
  border-radius: 8px;
  display: block;
}

.msg-image {
  width: 100%;
  max-height: min(52vh, 20rem);
  object-fit: contain;
  cursor: zoom-in;
  background: #0a0c10;
}

.msg-video-wrap {
  position: relative;
  width: 100%;
}

.msg-video {
  width: 100%;
  max-height: min(52vh, 20rem);
  background: #000;
  border-radius: 8px;
  vertical-align: middle;
}

.msg-video-expand {
  position: absolute;
  right: 6px;
  top: 6px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.55);
  color: #e8e0d6;
  border-radius: 8px;
  width: 2rem;
  height: 2rem;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  display: grid;
  place-items: center;
}

.msg-video-expand svg {
  width: 1rem;
  height: 1rem;
  fill: currentColor;
}

.msg-media-missing {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.msg-caption {
  margin: 0.35rem 0 0;
  font-size: 0.9rem;
}

.msg-file {
  color: #9ec5f5;
  text-decoration: underline;
}

.composer textarea {
  flex: 1;
  min-height: 2.5rem;
  max-height: 8rem;
  resize: none;
  border: none;
  border-radius: 20px;
  padding: 0.55rem 1rem;
  background: #13171c;
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
}

.composer textarea:focus {
  outline: 2px solid rgba(232, 135, 58, 0.45);
  outline-offset: 1px;
}

.btn-send {
  width: 2.5rem;
  height: 2.5rem;
  border: none;
  border-radius: 50%;
  background: var(--brand);
  color: var(--on-brand);
  font-size: 1.15rem;
  cursor: pointer;
  flex-shrink: 0;
}

.btn-icon {
  width: 2.25rem;
  height: 2.25rem;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-dim);
  font-size: 1.1rem;
  cursor: pointer;
}

.btn-icon:hover {
  background: var(--item-hover);
  color: var(--text);
}

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

/* ——— формы ——— */
.segmented {
  display: flex;
  padding: 0.25rem;
  gap: 0.25rem;
  background: #0f1216;
  border-radius: 12px;
  margin-bottom: 1rem;
}

.segment {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-dim);
  padding: 0.52rem 0.45rem;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  -webkit-tap-highlight-color: transparent;
}

.segment.active {
  background: var(--chat-bg);
  color: var(--text);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.04),
    0 4px 14px rgba(0, 0, 0, 0.28);
}

.segment:focus-visible {
  outline: 2px solid rgba(232, 135, 58, 0.55);
  outline-offset: 1px;
}

.tab-panel {
  animation: auth-panel-in 0.22s var(--ease-out, ease-out) both;
}

.tab-panel.hidden {
  animation: none;
}

@keyframes auth-panel-in {
  from {
    opacity: 0.88;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

label {
  display: block;
  margin: 0.5rem 0 0.25rem;
  font-size: 0.78rem;
  color: var(--text-dim);
}

input[type="text"],
input[type="password"],
input[type="search"] {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  border: 1px solid var(--stroke);
  background: #242f3d;
  color: var(--text);
  font: inherit;
}

.btn {
  padding: 0.55rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--stroke);
  background: #242f3d;
  color: var(--text);
  cursor: pointer;
  font: inherit;
}

.btn-primary {
  width: 100%;
  margin-top: 1.1rem;
  padding: 0.65rem 1rem;
  background: var(--brand);
  border-color: var(--brand-dim);
  color: var(--on-brand);
  font-weight: 600;
}

.btn-primary:disabled {
  opacity: 0.5;
}

.login-row {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}

.login-row input {
  flex: 1;
  min-width: 0;
}

.gate-card .login-row input {
  width: auto;
}

.gate-card .btn-secondary {
  flex-shrink: 0;
  width: 2.75rem;
  padding: 0;
  font-size: 1.1rem;
  line-height: 1;
  background: #2b3947;
  border-color: transparent;
}

.btn-block {
  width: 100%;
  margin-top: 0.5rem;
}

.btn-block-sm {
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.45rem;
  font-size: 0.85rem;
}

.btn-logout {
  margin-top: 1rem;
  border-color: rgba(200, 90, 80, 0.45);
  color: #d8a8a0;
  background: rgba(48, 22, 20, 0.85);
}

.btn-logout:hover {
  border-color: rgba(220, 100, 90, 0.65);
  color: #e8c0b8;
}

.btn-ghost {
  border-color: rgba(232, 135, 58, 0.22);
  color: var(--brand);
  background: transparent;
}

.btn-ghost:hover {
  background: rgba(232, 135, 58, 0.1);
  border-color: rgba(232, 135, 58, 0.4);
}

/* ——— модалка «Новая группа» (как Telegram) ——— */
.tg-modal {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: flex;
  align-items: stretch;
  justify-content: flex-end;
}

.tg-modal-scrim {
  position: absolute;
  inset: 0;
  border: none;
  background: rgba(0, 0, 0, 0.45);
  cursor: pointer;
}

.tg-modal-panel {
  position: relative;
  z-index: 1;
  width: min(100%, 400px);
  max-height: 100dvh;
  background: linear-gradient(180deg, #0e1116 0%, #0a0c0f 100%);
  display: flex;
  flex-direction: column;
  box-shadow: -12px 0 40px rgba(0, 0, 0, 0.55);
  border-left: 1px solid rgba(232, 135, 58, 0.08);
  animation: tg-slide-in 0.22s ease-out;
}

@keyframes tg-slide-in {
  from {
    transform: translateX(16px);
    opacity: 0.85;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

.tg-modal-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.5rem;
  border-bottom: 1px solid var(--stroke);
  min-height: 3rem;
}

.tg-back {
  border: none;
  background: transparent;
  color: var(--brand);
  font-size: 1.75rem;
  line-height: 1;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  cursor: pointer;
}

.tg-back:hover {
  background: var(--item-hover);
}

.tg-modal-title {
  flex: 1;
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.tg-done {
  border: none;
  background: transparent;
  color: var(--brand);
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.35rem 0.65rem;
  border-radius: 8px;
  cursor: pointer;
}

.tg-done:disabled {
  opacity: 0.4;
  cursor: default;
}

.tg-modal-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0.75rem 0.85rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.tg-input-lg {
  width: 100%;
  border: none;
  border-bottom: 1px solid var(--stroke);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 1.05rem;
  padding: 0.55rem 0.15rem;
  box-sizing: border-box;
}

.tg-input-lg:focus {
  outline: none;
  border-color: rgba(232, 135, 58, 0.55);
}

.tg-section-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--brand);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 0.35rem;
}

.tg-search-inline {
  width: 100%;
  padding: 0.45rem 0.75rem;
  border: none;
  border-radius: 18px;
  background: #242f3d;
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
}

.tg-sub {
  margin: 0;
  font-size: 0.78rem;
  color: var(--text-dim);
}

.field-label {
  display: block;
  margin: 0.2rem 0 0.35rem;
  font-size: 0.78rem;
  color: var(--text-dim);
}

.profile-body {
  gap: 1rem;
}

.profile-card {
  padding: 0.65rem 0.75rem 0.85rem;
  border-radius: 14px;
  background: var(--surface-card);
  border: 1px solid var(--stroke);
}

.profile-login-line {
  margin: 0.85rem 0 0;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
}

.profile-login-line span {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.95rem;
  text-transform: none;
  letter-spacing: 0;
  color: var(--brand);
  font-weight: 600;
}

.profile-actions {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: auto;
  padding-top: 0.25rem;
}

#profile-hint {
  min-height: 1.25rem;
  margin-top: 0.5rem;
  font-size: 0.82rem;
  color: #8eb89a;
}

.btn-about-inline {
  margin-top: 0.75rem;
  border-color: rgba(232, 135, 58, 0.35);
  color: var(--brand);
  background: rgba(232, 135, 58, 0.08);
}

.btn-about-inline:hover {
  border-color: rgba(232, 135, 58, 0.55);
  background: rgba(232, 135, 58, 0.12);
}

.conv-about-link {
  margin-top: 0.5rem;
}

.about-panel .tg-modal-body {
  padding-bottom: calc(1rem + var(--safe-bottom));
}

.about-body {
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--text-dim);
}

.about-lead {
  margin: 0 0 1rem;
  color: var(--text);
}

.about-brand {
  color: var(--brand);
  font-weight: 600;
}

.about-modal {
  justify-content: center;
  align-items: center;
  padding: max(0.75rem, var(--safe-top)) 0.75rem max(0.75rem, var(--safe-bottom));
}

.about-modal .about-panel {
  width: min(100%, 26.5rem);
  max-height: min(90dvh, 720px);
  border-radius: 18px;
  border: 1px solid rgba(232, 135, 58, 0.16);
  box-shadow:
    0 28px 72px rgba(0, 0, 0, 0.65),
    inset 0 1px 0 rgba(232, 135, 58, 0.07);
  animation: about-in 0.32s var(--ease-out) both;
}

@keyframes about-in {
  from {
    opacity: 0.85;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.about-hero {
  text-align: center;
  margin-bottom: 0.25rem;
}

.about-shield {
  width: 3.1rem;
  height: 3.1rem;
  margin: 0 auto 0.65rem;
  border-radius: 50%;
  border: 1px solid rgba(232, 135, 58, 0.35);
  background:
    radial-gradient(circle at 30% 25%, rgba(232, 135, 58, 0.4), rgba(232, 135, 58, 0.06) 62%, #0c0e12 100%);
  box-shadow: 0 0 28px var(--brand-glow);
  position: relative;
}

.about-shield::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 0.95rem;
  height: 1.1rem;
  border: 2px solid rgba(232, 160, 90, 0.85);
  border-radius: 3px 3px 6px 6px;
  box-shadow: inset 0 -4px 0 rgba(232, 135, 58, 0.25);
}

.about-hero-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.35;
  max-width: 16rem;
  margin-inline: auto;
}

.about-hero-tag {
  margin: 0.25rem 0 0.75rem;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--brand);
}

.about-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.35rem;
}

.about-chips-sm {
  margin: 0 0 0.85rem;
}

.about-chip {
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #e8b078;
  border: 1px solid rgba(232, 135, 58, 0.28);
  background: rgba(232, 135, 58, 0.08);
}

.about-card {
  margin-top: 0.65rem;
  padding: 0.7rem 0.75rem;
  border-radius: 12px;
  background: var(--surface-card);
  border: 1px solid var(--stroke);
}

.about-card-muted {
  opacity: 0.92;
}

.about-card .about-h {
  margin: 0 0 0.35rem;
}

.about-h-muted {
  color: var(--text-dim);
}

.about-p {
  margin: 0 0 0.35rem;
  font-size: 0.84rem;
  line-height: 1.45;
}

.about-points {
  margin: 0;
  padding: 0;
  list-style: none;
}

.about-points li {
  position: relative;
  padding-left: 0.85rem;
  margin: 0.3rem 0;
  font-size: 0.84rem;
  line-height: 1.4;
}

.about-points li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.55em;
  width: 0.3rem;
  height: 0.3rem;
  border-radius: 50%;
  background: var(--brand);
  opacity: 0.75;
}

.about-points span {
  color: #d4a67a;
  font-weight: 500;
}

.about-h {
  margin: 1.1rem 0 0.45rem;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--brand);
}

.about-list {
  margin: 0;
  padding-left: 1.1rem;
}

.about-list li {
  margin: 0.35rem 0;
}

.about-list-dim li {
  color: var(--text-dim);
}

.about-note {
  margin: 0.75rem 0 0;
  padding: 0.6rem 0.7rem;
  border-radius: 10px;
  font-size: 0.84rem;
  line-height: 1.4;
}

.about-note-good {
  border: 1px solid rgba(120, 180, 140, 0.28);
  background: rgba(30, 48, 38, 0.45);
  color: #a8c8b4;
}

.about-footer {
  margin: 1.15rem 0 0;
  font-size: 0.82rem;
  color: var(--text-dim);
}

.tg-modal-spacer {
  width: 2.25rem;
}

.tg-picker-list {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1;
  min-height: 8rem;
}

.group-member-list,
.tg-picker-list {
  overflow-y: auto;
}

.group-member-pick {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.5rem 0.6rem;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.group-member-pick:last-child {
  border-bottom: none;
}

.group-member-pick:hover {
  background: rgba(255, 255, 255, 0.04);
}

.group-member-pick.empty {
  justify-content: center;
  color: #7f91a4;
  font-size: 0.85rem;
  cursor: default;
}

.group-member-pick input {
  width: 1.1rem;
  height: 1.1rem;
  flex-shrink: 0;
}

.group-member-pick .pick-avatar {
  width: 2.1rem;
  height: 2.1rem;
  flex-shrink: 0;
}

.group-member-pick .pick-meta {
  flex: 1;
  min-width: 0;
}

.group-member-pick .pick-name {
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.group-member-pick .pick-login {
  font-size: 0.76rem;
  color: #7f91a4;
}

.btn-icon.btn-contact-saved {
  color: var(--brand);
  border-color: rgba(232, 135, 58, 0.45);
  background: rgba(232, 135, 58, 0.12);
}

.btn-icon.sm {
  padding: 0.2rem 0.45rem;
  font-size: 0.85rem;
}

.avatar.group.avatar-gen {
  border-color: rgba(232, 135, 58, 0.3);
}

.field-hint {
  margin: 0.35rem 0 0.85rem;
  font-size: 0.78rem;
  color: #7f91a4;
  line-height: 1.35;
}

.req {
  color: #6ab0e8;
}

.optional {
  color: #7f91a4;
  font-weight: normal;
  font-size: 0.85em;
}

.peer-login {
  display: block;
  font-size: 13px;
  line-height: 1.25;
  color: #6e7886;
  font-weight: 400;
  -webkit-font-smoothing: subpixel-antialiased;
}

.server-status {
  margin: 0.75rem 0 0;
  font-size: 0.78rem;
  color: #e8a070;
  text-align: center;
  line-height: 1.35;
}

.notice-error {
  color: #f0a0a0;
  font-size: 0.88rem;
}

.notice-warn {
  color: #e8c27a;
  font-size: 0.88rem;
}

.creds-card pre {
  margin: 0;
  padding: 0.75rem;
  background: #242f3d;
  border-radius: 8px;
  font-size: 0.82rem;
  white-space: pre-wrap;
}

.check {
  display: flex;
  gap: 0.5rem;
  margin: 0.75rem 0;
  font-size: 0.9rem;
}

.hint {
  font-size: 0.82rem;
  color: var(--text-dim);
  min-height: 1rem;
}

.dlg {
  border: 1px solid var(--stroke);
  border-radius: 12px;
  padding: 0;
  background: var(--sidebar);
  color: var(--text);
  max-width: 22rem;
}

.dlg::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

.dlg-body {
  padding: 1.25rem;
}

.dlg-body h3 {
  margin: 0 0 0.75rem;
}

.dlg-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
}

.dlg-actions .btn-primary {
  width: auto;
  margin-top: 0;
}

.call-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
  width: min(100%, 24rem);
  text-align: center;
}

.call-status {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: #e8e0d6;
  letter-spacing: -0.02em;
}

.call-secure-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  border: 1px solid rgba(232, 135, 58, 0.22);
  background: rgba(18, 22, 28, 0.55);
  color: #9eb89a;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition:
    border-color 0.25s ease,
    background 0.25s ease,
    color 0.25s ease;
}

.call-secure-ico {
  width: 0.9rem;
  height: 0.9rem;
  fill: currentColor;
  flex-shrink: 0;
  opacity: 0.9;
}

.call-secure-text {
  line-height: 1.2;
}

.call-secure-dot {
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: rgba(140, 170, 140, 0.35);
  flex-shrink: 0;
  transition:
    background 0.25s ease,
    box-shadow 0.25s ease;
}

.call-secure-badge.is-live {
  border-color: rgba(120, 190, 130, 0.45);
  background: rgba(24, 40, 32, 0.65);
  color: #b8dcc0;
}

.call-secure-badge.is-pending {
  border-color: rgba(232, 160, 90, 0.35);
  background: rgba(28, 24, 20, 0.6);
  color: #d4c4b0;
}

.call-secure-badge.is-live .call-secure-dot {
  background: #6fcf97;
  box-shadow: 0 0 8px rgba(111, 207, 151, 0.75);
}

.call-secure-badge.is-pending .call-secure-dot {
  background: rgba(232, 160, 90, 0.75);
  animation: call-secure-pulse 1.25s ease-in-out infinite;
}

@keyframes call-secure-pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.55;
    transform: scale(0.92);
  }
}

.call-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.88);
  backdrop-filter: blur(16px) saturate(1.1);
  -webkit-backdrop-filter: blur(16px) saturate(1.1);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: calc(1rem + var(--safe-top)) 1rem calc(1rem + var(--safe-bottom));
}

.call-peer-name {
  margin: 0 0 0.15rem;
  font-size: 1.45rem;
  font-weight: 600;
  color: var(--text);
  text-align: center;
}

.call-route-hint {
  margin: 0.35rem 0 0;
  max-width: 18rem;
  font-size: 0.78rem;
  line-height: 1.35;
  text-align: center;
  color: rgba(232, 180, 120, 0.95);
}

.call-route-hint.call-route-static {
  color: var(--text-dim);
  font-size: 0.74rem;
  letter-spacing: 0.02em;
}

.call-overlay.call-audio-only .call-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  aspect-ratio: auto;
  max-height: none;
  width: 100%;
  background: transparent;
  box-shadow: none;
}

.call-audio-avatar {
  width: 7.5rem;
  height: 7.5rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 2.4rem;
  font-weight: 600;
  color: var(--brand);
  background: linear-gradient(145deg, rgba(232, 135, 58, 0.22), rgba(15, 18, 22, 0.9));
  border: 2px solid rgba(232, 135, 58, 0.35);
  margin-bottom: 1rem;
}

.call-overlay.call-audio-only .call-placeholder {
  display: none;
}

.call-overlay.call-audio-only .call-secure-badge {
  margin-top: 0.25rem;
}

.call-overlay.call-live .call-stage {
  animation: call-stage-in 0.45s var(--ease-out) both;
}

.call-stage {
  width: min(100%, 26rem);
  max-height: min(68dvh, 32rem);
  aspect-ratio: 3 / 4;
  border-radius: 16px;
  overflow: hidden;
  background: #000;
  position: relative;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
}

.call-overlay.group-video .call-stage {
  width: min(100vw - 2rem, 40rem);
  aspect-ratio: auto;
  min-height: 14rem;
  max-height: 72vh;
}

.call-remote-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
  width: 100%;
  height: 100%;
  min-height: 12rem;
  padding: 4px;
  box-sizing: border-box;
}

.call-remote-grid.tiles-1 {
  grid-template-columns: 1fr;
}

.call-remote-grid.tiles-2 {
  grid-template-columns: repeat(2, 1fr);
}

.call-remote-grid.tiles-3plus {
  grid-template-columns: repeat(2, 1fr);
  grid-auto-rows: minmax(8rem, 1fr);
}

.call-remote-tile-wrap {
  position: relative;
  background: #111;
  border-radius: 8px;
  overflow: hidden;
  min-height: 8rem;
}

.call-remote-tile {
  width: 100%;
  height: 100%;
  min-height: 8rem;
  object-fit: cover;
  display: block;
}

.call-tile-label {
  position: absolute;
  left: 6px;
  bottom: 6px;
  font-size: 0.72rem;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.55);
  color: #e8eef4;
}

.call-remote,
.call-local {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* 1:1 видео — без обрезки, рамка по пропорциям потока */
.call-overlay.call-video:not(.group-video) .call-stage {
  width: min(100%, 40rem);
  max-height: min(78dvh, calc(100vw - 1.5rem));
  aspect-ratio: 16 / 9;
  min-height: 10rem;
}

.call-overlay.call-video:not(.group-video) .call-remote,
.call-overlay.call-video:not(.group-video) .call-local {
  object-fit: contain;
  background: #000;
}

.call-overlay.call-video:not(.group-video) .call-remote,
.call-overlay.call-video:not(.group-video) .call-local {
  position: absolute;
}

/* Основной поток — на весь экран */
.call-overlay.call-video:not(.group-video):not(.call-video-focus-local) .call-remote {
  inset: 0;
  width: 100%;
  height: 100%;
  max-height: none;
  z-index: 1;
  border: none;
  border-radius: 0;
  box-shadow: none;
}

.call-overlay.call-video:not(.group-video).call-video-focus-local .call-local {
  inset: 0;
  width: 100%;
  height: 100%;
  max-height: none;
  z-index: 1;
  border: none;
  border-radius: 0;
  box-shadow: none;
  right: auto;
  bottom: auto;
}

/* Мини-окно (PIP) */
.call-overlay.call-video:not(.group-video) .call-pip-slot {
  right: 0.5rem;
  bottom: 0.5rem;
  left: auto;
  top: auto;
  width: min(30%, 9.5rem);
  max-height: 32%;
  height: auto;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 10px;
  z-index: 3;
  cursor: pointer;
  border: 2px solid rgba(232, 135, 58, 0.45);
  box-shadow:
    0 4px 24px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(0, 0, 0, 0.35);
  transition:
    transform 0.2s var(--ease-out),
    box-shadow 0.2s ease;
}

.call-overlay.call-video:not(.group-video) .call-remote:not(.call-pip-slot),
.call-overlay.call-video:not(.group-video) .call-local:not(.call-pip-slot) {
  object-fit: contain;
}

.call-overlay.call-video:not(.group-video) .call-pip-slot:active {
  transform: scale(0.96);
}

.call-overlay.group-video .call-local {
  display: block;
}

.call-local {
  position: absolute;
  right: 0.5rem;
  bottom: 0.5rem;
  width: 28%;
  height: auto;
  max-height: 30%;
  border-radius: 8px;
  z-index: 2;
}

.call-overlay.group-video .call-local {
  width: 22%;
  max-height: 22%;
  border: 2px solid rgba(232, 135, 58, 0.35);
}

.call-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.85rem 1.25rem;
  width: min(100%, 22rem);
  margin-top: 0.5rem;
}

.btn-call-round {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  min-width: 4.25rem;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.btn-call-round-ico {
  display: grid;
  place-items: center;
  width: 3.25rem;
  height: 3.25rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #f2f4f6;
  transition: background 0.15s ease, transform 0.15s ease, color 0.15s ease;
}

.btn-call-round-ico .ctl-ico,
.btn-call-round-ico .call-ico {
  width: 1.35rem;
  height: 1.35rem;
  fill: currentColor;
}

.btn-call-round.is-on .btn-call-round-ico,
.btn-call-round:not(.is-off):focus-visible .btn-call-round-ico {
  background: rgba(255, 255, 255, 0.92);
  color: #111;
}

.btn-call-round.is-locked {
  opacity: 0.72;
}

.btn-call-round.is-locked.is-on {
  opacity: 1;
}

.btn-call-round.is-off .btn-call-round-ico {
  background: rgba(220, 90, 80, 0.35);
}

.btn-call-round-label {
  font-size: 0.72rem;
  color: rgba(232, 236, 240, 0.85);
}

.btn-call-hangup {
  margin-top: 1.25rem;
  padding: 0.85rem 2.5rem;
  border: none;
  border-radius: 999px;
  background: #e54d4d;
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 8px 28px rgba(229, 77, 77, 0.35);
}

.btn-call-hangup:active {
  transform: scale(0.98);
}

.btn-call-ctl {
  border: 1px solid rgba(232, 135, 58, 0.28);
  background: rgba(18, 22, 28, 0.9);
  color: var(--brand);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  cursor: pointer;
}

.btn-call-ctl-icon {
  display: inline-grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  padding: 0;
  border-radius: 50%;
}

.btn-call-ctl-icon .ctl-ico {
  width: 1.35rem;
  height: 1.35rem;
  fill: currentColor;
  display: block;
}

.btn-call-ctl-icon .ctl-ico-off {
  display: none;
}

.btn-call-ctl-icon.is-off .ctl-ico-on {
  display: none;
}

.btn-call-ctl-icon.is-off .ctl-ico-off {
  display: block;
}

.btn-call-ctl.is-off,
.btn-call-ctl-icon.is-off,
.btn-call-ctl[aria-pressed="true"] {
  border-color: rgba(200, 90, 80, 0.55);
  color: #d8a8a0;
  background: rgba(48, 28, 28, 0.85);
}

.call-log-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.call-log-note {
  font-size: 0.72rem;
  color: var(--text-dim);
}

.call-log-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 10.5rem;
  overflow-y: auto;
}

.call-log-body {
  padding-bottom: 1rem;
}

.call-log-modal-note {
  margin: 0 0 0.65rem;
  font-size: 0.78rem;
}

.call-log-list-sheet {
  max-height: min(58vh, 22rem);
}

.call-log-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.65rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.call-log-item:last-child {
  border-bottom: none;
}

.call-log-meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.call-log-when {
  font-size: 0.72rem;
  color: var(--text-dim);
}

.call-log-line {
  font-size: 0.84rem;
  color: #c4ccd6;
  line-height: 1.35;
}

.call-log-dur {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--brand);
  white-space: nowrap;
  flex-shrink: 0;
}

.profile-push-card {
  padding-bottom: 0.65rem;
}

.profile-push-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.push-status-chip {
  font-size: 0.75rem;
  color: var(--text-dim);
  white-space: nowrap;
}

.push-quiet-hint {
  margin: 0 0 0.45rem;
  font-size: 0.72rem;
  line-height: 1.35;
  color: var(--text-dim);
  opacity: 0.88;
}

.push-actions-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.btn-ghost-sm {
  border: none;
  background: transparent;
  color: var(--brand);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.15rem 0.1rem;
  cursor: pointer;
}

.btn-ghost-sm:hover {
  text-decoration: underline;
}

.call-log-empty {
  margin: 0.25rem 0 0;
}

.btn-hangup {
  background: var(--danger);
  color: #d8c4c4;
  border: none;
  padding: 0.65rem 1.5rem;
  border-radius: 999px;
}

.profile-card-tight {
  margin-top: 0.35rem;
}

.auth-lead {
  margin: 0.75rem 0 0.35rem;
  font-size: 0.86rem;
  line-height: 1.45;
  color: var(--text);
  opacity: 0.92;
}

.auth-muted {
  margin: 0 0 0.85rem;
  font-size: 0.76rem;
  line-height: 1.42;
  color: #8a939e;
}

/* ——— входящий звонок ——— */
.ring-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: calc(1rem + var(--safe-top)) 1rem calc(1rem + var(--safe-bottom));
}

.ring-scrim {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.ring-panel {
  position: relative;
  z-index: 1;
  width: min(100%, 20rem);
  padding: 1.5rem 1.25rem 1.35rem;
  border-radius: 20px;
  background: var(--sidebar);
  border: 1px solid var(--stroke);
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.45);
  text-align: center;
  animation: view-rise 0.4s var(--ease-out) both;
}

@keyframes ring-pulse {
  0%,
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(82, 136, 193, 0.45);
  }
  50% {
    transform: scale(1.04);
    box-shadow: 0 0 0 12px rgba(82, 136, 193, 0);
  }
}

.ring-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
}

.ring-sub {
  margin: 0.45rem 0 1.15rem;
  font-size: 0.88rem;
  color: var(--text-dim);
  line-height: 1.4;
}

.ring-actions {
  display: flex;
  gap: 0.65rem;
}

.ring-btn {
  flex: 1;
  border: none;
  border-radius: 999px;
  padding: 0.72rem 1rem;
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform 0.16s var(--ease-out), filter var(--motion);
}

.ring-btn:active {
  transform: scale(0.96);
}

.ring-decline {
  background: #3a2f32;
  color: #f5c6c6;
}

.ring-accept {
  background: #3d8f5a;
  color: #fff;
}

.room-video-opt {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.75rem 0 1rem;
  font-size: 0.92rem;
  color: var(--muted, #a89a8e);
}

.room-share-name {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0 0 0.35rem;
}

.room-code-pill {
  display: inline-block;
  margin: 0.5rem 0 0.75rem;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  background: rgba(255, 140, 60, 0.12);
  font-size: 0.88rem;
  letter-spacing: 0.04em;
}

.room-link-field {
  font-size: 0.82rem;
  margin-bottom: 0.35rem;
}

.guest-room-card {
  max-width: 22rem;
}

.guest-room-eyebrow {
  margin: 0 0 0.25rem;
  font-size: 0.82rem;
  color: var(--muted, #a89a8e);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.guest-room-title {
  margin: 0 0 0.35rem;
  font-size: 1.35rem;
}

.guest-room-meta {
  margin-bottom: 1rem;
}

.guest-auth-link {
  display: block;
  margin-top: 0.75rem;
}

.guest-legal-hint {
  margin-top: 1rem;
  font-size: 0.82rem;
  line-height: 1.4;
}

body.guest-mode #screen-auth,
body.guest-mode #screen-creds,
body.guest-mode #screen-room-guest,
body.guest-mode #messenger {
  display: none !important;
}

.chat-list-preview-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
}

.chat-list-preview-row .chat-list-preview {
  flex: 1;
  min-width: 0;
}

.unread-badge {
  flex-shrink: 0;
  min-width: 1.2rem;
  height: 1.2rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: var(--brand);
  color: var(--on-brand);
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.2rem;
  text-align: center;
}

.composer {
  position: relative;
}

.composer-toolbar {
  display: flex;
  align-items: flex-end;
  gap: 0.4rem;
  width: 100%;
}

.reply-bar {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0 0.65rem 0.35rem;
  padding: 0.45rem 0.55rem;
  border-radius: 12px;
  background: rgba(18, 22, 28, 0.95);
  border: 1px solid rgba(232, 135, 58, 0.18);
}

.reply-bar.hidden {
  display: none !important;
}

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

.reply-bar-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 650;
  color: var(--brand);
}

.reply-bar-text {
  display: block;
  font-size: 0.8rem;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reply-bar-close {
  width: 1.75rem;
  height: 1.75rem;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
}

.typing-line {
  min-height: 1.1rem;
  margin: 0 0.85rem 0.15rem;
  font-size: 0.75rem;
  color: var(--brand);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.typing-line.is-on {
  opacity: 1;
}

.typing-dots span {
  animation: typing-bounce 1.1s infinite ease-in-out;
  display: inline-block;
}

.typing-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.typing-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes typing-bounce {
  0%,
  80%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-2px);
  }
}

.btn-attach,
.btn-voice,
.btn-send {
  display: inline-grid;
  place-items: center;
}

.btn-attach .ui-ico,
.btn-voice .ui-ico,
.btn-send .ui-ico,
.btn-icon .ui-ico,
.tg-icon-btn .ui-ico {
  width: 1.15rem;
  height: 1.15rem;
  fill: currentColor;
}

.btn-voice {
  width: 2.5rem;
  height: 2.5rem;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--brand);
  cursor: pointer;
  flex-shrink: 0;
}

.btn-voice.is-recording {
  color: #fff;
  background: #c44;
  animation: pulse-rec 1s ease-in-out infinite;
}

@keyframes pulse-rec {
  50% {
    transform: scale(1.06);
  }
}

.upload-progress {
  height: 3px;
  margin: 0 0.75rem 0.35rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.upload-progress.hidden {
  display: none !important;
}

.upload-progress > i {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--brand-dim), var(--brand));
  transition: width 0.15s linear;
}

.list-skeleton {
  padding: 0.5rem 0.75rem;
}

.skel-row {
  display: flex;
  gap: 0.65rem;
  align-items: center;
  margin-bottom: 0.75rem;
}

.skel-avatar,
.skel-line {
  background: linear-gradient(90deg, #14181d 25%, #1c2229 50%, #14181d 75%);
  background-size: 200% 100%;
  animation: skel 1.2s ease-in-out infinite;
  border-radius: 8px;
}

.skel-avatar {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  flex-shrink: 0;
}

.skel-lines {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.skel-line {
  height: 0.65rem;
}

.skel-line.w60 {
  width: 60%;
}

.skel-line.w85 {
  width: 85%;
}

@keyframes skel {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: -100% 0;
  }
}

.call-mini {
  position: fixed;
  left: max(0.75rem, var(--safe-left));
  right: max(0.75rem, var(--safe-right));
  bottom: calc(0.85rem + var(--safe-bottom));
  z-index: 95;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.85rem;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(22, 28, 36, 0.96), rgba(10, 12, 16, 0.98));
  border: 1px solid rgba(232, 135, 58, 0.28);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.45);
  cursor: pointer;
}

.call-mini.hidden {
  display: none !important;
}

.call-mini-title {
  flex: 1;
  min-width: 0;
  font-weight: 650;
  font-size: 0.92rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.call-mini-sub {
  display: block;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--brand);
}

.call-mini-hang {
  border: none;
  border-radius: 999px;
  padding: 0.4rem 0.75rem;
  background: #e54d4d;
  color: #fff;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 650;
  cursor: pointer;
}

.btn-call-minimize {
  position: absolute;
  top: calc(0.65rem + var(--safe-top));
  left: max(0.75rem, var(--safe-left));
  z-index: 5;
  border: none;
  border-radius: 999px;
  padding: 0.4rem 0.75rem;
  background: rgba(0, 0, 0, 0.45);
  color: #e8eef4;
  font: inherit;
  font-size: 0.78rem;
  cursor: pointer;
}

.pwa-banner,
.push-nudge {
  position: fixed;
  left: max(0.75rem, var(--safe-left));
  right: max(0.75rem, var(--safe-right));
  bottom: calc(0.85rem + var(--safe-bottom));
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.85rem 0.9rem;
  border-radius: 16px;
  background: linear-gradient(165deg, #141a22, #0c0f14);
  border: 1px solid rgba(232, 135, 58, 0.22);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.45);
}

.pwa-banner.hidden,
.push-nudge.hidden {
  display: none !important;
}

.pwa-banner-text,
.push-nudge-text {
  flex: 1;
  min-width: 0;
  font-size: 0.86rem;
  line-height: 1.35;
}

.pwa-banner .btn,
.push-nudge .btn {
  flex-shrink: 0;
  padding: 0.45rem 0.75rem;
  font-size: 0.8rem;
}

.btn.is-busy {
  opacity: 0.72;
  pointer-events: none;
}

.empty-state-hint {
  margin: 0.35rem 0 0;
  font-size: 0.78rem;
  color: var(--text-dim);
  text-align: center;
  line-height: 1.4;
}

.msg-audio {
  width: min(100%, 16rem);
  height: 2.25rem;
}

@media (max-width: 768px) {
  .messenger {
    grid-template-columns: 1fr;
  }

  .messenger:not(.chat-open) .conversation {
    display: none;
  }

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

  .messenger.chat-open .conversation {
    animation: chat-slide-in 0.28s var(--ease-out) both;
  }

  @keyframes chat-slide-in {
    from {
      opacity: 0.6;
      transform: translateX(12px);
    }
    to {
      opacity: 1;
      transform: none;
    }
  }

  .btn-icon.back {
    display: inline-grid;
    place-items: center;
  }

  .tg-modal {
    justify-content: center;
    align-items: stretch;
  }

  .tg-modal-panel {
    width: 100%;
    max-height: 100dvh;
    box-shadow: none;
  }
}