/* Compact header voice panel. Scoping also shields it from legacy header,
 * panel, form, and Bootstrap element selectors. */
.voice-search {
    position: relative;
    display: inline-block;
    vertical-align: middle;
    color: var(--sx-ink, #1d2f2a);
    text-align: start;
    white-space: normal;
}

.voice-search .voice-search-trigger {
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; min-width: 36px; min-height: 36px; padding: 0;
    border: 1px solid var(--sx-border, #dce5df); border-radius: 8px;
    background: var(--sx-surface, #fff); color: var(--sx-muted, #64766e);
    font-size: 14px; line-height: 1;
}
.voice-search .voice-search-trigger:hover,
.voice-search .voice-search-trigger.is-recording { background: var(--sx-brand-soft, #e7f0ec); color: var(--sx-brand, #176b59); }
.voice-search .voice-search-trigger:focus-visible { outline: 2px solid var(--sx-brand, #176b59); outline-offset: 2px; }
.sx-dictation-field { position: relative; margin-block: 8px 16px; }
.sx-dictation-field > textarea { display: block; width: 100%; min-height: 88px; padding-inline-end: 54px; }
.sx-dictation-field > voice-search { position: absolute; inset-inline-end: 8px; top: 8px; }

.voice-search .voice-search-hint { margin-inline-start: 4px; font-size: 12px; }

.voice-search .voice-search-panel {
    position: absolute;
    z-index: 1080;
    top: calc(100% + 10px);
    inset-inline-end: 0;
    display: block;
    width: 360px;
    max-width: calc(100vw - 24px);
    margin: 0;
    padding: 0;
    overflow: hidden;
    border: 1px solid var(--sx-border, #dce5df);
    border-radius: 14px;
    background: var(--sx-surface, #fff);
    box-shadow: 0 16px 42px rgba(20, 47, 39, .18), 0 2px 8px rgba(20, 47, 39, .08);
    color: var(--sx-ink, #1d2f2a);
    font-size: 14px;
    line-height: 1.45;
    text-align: start;
    white-space: normal;
}

.voice-search .voice-search-panel__header {
    position: static;
    display: flex;
    width: auto;
    min-height: 0;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin: 0;
    padding: 16px 16px 12px;
    border: 0;
    border-block-end: 1px solid var(--sx-border, #e2e9e4);
    background: var(--sx-surface, #fff);
    color: inherit;
}

.voice-search .voice-search-panel__heading {
    display: flex;
    min-width: 0;
    align-items: flex-start;
    gap: 10px;
}

.voice-search .voice-search-panel__mark {
    display: inline-flex;
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: var(--sx-brand-soft, #e7f0ec);
    color: var(--sx-brand, #176b59);
    font-size: 16px;
}

.voice-search .voice-search-panel__header h2 {
    margin: 0;
    color: var(--sx-ink, #1d2f2a);
    font-size: 15px;
    font-weight: 700;
    line-height: 1.35;
}

.voice-search .voice-search-panel__header p {
    margin: 3px 0 0;
    color: var(--sx-muted, #64766e);
    font-size: 12px;
}

.voice-search .voice-search-panel__close {
    display: inline-flex;
    width: 32px;
    height: 32px;
    flex: 0 0 32px;
    align-items: center;
    justify-content: center;
    margin: -4px -4px 0 0;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--sx-muted, #64766e);
}

[dir='rtl'] .voice-search .voice-search-panel__close { margin: -4px 0 0 -4px; }
.voice-search .voice-search-panel__close:hover,
.voice-search .voice-search-panel__close:focus {
    background: var(--sx-brand-soft, #e7f0ec);
    color: var(--sx-brand-strong, #0f4a3e);
    outline: 2px solid transparent;
}

.voice-search .voice-search-panel__language {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px 0;
}

.voice-search .voice-search-panel__language label,
.voice-search .voice-search-panel__review label {
    margin: 0;
    color: var(--sx-muted, #64766e);
    font-size: 12px;
    font-weight: 600;
}

.voice-search .voice-search-panel__language select {
    width: auto;
    min-width: 116px;
    height: 32px;
    margin: 0;
    padding: 4px 28px 4px 9px;
    border: 1px solid var(--sx-border-strong, #bdcbc2);
    border-radius: 8px;
    background: #fff;
    color: var(--sx-ink, #1d2f2a);
    font: inherit;
    font-size: 12px;
}

[dir='rtl'] .voice-search .voice-search-panel__language select { padding: 4px 9px 4px 28px; }

.voice-search .voice-search-panel__stage { padding: 16px; text-align: center; }
.voice-search .voice-search-panel__activity {
    display: flex;
    min-height: 106px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 12px;
    background: #f6f8f6;
}

.voice-search .voice-search-panel__activity.is-listening {
    background: var(--sx-brand-soft, #e7f0ec);
    color: var(--sx-brand-strong, #0f4a3e);
}
.voice-search .voice-search-panel__activity.has-error { background: #fff4f3; color: #9d2f2a; }

.voice-search .voice-search-panel__wave {
    display: flex;
    height: 28px;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.voice-search .voice-search-panel__wave span {
    display: block;
    width: 4px;
    height: calc(6px + var(--sx-voice-level, 0) * 20px);
    border-radius: 4px;
    background: var(--sx-brand, #176b59);
    transition: height 90ms linear;
}
.voice-search .voice-search-panel__wave span:nth-child(2),
.voice-search .voice-search-panel__wave span:nth-child(4) {
    height: calc(8px + var(--sx-voice-level, 0) * 14px);
}
.voice-search .voice-search-panel__wave span:nth-child(3) {
    height: calc(7px + var(--sx-voice-level, 0) * 19px);
}

.voice-search .voice-search-panel__spinner,
.voice-search .voice-search-panel__error-icon { font-size: 24px; }
.voice-search .voice-search-panel__timer {
    color: var(--sx-muted, #64766e);
    font-variant-numeric: tabular-nums;
    font-size: 12px;
    direction: ltr;
}
.voice-search .voice-search-panel__hint {
    margin: 9px 8px 0;
    color: var(--sx-muted, #64766e);
    font-size: 12px;
}

.voice-search .voice-search-panel__review {
    margin: 0 16px 14px;
    padding: 12px;
    border: 1px solid #ead8a4;
    border-radius: 10px;
    background: #fffaf0;
}
.voice-search .voice-search-panel__review textarea {
    display: block;
    width: 100%;
    min-height: 72px;
    margin: 6px 0;
    padding: 8px 10px;
    resize: vertical;
    border: 1px solid var(--sx-border-strong, #bdcbc2);
    border-radius: 8px;
    background: #fff;
    color: var(--sx-ink, #1d2f2a);
    font: inherit;
    line-height: 1.45;
}
.voice-search .voice-search-panel__review p { margin: 0; color: #755d24; font-size: 11px; }

.voice-search .voice-search-panel__actions {
    position: static;
    display: flex;
    width: auto;
    min-height: 0;
    align-items: center;
    gap: 8px;
    margin: 0;
    padding: 0 16px 16px;
    border: 0;
    background: transparent;
}
.voice-search .voice-search-panel__actions .btn {
    min-height: 36px;
    margin: 0;
    border-radius: 8px;
    font-size: 13px;
}
.voice-search .voice-search-panel__done,
.voice-search .voice-search-panel__retry { flex: 1 1 auto; }
.voice-search .voice-search-panel__cancel { flex: 0 0 auto; color: var(--sx-muted, #64766e); }

@media (max-width: 520px) {
    .voice-search .voice-search-panel {
        position: fixed;
        top: 64px;
        inset-inline: 12px;
        width: auto;
        max-width: none;
        max-height: calc(100vh - 76px);
        overflow-y: auto;
    }
    .voice-search .voice-search-panel__header { padding: 14px; }
    .voice-search .voice-search-panel__language,
    .voice-search .voice-search-panel__stage { padding-inline: 14px; }
    .voice-search .voice-search-panel__review { margin-inline: 14px; }
    .voice-search .voice-search-panel__actions { padding-inline: 14px; }
}

@media (prefers-reduced-motion: reduce) {
    .voice-search .voice-search-panel__wave span { transition: none; }
    .voice-search .fa-spin { animation-duration: 2s; }
}
