* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #0f1115;
  color: #f0f0f2;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: #171a21;
  border-bottom: 1px solid #262a33;
}

.topbar h1 {
  font-size: 20px;
  margin: 0;
}

.status {
  font-size: 13px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #2a2f3a;
  color: #b7c0d0;
}

.status.searching {
  background: #4a3b12;
  color: #ffcf6b;
}

.status.connected {
  background: #123d24;
  color: #6bffa0;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
  gap: 20px;
  padding: 20px;
  max-width: 1200px;
  margin: 0 auto;
}

.video-area {
  position: relative;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  min-height: 480px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.video-wrap {
  position: absolute;
  inset: 0;
}

.video-wrap video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #14161c;
}

.video-wrap--small {
  inset: auto;
  bottom: 16px;
  right: 16px;
  width: 160px;
  height: 120px;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid #333;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.video-label {
  position: absolute;
  bottom: 6px;
  left: 8px;
  font-size: 11px;
  background: rgba(0, 0, 0, 0.5);
  padding: 2px 8px;
  border-radius: 999px;
}

.controls {
  position: absolute;
  top: 16px;
  left: 16px;
  display: flex;
  gap: 8px;
  z-index: 2;
}

.controls button {
  padding: 10px 18px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  background: #2f6fed;
  color: white;
  transition: opacity 0.15s;
}

.controls button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

#nextBtn {
  background: #e0a83a;
}

#stopBtn {
  background: #e0473a;
}

.chat-area {
  display: flex;
  flex-direction: column;
  background: #171a21;
  border-radius: 12px;
  min-height: 480px;
  overflow: hidden;
}

.messages {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 14px;
}

.msg {
  padding: 8px 12px;
  border-radius: 10px;
  max-width: 85%;
  line-height: 1.4;
  word-wrap: break-word;
}

.msg.me {
  align-self: flex-end;
  background: #2f6fed;
  color: white;
}

.msg.stranger {
  align-self: flex-start;
  background: #262a33;
}

.msg.system {
  align-self: center;
  background: transparent;
  color: #8a94a6;
  font-size: 12px;
  font-style: italic;
}

.chat-form {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid #262a33;
}

.chat-form input {
  flex: 1;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #2a2f3a;
  background: #0f1115;
  color: white;
  font-size: 14px;
}

.chat-form button {
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  background: #2f6fed;
  color: white;
  font-weight: 600;
  cursor: pointer;
}

.chat-form button:disabled,
.chat-form input:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

@media (max-width: 860px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .video-area {
    min-height: 320px;
  }
}
