:root {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #1f2a33;
  background: #d7e3eb;
  --app-height: 100dvh;
}

* {
  box-sizing: border-box;
}

html,
body,
#app {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: default;
  opacity: 0.45;
}

[v-cloak],
.hidden {
  display: none;
}

.auth-page {
  display: grid;
  place-items: center;
  min-height: var(--app-height);
  padding: 20px;
  padding-bottom: max(20px, env(safe-area-inset-bottom));
  background: linear-gradient(135deg, #dceaf3, #eef6f9);
}

.auth-card {
  display: grid;
  gap: 12px;
  width: min(100%, 360px);
  padding: 24px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 18px 50px rgba(20, 38, 50, 0.18);
}

.auth-card h1 {
  margin: 0 0 6px;
  font-size: 24px;
}

.loading-card p {
  margin: 0;
  color: #667888;
}

.auth-tabs,
.side-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.auth-tabs button,
.side-tabs button {
  height: 36px;
  color: #385061;
  background: #eef4f8;
  border: 0;
  border-radius: 8px;
}

.auth-tabs button.active,
.side-tabs button.active {
  color: #fff;
  background: #2d8ccf;
}

.auth-card input,
.search input {
  height: 42px;
  padding: 0 12px;
  border: 1px solid rgba(64, 88, 104, 0.2);
  border-radius: 8px;
  outline: none;
}

.auth-card > button,
.search button {
  height: 42px;
  color: #fff;
  background: #2d8ccf;
  border: 0;
  border-radius: 8px;
}

.error {
  margin: 0;
  color: #c33b3b;
  font-size: 13px;
}

.app-shell {
  display: grid;
  grid-template-columns: 320px 1fr;
  width: min(100%, 1100px);
  height: var(--app-height);
  margin: 0 auto;
  background: #edf4f8;
  box-shadow: 0 0 0 1px rgba(60, 78, 90, 0.08);
}

.sidebar {
  display: grid;
  grid-template-rows: auto auto 1fr;
  min-width: 0;
  background: #fff;
  border-right: 1px solid rgba(64, 88, 104, 0.12);
}

.side-head,
.chat-head {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: space-between;
  min-height: 64px;
  padding: 10px 14px;
  padding-top: max(10px, env(safe-area-inset-top));
  color: #fff;
  background: #2d8ccf;
}

.chat-head {
  position: sticky;
  top: 0;
  z-index: 5;
}

.side-head div,
.chat-head div {
  min-width: 0;
}

.side-head strong,
.side-head span,
.chat-head h1,
.chat-head span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.side-head span,
.chat-head span {
  margin-top: 2px;
  font-size: 12px;
  opacity: 0.86;
}

.side-head button {
  flex: 0 0 auto;
  padding: 6px 10px;
  color: #fff;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 8px;
}

.delete-chat-button {
  flex: 0 0 auto;
  height: 36px;
  padding: 0 10px;
  color: #fff;
  background: rgba(186, 38, 38, 0.24);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
}

.delete-chat-button:hover {
  background: rgba(186, 38, 38, 0.34);
}

.side-tabs {
  padding: 10px;
}

.empty-state {
  margin: 18px 12px;
  color: #71808a;
  font-size: 14px;
}

.list,
.friends-pane {
  min-height: 0;
  overflow-y: auto;
}

.friends-pane {
  padding: 0 10px 10px;
}

.friends-pane h2 {
  margin: 14px 0 7px;
  color: #667888;
  font-size: 12px;
  font-weight: 700;
}

.search {
  display: grid;
  grid-template-columns: 1fr 64px;
  gap: 8px;
  margin-bottom: 8px;
}

.list-item,
.request-item {
  display: grid;
  width: 100%;
  gap: 3px;
  padding: 11px 12px;
  text-align: left;
  background: transparent;
  border: 0;
  border-bottom: 1px solid rgba(64, 88, 104, 0.08);
}

.list-item.active,
.list-item:hover {
  background: #e6f2fa;
}

.list-item strong {
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-item span,
.request-item span {
  overflow: hidden;
  color: #667888;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.request-item {
  grid-template-columns: 1fr auto auto;
  align-items: center;
  background: #f7fbfd;
  border-radius: 8px;
  border-bottom: 0;
  margin-bottom: 6px;
}

.request-item button {
  padding: 5px 8px;
  color: #2376ad;
  background: #e6f2fa;
  border: 0;
  border-radius: 8px;
}

.chat {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-width: 0;
}

.chat-head h1 {
  margin: 0;
  font-size: 18px;
}

.back-button {
  display: none;
  flex: 0 0 auto;
  height: 36px;
  padding: 0 10px;
  color: #fff;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 8px;
}

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

.message-row {
  display: flex;
  margin: 8px 0;
}

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

.bubble {
  width: fit-content;
  max-width: min(78%, 560px);
  padding: 8px 10px 6px;
  background: #fff;
  border-radius: 8px 8px 8px 2px;
  box-shadow: 0 1px 1px rgba(35, 52, 64, 0.12);
}

.mine .bubble {
  background: #cfeeb2;
  border-radius: 8px 8px 2px 8px;
}

.bubble.revoked {
  color: #71808a;
  background: #f5f7f9;
}

.sender {
  margin-bottom: 3px;
  color: #2376ad;
  font-size: 12px;
  font-weight: 650;
}

.bubble p {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.45;
  font-size: 15px;
}

.chat-image {
  display: block;
  max-width: min(320px, 62vw);
  max-height: 360px;
  border-radius: 8px;
}

.bubble audio,
.chat-video {
  width: min(280px, 58vw);
}

.chat-video {
  display: block;
  max-height: 360px;
  background: #111;
  border-radius: 8px;
}

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

.bubble time,
.bubble footer button {
  color: rgba(31, 42, 51, 0.62);
  font-size: 11px;
}

.bubble footer button {
  padding: 0;
  color: #2376ad;
  background: transparent;
  border: 0;
}

.composer {
  display: grid;
  gap: 8px;
  padding: 10px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  background: #f7fbfd;
  border-top: 1px solid rgba(64, 88, 104, 0.12);
}

.composer-main {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 42px;
  align-items: end;
  gap: 8px;
}

.composer textarea {
  min-height: 42px;
  max-height: 120px;
  padding: 10px 12px;
  resize: none;
  color: #1f2a33;
  background: #fff;
  border: 1px solid rgba(64, 88, 104, 0.18);
  border-radius: 8px;
  outline: none;
}

.icon-button,
.hold-to-talk,
.send-button,
.attach-item {
  height: 42px;
  color: #1f2a33;
  background: #fff;
  border: 1px solid rgba(64, 88, 104, 0.18);
  border-radius: 8px;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  min-width: 42px;
  padding: 0;
  font-size: 20px;
  line-height: 1;
}

.plus-button {
  font-size: 28px;
  font-weight: 300;
}

.hold-to-talk {
  width: 100%;
  font-weight: 650;
  touch-action: none;
  user-select: none;
}

.hold-to-talk.recording {
  color: #fff;
  background: #2d8ccf;
  border-color: #2d8ccf;
}

.send-row {
  display: flex;
  justify-content: flex-end;
}

.send-button {
  min-width: 64px;
  padding: 0 14px;
  color: #fff;
  background: #2d8ccf;
  border-color: #2d8ccf;
}

.attach-panel {
  display: grid;
  grid-template-columns: repeat(4, minmax(64px, 1fr));
  gap: 10px;
  padding: 10px 0 4px;
}

.attach-item {
  display: grid;
  place-items: center;
  min-height: 64px;
  color: #385061;
  background: #fff;
}

.attach-item span {
  font-size: 14px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(22px, env(safe-area-inset-bottom));
  z-index: 20;
  max-width: min(88vw, 420px);
  padding: 10px 12px;
  color: #fff;
  text-align: center;
  background: rgba(15, 31, 43, 0.9);
  border-radius: 8px;
  transform: translateX(-50%);
}

.preview {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(14, 25, 34, 0.78);
}

.preview img {
  max-width: 96vw;
  max-height: 92vh;
  border-radius: 8px;
}

@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: 1fr;
    width: 100%;
    height: var(--app-height);
    overflow: hidden;
  }

  .sidebar {
    display: grid;
    height: var(--app-height);
    border-right: 0;
    border-bottom: 0;
  }

  .app-shell.show-chat .sidebar {
    display: none;
  }

  .chat {
    display: none;
    height: var(--app-height);
    min-height: 0;
  }

  .app-shell.show-chat .chat {
    display: grid;
  }

  .back-button {
    display: inline-flex;
    align-items: center;
  }

  .side-head,
  .chat-head {
    min-height: 58px;
    padding-left: 12px;
    padding-right: 12px;
  }

  .chat-head {
    justify-content: flex-start;
  }

  .chat-head div {
    flex: 1 1 auto;
  }

  .delete-chat-button {
    height: 34px;
    min-width: 48px;
    padding: 0 9px;
  }

  .side-tabs {
    padding: 8px;
  }

  .list-item {
    min-height: 58px;
    padding: 12px;
  }

  .friends-pane {
    padding: 0 8px 8px;
  }

  .search {
    grid-template-columns: 1fr 58px;
  }

  .messages {
    padding: 12px 8px;
    overscroll-behavior: contain;
  }

  .bubble {
    max-width: 84%;
  }

  .chat-image {
    max-width: min(260px, 72vw);
    max-height: 320px;
  }

  .bubble audio {
    width: min(240px, 70vw);
  }

  .chat-video {
    width: min(260px, 72vw);
    max-height: 320px;
  }

  .composer {
    gap: 7px;
    padding: 8px;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }

  .composer-main {
    grid-template-columns: 40px minmax(0, 1fr) 40px;
    gap: 7px;
  }

  .composer textarea {
    min-width: 0;
    min-height: 40px;
    padding: 9px 10px;
  }

  .icon-button,
  .hold-to-talk,
  .send-button {
    height: 40px;
  }

  .icon-button {
    min-width: 40px;
  }

  .send-button {
    min-width: 56px;
    padding: 0 12px;
  }

  .attach-panel {
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
  }

  .attach-item {
    min-height: 60px;
  }
}
