/* 2026-09-14 editor commercial UX layer.
   This is the final Editor route shell. It consolidates the high-impact
   workspace behavior without changing product imagery or commerce data. */

html:is([data-entry-mode="editor"], [data-entry-mode="home-editor"]) #builder .canvas-fit-badge:is([data-action="smart-complete"], [data-action="add-cart"]) {
  pointer-events: auto !important;
  cursor: pointer !important;
  min-height: 44px !important;
  padding: 6px 10px !important;
  border: 1px solid rgba(164, 123, 50, 0.42) !important;
  color: #6a4d17 !important;
  background: #fff8e9 !important;
  font-weight: 800 !important;
  text-decoration: none !important;
}

html:is([data-entry-mode="editor"], [data-entry-mode="home-editor"]) #builder .canvas-fit-badge[data-action="smart-complete"]:focus-visible {
  outline: 3px solid rgba(38, 99, 77, 0.35) !important;
  outline-offset: 2px !important;
}

html:is([data-entry-mode="editor"], [data-entry-mode="home-editor"]) #builder .canvas-fit-badge[data-action="add-cart"] {
  border-color: #173f2d !important;
  color: #fff !important;
  background: #173f2d !important;
}

html:is([data-entry-mode="editor"], [data-entry-mode="home-editor"]) #builder .canvas-fit-badge.transient-notice {
  pointer-events: none !important;
}

@media (max-width: 540px) {
  body.editor-tools-open {
    overflow: hidden !important;
    overscroll-behavior: none !important;
  }

  body.editor-tools-open::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: var(--z-dropdown);
    background: rgba(18, 30, 23, 0.36);
    backdrop-filter: blur(2px);
  }

  html:is([data-entry-mode="editor"], [data-entry-mode="home-editor"]) body #builder.builder #editorMobileTools.editor-mobile-tools {
    position: fixed !important;
    z-index: var(--z-modal) !important;
    inset: auto 8px max(8px, env(safe-area-inset-bottom)) 8px !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 8px !important;
    width: auto !important;
    max-width: 430px !important;
    max-height: min(72dvh, 540px) !important;
    margin: 0 auto !important;
    padding: 10px !important;
    overflow: auto !important;
    overscroll-behavior: contain !important;
    border: 1px solid rgba(18, 63, 45, 0.18) !important;
    border-radius: 18px !important;
    background: #fffefa !important;
    box-shadow: 0 24px 64px rgba(18, 30, 23, 0.28) !important;
  }

  html:is([data-entry-mode="editor"], [data-entry-mode="home-editor"]) body #builder.builder #editorMobileTools[hidden] {
    display: none !important;
  }

  html:is([data-entry-mode="editor"], [data-entry-mode="home-editor"]) #builder .editor-mobile-tools-head {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    min-height: 44px !important;
    padding: 0 2px 0 8px !important;
    color: #173f2d !important;
  }

  html:is([data-entry-mode="editor"], [data-entry-mode="home-editor"]) #builder .editor-mobile-tools-head strong {
    font-size: 15px !important;
    line-height: 1.2 !important;
  }

  html:is([data-entry-mode="editor"], [data-entry-mode="home-editor"]) #builder #editorMobileToolsClose {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 44px !important;
    min-width: 44px !important;
    height: 44px !important;
    min-height: 44px !important;
    padding: 0 !important;
    border: 1px solid #dcd9cf !important;
    border-radius: 50% !important;
    color: #173f2d !important;
    background: #fff !important;
    font-size: 24px !important;
    line-height: 1 !important;
  }

  html:is([data-entry-mode="editor"], [data-entry-mode="home-editor"]) #builder #editorMobileTools .editor-mobile-layout-row {
    display: grid !important;
    grid-template-columns: 58px minmax(0, 1fr) !important;
    align-items: center !important;
    gap: 8px !important;
    min-height: 44px !important;
    padding: 0 !important;
  }

  html:is([data-entry-mode="editor"], [data-entry-mode="home-editor"]) #builder #editorMobileTools .editor-mobile-segmented {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 4px !important;
    min-width: 0 !important;
    padding: 3px !important;
  }

  html:is([data-entry-mode="editor"], [data-entry-mode="home-editor"]) #builder #editorMobileTools .editor-mobile-segmented button {
    min-width: 0 !important;
    height: 44px !important;
    min-height: 44px !important;
  }

  html:is([data-entry-mode="editor"], [data-entry-mode="home-editor"]) #builder #editorMobileTools .editor-mobile-tool-grid {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 6px !important;
  }

  html:is([data-entry-mode="editor"], [data-entry-mode="home-editor"]) #builder #editorMobileTools .editor-mobile-tool-grid > button {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 5px !important;
    width: 100% !important;
    min-width: 0 !important;
    height: 52px !important;
    min-height: 52px !important;
    padding: 5px 6px !important;
    font-size: 11px !important;
    line-height: 1.15 !important;
  }

  html:is([data-entry-mode="editor"], [data-entry-mode="home-editor"]) #builder #editorMobileTools .editor-mobile-tool-grid svg {
    flex: 0 0 17px !important;
    width: 17px !important;
    height: 17px !important;
  }

  html:is([data-entry-mode="editor"], [data-entry-mode="home-editor"]) #builder #editorMobileTools .editor-details-toggle {
    width: 100% !important;
    min-height: 44px !important;
    margin: 0 !important;
  }

  html:is([data-entry-mode="editor"], [data-entry-mode="home-editor"]) body #builder.builder .bead-inspector {
    gap: 5px !important;
    padding: 6px !important;
    border: 1px solid #dbe1dd !important;
    border-radius: 8px !important;
    background: #fffefa !important;
  }

  html:is([data-entry-mode="editor"], [data-entry-mode="home-editor"]) body #builder.builder .bead-inspector-heading {
    grid-template-columns: 44px minmax(0, 1fr) 44px !important;
    gap: 7px !important;
    min-height: 44px !important;
  }

  html:is([data-entry-mode="editor"], [data-entry-mode="home-editor"]) body #builder.builder .bead-inspector #inspectorDetails,
  html:is([data-entry-mode="editor"], [data-entry-mode="home-editor"]) body #builder.builder .bead-inspector #inspectorPhoto {
    width: 44px !important;
    height: 44px !important;
  }

  html:is([data-entry-mode="editor"], [data-entry-mode="home-editor"]) body #builder.builder #inspectorName {
    font-size: 12px !important;
    line-height: 1.25 !important;
  }

  html:is([data-entry-mode="editor"], [data-entry-mode="home-editor"]) body #builder.builder :is(#inspectorMeta, .bead-inspector-status) {
    font-size: 10px !important;
    line-height: 1.25 !important;
  }

  html:is([data-entry-mode="editor"], [data-entry-mode="home-editor"]) body #builder.builder .bead-inspector-actions {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
    align-items: center !important;
    gap: 6px !important;
  }

  html:is([data-entry-mode="editor"], [data-entry-mode="home-editor"]) body #builder.builder .bead-inspector .three-bead-actions {
    display: grid !important;
    grid-template-columns: repeat(4, 44px) !important;
    gap: 4px !important;
  }

  html:is([data-entry-mode="editor"], [data-entry-mode="home-editor"]) body #builder.builder .bead-inspector-status:empty {
    display: none !important;
  }

  html:is([data-entry-mode="editor"], [data-entry-mode="home-editor"]) body #builder.builder .mobile-builder-inline-cta {
    grid-template-columns: minmax(92px, 0.72fr) minmax(0, 1.55fr) !important;
  }

  html:is([data-entry-mode="editor"], [data-entry-mode="home-editor"]) body #builder.builder .mobile-builder-inline-cta > div:first-child {
    grid-template-rows: auto auto !important;
    gap: 1px !important;
  }

  html:is([data-entry-mode="editor"], [data-entry-mode="home-editor"]) body #builder.builder #mobileBuilderInlineCtaLabel {
    display: block !important;
    color: #69746d !important;
    font-size: 9px !important;
    line-height: 1.15 !important;
    white-space: nowrap !important;
    text-overflow: ellipsis !important;
    overflow: hidden !important;
  }

  html:is([data-entry-mode="editor"], [data-entry-mode="home-editor"]) body #builder.builder #mobileBuilderInlineCtaPrice {
    color: #173f2d !important;
    font-size: 13px !important;
    line-height: 1.15 !important;
  }

  html:is([data-entry-mode="editor"], [data-entry-mode="home-editor"]) body:not(.canvas-fullscreen-open) #builder.builder .mobile-preview-controls #canvasFitBadge:is([data-action="smart-complete"], [data-action="add-cart"]) {
    min-height: 44px !important;
    padding: 4px 5px !important;
    border: 1px solid rgba(164, 123, 50, 0.42) !important;
    border-radius: 6px !important;
    background: #fff8e9 !important;
    font-size: 9.5px !important;
    line-height: 1.2 !important;
    pointer-events: auto !important;
  }

  html:is([data-entry-mode="editor"], [data-entry-mode="home-editor"]) body:not(.canvas-fullscreen-open) #builder.builder .mobile-preview-controls #canvasFitBadge[data-action="add-cart"] {
    color: #fff !important;
    background: #173f2d !important;
  }
}

