/* Canvas composer reconstructed from the workbench reference. */
.composer[data-portalized="true"] {
  height: calc(160px + var(--composer-extra-height, 0px)) !important;
  padding: 10px 16px 12px !important;
  border: 1px solid #333536 !important;
  border-radius: 20px !important;
  background: rgba(25, 25, 25, .985) !important;
  box-shadow: 0 18px 54px rgba(0, 0, 0, .62) !important;
  overflow: visible !important;
}

.image-result-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  background: #151617;
}

.text-result-card {
  grid-column: 1 / -1;
}

.text-result-card > p {
  margin: 0;
  padding: 22px;
  color: #e1e3e5;
  font-size: 13px;
  line-height: 1.75;
  white-space: pre-wrap;
}

.text-result-card footer button {
  border: 1px solid #70441d;
  border-radius: 7px;
  background: transparent;
  color: #ff9630;
  padding: 5px 9px;
  cursor: pointer;
}

.composer[data-portalized="true"] .composer-handle {
  width: 34px !important;
  height: 3px !important;
  margin: -1px auto 8px !important;
  border-radius: 3px !important;
  background: #606a72 !important;
}

.composer[data-portalized="true"] .prompt-row {
  display: flex !important;
  gap: 12px !important;
  width: 100% !important;
  min-height: calc(77px + var(--composer-extra-height, 0px)) !important;
  overflow: visible !important;
}

.composer[data-portalized="true"] .reference-button {
  width: 55px !important;
  height: 80px !important;
  border: 1px solid #3a3c3e !important;
  border-radius: 16px !important;
  background: #202122 !important;
  color: #b4b6b8 !important;
  gap: 7px !important;
}

.composer[data-portalized="true"] .reference-button:hover {
  border-color: #636668 !important;
  background: #252627 !important;
}

.composer[data-portalized="true"] .reference-button span {
  font-size: 21px !important;
  font-weight: 300 !important;
  line-height: 18px !important;
}

.composer[data-portalized="true"] .reference-button small {
  font-size: 10px !important;
  white-space: nowrap !important;
}

.composer[data-portalized="true"] .prompt-row textarea {
  display: block !important;
  flex: 1 1 auto !important;
  width: auto !important;
  min-width: 0 !important;
  height: calc(77px + var(--composer-extra-height, 0px)) !important;
  padding: 14px 15px 25px !important;
  border: 1px solid #383a3c !important;
  border-radius: 14px !important;
  background: #202020 !important;
  color: #ececec !important;
  font-size: 13px !important;
  line-height: 1.5 !important;
}

.composer[data-portalized="true"] .prompt-row textarea:focus {
  border-color: #595c5f !important;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .025) !important;
}

.composer[data-portalized="true"] .prompt-row textarea::placeholder {
  color: #858789 !important;
}

.composer[data-portalized="true"] .counter {
  right: 13px !important;
  bottom: 10px !important;
  color: #989a9c !important;
  font-size: 11px !important;
}

.composer[data-portalized="true"] .composer-controls {
  position: relative !important;
  display: flex !important;
  align-items: center !important;
  gap: 14px !important;
  width: 100% !important;
  height: 43px !important;
  min-width: 0 !important;
  margin-top: 8px !important;
  padding: 9px 0 0 !important;
  border-top: 1px solid #303132 !important;
  overflow: visible !important;
  flex-wrap: nowrap !important;
}

.composer[data-portalized="true"] .canvas-model-menu {
  position: absolute !important;
  left: 0 !important;
  bottom: 42px !important;
  z-index: 20 !important;
  display: grid !important;
  gap: 8px !important;
  width: min(560px, calc(100vw - 48px)) !important;
  max-height: min(540px, calc(100vh - 210px)) !important;
  padding: 12px !important;
  border: 1px solid #3a3c3e !important;
  border-radius: 12px !important;
  background: #1b1c1d !important;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .7) !important;
}

.composer[data-portalized="true"] .canvas-model-menu[hidden] {
  display: none !important;
}

