* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body, html {
  height: 100%;
  font-family: 'JetBrains Mono', monospace;
  background: #000;
  color: #fff;
  overflow: hidden;
}

.chat-app {
  display: flex;
  height: 100vh;
  position: relative;
}

/* Sidebar */
.sidebar {
  width: 320px;
  background: #000;
  border-right: 1px solid #333;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 10;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-header {
  padding: 24px 20px;
  border-bottom: 1px solid #333;
  background: #000;
  position: relative;
}

.logo {
  font-size: 1.8rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 3px;
  text-align: center;
  margin-bottom: 12px;
}

.logo::before {
  content: ">";
  margin-right: 8px;
  color: #666;
}

.relay-status {
  font-size: 0.85rem;
  color: #666;
  text-align: center;
  margin-top: 8px;
  padding: 4px 8px;
  background: #111;
  border-radius: 6px;
  display: inline-block;
  width: 100%;
}

.sidebar-toggle {
  display: none;
  position: absolute;
  top: 24px;
  right: 20px;
  background: none;
  border: none;
  color: #fff;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 8px;
  border-radius: 6px;
  transition: background 0.2s;
}

.sidebar-toggle:hover {
  background: #111;
}

.user-list-section {
  flex: 1;
  overflow-y: auto;
  padding: 0 20px;
}

.user-list-title {
  font-size: 0.8rem;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 20px 0 12px 0;
  font-weight: 600;
}

.user-list {
  list-style: none;
}

.user-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid #111;
  cursor: pointer;
  transition: background 0.2s;
  border-radius: 8px;
  margin-bottom: 2px;
}

.user-list li:hover {
  background: #111;
  padding-left: 12px;
  padding-right: 12px;
}

.user-list li::before {
  content: attr(data-initial);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #333;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
}

/* Main Chat Area */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #000;
  min-width: 0;
}

.chat-header {
  padding: 20px 24px;
  border-bottom: 1px solid #333;
  background: #000;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#room-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: #fff;
}

#room-title::before {
  content: "#";
  color: #666;
  margin-right: 4px;
}

.user-count {
  font-size: 0.85rem;
  color: #666;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: #000;
  scroll-behavior: smooth;
}

.message {
  display: flex;
  flex-direction: column;
  animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message .msg-meta {
  font-size: 0.75rem;
  color: #666;
  margin-bottom: 4px;
}

.message .msg-user {
  font-weight: 600;
  font-size: 0.9rem;
  color: #fff;
  margin-right: 8px;
}

.message .msg-text {
  background: #111;
  padding: 12px 16px;
  border-radius: 12px;
  border-top-left-radius: 4px;
  font-size: 0.95rem;
  line-height: 1.4;
  color: #fff;
  word-wrap: break-word;
  max-width: 70%;
  margin-top: 4px;
  display: inline-block;
}

.message.system .msg-text {
  background: transparent;
  color: #666;
  font-style: italic;
  text-align: center;
  margin: 0 auto;
  font-size: 0.85rem;
  max-width: 100%;
}

.message.system .msg-user {
  color: #666;
}

.message.whisper .msg-text {
  background: #1a1a1a;
  border-left: 3px solid #666;
  border-radius: 0 12px 12px 0;
}

.message.whisper .msg-user {
  color: #999;
}

.typing-indicator {
  min-height: 20px;
  color: #666;
  font-size: 0.85rem;
  padding: 0 24px 16px 24px;
  font-style: italic;
}

.chat-form {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #111;
  border: 1px solid #333;
  border-radius: 24px;
  padding: 4px 4px 4px 20px;
  margin: 20px 24px;
  transition: border-color 0.2s;
}

.chat-form:focus-within {
  border-color: #fff;
}

.input-prompt {
  color: #666;
  font-size: 0.9rem;
  font-weight: 500;
  flex-shrink: 0;
}

.chat-input {
  flex: 1;
  background: transparent;
  border: none;
  color: #fff;
  font-size: 0.95rem;
  padding: 12px 8px;
  outline: none;
  font-family: 'JetBrains Mono', monospace;
}

.chat-input::placeholder {
  color: #666;
}

.send-btn {
  background: #fff;
  color: #000;
  border: none;
  border-radius: 20px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 600;
  font-size: 0.9rem;
}

.send-btn:hover {
  background: #f0f0f0;
  transform: scale(1.05);
}

.send-btn:active {
  transform: scale(0.95);
}

/* Mobile Responsive */
@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    left: -100%;
    top: 0;
    height: 100vh;
    width: 100%;
    max-width: 320px;
    z-index: 100;
    background: #000;
    border-right: none;
    box-shadow: 2px 0 20px rgba(0,0,0,0.5);
  }

  .sidebar.open {
    transform: translateX(100%);
  }

  .sidebar-toggle {
    display: block;
  }

  .chat-header {
    padding: 16px 20px;
  }

  .chat-messages {
    padding: 16px 20px;
  }

  .chat-form {
    margin: 16px 20px;
  }

  .message .msg-text {
    max-width: 85%;
  }

  .user-count {
    display: none;
  }
}

