* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  background: #ece5dd;
  color: #111b21;
  height: 100vh;
  overflow: hidden;
}

/* Login */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #075e54;
}
.login-box {
  background: #fff;
  padding: 2.5rem 2rem;
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,.25);
  width: 320px;
  text-align: center;
}
.login-box h1 { font-size: 1.3rem; margin-bottom: 1.5rem; color: #075e54; }
.login-box form { display: flex; flex-direction: column; gap: .75rem; }
.login-box input {
  padding: .7rem .9rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 1rem;
}
.login-box button {
  padding: .7rem;
  border: none;
  border-radius: 6px;
  background: #25d366;
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
}
.login-box button:hover { background: #1fb959; }
.login-error { color: #d32f2f; font-size: .85rem; margin-bottom: .75rem; }

/* App layout */
.app {
  display: flex;
  height: 100vh;
}
.sidebar {
  width: 360px;
  min-width: 280px;
  background: #fff;
  border-right: 1px solid #d1d7db;
  display: flex;
  flex-direction: column;
}
.sidebar-header {
  background: #075e54;
  color: #fff;
  padding: 1rem;
  font-size: 1.1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.logout-link {
  color: #fff;
  text-decoration: none;
  font-size: 1.3rem;
  opacity: .85;
}
.logout-link:hover { opacity: 1; }
.search-box { padding: .6rem; background: #f0f2f5; }
.search-box input {
  width: 100%;
  padding: .55rem .9rem;
  border: none;
  border-radius: 20px;
  background: #fff;
  font-size: .9rem;
}
.chat-list { overflow-y: auto; flex: 1; }
.chat-item {
  display: flex;
  flex-direction: column;
  padding: .8rem 1rem;
  border-bottom: 1px solid #f0f2f5;
  cursor: pointer;
}
.chat-item:hover { background: #f5f6f6; }
.chat-item.active { background: #e9edef; }
.chat-item-top { display: flex; justify-content: space-between; align-items: baseline; }
.chat-item-name { font-weight: 600; font-size: .95rem; }
.chat-item-time { font-size: .72rem; color: #667781; }
.chat-item-preview {
  font-size: .82rem;
  color: #667781;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: .15rem;
}
.chat-item-badge {
  font-size: .68rem;
  color: #999;
  margin-top: .2rem;
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #efeae2;
}
.chat-header[hidden] { display: none; }
.chat-header {
  background: #f0f2f5;
  padding: .9rem 1.2rem;
  border-bottom: 1px solid #d1d7db;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
#chat-title { font-weight: 600; }
#chat-search-input {
  padding: .4rem .8rem;
  border: 1px solid #ccc;
  border-radius: 20px;
  font-size: .85rem;
  width: 240px;
}
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.2rem 8%;
  display: flex;
  flex-direction: column;
  gap: .3rem;
}
.empty-state {
  margin: auto;
  color: #667781;
  font-size: .95rem;
}
.bubble {
  max-width: 65%;
  padding: .45rem .7rem .35rem;
  border-radius: 8px;
  font-size: .92rem;
  line-height: 1.35;
  position: relative;
  box-shadow: 0 1px 1px rgba(0,0,0,.08);
  word-wrap: break-word;
  white-space: pre-wrap;
}
.bubble.me {
  align-self: flex-end;
  background: #d9fdd3;
}
.bubble.other {
  align-self: flex-start;
  background: #fff;
}
.bubble .sender {
  font-size: .78rem;
  font-weight: 700;
  color: #075e54;
  margin-bottom: .15rem;
  display: block;
}
.bubble .time {
  display: block;
  text-align: right;
  font-size: .68rem;
  color: #667781;
  margin-top: .2rem;
}
.bubble mark { background: #ffe08a; border-radius: 2px; }

.search-results { padding: .5rem 0; }
.search-result-item {
  padding: .7rem 1rem;
  border-bottom: 1px solid #f0f2f5;
  cursor: pointer;
}
.search-result-item:hover { background: #f5f6f6; }
.search-result-chat { font-size: .78rem; color: #075e54; font-weight: 600; }
.search-result-text { font-size: .88rem; margin-top: .15rem; }
.search-result-time { font-size: .7rem; color: #667781; margin-top: .1rem; }

@media (max-width: 720px) {
  .sidebar { width: 100%; }
  .main { display: none; }
  .app.chat-open .sidebar { display: none; }
  .app.chat-open .main { display: flex; }
  #chat-search-input { width: 140px; }
}
