/* A full-width timeline of the recorded voice, aligned with the toolbar. */
.chat-input-area .chat-voice-status,
.side-chat-voice-status {
    display: none;
    position: absolute;
    z-index: 5;
    align-items: center;
    gap: 10px;
    height: 38px;
    color: var(--text-secondary, #b8b2a9);
    pointer-events: none;
}

body #chatView .chat-main-area .chat-input-area .chat-voice-status {
    left: 12px;
    right: 106px;
    top: auto;
    bottom: 8px;
    transform: none;
    max-width: none;
    overflow: visible;
}

.chat-input-area.voice-status-active .chat-voice-status,
.side-chat-input-area.voice-status-active .side-chat-voice-status {
    display: flex;
}

/* The textarea keeps its draft visible above the recording controls. */
body #chatView .chat-main-area .chat-input-area.voice-status-active #chatInput {
    color: var(--text-primary) !important;
    caret-color: var(--text-primary) !important;
    text-align: left !important;
}

body #chatView .chat-main-area .chat-input-area.voice-status-active #chatInput::placeholder {
    color: var(--text-secondary) !important;
    text-align: left !important;
}

body #chatView .chat-main-area .chat-input-area.voice-status-active #mainAttachBtn,
body #chatView .chat-main-area .chat-input-area.voice-status-active #responseSpeedControl {
    visibility: hidden !important;
    pointer-events: none !important;
}

.voice-status-label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.voice-activity-meter {
    display: flex;
    flex: 1 1 0;
    min-width: 0;
    align-items: center;
    gap: calc(var(--voice-wave-step, 12px) - 4px);
    height: 36px;
    overflow: hidden;
    color: var(--text-secondary, #b8b2a9);
    mask-image: linear-gradient(to right, transparent, #000 8px, #000 calc(100% - 3px), transparent);
}

.voice-activity-meter i {
    display: block;
    position: relative;
    flex: 0 0 4px;
    width: 4px;
    height: 34px;
    contain: layout style;
}

.voice-activity-meter i::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    height: var(--voice-wave-height, 4px);
    border-radius: 999px !important;
    corner-shape: round !important;
    background: currentColor;
    opacity: var(--voice-wave-opacity, .38);
    transform: translateY(-50%);
}

/* Waiting feedback starts immediately; recorded heights are never animated
   with synthetic sine waves or rescaled while transcription is pending. */
:is(.chat-voice-status, .side-chat-voice-status, .study-chat-voice-status)[data-phase="requesting"] .voice-activity-meter,
:is(.chat-voice-status, .side-chat-voice-status, .study-chat-voice-status)[data-phase="transcribing"] .voice-activity-meter {
    animation: logicum-voice-pending 900ms ease-in-out infinite alternate;
}

.voice-recording-cancel {
    display: inline-flex;
    flex: 0 0 38px;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, .06);
    color: var(--text-secondary);
    cursor: pointer;
    pointer-events: auto;
}

.voice-recording-cancel svg { width: 20px; height: 20px; }
.voice-recording-cancel:hover { background: rgba(255, 255, 255, .12); color: var(--text-primary); }
.voice-recording-cancel:focus-visible { outline: 2px solid var(--text-secondary); outline-offset: 2px; }
body #chatView .chat-main-area .chat-input-area .voice-recording-cancel {
    border-radius: 50% !important;
    corner-shape: round !important;
}
body.light-mode .voice-recording-cancel { background: rgba(0, 0, 0, .04); }
body.light-mode .voice-recording-cancel:hover { background: rgba(0, 0, 0, .075); }

body #chatView .chat-main-area .chat-input-area.voice-status-active #mainVoiceBtn {
    color: var(--text-primary) !important;
    background: rgba(255, 255, 255, .06) !important;
    border-color: transparent !important;
    border-radius: 50% !important;
    corner-shape: round !important;
    box-shadow: none !important;
}

body.light-mode #chatView .chat-main-area .chat-input-area.voice-status-active #mainVoiceBtn {
    background: rgba(0, 0, 0, .04) !important;
}

body #chatView .chat-main-area .chat-input-area.voice-status-active #mainVoiceBtn:hover {
    background: rgba(255, 255, 255, .12) !important;
}

body.light-mode #chatView .chat-main-area .chat-input-area.voice-status-active #mainVoiceBtn:hover {
    background: rgba(0, 0, 0, .075) !important;
}

body #chatView .chat-main-area .chat-input-area.voice-status-active #sendBtn svg {
    transform: rotate(-90deg) !important;
}

body #chatView .chat-main-area .chat-input-area.voice-status-active #sendBtn {
    border: 0 !important;
    border-radius: 50% !important;
    corner-shape: round !important;
    background: var(--text-primary) !important;
    color: var(--codex-bg, var(--bg-dark)) !important;
    box-shadow: none !important;
}

.side-chat-input-area { position: relative !important; }
.side-chat-voice-status { left: 52px; right: 104px; top: auto; bottom: 7px; max-width: none; height: 32px; }
.side-chat-panel .side-chat-input-area.voice-status-active #sideVoiceBtn {
    color: var(--text-primary) !important;
    border-color: transparent !important;
    box-shadow: none !important;
    background: transparent !important;
}
.side-chat-panel .side-chat-input-area.voice-status-active #sideVoiceBtn:hover { background: var(--bg-hover) !important; }
.side-chat-panel .side-chat-input-area:is(.is-listening, .is-transcribing)::before { content: none !important; animation: none !important; box-shadow: none !important; }

@keyframes logicum-voice-pending {
    from { opacity: .45; }
    to { opacity: .95; }
}

/* Mic hover stays soft gray, with no bright outline around the circular button. */
.voice-btn:hover,
.voice-btn:focus-visible {
    border-color: transparent !important;
    background-color: rgba(255, 255, 255, .12) !important;
    box-shadow: none !important;
}

.voice-btn:focus-visible {
    outline: 2px solid color-mix(in srgb, var(--accent-color, #c17a0a) 68%, transparent) !important;
    outline-offset: 2px !important;
}

body.light-mode .voice-btn:hover,
body.light-mode .voice-btn:focus-visible {
    background-color: rgba(0, 0, 0, .075) !important;
}

@media (prefers-reduced-motion: reduce) {
    .voice-activity-meter { animation: none !important; }
    .voice-activity-meter i { transition: none !important; }
}
