* { box-sizing: border-box; }

body {
  margin: 0;
  background: #000;
  color: #00ff88;
  font-family: system-ui, sans-serif;
}

button, input {
  font: inherit;
}

button {
  background: #001b10;
  color: #00ff88;
  border: 1px solid #00ff88;
  border-radius: 10px;
  padding: 10px 14px;
}

input {
  background: #101010;
  color: #eafff5;
  border: 1px solid #003d24;
  border-radius: 999px;
  padding: 12px 16px;
  outline: none;
}

.screen {
  display: none;
  min-height: 100vh;
}

.screen.active {
  display: flex;
}

.login-card {
  width: min(420px, 92vw);
  margin: auto;
  border: 1px solid #00ff88;
  box-shadow: 0 0 35px rgba(0,255,136,.25);
  padding: 26px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-card h1 {
  font-size: 52px;
  margin: 0;
  color: #eafff5;
}

.status {
  color: #8cffc2;
  min-height: 22px;
}

#appScreen.active {
  display: grid;
  grid-template-columns: 360px 1fr;
  width: 100vw;
  height: 100vh;
}

.mx-sidebar {
  border-right: 1px solid #003d24;
  padding: 14px;
  overflow-y: auto;
}

.mx-sidebar header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.mx-sidebar h1 {
  font-size: 38px;
  margin: 0 0 12px;
  color: #eafff5;
}

.room-list {
  margin-top: 14px;
}

.room-row {
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 12px;
  align-items: center;
  padding: 10px;
  border-radius: 14px;
  cursor: pointer;
}

.room-row:hover {
  background: #06160f;
}

.room-name {
  color: #eafff5;
  font-weight: 700;
  font-size: 18px;
}

.room-preview {
  color: #8cffc2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #002b19;
  border: 2px solid #00ff88;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #00ff88;
  font-weight: 800;
}

.avatar.small {
  width: 44px;
  height: 44px;
}

.mx-chat {
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.chat-topbar {
  height: 72px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid #003d24;
  padding: 10px 14px;
}

.chat-title {
  min-width: 0;
}

.chat-title div {
  color: #eafff5;
  font-size: 20px;
  font-weight: 700;
}

.chat-title small {
  color: #8cffc2;
}

.message-area {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background:
    radial-gradient(circle at top right, rgba(0,255,136,.08), transparent 38%),
    #000;
}

.msg {
  max-width: 70%;
  margin: 8px 0;
  padding: 11px 14px;
  border-radius: 18px;
  word-break: break-word;
}

.mine {
  margin-left: auto;
  background: #005f38;
  color: #fff;
  border-bottom-right-radius: 5px;
}

.theirs {
  margin-right: auto;
  background: #101010;
  border: 1px solid #003d24;
  color: #eafff5;
  border-bottom-left-radius: 5px;
}

.meta {
  opacity: .55;
  font-size: 11px;
  margin-top: 4px;
}

.composer {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid #003d24;
}

.composer input {
  flex: 1;
  min-width: 0;
}

.mobile-back {
  display: none;
}

@media (max-width: 760px) {
  #appScreen.active {
    display: block;
  }

  .mx-sidebar {
    height: 100vh;
    border-right: none;
  }

  .mx-chat {
    display: none;
  }

  body.chat-open .mx-sidebar {
    display: none;
  }

  body.chat-open .mx-chat {
    display: flex;
  }

  .mobile-back {
    display: inline-block;
  }

  .msg {
    max-width: 82%;
  }
}

.sidebar-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.sidebar-actions {
  display: flex;
  gap: 8px;
}

.sidebar-actions button {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  padding: 0;
}

#sessionInfo {
  color: #8cffc2;
  opacity: .8;
}

.search-box {
  margin-bottom: 14px;
}

.search-box input {
  width: 100%;
}

.room-row {
  transition: .15s;
  border: 1px solid transparent;
}

.room-row.active {
  background: #072115;
  border-color: #00ff88;
}

.room-row:hover {
  transform: translateX(2px);
}

.room-preview {
  margin-top: 3px;
  font-size: 14px;
}

.message-area {
  display: flex;
  flex-direction: column;
}

.msg {
  animation: msgIn .12s ease;
}

@keyframes msgIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.theirs::before {
  content: "";
  display: block;
  font-size: 12px;
  color: #8cffc2;
  margin-bottom: 5px;
}

.composer {
  background: #050505;
}

.icon-btn,
.send-btn {
  width: 52px;
  min-width: 52px;
  border-radius: 50%;
  padding: 0;
  font-size: 20px;
}

#messageInput {
  font-size: 16px;
}

.chat-topbar {
  background: #020202;
  position: sticky;
  top: 0;
  z-index: 20;
}

@media (max-width: 760px) {

  .mx-sidebar {
    padding: 10px;
  }

  .mx-sidebar h1 {
    font-size: 32px;
  }

  .room-row {
    padding: 12px 8px;
  }

  .msg {
    max-width: 88%;
  }

  .composer {
    position: sticky;
    bottom: 0;
    background: #000;
  }
}

.room-menu {
  position: fixed;
  width: 220px;
  background: #050505;
  border: 1px solid #00ff88;
  border-radius: 14px;
  overflow: hidden;
  z-index: 9999;
  box-shadow: 0 12px 40px rgba(0,0,0,.55);
}

.room-menu.hidden {
  display: none;
}

.room-menu button {
  width: 100%;
  text-align: left;
  border: none;
  border-bottom: 1px solid #002b19;
  border-radius: 0;
  background: transparent;
  padding: 14px;
}

.room-menu button:hover {
  background: #072115;
}

.room-menu button.danger {
  color: #ff7d7d;
}
