/* Stroykalk v865 unified responsive layer: original v861 -> v862 -> v863 order preserved. */

/* --- portal-responsive-v861.css --- */
/* StroyKalk v861 — mobile/responsive layout hardening for all public calculators.
   Regression target: 320 / 375 / 505 / 768 CSS px.
   Prevents the shared Simple/PRO switch from shrinking the adjacent calculator
   heading into a one-character column and provides safe shrink containment. */

@media (max-width: 767px) {
  /* Known calculator headers that place the mode switch next to explanatory copy. */
  .irr-head,
.wp-head,
.chim-head,
.ply-head,
.sand-head,
.osb-head,
.adh-head,
.siding-head,
.guttermaster-head,
.loadmaster-head,
.windload-head,
.snowload-head,
.formwork-head,
.foundationmaster-head,
.roofmaster-head,
.shed-workstation-head,
.door-shell-head,
.grout-shell-head,
.mort-shell-head,
.win-shell-head,
.slope-shell-head,
.cem-shell-head,
.can-work-head-v292,
.pp-work-head-v282,
.truss-work-head-v275,
.room-work-head-v272,
.pipe-work-head-v262,
.walls-work-head-v259,
.beam-work-head-v237,
.bp-shell-head,
.mono-shell-head,
.framepro-shell-head,
.sf-shell-head,
.lathpro-shell-head,
.timber-shell-head,
.slp-shell-head,
.hc-modebar,
.rs-shell-head,
.slf-shell-head,
.pg-shell-head,
.sp-shell-head,
.electro-shell-head,
.vol-work-head-v312,
.vent-shell-head,
.wsup-shell-head,
.sew-work-head,
.hs-work-head,
.ds-work-head,
.rcs-work-head,
.rcb-work-head,
.rcc-work-head,
.rcf-work-head,
.rcw-work-head,
.rct-work-head,
.cbl-work-head,
.rbr-work-head,
.met-work-head,
.lgt-work-head,
.ac-work-head,
.wb-work-head {
    flex-direction:column!important;
    align-items:stretch!important;
    justify-content:flex-start!important;
    flex-wrap:nowrap!important;
    min-width:0!important;
    max-width:100%!important;
  }

  /* Fallback for future calculator headers using the same portal contract. */
  :where(header,section,div):has(> [data-portal-mode-group-v724="true"]) {
    flex-wrap:wrap!important;
    min-width:0!important;
    max-width:100%!important;
  }
  :where(header,section,div):has(> [data-portal-mode-group-v724="true"]) > :not([data-portal-mode-group-v724="true"]) {
    min-width:0!important;
    max-width:100%!important;
  }
  :where(header,section,div):has(> [data-portal-mode-group-v724="true"]) > [data-portal-mode-group-v724="true"] {
    flex:1 1 100%!important;
    width:100%!important;
    min-width:0!important;
    max-width:100%!important;
  }

  /* Shared switch is a second row on phones/tablets, never a competitor for
     the heading's horizontal space. */
  [data-portal-mode-group-v724="true"] {
    width:100%!important;
    max-width:100%!important;
    min-width:0!important;
  }

  /* Text remains readable even inside aggressively nested calculator shells. */
  :where(h1,h2,h3,h4,p,label,legend) {
    word-break:normal;
    overflow-wrap:break-word;
  }
  :where([class*="work"],[class*="station"],[class*="shell"],[class*="panel"],[class*="grid"]) > * {
    min-width:0;
  }

  /* Exact regression from /kalkulyator-balki/ at 505 px. */
  .beam-work-head-v237 {
    flex-direction:column!important;
    align-items:stretch!important;
    gap:12px!important;
  }
  .beam-work-head-v237 > div:first-child {
    width:100%!important;
    min-width:0!important;
    max-width:100%!important;
  }
  .beam-work-head-v237 h2,
  .beam-work-head-v237 p {
    width:auto!important;
    max-width:100%!important;
    white-space:normal!important;
    word-break:normal!important;
    overflow-wrap:break-word!important;
  }
}

