.speech-input-host.speech-input-host-positioned {
  position: relative;
}

.speech-input-control-layer {
  position: absolute;
  right: var(--speech-control-right, 12px);
  bottom: var(--speech-control-bottom, 12px);
  z-index: 18;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  width: var(--speech-control-width, calc(100% - 24px));
  height: 28px;
  pointer-events: none;
}

.speech-input-control-layer[hidden],
.speech-input-control-layer .free-prompt-speech-panel[hidden],
.speech-input-toast[hidden] {
  display: none !important;
}

.speech-input-control-layer .free-prompt-speech-button {
  position: relative;
  z-index: 2;
  display: inline-flex;
  flex: 0 0 28px;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  min-width: 28px;
  padding: 0;
  border: 0;
  border-radius: 0;
  color: #8b929f;
  background: transparent;
  box-shadow: none;
  cursor: pointer;
  pointer-events: auto;
  transition: color 150ms ease, opacity 150ms ease, transform 150ms ease;
}

.speech-input-control-layer .free-prompt-speech-button :is(.lucide, svg) {
  width: 17px;
  height: 17px;
  stroke-width: 1.9;
}

.speech-input-control-layer .free-prompt-speech-button:hover:not(:disabled) {
  color: #6f7682;
  transform: translateY(-1px);
}

.speech-input-control-layer .free-prompt-speech-button:focus-visible {
  border-radius: 6px;
  outline: 2px solid rgba(91, 73, 230, 0.38);
  outline-offset: 2px;
}

.speech-input-control-layer .free-prompt-speech-button:disabled {
  cursor: wait;
  opacity: 0.52;
}

.speech-input-control-layer .free-prompt-speech-button.is-panel-active {
  opacity: 0;
  pointer-events: none;
}

.speech-input-host.is-speech-active .speech-input-target {
  padding-bottom: 48px !important;
}

.speech-input-control-layer .free-prompt-speech-panel {
  position: absolute;
  inset: 0;
  z-index: 3;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 0;
  height: 28px;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  pointer-events: auto;
  transform-origin: right bottom;
  animation: free-prompt-speech-panel-in 180ms cubic-bezier(0.2, 0.72, 0.2, 1) both;
}

.speech-input-control-layer .free-prompt-speech-panel-button {
  display: inline-flex;
  flex: 0 0 28px;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  min-width: 28px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: #8b929f;
  background: transparent;
  box-shadow: none;
  cursor: pointer;
  transition: color 140ms ease, transform 140ms ease;
}

.speech-input-control-layer .free-prompt-speech-panel-button:hover:not(:disabled),
.speech-input-control-layer .free-prompt-speech-panel-button:focus-visible {
  color: #6f7682;
  background: transparent;
}

.speech-input-control-layer .free-prompt-speech-panel-button:focus-visible {
  outline: 2px solid rgba(196, 184, 255, 0.86);
  outline-offset: 1px;
}

.speech-input-control-layer .free-prompt-speech-panel-button:active:not(:disabled) {
  transform: scale(0.94);
}

.speech-input-control-layer .free-prompt-speech-panel-button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.speech-input-control-layer .free-prompt-speech-panel-button :is(.lucide, svg) {
  width: 16px;
  height: 16px;
  stroke-width: 1.8;
}

.speech-input-control-layer .free-prompt-speech-stop :is(.lucide, svg) {
  width: 15px;
  height: 15px;
  stroke-width: 2.2;
}

.speech-input-control-layer .free-prompt-speech-wave {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  justify-content: center;
  min-width: 0;
  height: 28px;
  margin: 0 2px;
  gap: 2px;
  overflow: hidden;
}

.speech-input-control-layer .free-prompt-speech-wave i {
  display: block;
  flex: 0 0 2px;
  width: 2px;
  height: 2px;
  border-radius: 999px;
  background: #9aa0aa;
  opacity: 0.58;
  transition: height 42ms linear, opacity 42ms linear;
}

.speech-input-control-layer .free-prompt-speech-panel.is-connecting .free-prompt-speech-wave i,
.speech-input-control-layer .free-prompt-speech-panel.is-stopping .free-prompt-speech-wave i {
  animation: free-prompt-speech-wait 980ms ease-in-out infinite alternate;
  animation-delay: calc(var(--speech-bar-index) * -17ms);
}

