* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #111;
  color: #eee;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hidden {
  display: none !important;
}

/* ── Login ── */

#login-screen {
  width: 100%;
  max-width: 340px;
  padding: 2rem;
}

#login-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

#login-form h1 {
  font-size: 2rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  letter-spacing: -0.02em;
}

#login-form input {
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  color: #eee;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.15s;
}

#login-form input:focus {
  border-color: #555;
}

#login-form button {
  background: #eee;
  color: #111;
  border: none;
  border-radius: 8px;
  padding: 0.75rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

#login-form button:hover {
  opacity: 0.85;
}

#login-error {
  color: #e44;
  font-size: 0.85rem;
  min-height: 1.2em;
}

/* ── Chat ── */

#chat-screen {
  display: flex;
  width: 100vw;
  height: 100vh;
}

/* Sidebar */
#sidebar {
  width: 220px;
  background: #0d0d0d;
  border-right: 1px solid #222;
  display: flex;
  flex-direction: column;
  padding: 1rem;
  flex-shrink: 0;
}

#sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

#sidebar-header h2 {
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

#logout-btn {
  background: none;
  border: 1px solid #333;
  color: #888;
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

#logout-btn:hover {
  color: #e44;
  border-color: #e44;
}

#online-count {
  font-size: 0.75rem;
  color: #666;
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

#user-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

#user-list li {
  font-size: 0.85rem;
  color: #aaa;
  padding: 0.25rem 0;
}

#user-list li::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  background: #3c3;
  border-radius: 50%;
  margin-right: 0.5rem;
  vertical-align: middle;
}

/* Main */
#main {
  flex: 1;
  display: flex;
  flex-direction: column;
}

#messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

#messages .msg {
  max-width: 72%;
  padding: 0.5rem 0.9rem;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.4;
  word-break: break-word;
}

#messages .msg.own {
  align-self: flex-end;
  background: #2a2a2a;
  border-bottom-right-radius: 4px;
}

#messages .msg.other {
  align-self: flex-start;
  background: #1a1a1a;
  border-bottom-left-radius: 4px;
}

#messages .msg .nick {
  font-size: 0.7rem;
  color: #666;
  margin-bottom: 0.15rem;
}

#messages .msg {
  position: relative;
}

.del-btn {
  position: absolute;
  top: 2px;
  right: 2px;
  background: none;
  border: none;
  color: #555;
  font-size: 0.7rem;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 3px;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
}

.msg:hover .del-btn {
  opacity: 1;
}

.del-btn:hover {
  color: #e44;
  background: #222;
}

#messages .msg .time {
  font-size: 0.6rem;
  color: #555;
  text-align: right;
  margin-top: 0.15rem;
}

#messages .msg.system {
  align-self: center;
  background: none;
  font-size: 0.75rem;
  color: #555;
  padding: 0.25rem 0;
}

#message-form {
  display: flex;
  gap: 0.5rem;
  padding: 1rem 2rem;
  border-top: 1px solid #222;
  background: #0d0d0d;
}

#message-input {
  flex: 1;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 8px;
  padding: 0.7rem 1rem;
  color: #eee;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s;
}

#message-input:focus {
  border-color: #555;
}

#message-form button {
  background: #eee;
  color: #111;
  border: none;
  border-radius: 8px;
  padding: 0.7rem 1.2rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

#message-form button:hover {
  opacity: 0.85;
}

@media (max-width: 600px) {
  #sidebar {
    display: none;
  }
  #messages {
    padding: 1rem;
  }
  #message-form {
    padding: 0.75rem 1rem;
  }
}