@media (max-width: 480px) {
  [data-portal-mode-group-v724="true"] > [data-portal-mode-v724] {
    min-height:44px!important;
    padding-inline:8px!important;
  }
}


/* --- portal-responsive-v862.css --- */
/* StroyKalk v862 — mobile wizard vertical rhythm hardening.
   Prevents the legacy multi-step rail from re-entering layout after the
   compact premium progress status has already been rendered. The late
   portal-calculator-system-v729 layer uses !important and previously could
   reserve ~220–280 px of empty space on <=480 px viewports. */

@media (max-width: 760px) {
  body.calc-premium-v258 .calc-wizard-head-v226,
  body.calc-premium-v258 .calc-wizard-head-v219 {
    height:auto!important;
    min-height:0!important;
    block-size:auto!important;
    min-block-size:0!important;
    max-height:none!important;
    overflow:visible!important;
  }

  /* The compact status contains the same current-step information and is the
     single mobile progress UI. Remove the legacy rail from layout completely. */
  body.calc-premium-v258 .calc-wizard-head-v226 > .calc-wizard-progress-v226,
  body.calc-premium-v258 .calc-wizard-head-v219 > .calc-wizard-progress-v219 {
    display:none!important;
    width:0!important;
    height:0!important;
    min-height:0!important;
    max-height:0!important;
    margin:0!important;
    padding:0!important;
    border:0!important;
    overflow:hidden!important;
  }

  body.calc-premium-v258 .calc-premium-status-v258 {
    display:flex!important;
    width:100%!important;
    min-width:0!important;
    height:auto!important;
    min-height:0!important;
    margin-bottom:0!important;
  }

  body.calc-premium-v258 .calc-wizard-mobile-summary-v226,
  body.calc-premium-v258 .calc-wizard-mobile-summary-v219 {
    margin-top:12px!important;
    margin-bottom:10px!important;
  }

  body.calc-premium-v258 .calc-wizard-steps-v226,
  body.calc-premium-v258 .calc-wizard-step-v219 {
    min-height:0!important;
  }
}

@media (max-width: 480px) {
  body.calc-premium-v258 .calc-wizard-head-v226,
  body.calc-premium-v258 .calc-wizard-head-v219 {
    padding-bottom:14px!important;
  }
  body.calc-premium-v258 .calc-wizard-mobile-summary-v226,
  body.calc-premium-v258 .calc-wizard-mobile-summary-v219 {
    margin-inline:14px!important;
  }
}


/* --- portal-mobile-qa-v863.css --- */
/* StroyKalk v863 — full mobile layout QA hardening.
   Verified target widths: 320 / 360 / 375 / 390 / 412 / 480 / 505 / 767 CSS px.
   Loaded last on every public calculator page. */

