/* Phone presentation only. The report and print layout retain their original DOM. */
.mobile-nav,.mobile-stepper,.mobile-install{display:none}
@media screen and (max-width:640px){
  :root{--cf-nav-h:65px;--cf-actions-h:61px;--cf-stepper-h:68px;--cf-safe-t:env(safe-area-inset-top,0px);--cf-safe-b:env(safe-area-inset-bottom,0px)}
  /* overflow-x:hidden on both html and body turns body into a scroll container, which
     stops the sticky step header from following the viewport. clip keeps the guard. */
  @supports (overflow:clip){html,body{overflow-x:clip}}
  body{padding-bottom:calc(var(--cf-nav-h) + 19px + var(--cf-safe-b))}
  body[data-mobile-view="inputs"]{padding-bottom:calc(var(--cf-nav-h) + var(--cf-actions-h) + 19px + var(--cf-safe-b))}
  .wrap{width:calc(100% - 24px)}
  .topbar{padding-top:max(12px,env(safe-area-inset-top,0px))}
  .layout{display:block;padding-bottom:12px}
  .intake{position:static;max-height:none;overflow:visible;padding:14px}
  .output{padding:14px}
  .control,.manual-details .control{font-size:16px;min-height:44px}

  /* Touch targets: at least 44px for every control a thumb has to hit. */
  button,.btn,.case-btn,.tier-btn,.preset-choice,.selected-risk-chip,.sec-toggle,.overview-link,.fb-opt,details.sec>summary{min-height:44px}
  nav[aria-label="Tool navigation"] a{display:inline-flex;align-items:center;min-height:44px;padding:0 4px}
  .trig,.protected-options label{min-height:44px;align-items:center}
  .trig{padding:8px 2px}
  .trig input,.protected-options input{margin-top:0;flex:0 0 auto}
  .manual-details>summary,.client-wording summary,.overview-secondary summary,.review-record summary,.focus-task summary,.preparation-disclosure>summary,#output details>summary{min-height:44px;padding-top:11px;padding-bottom:11px}

  /* Compact sticky step header: name and progress only, so it stays small above the keyboard. */
  .mobile-stepper{display:block;position:sticky;top:0;z-index:3;background:var(--card);margin:0 -14px 12px;padding:calc(8px + var(--cf-safe-t)) 14px 8px;border-bottom:1px solid var(--line)}
  .mobile-stepper p{display:flex;flex-direction:column;min-width:0;margin:0 0 7px}
  .mobile-step-count{font-size:11px;font-weight:700;letter-spacing:.04em;text-transform:uppercase;color:var(--muted)}
  .mobile-step-sep{display:none}
  .mobile-step-title{font-size:15px;font-weight:700;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
  .mobile-step-bar{height:4px;border-radius:999px;background:rgba(255,255,255,.1);overflow:hidden}
  .mobile-step-bar span{display:block;height:100%;border-radius:inherit;background:linear-gradient(90deg,var(--green2),var(--green))}

  /* Previous / Next stay in thumb reach above the view bar for the whole step. */
  .mobile-step-actions{display:flex;gap:8px;position:fixed;z-index:19;left:0;right:0;bottom:calc(var(--cf-nav-h) + var(--cf-safe-b));padding:8px max(12px,env(safe-area-inset-right,0px)) 8px max(12px,env(safe-area-inset-left,0px));background:#151525;border-top:1px solid var(--line)}
  .mobile-step-actions button{flex:1}
  .mobile-step-actions button:disabled{opacity:.45;cursor:default}
  .mobile-nav{display:flex;position:fixed;z-index:20;bottom:0;left:0;right:0;gap:6px;padding:8px max(12px,env(safe-area-inset-right,0px)) calc(8px + var(--cf-safe-b)) max(12px,env(safe-area-inset-left,0px));background:#151525;border-top:1px solid var(--line)}
  .mobile-nav button{flex:1;border:1px solid var(--line);border-radius:10px;background:var(--card);color:var(--text);font-weight:700;min-height:48px;font-size:13px}
  .mobile-nav button[aria-current]{border-color:var(--green);color:#c9efdd;background:#193b31}
  .mobile-nav button:focus-visible,.mobile-stepper button:focus-visible{outline:2px solid var(--green);outline-offset:2px}

  body[data-mobile-view] .mobile-inactive-step{display:none}
  /* The sticky header already names the open step; the step is always expanded on a phone. */
  body[data-mobile-view] #intake-form>details.sec>summary{display:none}
  body[data-mobile-view] #intake-form>details.sec>.fields{padding-top:12px}
  body[data-mobile-view="inputs"] #output,body[data-mobile-view="results"] #intake,
  body[data-mobile-view="install"] #intake,body[data-mobile-view="install"] #output{display:none}
  body[data-mobile-view="install"] .mobile-install{display:block;padding:18px;margin-bottom:16px}
  body[data-mobile-view] .jump{display:none}
  .mobile-install h2{font-size:21px;line-height:1.25}
  .mobile-install p{overflow-wrap:anywhere}

  /* Keep scrolled-to and focused controls clear of the sticky header and fixed bars. */
  #output,.mobile-stepper,.mobile-install{scroll-margin-top:calc(12px + var(--cf-safe-t))}
  #intake-form>details.sec{scroll-margin-top:calc(var(--cf-stepper-h) + var(--cf-safe-t) + 8px)}
  #intake :is(input,select,textarea,button,summary,label){scroll-margin-top:calc(var(--cf-stepper-h) + var(--cf-safe-t) + 12px);scroll-margin-bottom:calc(var(--cf-nav-h) + var(--cf-actions-h) + var(--cf-safe-b) + 12px)}
  #output :is(input,select,textarea,button,summary,label){scroll-margin-top:12px;scroll-margin-bottom:calc(var(--cf-nav-h) + var(--cf-safe-b) + 12px)}
  .toast{bottom:calc(var(--cf-nav-h) + 25px + var(--cf-safe-b));width:max-content;max-width:calc(100% - 24px);text-align:center}
  body[data-mobile-view="inputs"] .toast{bottom:calc(var(--cf-nav-h) + var(--cf-actions-h) + 25px + var(--cf-safe-b))}
}
/* Short viewports (small phones in landscape): slimmer fixed bars. */
@media screen and (max-width:640px) and (max-height:430px){
  :root{--cf-nav-h:53px;--cf-actions-h:53px}
  .mobile-nav{padding-top:4px;padding-bottom:calc(4px + var(--cf-safe-b))}
  .mobile-nav button{min-height:44px}
  .mobile-step-actions{padding-top:4px;padding-bottom:4px}
}
@media print{
  .mobile-nav,.mobile-stepper,.mobile-install{display:none!important}
}
