/* Shared customer commerce actions and quantity controls. */
/* Source candidate: Root must place this after the exact active theme consumers. */
/* Detail is built in this order: back, optional tabs, public tools, then panels. */
.market-product-detail:not([hidden]) {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.market-product-detail > :is(.market-back,.author-product-switcher,.author-public-tools) {
  flex: 0 1 auto;
  min-inline-size: 0;
  max-inline-size: 100%;
}
.market-product-detail > .market-back { margin: 0; }
.market-product-detail > :is(.author-product-switcher,.author-public-tools):not([hidden]) {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.market-product-detail > :not(.market-back):not(.author-product-switcher):not(.author-public-tools) {
  flex: 1 0 100%;
  min-inline-size: 0;
}

/* These groups already exist in the supplied source; do not move actions in DOM. */
:is(.market-storefront,.market-product-detail,.commerce-cart,[data-experience-view="shop"],[data-experience-view="orders"],[data-experience-view="help"]) .actions:not([hidden]),
.member-account-benefits .actions:not([hidden]),
.commerce-add-row:not([hidden]),
.commerce-mini-dialog .commerce-mini-actions:not([hidden]),
.commerce-cart :is(.commerce-cart-heading,.commerce-cart-actions,.commerce-cart-selection-actions,.commerce-cart-code-actions,.commerce-cart-line-controls):not([hidden]) {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  min-inline-size: 0;
}
:is(.market-storefront,.market-product-detail,.commerce-cart,[data-experience-view="shop"],[data-experience-view="orders"],[data-experience-view="help"],.member-account-benefits) :is(.actions,.commerce-add-row,.commerce-cart-heading,.commerce-cart-actions,.commerce-cart-selection-actions,.commerce-cart-code-actions,.commerce-cart-line-controls,.author-product-switcher,.author-public-tools) > :is(button,.btn),
.commerce-mini-dialog .commerce-mini-actions > button,
.commerce-cart :is(.commerce-cart-quote-form,.commerce-cart-confirmation) > button.btn,
.market-product-detail > .market-back {
  box-sizing: border-box;
  min-block-size: 44px;
  min-inline-size: 44px;
  max-inline-size: 100%;
  inline-size: auto;
  flex: 0 1 auto;
  white-space: normal;
  overflow-wrap: anywhere;
}
.commerce-cart-heading > h1 { margin-inline-end: auto; }
.commerce-cart :is(.commerce-cart-quote-form,.commerce-cart-confirmation) > button.btn { justify-self: start; }
:is(.market-storefront,.market-product-detail,.commerce-cart,[data-experience-view="shop"],[data-experience-view="orders"],[data-experience-view="help"],.member-account-benefits) :is(button,.btn):focus-visible { outline: 3px solid #855014; outline-offset: 3px; }

@media (max-width: 600px) {
  .market-product-detail { gap: 6px; }
  .market-product-detail > :is(.author-product-switcher,.author-public-tools):not([hidden]) { gap: 6px; }
  .commerce-add-row > .btn,
  .commerce-cart-code-actions > .btn { flex: 0 1 auto; }
}
@media (forced-colors: active) {
  :is(.market-storefront,.market-product-detail,.commerce-cart,[data-experience-view="shop"],[data-experience-view="orders"],[data-experience-view="help"],.member-account-benefits) :is(button,.btn):focus-visible { outline: 2px solid Highlight; outline-offset: 3px; }
}

/* Add after the existing commerce CSS. Scope is limited to the two patched views. */
.commerce-quantity{display:grid;grid-template-columns:44px minmax(3.5rem,5.5rem) 44px;align-items:end;gap:6px;max-inline-size:100%;min-inline-size:0}
.commerce-quantity[hidden]{display:none}
.commerce-quantity-label{display:grid;gap:4px;min-inline-size:0;overflow-wrap:anywhere}
.commerce-quantity-label input[type=number]{box-sizing:border-box;inline-size:100%;min-inline-size:0;min-block-size:44px;text-align:center;appearance:textfield;-moz-appearance:textfield}
.commerce-quantity-label input[type=number]::-webkit-inner-spin-button,.commerce-quantity-label input[type=number]::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}
.commerce-quantity .commerce-quantity-step{box-sizing:border-box;min-inline-size:44px;min-block-size:44px;padding-inline:8px}
.commerce-quantity :is(button,input):focus-visible{outline:3px solid var(--ywv-gold,#a98a57);outline-offset:2px}
@media(forced-colors:active){.commerce-quantity :is(button,input):focus-visible{outline-color:Highlight}}


/* Material P0: presentation only. Cart remains the original presenter. */
.market-product-detail>.market-detail-toolbar{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:start;gap:8px 16px;inline-size:100%;min-inline-size:0;direction:ltr}
.market-detail-toolbar>.market-detail-navigation{display:flex;flex-wrap:wrap;align-items:center;gap:8px 12px;min-inline-size:0}
.market-detail-toolbar .author-product-switcher:not([hidden]){display:flex;flex-wrap:wrap;align-items:center;gap:4px;max-inline-size:100%;min-inline-size:0}
.market-detail-toolbar>.author-public-tools:not([hidden]),.market-storefront .market-storefront-header>.market-storefront-cart{display:flex;align-items:flex-start;justify-content:flex-end;justify-self:end;inline-size:auto;max-inline-size:min(46vw,18rem);min-inline-size:0}
.market-detail-toolbar :is(.btn,button),.market-storefront .market-storefront-cart :is(.btn,button){box-sizing:border-box;min-block-size:44px;min-inline-size:44px;inline-size:auto;max-inline-size:100%;white-space:normal;overflow-wrap:anywhere}
.market-detail-toolbar .market-back{margin:0}
.market-product-detail .market-detail-breadcrumb{margin:8px 0 16px;font-size:.875rem;line-height:1.5}
.market-storefront#market-collections{grid-template-columns:minmax(0,1fr);gap:10px}
.market-storefront#market-collections>.market-storefront-header{display:grid;grid-template-columns:minmax(0,.8fr) minmax(12rem,1.4fr) auto;align-items:center;gap:12px 20px;padding:0 0 10px;margin:0;direction:ltr}
.market-storefront#market-collections .market-storefront-header>.market-storefront-heading{display:block;inline-size:auto;max-inline-size:100%;min-inline-size:0}
.market-storefront#market-collections .market-storefront-heading h1{font-size:clamp(25px,2.3vw,34px);margin:0}
.market-storefront#market-collections .market-storefront-header>.market-search221-group{inline-size:100%;min-inline-size:0}
.market-storefront#market-collections .market-storefront-cart .market-exchange-shortcut{max-inline-size:100%}
.market-storefront#market-collections>.market-browse-tools{display:grid;grid-template-columns:minmax(0,1fr) auto auto;align-items:center;gap:4px 12px;min-inline-size:0;border-block-end:1px solid var(--market-line,#d9d8ce);padding-block-end:4px}
.market-storefront#market-collections .market-browse-tools>.market-category-row.market-category-tree{display:flex;grid-column:1;grid-row:1;flex-wrap:nowrap;align-items:flex-start;gap:4px 8px;overflow-x:auto;min-inline-size:0;max-inline-size:100%;border:0;padding:0;margin:0;scroll-padding-inline:8px;scrollbar-width:thin}
.market-storefront#market-collections .market-category-row.market-category-tree>ul{display:flex;flex:0 0 auto;flex-wrap:nowrap;align-items:flex-start;gap:4px 8px;inline-size:max-content;max-inline-size:none;margin:0;padding:0}
.market-storefront#market-collections .market-category-row.market-category-tree>ul>li{display:flex;flex:0 0 auto;align-items:flex-start;gap:4px}
.market-storefront#market-collections .market-category-row.market-category-tree>a{flex:0 0 auto}
.market-storefront#market-collections .market-category-row.market-category-tree a,.market-storefront#market-collections .market-category-row.market-category-tree summary{min-block-size:44px;padding:9px 10px;line-height:1.5;white-space:nowrap;overflow-wrap:normal}
.market-storefront#market-collections .market-category-row.market-category-tree :focus-visible{outline-offset:-3px}
.market-storefront#market-collections .market-category-row.market-category-tree::-webkit-scrollbar{display:block;height:6px}
.market-storefront#market-collections .market-browse-tools>.market-shop-toolbar{display:flex;grid-column:2;grid-row:1;flex-wrap:wrap;align-items:center;justify-content:flex-start;gap:8px;padding:0;min-inline-size:0;max-inline-size:100%}
.market-storefront#market-collections .market-shop-toolbar>label{flex:1 1 auto;flex-wrap:nowrap;gap:4px;min-inline-size:0;max-inline-size:100%}
.market-storefront#market-collections .market-shop-toolbar select{flex:0 1 auto;min-inline-size:0;max-inline-size:100%}
.market-storefront#market-collections .market-browse-tools>.market-shop-result{display:flex;grid-column:3;grid-row:1;flex-wrap:wrap;align-items:center;justify-content:flex-end;gap:4px;min-block-size:44px;min-inline-size:0;max-inline-size:6rem;margin:0;text-align:end}
@media(max-width:1100px){.market-storefront#market-collections>.market-browse-tools{grid-template-columns:minmax(0,1fr) fit-content(6rem)}.market-storefront#market-collections .market-browse-tools>.market-category-row.market-category-tree{grid-column:1/-1;grid-row:1}.market-storefront#market-collections .market-browse-tools>.market-shop-toolbar{grid-column:1;grid-row:2}.market-storefront#market-collections .market-browse-tools>.market-shop-result{grid-column:2;grid-row:2}}
.market-storefront#market-collections>.market-category-breadcrumb{margin:0;font-size:.875rem;line-height:1.5}
.market-storefront#market-collections>.market-active-filters{grid-row:auto;gap:4px;margin:0}
.market-storefront#market-collections>.market-active-filters[hidden]{display:none!important}
@media(max-width:700px){.market-storefront#market-collections>.market-active-filters>button{flex:1 1 calc(50% - 2px);min-inline-size:0;max-inline-size:calc(50% - 2px);padding-inline:8px;text-align:start}}
.market-storefront#market-collections>.market-product-grid{grid-template-columns:repeat(4,minmax(0,1fr))}
.market-detail-toolbar [hidden],.market-storefront#market-collections>.market-category-breadcrumb[hidden],.market-storefront#market-collections .market-browse-tools [hidden]{display:none!important}
[dir=rtl] .market-detail-toolbar>*,[dir=rtl] .market-storefront#market-collections .market-storefront-header>*{direction:rtl}
.material-tier-prices.material-purchase-summary{display:grid;gap:8px;padding:12px 0;margin-block:12px;border:0;border-block-start:1px solid var(--market-line,#d9d8ce);border-radius:0;background:transparent;min-inline-size:0}
.material-tier-prices.material-purchase-summary>p{margin:0}
.material-tier-prices.material-purchase-summary .commerce-quantity{inline-size:max-content;max-inline-size:100%;justify-content:start}
.material-tier-prices.material-purchase-summary .commerce-quantity-label{display:grid;gap:4px;min-inline-size:0;font-size:.875rem}
.material-tier-prices.material-purchase-summary>.material-purchase-total{font-size:clamp(20px,2vw,26px);font-weight:650;line-height:1.4;color:inherit}
.material-tier-prices.material-purchase-summary>.material-purchase-shipping{font-size:.875rem;line-height:1.5;color:inherit}
.material-tier-prices.material-purchase-summary>.material-purchase-status{font-size:.8125rem;line-height:1.5}
.material-tier-prices.material-purchase-summary>button{justify-self:start}
.market-product-detail .market-detail-info:has(>.commerce-detail-rules .material-purchase-summary>.material-purchase-total:not([hidden]))>.market-price{display:none}
@media(max-width:1100px){.market-storefront#market-collections>.market-product-grid{grid-template-columns:repeat(3,minmax(0,1fr))}}
@media(max-width:700px){.market-storefront#market-collections>.market-storefront-header{grid-template-columns:minmax(0,1fr) auto;gap:8px 12px}.market-storefront#market-collections .market-storefront-heading{grid-column:1;grid-row:1}.market-storefront#market-collections .market-storefront-cart{grid-column:2;grid-row:1}.market-storefront#market-collections .market-search221-group{grid-column:1/-1;grid-row:2}.market-storefront#market-collections .market-browse-tools>.market-category-row.market-category-tree{flex-basis:100%}.market-storefront#market-collections .market-browse-tools>.market-shop-toolbar{flex:1 1 auto}.market-storefront#market-collections .market-browse-tools>.market-shop-result{margin-inline-start:auto}.market-product-detail>.market-detail-toolbar{gap:8px 12px}}
@media(max-width:650px){.market-storefront#market-collections>.market-product-grid{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media(max-width:359px){.market-storefront#market-collections>.market-product-grid{grid-template-columns:minmax(0,1fr)}}

/* Home materials: keep original pending and physical action shells on the same grid. */
body.knitora[data-wb-edition] .wh-home.wph-public-home #home-market .wph-market-row .wph-carousel-page>:is(.wph-shop-card,.wh-official-product)>:is(.wph-shop-copy,.wh-card-copy)>.commerce-add-row:not([hidden]):has(>button.btn.primary:not([hidden])){display:grid;grid-template-columns:repeat(2,minmax(0,1fr));grid-template-rows:minmax(44px,auto) minmax(36px,auto);grid-row:4;grid-column:1/-1;align-content:start;align-items:stretch;gap:8px;inline-size:100%;min-inline-size:0;margin:0;padding:0;font-size:12px;line-height:1.5}
body.knitora[data-wb-edition] .wh-home.wph-public-home #home-market .wph-market-row .wph-carousel-page>:is(.wph-shop-card,.wh-official-product)>:is(.wph-shop-copy,.wh-card-copy)>.commerce-add-row:not([hidden]):has(>button.btn.primary:not([hidden]))>.btn:not([hidden]){box-sizing:border-box;inline-size:100%;min-inline-size:0;max-inline-size:100%;min-block-size:44px;padding:8px;font-size:12px;line-height:1.4;white-space:normal;overflow-wrap:anywhere}
body.knitora[data-wb-edition] .wh-home.wph-public-home #home-market .wph-market-row .wph-carousel-page>:is(.wph-shop-card,.wh-official-product)>:is(.wph-shop-copy,.wh-card-copy)>.commerce-add-row:not([hidden]):has(>button.btn.primary:not([hidden]))>:is(p,details):not([hidden]){grid-column:1/-1;grid-row:2;min-inline-size:0;min-block-size:36px;margin:0;font-size:12px;line-height:1.5;overflow-wrap:anywhere}

/* An existing order owns the summary when the basket and pricing panels are both empty. */
.commerce-cart:has(> .commerce-cart-pending:not([hidden])) > .commerce-cart-workspace:has(> .commerce-cart-items .commerce-cart-empty:not([hidden])):has(> .commerce-cart-pricing[hidden]) {
  display: none;
}
