.tts-widget {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 99999;
  font-family: "Segoe UI", Tahoma, sans-serif;
}

.tts-widget__button {
  background: linear-gradient(135deg, #0d6efd, #0ea5e9);
  color: #fff;
  border: 0;
  border-radius: 999px;
  padding: 12px 16px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(13, 110, 253, 0.35);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.tts-widget__toggle-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.tts-widget__toggle-icon svg {
  width: 16px;
  height: 16px;
}

.tts-widget__label {
  display: inline;
}

.tts-widget__panel {
  position: absolute;
  left: calc(100% + 8px);
  bottom: 0;
  display: none;
  align-items: center;
  gap: 4px;
  background: #ffffff;
  border-radius: 14px;
  padding: 6px 8px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.18);
  border: 1px solid #dbe4f0;
  white-space: nowrap;
}

.tts-widget--in-container {
  position: absolute;
  top: 18px;
  right: 18px;
  bottom: auto;
}

.tts-widget__icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #4b5563;
  transition: background 0.15s, color 0.15s;
}

.tts-widget__icon-btn:hover {
  background: #f0f4f8;
  color: #0d6efd;
}

.tts-widget__icon-btn:active {
  background: #e4eaf3;
}

.tts-widget__icon-btn.active {
  color: #0d6efd;
}

.tts-widget__icon-btn--stop:hover {
  background: #fdecec;
  color: #dc3545;
}

.tts-widget__icon-btn--stop:active {
  background: #f8d7da;
}

.tts-widget__speed-wrapper {
  position: relative;
  border-left: 1px solid #e2e8f0;
  padding-left: 6px;
  margin-left: 2px;
}

.tts-widget__speed-current {
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  background: #fff;
  color: #4b5563;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.15s;
}

.tts-widget__speed-current:hover {
  border-color: #c9d6e8;
  background: #f8fbff;
}

.tts-widget__speed-dropdown {
  display: none;
  position: absolute;
  bottom: calc(100% + 4px);
  right: 0;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 4px 0;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
  z-index: 10;
  min-width: 60px;
}

.tts-widget__speed-dropdown.open {
  display: block;
}

.tts-widget__speed-dropdown button {
  display: block;
  width: 100%;
  padding: 4px 14px;
  font-size: 11px;
  font-weight: 600;
  border: none;
  background: none;
  color: #4b5563;
  cursor: pointer;
  text-align: center;
  font-family: inherit;
  transition: background 0.1s;
}

.tts-widget__speed-dropdown button:hover {
  background: #f0f4f8;
}

.tts-widget__speed-dropdown button.active {
  color: #0d6efd;
}

.tts-widget__volume-group {
  display: flex;
  align-items: center;
  gap: 3px;
  border-left: 1px solid #e2e8f0;
  padding-left: 6px;
  margin-left: 2px;
}

.tts-widget__volume-group svg {
  flex-shrink: 0;
  color: #4b5563;
}

.tts-widget__volume-group input[type="range"] {
  width: 50px;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: #e2e8f0;
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.tts-widget__volume-group input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #0d6efd;
  cursor: pointer;
  border: none;
}

.tts-widget__volume-group input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #0d6efd;
  cursor: pointer;
  border: none;
}

.tts-widget__spinner {
  display: none;
  width: 16px;
  height: 16px;
  border: 2.5px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  vertical-align: middle;
}

.tts-widget__button--busy .tts-widget__spinner {
  display: inline-block;
  animation: tts-spin 0.7s linear infinite;
}

.tts-widget__button--loading {
  font-size: 0;
  min-width: 48px;
  min-height: 48px;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tts-widget__button--loading .tts-widget__spinner {
  width: 22px;
  height: 22px;
  border-width: 3px;
  margin-right: 0;
}

.tts-widget__button--loading .tts-widget__toggle-icon {
  display: none;
}

@keyframes tts-spin {
  to { transform: rotate(360deg); }
}

.tts-reading {
  background-color: rgba(13, 110, 253, 0.10) !important;
  border-radius: 4px;
  transition: background-color 0.25s ease;
}

.tts-word {
  border-radius: 2px;
  transition: background-color 0.1s ease, color 0.1s ease;
}

.tts-word-active {
  background-color: rgba(13, 110, 253, 0.25) !important;
  color: #0d6efd;
}