.speech-input-control-layer .free-prompt-speech-status {
  position: fixed;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.speech-input-toast {
  position: fixed;
  top: 18px;
  left: 50%;
  z-index: 2147483646;
  max-width: min(420px, calc(100vw - 32px));
  padding: 9px 14px;
  border: 1px solid rgba(139, 146, 159, 0.24);
  border-radius: 10px;
  color: #3f4652;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 10px 28px rgba(42, 48, 61, 0.14);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  transform: translateX(-50%);
}

/* Product-main keeps optimization in its three-button row, not independently
 * positioned against the shared speech target. */
html body.feature-focus-mode.workstation-feature-mode[data-active-feature]:not([data-active-feature="pet-product-main-image"])
  #task-panel .extra-prompt-box #prompt-optimize-button {
  position: absolute !important;
  right: auto !important;
  bottom: var(--speech-target-bottom, 12px) !important;
  left: var(--speech-target-left, 12px) !important;
  width: auto !important;
  min-width: 0 !important;
  max-width: none !important;
  flex: 0 0 auto !important;
  justify-self: start !important;
  margin: 0 !important;
}

html body.feature-focus-mode.workstation-feature-mode[data-active-feature]:not([data-active-feature="pet-product-main-image"])
  #task-panel .speech-input-host.extra-prompt-box:has(> #video-material-mention:not([hidden]))
  #prompt-optimize-button.speech-input-optimize-action {
  position: absolute !important;
  grid-column: auto !important;
  grid-row: auto !important;
  inset: auto auto var(--speech-target-bottom, 12px) var(--speech-target-left, 12px) !important;
  width: auto !important;
  min-width: 0 !important;
  max-width: none !important;
  flex: 0 0 auto !important;
  align-self: auto !important;
  justify-self: start !important;
  margin: 0 !important;
}

/* Reserve the field's right edge for voice input; text actions stay on the left. */
html body.feature-focus-mode.workstation-feature-mode[data-active-feature="pet-product-main-image"]
  #task-panel .extra-prompt-box {
  container-type: inline-size;
  container-name: product-main-copy;
}

html body.feature-focus-mode.workstation-feature-mode[data-active-feature="pet-product-main-image"]
  #task-panel .pet-product-main-copy-inline-actions {
  left: var(--speech-target-left, 12px) !important;
  right: auto !important;
  bottom: var(--speech-target-bottom, 12px) !important;
  display: grid !important;
  grid-template-columns: 0.8fr 1.2fr 1fr !important;
  align-items: center !important;
  column-gap: 6px !important;
  width: 312px;
  max-width: calc(100% - 64px) !important;
}

html body.feature-focus-mode.workstation-feature-mode[data-active-feature="pet-product-main-image"]
  #task-panel #pet-product-main-copy-switches:not([hidden]) {
  display: contents !important;
}

html body.feature-focus-mode.workstation-feature-mode[data-active-feature="pet-product-main-image"]
  #task-panel :is(#pet-product-main-no-text, #pet-product-main-text-strict, #prompt-optimize-button) {
  width: 100% !important;
  min-width: 0 !important;
  height: 28px !important;
  min-height: 28px !important;
  padding: 0 4px !important;
  gap: 3px !important;
  font-size: 10px !important;
  font-weight: 500 !important;
}

html body.feature-focus-mode.workstation-feature-mode[data-active-feature="pet-product-main-image"]
  #task-panel :is(#pet-product-main-no-text, #pet-product-main-text-strict) > i {
  width: 18px;
}

html body.feature-focus-mode.workstation-feature-mode[data-active-feature="pet-product-main-image"]
  #task-panel :is(#pet-product-main-no-text, #pet-product-main-text-strict) > i::after {
  top: 4px;
  left: 2px;
  width: 8px;
  height: 8px;
}

html body.feature-focus-mode.workstation-feature-mode[data-active-feature="pet-product-main-image"]
  #task-panel :is(#pet-product-main-no-text, #pet-product-main-text-strict).selected > i::after {
  transform: translateX(6px);
}

