@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --ay-bg: #0f1216;
    --ay-surface: #161b22;
    --ay-surface-2: #1d232c;
    --ay-border: #2e3742;
    --ay-text: #eef2f6;
    --ay-text-soft: #c6d0db;
    --ay-text-dim: #99a6b5;
    --ay-accent: #d3541d;
    --ay-accent-2: #eb6a32;
  }

  html, body, #page, .site {
    background: var(--ay-bg) !important;
    color: var(--ay-text) !important;
  }

  body, p, li, dt, dd, blockquote,
  .entry-title, .entry-title a,
  .widget, .widget a,
  .main-navigation li a,
  .post-title a,
  .site-title a,
  .site-description,
  .entry-meta, .entry-meta a,
  .post-date, .posted-on, .byline,
  .breadcrumbs, .breadcrumbs a,
  #engage-mag-breadcrumbs, #engage-mag-breadcrumbs a,
  .ayari-apb-wrap, .ayari-apb-wrap a {
    color: var(--ay-text) !important;
  }

  .site-header, .top-bar, .engage-mag-menu-container,
  .main-navigation ul ul, .main-navigation ul ul li,
  .offcanvas-menu,
  .site-footer, .site-info {
    background: var(--ay-surface) !important;
    border-color: var(--ay-border) !important;
  }

  #primary #main,
  article .post-content-wrap,
  article .post-content,
  .widget, .widget-area .widget,
  .related-post-entries li,
  .posts-navigation .nav-previous,
  .posts-navigation .nav-next,
  .post-navigation .nav-previous,
  .post-navigation .nav-next,
  #comments .comment-list li .comment-body,
  .ayari-press-review .ayari-card,
  .ayari-press-review .ayari-grid-empty {
    background: var(--ay-surface) !important;
    color: var(--ay-text) !important;
    border-color: var(--ay-border) !important;
    box-shadow: none !important;
  }

  .main-navigation #primary-menu > li > a:hover,
  .main-navigation #primary-menu > li.current-menu-item > a,
  .main-navigation #primary-menu > li.current_page_item > a,
  .main-navigation #primary-menu > li.current-menu-ancestor > a,
  .main-navigation #primary-menu > li.current-page-ancestor > a {
    background: transparent !important;
    color: #fff !important;
    box-shadow: inset 0 -2px 0 var(--ay-accent) !important;
  }

  .main-navigation #primary-menu li ul li > a:hover,
  .main-navigation #primary-menu li ul li.current-menu-item > a,
  .main-navigation #primary-menu li ul li.current_page_item > a {
    background: rgba(211, 84, 29, .18) !important;
    color: #fff !important;
  }

  a:hover, .widget a:hover, .entry-title a:hover, .post-title a:hover {
    color: #fff !important;
  }

  .search-form input[type="search"],
  input[type="text"], input[type="email"], input[type="url"], input[type="password"],
  input[type="search"], input[type="number"], input[type="tel"], input[type="range"],
  input[type="date"], input[type="month"], input[type="week"], input[type="time"],
  input[type="datetime"], input[type="datetime-local"], input[type="color"],
  textarea, select {
    background: #10151b !important;
    color: var(--ay-text) !important;
    border-color: var(--ay-border) !important;
  }

  button,
  input[type="submit"],
  .wp-block-button__link,
  .ayari-press-review .ayari-card-readmore,
  .ayari-press-review .ayari-card-source {
    background: var(--ay-accent) !important;
    border-color: var(--ay-accent) !important;
    color: #fff !important;
  }

  button:hover,
  input[type="submit"]:hover,
  .wp-block-button__link:hover,
  .ayari-press-review .ayari-card-readmore:hover,
  .ayari-press-review .ayari-card-source:hover {
    background: var(--ay-accent-2) !important;
    border-color: var(--ay-accent-2) !important;
  }

  /* Parliamentary bridge */
  body.ayari-apb-front {
    --ayari-apb-bg: #0f1216;
    --ayari-apb-surface: #161b22;
    --ayari-apb-surface-strong: #1d232c;
    --ayari-apb-border: #2e3742;
    --ayari-apb-text: #eef2f6;
    --ayari-apb-muted: #b9c4cf;
    --ayari-apb-accent: #d3541d;
    --ayari-apb-accent-strong: #eb6a32;
    --ayari-apb-warning: #ffdb88;
    --ayari-apb-warning-bg: rgba(255, 219, 136, .12);
    --ayari-apb-shadow: none;
  }

  .ayari-apb-wrap,
  .ayari-apb-wrap .ayari-apb-breadcrumb,
  .ayari-apb-wrap .ayari-apb-meta,
  .ayari-apb-wrap .ayari-apb-panel p,
  .ayari-apb-wrap .ayari-apb-card p,
  .ayari-apb-wrap .ayari-apb-dl dt,
  .ayari-apb-wrap .ayari-apb-dl dd,
  .ayari-apb-wrap .ayari-apb-attachments li,
  .ayari-apb-wrap .ayari-apb-grid-card,
  .ayari-apb-wrap .ayari-apb-card a,
  .ayari-apb-wrap .ayari-apb-breadcrumb a,
  .ayari-apb-wrap .ayari-apb-kicker,
  .ayari-apb-wrap h1,
  .ayari-apb-wrap h2,
  .ayari-apb-wrap h3 {
    color: var(--ayari-apb-text) !important;
  }

  .ayari-apb-wrap .ayari-apb-kicker {
    color: var(--ayari-apb-accent) !important;
  }

  .ayari-apb-wrap .ayari-apb-grid-card,
  .ayari-apb-wrap .ayari-apb-pagination .page-numbers,
  .ayari-apb-wrap .ayari-apb-filterbar input,
  .ayari-apb-wrap .ayari-apb-filterbar select,
  .ayari-apb-wrap .ayari-apb-panel,
  .ayari-apb-wrap .ayari-apb-card,
  .ayari-apb-wrap .ayari-apb-hero {
    background: var(--ayari-apb-surface) !important;
    border-color: var(--ayari-apb-border) !important;
    box-shadow: none !important;
  }

  .ayari-apb-wrap .ayari-apb-grid-card.is-current,
  .ayari-apb-wrap .ayari-apb-pagination .page-numbers.current,
  .ayari-apb-wrap .ayari-apb-download,
  .ayari-apb-wrap .ayari-apb-more,
  .ayari-apb-wrap .ayari-apb-filterbar button {
    background: var(--ayari-apb-accent) !important;
    border-color: var(--ayari-apb-accent) !important;
    color: #fff !important;
  }

  .ayari-apb-wrap .ayari-apb-download.ayari-apb-secondary {
    background: var(--ayari-apb-surface-strong) !important;
    color: var(--ayari-apb-text) !important;
    border-color: var(--ayari-apb-border) !important;
  }

  .ayari-apb-wrap .ayari-apb-flag {
    background: var(--ayari-apb-surface-strong) !important;
    border-color: var(--ayari-apb-border) !important;
    color: var(--ayari-apb-muted) !important;
  }

  .ayari-apb-wrap .ayari-apb-flag.is-warning {
    background: var(--ayari-apb-warning-bg) !important;
    color: var(--ayari-apb-warning) !important;
  }


  .site-content,
  #content,
  .content-area,
  .site-main,
  .page-content,
  .entry-content,
  .entry-summary,
  .archive-description,
  .page-header,
  .nav-links,
  .inner-main-wrap,
  .main-wrapper,
  .content-wrap,
  .site-content-wrap,
  .widget-area,
  .secondary-sidebar,
  .right-sidebar,
  .left-sidebar,
  .page,
  .post,
  article,
  .hentry,
  .single-post-wrap,
  .archive-posts,
  .featured-section,
  .block-section,
  .wrapper,
  .container,
  .boxed-layout,
  .candid-widget-wrapper,
  .ayari-v1-forced-menu,
  .ayari-apb-front .site-main,
  .ayari-apb-front #primary,
  .ayari-apb-front #content {
    background-color: var(--ay-bg) !important;
    color: var(--ay-text) !important;
    border-color: var(--ay-border) !important;
  }

  .site-header,
  .site-footer,
  .main-navigation,
  .main-navigation ul,
  .main-navigation li,
  .menu,
  .sub-menu,
  .children,
  .top-header,
  .bottom-header,
  .header-main,
  .header-wrapper,
  .page-header,
  .archive-header,
  .entry-header,
  .widget-title,
  .cat-links,
  .tags-links,
  .post-categories,
  .post-tags,
  .pagination,
  .page-numbers,
  .breadcrumb-trail,
  .breadcrumbs,
  .comment-respond,
  .comments-area,
  .comment-body,
  .author-box,
  .related-posts,
  .post-item,
  .grid-item,
  .card,
  .panel {
    background-color: var(--ay-surface) !important;
    color: var(--ay-text) !important;
    border-color: var(--ay-border) !important;
  }

  .site-header a,
  .site-footer a,
  .main-navigation a,
  .menu a,
  .sub-menu a,
  .entry-content a,
  .page-content a,
  .widget a,
  .breadcrumbs a,
  .page-numbers,
  .nav-links a {
    color: var(--ay-text) !important;
  }


  img, video, iframe, svg {
    filter: none !important;
  }

  /* Engage Mag residual light surfaces cleanup */
  .engage-mag-content-area,
  .engage-mag-content-container,
  .engage-mag-content-container.engage-mag-has-thumbnail .engage-mag-content-area,
  .ct-below-featured-area,
  .ct-above-footer,
  .ct-below-featured-area.ct-grid-wrapper,
  .ct-header-carousel-section,
  .ct-missed-block,
  .ct-carousel-inner,
  .ct-carousel.slider,
  .ct-carousel-single,
  .slick-track,
  .slick-list,
  .engage-mag-featured-block,
  .engage-mag-thumbnail-post,
  .ct-grid-post,
  .ct-grid-post-list,
  .list-post,
  .list-post .post-block-style,
  .post-block-style,
  .post-content,
  .post-content-wrap,
  .ct-post-overlay .post-content.post-relative,
  .ct-post-overlay .post-content.post-relative a,
  .featured-post-content,
  .single-top-sidebar,
  .widget_media_image,
  .widget_block,
  .wp-block-group,
  .wp-block-cover,
  .archive.category .site-content,
  .archive.category #primary,
  .archive.category #main,
  .home.blog .site-content,
  .home.blog #primary,
  .home.blog #main {
    background: var(--ay-bg) !important;
    color: var(--ay-text) !important;
    border-color: var(--ay-border) !important;
  }

  .engage-mag-content-area,
  .ct-post-overlay .post-content.post-relative,
  .featured-post-content,
  .post-content-wrap,
  .widget,
  .widget-area .widget,
  .ct-missed-block.widget,
  .ct-container-main {
    background: var(--ay-surface) !important;
  }

  .ct-below-featured-area,
  .ct-above-footer,
  .ct-header-carousel-section,
  .ct-below-featured-area.ct-grid-wrapper,
  .ct-missed-block {
    background: var(--ay-bg) !important;
  }

  ul.ct-carousel li {
    border-left-color: var(--ay-border) !important;
    border-right-color: var(--ay-border) !important;
  }

  .widget-title:before,
  .widget ul.ct-nav-tabs:before,
  .about-author-box .container-title:before {
    background: var(--ay-border) !important;
  }

  .widget .tagcloud a,
  .ct-title-head,
  .widget ul.ct-nav-tabs li.ct-title-head,
  .widget ul.ct-nav-tabs li.ct-title-head:hover,
  .widget ul.ct-nav-tabs li.ct-title-head.ui-tabs-active {
    background: var(--ay-accent) !important;
    color: #fff !important;
    border-color: var(--ay-accent) !important;
  }

  .archive .page-header,
  .archive .archive-description,
  .archive .taxonomy-description,
  .archive #engage-mag-breadcrumbs,
  .archive .breadcrumb-trail,
  .archive .breadcrumbs {
    background: transparent !important;
  }

  .archive .page-title,
  .archive .archive-title,
  .archive h1.page-title,
  .archive h1.archive-title {
    color: var(--ay-text) !important;
  }

  .entry-content a.read-more-text,
  .read-more-text {
    color: var(--ay-text-soft) !important;
  }

  .entry-meta, .entry-meta a,
  .post-meta, .post-meta a,
  .featured-post-title .entry-meta,
  .featured-post-title .entry-meta a {
    color: var(--ay-text-soft) !important;
  }

  .ct-post-overlay .post-content.post-relative,
  .ct-post-overlay .post-content.post-relative a,
  .widget .ct-post-overlay .post-content.post-relative,
  .widget .ct-post-overlay .post-content.post-relative a,
  .ct-post-overlay .post-content.post-relative a:visited,
  .widget .ct-post-overlay .post-content.post-relative a:visited {
    color: var(--ay-text) !important;
  }

  .post-content > *:last-child,
  .engage-mag-content-area > *:last-child {
    margin-bottom: 0 !important;
  }

  .main-navigation, .main-navigation ul, .top-bar, .site-header, .site-footer {
    box-shadow: none !important;
  }



  /* Hotfix stronger residual light bands */
  .site-content .container,
  .widget-area .widget,
  .ct-container-main,
  .archive .page-header,
  .home .ct-below-featured-area,
  .home .ct-above-footer,
  .home .widget,
  .archive .widget,
  .archive article,
  .archive .post-content-wrap,
  .archive .content-area,
  .archive .site-main,
  .archive .container,
  .home .container,
  .home .site-main,
  .home .content-area {
    background: var(--ay-bg) !important;
    background-color: var(--ay-bg) !important;
  }

  .home article,
  .home .post,
  .home .hentry,
  .home .ct-post-overlay,
  .home .post-content-wrap,
  .archive .post,
  .archive .hentry,
  .archive .ct-post-overlay {
    background: var(--ay-surface) !important;
    background-color: var(--ay-surface) !important;
  }

  .home .wp-post-image,
  .archive .wp-post-image {
    background: transparent !important;
  }

  /* AYARI_PARL_DARK_CONTRAST_V1 START */
  .ayari-parl-archive,
  .ayari-parl-record {
    color-scheme: dark;
    color: var(--ay-text) !important;
  }

  .ayari-parl-notice,
  .ayari-parl-card,
  .ayari-parl-record,
  .ayari-surface-card {
    background: #0f172a !important;
    color: #f8fafc !important;
    border-color: #334155 !important;
    box-shadow: none !important;
  }

  .ayari-parl-card-inner {
    background: transparent !important;
    color: #f8fafc !important;
  }

  .ayari-parl-card h3,
  .ayari-parl-card h3 a,
  .ayari-parl-card-topline,
  .ayari-parl-kicker,
  .ayari-parl-card-summary,
  .ayari-parl-card-meta,
  .ayari-parl-card-facts dt,
  .ayari-parl-card-facts dd,
  .ayari-parl-availability-note,
  .ayari-parl-empty,
  .ayari-parl-actions,
  .ayari-parl-card-actions {
    color: #f8fafc !important;
  }

  .ayari-parl-card-topline,
  .ayari-parl-card-facts dt,
  .ayari-parl-card-meta {
    color: #cbd5e1 !important;
  }

  .ayari-parl-card-facts div,
  .ayari-parl-card-facts.ayari-apb-card-facts div,
  .ayari-apb-card-facts.ayari-parl-card-facts div {
    background: #1e293b !important;
    color: #f8fafc !important;
    border-color: #475569 !important;
  }

  .ayari-parl-availability-note {
    background: #111827 !important;
    border-color: #fb923c !important;
    border-right-color: #fb923c !important;
  }

  .ayari-parl-btn {
    background: #c2410c !important;
    color: #fff !important;
    border-color: rgba(251, 146, 60, .45) !important;
  }

  .ayari-parl-btn-secondary {
    background: #1e293b !important;
    color: #f8fafc !important;
    border-color: #475569 !important;
  }
  /* AYARI_PARL_DARK_CONTRAST_V1 END */
  /* AYARI_PUBLIC_DARK_CONTRAST_V2 START */
  .ayari-home-card,
  .ayari-apb-hero,
  .ayari-apb-panel,
  .ayari-apb-card,
  .ayari-apb-admin-card,
  .ayari-mel7it-intro,
  .ayari-mel7it-card,
  .ayari-mel7it-thumb-placeholder,
  .ayari-mel7it-read,
  .ayari-mel7it-actions .ayari-apb-secondary {
    background: #0f172a !important;
    color: #f8fafc !important;
    border-color: #334155 !important;
    box-shadow: none !important;
  }

  .ayari-home-card p,
  .ayari-home-card h2,
  .ayari-home-card h2 a,
  .ayari-home-links a,
  .ayari-home-panel-head h2,
  .ayari-home-panel-head p,
  .ayari-apb-card h2,
  .ayari-apb-card h2 a,
  .ayari-apb-card p,
  .ayari-apb-panel h2,
  .ayari-apb-panel p,
  .ayari-apb-panel li,
  .ayari-apb-card-facts div,
  .ayari-apb-card-facts dt,
  .ayari-apb-card-facts dd,
  .ayari-mel7it-intro h2,
  .ayari-mel7it-intro p,
  .ayari-mel7it-card h3,
  .ayari-mel7it-card h3 a,
  .ayari-mel7it-excerpt,
  .ayari-mel7it-thumb-placeholder span {
    color: #f8fafc !important;
  }

  .ayari-apb-card-facts div,
  .ayari-mel7it-card-body {
    background: #111827 !important;
    border-color: #334155 !important;
  }

  .ayari-apb-card-facts dt,
  .ayari-mel7it-date,
  .ayari-apb-small,
  .ayari-apb-meta {
    color: #cbd5e1 !important;
  }

  .ayari-mel7it-read,
  .ayari-mel7it-date,
  .ayari-home-links a:hover,
  .ayari-mel7it-card h3 a:hover {
    color: #fb923c !important;
  }

  .ayari-apb-grid-card,
  .ayari-apb-pagination .page-numbers {
    background: #111827 !important;
    color: #f8fafc !important;
    border-color: #334155 !important;
  }
  /* AYARI_PUBLIC_DARK_CONTRAST_V2 END */
}


