/* User-requested V4 refinements: fixed viewport and panel-local scrolling. */
html,body{height:100%;max-height:100%;overflow:hidden!important;overscroll-behavior:none}
html.v4-embedded,html.v4-embedded body{height:100%!important;max-height:100%!important;overflow:hidden!important}
main,html.v4-embedded main{
 height:100dvh!important;min-height:0!important;max-height:100dvh!important;
 grid-template-rows:minmax(0,1fr)!important;overflow:hidden!important;
 padding-bottom:8px!important;
}
main>.catalog,main>.scene,main>.side,main>.side>.panel{
 min-height:0!important;
}
#v4-library #results,#v4-library #v4-v2-favorites-grid{
 min-height:0!important;overflow-y:auto!important;overscroll-behavior:contain;
}
#v4-character{overscroll-behavior:contain}
#v4-appearance{overflow-y:auto!important;overscroll-behavior:contain}
#v4-character .progress,#v4-character #message:not(.error),#v4-character #v4-v2-go,
#v4-character #v4-focus-toggle{display:none!important}
#v4-character .v4-v2-action-row{
 justify-content:center!important;gap:7px!important;
 align-items:center!important;
}
#v4-character .v4-v2-core-actions{flex:0 0 auto!important;justify-content:center!important}
#v4-character .v4-v2-action-row .v4-v2-menu{flex:0 0 auto}
#v4-character .v4-toolbar-grid .v4-toolbar-block:nth-child(1),
#v4-character .v4-toolbar-grid .v4-toolbar-block:nth-child(3){
 display:flex!important;
}
#v4-character .canvas-hint .v4-hint-touch{font-size:0!important}
#v4-character .canvas-hint .v4-hint-touch::after{content:"Tap preview to punch · Movement available below";font-size:10px}
#v4-appearance .v4-appearance-group:has(#effects){display:none!important}
#v4-appearance .v4-advanced-tools .panel:has(#diagnostics){display:none!important}
#v4-appearance .v4-renderer-mode{display:none!important}
#v4-library .v4-v2-searchrow{gap:5px}
#v4-library .v4-clear-filters{
 flex:0 0 28px;align-self:stretch;
 padding:0;border:1px solid rgba(186,224,251,.35);
 border-radius:9px;background:rgba(41,89,143,.40);
 color:#e6f8ff;font:700 23px/1 Inter,system-ui;
 cursor:pointer;
}
#v4-library .v4-clear-filters:hover{background:rgba(86,159,211,.40)}
#v4-library .v4-clear-filters[hidden]{display:none!important}
#v4-library .v4-v2-filters-button .v4-filters-selected{display:none!important}
#v4-library .v4-sort-toolbar{
 display:flex;align-items:center;justify-content:flex-end;gap:5px;
 padding:1px 11px 7px;min-height:34px;
}
#v4-library .v4-sort-toolbar .v4-sort-label{margin-right:auto;color:#abcfe4;font-size:10px}
#v4-library .v4-sort-toolbar button{
 padding:4px;min-width:29px;height:27px;
 border:1px solid rgba(171,222,251,.30);border-radius:7px;
 background:rgba(58,104,149,.20);cursor:pointer;
 display:inline-flex;align-items:center;justify-content:center;
 color:#d9efff;font-size:11px;font-weight:750;
}
#v4-library .v4-sort-toolbar button:hover,
#v4-library .v4-sort-toolbar button[aria-pressed="true"]{
 border-color:#a2dbfa;background:rgba(75,150,221,.40)
}
#v4-library .v4-sort-toolbar .v4-sort-icon{width:23px;height:19px;display:block;background-repeat:no-repeat;background-position:center;background-size:contain;image-rendering:pixelated}
#v4-library #results .v4-icon-fit{display:none!important}
#v4-library #results .item img.v4-icon-fit-source,
#v4-library #v4-v2-favorites-grid .item img.v4-icon-fit-source{
 display:block!important;opacity:1!important;visibility:visible;
}
#v4-library #results .item img,
#v4-library #v4-v2-favorites-grid .item img{
 image-rendering:pixelated;object-fit:contain;filter:none;
}
@media(max-width:760px){
 main,html.v4-embedded main{
  height:calc(100dvh - 46px)!important;
  max-height:calc(100dvh - 46px)!important;
  overflow:hidden!important
 }
 #v4-library,#v4-character,#v4-appearance{min-height:0}
 #v4-character .v4-v2-action-row{gap:5px!important}
 #v4-library .v4-sort-toolbar{padding:1px 9px 6px}
}

