/* Speech-to-text — nút micro cạnh ô nhập + overlay lắng nghe (kiểu Gemini) */

.speech-input-wrap {
    position: relative;
    display: block;
    width: 100%;
}

.speech-input-wrap > input.speech-input-enhanced,
.speech-input-wrap > textarea.speech-input-enhanced {
    padding-right: 2.75rem !important;
}

.speech-input-wrap > textarea.speech-input-enhanced {
    resize: vertical;
}

/* Nút micro inline (Material / Gemini outline) */
.speech-input-btn {
    position: absolute;
    right: 0.35rem;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.125rem;
    height: 2.125rem;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: #5f6368;
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
}

.speech-input-wrap > textarea + .speech-input-btn {
    top: 0.5rem;
    transform: none;
}

.speech-input-btn:hover:not(:disabled) {
    color: #1a73e8;
    background: rgba(26, 115, 232, 0.08);
}

.speech-input-btn:focus-visible {
    outline: 2px solid #1a73e8;
    outline-offset: 2px;
}

.speech-input-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.speech-input-btn svg {
    width: 1.25rem;
    height: 1.25rem;
    display: block;
}

/* Overlay che phủ toàn màn hình */
.speech-input-overlay {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.22s ease, visibility 0.22s ease;
}

.speech-input-overlay.is-open {
    opacity: 1;
    visibility: visible;
}

.speech-input-overlay__panel {
    width: 100%;
    max-width: 22rem;
    text-align: center;
    color: #fff;
}

.speech-input-overlay__visual {
    position: relative;
    width: 7.5rem;
    height: 7.5rem;
    margin: 0 auto 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.speech-input-overlay__ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid rgba(138, 180, 248, 0.45);
    animation: speech-overlay-ring 2.4s ease-out infinite;
}

.speech-input-overlay__ring:nth-child(2) {
    animation-delay: 0.8s;
}

.speech-input-overlay__ring:nth-child(3) {
    animation-delay: 1.6s;
}

@keyframes speech-overlay-ring {
    0% {
        transform: scale(0.55);
        opacity: 0.85;
    }
    100% {
        transform: scale(1.35);
        opacity: 0;
    }
}

.speech-input-overlay__mic-disc {
    position: relative;
    z-index: 1;
    width: 4.5rem;
    height: 4.5rem;
    border-radius: 50%;
    background: linear-gradient(145deg, #8ab4f8 0%, #669df6 45%, #4285f4 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 32px rgba(66, 133, 244, 0.45);
}

.speech-input-overlay__mic-disc svg {
    width: 2rem;
    height: 2rem;
    color: #fff;
}

.speech-input-overlay__status {
    font-size: 1.125rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    margin: 0 0 0.75rem;
    color: #e8eaed;
}

.speech-input-overlay__preview {
    min-height: 3.5rem;
    max-height: 8rem;
    overflow-y: auto;
    margin: 0 0 1.5rem;
    padding: 0.75rem 1rem;
    font-size: 0.9375rem;
    line-height: 1.5;
    color: #bdc1c6;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 0.75rem;
    word-break: break-word;
}

.speech-input-overlay__preview:empty::before {
    content: 'Nói để nhập nội dung…';
    color: rgba(255, 255, 255, 0.35);
    font-style: italic;
}

.speech-input-overlay__preview:not(:empty)::before {
    content: none;
}

.speech-input-overlay__actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.speech-input-overlay__ok {
    min-width: 8rem;
    padding: 0.65rem 2rem;
    border: none;
    border-radius: 9999px;
    background: #fff;
    color: #1a73e8;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.speech-input-overlay__ok:hover {
    background: #f1f3f4;
}

.speech-input-overlay__ok:active {
    transform: scale(0.98);
}

.speech-input-overlay__cancel {
    padding: 0.35rem 0.75rem;
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.65);
    font-size: 0.875rem;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.speech-input-overlay__cancel:hover {
    color: #fff;
}