html body.feature-focus-mode.workstation-feature-mode[data-active-feature="pet-product-main-image"]
  #task-panel #extra-prompt {
  padding-bottom: 52px !important;
}

/* On very narrow fields keep the microphone bottom-right and put the complete
 * left-aligned text row one line above it, rather than squeeze the labels. */
@container product-main-copy (max-width: 304px) {
  html body.feature-focus-mode.workstation-feature-mode[data-active-feature="pet-product-main-image"]
    #task-panel .pet-product-main-copy-inline-actions {
    max-width: calc(100% - 24px) !important;
    bottom: calc(var(--speech-target-bottom, 12px) + 36px) !important;
  }

  html body.feature-focus-mode.workstation-feature-mode[data-active-feature="pet-product-main-image"]
    #task-panel #extra-prompt {
    padding-bottom: 84px !important;
  }
}

/* Free generate keeps both prompt actions together at the field's lower-left edge. */
html:not([data-mobile-workbench="true"]) body.feature-focus-mode.workstation-feature-mode[data-active-feature="free-generate"]
  #task-panel .speech-input-host.extra-prompt-box:has(> #video-material-mention:not([hidden])) {
  grid-template-columns: max-content max-content minmax(0, 1fr) !important;
  column-gap: 8px !important;
}

html:not([data-mobile-workbench="true"]) body.feature-focus-mode.workstation-feature-mode[data-active-feature="free-generate"]
  #task-panel .speech-input-host.extra-prompt-box:has(> #video-material-mention:not([hidden]))
  #prompt-optimize-button.speech-input-optimize-action {
  position: relative !important;
  grid-column: 1 !important;
  grid-row: 2 !important;
  inset: auto !important;
  z-index: 2 !important;
  align-self: end !important;
  justify-self: start !important;
  margin: 0 0 14px 16px !important;
}

html body.feature-focus-mode.workstation-feature-mode[data-active-feature="free-generate"]
  .speech-input-host .free-page-toolbar {
  right: 12px !important;
  left: 12px !important;
  justify-content: flex-start !important;
}

html body.feature-focus-mode.workstation-feature-mode[data-active-feature="free-generate"]
  .speech-input-host.free-page-prompt:has(.free-material-picker-button) .free-page-toolbar {
  justify-content: flex-start !important;
}

html body.feature-focus-mode.workstation-feature-mode[data-active-feature="free-generate"]
  .speech-input-host .free-prompt-optimize-button.speech-input-optimize-action {
  order: -2 !important;
  margin: 0 6px 0 0 !important;
}

html body.feature-focus-mode.workstation-feature-mode[data-active-feature="free-generate"]
  .speech-input-host .free-page-toolbar-left {
  order: -1 !important;
  flex: 0 1 auto !important;
}

html body.video-workspace-mode
  .speech-input-host .video-free-prompt-actions {
  justify-content: flex-start !important;
}

html body.video-workspace-mode
  .speech-input-host [data-vf-optimize-prompt].speech-input-optimize-action {
  order: -1 !important;
  margin: 0 2px 0 0 !important;
}

html body.feature-focus-mode.workstation-feature-mode[data-active-feature]
  .speech-input-host :is(
    #prompt-optimize-button.speech-input-optimize-action,
    .free-prompt-optimize-button.speech-input-optimize-action,
    [data-vf-optimize-prompt].speech-input-optimize-action
  ) {
  border-color: rgba(139, 146, 159, 0.3) !important;
  color: #8b929f !important;
  background: rgba(246, 247, 249, 0.96) !important;
  box-shadow: none !important;
  font-size: 11px !important;
  font-weight: 500 !important;
}

html body.feature-focus-mode.workstation-feature-mode[data-active-feature]
  .speech-input-host :is(
    #prompt-optimize-button.speech-input-optimize-action,
    .free-prompt-optimize-button.speech-input-optimize-action,
    [data-vf-optimize-prompt].speech-input-optimize-action
  ) > span {
  color: inherit !important;
  font-size: 11px !important;
  font-weight: 500 !important;
}

