:root {
  color-scheme: light;
  --app-bg: #d7dbd6;
  --green: #008069;
  --green-dark: #075e54;
  --header: #f0f2f5;
  --panel: #ffffff;
  --panel-soft: #f7f8fa;
  --chat-bg: #efe7dc;
  --text: #111b21;
  --muted: #667781;
  --line: #e9edef;
  --sent: #d9fdd3;
  --received: #ffffff;
  --danger: #c0392b;
  --focus: rgba(0, 128, 105, 0.22);
  --shadow: 0 10px 28px rgba(11, 20, 26, 0.16);
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
  min-width: 320px;
  background: var(--app-bg);
}

body {
  margin: 0;
  height: 100%;
  min-height: 100vh;
  overflow: hidden;
  color: var(--text);
  font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: linear-gradient(var(--green) 0 128px, transparent 128px), var(--app-bg);
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled,
input:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

input,
textarea {
  width: 100%;
  border: 1px solid #dde3e7;
  border-radius: 8px;
  padding: 0 13px;
  color: var(--text);
  background: #ffffff;
}

input {
  min-height: 42px;
}

textarea {
  min-height: 70px;
  padding-top: 10px;
  resize: none;
}

input::placeholder,
textarea::placeholder {
  color: #8696a0;
}

label {
  display: grid;
  gap: 6px;
  color: #3b4a54;
  font-size: 0.8rem;
  font-weight: 650;
}

.hidden {
  display: none !important;
}

.login-screen {
  display: grid;
  height: 100dvh;
  min-height: 100vh;
  overflow: auto;
  place-items: center;
  padding: 20px;
}

.login-card {
  display: grid;
  gap: 22px;
  width: min(440px, 100%);
  border-radius: 8px;
  padding: 28px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-brand,
.brand,
.chat-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.sidebar .brand {
  border-radius: 8px;
  padding: 4px 6px;
  cursor: pointer;
}

.sidebar .brand:hover {
  background: #e6e9ec;
}

.chat-title-row.clickable {
  border-radius: 8px;
  padding: 4px 6px;
  cursor: pointer;
}

.chat-title-row.clickable:hover {
  background: #e6e9ec;
}

.login-brand h1,
.login-brand p,
.brand h1,
.brand p,
.chat-header h2 {
  margin: 0;
}

.login-brand h1 {
  font-size: 1.65rem;
}

.login-brand p,
.brand p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.86rem;
}

.login-form,
.add-contact,
.group-form {
  display: grid;
  gap: 12px;
}

.login-form button,
.add-contact button,
.group-form button {
  min-height: 42px;
  border-radius: 8px;
  color: #ffffff;
  font-weight: 750;
  background: var(--green);
}

.login-form button:hover,
.add-contact button:hover,
.group-form button:hover,
.send-button:hover {
  background: var(--green-dark);
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  border-radius: 8px;
  padding: 4px;
  background: var(--panel-soft);
}

.auth-tabs button {
  min-height: 38px;
  border-radius: 7px;
  color: var(--muted);
  font-weight: 750;
  background: transparent;
}

.auth-tabs button.active {
  color: #ffffff;
  background: var(--green);
}

.photo-picker input {
  padding-top: 9px;
}

.photo-preview {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background-position: center;
  background-size: cover;
  box-shadow: inset 0 0 0 2px #ffffff, 0 0 0 1px #dde3e7;
}

.form-status,
.send-status {
  margin: 0;
  min-height: 18px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.form-status.ok,
.send-status.ok {
  color: var(--green-dark);
}

.form-status.error,
.send-status.error {
  color: var(--danger);
}

.shell {
  display: grid;
  grid-template-columns: minmax(320px, 410px) minmax(0, 1fr);
  width: min(1500px, calc(100% - 38px));
  height: calc(100dvh - 38px);
  min-height: 0;
  margin: 19px auto;
  overflow: hidden;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.sidebar {
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  height: 100%;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  border-right: 1px solid #d1d7db;
  background: var(--panel);
}

.appbar {
  min-height: 60px;
  background: var(--header);
}

.sidebar-appbar,
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 9px 16px;
}

.chat-header {
  border-bottom: 1px solid #d1d7db;
}

.appbar-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 4px;
  align-items: center;
}

.brand h1,
.chat-header h2 {
  overflow: hidden;
  font-size: 1rem;
  font-weight: 650;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.avatar {
  display: grid;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  color: #ffffff;
  font-size: 0.82rem;
  font-weight: 800;
  background: linear-gradient(135deg, #00a884, #128c7e);
  background-position: center;
  background-size: cover;
}

.avatar.has-photo {
  color: transparent;
}

.self-avatar {
  background: linear-gradient(135deg, #128c7e, #34b7f1);
}

.chat-avatar {
  width: 42px;
  height: 42px;
  background: #8796a1;
}

.icon-button {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 50%;
  color: #54656f;
  font-weight: 800;
  background: transparent;
}

.icon-button:hover {
  background: #e6e9ec;
}

.logout-button {
  width: auto;
  min-width: 42px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 0.72rem;
}

.mobile-menu-button,
.chat-back-button,
.mobile-menu-action {
  display: none;
}

.sidebar-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  padding: 8px 12px;
  background: #ffffff;
}

.action-panel {
  position: relative;
  min-width: 0;
}

.action-panel summary {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border: 1px solid #d1d7db;
  border-radius: 999px;
  padding: 0 12px;
  color: var(--green-dark);
  font-size: 0.82rem;
  font-weight: 800;
  list-style: none;
  cursor: pointer;
  background: #f7f8fa;
}

.action-panel summary::-webkit-details-marker {
  display: none;
}

.action-panel summary::after {
  content: "";
  display: none;
}

.action-panel[open] summary {
  border-color: var(--green);
  color: #ffffff;
  background: var(--green);
}

.action-panel summary:hover {
  background: #e9edef;
}

.add-contact,
.group-form {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 35;
  display: grid;
  gap: 8px;
  width: min(340px, calc(100vw - 24px));
  border: 1px solid #d1d7db;
  border-radius: 8px;
  padding: 10px;
  background: #ffffff;
  box-shadow: 0 14px 34px rgba(17, 27, 33, 0.18);
}

.action-panel:nth-child(2) .group-form {
  right: 0;
  left: auto;
}

.group-form {
  background: #fbfcfc;
}

.add-contact {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
}

.add-contact label {
  gap: 4px;
}

.add-contact .form-status {
  grid-column: 1 / -1;
}

.group-form textarea {
  min-height: 46px;
  max-height: 46px;
}

.add-contact input,
.group-form input,
.group-form textarea {
  min-height: 36px;
  font-size: 0.84rem;
}

.add-contact button,
.group-form button {
  min-height: 36px;
  border-radius: 8px;
  padding: 0 12px;
  color: #ffffff;
  font-size: 0.82rem;
  font-weight: 800;
  background: var(--green);
}

.add-contact button:hover,
.group-form button:hover {
  background: var(--green-dark);
}

.add-contact .form-status,
.group-form .form-status {
  min-height: 0;
  margin-top: 0;
  font-size: 0.74rem;
}

.mobile-menu-action {
  min-height: 36px;
  border-radius: 8px;
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 800;
  background: #f7f8fa;
}

.mobile-menu-action.danger {
  color: #ffffff;
  background: #d9534f;
}

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

.search-row input {
  min-height: 35px;
  border: 0;
  border-radius: 999px;
  padding-left: 18px;
}

.contacts {
  min-height: 0;
  overflow-y: scroll;
  overflow-x: hidden;
  scrollbar-gutter: stable;
  scrollbar-color: rgba(84, 101, 111, 0.5) rgba(247, 248, 250, 0.7);
  scrollbar-width: thin;
}

.contacts::-webkit-scrollbar {
  width: 10px;
}

.contacts::-webkit-scrollbar-track {
  background: rgba(247, 248, 250, 0.85);
}

.contacts::-webkit-scrollbar-thumb {
  border: 2px solid rgba(247, 248, 250, 0.85);
  border-radius: 999px;
  background: rgba(84, 101, 111, 0.55);
}

.contact {
  position: relative;
  display: grid;
  grid-template-columns: 49px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 72px;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 10px 14px;
  color: var(--text);
  text-align: left;
  background: #ffffff;
  cursor: pointer;
}

.contact::before {
  content: attr(data-initials);
  display: grid;
  width: 49px;
  height: 49px;
  place-items: center;
  border-radius: 50%;
  color: #ffffff;
  font-weight: 800;
  background: linear-gradient(135deg, #8bc34a, #00a884);
}

.contact:hover {
  background: #f5f6f6;
}

.contact.active {
  background: #e9edef;
}

.contact span {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 0.98rem;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.contact small {
  display: inline-block;
  max-width: 100%;
  margin-top: 3px;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 400;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.contact strong {
  display: grid;
  min-width: 22px;
  height: 22px;
  place-items: center;
  border-radius: 999px;
  color: #ffffff;
  font-size: 0.72rem;
  background: #25d366;
}

.chat-menu-wrap {
  position: relative;
  display: grid;
  place-items: center;
}

.chat-menu-button {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 50%;
  color: #54656f;
  font-size: 1.1rem;
  font-weight: 800;
  line-height: 1;
  background: transparent;
}

.contact:hover .chat-menu-button,
.contact.menu-open .chat-menu-button {
  background: #e6e9ec;
}

.chat-menu-button:hover {
  color: #111b21;
}

.chat-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 20;
  display: grid;
  min-width: 136px;
  overflow: hidden;
  border: 1px solid #d1d7db;
  border-radius: 8px;
  padding: 6px;
  background: #ffffff;
  box-shadow: 0 12px 28px rgba(17, 27, 33, 0.18);
}

.chat-menu button {
  min-height: 34px;
  border-radius: 6px;
  padding: 0 10px;
  color: #111b21;
  font-size: 0.88rem;
  font-weight: 600;
  text-align: left;
  background: transparent;
}

.chat-menu button:hover {
  background: #f0f2f5;
}

.chat-menu button[data-action="delete"] {
  color: var(--danger);
}

/* Old chat remove affordance kept harmless for previously cached markup. */
.contact em {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 50%;
  color: #8696a0;
  font-size: 0.8rem;
  font-style: normal;
  font-weight: 800;
}

.contact em:hover {
  color: #ffffff;
  background: #d9534f;
}

.contact-empty {
  margin: 18px 16px;
  border-radius: 8px;
  padding: 14px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
  text-align: center;
  background: #f7f8fa;
}

.chat {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100%;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  background-color: var(--chat-bg);
  background-image:
    radial-gradient(circle at 18px 18px, rgba(90, 72, 56, 0.055) 1px, transparent 1.4px),
    radial-gradient(circle at 58px 46px, rgba(90, 72, 56, 0.045) 1px, transparent 1.4px);
  background-size: 84px 84px;
}

.status {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.76rem;
}

.status.registered {
  color: var(--green);
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-height: 0;
  overflow-y: scroll;
  overflow-x: hidden;
  padding: 22px 7.5%;
  scrollbar-gutter: stable;
  scrollbar-color: rgba(84, 101, 111, 0.55) rgba(255, 255, 255, 0.18);
  scrollbar-width: thin;
}

.messages::-webkit-scrollbar {
  width: 10px;
}

.messages::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.2);
}

.messages::-webkit-scrollbar-thumb {
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  background: rgba(84, 101, 111, 0.58);
}

.empty {
  margin: auto;
  max-width: 410px;
  border-radius: 8px;
  padding: 13px 16px;
  color: #54656f;
  text-align: center;
  line-height: 1.5;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 1px 1px rgba(11, 20, 26, 0.08);
}

.date-divider {
  align-self: center;
  margin: 10px 0 8px;
  border-radius: 7px;
  padding: 6px 12px;
  color: #54656f;
  font-size: 0.74rem;
  font-weight: 700;
  line-height: 1;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13);
}

.chat-request {
  display: flex;
  align-items: center;
  align-self: center;
  justify-content: space-between;
  gap: 12px;
  width: min(520px, 100%);
  margin: 4px 0 12px;
  border-radius: 8px;
  padding: 10px 12px;
  color: #3b4a54;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13);
}

.chat-request span,
.chat-request strong,
.chat-request small {
  min-width: 0;
}

.chat-request strong,
.chat-request small {
  display: block;
}

.chat-request strong {
  color: var(--green-dark);
  font-size: 0.86rem;
}

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

.chat-request button {
  flex: 0 0 auto;
  min-height: 34px;
  border-radius: 999px;
  padding: 0 12px;
  color: #ffffff;
  font-size: 0.76rem;
  font-weight: 800;
  background: var(--green);
}

.chat-request button:hover {
  background: var(--green-dark);
}

.bubble {
  position: relative;
  max-width: min(650px, 76%);
  border-radius: 7.5px;
  padding: 7px 9px 5px;
  color: var(--text);
  line-height: 1.38;
  word-break: break-word;
  box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13);
}

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

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

.bubble.error {
  align-self: center;
  max-width: min(560px, 90%);
  color: var(--danger);
  text-align: center;
  background: #fff4f2;
}

.bubble.unseen {
  background: #ffe8e5;
}

.bubble.seen {
  background: var(--sent);
}

.bubble.error.seen,
.bubble.error.unseen {
  background: #fff4f2;
}

.bubble small {
  display: block;
  margin-top: 3px;
  color: rgba(84, 101, 111, 0.92);
  font-size: 0.68rem;
  text-align: right;
}

.message-sender {
  display: block;
  margin-bottom: 4px;
  color: var(--green-dark);
  font-size: 0.76rem;
  font-weight: 800;
}

.message-time {
  display: block;
  margin-top: 3px;
  color: rgba(84, 101, 111, 0.92);
  font-size: 0.68rem;
  text-align: right;
}

.reply-action {
  display: block;
  min-height: 22px;
  margin-top: 5px;
  margin-left: auto;
  border-radius: 999px;
  padding: 0 8px;
  color: #54656f;
  font-size: 0.68rem;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.62);
}

