.site-speech-reader,
.site-speech-reader * {
    box-sizing: border-box;
}

.site-speech-reader {
    position: fixed;
    z-index: 9998;
    bottom: max(18px, env(safe-area-inset-bottom));
    left: max(18px, env(safe-area-inset-left));
    color: #0f172a;
    font-family: 'Prompt', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 16px;
    line-height: 1.5;
}

.site-speech-toggle {
    position: relative;
    display: inline-flex;
    width: 46px;
    min-width: 46px;
    height: 46px;
    min-height: 46px;
    align-items: center;
    justify-content: center;
    padding: 0;
    overflow: visible;
    border: 2px solid #ffffff;
    border-radius: 999px;
    background: linear-gradient(145deg, #1e3a8a, #172554);
    box-shadow: 0 7px 20px rgba(15, 23, 42, 0.3), 0 0 0 1px rgba(96, 165, 250, 0.24);
    color: #ffffff;
    cursor: pointer;
    font: inherit;
    line-height: 1;
    transition: background-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.site-speech-toggle::before {
    position: absolute;
    z-index: -1;
    inset: -4px;
    border: 2px solid rgba(59, 130, 246, 0.65);
    border-radius: inherit;
    content: '';
    pointer-events: none;
    animation: site-speech-ring 2.6s ease-out infinite;
}

.site-speech-toggle:hover {
    background: linear-gradient(145deg, #2563eb, #1e40af);
    box-shadow: 0 10px 28px rgba(29, 78, 216, 0.36);
    transform: translateY(-2px);
}

.site-speech-toggle:focus-visible,
.site-speech-reader button:focus-visible,
.site-speech-reader select:focus-visible {
    outline: 3px solid #facc15;
    outline-offset: 3px;
}

.site-speech-toggle-icon {
    position: relative;
    display: inline-grid;
    width: 20px;
    height: 20px;
    place-items: center;
    font-size: 17px;
}

.site-speech-toggle-icon i {
    transform-origin: 45% 50%;
    animation: site-speech-icon-wiggle 2.6s ease-in-out infinite;
}

.site-speech-toggle-icon::after {
    position: absolute;
    top: 50%;
    right: -5px;
    width: 6px;
    height: 12px;
    border-right: 2px solid rgba(219, 234, 254, 0.9);
    border-radius: 0 100% 100% 0;
    content: '';
    opacity: 0.75;
    transform: translateY(-50%) scale(0.7);
    animation: site-speech-wave 1.35s ease-in-out infinite;
}

.site-speech-toggle-label {
    position: absolute;
    bottom: 50%;
    left: calc(100% + 11px);
    width: max-content;
    max-width: min(230px, calc(100vw - 85px));
    padding: 7px 10px;
    visibility: hidden;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.96);
    box-shadow: 0 7px 20px rgba(15, 23, 42, 0.24);
    color: #ffffff;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.35;
    opacity: 0;
    pointer-events: none;
    transform: translate(-6px, 50%);
    transition: opacity 160ms ease, transform 160ms ease, visibility 160ms ease;
    white-space: nowrap;
}

.site-speech-toggle:hover .site-speech-toggle-label,
.site-speech-toggle:focus-visible .site-speech-toggle-label {
    visibility: visible;
    opacity: 1;
    transform: translate(0, 50%);
}

.site-speech-reader.is-reading .site-speech-toggle-icon {
    animation: site-speech-pulse 0.8s ease-in-out infinite;
}

.site-speech-reader.is-reading .site-speech-toggle {
    background: linear-gradient(145deg, #2563eb, #0891b2);
    box-shadow: 0 8px 24px rgba(8, 145, 178, 0.38), 0 0 0 1px rgba(103, 232, 249, 0.4);
}

.site-speech-reader.is-reading .site-speech-toggle::before {
    border-color: rgba(34, 211, 238, 0.75);
    animation-duration: 1.05s;
}

.site-speech-panel {
    position: absolute;
    bottom: calc(100% + 12px);
    left: 0;
    width: min(360px, calc(100vw - 36px));
    overflow: hidden;
    border: 1px solid #cbd5e1;
    border-radius: 18px;
    background: #ffffff;
    box-shadow: 0 18px 50px rgba(15, 23, 42, 0.28);
}

.site-speech-panel[hidden] {
    display: none !important;
}

.site-speech-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px;
    background: #172554;
    color: #ffffff;
}

.site-speech-panel-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    color: inherit;
    font-size: 17px;
    font-weight: 700;
    line-height: 1.35;
}

.site-speech-close {
    display: inline-grid;
    width: 38px;
    height: 38px;
    flex: 0 0 auto;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, 0.45);
    border-radius: 999px;
    background: transparent;
    color: #ffffff;
    cursor: pointer;
    font: inherit;
    font-size: 21px;
    line-height: 1;
}

