/* StroyKalk v872: keep mode controls inside the actual calculator panel. */
@media screen {
  body[data-portal-page-type="calculator"] .calc-generated-statement-v810__mirror .calc-generated-statement-v810__result-data {
    content-visibility: visible !important;
    contain-intrinsic-size: none !important;
  }
  #calculator .roofmaster-live-head{flex-wrap:wrap}
  #calculator .roofmaster-live-actions{flex:0 0 auto;flex-wrap:wrap;max-width:100%}
  #calculator .rs-view-head {
    flex-wrap: wrap;
  }

  #calculator .rs-axo-tools {
    flex: 0 0 auto;
    max-width: 100%;
  }
}

@media screen and (min-width: 768px) {
  #calculator :has(> [data-portal-mode-group-v724]) {
    flex-wrap: wrap;
  }

  #calculator [data-portal-mode-group-v724] {
    flex: 0 0 auto !important;
    flex-wrap: wrap !important;
    width: max-content !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box;
  }

  #calculator [data-portal-mode-group-v724] > button {
    flex: 1 1 88px !important;
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box;
  }
}

/* v932: these controls live in the calculator's actual editor/preview width,
   which can be much narrower than the viewport beside the advertising rail.
   Keep text buttons intrinsic and wrap their row instead of breaking words. */
@media screen {
  main :is(
    [class*="-view-tabs"],[class*="-visual-tabs"],[class*="-ledger-tabs"],
    [class*="-mode-tabs"],[class*="-actions"],.slf-export,.mono-segment,.wfh-segment
  ):has(>button):not(:has(>:not(button))):not([hidden]):not([style*="display: none"]):not([style*="display:none"]):not(.form-actions):not([data-portal-ledger-tabs-v741="generated"]),
  main :is([class*="-nav-"],[data-portal-actionbar-v715])>div:has(>button):not(:has(>:not(button))):not([hidden]):not([style*="display: none"]):not([style*="display:none"]):not(.form-actions){
    display:flex!important;
    flex-wrap:wrap!important;
    gap:6px;
    min-width:0;
    max-width:100%;
    height:auto!important;
    box-sizing:border-box;
  }
  main :is(
    [class*="-view-tabs"],[class*="-visual-tabs"],[class*="-ledger-tabs"],
    [class*="-mode-tabs"],[class*="-actions"],.slf-export,.mono-segment,.wfh-segment
  ):has(>button):not(:has(>:not(button))):not([hidden]):not([style*="display: none"]):not([style*="display:none"]):not(.form-actions):not([data-portal-ledger-tabs-v741="generated"])>button:not([hidden]):not([style*="display: none"]):not([style*="display:none"]),
  main :is([class*="-nav-"],[data-portal-actionbar-v715])>div:has(>button):not(:has(>:not(button))):not([hidden]):not([style*="display: none"]):not([style*="display:none"]):not(.form-actions)>button:not([hidden]):not([style*="display: none"]):not([style*="display:none"]){
    flex:1 0 auto!important;
    width:auto!important;
    min-width:44px!important;
    max-width:100%;
    min-height:44px;
    height:auto!important;
    white-space:normal!important;
    overflow-wrap:normal!important;
    word-break:normal!important;
  }
  main :is(
    [class*="-view-tabs"],[class*="-visual-tabs"],[class*="-ledger-tabs"],
    [class*="-mode-tabs"],[class*="-actions"],.slf-export,.mono-segment,.wfh-segment
  ):has(>button):not(:has(>:not(button))):not([hidden]):not([style*="display: none"]):not([style*="display:none"]):not(.form-actions)>button :is(b,strong,small,span){
    overflow-wrap:normal!important;
    word-break:normal!important;
  }

  /* Rich steps and illustrated choices need a readable card width. Reset
     old column spans so a one-column editor cannot create implicit tracks. */
  main :is(.calc-adaptive-grid-v143,.paint-wizard-tabs,.floor-progress-v764):has(>button):not(:has(>:not(button))):not([hidden]):not([style*="display: none"]):not([style*="display:none"]):not(.form-actions),
  main .calc-stage-responsive-rich-v472{
    grid-template-columns:repeat(auto-fit,minmax(min(100%,200px),1fr))!important;
    grid-auto-flow:row!important;
    grid-auto-columns:auto!important;
    grid-template-rows:none!important;
  }
  main :is(.calc-adaptive-grid-v143,.paint-wizard-tabs,.floor-progress-v764):has(>button):not(:has(>:not(button)))>button{
    grid-column:auto!important;
    max-width:100%;
  }
  main :is(.calc-adaptive-grid-v143,.paint-wizard-tabs,.floor-progress-v764):not([hidden]):not([style*="display: none"]):not([style*="display:none"]):not(.form-actions)>button,
  main :is(.calc-adaptive-grid-v143,.paint-wizard-tabs,.floor-progress-v764):not([hidden]):not([style*="display: none"]):not([style*="display:none"]):not(.form-actions)>button :is(b,strong,small){
    overflow-wrap:normal!important;
    word-break:normal!important;
  }
  main .calc-stage-responsive-rich-v472>button:not([hidden]):not([style*="display: none"]):not([style*="display:none"]):not(.form-actions):has(>[data-portal-stage-number-v726]):has(>small){
    display:grid!important;
    grid-template-columns:26px minmax(0,1fr)!important;
  }
  main .calc-stage-responsive-rich-v472>button>[data-portal-stage-number-v726]{grid-column:1;grid-row:1/span 2}
  main .calc-stage-responsive-rich-v472>button:not([hidden]):not([style*="display: none"]):not([style*="display:none"]):not(.form-actions):has(>[data-portal-stage-number-v726])>:is(b,strong,small):not([hidden]):not([style*="display: none"]):not([style*="display:none"]):not(.form-actions){
    grid-column:2;
    display:block!important;
    min-width:0!important;
    padding:0!important;
    background:none!important;
    overflow-wrap:normal!important;
    word-break:normal!important;
  }

  /* Eight region values must wrap as cards in a narrow editor. */
  main :is(.snowload-zone-grid,.windload-region-grid){grid-template-columns:repeat(auto-fit,minmax(min(100%,80px),1fr))!important}
  main :is(.snowload-zone-grid,.windload-region-grid)>button,
  main :is(.snowload-zone-grid,.windload-region-grid)>button :is(b,small){overflow-wrap:normal!important;word-break:normal!important}

  /* The lathing live estimate also occupies the preview's narrow column. */
  main .lathpro-live-kpis{grid-template-columns:repeat(auto-fit,minmax(min(100%,180px),1fr))!important;grid-auto-flow:row!important}

  /* Headings and their utility buttons may use separate lines. */
  main :is(.mini-head,[class*="-mini-head"],[class*="-step-head"],[class*="-climate-head"]){flex-wrap:wrap!important;min-width:0;max-width:100%}
  main :is(.mini-head,[class*="-mini-head"],[class*="-step-head"],[class*="-climate-head"])>button{
    flex:0 0 auto!important;
    width:auto!important;
    max-width:100%;
    white-space:normal!important;
    overflow-wrap:normal!important;
    word-break:normal!important;
  }
}
