/*
 * Dr.Prompt · global containment pass (P8)
 *
 * Presentation-only geometry safeguards. Every framed surface keeps its
 * border, padding, and content inside the same box; flexible children are
 * allowed to shrink instead of expanding the parent on narrow screens.
 */

/* Shared page frames: width includes padding and never exceeds its viewport. */
#app[data-active-view] .page-scroll,
#app[data-active-view] .workbench-grid,
#app[data-active-view] .setup-shell,
#app[data-active-view] .setup-content-grid,
#app[data-active-view] .task-session-board,
#app[data-active-view] .template-use-workspace,
#app[data-active-view] .template-grid,
#app[data-active-view] .schema-grid,
#app[data-active-view] .workflow-board,
#app[data-active-view] .model-service-workspace,
#app[data-active-view] .project-log-page,
#app[data-active-view] .project-log-grid {
  box-sizing: border-box !important;
  min-width: 0 !important;
  max-width: 100% !important;
}

#app[data-active-view] .page-scroll {
  overflow-x: clip !important;
}

/* Flexible/grid children must be shrinkable before their text is allowed to
   wrap. This is the main protection against inner cards escaping outer cards. */
#app[data-active-view] .workbench-grid > *,
#app[data-active-view] .setup-content-grid > *,
#app[data-active-view] .task-session-board > *,
#app[data-active-view] .template-use-workspace > *,
#app[data-active-view] .template-grid > *,
#app[data-active-view] .schema-grid > *,
#app[data-active-view] .workflow-board > *,
#app[data-active-view] .model-service-workspace > *,
#app[data-active-view] .project-log-page > *,
#app[data-active-view] .project-log-grid > * {
  box-sizing: border-box !important;
  min-width: 0 !important;
  max-width: 100% !important;
}

/* Framed inner surfaces: borders and padding are included in the declared
   width, so an inner frame cannot protrude beyond its transparent outer frame. */
#app[data-active-view] .composer-stage,
#app[data-active-view] .idea-input,
#app[data-active-view] .composer-bottombar,
#app[data-active-view] .composer-reference-strip,
#app[data-active-view] .reference-preview,
#app[data-active-view] .output-panel,
#app[data-active-view] .output-stage,
#app[data-active-view] .prompt-card,
#app[data-active-view] .first-frame-workspace,
#app[data-active-view] .template-use-editor-card,
#app[data-active-view] .template-editor,
#app[data-active-view] .schema-card,
#app[data-active-view] .schema-code,
#app[data-active-view] .provider-config,
#app[data-active-view] .provider-guide,
#app[data-active-view] .project-log-summary,
#app[data-active-view] .project-log-detail,
#app[data-active-view] .coming-soon-panel {
  box-sizing: border-box !important;
  min-width: 0 !important;
  max-width: 100% !important;
}

/* Keep wide text, code, and control rows inside their parent frame. */
#app[data-active-view] .idea-input,
#app[data-active-view] .template-editor,
#app[data-active-view] .schema-code,
#app[data-active-view] .prompt-body,
#app[data-active-view] .project-log-card-copy,
#app[data-active-view] .project-log-user-input,
#app[data-active-view] .project-run-output pre {
  overflow-wrap: anywhere !important;
  word-break: break-word !important;
}

#app[data-active-view] .composer-bottom-left,
#app[data-active-view] .composer-bottom-right,
#app[data-active-view] .composer-launcher-row,
#app[data-active-view] .template-editor-actions,
#app[data-active-view] .project-log-toolbar,
#app[data-active-view] .project-log-filters,
#app[data-active-view] .model-service-commandbar,
#app[data-active-view] .model-service-detail-stack {
  box-sizing: border-box !important;
  min-width: 0 !important;
  max-width: 100% !important;
}

/* Reassert the Creative Engine double-frame geometry after legacy overrides. */
#app#app[data-active-view="workbench"][data-creation-entry="fast"] .composer-stage {
  box-sizing: border-box !important;
  width: auto !important;
  max-width: calc(100% - 36px) !important;
  margin-inline: 18px !important;
  overflow: hidden !important;
}

#app#app[data-active-view="workbench"][data-creation-entry="fast"] .composer-stage > .idea-input,
#app#app[data-active-view="workbench"][data-creation-entry="fast"] .composer-stage > textarea.idea-input,
#app#app[data-active-view="workbench"][data-creation-entry="fast"] .idea-input.studio-input {
  box-sizing: border-box !important;
  display: block !important;
  width: 100% !important;
  max-width: 100% !important;
  margin-inline: 0 !important;
}

@media (max-width: 720px) {
  #app[data-active-view] .page-scroll {
    width: 100% !important;
    padding-inline: 12px !important;
  }

  #app#app[data-active-view="workbench"][data-creation-entry="fast"] .composer-stage {
    max-width: calc(100% - 24px) !important;
    margin-inline: 12px !important;
  }

  #app[data-active-view] .workflow-board,
  #app[data-active-view] .schema-grid,
  #app[data-active-view] .model-service-workspace {
    width: 100% !important;
  }
}