/* Pet visibility is controlled directly from its equipped item bubble. */
#v4-equipped .v4-equipped-pet-toggle{
 display:grid;place-items:center;margin-left:5px;
 width:27px;height:27px;min-width:27px;
 border-radius:8px;border:1px solid rgba(162,214,250,.45);
 background:rgba(45,100,153,.34);font:bold 18px/1 Inter,system-ui;
 color:#b7e6fd;cursor:pointer;user-select:none;
}
#v4-equipped .v4-equipped-pet-toggle:hover,
#v4-equipped .v4-equipped-pet-toggle:focus-visible{
 border-color:#a1e6ff;background:rgba(80,153,199,.45);
}
#v4-equipped .v4-equipped-pet-toggle[aria-pressed=false]{
 opacity:.7;color:#9db4c7;
}

/* Supplied in-game sorting artwork (A-Z, Z-A, oldest, newest). */
#v4-library .v4-sort-toolbar button{
 min-width:36px;width:36px;height:29px;
 font-size:0!important;line-height:0;overflow:hidden;
}
#v4-library .v4-sort-toolbar button::before{
 content:"";display:block;width:32px;height:20px;
 background-image:url('/lab/v4-sort-icons-20261102.png');
 background-size:128px auto;
 background-repeat:no-repeat;
 background-position:0 center;
 image-rendering:pixelated;
}
#v4-library .v4-sort-toolbar button[data-v4-sort="name-desc"]::before{background-position:-32px center}
#v4-library .v4-sort-toolbar button[data-v4-sort="id-asc"]::before{background-position:-64px center}
#v4-library .v4-sort-toolbar button[data-v4-sort="id-desc"]::before{background-position:-96px center}
#v4-library .v4-clear-filters{
 font-size:0!important;background-image:url('/lab/v4-clear-filter-20261102.png');
 background-position:center;background-repeat:no-repeat;background-size:23px 24px;
 image-rendering:pixelated;
}

/* Source PNGs use the native in-game 32px inventory cell, not a
   content-bounds crop scaled to fill a 64px tile. */
#v4-library[data-v4-layout="tiles"] #results button.item>img,
#v4-library #v4-v2-favorites-grid button.item>img{
 width:32px!important;height:32px!important;
 max-width:32px!important;max-height:32px!important;
 flex:0 0 32px!important;
 object-fit:contain!important;image-rendering:pixelated!important;
 transform:none;
}

/* V4 wardrobe controls — no invisible image-only icons or grid-wrapped clear. */
#v4-library .v4-v2-searchrow{grid-template-columns:minmax(0,1fr) minmax(132px,36%)!important;gap:7px!important;align-items:center}
#v4-library .v4-v2-searchrow:has(>.v4-clear-filters:not([hidden])){grid-template-columns:minmax(0,1fr) minmax(132px,36%) 32px!important}
#v4-library .v4-v2-searchrow #v4-v2-filters{height:39px;max-width:none;min-width:0;padding:5px 9px}
#v4-library #v4-v2-filters[data-v4-selected="true"]::before{display:none!important}
#v4-library #v4-v2-filters .v4-filters-selected{
 display:inline-block!important;color:#eff9ff!important;
 font:700 11px/1.2 Inter,system-ui,sans-serif!important;
 max-width:145px!important;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap
}
#v4-library #v4-v2-filters[data-v4-selected="true"] > span:not(.v4-filters-selected){display:none!important}
#v4-library #v4-v2-filters .v4-active-filter-icon{
 width:24px;height:24px;min-width:24px;flex:0 0 24px;
 object-fit:contain;image-rendering:pixelated;background-repeat:no-repeat
}
#v4-library #v4-v2-filters .v4-active-filter-icon[hidden]{display:none!important}
#v4-library .v4-v2-searchrow>.v4-clear-filters{
 display:grid!important;place-items:center!important;align-self:center!important;
 box-sizing:border-box;min-width:32px!important;width:32px!important;height:36px!important;
 min-height:36px!important;max-height:36px!important;flex:0 0 32px!important;
 margin:0!important;padding:0!important;
 background-image:url('/lab/v4-clear-filter-20261102.png');background-size:23px 24px;
 font-size:23px!important;line-height:1!important;color:#e4f6ff!important;
 text-align:center;overflow:visible!important
}
#v4-library .v4-v2-searchrow>.v4-clear-filters[hidden]{display:none!important}
#v4-library .v4-v2-searchrow>.v4-clear-filters::before{content:none!important}
#v4-library .v4-sort-toolbar button{
 min-width:36px!important;width:36px!important;height:29px!important;
 font-size:11px!important;line-height:1.15!important;overflow:visible!important;
 color:#eaf8ff!important;position:relative!important
}
#v4-library .v4-sort-toolbar button::before{display:none!important}
#v4-library[data-v4-layout="tiles"] #results button.item>img,
#v4-library #v4-v2-favorites-grid button.item>img{
 display:block!important;width:57px!important;height:57px!important;
 max-width:88%!important;max-height:88%!important;min-width:0!important;
 flex:0 1 57px!important;margin:auto!important;
 object-fit:contain!important;object-position:center center!important;
 image-rendering:pixelated!important;transform:none!important
}
#v4-library[data-v4-layout="tiles"] #results button.item,
#v4-library #v4-v2-favorites-grid button.item{
 display:flex!important;align-items:center!important;justify-content:center!important;
 padding:3px!important
}
@media(max-width:420px){
 #v4-library .v4-v2-searchrow #v4-v2-filters{max-width:155px}
 #v4-library #v4-v2-filters .v4-filters-selected{max-width:100px!important}
 #v4-library[data-v4-layout="tiles"] #results button.item>img,
 #v4-library #v4-v2-favorites-grid button.item>img{width:52px!important;height:52px!important}
}

