/* The document is the page scroller. Keeping scroll ownership at the document
   lets wheel, trackpad, and touch input over any ordinary page surface work. */
html:where(:not(.tv-stitch-surface):not(.tv-stitch-surface *):not(.tv-home-v1):not(.tv-home-v1 *)){
  height: auto;
  min-height: 100%;
  overflow-x: clip;
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

body:where(:not(.tv-stitch-surface):not(.tv-stitch-surface *):not(.tv-home-v1):not(.tv-home-v1 *)){
  height: auto;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: clip;
  overflow-y: visible;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

/* The legacy workspace theme fixes #tv-app to the viewport. Release that
   root too, so overflowing workspace content contributes to document height. */
body #tv-app:where(:not(.tv-stitch-surface):not(.tv-stitch-surface *):not(:has(.tv-stitch-surface))){
  height: auto;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: visible;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

/* Keep the page behind the mobile navigation stationary. The sidebar's own
   navigation list remains independently scrollable while it is open. */
html:has(body[data-navy-navigation-open]):where(:not(.tv-stitch-surface):not(.tv-stitch-surface *):not(.tv-home-v1):not(.tv-home-v1 *)){
  overflow: hidden;
}

body[data-navy-navigation-open] #tv-app > .app-shell.ps-app:where(:not(.tv-stitch-surface):not(.tv-stitch-surface *):not(:has(.tv-stitch-surface))){
  overflow: hidden;
}

/* Let the shell grow with its content instead of trapping page scrolling in
   a viewport-sized nested container. */
body #tv-app > .app-shell.ps-app[data-shell-design="stitch-navy-atelier-v1"] {
  position: relative;
  inset: auto;
  grid-template-rows: 64px max-content max-content;
  align-content: start;
  min-height: 100vh;
  min-height: 100dvh;
  height: auto;
  overflow: visible;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

/* Keep navigation anchored to the viewport and outside document grid sizing. */
body #tv-app > .app-shell.ps-app[data-shell-design="stitch-navy-atelier-v1"] > .ps-sidebar {
  position: fixed;
  inset: 0 auto auto 0;
}

body #tv-app > .app-shell.ps-app[data-shell-design="stitch-navy-atelier-v1"] > .ps-header {
  position: sticky;
  top: 0;
  z-index: 50;
}

/* Main content remains in normal document flow and expands to its content. */
body #tv-app > .app-shell.ps-app[data-shell-design="stitch-navy-atelier-v1"] > main.ps-main {
  grid-column: 2;
  grid-row: 3;
  min-width: 0;
  min-height: max-content;
  height: auto;
  overflow: visible;
}

body #tv-app > .app-shell.ps-app[data-shell-design="stitch-navy-atelier-v1"] > main.ps-main > .content-frame {
  height: auto;
  min-height: max-content;
  overflow: visible;
}

body #tv-app > .app-shell.ps-app[data-shell-design="stitch-navy-atelier-v1"] > main.ps-main > .content-frame > .workspace {
  height: auto;
  min-height: max-content;
  overflow: visible;
  overscroll-behavior-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

/* Preserve native document and menu scrolling while hiding decorative tracks.
   Nested drawers/tables retain their own scroll behavior. */
html:where(:not(.tv-stitch-surface):not(.tv-stitch-surface *):not(.tv-home-v1):not(.tv-home-v1 *))::-webkit-scrollbar,body:where(:not(.tv-stitch-surface):not(.tv-stitch-surface *):not(.tv-home-v1):not(.tv-home-v1 *))::-webkit-scrollbar,#tv-app:where(:not(.tv-stitch-surface):not(.tv-stitch-surface *):not(:has(.tv-stitch-surface)))::-webkit-scrollbar,.ps-app:where(:not(.tv-stitch-surface):not(.tv-stitch-surface *):not(:has(.tv-stitch-surface)))::-webkit-scrollbar,.ps-app > .ps-main::-webkit-scrollbar,.ps-app .workspace:where(:not(.tv-stitch-surface):not(.tv-stitch-surface *):not(:has(.tv-stitch-surface)))::-webkit-scrollbar,.ps-app .ps-nav:where(:not(.tv-stitch-surface):not(.tv-stitch-surface *):not(.tv-home-v1):not(.tv-home-v1 *))::-webkit-scrollbar{
  display: none;
  width: 0;
  height: 0;
}

.ps-app,.ps-app > .ps-main,.ps-app .ps-nav:where(:not(.tv-stitch-surface):not(.tv-stitch-surface *):not(.tv-home-v1):not(.tv-home-v1 *)){
  scrollbar-width: none;
  -ms-overflow-style: none;
}

/* Sidebar regions must not consume the page's wheel/touch gesture when they
   have no remaining vertical movement. Keep the list scrollable, but let the
   gesture chain to the document at either boundary. */
.ps-app .ps-sidebar:where(:not(.tv-stitch-surface):not(.tv-stitch-surface *):not(.tv-home-v1):not(.tv-home-v1 *)),.ps-app .ps-nav:where(:not(.tv-stitch-surface):not(.tv-stitch-surface *):not(.tv-home-v1):not(.tv-home-v1 *)){
  overscroll-behavior-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.ps-app .ps-sidebar:where(:not(.tv-stitch-surface):not(.tv-stitch-surface *):not(.tv-home-v1):not(.tv-home-v1 *))::-webkit-scrollbar,.ps-app .ps-nav:where(:not(.tv-stitch-surface):not(.tv-stitch-surface *):not(.tv-home-v1):not(.tv-home-v1 *))::-webkit-scrollbar{
  display: none;
  width: 0;
  height: 0;
}

@media (max-width: 900px) {
  body #tv-app > .app-shell.ps-app[data-shell-design="stitch-navy-atelier-v1"] {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 64px max-content max-content;
  }

  body #tv-app > .app-shell.ps-app[data-shell-design="stitch-navy-atelier-v1"] > main.ps-main {
    grid-column: 1;
    grid-row: 3;
  }
}
