:root {
  color-scheme: light;
}

.meeting-page {
  background: linear-gradient(180deg, #eef2f6 0%, #f7f8fa 100%);
}

.video-grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-auto-rows: minmax(140px, 1fr);
  min-height: 0;
  flex: 1;
}

.video-tile {
  position: relative;
  border: 1px solid #dce3ec;
  border-radius: 0.9rem;
  overflow: hidden;
  background: #f3f6fa;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.06);
  animation: tile-in 220ms ease forwards;
  opacity: 0;
  transform: translateY(8px);
}

.video-tile:first-child {
  grid-column: span 3;
  min-height: 360px;
}

.video-tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #e5e9ef;
}

.video-placeholder {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  background: linear-gradient(180deg, #eef2f7 0%, #e2e8f0 100%);
}

.video-placeholder-avatar {
  width: 72px;
  height: 72px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 1.6rem;
  font-weight: 700;
  color: #334155;
  background: #cbd5e1;
  border: 2px solid #fff;
}

.video-placeholder-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: #334155;
}

.video-tile.camera-off .video-placeholder {
  display: flex;
}

.video-tile.camera-off video {
  opacity: 0;
}

.tile-tools {
  position: absolute;
  top: 0.55rem;
  right: 0.55rem;
  z-index: 4;
  display: flex;
  gap: 0.35rem;
}

.tile-fullscreen,
.tile-pin {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: rgba(15, 23, 42, 0.55);
  color: #fff;
  display: inline-grid;
  place-items: center;
  backdrop-filter: blur(2px);
}

.tile-fullscreen:hover,
.tile-pin:hover {
  background: rgba(15, 23, 42, 0.75);
}

.tile-pin.active,
.video-tile.pinned .tile-pin {
  background: rgba(37, 99, 235, 0.82);
  border-color: rgba(191, 219, 254, 0.9);
}

.video-tile.local video {
  transform: scaleX(-1);
}

.video-meta {
  position: absolute;
  left: 0.55rem;
  right: 0.55rem;
  bottom: 0.55rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.4rem;
  pointer-events: none;
}

.badge {
  pointer-events: auto;
  background: rgba(17, 24, 39, 0.75);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  padding: 0.22rem 0.55rem;
  font-size: 0.73rem;
  line-height: 1;
}

.video-meta .actions {
  display: flex;
  gap: 0.25rem;
}

.video-meta .actions .badge {
  cursor: pointer;
}

.video-tile.active-speaker {
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.7), 0 12px 30px rgba(37, 99, 235, 0.2);
}

.video-tile.pinned {
  box-shadow: 0 0 0 2px rgba(251, 191, 36, 0.7), 0 14px 32px rgba(245, 158, 11, 0.22);
}

.ctrl-btn {
  border: 1px solid #d4dce7;
  background: #fff;
  color: #0f172a;
  border-radius: 0.7rem;
  padding: 0.55rem 0.8rem;
  font-size: 0.88rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 160ms ease;
}

.ctrl-btn:hover {
  background: #f8fafc;
}

.ctrl-btn i {
  font-size: 1rem;
  line-height: 1;
}

.ctrl-btn.icon-only {
  width: 2.4rem;
  height: 2.4rem;
  padding: 0;
  justify-content: center;
}

.ctrl-btn.active {
  border-color: #22c55e;
  color: #15803d;
  background: #f0fdf4;
}

.btn-leave {
  border-color: #ef4444;
  background: #ef4444;
  color: #fff;
}

.btn-leave:hover {
  background: #dc2626;
}

.recording-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid #fecaca;
  background: #fff1f2;
  color: #be123c;
  border-radius: 999px;
  padding: 0.3rem 0.55rem;
  font-weight: 600;
}

.recording-pill i {
  font-size: 0.9rem;
}

.recording-pill strong {
  color: #9f1239;
  font-variant-numeric: tabular-nums;
}

.chat-drawer {
  transform: translateX(0);
  transition: transform 220ms ease;
}

.chat-drawer.closed {
  transform: translateX(100%);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  background: rgba(15, 23, 42, 0.2);
  animation: fade-in 160ms ease;
}

.modal-card {
  width: min(95vw, 720px);
  border-radius: 1rem;
  border: 1px solid #dce3ec;
  background: #fff;
  padding: 1.1rem;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.16);
  animation: scale-in 180ms ease;
}

.toast {
  pointer-events: auto;
  border: 1px solid #e2e8f0;
  background: #fff;
  color: #0f172a;
  border-radius: 0.75rem;
  padding: 0.6rem 0.8rem;
  font-size: 0.85rem;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.12);
  animation: slide-up 180ms ease;
}

.chat-msg {
  margin-bottom: 0.75rem;
}

.chat-row {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

.chat-avatar {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  flex-shrink: 0;
  border: 1px solid #e2e8f0;
  background: #fff;
}

.chat-body {
  min-width: 0;
  max-width: 78%;
}

.chat-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.3rem;
}

.chat-name {
  color: #94a3b8;
  font-size: 0.8rem;
  font-weight: 600;
}

.chat-time {
  color: #9ca3af;
  font-size: 0.75rem;
}

.chat-bubble {
  display: inline-block;
  background: #f1f5f9;
  color: #334155;
  border-radius: 0.7rem;
  padding: 0.45rem 0.75rem;
  line-height: 1.35;
}

.chat-out .chat-row {
  justify-content: flex-end;
}

.chat-out .chat-meta {
  justify-content: flex-end;
}

.chat-out .chat-name {
  text-align: right;
}

.chat-out .chat-bubble {
  background: #ef4444;
  color: #fff;
}

@keyframes tile-in {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slide-up {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scale-in {
  from {
    transform: scale(0.96);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

@media (max-width: 1200px) {
  .video-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .video-tile:first-child {
    grid-column: span 2;
  }
}

@media (max-width: 1024px) {
  .chat-drawer {
    position: fixed;
    top: 5rem;
    right: 1rem;
    bottom: 1rem;
    width: min(92vw, 350px);
    border: 1px solid #dce3ec;
    border-radius: 1rem;
    box-shadow: 0 20px 40px rgba(15, 23, 42, 0.16);
    z-index: 35;
    background: #fff;
  }
}

@media (max-width: 820px) {
  .video-grid {
    grid-template-columns: 1fr;
  }

  .video-tile:first-child {
    grid-column: span 1;
    min-height: 260px;
  }

  .control-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.6rem;
  }
}
