:root {
  --ink: #2a191a;
  --muted: #7a6862;
  --line: #eadbd6;
  --panel: #ffffff;
  --panel-soft: #fbf4f1;
  --brand: #9b5558;
  --brand-dark: #683134;
  --teal: #128c7e;
  --bubble-out: #f3ddd6;
  --bubble-in: #ffffff;
  --accent: #128c7e;
  --danger: #d64f42;
  --shadow: 0 22px 70px rgba(80, 38, 39, 0.16);
  --app-height: 100dvh;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  min-height: 100%;
}

body {
  margin: 0;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(155, 85, 88, 0.22), transparent 36%),
    linear-gradient(135deg, #f5ebe7 0%, #fffaf8 46%, #eadbd6 100%);
  overflow-x: hidden;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.identity-screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    linear-gradient(rgba(104, 49, 52, 0.9), rgba(155, 85, 88, 0.84)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 120 120'%3E%3Cpath d='M28 40h64M28 64h40M28 88h58' stroke='%23ffffff' stroke-opacity='.16' stroke-width='8' stroke-linecap='round'/%3E%3C/svg%3E");
}

.identity-screen.hidden {
  display: none;
}

.identity-card {
  display: grid;
  gap: 16px;
  width: min(420px, 100%);
  padding: 28px;
  background: #fff;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.identity-card .avatar {
  width: 58px;
  height: 58px;
  font-size: 1.15rem;
}

.identity-card h1 {
  font-size: 1.65rem;
}

.identity-card p {
  color: var(--muted);
  line-height: 1.5;
}

.login-steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
}

.login-steps span {
  display: grid;
  place-items: center;
  min-height: 34px;
  border-radius: 999px;
  color: #31524b;
  background: #eef6f3;
  font-size: 0.78rem;
  font-weight: 800;
}

.login-steps .active {
  color: #fff;
  background: var(--brand);
}

.identity-card label {
  display: grid;
  gap: 8px;
  color: #31524b;
  font-weight: 700;
}

.identity-card input {
  height: 46px;
  min-width: 0;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
}

.identity-card input:focus {
  border-color: var(--brand);
}

.primary-button {
  min-height: 46px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: var(--brand);
  font-weight: 800;
}

.primary-button:hover {
  background: var(--brand-dark);
}

.otp-panel {
  display: grid;
  gap: 10px;
}

.otp-panel[hidden] {
  display: none;
}

.otp-panel p {
  padding: 10px 12px;
  color: var(--brand-dark);
  background: #e7f4f0;
  border-radius: 8px;
  font-weight: 800;
}

.secondary-button {
  min-height: 44px;
  border: 1px solid rgba(18, 140, 126, 0.28);
  border-radius: 8px;
  color: var(--brand-dark);
  background: #e7f4f0;
  font-weight: 800;
}

.messenger {
  position: relative;
  display: grid;
  grid-template-columns: 1fr;
  width: min(430px, calc(100vw - 28px));
  height: min(932px, calc(var(--app-height) - 28px));
  max-height: 932px;
  margin: 14px auto;
  overflow: hidden;
  background: var(--panel);
  border: 8px solid #101817;
  border-radius: 34px;
  box-shadow:
    0 26px 78px rgba(20, 47, 40, 0.26),
    inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.sidebar {
  grid-column: 1;
  grid-row: 1;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  min-width: 0;
  background: #fbfdfc;
}

.phone-statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 30px;
  padding: max(8px, env(safe-area-inset-top)) 22px 4px;
  color: #fff;
  background: var(--brand-dark);
  font-size: 0.78rem;
  font-weight: 800;
}

.status-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  min-width: 0;
}