.reply-action:hover {
  background: rgba(255, 255, 255, 0.9);
}

.quoted-reply {
  display: grid;
  gap: 3px;
  min-width: min(230px, 100%);
  margin-bottom: 6px;
  border-left: 4px solid var(--green);
  border-radius: 6px;
  padding: 7px 9px;
  background: rgba(255, 255, 255, 0.52);
}

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

.quoted-reply strong {
  color: var(--green-dark);
  font-size: 0.74rem;
}

.quoted-reply span {
  color: #3b4a54;
  font-size: 0.78rem;
}

.composer {
  display: grid;
  grid-template-columns: 42px minmax(150px, 190px) minmax(0, 1fr) 82px;
  flex: 0 0 auto;
  gap: 8px;
  align-items: center;
  border-top: 1px solid #d1d7db;
  padding: 9px 14px;
  background: var(--header);
}

.reply-preview {
  grid-column: 1 / -1;
}

.reply-preview > div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 32px;
  gap: 8px;
  align-items: center;
  border-left: 4px solid var(--green);
  border-radius: 8px;
  padding: 8px 8px 8px 10px;
  background: #ffffff;
}

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

.reply-preview span {
  display: grid;
  gap: 2px;
}

.reply-preview strong {
  color: var(--green-dark);
  font-size: 0.78rem;
}

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

