/* Keep the creation shell within the available browser viewport. Variable work
   (results, references, canvas notes) scrolls inside its workspace. */
.creation-studio {
  --studio-gap: clamp(8px, 1.8dvh, 20px);
  box-sizing: border-box;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
  min-height: 0;
}
.creation-studio .creation-header {
  min-height: 0;
  padding: max(10px, env(safe-area-inset-top)) clamp(16px, 2vw, 28px) 8px;
}
.creation-studio .creation-main {
  display: grid;
  align-items: stretch;
  justify-items: stretch;
  grid-template-rows: minmax(0, 1fr) clamp(164px, 29dvh, 310px);
  gap: var(--studio-gap);
  min-height: 0;
  padding: 0 0 max(12px, env(safe-area-inset-bottom));
}
.creation-studio .creation-workbench {
  box-sizing: border-box;
  width: min(1292px, calc(100% - 80px));
  min-width: 0;
  min-height: 0;
  height: 100%;
  padding: 4px 4px 6px;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-gutter: stable;
  container-type: inline-size;
}
.creation-studio .creation-workbench > * { flex-shrink: 0; }
.creation-studio .creation-workbench h1 {
  margin: 0 0 clamp(8px, 1.8dvh, 20px);
  font-size: clamp(22px, 3.8dvh, 34px);
  line-height: 1.25;
}
.creation-studio .creation-tabs { flex: none; max-width: 100%; height: clamp(32px, 4.8dvh, 44px); }
.creation-studio .creation-composer {
  box-sizing: border-box;
  min-height: 0;
  margin-top: clamp(10px, 2.5dvh, 28px);
  padding: clamp(12px, 2dvh, 20px) clamp(14px, 1.6vw, 24px) 12px;
  border-radius: clamp(18px, 2.8dvh, 26px);
}
.creation-studio .creation-composer:not(.canvas-mode) {
  display: flex;
  flex-direction: column;
  flex: 1 0 auto;
  max-height: clamp(180px, 30dvh, 260px);
}
.creation-studio .creation-prompt-area { min-height: clamp(60px, 11dvh, 100px); gap: clamp(14px, 2vw, 24px); }
.creation-studio .creation-composer:not(.canvas-mode) .creation-prompt-area { flex: 1; }
.creation-studio .creation-prompt-area textarea {
  box-sizing: border-box;
  min-width: 0;
  min-height: clamp(60px, 11dvh, 100px);
  max-height: min(22dvh, 200px);
  resize: none;
  overflow: auto;
  align-self: stretch;
}
.creation-studio .creation-settings { flex: none; gap: 12px; margin-top: 7px; }
.creation-studio .creation-settings-left { min-width: 0; gap: 8px 14px; }
.creation-studio .creation-add-reference { height: clamp(52px, 8dvh, 70px); }
.creation-studio .creation-skills {
  min-width: 0;
  min-height: 0;
  margin-top: clamp(8px, 2dvh, 20px);
  padding-bottom: 3px;
}
.creation-studio .creation-skills > button { min-height: clamp(32px, 4.7dvh, 39px); }
.creation-studio .creation-workbench > p { margin: 5px 2px 0; font-size: 12px; line-height: 1.5; }
.creation-studio .ai-image-status { margin-top: 7px; }
.creation-studio .creation-more-skills { margin-top: 6px; }
.creation-studio .creation-discover {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 9px;
  min-width: 0;
  min-height: 0;
  margin: 0 clamp(16px, 3vw, 42px);
}
.creation-studio .creation-discover h2 { margin: 0 0 0 3px; line-height: 1.4; }
.creation-studio .creation-banner-track {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  height: 100%;
  gap: 12px;
  border-radius: 0;
}
.creation-studio .creation-banner {
  min-width: 0;
  min-height: 0;
  height: 100%;
  aspect-ratio: auto;
  border-radius: 14px;
}
.creation-studio .creation-category-row { min-width: 0; gap: 12px; margin: 0; flex-wrap: nowrap; }
.creation-studio .creation-category-row nav {
  flex: 1;
  min-width: 0;
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 5px;
}
.creation-studio .creation-category-row nav button { flex: none; white-space: nowrap; padding: 7px 12px; }
.creation-studio .creation-content-search { flex: 0 0 clamp(145px, 18vw, 225px); min-width: 0; }
.creation-studio .creation-content-search input { width: 100%; min-width: 0; }
.aura-select-menu { box-sizing: border-box; max-height: calc(100dvh - 16px); max-width: calc(100vw - 16px); overflow: auto; overscroll-behavior: contain; }
.creation-studio .creation-canvas-board { min-height: 120px; max-height: 28dvh; margin-bottom: 12px; overflow: auto; }
.creation-studio .canvas-items { min-height: 80px; }
.creation-studio .creation-workbench > .ai-results { max-height: 30dvh; overflow: auto; margin-top: 9px; }
.creation-studio .ai-results-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.creation-studio .ai-result-preview { height: clamp(110px, 20dvh, 220px) !important; min-height: 0; }
.creation-studio .ai-result-preview img { width: 100%; height: 100% !important; object-fit: contain; }
.creation-studio .aura-wait-grid { grid-auto-rows: clamp(90px, 17dvh, 160px); }
.creation-studio .aura-wait-cell { height: clamp(90px, 17dvh, 160px); }
/* Reference cards get their own row when the workspace itself is narrow,
   including the left pane of a landscape layout. */