/* AYARI_DARK_NAV_SHARE_SURFACES_0_2_8
   Fix audited Engage Mag navigation/share surfaces in dark mode.
   Plugin-owned override only: no theme edit. */
body.ct-dark-mode .site-main .comment-navigation,
body.ct-dark-mode .site-main .posts-navigation,
body.ct-dark-mode .site-main .post-navigation,
body.ct-dark-mode .posts-navigation,
body.ct-dark-mode .post-navigation,
body.ct-dark-mode .nav-links,
body.ct-dark-mode .page-links,
body.ct-dark-mode .navigation.pagination,
body.ct-dark-mode .candid-pagination,
body.ct-dark-mode body.ct-boxed .posts-navigation,
body.ct-dark-mode body.ct-boxed .post-navigation {
  background: #111827 !important;
  color: #e5e7eb !important;
  border: 1px solid rgba(148, 163, 184, .22) !important;
  border-radius: 16px !important;
  box-shadow: none !important;
}

body.ct-dark-mode .post-navigation .nav-previous,
body.ct-dark-mode .post-navigation .nav-next,
body.ct-dark-mode .posts-navigation .nav-previous,
body.ct-dark-mode .posts-navigation .nav-next,
body.ct-dark-mode .nav-links .nav-previous,
body.ct-dark-mode .nav-links .nav-next {
  background: #111827 !important;
  color: #e5e7eb !important;
  border-color: rgba(148, 163, 184, .22) !important;
}

