* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.4s ease;
  background-color: #0f172a;
  background-size: cover;
  background-position: center;
  background-repeat: repeat;
}

/* === ВАШИ ПАТТЕРНЫ ФОНА === */
body.bg-space {
  background-color: #050515;
  background-image: radial-gradient(white, rgba(255,255,255,.2) 2px, transparent 40px), 
                    radial-gradient(white, rgba(255,255,255,.15) 1px, transparent 30px);
  background-size: 550px 550px, 350px 350px;
}

body.bg-hearts {
  background-color: #1a0b2e;
  background-image: radial-gradient(#ec4899 1px, transparent 1px), radial-gradient(#ec4899 1px, #1a0b2e 1px);
  background-size: 40px 40px;
  background-position: 0 0, 20px 20px;
}

body.bg-kids {
  background-color: #2e1065;
  background-image: radial-gradient(#38bdf8 2px, transparent 2px), radial-gradient(#a855f7 2px, #2e1065 2px);
  background-size: 30px 30px;
  background-position: 0 0, 15px 15px;
}

body.bg-none {
  background: #111827;
}

/* Контейнер приложения */
.app-container {
  width: 100vw;
  height: 100dvh;
  background: rgba(30, 27, 46, 0.92);
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: row;
  overflow: hidden;
}

@media (min-width: 768px) {
  .app-container {
    width: 90vw;
    max-width: 1200px;
    height: 85vh;
    border-radius: 16px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
  }
}

/* Боковое меню */
.sidebar {
  width: 300px;
  min-width: 300px;
  background: rgba(23, 20, 36, 0.95);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
}

@media (max-width: 767px) {
  .app-container {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    min-width: 100%;
    max-height: 42vh;
    border-right: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding: 12px;
    gap: 10px;
  }
}

.brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: white;
  font-weight: bold;
  font-size: 18px;
}

.badge {
  font-size: 10px;
  background: rgba(168, 85, 247, 0.2);
  color: #c084fc;
  padding: 2px 6px;
  border-radius: 10px;
  border: 1px solid rgba(168, 85, 247, 0.3);
}

.panel-section {
  background: rgba(255, 255, 255, 0.03);
  padding: 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.panel-section h3 {
  font-size: 11px;
  color: #94a3b8;
  margin-bottom: 8px;
  text-transform: uppercase;
}

.bg-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.bg-btn {
  padding: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #cbd5e1;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  text-align: center;
}

.bg-btn.active {
  background: #a855f7;
  color: #fff;
  border-color: #c084fc;
}

.connect-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.connect-box input {
  width: 100%;
  padding: 10px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: #fff;
  font-size: 12px;
  outline: none;
}

.connect-box button, .btn-action {
  padding: 10px;
  background: #a855f7;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 12px;
  width: 100%;
}

.btn-action.clear {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  font-size: 12px;
  color: #94a3b8;
}

.dot {
  width: 8px;
  height: 8px;
  background: #ef4444;
  border-radius: 50%;
}

.dot.connected {
  background: #22c55e;
}

/* Чат зона */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: rgba(15, 12, 29, 0.6);
  min-width: 0;
  height: 100%;
}

.chat-header {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #a855f7;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: bold;
}

.chat-info h2 { font-size: 14px; color: #fff; }
.chat-info span { font-size: 11px; color: #64748b; }

.messages-container {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.empty-state {
  margin: auto;
  color: #64748b;
  font-size: 13px;
  text-align: center;
}

.message {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  word-break: break-word;
}

.message .author {
  font-size: 10px;
  opacity: 0.7;
  margin-bottom: 2px;
}

.message.my {
  align-self: flex-end;
  background: #a855f7;
  color: #fff;
}

.message.peer {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.1);
  color: #f1f5f9;
}

.chat-input-area {
  padding: 12px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  gap: 8px;
  background: rgba(23, 20, 36, 0.95);
}

.chat-input-area input {
  flex: 1;
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  color: #fff;
  outline: none;
  font-size: 14px;
}

.chat-input-area button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #a855f7;
  border: none;
  color: white;
  cursor: pointer;
}