.tsm-root {
  max-width: 1520px;
  margin: 0 auto;
  padding: 18px 16px 36px;
  font-family: inherit;
}

.tsm-shell {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 16px;
  min-height: 84vh;
}

.tsm-sidebar,
.tsm-chat-panel,
.tsm-empty-card {
  background: #ffffff;
  border: 1px solid #e9eef5;
  border-radius: 28px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.05);
}

.tsm-sidebar {
  padding: 16px;
  display: flex;
  flex-direction: column;
  min-height: 84vh;
  overflow: hidden;
  background: linear-gradient(180deg, #ffffff 0%, #fbfcfe 100%);
}

.tsm-sidebar-top {
  margin-bottom: 14px;
}

.tsm-sidebar-head {
  margin-bottom: 14px;
}

.tsm-eyebrow {
  font-size: 11px;
  font-weight: 800;
  color: #22c55e;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}

.tsm-sidebar-head h2 {
  margin: 0;
  font-size: 25px;
  line-height: 1.1;
  color: #111827;
}

.tsm-auth-box {
  margin-bottom: 14px;
}

.tsm-login-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tsm-login-form input,
.tsm-search,
.tsm-message-form input {
  width: 100%;
  border: 1px solid #dde5ee;
  border-radius: 16px;
  padding: 13px 14px;
  font-size: 14px;
  outline: none;
  background: #fff;
  color: #111827;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.tsm-login-form input:focus,
.tsm-search:focus,
.tsm-message-form input:focus {
  border-color: #22c55e;
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.12);
}

.tsm-login-form input::placeholder,
.tsm-search::placeholder,
.tsm-message-form input::placeholder {
  color: #9aa4b2;
}

.tsm-login-form button,
#tsm-logout-btn,
.tsm-send-btn,
.tsm-secondary-btn,
.tsm-icon-btn {
  border: 0;
  border-radius: 16px;
  padding: 12px 14px;
  font-weight: 700;
  width:90px;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}

.tsm-login-form button:hover,
#tsm-logout-btn:hover,
.tsm-send-btn:hover,
.tsm-secondary-btn:hover,
.tsm-icon-btn:hover {
  transform: translateY(-1px);
}

.tsm-login-form button,
.tsm-send-btn {
  background: #22c55e;
  color: #fff;
  width:90px;
  box-shadow: 0 8px 18px rgba(34, 197, 94, 0.18);
}

#tsm-logout-btn,
.tsm-secondary-btn {
  background: #111827;
  color: #fff;
}

.tsm-icon-btn {
  background: #f3f6f9;
  color: #111827;
  min-width: 46px;
  height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 999px;
}

.tsm-icon-btn.recording {
  background: #ef4444;
  color: #fff;
}

.tsm-user-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.tsm-user-email {
  font-size: 14px;
  font-weight: 600;
  color: #111827;
  word-break: break-word;
}

.tsm-search-wrap {
  margin-bottom: 10px;
}

.tsm-chat-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: auto;
  min-height: 0;
  padding-right: 4px;
}

.tsm-chat-list::-webkit-scrollbar,
.tsm-messages::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.tsm-chat-list::-webkit-scrollbar-thumb,
.tsm-messages::-webkit-scrollbar-thumb {
  background: #d6dee8;
  border-radius: 999px;
}

.tsm-chat-item {
  width: 100%;
  text-align: left;
  border: 1px solid #edf2f7;
  background: #fff;
  border-radius: 20px;
  padding: 12px;
  display: flex;
  gap: 12px;
  align-items: center;
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.tsm-chat-item:hover {
  background: #f8fffb;
  border-color: #d7f5e1;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.05);
}

.tsm-chat-item.active {
  background: #eefcf3;
  border-color: #bbf7d0;
  box-shadow: 0 10px 24px rgba(34, 197, 94, 0.1);
}

.tsm-avatar {
  width: 46px;
  height: 46px;
  border-radius: 999px;
  background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  flex: 0 0 auto;
  box-shadow: 0 6px 14px rgba(34, 197, 94, 0.18);
}

.tsm-avatar.small {
  width: 44px;
  height: 44px;
  font-size: 14px;
}

.tsm-chat-item-body {
  min-width: 0;
  flex: 1;
}

.tsm-chat-item-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin-bottom: 5px;
}

.tsm-chat-item-name-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.tsm-chat-item-name {
  font-size: 15px;
  font-weight: 700;
  color: #111827;
}

.tsm-inline-verified {
  color: #22c55e;
  font-size: 12px;
  font-weight: 800;
}

.tsm-chat-item-time {
  font-size: 12px;
  color: #9aa4b2;
  white-space: nowrap;
}

.tsm-chat-item-bottom {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tsm-chat-item-preview {
  font-size: 13px;
  color: #6b7280;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.tsm-unread-badge {
  min-width: 20px;
  height: 20px;
  border-radius: 999px;
  background: #22c55e;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  box-shadow: 0 4px 10px rgba(34, 197, 94, 0.2);
}

.tsm-main {
  min-width: 0;
}

.tsm-empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 84vh;
}

.tsm-empty-card {
  width: 100%;
  min-height: 84vh;
  padding: 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #6b7280;
  background: linear-gradient(180deg, #ffffff 0%, #fbfcfe 100%);
}

.tsm-empty-icon {
  font-size: 42px;
  margin-bottom: 12px;
}

.tsm-empty-card h3 {
  margin: 0 0 8px;
  color: #111827;
  font-size: 24px;
}

.tsm-empty-card p {
  margin: 0;
  font-size: 15px;
}

.tsm-chat-panel {
  min-height: 84vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

.tsm-chat-header {
  padding: 16px 18px;
  border-bottom: 1px solid #edf2f7;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
}

.tsm-chat-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.tsm-back-btn {
  display: none;
  border: 0;
  background: #f3f6f9;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  font-size: 18px;
  cursor: pointer;
  color: #111827;
  padding: 0;
}

.tsm-chat-person {
  min-width: 0;
}

.tsm-chat-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tsm-chat-name-row h3 {
  margin: 0;
  font-size: 17px;
  color: #111827;
}

.tsm-verified {
  color: #22c55e;
  font-size: 13px;
  font-weight: 800;
}

.tsm-chat-status {
  font-size: 12px;
  color: #6b7280;
  margin-top: 2px;
}

.tsm-typing {
  padding: 8px 18px 0;
  font-size: 13px;
  color: #6b7280;
}

.tsm-messages {
  flex: 1;
  overflow: auto;
  padding: 18px;
  background:
    radial-gradient(circle at top left, rgba(34, 197, 94, 0.04), transparent 22%),
    linear-gradient(180deg, #f7faf8 0%, #f4f7fb 100%);
}

.tsm-message-row {
  display: flex;
  margin-bottom: 10px;
}

.tsm-message-row.mine {
  justify-content: flex-end;
}

.tsm-message-row.theirs {
  justify-content: flex-start;
}

.tsm-message-bubble {
  max-width: min(76%, 560px);
  border-radius: 20px;
  padding: 11px 13px;
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.04);
}

.tsm-message-bubble.mine {
  background: linear-gradient(180deg, #dcf8c6 0%, #d2f3b6 100%);
  color: #111827;
  border-bottom-right-radius: 6px;
}

.tsm-message-bubble.theirs {
  background: #ffffff;
  color: #111827;
  border: 1px solid #edf2f7;
  border-bottom-left-radius: 6px;
}

.tsm-message-text {
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}

.tsm-media-link {
  display: inline-block;
  margin-top: 6px;
}

.tsm-message-image,
.tsm-message-video {
  width: 220px;
  max-width: 100%;
  height: 220px;
  object-fit: cover;
  border-radius: 14px;
  display: block;
}

.tsm-voice-note {
  margin-top: 6px;
  background: #22c55e;
  border-radius: 18px;
  padding: 10px 12px;
}

.tsm-voice-note audio {
  width: 220px;
  max-width: 100%;
}

.tsm-message-meta {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 6px;
  font-size: 11px;
  color: #6b7280;
}

.tsm-message-form {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  gap: 10px;
  padding: 12px 14px;
  border-top: 1px solid #edf2f7;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
}

.tsm-send-btn {
  border-radius: 999px;
  padding: 0 18px;
  min-height: 46px;
}

.tsm-muted,
.tsm-error {
  color: #6b7280;
  font-size: 14px;
}

@media (max-width: 980px) {
  .tsm-shell {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .tsm-sidebar,
  .tsm-chat-panel,
  .tsm-empty-card,
  .tsm-empty-state {
    min-height: auto;
  }

  .tsm-main.mobile-hidden {
    display: none;
  }

  .tsm-sidebar.mobile-hidden {
    display: none;
  }

  .tsm-back-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
}

@media (max-width: 640px) {
  .tsm-root {
    padding: 10px;
  }

  .tsm-shell {
    gap: 12px;
  }

  .tsm-sidebar,
  .tsm-chat-panel,
  .tsm-empty-card {
    border-radius: 22px;
  }

  .tsm-chat-header {
    padding: 14px;
  }

  .tsm-messages {
    padding: 12px;
  }

  .tsm-message-form {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .tsm-send-btn {
    grid-column: 1 / -1;
    height: 44px;
    width:100px;
  }

  .tsm-message-bubble {
    max-width: 88%;
  }

  .tsm-message-image,
  .tsm-message-video {
    width: 180px;
    height: 180px;
  }

  .tsm-voice-note audio {
    width: 180px;
  }

  .tsm-secondary-btn {
    padding: 10px 12px;
    font-size: 12px;
  }
}
