/* v541: UX polish requested 2026-10-02.
   Scope: start card text/USP hover, setup modal cleanup, toolbar tooltips support,
   usable mobile zoom, and compact mobile-landscape editor geometry. */

/* ===== Start screen: consistent white copy inside the glass card ===== */
html.ahp-layout-v497 #app #startScreen.start-usp-below-v537.start-refined-v538 .start-card {
  color: #fff !important;
}
html.ahp-layout-v497 #app #startScreen.start-usp-below-v537.start-refined-v538 .start-card :is(
  .start-title-rest,
  .start-subtitle,
  .chooser-block > h2,
  .choice-label,
  .wall-input > span:not(.ahp-wall-control),
  .wall-input-label-line > span:first-child,
  .start-action-set .btn,
  .start-usp-item h2,
  .start-usp-item p
) {
  color: #fff !important;
}
html.ahp-layout-v497 #app #startScreen.start-usp-below-v537.start-refined-v538 .start-title-brand {
  color: #fff !important;
}
html.ahp-layout-v497 #app #startScreen.start-usp-below-v537.start-refined-v538 .wall-range-help {
  color: #fff !important;
  border-color: rgba(255,255,255,.62) !important;
  background: rgba(255,255,255,.045) !important;
}
html.ahp-layout-v497 #app #startScreen.start-usp-below-v537.start-refined-v538 .start-action-set .btn {
  font-size: 14px !important;
}

/* Decent USP hover: the card stays visually calm, only gains a little depth. */
html.ahp-layout-v497 #app #startScreen.start-usp-below-v537.start-refined-v538 .start-usp-item {
  transition: transform .16s ease, border-color .16s ease, background .16s ease, box-shadow .16s ease !important;
}
@media (hover:hover) and (pointer:fine) {
  html.ahp-layout-v497 #app #startScreen.start-usp-below-v537.start-refined-v538 .start-usp-item:hover {
    transform: translateY(-2px) !important;
    border-color: rgba(255,255,255,.22) !important;
    background: rgba(255,255,255,.055) !important;
    box-shadow: 0 8px 22px rgba(0,0,0,.13) !important;
  }
}

/* ===== Parameters modal: same simplified option language as the start page ===== */
html.ahp-layout-v497 #setupParamContent :is(.assembly-swatch,.numeric-swatch) {
  display: none !important;
}
html.ahp-layout-v497 #setupParamContent .setup-modal-option {
  gap: 10px !important;
}

/* Phone: both corner-wall inputs always share the same baseline, even when a label wraps. */
@media (max-width: 600px) {
  html.ahp-layout-v497 #setupParamContent .setup-modal-wall-corner {
    display: grid !important;
    grid-template-columns: repeat(2,minmax(0,1fr)) !important;
    align-items: end !important;
    gap: 10px !important;
  }
  html.ahp-layout-v497 #setupParamContent .setup-modal-wall-corner .setup-modal-input {
    display: grid !important;
    grid-template-rows: 42px var(--ahp-field-height,48px) !important;
    align-content: end !important;
    gap: 6px !important;
    min-width: 0 !important;
  }
  html.ahp-layout-v497 #setupParamContent .setup-modal-wall-corner .setup-modal-input > span:first-child {
    display: flex !important;
    align-items: flex-end !important;
    min-height: 42px !important;
    margin: 0 !important;
    font-size: 12px !important;
    line-height: 1.22 !important;
  }
  html.ahp-layout-v497 #setupParamContent .setup-modal-wall-corner .ahp-wall-control {
    align-self: end !important;
    width: 100% !important;
  }
}

/* ===== Toolbar: shared tooltip renderer uses aria-label; keep native title bubbles out. ===== */
html.ahp-layout-v497 #editorScreen .workspace-toolbar button[aria-label] {
  position: relative;
}

