#componentDialog {
  width: min(780px, calc(100% - 32px));
  height: min(730px, calc(100dvh - 40px));
  max-height: calc(100dvh - 40px);
  padding: 26px;
  overflow: hidden;
}
#componentDialog[open] { display: flex; flex-direction: column; }
#componentDialog [hidden] { display: none !important; }
#componentDialog .dialog-heading { flex-shrink: 0; }
#componentDialog h2 { font-size: 25px; }
.component-tools { display: flex; gap: 10px; margin-top: 20px; flex-shrink: 0; }
.component-search { display: flex; align-items: center; gap: 9px; min-width: 0; flex: 1; padding: 0 12px; border: 1px solid #d6e4d9; border-radius: 6px; background: white; }
.component-search:focus-within { outline: 2px solid #6fa28a; }
.component-search svg { width: 19px; height: 19px; flex-shrink: 0; color: #77958b; }
.component-search input { min-width: 0; width: 100%; height: 42px; border: 0; background: transparent; color: #315c57; font-size: 13px; outline: 0; }
.component-tools select { max-width: 36%; min-width: 112px; padding: 0 10px; border: 1px solid #d6e4d9; border-radius: 6px; background: #edf4ed; color: #41695d; font: inherit; font-size: 12px; }
.generate-component { margin-top: 12px; padding: 11px; border: 1px solid #d9e8db; background: #eef6ed; border-radius: 7px; flex-shrink: 0; }
.generate-component > label { display: flex; align-items: center; gap: 7px; color: #5d826b; font-size: 11px; }
.generate-component > label svg { width: 15px; height: 15px; }
.generate-component > div { display: flex; gap: 7px; margin-top: 8px; }
.generate-component input { min-width: 0; flex: 1; height: 38px; padding: 0 10px; border: 1px solid #cddfcf; border-radius: 5px; background: white; color: #315c57; font: inherit; font-size: 12px; outline: 0; }
.generate-component input:focus { border-color: #6e9f7c; box-shadow: 0 0 0 2px #6e9f7c22; }
.generate-component button { height: 38px; min-width: 67px; gap: 5px; padding: 0 10px; border-radius: 5px; background: #5e9475; color: white; font-size: 12px; }
.generate-component button:hover { background: #4e8467; }
.generate-component button:disabled { cursor: wait; opacity: .65; transform: none; }
.generate-component button svg { width: 15px; height: 15px; }
.generate-component small { display: block; min-height: 13px; margin-top: 7px; color: #779181; font-size: 10px; line-height: 1.35; }
.component-summary { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 5px 12px; padding: 14px 0; color: #67877a; font-size: 11px; flex-shrink: 0; }
.component-status { color: #7e938b; }
.placement-hint, .selection-toolbar { position: absolute; z-index: 8; bottom: 27px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 12px; padding: 8px 10px 8px 16px; border-radius: 8px; background: #fcfef8; color: #3e6e61; box-shadow: 0 7px 24px #275c4b26; font-size: 13px; max-width: calc(100% - 40px); }
.placement-hint[hidden], .selection-toolbar[hidden] { display: none; }
.placement-hint > svg, .selection-toolbar > svg { width: 21px; height: 21px; flex-shrink: 0; color: #5b9b78; }
.placement-hint .icon, .selection-toolbar .icon { width: 42px; height: 42px; background: #eaf2e6; box-shadow: none; }
.placement-hint .icon svg, .selection-toolbar .icon svg { width: 19px; height: 19px; }
.placement-copy { display: flex; flex-direction: column; gap: 3px; min-width: 74px; }
.placement-copy b, .selection-toolbar b { overflow-wrap: anywhere; }
#placementStatus { font-size: 10px; color: #589474; }
.placement-hint[data-valid="false"] #placementStatus { color: #b78c55; }
#deletePlaced { color: #c26d60; }
#world.placement-ready { cursor: copy; }
#world.placement-invalid { cursor: not-allowed; }
.placing .bottom-center, .object-selected .bottom-center { visibility: hidden; }
@media (max-width: 650px) {
  .placement-hint, .selection-toolbar { top: 142px; bottom: auto; padding: 6px 8px; gap: 7px; max-width: calc(100% - 142px); font-size: 11px; }
  .placement-hint > svg, .selection-toolbar > svg { display: none; }
  .placement-copy { min-width: 60px; }
  .selection-toolbar { flex-wrap: wrap; justify-content: center; }
  .selection-toolbar b { flex-basis: 100%; text-align: center; }
}

.component-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 1px 6px 5px 1px; align-content: start; grid-auto-rows: max-content; scrollbar-width: thin; scrollbar-color: #b5cdbd transparent; }
.component-row { display: grid; cursor: default; grid-template-columns: minmax(0, 1fr) 40px; grid-template-rows: auto 87px; min-width: 0; border: 1px solid #dbe6dc; border-radius: 7px; overflow: hidden; background: white; }
.component-row.is-placeable { cursor: grab; user-select: none; }
.component-row.is-placeable:active { cursor: grabbing; }
.component-row.is-reference { opacity: .74; }
.component-preview { grid-column: 1 / -1; width: 100%; aspect-ratio: 208 / 144; display: grid; place-items: center; background: #e9f1e5; border-bottom: 1px solid #e2ebdf; position: relative; padding: 0; border-radius: 0; }
button.component-preview { touch-action: none; cursor: grab; transition: none; }
button.component-preview:hover, button.component-preview:active { transform: none; }
.component-dragmark { position: absolute; right: 8px; top: 8px; color: #729481; pointer-events: none; opacity: .65; }
.component-dragmark svg { width: 17px; height: 17px; }
.component-preview img { pointer-events: none; }
.component-row:nth-of-type(3n+2) .component-preview { background: #e6f0f0; }
.component-row:nth-of-type(3n) .component-preview { background: #f7efdf; }
.component-preview img { display: block; width: 100%; height: 100%; object-fit: contain; }
.component-loading { color: #7c9487; font-size: 11px; }
.component-copy { padding: 12px 0 12px 12px; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.component-copy h3 { font-size: 13px; line-height: 1.4; margin: 0; color: #315c57; overflow-wrap: anywhere; }
.component-meta { color: #819487; font-size: 10px; }
.component-copy code { color: #9aa49d; font-size: 9px; overflow-wrap: anywhere; }
.component-export { width: 38px; height: 42px; align-self: center; background: transparent; color: #5a8a77; border-radius: 5px; }
.component-export:hover { background: #e4eee4; }
.component-export svg { width: 18px; height: 18px; }
.component-empty { grid-column: 1 / -1; text-align: center; padding: 40px 10px; color: #82978b; font-size: 13px; }
@media (max-width: 650px) {
  #components { position: absolute; right: 0; top: 66px; background: #ffffffe6; width: 43px; height: 43px; }
  #componentDialog { padding: 18px; width: calc(100% - 24px); height: min(720px, calc(100dvh - 28px)); max-height: calc(100dvh - 28px); }
  #componentDialog h2 { font-size: 22px; }
  .component-list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; padding-right: 3px; }
  .component-tools { gap: 7px; margin-top: 16px; }
  .generate-component { margin-top: 9px; padding: 9px; }
  .generate-component > label { font-size: 10px; }
  .generate-component button { min-width: 54px; padding: 0 8px; }
  .generate-component button span { display: none; }
  .component-tools select { min-width: 94px; padding: 0 6px; }
  .component-search { padding: 0 8px; gap: 5px; }
  .component-search input { font-size: 12px; }
  .component-copy { padding-left: 9px; }
}
@media (max-height: 500px) {
  #componentDialog { padding: 15px 20px; height: calc(100dvh - 24px); max-height: calc(100dvh - 24px); }
  #componentDialog h2 { font-size: 21px; }
  #componentDialog .eyebrow { display: none; }
  .component-tools { margin-top: 10px; }
  .generate-component { display: none; }
  .component-summary { padding: 8px 0; }
  .component-preview { aspect-ratio: 208 / 110; }
}