body.ct-dark-mode .post-navigation a,
body.ct-dark-mode .posts-navigation a,
body.ct-dark-mode .nav-links a,
body.ct-dark-mode .page-links a,
body.ct-dark-mode .navigation.pagination a,
body.ct-dark-mode .candid-pagination a,
body.ct-dark-mode .candid-pagination .page-numbers {
  color: #f8fafc !important;
  background: #18202b !important;
  border: 1px solid rgba(148, 163, 184, .28) !important;
  border-radius: 999px !important;
  min-height: 44px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: .55rem .85rem !important;
  text-decoration: none !important;
}

body.ct-dark-mode .post-navigation a:hover,
body.ct-dark-mode .posts-navigation a:hover,
body.ct-dark-mode .nav-links a:hover,
body.ct-dark-mode .page-links a:hover,
body.ct-dark-mode .navigation.pagination a:hover,
body.ct-dark-mode .candid-pagination a:hover,
body.ct-dark-mode .post-navigation a:focus-visible,
body.ct-dark-mode .posts-navigation a:focus-visible,
body.ct-dark-mode .nav-links a:focus-visible,
body.ct-dark-mode .page-links a:focus-visible {
  color: #ffffff !important;
  background: #1f2937 !important;
  border-color: rgba(226, 232, 240, .55) !important;
  outline: 2px solid rgba(226, 232, 240, .38) !important;
  outline-offset: 2px !important;
}

