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

:root {
  --bg: #061719;
  --panel: rgba(12, 26, 29, 0.72);
  --panel-strong: rgba(16, 31, 35, 0.92);
  --line: rgba(255, 255, 255, 0.13);
  --text: #f7fbfb;
  --muted: #a7b7bc;
  --accent: #00bcd4;
  --accent-2: #f19408;
  --danger: #ff6b6b;
  --bubble: rgba(255, 255, 255, 0.1);
  --own: rgba(0, 188, 212, 0.24);
  --radius: 8px;
}

body {
  min-height: 100vh;
  font-family: "Segoe UI", Arial, sans-serif;
  color: var(--text);
  background: linear-gradient(rgba(0, 0, 0, 0.22), rgba(0, 0, 0, 0.55)),
    url("../Assets/bg2.png") no-repeat center 0 fixed;
  background-size: cover;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.chat-shell {
  width: min(1400px, calc(100% - 28px));
  min-height: 100vh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

.chat-header {
  height: 96px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.45rem;
  font-weight: 700;
}

.brand img {
  width: 62px;
  height: 62px;
  object-fit: contain;
}

.chat-nav {
  display: flex;
  gap: 22px;
  font-size: 0.95rem;
  font-weight: 700;
}

.chat-nav a {
  transition: color 0.2s ease, transform 0.2s ease;
}

.chat-nav a:hover {
  color: var(--accent);
  transform: translateY(-1px);
}

.chat-app {
  flex: 1;
  min-height: 0;
  margin-bottom: 22px;
  display: grid;
  grid-template-rows: auto minmax(360px, 1fr) auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  backdrop-filter: blur(18px);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.32);
}

.room-panel {
  padding: 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
}

.room-hero,
.room-meta,
.status-stack {
  display: flex;
  align-items: center;
}

.room-hero {
  justify-content: space-between;
  gap: 18px;
}

.eyebrow {
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.room-hero h1 {
  margin-top: 2px;
  font-size: clamp(1.6rem, 3vw, 2.45rem);
  line-height: 1.1;
}

.status-stack {
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.status-pill,
.online-pill,
.ghost-btn {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 11px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

.status-pill {
  font-size: 0.8rem;
  font-weight: 700;
}

.status-pill.online {
  color: #8df5d1;
}

.status-pill.offline {
  color: #ffd18a;
}

.online-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #40f2a2;
  box-shadow: 0 0 14px rgba(64, 242, 162, 0.9);
}

.room-meta {
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  color: var(--muted);
}

.room-meta span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ghost-btn {
  border: none;
  transition: background 0.2s ease, color 0.2s ease;
}

.ghost-btn:hover {
  color: var(--accent);
  background: rgba(0, 188, 212, 0.12);
}

.messages-panel {
  position: relative;
  min-height: 0;
  overflow-y: auto;
  padding: 18px;
  scroll-behavior: smooth;
}

.messages-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.message {
  width: min(680px, 88%);
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  background: var(--bubble);
  animation: messageIn 0.22s ease both;
}

.message.own {
  align-self: flex-end;
  background: var(--own);
}

.message-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.message-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #ffffff;
  font-size: 0.92rem;
  font-weight: 800;
}

.message-time {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.76rem;
}

.message-text {
  color: #edf7f8;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.message-image {
  width: 100%;
  max-height: 360px;
  margin-top: 8px;
  border-radius: var(--radius);
  object-fit: cover;
  background: rgba(0, 0, 0, 0.24);
}

.typing-indicator {
  min-height: 24px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 4px;
  text-align: center;
  color: var(--muted);
}

.empty-state h2 {
  color: var(--text);
  font-size: 1.3rem;
}

.hidden {
  display: none !important;
}

.skeleton-list {
  display: grid;
  gap: 12px;
}

.skeleton-message {
  width: min(620px, 82%);
  height: 76px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.06));
  background-size: 220% 100%;
  animation: shimmer 1.1s linear infinite;
}

.skeleton-message.short {
  width: min(460px, 64%);
  justify-self: end;
}

.composer {
  position: relative;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  padding: 14px;
  border-top: 1px solid var(--line);
  background: var(--panel-strong);
}

.upload-btn,
.send-btn {
  height: 42px;
  border: none;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #071316;
  font-weight: 800;
  background: var(--accent);
  transition: transform 0.2s ease, filter 0.2s ease;
}

.upload-btn {
  width: 42px;
  font-size: 1.6rem;
}

.upload-btn input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.send-btn {
  min-width: 92px;
  padding: 0 18px;
}

.upload-btn:hover,
.send-btn:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.send-btn:disabled {
  cursor: not-allowed;
  filter: grayscale(1) brightness(0.7);
  transform: none;
}

#messageInput {
  width: 100%;
  max-height: 130px;
  min-height: 42px;
  resize: none;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: none;
  padding: 10px 12px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

#messageInput:focus {
  border-color: rgba(0, 188, 212, 0.72);
}

.image-preview {
  grid-column: 1 / -1;
  position: relative;
  width: 180px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
}

.image-preview img {
  width: 100%;
  height: 120px;
  display: block;
  object-fit: cover;
}

.image-preview button {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 50%;
  color: #fff;
  background: rgba(0, 0, 0, 0.62);
}

.spinner {
  width: 18px;
  height: 18px;
  border: 3px solid rgba(7, 19, 22, 0.25);
  border-top-color: #071316;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(14px);
}

.nickname-card {
  width: min(420px, 100%);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(12, 26, 29, 0.9);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.4);
}

.modal-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  font-weight: 800;
}

.modal-brand img {
  width: 42px;
  height: 42px;
  object-fit: contain;
}

.nickname-card h2 {
  margin-bottom: 4px;
}

.nickname-card p {
  margin-bottom: 18px;
  color: var(--muted);
}

#nicknameForm {
  display: grid;
  gap: 10px;
}

#nicknameForm input,
#nicknameForm button {
  height: 44px;
  border-radius: var(--radius);
}

#nicknameForm input {
  border: 1px solid var(--line);
  outline: none;
  padding: 0 12px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

#nicknameForm button {
  border: none;
  color: #071316;
  font-weight: 800;
  background: var(--accent-2);
}

.toast-stack {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 30;
  display: grid;
  gap: 10px;
}

.toast {
  width: min(360px, calc(100vw - 36px));
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  background: rgba(13, 27, 31, 0.96);
  box-shadow: 0 18px 34px rgba(0, 0, 0, 0.25);
  animation: toastIn 0.2s ease both;
}

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

@keyframes shimmer {
  to {
    background-position: -220% 0;
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

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

@media (max-width: 760px) {
  .chat-shell {
    width: 100%;
  }

  .chat-header {
    height: auto;
    padding: 14px;
    flex-direction: column;
    gap: 10px;
  }

  .chat-nav {
    gap: 14px;
    font-size: 0.84rem;
  }

  .chat-app {
    min-height: calc(100vh - 124px);
    margin: 0;
    border-left: none;
    border-right: none;
    border-radius: 0;
  }

  .room-hero {
    align-items: flex-start;
    flex-direction: column;
  }

  .status-stack {
    justify-content: flex-start;
  }

  .message {
    width: 94%;
  }

  .composer {
    grid-template-columns: 42px minmax(0, 1fr);
  }

  .send-btn {
    grid-column: 1 / -1;
    width: 100%;
  }
}
