/* Canvas-first editing. This layer deliberately preserves the existing theme. */
body.studio-active #mainContent.page, #studioView[data-stage="create"], #studioView[data-stage="create"] .workspace { transform: none !important; animation: none !important; filter: none; }
#studioView[data-stage="create"] .workspace { height: auto !important; min-height: 0 !important; }
#studioView[data-stage="create"] .same-style-action-bar { position: fixed !important; bottom: max(12px, env(safe-area-inset-bottom)); left: 12px; right: 12px; width: auto !important; }
#studioView[data-stage="create"] #remixCard .context-panel-scroll { flex: 0 1 auto; }
#studioView[data-stage="create"] #remixCard.is-contextual .remix-form { margin: 0; padding: 0; min-height: 0; }
#studioView[data-stage="create"] { display: block; overflow: visible; }
#studioView[data-stage="create"] .workspace { overflow: visible; }
#studioView[data-stage="create"] .reference-toolbar { display: flex !important; min-height: 60px; padding: 8px 16px; flex: none; }
#studioView[data-stage="create"] #inputPanel { display: flex; flex-direction: column; }
#studioView[data-stage="create"] #dropzone { flex: 1; height: auto; min-height: 0; }
#studioView[data-stage="create"] .same-style-action-bar .selection-summary { display: flex !important; }
#studioView[data-stage="create"] #resetEditsBtn:not(.hidden) { display: block !important; }
#studioView[data-stage="create"] #remixCard .context-close { display: grid !important; place-items: center; }
#studioView[data-stage="create"] #remixCard.is-contextual { position: fixed !important; transform: none !important; padding: 0; }
#studioView[data-stage="create"] .workspace { display: block; width: 100%; max-width: none; }
#studioView[data-stage="create"] #inputPanel { width: 100%; max-width: none; height: calc(100dvh - 210px); min-height: 380px; margin: 0; }
#studioView[data-stage="create"] #remixPromptCard { display: none !important; }
#studioView[data-stage="create"] #remixCard { display: none; position: fixed; z-index: 160; right: 24px; top: 140px; width: 380px; height: auto; min-height: 0; max-height: calc(100dvh - 245px); margin: 0; border: 1px solid var(--border-strong); border-radius: 20px; background: var(--card); box-shadow: 0 12px 44px #00000016, 0 2px 8px #0000000a; overflow: hidden; }
#studioView[data-stage="create"] #remixCard:not(.is-tools-open) { display: none !important; }
#studioView[data-stage="create"] #remixCard.is-tools-open { display: flex !important; flex-direction: column; }
#studioView[data-stage="create"] #remixCard.is-contextual { width: 340px; right: auto; animation: context-arrive 160ms ease-out; }
#studioView[data-stage="create"] #remixCard .context-panel-head { flex: none; min-height: 64px; padding: 12px 16px; gap: 10px; }
#studioView[data-stage="create"] #remixCard .context-panel-head > div { min-width: 0; }
#studioView[data-stage="create"] #remixCard .context-title { font-size: 16px; font-weight: 600; white-space: normal; overflow-wrap: anywhere; }
#studioView[data-stage="create"] #remixCard .context-eyebrow { font-size: 11px; letter-spacing: .06em; color: var(--muted-strong); }
#studioView[data-stage="create"] #remixCard .context-close { margin-left: auto; flex-shrink: 0; width: 44px; height: 44px; }
#studioView[data-stage="create"] #remixCard .context-panel-scroll { display: block; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 16px; }
#studioView[data-stage="create"] #remixCard.is-contextual .edit-mode-switch,
#studioView[data-stage="create"] #remixCard.is-contextual .element-delete-copy,
#studioView[data-stage="create"] #remixCard.is-contextual .element-reference-head small,
#studioView[data-stage="create"] #remixCard.is-contextual .field-note,
#studioView[data-stage="create"] #remixCard .context-empty-hero,
#studioView[data-stage="create"] #remixCard .open-all-editable { display: none !important; }
#studioView[data-stage="create"] #remixCard .context-empty { padding: 0; min-height: 0; }
#studioView[data-stage="create"] #remixCard.is-contextual .element-delete-bar { padding: 0; margin: 0; border: 0; background: none; order: 3; justify-content: flex-start; }
#studioView[data-stage="create"] #dynamicElementEditor.is-context-visible { display: flex; flex-direction: column; gap: 12px; padding: 0; }
#studioView[data-stage="create"] #dynamicElementEditor > label { margin: 0; font-size: 13px; }
#studioView[data-stage="create"] #dynamicElementEditor > :is(input,textarea) { display: block; box-sizing: border-box; padding: 12px 14px; font-size: 16px; line-height: 1.55; text-align: start; border-radius: 12px; }
#studioView[data-stage="create"] #dynamicElementEditor > input { min-height: 48px; }
#studioView[data-stage="create"] #dynamicElementEditor > textarea { min-height: 96px; vertical-align: top; overflow-y: auto; resize: vertical; }
#studioView[data-stage="create"] #dynamicElementEditor.is-context-visible > :is(input,textarea) { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
#studioView[data-stage="create"] #dynamicElementEditor .element-reference-upload { margin: 0; padding: 10px; border-radius: 12px; }
#studioView[data-stage="create"] #dynamicElementEditor .element-reference-head { gap: 8px; }
#studioView[data-stage="create"] #dynamicElementEditor .element-reference-head strong { font-size: 12px; }
.context-scope { display: none; align-items: center; flex: none; gap: 12px; margin: 0; padding: 0 16px 12px; font-size: 12px; color: var(--muted-strong); }
.is-contextual .context-scope { display: flex; }
.context-scope select { min-width: 0; flex: 1; min-height: 44px; border: 1px solid var(--border); border-radius: 10px; background: var(--field); color: var(--text); padding: 8px; font: inherit; }
.context-done-bar { display: none; flex: none; gap: 8px; align-items: center; padding: 12px 16px; border-top: 1px solid var(--border); }
.is-contextual .context-done-bar { display: flex; flex-wrap: wrap; }
.context-done-bar > span { flex: 1 0 100%; font-size: 12px; color: var(--muted-strong); }
.context-done-bar button { min-height: 44px; }
.context-done-bar .primary { margin-left: auto; min-width: 88px; }
#studioView[data-stage="create"] .canvas-edit-hint { position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 45; margin: 0; padding: 9px 16px; border: 1px solid var(--border); border-radius: 24px; background: var(--card); color: var(--muted-strong); font-size: 13px; pointer-events: none; white-space: nowrap; }
#studioView.is-editing-element .canvas-edit-hint, #studioView.is-generation-locked .canvas-edit-hint { display: none; }
#studioView[data-stage="create"] .reference-toolbar { gap: 12px; }
#studioView[data-stage="create"] .reference-toolbar-actions { gap: 6px; flex-wrap: wrap; }
.reference-toolbar-actions .canvas-tool, .reference-toolbar-actions .region-toggle { min-width: 44px; min-height: 44px; }
.reference-toolbar-actions button:disabled { opacity: .35; cursor: default; }
#studioView[data-stage="create"] .reference-hotspot:hover { outline: 2px solid var(--highlight); outline-offset: 1px; }
#studioView[data-stage="create"] .reference-hotspot.is-applied::after { content: none; }
#studioView[data-stage="create"] .same-style-action-bar { position: relative; z-index: 165; margin-top: 12px; min-height: 68px; gap: 12px; }
#studioView[data-stage="create"] .same-style-action-bar .overall-adjust { min-width: 108px; min-height: 44px; }
#studioView[data-stage="create"] .change-summary-popover { display: none !important; max-height: min(45dvh, 340px); overflow: auto; width: min(360px, calc(100vw - 32px)); }
#studioView[data-stage="create"] .change-summary-popover.is-open {
  display: block !important;
  opacity: 1;
  visibility: visible;
  transform: none;
  pointer-events: auto;
}
.change-summary-popover li button { display: block; width: 100%; min-height: 44px; padding: 8px 0; text-align: left; background: none; border: 0; color: var(--text); font: inherit; overflow-wrap: anywhere; }
#studioView.is-generation-locked #remixCard, #studioView.is-generation-locked #moreToolsBtn { pointer-events: none; opacity: .55; }
@keyframes context-arrive { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
@media (max-width: 640px) {
  #studioView[data-stage="create"] #inputPanel { height: calc(100dvh - 240px); min-height: 320px; border-radius: 18px; }
  #studioView[data-stage="create"] .reference-toolbar { align-items: flex-start; padding: 8px; flex-direction: column; gap: 4px; }
  #studioView[data-stage="create"] .reference-toolbar-title { flex-direction: row; gap: 8px; }
  #studioView[data-stage="create"] .reference-toolbar-actions { width: 100%; justify-content: flex-end; gap: 2px; }
  #studioView[data-stage="create"] .reference-toolbar-actions .region-toggle span:last-child { display: none; }
  #studioView[data-stage="create"] #remixCard, #studioView[data-stage="create"] #remixCard.is-contextual { width: calc(100vw - 24px); max-height: min(55dvh, 480px); right: 12px; top: auto; bottom: 100px; border-radius: 20px; }
  #studioView[data-stage="create"] #remixCard.is-contextual { bottom: auto; }
  #studioView[data-stage="create"] .canvas-edit-hint { font-size: 12px; bottom: 70px; }
  #studioView[data-stage="create"] .same-style-action-bar { padding: 8px; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
  #studioView[data-stage="create"] .same-style-action-bar .selection-summary { flex: 1 0 100%; min-height: 24px; }
  #studioView[data-stage="create"] .same-style-action-bar .overall-adjust { min-width: 88px; padding: 0 10px; }
  #studioView[data-stage="create"] .same-style-action-bar #generateBtn { min-width: 0; min-height: 44px; padding: 0 14px; font-size: 14px; }
  #studioView[data-stage="create"] #resetEditsBtn { min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) { #studioView[data-stage="create"] #remixCard.is-contextual { animation: none; } }
@media (prefers-contrast: more) { #studioView[data-stage="create"] #remixCard { border: 2px solid var(--text); } }
@media (max-width: 640px) {
  #studioView[data-stage="create"] .same-style-action-bar { display: grid !important; grid-template-columns: 1fr auto; grid-template-rows: auto auto; align-items: center; padding: 10px; gap: 8px; }
  #studioView[data-stage="create"] .same-style-action-bar .selection-summary { grid-column: 1; grid-row: 1; order: 0; width: auto; min-height: 28px; padding: 0; }
  #studioView[data-stage="create"] #selectionStatus { display: none; }
  #studioView[data-stage="create"] #resetEditsBtn { grid-column: 2; grid-row: 1; order: 0; margin: 0; padding: 0 8px; min-height: 32px; }
  #studioView[data-stage="create"] #overallAdjustBtn { grid-column: 1; grid-row: 2; order: 0; width: auto; justify-self: start; margin: 0; }
  #studioView[data-stage="create"] .generation-action { display: contents; }
  #studioView[data-stage="create"] #generateBtn { position: static; grid-column: 2; grid-row: 2; order: 0; width: auto; margin: 0; }
  #studioView[data-stage="create"] #genStatus:not(.hidden) { position: static !important; grid-column: 1 / -1; grid-row: 3; width: auto; max-width: none; margin: 0; transform: none; }
  #studioView[data-stage="create"] #remixCard.is-contextual .context-panel-head { min-height: 56px; padding: 6px 12px; }
  #studioView[data-stage="create"] #remixCard.is-contextual .context-panel-scroll { padding: 12px; }
  #studioView[data-stage="create"] #remixCard.is-contextual .context-done-bar { padding: 10px 12px; }
}