.canvas-model-menu header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1px 2px 8px;
  border-bottom: 1px solid #303234;
}

.canvas-model-menu header strong {
  color: #f0f1f2;
  font-size: 13px;
}

.canvas-model-menu header span {
  color: #ff9225;
  font-size: 10px;
}

.canvas-model-search {
  width: 100%;
  height: 36px;
  padding: 0 11px;
  border: 1px solid #3a3c3f;
  border-radius: 8px;
  outline: none;
  background: #111213;
  color: #f0f1f2;
  font: inherit;
  font-size: 11px;
}

.canvas-model-search:focus {
  border-color: #9c5319;
}

.canvas-model-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
}

.canvas-model-tabs button {
  height: 29px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: #a3a6a9;
  font: inherit;
  font-size: 10px;
  white-space: nowrap;
  cursor: pointer;
}

.canvas-model-tabs button.active {
  border-color: #7e451a;
  background: #302116;
  color: #ff952d;
}

.canvas-model-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  max-height: 330px;
  overflow-y: auto;
  padding-right: 2px;
  scrollbar-color: #55585b transparent;
  scrollbar-width: thin;
}

.canvas-model-loading,
.canvas-model-empty {
  grid-column: 1 / -1;
  padding: 42px 16px;
  color: #898d91;
  text-align: center;
  font-size: 11px;
}

.canvas-model-option {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 18px;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  padding: 7px 8px;
  border: 1px solid #3b3d3f;
  border-radius: 9px;
  background: #232425;
  color: #e9eaeb;
  text-align: left;
  cursor: pointer;
}

.canvas-model-option:disabled {
  border-color: #303234;
  background: #1d1e1f;
  color: #74777a;
  cursor: not-allowed;
  opacity: .72;
}

.canvas-model-option:hover,
.canvas-model-option.selected {
  border-color: #985118;
  background: #2b231c;
}

.canvas-model-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: #ff7b14;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
}

.canvas-model-option > span:nth-child(2) {
  display: grid;
  gap: 4px;
}

.canvas-model-option strong {
  font-size: 12px;
}

.canvas-model-option small {
  color: #929598;
  font-size: 10px;
}

.canvas-model-option small em {
  margin-left: 5px;
  color: #bb6b2b;
  font-style: normal;
}

.canvas-model-option b {
  color: #ff8b20;
}

.composer[data-portalized="true"] .model-trigger-label {
  display: block;
  max-width: 84px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.composer[data-portalized="true"] .control-select[hidden] {
  display: none !important;
}

@media (max-width: 700px) {
  .canvas-model-list {
    grid-template-columns: 1fr;
  }
}

.composer[data-portalized="true"] .composer-controls > * {
  flex: 0 0 auto !important;
}

.composer[data-portalized="true"] .model-control,
.composer[data-portalized="true"] #analyzeButton {
  display: none !important;
}

.composer[data-portalized="true"] .control-button,
.composer[data-portalized="true"] .control-select {
  position: relative !important;
  display: flex !important;
  align-items: center !important;
  height: 34px !important;
  padding: 0 13px !important;
  border: 1px solid #3b3d3f !important;
  border-radius: 10px !important;
  background: #202122 !important;
  color: #d5d6d7 !important;
  font-size: 12px !important;
}

.composer[data-portalized="true"] .model-trigger {
  width: 138px !important;
  justify-content: flex-start !important;
  gap: 8px !important;
}

.composer[data-portalized="true"] .model-trigger::after {
  content: "";
  position: absolute;
  right: 12px;
  top: 12px;
  width: 7px;
  height: 7px;
  border-right: 1px solid #949698;
  border-bottom: 1px solid #949698;
  transform: rotate(45deg);
}

.composer[data-portalized="true"] .model-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #7b7d7f;
}

