:root {
  color-scheme: light;
  --md-sys-color-primary: #1266d6;
  --md-sys-color-on-primary: #ffffff;
  --md-sys-color-primary-container: #d8e7ff;
  --md-sys-color-on-primary-container: #001b3e;
  --md-sys-color-secondary: #006c57;
  --md-sys-color-on-secondary: #ffffff;
  --md-sys-color-secondary-container: #baf2df;
  --md-sys-color-on-secondary-container: #002018;
  --md-sys-color-tertiary: #8a4d68;
  --md-sys-color-tertiary-container: #ffd8e7;
  --md-sys-color-error: #ba1a1a;
  --md-sys-color-error-container: #ffdad6;
  --md-sys-color-surface: #f8fbff;
  --md-sys-color-surface-dim: #d8e2ee;
  --md-sys-color-surface-container-lowest: #ffffff;
  --md-sys-color-surface-container-low: #f2f7fd;
  --md-sys-color-surface-container: #ecf3fb;
  --md-sys-color-surface-container-high: #e4edf7;
  --md-sys-color-surface-container-highest: #dce7f2;
  --md-sys-color-on-surface: #17202b;
  --md-sys-color-on-surface-variant: #4b5c70;
  --md-sys-color-outline: #748398;
  --md-sys-color-outline-variant: #c6d0de;
  --md-shape-corner-small: 10px;
  --md-shape-corner-medium: 16px;
  --md-shape-corner-large: 22px;
  --md-shape-corner-extra-large: 30px;
  --md-shape-corner-full: 999px;
  --md-elevation-level1: 0 2px 8px rgba(28, 52, 79, 0.08), 0 1px 2px rgba(28, 52, 79, 0.05);
  --md-elevation-level2: 0 10px 28px rgba(22, 50, 82, 0.12), 0 2px 8px rgba(22, 50, 82, 0.06);
  --md-elevation-level3: 0 24px 70px rgba(22, 50, 82, 0.16), 0 6px 20px rgba(22, 50, 82, 0.08);
  --md-motion-duration-short: 150ms;
  --md-motion-duration-medium: 240ms;
  --md-motion-duration-long: 360ms;
  --composer-action-flip-duration: 360ms;
  --md-motion-easing-standard: cubic-bezier(0.2, 0, 0, 1);
  --md-motion-easing-emphasized: cubic-bezier(0.2, 0, 0, 1);
  --md-motion-easing-expressive: cubic-bezier(0.34, 1.56, 0.64, 1);
  --bg: radial-gradient(circle at 14% 8%, rgba(18, 102, 214, 0.12), transparent 28vw), linear-gradient(135deg, #f8fbff, #e9f2fb 48%, #e8f6f0);
  --panel: var(--md-sys-color-surface-container-lowest);
  --panel-soft: var(--md-sys-color-surface-container);
  --header-bg: rgba(255, 255, 255, 0.78);
  --composer-bg: rgba(255, 255, 255, 0.88);
  --chat-bg: #f6faff;
  --hover: rgba(18, 102, 214, 0.08);
  --active: var(--md-sys-color-primary-container);
  --input-bg: rgba(255, 255, 255, 0.92);
  --line: var(--md-sys-color-outline-variant);
  --text: var(--md-sys-color-on-surface);
  --muted: var(--md-sys-color-on-surface-variant);
  --blue: var(--md-sys-color-primary);
  --blue-strong: #004a9f;
  --green: #0c7b5d;
  --voice-waveform-out: rgba(212, 232, 255, 0.78);
  --voice-waveform-out-played: #ffffff;
  --voice-duration-out: rgba(231, 242, 255, 0.86);
  --amber: #a75d00;
  --danger: var(--md-sys-color-error);
  --danger-soft: var(--md-sys-color-error-container);
  --bubble-in: var(--md-sys-color-surface-container-lowest);
  --bubble-out: #cfe5ff;
  --bubble-meta: rgba(15, 23, 32, 0.54);
  --toast-bg: #1f2935;
  --toast-text: #ffffff;
  --modal-backdrop: rgba(17, 28, 39, 0.42);
  --shadow: var(--md-elevation-level3);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --mobile-visual-viewport-height: 100dvh;
  --mobile-visual-viewport-top: 0px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --md-sys-color-primary: #a9c8ff;
  --md-sys-color-on-primary: #003063;
  --md-sys-color-primary-container: #004a95;
  --md-sys-color-on-primary-container: #d8e7ff;
  --md-sys-color-secondary: #8fd6c1;
  --md-sys-color-on-secondary: #00382c;
  --md-sys-color-secondary-container: #005142;
  --md-sys-color-on-secondary-container: #baf2df;
  --md-sys-color-tertiary: #f7b8d0;
  --md-sys-color-tertiary-container: #6e3650;
  --md-sys-color-error: #ffb4ab;
  --md-sys-color-error-container: #93000a;
  --md-sys-color-surface: #0f1722;
  --md-sys-color-surface-dim: #0f1722;
  --md-sys-color-surface-container-lowest: #0a111a;
  --md-sys-color-surface-container-low: #151f2c;
  --md-sys-color-surface-container: #1a2532;
  --md-sys-color-surface-container-high: #243242;
  --md-sys-color-surface-container-highest: #2e3d50;
  --md-sys-color-on-surface: #edf3fb;
  --md-sys-color-on-surface-variant: #bdc8d7;
  --md-sys-color-outline: #8996a8;
  --md-sys-color-outline-variant: #354457;
  --md-elevation-level1: 0 2px 8px rgba(0, 0, 0, 0.22);
  --md-elevation-level2: 0 12px 30px rgba(0, 0, 0, 0.28);
  --md-elevation-level3: 0 26px 76px rgba(0, 0, 0, 0.38);
  --bg: radial-gradient(circle at 10% 8%, rgba(169, 200, 255, 0.12), transparent 28vw), linear-gradient(135deg, #0d1520, #111d2a 52%, #10231f);
  --panel: var(--md-sys-color-surface-container-lowest);
  --panel-soft: var(--md-sys-color-surface-container);
  --header-bg: rgba(21, 31, 44, 0.82);
  --composer-bg: rgba(21, 31, 44, 0.9);
  --chat-bg: #101a25;
  --hover: rgba(169, 200, 255, 0.1);
  --active: var(--md-sys-color-primary-container);
  --input-bg: rgba(10, 17, 26, 0.92);
  --line: var(--md-sys-color-outline-variant);
  --text: var(--md-sys-color-on-surface);
  --muted: var(--md-sys-color-on-surface-variant);
  --blue: var(--md-sys-color-primary);
  --blue-strong: #d8e7ff;
  --green: #8fd6c1;
  --amber: #ffc170;
  --danger: var(--md-sys-color-error);
  --danger-soft: #3d1918;
  --bubble-in: var(--md-sys-color-surface-container);
  --bubble-out: #163a63;
  --bubble-meta: rgba(238, 245, 251, 0.56);
  --toast-bg: #152235;
  --toast-text: #eef5ff;
  --modal-backdrop: rgba(0, 0, 0, 0.58);
  --shadow: var(--md-elevation-level3);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

button,
input,
textarea {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.hidden {
  display: none !important;
}

.app-shell {
  height: 100dvh;
  min-height: 100dvh;
  overflow: hidden;
  padding: max(14px, var(--safe-top)) 14px max(14px, var(--safe-bottom));
}

.login-screen {
  --login-text: var(--md-sys-color-on-surface);
  --login-muted: var(--md-sys-color-on-surface-variant);
  --login-label: color-mix(in srgb, var(--md-sys-color-primary) 72%, var(--login-text));
  --login-line: color-mix(in srgb, var(--md-sys-color-outline-variant) 78%, transparent);
  --login-surface: color-mix(in srgb, var(--md-sys-color-surface-container-lowest) 84%, transparent);
  --login-field: color-mix(in srgb, var(--md-sys-color-surface-container-lowest) 76%, var(--md-sys-color-surface-container));
  --login-input-bg: color-mix(in srgb, var(--md-sys-color-surface-container-lowest) 88%, var(--md-sys-color-surface-container));
  --login-control-radius: 20px;
  min-height: calc(100dvh - 24px);
  display: grid;
  place-content: center;
  justify-items: center;
  gap: clamp(20px, 3vh, 32px);
  padding: 24px;
  color: var(--login-text);
  background:
    radial-gradient(circle at 50% 30%, color-mix(in srgb, var(--md-sys-color-primary) 18%, transparent), transparent 330px),
    linear-gradient(135deg, color-mix(in srgb, var(--md-sys-color-surface) 96%, white), var(--md-sys-color-surface-container) 48%, color-mix(in srgb, var(--md-sys-color-secondary-container) 46%, var(--md-sys-color-surface))),
    url("/assets/chat-pattern.svg");
  background-color: var(--md-sys-color-surface);
  background-blend-mode: normal, normal, soft-light;
  border: 1px solid rgba(255, 255, 255, 0.78);
}

.login-mark {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
  transform: translateY(0);
  animation: enterUp 520ms ease both;
}

.login-mark img {
  width: 90px;
  height: 90px;
  border-radius: 24%;
  filter: drop-shadow(0 18px 34px color-mix(in srgb, var(--md-sys-color-primary) 24%, transparent));
}

.brand img,
.empty-state img {
  border-radius: 24%;
}

.login-mark h1,
.login-mark p {
  margin: 0;
}

.login-mark h1 {
  font-size: 54px;
  line-height: 0.92;
  letter-spacing: 0;
  color: var(--login-text);
  text-shadow: 0 1px 0 color-mix(in srgb, var(--md-sys-color-surface-container-lowest) 54%, transparent);
}

.login-mark p {
  margin-top: 8px;
  color: var(--login-muted);
  font-weight: 600;
}

.login-form {
  width: min(520px, calc(100vw - 48px));
  display: grid;
  gap: 14px;
  padding: 20px;
  border: 1px solid var(--login-line);
  border-radius: var(--md-shape-corner-extra-large);
  background: var(--login-surface);
  box-shadow:
    0 24px 72px color-mix(in srgb, var(--md-sys-color-primary) 10%, transparent),
    var(--md-elevation-level2);
  backdrop-filter: blur(18px);
  animation: containerEnter var(--md-motion-duration-long) 80ms var(--md-motion-easing-expressive) both;
}

.login-form label {
  color: var(--login-label);
  font-size: 13px;
  font-weight: 700;
}

.phone-row {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(156px, auto);
  gap: 10px;
}

.identity-login-details {
  border: 1px solid var(--login-line);
  border-radius: var(--login-control-radius);
  padding: 12px 14px;
  background: var(--login-field);
  box-shadow: inset 0 1px 0 color-mix(in srgb, var(--md-sys-color-surface-container-lowest) 42%, transparent);
  transition:
    border-color var(--md-motion-duration-short) var(--md-motion-easing-standard),
    background var(--md-motion-duration-short) var(--md-motion-easing-standard);
}

.identity-login-details[open] {
  border-color: color-mix(in srgb, var(--md-sys-color-primary) 42%, var(--login-line));
  background: color-mix(in srgb, var(--login-field) 86%, var(--md-sys-color-primary-container));
}

.identity-login-details summary {
  cursor: pointer;
  color: var(--login-muted);
  font-size: 14px;
  font-weight: 750;
  line-height: 1.35;
}

.identity-login-details summary::marker {
  color: color-mix(in srgb, var(--login-muted) 82%, transparent);
}

.identity-login-details textarea {
  width: 100%;
  min-width: 0;
  margin-top: 12px;
  border: 1px solid var(--login-line);
  border-radius: var(--login-control-radius);
  padding: 12px;
  resize: vertical;
  background: var(--login-input-bg);
  color: var(--login-text);
  font: 700 12px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.login-environment-warning {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 13px 14px;
  border: 1px solid color-mix(in srgb, var(--md-sys-color-error) 34%, var(--login-line));
  border-radius: var(--login-control-radius);
  background: color-mix(in srgb, var(--md-sys-color-error-container) 64%, var(--login-field));
  color: var(--login-text);
  box-shadow: inset 0 1px 0 color-mix(in srgb, var(--md-sys-color-surface-container-lowest) 38%, transparent);
}

.login-environment-warning i {
  margin-top: 2px;
  color: var(--md-sys-color-error);
  font-size: 22px;
}

.login-environment-warning strong,
.login-environment-warning p {
  margin: 0;
}

.login-environment-warning strong {
  color: var(--login-text);
  font-size: 14px;
}

.login-environment-warning p {
  margin-top: 4px;
  color: var(--login-muted);
  font-size: 13px;
  font-weight: 650;
  line-height: 1.42;
}

.identity-import-control textarea {
  width: 100%;
  min-width: 0;
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: var(--md-shape-corner-large);
  padding: 12px;
  resize: vertical;
  background: var(--input-bg);
  color: var(--text);
  font: 700 12px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.turnstile-box {
  min-height: 70px;
  display: grid;
  place-items: center start;
}

.phone-row input,
.contact-form input,
.composer textarea,
.account-form input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  color: var(--text);
  background: var(--input-bg);
  outline: none;
  transition:
    border-color var(--md-motion-duration-short) var(--md-motion-easing-standard),
    box-shadow var(--md-motion-duration-short) var(--md-motion-easing-standard),
    background var(--md-motion-duration-short) var(--md-motion-easing-standard),
    transform var(--md-motion-duration-short) var(--md-motion-easing-standard);
}

.phone-row input {
  height: 58px;
  padding: 0 18px;
  border-radius: var(--login-control-radius);
  border-color: var(--login-line);
  background: var(--login-input-bg);
  color: var(--login-text);
  font-size: 18px;
  font-weight: 650;
  box-shadow: inset 0 1px 0 color-mix(in srgb, var(--md-sys-color-surface-container-lowest) 44%, transparent);
}

.phone-row input::placeholder {
  color: color-mix(in srgb, var(--login-muted) 72%, transparent);
}

.phone-row input:focus,
.contact-form input:focus,
.composer textarea:focus,
.account-form input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--md-sys-color-primary) 16%, transparent);
}

.primary-btn,
.secondary-btn,
.send-btn,
.composer-action-btn,
.icon-btn {
  border: 0;
  cursor: pointer;
  display: inline-grid;
  place-items: center;
  transition:
    transform var(--md-motion-duration-short) var(--md-motion-easing-expressive),
    background var(--md-motion-duration-short) var(--md-motion-easing-standard),
    color var(--md-motion-duration-short) var(--md-motion-easing-standard),
    opacity var(--md-motion-duration-short) var(--md-motion-easing-standard),
    box-shadow var(--md-motion-duration-short) var(--md-motion-easing-standard);
}

.primary-btn {
  height: 52px;
  padding: 0 22px;
  border-radius: var(--md-shape-corner-full);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--blue);
  color: var(--md-sys-color-on-primary);
  font-weight: 800;
  gap: 8px;
}

.login-form .primary-btn {
  height: 58px;
  border-radius: var(--login-control-radius);
  background: linear-gradient(135deg, var(--md-sys-color-primary), color-mix(in srgb, var(--md-sys-color-primary) 72%, var(--md-sys-color-secondary)));
  color: var(--md-sys-color-on-primary);
  box-shadow:
    0 12px 28px color-mix(in srgb, var(--md-sys-color-primary) 18%, transparent),
    inset 0 1px 0 color-mix(in srgb, white 36%, transparent);
}

.login-submit {
  min-width: 156px;
  font-size: 15px;
}

.login-submit i {
  font-size: 18px;
  line-height: 1;
}

.secondary-btn {
  height: 44px;
  padding: 0 18px;
  border-radius: var(--md-shape-corner-full);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--md-sys-color-surface-container-high) 24%, transparent);
  color: #fff;
  font-weight: 800;
}