.reply-preview button {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 50%;
  color: #54656f;
  font-weight: 800;
  background: #f0f2f5;
}

.reply-preview button:hover {
  background: #e6e9ec;
}

.composer input {
  min-height: 44px;
  border: 0;
  border-radius: 999px;
  padding: 0 17px;
}

.schedule-input {
  color: #3b4a54;
  font-size: 0.82rem;
}

.composer-tool {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 50%;
  color: #54656f;
  font-size: 1.4rem;
  font-weight: 500;
  background: transparent;
  cursor: pointer;
}

.composer-tool input {
  display: none;
}

.send-button {
  display: grid;
  min-height: 42px;
  place-items: center;
  border-radius: 999px;
  color: #ffffff;
  font-size: 0.82rem;
  font-weight: 800;
  background: var(--green);
}

.send-status {
  grid-column: 2 / -1;
  padding-left: 4px;
}

.attachment-preview {
  display: flex;
  grid-column: 2 / -1;
  gap: 6px;
  min-width: 0;
  overflow-x: auto;
}

.attachment-chip {
  flex: 0 0 auto;
  max-width: 180px;
  min-height: 30px;
  overflow: hidden;
  border-radius: 999px;
  padding: 0 10px;
  color: #31515b;
  font-size: 0.76rem;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: #ffffff;
}

