/* The cover and alternating dark bands share Secure Trading's charcoal. Set
   these roles on nested dark bands too, so they can sit in an ivory article. */
:root, :host, [data-aft-band="dark"], [data-aft-band="footer"] {
  --chapter-base: var(--aft-charcoal, #111715);
  --chapter-surface: var(--chapter-base);
  --chapter-raised: #242424;
  --chapter-card: #303030;
  --chapter-title: #fff;
  --chapter-text: rgb(255 255 255 / 86%);
  --chapter-muted: rgb(255 255 255 / 72%);
  --chapter-line: rgb(255 255 255 / 20%);
  --chapter-link: var(--action-normal);
  --action-normal: var(--aft-mint, #33ffb5);
  --action-hover: var(--aft-button-hover, #19dc95);
  --action-ink: #111;
  color-scheme: dark;
}
body, :host {
  --paper: var(--chapter-base);
  --ink: var(--chapter-title);
  --carbon: var(--chapter-title);
  --line: var(--chapter-line);
  --quiet: var(--chapter-muted);
  --wash: var(--chapter-raised);
}

/* Saved pages include locally scoped, important utility declarations. Keep
   their layout intact while applying the same color roles to each template. */
@layer inner-page-colors {
  html, body, :host { background-color: var(--chapter-base) !important; color: var(--chapter-text) !important; }
  header.aft-site-nav {
    --site-nav-bg: #161616 !important;
    --site-nav-panel: var(--chapter-raised) !important;
    --site-nav-line: var(--chapter-line) !important;
    --site-nav-text: var(--chapter-title) !important;
    --site-nav-muted: var(--chapter-muted) !important;
  }
  header.aft-site-nav :is(.auth .button,.cta-btn):hover {
    color: var(--action-ink) !important;
    background: var(--action-hover) !important;
  }
  .aft-terrain { background: var(--chapter-line) !important; }
  .aft-terrain::after {
    background-image: linear-gradient(161deg, transparent 35%, var(--chapter-line) 49%, transparent 64%) !important;
  }
  footer { background-color: #0a0a0a !important; }
  [data-aft-band="dark"] { background-color: var(--chapter-base) !important; }
  [data-aft-band="light"] { background-color: var(--chapter-surface) !important; }
  [data-aft-band="footer"] { background-color: #0a0a0a !important; }

  :is(.section.aft-reading, [data-aft-band="light"]) {
    --chapter-surface: var(--aft-ivory, #f6f5ef);
    --chapter-card: #fff;
    --chapter-title: var(--aft-ink, #18241f);
    --chapter-text: var(--chapter-title);
    --chapter-muted: var(--aft-muted, #42564e);
    --chapter-line: var(--aft-rule, #c4d2c9);
    --chapter-link: var(--aft-green-ink, #126449);
    color-scheme: light !important;
  }
  .aft-contact-band {
    --chapter-title: var(--aft-ink, #18241f);
    --chapter-text: var(--chapter-title);
    background: var(--action-normal) !important;
  }
  @scope (:is(main, #root, #app, footer, .aft-contact-band, .aft-utility, [data-aft-band], :host)) to (.aft-site-nav, .language-picker) {
    :scope { color: var(--chapter-text) !important; }
    :where(*):not(svg,svg *) { border-color: var(--chapter-line) !important; }

    /* Original layouts use independent background fills on many wrappers. */
    :where(div,main,section,header,nav,article,aside,details,summary,fieldset,form,table,figure,
      h1,h2,h3,h4,p,span,small,strong,dl,dt,dd,ul,li,thead,tbody,tr,td,th,label,a) {
      background-color: transparent !important;
    }
    :where(#root,#root > div,main) { background-color: var(--chapter-base) !important; }
    :where([class*="bg-gradient"],[class*="from-white"],.aft-document-title) {
      background-image: none !important;
    }
    :where(.subhero,.compare-intro,.campaign-summary,.aft-photo-cover,[data-aft-band="dark"]) {
      background-color: var(--chapter-base) !important;
    }
    :where(.section.aft-reading, [data-aft-band="light"]) {
      color-scheme: light !important;
      background-color: var(--chapter-surface) !important;
    }
    .section.aft-reading {
      --ink: var(--chapter-title);
      --quiet: var(--chapter-muted);
      --mint: var(--chapter-text);
      --line: var(--chapter-line);
      box-shadow: 0 0 0 100vmax var(--chapter-surface) !important;
    }
    :where(footer,[data-aft-band="footer"]) { background-color: #0a0a0a !important; }
    :where(.contents,.sticky,.ctd-tabs,.pm-tabs,.ec-toolbar) { background-color: var(--chapter-surface) !important; }
    :where(.workbox,[data-compare],.ai-example,.marketview,.account-facts,
      .risk-scenarios,.risk-source-cards,.help-topic,.ctd-box,.aft-register-demo,
      .handoff:not([hidden]),.setup-walkthrough .pane,thead th,
      article[class*="card"],div[class*="-card"],section[class*="-panel"],
      [class~="bg-white"][class*="rounded"],[data-slot="card"]) {
      background-color: var(--chapter-card) !important;
    }

    :is(h1,h2,h3,h4,h5,h6) {
      color: var(--chapter-title) !important;
      -webkit-text-fill-color: currentColor !important;
    }
    :where(h1,.hero-title) { font-weight: 700 !important; }
    :where(h2,h3,.lead,.deck,.section-lead,.hero-subtitle) { font-weight: 400 !important; }
    :where(p,blockquote,div,li,th,td,dt,dd,label,strong,b,em,output,summary,span,legend,code,pre,time,small,bdi,
      [class*="text-gray-"],[class*="text-slate-"],[class*="text-[#"]) {
      color: var(--chapter-text) !important;
    }
    :is(h1,h2,h3,h4,h5,h6) :where(span,strong,b,em) {
      color: inherit !important;
      font-weight: inherit !important;
      -webkit-text-fill-color: currentColor !important;
    }
    :is(.account-visual span,.metal-type) {
      background-image: none !important;
      color: var(--chapter-title) !important;
      -webkit-text-fill-color: currentColor !important;
    }
    :where(small,time,figcaption,.fine,.stamp,.section-label,.risk,.muted,.disclaimer,.deck,.lead,.section-lead) {
      color: var(--chapter-muted) !important;
    }
    :where(.section-label)::before, hr { background-color: var(--chapter-line) !important; }
    :where(.section-label,.steps li)::before { color: var(--chapter-text) !important; border-color: var(--chapter-line) !important; }
    .steps li::before { background-color: var(--chapter-card) !important; }

    :where(input,select,textarea,option,button) {
      color: var(--chapter-title) !important;
      background-color: var(--chapter-card) !important;
      accent-color: var(--action-normal);
    }
    ::placeholder { color: var(--chapter-muted) !important; }
    :where(input,select,textarea)[aria-invalid="true"] { outline: 2px solid var(--chapter-title); }
    :where(a,.link,.text-button,.quote-refresh,.ct-refresh,.copy-enquiry,.learn-more-btn,.help-view-all) {
      color: var(--chapter-link, var(--action-normal)) !important;
    }
    :where(a,button,summary):hover { color: var(--action-hover) !important; }
    :where(a,button,summary):focus-visible { outline: 2px solid var(--action-normal) !important; outline-offset: 2px; }
    :where(button[aria-pressed="true"],button[aria-selected="true"],button[data-state="active"]) {
      color: var(--chapter-link) !important;
      box-shadow: inset 0 -2px var(--chapter-link) !important;
    }
    :is(.button,.cta-btn,.bit-btn-main,.id-trade,.help-search-submit,.aft-contact-band a,button[type="submit"],a[class*="-button"],.gold-action-link) {
      background: var(--action-normal) !important;
      color: var(--action-ink) !important;
      border-color: transparent !important;
      &:hover { background: var(--action-hover) !important; }
      &:is(:disabled,[aria-disabled="true"]) {
        color: var(--chapter-muted) !important;
        background: var(--chapter-card) !important;
      }
    }
    :is(a,button,summary) :where(span,strong,b,bdi,i) { color: inherit !important; }
    :is(.crumb,[aria-label*="breadcrumb" i],[class*="breadcrumb" i],
      .flex.items-center:has(> a[href$="/index.html"], > a[href*="/index.html?lang="])) {
      color: var(--chapter-muted) !important;
      & :where(a,span,li,b) { color: inherit !important; }
      & a:hover { color: var(--chapter-title) !important; }
    }
    :is(.contents,.footlinks,footer nav) a, a:has(> h2, > h3, > h4) {
      color: var(--chapter-text) !important;
    }
    :is(.contents,.footlinks,footer nav) a:hover { color: var(--action-hover) !important; }
    .contents a:not([aria-current="location"]) { border-block-end-color: transparent !important; }
    .contents a[aria-current="location"] { color: var(--chapter-title) !important; border-color: var(--chapter-line) !important; }
  }
  .aft-contact-band .aft-contact-inner a {
    color: #fff !important;
    background: var(--chapter-base) !important;
  }
}
/* Extend the band behind the reading column while keeping its text measure. */
.feature-page :is(#account-comparison,.campaign-terms)[data-aft-band="light"],
:is(.nbp-sections,.risk-prose,.help-category-content,.campaign-terms) > section[data-aft-band],
:is(.nbp-heading,.risk-report-header,.risk-layout,.newsroom-content,.newsroom-section)[data-aft-band],
main > .max-w-\[820px\] > [data-aft-band] {
  box-shadow: 0 0 0 100vmax var(--chapter-surface);
  clip-path: inset(0 -100vmax);
}
.risk-prose > section[data-aft-band],
.help-category-content > section[data-aft-band],
.campaign-terms > section[data-aft-band] {
  margin-block: 0;
  padding-block: clamp(24px, 4vw, 56px);
}
.aft-utility > :is(header,section) {
  display: flow-root;
  padding-block: 1rem;
}
.aft-error-heading, .aft-error-actions {
  display: grid;
  justify-items: center;
  align-content: center;
  padding: clamp(36px, 6vw, 88px) 6%;
}
.aft-error-heading { min-height: 42svh; }
.market-trade.feature-page main > .container:first-child { padding-block-start: clamp(22px, 3vw, 48px); }

/* Reclaim the columns previously occupied by the local chapter menus. */
.newsroom-content { grid-template-columns: minmax(0,1fr); }
.risk-layout { grid-template-columns: minmax(0,830px); justify-content: center; row-gap: 1.5rem; }
@media (min-width: 1001px) {
  .help-detail-grid { grid-template-columns: 230px minmax(0,1fr); }
}
