* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, sans-serif;
  background: #1a1a2e;
  color: #eee;
  min-height: 100vh;
}

.container {
  max-width: 360px;
  margin: 2rem auto;
  padding: 1.5rem;
  background: #16213e;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

h1 {
  margin: 0 0 0.25rem;
  font-size: 1.5rem;
  text-align: center;
}

.subtitle {
  margin: 0 0 1.25rem;
  font-size: 0.875rem;
  color: #888;
  text-align: center;
}

.tabs {
  display: flex;
  gap: 0;
  margin-bottom: 1rem;
}

.tab {
  flex: 1;
  padding: 0.6rem 1rem;
  border: 1px solid #0f3460;
  background: #0f3460;
  color: #aaa;
  cursor: pointer;
  font-size: 0.95rem;
  border-radius: 8px 8px 0 0;
}

.tab.active {
  background: #1a1a2e;
  color: #fff;
  border-bottom-color: #1a1a2e;
}

.form {
  display: none;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem 0;
}

.form.active {
  display: flex;
}

.form input {
  padding: 0.65rem 0.85rem;
  border: 1px solid #0f3460;
  border-radius: 8px;
  background: #1a1a2e;
  color: #fff;
  font-size: 1rem;
}

.form input::placeholder {
  color: #666;
}

.form button {
  padding: 0.7rem;
  background: #e94560;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
}

.form button:hover {
  background: #ff6b6b;
}

.error {
  color: #e94560;
  font-size: 0.875rem;
  margin: 0;
}

.hidden {
  display: none !important;
}

/* Chat layout */
.chat-layout {
  display: flex;
  height: 100vh;
  background: #0f1725;
}

.users-panel {
  width: 320px;
  background: #17212b;
  border-right: 1px solid #0f1a26;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sidebar-top {
  padding: 1rem 1rem 0.8rem;
  border-bottom: 1px solid #223041;
}

.sidebar-title {
  font-weight: 700;
  font-size: 1.05rem;
  color: #f5f7fb;
}

.sidebar-subtitle {
  margin-top: 0.35rem;
  color: #98a7ba;
  font-size: 0.88rem;
}

.users-panel ul {
  list-style: none;
  margin: 0;
  padding: 0.35rem 0;
  flex: 1;
  overflow-y: auto;
}

.user-item {
  padding: 0.75rem 1rem;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  transition: background 0.15s ease;
}

.user-item .name {
  font-weight: 500;
  color: #f0f4f8;
}

.user-item:hover,
.user-item.selected {
  background: #2b5278;
}

.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: radial-gradient(circle at center, #233347 0%, #182533 65%);
  min-height: 0;
}

.chat-header {
  display: flex;
  align-items: center;
  min-height: 62px;
  padding: 0 1rem;
  background: #17212b;
  border-bottom: 1px solid #0f1a26;
  color: #f5f7fb;
  font-weight: 600;
}

.messages-list {
  flex: 1;
  overflow-y: auto;
  list-style: none;
  margin: 0;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.messages-list li {
  max-width: 72%;
  padding: 0.5rem 0.78rem;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.25);
}

.messages-list li.sent {
  align-self: flex-end;
  background: #2b5278;
  color: #ecf3fb;
  border-bottom-right-radius: 4px;
}

.messages-list li.received {
  align-self: flex-start;
  background: #233447;
  color: #ecf3fb;
  border-bottom-left-radius: 4px;
}

.messages-list .who {
  font-size: 0.72rem;
  opacity: 0.85;
}

.messages-list .text {
  word-break: break-word;
  line-height: 1.35;
}

.input-row {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1rem 0.9rem;
  background: #17212b;
  border-top: 1px solid #0f1a26;
}

.input-row input {
  flex: 1;
  padding: 0.62rem 0.9rem;
  border: 1px solid #2a3e54;
  border-radius: 20px;
  background: #0f1725;
  color: #e9eef4;
  font-size: 1rem;
}

.input-row button {
  padding: 0.6rem 1.1rem;
  background: #3390ec;
  color: #fff;
  border: none;
  border-radius: 18px;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
}

.input-row button:hover {
  background: #45a0fb;
}

.logout {
  margin: 0.6rem 1rem 1rem;
  text-align: center;
  color: #8ea4bd;
  text-decoration: none;
  font-size: 0.88rem;
}

.logout:hover {
  color: #d5e7fb;
}

@media (max-width: 900px) {
  .users-panel {
    width: 250px;
  }
}