.primary-btn:hover,
.send-btn:hover,
.composer-action-btn:hover,
.icon-btn:hover {
  transform: translateY(-2px);
}

.primary-btn:active,
.secondary-btn:active,
.send-btn:active,
.composer-action-btn:active,
.icon-btn:active {
  transform: translateY(0) scale(0.94);
}

.login-note {
  margin: 2px 0 0;
  color: var(--login-muted);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.5;
}

.messenger {
  height: calc(100dvh - 24px);
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(300px, 392px) minmax(0, 1fr);
  overflow: hidden;
  background: color-mix(in srgb, var(--md-sys-color-surface-container-lowest) 82%, transparent);
  border: 1px solid color-mix(in srgb, var(--md-sys-color-outline-variant) 72%, transparent);
  border-radius: var(--md-shape-corner-extra-large);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
  animation: containerEnter var(--md-motion-duration-medium) var(--md-motion-easing-emphasized) both;
}

.sidebar {
  min-width: 0;
  display: grid;
  grid-template-rows: auto auto 1fr;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, var(--md-sys-color-surface-container-lowest), var(--md-sys-color-surface-container-low));
}

.sidebar-header,
.chat-header {
  min-height: 76px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--header-bg);
  backdrop-filter: blur(18px);
  z-index: 2;
}

.brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}

.brand strong,
.peer-title strong {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand span,
.peer-title span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.peer-title .peer-meta.offline,
.peer-title .peer-meta.muted {
  color: var(--muted);
}

.peer-title .peer-meta.online {
  color: var(--green);
}

.header-actions,
.call-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--md-sys-color-surface-container-high) 52%, transparent);
  color: var(--muted);
  font-size: 21px;
  line-height: 1;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--md-sys-color-outline-variant) 58%, transparent);
}

.icon-btn i,
.send-btn i,
.composer-action-btn i,
.primary-btn i,
.segmented i {
  display: block;
  line-height: 1;
}

.icon-btn:hover {
  background: var(--md-sys-color-primary-container);
  color: var(--blue);
  box-shadow: var(--md-elevation-level1);
}

.icon-btn.accent {
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  box-shadow: var(--md-elevation-level1);
}

.icon-btn.danger {
  background: var(--md-sys-color-error);
  color: var(--md-sys-color-on-primary);
}

.icon-btn.glass {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  backdrop-filter: blur(12px);
}

.icon-btn.glass.active {
  background: var(--blue);
  color: #fff;
}

.contact-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 12px 16px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--md-sys-color-surface-container-low);
}

.contact-form input {
  height: 46px;
  padding: 0 16px;
  border-radius: var(--md-shape-corner-full);
}

.contact-list {
  overflow: auto;
  padding: 8px;
}

.contact-item {
  width: 100%;
  min-width: 0;
  min-height: 72px;
  border: 0;
  border-radius: var(--md-shape-corner-large);
  padding: 10px;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition:
    background var(--md-motion-duration-short) var(--md-motion-easing-standard),
    transform var(--md-motion-duration-short) var(--md-motion-easing-expressive),
    box-shadow var(--md-motion-duration-short) var(--md-motion-easing-standard),
    color var(--md-motion-duration-short) var(--md-motion-easing-standard);
}

.contact-item.unread {
  font-weight: 760;
}

.contact-item:hover,
.contact-item.active {
  background: var(--active);
  transform: translateY(-1px);
}

.contact-item.active {
  color: var(--md-sys-color-on-primary-container);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--md-sys-color-primary) 36%, transparent), var(--md-elevation-level1);
}

.avatar,
.peer-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--md-sys-color-on-primary);
  background:
    linear-gradient(145deg, var(--md-sys-color-secondary), var(--md-sys-color-primary));
  font-weight: 850;
  letter-spacing: 0;
  box-shadow: var(--md-elevation-level1);
}

.avatar.has-image,
.peer-avatar.has-image {
  overflow: hidden;
  background: linear-gradient(145deg, #dceeff, #f5f8fb);
}

.avatar img,
.peer-avatar img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.peer-avatar {
  flex: 0 0 auto;
}

.peer-avatar.large {
  width: 92px;
  height: 92px;
  font-size: 34px;
}

.contact-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.contact-copy strong,
.contact-copy span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.contact-copy span {
  color: var(--muted);
  font-size: 13px;
}

.contact-copy span.contact-meta.online {
  color: var(--green);
  font-weight: 760;
}

.contact-copy span.contact-meta.offline {
  color: var(--muted);
}

.contact-item.unread .contact-copy span {
  color: var(--blue);
  font-weight: 800;
}

.contact-item.key-alert .contact-copy span {
  color: var(--danger);
  font-weight: 850;
}

.contact-item.unverified-key .contact-copy span {
  color: #b97808;
  font-weight: 850;
}

.contact-side {
  display: grid;
  justify-items: end;
  align-items: center;
  gap: 8px;
}

.presence-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #aab6c1;
}

.presence-dot.online {
  background: var(--green);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--md-sys-color-secondary) 18%, transparent);
}

.unread-badge {
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  box-shadow: 0 6px 14px color-mix(in srgb, var(--md-sys-color-primary) 28%, transparent);
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
}

.key-alert-badge {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  background: var(--danger);
  color: #fff;
  box-shadow: 0 6px 14px rgba(226, 70, 70, 0.24);
  font-size: 14px;
  line-height: 1;
}

.request-badge,
.blocked-badge,
.unverified-badge,
.contact-muted-indicator {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  color: #fff;
  font-size: 14px;
  line-height: 1;
}

.request-badge {
  background: var(--blue);
  box-shadow: 0 6px 14px color-mix(in srgb, var(--md-sys-color-primary) 24%, transparent);
}

.blocked-badge {
  background: #7d8a9d;
  box-shadow: 0 6px 14px rgba(80, 93, 112, 0.18);
}

.unverified-badge {
  background: #e4a11b;
  box-shadow: 0 6px 14px rgba(228, 161, 27, 0.22);
}

.contact-muted-indicator {
  background: color-mix(in srgb, var(--muted) 14%, transparent);
  color: var(--muted);
  box-shadow: none;
}

.chat-panel {
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  position: relative;
  display: grid;
  grid-template-rows: auto auto auto auto auto minmax(0, 1fr) auto auto;
  background-color: var(--chat-bg);
  background-image:
    linear-gradient(color-mix(in srgb, var(--chat-bg) 84%, transparent), color-mix(in srgb, var(--chat-bg) 84%, transparent)),
    url("/assets/chat-pattern.svg");
}

.chat-panel:not(.has-contact) {
  grid-row: 1 / -1;
  grid-template-rows: minmax(0, 1fr);
}

.chat-panel:not(.has-contact) .chat-header {
  display: none;
}

.chat-panel:not(.has-contact) .key-warning {
  display: none;
}

.chat-panel:not(.has-contact) .chat-request-warning {
  display: none;
}

.chat-panel:not(.has-contact) .contact-trust-warning {
  display: none;
}

.chat-panel:not(.has-contact) .chat-search-bar {
  display: none;
}

.chat-panel:not(.has-contact) .messages {
  display: none;
}

.chat-panel:not(.has-contact) .composer-context {
  display: none;
}

.chat-panel:not(.has-contact) .composer {
  display: none;
}

.chat-panel:not(.has-contact) .empty-state {
  grid-row: 1;
}

.chat-back-btn {
  display: none;
  flex: 0 0 auto;
}

.chat-panel.has-contact .chat-back-btn {
  display: grid;
}

.mobile-only {
  display: none;
}

.peer-title {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.peer-name-display {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.peer-name-display strong {
  min-width: 0;
  flex: 0 1 auto;
}

.peer-title .peer-muted-indicator {
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  background: color-mix(in srgb, var(--muted) 12%, transparent);
  color: var(--muted);
  font-size: 15px;
  line-height: 1;
}

.peer-rename-btn,
.peer-name-action {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--md-sys-color-surface-container-high) 56%, transparent);
  color: var(--muted);
  cursor: pointer;
}

.peer-rename-btn:hover,
.peer-name-action:hover {
  background: var(--md-sys-color-primary-container);
  color: var(--blue);
}

.peer-name-form {
  width: min(360px, 100%);
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 6px;
}

.peer-name-form input {
  min-width: 0;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--md-shape-corner-large);
  padding: 0 12px;
  background: var(--input-bg);
  color: var(--text);
  font-weight: 750;
}

.empty-state {
  grid-row: 2 / 4;
  align-self: center;
  justify-self: center;
  width: min(420px, calc(100% - 40px));
  text-align: center;
  color: var(--muted);
  padding: 28px;
  border-radius: var(--md-shape-corner-extra-large);
  background: color-mix(in srgb, var(--md-sys-color-surface-container-lowest) 62%, transparent);
  box-shadow: var(--md-elevation-level1);
  animation: containerEnter var(--md-motion-duration-long) var(--md-motion-easing-expressive) both;
}

.empty-state h2 {
  margin: 12px 0 8px;
  color: var(--text);
  font-size: 24px;
  line-height: 1.1;
  letter-spacing: 0;
}

.empty-state p {
  margin: 0;
  line-height: 1.45;
}

.chat-search-bar {
  grid-row: 2;
  min-width: 0;
  margin: 10px min(6vw, 72px) 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--md-shape-corner-large);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  background: var(--composer-bg);
  color: var(--text);
  box-shadow: var(--md-elevation-level1);
  backdrop-filter: blur(18px);
  z-index: 2;
  animation: containerEnter var(--md-motion-duration-short) var(--md-motion-easing-emphasized) both;
}

.chat-search-bar > i {
  color: var(--muted);
  font-size: 20px;
}

.chat-search-bar input {
  min-width: 0;
  height: 40px;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  font-weight: 700;
}

.chat-search-bar input::-webkit-search-cancel-button {
  display: none;
}

.chat-search-counter {
  min-width: 64px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
  text-align: center;
  white-space: nowrap;
}

.chat-search-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.chat-search-actions .icon-btn {
  width: 36px;
  height: 36px;
  font-size: 18px;
}

.icon-btn.active {
  background: var(--md-sys-color-primary-container);
  color: var(--blue);
}

.key-warning {
  grid-row: 3;
  margin: 12px min(6vw, 72px) 0;
  padding: 14px;
  border: 1px solid color-mix(in srgb, var(--md-sys-color-error) 28%, transparent);
  border-radius: var(--md-shape-corner-large);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  background: var(--danger-soft);
  color: var(--text);
  box-shadow: var(--md-elevation-level1);
  z-index: 1;
  animation: tonalPulse var(--md-motion-duration-long) var(--md-motion-easing-emphasized) both;
}

.key-warning-icon {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--danger);
  color: #fff;
  font-size: 22px;
}

.key-warning strong,
.key-warning p {
  margin: 0;
}

.key-warning p {
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.35;
}

.secondary-warning-btn {
  min-height: 38px;
  border: 0;
  border-radius: var(--md-shape-corner-full);
  padding: 0 12px;
  background: var(--danger);
  color: #fff;
  cursor: pointer;
  font-weight: 850;
  white-space: nowrap;
}

.key-warning-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.secondary-warning-btn.ghost {
  border: 1px solid rgba(226, 70, 70, 0.24);
  background: rgba(255, 255, 255, 0.78);
  color: var(--danger);
}

.contact-trust-warning {
  grid-row: 4;
  margin: 12px min(6vw, 72px) 0;
  padding: 14px;
  border: 1px solid rgba(228, 161, 27, 0.32);
  border-radius: var(--md-shape-corner-large);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  background: color-mix(in srgb, #ffd27a 22%, var(--panel));
  color: var(--text);
  box-shadow: var(--md-elevation-level1);
  z-index: 1;
}

.contact-trust-icon {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #e4a11b;
  color: #fff;
  font-size: 22px;
}

.contact-trust-warning strong,
.contact-trust-warning p {
  margin: 0;
}

.contact-trust-warning p {
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.35;
}

.contact-trust-fingerprint {
  display: inline-block;
  margin-top: 8px;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  font-weight: 850;
}

.contact-trust-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.contact-trust-actions .secondary-warning-btn {
  background: #e4a11b;
}

.chat-request-warning {
  grid-row: 5;
  margin: 12px min(6vw, 72px) 0;
  padding: 14px;
  border: 1px solid color-mix(in srgb, var(--md-sys-color-primary) 24%, transparent);
  border-radius: var(--md-shape-corner-large);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  background: color-mix(in srgb, var(--md-sys-color-primary-container) 68%, var(--panel));
  color: var(--text);
  box-shadow: var(--md-elevation-level1);
  z-index: 1;
}

.chat-request-warning.blocked {
  border-color: rgba(125, 138, 157, 0.28);
  background: color-mix(in srgb, var(--md-sys-color-surface-container-high) 74%, var(--panel));
}

.chat-request-icon {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--blue);
  color: #fff;
  font-size: 22px;
}

.chat-request-warning.blocked .chat-request-icon {
  background: #7d8a9d;
}

.chat-request-warning strong,
.chat-request-warning p {
  margin: 0;
}

.chat-request-warning p {
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.35;
}

.chat-request-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.messages {
  grid-row: 6;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 20px min(6vw, 76px);
}

.unread-notice {
  position: absolute;
  right: 24px;
  bottom: calc(92px + var(--safe-bottom));
  z-index: 8;
  min-width: 42px;
  height: 34px;
  padding: 0 12px;
  border: 1px solid rgba(118, 153, 205, 0.24);
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  background: rgba(28, 96, 178, 0.94);
  color: #ffffff;
  box-shadow: 0 12px 30px rgba(20, 48, 92, 0.24);
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  transition:
    opacity var(--md-motion-duration-short) var(--md-motion-easing-standard),
    transform var(--md-motion-duration-short) var(--md-motion-easing-expressive);
}

