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

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background-color: #f5f5f5;
  color: #0e75d6;
  display: flex;
  flex-direction: column;
}

/* HEADER */
.topbar {
  background: white;
  color: #0e75d6;
  padding: 12px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  width: 36px;
  height: 36px;
  background: white;
  border-radius: 50%;
  display: inline-block;
}

.brand h1 {
  font-size: 22px;
  font-weight: 700;
  margin: 0;
}

.right {
  display: flex;
  align-items: center;
  gap: 15px;
  font-size: 14px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #fbbf24;
  display: inline-block;
}

.status-dot.connected {
  background: #10b981;
}

.status-text {
  font-weight: 600;
}

.online-count {
  background: rgba(255, 255, 255, 0.2);
  padding: 6px 12px;
  border-radius: 20px;
  font-weight: 600;
}

/* MAIN APP */
.app {
  display: grid;
  grid-template-columns: 1fr 400px;
  gap: 15px;
  padding: 15px;
  flex: 1;
  overflow: hidden;
  max-width: 1800px;
  margin: 0 auto;
  width: 100%;
}

.panel {
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  overflow: hidden;
}

/* VIDEO SECTION */
.video.panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
  overflow: hidden;
}

.remote.video-box {
  position: relative;
  background: #1a1a1a;
  border-radius: 12px;
  overflow: hidden;
  flex: 1;
  min-height: 0;
}

.remote video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.bottom-row {
  display: flex;
  gap: 12px;
  flex-shrink: 0;
}

.local.video-box {
  position: relative;
  background: #1a1a1a;
  border-radius: 12px;
  overflow: hidden;
  width: 280px;
  height: 160px;
  flex-shrink: 0;
}

.local video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.name-tag {
  position: absolute;
  bottom: 10px;
  left: 10px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
}

/* CONTROLS */
.controls.panel {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 12px;
  background: white;
  flex: 1;
}

.spacer {
  grid-column: 1 / -1;
  height: 0;
}

.btn {
  padding: 12px 20px;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  background: #e5e7eb;
  color: #374151;
  width: 100%;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn.primary {
  background: #0e75d6;
  color: white;
}

.btn.primary:hover {
  background: #0a5cb8;
}

.btn.icon {
  font-size: 20px;
  padding: 10px;
}

/* CHAT SIDEBAR */
.side.panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

.msg {
  padding: 10px 14px;
  border-radius: 12px;
  max-width: 85%;
  word-wrap: break-word;
  font-size: 14px;
  line-height: 1.5;
}

.msg.sys {
  background: #fef3c7;
  color: #92400e;
  align-self: center;
  text-align: center;
  font-weight: 500;
  max-width: 100%;
}

.msg.you {
  background: #0e75d6;
  color: white;
  align-self: flex-end;
}

.msg.stranger {
  background: #e5e7eb;
  color: #374151;
  align-self: flex-start;
}

/* COMPOSER */
.composer {
  display: flex;
  gap: 10px;
  padding: 12px;
  border-top: 1px solid #e5e7eb;
  background: #f9fafb;
  flex-shrink: 0;
}

.composer input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.3s ease;
}

.composer input:focus {
  border-color: #0e75d6;
}

.composer button {
  padding: 10px 20px;
}

/* FOOTER */
.foot {
  background: #f9fafb;
  padding: 8px;
  text-align: center;
  color: #6b7280;
  font-size: 12px;
  border-top: 1px solid #e5e7eb;
  flex-shrink: 0;
}

/* LARGE DESKTOP */
@media (min-width: 1400px) {
  .app {
    grid-template-columns: 1fr 450px;
    gap: 20px;
    padding: 20px;
  }

  .local.video-box {
    width: 320px;
    height: 180px;
  }
}

/* TABLET LANDSCAPE */
@media (max-width: 1200px) {
  .app {
    grid-template-columns: 1fr 350px;
  }

  .local.video-box {
    width: 240px;
    height: 140px;
  }

  .btn {
    padding: 10px 16px;
    font-size: 14px;
  }
}

/* TABLET PORTRAIT */
@media (max-width: 968px) {
  html,
  body {
    overflow: auto;
  }

  .app {
    grid-template-columns: 1fr;
    overflow: visible;
  }

  .video.panel {
    min-height: 500px;
  }

  .remote.video-box {
    min-height: 300px;
  }

  .bottom-row {
    flex-direction: column;
  }

  .local.video-box {
    width: 100%;
    height: auto;
    aspect-ratio: 16/9;
  }

  .controls.panel {
    width: 100%;
  }

  .side.panel {
    min-height: 400px;
  }

  .messages {
    min-height: 300px;
  }
}

/* MOBILE */
@media (max-width: 640px) {
  .topbar {
    padding: 10px 15px;
  }

  .brand {
    gap: 8px;
  }

  .logo {
    width: 30px;
    height: 30px;
  }

  .brand h1 {
    font-size: 18px;
  }

  .right {
    gap: 10px;
    font-size: 12px;
  }

  .online-count {
    display: inline-block;
    padding: 4px 8px;
    font-size: 11px;
  }

  .app {
    padding: 10px;
    gap: 10px;
  }

  .video.panel {
    padding: 10px;
    gap: 10px;
    min-height: 450px;
  }

  .remote.video-box {
    min-height: 250px;
  }

  .controls.panel {
    padding: 10px;
    gap: 8px;
  }

  .btn {
    padding: 10px 14px;
    font-size: 13px;
  }

  .composer input {
    padding: 10px 12px;
    font-size: 14px;
  }

  .composer button {
    padding: 10px 16px;
    font-size: 13px;
  }

  .name-tag {
    font-size: 12px;
    padding: 4px 10px;
  }

  .msg {
    font-size: 13px;
  }
}

/* SMALL MOBILE */
@media (max-width: 380px) {
  .brand h1 {
    font-size: 16px;
  }

  .controls.panel {
    gap: 6px;
  }

  .btn {
    padding: 8px 10px;
    font-size: 12px;
  }
}