.speech-settings {
    display: grid;
    gap: 0.75rem;
    margin-top: 1rem;
}

.speech-setting,
.speech-meter-heading,
.speech-run-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.speech-setting .input-field {
    width: min(65%, 22rem);
    min-width: 0;
}

.speech-setting.hidden {
    display: none;
}

#media-preview audio,
#media-preview video {
    display: block;
    width: 100%;
    max-height: 25vh;
    margin-top: 1rem;
    border-radius: var(--radius-md);
}

.speech-meter-heading {
    margin: 1rem 0 0.5rem;
}

.speech-meter {
    height: 0.75rem;
    overflow: hidden;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-bg-primary);
}

#audio-meter-bar {
    height: 100%;
    width: 0;
    background: var(--color-accent-blue);
}

#speech-status[data-error="true"] {
    color: #f87171;
}

#speech-output {
    min-height: 6rem;
    max-height: 25vh;
    overflow-y: auto;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font-family: var(--font-family-controls);
    font-size: 1rem;
    line-height: 1.75;
}

.speech-mode-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

#on-device {
    appearance: none;
    width: 2.5rem;
    height: 1.5rem;
    margin: 0;
    padding: 0.125rem;
    border: 1px solid var(--color-border);
    border-radius: 1rem;
    background: var(--color-bg-primary);
    cursor: pointer;
}

#on-device::before {
    content: "";
    display: block;
    width: 1.125rem;
    height: 1.125rem;
    border-radius: 50%;
    background: var(--color-text-primary);
}

#on-device:checked {
    background: var(--color-accent-blue);
}

#on-device:checked::before {
    transform: translateX(1rem);
}

#on-device:focus-visible {
    outline: 2px solid #93c5fd;
    outline-offset: 3px;
}

#on-device:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

@media (max-width: 600px) {
    .speech-setting {
        align-items: stretch;
        flex-direction: column;
        gap: 0.375rem;
    }

    .speech-setting .input-field {
        width: 100%;
    }
}