.unread-notice.hidden {
  display: none;
}

.unread-notice i {
  font-size: 15px;
}

.unread-notice:active {
  transform: scale(0.96);
}

.message-row {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: min(78%, 640px);
  animation: bubbleIn var(--md-motion-duration-medium) var(--md-motion-easing-expressive) both;
  transition:
    transform var(--md-motion-duration-short) var(--md-motion-easing-expressive),
    filter var(--md-motion-duration-medium) var(--md-motion-easing-standard);
}

.message-row.actions-open {
  padding-bottom: 42px;
}

.message-row.out {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message-row.in {
  align-self: flex-start;
}

.message-row.swiping::before {
  content: "\ea96";
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  align-self: center;
  background: var(--blue);
  color: var(--md-sys-color-on-primary);
  font-family: "Phosphor";
  animation: expressiveSend var(--md-motion-duration-medium) var(--md-motion-easing-expressive) both;
}

.message-row.highlight {
  filter: drop-shadow(0 0 12px rgba(36, 129, 204, 0.34));
}

.message-row.search-current .bubble {
  border-color: color-mix(in srgb, var(--md-sys-color-primary) 52%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--md-sys-color-primary) 18%, transparent), var(--md-elevation-level1);
}

.search-hit {
  border-radius: 5px;
  padding: 0 2px;
  background: rgba(255, 211, 79, 0.62);
  color: inherit;
}

.message-row.search-current .search-hit {
  background: #ffbe45;
}

.message-row.no-enter-animation {
  animation: none;
}

.message-row.media-message-row {
  width: min(92%, 640px);
  max-width: none;
}

.message-row.media-message-row .bubble {
  min-width: 0;
  max-width: 100%;
  flex: 1 1 auto;
  overflow: hidden;
}

.message-row.media-message-row .message-actions {
  flex: 0 0 auto;
}

.bubble {
  min-width: 88px;
  min-height: 36px;
  padding: 10px 14px 8px;
  border: 1px solid color-mix(in srgb, var(--md-sys-color-outline-variant) 48%, transparent);
  border-radius: 20px;
  box-shadow: var(--md-elevation-level1);
  overflow-wrap: anywhere;
}

.deleted-message {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-style: italic;
  line-height: 1.35;
}

.call-message {
  min-width: 188px;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

.call-message-icon {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--md-sys-color-primary) 14%, transparent);
  color: var(--blue);
  font-size: 19px;
  line-height: 1;
}

.call-message-missed .call-message-icon {
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  color: var(--danger);
}

.call-message-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.call-message-copy strong,
.call-message-copy span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.call-message-copy strong {
  font-size: 14px;
  font-weight: 840;
}

.call-message-copy span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 720;
}

.reply-preview {
  width: 100%;
  min-width: 0;
  margin-bottom: 7px;
  padding: 7px 10px;
  border: 0;
  border-left: 3px solid var(--blue);
  border-radius: var(--md-shape-corner-medium);
  display: grid;
  gap: 2px;
  background: color-mix(in srgb, var(--md-sys-color-primary-container) 54%, transparent);
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.reply-preview strong,
.reply-preview span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reply-preview strong {
  color: var(--blue-strong);
  font-size: 12px;
}

.reply-preview span {
  color: var(--muted);
  font-size: 12px;
}

.message-row.in .bubble {
  background: var(--bubble-in);
  border-bottom-left-radius: var(--md-shape-corner-small);
}

.message-row.out .bubble {
  background: var(--bubble-out);
  border-color: color-mix(in srgb, var(--md-sys-color-primary) 16%, transparent);
  border-bottom-right-radius: var(--md-shape-corner-small);
}

.bubble-text {
  white-space: pre-wrap;
  line-height: 1.38;
}

.bubble-meta {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  color: var(--bubble-meta);
  font-size: 11px;
  font-weight: 700;
}

.message-reactions {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.message-reactions button {
  min-height: 24px;
  border: 1px solid color-mix(in srgb, var(--md-sys-color-primary) 18%, transparent);
  border-radius: 999px;
  padding: 2px 8px;
  background: color-mix(in srgb, var(--md-sys-color-surface-container-lowest) 72%, transparent);
  cursor: pointer;
  font-weight: 800;
}

.message-reactions button.own {
  border-color: color-mix(in srgb, var(--md-sys-color-primary) 42%, transparent);
  background: color-mix(in srgb, var(--md-sys-color-primary-container) 76%, transparent);
}

.message-actions-trigger {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  border: 1px solid rgba(148, 170, 204, 0.14);
  border-radius: 50%;
  display: grid;
  place-items: center;
  align-self: flex-end;
  margin-bottom: 4px;
  background: var(--ref-mobile-card-bg);
  color: var(--ref-muted);
  cursor: pointer;
  opacity: 0.58;
  transition:
    opacity var(--md-motion-duration-short) var(--md-motion-easing-standard),
    background var(--md-motion-duration-short) var(--md-motion-easing-standard),
    color var(--md-motion-duration-short) var(--md-motion-easing-standard);
}

.message-row.actions-open .message-actions-trigger,
.message-actions-trigger:focus-visible {
  background: rgba(148, 170, 204, 0.12);
  color: var(--ref-text);
  opacity: 1;
}

.message-actions {
  position: absolute;
  bottom: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  border: 1px solid rgba(148, 170, 204, 0.14);
  border-radius: 999px;
  background: var(--ref-mobile-menu-bg);
  box-shadow: var(--ref-mobile-menu-shadow);
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transform: translateY(4px) scale(0.98);
  z-index: 4;
  backdrop-filter: blur(12px);
  transition:
    opacity var(--md-motion-duration-short) var(--md-motion-easing-standard),
    visibility var(--md-motion-duration-short) var(--md-motion-easing-standard),
    transform var(--md-motion-duration-short) var(--md-motion-easing-expressive);
}

.message-row.actions-open .message-actions {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
  transform: none;
}

.message-row.in .message-actions {
  left: 0;
}

.message-row.out .message-actions {
  right: 0;
}

.message-actions > button {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(148, 170, 204, 0.16);
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(148, 170, 204, 0.1);
  color: var(--ref-text);
  cursor: pointer;
  box-shadow: none;
}

.message-actions > button:hover {
  color: var(--blue);
}

.reaction-picker {
  position: absolute;
  bottom: 36px;
  left: 0;
  display: flex;
  gap: 3px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  box-shadow: var(--shadow);
  z-index: 5;
  animation: containerEnter var(--md-motion-duration-short) var(--md-motion-easing-expressive) both;
}

.message-row.out .reaction-picker {
  left: auto;
  right: 0;
}

.reaction-picker button {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: transparent;
  cursor: pointer;
  font-size: 18px;
}

.reaction-picker button:hover {
  background: var(--hover);
}

.file-bubble {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-width: min(320px, 72vw);
  max-width: 100%;
}

.image-file-bubble {
  min-width: min(340px, 72vw);
}

.video-file-bubble {
  min-width: min(420px, 76vw);
}

.voice-bubble {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  min-width: min(430px, 72vw);
  max-width: 100%;
}

.voice-play-button {
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #3195ff, #1266d6);
  color: #fff;
  cursor: pointer;
  font-size: 20px;
  box-shadow: 0 8px 18px rgba(18, 102, 214, 0.22);
  transition:
    transform var(--md-motion-duration-short) var(--md-motion-easing-expressive),
    filter var(--md-motion-duration-short) var(--md-motion-easing-standard);
}

.voice-play-button:hover,
.voice-play-button:focus-visible {
  filter: brightness(1.04);
}

.voice-play-button:active {
  transform: scale(0.94);
}

.voice-body {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 4px;
}

.voice-waveform {
  min-width: 0;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2px;
}

.voice-waveform span {
  width: 3px;
  height: var(--voice-bar-height, 12px);
  border-radius: 999px;
  background: color-mix(in srgb, var(--blue) 34%, transparent);
  opacity: 0.72;
  transition:
    background var(--md-motion-duration-short) var(--md-motion-easing-standard),
    opacity var(--md-motion-duration-short) var(--md-motion-easing-standard);
}

.voice-waveform span.played {
  background: var(--blue);
  opacity: 1;
}

.voice-duration {
  justify-self: start;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}

.voice-audio {
  display: none;
}

.message-row.out .voice-waveform span {
  background: var(--voice-waveform-out);
  opacity: 0.92;
}

.message-row.out .voice-waveform span.played {
  background: var(--voice-waveform-out-played);
}

.message-row.out .voice-duration {
  color: var(--voice-duration-out);
}

.message-row.media-message-row .file-bubble {
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

.image-preview {
  grid-column: 1 / -1;
  position: relative;
  width: 100%;
  max-width: 100%;
  max-height: 330px;
  padding: 0;
  border: 0;
  border-radius: var(--md-shape-corner-large);
  overflow: hidden;
  display: block;
  background: #101820;
  cursor: zoom-in;
}

.image-preview img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  max-height: 330px;
  object-fit: contain;
}

.image-preview span {
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(7, 16, 24, 0.7);
  color: #fff;
  opacity: 0;
  transition: opacity 160ms ease;
}

.image-preview:hover span,
.image-preview:focus-visible span {
  opacity: 1;
}

.video-preview {
  grid-column: 1 / -1;
  position: relative;
  width: 100%;
  border-radius: var(--md-shape-corner-large);
  overflow: hidden;
  background: #071018;
}

.video-preview video {
  display: block;
  width: 100%;
  max-height: 330px;
  background: #000;
}

.video-preview-actions {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 6px;
  z-index: 1;
}

.video-fullscreen-btn {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(7, 16, 24, 0.72);
  color: #fff;
  cursor: pointer;
  backdrop-filter: blur(10px);
}

.video-fullscreen-btn:hover {
  background: rgba(36, 129, 204, 0.9);
}

.file-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--md-shape-corner-medium);
  display: grid;
  place-items: center;
  background: var(--md-sys-color-primary-container);
  color: var(--blue);
  font-weight: 900;
}

.file-info {
  min-width: 0;
}

.file-info strong,
.file-info span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-info span {
  color: var(--muted);
  font-size: 12px;
}

.file-info button {
  margin-top: 4px;
  padding: 0;
  border: 0;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: transparent;
  color: var(--blue);
  cursor: pointer;
  font-weight: 800;
}

.file-info button:disabled {
  color: var(--muted);
  cursor: default;
  opacity: 0.7;
}

.file-transfer-progress {
  width: 100%;
  height: 4px;
  margin: 8px 0 2px;
  border-radius: 999px;
  overflow: hidden;
  background: color-mix(in srgb, var(--md-sys-color-primary) 14%, transparent);
}

.file-transfer-progress span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), #22c55e);
  transition: width 180ms ease;
}

.composer-context {
  grid-row: 7;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px min(3vw, 22px);
  border-top: 1px solid var(--line);
  background: var(--composer-bg);
  backdrop-filter: blur(18px);
  animation: containerEnter var(--md-motion-duration-short) var(--md-motion-easing-emphasized) both;
}

.composer-context > div {
  min-width: 0;
  padding-left: 9px;
  border-left: 3px solid var(--blue);
  display: grid;
  gap: 2px;
}

.composer-context strong,
.composer-context span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.composer-context strong {
  color: var(--blue-strong);
  font-size: 13px;
}

.composer-context span {
  color: var(--muted);
  font-size: 13px;
}

.composer {
  grid-row: 8;
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: end;
  gap: 10px;
  padding: 12px min(3vw, 24px) calc(12px + var(--safe-bottom));
  background: var(--composer-bg);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.file-input {
  display: none;
}

.composer textarea {
  min-height: 46px;
  max-height: 130px;
  overflow-y: hidden;
  resize: none;
  padding: 11px 16px;
  border-radius: var(--md-shape-corner-extra-large);
  line-height: 1.35;
}

.composer-action-btn {
  position: relative;
  overflow: hidden;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--md-sys-color-surface-container-high) 52%, transparent);
  color: var(--muted);
  font-size: 21px;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--md-sys-color-outline-variant) 58%, transparent);
  touch-action: none;
  user-select: none;
  perspective: 640px;
}