.message-text + .message-attachment,
.message-attachment + .message-attachment {
  margin-top: 7px;
}

.message-text a {
  color: #027eb5;
  text-decoration: underline;
  word-break: break-all;
}

.message-attachment img,
.message-attachment video {
  display: block;
  width: min(320px, 100%);
  min-width: min(220px, 100%);
  max-height: 300px;
  border-radius: 7px;
  object-fit: cover;
}

.message-attachment video {
  background: #111b21;
}

.audio-card {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  width: min(340px, 100%);
  border-radius: 7px;
  padding: 9px;
  background: rgba(255, 255, 255, 0.68);
}

.audio-card > span {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 6px;
  color: #ffffff;
  font-size: 0.68rem;
  font-weight: 800;
  background: #0b84a5;
}

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

.audio-card strong {
  font-size: 0.84rem;
}

.audio-card small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.72rem;
}

.audio-card audio {
  grid-column: 1 / -1;
  width: 100%;
  height: 36px;
}

.media-download {
  display: inline-grid;
  min-height: 30px;
  margin-top: 7px;
  place-items: center;
  border-radius: 999px;
  padding: 0 12px;
  color: #ffffff;
  font-size: 0.76rem;
  font-weight: 800;
  text-decoration: none;
  background: var(--green);
}

