/* 23-voice-input.css — 实时语音输入麦克风按钮(P524)
   语音按钮独立常驻:不抢发送按钮;录音时只改变语音按钮状态。
   不新建 user.css(铁律 22)。颜色全走 75 变量体系。 */

.voice-mic-btn {
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; border: none; cursor: pointer;
  -webkit-appearance: none; appearance: none;
  transition: background var(--transit-fast), color var(--transit-fast), opacity var(--transit-fast), transform var(--transit-fast), box-shadow var(--transit-fast);
}
.voice-mic-btn svg { width: 20px; height: 20px; }
.voice-mic-btn:active { transform: scale(0.94); }
/* 禁用态兜底(当前默认允许已有文字后继续语音追加) */
.voice-mic-btn:disabled, .voice-mic-btn.voice-disabled { opacity: 0.32; cursor: not-allowed; }
.voice-mic-btn:disabled:active { transform: none; }

/* 聊天视图:独立次要麦克风图标(ghost),不与发送 CTA 抢视觉 */
.input-row .voice-mic-sidecar {
  width: 44px; height: 44px; border-radius: var(--radius-md);
  background: transparent; color: var(--text-muted);
}
.input-row .voice-mic-sidecar:hover { background: var(--bg-layer-1); color: var(--text-main); }

/* 移动端首页 compose:页脚左侧独立圆形语音按钮,发送靠 margin-left:auto 永远在最右 */
.compose-card-foot .voice-mic-compose {
  width: 44px; height: 44px; border-radius: 50%;
  background: transparent; color: var(--text-muted);
}
.compose-card-foot .voice-mic-compose:hover { background: var(--bg-layer-1); color: var(--text-main); }
.compose-card-foot .voice-mic-compose svg { width: 18px; height: 18px; }

/* 录音态:按钮外形不变,只让麦克风图标变红并发射,避免"红色大方块" */
.input-row .voice-mic-sidecar.voice-rec,
.compose-card-foot .voice-mic-compose.voice-rec {
  background: transparent;
  color: var(--error-color);
  animation: voicePulse 1.6s ease-in-out infinite;
}
.input-row .voice-mic-sidecar.voice-rec:hover,
.compose-card-foot .voice-mic-compose.voice-rec:hover {
  background: var(--bg-layer-1);
  color: var(--error-color);
}
.voice-mic-btn.voice-rec svg {
  transform-origin: center;
  animation: voiceMicLift 1.6s ease-in-out infinite;
}
.voice-mic-btn.voice-starting {
  color: var(--text-main);
  opacity: 0.72;
  animation: none;
}
@keyframes voicePulse {
  0%   { box-shadow: 0 0 0 0 rgba(255, 59, 48, 0.22); }
  70%  { box-shadow: 0 0 0 5px rgba(255, 59, 48, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 59, 48, 0); }
}
@keyframes voiceMicLift {
  0%, 100% { transform: translateY(0) scale(1); }
  45%      { transform: translateY(-0.5px) scale(1.035); }
}

@media (max-width: 768px) {
  .input-row .voice-mic-sidecar {
    width: 40px;
    height: 44px;
  }
}

/* ── 按住说话(voice-hold.js,手机):输入框原地变成声音条,识别的字浮在输入栏上方 ──
   宿主 = 对话页 .input-container / 首页 .compose-card;状态类 is-pressing / is-holding / is-armed(上滑取消)/ is-final(等定稿) */
.voice-hold-host { position: relative; }
.voice-hold-hidden { visibility: hidden; }
.voice-hold-host.is-holding { outline: 1.5px solid color-mix(in srgb, var(--brand-primary) 70%, transparent); outline-offset: 0; }
.voice-hold-host.is-holding.is-armed { outline-color: color-mix(in srgb, var(--error-color) 80%, transparent); }
.voice-hold-host.is-holding > :not(.voice-hold-live):not(.voice-hold-meter) { opacity: 0.3; }

