:root {
  color-scheme: light;
  --bg: #f6f7f2;
  --ink: #151515;
  --muted: #61645f;
  --panel: #ffffff;
  --panel-soft: #f4f8f5;
  --line: #d7ddd4;
  --accent: #08766f;
  --accent-strong: #075f59;
  --coral: #d75a4a;
  --gold: #c9932c;
  --danger: #b42318;
  --shadow: 0 22px 60px rgba(28, 31, 28, 0.14);
  --soft-shadow: 0 12px 32px rgba(28, 31, 28, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
  background:
    linear-gradient(135deg, rgba(8, 118, 111, 0.09), transparent 34%),
    linear-gradient(315deg, rgba(215, 90, 74, 0.1), transparent 30%),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body::before {
  content: "";
  inset: 0;
  pointer-events: none;
  position: fixed;
  background-image:
    linear-gradient(rgba(21, 21, 21, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(21, 21, 21, 0.045) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.65), transparent 82%);
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  cursor: pointer;
  font-weight: 800;
  min-height: 44px;
  padding: 0 16px;
  transition: background 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

button:hover {
  background: var(--accent-strong);
  box-shadow: var(--soft-shadow);
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

button:disabled {
  box-shadow: none;
  cursor: not-allowed;
  opacity: 0.48;
  transform: none;
}

.secondary {
  background: #e9eee8;
  color: var(--ink);
}

.secondary:hover {
  background: #dfe7df;
}

.danger {
  background: var(--danger);
}

.danger:hover {
  background: #8f1d14;
}

.hidden {
  display: none !important;
}

.shell {
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
  width: 100%;
}

.app-notice {
  background: rgba(215, 90, 74, 0.12);
  border: 1px solid rgba(215, 90, 74, 0.28);
  border-radius: 8px;
  color: var(--danger);
  font-size: 0.86rem;
  line-height: 1.35;
  margin: 0;
  padding: 10px 12px;
}

/* ── AUTH ─────────────────────────────────── */

.auth {
  align-items: center;
  animation: view-in 420ms ease both;
  display: grid;
  gap: 44px;
  grid-template-columns: minmax(0, 1.05fr) minmax(340px, 430px);
  min-height: 100vh;
  padding: 56px;
}

.brand {
  align-items: center;
  display: grid;
  gap: 30px;
  grid-template-columns: 210px minmax(0, 1fr);
  max-width: 900px;
}

.brand__visual {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  position: relative;
}

.brand__visual::before {
  content: "";
  border: 1px solid rgba(8, 118, 111, 0.24);
  border-radius: 8px;
  inset: 18px;
  position: absolute;
  transform: rotate(8deg);
}

.brand__mark {
  animation: float-mark 4.2s ease-in-out infinite;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  height: 160px;
  object-fit: cover;
  position: relative;
  width: 160px;
  z-index: 2;
}

.signal {
  border: 2px solid rgba(8, 118, 111, 0.38);
  border-radius: 8px;
  position: absolute;
  transform: rotate(8deg);
}

.signal--one {
  animation: signal-scan 2.8s ease-in-out infinite;
  height: 116px;
  width: 116px;
}

.signal--two {
  animation: signal-scan 2.8s ease-in-out 320ms infinite;
  height: 154px;
  width: 154px;
}

.signal--three {
  animation: signal-scan 2.8s ease-in-out 640ms infinite;
  height: 192px;
  width: 192px;
}

.eyebrow {
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0;
  margin: 0 0 7px;
  text-transform: uppercase;
}

h1,
h2 {
  line-height: 1.05;
  margin: 0;
}

h1 {
  font-size: 5.1rem;
  max-width: 11ch;
}

h2 {
  font-size: 1.25rem;
}

.lead {
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.58;
  margin: 20px 0 0;
  max-width: 52ch;
}

.auth-form,
.sidebar,
.chat,
.incoming-dialog {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(215, 221, 212, 0.9);
  border-radius: 8px;
  backdrop-filter: blur(16px);
}

.auth-form {
  animation: panel-in 480ms ease 80ms both;
  box-shadow: var(--shadow);
  display: grid;
  gap: 18px;
  padding: 26px;
  position: relative;
  overflow: hidden;
}

.auth {
  --look-x: 0;
  --look-y: 0;
}

/* ── Login mascots ─────────────────────────── */

.login-mascots {
  background:
    radial-gradient(circle at 50% 95%, rgba(8, 118, 111, 0.18), transparent 36%),
    linear-gradient(135deg, rgba(8, 118, 111, 0.12), transparent 58%),
    linear-gradient(315deg, rgba(201, 147, 44, 0.14), transparent 58%),
    #f8faf5;
  border-radius: 6px;
  min-height: 218px;
  overflow: hidden;
  padding: 14px 14px 16px;
}

.login-mascots__speech {
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 800;
  min-height: 36px;
  text-align: center;
  transition: color 220ms ease, transform 220ms ease;
}

.auth.is-password-active .login-mascots__speech {
  color: var(--coral);
  transform: translateY(-2px);
}

/* ── Capybara login mascot ───────────────────── */

.capybara-login {
  height: 150px;
  margin-top: -2px;
  overflow: hidden;
  position: relative;
}

.capybara-login__shadow {
  background: rgba(8, 118, 111, 0.15);
  border-radius: 999px;
  bottom: 7px;
  filter: blur(1px);
  height: 18px;
  left: 50%;
  position: absolute;
  transform: translateX(-50%);
  width: 176px;
}

.capybara {
  animation: capybara-breathe 3.2s ease-in-out infinite;
  bottom: 16px;
  height: 126px;
  left: 50%;
  position: absolute;
  transform: translateX(-50%);
  transform-origin: 50% 100%;
  width: 190px;
}

.capybara__body {
  background:
    radial-gradient(circle at 28% 22%, rgba(255, 255, 255, 0.18), transparent 24%),
    linear-gradient(135deg, #b57a3d, #8f5f30);
  border: 1px solid rgba(90, 57, 27, 0.18);
  border-radius: 44px 54px 36px 42px;
  bottom: 6px;
  box-shadow: 0 16px 26px rgba(28, 31, 28, 0.16);
  height: 76px;
  left: 22px;
  position: absolute;
  width: 146px;
}

.capybara__paw {
  background: #75471f;
  border-radius: 999px;
  bottom: 3px;
  height: 17px;
  position: absolute;
  width: 31px;
  z-index: 1;
}

.capybara__paw--left {
  left: 52px;
}

.capybara__paw--right {
  right: 44px;
}

.capybara__head {
  background:
    radial-gradient(circle at 31% 29%, rgba(255, 255, 255, 0.22), transparent 24%),
    linear-gradient(145deg, #c88945, #9a672f);
  border: 1px solid rgba(90, 57, 27, 0.18);
  border-radius: 48% 54% 46% 50%;
  box-shadow: 0 14px 24px rgba(28, 31, 28, 0.12);
  height: 96px;
  left: 48px;
  position: absolute;
  top: 4px;
  transform:
    translate(calc(var(--look-x) * 4px), calc(var(--look-y) * 3px))
    rotate(calc(var(--look-x) * 2.6deg));
  transform-origin: 50% 82%;
  transition: transform 130ms ease-out;
  width: 96px;
  z-index: 3;
}

.capybara__ear {
  background: #7d4f25;
  border: 1px solid rgba(90, 57, 27, 0.16);
  border-radius: 999px;
  height: 22px;
  position: absolute;
  top: -3px;
  width: 22px;
  z-index: -1;
}

.capybara__ear--left {
  left: 13px;
  transform: rotate(-18deg);
}

.capybara__ear--right {
  right: 12px;
  transform: rotate(18deg);
}

.capybara__face {
  display: block;
  height: 100%;
  position: relative;
  width: 100%;
}

.capybara__eye {
  background: #ffffff;
  border: 1px solid rgba(90, 57, 27, 0.18);
  border-radius: 999px;
  height: 22px;
  overflow: hidden;
  position: absolute;
  top: 34px;
  width: 22px;
}

.capybara__eye--left {
  left: 26px;
}

.capybara__eye--right {
  right: 26px;
}

.capybara__pupil {
  background: #221a13;
  border-radius: 999px;
  height: 9px;
  left: 50%;
  position: absolute;
  top: 50%;
  transform:
    translate(-50%, -50%)
    translate(calc(var(--look-x) * 4px), calc(var(--look-y) * 4px));
  transition: opacity 120ms ease-out, transform 120ms ease-out;
  width: 9px;
}

.capybara__lid {
  background: #9a672f;
  border-bottom: 2px solid rgba(90, 57, 27, 0.3);
  border-radius: 999px 999px 0 0;
  height: 110%;
  left: -6%;
  position: absolute;
  top: -112%;
  transition: top 220ms ease, transform 220ms ease;
  width: 112%;
}

.capybara__snout {
  background: #d7a36f;
  border: 1px solid rgba(90, 57, 27, 0.14);
  border-radius: 44% 44% 48% 48%;
  height: 34px;
  left: 50%;
  position: absolute;
  top: 51px;
  transform:
    translateX(-50%)
    translate(calc(var(--look-x) * 1.2px), calc(var(--look-y) * 1.3px));
  transition: transform 140ms ease-out;
  width: 46px;
}

.capybara__nose {
  background: #362417;
  border-radius: 999px 999px 8px 8px;
  height: 10px;
  left: 50%;
  position: absolute;
  top: 8px;
  transform: translateX(-50%);
  width: 15px;
}

.capybara__mouth {
  border-bottom: 2px solid rgba(54, 36, 23, 0.58);
  border-radius: 0 0 999px 999px;
  height: 10px;
  left: 50%;
  position: absolute;
  top: 17px;
  transform: translateX(-50%);
  width: 18px;
}

.auth.is-password-active .capybara__head {
  transform: translateY(4px) rotate(0deg);
  transition: transform 240ms ease;
}

.auth.is-password-active .capybara__eye {
  background: transparent;
  border-color: transparent;
  overflow: visible;
}

.auth.is-password-active .capybara__pupil {
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.7);
}

.auth.is-password-active .capybara__lid {
  background: transparent;
  border-bottom: 3px solid rgba(54, 36, 23, 0.58);
  border-radius: 0 0 999px 999px;
  height: 15px;
  left: 1px;
  top: 1px;
  width: 20px;
}

.auth.is-password-active .capybara__snout {
  transform: translateX(-50%) translateY(2px);
}

.auth-perks {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.auth-perks span {
  background: rgba(8, 118, 111, 0.08);
  border: 1px solid rgba(8, 118, 111, 0.16);
  border-radius: 8px;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 900;
  min-width: 0;
  padding: 8px 10px;
  text-align: center;
}

/* ── Form fields ─────────────────────────────── */

label {
  color: var(--muted);
  display: grid;
  font-size: 0.9rem;
  font-weight: 800;
  gap: 8px;
}

input,
textarea {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  outline: none;
  padding: 12px 14px;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
  width: 100%;
}

input:focus,
textarea:focus {
  background: #ffffff;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(8, 118, 111, 0.15);
}

textarea {
  min-height: 52px;
  resize: none;
}

.auth-actions {
  display: flex;
  gap: 10px;
}

.auth-hint {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
  margin: -4px 0 0;
}

.status {
  color: var(--muted);
  line-height: 1.4;
  margin: 0;
  min-height: 1.4em;
}

.register-dialog {
  background: transparent;
  border: 0;
  max-width: 430px;
  padding: 0;
  width: calc(100vw - 32px);
}

.register-dialog::backdrop {
  background: rgba(21, 21, 21, 0.48);
  backdrop-filter: blur(5px);
}

.register-dialog[open] {
  animation: dialog-pop 320ms cubic-bezier(0.22, 1.2, 0.36, 1) both;
}

.register-form {
  background:
    linear-gradient(135deg, rgba(8, 118, 111, 0.1), transparent 48%),
    linear-gradient(315deg, rgba(215, 90, 74, 0.08), transparent 44%),
    #ffffff;
  border: 1px solid rgba(215, 221, 212, 0.9);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 16px;
  padding: 22px;
}

.register-form__head {
  align-items: center;
  display: grid;
  gap: 12px;
  grid-template-columns: 54px minmax(0, 1fr);
}

.register-form__logo {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--soft-shadow);
  height: 54px;
  width: 54px;
}

/* ── Messenger layout ─────────────────────────── */

.messenger {
  animation: view-in 360ms ease both;
  display: grid;
  gap: 16px;
  grid-template-columns: 320px minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
  padding: 16px;
}

/* ── Sidebar ─────────────────────────────────── */

.sidebar {
  box-shadow: var(--soft-shadow);
  display: grid;
  gap: 16px;
  grid-template-rows: auto auto auto auto auto auto auto minmax(0, 1fr);
  overflow: auto;
  padding: 16px;
}

.side-nav {
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.side-nav__item {
  background: #ffffff;
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 0.82rem;
  min-height: 38px;
  padding: 0 8px;
}

.side-nav__item:hover,
.side-nav__item--active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.user-section {
  display: grid;
  gap: 10px;
  grid-template-rows: auto 1fr;
  min-height: 0;
}

.contact-search {
  background: #ffffff;
  min-height: 42px;
  padding: 10px 12px;
}

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

.avatar {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  height: 48px;
  object-fit: cover;
  width: 48px;
}

.avatar-mascot {
  align-items: center;
  animation: avatar-float 2.8s ease-in-out infinite;
  animation-delay: var(--avatar-delay, 0s);
  background:
    radial-gradient(circle at 32% 26%, rgba(255, 255, 255, 0.84), transparent 9px),
    linear-gradient(145deg, hsl(var(--avatar-hue) 72% 66%), hsl(calc(var(--avatar-hue) - 34) 78% 42%));
  display: inline-flex;
  flex-shrink: 0;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.avatar-mascot::after {
  background: rgba(255, 255, 255, 0.42);
  border-radius: 999px;
  content: "";
  height: 36px;
  position: absolute;
  right: -14px;
  top: -18px;
  width: 36px;
}

.avatar-mascot__face {
  height: 100%;
  position: relative;
  width: 100%;
}

.avatar-mascot__eye {
  animation: avatar-blink 4.8s infinite;
  background: #ffffff;
  border-radius: 999px;
  height: 4px;
  position: absolute;
  top: 18px;
  width: 6px;
}

.avatar-mascot__eye--one { left: 15px; }
.avatar-mascot__eye--two { right: 15px; }

.avatar-mascot__smile {
  border-bottom: 2px solid #ffffff;
  border-radius: 0 0 999px 999px;
  bottom: 15px;
  height: 8px;
  left: 18px;
  position: absolute;
  width: 13px;
}

.avatar-mascot__heart {
  animation: avatar-heart 1.9s ease-in-out infinite;
  bottom: 5px;
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 900;
  position: absolute;
  right: 6px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
}

.avatar-mascot--small {
  height: 34px;
  width: 34px;
}

.avatar-mascot--small .avatar-mascot__eye {
  top: 13px;
}

.avatar-mascot--small .avatar-mascot__eye--one { left: 10px; }
.avatar-mascot--small .avatar-mascot__eye--two { right: 10px; }
.avatar-mascot--small .avatar-mascot__smile { bottom: 10px; left: 12px; }
.avatar-mascot--small .avatar-mascot__heart { font-size: 0.62rem; }

.icon-button {
  align-items: center;
  display: flex;
  justify-content: center;
  min-height: 38px;
  padding: 0 12px;
}

.profile-panel,
.media-panel,
.device-panel {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  padding: 12px;
}

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

.profile-card__info {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.profile-card__info strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-card__info span,
.media-item small {
  color: var(--muted);
  font-size: 0.78rem;
}

.profile-card__edit {
  font-size: 0.8rem;
  min-height: 36px;
  padding: 0 10px;
}

.media-list {
  display: grid;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
}

.media-item {
  align-items: center;
  background: rgba(244, 248, 245, 0.95);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  display: grid;
  gap: 8px;
  grid-template-columns: 38px minmax(0, 1fr);
  min-height: 48px;
  padding: 8px;
  text-decoration: none;
}

.media-item--empty {
  color: var(--muted);
  display: block;
  font-size: 0.84rem;
}

.media-item__icon {
  align-items: center;
  background: rgba(8, 118, 111, 0.12);
  border-radius: 8px;
  color: var(--accent);
  display: flex;
  font-size: 0.68rem;
  font-weight: 900;
  height: 34px;
  justify-content: center;
  width: 34px;
}

.media-item__text {
  display: grid;
  min-width: 0;
}

.media-item__text strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.device-panel p:last-child {
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.35;
  margin: 0;
}

.device-actions {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr 1fr;
}

.device-actions button {
  font-size: 0.82rem;
  min-height: 38px;
  padding: 0 8px;
}

.secret-panel {
  background:
    linear-gradient(135deg, rgba(8, 118, 111, 0.12), transparent 56%),
    linear-gradient(315deg, rgba(201, 147, 44, 0.14), transparent 60%),
    var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  padding: 12px;
}

.secret-panel p {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.35;
  margin: 0;
}

.secret-actions {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr 1fr;
}

.secret-actions button {
  font-size: 0.82rem;
  min-height: 38px;
  padding: 0 8px;
}

.privacy-toggle {
  font-size: 0.84rem;
  min-height: 40px;
}

.admin-panel,
.call-history-panel {
  background: rgba(244, 248, 245, 0.9);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  padding: 12px;
}

.admin-panel h3 {
  font-size: 1rem;
  margin: 0;
}

.admin-users,
.call-history {
  display: grid;
  gap: 8px;
  max-height: 180px;
  overflow-y: auto;
}

.admin-user-row,
.call-history-item {
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  padding: 8px;
}

.admin-user-row {
  grid-template-columns: 34px minmax(0, 1fr) auto auto;
}

.admin-user-row strong,
.call-history-item strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-user-row button {
  background: var(--danger);
  min-height: 34px;
  padding: 0 10px;
}

.admin-user-row__edit {
  background: var(--accent) !important;
}

.call-history-item {
  font-size: 0.84rem;
}

.call-history-item span {
  color: var(--muted);
  font-size: 0.78rem;
}

.fingerprint {
  background: #f5f6f1;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  overflow-wrap: anywhere;
  padding: 10px;
}

.users {
  display: grid;
  align-content: start;
  gap: 6px;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding-right: 2px;
}

.user-row {
  align-items: center;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  display: grid;
  gap: 10px;
  grid-template-columns: 42px minmax(0, 1fr) auto 10px;
  min-height: 56px;
  padding: 8px;
  text-align: left;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.unread-badge {
  align-items: center;
  background: var(--accent);
  border-radius: 999px;
  color: #ffffff;
  display: inline-flex;
  font-size: 0.72rem;
  font-weight: 900;
  height: 22px;
  justify-content: center;
  min-width: 22px;
  padding: 0 7px;
}

.user-row:hover,
.user-row--active {
  background: #ffffff;
  border-color: rgba(8, 118, 111, 0.45);
  transform: translateX(2px);
}

.user-row__name {
  font-weight: 900;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.presence {
  background: var(--gold);
  border-radius: 999px;
  height: 10px;
  opacity: 0.42;
  width: 10px;
}

.presence--online {
  animation: presence-pulse 1.7s ease-in-out infinite;
  background: var(--accent);
  opacity: 1;
}

/* ── Chat ────────────────────────────────────── */

.chat {
  box-shadow: var(--soft-shadow);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  min-width: 0;
  overflow: hidden;
}

.chat-header {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 10px;
  padding: 12px 16px;
}

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

.chat-header__info h2 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.call-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.call-btn {
  align-items: center;
  display: flex;
  flex-direction: column;
  font-size: 0.68rem;
  font-weight: 700;
  gap: 2px;
  min-height: 48px;
  padding: 6px 12px;
}

.call-btn__label {
  line-height: 1;
}

.back-button {
  display: none;
  flex-shrink: 0;
  padding: 0 10px;
  min-height: 44px;
}

.messages {
  align-content: end;
  background:
    linear-gradient(90deg, rgba(8, 118, 111, 0.08) 1px, transparent 1px),
    linear-gradient(rgba(21, 21, 21, 0.04) 1px, transparent 1px);
  background-size: 38px 38px;
  display: grid;
  gap: 10px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
}

.message {
  animation: message-in 280ms cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: var(--msg-delay, 0ms);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 18px rgba(28, 31, 28, 0.08);
  display: grid;
  gap: 6px;
  justify-self: start;
  max-width: min(68ch, 88%);
  padding: 10px 12px;
}

.message--self {
  background: #edf8f4;
  border-color: rgba(8, 118, 111, 0.28);
  justify-self: end;
}

.message__meta {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.message__body {
  line-height: 1.45;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.message__media {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: block;
  max-height: 360px;
  max-width: min(440px, 100%);
  object-fit: contain;
  overflow: hidden;
}

.message__audio {
  display: block;
  max-width: min(360px, 100%);
  width: 100%;
}

.message__file {
  align-items: center;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  display: grid;
  gap: 10px;
  grid-template-columns: 42px minmax(0, 1fr);
  min-width: min(320px, 100%);
  padding: 10px;
  text-decoration: none;
}

.message__file-icon {
  align-items: center;
  background: rgba(8, 118, 111, 0.12);
  border-radius: 8px;
  color: var(--accent);
  display: flex;
  font-size: 0.7rem;
  font-weight: 900;
  height: 38px;
  justify-content: center;
  width: 38px;
}

.message__file-text {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.message__file-text strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message__file-text small {
  color: var(--muted);
  font-size: 0.76rem;
}

.message__receipt {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  justify-self: end;
}

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

.attachment-preview {
  background: rgba(255, 255, 255, 0.94);
  border-top: 1px solid var(--line);
  padding: 10px 16px;
}

.attachment-preview__frame {
  align-items: center;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  grid-template-columns: 72px minmax(0, 1fr) auto;
  min-height: 74px;
  padding: 8px;
}

.attachment-preview img,
.attachment-preview video {
  border-radius: 8px;
  height: 56px;
  object-fit: cover;
  width: 72px;
}

.attachment-preview audio {
  max-width: 210px;
  width: 100%;
}

.attachment-preview__file-icon {
  align-items: center;
  background: rgba(8, 118, 111, 0.12);
  border-radius: 8px;
  color: var(--accent);
  display: flex;
  font-size: 0.76rem;
  font-weight: 900;
  height: 56px;
  justify-content: center;
  width: 72px;
}

.attachment-preview__info {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.attachment-preview__info strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-preview__info span {
  color: var(--muted);
  font-size: 0.8rem;
}

.attachment-preview__remove {
  background: #e9eee8;
  color: var(--ink);
  font-size: 0.8rem;
  min-height: 36px;
  padding: 0 10px;
}

.composer {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 10px;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: end;
  padding: 12px 16px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
}

.attach-button,
.voice-button,
.send-button {
  align-items: center;
  display: flex;
  height: 44px;
  justify-content: center;
  min-height: unset;
  padding: 0;
  width: 44px;
}

.attach-button {
  background: #e9eee8;
  color: var(--ink);
}

.voice-button {
  background: #e9eee8;
  color: var(--ink);
}

.voice-button--recording {
  animation: recording-pulse 1s ease-in-out infinite;
  background: var(--coral);
  color: #ffffff;
}

.attach-button--ready {
  background: var(--gold);
  color: #ffffff;
}

/* ── Call panel ──────────────────────────────── */

.call-panel {
  animation: call-in 420ms cubic-bezier(0.22, 1, 0.36, 1) both;
  border-radius: 8px;
  left: 50%;
  max-height: calc(100vh - 48px);
  overflow: hidden;
  position: fixed;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(1180px, calc(100vw - 48px));
  box-shadow: 0 36px 90px rgba(0, 0, 0, 0.48);
  z-index: 100;
}

.call-stage {
  background: #0c1210;
  height: min(720px, calc(100vh - 48px));
  min-height: 520px;
  position: relative;
}

#remoteVideo {
  background: #0c1210;
  height: 100%;
  object-fit: cover;
  width: 100%;
}

#localVideo {
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-radius: 8px;
  bottom: 96px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
  cursor: pointer;
  height: 160px;
  max-width: none;
  object-fit: cover;
  position: absolute;
  right: 18px;
  width: 260px;
  z-index: 2;
}

#localVideo.is-floating {
  touch-action: none;
}

.call-panel.is-local-mirrored #localVideo {
  transform: scaleX(-1);
}

.call-panel.is-self-focused #localVideo {
  border: 0;
  bottom: 0;
  height: 100%;
  left: auto !important;
  right: 0;
  top: auto !important;
  width: 100%;
  z-index: 1;
}

.call-panel.is-self-focused #remoteVideo {
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-radius: 8px;
  bottom: 96px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
  cursor: pointer;
  height: 160px;
  object-fit: cover;
  position: absolute;
  right: 18px;
  width: 260px;
  z-index: 2;
}

.call-panel.is-audio-only #remoteVideo,
.call-panel.is-audio-only #localVideo {
  opacity: 0;
}

.call-panel.is-audio-only .call-stage::before {
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 255, 255, 0.14), transparent 18%),
    linear-gradient(135deg, rgba(8, 118, 111, 0.5), transparent 50%),
    linear-gradient(315deg, rgba(215, 90, 74, 0.35), transparent 48%),
    #0c1210;
  content: "";
  inset: 0;
  position: absolute;
}

.call-panel.is-audio-only .call-stage::after {
  color: rgba(255, 255, 255, 0.86);
  content: "Аудиозвонок";
  font-size: 2rem;
  font-weight: 900;
  left: 50%;
  position: absolute;
  text-align: center;
  top: 50%;
  transform: translate(-50%, -50%);
}

.call-overlay {
  bottom: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  left: 0;
  pointer-events: none;
  position: absolute;
  right: 0;
  top: 0;
  background: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.55) 0%,
    transparent 38%,
    transparent 58%,
    rgba(0, 0, 0, 0.65) 100%
  );
}

.call-overlay__top {
  padding: 14px 16px;
  pointer-events: auto;
}

.call-eyebrow {
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  margin: 0 0 3px;
  text-transform: uppercase;
}

.call-title {
  color: #ffffff;
  font-size: 1.05rem;
  margin: 0;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

.call-status-line {
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.78rem;
  line-height: 1.4;
  margin: 3px 0 0;
  min-height: 1em;
}

.call-quality {
  margin-top: 10px;
  max-width: 170px;
}

.call-quality label {
  color: rgba(255, 255, 255, 0.74);
  font-size: 0.72rem;
  gap: 5px;
}

.call-quality select {
  appearance: none;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 8px;
  color: #ffffff;
  font: inherit;
  font-weight: 900;
  min-height: 34px;
  outline: none;
  padding: 0 10px;
}

.call-quality option {
  color: #151515;
}

.call-overlay__bottom {
  padding: 12px 16px 14px;
  pointer-events: auto;
}

.call-controls {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: center;
}

.call-ctrl {
  align-items: center;
  backdrop-filter: blur(12px);
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 50%;
  color: #ffffff;
  cursor: pointer;
  display: flex;
  height: 52px;
  justify-content: center;
  min-height: unset;
  padding: 0;
  transition: background 160ms ease, transform 160ms ease;
  width: 52px;
}

.call-ctrl:hover {
  background: rgba(255, 255, 255, 0.30);
  box-shadow: none;
  transform: scale(1.08);
}

.call-ctrl:active {
  transform: scale(0.95);
}

.call-ctrl:disabled {
  opacity: 0.35;
  transform: none;
}

.call-ctrl--hangup {
  background: rgba(180, 35, 24, 0.9);
  border-color: rgba(255, 255, 255, 0.12);
  height: 62px;
  width: 62px;
}

.call-ctrl--hangup:hover {
  background: rgba(180, 35, 24, 1);
}

.call-ctrl--muted,
.call-ctrl--cam-off,
.call-ctrl--active {
  background: rgba(180, 35, 24, 0.7);
  border-color: rgba(255, 255, 255, 0.15);
}

.call-ctrl--active {
  background: rgba(8, 118, 111, 0.88);
}

/* ── Dialogs ─────────────────────────────────── */

.incoming-dialog {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(215, 221, 212, 0.9);
  border-radius: 12px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 14px;
  max-width: 380px;
  padding: 24px;
  width: calc(100vw - 32px);
}

.incoming-dialog[open] {
  animation: dialog-pop 340ms cubic-bezier(0.22, 1.2, 0.36, 1) both;
}

.incoming-dialog::backdrop {
  animation: backdrop-fade 280ms ease both;
  background: rgba(0, 0, 0, 0.48);
  backdrop-filter: blur(4px);
}

.incoming-call-art {
  display: grid;
  height: 92px;
  place-items: center;
  position: relative;
}

.incoming-call-art__ring {
  animation: incoming-ring 1.6s ease-in-out infinite;
  border: 2px solid rgba(8, 118, 111, 0.25);
  border-radius: 999px;
  height: 74px;
  position: absolute;
  width: 74px;
}

.incoming-call-art__avatar {
  align-items: center;
  background: var(--accent);
  border-radius: 8px;
  color: #ffffff;
  display: flex;
  font-size: 2rem;
  height: 58px;
  justify-content: center;
  width: 58px;
}

.incoming-actions {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr 1fr;
}

.warning-note {
  background: rgba(215, 90, 74, 0.1);
  border: 1px solid rgba(215, 90, 74, 0.22);
  border-radius: 8px;
  color: var(--danger);
  font-size: 0.88rem;
  line-height: 1.4;
  margin: 0;
  padding: 10px;
}

/* ── Keyframes ───────────────────────────────── */

@keyframes view-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes panel-in {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes float-mark {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-8px); }
}

@keyframes signal-scan {
  0%   { opacity: 0; transform: rotate(8deg) scale(0.9); }
  45%  { opacity: 1; }
  100% { opacity: 0; transform: rotate(8deg) scale(1.12); }
}

@keyframes capybara-breathe {
  0%,
  100% {
    transform: translateX(-50%) translateY(0) rotate(0deg);
  }
  35% {
    transform: translateX(-50%) translateY(-4px) rotate(-1deg);
  }
  70% {
    transform: translateX(-50%) translateY(2px) rotate(1deg);
  }
}

@keyframes presence-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(8, 118, 111, 0.2); }
  50%       { box-shadow: 0 0 0 6px rgba(8, 118, 111, 0); }
}

@keyframes avatar-float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  45%      { transform: translateY(-2px) rotate(-1deg); }
  70%      { transform: translateY(1px) rotate(1deg); }
}