/* Native title timebase wins over older prototype CSS animations; otherwise
 * CSS keyframes override JS channel colors, making G4G and L125 inconsistent. */
#v4-v2-nameplate-name .v4-v2-name-letters[data-title="g4g"],
#v4-v2-nameplate-name .v4-v2-name-letters[data-title="g4g"] .v4-title-letter,
#v4-v2-nameplate-name .v4-v2-name-letters[data-title="l125"],
#v4-v2-nameplate-name .v4-v2-name-letters[data-title="l125"] .v4-title-letter{
 animation:none!important;transition:none!important;
}

#v4-library #v4-v2-filters .v4-active-native-icon{
 display:block;flex:0 0 32px;width:32px;height:32px;
 align-self:center;image-rendering:pixelated;
}
#v4-library #v4-v2-filters .v4-active-native-icon[hidden]{display:none!important}

/* Restore the actual V2 sprite for the four ordering actions when the
 * client confirms that all four frames contain visible pixels. */
#v4-library.v4-native-sort-ready .v4-sort-toolbar button{
 font-size:0!important;overflow:hidden!important;
}
#v4-library.v4-native-sort-ready .v4-sort-toolbar button::before{
 content:"";display:block!important;position:absolute!important;
 left:50%;top:50%;width:28px!important;height:28px!important;
 margin:0!important;transform:translate(-50%,-50%)!important;
 background-image:url('/lab/v4-sort-icons-20261102.png')!important;
 background-size:112px 28px!important;
 background-position-y:0!important;background-repeat:no-repeat!important;
 image-rendering:pixelated!important;pointer-events:none!important;
}
#v4-library.v4-native-sort-ready .v4-sort-toolbar button[data-v4-sort="name-asc"]::before{background-position-x:0!important}
#v4-library.v4-native-sort-ready .v4-sort-toolbar button[data-v4-sort="name-desc"]::before{background-position-x:-28px!important}
#v4-library.v4-native-sort-ready .v4-sort-toolbar button[data-v4-sort="id-asc"]::before{background-position-x:-56px!important}
#v4-library.v4-native-sort-ready .v4-sort-toolbar button[data-v4-sort="id-desc"]::before{background-position-x:-84px!important}


/* Tablet V4: the compact two-column layout has TWO real stacked rows:
 * Preview spans the upper row, with Library and Appearance underneath.
 * The global single-row height rule otherwise stacks the second row over
 * the preview, letting Appearance intercept its toolbar and wardrobe.
 * Keep fixed viewport panels, but make each row independently scrollable. */
@media (min-width:761px) and (max-width:1180px){
 main,html.v4-embedded main{
  grid-template-columns:minmax(0,1fr) minmax(0,1fr)!important;
  grid-template-rows:minmax(0,1fr) minmax(0,1fr)!important;
 }
 main>#v4-character{
  grid-column:1/-1!important;grid-row:1!important;
  min-height:0!important;height:100%!important;overflow-y:auto!important;
 }
 main>#v4-library{
  grid-column:1!important;grid-row:2!important;
  min-height:0!important;height:100%!important;
  overflow:hidden!important;
 }
 main>#v4-appearance{
  grid-column:2!important;grid-row:2!important;
  min-height:0!important;height:100%!important;
  overflow-y:auto!important;
 }
}
