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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: linear-gradient(135deg, #08081a 0%, #12122a 40%, #1a0a2e 70%, #0d0d20 100%);
  color: #f0f0f5;
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.hidden {
  display: none !important;
}

/* ── Glass base ── */
.glass {
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

/* ── Join Screen ── */
#join-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  height: 100dvh;
  padding: 20px;
  position: relative;
}

#join-screen::before {
  content: '';
  position: absolute;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(91,154,255,0.08) 0%, transparent 70%);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.join-card {
  padding: 44px 40px 40px;
  border-radius: 24px;
  width: 380px;
  max-width: 100%;
  text-align: center;
  box-shadow: 0 12px 48px rgba(0,0,0,0.4), 0 1px 0 rgba(255,255,255,0.05) inset;
  position: relative;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-bottom: 6px;
}

.brand-icon {
  width: 38px;
  height: 38px;
  color: #5b9aff;
  flex-shrink: 0;
  filter: drop-shadow(0 0 12px rgba(91,154,255,0.3));
}

.brand-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.1;
}

.brand-name {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 2px;
  color: #fff;
}

.brand-name.accent {
  color: #5b9aff;
  letter-spacing: 3px;
}

.join-card .subtitle {
  font-size: 13px;
  color: rgba(255,255,255,0.3);
  margin-bottom: 28px;
  margin-top: 4px;
}

.join-card input {
  width: 100%;
  padding: 14px 16px;
  margin-bottom: 10px;
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 12px;
  background: rgba(0,0,0,0.25);
  color: #f0f0f5;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.25s, box-shadow 0.25s;
}

.join-card input:focus {
  border-color: rgba(91, 154, 255, 0.3);
  box-shadow: 0 0 0 3px rgba(91, 154, 255, 0.08);
}

.join-card input::placeholder {
  color: rgba(255,255,255,0.18);
}

.btn-primary {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #5b9aff, #3a7bd5);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s, box-shadow 0.25s;
  margin-top: 4px;
}

.btn-primary:hover {
  opacity: 0.92;
  box-shadow: 0 4px 24px rgba(91,154,255,0.25);
}

.btn-primary:active {
  transform: scale(0.97);
}

/* ── Room Layout ── */
#chat-room {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

/* ── Header ── */
header.glass {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  z-index: 5;
}

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

.header-brand {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: rgba(255,255,255,0.4);
}

.header-sep {
  width: 1px;
  height: 16px;
  background: rgba(255,255,255,0.08);
}

#room-title {
  font-size: 13px;
  font-weight: 500;
  color: rgba(255,255,255,0.5);
}

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

/* ── Icon Buttons ── */
.icon-btn {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 10px;
  background: rgba(255,255,255,0.03);
  cursor: pointer;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-btn svg {
  width: 18px;
  height: 18px;
  stroke: rgba(255,255,255,0.35);
  transition: stroke 0.2s;
}

.icon-btn:hover {
  background: rgba(255,255,255,0.07);
}

.icon-btn:hover svg {
  stroke: rgba(255,255,255,0.7);
}

.icon-btn.danger:hover {
  background: rgba(255, 71, 87, 0.12);
}

.icon-btn.danger:hover svg {
  stroke: #ff4757;
}

/* ── Main ── */
main {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
}

/* ── Video Grid ── */
#video-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
  padding: 12px;
  align-content: start;
  overflow-y: auto;
}

.video-container {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  background: rgba(0,0,0,0.35);
  aspect-ratio: 4 / 3;
  border: 1px solid rgba(255,255,255,0.04);
  box-shadow: 0 4px 24px rgba(0,0,0,0.25);
}

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

.audio-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-size: 40px;
  background: rgba(0,0,0,0.15);
  color: rgba(255,255,255,0.06);
  user-select: none;
}

.video-container.speaking {
  border-color: rgba(91, 154, 255, 0.5);
  box-shadow: 0 0 24px rgba(91, 154, 255, 0.25), 0 0 48px rgba(91, 154, 255, 0.06);
  transition: border-color 0.1s, box-shadow 0.1s;
}

