/* Keep topic commands on one row even when shared cost controls shrink to fit. */
.site-shell.workspace-open .workspace .topic-assistant-actions {
  display: flex;
  box-sizing: border-box;
  flex-direction: row;
  flex-wrap: nowrap !important;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
}

.site-shell.workspace-open .workspace .topic-assistant-actions > button.credit-action {
  flex: 0 0 216px;
  width: 216px;
  min-width: 216px;
  max-width: none;
}

.site-shell.workspace-open .workspace .topic-assistant-actions > button.generation-cancel-action {
  flex: 0 0 auto;
  width: auto;
  min-width: 0;
  max-width: none;
  margin-left: 0;
}

/* Match the adjacent character review command without changing other stages. */
.site-shell.workspace-open .workspace .prompt-stage .character-manager-actions {
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
}

.site-shell.workspace-open .workspace .prompt-stage .character-manager-actions :is(
  .character-manager-reference-actions, .character-manager-source-controls
) {
  flex: 0 0 auto;
  flex-wrap: nowrap;
  width: auto;
  max-width: none;
}

.site-shell.workspace-open .workspace .prompt-stage .character-manager-source-controls > .character-mode-switch {
  order: 0;
  flex: 0 0 220px;
  width: 220px;
}

.site-shell.workspace-open .workspace .prompt-stage .character-manager-source-controls > .character-manager-review {
  display: inline-flex;
  flex: 0 0 auto;
  flex-wrap: nowrap;
  width: auto;
  height: 42px;
  min-height: 42px;
  gap: 7px;
  padding-inline: 10px;
  padding-block: 0;
  font-size: 12px;
  white-space: nowrap !important;
}

.site-shell.workspace-open .workspace .prompt-stage .character-manager-review > :is(span, .action-label) {
  flex: 0 0 auto;
  min-block-size: 0;
  font-size: 12px;
  white-space: nowrap !important;
}

.site-shell.workspace-open .workspace .prompt-stage .character-manager-review > small {
  display: block;
  flex: 0 0 auto;
  width: auto;
  min-block-size: 24px;
  padding: 2px 6px;
  font-size: 11px;
  line-height: 1.4;
  white-space: nowrap !important;
}

.site-shell.workspace-open .workspace .prompt-stage .character-manager-review > svg {
  flex: 0 0 16px;
  width: 16px;
  height: 16px;
}

.site-shell.workspace-open .workspace .prompt-stage .prompt-storyboard-actions {
  flex-wrap: nowrap;
  justify-content: flex-start;
  gap: 8px;
  min-width: 0;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
}

/* Nested groups share the outer scroller so every command stays on one row. */
.site-shell.workspace-open .workspace .prompt-stage .character-manager-actions .prompt-storyboard-actions {
  flex: 1 0 auto;
  justify-content: flex-end;
  width: max-content;
  max-width: none;
  overflow: visible;
}

.site-shell.workspace-open .workspace .prompt-stage .prompt-storyboard-actions > :is(button, .storyboard-progress-status) {
  flex: 0 0 auto;
  flex-wrap: nowrap;
  white-space: nowrap;
}

.site-shell.workspace-open .workspace .prompt-stage .prompt-storyboard-actions > .storyboard-progress-status {
  display: none;
}

.site-shell.workspace-open .workspace .prompt-stage .prompt-storyboard-actions > button {
  width: auto;
  min-width: 0;
  max-width: none;
  height: 42px;
  min-height: 42px;
}

.site-shell.workspace-open .workspace .prompt-stage .prompt-storyboard-actions > button.credit-action {
  display: inline-flex;
  box-sizing: border-box;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  flex-wrap: nowrap;
  gap: 7px;
  width: auto;
  min-width: 0;
  max-width: 100%;
  height: 42px;
  min-height: 42px;
  padding: 0 12px;
  border-radius: 4px;
  font-size: 12px;
  line-height: 1.4;
  white-space: nowrap !important;
  text-wrap: nowrap;
}

.site-shell.workspace-open .workspace .prompt-stage .prompt-storyboard-actions > button.credit-action > svg {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
}

.site-shell.workspace-open .workspace .prompt-stage .prompt-storyboard-actions > button.credit-action > .action-label {
  flex: 0 0 auto;
  min-block-size: 0;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap !important;
}

.site-shell.workspace-open .workspace .prompt-stage .prompt-storyboard-actions > button.credit-action > small {
  display: block;
  box-sizing: border-box;
  flex: 0 1 auto;
  align-items: center;
  justify-content: center;
  width: auto;
  min-width: 0;
  max-width: 110px;
  min-block-size: 24px;
  margin: 0;
  padding: 2px 6px;
  border: 1px solid var(--control-command-border, var(--ui-edge));
  border-radius: 3px;
  font-size: 11px;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap !important;
}

@media (max-width: 760px) {
  .site-shell.workspace-open .workspace .prompt-stage .prompt-storyboard-actions {
    justify-content: flex-start;
    gap: 8px;
  }

  .site-shell.workspace-open .workspace .prompt-stage .prompt-storyboard-actions > button.credit-action {
    padding-inline: 10px;
  }
}