.status-network {
  max-width: 74px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-battery {
  position: relative;
  width: 24px;
  height: 12px;
  padding: 2px;
  border: 1.7px solid currentColor;
  border-radius: 3px;
}

.status-battery::after {
  content: "";
  position: absolute;
  right: -4px;
  top: 3px;
  width: 2px;
  height: 5px;
  border-radius: 0 2px 2px 0;
  background: currentColor;
}

.status-battery span {
  display: block;
  height: 100%;
  width: 70%;
  border-radius: 1px;
  background: currentColor;
}

.status-battery-text {
  min-width: 34px;
  text-align: right;
}

.topbar,
.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 72px;
  padding: 12px 16px;
  background: var(--panel-soft);
}

.topbar {
  color: #fff;
  background: var(--brand-dark);
}

.topbar .profile p,
.topbar .icon-button {
  color: rgba(255, 255, 255, 0.78);
}

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

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

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.02rem, 2.5vw, 1.12rem);
  line-height: 1.2;
  font-weight: 820;
}

h2 {
  font-size: clamp(0.98rem, 2.4vw, 1.08rem);
  line-height: 1.2;
  font-weight: 820;
}

.profile p,
.chat-person p,
.conversation-meta,
.preview,
.message-time {
  color: var(--muted);
  font-size: 0.78rem;
}

.avatar {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  color: #fff;
  font-weight: 800;
  letter-spacing: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, #9b5558, #128c7e);
  overflow: hidden;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-button {
  position: relative;
  display: block;
  flex: 0 0 auto;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
}

.avatar-edit {
  position: absolute;
  right: -2px;
  bottom: -2px;
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border: 2px solid var(--brand-dark);
  border-radius: 50%;
  color: var(--brand-dark);
  background: #fff;
  font-size: 0.72rem;
  font-weight: 900;
  line-height: 1;
  box-shadow: 0 2px 8px rgba(8, 29, 25, 0.18);
}

.avatar.me {
  background: linear-gradient(135deg, #683134, #128c7e);
}

.avatar.large {
  width: 48px;
  height: 48px;
}

.icon-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  min-width: 0;
}

.icon-button,
.send-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border: 0;
  border-radius: 50%;
  color: #53645d;
  background: transparent;
  font-size: 1.22rem;
}

.icon-button:hover,
.conversation:hover {
  background: #f5e8e3;
}

