/* Native 160×600 rails share available space with the existing workspace.
   At least ~1,070px remains for content at 1280px. Smaller windows use
   their configured mobile inline placement instead of relocating a side unit. */
.th-ad-market-scroll{display:contents}
@media (max-width:1279px){
 body [data-th-fluid-ad-layout]>:is(.markets-ad-rails,.th-wide-ad-rails){display:none!important}
}
@media (min-width:1280px){
 body.th-recap .recap-shell[data-th-fluid-ad-layout]{--th-fluid-ad-max:980px}
 body #main.ws-main[data-th-fluid-ad-layout]{--th-fluid-ad-max:1320px}
 body.th-learn #main[data-th-fluid-ad-layout],body.th-tools #main[data-th-fluid-ad-layout]{--th-fluid-ad-max:1260px}
 body #main:is(.deriv-page,.liqmap-seo-page)[data-th-fluid-ad-layout]{--th-fluid-ad-max:1360px}
 html:has([data-th-fluid-ad-layout]>:is(.markets-ad-rails,.th-wide-ad-rails)>.has-inventory),body:has([data-th-fluid-ad-layout]>:is(.markets-ad-rails,.th-wide-ad-rails)>.has-inventory){overflow-x:clip}
 /* Keep the content itself centred when its side gutter fits the rail.
    On narrower desktops, shift only as far as needed to retain the workspace
    width and a 16px outer rail gutter. Never centre the ad/content group. */
 body :is(main#main,main.markets-shell,.recap-shell)[data-th-fluid-ad-layout]:has(>:is(.markets-ad-rails,.th-wide-ad-rails)>.has-inventory){--th-fluid-ad-gap:clamp(12px,1.3vw,24px);--th-fluid-ad-outer-margin:max(16px,min(calc((100% - var(--th-fluid-ad-max,1180px)) / 2),calc(100% - var(--th-fluid-ad-max,1180px) - 176px - var(--th-fluid-ad-gap))));box-sizing:border-box;position:relative;overflow:visible;width:calc(100% - 192px - var(--th-fluid-ad-gap));max-width:var(--th-fluid-ad-max,1180px);min-width:0;min-height:720px;margin-left:var(--th-fluid-ad-outer-margin);margin-right:auto}
 /* A left-only campaign keeps its identity and its left-hand position. */
 body :is(main#main,main.markets-shell,.recap-shell)[data-th-fluid-ad-layout]:has(>:is(.markets-ad-rails,.th-wide-ad-rails)>.has-inventory):not(:has(>:is(.markets-ad-rails,.th-wide-ad-rails)>:last-child.has-inventory)){margin-left:auto;margin-right:var(--th-fluid-ad-outer-margin)}
 body [data-th-fluid-ad-layout]>:is(.markets-ad-rails,.th-wide-ad-rails){display:none!important}
 body [data-th-fluid-ad-layout]:has(>:is(.markets-ad-rails,.th-wide-ad-rails)>.has-inventory)>:is(.markets-ad-rails,.th-wide-ad-rails){display:grid!important;grid-template-columns:160px;grid-template-rows:minmax(0,1fr);position:absolute;top:0;bottom:0;left:auto;right:calc(-160px - var(--th-fluid-ad-gap));width:160px;pointer-events:none}
 body [data-th-fluid-ad-layout]:has(>:is(.markets-ad-rails,.th-wide-ad-rails)>.has-inventory):not(:has(>:is(.markets-ad-rails,.th-wide-ad-rails)>:last-child.has-inventory))>:is(.markets-ad-rails,.th-wide-ad-rails){left:calc(-160px - var(--th-fluid-ad-gap));right:auto}
 body [data-th-fluid-ad-layout]>:is(.markets-ad-rails,.th-wide-ad-rails)>.th-ad-slot--rail.has-inventory{display:block!important;position:sticky;top:clamp(12px,calc(100dvh - 630px),118px);align-self:start;grid-row:1;grid-column:1;width:160px;max-width:none;margin:0;z-index:2;pointer-events:auto}
 body [data-th-fluid-ad-layout]:has(>:is(.markets-ad-rails,.th-wide-ad-rails)>:last-child.has-inventory)>:is(.markets-ad-rails,.th-wide-ad-rails)>:first-child{display:none!important}
 /* The fixed banners and the ad row never force the entire page to scroll. */
 .market-page main.markets-shell[data-th-fluid-ad-layout]>.markets-table-wrap{max-width:100%;overflow-x:auto;overflow-y:hidden;scrollbar-width:thin}
 .market-page main.markets-shell[data-th-fluid-ad-layout]>.markets-table-wrap>.markets-table{min-width:860px}
 .radar-page main.markets-shell[data-th-fluid-ad-layout]>.markets-table-wrap>.markets-table{min-width:1000px}
 body.market-page main.markets-shell[data-th-fluid-ad-layout],body.th-tools main#main[data-th-fluid-ad-layout]{container-type:inline-size;container-name:th-section-ad-content}
 @container th-section-ad-content (max-width:1100px){
  .th-tools main[data-th-fluid-ad-layout]>.tools-calculators .calc-panel.active{grid-template-columns:minmax(0,1fr)}
  .th-tools main[data-th-fluid-ad-layout]>.tools-calculators .calc-form,.th-tools main[data-th-fluid-ad-layout]>.tools-calculators .calc-result{min-width:0}
  .th-tools main[data-th-fluid-ad-layout]>.tools-directory .seo-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
 }
}
@media (min-width:1600px){
 /* A single active rail reserves one gutter; two reserve two. */
 body :is(main#main,main.markets-shell,.recap-shell)[data-th-fluid-ad-layout]:has(>:is(.markets-ad-rails,.th-wide-ad-rails)>:first-child.has-inventory):has(>:is(.markets-ad-rails,.th-wide-ad-rails)>:last-child.has-inventory){width:calc(100% - 352px - var(--th-fluid-ad-gap) - var(--th-fluid-ad-gap));margin-left:auto;margin-right:auto}
 body [data-th-fluid-ad-layout]:has(>:is(.markets-ad-rails,.th-wide-ad-rails)>:first-child.has-inventory):has(>:is(.markets-ad-rails,.th-wide-ad-rails)>:last-child.has-inventory)>:is(.markets-ad-rails,.th-wide-ad-rails){width:auto;grid-template-columns:160px 160px;justify-content:space-between;left:calc(-160px - var(--th-fluid-ad-gap));right:calc(-160px - var(--th-fluid-ad-gap))}
 body [data-th-fluid-ad-layout]:has(>:is(.markets-ad-rails,.th-wide-ad-rails)>:last-child.has-inventory)>:is(.markets-ad-rails,.th-wide-ad-rails)>.th-ad-slot--rail:first-child.has-inventory{display:block!important;grid-column:1}
 body [data-th-fluid-ad-layout]>:is(.markets-ad-rails,.th-wide-ad-rails)>.th-ad-slot--rail:last-child{grid-column:-2}
}
/* Short windows use document scrolling, keeping the full creative reachable. */
@media (min-width:1280px) and (max-height:739px){
 body [data-th-fluid-ad-layout]>:is(.markets-ad-rails,.th-wide-ad-rails)>.th-ad-slot--rail.has-inventory{position:relative;top:0}
}
