html,
body {
  width: 100%;
  max-width: 100%;
  height: 100%;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  overscroll-behavior: none;
}

.brand {
  margin: 0 5px 14px;
}

.brand #new-chat {
  width: 38px;
  height: 38px;
  margin-left: auto;
  padding: 0;
  border-radius: 12px;
  font-size: 24px;
  line-height: 1;
}

.brand #new-chat.is-selecting {
  background: var(--soft);
  color: var(--accent);
}

.avatar {
  position: relative;
  overflow: visible;
}

.avatar > img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: cover;
}

.avatar.is-online::after,
.avatar.is-away::after,
.avatar.is-invisible::after {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 10px;
  height: 10px;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: #56a77b;
  content: '';
  z-index: 2;
}

.avatar.is-away::after {
  background: #d29b38;
}

.avatar.is-invisible::after {
  border-color: #8c98a4;
  background: var(--surface);
}

.presence-online {
  color: #3f8b68 !important;
}

.presence-away {
  color: #a8751f !important;
}

footer {
  position: relative;
  gap: 6px;
  padding-right: 0;
  padding-left: 0;
}

.profile {
  display: flex;
  flex: 1;
  align-items: center;
  min-width: 0;
  gap: 10px;
  padding: 5px 7px;
  color: var(--text);
  background: transparent;
  text-align: left;
}

.self-avatar {
  width: 35px;
  height: 35px;
  border-radius: 12px;
}

.profile-copy {
  min-width: 0;
}

.profile-copy strong,
.profile-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-copy strong {
  font-size: 12px;
}

.profile-copy small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
}

.profile-chevron {
  margin-left: auto;
  color: var(--muted);
  font-size: 14px;
  transition: transform .15s ease;
}

.profile[aria-expanded='true'] .profile-chevron {
  transform: rotate(180deg);
}

.presence-menu {
  position: absolute;
  right: 0;
  bottom: calc(100% + 10px);
  left: 0;
  z-index: 5;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface);
  box-shadow: 0 14px 45px #10232d26;
}

.presence-menu button {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) 18px;
  align-items: center;
  width: 100%;
  gap: 10px;
  padding: 10px;
  color: var(--text);
  background: transparent;
  text-align: left;
}

.presence-menu button[aria-checked='true'] {
  background: var(--soft);
}

.presence-menu strong,
.presence-menu small {
  display: block;
}

.presence-menu strong {
  font-size: 12px;
}

.presence-menu small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #56a77b;
}

.status-away {
  background: #d29b38;
}

.status-invisible {
  border: 2px solid #8c98a4;
  background: transparent;
}

.status-check {
  visibility: hidden;
  color: var(--accent);
}

.presence-menu button[aria-checked='true'] .status-check {
  visibility: visible;
}

.shell {
  grid-template-columns: 320px minmax(0, 1fr);
  width: 100%;
  height: var(--app-height, 100dvh);
  max-height: 100%;
  overflow: hidden;
}

.sidebar,
.chat,
.chat-header,
.messages,
#composer {
  min-width: 0;
}

.chat-header > div:last-child {
  min-width: 0;
}

.chat-header h2,
.chat-header p {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.messages {
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.welcome {
  max-width: 360px;
}

.welcome-icon {
  position: relative;
  width: 42px;
  height: 34px;
  padding: 0;
  border: 2px solid var(--muted);
  border-radius: 13px;
  background: transparent;
  opacity: .55;
}

.welcome-icon::after {
  position: absolute;
  right: 7px;
  bottom: -6px;
  width: 10px;
  height: 10px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  background: var(--surface);
  content: '';
  transform: rotate(45deg);
}

.welcome p {
  margin-top: 18px;
  line-height: 1.6;
}

.bubble {
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}

#composer {
  max-width: 100%;
}

.login-screen {
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

.login-card {
  width: min(100%, 410px);
  max-width: 100%;
  overflow-wrap: anywhere;
}

textarea {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

@media (max-width: 650px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    padding-top: calc(18px + env(safe-area-inset-top));
    padding-right: calc(16px + env(safe-area-inset-right));
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
    padding-left: calc(16px + env(safe-area-inset-left));
  }

  .chat-header {
    padding-top: calc(14px + env(safe-area-inset-top));
    padding-right: calc(16px + env(safe-area-inset-right));
    padding-left: calc(16px + env(safe-area-inset-left));
  }

  .messages {
    padding-right: calc(16px + env(safe-area-inset-right));
    padding-left: calc(16px + env(safe-area-inset-left));
  }

  #composer {
    margin-right: calc(13px + env(safe-area-inset-right));
    margin-left: calc(13px + env(safe-area-inset-left));
  }

  .compose-hint {
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }

  .login-screen {
    padding-top: calc(20px + env(safe-area-inset-top));
    padding-right: calc(20px + env(safe-area-inset-right));
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
    padding-left: calc(20px + env(safe-area-inset-left));
  }

  .login-card {
    padding: 30px 22px;
  }

  .search input,
  textarea {
    font-size: 16px;
  }

  .message {
    max-width: 88%;
  }

  button {
    touch-action: manipulation;
  }

  body > header {
    padding-top: env(safe-area-inset-top);
    padding-right: calc(6vw + env(safe-area-inset-right));
    padding-left: calc(6vw + env(safe-area-inset-left));
  }

  body > main {
    padding-right: calc(7vw + env(safe-area-inset-right));
    padding-bottom: calc(30px + env(safe-area-inset-bottom));
    padding-left: calc(7vw + env(safe-area-inset-left));
    overflow-x: hidden;
  }

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

  body > main > h1 {
    font-size: clamp(34px, 12vw, 52px);
    overflow-wrap: anywhere;
  }
}

@media (max-width: 650px) {
  .conversation,
  .person {
    min-height: 76px;
    gap: 14px;
    padding: 13px 10px;
  }

  .conversation .avatar,
  .person .avatar {
    width: 52px;
    height: 52px;
    border-radius: 18px;
    font-size: 16px;
  }

  .conversation .avatar.is-online::after,
  .conversation .avatar.is-away::after,
  .conversation .avatar.is-invisible::after,
  .person .avatar.is-online::after,
  .person .avatar.is-away::after,
  .person .avatar.is-invisible::after {
    width: 12px;
    height: 12px;
  }

  .conversation .row-text strong,
  .person .row-text strong {
    font-size: 16px;
  }

  .conversation .row-text small,
  .person .row-text small {
    max-width: none;
    margin-top: 5px;
    font-size: 13px;
  }

  .conversation .badge {
    min-width: 29px;
    height: 29px;
    padding: 0 8px;
    border-radius: 15px;
    background: #d63c45;
    font-size: 13px;
    font-weight: 700;
  }
}
