.trtc-voice-widget {
  --tvw-primary: #0b7fe8;
  --tvw-primary-dark: #0766c2;
  --tvw-border: #d7eafe;
  --tvw-border-strong: #b9dcff;
  --tvw-text: #163257;
  --tvw-muted: #60758f;
  --tvw-bg: #fff;
  --tvw-error: #d93945;
  --tvw-error-bg: #fff7f7;
  --tvw-shadow: 0 10px 26px rgba(24, 113, 214, 0.18);
  position: relative;
  z-index: 99;
  font-family: "Microsoft YaHei", Arial, sans-serif;
  color: var(--tvw-text);
}

.trtc-voice-widget.tvw-floating {
  position: fixed;
  right: 28px;
  top: 64%;
  transform: translateY(-50%);
}

.trtc-voice-widget * {
  box-sizing: border-box;
}

.tvw-main {
  width: 146px;
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 7px 6px 14px;
  border: 1px solid var(--tvw-border);
  border-radius: 999px;
  background: linear-gradient(180deg, #fff, #f8fbff);
  box-shadow: var(--tvw-shadow);
  cursor: pointer;
  outline: none;
  transition: transform 160ms ease, border-color 160ms ease;
}

.tvw-main:hover {
  transform: translateY(-2px);
  border-color: var(--tvw-border-strong);
}

.tvw-main:disabled {
  cursor: not-allowed;
  opacity: 0.75;
  transform: none;
}

.tvw-status-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: #91a4ba;
  box-shadow: 0 0 0 4px rgba(145, 164, 186, 0.12);
}

.tvw-label {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1.1;
  color: var(--tvw-text);
  white-space: nowrap;
}

.tvw-icon {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--tvw-primary), var(--tvw-primary-dark));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.24);
}

.tvw-icon img {
  width: 32px;
  height: 32px;
  display: block;
}

.tvw-controls {
  position: absolute;
  right: 0;
  bottom: calc(100% + 9px);
  display: none;
  align-items: center;
  gap: 4px;
  padding: 5px;
  border: 1px solid #e1edf9;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 10px 24px rgba(22, 50, 87, 0.12);
}

.trtc-voice-widget.tvw-controls-open .tvw-controls {
  display: flex;
}

.tvw-control-btn {
  min-width: 58px;
  height: 30px;
  padding: 0 10px;
  border: 0;
  border-radius: 14px;
  font-size: 13px;
  font-weight: 700;
  color: #235175;
  background: transparent;
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease;
}

.tvw-control-btn:hover {
  color: var(--tvw-primary);
  background: #eef7ff;
}

.tvw-control-btn.tvw-danger {
  color: #b53a3a;
  background: #fff2f2;
}

.tvw-control-btn.tvw-danger:hover {
  color: #a92d2d;
  background: #ffe3e3;
}

.tvw-toast {
  position: absolute;
  right: 0;
  bottom: calc(100% + 12px);
  width: 280px;
  max-width: min(280px, calc(100vw - 32px));
  display: none;
  padding: 10px 12px 10px 36px;
  border-radius: 14px;
  border: 1px solid rgba(217, 57, 69, 0.2);
  background: var(--tvw-error-bg);
  box-shadow: 0 14px 28px rgba(87, 34, 38, 0.12);
  color: #a62f39;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.45;
  text-align: left;
  white-space: normal;
  overflow-wrap: anywhere;
}

.tvw-toast::before {
  content: "!";
  position: absolute;
  left: 12px;
  top: 11px;
  width: 16px;
  height: 16px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: #fff;
  background: var(--tvw-error);
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
}

.tvw-toast::after {
  content: "";
  position: absolute;
  right: 24px;
  bottom: -6px;
  width: 10px;
  height: 10px;
  border-right: 1px solid rgba(217, 57, 69, 0.2);
  border-bottom: 1px solid rgba(217, 57, 69, 0.2);
  background: var(--tvw-error-bg);
  transform: rotate(45deg);
}

.trtc-voice-widget.tvw-has-toast .tvw-toast {
  display: block;
}

.trtc-voice-widget[data-status="connecting"] .tvw-status-dot {
  background: #198ff4;
  animation: tvw-pulse 1.2s ease-in-out infinite;
}

.trtc-voice-widget[data-status="connected"] .tvw-status-dot {
  background: #25c879;
  box-shadow: 0 0 0 4px rgba(37, 200, 121, 0.14);
}

.trtc-voice-widget[data-status="muted"] .tvw-status-dot {
  background: #ff9a2f;
  box-shadow: 0 0 0 4px rgba(255, 154, 47, 0.14);
}

.trtc-voice-widget[data-status="error"] .tvw-status-dot,
.trtc-voice-widget[data-status="permission-denied"] .tvw-status-dot {
  background: #f05b5b;
  box-shadow: 0 0 0 4px rgba(240, 91, 91, 0.14);
}

.trtc-voice-widget[data-status="error"] .tvw-main,
.trtc-voice-widget[data-status="permission-denied"] .tvw-main {
  border-color: rgba(217, 57, 69, 0.34);
  background: linear-gradient(180deg, #fff, #fff9f9);
}

@keyframes tvw-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(25, 143, 244, 0.28);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(25, 143, 244, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(25, 143, 244, 0);
  }
}

@media (max-width: 768px) {
  .trtc-voice-widget.tvw-floating {
    right: 16px;
    top: auto;
    bottom: 20px;
    transform: none;
  }

  .tvw-main {
    width: 136px;
    min-height: 42px;
    padding-left: 10px;
  }

  .tvw-label {
    font-size: 13px;
  }

  .tvw-toast {
    right: 0;
    bottom: calc(100% + 12px);
    width: min(280px, calc(100vw - 32px));
  }
}