.composer[data-portalized="true"] .preset-trigger {
  width: 105px !important;
  justify-content: center !important;
  gap: 8px !important;
  padding: 0 10px !important;
  border-color: #414345 !important;
  background: #202122 !important;
  color: #f1f1f1 !important;
  font-weight: 700 !important;
}

.composer[data-portalized="true"] .preset-trigger .preset-grid-icon {
  color: #d3d5d6 !important;
}

.composer[data-portalized="true"] .preset-trigger[hidden] {
  display: none !important;
}

.composer[data-portalized="true"] .control-select::after {
  content: "";
  position: absolute;
  right: 12px;
  top: 11px;
  width: 7px;
  height: 7px;
  border-right: 1px solid #929496;
  border-bottom: 1px solid #929496;
  transform: rotate(45deg);
  pointer-events: none;
}

.composer[data-portalized="true"] .control-select select {
  width: 100% !important;
  max-width: none !important;
  height: 100% !important;
  padding: 0 22px 0 0 !important;
  color: inherit !important;
  font-size: 12px !important;
}

.composer[data-portalized="true"] .ratio-control { width: 132px !important; }
.composer[data-portalized="true"] .quality-control { width: 104px !important; }
.composer[data-portalized="true"] .quantity-control { width: 104px !important; }
.composer[data-portalized="true"] .speed-control { width: 100px !important; }

.composer[data-portalized="true"] .preset-trigger::before,
.composer[data-portalized="true"] .ratio-control::before,
.composer[data-portalized="true"] .quality-control::before,
.composer[data-portalized="true"] .quantity-control::before,
.composer[data-portalized="true"] .speed-control::before,
.composer[data-portalized="true"] .usage-label::before {
  content: "";
  position: absolute;
  left: -8px;
  top: 7px;
  width: 1px;
  height: 20px;
  background: #343638;
}

.composer[data-portalized="true"] .usage-label {
  position: relative !important;
  display: block !important;
  margin-left: auto !important;
  color: #9c9ea0 !important;
  font-size: 11px !important;
}

.composer[data-portalized="true"] .generate-button {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 7px !important;
  width: 86px !important;
  height: 36px !important;
  padding: 0 13px !important;
  border: 0 !important;
  border-radius: 19px !important;
  background: #ff7912 !important;
  color: #fff !important;
  font-size: 13px !important;
  font-weight: 700 !important;
  box-shadow: 0 4px 18px rgba(255, 113, 8, .25) !important;
}

.composer[data-portalized="true"] .generate-button:hover {
  background: #ff8a25 !important;
}

.composer[data-portalized="true"] .generate-button .send-plane {
  margin: 0 !important;
  transform: rotate(-22deg);
  font-size: 14px;
}

.composer[data-portalized="true"] .composer-message {
  display: none !important;
}

@media (max-width: 1100px) {
  .composer[data-portalized="true"] .composer-controls {
    gap: 8px !important;
    overflow-x: auto !important;
    scrollbar-width: none;
  }

  .composer[data-portalized="true"] .composer-controls::-webkit-scrollbar {
    display: none;
  }
}

@media (max-width: 650px) {
  .composer[data-portalized="true"] {
    height: 150px !important;
    padding: 8px 10px 10px !important;
    border-radius: 15px !important;
  }

  .composer[data-portalized="true"] .prompt-row {
    gap: 8px !important;
    min-height: 70px !important;
  }

  .composer[data-portalized="true"] .reference-button {
    width: 48px !important;
    height: 70px !important;
  }

  .composer[data-portalized="true"] .prompt-row textarea {
    height: 70px !important;
  }
}

/* Keep legacy model/analyzer nodes in the DOM for compatibility, but out of the visual toolbar. */
.composer[data-portalized="true"] .model-control,
.composer[data-portalized="true"] #analyzeButton {
  display: none !important;
}

.composer[data-portalized="true"] .composer-handle {
  position: absolute !important;
  top: 8px !important;
  left: calc(67px + (100% - 67px) / 2) !important;
  z-index: 2;
  margin: 0 !important;
  transform: translateX(-50%);
  cursor: ns-resize;
  touch-action: none;
}