.media-download:hover {
  background: var(--green-dark);
}

.document-link {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  min-width: min(280px, 100%);
  border-radius: 7px;
  padding: 9px;
  color: var(--text);
  text-decoration: none;
  background: rgba(255, 255, 255, 0.68);
}

.document-link.unavailable {
  opacity: 0.72;
}

.document-link span {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 6px;
  color: #ffffff;
  font-size: 0.68rem;
  font-weight: 800;
  background: var(--green);
}

.document-link strong,
.document-link small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.document-link strong {
  font-size: 0.84rem;
}

.document-link small {
  grid-column: 2;
  margin: -7px 0 0;
  color: var(--muted);
  text-align: left;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(17, 27, 33, 0.38);
}

.modal-window {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(430px, 100%);
  max-height: min(620px, calc(100dvh - 36px));
  overflow: hidden;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.modal-window header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  padding: 16px;
  background: var(--header);
}

.modal-window h2,
.modal-window p {
  margin: 0;
}

.modal-window h2 {
  font-size: 1rem;
}

.modal-window p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.8rem;
}

.modal-window header button {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 50%;
  color: #54656f;
  font-weight: 800;
  background: #ffffff;
}

.modal-window header button:hover {
  background: #e6e9ec;
}

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

.member-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 68px;
  border-bottom: 1px solid var(--line);
  padding: 10px 16px;
}

.member-avatar {
  width: 44px;
  height: 44px;
}

.member-row span:not(.avatar) {
  display: grid;
  gap: 3px;
  min-width: 0;
}

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

.member-row strong {
  font-size: 0.94rem;
}

.member-row small,
.member-empty {
  color: var(--muted);
  font-size: 0.8rem;
}

.member-empty {
  margin: 0;
  padding: 18px;
  text-align: center;
}

.member-action {
  min-height: 32px;
  border-radius: 999px;
  padding: 0 12px;
  color: #ffffff;
  font-size: 0.74rem;
  font-weight: 800;
  background: var(--green);
}

.member-action:hover {
  background: var(--green-dark);
}

.member-action.danger {
  background: #d9534f;
}

.member-action.danger:hover {
  background: #c0392b;
}

.member-footer {
  display: flex;
  justify-content: flex-end;
  padding: 14px 16px;
  background: #fbfcfc;
}

.profile-window {
  width: min(420px, 100%);
}