@media (max-width: 767px) {
  /* Flex/grid descendants must be allowed to shrink without forcing page overflow. */
  main,
  main :where(section,article,aside,form,div,nav,header,footer) {
    min-width: 0;
  }

  main :where(img,svg,canvas,video) {
    max-width: 100%;
  }

  /* Wide tables belong to a local scroller; they must never widen the page. */
  :where(.table-wrap,[class*="table-wrap"],[class*="table-scroll"],.semantic-surface-v828__table-wrap,.semantic-tail-v827__table-wrap) {
    max-width: 100% !important;
    overflow-x: auto !important;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-inline: contain;
  }

  /* v862 guard extended through the full mobile/tablet breakpoint. */
  body.calc-premium-v258 .calc-wizard-head-v226,
  body.calc-premium-v258 .calc-wizard-head-v219 {
    height: auto !important;
    min-height: 0 !important;
    block-size: auto !important;
    min-block-size: 0 !important;
    max-height: none !important;
    overflow: visible !important;
  }

  body.calc-premium-v258 .calc-wizard-head-v226 > .calc-wizard-progress-v226,
  body.calc-premium-v258 .calc-wizard-head-v219 > .calc-wizard-progress-v219 {
    display: none !important;
    inline-size: 0 !important;
    block-size: 0 !important;
    min-height: 0 !important;
    max-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    overflow: hidden !important;
  }

  body.calc-premium-v258 .calc-premium-status-v258 {
    display: flex !important;
    width: 100% !important;
    min-width: 0 !important;
    height: auto !important;
    min-height: 0 !important;
  }

  /* Six transformer modes must not collapse into one-character columns. */
  .tr856-mode-tabs {
    grid-template-columns: repeat(2,minmax(0,1fr)) !important;
    gap: 8px !important;
    padding-inline: 18px !important;
  }
  .tr856-mode-tabs > button {
    width: 100% !important;
    min-width: 0 !important;
    white-space: normal !important;
    overflow-wrap: normal !important;
    word-break: normal !important;
  }

  /* Dense 4–5 step rails: use readable two-column cards on phones. */
  :where(.fuel-progress-v778,.gas-progress-v776,.elec-progress-v770,.circ-progress-v768,.tri-progress-v766) {
    grid-template-columns: repeat(2,minmax(0,1fr)) !important;
    gap: 7px !important;
  }
  :where(.fuel-progress-v778,.gas-progress-v776,.elec-progress-v770,.circ-progress-v768,.tri-progress-v766) > button {
    min-width: 0 !important;
    min-height: 44px !important;
    padding: 8px 7px !important;
    white-space: normal !important;
    word-break: normal !important;
    overflow-wrap: break-word !important;
  }
  :where(.fuel-progress-v778,.gas-progress-v776) > button:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }

  /* View/ledger/3D tool strips remain usable through local horizontal scrolling. */
  :where(
    [class*="-view-tabs"],
    [class*="-visual-tabs"],
    [class*="-ledger-tabs"],
    [class*="-axo-tools"],
    .hc-3d-tools,
    .stair-axo-buttons
  ) {
    max-width: 100% !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-inline: contain;
  }
  :where(
    [class*="-view-tabs"],
    [class*="-visual-tabs"],
    [class*="-ledger-tabs"],
    [class*="-axo-tools"],
    .hc-3d-tools,
    .stair-axo-buttons
  ) > button {
    min-width: 44px !important;
    min-height: 44px !important;
  }

  /* General touch floor for real buttons without changing text-field geometry. */
  button,
  [role="button"],
  [role="tab"] {
    min-height: 44px;
  }
  button:not([class*="close"]):not([aria-label*="Закрыть"]),
  [role="button"],
  [role="tab"] {
    min-width: 44px;
  }

  /* Native checks used by older calculators were visually 11–17 px. */
  :where(.adh-check,.guttermaster-check,.aacp-check,.bp-check,.gklp-check,.fi-check,.pool-checkline) input:is([type="checkbox"],[type="radio"]) {
    width: 20px !important;
    height: 20px !important;
    min-width: 20px !important;
    flex: 0 0 20px !important;
    accent-color: #148149;
  }
  :where(.adh-check,.guttermaster-check,.aacp-check,.bp-check,.gklp-check,.fi-check,.pool-checkline) {
    min-height: 44px;
  }

  /* Controls that previously wrapped vertically because their own column was too narrow. */
  .guttermaster-step-head {
    flex-wrap: wrap !important;
  }
  .guttermaster-reset {
    min-width: 88px !important;
    min-height: 44px !important;
    white-space: nowrap !important;
  }
  .openings-title {
    flex-wrap: wrap !important;
    align-items: flex-start !important;
  }
  .openings-title .tiny-btn,
  #addOpening {
    min-width: 132px !important;
    min-height: 44px !important;
    white-space: normal !important;
  }
  #flowUnit {
    min-width: 100px !important;
  }

  /* Result headers/status pills must wrap instead of widening their cards. */
  :where([class*="result-head"],[class*="results-head"]) {
    min-width: 0 !important;
    flex-wrap: wrap !important;
  }
  :where([class*="result-status"],[class*="status-pill"]) {
    max-width: 100% !important;
    white-space: normal !important;
    overflow-wrap: break-word !important;
  }

  /* Text must wrap by words, not character-by-character. */
  :where(h1,h2,h3,h4,p,label,legend,button,[role="tab"]) {
    word-break: normal !important;
  }
}