body.ct-dark-mode .post-share,
body.ct-dark-mode .sharedaddy,
body.ct-dark-mode .sd-sharing-enabled {
  display: none !important;
}

body.ct-dark-mode .ayari-apb-share-panel {
  display: block !important;
  background: #111827 !important;
  color: #f8fafc !important;
  border-color: rgba(148, 163, 184, .28) !important;
}

body.ct-dark-mode .ayari-apb-share-panel__link,
body.ct-dark-mode .ayari-apb-share-panel__link:visited {
  pointer-events: auto !important;
  color: #f8fafc !important;
  background: #18202b !important;
  border-color: rgba(148, 163, 184, .34) !important;
}


/* AYARI_DARK_QUICKNAV_PRO_SURFACES_0_2_9
   Targeted dark correction for the quick-navigation block immediately before APB share.
   Uses :has() to avoid touching the theme globally. */
body #primary article .entry-content > :is(nav, section, div):has(+ .ayari-apb-share-pro),
body .entry-content > :is(nav, section, div):has(+ .ayari-apb-share-pro),
body #primary article .entry-content > :is(nav, section, div):has(+ .ayari-apb-share-panel),
body .entry-content > :is(nav, section, div):has(+ .ayari-apb-share-panel) {
  background: linear-gradient(135deg, #111827, #0f172a) !important;
  color: #e5e7eb !important;
  border: 1px solid rgba(148, 163, 184, .24) !important;
  border-radius: 18px !important;
  box-shadow: 0 14px 34px rgba(0,0,0,.18) !important;
}

body #primary article .entry-content > :is(nav, section, div):has(+ .ayari-apb-share-pro) *,
body .entry-content > :is(nav, section, div):has(+ .ayari-apb-share-pro) *,
body #primary article .entry-content > :is(nav, section, div):has(+ .ayari-apb-share-panel) *,
body .entry-content > :is(nav, section, div):has(+ .ayari-apb-share-panel) * {
  color: #e5e7eb !important;
}

body #primary article .entry-content > :is(nav, section, div):has(+ .ayari-apb-share-pro) a,
body .entry-content > :is(nav, section, div):has(+ .ayari-apb-share-pro) a,
body #primary article .entry-content > :is(nav, section, div):has(+ .ayari-apb-share-panel) a,
body .entry-content > :is(nav, section, div):has(+ .ayari-apb-share-panel) a {
  background: rgba(24, 32, 43, .92) !important;
  color: #f8fafc !important;
  border-color: rgba(148, 163, 184, .28) !important;
  text-decoration: none !important;
  box-shadow: none !important;
}

body #primary article .entry-content > :is(nav, section, div):has(+ .ayari-apb-share-pro)::before,
body .entry-content > :is(nav, section, div):has(+ .ayari-apb-share-pro)::before {
  color: #e5e7eb !important;
}

body .post-share,
body .sharedaddy,
body .sd-sharing-enabled {
  display: none !important;
}

body .ayari-apb-share-panel:not(.ayari-apb-share-pro) {
  display: none !important;
}

body .ayari-apb-share-pro {
  display: block !important;
}


/* AYARI_DARK_HIDE_LEGACY_META_BOTTOM_SHARE_0_2_10
   Exact fallback for Engage Mag legacy share block if an HTML cache serves it.
   The primary removal is APB output cleanup, not a theme edit. */
body .engage-mag-content-area > .meta_bottom:has(> .text_share.header-text + .post-share),
body .meta_bottom:has(> .text_share.header-text + .post-share),
body .meta_bottom > .text_share.header-text,
body .meta_bottom > .post-share {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

body .ayari-apb-share-pro {
  display: block !important;
}