.video-container.speaking .audio-placeholder {
  color: rgba(91, 154, 255, 0.2);
}

.video-label {
  position: absolute;
  bottom: 10px;
  left: 10px;
  padding: 4px 12px;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 8px;
  font-size: 11px;
  font-weight: 500;
  color: rgba(255,255,255,0.6);
  pointer-events: none;
  border: 1px solid rgba(255,255,255,0.04);
}

/* ── Chat Panel ── */
#chat-panel {
  width: 300px;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  border-left: 1px solid rgba(255,255,255,0.05);
}

.chat-header {
  padding: 14px 16px 12px;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.5px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  flex-shrink: 0;
  color: rgba(255,255,255,0.5);
}

#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.message {
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
  color: rgba(255,255,255,0.6);
  padding: 6px 0;
}

.message strong {
  color: #7ab7ff;
  margin-right: 6px;
  font-weight: 600;
}

.chat-input-wrap {
  padding: 10px 12px;
  flex-shrink: 0;
}

#chat-input {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 12px;
  background: rgba(0,0,0,0.2);
  color: #f0f0f5;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

#chat-input:focus {
  border-color: rgba(91, 154, 255, 0.25);
}

#chat-input::placeholder {
  color: rgba(255,255,255,0.15);
}

/* ── Controls Bar ── */
footer.glass {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 12px 20px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  flex-shrink: 0;
  border-top: 1px solid rgba(255,255,255,0.04);
  z-index: 5;
}

.control-btn {
  width: 52px;
  height: 52px;
  border: none;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
  cursor: pointer;
  transition: background 0.25s, box-shadow 0.25s, transform 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.control-btn svg {
  width: 22px;
  height: 22px;
  stroke: rgba(255,255,255,0.85);
  transition: stroke 0.25s;
}

.control-btn:hover {
  background: rgba(255,255,255,0.18);
}

.control-btn:hover svg {
  stroke: #fff;
}

.control-btn:active {
  transform: scale(0.92);
}

/* Mute active (muted) */
.control-btn.active {
  background: rgba(255, 71, 87, 0.2);
  box-shadow: 0 0 20px rgba(255, 71, 87, 0.25);
}

.control-btn.active svg {
  stroke: #ff4757;
}

.control-btn .icon-off {
  display: none;
}

.control-btn.active .icon-on {
  display: none;
}

.control-btn.active .icon-off {
  display: block;
}

/* Video active (camera on) */
#video-btn.active {
  background: rgba(91, 154, 255, 0.2);
  box-shadow: 0 0 20px rgba(91, 154, 255, 0.25);
}

#video-btn.active svg {
  stroke: #5b9aff;
}

/* ── Scrollbar ── */
#video-grid::-webkit-scrollbar,
#chat-messages::-webkit-scrollbar {
  width: 3px;
}

#video-grid::-webkit-scrollbar-thumb,
#chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.06);
  border-radius: 2px;
}

#video-grid::-webkit-scrollbar-track,
#chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  #chat-panel {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 260px;
    z-index: 10;
  }

  #video-grid {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 8px;
  }

  .video-container {
    aspect-ratio: 4 / 3;
  }

  .join-card {
    padding: 32px 24px 28px;
  }

  .brand-icon {
    width: 32px;
    height: 32px;
  }

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

  .control-btn {
    width: 48px;
    height: 48px;
  }

  .control-btn svg {
    width: 20px;
    height: 20px;
  }

  footer.glass {
    gap: 16px;
    padding: 10px 16px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
  }

  header.glass {
    padding: 8px 14px;
  }

  .header-brand {
    font-size: 10px;
  }
}

@media (max-width: 480px) {
  #video-grid {
    gap: 6px;
    padding: 6px;
  }

  .video-container {
    border-radius: 12px;
  }

  .control-btn {
    width: 44px;
    height: 44px;
  }

  .control-btn svg {
    width: 18px;
    height: 18px;
  }

  footer.glass {
    gap: 14px;
    padding: 8px 12px;
  }
}

@media (min-width: 1200px) {
  #video-grid {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 16px;
    padding: 16px;
  }

  #chat-panel {
    width: 340px;
  }
}