.composer-action-btn.send-mode {
  background: linear-gradient(145deg, #25a7ee, var(--md-sys-color-primary));
  color: var(--md-sys-color-on-primary);
  box-shadow: var(--md-elevation-level2);
}

.composer-action-face {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  backface-visibility: hidden;
  transition:
    transform var(--composer-action-flip-duration) var(--md-motion-easing-expressive),
    opacity var(--md-motion-duration-short) var(--md-motion-easing-standard);
}

.composer-action-send {
  opacity: 0;
  transform: rotateY(180deg);
}

.composer-action-btn.send-mode .composer-action-voice {
  opacity: 0;
  transform: rotateY(-180deg);
}

.composer-action-btn.send-mode .composer-action-send {
  opacity: 1;
  transform: rotateY(0deg);
}

.composer-action-btn.send-mode:not(:disabled):active {
  animation: expressiveSend var(--md-motion-duration-medium) var(--md-motion-easing-expressive) both;
}

.send-btn:disabled,
.composer-action-btn:disabled,
.composer textarea:disabled,
.icon-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.composer-action-btn.recording {
  background: var(--danger);
  color: #fff;
  opacity: 1;
  animation: tonalPulse 900ms ease-in-out infinite;
}

.voice-recording-indicator {
  position: absolute;
  right: min(3vw, 24px);
  bottom: calc(76px + var(--safe-bottom));
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid color-mix(in srgb, var(--danger) 28%, transparent);
  border-radius: var(--md-shape-corner-full);
  background: var(--panel);
  color: var(--danger);
  box-shadow: var(--md-elevation-level2);
  z-index: 8;
  font-weight: 800;
}

.voice-recording-indicator i {
  font-size: 13px;
}

.status-icon {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.status-icon.delivered {
  color: var(--blue);
}

.status-icon.failed {
  color: var(--danger);
}

.status-icon.key_changed,
.status-icon.not_sent {
  color: var(--danger);
}

.emoji-toggle-btn {
  --emoji-toggle-duration: 220ms;
  --emoji-toggle-easing: cubic-bezier(0.2, 0, 0, 1);
  position: relative;
  overflow: hidden;
}

.emoji-toggle-face {
  position: relative;
  width: 24px;
  height: 24px;
  display: block;
  border: 1.55px solid currentColor;
  border-radius: 50%;
  transform: translateZ(0);
  transition:
    transform var(--emoji-toggle-duration) var(--emoji-toggle-easing),
    color var(--md-motion-duration-short) var(--md-motion-easing-standard);
}

.emoji-toggle-eye {
  position: absolute;
  top: 6.4px;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: currentColor;
  transition:
    transform var(--emoji-toggle-duration) var(--emoji-toggle-easing),
    opacity var(--md-motion-duration-short) var(--md-motion-easing-standard);
}

.emoji-toggle-eye-left {
  left: 5.8px;
}

.emoji-toggle-eye-right {
  right: 5.8px;
}

.emoji-toggle-mouth {
  position: absolute;
  left: 50%;
  top: 13px;
  width: 10px;
  height: 5.2px;
  border: 1.55px solid transparent;
  border-bottom-color: currentColor;
  border-radius: 0 0 999px 999px;
  transform: translateX(-50%) scale(1);
  transform-origin: center;
  transition:
    top var(--emoji-toggle-duration) var(--emoji-toggle-easing),
    width var(--emoji-toggle-duration) var(--emoji-toggle-easing),
    height var(--emoji-toggle-duration) var(--emoji-toggle-easing),
    border-color var(--md-motion-duration-short) var(--md-motion-easing-standard),
    border-radius var(--emoji-toggle-duration) var(--emoji-toggle-easing),
    background var(--md-motion-duration-short) var(--md-motion-easing-standard),
    transform var(--emoji-toggle-duration) var(--emoji-toggle-easing);
}

.emoji-open .emoji-toggle-face {
  transform: translateZ(0) scale(1.025) rotate(-1deg);
}

.emoji-open .emoji-toggle-eye-left {
  transform: translateY(-0.35px);
}

.emoji-open .emoji-toggle-eye-right {
  transform: translateY(-0.35px);
}

.emoji-open .emoji-toggle-mouth {
  top: 11.6px;
  width: 6.4px;
  height: 7.2px;
  border-color: currentColor;
  border-radius: 50%;
  background: color-mix(in srgb, currentColor 8%, transparent);
  transform: translateX(-50%) scale(1.02);
}

.emoji-panel {
  position: absolute;
  left: min(3vw, 22px);
  bottom: calc(76px + var(--safe-bottom));
  width: min(360px, calc(100vw - 24px));
  max-height: 304px;
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--md-shape-corner-extra-large);
  background: var(--panel);
  box-shadow: var(--shadow);
  z-index: 6;
  animation: containerEnter var(--md-motion-duration-medium) var(--md-motion-easing-expressive) both;
}

.emoji-btn {
  width: 100%;
  aspect-ratio: 1;
  border: 0;
  border-radius: var(--md-shape-corner-medium);
  display: grid;
  place-items: center;
  background: transparent;
  cursor: pointer;
  font-size: 24px;
  transition:
    background var(--md-motion-duration-short) var(--md-motion-easing-standard),
    transform var(--md-motion-duration-short) var(--md-motion-easing-expressive);
}

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

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

.account-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
  background: var(--modal-backdrop);
  backdrop-filter: blur(14px);
}

.account-card {
  width: min(480px, 100%);
  max-height: calc(100dvh - 36px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--md-shape-corner-extra-large);
  background: var(--panel);
  box-shadow: var(--shadow);
  animation: containerEnter var(--md-motion-duration-medium) var(--md-motion-easing-expressive) both;
}

.account-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 20px;
  border-bottom: 1px solid var(--line);
  background: var(--md-sys-color-surface-container-low);
}

.account-header h2,
.account-header p {
  margin: 0;
}

.account-header h2 {
  font-size: 22px;
  letter-spacing: 0;
}

.account-header p {
  margin-top: 4px;
  color: var(--muted);
  font-weight: 700;
}

.settings-card {
  width: min(540px, 100%);
}

.settings-icon {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: linear-gradient(135deg, #e8f2ff, #f7fbff);
  color: var(--blue);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 10px 24px rgba(36, 116, 242, 0.12);
  font-size: 26px;
}

.account-form {
  display: grid;
  gap: 14px;
  padding: 20px;
}

.account-form label,
.avatar-picker-row > span,
.theme-row > span,
.notification-settings-row > span,
.relay-server-row > span,
.chat-privacy-row > span,
.identity-transfer-row > span,
.media-cache-heading > span,
.chat-backup-row > span,
.account-grid span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.account-form input {
  height: 44px;
  border-radius: var(--md-shape-corner-large);
  padding: 0 14px;
}

.avatar-picker-row {
  display: grid;
  gap: 8px;
}

.avatar-picker {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.avatar-picker button {
  min-width: 0;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: var(--md-shape-corner-large);
  padding: 3px;
  background: var(--panel-soft);
  cursor: pointer;
  transition: border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.avatar-picker button:hover {
  transform: translateY(-1px);
  border-color: rgba(36, 129, 204, 0.38);
}

.avatar-picker button.active {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--md-sys-color-primary) 18%, transparent);
}

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

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

.account-grid > div {
  min-width: 0;
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--md-shape-corner-large);
  background: var(--panel-soft);
}

.account-grid strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-logout-btn {
  min-height: 44px;
  border: 1px solid rgba(226, 70, 70, 0.24);
  border-radius: var(--md-shape-corner-large);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--danger-soft);
  color: var(--danger);
  cursor: pointer;
  font-weight: 850;
}

.account-logout-btn:hover {
  border-color: rgba(226, 70, 70, 0.42);
  background: color-mix(in srgb, var(--danger) 12%, var(--panel));
}

.theme-row {
  display: grid;
  gap: 8px;
}

.notification-settings-row {
  display: grid;
  gap: 8px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.relay-server-row {
  display: grid;
  gap: 8px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.chat-privacy-row {
  display: grid;
  gap: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.identity-transfer-row {
  display: grid;
  gap: 12px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.identity-transfer-note {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
}

.identity-transfer-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.identity-transfer-btn {
  min-width: 0;
  min-height: 42px;
  gap: 8px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--ref-text, var(--text));
  box-shadow: none;
}

.identity-transfer-btn:hover {
  background: var(--hover);
  color: var(--blue);
}

.identity-export-warning {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid rgba(226, 70, 70, 0.24);
  border-radius: var(--md-shape-corner-large);
  background: var(--danger-soft);
}

.identity-export-warning strong,
.identity-export-warning p {
  margin: 0;
}

.identity-export-warning p {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
}

.identity-import-control {
  display: grid;
  gap: 8px;
}

.relay-server-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 138px;
  gap: 8px;
}

.relay-server-control input {
  min-width: 0;
  border: 1px solid var(--line);
  background: var(--input-bg);
  color: var(--ref-text, var(--text));
  font-weight: 700;
}

.relay-server-save {
  min-width: 0;
  height: 44px;
  gap: 8px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--ref-text, var(--text));
  box-shadow: none;
}

.relay-server-save:hover {
  background: var(--hover);
  color: var(--blue);
}

.relay-server-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.relay-server-footer small {
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.relay-server-reset {
  border: 0;
  background: transparent;
  color: var(--blue);
  cursor: pointer;
  font-size: 12px;
  font-weight: 850;
}

.media-cache-row {
  display: grid;
  gap: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.chat-backup-row {
  display: grid;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.media-cache-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.media-cache-heading strong {
  min-width: max-content;
  color: var(--ref-text, var(--text));
  font-size: 14px;
  font-weight: 850;
}

.cache-control {
  display: grid;
  gap: 8px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--md-shape-corner-large);
  background: var(--panel-soft);
}

.segmented button {
  min-width: 0;
  height: 38px;
  border: 0;
  border-radius: var(--md-shape-corner-medium);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 800;
}

.segmented button.active {
  background: var(--panel);
  color: var(--blue);
  box-shadow: var(--md-elevation-level1);
}

.media-cache-segmented {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.chat-privacy-segmented {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.notification-segmented {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.blocklist-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--md-shape-corner-large);
  background: var(--panel-soft);
}

.blocklist-heading,
.blocked-contact-item {
  display: flex;
  align-items: center;
  gap: 10px;
}

.blocklist-heading {
  justify-content: space-between;
}

.blocklist-heading strong {
  color: var(--ref-text, var(--text));
  font-size: 14px;
  font-weight: 850;
}

.blocklist-heading span {
  min-width: 26px;
  height: 24px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  background: var(--panel);
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.blocked-contacts-list {
  display: grid;
  gap: 8px;
}

.blocklist-empty {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
}

.blocked-contact-item {
  min-width: 0;
  padding: 8px;
  border-radius: var(--md-shape-corner-medium);
  background: var(--panel);
}

.avatar.small {
  width: 38px;
  height: 38px;
  font-size: 16px;
}

.blocked-contact-copy {
  min-width: 0;
  flex: 1 1 auto;
  display: grid;
  gap: 2px;
}

.blocked-contact-copy strong,
.blocked-contact-copy span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.blocked-contact-copy strong {
  color: var(--ref-text, var(--text));
  font-size: 14px;
  font-weight: 850;
}

.blocked-contact-copy span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.blocklist-unblock {
  flex: 0 0 auto;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--md-shape-corner-full);
  padding: 0 12px;
  background: var(--panel-soft);
  color: var(--blue);
  cursor: pointer;
  font-size: 12px;
  font-weight: 850;
}

.media-cache-clear-btn {
  width: 100%;
  height: 42px;
  gap: 8px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--ref-text, var(--text));
  box-shadow: none;
}

.media-cache-clear-btn:hover {
  background: var(--hover);
  color: var(--blue);
}

.chat-backup-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.chat-backup-btn {
  min-width: 0;
  height: 42px;
  gap: 8px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--ref-text, var(--text));
  box-shadow: none;
}

.chat-backup-btn:hover {
  background: var(--hover);
  color: var(--blue);
}

.backup-password-card {
  width: min(460px, 100%);
}

.backup-password-form {
  gap: 12px;
}

.backup-password-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding-top: 4px;
}

.backup-password-error {
  min-height: 18px;
  margin: -2px 0 0;
  color: var(--danger);
  font-size: 13px;
  font-weight: 800;
}

.backup-password-actions .primary-btn,
.backup-password-actions .secondary-btn {
  width: 100%;
}

.backup-password-cancel {
  border: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--ref-text, var(--text));
}

.cache-cleared-file-bubble .file-icon {
  background: color-mix(in srgb, var(--muted) 14%, transparent);
  color: var(--muted);
}

.call-layer {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 15%, rgba(37, 167, 238, 0.18), transparent 34vw),
    #071018;
  color: #fff;
  animation: containerEnter var(--md-motion-duration-medium) var(--md-motion-easing-emphasized) both;
}

.image-viewer {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: rgba(3, 8, 13, 0.94);
  color: #fff;
  animation: containerEnter var(--md-motion-duration-medium) var(--md-motion-easing-emphasized) both;
}

.image-viewer-bar {
  min-height: calc(58px + var(--safe-top));
  padding: calc(10px + var(--safe-top)) 16px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: rgba(6, 14, 22, 0.78);
  backdrop-filter: blur(18px);
}

.image-viewer-bar > div:first-child {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.image-viewer-bar strong,
.image-viewer-bar span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-viewer-bar span {
  color: rgba(255, 255, 255, 0.66);
  font-size: 12px;
  font-weight: 750;
}

.image-viewer-actions {
  display: flex;
  gap: 8px;
  flex: 0 0 auto;
}

.image-viewer-stage {
  min-height: 0;
  padding: 18px 18px calc(18px + var(--safe-bottom));
  display: grid;
  place-items: center;
  cursor: zoom-out;
}

.image-viewer-stage img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
}

.remote-stage {
  position: absolute;
  inset: 0;
  padding: calc(24px + var(--safe-top)) 24px calc(124px + var(--safe-bottom));
  display: grid;
  place-items: center;
  overflow: hidden;
}

.remote-stage video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.remote-stage video,
.call-placeholder {
  grid-area: 1 / 1;
}

.call-placeholder {
  max-width: min(720px, calc(100vw - 32px));
  min-width: 0;
  display: grid;
  place-items: center;
  gap: 10px;
  text-align: center;
}

.call-placeholder strong,
.call-placeholder span {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.call-placeholder strong {
  font-size: 24px;
  letter-spacing: 0;
}

.call-placeholder span {
  color: rgba(255, 255, 255, 0.72);
}

@media (max-height: 520px) {
  .remote-stage {
    padding: calc(14px + var(--safe-top)) 16px calc(106px + var(--safe-bottom));
  }

  .call-placeholder {
    gap: 6px;
  }

  .call-placeholder .peer-avatar.large {
    width: clamp(68px, 24vh, 92px);
    height: clamp(68px, 24vh, 92px);
    font-size: clamp(24px, 8vh, 34px);
  }

  .call-placeholder strong {
    font-size: clamp(20px, 6vh, 24px);
    line-height: 1.12;
  }

  .call-placeholder span {
    font-size: clamp(13px, 4.6vh, 16px);
    line-height: 1.2;
  }
}

.local-video {
  position: fixed;
  right: 20px;
  top: calc(20px + var(--safe-top));
  width: min(28vw, 210px);
  aspect-ratio: 3 / 4;
  object-fit: cover;
  background: #111b24;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: var(--md-shape-corner-extra-large);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.36);
}

.incoming-card {
  position: relative;
  z-index: 5;
  width: min(360px, calc(100vw - 32px));
  min-width: 0;
  display: grid;
  justify-items: center;
  gap: 18px;
  padding: 22px;
  border-radius: var(--md-shape-corner-extra-large);
  background: rgba(10, 20, 31, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(16px);
  text-align: center;
  animation: containerEnter var(--md-motion-duration-medium) var(--md-motion-easing-expressive) both;
}

.call-layer.ringing .call-placeholder .peer-avatar,
.incoming-call-mark {
  animation: callRingPulse 1400ms ease-in-out infinite;
}

.incoming-call-mark {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #2ebf7d, #2481cc);
  color: #fff;
  font-size: 34px;
  box-shadow: 0 18px 52px rgba(36, 129, 204, 0.36);
}

.incoming-card strong,
.incoming-card span {
  display: block;
}

.incoming-card span {
  margin-top: -10px;
  color: rgba(255, 255, 255, 0.68);
  font-size: 14px;
  font-weight: 760;
}

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

.call-controls {
  position: fixed;
  left: 50%;
  bottom: calc(26px + var(--safe-bottom));
  transform: translateX(-50%);
  display: flex;
  gap: 14px;
  z-index: 3;
}

.call-controls #endCallButton {
  background: rgba(255, 255, 255, 0.15);
  color: #ff5f68;
  box-shadow:
    inset 0 0 0 1px rgba(255, 95, 104, 0.34),
    0 12px 30px rgba(255, 95, 104, 0.16);
}

.call-controls #endCallButton i {
  color: #ff5f68;
}