/* ===== Mobile landscape: compact desktop-like catalogue + full promotion visibility ===== */
@media (max-width: 999px) and (orientation: landscape) and (max-height: 560px) {
  :root {
    --ahp-header-height: calc(42px + env(safe-area-inset-top, 0px));
    --ahp-footer-height: calc(16px + env(safe-area-inset-bottom, 0px));
    --ahp-glyph-size: 30px;
    --ahp-control-size: 32px;
  }

  html.ahp-layout-v497 :is(#startHeader,#editorHeader).app-header {
    gap: 10px !important;
    padding-left: max(8px,env(safe-area-inset-left,0px)) !important;
    padding-right: max(8px,env(safe-area-inset-right,0px)) !important;
  }
  html.ahp-layout-v497 :is(#startHeader,#editorHeader) .brand-logo {
    height: 30px !important;
    max-width: 31vw !important;
  }
  html.ahp-layout-v497 :is(#startHeader,#editorHeader) :is(.top-summary-button,.header-menu-button,.ahp-mobile-menu-button,.ahp-mobile-cart-button) {
    height: 34px !important;
    min-height: 34px !important;
    min-width: 34px !important;
    padding: 0 2px !important;
  }
  html.ahp-layout-v497 body .app-footer {
    font-size: 9px !important;
    padding-inline: 6px !important;
  }

  html.ahp-layout-v497 #editorScreen .editor-shell {
    grid-template-columns: clamp(190px,25vw,222px) minmax(0,1fr) !important;
    grid-template-rows: minmax(0,1fr) !important;
    grid-template-areas: "catalog workspace" !important;
  }
  html.ahp-layout-v497 #editorScreen .catalog-panel {
    gap: 3px !important;
    padding: 4px !important;
    overflow: hidden !important;
  }

  /* Previous short-height rules hid the discount block completely. Restore a compact version. */
  html.ahp-layout-v497 #editorScreen .catalog-panel > .editor-promo-bar {
    display: grid !important;
    grid-template-columns: 22px minmax(0,1fr) !important;
    min-height: 34px !important;
    height: auto !important;
    margin: 0 0 2px !important;
    padding: 3px 5px !important;
    gap: 5px !important;
    border-radius: 8px !important;
  }
  html.ahp-layout-v497 #editorScreen .catalog-panel > .editor-promo-bar .editor-promo-icon {
    width: 22px !important;
    height: 22px !important;
  }
  html.ahp-layout-v497 #editorScreen .catalog-panel > .editor-promo-bar .editor-promo-body {
    min-width: 0 !important;
    gap: 0 !important;
  }
  html.ahp-layout-v497 #editorScreen .catalog-panel > .editor-promo-bar .editor-promo-copy {
    display: -webkit-box !important;
    -webkit-box-orient: vertical !important;
    -webkit-line-clamp: 2 !important;
    white-space: normal !important;
    overflow: hidden !important;
    text-overflow: clip !important;
    font-size: 9.5px !important;
    line-height: 1.12 !important;
  }
  html.ahp-layout-v497 #editorScreen .catalog-panel > .editor-promo-bar .editor-promo-status {
    display: none !important;
  }
  html.ahp-layout-v497 #editorScreen .catalog-panel > .editor-promo-bar .promo-discount-track {
    display: block !important;
    height: 14px !important;
    margin-top: 0 !important;
  }

  html.ahp-layout-v497 #editorScreen #catalogModeTabs {
    gap: 4px !important;
  }
  html.ahp-layout-v497 #editorScreen .catalog-mode-tab {
    min-height: 29px !important;
    height: 29px !important;
    padding: 3px 4px !important;
    font-size: 11px !important;
    border-radius: 8px !important;
  }
  html.ahp-layout-v497 #editorScreen #cornerInsertPanel:not(:empty) {
    min-height: 27px !important;
    margin: 0 0 2px !important;
    padding: 2px 3px !important;
  }
  html.ahp-layout-v497 #editorScreen #cornerInsertPanel .corner-insert-row,
  html.ahp-layout-v497 #editorScreen #cornerInsertPanel .corner-insert-buttons {
    min-height: 24px !important;
    gap: 3px !important;
    padding: 0 !important;
  }
  html.ahp-layout-v497 #editorScreen #cornerInsertPanel .corner-insert-btn {
    min-height: 24px !important;
    height: 24px !important;
    padding: 1px 5px !important;
    font-size: 10px !important;
  }
  html.ahp-layout-v497 #editorScreen #cornerInsertPanel .corner-insert-title {
    font-size: 10px !important;
  }

  html.ahp-layout-v497 #editorScreen #categoryTabs {
    grid-template-columns: repeat(4,minmax(0,1fr)) !important;
    grid-auto-rows: 32px !important;
    min-height: 68px !important;
    height: 68px !important;
    gap: 3px !important;
    padding: 0 !important;
    overflow: hidden !important;
  }
  html.ahp-layout-v497 #editorScreen #categoryTabs .category-icon-tab {
    height: 32px !important;
    min-height: 32px !important;
    padding: 3px !important;
    border-radius: 8px !important;
  }

  html.ahp-layout-v497 #editorScreen #productList.product-list {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 1 0 !important;
    min-height: 72px !important;
    height: auto !important;
    max-height: none !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    gap: 5px !important;
    padding: 2px 2px 6px !important;
    scrollbar-gutter: stable !important;
  }
  html.ahp-layout-v497 #editorScreen #productList :is(.product-card,.product-card-ref) {
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    min-height: 108px !important;
    height: auto !important;
    padding: 6px !important;
    gap: 4px 6px !important;
    grid-template-columns: 46px minmax(0,1fr) !important;
    grid-template-rows: minmax(54px,auto) 1px 34px !important;
  }
  html.ahp-layout-v497 #editorScreen #productList .product-thumb {
    width: 46px !important;
    min-width: 46px !important;
    max-width: 46px !important;
    height: 54px !important;
    min-height: 54px !important;
    max-height: 54px !important;
  }
  html.ahp-layout-v497 #editorScreen #productList .product-title {
    font-size: 11.5px !important;
    line-height: 1.12 !important;
  }
  html.ahp-layout-v497 #editorScreen #productList :is(.product-code,.stock-line) {
    font-size: 9.5px !important;
    line-height: 1.12 !important;
  }
  html.ahp-layout-v497 #editorScreen #productList .product-bottom {
    min-height: 34px !important;
    gap: 4px !important;
  }
  html.ahp-layout-v497 #editorScreen #productList .product-controls {
    transform: scale(.88) !important;
    transform-origin: right center !important;
  }

  html.ahp-layout-v497 #editorScreen .workspace-toolbar {
    flex-wrap: nowrap !important;
    min-height: 38px !important;
    height: 38px !important;
    padding: 2px 4px !important;
    gap: 3px !important;
    overflow: visible !important;
  }
  html.ahp-layout-v497 #editorScreen .toolbar-main-controls {
    flex-wrap: nowrap !important;
    gap: 3px !important;
  }
  html.ahp-layout-v497 #editorScreen .toolbar-minimap.stage-minimap {
    height: 32px !important;
    margin-left: auto !important;
  }
  html.ahp-layout-v497 #editorScreen #stageViewport {
    padding: 16px 8px 6px 30px !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  html.ahp-layout-v497 #app #startScreen.start-usp-below-v537.start-refined-v538 .start-usp-item {
    transition: none !important;
  }
}