@keyframes avatar-blink {
  0%, 92%, 100% { transform: scaleY(1); }
  95%           { transform: scaleY(0.18); }
}

@keyframes avatar-heart {
  0%, 100% { opacity: 0.78; transform: translateY(0) scale(1); }
  50%      { opacity: 1; transform: translateY(-3px) scale(1.16); }
}

@keyframes message-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes call-in {
  from {
    opacity: 0;
    transform: translate(-50%, -46%) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

@keyframes call-in-mobile {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes dialog-pop {
  from {
    opacity: 0;
    filter: blur(2px);
    transform: scale(0.94) translateY(12px);
  }
  to {
    opacity: 1;
    filter: none;
    transform: scale(1) translateY(0);
  }
}

@keyframes backdrop-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes incoming-ring {
  0% {
    opacity: 0.8;
    transform: scale(0.88);
  }
  100% {
    opacity: 0;
    transform: scale(1.28);
  }
}

@keyframes recording-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(215, 90, 74, 0.25); }
  50%      { box-shadow: 0 0 0 8px rgba(215, 90, 74, 0); }
}

/* ── Accessibility ────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
  }
}

/* ── Responsive: 1100px ──────────────────────── */

@media (max-width: 1100px) {
  h1 {
    font-size: 4rem;
  }

  .auth {
    grid-template-columns: 1fr;
    padding: 32px;
  }

  .brand {
    grid-template-columns: 176px minmax(0, 1fr);
  }
}

/* ── Responsive: 900px ───────────────────────── */

@media (max-width: 900px) {
  .brand {
    align-items: flex-start;
    grid-template-columns: 1fr;
  }

  .brand__visual {
    height: 168px;
    width: 168px;
  }

  .brand__mark {
    height: 122px;
    width: 122px;
  }

  .signal--one  { height: 92px;  width: 92px; }
  .signal--two  { height: 124px; width: 124px; }
  .signal--three{ height: 154px; width: 154px; }
}

/* ── Responsive: Mobile ≤768px ───────────────── */

@media (max-width: 768px) {

  /* AUTH */
  .auth {
    gap: 18px;
    grid-template-columns: 1fr;
    min-height: auto;
    padding: 16px;
    padding-top: max(24px, env(safe-area-inset-top));
  }

  h1 {
    font-size: 2.8rem;
  }

  .lead {
    font-size: 0.95rem;
    margin-top: 12px;
  }

  .brand__visual {
    height: 124px;
    width: 124px;
  }

  .brand__mark {
    height: 92px;
    width: 92px;
  }

  .signal--one  { height: 68px;  width: 68px; }
  .signal--two  { height: 96px;  width: 96px; }
  .signal--three{ height: 122px; width: 122px; }

  .auth-form {
    gap: 14px;
    padding: 18px;
  }

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

  .login-mascots {
    min-height: 176px;
    padding: 10px 10px 12px;
  }

  .login-mascots__speech {
    min-height: 28px;
  }

  .capybara-login {
    height: 126px;
  }

  .capybara-login__shadow {
    bottom: 5px;
    width: 152px;
  }

  .capybara {
    bottom: 10px;
    scale: 0.88;
  }

  .auth-actions {
    flex-direction: column;
    gap: 8px;
  }

  .auth-actions button {
    width: 100%;
  }

  /* MESSENGER — mobile slide layout */
  .messenger {
    display: block;
    height: 100vh;
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
    padding: 0;
    position: relative;
    touch-action: manipulation;
  }

  .sidebar {
    background: rgba(255, 255, 255, 0.98);
    border-radius: 0;
    border: none;
    box-shadow: none;
    height: 100%;
    left: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 16px;
    padding-top: max(16px, env(safe-area-inset-top));
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    position: absolute;
    top: 0;
    transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
    width: 100%;
    will-change: transform;
    z-index: 30;
  }

  .sidebar.is-behind {
    pointer-events: none;
    transform: translateX(-104%);
    z-index: 5;
  }

  .chat {
    border-radius: 0;
    border: none;
    bottom: 0;
    height: 100%;
    left: 0;
    max-height: 100dvh;
    position: absolute;
    right: 0;
    top: 0;
    z-index: 20;
  }

  .back-button {
    display: flex;
  }

  .chat-header {
    padding: 10px 12px;
    padding-top: max(10px, env(safe-area-inset-top));
  }

  .composer {
    padding: 10px 12px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }

  .attachment-preview {
    padding: 8px 12px;
  }

  .attachment-preview__frame {
    grid-template-columns: 56px minmax(0, 1fr) auto;
  }

  .attachment-preview img,
  .attachment-preview video,
  .attachment-preview__file-icon {
    height: 48px;
    width: 56px;
  }

  .attachment-preview audio {
    max-width: 150px;
  }

  .composer textarea {
    font-size: 16px;
  }

  .admin-user-row {
    grid-template-columns: 34px minmax(0, 1fr);
  }

  .admin-user-row button {
    width: 100%;
  }

  .call-btn__label {
    display: none;
  }

  .call-btn {
    flex-direction: row;
    padding: 0 12px;
    gap: 0;
  }

  .message {
    max-width: 92%;
  }

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

  /* CALL PANEL — full screen on mobile */
  .call-panel {
    animation: call-in-mobile 380ms cubic-bezier(0.22, 1, 0.36, 1) both;
    border-radius: 0;
    bottom: 0;
    height: 100dvh;
    left: 0;
    max-height: none;
    right: 0;
    top: 0;
    transform: none;
    width: 100%;
    z-index: 200;
  }

  .call-stage {
    aspect-ratio: unset;
    height: 100%;
    height: 100dvh;
  }

  .call-overlay__top {
    padding-top: max(20px, env(safe-area-inset-top));
  }

  .call-overlay__bottom {
    padding-bottom: max(24px, env(safe-area-inset-bottom));
  }

  .call-ctrl {
    height: 60px;
    width: 60px;
  }

  .call-ctrl--hangup {
    height: 72px;
    width: 72px;
  }

  #localVideo {
    bottom: 90px;
    height: 112px;
    right: 14px;
    width: 88px;
  }

  .call-panel.is-self-focused #remoteVideo {
    bottom: 90px;
    height: 112px;
    right: 14px;
    width: 88px;
  }
}

/* ── Responsive: 560px ───────────────────────── */

@media (max-width: 560px) {
  h1 {
    font-size: 2.35rem;
  }
}