/* Generated images live as independent nodes on the canvas. */
.result-layer.canvas-node-layer {
  position: absolute;
  inset: 70px 80px 230px 30px;
  display: block;
  max-width: none;
  min-width: 620px;
  min-height: 440px;
  margin: 0;
  pointer-events: none;
}

.canvas-image-node {
  position: absolute;
  width: 260px;
  overflow: hidden;
  border-radius: 8px;
  pointer-events: auto;
  user-select: none;
  transition: border-color .15s, box-shadow .15s;
}

.canvas-image-node:hover,
.canvas-image-node.is-dragging {
  border-color: #686b6e;
  box-shadow: 0 20px 54px rgba(0, 0, 0, .7);
}

.canvas-node-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  height: 36px;
  padding: 0 7px 0 11px;
  border-bottom: 1px solid #343638;
  background: #202223;
  color: #c5c8ca;
  cursor: grab;
  touch-action: none;
}

.canvas-node-toolbar:active {
  cursor: grabbing;
}

.canvas-node-toolbar > span {
  min-width: 0;
  overflow: hidden;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.canvas-node-actions {
  display: flex;
  flex: none;
  gap: 3px;
}

.canvas-node-actions button,
.canvas-node-actions a {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: #aeb1b3;
  font: inherit;
  font-size: 17px;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
}

.canvas-node-actions button:hover,
.canvas-node-actions a:hover {
  background: #343638;
  color: #fff;
}

.canvas-node-preview {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: #151617;
  cursor: grab;
  touch-action: none;
}

.canvas-image-node.is-dragging .canvas-node-preview {
  cursor: grabbing;
}

.canvas-image-node .canvas-node-preview img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  background: #151617;
}

.image-viewer {
  position: fixed;
  inset: 0;
  z-index: 300;
  overflow: hidden;
  background: rgba(4, 5, 6, .94);
}

.image-viewer[hidden] {
  display: none !important;
}

.image-viewer-backdrop {
  position: absolute;
  inset: 0;
}

.image-viewer-toolbar {
  position: absolute;
  z-index: 2;
  top: 14px;
  left: 50%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(720px, calc(100vw - 32px));
  height: 48px;
  padding: 0 8px 0 16px;
  transform: translateX(-50%);
  border: 1px solid #393b3d;
  border-radius: 8px;
  background: rgba(28, 30, 31, .96);
  box-shadow: 0 14px 40px rgba(0, 0, 0, .55);
}

.image-viewer-toolbar strong {
  min-width: 0;
  overflow: hidden;
  color: #e4e6e7;
  font-size: 12px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-viewer-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.image-viewer-actions button,
.image-viewer-actions a {
  display: grid;
  place-items: center;
  min-width: 32px;
  height: 32px;
  padding: 0 7px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #c2c5c7;
  font: inherit;
  font-size: 16px;
  text-decoration: none;
  cursor: pointer;
}

.image-viewer-actions button:hover,
.image-viewer-actions a:hover {
  background: #3a3c3e;
  color: #fff;
}

.image-viewer-actions #imageViewerReset {
  min-width: 48px;
  font-size: 11px;
}

.image-viewer-stage {
  position: absolute;
  inset: 78px 24px 24px;
  display: grid;
  place-items: center;
  overflow: auto;
}

.image-viewer-stage img {
  display: block;
  max-width: min(86vw, 1400px);
  max-height: 80vh;
  transform: scale(var(--viewer-scale, 1));
  transform-origin: center;
  transition: transform .12s ease-out;
  box-shadow: 0 20px 80px rgba(0, 0, 0, .7);
}

@media (max-width: 650px) {
  .result-layer.canvas-node-layer {
    inset: 60px 50px 220px 16px;
  }

  .image-viewer-toolbar {
    top: 8px;
    width: calc(100vw - 16px);
    justify-content: center;
  }

  .image-viewer-toolbar strong {
    display: none;
  }
}