.call-controls #endCallButton:hover {
  background: rgba(255, 95, 104, 0.18);
  color: #ff7a82;
}

.call-controls #endCallButton:hover i {
  color: #ff7a82;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(22px + var(--safe-bottom));
  z-index: 60;
  transform: translate(-50%, 20px);
  max-width: min(460px, calc(100vw - 28px));
  padding: 12px 16px;
  border-radius: var(--md-shape-corner-large);
  background: var(--toast-bg);
  color: var(--toast-text);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity var(--md-motion-duration-medium) var(--md-motion-easing-standard),
    transform var(--md-motion-duration-medium) var(--md-motion-easing-expressive);
  box-shadow: var(--shadow);
  font-size: 14px;
  line-height: 1.35;
}

.toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

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

@keyframes callRingPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(46, 191, 125, 0.3), 0 18px 52px rgba(36, 129, 204, 0.32);
    transform: scale(1);
  }
  55% {
    box-shadow: 0 0 0 22px rgba(46, 191, 125, 0), 0 22px 60px rgba(36, 129, 204, 0.38);
    transform: scale(1.04);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(46, 191, 125, 0), 0 18px 52px rgba(36, 129, 204, 0.32);
    transform: scale(1);
  }
}

@keyframes bubbleIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes containerEnter {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.96);
  }
  68% {
    opacity: 1;
    transform: translateY(-2px) scale(1.01);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes expressiveSend {
  0% {
    transform: scale(0.88) rotate(-6deg);
  }
  58% {
    transform: scale(1.08) rotate(3deg);
  }
  100% {
    transform: scale(1) rotate(0deg);
  }
}

@keyframes tonalPulse {
  0% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--md-sys-color-error) 18%, transparent);
  }
  100% {
    box-shadow: var(--md-elevation-level1);
  }
}

