/* NIRVANA V159 — quality/stability layer */
:root{--nirvana-vh:100dvh;--safe-bottom:env(safe-area-inset-bottom,0px)}
html{scrollbar-gutter:stable}
body[data-active-page]:not([data-active-page="homePage"]){background:#f4f7fb!important}
body[data-active-page]:not([data-active-page="homePage"]) .content{background:#f4f7fb!important}

/* one clear active navigation state */
.side-nav>button.active,.nav-group.active>.nav-group-trigger{outline:1px solid rgba(255,255,255,.28)!important}
.nav-group.open>.nav-group-trigger{background:#edf5ff!important;color:#1768ce!important}
.nav-group.active.open>.nav-group-trigger{background:linear-gradient(135deg,#297ef0,#3e99ff)!important;color:#fff!important}

/* predictable panels and overlays */
.nav-flyout{overscroll-behavior:contain!important;scrollbar-width:thin}
.nav-flyout button:focus-visible,.side-nav button:focus-visible,#v123CoachForm button:focus-visible{outline:3px solid rgba(47,131,245,.28)!important;outline-offset:2px!important}

/* AI coach must be an opaque workspace on every device */
#coachPage,#coachPage .v123-coach,#coachPage .v123-chat{background:#f7f9fc!important;background-image:none!important}
#coachPage .v123-chat{min-width:0!important;overflow:hidden!important}
#v123CoachMsgs{min-width:0!important;overscroll-behavior:contain!important;scrollbar-gutter:stable}
#v123CoachMsgs *{max-width:100%;overflow-wrap:anywhere}
#v123CoachForm{isolation:isolate}
#v123CoachInput{min-width:0!important}

/* long tables/content never destroy page width */
.page table{max-width:100%}
.page .table-wrap,.page .table-container{max-width:100%;overflow:auto;-webkit-overflow-scrolling:touch}
.page img,.page svg,.page canvas{max-width:100%}

/* reduce needless GPU work while retaining premium look */
@media (hover:none),(pointer:coarse){
  .ref-kpis article,.ref-card,.sidebar,.nav-flyout{backdrop-filter:none!important;-webkit-backdrop-filter:none!important}
  .side-nav>button,.nav-group>.nav-group-trigger{transition:background .12s ease,color .12s ease!important}
}

/* tablet: no desktop flyout off-screen */
@media (min-width:769px) and (max-width:1180px){
  .nav-flyout{width:min(320px,calc(100vw - var(--sidebar-w) - 34px))!important;max-height:68dvh!important}
  #coachPage{padding:18px!important}
  #coachPage .v123-coach{height:calc(var(--nirvana-vh) - 36px)!important;min-height:560px!important;overflow:hidden!important}
  #coachPage .v123-chat{height:100%!important;min-height:0!important;display:flex!important;flex-direction:column!important}
  #v123CoachMsgs{flex:1 1 auto!important;min-height:0!important;overflow-y:auto!important}
  #v123CoachForm{flex:0 0 auto!important}
}

/* phone: stable viewport + composer + bottom dock */
@media (max-width:768px){
  body{min-height:var(--nirvana-vh)!important;padding-bottom:calc(72px + var(--safe-bottom))!important}
  .sidebar{height:calc(72px + var(--safe-bottom))!important}
  .content{padding-bottom:calc(72px + var(--safe-bottom))!important}
  .page:not(#homePage){padding-bottom:calc(92px + var(--safe-bottom))!important}
  #coachPage{height:calc(var(--nirvana-vh) - 72px - var(--safe-bottom))!important;min-height:0!important;padding:0!important;overflow:hidden!important}
  #coachPage .v123-coach,#coachPage .v123-chat{height:100%!important;min-height:0!important;max-height:none!important}
  #coachPage .v123-chat{display:flex!important;flex-direction:column!important;padding:10px 10px 8px!important}
  #v123CoachMsgs{flex:1 1 auto!important;height:auto!important;max-height:none!important;min-height:0!important;overflow-y:auto!important;-webkit-overflow-scrolling:touch!important;padding-bottom:12px!important}
  #v123Typing,#coachPage .v123-chips,#v136Attachments{flex:0 0 auto!important}
  #v123CoachForm{position:relative!important;bottom:auto!important;flex:0 0 auto!important;display:grid!important;grid-template-columns:42px minmax(0,1fr) 46px!important;gap:7px!important;width:100%!important;margin:0!important;padding:8px!important;background:#fff!important;border:1px solid rgba(15,42,76,.10)!important;border-radius:16px!important;box-shadow:0 8px 24px rgba(15,42,76,.10)!important}
  #v123CoachInput{font-size:16px!important;min-height:48px!important;max-height:132px!important;overflow-y:auto!important}
  .nav-flyout{bottom:calc(80px + var(--safe-bottom))!important;max-height:58dvh!important}
}

@media (prefers-reduced-motion:reduce){*,*::before,*::after{scroll-behavior:auto!important;animation-duration:.001ms!important;animation-iteration-count:1!important;transition-duration:.001ms!important}}