@media (max-width: 420px) {
  .tr856-mode-tabs {
    grid-template-columns: 1fr !important;
  }

  .guttermaster-step-head {
    flex-direction: column !important;
    align-items: stretch !important;
  }
  .guttermaster-reset {
    align-self: flex-start;
  }
}

/* v863.1 — resolve the generic v729 mode-grid auto-flow conflict on dense modes. */
@media (max-width: 767px) {
  main :is(.tr856-mode-tabs,.engine-mode-grid)[aria-label="Режим расчёта"] {
    display: grid !important;
    grid-auto-flow: row !important;
    grid-auto-columns: auto !important;
    grid-template-columns: repeat(2,minmax(0,1fr)) !important;
    width: 100% !important;
    min-width: 0 !important;
    gap: 8px !important;
  }
  main :is(.tr856-mode-tabs,.engine-mode-grid)[aria-label="Режим расчёта"] > button {
    width: 100% !important;
    min-width: 0 !important;
    min-height: 44px !important;
    white-space: normal !important;
    overflow-wrap: break-word !important;
    word-break: normal !important;
  }

  /* The area-unit switch is a flex row; prevent its buttons from shrinking below touch size. */
  .area-unit-v762 > button {
    flex: 1 0 48px !important;
    min-width: 48px !important;
    min-height: 44px !important;
    height: 44px !important;
  }
}

@media (max-width: 420px) {
  main :is(.tr856-mode-tabs,.engine-mode-grid)[aria-label="Режим расчёта"] {
    grid-template-columns: 1fr !important;
  }
}

/* v863.2 — consistent mobile form touch geometry across legacy calculators. */
@media (max-width: 767px) {
  main input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="hidden"]):not([type="color"]),
  main select {
    min-height: 44px !important;
    box-sizing: border-box !important;
  }

  :where(.hl-check,.rad-inline-check) input:is([type="checkbox"],[type="radio"]) {
    width: 20px !important;
    height: 20px !important;
    min-width: 20px !important;
    min-height: 20px !important;
    flex: 0 0 20px !important;
    accent-color: #148149;
  }
  :where(.hl-check,.rad-inline-check) {
    min-height: 44px !important;
    align-items: center !important;
  }
}

/* v863.3 — enforce the 44px mobile touch floor even against legacy fixed heights. */
@media (max-width: 767px) {
  main button,
  main [role="button"],
  main [role="tab"],
  .portal-shell-actions-v691 > :is(a,button) {
    min-height: 44px !important;
    box-sizing: border-box !important;
  }
}

@media (max-width: 767px) {
  .circ-unit-v768 > button {
    flex: 1 0 44px !important;
    min-width: 44px !important;
    min-height: 44px !important;
  }
}

/* v863.3: legacy calculator component styles set fixed 42px button heights.
   A final high-specificity, scoped touch-size contract prevents 42px controls. */
@media (max-width: 767px) {
  main button,
  main [role="button"],
  main [role="tab"] {
    min-height: 44px !important;
    box-sizing: border-box;
  }
  main button:not([class*="close"]):not([aria-label*="Закрыть"]),
  main [role="button"],
  main [role="tab"] {
    min-width: 44px !important;
  }
}

/* v863.4 — beat high-specificity legacy 42px contracts on common controls. */
@media (max-width: 767px) {
  main [data-portal-mode-group-v724="true"] > [data-portal-mode-v724],
  main [data-portal-actionbar-v715="1"] [data-portal-action-v715],
  main [data-full-ledger-action],
  main [data-rewarded-export-action-v740] {
    min-height: 44px !important;
    height: auto !important;
    box-sizing: border-box !important;
  }
}