.search-panel {
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.search-box {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  height: 44px;
  padding: 0 12px;
  color: var(--muted);
  background: var(--panel-soft);
  border-radius: 8px;
}

.search-box input {
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.member-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.8rem;
}

.text-button {
  border: 0;
  padding: 0;
  color: var(--brand-dark);
  background: transparent;
  font-weight: 800;
}

.tab {
  min-height: 34px;
  border: 1px solid transparent;
  border-radius: 999px;
  color: #693e3b;
  background: #f7e9e4;
  font-size: 0.84rem;
}

.tab.active {
  color: #fff;
  background: var(--brand);
}

.conversation-list {
  min-height: 0;
  overflow: auto;
}

.empty-state {
  display: grid;
  gap: 6px;
  padding: 24px 18px;
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  color: var(--ink);
}

.conversation {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  gap: 12px;
  width: 100%;
  min-height: 76px;
  padding: 12px 14px;
  border: 0;
  border-bottom: 1px solid #edf2ef;
  text-align: left;
  color: inherit;
  background: transparent;
}

.conversation.active {
  background: #f0ded8;
}

.conversation-main {
  min-width: 0;
}

.conversation-title {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  font-weight: 760;
}

.conversation-title span:first-child,
.preview {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pin {
  color: var(--accent);
  font-size: 0.82rem;
}

.conversation-meta {
  display: grid;
  justify-items: end;
  gap: 8px;
}

.unread {
  display: grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  color: #fff;
  background: #25d366;
  font-size: 0.72rem;
  font-weight: 800;
}

.chat {
  grid-column: 1;
  grid-row: 1;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  min-width: 0;
  transform: translateX(100%);
  transition: transform 180ms ease;
  background:
    linear-gradient(rgba(248, 239, 235, 0.9), rgba(248, 239, 235, 0.9)),
    repeating-linear-gradient(45deg, transparent 0 16px, rgba(155, 85, 88, 0.05) 16px 17px),
    repeating-linear-gradient(-45deg, transparent 0 20px, rgba(18, 140, 126, 0.05) 20px 21px);
}

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

.messenger.chat-open .sidebar {
  visibility: hidden;
}

.chat-statusbar {
  background: var(--panel-soft);
  color: var(--ink);
}

.chat-header {
  border-bottom: 1px solid rgba(217, 226, 221, 0.9);
}

.chat-person {
  min-width: 0;
}

.chat-title-button {
  display: block;
  max-width: 100%;
  padding: 0;
  border: 0;
  color: inherit;
  text-align: left;
  background: transparent;
}

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

.messages {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  padding: 22px clamp(14px, 3vw, 52px);
  overflow: auto;
  overscroll-behavior: contain;
  scroll-behavior: auto;
  -webkit-overflow-scrolling: touch;
}

.messages::before {
  content: "";
  flex: 1 1 auto;
  min-height: 0;
}

.scroll-anchor {
  flex: 0 0 1px;
  width: 100%;
}

.day-chip {
  align-self: center;
  padding: 7px 12px;
  color: #49625a;
  background: rgba(255, 255, 255, 0.82);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(24, 39, 34, 0.08);
  font-size: 0.75rem;
}

.message {
  max-width: min(620px, 78%);
  padding: 8px 10px 6px;
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(24, 39, 34, 0.12);
}

.message.in {
  align-self: flex-start;
  background: var(--bubble-in);
  border-top-left-radius: 2px;
}

.message.out {
  align-self: flex-end;
  background: var(--bubble-out);
  border-top-right-radius: 2px;
}

.message p {
  font-size: clamp(0.95rem, 2.7vw, 1rem);
  overflow-wrap: anywhere;
  line-height: 1.45;
}

.media-attachment,
.media-frame {
  display: block;
  width: min(316px, 72vw);
  margin-bottom: 6px;
  overflow: hidden;
  border-radius: 8px;
  background: rgba(8, 29, 25, 0.08);
  border: 1px solid rgba(8, 29, 25, 0.08);
}

.media-attachment img,
video.media-attachment {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  max-height: 380px;
  object-fit: cover;
  background: #eaf1ee;
}

.image-attachment {
  position: relative;
  text-decoration: none;
}

.image-attachment span,
.media-frame span {
  display: block;
  max-width: 100%;
  padding: 7px 9px;
  overflow: hidden;
  color: #40544e;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.72);
  font-size: 0.76rem;
  font-weight: 750;
}

.voice-attachment {
  display: block;
  width: min(230px, 56vw);
  height: 42px;
}

.voice-note {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  width: min(292px, 70vw);
  min-height: 58px;
  padding: 8px 10px;
  margin-bottom: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.56);
}

.voice-dot {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  color: #fff;
  background: #d7372f;
  border-radius: 50%;
  font-size: 0.78rem;
}

.file-attachment {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  width: min(292px, 70vw);
  min-height: 58px;
  padding: 10px;
  margin-bottom: 5px;
  color: var(--ink);
  text-decoration: none;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.66);
  border: 1px solid rgba(8, 29, 25, 0.07);
}

.file-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  color: #fff;
  background: linear-gradient(135deg, var(--brand), #25d366);
  border-radius: 7px;
  font-size: 1.08rem;
  box-shadow: inset 0 -8px 16px rgba(7, 94, 84, 0.18);
}

.file-attachment strong,
.file-attachment small {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-attachment small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.74rem;
}

.sender-name {
  display: block;
  margin-bottom: 3px;
  color: var(--brand-dark);
  font-size: 0.78rem;
}

.message-footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
  margin-top: 3px;
}

.ticks {
  color: var(--brand);
  font-size: 0.75rem;
}

.composer {
  display: grid;
  grid-template-columns: 44px 44px 44px minmax(0, 1fr) 44px 48px;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--panel-soft);
  border-top: 1px solid rgba(217, 226, 221, 0.9);
}

