/* TERA Coding Space v5.37.9: canonical body authority
   Header/footer content remain unchanged. This file owns research-shell geometry,
   pane containment, resizable body/footer boundaries, and page-specific body layouts. */

:root{
  --tera-body-splitter:10px;
  --tera-page-pad-x:14px;
  --tera-page-pad-y:12px;
  --tera-footer-height:104px;
  --tera-footer-splitter:8px;
}

/* --------------------------------------------------------------------------
   Canonical desktop shell: header | body | horizontal resize edge | footer
   -------------------------------------------------------------------------- */
@media (min-width:921px){
  html{height:100%;overflow:hidden}
  body.research-shell-body{
    height:100dvh!important;
    width:100vw!important;
    max-width:100vw!important;
    min-width:0!important;
    margin:0!important;
    padding:0!important;
    overflow:hidden!important;
    display:grid!important;
    grid-template-rows:auto minmax(0,1fr) var(--tera-footer-splitter) var(--tera-footer-height)!important;
    grid-template-columns:minmax(0,1fr)!important;
  }
  body.research-shell-body>.app-header.tera-canonical{
    grid-row:1!important;
    grid-column:1!important;
    position:relative!important;
    top:auto!important;
    width:100%!important;
    max-width:100vw!important;
    min-width:0!important;
    z-index:70!important;
  }
  body.research-shell-body>.layout{
    grid-row:2!important;
    grid-column:1!important;
    display:grid!important;
    grid-template-columns:minmax(78px,min(var(--sidebar-width),var(--shell-sidebar-max))) var(--tera-body-splitter) minmax(0,1fr)!important;
    gap:0!important;
    width:100%!important;
    max-width:100%!important;
    min-width:0!important;
    height:100%!important;
    min-height:0!important;
    margin:0!important;
    padding:0!important;
    align-items:stretch!important;
    overflow:hidden!important;
  }
  body.research-shell-body>.footer-splitter{
    grid-row:3!important;
    grid-column:1!important;
    position:relative!important;
    inset:auto!important;
    width:100%!important;
    height:var(--tera-footer-splitter)!important;
    min-height:var(--tera-footer-splitter)!important;
    margin:0!important;
    display:grid!important;
    place-items:center!important;
    cursor:row-resize!important;
    user-select:none!important;
    touch-action:none!important;
    background:var(--surface)!important;
    border-top:1px solid var(--border)!important;
    border-bottom:2px solid var(--blue)!important;
    z-index:79!important;
  }
  body.research-shell-body>.footer-splitter::before{
    content:"";
    width:72px;
    height:3px;
    border-radius:999px;
    background:color-mix(in srgb,var(--blue) 48%,var(--border));
  }
  body.research-shell-body>.footer-splitter:hover::before,
  body.research-shell-body>.footer-splitter:focus-visible::before{background:var(--gold)}
  body.research-shell-body>.footer-splitter>span{position:absolute;font-size:0}
  body.research-shell-body>.tera-institutional-footer{
    grid-row:4!important;
    grid-column:1!important;
    position:relative!important;
    inset:auto!important;
    width:100%!important;
    max-width:100%!important;
    min-width:0!important;
    height:100%!important;
    min-height:0!important;
    max-height:none!important;
    margin:0!important;
    overflow-y:auto!important;
    overflow-x:hidden!important;
    z-index:80!important;
  }
  body.research-shell-body>.tera-institutional-footer *{min-width:0}
  body.research-shell-body>.tera-institutional-footer .tera-footer-main,
  body.research-shell-body>.tera-institutional-footer .tera-footer-sub{max-width:100%!important}

  /* Left rail = primary workspace group + scrollable remaining navigation + identity. */
  body.research-shell-body .studio-sidebar{
    grid-column:1!important;
    grid-row:1!important;
    position:relative!important;
    inset:auto!important;
    width:auto!important;
    min-width:0!important;
    height:100%!important;
    min-height:0!important;
    max-height:none!important;
    align-self:stretch!important;
    display:grid!important;
    grid-template-rows:auto minmax(0,1fr) auto!important;
    overflow:hidden!important;
    border-right:1px solid var(--border)!important;
    background:var(--surface)!important;
    z-index:18!important;
  }
  body.research-shell-body .sidebar-primary-nav{
    grid-row:1!important;
    display:block!important;
    visibility:visible!important;
    min-height:0!important;
    padding:13px 12px 9px!important;
    margin:0!important;
    overflow:visible!important;
    border-bottom:1px solid var(--border)!important;
    background:var(--surface)!important;
  }
  body.research-shell-body .sidebar-primary-nav .sidebar-tools{display:block!important;margin:0 0 4px!important;padding:0!important}
  body.research-shell-body .sidebar-primary-nav .sidebar-tools>.nav-label{
    margin:0 8px 6px!important;
    color:var(--ink)!important;
    font-weight:850!important;
  }
  body.research-shell-body .sidebar-primary-nav .nav-group{margin:0!important}
  body.research-shell-body .sidebar-primary-nav .nav-section-label{
    margin:0 8px 5px!important;
    padding:0!important;
    border:0!important;
    color:var(--ink)!important;
    font-weight:800!important;
  }
  body.research-shell-body .sidebar-nav-scroll{
    grid-row:2!important;
    min-height:0!important;
    height:auto!important;
    max-height:none!important;
    margin:0!important;
    padding:9px 12px 8px!important;
    overflow-y:auto!important;
    overflow-x:hidden!important;
    overscroll-behavior:contain!important;
    overflow-anchor:none!important;
    scrollbar-gutter:stable!important;
    scroll-behavior:auto!important;
  }
  body.research-shell-body .nav-groups{display:block!important}
  body.research-shell-body .nav-group{margin:0 0 15px!important}
  body.research-shell-body .nav-group:last-child{margin-bottom:2px!important}
  body.research-shell-body .nav-section-label{
    margin:0 8px 5px!important;
    padding-top:9px!important;
    border-top:1px solid var(--border)!important;
    color:var(--muted)!important;
    font-weight:800!important;
  }
  body.research-shell-body .nav-link{
    display:flex!important;
    align-items:center!important;
    gap:10px!important;
    min-height:38px!important;
    margin:1px 0!important;
    padding:7px 9px!important;
    border-radius:9px!important;
    color:var(--ink)!important;
    font-weight:720!important;
    overflow:hidden!important;
  }
  body.research-shell-body .nav-link.active{
    background:var(--gold2)!important;
    color:var(--ink)!important;
    box-shadow:inset 3px 0 0 var(--gold)!important;
  }
  body.research-shell-body .nav-ico{flex:0 0 26px!important;width:26px!important;text-align:center!important}
  body.research-shell-body .nav-text{min-width:0!important;overflow:hidden!important;text-overflow:ellipsis!important;white-space:nowrap!important}
  body.research-shell-body .sidebar-footer{
    grid-row:3!important;
    min-height:0!important;
    margin:0!important;
    padding:10px 13px 11px!important;
    border-top:1px solid var(--border)!important;
    background:var(--surface)!important;
    line-height:1.3!important;
    overflow:hidden!important;
  }
  body.research-shell-body .sidebar-footer strong{display:block!important;color:var(--ink)!important;font-weight:850!important}
  body.research-shell-body .sidebar-footer br{display:none!important}
  body.research-shell-body .sidebar-footer .nav-text{display:block!important;margin-top:2px!important;color:var(--muted)!important;font-size:1rem!important}

  /* Vertical body splitter never contributes extra document width. */
  body.research-shell-body .shell-splitter{
    grid-column:2!important;
    grid-row:1!important;
    position:relative!important;
    inset:auto!important;
    width:var(--tera-body-splitter)!important;
    height:100%!important;
    min-height:0!important;
    max-height:none!important;
    margin:0!important;
    padding:0!important;
    align-self:stretch!important;
    background:transparent!important;
    z-index:19!important;
  }

  /* Scientific page owns only the remaining body rectangle. */
  body.research-shell-body .page{
    grid-column:3!important;
    grid-row:1!important;
    min-width:0!important;
    width:100%!important;
    max-width:100%!important;
    height:100%!important;
    min-height:0!important;
    margin:0!important;
    padding:var(--tera-page-pad-y) var(--tera-page-pad-x)!important;
    align-self:stretch!important;
    overflow-y:auto!important;
    overflow-x:hidden!important;
    overscroll-behavior:contain!important;
    scrollbar-gutter:stable!important;
  }
  body.research-shell-body .page>*{min-width:0!important;max-width:100%!important}
  body.research-shell-body .page-head{margin:0 0 9px!important;min-width:0!important}

  /* Shared elastic workbench containment. JS allocates pane widths from the usable
     root width, so no application-level horizontal scrollbar is ever necessary. */
  body.research-shell-body .elastic-workspace{
    width:100%!important;
    max-width:100%!important;
    min-width:0!important;
    min-height:0!important;
    gap:0!important;
    overflow:hidden!important;
  }
  body.research-shell-body .elastic-pane{
    min-width:0!important;
    max-width:none!important;
    overflow:hidden!important;
  }
  body.research-shell-body .elastic-pane>.card{
    min-width:0!important;
    max-width:100%!important;
  }
  body.research-shell-body .elastic-pane .card-body,
  body.research-shell-body .pane-fill,
  body.research-shell-body .scroll-fill{min-width:0!important}
  body.research-shell-body .splitter{
    flex:0 0 var(--tera-body-splitter)!important;
    width:var(--tera-body-splitter)!important;
    min-width:var(--tera-body-splitter)!important;
    max-width:var(--tera-body-splitter)!important;
    margin:0!important;
    padding:0!important;
  }

  /* Workbench pages consume exactly the body viewport and scroll inside panes. */
  body.research-shell-body[data-page="python"] .page,
  body.research-shell-body[data-page="discovery"] .page,
  body.research-shell-body[data-page="manuscript"] .page,
  body.research-shell-body[data-page~="book"] .page,
  body.research-shell-body[data-page="data"] .page,
  body.research-shell-body[data-page="references"] .page,
  body.research-shell-body[data-page="audio"] .page,
  body.research-shell-body[data-page="experiments"] .page,
  body.research-shell-body[data-page="latex"] .page,
  body.research-shell-body[data-page="figures"] .page,
  body.research-shell-body[data-page~="publication"] .page{
    display:flex!important;
    flex-direction:column!important;
    min-height:0!important;
    overflow:hidden!important;
  }
  body.research-shell-body[data-page="python"] .page>.elastic-workspace,
  body.research-shell-body[data-page="discovery"] .page>.elastic-workspace,
  body.research-shell-body[data-page="manuscript"] .page>.elastic-workspace,
  body.research-shell-body[data-page~="book"] .page>.elastic-workspace,
  body.research-shell-body[data-page="data"] .page>.elastic-workspace,
  body.research-shell-body[data-page="references"] .page>.elastic-workspace,
  body.research-shell-body[data-page="audio"] .page>.elastic-workspace,
  body.research-shell-body[data-page="experiments"] .page>.elastic-workspace,
  body.research-shell-body[data-page="figures"] .page>.elastic-workspace,
  body.research-shell-body[data-page~="publication"] .page>.elastic-workspace{
    flex:1 1 auto!important;
    height:auto!important;
    min-height:0!important;
    max-height:none!important;
    align-items:stretch!important;
  }
  body.research-shell-body[data-page="latex"] #latexModeHost{
    display:flex!important;
    flex:1 1 auto!important;
    min-height:0!important;
    overflow:hidden!important;
  }
  body.research-shell-body[data-page="latex"] #latexWorkspace{
    flex:1 1 auto!important;
    height:auto!important;
    min-height:0!important;
    max-height:none!important;
    align-items:stretch!important;
  }
  body.research-shell-body[data-page="python"] .elastic-pane,
  body.research-shell-body[data-page="discovery"] .elastic-pane,
  body.research-shell-body[data-page="manuscript"] .elastic-pane,
  body.research-shell-body[data-page~="book"] .elastic-pane,
  body.research-shell-body[data-page="data"] .elastic-pane,
  body.research-shell-body[data-page="references"] .elastic-pane,
  body.research-shell-body[data-page="audio"] .elastic-pane,
  body.research-shell-body[data-page="experiments"] .elastic-pane,
  body.research-shell-body[data-page="latex"] .elastic-pane,
  body.research-shell-body[data-page="figures"] .elastic-pane,
  body.research-shell-body[data-page~="publication"] .elastic-pane{
    height:100%!important;
    min-height:0!important;
    align-self:stretch!important;
    overflow:hidden!important;
  }
  body.research-shell-body[data-page="python"] .elastic-pane>.card,
  body.research-shell-body[data-page="discovery"] .elastic-pane>.card,
  body.research-shell-body[data-page="manuscript"] .elastic-pane>.card,
  body.research-shell-body[data-page~="book"] .elastic-pane>.card,
  body.research-shell-body[data-page="data"] .elastic-pane>.card,
  body.research-shell-body[data-page="references"] .elastic-pane>.card,
  body.research-shell-body[data-page="audio"] .elastic-pane>.card,
  body.research-shell-body[data-page="experiments"] .elastic-pane>.card,
  body.research-shell-body[data-page="latex"] .elastic-pane>.card,
  body.research-shell-body[data-page="figures"] .elastic-pane>.card,
  body.research-shell-body[data-page~="publication"] .elastic-pane>.card{
    height:100%!important;
    min-height:0!important;
    display:flex!important;
    flex-direction:column!important;
  }
  body.research-shell-body[data-page="python"] .elastic-pane>.card>.card-body,
  body.research-shell-body[data-page="discovery"] .elastic-pane>.card>.card-body,
  body.research-shell-body[data-page="manuscript"] .elastic-pane>.card>.card-body,
  body.research-shell-body[data-page~="book"] .elastic-pane>.card>.card-body,
  body.research-shell-body[data-page="data"] .elastic-pane>.card>.card-body,
  body.research-shell-body[data-page="references"] .elastic-pane>.card>.card-body,
  body.research-shell-body[data-page="audio"] .elastic-pane>.card>.card-body,
  body.research-shell-body[data-page="experiments"] .elastic-pane>.card>.card-body,
  body.research-shell-body[data-page="latex"] .elastic-pane>.card>.card-body,
  body.research-shell-body[data-page="figures"] .elastic-pane>.card>.card-body,
  body.research-shell-body[data-page~="publication"] .elastic-pane>.card>.card-body{
    flex:1 1 auto!important;
    min-height:0!important;
  }

  /* Python: canonical IDE proportions and internal pane scrolling. */
  body.research-shell-body[data-page="python"] #pythonWorkspace{flex:1 1 auto!important;height:auto!important;min-height:0!important;max-height:none!important}
  body.research-shell-body[data-page="python"] .py-commandbar,
  body.research-shell-body[data-page="python"] .py-run-contract{flex:0 0 auto!important}
  body.research-shell-body[data-page="python"] #pythonWorkspace .card-body{overflow:hidden!important}
  body.research-shell-body[data-page="python"] #pythonWorkspace .scroll-fill{min-height:0!important;overflow:auto!important}

  /* LaTeX: large editor + large rendered verification surface. */
  body.research-shell-body[data-page="latex"] .latex-hero,
  body.research-shell-body[data-page="latex"] .latex-commandbar{flex:0 0 auto!important}
  body.research-shell-body[data-page="latex"] .latex-research-workspace{height:auto!important;min-height:0!important;max-height:none!important}
  body.research-shell-body[data-page="latex"] .latex-code-shell{flex:1 1 auto!important;min-height:0!important;height:auto!important;overflow:hidden!important}
  body.research-shell-body[data-page="latex"] .latex-editor-stack{height:100%!important;min-height:0!important}
  body.research-shell-body[data-page="latex"] .latex-editor{height:100%!important;min-height:0!important;resize:none!important;overflow:auto!important}
  body.research-shell-body[data-page="latex"] .latex-result-host{flex:1 1 auto!important;min-height:0!important;overflow:auto!important}
  body.research-shell-body[data-page="latex"] .latex-pdf-stage{height:100%!important;min-height:0!important;max-height:none!important}
  body.research-shell-body[data-page="latex"] .latex-pdf-frame{height:100%!important;min-height:0!important;width:100%!important}
  body.research-shell-body[data-page="latex"] .latex-runtime-card{margin-top:8px!important}
  body.research-shell-body[data-page="latex"] .latex-pane-head{padding-block:9px!important}
  body.research-shell-body[data-page="latex"] .latex-structure-tabs{flex:0 0 auto!important}

  /* Data: library | governed laboratory | context, as designed. */
  body.research-shell-body[data-page="data"] .data-journey{flex:0 0 auto!important;margin-bottom:8px!important}
  body.research-shell-body[data-page="data"] #dataWorkspace{flex:1 1 auto!important;height:auto!important;min-height:0!important;max-height:none!important}
  body.research-shell-body[data-page="data"] .workflow-strip{flex:0 0 auto!important}
  body.research-shell-body[data-page="data"] .data-main-pane{flex:1 1 auto!important;min-height:0!important;overflow:auto!important}
  body.research-shell-body[data-page="data"] #contextPane{overflow:auto!important;overflow-wrap:anywhere!important}
  body.research-shell-body[data-page="data"] .kv{grid-template-columns:minmax(105px,.8fr) minmax(0,1.2fr)!important}
  body.research-shell-body[data-page="data"] .kv>span{overflow-wrap:anywhere!important}
  body.research-shell-body[data-page="data"] .dataset-library-tools{flex:0 0 auto!important}
  body.research-shell-body[data-page="data"] .context-tabs{grid-template-columns:1fr!important;gap:5px!important}
  body.research-shell-body[data-page="data"] .context-tab{text-align:left!important}

  /* Figures: initial preview always fits; scroll is opt-in through explicit zoom, not required for first view. */
  body.research-shell-body[data-page="figures"] #figureWorkspace{flex:1 1 auto!important;height:auto!important;min-height:0!important;max-height:none!important}
  body.research-shell-body[data-page="figures"] .figure-preview-stage{
    flex:1 1 auto!important;
    width:100%!important;
    height:auto!important;
    min-height:0!important;
    max-height:none!important;
    padding:10px!important;
    overflow:hidden!important;
    display:grid!important;
    place-items:center!important;
  }
  body.research-shell-body[data-page="figures"] .figure-preview-stage img,
  body.research-shell-body[data-page="figures"] .figure-preview-stage svg{
    display:block!important;
    width:auto!important;
    height:auto!important;
    max-width:100%!important;
    max-height:100%!important;
    object-fit:contain!important;
  }
  body.research-shell-body[data-page="figures"] #figureContext,
  body.research-shell-body[data-page="figures"] #figureList{overflow:auto!important;min-height:0!important}

  /* Manuscript, Discovery, Book and other multi-pane pages stay bounded and internally scroll. */
  body.research-shell-body[data-page="manuscript"] #manuscriptWorkspace #ed{flex:1 1 auto!important;height:auto!important;min-height:0!important;resize:none!important}
  body.research-shell-body[data-page="manuscript"] #manuscriptWorkspace #preview{flex:1 1 auto!important;min-height:0!important}
  body.research-shell-body[data-page="discovery"] #entryDetail{height:100%!important;min-height:0!important;overflow:auto!important}
  body.research-shell-body[data-page="discovery"] #entryDetail>.workspace-empty{height:100%!important;min-height:0!important}

  /* Studio uses the approved scientific surface at readable scale; no dead image canvas. */
  body.research-shell-body[data-page="studio"] .page{overflow-y:auto!important;overflow-x:hidden!important}
  body.research-shell-body[data-page="studio"] #studioWorkspace{height:auto!important;min-height:0!important;max-height:none!important;align-items:flex-start!important;overflow:visible!important}
  body.research-shell-body[data-page="studio"] #studioWorkspace>.elastic-pane{align-self:flex-start!important;overflow:visible!important}
  body.research-shell-body[data-page="studio"] #studioWorkspace>.elastic-pane>.card{height:auto!important;min-height:0!important}
  body.research-shell-body[data-page="studio"] .studio-dashboard-body{display:block!important;overflow:visible!important}
  body.research-shell-body[data-page="studio"] .studio-hero{align-items:start!important;grid-template-columns:minmax(0,1.68fr) minmax(300px,.76fr)!important;gap:16px!important}
  body.research-shell-body[data-page="studio"] .math-hero.math-hero-image{align-self:start!important;height:auto!important;min-height:0!important;padding:0!important;overflow:hidden!important;background:var(--surface2)!important;border:1px solid var(--border)!important;border-radius:14px!important}
  body.research-shell-body[data-page="studio"] .math-hero-image-head{display:flex!important;justify-content:space-between!important;align-items:flex-start!important;gap:18px!important;padding:14px 16px 10px!important;background:var(--surface2)!important;color:var(--ink)!important}
  body.research-shell-body[data-page="studio"] .math-hero-image-head h3{margin:0!important;color:var(--gold)!important;font-size:1.18rem!important;line-height:1.2!important}
  body.research-shell-body[data-page="studio"] .math-hero-image-head p{margin:4px 0 0!important;color:var(--ink)!important;font-size:1rem!important;line-height:1.45!important}
  body.research-shell-body[data-page="studio"] .math-hero-image-head .mono{font-size:1rem!important;font-weight:850!important;white-space:nowrap!important;color:var(--ink)!important}
  body.research-shell-body[data-page="studio"] .math-hero-plot{width:100%!important;overflow:hidden!important;background:#102033!important}
  body.research-shell-body[data-page="studio"] .math-hero-image img{display:block!important;width:100%!important;height:auto!important;aspect-ratio:694/273!important;object-fit:cover!important;object-position:center!important;background:#102033!important;border-radius:0!important}
  body.research-shell-body[data-page="studio"] .math-hero-image-foot{display:flex!important;align-items:center!important;justify-content:space-between!important;gap:18px!important;padding:10px 16px 12px!important;background:var(--surface2)!important;color:var(--ink)!important;font-size:1rem!important;line-height:1.3!important}
  body.research-shell-body[data-page="studio"] .math-hero-image-foot strong{font-size:1rem!important;font-weight:800!important}
  body.research-shell-body[data-page="studio"] .continue-card{align-self:start!important;height:auto!important}
  body.research-shell-body[data-page="studio"] .research-state-strip{align-items:start!important}
  body.research-shell-body[data-page="studio"] .dashboard-lower{grid-auto-rows:auto!important;align-items:start!important;gap:14px!important}
  body.research-shell-body[data-page="studio"] .dashboard-lower>.card{height:auto!important;min-height:0!important;align-self:start!important}
  body.research-shell-body[data-page="studio"] .dashboard-lower>.card>.card-body{height:auto!important;min-height:0!important;max-height:360px!important;overflow:auto!important}
  body.research-shell-body[data-page="studio"] #studioWorkspace>.elastic-pane:last-child>.card>.studio-context-body{max-height:calc(100dvh - var(--shell-header-height) - var(--tera-footer-height) - 56px)!important;overflow:auto!important}

  /* Projects are document-height driven; compact registry does not manufacture an empty column. */
  body.research-shell-body[data-page="projects"] .page{overflow-y:auto!important;overflow-x:hidden!important}
  body.research-shell-body[data-page="projects"] #projectWorkspace{height:auto!important;min-height:0!important;max-height:none!important;align-items:flex-start!important;overflow:visible!important}
  body.research-shell-body[data-page="projects"] #projectWorkspace>.elastic-pane{align-self:flex-start!important;overflow:visible!important}
  body.research-shell-body[data-page="projects"] #projectWorkspace>.elastic-pane>.card{height:auto!important;min-height:0!important}
  body.research-shell-body[data-page="projects"] #projectWorkspace>.elastic-pane>.card>.card-body{height:auto!important;min-height:0!important;overflow:visible!important}
  body.research-shell-body[data-page="projects"] #projectWorkspace>.elastic-pane:first-child>.card>.card-body.pane-fill{display:block!important}
  body.research-shell-body[data-page="projects"] #projectWorkspace>.elastic-pane:first-child .scroll-fill{overflow:visible!important;max-height:none!important}

  /* Workbench vertical priority: preserve current header/footer content while giving scientific panes room. */
  body.research-shell-body[data-page="python"] .page-head{margin-bottom:6px!important}
  body.research-shell-body[data-page="python"] .page-head h1{font-size:clamp(2rem,2.5vw,2.55rem)!important;line-height:1!important}
  body.research-shell-body[data-page="python"] .py-commandbar{margin-bottom:6px!important}
  body.research-shell-body[data-page="python"] .py-run-contract{margin-bottom:6px!important}
  body.research-shell-body[data-page="python"] #pythonWorkspace{min-height:320px!important}

  body.research-shell-body[data-page="latex"] .latex-hero{margin-bottom:6px!important;padding:6px 8px 8px!important;gap:12px!important;align-items:center!important}
  body.research-shell-body[data-page="latex"] .latex-hero-copy h1{margin:5px 0 2px!important;font-size:clamp(1.9rem,2.5vw,2.35rem)!important}
  body.research-shell-body[data-page="latex"] .latex-hero-copy p{font-size:1rem!important;line-height:1.35!important}
  body.research-shell-body[data-page="latex"] .latex-hero-status>div{padding:5px 7px!important}
  body.research-shell-body[data-page="latex"] .latex-commandbar{min-height:42px!important;margin-bottom:6px!important;padding:3px 5px!important;gap:4px!important}
  body.research-shell-body[data-page="latex"] .latex-commandbar .latex-menu>summary,
  body.research-shell-body[data-page="latex"] .latex-commandbar .mode-tab{padding:5px 8px!important;min-height:32px!important}
  body.research-shell-body[data-page="latex"] .latex-compile-action{min-height:34px!important;padding:5px 12px!important}
  body.research-shell-body[data-page="latex"] .latex-pane-head{padding-block:6px!important}
  body.research-shell-body[data-page="latex"] .latex-result-host{overflow:hidden!important;display:flex!important;flex-direction:column!important}
  body.research-shell-body[data-page="latex"] .latex-result-host>.preview,
  body.research-shell-body[data-page="latex"] .latex-result-host>.latex-pdf-stage{flex:1 1 auto!important;min-height:0!important;overflow:auto!important}
  body.research-shell-body[data-page="latex"] .latex-quick-preview{height:100%!important;min-height:0!important}
  body.research-shell-body[data-page="latex"] .latex-pdf-stage{height:100%!important;min-height:0!important;padding:8px!important}
  body.research-shell-body[data-page="latex"] .latex-pdf-frame{height:100%!important;min-height:0!important}

  body.research-shell-body[data-page="data"] .page-head{margin-bottom:6px!important}
  body.research-shell-body[data-page="data"] .data-journey{margin-bottom:6px!important}
  body.research-shell-body[data-page="data"] #contextPane{overflow-wrap:break-word!important;word-break:normal!important}
  body.research-shell-body[data-page="figures"] .page-head{margin-bottom:6px!important}

  /* Document pages can scroll naturally inside the body rectangle. */
  body.research-shell-body[data-page="export"] .page{overflow-y:auto!important;overflow-x:hidden!important;padding-bottom:24px!important}

  /* Never allow a page/pane to force an application-level horizontal scrollbar. */
  body.research-shell-body table{max-width:100%}
  body.research-shell-body .table-wrap{max-width:100%;overflow:auto}
  body.research-shell-body code,
  body.research-shell-body .mono,
  body.research-shell-body .wrap-anywhere{overflow-wrap:anywhere;word-break:break-word}
}

/* --------------------------------------------------------------------------
   Export integrity / artifact manager (retained and hardened)
   -------------------------------------------------------------------------- */
body[data-page="export"] .artifact-manager{overflow:hidden}
body[data-page="export"] .artifact-manager-head{align-items:center}
body[data-page="export"] .artifact-manager-head small{display:block;margin-top:3px;color:var(--muted)}
body[data-page="export"] .artifact-toolbar{display:grid;grid-template-columns:minmax(260px,1fr) minmax(170px,240px) auto auto;gap:10px;align-items:center;margin-bottom:10px}
body[data-page="export"] .artifact-toolbar input,body[data-page="export"] .artifact-toolbar select{min-width:0;width:100%}
body[data-page="export"] .artifact-batchbar{display:flex;align-items:center;gap:10px;padding:10px 0;border-top:1px solid var(--border);border-bottom:1px solid var(--border);margin-bottom:10px}
body[data-page="export"] .artifact-batchbar .spacer{flex:1}
body[data-page="export"] .artifact-list{display:grid;gap:8px}
body[data-page="export"] .artifact-row{display:grid;grid-template-columns:28px minmax(0,1fr) auto;gap:12px;align-items:center;padding:12px 14px;border:1px solid var(--border);border-radius:12px;background:var(--surface)}
body[data-page="export"] .artifact-row:hover{background:var(--surface2)}
body[data-page="export"] .artifact-check{display:grid;place-items:center}
body[data-page="export"] .artifact-check input{width:18px;height:18px}
body[data-page="export"] .artifact-main{min-width:0}
body[data-page="export"] .artifact-title{display:flex;align-items:center;gap:8px;flex-wrap:wrap;min-width:0}
body[data-page="export"] .artifact-title strong{overflow-wrap:anywhere}
body[data-page="export"] .artifact-meta{display:flex;gap:12px;align-items:center;flex-wrap:wrap;margin-top:5px;color:var(--muted)}
body[data-page="export"] .artifact-meta code{max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
body[data-page="export"] .artifact-actions{display:flex;gap:7px;flex-wrap:wrap;justify-content:flex-end}
body[data-page="export"] .artifact-text-preview{max-height:58vh;overflow:auto;white-space:pre-wrap;overflow-wrap:anywhere;padding:14px;border:1px solid var(--border);border-radius:10px;background:var(--surface2)}
body[data-page="export"] .artifact-preview-meta{display:flex;justify-content:space-between;gap:12px;flex-wrap:wrap;margin-bottom:12px}
body[data-page="export"] .artifact-binary-preview{display:grid;place-items:center;max-height:62vh;overflow:auto;border:1px solid var(--border);border-radius:10px;background:#fff;padding:12px}
body[data-page="export"] .artifact-binary-preview img{max-width:100%;height:auto;display:block}
body[data-page="export"] .artifact-pdf-preview{width:100%;height:62vh;border:1px solid var(--border);border-radius:10px;background:#fff}


@media(min-width:921px) and (max-height:860px){
  :root{--tera-footer-height:78px}
  body.research-shell-body .page{padding-top:8px!important;padding-bottom:8px!important}
  body.research-shell-body[data-page="latex"] .latex-hero-status{display:none!important}
  body.research-shell-body[data-page="latex"] .latex-hero{grid-template-columns:1fr!important}
  body.research-shell-body[data-page="studio"] .math-hero-image-head{padding-block:10px 7px!important}
  body.research-shell-body[data-page="studio"] .math-hero-image-foot{padding-block:8px 9px!important}
}

/* --------------------------------------------------------------------------
   Responsive fallback
   -------------------------------------------------------------------------- */
@media(max-width:1180px){
  body[data-page="export"] .artifact-toolbar{grid-template-columns:1fr 1fr}
  body[data-page="export"] .artifact-row{grid-template-columns:28px minmax(0,1fr)}
  body[data-page="export"] .artifact-actions{grid-column:2;justify-content:flex-start}
}
@media(max-width:920px){
  html{height:auto;overflow:auto}
  body.research-shell-body{display:block!important;height:auto!important;overflow:auto!important}
  body.research-shell-body .layout{display:block!important;height:auto!important;overflow:visible!important}
  body.research-shell-body .studio-sidebar{display:none!important}
  body.research-shell-body .shell-splitter{display:none!important}
  body.research-shell-body .page{width:100%!important;height:auto!important;min-height:0!important;padding:16px 12px 22px!important;overflow:visible!important}
  body.research-shell-body .footer-splitter{display:none!important}
  body.research-shell-body .tera-institutional-footer{position:relative!important;height:auto!important;overflow:visible!important}
  body.research-shell-body .elastic-workspace{display:grid!important;height:auto!important;max-height:none!important;min-height:0!important;gap:16px!important;overflow:visible!important}
  body.research-shell-body .elastic-pane{height:auto!important;min-height:0!important;overflow:visible!important}
  body.research-shell-body .elastic-pane>.card{height:auto!important}
  body.research-shell-body .splitter{display:none!important}
  body.research-shell-body[data-page="latex"] #latexModeHost{display:block!important}
  body.research-shell-body[data-page="studio"] .studio-hero{grid-template-columns:1fr!important}
}
@media(max-width:720px){
  body[data-page="export"] .artifact-toolbar{grid-template-columns:1fr}
  body[data-page="export"] .artifact-batchbar{align-items:stretch;flex-direction:column}
  body[data-page="export"] .artifact-row{grid-template-columns:28px minmax(0,1fr)}
  body[data-page="export"] .artifact-actions{grid-column:1/-1}
}