@keyframes emojiPop {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

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

@media (max-width: 760px) {
  .app-shell {
    padding: 0;
  }

  .messenger {
    height: 100dvh;
    grid-template-columns: 1fr;
    border: 0;
    box-shadow: none;
  }

  .sidebar {
    min-height: 0;
    border-right: 0;
  }

  .chat-panel {
    position: fixed;
    inset: 0;
    transform: translateX(100%);
    transition: transform 220ms ease;
    z-index: 10;
  }

  .messenger.chat-open .chat-panel {
    transform: translateX(0);
  }

  .mobile-only {
    display: grid;
  }

  .messages {
    padding: 14px 10px;
  }

  .key-warning,
  .contact-trust-warning,
  .chat-request-warning {
    margin: 10px;
    grid-template-columns: auto minmax(0, 1fr);
  }

  .secondary-warning-btn {
    width: 100%;
  }

  .key-warning-actions,
  .contact-trust-actions,
  .chat-request-actions {
    grid-column: 1 / -1;
    width: 100%;
  }

  .emoji-panel {
    left: 8px;
    right: 8px;
    width: auto;
    grid-template-columns: repeat(7, minmax(0, 1fr));
  }

  .message-row {
    max-width: 88%;
  }

  .message-row.media-message-row {
    width: 92%;
    max-width: none;
  }

  .image-file-bubble,
  .video-file-bubble {
    min-width: 0;
  }

  .image-preview,
  .image-preview img,
  .video-preview video {
    max-height: 300px;
  }

  .image-viewer-bar {
    padding-left: 10px;
    padding-right: 10px;
  }

  .image-viewer-stage {
    padding-left: 8px;
    padding-right: 8px;
  }

  .login-screen {
    min-height: 100dvh;
    border: 0;
    padding: 20px 16px;
  }

  .login-mark {
    justify-content: center;
    text-align: center;
    flex-direction: column;
  }

  .login-mark h1 {
    font-size: 46px;
  }

  .login-form {
    width: min(480px, calc(100vw - 32px));
    padding: 16px;
  }

  .phone-row {
    grid-template-columns: 1fr;
  }

  .primary-btn {
    width: 100%;
  }

  .local-video {
    width: 108px;
    right: 12px;
  }

  .account-modal {
    align-items: end;
    padding: 0;
  }

  .account-card {
    width: 100%;
    max-height: calc(100dvh - 12px);
    border-radius: var(--md-shape-corner-extra-large) var(--md-shape-corner-extra-large) 0 0;
  }

  .account-grid {
    grid-template-columns: 1fr;
  }

  .segmented {
    grid-template-columns: 1fr;
  }

  .media-cache-segmented {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .relay-server-control,
  .chat-backup-actions,
  .backup-password-actions {
    grid-template-columns: 1fr;
  }
}

/* Reference concept: light Material 3 Expressive MSGR shell */
:root {
  --ref-font-size-ui: 15px;
  --ref-icon-size: 22px;
  --ref-page-bg: radial-gradient(circle at 52% 0%, rgba(255, 255, 255, 0.9), transparent 34vw), linear-gradient(135deg, #f5f7fa, #e7edf4);
  --ref-bg: #eef2f6;
  --ref-shell: rgba(255, 255, 255, 0.84);
  --ref-panel: rgba(255, 255, 255, 0.78);
  --ref-panel-strong: #ffffff;
  --ref-chat: #f8fbff;
  --ref-text: #0f1d3a;
  --ref-muted: #5f6f88;
  --ref-faint: #96a3b5;
  --ref-line: rgba(118, 137, 164, 0.18);
  --ref-blue: #2474f2;
  --ref-blue-strong: #0053d6;
  --ref-blue-soft: #ddebff;
  --ref-green: #22b573;
  --ref-shadow-soft: 0 18px 60px rgba(31, 71, 116, 0.08);
  --ref-shadow-control: 0 12px 26px rgba(31, 98, 210, 0.18);
  --ref-mobile-shell-bg: #eef2f6;
  --ref-mobile-shell-image:
    radial-gradient(circle at 18% -8%, rgba(36, 116, 242, 0.12), transparent 280px),
    linear-gradient(180deg, #f7faff 0%, #eef2f6 46%, #e7edf4 100%);
  --ref-mobile-control-bg: rgba(255, 255, 255, 0.74);
  --ref-mobile-control-focus-bg: rgba(255, 255, 255, 0.86);
  --ref-mobile-control-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.88);
  --ref-mobile-control-focus-border: rgba(80, 130, 205, 0.42);
  --ref-mobile-control-focus-ring: 0 0 0 6px rgba(74, 110, 165, 0.16);
  --ref-mobile-icon-color: #50627f;
  --ref-mobile-placeholder: #687891;
  --ref-mobile-list-bg: rgba(255, 255, 255, 0.68);
  --ref-mobile-card-bg: rgba(255, 255, 255, 0.72);
  --ref-mobile-item-bg: rgba(255, 255, 255, 0.62);
  --ref-mobile-item-hover: #edf6ff;
  --ref-mobile-item-alert-bg: rgba(232, 241, 255, 0.76);
  --ref-mobile-menu-bg: rgba(255, 255, 255, 0.94);
  --ref-mobile-submenu-bg: rgba(36, 116, 242, 0.06);
  --ref-mobile-menu-shadow: 0 18px 44px rgba(37, 64, 98, 0.16);
  --ref-mobile-warning-text: #9d6708;
  --ref-mobile-alert-text: #b5332d;
  --bg: var(--ref-bg);
  --panel: var(--ref-panel-strong);
  --panel-soft: #f7faff;
  --header-bg: rgba(255, 255, 255, 0.88);
  --composer-bg: rgba(255, 255, 255, 0.9);
  --chat-bg: var(--ref-chat);
  --hover: rgba(36, 116, 242, 0.08);
  --active: #d9ebff;
  --input-bg: rgba(255, 255, 255, 0.84);
  --line: var(--ref-line);
  --text: var(--ref-text);
  --muted: var(--ref-muted);
  --blue: var(--ref-blue);
  --blue-strong: var(--ref-blue-strong);
  --green: var(--ref-green);
  --bubble-in: rgba(255, 255, 255, 0.86);
  --bubble-out: #d9ecff;
  --bubble-meta: rgba(15, 29, 58, 0.58);
  --toast-bg: #ffffff;
  --toast-text: var(--ref-text);
  --shadow: var(--ref-shadow-soft);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --ref-font-size-ui: 15px;
  --ref-icon-size: 22px;
  --ref-page-bg: radial-gradient(circle at 12% 8%, rgba(49, 132, 255, 0.18), transparent 28vw), radial-gradient(circle at 88% 92%, rgba(39, 211, 151, 0.1), transparent 26vw), linear-gradient(135deg, #08111f, #0d1420 54%, #111826);
  --ref-bg: #08111f;
  --ref-shell: rgba(10, 18, 30, 0.88);
  --ref-panel: rgba(18, 29, 44, 0.82);
  --ref-panel-strong: #121d2c;
  --ref-chat: #0d1724;
  --ref-text: #eef5ff;
  --ref-muted: #aab8cc;
  --ref-faint: #73839a;
  --ref-line: rgba(148, 170, 204, 0.16);
  --ref-blue: #78adff;
  --ref-blue-strong: #aecdff;
  --ref-blue-soft: #163354;
  --ref-green: #5fe0a5;
  --ref-shadow-soft: 0 22px 70px rgba(0, 0, 0, 0.32);
  --ref-shadow-control: 0 16px 34px rgba(13, 90, 214, 0.28);
  --ref-mobile-shell-bg: #08111f;
  --ref-mobile-shell-image:
    radial-gradient(circle at 18% -8%, rgba(80, 145, 255, 0.16), transparent 280px),
    linear-gradient(180deg, #08111f 0%, #0b1523 46%, #0f1a29 100%);
  --ref-mobile-control-bg: rgba(18, 29, 44, 0.58);
  --ref-mobile-control-focus-bg: rgba(18, 29, 44, 0.72);
  --ref-mobile-control-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  --ref-mobile-control-focus-border: rgba(116, 151, 205, 0.44);
  --ref-mobile-control-focus-ring: 0 0 0 6px rgba(91, 124, 176, 0.24);
  --ref-mobile-icon-color: #9fb1ca;
  --ref-mobile-placeholder: #8fa1ba;
  --ref-mobile-list-bg: rgba(18, 29, 44, 0.42);
  --ref-mobile-card-bg: rgba(18, 29, 44, 0.48);
  --ref-mobile-item-bg: rgba(18, 29, 44, 0.48);
  --ref-mobile-item-hover: rgba(28, 43, 64, 0.78);
  --ref-mobile-item-alert-bg: rgba(26, 48, 72, 0.58);
  --ref-mobile-menu-bg: rgba(18, 29, 44, 0.94);
  --ref-mobile-submenu-bg: rgba(120, 173, 255, 0.08);
  --ref-mobile-menu-shadow: 0 18px 44px rgba(0, 0, 0, 0.32);
  --ref-mobile-warning-text: #cdb77a;
  --ref-mobile-alert-text: #ffb9b1;
  --bg: var(--ref-bg);
  --panel: var(--ref-panel-strong);
  --panel-soft: #172437;
  --header-bg: rgba(18, 29, 44, 0.9);
  --composer-bg: rgba(18, 29, 44, 0.92);
  --chat-bg: var(--ref-chat);
  --hover: rgba(120, 173, 255, 0.12);
  --active: #1b3d63;
  --input-bg: rgba(8, 17, 31, 0.8);
  --line: var(--ref-line);
  --text: var(--ref-text);
  --muted: var(--ref-muted);
  --blue: var(--ref-blue);
  --blue-strong: var(--ref-blue-strong);
  --green: var(--ref-green);
  --bubble-in: rgba(24, 37, 55, 0.94);
  --bubble-out: #163a63;
  --bubble-meta: rgba(238, 245, 255, 0.58);
  --toast-bg: #152235;
  --toast-text: #eef5ff;
  --modal-backdrop: rgba(2, 8, 15, 0.7);
  --shadow: var(--ref-shadow-soft);
}

body {
  background: var(--ref-page-bg);
  color: var(--ref-text);
  font-size: var(--ref-font-size-ui);
  font-weight: 500;
}

.app-shell {
  padding: 14px;
  background: transparent;
}

.messenger {
  height: calc(100dvh - 28px);
  grid-template-columns: 270px 340px minmax(0, 1fr);
  gap: 18px;
  padding: 16px 14px 16px 18px;
  background: var(--ref-shell);
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 26px;
  box-shadow: 0 24px 86px rgba(24, 45, 74, 0.12);
  backdrop-filter: blur(28px);
}

.app-nav,
.chat-list-pane,
.conversation-pane {
  min-width: 0;
  min-height: 0;
}

.app-nav {
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  gap: 0;
  padding: 8px 0 0;
  border-right: 0;
  background: transparent;
}

.sidebar-header {
  height: 62px;
  min-height: 62px;
  padding: 0 6px 0 8px;
  border-bottom: 0;
  background: transparent;
  backdrop-filter: none;
}

.brand img {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  box-shadow: 0 12px 28px rgba(0, 85, 205, 0.24);
}

.brand {
  gap: 12px;
}

.brand strong {
  color: var(--ref-text);
  font-size: 26px;
  font-weight: 850;
  line-height: 1;
}

.brand span {
  margin-top: 4px;
  color: var(--ref-green);
  font-size: 15px;
  font-weight: 700;
}

.brand .connection-state.online {
  color: var(--ref-green);
}

.brand .connection-state.offline,
.brand .connection-state.connecting {
  color: var(--ref-muted);
}

.mobile-header-actions {
  display: none;
}

.contact-search-wrap {
  position: relative;
  align-self: start;
  margin-top: 14px;
  z-index: 3;
}

.contact-form {
  align-self: start;
  margin-top: 0;
  height: 50px;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 0 12px 0 14px;
  border: 1px solid rgba(119, 138, 166, 0.18);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.76);
  transition:
    border-color var(--md-motion-duration-short) var(--md-motion-easing-standard),
    box-shadow var(--md-motion-duration-short) var(--md-motion-easing-standard),
    background var(--md-motion-duration-short) var(--md-motion-easing-standard);
}

.contact-form:focus-within {
  border-color: rgba(80, 130, 205, 0.42);
  background: rgba(255, 255, 255, 0.82);
  box-shadow:
    0 0 0 6px rgba(74, 110, 165, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.84);
}

.contact-form > i {
  color: #50627f;
  font-size: var(--ref-icon-size);
}

.contact-form input {
  height: 100%;
  padding: 0 0 0 4px;
  border: 0;
  background: transparent;
  color: var(--ref-text);
  font-size: var(--ref-font-size-ui);
  font-weight: 650;
}

.contact-form input::placeholder {
  color: #687891;
}

.contact-form input:focus {
  outline: none;
  box-shadow: none;
}

.contact-form .icon-btn {
  width: 32px;
  height: 32px;
  background: transparent;
  box-shadow: none;
  color: #50627f;
}

.contact-form .icon-btn .ph-address-book::before {
  display: block;
  transform: translateX(-1px);
}

.contact-search-menu {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 8px);
  z-index: 12;
  display: grid;
  padding: 8px;
  border: 1px solid rgba(119, 138, 166, 0.18);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 18px 34px rgba(32, 48, 72, 0.18);
  backdrop-filter: blur(18px);
}

.add-contact-suggestion {
  min-width: 0;
  height: 44px;
  border: 0;
  border-radius: 14px;
  display: block;
  align-items: center;
  padding: 0 14px;
  background: transparent;
  color: var(--ref-text);
  cursor: pointer;
  text-align: left;
}

.add-contact-suggestion:hover {
  background: rgba(36, 116, 242, 0.1);
}

.add-contact-suggestion strong {
  overflow: hidden;
  font-size: 13px;
  font-weight: 800;
  line-height: 44px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.side-menu {
  align-self: start;
  margin-top: 10px;
  display: grid;
  gap: 8px;
  padding: 2px 0;
}

.nav-item {
  width: 100%;
  height: 52px;
  border: 0;
  border-radius: 14px;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: transparent;
  color: #52637f;
  cursor: pointer;
  text-align: left;
  font-size: 16px;
  font-weight: 660;
  transition:
    background var(--md-motion-duration-short) var(--md-motion-easing-standard),
    color var(--md-motion-duration-short) var(--md-motion-easing-standard),
    transform var(--md-motion-duration-short) var(--md-motion-easing-expressive);
}

.nav-item i {
  font-size: var(--ref-icon-size);
  color: currentColor;
}

.nav-item.active {
  background: #d9ebff;
  color: #0865df;
  font-weight: 820;
}

.nav-item:hover {
  background: rgba(36, 116, 242, 0.08);
  color: #0865df;
  transform: translateX(2px);
}

.security-card {
  align-self: end;
  margin-top: 0;
  min-height: 118px;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 16px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(227, 247, 238, 0.96), rgba(235, 250, 246, 0.8));
  color: #14354b;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.86);
}

.security-card > i,
.encryption-ribbon > i {
  display: grid;
  place-items: center;
  color: var(--ref-green);
  font-size: 34px;
}

.security-card strong,
.encryption-ribbon strong {
  display: block;
  color: #15324b;
  font-size: 14px;
  font-weight: 850;
  line-height: 1.2;
}

.security-card p,
.encryption-ribbon span {
  margin: 6px 0 0;
  color: #597087;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
}

.security-card-link {
  margin-top: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  padding: 0;
  background: transparent;
  color: #0b6fe9;
  cursor: pointer;
  font-size: 13px;
  line-height: 1.2;
  font-weight: 750;
}

.security-card-link:hover,
.encryption-info-link:hover {
  color: var(--ref-blue-strong);
}

.account-chip {
  margin-top: 12px;
  height: 82px;
  min-height: 82px;
  max-height: 82px;
  overflow: hidden;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid rgba(118, 137, 164, 0.14);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 14px 34px rgba(32, 48, 72, 0.08);
}

.account-chip .peer-avatar {
  width: 52px;
  height: 52px;
}

.account-chip-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.account-chip strong {
  display: block;
  color: var(--ref-text);
  font-size: 13px;
  font-weight: 850;
  line-height: 1.1;
}

.account-chip span {
  display: block;
  max-width: 100%;
  overflow: hidden;
  color: #61708a;
  font-size: 11px;
  font-weight: 650;
  line-height: 1.18;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-rail-phone {
  color: var(--ref-text);
  font-weight: 760;
}

.account-rail-key {
  color: var(--ref-muted);
}

.utility-actions {
  display: none;
}

.chat-list-pane {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  padding: 26px 8px 18px;
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: var(--ref-shadow-soft);
  backdrop-filter: blur(18px);
}

.chat-list-header {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 18px 12px;
}

.chat-list-header h2 {
  margin: 0;
  color: var(--ref-text);
  font-size: 22px;
  font-weight: 850;
  line-height: 1.1;
}

.contact-list {
  padding: 2px 0;
}

.contact-list > .empty-state {
  width: auto;
  margin: 14px;
  padding: 22px;
  border-radius: 22px;
  background: rgba(247, 250, 255, 0.78);
  box-shadow: none;
}

.contact-item {
  min-height: 82px;
  grid-template-columns: 58px minmax(0, 1fr) 44px;
  gap: 12px;
  padding: 10px 14px;
  border: 1px solid transparent;
  border-radius: 22px;
  background: transparent;
}

.contact-item + .contact-item {
  margin-top: 6px;
}

.contact-item .avatar {
  width: 58px;
  height: 58px;
}

.contact-copy {
  gap: 8px;
}

.contact-copy strong {
  color: var(--ref-text);
  font-size: 16px;
  font-weight: 850;
}

.contact-copy span {
  color: #5d6d87;
  font-size: 15px;
  font-weight: 560;
}

.contact-item:hover,
.contact-item.active {
  background: #edf6ff;
  transform: none;
}

.contact-item.active {
  border-color: #6da8ff;
  box-shadow: 0 8px 24px rgba(64, 128, 224, 0.12);
  color: var(--ref-text);
}

.contact-item.chat-request {
  background: rgba(219, 235, 255, 0.62);
}

.contact-item.blocked {
  opacity: 0.72;
}

.contact-item.blocked .presence-dot {
  background: #9aa7b8;
}

.contact-side {
  height: 100%;
  align-content: center;
  justify-items: end;
}

.presence-dot {
  width: 11px;
  height: 11px;
}

.presence-dot.online {
  background: var(--ref-green);
  box-shadow: none;
}

.unread-badge {
  min-width: 22px;
  height: 22px;
  background: var(--ref-blue);
}

.conversation-pane {
  display: grid;
  grid-template-rows: minmax(0, 1fr) 56px;
  gap: 14px;
}

.chat-panel {
  border-radius: 0 20px 20px 0;
  background-color: var(--ref-chat);
  background-image:
    linear-gradient(rgba(248, 251, 255, 0.82), rgba(248, 251, 255, 0.82)),
    url("/assets/chat-pattern.svg");
  overflow: hidden;
}

.chat-header {
  min-height: 104px;
  padding: 18px 24px;
  border-bottom: 0;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 12px 32px rgba(40, 65, 94, 0.06);
}

.chat-header .peer-avatar {
  width: 58px;
  height: 58px;
}

.peer-title {
  gap: 8px;
}

.peer-title strong {
  color: var(--ref-text);
  font-size: 21px;
  font-weight: 850;
}

.peer-rename-btn,
.peer-name-action {
  background: #f2f6fb;
  color: var(--ref-muted);
}

.peer-name-form input {
  border: 1px solid rgba(119, 138, 166, 0.18);
  background: rgba(255, 255, 255, 0.78);
  color: var(--ref-text);
  font-size: 15px;
}

.peer-status-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.peer-title span {
  color: var(--ref-green);
  font-size: 15px;
  font-weight: 720;
}

.peer-title .peer-meta.offline,
.peer-title .peer-meta.muted {
  color: var(--ref-muted);
}

.peer-title .peer-meta.online {
  color: var(--ref-green);
}

.peer-title .peer-meta.request {
  color: var(--ref-blue);
}

.peer-title .peer-meta.blocked {
  color: #7d8a9d;
}

.verified-key-chip {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 10px;
  border-radius: 999px;
  background: #e2f6ed;
  color: #158354 !important;
  font-size: 13px !important;
  font-weight: 800 !important;
  white-space: nowrap;
}

.verified-key-chip i {
  font-size: 16px;
}

.verified-key-chip.request {
  background: #e7f0ff;
  color: var(--ref-blue-strong) !important;
}

.verified-key-chip.unverified {
  background: #fff3d8;
  color: #9d6708 !important;
}

.verified-key-chip.verified {
  background: #e2f6ed;
  color: #158354 !important;
}

.icon-btn.blocked {
  background: rgba(125, 138, 157, 0.14);
  color: #687689;
}

.call-actions {
  position: relative;
  gap: 12px;
}

.chat-actions-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 210px;
  z-index: 16;
  display: grid;
  gap: 4px;
  padding: 7px;
  border: 1px solid rgba(119, 138, 166, 0.18);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 18px 38px rgba(37, 64, 98, 0.16);
  backdrop-filter: blur(16px);
}

.chat-actions-menu button {
  min-height: 42px;
  border: 0;
  border-radius: 14px;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  padding: 0 11px;
  background: transparent;
  color: var(--ref-text);
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  font-weight: 760;
  text-align: left;
}

.chat-actions-menu button:hover,
.chat-actions-menu button:focus-visible {
  background: rgba(36, 116, 242, 0.1);
  outline: none;
}

.chat-actions-menu button:disabled {
  cursor: default;
  opacity: 0.44;
}

.chat-actions-menu button i {
  justify-self: center;
  color: var(--ref-muted);
  font-size: 20px;
}

.chat-actions-menu button.active i {
  color: var(--ref-blue);
}

.chat-actions-menu button[aria-expanded="true"] {
  background: rgba(36, 116, 242, 0.1);
}

.notification-mute-menu {
  display: grid;
  gap: 3px;
  margin: -1px 0 3px;
  padding: 6px;
  border: 1px solid rgba(119, 138, 166, 0.12);
  border-radius: 14px;
  background: rgba(36, 116, 242, 0.06);
}

.notification-mute-menu button {
  min-height: 36px;
  border-radius: 12px;
  font-size: 13px;
}

.icon-btn {
  width: 52px;
  height: 52px;
  border: 1px solid rgba(119, 138, 166, 0.18);
  background: rgba(255, 255, 255, 0.72);
  color: var(--ref-text);
  box-shadow: none;
  font-size: var(--ref-icon-size);
}

.icon-btn:hover {
  background: #edf6ff;
  color: var(--ref-blue);
  box-shadow: 0 8px 20px rgba(36, 116, 242, 0.12);
}

.chat-search-bar {
  margin: 10px 22px 0;
  padding: 8px 10px;
  border: 1px solid rgba(119, 138, 166, 0.16);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 12px 28px rgba(37, 64, 98, 0.08);
}

.chat-search-bar input {
  color: var(--ref-text);
  font-size: 15px;
  font-weight: 750;
}

.chat-search-actions .icon-btn {
  width: 40px;
  height: 40px;
  border: 0;
  background: #f2f6fb;
}

.icon-btn.active {
  background: var(--ref-blue-soft);
  color: var(--ref-blue-strong);
}

.messages {
  gap: 12px;
  padding: 22px 24px 22px;
}

.message-row {
  max-width: min(64%, 560px);
}

.bubble {
  padding: 14px 16px 10px;
  border-color: rgba(119, 138, 166, 0.16);
  border-radius: 18px;
  box-shadow: 0 8px 28px rgba(37, 64, 98, 0.08);
  color: var(--ref-text);
  font-size: 16px;
  font-weight: 560;
}

.message-row.in .bubble {
  background: rgba(255, 255, 255, 0.84);
  border-bottom-left-radius: 10px;
}

.message-row.out .bubble {
  background: #d9ecff;
  border-color: rgba(115, 176, 255, 0.24);
  border-bottom-right-radius: 10px;
}

.message-row.media-message-row.out .bubble {
  background: linear-gradient(135deg, #005bcc, #003b96);
  color: #ffffff;
  border: 10px solid #b9dcff;
  border-radius: 20px;
  box-shadow: 0 18px 34px rgba(27, 101, 214, 0.18);
}

.message-row.media-message-row.out .file-info span,
.message-row.media-message-row.out .file-info button,
.message-row.media-message-row.out .bubble-meta {
  color: rgba(255, 255, 255, 0.76);
}

.message-row.media-message-row.out .file-info strong {
  color: #ffffff;
}

.message-row.media-message-row.out .file-icon {
  background: rgba(210, 228, 255, 0.92);
  color: #ffffff;
}

.deleted-message {
  color: #7d8a9d;
}

.message-reactions button {
  min-height: 26px;
  border: 0;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 5px 14px rgba(37, 64, 98, 0.08);
}

.composer-context {
  margin: 0 22px;
  border: 1px solid rgba(119, 138, 166, 0.16);
  border-radius: 18px 18px 0 0;
}

.composer {
  grid-template-columns: 56px minmax(0, 1fr) 58px;
  align-items: end;
  gap: 12px;
  margin: 0 22px 18px;
  padding: 12px;
  border: 0;
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 16px 44px rgba(37, 64, 98, 0.11);
}

.composer .icon-btn {
  width: 52px;
  height: 52px;
  background: #f2f6fb;
  border: 0;
}

.composer #attachButton {
  grid-column: 1;
  grid-row: 1;
  align-self: end;
}

.composer #emojiButton {
  grid-column: 2;
  grid-row: 1;
  justify-self: end;
  align-self: end;
  width: 42px;
  height: 42px;
  margin: 0 6px 5px 0;
  background: transparent;
  box-shadow: none;
  color: var(--ref-text);
  z-index: 1;
}

.composer #composerActionButton {
  grid-column: 3;
  grid-row: 1;
  align-self: end;
}

@media (min-width: 901px) {
  .composer .emoji-panel {
    left: auto;
    right: 88px;
    bottom: calc(86px + var(--safe-bottom));
  }
}

.composer textarea {
  grid-column: 2;
  grid-row: 1;
  min-height: 52px;
  max-height: min(34dvh, 176px);
  overflow-y: auto;
  padding: 14px 56px 14px 16px;
  border: 1px solid rgba(119, 138, 166, 0.18);
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ref-text);
  font-size: 16px;
  font-weight: 600;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 170, 204, 0.46) transparent;
}

.composer textarea::placeholder {
  color: #7e8ca4;
}

.composer textarea:focus {
  box-shadow: 0 0 0 5px rgba(91, 124, 176, 0.24);
}

.composer-action-btn {
  width: 58px;
  height: 58px;
  font-size: 25px;
}

.composer-action-btn:not(.send-mode) {
  background: #f2f6fb;
  color: var(--ref-text);
  box-shadow: none;
}

.composer-action-btn.send-mode {
  background: linear-gradient(135deg, #2b85ff, #1f61e8);
  color: #ffffff;
  box-shadow: var(--ref-shadow-control);
}

.encryption-ribbon {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 8px 22px;
  border-radius: 20px;
  background: linear-gradient(135deg, #ecfbf6, #eaf7ff);
  box-shadow: var(--ref-shadow-soft);
}

.encryption-info-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--ref-blue);
  cursor: pointer;
  font-size: 14px;
  font-weight: 760;
  text-decoration: none;
}

