/* HOME only: budget for the visible viewport, browser chrome and safe areas.
   Content may grow naturally for text zoom/long names: never hide vertical overflow. */
body.nav-visible #screen-main.active {
  --home-fit-height:calc(100svh - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  min-height:100svh;
  padding-bottom:calc(76px + env(safe-area-inset-bottom));
}
#screen-main.active .home-header {
  padding:calc(24px + env(safe-area-inset-top)) 16px 0;
  flex:0 0 auto;
}
#screen-main.active .greeting-name {font-size:clamp(1.4rem,5.8vw,2rem);overflow-wrap:anywhere}
#screen-main.active .home-console-wrap {
  flex:1 0 auto;justify-content:flex-end;gap:8px;
  padding:0 16px 8px!important;
}
#screen-main.active #home-console-stage {
  margin:0 auto!important;display:flex;align-items:center;justify-content:center;
  flex:1 0 140px;min-height:140px;width:100%;position:relative;
}
#screen-main.active #home-console-stage .booki-character-stage {
  width:100%!important;min-height:0!important;height:100%!important;
  position:absolute;inset:0;display:flex;align-items:center;justify-content:center;
  padding:0!important;margin:0!important;
}
#screen-main.active #home-console-stage .booki-character-stage > img {
  width:auto!important;height:100%!important;max-height:min(42svh,360px)!important;
  max-width:76vw;object-fit:contain;display:block;
}
#screen-main.active #booki-reading-dial {
  width:min(100%,440px,calc(var(--home-fit-height) * .48));margin:0 auto!important;flex:0 0 auto;
}
#screen-main.active #home-personal-goal {
  width:min(100%,390px);margin:0 auto;padding:10px 12px;gap:8px;flex:0 0 auto;
}
#screen-main.active #home-personal-goal .home-class-goal-tree {
  width:38px;height:38px;flex-basis:38px;font-size:1.4rem;
}
#screen-main.active #home-personal-goal .home-class-goal-topline {flex-wrap:wrap;gap:2px 8px}
#screen-main.active #home-personal-goal .home-class-goal-body {gap:5px}
#screen-main.active #home-personal-goal small {overflow-wrap:anywhere}
/* Very short/landscape or zoomed viewports scroll normally, retaining all controls. */
@media(max-height:480px){
  #screen-main.active #home-console-stage {flex:0 0 100px;min-height:100px}
  #screen-main.active #home-console-stage .booki-character-stage > img {height:100px!important}
  #screen-main.active #booki-reading-dial {width:min(100%,300px)}
}
/* Reader card owns its sticky header inset exactly once. The screen's existing
   nav-visible bottom padding remains the scroll clearance for the fixed tabs. */
#screen-reader-card > .sticky-header {
  padding-top:calc(16px + env(safe-area-inset-top,0px));
  padding-inline:max(20px,env(safe-area-inset-right,0px)) max(20px,env(safe-area-inset-left,0px));
}
#screen-reader-card > .sticky-header .header-row {flex-wrap:wrap}
#screen-reader-card > .sticky-header h2 {min-width:0;flex:1 1 160px;overflow-wrap:anywhere}
#screen-reader-card > .sticky-header .btn-back {flex:0 0 auto;min-height:44px}
