* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

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

body {
  background: #F8F8F8;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  display: flex;
  flex-direction: column;
  /* iOS 全面屏：左右安全区避让，避免横屏时内容贴边被刘海/圆角遮挡 */
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* 顶栏已移除：使用小程序原生导航栏（#F8F8F8 背景），
   返回按钮由微信原生提供，触发页面卸载时 window 的 beforeunload 会调用 stopAll() */

/* ========== 视频区域 ========== */
.video-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  min-height: 0;
}

.video-area video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.video-placeholder {
  position: absolute;
  inset: 0;
  pointer-events: none;
  /* 头像 + 宝宝姓名 + loading 三段竖向居中，避免不同元素散落在四角 */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.video-placeholder span {
  font-size: 14px;
}

/* 宝宝姓名：在深色视频底上保持可读，字号偏大用于一眼识别当前通话对象 */
.baby-name {
  font-size: 18px;
}

/* ========== 加入通话弹窗 ==========
   .join-mask：全屏半透明遮罩层，承载 #btnJoin 的显隐切换
   通过 align-items:flex-start + padding-top 让弹窗水平居中、垂直靠上
   JS 通过切换 display 控制显隐，保留 #btnJoin 选择器约定 */
.join-mask {
  position: fixed;
  inset: 0;
  z-index: 100;
  /* 默认 display:none 由内联 style 控制；显示时 JS 设为 flex */
  /* display: flex; */
  justify-content: center;
  padding-top: 20vh;
  background: rgba(0, 0, 0, 0.5);
}

.join-dialog {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 38px;
  width: 300px;
  /* 老旧小屏（≤320px）改为 max-width，避免横向溢出弹出滚动条 */
  max-width: calc(100vw - 32px);
  height: 310px;
  padding: 40px 22px 20px;
  border-radius: 40px;
  background: linear-gradient(#FEF0D2 10%, #FFFFFF 30%);
  box-sizing: border-box;
}

.join-dialog-actions {
  width: 100%;
  display: flex;
  gap: 12px;
}

.join-dialog-text {
  font-weight: bold;
  color: #333;
  text-align: center;
  font-size: 18px;
}

.join-dialog-btn {
  margin-top: -20px;
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 45px;
  border-radius: 80px;
  font-size: 16px;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.2s;
  border: 1px solid #FEB41C;
}

.join-dialog-btn:active {
  transform: scale(0.96);
  opacity: 0.85;
}

.join-dialog-btn--primary {
  background: #FEB41C;
  color: #fff;
}

.join-dialog-btn--cancel {
  background: unset;
  color: #FEB41C;
}

.control_direction {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 42px;
}

/* ========== 控制栏 ========== */
.controls {
  display: flex;
  flex-direction: column;
  gap: 32px;
  /* iPhone 全面屏 Home 指示条会盖住按钮，加底部安全区让控制栏整体上移 */
  padding-bottom: calc(env(safe-area-inset-bottom) + 100px);
  flex-shrink: 0;
}

.control_video {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 45px;
  flex-shrink: 0;
}

/* ========== 日志内容 ========== */
.log-content {
  max-height: 50vh;
  overflow-y: auto;
  background: #111;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12px;
  color: #777;
  font-family: "SF Mono", "Cascadia Code", monospace;
  line-height: 1.7;
}

/* ========== 弹窗 ========== */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 100;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.25s;
}

.overlay.open {
  display: flex;
  opacity: 1;
}

.modal {
  width: 100%;
  max-width: 420px;
  background: #1a1a1a;
  border-radius: 16px 16px 0 0;
  padding: 20px 20px 28px;
  /* iPhone 底部 Home 指示条避让：在原 28px 基础上叠加安全区 */
  padding-bottom: calc(28px + env(safe-area-inset-bottom));
  transform: translateY(100%);
  transition: transform 0.25s ease-out;
}

.overlay.open .modal {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-title {
  font-size: 16px;
  font-weight: 600;
  color: #e5e5e5;
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: #2a2a2a;
  color: #888;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-size: 12px;
  color: #888;
  margin-bottom: 6px;
  font-weight: 500;
}

.field input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid #333;
  background: #222;
  color: #e5e5e5;
  font-size: 14px;
  font-family: "SF Mono", "Cascadia Code", monospace;
  outline: none;
  transition: border-color 0.2s;
}

.field input:focus {
  border-color: #4a9eff;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

.modal-actions button {
  flex: 1;
  height: 42px;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}

.modal-actions .btn-save {
  background: #4a9eff;
  color: #fff;
}

.modal-actions .btn-cancel {
  background: #2a2a2a;
  color: #aaa;
}

/* ========== 响应式 ========== */
@media (min-width: 600px) {
  .modal {
    border-radius: 16px;
    margin-bottom: 10vh;
  }

  .overlay {
    align-items: center;
  }
}

/* ========== 三点 Loading 动画 ========== */
/* 用于设备连接中的等待提示，横向排列 3 个圆点依次脉动 */
.loading-dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.loading-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #F2C85A;
  /* 通过 animation-delay 让 3 个点形成波浪式相位差 */
  animation: pulse 1.2s ease-in-out infinite;
}

.loading-dot:nth-child(1) {
  animation-delay: 0s;
}

.loading-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.loading-dot:nth-child(3) {
  animation-delay: 0.4s;
}

/* 50% 处放大到 1.5 倍并提升透明度，营造呼吸节奏 */
@keyframes pulse {
  0%, 100% {
    transform: scale(1);
    opacity: 0.5;
  }
  50% {
    transform: scale(1.5);
    opacity: 1;
  }
}