/* Shared command geometry applies to every workbench stage and task banner. */
.site-shell.workspace-open .workspace button:is(
  .primary-action, .secondary-action, .text-button, .credit-action,
  .generation-recovery-action, .generation-retry-action,
  .workspace-primary-action, .workspace-step-button
)[type="button"],
.site-shell.workspace-open .workspace .scene-card-meta > button.scene-image-action {
  display: inline-flex;
  box-sizing: border-box;
  align-items: center;
  justify-content: center;
  flex-wrap: nowrap;
  gap: 7px;
  height: 42px;
  min-height: 42px;
  min-block-size: 42px;
  max-height: 42px;
  padding: 0 12px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: 0;
  white-space: nowrap !important;
}

.site-shell.workspace-open .workspace button:is(
  .primary-action, .secondary-action, .text-button, .credit-action,
  .workspace-primary-action, .workspace-step-button
)[type="button"] > svg,
.site-shell.workspace-open .workspace .scene-card-meta > button.scene-image-action > svg {
  flex: 0 0 16px;
  width: 16px;
  height: 16px;
}

.site-shell.workspace-open .workspace button:is(
  .credit-action, .workspace-primary-action
)[type="button"] > :is(.action-label, span),
.site-shell.workspace-open .workspace .scene-card-meta > button.scene-image-action > .action-label {
  flex: 0 1 auto;
  min-width: 0;
  min-block-size: 0;
  font-size: 12px;
  line-height: 1.4;
  white-space: nowrap !important;
}

.site-shell.workspace-open .workspace .scene-card-meta > button.scene-image-action {
  width: auto;
  max-width: 100%;
}

.site-shell.workspace-open .workspace .scene-card-meta > button.scene-image-action > .scene-image-cost {
  flex: 0 0 auto;
  width: auto;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding-left: 7px;
  font-size: 11px;
  line-height: 1.4;
  white-space: nowrap !important;
}

.site-shell.workspace-open .workspace button:is(
  .credit-action, .workspace-primary-action
)[type="button"] > small {
  display: block;
  box-sizing: border-box;
  flex: 0 1 auto;
  width: auto;
  min-width: 0;
  max-width: 110px;
  min-block-size: 24px;
  margin: 0;
  padding: 2px 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 11px;
  line-height: 1.4;
  white-space: nowrap !important;
}

.site-shell.workspace-open .workspace button:is(
  .stage-status-dismiss, .character-manager-retry, .character-manager-upload
) {
  box-sizing: border-box;
  flex: 0 0 34px;
  width: 34px;
  min-width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  border-radius: 4px;
}

/* Clear commands need the same visible surface as the adjacent actions. */
.site-shell.workspace-open .workspace button.text-button.danger-text-button {
  border: 1px solid var(--button-action-border, var(--control-command-border, var(--ui-edge))) !important;
  color: var(--button-action-text, var(--control-text, var(--ui-text))) !important;
  background: var(--button-action-bg, var(--control-command-bg, var(--ui-surface-raised))) !important;
}