.encryption-info-card {
  width: min(620px, 100%);
}

.encryption-info-body {
  display: grid;
  gap: 18px;
  padding: 22px;
}

.encryption-info-lead {
  margin: 0;
  color: var(--ref-muted);
  font-size: 15px;
  font-weight: 650;
  line-height: 1.5;
}

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

.encryption-info-list section {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--ref-line);
  border-radius: 18px;
  background: rgba(247, 250, 255, 0.78);
}

.encryption-info-list i {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 15px;
  background: #e7f1ff;
  color: var(--ref-blue);
  font-size: 22px;
}

.encryption-info-list h3,
.encryption-info-list p {
  margin: 0;
}

.encryption-info-list h3 {
  color: var(--ref-text);
  font-size: 15px;
  font-weight: 850;
}

.encryption-info-list p {
  margin-top: 4px;
  color: var(--ref-muted);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.45;
}

.chat-panel:not(.has-contact) {
  grid-template-rows: minmax(0, 1fr);
}

.chat-panel:not(.has-contact) + .encryption-ribbon {
  display: none;
}

.empty-state {
  background: rgba(255, 255, 255, 0.74);
}

.account-modal {
  background: rgba(238, 242, 246, 0.7);
}

.account-card {
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 24px 86px rgba(24, 45, 74, 0.14);
}

.account-modal .account-header {
  min-height: 108px;
  padding: 22px 24px;
  border-bottom: 1px solid rgba(118, 137, 164, 0.14);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.94), rgba(246, 250, 255, 0.86));
  color: var(--ref-text);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.92);
}

.account-modal .account-header h2 {
  color: var(--ref-text);
  font-size: 24px;
  font-weight: 850;
}

.account-modal .account-header p {
  color: #61708a;
  font-size: 15px;
  font-weight: 700;
}

.account-modal .account-header .peer-avatar.large,
.account-modal .settings-icon {
  width: 64px;
  height: 64px;
  border-radius: 22px;
  font-size: 24px;
  box-shadow: 0 14px 30px rgba(36, 116, 242, 0.14);
}

.account-modal .account-header .peer-avatar.large.has-image {
  background: linear-gradient(145deg, #e8f2ff, #ffffff);
}

.account-modal .account-header .icon-btn {
  width: 46px;
  height: 46px;
  border: 1px solid rgba(119, 138, 166, 0.18);
  background: #f4f8fd;
  color: var(--ref-text);
  box-shadow: none;
}

.account-modal .account-header .icon-btn:hover {
  background: #eaf3ff;
  color: var(--ref-blue);
}

:root[data-theme="dark"] .messenger {
  background: var(--ref-shell);
  border-color: rgba(148, 170, 204, 0.16);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.34);
}

:root[data-theme="dark"] .chat-list-pane,
:root[data-theme="dark"] .contact-form,
:root[data-theme="dark"] .contact-search-menu,
:root[data-theme="dark"] .chat-actions-menu,
:root[data-theme="dark"] .account-chip,
:root[data-theme="dark"] .empty-state,
:root[data-theme="dark"] .contact-list > .empty-state {
  background: var(--ref-panel);
  border-color: var(--ref-line);
  box-shadow: var(--ref-shadow-soft);
}

:root[data-theme="dark"] .contact-form,
:root[data-theme="dark"] .contact-search-menu,
:root[data-theme="dark"] .chat-actions-menu,
:root[data-theme="dark"] .account-chip {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), var(--ref-shadow-soft);
}

:root[data-theme="dark"] .chat-actions-menu button {
  color: var(--ref-text);
}

:root[data-theme="dark"] .chat-actions-menu button:hover,
:root[data-theme="dark"] .chat-actions-menu button:focus-visible {
  background: rgba(120, 173, 255, 0.12);
}

:root[data-theme="dark"] .chat-actions-menu button[aria-expanded="true"],
:root[data-theme="dark"] .notification-mute-menu {
  background: rgba(120, 173, 255, 0.1);
}

:root[data-theme="dark"] .notification-mute-menu {
  border-color: rgba(148, 170, 204, 0.14);
}

:root[data-theme="dark"] .contact-form:focus-within {
  border-color: rgba(116, 151, 205, 0.42);
  background: rgba(18, 29, 44, 0.72);
  box-shadow:
    0 0 0 6px rgba(91, 124, 176, 0.24),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

:root[data-theme="dark"] .add-contact-suggestion {
  color: var(--ref-text);
}

:root[data-theme="dark"] .add-contact-suggestion:hover {
  background: rgba(86, 154, 255, 0.14);
}

:root[data-theme="dark"] .contact-form > i,
:root[data-theme="dark"] .contact-form .icon-btn,
:root[data-theme="dark"] .contact-copy span,
:root[data-theme="dark"] .account-chip span,
:root[data-theme="dark"] .account-modal .account-header p {
  color: var(--ref-muted);
}

:root[data-theme="dark"] .contact-copy span.contact-meta.online {
  color: var(--ref-green);
}

:root[data-theme="dark"] .contact-item.unverified-key .contact-copy span {
  color: #f5c86c;
}

:root[data-theme="dark"] .chat-request-warning {
  background: rgba(30, 55, 86, 0.92);
  border-color: rgba(86, 154, 255, 0.28);
}

:root[data-theme="dark"] .contact-trust-warning {
  background: rgba(79, 54, 11, 0.9);
  border-color: rgba(228, 161, 27, 0.34);
}

:root[data-theme="dark"] .contact-trust-fingerprint {
  color: var(--ref-text);
}

:root[data-theme="dark"] .chat-request-warning.blocked,
:root[data-theme="dark"] .blocklist-panel,
:root[data-theme="dark"] .blocked-contact-item,
:root[data-theme="dark"] .identity-export-warning {
  background: rgba(18, 29, 44, 0.86);
  border-color: var(--ref-line);
}

:root[data-theme="dark"] .identity-login-details {
  background: var(--login-field);
  border-color: var(--login-line);
}

:root[data-theme="dark"] .identity-login-details textarea {
  background: var(--login-input-bg);
  border-color: var(--login-line);
  color: var(--login-text);
}

:root[data-theme="dark"] .identity-import-control textarea {
  background: rgba(8, 17, 31, 0.72);
  color: var(--ref-text);
}

:root[data-theme="dark"] .verified-key-chip.request {
  background: rgba(86, 154, 255, 0.18);
  color: #9fc7ff !important;
}

:root[data-theme="dark"] .verified-key-chip.unverified {
  background: rgba(228, 161, 27, 0.18);
  color: #f5c86c !important;
}

:root[data-theme="dark"] .blocklist-heading span,
:root[data-theme="dark"] .blocklist-unblock {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--ref-line);
}

:root[data-theme="dark"] .contact-form input::placeholder,
:root[data-theme="dark"] .composer textarea::placeholder {
  color: var(--ref-faint);
}

:root[data-theme="dark"] .nav-item {
  color: var(--ref-muted);
}

:root[data-theme="dark"] .nav-item.active {
  background: var(--active);
  color: var(--ref-blue-strong);
}

:root[data-theme="dark"] .nav-item:hover,
:root[data-theme="dark"] .contact-item:hover,
:root[data-theme="dark"] .contact-item.active,
:root[data-theme="dark"] .icon-btn:hover {
  background: var(--hover);
  color: var(--ref-blue-strong);
}

:root[data-theme="dark"] .contact-item.active {
  border-color: rgba(120, 173, 255, 0.42);
  box-shadow: 0 10px 30px rgba(15, 90, 220, 0.16);
}

:root[data-theme="dark"] .security-card,
:root[data-theme="dark"] .encryption-ribbon {
  background: linear-gradient(135deg, rgba(21, 68, 58, 0.92), rgba(18, 42, 62, 0.86));
  color: var(--ref-text);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), var(--ref-shadow-soft);
}

:root[data-theme="dark"] .security-card strong,
:root[data-theme="dark"] .encryption-ribbon strong {
  color: var(--ref-text);
}

:root[data-theme="dark"] .security-card p,
:root[data-theme="dark"] .encryption-ribbon span {
  color: var(--ref-muted);
}

:root[data-theme="dark"] .security-card-link,
:root[data-theme="dark"] .encryption-info-link {
  color: var(--ref-blue-strong);
}

:root[data-theme="dark"] .chat-panel {
  background-color: var(--ref-chat);
  background-image:
    linear-gradient(rgba(13, 23, 36, 0.82), rgba(13, 23, 36, 0.82)),
    url("/assets/chat-pattern.svg");
}

:root[data-theme="dark"] .chat-header {
  background: rgba(18, 29, 44, 0.92);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.22);
}

:root[data-theme="dark"] .chat-search-bar {
  border-color: var(--ref-line);
  background: rgba(18, 29, 44, 0.92);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.24);
}

:root[data-theme="dark"] .chat-search-bar input {
  color: var(--ref-text);
}

:root[data-theme="dark"] .search-hit {
  background: rgba(255, 193, 112, 0.48);
}

:root[data-theme="dark"] .message-row.search-current .search-hit {
  background: rgba(255, 193, 112, 0.76);
}

:root[data-theme="dark"] .verified-key-chip {
  background: rgba(46, 191, 125, 0.16);
  color: #76e5af !important;
}

:root[data-theme="dark"] .peer-title .peer-muted-indicator,
:root[data-theme="dark"] .contact-muted-indicator {
  background: rgba(148, 170, 204, 0.12);
  color: #9fb1ca;
}

:root[data-theme="dark"] .icon-btn,
:root[data-theme="dark"] .composer .icon-btn,
:root[data-theme="dark"] .composer-action-btn:not(.send-mode),
:root[data-theme="dark"] .peer-rename-btn,
:root[data-theme="dark"] .peer-name-action {
  background: rgba(23, 36, 55, 0.82);
  border-color: var(--ref-line);
  color: var(--ref-text);
}

:root[data-theme="dark"] .peer-name-form input {
  border-color: var(--ref-line);
  background: rgba(8, 17, 31, 0.8);
  color: var(--ref-text);
}

:root[data-theme="dark"] .message-row.in .bubble {
  background: var(--bubble-in);
  border-color: var(--ref-line);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.2);
}

:root[data-theme="dark"] .message-row.out .bubble {
  background: linear-gradient(135deg, #173f6d, #1b5ea2);
  border-color: rgba(120, 173, 255, 0.22);
  color: var(--ref-text);
  box-shadow: 0 12px 30px rgba(8, 58, 124, 0.2);
}

:root[data-theme="dark"] .message-reactions button {
  background: rgba(238, 245, 255, 0.12);
  color: var(--ref-text);
  box-shadow: none;
}

:root[data-theme="dark"] .composer {
  background: rgba(18, 29, 44, 0.92);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.3);
}

:root[data-theme="dark"] .composer textarea {
  background: rgba(8, 17, 31, 0.8);
  border-color: var(--ref-line);
  color: var(--ref-text);
}

:root[data-theme="dark"] .emoji-panel {
  background: #121d2c;
  border-color: var(--ref-line);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.36);
}

:root[data-theme="dark"] .account-modal {
  background: rgba(2, 8, 15, 0.72);
}

:root[data-theme="dark"] .account-card {
  background: rgba(18, 29, 44, 0.96);
  border-color: var(--ref-line);
  box-shadow: 0 28px 86px rgba(0, 0, 0, 0.42);
}

