:root {
  --green: #075e54;
  --green-2: #128c7e;
  --mint: #dcf8c6;
  --bg: #e5ddd5;
  --line: #d8d8d8;
  --text: #17212b;
  --muted: #667781;
  --panel: #ffffff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(var(--green) 0 128px, #d9dbd5 128px);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input {
  font: inherit;
}

.hidden {
  display: none !important;
}

.shell {
  width: min(1440px, calc(100vw - 32px));
  height: calc(100vh - 32px);
  margin: 16px auto;
}

.auth-panel {
  width: min(420px, 100%);
  margin: 64px auto;
  background: var(--panel);
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
  padding: 28px;
}

.brand {
  text-align: center;
}

.brand-mark,
.avatar {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  font-weight: 700;
  flex: 0 0 auto;
}

.brand-mark {
  width: 72px;
  height: 72px;
  margin: 0 auto 12px;
  font-size: 24px;
}

.brand h1 {
  margin: 0;
}

.brand p,
.message {
  color: var(--muted);
}

.auth-form {
  display: grid;
  gap: 10px;
  margin-top: 24px;
}

.qr-login {
  display: grid;
  gap: 12px;
  justify-items: center;
  margin-top: 24px;
  text-align: center;
}

.qr-box {
  display: grid;
  place-items: center;
  width: 248px;
  height: 248px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.qr-box img {
  width: 224px;
  height: 224px;
}

.qr-login code {
  max-width: 100%;
  padding: 8px;
  border-radius: 6px;
  background: #f0f2f5;
  color: var(--muted);
  overflow-wrap: anywhere;
}

input {
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  outline-color: var(--green-2);
}

button {
  border: 0;
  border-radius: 6px;
  background: var(--green);
  color: #fff;
  cursor: pointer;
  height: 44px;
  padding: 0 16px;
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.app-panel {
  display: grid;
  grid-template-columns: 380px 1fr;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  background: var(--panel);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
}

.sidebar {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: #f7f8fa;
}

.side-header,
.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 64px;
  padding: 10px 14px;
  background: #f0f2f5;
}

.side-header {
  justify-content: space-between;
}

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

.user span,
.chat-header span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
}

.icon-btn {
  width: auto;
  height: 36px;
  background: transparent;
  color: var(--green);
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 8px;
  gap: 8px;
}

.tabs button {
  background: #e9edef;
  color: var(--text);
}

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

.search {
  margin: 0 12px 8px;
  background: #fff;
}

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

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid #edf0f2;
  cursor: pointer;
}

.row:hover,
.row.active {
  background: #e9edef;
}

.row-main {
  min-width: 0;
  flex: 1;
}

.row-title,
.row-message {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.row-message {
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
}

.chat {
  display: grid;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  grid-template-rows: auto 1fr auto;
  background: var(--bg);
}

.messages {
  min-height: 0;
  height: 100%;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 20px 48px;
  background:
    linear-gradient(rgba(229, 221, 213, 0.88), rgba(229, 221, 213, 0.88)),
    repeating-linear-gradient(45deg, transparent 0 12px, rgba(255,255,255,0.18) 12px 24px);
}

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

.messages::-webkit-scrollbar-thumb,
.list::-webkit-scrollbar-thumb {
  background: rgba(102, 119, 129, 0.45);
  border-radius: 999px;
}

.empty {
  max-width: 340px;
  margin: 20vh auto;
  color: var(--muted);
  text-align: center;
}

.bubble {
  max-width: min(560px, 74%);
  margin: 6px 0;
  padding: 8px 10px;
  border-radius: 7px;
  background: #fff;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.08);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.bubble.me {
  margin-left: auto;
  background: var(--mint);
}

.bubble .time {
  display: block;
  margin-top: 4px;
  text-align: right;
  color: var(--muted);
  font-size: 11px;
}

.message-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 6px;
}

.message-actions button,
.message-actions a {
  display: inline-flex;
  align-items: center;
  height: 28px;
  border-radius: 5px;
  border: 0;
  background: rgba(7, 94, 84, 0.12);
  color: var(--green);
  font-size: 12px;
  text-decoration: none;
  padding: 0 8px;
}

.media-preview {
  display: block;
  max-width: 280px;
  max-height: 280px;
  border-radius: 6px;
  object-fit: cover;
}

.attachment {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
}

.video-preview,
.audio-preview {
  display: block;
  width: min(320px, 70vw);
  max-height: 260px;
  border-radius: 6px;
}

.file-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 6px;
  background: rgba(7, 94, 84, 0.12);
  color: var(--green);
  font-weight: 700;
}

.composer {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 10px;
  background: #f0f2f5;
}

#attachBtn {
  border-radius: 50%;
  font-size: 24px;
  line-height: 1;
}

@media (max-width: 820px) {
  .shell {
    width: 100vw;
    height: 100vh;
    margin: 0;
  }

  .app-panel {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
  }

  .messages {
    padding: 14px;
  }
}