@container (max-width: 600px) {
  .creation-studio .creation-composer:has(.creation-reference-list.is-row) {
    flex: none;
    max-height: none;
  }
  .creation-studio .creation-prompt-area { padding-left: 0 !important; }
  .creation-studio .creation-reference-list.is-row {
    position: static !important;
    width: 100% !important;
    left: auto !important;
    top: auto !important;
    gap: 8px !important;
    margin: 8px 0 !important;
    overflow-x: auto;
    padding: 2px;
  }
  .creation-studio .creation-reference-list.is-row .creation-reference-item:nth-child(n) { width: 48px; height: 52px; transform: none; }
}
@media (max-width: 900px) {
  .creation-studio .creation-workbench { width: calc(100% - 36px); }
  .creation-studio .creation-main { grid-template-rows: minmax(0, 1fr) clamp(180px, 29dvh, 280px); }
  .creation-studio .creation-banner-track { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .creation-studio .creation-banner { border-radius: 10px; }
  .creation-studio .creation-content-search { flex-basis: 160px; }
}
@media (max-width: 600px) {
  .creation-studio .creation-header { padding: max(8px, env(safe-area-inset-top)) 12px 7px; }
  .creation-studio .creation-header-action { min-height: 31px; padding: 0 9px; font-size: 11px; }
  .creation-studio .creation-main { gap: 10px; padding-bottom: max(8px, env(safe-area-inset-bottom)); }
  .creation-studio .creation-workbench { width: calc(100% - 24px); padding-top: 2px; }
  .creation-studio .creation-workbench h1 { font-size: clamp(19px, 4.9vw, 23px); margin-bottom: 9px; line-height: 1.3; }
  .creation-studio .creation-tabs { width: min(300px, 85%); height: 34px; }
  .creation-studio .creation-composer { margin-top: 12px; padding: 12px; }
  .creation-studio .creation-prompt-area { gap: 12px; min-height: 60px; }
  .creation-studio .creation-prompt-area textarea { min-height: 60px; max-height: 18dvh; font-size: 13px; }
  .creation-studio .creation-settings { align-items: flex-end; gap: 8px; }
  .creation-studio .creation-settings-left { gap: 5px 10px; }
  .creation-studio .creation-settings-left label { font-size: 11px; }
  .creation-studio .creation-settings-left select { max-width: 125px; }
  .creation-studio .creation-submit-group { flex-direction: row; gap: 6px; }
  .creation-studio .creation-submit { width: 32px; height: 32px; flex-basis: 32px; }
  .creation-studio .creation-skills { margin-top: 10px; }
  .creation-studio .creation-skills > button { min-height: 32px; font-size: 11px; }
  .creation-studio .creation-discover { gap: 7px; margin-inline: 12px; }
  .creation-studio .creation-content-search { flex-basis: 132px; }
  .creation-studio .creation-category-row { gap: 7px; }
  .creation-studio .creation-category-row nav button { padding: 6px 9px; }
}
/* A two-row header keeps every action readable on narrow phones. */
@media (max-width: 440px) {
  .creation-studio .creation-header { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .creation-studio .creation-header > a { grid-area: 1 / 1 / 2 / 3; justify-self: start; }
  .creation-studio .creation-account { display: contents; }
  .creation-studio .creation-account > .user-menu { grid-area: 1 / 3; justify-self: end; }
  .creation-studio .creation-account > .creation-header-action { grid-row: 2; }
}
@media (max-height: 700px) and (max-width: 600px) {
  .creation-studio .creation-main { grid-template-rows: minmax(0, 1fr) 150px; gap: 7px; }
  .creation-studio .creation-composer { margin-top: 8px; padding: 10px; }
  .creation-studio .creation-prompt-area,.creation-studio .creation-prompt-area textarea { min-height: 48px; }
  .creation-studio .creation-workbench h1 { margin-bottom: 6px; }
  .creation-studio .creation-skills { margin-top: 7px; }
}
/* On short landscape windows, use the width instead of stacking two sections. */
@media (max-height: 600px) and (min-width: 640px) {
  .creation-studio .creation-header { padding-top: max(6px, env(safe-area-inset-top)); padding-bottom: 6px; }
  .creation-studio .creation-main { grid-template-columns: minmax(0, 1.55fr) minmax(240px, 1fr); grid-template-rows: minmax(0, 1fr); gap: 18px; padding: 0 18px max(8px, env(safe-area-inset-bottom)); }
  .creation-studio .creation-workbench { width: 100%; }
  .creation-studio .creation-workbench h1 { font-size: 22px; margin-bottom: 7px; }
  .creation-studio .creation-composer { margin-top: 10px; padding: 12px; }
  .creation-studio .creation-prompt-area,.creation-studio .creation-prompt-area textarea { min-height: 54px; }
  .creation-studio .creation-discover { margin: 0; }
  .creation-studio .creation-banner-track { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(2, minmax(0, 1fr)); }
  .creation-studio .creation-category-row { flex-wrap: wrap; gap: 6px; }
  .creation-studio .creation-category-row nav { flex-basis: 100%; }
  .creation-studio .creation-content-search { flex: 1; }
}
