.tts-widget {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 1050;
    font-family: Arial, sans-serif;
}

.tts-widget .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.tts-widget-toggle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background-color: #4b8fe3;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s ease, transform 0.15s ease;
}

.tts-widget-toggle:hover {
    background-color: #3a75c4;
    transform: scale(1.05);
}

.tts-widget-toggle .tts-icon-close {
    display: none;
}

.tts-widget.is-open .tts-widget-toggle .tts-icon-speaker {
    display: none;
}

.tts-widget.is-open .tts-widget-toggle .tts-icon-close {
    display: block;
}

.tts-widget-panel {
    position: absolute;
    right: 0;
    bottom: 68px;
    width: 320px;
    max-width: calc(100vw - 40px);
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    opacity: 0;
    transform: translateY(12px) scale(0.98);
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.tts-widget.is-open .tts-widget-panel {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.tts-widget-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background-color: #4b8fe3;
    color: #ffffff;
    font-weight: bold;
}

.tts-widget-close {
    background: none;
    border: none;
    color: #ffffff;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
}

.tts-widget-body {
    padding: 12px 16px;
}

.tts-widget-textarea {
    width: 100%;
    min-height: 90px;
    resize: vertical;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 14px;
    box-sizing: border-box;
}

.tts-widget-settings-toggle {
    margin-top: 8px;
    width: 26px;
    height: 26px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1px solid #ccc;
    border-radius: 50%;
    color: #777;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.tts-widget-settings-toggle:hover,
.tts-widget-settings-toggle[aria-expanded="true"] {
    background-color: #f2f6fc;
    color: #4b8fe3;
}

.tts-widget-settings {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #eee;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.tts-widget-settings[hidden] {
    display: none;
}

.tts-widget-settings-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #555;
}

.tts-widget-settings-name {
    flex: 0 0 60px;
}

.tts-widget-settings-output {
    flex: 0 0 36px;
    text-align: right;
}

.tts-widget-select {
    flex: 1;
    font-size: 12px;
    padding: 2px 4px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

.tts-widget-range {
    flex: 1;
}

.tts-widget-reset-btn {
    flex: 0 0 auto;
    width: 20px;
    height: 20px;
    padding: 0;
    background: none;
    border: 1px solid #ccc;
    border-radius: 4px;
    color: #555;
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
}

.tts-widget-reset-btn:hover {
    background-color: #f2f6fc;
    color: #4b8fe3;
}

.tts-widget-status {
    min-height: 18px;
    margin-top: 6px;
    font-size: 13px;
    color: #c0392b;
}

.tts-widget-status.is-loading {
    color: #555;
}

.tts-widget-processed {
    margin-top: 6px;
    padding: 6px 8px;
    background-color: #f2f6fc;
    border-radius: 6px;
    font-size: 12px;
    color: #444;
    line-height: 1.4;
}

.tts-widget-processed[hidden] {
    display: none;
}

.tts-widget-processed-label {
    font-weight: bold;
    color: #4b8fe3;
    margin-right: 4px;
}

.tts-widget-audio {
    width: 100%;
    margin-top: 8px;
}

.tts-widget-footer {
    padding: 0 16px 16px;
}

.tts-widget-speak-btn {
    width: 100%;
    padding: 10px;
    background-color: #4CAF50;
    color: #ffffff;
    border: none;
    border-radius: 6px;
    font-size: 15px;
    cursor: pointer;
}

.tts-widget-speak-btn:hover {
    background-color: #45a049;
}

.tts-widget-speak-btn:disabled {
    background-color: #9e9e9e;
    cursor: not-allowed;
}

@media print {
    .tts-widget {
        display: none !important;
    }
}

@media (max-width: 400px) {
    .tts-widget {
        right: 12px;
        bottom: 12px;
    }

    .tts-widget-panel {
        width: calc(100vw - 24px);
    }
}