.voice-hold-meter {
  position: absolute; display: flex; align-items: center; gap: 12px;
  padding: 0 12px; box-sizing: border-box; border-radius: 18px; pointer-events: none;
}
.voice-hold-host.is-pressing .voice-hold-meter { background: color-mix(in srgb, var(--text-main) 7%, transparent); }
.voice-hold-host:not(.is-holding) .voice-hold-meter > * { visibility: hidden; }
.vh-bars { flex: 1; min-width: 0; height: 22px; display: flex; align-items: center; justify-content: center; gap: 3px; }
.vh-bars i {
  flex: 0 0 3px; height: 100%; border-radius: 2px; background: var(--brand-primary);
  transform: scaleY(0.12); transition: transform 80ms linear, background-color 0.15s;
}
.voice-hold-host.is-armed .vh-bars i { background: var(--error-color); }
.vh-time { flex: 0 0 auto; font-size: 13px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

.voice-hold-live {
  position: absolute; left: 0; right: 0; bottom: calc(100% + 10px); z-index: 1;
  display: flex; flex-direction: column; align-items: center; gap: 10px; pointer-events: none;
  opacity: 0; transform: translateY(8px) scale(0.98); transform-origin: 50% 100%;
  transition: opacity 0.18s ease, transform 0.26s cubic-bezier(0.32, 0.72, 0, 1);
}
.voice-hold-host.is-holding .voice-hold-live { opacity: 1; transform: none; }
.vh-hint {
  padding: 5px 12px; border-radius: 14px; font-size: 13px; color: var(--text-muted); white-space: nowrap;
  background: var(--chrome-glass-strong, var(--bg-surface));
  -webkit-backdrop-filter: var(--chrome-blur, none); backdrop-filter: var(--chrome-blur, none);
  box-shadow: var(--chrome-shadow, var(--shadow-ambient));
}
.voice-hold-host.is-armed .vh-hint { color: var(--error-text); }
.voice-hold-host.is-final .vh-hint { visibility: hidden; }
.vh-card {
  width: 100%; box-sizing: border-box; min-height: 58px; max-height: 176px;
  padding: 14px 16px; border-radius: 22px; overflow: hidden; display: flex; align-items: flex-end;
  background: color-mix(in srgb, var(--chrome-base, var(--bg-surface)) 98%, transparent);
  box-shadow: var(--chrome-edge, 0 0 0 transparent), var(--chrome-shadow, var(--shadow-ambient));
}
.vh-text { min-width: 0; font-size: 17px; line-height: 1.6; color: var(--text-bright); overflow-wrap: anywhere; text-align: left; transition: opacity 0.15s; }
.vh-interim { color: var(--text-muted); }   /* 说话中大多是临时结果,保持可读 */
.voice-hold-host.is-armed .vh-text { opacity: 0.4; }
/* 松手后等定稿:文字扫光 */
.voice-hold-host.is-final .vh-text {
  background: linear-gradient(90deg, var(--text-dim) 20%, var(--text-bright) 50%, var(--text-dim) 80%);
  background-size: 220% 100%; -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: vhShimmer 1.1s linear infinite;
}
.voice-hold-host.is-final .vh-text span { color: transparent; }
.vh-wait { display: inline-flex; gap: 5px; align-items: center; height: 1.6em; vertical-align: bottom; }
.vh-wait[hidden] { display: none; }
.vh-wait i { width: 6px; height: 6px; border-radius: 50%; background: var(--text-muted); animation: vhDot 1.1s ease-in-out infinite; }
.vh-wait i:nth-child(2) { animation-delay: 0.15s; }
.vh-wait i:nth-child(3) { animation-delay: 0.3s; }

/* 对话页:按住时把消息区压暗一层(在输入栏之下) */
.voice-hold-scrim {
  position: absolute; inset: 0; z-index: 59; pointer-events: none;
  background: color-mix(in srgb, var(--shadow-overlay) 70%, transparent);
  opacity: 0; transition: opacity 0.2s ease;
}
.voice-hold-scrim.is-on { opacity: 1; }

@keyframes vhShimmer { from { background-position: 100% 0; } to { background-position: -120% 0; } }
@keyframes vhDot { 0%, 100% { opacity: 0.25; transform: scale(0.85); } 50% { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .voice-hold-live, .vh-bars i, .voice-hold-scrim { transition: none; }
  .voice-hold-host.is-final .vh-text, .vh-wait i { animation: none; }
}