html body.feature-focus-mode.workstation-feature-mode[data-active-feature]
  .speech-input-host :is(
    #prompt-optimize-button.speech-input-optimize-action,
    .free-prompt-optimize-button.speech-input-optimize-action,
    [data-vf-optimize-prompt].speech-input-optimize-action
  ):hover:not(:disabled) {
  border-color: rgba(112, 120, 132, 0.42) !important;
  color: #6f7682 !important;
  background: #eef0f3 !important;
}

html body.feature-focus-mode.workstation-feature-mode[data-active-feature]
  .speech-input-host :is(
    #prompt-optimize-button.speech-input-optimize-action,
    .free-prompt-optimize-button.speech-input-optimize-action,
    [data-vf-optimize-prompt].speech-input-optimize-action
  ):is(:disabled, .is-busy, [aria-busy="true"]) {
  border-color: rgba(139, 146, 159, 0.22) !important;
  color: #9aa0aa !important;
  background: rgba(246, 247, 249, 0.88) !important;
  box-shadow: none !important;
}

html[data-theme="dark"] body.feature-focus-mode.workstation-feature-mode[data-active-feature]
  .speech-input-host :is(
    #prompt-optimize-button.speech-input-optimize-action,
    .free-prompt-optimize-button.speech-input-optimize-action,
    [data-vf-optimize-prompt].speech-input-optimize-action
  ) {
  border-color: rgba(166, 172, 182, 0.28) !important;
  color: #a6acb6 !important;
  background: rgba(39, 43, 51, 0.96) !important;
}

html body.video-workspace-mode
  .speech-input-host [data-vf-optimize-prompt].speech-input-optimize-action {
  border-color: rgba(139, 146, 159, 0.3) !important;
  color: #8b929f !important;
  background: rgba(246, 247, 249, 0.96) !important;
  box-shadow: none !important;
  font-size: 11px !important;
  font-weight: 500 !important;
}

html body.video-workspace-mode
  .speech-input-host [data-vf-optimize-prompt].speech-input-optimize-action:hover:not(:disabled) {
  border-color: rgba(112, 120, 132, 0.42) !important;
  color: #6f7682 !important;
  background: #eef0f3 !important;
}

html body.video-workspace-mode
  .speech-input-host [data-vf-optimize-prompt].speech-input-optimize-action:is(:disabled, [aria-busy="true"]) {
  border-color: rgba(139, 146, 159, 0.22) !important;
  color: #9aa0aa !important;
  background: rgba(246, 247, 249, 0.88) !important;
}

html[data-theme="dark"] body.video-workspace-mode
  .speech-input-host [data-vf-optimize-prompt].speech-input-optimize-action {
  border-color: rgba(166, 172, 182, 0.28) !important;
  color: #a6acb6 !important;
  background: rgba(39, 43, 51, 0.96) !important;
}

html[data-theme="dark"] .speech-input-control-layer .free-prompt-speech-button,
html[data-theme="dark"] .speech-input-control-layer .free-prompt-speech-panel-button {
  color: #a6acb6;
}

html[data-theme="dark"] .speech-input-control-layer .free-prompt-speech-button:hover:not(:disabled),
html[data-theme="dark"] .speech-input-control-layer .free-prompt-speech-panel-button:hover:not(:disabled) {
  color: #c4c9d0;
}

html[data-theme="dark"] .speech-input-control-layer .free-prompt-speech-wave i {
  background: #a6acb6;
}

html[data-theme="dark"] .speech-input-toast {
  border-color: rgba(255, 255, 255, 0.12);
  color: #e5e7eb;
  background: rgba(24, 27, 35, 0.96);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.34);
}

@keyframes free-prompt-speech-panel-in {
  from { opacity: 0; transform: translateY(5px) scaleX(0.96); }
  to { opacity: 1; transform: translateY(0) scaleX(1); }
}

@keyframes free-prompt-speech-wait {
  from { height: 2px; opacity: 0.38; }
  to { height: 7px; opacity: 0.72; }
}

@media (prefers-reduced-motion: reduce) {
  .speech-input-control-layer .free-prompt-speech-button,
  .speech-input-control-layer .free-prompt-speech-panel,
  .speech-input-control-layer .free-prompt-speech-panel-button,
  .speech-input-control-layer .free-prompt-speech-wave i {
    animation: none;
    transition: none;
  }
}