@media (min-width: 1181px) {
  html:is([data-entry-mode="editor"], [data-entry-mode="home-editor"]) #builder.builder .left-panel .catalog {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    grid-auto-rows: 164px !important;
    gap: 8px !important;
    padding: 8px !important;
  }

  html:is([data-entry-mode="editor"], [data-entry-mode="home-editor"]) #builder.builder .left-panel .catalog > .product-card {
    height: 164px !important;
    min-height: 164px !important;
    max-height: 164px !important;
    grid-template-rows: 76px 48px 18px !important;
    padding: 7px 6px 6px !important;
  }

  html:is([data-entry-mode="editor"], [data-entry-mode="home-editor"]) #builder.builder .left-panel .product-top {
    width: 72px !important;
    max-width: 72px !important;
    height: 72px !important;
    min-height: 72px !important;
  }

  html:is([data-entry-mode="editor"], [data-entry-mode="home-editor"]) #builder.builder .left-panel .product-art.photo-backed {
    width: 70px !important;
    min-width: 70px !important;
    max-width: 70px !important;
    height: 70px !important;
    min-height: 70px !important;
    max-height: 70px !important;
  }

  html:is([data-entry-mode="editor"], [data-entry-mode="home-editor"]) #builder.builder .left-panel .product-card h3 {
    max-height: 30px !important;
    font-size: 11.5px !important;
    line-height: 1.28 !important;
  }

  html:is([data-entry-mode="editor"], [data-entry-mode="home-editor"]) #builder.builder .left-panel :is(.product-card-price, .price-line) {
    min-height: 18px !important;
    font-size: 11px !important;
    line-height: 18px !important;
  }

  :root:is([data-entry-mode="editor"], [data-entry-mode="home-editor"]) body #builder.builder > .right-panel .line-items {
    max-height: clamp(132px, 25vh, 280px) !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior: contain !important;
  }
}

@media (pointer: coarse) {
  html:is([data-entry-mode="editor"], [data-entry-mode="home-editor"]) #designCanvas > .preview-item.canvas-positioned {
    touch-action: none !important;
  }
}