.profile-form {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.profile-preview {
  width: 88px;
  height: 88px;
  justify-self: center;
  font-size: 1rem;
}

.profile-form button[type="submit"] {
  min-height: 42px;
  border-radius: 8px;
  color: #ffffff;
  font-weight: 800;
  background: var(--green);
}

.profile-form button[type="submit"]:hover {
  background: var(--green-dark);
}

@media (max-width: 820px) {
  html,
  body {
    min-width: 0;
  }

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

  .shell {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr);
    width: 100%;
    height: 100dvh;
    min-height: 0;
    margin: 0;
    box-shadow: none;
  }

  .sidebar {
    position: relative;
    grid-template-rows: auto auto minmax(0, 1fr);
    min-height: 0;
    overflow: hidden;
    border-right: 0;
    border-bottom: 1px solid #d1d7db;
  }

  .shell.mobile-chat-open .sidebar {
    display: none;
  }

  .shell:not(.mobile-chat-open) .chat {
    display: none;
  }

  .shell.mobile-chat-open .chat {
    display: grid;
  }

  .sidebar-appbar,
  .chat-header {
    padding: 8px 12px;
  }

  .appbar-actions .logout-button {
    display: none;
  }

  .mobile-menu-button {
    display: grid;
  }

  .chat-back-button {
    display: grid;
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    font-size: 1.8rem;
    line-height: 1;
  }

  .chat-title-row {
    flex: 1 1 auto;
  }

  .sidebar-actions {
    position: absolute;
    top: 58px;
    right: 10px;
    z-index: 45;
    display: none;
    width: min(330px, calc(100vw - 20px));
    grid-template-columns: 1fr;
    gap: 8px;
    border: 1px solid #d1d7db;
    border-radius: 8px;
    padding: 8px;
    background: #ffffff;
    box-shadow: 0 16px 38px rgba(17, 27, 33, 0.22);
  }

  .sidebar.menu-open .sidebar-actions {
    display: grid;
  }

  .action-panel summary {
    min-height: 36px;
    padding: 0 12px;
    font-size: 0.8rem;
  }

  .add-contact,
  .group-form {
    position: static;
    width: 100%;
    max-height: min(230px, 54dvh);
    border: 0;
    overflow-y: auto;
    padding: 9px;
    box-shadow: none;
  }

  .mobile-menu-action {
    display: grid;
    place-items: center;
  }

  .search-row {
    padding: 7px 10px;
  }

  .contacts {
    min-height: 0;
    max-height: none;
  }

  .contact {
    grid-template-columns: 44px minmax(0, 1fr) auto auto;
    min-height: 62px;
    gap: 10px;
    padding: 8px 10px;
  }

  .contact::before {
    width: 44px;
    height: 44px;
    font-size: 0.78rem;
  }

  .contact span {
    font-size: 0.92rem;
  }

  .contact small {
    font-size: 0.76rem;
  }

  .chat-menu {
    right: -2px;
  }

  .chat {
    min-height: 0;
  }

  .chat-header {
    min-height: 58px;
  }

  .messages {
    padding: 14px 10px;
  }

  .bubble {
    max-width: 92%;
    padding: 7px 9px;
  }

  .chat-request {
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
  }

  .chat-request button {
    width: 100%;
  }

  .composer {
    grid-template-columns: 38px minmax(0, 1fr) 66px;
    padding: 8px;
    gap: 7px;
  }

  .schedule-input {
    grid-column: 2 / -1;
    min-height: 38px;
    border-radius: 8px;
    font-size: 0.78rem;
  }

  #message-input {
    grid-column: 1 / 3;
    min-height: 40px;
    padding: 0 13px;
  }

  .composer-tool {
    width: 38px;
    height: 38px;
  }

  .send-button {
    min-height: 40px;
    font-size: 0.76rem;
  }

  .attachment-preview,
  .send-status {
    grid-column: 1 / -1;
  }
}

@media (max-width: 520px) {
  .brand h1,
  .chat-header h2 {
    font-size: 0.94rem;
  }

  .status {
    font-size: 0.7rem;
  }

  .messages {
    padding: 12px 8px;
  }

  .bubble {
    max-width: 95%;
  }

  .modal {
    padding: 10px;
  }

  .modal-window {
    max-height: calc(100dvh - 20px);
  }
}
