/* v114 - scoped visual polish. Existing page behaviour and calculations are unchanged. */
html,body{max-width:100%;overscroll-behavior:none}
#app,.main,#view{min-width:0}
#view>*{max-width:100%;box-sizing:border-box}
button,input,select,textarea{font:inherit}
button,[role="button"],a{-webkit-tap-highlight-color:transparent}

/* Keep normal pages clear of the fixed bottom navigation and the mini chrome controls. */
body:not(.bottombar-hidden):not(.page-sale):not(.page-charts) #view{padding-bottom:max(76px,calc(66px + env(safe-area-inset-bottom)))}
body:not(.bottombar-hidden) #chromeToggles{bottom:max(68px,calc(62px + env(safe-area-inset-bottom)))!important}
body.bottombar-hidden #chromeToggles{bottom:max(6px,env(safe-area-inset-bottom))!important}

/* Work pages always consume the usable viewport without making the document scroll. */
body.ak-work-route #view{height:100%;min-height:0}
body.ak-work-route #view>section,
body.ak-work-route #view>div{min-height:0;max-height:100%;box-sizing:border-box}

/* Desktop Sale: balanced gutters and a toolbar that does not collide with T/B/M. */
@media (min-width:901px){
  body.page-sale .ak-sale-main{column-gap:16px!important;padding-inline:18px!important}
  body.page-sale .ak-bottom-toolbar{max-width:calc(100vw - 150px)!important;margin-inline:auto!important}
  body.page-sale #chromeToggles{right:7px!important}
  .ak-smart-sampletop{grid-template-columns:minmax(0,1.35fr) minmax(320px,.65fr)!important}
  .ak-smart-samplepair{grid-template-columns:minmax(0,62fr) minmax(340px,38fr)!important;height:clamp(390px,64dvh,680px)!important}
  .ak-smart-sampleimg{padding:10px!important}
  .ak-smart-sampletext{font-size:17px!important;line-height:1.5!important}
  .ak-smart-compact{grid-template-columns:auto auto minmax(90px,1fr) auto minmax(130px,auto)!important;align-items:center!important}
  .ak-reread-layer{padding:18px!important}
  .ak-reread-card{width:min(920px,94vw)!important;max-height:88dvh!important;overflow:auto!important;padding:12px 14px!important;gap:5px 9px!important}
  .ak-reread-opt{min-height:48px!important;padding:6px 8px!important}
  .ak-reread-custom{min-height:52px!important;max-height:70px!important}
}

/* Mobile Smart/Work review: image and text need real reading space, not two narrow columns. */
@media (max-width:700px){
  .ak-smart-head{height:46px!important;padding:5px 8px!important}
  .ak-smart-head b{font-size:16px!important}
  .ak-smart-tabs{height:38px!important;padding:4px 6px!important}
  .ak-smart-tab{min-width:92px!important;font-size:11px!important}
  .ak-smart-taskbar{min-height:42px!important;display:grid!important;grid-template-columns:minmax(0,1fr) auto!important;gap:4px!important}
  .ak-smart-taskbar select{width:100%!important;min-width:0!important}
  .ak-smart-mainreview{display:grid!important;grid-template-columns:1fr!important;grid-template-rows:minmax(220px,56fr) minmax(170px,44fr)!important;gap:5px!important;padding:5px!important}
  .ak-smart-imagebox,.ak-smart-textbox{width:100%!important;min-width:0!important}
  .ak-smart-textbox textarea{font-size:14px!important;line-height:1.42!important;padding:7px!important}
  .ak-smart-compact{grid-template-columns:minmax(82px,1fr) 44px minmax(64px,.75fr) 44px!important;gap:4px!important;padding:5px!important}
  .ak-smart-compact .ak-smart-thumbs{display:none!important}
  .ak-smart-choose{width:100%!important;min-width:0!important;height:36px!important}
  .ak-smart-navbtn{width:44px!important;min-width:44px!important;height:36px!important}
  .ak-smart-samplepane{padding:6px!important}
  .ak-smart-sampletop{display:block!important}
  .ak-smart-samplepair{display:grid!important;grid-template-columns:1fr!important;grid-template-rows:minmax(235px,58fr) minmax(165px,42fr)!important;height:calc(100dvh - 210px)!important;min-height:420px!important;gap:6px!important}
  .ak-smart-sampleimg{padding:5px!important}
  .ak-smart-sampletext{font-size:14px!important;line-height:1.45!important;padding:8px!important}
  .ak-smart-snav{margin-top:5px!important}
  .ak-smart-sactions{gap:4px!important}
  .ak-smart-sactions button,.ak-smart-sactions label{min-height:36px!important;flex:1 1 92px!important}
  .ak-reread-layer{align-items:flex-start!important;padding:6px!important}
  .ak-reread-card{width:100%!important;max-height:calc(100dvh - 12px)!important;border-radius:11px!important;padding:9px!important}
  .ak-reread-actions{position:sticky!important;bottom:0!important;background:#fff!important;padding-top:6px!important}
}

@media (max-width:390px){
  .ak-smart-mainreview{grid-template-rows:minmax(205px,55fr) minmax(165px,45fr)!important}
  .ak-smart-compact{grid-template-columns:minmax(74px,1fr) 40px minmax(54px,.7fr) 40px!important;gap:3px!important}
  .ak-smart-choose,.ak-smart-navbtn{font-size:10px!important;padding-inline:4px!important}
  .ak-smart-samplepair{height:calc(100dvh - 196px)!important;min-height:390px!important;grid-template-rows:minmax(215px,57fr) minmax(155px,43fr)!important}
}

@media (prefers-reduced-motion:reduce){
  html{scroll-behavior:auto!important}
}
