:root {
  --wpsp-player-bg-color: #00205B;
  --wpsp-player-bg-gradient: linear-gradient(135deg, #00205B 0%, #00143C 100%);
  --wpsp-primary-color: #D4A017;
  --wpsp-primary-hover: #E5A823;
  --wpsp-text-color: #FFFFFF;
  --wpsp-muted-color: #A0B0D0;
  --wpsp-border-radius: 12px;
  --wpsp-gold-border: rgba(212, 160, 23, 0.35);
}

/* Base Player Container & Strict Layout Isolation */
.wpspeech,
.wpspeech-isolated-player {
  position: relative !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  background: var(--wpsp-player-bg-gradient) !important;
  border-radius: var(--wpsp-border-radius) !important;
  border: 1px solid var(--wpsp-gold-border) !important;
  box-shadow: 0 8px 24px rgba(0, 32, 91, 0.25) !important;
  color: var(--wpsp-text-color) !important;
  padding: 8px 16px !important;
  box-sizing: border-box !important;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif !important;
  width: 100% !important;
  max-width: 100% !important;
  margin: 15px auto !important;
  float: none !important;
  clear: both !important;
}

.wpspeech.wpspeech--singular,
.wpspeech-isolated-player.wpspeech--singular {
  margin-bottom: 30px !important;
}

/* Clearfix after player so post content never floats next to player */
.wpspeech::after,
.wpspeech-isolated-player::after {
  content: "" !important;
  display: table !important;
  clear: both !important;
}

/* Force following post elements to clear any theme float interference */
.wpspeech + *,
.wpspeech-isolated-player + * {
  clear: both !important;
}

/* Override default button behaviors */
.wpspeech button,
.wpspeech-isolated-player button,
.wpspeech-isolated-player .mejs-button button {
  outline: none !important;
  box-shadow: none !important;
}

/* MediaElement Container Overrides */
.wpspeech .mejs-container,
.wpspeech .mejs-inner,
.wpspeech .mejs-controls,
.wpspeech .mejs-mediaelement,
.wpspeech-isolated-player .mejs-container,
.wpspeech-isolated-player .mejs-inner,
.wpspeech-isolated-player .mejs-controls,
.wpspeech-isolated-player .mejs-mediaelement,
.wpspeech-isolated-player .mejs-controls > div {
  background: transparent !important;
  background-color: transparent !important;
  box-shadow: none !important;
  border: none !important;
  outline: none !important;
  float: none !important;
  clear: both !important;
}

.wpspeech-isolated-player .mejs-container {
  height: 34px !important;
  flex: 1 1 auto !important;
}

/* Ensure post images and figures stay centered when TTS player is present */
.entry-content figure.aligncenter,
.entry-content img.aligncenter,
.td-post-content figure.aligncenter,
.td-post-content img.aligncenter,
.post-content figure.aligncenter,
.post-content img.aligncenter,
.wp-block-image.aligncenter,
figure.aligncenter,
img.aligncenter {
  display: block !important;
  margin-left: auto !important;
  margin-right: auto !important;
  clear: both !important;
}

.wpspeech .mejs-controls,
.wpspeech-isolated-player .mejs-controls {
  display: flex !important;
  align-items: center !important;
  justify-content: flex-start !important;
  height: 100% !important;
  width: 100% !important;
  padding: 0 !important;
  margin: 0 !important;
  background: transparent !important;
  gap: 10px !important;
  position: static !important;
}

.wpspeech .mejs-playpause-button,
.wpspeech .mejs-play,
.wpspeech .mejs-pause,
.wpspeech .mejs-button,
.wpspeech-isolated-player .mejs-button {
  width: 34px !important;
  height: 34px !important;
  min-width: 34px !important;
  max-width: 34px !important;
  min-height: 34px !important;
  max-height: 34px !important;
  margin: 0 !important;
  padding: 0 !important;
  flex: 0 0 34px !important;
  position: relative !important;
  background: none !important;
  box-shadow: none !important;
  border-radius: 50% !important;
}

/* Play/Pause Button - 100% Perfect Gold Circle */
.wpspeech .mejs-playpause-button button,
.wpspeech .mejs-play button,
.wpspeech .mejs-pause button,
.wpspeech .mejs-replay button,
.wpspeech-isolated-player .mejs-playpause-button button,
.wpspeech-isolated-player .mejs-play button,
.wpspeech-isolated-player .mejs-pause button {
  all: unset !important;
  box-sizing: border-box !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 34px !important;
  height: 34px !important;
  min-width: 34px !important;
  max-width: 34px !important;
  min-height: 34px !important;
  max-height: 34px !important;
  aspect-ratio: 1 / 1 !important;
  margin: 0 !important;
  padding: 0 !important;
  border: none !important;
  border-radius: 50% !important;
  background-color: var(--wpsp-primary-color, #D4A017) !important;
  cursor: pointer !important;
  box-shadow: none !important;
  filter: none !important;
  font-size: 0 !important;
  line-height: 0 !important;
  color: transparent !important;
}

.wpspeech .mejs-playpause-button button:hover,
.wpspeech .mejs-play button:hover,
.wpspeech .mejs-pause button:hover {
  background-color: var(--wpsp-primary-hover) !important;
  transform: scale(1.06) !important;
}

/* Custom Play & Pause SVGs in CSS Data URIs */
.wpspeech .mejs-play button {
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%2300205B"><polygon points="6 3 20 12 6 21 6 3"/></svg>') !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
  background-size: 14px 14px !important;
}

.wpspeech .mejs-pause button {
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%2300205B"><rect x="6" y="4" width="4" height="16" rx="1"/><rect x="14" y="4" width="4" height="16" rx="1"/></svg>') !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
  background-size: 14px 14px !important;
}

/* Volume / Mute Button - Transparent subtle icon button */
.wpspeech .mejs-volume-button,
.wpspeech .mejs-mute,
.wpspeech .mejs-unmute {
  width: 28px !important;
  height: 28px !important;
  min-width: 28px !important;
  max-width: 28px !important;
  min-height: 28px !important;
  max-height: 28px !important;
  flex: 0 0 28px !important;
  margin: 0 2px !important;
  padding: 0 !important;
  background: none !important;
  box-shadow: none !important;
  border-radius: 50% !important;
}

.wpspeech .mejs-volume-button button,
.wpspeech .mejs-mute button,
.wpspeech .mejs-unmute button {
  width: 28px !important;
  height: 28px !important;
  min-width: 28px !important;
  max-width: 28px !important;
  min-height: 28px !important;
  max-height: 28px !important;
  aspect-ratio: 1 / 1 !important;
  margin: 0 !important;
  padding: 0 !important;
  border: none !important;
  border-radius: 50% !important;
  background-color: transparent !important;
  box-shadow: none !important;
  cursor: pointer !important;
  opacity: 0.85 !important;
  transition: opacity 0.2s ease !important;
  font-size: 0 !important;
  line-height: 0 !important;
  color: transparent !important;
  font-family: inherit !important;
}

.wpspeech .mejs-volume-button button:hover,
.wpspeech .mejs-mute button:hover,
.wpspeech .mejs-unmute button:hover {
  opacity: 1 !important;
  transform: none !important;
  background-color: transparent !important;
  box-shadow: none !important;
}

.wpspeech .mejs-volume-button button,
.wpspeech .mejs-mute button {
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%23D4A017" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="11 5 6 9 2 9 2 15 6 15 11 19 11 5"/><path d="M19.07 4.93a10 10 0 0 1 0 14.14M15.54 8.46a5 5 0 0 1 0 7.07"/></svg>') !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
  background-size: 18px 18px !important;
}

.wpspeech .mejs-unmute button {
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%23A0B0D0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="11 5 6 9 2 9 2 15 6 15 11 19 11 5"/><line x1="23" y1="9" x2="17" y2="15"/><line x1="17" y1="9" x2="23" y2="15"/></svg>') !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
  background-size: 18px 18px !important;
}

/* Time Counters */
.wpspeech .mejs-time {
  display: flex !important;
  align-items: center !important;
  font-size: 12px !important;
  font-weight: 500 !important;
  color: var(--wpsp-muted-color) !important;
  padding: 0 !important;
  height: auto !important;
  line-height: 1 !important;
  flex: 0 0 auto !important;
  box-sizing: border-box !important;
  background: transparent !important;
  box-shadow: none !important;
}

.wpspeech .mejs-currenttime-container,
.wpspeech .mejs-duration-container {
  position: static !important;
  width: auto !important;
  background: transparent !important;
}

.wpspeech .mejs-time-separator {
  display: inline-block !important;
  margin: 0 3px !important;
  color: var(--wpsp-muted-color) !important;
  opacity: 0.7;
}

/* Progress Rail */
.wpspeech .mejs-time-rail {
  flex: 1 1 auto !important;
  margin: 0 8px !important;
  padding: 0 !important;
  height: 24px !important;
  display: flex !important;
  align-items: center !important;
  position: relative !important;
  min-width: 50px !important;
  background: transparent !important;
}

.wpspeech .mejs-time-total {
  width: 100% !important;
  height: 6px !important;
  border-radius: 3px !important;
  background: rgba(255, 255, 255, 0.18) !important;
  margin: 0 !important;
  padding: 0 !important;
  position: relative !important;
  cursor: pointer !important;
  overflow: hidden !important;
}

.wpspeech .mejs-time-buffering {
  height: 6px !important;
  border-radius: 3px !important;
}

.wpspeech .mejs-time-loaded {
  height: 6px !important;
  border-radius: 3px !important;
  background: rgba(255, 255, 255, 0.28) !important;
}

.wpspeech .mejs-time-current {
  height: 6px !important;
  border-radius: 3px !important;
  background: linear-gradient(90deg, #D4A017, #F3E0A7) !important;
}

.wpspeech .mejs-time-handle {
  display: none !important;
}

.wpspeech .mejs-time-float {
  display: none !important;
}

/* Hide Volume Slider to avoid layout clutter */
.wpspeech .mejs-volume-button .mejs-volume-slider {
  display: none !important;
}

/* Voice Selector Section */
.wpspeech__voice {
  position: relative !important;
  margin-left: 10px !important;
  flex: 0 0 auto !important;
}

.wpspeech__voice__button {
  display: flex !important;
  align-items: center !important;
  gap: 6px !important;
  background: rgba(255, 255, 255, 0.08) !important;
  border: 1px solid rgba(212, 160, 23, 0.3) !important;
  border-radius: 20px !important;
  padding: 4px 12px !important;
  color: var(--wpsp-text-color) !important;
  font-size: 12px !important;
  font-weight: 500 !important;
  cursor: pointer !important;
  transition: all 0.2s ease !important;
  outline: none !important;
  height: 32px !important;
  box-sizing: border-box !important;
}

.wpspeech__voice__button:hover,
.wpspeech__voice__button--pressed {
  background: rgba(212, 160, 23, 0.18) !important;
  border-color: var(--wpsp-primary-color) !important;
  color: #FFFFFF !important;
}

.wpspeech__voice__button .wpsp-voice-icon {
  width: 14px !important;
  height: 14px !important;
  fill: var(--wpsp-primary-color) !important;
}

.wpspeech__voice__button .wpsp-voice-title {
  white-space: nowrap !important;
}

.wpspeech__voice__button .wpsp-chevron-icon {
  width: 12px !important;
  height: 12px !important;
  stroke: var(--wpsp-muted-color) !important;
  transition: transform 0.2s ease !important;
}

.wpspeech__voice__button--pressed .wpsp-chevron-icon {
  transform: rotate(180deg) !important;
  stroke: var(--wpsp-primary-color) !important;
}

/* Voice List Dropdown Card */
.wpspeech__voice__list {
  position: absolute !important;
  right: 0 !important;
  top: calc(100% + 8px) !important;
  background: #00163A !important;
  border: 1px solid rgba(212, 160, 23, 0.4) !important;
  border-radius: 12px !important;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45) !important;
  padding: 6px !important;
  margin: 0 !important;
  list-style: none !important;
  list-style-type: none !important;
  min-width: 160px !important;
  max-width: 260px !important;
  z-index: 99999 !important;
  opacity: 0 !important;
  visibility: hidden !important;
  transform: translateY(-8px) !important;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1) !important;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif !important;
}

.wpspeech__voice__list--show {
  opacity: 1 !important;
  visibility: visible !important;
  transform: translateY(0) !important;
}

.wpspeech__voice__list__item {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  padding: 8px 12px !important;
  border-radius: 8px !important;
  font-size: 13px !important;
  font-weight: 400 !important;
  color: #D1DDF5 !important;
  cursor: pointer !important;
  transition: all 0.15s ease !important;
  margin-bottom: 2px !important;
  user-select: none !important;
  white-space: nowrap !important;
  list-style: none !important;
  list-style-type: none !important;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif !important;
}

.wpspeech__voice__list__item,
.wpspeech__voice__list__item *,
.wpspeech .wpsp-item-text,
.wpspeech .wpsp-item-text * {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif !important;
}

.wpspeech__voice__list__item::before,
.wpspeech__voice__list__item::after,
.wpspeech__voice__list__item *::before,
.wpspeech__voice__list__item *::after,
.wpspeech .wpsp-item-text::before,
.wpspeech .wpsp-item-text::after {
  display: none !important;
  content: "" !important;
  width: 0 !important;
  height: 0 !important;
  border: none !important;
  background: none !important;
}

.wpspeech__voice__list__item:last-child {
  margin-bottom: 0 !important;
}

.wpspeech__voice__list__item:hover {
  background: rgba(255, 255, 255, 0.1) !important;
  color: #FFFFFF !important;
}

.wpspeech__voice__list__item--active {
  background: rgba(212, 160, 23, 0.18) !important;
  color: var(--wpsp-primary-color) !important;
  font-weight: 600 !important;
}

.wpspeech__voice__list__item .wpsp-check-icon {
  display: none !important;
  stroke: var(--wpsp-primary-color) !important;
  margin-left: 8px !important;
  flex-shrink: 0 !important;
}

.wpspeech__voice__list__item--active .wpsp-check-icon {
  display: inline-block !important;
}

/* RTL Support */
.rtl .wpspeech__voice {
  margin-left: 0 !important;
  margin-right: 10px !important;
}

.rtl .wpspeech__voice__list {
  left: 0 !important;
  right: auto !important;
}

/* Responsive UI tweaks */
@media (max-width: 576px) {
  .wpspeech {
    padding: 6px 10px !important;
  }

  .wpspeech .mejs-time-rail {
    margin: 0 4px !important;
  }

  .wpspeech__voice__button {
    padding: 4px 8px !important;
  }

  .wpspeech__voice__button .wpsp-voice-title {
    max-width: 85px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }
}