.emoji-wrap {
  position: relative;
}

.emoji-panel {
  position: absolute;
  left: 0;
  bottom: 50px;
  z-index: 4;
  display: grid;
  grid-template-columns: repeat(4, 42px);
  gap: 6px;
  padding: 10px;
  border: 1px solid rgba(8, 29, 25, 0.08);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 16px 42px rgba(20, 47, 40, 0.18);
}

.emoji-panel[hidden] {
  display: none;
}

.emoji-panel button {
  width: 42px;
  height: 38px;
  border: 0;
  border-radius: 8px;
  background: #f3f7f5;
  font-size: 1.25rem;
}

.emoji-panel button:hover {
  background: #e2f1ed;
}

.hidden-file,
.composer .hidden-file {
  position: fixed;
  width: 1px;
  height: 1px;
  min-width: 1px;
  opacity: 0;
  pointer-events: none;
  padding: 0;
  border: 0;
}

.composer input {
  width: 100%;
  height: 46px;
  min-width: 0;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 999px;
  outline: 0;
  color: var(--ink);
  background: #fff;
}

.composer input:focus {
  border-color: rgba(18, 140, 126, 0.38);
}

.send-button {
  width: 46px;
  height: 46px;
  flex-basis: 46px;
  color: #fff;
  background: var(--brand);
}

.send-button:hover {
  background: var(--brand-dark);
}

.record-button {
  color: #d7372f;
}

.record-button.recording {
  color: #fff;
  background: #d7372f;
  box-shadow: 0 0 0 4px rgba(215, 55, 47, 0.18);
}

.danger-button {
  min-height: 46px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: var(--danger);
  font-weight: 850;
}

.profile-summary {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 8px;
  background: #f3f7f5;
}

.profile-summary strong,
.profile-summary p {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.call-dialog {
  width: min(430px, 100vw);
  height: min(760px, 100dvh);
  padding: 0;
  border: 0;
  border-radius: 18px;
  overflow: hidden;
  background: #101817;
  box-shadow: var(--shadow);
}

.call-dialog::backdrop {
  background: rgba(2, 12, 10, 0.78);
}

.call-card {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  height: 100%;
  color: #fff;
  background:
    linear-gradient(180deg, rgba(7, 94, 84, 0.92), rgba(16, 24, 23, 0.98)),
    #101817;
}

.call-top,
.call-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
}

.call-top strong,
.call-top span {
  display: block;
}

.call-top span {
  margin-top: 3px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.78rem;
}

.call-card .icon-button {
  color: #fff;
  background: rgba(255, 255, 255, 0.14);
}

.call-card .icon-button.active {
  background: rgba(214, 79, 66, 0.9);
}

.incoming-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.1);
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.incoming-panel[hidden] {
  display: none;
}

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

.incoming-panel span {
  margin-top: 3px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.78rem;
}

.incoming-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.accept-button,
.decline-button {
  min-height: 38px;
  border: 0;
  border-radius: 999px;
  padding: 0 14px;
  color: #fff;
  font-weight: 850;
}

.accept-button {
  background: #25d366;
}

.decline-button {
  background: #d7372f;
}

.video-stage {
  position: relative;
  min-height: 0;
  background: #060b0a;
}

#localVideo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #060b0a;
}

.remote-video {
  position: absolute;
  right: 14px;
  bottom: 14px;
  display: grid;
  place-items: center;
  gap: 8px;
  width: 132px;
  min-height: 174px;
  padding: 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(12px);
  overflow: hidden;
}

#remoteVideo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#remoteVideo[hidden] {
  display: none;
}

.remote-video p {
  position: relative;
  z-index: 1;
  color: rgba(255, 255, 255, 0.82);
  text-align: center;
  font-size: 0.72rem;
}

.remote-video .avatar {
  position: relative;
  z-index: 1;
}

