/* Project Nexus Engine V48.3 — layout fix (em pé / deitado)
 * Causa: V45 (layout), V47 (studio) e V48.2 (densidade) definiam grid-template e posições com !important
 * e se anulavam. Em pé: coluna do viewport = 0px. Deitado: viewport espremido e página com scroll lateral.
 * Aqui: uma única fonte de verdade, com especificidade maior (html body ...), vencendo qualquer ordem. */
:root{--nx-top-base:42px}
html:root{--nx-top:calc(var(--nx-top-base) * var(--nx-ui-scale,1))}
html,body{height:100%;overflow:hidden;overscroll-behavior:none}
html body .top{height:var(--nx-top)!important;min-height:0!important}
html body .layout{height:calc(100dvh - var(--nx-top) - var(--nx-dock,0px))!important;max-height:calc(100dvh - var(--nx-top) - var(--nx-dock,0px))!important;width:100%!important;max-width:100vw!important;overflow:hidden!important;min-width:0!important}
html body .layout>*{min-width:0;min-height:0}
html body .layout>.center{overflow:hidden!important}
html body .viewport{min-height:0!important;min-width:0!important;overflow:hidden!important}
html body .viewport canvas{width:100%!important;height:100%!important;display:block;touch-action:none}
html body .splitter{min-width:4px;min-height:4px}

/* ===== DEITADO: Cena | Viewport | Inspetor + painel inferior ===== */
@media (orientation:landscape){
 html body .layout{
  grid-template-columns:var(--leftW,clamp(120px,20vw,235px)) 5px minmax(0,1fr) 5px var(--rightW,clamp(140px,22vw,285px))!important;
  grid-template-rows:minmax(0,1fr) 5px var(--bottomH,clamp(90px,30dvh,200px))!important}
 html body .layout>.left{display:block!important;grid-column:1!important;grid-row:1/4!important}
 html body .layout>.right{display:block!important;grid-column:5!important;grid-row:1/4!important}
 html body .layout>.center{grid-column:3!important;grid-row:1!important}
 html body .layout>.bottom{display:flex!important;grid-column:3!important;grid-row:3!important}
 html body #splitLeft{display:block!important;grid-column:2!important;grid-row:1/4!important}
 html body #splitRight{display:block!important;grid-column:4!important;grid-row:1/4!important}
 html body #splitBottom{display:block!important;grid-column:3!important;grid-row:2!important}
 html body #nxPd{display:none!important}
 html body .layout.nx-maxb>.center,html body .layout.nx-maxb>#splitBottom{display:none!important}
 html body .layout.nx-maxb>.bottom{grid-row:1/4!important}
}
@media (orientation:landscape) and (max-height:520px){
 :root{--nx-top-base:36px}
 html body .layout{grid-template-rows:minmax(0,1fr) 5px var(--bottomH,clamp(70px,28dvh,130px))!important}
 html body .viewportbar{height:28px!important}
 html body .panelhead{height:25px!important}
}

/* ===== EM PÉ: viewport em cima, dock com abas embaixo ===== */
@media (orientation:portrait){
 :root{--nx-top-base:38px}
 html body .nx-ws{display:none}
 html body .layout{
  grid-template-columns:minmax(0,1fr)!important;
  grid-template-rows:minmax(0,1fr) auto minmax(0,var(--pdH,40dvh))!important}
 html body .layout>.center{grid-column:1!important;grid-row:1!important}
 html body #nxPd{display:flex!important;grid-column:1!important;grid-row:2!important}
 html body .splitter{display:none!important}
 html body .layout>.left,html body .layout>.right,html body .layout>.bottom{grid-column:1!important;grid-row:3!important;display:none!important;overflow:auto}
 html body .layout[data-pd=scene]>.left,html body .layout[data-pd=inspector]>.right{display:block!important}
 html body .layout[data-pd=bottom]>.bottom{display:flex!important}
}
@media (orientation:portrait) and (min-width:700px){ :root{--nx-top-base:42px} }