.site-speech-close:hover {
    background: rgba(255, 255, 255, 0.15);
}

.site-speech-panel-body {
    padding: 18px;
}

.site-speech-help {
    margin: 0 0 13px;
    color: #334155;
    font-size: 13px;
}

.site-speech-status {
    min-height: 48px;
    margin: 0 0 14px;
    padding: 11px 13px;
    border-left: 4px solid #2563eb;
    border-radius: 9px;
    background: #eff6ff;
    color: #1e3a8a;
    font-size: 13px;
    font-weight: 600;
}

.site-speech-controls {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 0.72fr);
    gap: 10px;
    margin-bottom: 15px;
}

.site-speech-control {
    display: inline-flex;
    min-height: 46px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 13px;
    border: 0;
    border-radius: 10px;
    cursor: pointer;
    font: inherit;
    font-size: 14px;
    font-weight: 700;
}

.site-speech-control-primary {
    background: #2563eb;
    color: #ffffff;
}

.site-speech-control-primary:hover {
    background: #1d4ed8;
}

.site-speech-control-stop {
    background: #fee2e2;
    color: #991b1b;
}

.site-speech-control-stop:hover {
    background: #fecaca;
}

.site-speech-control:disabled,
.site-speech-speed:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.site-speech-speed-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 12px;
}

.site-speech-speed-label {
    color: #334155;
    font-size: 13px;
    font-weight: 700;
}

.site-speech-speed {
    min-width: 114px;
    min-height: 42px;
    padding: 7px 32px 7px 10px;
    border: 1px solid #94a3b8;
    border-radius: 9px;
    background: #ffffff;
    color: #0f172a;
    font: inherit;
    font-size: 14px;
    font-weight: 600;
}

.site-speech-shortcuts {
    display: block;
    margin: 0;
    color: #64748b;
    font-size: 11px;
}

@keyframes site-speech-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.16); opacity: 0.72; }
}

@keyframes site-speech-ring {
    0% { opacity: 0.72; transform: scale(0.9); }
    55%, 100% { opacity: 0; transform: scale(1.28); }
}

@keyframes site-speech-icon-wiggle {
    0%, 72%, 100% { transform: rotate(0deg) scale(1); }
    78% { transform: rotate(-8deg) scale(1.05); }
    84% { transform: rotate(7deg) scale(1.08); }
    90% { transform: rotate(-4deg) scale(1.04); }
    96% { transform: rotate(2deg) scale(1); }
}

@keyframes site-speech-wave {
    0%, 100% { opacity: 0.35; transform: translateY(-50%) scale(0.55); }
    50% { opacity: 1; transform: translateY(-50%) scale(1); }
}

@media (max-width: 640px) {
    .site-speech-reader {
        bottom: max(12px, env(safe-area-inset-bottom));
        left: max(12px, env(safe-area-inset-left));
    }

    .site-speech-toggle {
        width: 44px;
        min-width: 44px;
        height: 44px;
        min-height: 44px;
        padding: 0;
    }

    .site-speech-toggle-label {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        clip-path: inset(50%);
        white-space: nowrap;
    }

    .site-speech-panel {
        width: min(360px, calc(100vw - 24px));
    }
}

@media (prefers-reduced-motion: reduce) {
    .site-speech-reader *,
    .site-speech-reader *::before,
    .site-speech-reader *::after {
        scroll-behavior: auto !important;
        transition: none !important;
        animation: none !important;
    }
}

@media print {
    .site-speech-reader {
        display: none !important;
    }
}