.remote-grid {
  position: absolute;
  inset: auto 14px 14px 14px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(98px, 1fr));
  gap: 10px;
  max-height: 46%;
  overflow: auto;
}

.remote-grid[hidden] {
  display: none;
}

.remote-tile {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 132px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 14px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.14);
}

.remote-tile video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.remote-tile .avatar,
.remote-tile small {
  position: relative;
  z-index: 1;
}

.remote-tile small {
  align-self: end;
  width: 100%;
  padding: 6px 7px;
  overflow: hidden;
  color: #fff;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: rgba(2, 12, 10, 0.46);
}

.install-steps {
  display: grid;
  gap: 7px;
  padding: 12px;
  border-radius: 8px;
  background: #f3f7f5;
}

.install-steps strong {
  color: var(--brand-dark);
}

.install-steps p {
  margin-bottom: 8px;
}

.end-call-button {
  min-width: 96px;
  height: 44px;
  border: 0;
  border-radius: 999px;
  color: #fff;
  background: #d7372f;
  font-weight: 850;
}

.mobile-back {
  display: grid;
}

.contact-dialog {
  width: min(420px, calc(100vw - 28px));
  padding: 0;
  border: 0;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.contact-dialog::backdrop {
  background: rgba(7, 31, 27, 0.52);
}

.contact-card {
  display: grid;
  gap: 14px;
  padding: 18px;
  background: #fff;
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.contact-card label {
  display: grid;
  gap: 7px;
  color: #31524b;
  font-weight: 800;
}

.contact-card input {
  height: 48px;
  min-width: 0;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
}

.contact-card input:focus {
  border-color: var(--brand);
}

.contact-card p {
  color: var(--muted);
  line-height: 1.45;
}

.install-banner {
  position: fixed;
  right: max(14px, env(safe-area-inset-right));
  bottom: max(14px, env(safe-area-inset-bottom));
  left: max(14px, env(safe-area-inset-left));
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 40px;
  align-items: center;
  gap: 10px;
  max-width: 520px;
  margin-inline: auto;
  padding: 12px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(8, 29, 25, 0.08);
  border-radius: 14px;
  box-shadow: 0 18px 48px rgba(20, 47, 40, 0.22);
  backdrop-filter: blur(14px);
}

.install-banner[hidden] {
  display: none;
}

.install-banner strong,
.install-banner p {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.install-banner p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.82rem;
}

.primary-button.compact {
  min-height: 40px;
  padding-inline: 14px;
}

.member-picker {
  display: grid;
  gap: 8px;
  max-height: 280px;
  overflow: auto;
}

.member-choice {
  display: grid;
  grid-template-columns: 22px 44px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 62px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
}

.member-choice input {
  width: 18px;
  height: 18px;
  accent-color: var(--brand);
}

.member-choice strong,
.member-choice small {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.member-choice small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.78rem;
}

@media (min-width: 900px) {
  .messenger {
    grid-template-columns: minmax(320px, 390px) minmax(0, 1fr);
    width: min(1180px, calc(100vw - 36px));
    height: min(860px, calc(var(--app-height) - 36px));
    max-height: 860px;
    border-width: 6px;
    border-radius: 26px;
  }

  .sidebar {
    grid-column: 1;
    border-right: 1px solid var(--line);
  }

  .chat {
    grid-column: 2;
    transform: none;
  }

  .messenger.chat-open .sidebar {
    visibility: visible;
  }

  .mobile-back {
    display: none;
  }

  .messages {
    padding-inline: clamp(28px, 5vw, 76px);
  }

  .message {
    max-width: min(680px, 74%);
  }

  .media-attachment,
  .media-frame,
  .file-attachment,
  .voice-note {
    width: min(360px, 38vw);
  }
}

@media (max-width: 760px) {
  html,
  body {
    overflow: hidden;
  }

  body {
    background: var(--panel);
    height: var(--app-height);
    min-height: var(--app-height);
  }

  .identity-screen {
    align-items: stretch;
    padding: 0;
  }

  .identity-card {
    align-content: center;
    width: 100%;
    min-height: 100dvh;
    padding: 34px 22px;
    border-radius: 0;
    box-shadow: none;
  }

  .identity-card h1 {
    font-size: 1.7rem;
  }

  .identity-card input,
  .primary-button,
  .secondary-button {
    min-height: 50px;
    font-size: 1rem;
  }

  .messenger {
    width: 100vw;
    height: var(--app-height);
    min-height: var(--app-height);
    max-height: none;
    margin: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    grid-template-columns: 1fr;
  }

  .topbar,
  .chat-header {
    min-height: clamp(58px, 8dvh, 68px);
    padding-inline: 12px;
  }

  .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .topbar .icon-row {
    max-width: 176px;
  }

  .topbar .icon-button {
    width: 36px;
    height: 36px;
    flex-basis: 36px;
    font-size: 1.08rem;
  }

  .search-panel {
    padding: 9px 10px;
  }

  .member-strip {
    font-size: 0.78rem;
  }

  .conversation {
    min-height: 72px;
    padding-inline: 12px;
  }

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

  .message {
    max-width: 88%;
  }

  .composer {
    grid-template-columns: 36px 36px 36px minmax(86px, 1fr) 36px 42px;
    gap: 4px;
    padding: 9px 8px max(9px, env(safe-area-inset-bottom));
  }

  .composer input {
    height: 42px;
    padding-inline: 12px;
  }

  .composer .icon-button {
    width: 36px;
    height: 36px;
    flex-basis: 36px;
    font-size: 1.14rem;
  }

  .send-button {
    width: 42px;
    height: 42px;
    flex-basis: 42px;
  }

  .chat-header .icon-row {
    gap: 2px;
  }

  .chat-header .icon-button {
    width: 36px;
    height: 36px;
    flex-basis: 36px;
  }

  .call-dialog {
    width: 100vw;
    height: 100dvh;
    height: var(--app-height);
    max-width: 100vw;
    max-height: 100dvh;
    border-radius: 0;
  }

  .incoming-panel {
    align-items: stretch;
    flex-direction: column;
  }

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

  .contact-dialog {
    width: 100vw;
    max-width: 100vw;
    margin: auto 0 0;
    border-radius: 16px 16px 0 0;
  }

  .contact-card {
    padding: 18px 16px max(18px, env(safe-area-inset-bottom));
  }

  .phone-statusbar {
    min-height: max(28px, env(safe-area-inset-top));
    padding-inline: max(16px, env(safe-area-inset-left)) max(16px, env(safe-area-inset-right));
  }

  .status-network {
    max-width: 58px;
  }

  .media-attachment,
  .media-frame,
  .file-attachment,
  .voice-note {
    width: min(304px, 78vw);
  }

  .remote-video {
    width: 112px;
    min-height: 146px;
  }
}

@media (hover: none) and (pointer: coarse), (max-width: 899px) {
  html,
  body {
    overflow: hidden;
    width: 100%;
    height: var(--app-height);
    min-height: var(--app-height);
  }

  body {
    background: var(--panel);
  }

  .messenger {
    width: 100vw;
    height: var(--app-height);
    min-height: var(--app-height);
    max-height: none;
    margin: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .topbar .icon-row {
    max-width: min(46vw, 190px);
    overflow-x: auto;
    scrollbar-width: none;
  }

  .topbar .icon-row::-webkit-scrollbar {
    display: none;
  }

  .profile {
    gap: 9px;
  }
}

@media (max-width: 360px) {
  .composer {
    grid-template-columns: 30px 30px 30px minmax(72px, 1fr) 30px 38px;
    gap: 3px;
    padding-inline: 6px;
  }

  .composer .icon-button {
    width: 30px;
    height: 30px;
    flex-basis: 30px;
  }

  .send-button {
    width: 38px;
    height: 38px;
    flex-basis: 38px;
  }

  .status-battery-text {
    display: none;
  }
}