:root[data-theme="dark"] .account-modal .account-header {
  background: linear-gradient(135deg, rgba(22, 35, 53, 0.96), rgba(15, 25, 39, 0.9));
  border-bottom-color: var(--ref-line);
  color: var(--ref-text);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

:root[data-theme="dark"] .account-modal .account-header h2 {
  color: var(--ref-text);
}

:root[data-theme="dark"] .account-modal .account-header .icon-btn {
  background: rgba(24, 38, 58, 0.92);
  border-color: var(--ref-line);
  color: var(--ref-text);
}

:root[data-theme="dark"] .account-modal .account-header .icon-btn:hover {
  background: var(--hover);
  color: var(--ref-blue-strong);
}

:root[data-theme="dark"] .account-modal .settings-icon,
:root[data-theme="dark"] .settings-icon {
  background: linear-gradient(135deg, #173a64, #1a2435);
  color: var(--ref-blue-strong);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 14px 30px rgba(0, 0, 0, 0.24);
}

:root[data-theme="dark"] .account-modal .account-header .peer-avatar.large.has-image {
  background: linear-gradient(145deg, #172437, #22324a);
}

:root[data-theme="dark"] .encryption-info-list section {
  background: rgba(23, 36, 55, 0.74);
  border-color: var(--ref-line);
}

:root[data-theme="dark"] .encryption-info-list i {
  background: rgba(120, 173, 255, 0.14);
  color: var(--ref-blue-strong);
}

:root[data-theme="dark"] .mobile-key-status {
  background: rgba(46, 191, 125, 0.16);
  border-color: rgba(95, 224, 165, 0.24);
  color: #76e5af;
}

@media (max-width: 1120px) {
  .messenger {
    grid-template-columns: 244px 304px minmax(0, 1fr);
    gap: 12px;
    padding: 12px;
  }

  .brand strong {
    font-size: 22px;
  }

  .message-row {
    max-width: 78%;
  }
}

@media (max-width: 900px) {
  .app-shell {
    padding: 0;
  }

  .messenger {
    height: 100dvh;
    min-height: 100dvh;
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: var(--ref-mobile-shell-bg);
    background-image: var(--ref-mobile-shell-image);
    box-shadow: none;
    color: var(--ref-text);
  }

  .app-nav {
    display: grid;
    grid-template-rows: auto auto;
    gap: 18px;
    padding: calc(18px + var(--safe-top)) 18px 0;
    background: transparent;
  }

  .sidebar-header {
    height: auto;
    min-height: 58px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0;
  }

  .brand {
    min-width: 0;
  }

  .brand > div {
    min-width: 0;
  }

  .brand img {
    width: 58px;
    height: 58px;
    border-radius: 18px;
    box-shadow: 0 18px 36px rgba(0, 85, 205, 0.28);
  }

  .brand strong {
    color: var(--ref-text);
    font-size: 25px;
    line-height: 0.98;
  }

  .brand span {
    margin-top: 2px;
    color: var(--ref-green);
    font-size: 15px;
  }

  .brand .connection-state.online {
    color: var(--ref-green);
  }

  .brand .connection-state.offline,
  .brand .connection-state.connecting {
    color: var(--ref-muted);
  }

  .mobile-header-actions {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 7px;
    padding-top: 0;
  }

  .mobile-header-actions .icon-btn,
  .mobile-key-status {
    width: 48px;
    height: 48px;
    min-width: 48px;
    border: 1px solid var(--ref-line);
    border-radius: 22px;
    display: grid;
    place-items: center;
    background: var(--ref-mobile-control-bg);
    color: var(--ref-mobile-icon-color);
    box-shadow: var(--ref-mobile-control-shadow);
    font-size: 23px;
  }

  .mobile-header-actions .icon-btn i,
  .mobile-key-status i {
    display: block;
    line-height: 1;
  }

  .mobile-key-status {
    border-color: rgba(95, 224, 165, 0.28);
    background: rgba(46, 191, 125, 0.14);
    color: var(--ref-green);
  }

  .contact-search-wrap {
    margin-top: 0;
  }

  .contact-form {
    height: 58px;
    gap: 12px;
    padding: 0 10px 0 18px;
    border: 1px solid var(--ref-line);
    border-radius: 24px;
    background: var(--ref-mobile-control-bg);
    box-shadow: var(--ref-mobile-control-shadow);
  }

  .contact-form:focus-within {
    border-color: var(--ref-mobile-control-focus-border);
    background: var(--ref-mobile-control-focus-bg);
    box-shadow:
      var(--ref-mobile-control-focus-ring),
      var(--ref-mobile-control-shadow);
  }

  .contact-form > i {
    color: var(--ref-mobile-icon-color);
    font-size: 25px;
  }

  .contact-form input {
    color: var(--ref-text);
    font-size: 18px;
    font-weight: 760;
  }

  .contact-form input::placeholder {
    color: var(--ref-mobile-placeholder);
  }

  .contact-form .icon-btn {
    width: 42px;
    height: 42px;
    border-radius: 18px;
    background: rgba(148, 170, 204, 0.1);
    color: var(--ref-mobile-icon-color);
  }

  .side-menu,
  .security-card,
  .account-chip {
    display: none;
  }

  .chat-list-pane {
    display: grid;
    min-height: 0;
    margin-top: 12px;
    padding: 18px 18px calc(18px + var(--safe-bottom));
    border-top: 1px solid rgba(148, 170, 204, 0.12);
    border-radius: 0;
    background: var(--ref-mobile-list-bg);
    box-shadow: none;
  }

  .chat-list-header {
    min-height: 34px;
    padding: 0 0 14px;
  }

  .chat-list-header h2 {
    color: var(--ref-text);
    font-size: 24px;
    font-weight: 850;
  }

  .contact-list {
    padding: 0;
  }

  .contact-list > .empty-state {
    margin: 6px 0 0;
    background: var(--ref-mobile-card-bg);
    border: 1px solid var(--ref-line);
    color: var(--ref-muted);
  }

  .contact-item {
    min-height: 74px;
    grid-template-columns: 52px minmax(0, 1fr) 32px;
    gap: 12px;
    padding: 10px 10px;
    border: 1px solid var(--ref-line);
    border-radius: 20px;
    background: var(--ref-mobile-item-bg);
  }

  .contact-item + .contact-item {
    margin-top: 8px;
  }

  .contact-item:hover,
  .contact-item.active {
    background: var(--ref-mobile-item-hover);
    color: var(--ref-text);
  }

  .contact-item.active {
    border-color: rgba(120, 173, 255, 0.36);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  }

  .contact-item.chat-request,
  .contact-item.key-alert,
  .contact-item.unverified-key {
    background: var(--ref-mobile-item-alert-bg);
  }

  .contact-item .avatar {
    width: 52px;
    height: 52px;
  }

  .contact-copy {
    gap: 5px;
  }

  .contact-copy strong {
    color: var(--ref-text);
    font-size: 17px;
    line-height: 1.1;
  }

  .contact-copy span {
    color: var(--ref-muted);
    font-size: 14px;
    font-weight: 650;
  }

  .contact-item.unverified-key .contact-copy span {
    color: var(--ref-mobile-warning-text);
    font-weight: 760;
  }

  :root[data-theme="dark"] .contact-item.unverified-key .contact-copy span {
    color: #cdb77a;
  }

  .contact-item.key-alert .contact-copy span {
    color: var(--ref-mobile-alert-text);
    font-weight: 780;
  }

  :root[data-theme="dark"] .contact-item.key-alert .contact-copy span {
    color: #ffb9b1;
  }

  .contact-side {
    align-content: center;
  }

  .peer-title .peer-muted-indicator,
  .contact-muted-indicator {
    background: rgba(148, 170, 204, 0.12);
    color: var(--ref-muted);
  }

  .presence-dot {
    width: 10px;
    height: 10px;
    background: #95a5b8;
  }

  .presence-dot.online {
    background: var(--ref-green);
  }

  .unverified-badge,
  .key-alert-badge {
    background: rgba(205, 183, 122, 0.18);
    color: var(--ref-mobile-warning-text);
    box-shadow: none;
  }

  .conversation-pane {
    position: fixed;
    inset: var(--mobile-visual-viewport-top, 0px) 0 auto 0;
    height: var(--mobile-visual-viewport-height, 100dvh);
    grid-template-rows: minmax(0, 1fr);
    transform: translateX(100%);
    transition: transform 220ms ease;
    z-index: 10;
  }

  .messenger.chat-open .conversation-pane {
    transform: translateX(0);
  }

  .chat-panel {
    position: relative;
    inset: auto;
    transform: none;
    transition: none;
    z-index: auto;
    border-radius: 0;
    height: 100%;
    max-height: var(--mobile-visual-viewport-height, 100dvh);
    overflow: hidden;
  }

  .chat-header {
    min-height: 70px;
    display: grid;
    grid-template-columns: 42px 44px minmax(0, 1fr) minmax(0, auto);
    align-items: center;
    gap: 8px;
    padding: 10px max(10px, calc(8px + var(--safe-right))) 10px max(10px, calc(8px + var(--safe-left)));
  }

  .chat-search-bar {
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    gap: 7px;
    margin: 8px 8px 0;
    padding: 7px;
    border-radius: 18px;
  }

  .chat-search-counter {
    min-width: 52px;
    font-size: 12px;
  }

  .chat-search-actions {
    gap: 2px;
  }

  .chat-search-actions .icon-btn {
    width: 34px;
    height: 34px;
    font-size: 17px;
  }

  .chat-header .peer-avatar {
    width: 44px;
    height: 44px;
    grid-column: 2;
  }

  .chat-back-btn {
    grid-column: 1;
    width: 42px;
    height: 42px;
  }

  .peer-title {
    grid-column: 3;
    min-width: 0;
    overflow: hidden;
  }

  .peer-title strong {
    font-size: 17px;
  }

  .peer-status-row {
    min-width: 0;
    gap: 6px;
  }

  .peer-name-form {
    width: 100%;
  }

  .chat-panel.renaming-contact .chat-header {
    grid-template-columns: 42px minmax(0, 1fr);
  }

  .chat-panel.renaming-contact .chat-header .peer-avatar,
  .chat-panel.renaming-contact .peer-status-row {
    display: none;
  }

  .chat-panel.renaming-contact .peer-title {
    grid-column: 2;
    min-width: 0;
    overflow: visible;
  }

  .chat-panel.renaming-contact .peer-name-form {
    width: 100%;
    max-width: 100%;
    grid-template-columns: minmax(0, 1fr) 40px 40px;
    gap: 6px;
  }

  .chat-panel.renaming-contact .peer-name-form input {
    width: 100%;
    min-width: 0;
    height: 42px;
    font-size: 16px;
  }

  .chat-panel.renaming-contact .peer-name-action {
    width: 40px;
    height: 40px;
    font-size: 20px;
  }

  .chat-panel.renaming-contact .call-actions {
    display: none;
  }

  .verified-key-chip {
    display: none;
  }

  .call-actions {
    grid-column: 4;
    min-width: 0;
    max-width: min(34vw, 82px);
    overflow: visible;
    gap: 5px;
    padding: 2px 0;
  }

  .call-actions .icon-btn {
    flex: 0 0 38px;
    width: 38px;
    height: 38px;
    font-size: 19px;
  }

  .chat-actions-menu {
    top: calc(100% + 8px);
    right: 0;
    min-width: min(220px, calc(100vw - 24px));
    border-color: rgba(148, 170, 204, 0.16);
    background: var(--ref-mobile-menu-bg);
    box-shadow: var(--ref-mobile-menu-shadow);
  }

  .chat-actions-menu button {
    color: var(--ref-text);
  }

  .chat-actions-menu button i {
    color: var(--ref-muted);
  }

  .notification-mute-menu {
    border-color: rgba(148, 170, 204, 0.12);
    background: var(--ref-mobile-submenu-bg);
  }

  .messages {
    min-height: 0;
    overflow-y: auto;
    padding: 14px 10px;
  }

  .unread-notice {
    right: 16px;
    bottom: calc(82px + var(--safe-bottom));
    height: 32px;
    min-width: 40px;
    padding: 0 10px;
    font-size: 12px;
  }

  .message-row {
    width: 100%;
    max-width: 100%;
    gap: 4px;
    padding-bottom: 0;
  }

  .message-row.actions-open {
    padding-bottom: 42px;
  }

  .message-row.in {
    justify-content: flex-start;
  }

  .message-row.out {
    flex-direction: row;
    justify-content: flex-end;
  }

  .message-row .bubble {
    max-width: min(82%, 340px);
  }

  .message-row.media-message-row {
    width: 100%;
    max-width: 100%;
  }

  .message-row.media-message-row .bubble {
    width: min(100%, 330px);
    max-width: calc(100vw - 20px);
    flex: 0 1 auto;
  }

  .message-row.media-message-row.out .bubble {
    border-width: 6px;
    border-radius: 18px;
  }

  .message-actions-trigger {
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    border: 1px solid rgba(148, 170, 204, 0.14);
    border-radius: 50%;
    display: grid;
    place-items: center;
    align-self: flex-end;
    margin-bottom: 4px;
    background: var(--ref-mobile-card-bg);
    color: var(--ref-muted);
    cursor: pointer;
    opacity: 0.58;
    transition:
      opacity var(--md-motion-duration-short) var(--md-motion-easing-standard),
      background var(--md-motion-duration-short) var(--md-motion-easing-standard),
      color var(--md-motion-duration-short) var(--md-motion-easing-standard);
  }

  .message-row.actions-open .message-actions-trigger,
  .message-actions-trigger:focus-visible {
    background: rgba(148, 170, 204, 0.12);
    color: var(--ref-text);
    opacity: 1;
  }

  .file-bubble,
  .image-file-bubble,
  .video-file-bubble,
  .voice-bubble {
    min-width: 0;
  }

  .file-bubble {
    grid-template-columns: 34px minmax(0, 1fr);
    gap: 8px;
  }

  .file-icon {
    width: 34px;
    height: 34px;
    border-radius: 14px;
  }

  .image-preview,
  .image-preview img,
  .video-preview video {
    max-height: min(54vh, 280px);
  }

  .message-actions {
    position: absolute;
    bottom: 2px;
    gap: 6px;
    padding: 4px;
    border: 1px solid rgba(148, 170, 204, 0.14);
    border-radius: 999px;
    background: var(--ref-mobile-menu-bg);
    box-shadow: var(--ref-mobile-menu-shadow);
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
    transform: translateY(4px) scale(0.98);
    z-index: 4;
    backdrop-filter: blur(12px);
  }

  .message-row.actions-open .message-actions {
    opacity: 1;
    pointer-events: auto;
    visibility: visible;
    transform: none;
  }

  .message-row.in .message-actions {
    left: 0;
  }

  .message-row.out .message-actions {
    right: 0;
  }

  .message-actions > button {
    width: 34px;
    height: 34px;
    border-color: rgba(148, 170, 204, 0.16);
    background: rgba(148, 170, 204, 0.1);
    color: var(--ref-text);
    box-shadow: none;
  }

  .reaction-picker {
    bottom: 44px;
    max-width: calc(100vw - 28px);
    overflow-x: auto;
    background: var(--ref-mobile-menu-bg);
  }

  .message-row.out .reaction-picker {
    right: 0;
    left: auto;
  }

  .composer-context {
    margin: 0 8px;
    border: 1px solid rgba(148, 170, 204, 0.14);
    border-bottom: 0;
    border-radius: 18px 18px 0 0;
    background: var(--ref-mobile-menu-bg);
  }

  .composer {
    position: sticky;
    bottom: calc(8px + var(--safe-bottom));
    z-index: 7;
    grid-template-columns: 46px minmax(0, 1fr) 48px;
    align-items: end;
    gap: 8px;
    margin: 0 8px calc(8px + var(--safe-bottom));
    padding: 8px;
  }

  .composer-action-btn,
  .composer .icon-btn {
    width: 44px;
    height: 44px;
  }

  .composer #attachButton {
    grid-column: 1;
    grid-row: 1;
    align-self: end;
  }

  .composer #emojiButton {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
    align-self: end;
    width: 38px;
    height: 38px;
    margin: 0 4px 3px 0;
    background: transparent;
    box-shadow: none;
    color: var(--ref-mobile-icon-color);
    z-index: 1;
  }

  .composer .emoji-panel {
    --emoji-panel-mobile-edge: clamp(12px, 6vw, 56px);
    left: auto;
    right: var(--emoji-panel-mobile-edge);
    bottom: calc(64px + var(--safe-bottom));
    width: min(360px, calc(100vw - var(--emoji-panel-mobile-edge) - 12px));
  }

  .composer #composerActionButton {
    grid-column: 3;
    grid-row: 1;
    align-self: end;
  }

  .voice-recording-indicator {
    right: 12px;
    bottom: calc(64px + var(--safe-bottom));
  }

  .composer textarea {
    grid-column: 2;
    grid-row: 1;
    min-height: 44px;
    max-height: min(34dvh, 176px);
    overflow-y: auto;
    padding: 10px 48px 10px 12px;
    border-radius: 24px;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 170, 204, 0.46) transparent;
  }

  .composer textarea:focus {
    box-shadow: 0 0 0 5px rgba(91, 124, 176, 0.24);
  }

  .encryption-ribbon {
    display: none;
  }
}

@media (max-width: 420px) {
  .mobile-header-actions {
    gap: 6px;
  }

  .mobile-header-actions .icon-btn,
  .mobile-key-status {
    width: 40px;
    height: 40px;
    min-width: 40px;
    font-size: 20px;
  }

  .brand img {
    width: 48px;
    height: 48px;
  }

  .brand strong {
    font-size: 22px;
  }
}