@media (max-width: 767px) {
  main select {
    min-width: 44px !important;
  }
}

/* v863.4: compact selects in roof lath and blind-area visual controls. */
@media (max-width: 767px) {
  main #lathFaceSelect,
  main #baVisualSegment {
    min-width: 44px !important;
    min-height: 44px !important;
    box-sizing: border-box !important;
  }
}

@media (max-width: 767px) {
  #lathFaceSelect,
  #baVisualSegment {
    width: auto !important;
    min-width: 44px !important;
    max-width: 100% !important;
  }
  .lathpro-view-head > .lathpro-field,
  .ba-visual-options > label:has(> #baVisualSegment) {
    min-width: 44px !important;
  }
}

/* v863.5 — issues found in the extended audit of PTO and reference pages. */
@media (max-width: 767px) {
  /* Welding log: a legacy heading forced a 541px scroll width at 320px. */
  #example.id-section h2 {
    max-width: 100%;
    min-width: 0;
    white-space: normal !important;
    overflow-wrap: anywhere !important;
    word-break: normal !important;
  }
  /* KS-3 reference hub: 300px-wide link cards inside a 260px column. */
  .ks3-article-nav {
    min-width: 0 !important;
    max-width: 100% !important;
    grid-template-columns: minmax(0, 1fr) !important;
  }
  .ks3-article-nav > a {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }
  /* Example article tables: keep their useful width and scroll within the article. */
  .portal-mobile-table-v863 {
    display: block;
    width: 100%;
    max-width: 100% !important;
    min-width: 0 !important;
    overflow-x: auto !important;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
  }
}
@media (max-width:767px) {
 #example.id-section h2 { text-wrap: wrap !important; }
 .ks3-article-nav > a { overflow-wrap: anywhere !important; word-break: normal !important; }
}
@media (max-width: 767px) {
  body.ks3-page .portal-section-shell-v685,
  body.ks3-page .portal-section-main-v685 {
    max-width: 100% !important;
    min-width: 0 !important;
    overflow-x: clip !important;
  }
}

/* v863.6 — all-site tab/step layouts, including PTO forms and directory. */
@media (max-width: 767px) {
  .idr-nav-v530,
  .ks3c-tabs,
  .ks6a-tabs,
  #idcSteps {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    grid-auto-flow: row !important;
    gap: 8px !important;
    min-width: 0 !important;
    max-width: 100% !important;
    overflow-x: hidden !important;
  }
  .idr-nav-v530 > button,
  .ks3c-tabs > button,
  .ks6a-tabs > button,
  #idcSteps > button {
    min-width: 0 !important;
    width: 100% !important;
    white-space: normal !important;
    overflow-wrap: break-word !important;
    word-break: normal !important;
    text-wrap: wrap !important;
  }
  .catalog-category-tabs,
  .pto-tabs {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    max-width: 100% !important;
    min-width: 0 !important;
    gap: 8px !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-inline: contain;
  }
  .catalog-category-tabs > button,
  .pto-tabs > button {
    flex: 0 0 auto !important;
    width: auto !important;
    min-width: 110px !important;
    white-space: normal !important;
    word-break: normal !important;
    text-wrap: wrap !important;
  }
}
@media (max-width: 767px) {
  body.id-tool-page-v528 .idc-tool-v528 {
    max-width: 100% !important;
    overflow-x: clip !important;
  }
  body.id-tool-page-v528 .idc-save-state-v528 {
    max-width: 100% !important;
    white-space: normal !important;
    overflow-wrap: anywhere !important;
  }
  body.id-tool-page-v528 .id-table {
    max-width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }
}
/* v863.7 — native check/radio controls in PTO forms previously remained 13px. */
@media (max-width: 767px) {
  main input:is([type="checkbox"],[type="radio"]) {
    min-width: 20px !important;
    min-height: 20px !important;
    accent-color: #148149;
  }
}