.site-shell.workspace-open .workspace button.text-button.danger-text-button:is(:hover, :focus-visible):not(:disabled):not([aria-disabled='true']) {
  border-color: var(--control-danger-border, var(--ui-danger, #d98b9e)) !important;
  color: var(--control-danger-text, #ffdce4) !important;
  background: var(--control-danger, #693748) !important;
}

.site-shell.workspace-open .workspace button.text-button.danger-text-button:is(:disabled, [aria-disabled='true']) {
  border-color: var(--button-muted-border, var(--control-disabled-border, var(--ui-edge))) !important;
  color: var(--button-muted-text, var(--control-disabled-text, var(--ui-text-secondary))) !important;
  background: var(--button-muted-bg, var(--control-disabled, var(--ui-surface))) !important;
}

.site-shell.workspace-open .workspace .voice-stage .voice-tuning-popover {
  width: min(292px, calc(100vw - 32px));
  max-height: min(48dvh, 240px);
  min-height: 0;
  padding: 8px 10px;
}

.site-shell.workspace-open .workspace .voice-stage .voice-tuning-popover > header {
  align-items: center;
  min-height: 28px;
  padding-right: 34px;
  margin-bottom: 4px;
}

.site-shell.workspace-open .workspace .voice-stage .voice-tuning-popover > header .icon-action {
  position: absolute !important;
  top: 8px;
  right: 10px;
  width: 28px;
  min-width: 28px;
  height: 28px;
  min-height: 28px;
  padding: 0;
}

.site-shell.workspace-open .workspace .voice-stage .voice-toolbar-tuning-grid {
  gap: 2px;
}

.site-shell.workspace-open .workspace .voice-stage .voice-toolbar-tuning-grid label {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 28px;
  font-size: 11px;
}

.site-shell.workspace-open .workspace .voice-stage .voice-toolbar-tuning-grid label > span {
  align-items: center;
  gap: 4px;
  min-width: 0;
  white-space: nowrap;
}

.site-shell.workspace-open .workspace .voice-stage .voice-toolbar-tuning-grid input[type="range"] {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  height: 24px;
  min-height: 24px;
  min-block-size: 24px;
  max-height: 24px;
  margin: 0;
  padding: 0;
}

.site-shell.workspace-open .workspace .voice-stage .voice-tuning-popover :is(.voice-toolbar-tuning-grid small, .voice-tuning-baseline-note) {
  display: none;
}

.site-shell.workspace-open .workspace .voice-stage .voice-tuning-popover .voice-settings-reset {
  position: absolute !important;
  top: 8px;
  right: 44px;
  width: 28px;
  min-width: 28px;
  height: 28px;
  min-height: 28px;
  min-block-size: 28px;
  max-height: 28px;
  gap: 0;
  margin: 0;
  padding: 0;
  font-size: 0;
}

.site-shell.workspace-open .workspace .voice-stage .voice-tuning-popover .voice-settings-reset > svg {
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
}

/* An open voice menu and its trigger form one continuous outlined surface. */
.site-shell.workspace-open .workspace .voice-stage .voice-control-main {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 10px;
}

.site-shell.workspace-open .workspace .voice-stage .voice-toolbar-disclosure,
.site-shell.workspace-open .workspace .voice-stage .voice-toolbar-disclosure[open] {
  box-sizing: border-box;
  width: 164px;
  min-width: 0;
  max-width: 164px;
  flex: 0 0 164px;
}

.site-shell.workspace-open .workspace .voice-stage .voice-toolbar-disclosure {
  position: relative;
  overflow: visible;
}

.site-shell.workspace-open .workspace .voice-stage .voice-toolbar-disclosure > summary {
  box-sizing: border-box;
  display: flex;
  width: 100%;
  min-width: 0;
  height: 42px;
  min-height: 42px;
  max-height: 42px;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  position: relative !important;
  border: 1px solid var(--button-action-border, var(--ui-edge)) !important;
  border-radius: 4px;
  background: var(--button-action-bg, var(--ui-surface-raised)) !important;
}

.site-shell.workspace-open .workspace .voice-stage .voice-toolbar-disclosure > summary > span {
  display: block;
  min-width: 0;
}

.site-shell.workspace-open .workspace .voice-stage .voice-toolbar-disclosure > summary b {
  display: block;
  font-size: 12px;
  font-weight: 600;
  line-height: 18px;
}

.site-shell.workspace-open .workspace .voice-stage .voice-toolbar-disclosure > summary small {
  display: none;
}

.site-shell.workspace-open .workspace .voice-stage .voice-selector-disclosure > summary {
  justify-content: space-between;
}

.site-shell.workspace-open .workspace .voice-stage .voice-tuning-disclosure > summary {
  justify-content: center;
}

.site-shell.workspace-open .workspace .voice-stage .voice-toolbar-disclosure[open] {
  z-index: 46;
}

.site-shell.workspace-open .workspace .voice-stage .voice-toolbar-disclosure[open] > summary,
.site-shell.workspace-open .workspace .voice-stage .voice-toolbar-disclosure[open] > summary:is(:hover, :focus-visible) {
  z-index: 2;
  border-color: var(--ui-accent) !important;
  border-top-color: transparent !important;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  background: var(--ui-surface-raised) !important;
  box-shadow: none !important;
  transition: none !important;
}

.site-shell.workspace-open .workspace .voice-stage .voice-toolbar-disclosure[open] > summary::before {
  position: absolute;
  z-index: 1;
  top: -2px;
  right: 0;
  left: 0;
  height: 3px;
  background: var(--ui-surface-raised);
  pointer-events: none;
  content: '';
}

.site-shell.workspace-open .workspace .voice-stage .voice-toolbar-disclosure > .voice-toolbar-popover {
  position: absolute;
  z-index: 1;
  top: auto;
  bottom: calc(100% - 1px);
  margin: 0;
  border-color: var(--ui-accent) !important;
  background: var(--ui-surface-raised) !important;
  box-shadow: 0 -8px 20px color-mix(in srgb, var(--ui-canvas, #0e1924) 28%, transparent) !important;
}

.site-shell.workspace-open .workspace .voice-stage .voice-selector-disclosure > .voice-selector-popover {
  right: auto;
  left: 0;
  border-radius: 6px 6px 6px 0;
}

.site-shell.workspace-open .workspace .voice-stage .voice-tuning-disclosure > .voice-tuning-popover {
  right: 0;
  left: auto;
  border-radius: 6px 6px 0 6px;
}

@media (max-width: 760px) {
  .site-shell.workspace-open .workspace .voice-stage .voice-control-main {
    gap: 8px;
  }

  .site-shell.workspace-open .workspace .voice-stage .voice-control-label {
    flex: 0 0 auto;
  }

  .site-shell.workspace-open .workspace .voice-stage .voice-toolbar-disclosure,
  .site-shell.workspace-open .workspace .voice-stage .voice-toolbar-disclosure[open] {
    width: 0;
    max-width: none;
    flex: 1 1 0;
  }
}
