/* v1.6.3 — single source of truth for the visible magazine in LIVE and EDITOR.
   Loaded last. It intentionally uses high specificity to override all legacy book/tab rules. */
:root{
  --nc-v163-book-ratio:1.72;
  --nc-v163-book-width:min(1180px, calc(100vw - 360px), calc((100vh - 250px) * 1.72));
  --nc-v163-tab-width:50px;
  --nc-v163-tab-lip:44px;
  --nc-v163-stack-width:42px;
}

/* Same stage math in live and editor. Only the surrounding admin/public UI differs. */
html body:not(.nc-editor-page) .stage,
html body.nc-editor-page .nc-canvas{
  display:grid!important;
  place-items:center!important;
  overflow:visible!important;
  box-sizing:border-box!important;
}
html body:not(.nc-editor-page) .stage{
  min-height:calc(100vh - 170px)!important;
  padding:22px 0 118px!important;
}
html body.nc-editor-page .nc-canvas{
  position:fixed!important;
  inset:0!important;
  width:100vw!important;
  height:100vh!important;
  padding:70px 0 92px!important;
  background:radial-gradient(circle at 50% 48%, rgba(74,41,17,.54), #050302 72%)!important;
}

html body:not(.nc-editor-page) .stage .magazine-shell,
html body.nc-editor-page .nc-canvas .magazine-shell,
html body .magazine-shell{
  width:var(--nc-v163-book-width)!important;
  height:auto!important;
  aspect-ratio:var(--nc-v163-book-ratio)!important;
  max-width:none!important;
  min-width:0!important;
  margin:0 auto!important;
  position:relative!important;
  overflow:visible!important;
  display:block!important;
  transform:none!important;
  filter:none!important;
  box-sizing:border-box!important;
}
html body .magazine-shell .book-wrap{
  position:relative!important;
  width:100%!important;
  height:100%!important;
  aspect-ratio:var(--nc-v163-book-ratio)!important;
  margin:0!important;
  overflow:visible!important;
  isolation:isolate!important;
  transform:none!important;
  perspective:none!important;
}
html body .magazine-shell .book{
  position:absolute!important;
  inset:0!important;
  width:100%!important;
  height:100%!important;
  z-index:60!important;
  overflow:visible!important;
  transform:none!important;
  filter:drop-shadow(0 30px 34px rgba(0,0,0,.62))!important;
}
html body .magazine-shell .spread{
  position:absolute!important;
  inset:0!important;
  width:100%!important;
  height:100%!important;
  display:none!important;
  grid-template-columns:1fr 1fr!important;
  z-index:70!important;
  overflow:visible!important;
  opacity:1!important;
  visibility:visible!important;
  pointer-events:auto!important;
}
html body .magazine-shell .spread.is-active{display:grid!important;}
html body .magazine-shell .page{
  position:relative!important;
  width:100%!important;
  height:100%!important;
  min-height:0!important;
  overflow:hidden!important;
  z-index:90!important;
  box-sizing:border-box!important;
}
html body .magazine-shell .spine{z-index:130!important;}

/* Physical page stacks behind open sheets. */
html body .magazine-shell .stack-left,
html body .magazine-shell .stack-right{
  position:absolute!important;
  top:2.3%!important;
  bottom:2.3%!important;
  width:var(--nc-v163-stack-width)!important;
  z-index:12!important;
  opacity:1!important;
  pointer-events:none!important;
  border-radius:13px!important;
  overflow:hidden!important;
  background:
    linear-gradient(90deg,rgba(67,44,16,.58),rgba(255,245,204,.52) 22%,rgba(224,195,119,.76) 52%,rgba(100,69,25,.50) 86%),
    repeating-linear-gradient(90deg,#5b3e17 0 1px,#9e742b 1px 2px,#d9bd72 2px 4px,#fff0b8 4px 6px,#967028 6px 7px)!important;
  box-shadow:inset 8px 0 9px rgba(255,250,224,.42), inset -12px 0 14px rgba(43,27,9,.50), 0 16px 24px rgba(0,0,0,.46)!important;
}
html body .magazine-shell .stack-left{left:calc(-1 * var(--nc-v163-stack-width) + 10px)!important;}
html body .magazine-shell .stack-right{right:calc(-1 * var(--nc-v163-stack-width) + 10px)!important;}

/* Reference-style integrated index tabs.
   The same selectors target live and editor; no editor-only geometry exists below. */
html body .magazine-shell .tabs,
html body.nc-editor-page .nc-canvas .magazine-shell .tabs,
html body:not(.nc-editor-page) .stage .magazine-shell .tabs{
  position:absolute!important;
  top:5.4%!important;
  bottom:5.4%!important;
  width:var(--nc-v163-tab-width)!important;
  padding:0!important;
  display:flex!important;
  flex-direction:column!important;
  gap:0!important;
  z-index:35!important;
  pointer-events:auto!important;
  overflow:visible!important;
  transform:none!important;
  filter:drop-shadow(0 9px 10px rgba(0,0,0,.36))!important;
}
html body .magazine-shell .tabs.left,
html body.nc-editor-page .nc-canvas .magazine-shell .tabs.left,
html body:not(.nc-editor-page) .stage .magazine-shell .tabs.left{
  left:calc(-1 * var(--nc-v163-tab-lip))!important;
  right:auto!important;
  align-items:flex-end!important;
}
html body .magazine-shell .tabs.right,
html body.nc-editor-page .nc-canvas .magazine-shell .tabs.right,
html body:not(.nc-editor-page) .stage .magazine-shell .tabs.right{
  right:calc(-1 * var(--nc-v163-tab-lip))!important;
  left:auto!important;
  align-items:flex-start!important;
}

html body .magazine-shell .tabs::before{
  content:""!important;
  position:absolute!important;
  top:-2.5%!important;
  bottom:-2.5%!important;
  width:20px!important;
  z-index:0!important;
  pointer-events:none!important;
  background:
    linear-gradient(90deg,rgba(255,249,218,.86),rgba(198,164,83,.73),rgba(70,46,17,.42)),
    repeating-linear-gradient(0deg,rgba(93,68,29,.18) 0 1px,rgba(255,255,255,.22) 1px 5px)!important;
  box-shadow:inset 0 0 10px rgba(0,0,0,.28)!important;
}
html body .magazine-shell .tabs.left::before{right:0!important;border-radius:0 9px 9px 0!important;}
html body .magazine-shell .tabs.right::before{left:0!important;border-radius:9px 0 0 9px!important;}

html body .magazine-shell .tab,
html body.nc-editor-page .nc-canvas .magazine-shell .tab,
html body:not(.nc-editor-page) .stage .magazine-shell .tab{
  position:relative!important;
  z-index:1!important;
  flex:1 1 0!important;
  width:46px!important;
  min-height:0!important;
  height:auto!important;
  margin:0!important;
  padding:0 3px!important;
  border:1px solid rgba(102,76,37,.66)!important;
  color:#22170a!important;
  background:
    linear-gradient(90deg,#fff9e8 0%,#efe0b4 34%,#c7a361 68%,#856029 100%),
    repeating-linear-gradient(0deg,rgba(255,255,255,.17) 0 1px,transparent 1px 5px)!important;
  font-family:Arial,Helvetica,sans-serif!important;
  font-size:9px!important;
  line-height:1!important;
  letter-spacing:0!important;
  font-weight:900!important;
  text-transform:uppercase!important;
  writing-mode:vertical-rl!important;
  text-orientation:mixed!important;
  display:flex!important;
  align-items:center!important;
  justify-content:center!important;
  text-align:center!important;
  text-shadow:0 1px 0 rgba(255,255,255,.74)!important;
  box-shadow:inset 1px 0 0 rgba(255,255,255,.75), inset -8px 0 10px rgba(78,52,20,.25), 0 2px 4px rgba(0,0,0,.24)!important;
  transform:none!important;
  overflow:hidden!important;
  white-space:nowrap!important;
}
html body .magazine-shell .tabs.left .tab{border-radius:8px 2px 2px 8px!important;}
html body .magazine-shell .tabs.right .tab{border-radius:2px 8px 8px 2px!important;}
html body .magazine-shell .tab + .tab{margin-top:-1px!important;}
html body .magazine-shell .tab::before{
  content:""!important;
  position:absolute!important;
  inset:0!important;
  border-radius:inherit!important;
  pointer-events:none!important;
  background:linear-gradient(180deg,rgba(255,255,255,.58),transparent 46%,rgba(78,55,25,.20))!important;
}
html body .magazine-shell .tab::after{
  content:""!important;
  position:absolute!important;
  top:0!important;
  bottom:0!important;
  width:6px!important;
  pointer-events:none!important;
  background:linear-gradient(90deg,rgba(255,255,255,.55),rgba(67,46,18,.30))!important;
}
html body .magazine-shell .tabs.left .tab::after{right:0!important;}
html body .magazine-shell .tabs.right .tab::after{left:0!important;}
html body .magazine-shell .tab.is-active,
html body .magazine-shell .tab[aria-current="true"]{
  background:
    linear-gradient(90deg,#ffe98a 0%,#e0b21c 58%,#9a680e 100%),
    repeating-linear-gradient(0deg,rgba(255,255,255,.16) 0 1px,transparent 1px 5px)!important;
  border-color:rgba(105,70,9,.80)!important;
  box-shadow:inset 1px 0 0 rgba(255,255,255,.66), inset -8px 0 10px rgba(90,56,7,.27), 0 3px 7px rgba(0,0,0,.32)!important;
}

/* Page lips mask only the inserted inner strip; they do not alter visible tab width. */
html body .magazine-shell .page.left{
  box-shadow:inset -58px 0 48px rgba(54,35,17,.32), inset 18px 0 10px rgba(255,244,196,.30), -8px 0 0 rgba(246,229,169,.95), -18px 0 0 rgba(143,105,46,.50), inset 0 0 42px rgba(90,55,17,.18)!important;
}
html body .magazine-shell .page.right{
  box-shadow:inset 58px 0 48px rgba(54,35,17,.28), inset -18px 0 10px rgba(255,244,196,.30), 8px 0 0 rgba(246,229,169,.95), 18px 0 0 rgba(143,105,46,.50), inset 0 0 42px rgba(90,55,17,.18)!important;
}

/* Editor overlays cannot change the magazine geometry. */
html body.nc-editor-page .nc-canvas .page.is-active-page::after{
  content:""!important;
  position:absolute!important;
  inset:12px!important;
  border:2px solid rgba(58,185,255,.88)!important;
  border-radius:5px!important;
  box-shadow:0 0 0 2px rgba(0,0,0,.12)!important;
  pointer-events:none!important;
  z-index:180!important;
  background:transparent!important;
}
html body.nc-editor-page .nc-editor-topline{z-index:320!important;}
html body.nc-editor-page .nc-select-chip{z-index:300!important;}

@media (max-width:980px){
  :root{--nc-v163-book-width:min(94vw, calc((100vh - 210px) * 1.45)); --nc-v163-tab-lip:36px; --nc-v163-tab-width:42px;}
  html body .magazine-shell .tab{width:40px!important;font-size:7.5px!important;}
}