@media (max-width: 700px) {
  .logo {
    font-size: 1.5rem;
  }

  .sidebar-header {
    padding: 20px 16px;
  }

  .user-list-section {
    padding: 0 16px;
  }

  .chat-messages {
    padding: 12px 16px;
    gap: 12px;
  }

  .message .msg-text {
    max-width: 90%;
    padding: 10px 14px;
  }

  .chat-form {
    margin: 12px 16px;
    padding: 2px 2px 2px 16px;
  }

  .send-btn {
    width: 36px;
    height: 36px;
  }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: #000;
}

::-webkit-scrollbar-thumb {
  background: #333;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #444;
}

/* Overlay for mobile sidebar */
.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  z-index: 50;
  display: none;
}

.session-info {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 20px;
  background: #111;
  color: #00ff99;
  font-size: 1rem;
  border-bottom: 1px solid #222;
}
#session-username {
  font-weight: bold;
}
#session-timer {
  color: #fff;
  background: #222;
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 0.95rem;
}
#user-history-btn {
  background: #00ff99;
  color: #000;
  border: none;
  border-radius: 4px;
  padding: 4px 10px;
  cursor: pointer;
  font-weight: 600;
}
#user-history-btn:hover {
  background: #00c3ff;
  color: #fff;
}
.modal {
  position: fixed;
  z-index: 200;
  left: 0; top: 0; width: 100vw; height: 100vh;
  background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn 0.2s;
}
.modal-content {
  background: #181820;
  padding: 32px 24px 24px 24px;
  border-radius: 16px;
  min-width: 340px;
  max-width: 95vw;
  max-height: 80vh;
  color: #fff;
  position: relative;
  box-shadow: 0 8px 32px rgba(0,0,0,0.7);
  display: flex;
  flex-direction: column;
  align-items: stretch;
}
.close {
  position: absolute;
  right: 16px; top: 16px;
  font-size: 1.7rem;
  cursor: pointer;
  color: #00ff99;
  background: none;
  border: none;
  transition: color 0.2s;
}
.close:hover {
  color: #00c3ff;
}
.user-history-header {
  font-size: 1.3rem;
  font-weight: 700;
  color: #00ff99;
  margin-bottom: 12px;
  text-align: center;
  letter-spacing: 1px;
}
.user-history-search {
  margin-bottom: 16px;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid #333;
  background: #111;
  color: #fff;
  font-size: 1rem;
  outline: none;
  width: 100%;
}
.user-history-list {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 40vh;
  overflow-y: auto;
  border-top: 1px solid #222;
  border-bottom: 1px solid #222;
}
.user-history-item {
  padding: 10px 0;
  border-bottom: 1px solid #222;
  font-size: 1rem;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background 0.2s;
}
.user-history-item:last-child {
  border-bottom: none;
}
.user-history-highlight {
  background: #00ff99;
  color: #181820;
  border-radius: 6px;
  padding: 2px 8px;
  font-weight: 700;
}
.user-history-timestamp {
  color: #00c3ff;
  font-size: 0.95rem;
  margin-left: auto;
}
@media (max-width: 600px) {
  .modal-content {
    min-width: 90vw;
    padding: 18px 6px 12px 6px;
  }
  .user-history-header {
    font-size: 1.1rem;
  }
}