/* ==========================================================================
   Appearance: dark mode in the site's plum palette, and reading mode for
   long reads (an aged-paper page set like The Long Arc). Linked on every
   public page after site.css (src/features/pwa.js publicHead), with
   assets/js/theme-init.js (applies the choice before paint) and
   assets/js/theme.js (the switches).

   html[data-theme="dark"]  the reader chose dark, or chose Auto and their
                            system is dark. Without JavaScript: light.
   html[data-reading="on"]  reading mode, applied only on pages with a long
                            read (the LONG_READS list in theme.js, repeated
                            in the :has() selectors below).

   How dark works: the tokens on :root flip (paper and mist go dark, ink and
   text go light), and every surface that the light theme paints in ink
   (header, footer, heroes, dark bands, code blocks...) becomes a "light-mode
   island": it gets the light tokens back, so it looks exactly as it does in
   the light theme. Text keeps at least 4.5:1 contrast on every surface.
   ========================================================================== */

/* ---------------------------------------------------------- Dark tokens */
:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #EDE7F6;
  --ink-2: #D9CCEB;
  --ink-deep: #0B0812;
  --mist: #140F1C;
  --paper: #1C1626;
  --accent: #8A5CC7;
  --accent-dark: #C9B2EA;
  --accent-soft: #6A5590;
  --pine: #CDB8EA;
  --danger: #EBA3A3;
  --text: #E4DEEC;
  --muted: #B3AAC1;
  --line: #352B45;
  --line-dark: #4A3359;
  /* Dark-only helpers for the generated overrides below. */
  --accent-text: #A884DA;
  --accent-soft-text: #A996C9;
  --tint: #221B2E;
}

/* Light-mode islands: surfaces painted in ink keep their light-theme look.
   (Selectors gathered from every stylesheet that sets an ink background.) */
:root[data-theme="dark"] :is(
  .ag-hero,
    .ag-text,
    .ag-close,
    .cr-type.is-honorary,
    .cr-chip[aria-current],
    .cr-progress a[aria-current] .cr-progress-num,
    .cr-pill input:checked + span,
    .dc-type input:checked + span,
    .dr-go,
    .dr-file-badge,
    .dr-fmt-csv,
    .dr-bibtex,
    .dm-hero,
    .dv-code,
    .eg-card-media,
    .eg-step,
    .ev-pages [aria-current="page"],
    .ev-recording,
    .ev-monogram,
    .xi-hero,
    .xi-active-chip,
    .xc-tip,
    .fc-board-band,
    .fc-count,
    .gl-go,
    .gl-card-media,
    .gl-card-blank,
    .gx-hero,
    .gx-go,
    .gx-cats a[aria-current],
    .gx-thumbs a,
    .gx-card-guide span,
    .h-lead-media,
    .h-date,
    .h-pk,
    .h-expert-photo,
    .h-expert-photo:has(.h-initials),
    .hg-pin-photo,
    .hb-quick,
    .hb-quick a,
    .hb-signup,
    .hb-cta,
    .hb .hd-feature,
    .im-brief-cta,
    .im-panel,
    .ip-bar,
    .dash-head.hero-has-banner,
    .jr-hero,
    .jr-cover-blank,
    .jr-step-num,
    .jrx-tabs a[aria-current="page"],
    .jrx-file-kind,
    .lg-hero,
    .lp-monogram,
    .lp-to-opt input:checked + span,
    .md-btn,
    .md-art-tile,
    .md-player,
    .md-go,
    .md-video-card-thumb,
    .md-related-thumb,
    .md-thumb-ph,
    .md-embed-load,
    .md-embed-frame,
    .nl-issue-hero,
    .nr-fp.is-js .nr-fp-name,
    .nr-go,
    .nr-copy.is-copied,
    .nr-cta,
    .nr-aud,
    .nr-aud-pk-parliament,
    .nr-aud-ministry,
    .nr-press,
    .op-hero,
    .pp-hero,
    .pp-card-photo,
    .pp-monogram,
    .pp-portrait-img,
    .pp-expert-photo,
    .pv-hero,
    .pv-plate-link,
    .pl-hero,
    .pl-item-cover,
    .pl-featured-cover,
    .pl-head-cover,
    .pl-page-num[aria-current],
    .rd-toast,
    .ri-stage,
    .ri-wf-bar,
    .sn-avatar,
    .sr-hero,
    .sr-page-num[aria-current],
    .utility-bar,
    .site-header,
    .nav-menu-panel,
    .main-nav,
    .hero,
    .page-hero,
    .section-ink,
    .bio-portrait,
    .team-card-photo,
    .site-footer,
    .page-banner,
    .sp-step-n,
    .st-hero,
    .st-chips a[aria-current],
    .st-month-h span,
    .tk-chip[aria-pressed="true"],
    .tk-chip[aria-current="page"],
    .tk-track-link,
    .tk-tl-year span,
    .tr-tip
),
:root[data-reading="on"] body:has(article.article, article.pl-article, article.xp, article.nr-article, article.jr-article, article.ip-article, article.nl-issue-body, .nl-letter, .la-read, .la) :is(
  .ag-hero,
    .ag-text,
    .ag-close,
    .cr-type.is-honorary,
    .cr-chip[aria-current],
    .cr-progress a[aria-current] .cr-progress-num,
    .cr-pill input:checked + span,
    .dc-type input:checked + span,
    .dr-go,
    .dr-file-badge,
    .dr-fmt-csv,
    .dr-bibtex,
    .dm-hero,
    .dv-code,
    .eg-card-media,
    .eg-step,
    .ev-pages [aria-current="page"],
    .ev-recording,
    .ev-monogram,
    .xi-hero,
    .xi-active-chip,
    .xc-tip,
    .fc-board-band,
    .fc-count,
    .gl-go,
    .gl-card-media,
    .gl-card-blank,
    .gx-hero,
    .gx-go,
    .gx-cats a[aria-current],
    .gx-thumbs a,
    .gx-card-guide span,
    .h-lead-media,
    .h-date,
    .h-pk,
    .h-expert-photo,
    .h-expert-photo:has(.h-initials),
    .hg-pin-photo,
    .hb-quick,
    .hb-quick a,
    .hb-signup,
    .hb-cta,
    .hb .hd-feature,
    .im-brief-cta,
    .im-panel,
    .ip-bar,
    .dash-head.hero-has-banner,
    .jr-hero,
    .jr-cover-blank,
    .jr-step-num,
    .jrx-tabs a[aria-current="page"],
    .jrx-file-kind,
    .lg-hero,
    .lp-monogram,
    .lp-to-opt input:checked + span,
    .md-btn,
    .md-art-tile,
    .md-player,
    .md-go,
    .md-video-card-thumb,
    .md-related-thumb,
    .md-thumb-ph,
    .md-embed-load,
    .md-embed-frame,
    .nl-issue-hero,
    .nr-fp.is-js .nr-fp-name,
    .nr-go,
    .nr-copy.is-copied,
    .nr-cta,
    .nr-aud,
    .nr-aud-pk-parliament,
    .nr-aud-ministry,
    .nr-press,
    .op-hero,
    .pp-hero,
    .pp-card-photo,
    .pp-monogram,
    .pp-portrait-img,
    .pp-expert-photo,
    .pv-hero,
    .pv-plate-link,
    .pl-hero,
    .pl-item-cover,
    .pl-featured-cover,
    .pl-head-cover,
    .pl-page-num[aria-current],
    .rd-toast,
    .ri-stage,
    .ri-wf-bar,
    .sn-avatar,
    .sr-hero,
    .sr-page-num[aria-current],
    .utility-bar,
    .site-header,
    .nav-menu-panel,
    .main-nav,
    .hero,
    .page-hero,
    .section-ink,
    .bio-portrait,
    .team-card-photo,
    .site-footer,
    .page-banner,
    .sp-step-n,
    .st-hero,
    .st-chips a[aria-current],
    .st-month-h span,
    .tk-chip[aria-pressed="true"],
    .tk-chip[aria-current="page"],
    .tk-track-link,
    .tk-tl-year span,
    .tr-tip
) {
  --ink: #2A1B45;
  --ink-2: #3D2860;
  --ink-deep: #081426;
  --mist: #F4F2F7;
  --paper: #FFFFFF;
  --accent: #6E42A6;
  --accent-dark: #5A3689;
  --accent-soft: #C9B8DE;
  --pine: #4A2F73;
  --danger: #8B3A3A;
  --text: #1C1C19;
  --muted: #5D5B54;
  --line: #E4E1EA;
  --line-dark: #4A3359;
  --accent-text: #6E42A6;
  --accent-soft-text: #C9B8DE;
  --tint: #F4F2F7;
}

/* --------------------------------------------- Dark: feature stylesheets
   Gathered from the public stylesheets (October 2026): text set in the
   accent or the soft accent gets a lighter accent that reads on plum; white
   and pale-tinted surfaces become dark paper; pale hairlines become the
   dark line colour. Elements whose rule sets its own dark text colour are
   left alone (self-contained paper designs). Hand fixes follow. */
/* accent text */
:root[data-theme="dark"] :is(
  .ab-step-n,
  .ab-step-link,
  .ab-standard dt span,
  .cu-cite-n,
  .fa-follow-btn svg,
  .cr-card-facts .eg-icon,
  .cr-num,
  .cr-step-num,
  .cr-skip .eg-icon,
  .cg-empty-icon,
  .ic-empty-icon,
  .eg-closing .eg-icon,
  .eg-req,
  .eg-way-num,
  .eg-tier li .eg-icon,
  .ev-meta .ev-icon,
  .ev-empty > .ev-icon,
  .ev-cal-btn .ev-icon,
  .ev-proc-year span,
  .xi-read:hover,
  .xi-num,
  a.xp-src-title .xp-i,
  .xc-csv:hover,
  .gl-facts .gl-i,
  .gx-more,
  .gx-marks a,
  .hb-more:hover,
  .int-empty-card .int-icon,
  .jr-link:hover,
  .jr-policy-num,
  .lg-finalising svg,
  .lg-more svg,
  .ob-soon-icon,
  .pp-sky-tip em,
  .pp-sky-tip a,
  .pp-facts svg,
  .pp-links a svg:first-child,
  .pl-featured-label,
  .rd-title .rd-icon,
  .rr-toc-num,
  .rr-num,
  .rr-side b,
  .sn-step-num,
  .sn-tips .eg-icon,
  .sn-member-place .eg-icon,
  .tk-dl svg,
  .tr-empty-icon
),
:root[data-reading="on"] body:has(article.article, article.pl-article, article.xp, article.nr-article, article.jr-article, article.ip-article, article.nl-issue-body, .nl-letter, .la-read, .la) :is(
  .ab-step-n,
  .ab-step-link,
  .ab-standard dt span,
  .cu-cite-n,
  .fa-follow-btn svg,
  .cr-card-facts .eg-icon,
  .cr-num,
  .cr-step-num,
  .cr-skip .eg-icon,
  .cg-empty-icon,
  .ic-empty-icon,
  .eg-closing .eg-icon,
  .eg-req,
  .eg-way-num,
  .eg-tier li .eg-icon,
  .ev-meta .ev-icon,
  .ev-empty > .ev-icon,
  .ev-cal-btn .ev-icon,
  .ev-proc-year span,
  .xi-read:hover,
  .xi-num,
  a.xp-src-title .xp-i,
  .xc-csv:hover,
  .gl-facts .gl-i,
  .gx-more,
  .gx-marks a,
  .hb-more:hover,
  .int-empty-card .int-icon,
  .jr-link:hover,
  .jr-policy-num,
  .lg-finalising svg,
  .lg-more svg,
  .ob-soon-icon,
  .pp-sky-tip em,
  .pp-sky-tip a,
  .pp-facts svg,
  .pp-links a svg:first-child,
  .pl-featured-label,
  .rd-title .rd-icon,
  .rr-toc-num,
  .rr-num,
  .rr-side b,
  .sn-step-num,
  .sn-tips .eg-icon,
  .sn-member-place .eg-icon,
  .tk-dl svg,
  .tr-empty-icon
) { color: var(--accent-text); }
:root[data-theme="dark"] .cr-pills.is-multi .cr-pill input:checked + span::before, :root[data-reading="on"] body:has(article.article, article.pl-article, article.xp, article.nr-article, article.jr-article, article.ip-article, article.nl-issue-body, .nl-letter, .la-read, .la) .cr-pills.is-multi .cr-pill input:checked + span::before { color: var(--accent-text); }
:root[data-theme="dark"] .dm-item::after, :root[data-reading="on"] body:has(article.article, article.pl-article, article.xp, article.nr-article, article.jr-article, article.ip-article, article.nl-issue-body, .nl-letter, .la-read, .la) .dm-item::after { color: var(--accent-text); }
:root[data-theme="dark"] .eg-faq summary::after, :root[data-reading="on"] body:has(article.article, article.pl-article, article.xp, article.nr-article, article.jr-article, article.ip-article, article.nl-issue-body, .nl-letter, .la-read, .la) .eg-faq summary::after { color: var(--accent-text); }
:root[data-theme="dark"] .xp-prose li::marker, :root[data-reading="on"] body:has(article.article, article.pl-article, article.xp, article.nr-article, article.jr-article, article.ip-article, article.nl-issue-body, .nl-letter, .la-read, .la) .xp-prose li::marker { color: var(--accent-text); }
:root[data-theme="dark"] .xp-sources li::before, :root[data-reading="on"] body:has(article.article, article.pl-article, article.xp, article.nr-article, article.jr-article, article.ip-article, article.nl-issue-body, .nl-letter, .la-read, .la) .xp-sources li::before { color: var(--accent-text); }
:root[data-theme="dark"] .jr-prose li::marker, :root[data-reading="on"] body:has(article.article, article.pl-article, article.xp, article.nr-article, article.jr-article, article.ip-article, article.nl-issue-body, .nl-letter, .la-read, .la) .jr-prose li::marker { color: var(--accent-text); }
:root[data-theme="dark"] .md-prose li::marker, :root[data-reading="on"] body:has(article.article, article.pl-article, article.xp, article.nr-article, article.jr-article, article.ip-article, article.nl-issue-body, .nl-letter, .la-read, .la) .md-prose li::marker { color: var(--accent-text); }
:root[data-theme="dark"] .nl-benefits li::before, :root[data-reading="on"] body:has(article.article, article.pl-article, article.xp, article.nr-article, article.jr-article, article.ip-article, article.nl-issue-body, .nl-letter, .la-read, .la) .nl-benefits li::before { color: var(--accent-text); }
:root[data-theme="dark"] .nl-topics-more summary::marker, :root[data-reading="on"] body:has(article.article, article.pl-article, article.xp, article.nr-article, article.jr-article, article.ip-article, article.nl-issue-body, .nl-letter, .la-read, .la) .nl-topics-more summary::marker { color: var(--accent-text); }
:root[data-theme="dark"] .nr-prose li::marker, :root[data-reading="on"] body:has(article.article, article.pl-article, article.xp, article.nr-article, article.jr-article, article.ip-article, article.nl-issue-body, .nl-letter, .la-read, .la) .nr-prose li::marker { color: var(--accent-text); }
:root[data-theme="dark"] .nb-booklet > .eg-block:not(.eg-apply) > h2::before, :root[data-reading="on"] body:has(article.article, article.pl-article, article.xp, article.nr-article, article.jr-article, article.ip-article, article.nl-issue-body, .nl-letter, .la-read, .la) .nb-booklet > .eg-block:not(.eg-apply) > h2::before { color: var(--accent-text); }
:root[data-theme="dark"] .nb-booklet #sn-standards + .prose li::before, :root[data-reading="on"] body:has(article.article, article.pl-article, article.xp, article.nr-article, article.jr-article, article.ip-article, article.nl-issue-body, .nl-letter, .la-read, .la) .nb-booklet #sn-standards + .prose li::before { color: var(--accent-text); }
:root[data-theme="dark"] .pp-biblio li::before, :root[data-reading="on"] body:has(article.article, article.pl-article, article.xp, article.nr-article, article.jr-article, article.ip-article, article.nl-issue-body, .nl-letter, .la-read, .la) .pp-biblio li::before { color: var(--accent-text); }
:root[data-theme="dark"] .pl-takeaways li::before, :root[data-reading="on"] body:has(article.article, article.pl-article, article.xp, article.nr-article, article.jr-article, article.ip-article, article.nl-issue-body, .nl-letter, .la-read, .la) .pl-takeaways li::before { color: var(--accent-text); }
:root[data-theme="dark"] .rr-notes li::marker, :root[data-reading="on"] body:has(article.article, article.pl-article, article.xp, article.nr-article, article.jr-article, article.ip-article, article.nl-issue-body, .nl-letter, .la-read, .la) .rr-notes li::marker { color: var(--accent-text); }
:root[data-theme="dark"] th[aria-sort="ascending"] .tk-sort-btn::after, :root[data-reading="on"] body:has(article.article, article.pl-article, article.xp, article.nr-article, article.jr-article, article.ip-article, article.nl-issue-body, .nl-letter, .la-read, .la) th[aria-sort="ascending"] .tk-sort-btn::after { color: var(--accent-text); }
:root[data-theme="dark"] th[aria-sort="descending"] .tk-sort-btn::after, :root[data-reading="on"] body:has(article.article, article.pl-article, article.xp, article.nr-article, article.jr-article, article.ip-article, article.nl-issue-body, .nl-letter, .la-read, .la) th[aria-sort="descending"] .tk-sort-btn::after { color: var(--accent-text); }
/* accent-soft text */
:root[data-theme="dark"] :is(
  .ic-thumb-blank,
  .ic-sep,
  .eg-hero .eg-pill.is-soon,
  .eg-empty-mark,
  .ev-facts .ev-icon,
  .ev-localtime,
  .ev-monogram,
  .xi-kicker,
  .xi-featured-mark,
  .xi-empty-mark,
  .fc-back,
  .gl-dot,
  .gl-kicker-sep,
  .gx-cats a[aria-current] .gx-n,
  .h-ticker-label,
  .hs-band .dateline,
  .h-map-actions .h-more,
  .h-map-band .dateline,
  .h-issue-list a:hover,
  .h-more-light,
  .h-q,
  .h-date-m,
  .h-pk-kicker,
  .h-region:hover .h-region-count,
  .h-initials,
  .hd-band .dateline,
  .hc-title em,
  .hb-quick-h,
  .hd-feature .hb-kicker,
  .hd-feature .hd-tally,
  .dash-head.hero-has-banner .ip-tag,
  .jr-hero .jr-kicker,
  .md-dot,
  .md-kicker-sep,
  .md-art-wave,
  .nl-eyebrow,
  .nl-issue-hero .dateline,
  .nr-kicker-sep,
  .nr-press li .nr-i,
  .pp-hero .dateline,
  .pp-hero-facts a,
  .pp-press-box h2,
  .pp-press-box li,
  .pp-monogram,
  .pv-hero .pv-kicker,
  .pv-list-group,
  .pv-badge,
  .pl-crumbs-on-ink a,
  .pl-hero .dateline,
  .sr-hero .dateline,
  .sp-hero-box li svg,
  .sp-crumbs a,
  .tk-track-link-label
),
:root[data-reading="on"] body:has(article.article, article.pl-article, article.xp, article.nr-article, article.jr-article, article.ip-article, article.nl-issue-body, .nl-letter, .la-read, .la) :is(
  .ic-thumb-blank,
  .ic-sep,
  .eg-hero .eg-pill.is-soon,
  .eg-empty-mark,
  .ev-facts .ev-icon,
  .ev-localtime,
  .ev-monogram,
  .xi-kicker,
  .xi-featured-mark,
  .xi-empty-mark,
  .fc-back,
  .gl-dot,
  .gl-kicker-sep,
  .gx-cats a[aria-current] .gx-n,
  .h-ticker-label,
  .hs-band .dateline,
  .h-map-actions .h-more,
  .h-map-band .dateline,
  .h-issue-list a:hover,
  .h-more-light,
  .h-q,
  .h-date-m,
  .h-pk-kicker,
  .h-region:hover .h-region-count,
  .h-initials,
  .hd-band .dateline,
  .hc-title em,
  .hb-quick-h,
  .hd-feature .hb-kicker,
  .hd-feature .hd-tally,
  .dash-head.hero-has-banner .ip-tag,
  .jr-hero .jr-kicker,
  .md-dot,
  .md-kicker-sep,
  .md-art-wave,
  .nl-eyebrow,
  .nl-issue-hero .dateline,
  .nr-kicker-sep,
  .nr-press li .nr-i,
  .pp-hero .dateline,
  .pp-hero-facts a,
  .pp-press-box h2,
  .pp-press-box li,
  .pp-monogram,
  .pv-hero .pv-kicker,
  .pv-list-group,
  .pv-badge,
  .pl-crumbs-on-ink a,
  .pl-hero .dateline,
  .sr-hero .dateline,
  .sp-hero-box li svg,
  .sp-crumbs a,
  .tk-track-link-label
) { color: var(--accent-soft-text); }
:root[data-theme="dark"] .ic-crumbs li + li::before, :root[data-reading="on"] body:has(article.article, article.pl-article, article.xp, article.nr-article, article.jr-article, article.ip-article, article.nl-issue-body, .nl-letter, .la-read, .la) .ic-crumbs li + li::before { color: var(--accent-soft-text); }
:root[data-theme="dark"] .ic-date::before, :root[data-reading="on"] body:has(article.article, article.pl-article, article.xp, article.nr-article, article.jr-article, article.ip-article, article.nl-issue-body, .nl-letter, .la-read, .la) .ic-date::before { color: var(--accent-soft-text); }
:root[data-theme="dark"] .dr-item-meta li:not(:last-child)::after, :root[data-reading="on"] body:has(article.article, article.pl-article, article.xp, article.nr-article, article.jr-article, article.ip-article, article.nl-issue-body, .nl-letter, .la-read, .la) .dr-item-meta li:not(:last-child)::after { color: var(--accent-soft-text); }
:root[data-theme="dark"] .xp-crumbs li + li::before, :root[data-reading="on"] body:has(article.article, article.pl-article, article.xp, article.nr-article, article.jr-article, article.ip-article, article.nl-issue-body, .nl-letter, .la-read, .la) .xp-crumbs li + li::before { color: var(--accent-soft-text); }
:root[data-theme="dark"] .nr-crumbs li + li::before, :root[data-reading="on"] body:has(article.article, article.pl-article, article.xp, article.nr-article, article.jr-article, article.ip-article, article.nl-issue-body, .nl-letter, .la-read, .la) .nr-crumbs li + li::before { color: var(--accent-soft-text); }
:root[data-theme="dark"] .pp-crumbs li + li::before, :root[data-reading="on"] body:has(article.article, article.pl-article, article.xp, article.nr-article, article.jr-article, article.ip-article, article.nl-issue-body, .nl-letter, .la-read, .la) .pp-crumbs li + li::before { color: var(--accent-soft-text); }
:root[data-theme="dark"] .pl-crumbs li + li::before, :root[data-reading="on"] body:has(article.article, article.pl-article, article.xp, article.nr-article, article.jr-article, article.ip-article, article.nl-issue-body, .nl-letter, .la-read, .la) .pl-crumbs li + li::before { color: var(--accent-soft-text); }
/* white surfaces */
:root[data-theme="dark"] :is(
  .ab-office,
  .ab-standards,
  .cg-items .cg-item .cg-id,
  .cg-item.is-featured .cg-id,
  .eg-pill.is-ongoing,
  .eg-pill.is-closed,
  .evx-form input[type=datetime-local],
  .xi-search,
  .xi-select,
  .gx-search input:focus,
  .hx-docs li,
  .hc-form select,
  .hc-pick select,
  .hc-pick .hc-go:hover,
  .hc-side,
  .hb-hero,
  .hb-tally a,
  .hb-cal,
  .hb-person a,
  .hb-picks > li,
  .hb-empty,
  .hb-btn-light,
  .hb-world,
  .hd-jump a,
  .hd-card a,
  .im-replay-range::-moz-range-thumb,
  .im-brand img,
  .im-check input:checked + .im-box,
  .im-js .im-sheet-count,
  .dash-search input,
  .dash-facet summary,
  .dash-facet-pop,
  .ia-country-list,
  .lp-plug:hover,
  .lp-plug:focus-visible,
  .md-embed-play,
  .nr-pk-logos img,
  .nr-pk-logos .nr-logo-dl:hover,
  .nr-clipboard .nr-mention,
  .nr-clipboard .nr-mention:first-child,
  .nr-logo-art,
  .nb-board :is(.nb-note, .cr-card),
  .nb-board.is-empty > .eg-empty,
  .nb-booklet > .eg-block:not(.eg-apply),
  .s-end,
  .ppa-check,
  .pv-deck-btn,
  .pv-card,
  .pv-key-capital,
  .pv-table-wrap,
  .pv-btn,
  .pv-uhero,
  .pv-notice,
  .pv-fig,
  .pv-side-card,
  .rd-keys kbd,
  .rd-checkpill,
  .rr-slip .pl-copy,
  .sg-card a,
  .sr-cards .sr-item,
  .sr-cards .sr-item:first-child
),
:root[data-reading="on"] body:has(article.article, article.pl-article, article.xp, article.nr-article, article.jr-article, article.ip-article, article.nl-issue-body, .nl-letter, .la-read, .la) :is(
  .ab-office,
  .ab-standards,
  .cg-items .cg-item .cg-id,
  .cg-item.is-featured .cg-id,
  .eg-pill.is-ongoing,
  .eg-pill.is-closed,
  .evx-form input[type=datetime-local],
  .xi-search,
  .xi-select,
  .gx-search input:focus,
  .hx-docs li,
  .hc-form select,
  .hc-pick select,
  .hc-pick .hc-go:hover,
  .hc-side,
  .hb-hero,
  .hb-tally a,
  .hb-cal,
  .hb-person a,
  .hb-picks > li,
  .hb-empty,
  .hb-btn-light,
  .hb-world,
  .hd-jump a,
  .hd-card a,
  .im-replay-range::-moz-range-thumb,
  .im-brand img,
  .im-check input:checked + .im-box,
  .im-js .im-sheet-count,
  .dash-search input,
  .dash-facet summary,
  .dash-facet-pop,
  .ia-country-list,
  .lp-plug:hover,
  .lp-plug:focus-visible,
  .md-embed-play,
  .nr-pk-logos img,
  .nr-pk-logos .nr-logo-dl:hover,
  .nr-clipboard .nr-mention,
  .nr-clipboard .nr-mention:first-child,
  .nr-logo-art,
  .nb-board :is(.nb-note, .cr-card),
  .nb-board.is-empty > .eg-empty,
  .nb-booklet > .eg-block:not(.eg-apply),
  .s-end,
  .ppa-check,
  .pv-deck-btn,
  .pv-card,
  .pv-key-capital,
  .pv-table-wrap,
  .pv-btn,
  .pv-uhero,
  .pv-notice,
  .pv-fig,
  .pv-side-card,
  .rd-keys kbd,
  .rd-checkpill,
  .rr-slip .pl-copy,
  .sg-card a,
  .sr-cards .sr-item,
  .sr-cards .sr-item:first-child
) { background-color: var(--paper); }
:root[data-theme="dark"] .cs-sheet::before, :root[data-reading="on"] body:has(article.article, article.pl-article, article.xp, article.nr-article, article.jr-article, article.ip-article, article.nl-issue-body, .nl-letter, .la-read, .la) .cs-sheet::before { background-color: var(--paper); }
:root[data-theme="dark"] .eg-pill.is-open::before, :root[data-reading="on"] body:has(article.article, article.pl-article, article.xp, article.nr-article, article.jr-article, article.ip-article, article.nl-issue-body, .nl-letter, .la-read, .la) .eg-pill.is-open::before { background-color: var(--paper); }
:root[data-theme="dark"] .tr-lanes-key::after, :root[data-reading="on"] body:has(article.article, article.pl-article, article.xp, article.nr-article, article.jr-article, article.ip-article, article.nl-issue-body, .nl-letter, .la-read, .la) .tr-lanes-key::after { background-color: var(--paper); }
/* tinted surfaces */
:root[data-theme="dark"] :is(
  .dc-panel,
  .cj-empty,
  .fa-follow-btn:hover,
  .fa-chip input:checked + span,
  .cr-type.is-internship,
  .cr-pay,
  .cr-skip,
  .cr-pills.is-multi .cr-pill input:checked + span,
  .cr-errors,
  .cgm-face,
  .du-list a,
  .dr-table tbody tr:nth-child(even) td,
  .eg-pill.is-soon,
  .eg-file-again,
  .contact-form.eg-form .eg-type:has(input:checked),
  .egx-pill.is-closed,
  .egx-pill.is-withdrawn,
  .egx-pill.is-done,
  .ev-pb-backcover,
  .ev-pill.is-alert,
  .ev-past-note,
  .ev-form .ev-radio:has(input:checked),
  .ev-confirm,
  .ev-confirm.is-waitlist,
  .ev-cal-btn:hover,
  .ev-booklet-plate,
  .evx-status-cancelled,
  .xp-cite-box,
  .xp-whatis,
  .fc-time,
  .gl-preview,
  .glc.is-above .glc-arrow,
  .gw-card,
  .gx-thumbs .is-off,
  .h-week,
  .hx-tab[aria-selected="true"],
  .hc,
  .hb-pakistan .hb-why,
  .hd-feature-map,
  .int-callout,
  .int-channel.is-off,
  .int-reveal,
  .im-brief > .ids-stamp,
  .ip-figure img,
  .ip-mini,
  .dash-check:hover,
  .dash-table tbody tr:hover,
  .jr-error-summary,
  .jr-confirm,
  .jr-pill,
  .jr-pill.is-rejected,
  .jr-pill.is-withdrawn,
  .jrx-pill.is-withdrawn,
  .jrx-rev-status.is-declined,
  .lp-card,
  .md-preview,
  .md-turn.is-current,
  mark.md-hit,
  .mda-info,
  .nl-chip input:checked + span,
  .nl-status,
  .nl-done,
  .nl-done.is-warn,
  .nl-status-icon,
  .nl-env-card,
  .nr-wb-row[data-kind="release"] .nr-wb-lamp,
  .nr-wire-slug,
  .nr-panel:has(.nr-clipboard),
  .nr-clipboard-full,
  .nr-preview,
  .nb-board :is(.nb-note, .cr-card):nth-child(3n + 2),
  .nb-board :is(.nb-note, .cr-card):nth-child(3n + 3),
  .ob-soon-icon,
  .pp-sky-dot.is-staff,
  .pp-sky-swatch.is-staff,
  .pp-sky-tip,
  .ppa-check:has(input:checked),
  .pv-fc-dot,
  .pv-table thead th,
  .pv-mapnotes,
  .pv-status-note,
  .pv-sources li:target,
  .pv-cite,
  .pv-side-list a:hover,
  .pv-cover-img,
  .pv-place-img,
  .pv-plate-capital .pv-key-capital,
  .pa-meter span,
  mark,
  .rd-item:hover,
  .rd-item:focus,
  .rd-item.is-current,
  .rd-score,
  .rd-badge-dismissed,
  .rd-sources tr.is-off td,
  .rd-health-badge.is-off,
  .rr-exec,
  .rr-notes li:target,
  .rx-fig--cover,
  .sx-table tr:target,
  .contact-form.eg-form .sn-check:has(input:checked),
  .contact-form.eg-form .sn-stage:has(input:checked),
  .sn-chips li,
  .snx-listed,
  .sn-drawer .sn-member,
  .ss-title mark,
  .sr-item mark,
  .sr-snippet mark,
  .sr-tab-count,
  .sr-tab.is-empty .sr-tab-count,
  .sr-badge,
  .sr-badge-page,
  .sr-drawer-card,
  .sp-chosen,
  .tk-dl:hover,
  .tk-table thead th,
  .tk-table tbody tr:hover
),
:root[data-reading="on"] body:has(article.article, article.pl-article, article.xp, article.nr-article, article.jr-article, article.ip-article, article.nl-issue-body, .nl-letter, .la-read, .la) :is(
  .dc-panel,
  .cj-empty,
  .fa-follow-btn:hover,
  .fa-chip input:checked + span,
  .cr-type.is-internship,
  .cr-pay,
  .cr-skip,
  .cr-pills.is-multi .cr-pill input:checked + span,
  .cr-errors,
  .cgm-face,
  .du-list a,
  .dr-table tbody tr:nth-child(even) td,
  .eg-pill.is-soon,
  .eg-file-again,
  .contact-form.eg-form .eg-type:has(input:checked),
  .egx-pill.is-closed,
  .egx-pill.is-withdrawn,
  .egx-pill.is-done,
  .ev-pb-backcover,
  .ev-pill.is-alert,
  .ev-past-note,
  .ev-form .ev-radio:has(input:checked),
  .ev-confirm,
  .ev-confirm.is-waitlist,
  .ev-cal-btn:hover,
  .ev-booklet-plate,
  .evx-status-cancelled,
  .xp-cite-box,
  .xp-whatis,
  .fc-time,
  .gl-preview,
  .glc.is-above .glc-arrow,
  .gw-card,
  .gx-thumbs .is-off,
  .h-week,
  .hx-tab[aria-selected="true"],
  .hc,
  .hb-pakistan .hb-why,
  .hd-feature-map,
  .int-callout,
  .int-channel.is-off,
  .int-reveal,
  .im-brief > .ids-stamp,
  .ip-figure img,
  .ip-mini,
  .dash-check:hover,
  .dash-table tbody tr:hover,
  .jr-error-summary,
  .jr-confirm,
  .jr-pill,
  .jr-pill.is-rejected,
  .jr-pill.is-withdrawn,
  .jrx-pill.is-withdrawn,
  .jrx-rev-status.is-declined,
  .lp-card,
  .md-preview,
  .md-turn.is-current,
  mark.md-hit,
  .mda-info,
  .nl-chip input:checked + span,
  .nl-status,
  .nl-done,
  .nl-done.is-warn,
  .nl-status-icon,
  .nl-env-card,
  .nr-wb-row[data-kind="release"] .nr-wb-lamp,
  .nr-wire-slug,
  .nr-panel:has(.nr-clipboard),
  .nr-clipboard-full,
  .nr-preview,
  .nb-board :is(.nb-note, .cr-card):nth-child(3n + 2),
  .nb-board :is(.nb-note, .cr-card):nth-child(3n + 3),
  .ob-soon-icon,
  .pp-sky-dot.is-staff,
  .pp-sky-swatch.is-staff,
  .pp-sky-tip,
  .ppa-check:has(input:checked),
  .pv-fc-dot,
  .pv-table thead th,
  .pv-mapnotes,
  .pv-status-note,
  .pv-sources li:target,
  .pv-cite,
  .pv-side-list a:hover,
  .pv-cover-img,
  .pv-place-img,
  .pv-plate-capital .pv-key-capital,
  .pa-meter span,
  mark,
  .rd-item:hover,
  .rd-item:focus,
  .rd-item.is-current,
  .rd-score,
  .rd-badge-dismissed,
  .rd-sources tr.is-off td,
  .rd-health-badge.is-off,
  .rr-exec,
  .rr-notes li:target,
  .rx-fig--cover,
  .sx-table tr:target,
  .contact-form.eg-form .sn-check:has(input:checked),
  .contact-form.eg-form .sn-stage:has(input:checked),
  .sn-chips li,
  .snx-listed,
  .sn-drawer .sn-member,
  .ss-title mark,
  .sr-item mark,
  .sr-snippet mark,
  .sr-tab-count,
  .sr-tab.is-empty .sr-tab-count,
  .sr-badge,
  .sr-badge-page,
  .sr-drawer-card,
  .sp-chosen,
  .tk-dl:hover,
  .tk-table thead th,
  .tk-table tbody tr:hover
) { background-color: var(--tint); }
:root[data-theme="dark"] .ev-pb-js .ev-pb-book::before, :root[data-reading="on"] body:has(article.article, article.pl-article, article.xp, article.nr-article, article.jr-article, article.ip-article, article.nl-issue-body, .nl-letter, .la-read, .la) .ev-pb-js .ev-pb-book::before { background-color: var(--tint); }
:root[data-theme="dark"] .nl-tray-box::before, :root[data-reading="on"] body:has(article.article, article.pl-article, article.xp, article.nr-article, article.jr-article, article.ip-article, article.nl-issue-body, .nl-letter, .la-read, .la) .nl-tray-box::before { background-color: var(--tint); }
:root[data-theme="dark"] .nl-letter::before, :root[data-reading="on"] body:has(article.article, article.pl-article, article.xp, article.nr-article, article.jr-article, article.ip-article, article.nl-issue-body, .nl-letter, .la-read, .la) .nl-letter::before { background-color: var(--tint); }
:root[data-theme="dark"] .sx-dossier::before, :root[data-reading="on"] body:has(article.article, article.pl-article, article.xp, article.nr-article, article.jr-article, article.ip-article, article.nl-issue-body, .nl-letter, .la-read, .la) .sx-dossier::before { background-color: var(--tint); }
:root[data-theme="dark"] .sn-drawer .sn-member::before, :root[data-reading="on"] body:has(article.article, article.pl-article, article.xp, article.nr-article, article.jr-article, article.ip-article, article.nl-issue-body, .nl-letter, .la-read, .la) .sn-drawer .sn-member::before { background-color: var(--tint); }
:root[data-theme="dark"] .sr-cards .sr-item::after, :root[data-reading="on"] body:has(article.article, article.pl-article, article.xp, article.nr-article, article.jr-article, article.ip-article, article.nl-issue-body, .nl-letter, .la-read, .la) .sr-cards .sr-item::after { background-color: var(--tint); }
/* pale rules */
:root[data-theme="dark"] :is(
  .aidf-key li,
  .egx-pill.is-reviewing,
  .cgr,
  .cg-items .cg-item,
  .cg-item.is-featured,
  .cg-items .cg-item-foot,
  .cgm-face,
  .cgm-back .cgm-top,
  .cgm-stats,
  .cg-field input,
  .cg-field select,
  .cg-stage,
  .cg-stage-committee,
  .cg-stage-passed_house,
  .cg-stage-passed_senate,
  .cg-stage-passed_both,
  .cg-stage-law,
  .cg-stage-agreed,
  .du-list a,
  .dr-preview-banner,
  .dr-field select,
  .dr-field input,
  .egx-pill.is-open,
  .egx-pill.is-accepted,
  .egx-pill.is-soon,
  .egx-pill.is-received,
  .egx-pill.is-new,
  .egx-pill.is-ongoing,
  .egx-pill.is-shortlisted,
  .egx-pill.is-in_progress,
  .egx-pill.is-interview,
  .egx-pill.is-declined,
  .ev-pb-page,
  .ev-pb-page h4,
  .ev-spread,
  .ev-spread.is-double .ev-page-speakers,
  .xp-preview,
  .badge.xa-needs,
  .xp-whatis,
  .xp-whatis-h,
  .xp-steps,
  .xp-steps-cap,
  .gl-preview,
  .gl-select select,
  .glc.is-above .glc-arrow,
  .gw-card,
  .h-week,
  .h-week-col + .h-week-col,
  .h-week-item,
  .h-week-empty,
  .h-week-note,
  .hb-empty,
  .int-protect.is-strong,
  .int-badge-bad,
  .int-badge-warn,
  .int-kind,
  .int-kind-slack,
  .int-kind-teams,
  .int-kind-discord,
  .ids-say + .ids-say,
  .im-brief-meta,
  .im-search input:focus,
  .im-check:hover .im-box,
  .im-check input:checked + .im-box,
  .im-tt-meta,
  .im-toplinks a:hover,
  .im-zoom-btn:hover,
  .im-zoom-world:hover,
  .im-swatch-dash,
  .dash-facet-pop,
  .jr-search input,
  .jr-search select,
  .jr-field input[type=text],
  .jr-field input[type=email],
  .jr-field select,
  .jr-field textarea,
  .jrx-pill,
  .jrx-pill.is-desk_review,
  .jrx-pill.is-under_review,
  .jrx-pill.is-revisions,
  .jrx-pill.is-revised,
  .jrx-pill.is-accepted,
  .jrx-pill.is-production,
  .jrx-pill.is-published,
  .jrx-pill.is-rejected,
  .lg-preview-bar,
  .lp-letter,
  .lp-card,
  .md-preview,
  .md-btn-ghost,
  .md-inline-filter select,
  .md-select select,
  .md-ep-row-play,
  .md-tr-search,
  .nr-clipboard-full,
  .nr-select select,
  .nr-preview,
  .nr-copy,
  .nb-booklet > .eg-block:not(.eg-apply),
  .nb-booklet > .eg-block:not(.eg-apply) > h2,
  .nb-booklet #sn-standards + .prose li,
  .ob-badge.is-soon,
  .pc-links a:hover,
  .pc-links a:focus-visible,
  .pp-badge,
  .pp-catcard,
  .pv-theme-tab input:checked + span,
  .pv-preview,
  .pv-key-loc,
  .pl-meta-pdf a,
  .pl-copy.is-done,
  .rd-score.is-mid,
  .rd-badge-saved,
  .rd-badge-used,
  .rd-tag.is-topic,
  .rd-tag.is-region,
  .rd-kw.is-blocked,
  .rd-summary .is-error,
  .rd-health-badge.is-ok,
  .rd-health-badge.is-error,
  .rd-health-badge.is-pending,
  .rr-exec .pl-section-title,
  .rr-side,
  .rr-slip,
  .rr-slip-entry + .rr-slip-entry,
  .rr-slip-more .pl-cite-panel,
  .egx-pill.is-under_review,
  .egx-pill.is-considering,
  .egx-pill.is-approved,
  .egx-pill.is-commissioned,
  .egx-pill.is-waitlisted,
  .sn-drawer .sn-member,
  .sg-card a,
  .sr-drawer,
  .sra-terms li,
  .st-log,
  .tk-tone-signed,
  .tk-tone-progress,
  .tk-tone-done,
  .tk-tone-stalled,
  .tk-tone-neutral,
  .tk-tone-none,
  .badge.tka-badge-warn,
  .tk-lg-page,
  .trs-fig
),
:root[data-reading="on"] body:has(article.article, article.pl-article, article.xp, article.nr-article, article.jr-article, article.ip-article, article.nl-issue-body, .nl-letter, .la-read, .la) :is(
  .aidf-key li,
  .egx-pill.is-reviewing,
  .cgr,
  .cg-items .cg-item,
  .cg-item.is-featured,
  .cg-items .cg-item-foot,
  .cgm-face,
  .cgm-back .cgm-top,
  .cgm-stats,
  .cg-field input,
  .cg-field select,
  .cg-stage,
  .cg-stage-committee,
  .cg-stage-passed_house,
  .cg-stage-passed_senate,
  .cg-stage-passed_both,
  .cg-stage-law,
  .cg-stage-agreed,
  .du-list a,
  .dr-preview-banner,
  .dr-field select,
  .dr-field input,
  .egx-pill.is-open,
  .egx-pill.is-accepted,
  .egx-pill.is-soon,
  .egx-pill.is-received,
  .egx-pill.is-new,
  .egx-pill.is-ongoing,
  .egx-pill.is-shortlisted,
  .egx-pill.is-in_progress,
  .egx-pill.is-interview,
  .egx-pill.is-declined,
  .ev-pb-page,
  .ev-pb-page h4,
  .ev-spread,
  .ev-spread.is-double .ev-page-speakers,
  .xp-preview,
  .badge.xa-needs,
  .xp-whatis,
  .xp-whatis-h,
  .xp-steps,
  .xp-steps-cap,
  .gl-preview,
  .gl-select select,
  .glc.is-above .glc-arrow,
  .gw-card,
  .h-week,
  .h-week-col + .h-week-col,
  .h-week-item,
  .h-week-empty,
  .h-week-note,
  .hb-empty,
  .int-protect.is-strong,
  .int-badge-bad,
  .int-badge-warn,
  .int-kind,
  .int-kind-slack,
  .int-kind-teams,
  .int-kind-discord,
  .ids-say + .ids-say,
  .im-brief-meta,
  .im-search input:focus,
  .im-check:hover .im-box,
  .im-check input:checked + .im-box,
  .im-tt-meta,
  .im-toplinks a:hover,
  .im-zoom-btn:hover,
  .im-zoom-world:hover,
  .im-swatch-dash,
  .dash-facet-pop,
  .jr-search input,
  .jr-search select,
  .jr-field input[type=text],
  .jr-field input[type=email],
  .jr-field select,
  .jr-field textarea,
  .jrx-pill,
  .jrx-pill.is-desk_review,
  .jrx-pill.is-under_review,
  .jrx-pill.is-revisions,
  .jrx-pill.is-revised,
  .jrx-pill.is-accepted,
  .jrx-pill.is-production,
  .jrx-pill.is-published,
  .jrx-pill.is-rejected,
  .lg-preview-bar,
  .lp-letter,
  .lp-card,
  .md-preview,
  .md-btn-ghost,
  .md-inline-filter select,
  .md-select select,
  .md-ep-row-play,
  .md-tr-search,
  .nr-clipboard-full,
  .nr-select select,
  .nr-preview,
  .nr-copy,
  .nb-booklet > .eg-block:not(.eg-apply),
  .nb-booklet > .eg-block:not(.eg-apply) > h2,
  .nb-booklet #sn-standards + .prose li,
  .ob-badge.is-soon,
  .pc-links a:hover,
  .pc-links a:focus-visible,
  .pp-badge,
  .pp-catcard,
  .pv-theme-tab input:checked + span,
  .pv-preview,
  .pv-key-loc,
  .pl-meta-pdf a,
  .pl-copy.is-done,
  .rd-score.is-mid,
  .rd-badge-saved,
  .rd-badge-used,
  .rd-tag.is-topic,
  .rd-tag.is-region,
  .rd-kw.is-blocked,
  .rd-summary .is-error,
  .rd-health-badge.is-ok,
  .rd-health-badge.is-error,
  .rd-health-badge.is-pending,
  .rr-exec .pl-section-title,
  .rr-side,
  .rr-slip,
  .rr-slip-entry + .rr-slip-entry,
  .rr-slip-more .pl-cite-panel,
  .egx-pill.is-under_review,
  .egx-pill.is-considering,
  .egx-pill.is-approved,
  .egx-pill.is-commissioned,
  .egx-pill.is-waitlisted,
  .sn-drawer .sn-member,
  .sg-card a,
  .sr-drawer,
  .sra-terms li,
  .st-log,
  .tk-tone-signed,
  .tk-tone-progress,
  .tk-tone-done,
  .tk-tone-stalled,
  .tk-tone-neutral,
  .tk-tone-none,
  .badge.tka-badge-warn,
  .tk-lg-page,
  .trs-fig
) { border-color: var(--line); }
:root[data-theme="dark"] .im-check input:checked + .im-box::after, :root[data-reading="on"] body:has(article.article, article.pl-article, article.xp, article.nr-article, article.jr-article, article.ip-article, article.nl-issue-body, .nl-letter, .la-read, .la) .im-check input:checked + .im-box::after { border-color: var(--line); }

/* --------------------------------------------- Dark: hand fixes
   Each section's own palette (paper, tint, rules, text), then single
   elements found by checking every main page for contrast. */
:root[data-theme="dark"] {
  --ip-paper: #1C1626; --ip-ink: #E4DEEC; --ip-grey: #B3AAC1; --ip-rule: #352B45;
  --dm-paper: #1C1626; --dm-paper-edge: #352B45; --dm-rule: #352B45; --dm-gold-deep: #D9B866;
  --st-paper: #1C1626; --st-rule: #352B45; --st-gold-deep: #D9B866; --st-pk-ink: #B998E6; --st-us-ink: #D9B866;
  --op-glass: #221B2E; --op-rule: #352B45; --op-gold-deep: #D9B866; --op-us-ink: #D9B866; --op-pk-ink: #B998E6;
  --ag-paper: #1C1626; --ag-rule: #352B45; --ag-gold-deep: #D9B866;
  --gx-paper: #1C1626; --gx-paper-edge: #352B45; --gx-rule: #352B45; --gx-gold-deep: #D9B866;
  --xp-tint: #221B2E; --xp-text: #E4DEEC; --xp-rule: #352B45;
}
:root[data-theme="dark"] .pv { --pv-paper: #1C1626; --pv-rule: #352B45; --pv-text: #E4DEEC; --pv-grey: #B3AAC1; }
:root[data-theme="dark"] .hb { --hb-paper: #1C1626; --hb-tint: #221B2E; --hb-rule: #352B45; --hb-text: #E4DEEC; --hb-grey: #B3AAC1; --hb-pak: #8FD3AC; --hb-pak-soft: #17301F; }
:root[data-theme="dark"] .rx { --rx-accent: var(--accent-text); }

/* Buttons that leave their background to the browser get its dark grey. */
:root[data-theme="dark"] :is(.btn-outline, .btn-ghost) { background-color: transparent; }
:root[data-theme="dark"] .btn-outline:hover { background-color: var(--ink); color: var(--mist); }

/* Golds and greens set for cream paper, lifted for plum. */
:root[data-theme="dark"] :is(.h-week-kicker, .xp-entry-l, .xp-whatis-sub, .rr-exec .pl-section-title, .tk-spark-cap span) { color: #D9B866; }
:root[data-theme="dark"] .rx-t-longarc .rx-type { color: #EBA3A3; }
:root[data-theme="dark"] :is(.rx-t-issue, .rx-t-tracker, .rx-t-dataset, .rx-t-dashboard) .rx-type, :root[data-theme="dark"] .tk-live { color: #8FD3AC; }
:root[data-theme="dark"] .h-week-empty { color: var(--muted); }
:root[data-theme="dark"] .h-week-mast { border-bottom-color: #8E7BB0; }
:root[data-theme="dark"] .rr-exec .pl-section-title { border-bottom-color: var(--line); }
:root[data-theme="dark"] :is(.xp-rail a.is-active, .xp-rail a[aria-current="true"]) .xp-rail-n { background: #3D2860; border-color: #8E7BB0; }

:root[data-theme="dark"] :is(.soon-links a, .eg-ways li) { background-color: var(--paper); }
:root[data-theme="dark"] :is(.nr-fp-blank-copy p, .hb-teaser, .hd-intro, .tk-lg-note) { color: var(--muted); }
:root[data-theme="dark"] .sr-drawer-n { color: #CDB78A; }
:root[data-theme="dark"] .sr-badge-explainer { color: #8FD3C0; }
:root[data-theme="dark"] .sr-badge-tracker { color: #A9C2EE; }

/* The publication's title page: dark stock instead of cream. */
:root[data-theme="dark"] .rr-titlepage {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0)) 0 0 / 100% 40%, var(--paper);
  box-shadow: inset 0 -1px 0 var(--line), inset 0 -5px 0 var(--paper), inset 0 -6px 0 var(--line);
}
/* The Long Arc: its broadsheets keep their paper; the desk they lie on goes dark. */
:root[data-theme="dark"] .la { background: #100C16; }
:root[data-theme="dark"] .xp-whatis { background: var(--paper); border-color: var(--line); box-shadow: 0 0 0 4px var(--paper), 0 0 0 5px var(--line); }
:root[data-theme="dark"] .xp-whatis-h { border-bottom-color: var(--line); }

/* Paper objects that keep their paper in the dark (the charter on About,
   the data catalogue drawers, today's front page, the instrument cards): light tokens inside, like the islands. */
:root[data-theme="dark"] :is(.dw-wall, .ab-charter, .la-empty, .nr-fp-sheet, .ob-inst, .ob-soon-card) {
  --ink: #2A1B45; --ink-2: #3D2860; --mist: #F4F2F7; --paper: #FFFFFF; --accent: #6E42A6; --accent-dark: #5A3689;
  --accent-soft: #C9B8DE; --text: #1C1C19; --muted: #5D5B54; --line: #E4E1EA;
  --accent-text: #6E42A6; --accent-soft-text: #C9B8DE; --tint: #F4F2F7;
  color-scheme: light;
}

/* --------------------------------------------- Dark: contrast audit (October 2026)
   Found by tests/dark-contrast.mjs, which measures every visible line of
   text on every public page against the pixels behind it. Three causes:
   1. Paper designs (cards, slips, letters, folders on cream) whose cream
      comes from a gradient, so the generated rules above left the paper
      but their text, set in tokens, went light: they keep their paper and
      get the light tokens back, like the paper objects above.
   2. Surfaces painted in ink (or over a dark banner) whose text uses
      tokens: light-mode islands.
   3. Text set in a fixed dark colour on a surface that goes dark: the
      dark theme's text, muted, gold or accent colours instead. */

/* 1. Paper designs */
:root[data-theme="dark"] :is(.hd-face, .pv-fc-card, .hc-card, .pp-catcard, .tk-lg-page, .lp-letter, .rr-slip, .hx-folder, .hx-tab[aria-selected="true"], .sr-drawer, .nl-coupon) {
  --ink: #2A1B45; --ink-2: #3D2860; --mist: #F4F2F7; --paper: #FFFFFF; --accent: #6E42A6; --accent-dark: #5A3689;
  --accent-soft: #C9B8DE; --text: #1C1C19; --muted: #5D5B54; --line: #E4E1EA;
  --accent-text: #6E42A6; --accent-soft-text: #6A5590; --tint: #F4F2F7; --hx-ink: #2A1B45;
  color-scheme: light; color: var(--text);
}
:root[data-theme="dark"] section.nl-band.nl-coupon p.nl-eyebrow { color: var(--cp-wax); }
:root[data-theme="dark"] .hero-has-banner { --accent-soft: #C9B8DE; }
:root[data-theme="dark"] .ag-b-folder .ag-spine, :root[data-theme="dark"] .f-tile { color: #2A1B45; }

/* 2. Ink surfaces and banner heroes */
:root[data-theme="dark"] :is(.gw-side, .hs-band, .hc-go) {
  --ink: #2A1B45; --ink-2: #3D2860; --mist: #F4F2F7; --paper: #FFFFFF; --accent: #6E42A6; --accent-dark: #5A3689;
  --accent-soft: #C9B8DE; --text: #1C1C19; --muted: #5D5B54; --line: #E4E1EA;
  --accent-text: #6E42A6; --accent-soft-text: #C9B8DE; --tint: #F4F2F7;
}

/* 3. Fixed dark text on surfaces that go dark */
:root[data-theme="dark"] :is(.lp-section, .cs) { background: linear-gradient(180deg, var(--mist), var(--paper) 60%); }
:root[data-theme="dark"] .lp-funds { background: linear-gradient(180deg, var(--paper), var(--mist)); }
:root[data-theme="dark"] .pc-ask { background: linear-gradient(180deg, var(--tint), var(--paper)); }
:root[data-theme="dark"] .jr-main > .jr-cfp { background: linear-gradient(180deg, var(--tint) 0%, var(--paper) 100%); }
:root[data-theme="dark"] .pv-deck { background: linear-gradient(180deg, var(--tint) 0%, var(--pv-paper) 100%); }
:root[data-theme="dark"] .sr-cards .sr-chips a { background: var(--paper); }
:root[data-theme="dark"] .gw-def { color: var(--text); }
:root[data-theme="dark"] .gw-label { color: var(--accent-text); }
:root[data-theme="dark"] .gw-aka { color: var(--muted); }
:root[data-theme="dark"] .gw-aka b { color: var(--ink-2); }
:root[data-theme="dark"] .gw-more { color: var(--accent-dark); }
/* The Issue Map's pages */
:root[data-theme="dark"] :is(.ip-lede p, .ip-prose, .ip-prose blockquote, .ip-update-body, .ip-crumbs a, .ids-say-quote p, .dash-intro, .dash-table thead th) { color: var(--text); }
:root[data-theme="dark"] .ip-meta dt { color: var(--ink); }
:root[data-theme="dark"] :is(.ip-crumbs ol, .ip-figure figcaption, .ip-toc a, .ids-gauge figcaption, .ids-gauge figcaption span, .ids-say-src, .dash-table .col-countries) { color: var(--muted); }
:root[data-theme="dark"] .ids-stamp { mix-blend-mode: normal; opacity: 1; }
:root[data-theme="dark"] :is(.ids-active, .ids-worsening) { --ink-c: #F0A096; }
:root[data-theme="dark"] .ids-watch { --ink-c: #E8BE6A; }
:root[data-theme="dark"] :is(.ids-resolved, .ids-improving) { --ink-c: #8FD3AC; }
:root[data-theme="dark"] .ids-unchanging { --ink-c: #A9C2EE; }
:root[data-theme="dark"] .ids-developing { --ink-c: #C4C7CF; }
/* Region and topic pages */
:root[data-theme="dark"] .hx-dossier { --hx-ink: #EDE7F6; }
:root[data-theme="dark"] .hx-tab { background: linear-gradient(180deg, #3A2E22, #2E2419); border-color: #5A4A30; color: #E6D3AE; }
:root[data-theme="dark"] .hx-tab:hover { color: #fff; }
:root[data-theme="dark"] .hx-tab[aria-selected="true"] { background: #FBF5E6; border-color: #D9C9A6; color: #2A1B45; }
:root[data-theme="dark"] .hx-tab-n { background: rgba(201, 178, 234, 0.16); color: #D9CCEB; }
:root[data-theme="dark"] .hx-tab[aria-selected="true"] .hx-tab-n { background: rgba(110, 66, 166, 0.12); color: #5A3689; }
:root[data-theme="dark"] :is(.hx-dossier .hx-kicker, .hx-eyebrow, .hx-panel-n) { color: #D9B866; }
:root[data-theme="dark"] .hx-folder :is(.hx-eyebrow, .hx-panel-n) { color: #7A5C22; }
:root[data-theme="dark"] :is(.hx-docs .hx-meta, .hx-dossier .hx-meta) { color: var(--muted); }
:root[data-theme="dark"] .hx-folder .hx-meta { color: #5D5B54; }
/* Search */
:root[data-theme="dark"] :is(.sr-snippet, .sr-cards .sr-snippet, .sg-def) { color: var(--text); }
:root[data-theme="dark"] :is(.ss-title mark, .sr-item mark, .sr-snippet mark) { background: #3D2860; }
:root[data-theme="dark"] .sr-badge-issue { color: #F0A096; background: #3A1E1A; }
:root[data-theme="dark"] .sr-drawer .sr-badge-issue { color: #8A3B1F; background: #F8E7DF; }
:root[data-theme="dark"] .sr-drawer .sr-drawer-n { color: #6A5B3E; }
/* Trackers, glossary, defence sales, the newsroom's press kit */
:root[data-theme="dark"] .dm-s-delivered { color: #8FD3AC; }
:root[data-theme="dark"] .gx-pos { color: #D9B866; }
:root[data-theme="dark"] :is(.tk-lg-margin-h, .sr-tab.is-empty, .sr-tab.is-empty .sr-tab-count, .pv-empty) { color: var(--muted); }
/* The Long Arc article page: the broadsheet keeps its paper; the desk goes dark. */
:root[data-theme="dark"] .la-read, :root[data-theme="dark"] .la-read[data-era-style="modern"] { background: #100C16; }
:root[data-theme="dark"] :is(.la-read-crumbs, .la-read-share .share-label) { color: #B3AAC1; }
:root[data-theme="dark"] .la-read-pn a { color: #E4DEEC; }
:root[data-theme="dark"] .la-read-all { border-color: var(--line-dark); }

/* ------------------------------------------------------------- Switches */
.theme-btn {
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 44px; height: 44px; padding: 0;
  color: #fff; background: none; border: 1px solid var(--line-dark); border-radius: var(--radius); cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.theme-btn:hover { background: rgba(255, 255, 255, 0.08); border-color: var(--accent-soft); }
.theme-btn:focus-visible, .theme-switch button:focus-visible, .reading-btn:focus-visible, .nav-theme:focus-visible { outline: 2px solid #E8C877; outline-offset: 2px; }
.theme-btn .theme-sun, .nav-theme .theme-sun, :root[data-theme="dark"] .theme-btn .theme-moon, :root[data-theme="dark"] .nav-theme .theme-moon { display: none; }
:root[data-theme="dark"] .theme-btn .theme-sun, :root[data-theme="dark"] .nav-theme .theme-sun { display: block; color: #E8C877; }
/* Phones: the header keeps search and the menu; dark mode is a row in the drawer. */
@media (max-width: 599px) { .theme-btn { display: none; } }
.nav-theme {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 52px; padding: 0 14px;
  font: 500 0.98rem/1.2 var(--font); color: #fff; text-align: left;
  background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line-dark); border-radius: 6px; cursor: pointer;
}
.nav-theme-label { flex: 1; }
.nav-theme-state { font-size: 0.82rem; color: var(--on-ink-muted); }
.nav-theme:hover { background: rgba(255, 255, 255, 0.08); }

.theme-switch { display: inline-flex; align-items: center; gap: 2px; margin-top: 0.75rem; padding: 3px; border: 1px solid var(--line-dark); border-radius: 999px; font-size: 0.8rem; }
.theme-switch-label { padding: 0 0.5rem 0 0.6rem; color: var(--on-ink-muted); font-variant-caps: all-small-caps; letter-spacing: 0.1em; font-size: 0.86rem; }
.theme-switch button { min-height: 30px; padding: 0.15rem 0.75rem; font: inherit; color: var(--on-ink); background: none; border: 0; border-radius: 999px; cursor: pointer; }
.theme-switch button:hover { color: #fff; background: rgba(255, 255, 255, 0.08); }
.theme-switch button[aria-pressed="true"] { color: var(--ink); background: #E8C877; font-weight: 600; }
.footer-bottom:has(.theme-switch) { flex-wrap: wrap; }
.site-footer .footer-bottom .theme-switch { flex-basis: auto; }

.reading-btn {
  position: fixed; right: 18px; bottom: 18px; z-index: 40;
  display: inline-flex; align-items: center; gap: 0.5rem; min-height: 44px; padding: 0.5rem 1rem 0.5rem 0.85rem;
  font: 600 0.84rem/1 var(--font); letter-spacing: 0.01em; color: #fff; background: #2A1B45;
  border: 1px solid rgba(255, 255, 255, 0.16); border-radius: 999px; cursor: pointer;
  box-shadow: 0 10px 30px -12px rgba(20, 12, 34, 0.55), 0 2px 6px rgba(20, 12, 34, 0.18);
}
.reading-btn:hover { background: #3D2860; }
.reading-btn[aria-pressed="true"] { color: #1D1912; background: #F1E5C8; border-color: rgba(60, 46, 24, 0.4); }
.reading-btn[aria-pressed="true"]:hover { background: #E9DBB8; }
@media (max-width: 600px) { .reading-btn { right: 12px; bottom: 12px; padding: 0.5rem 0.75rem; } }

/* The printout's cover line (theme.js); print.css shows it. */
.pr-cover { display: none; }

/* --------------------------------------------------------- Reading mode
   Aged paper (The Long Arc's 1947-1978 look): yellowed stock with grain,
   ink-black text in Newsreader at reading size, old-style figures, gentle
   justification with hyphens, a drop cap. Heroes and the header keep their
   plum (the islands above). */
:root[data-reading="on"] body:has(article.article, article.pl-article, article.xp, article.nr-article, article.jr-article, article.ip-article, article.nl-issue-body, .nl-letter, .la-read, .la) {
  color-scheme: light;
  --mist: #EBDDBA;
  --paper: #F3E8CD;
  --ink: #1D1912;
  --ink-2: #2C251A;
  --text: #1D1912;
  --muted: #574A33;
  --accent: #7B2D1F;
  --accent-dark: #6E2619;
  --accent-soft: #C9A98A;
  --pine: #4A3A22;
  --line: rgba(60, 46, 24, 0.24);
  --nums-text: oldstyle-nums proportional-nums;
  --accent-text: #7B2D1F;
  --accent-soft-text: #6E5236;
  --tint: #EBDDBA;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .32 0 0 0 0 .24 0 0 0 0 .1 0 0 0 .1 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"),
    linear-gradient(180deg, #F1E5C8, #EBDDBA 900px, #E9DAB5);
  color: var(--text);
}
:root[data-reading="on"] body:has(article.article, article.pl-article, article.xp, article.nr-article, article.jr-article, article.ip-article, article.nl-issue-body, .nl-letter, .la-read, .la) main :is(.section, .section-alt, .pl-body, .xp-layout, .rr-report, .rr-titlepage, .pl-article, .xp, .nr-article, .jr-article, .article, .ip-article) {
  background: transparent;
}
:root[data-reading="on"] body:has(article.pl-article) .rr-titlepage { box-shadow: inset 0 -1px 0 rgba(60, 46, 24, 0.3), inset 0 -5px 0 transparent, inset 0 -6px 0 rgba(60, 46, 24, 0.3); }
/* Undo the dark theme's lifted golds when reading mode is on in the dark. */
:root[data-reading="on"] body:has(article.pl-article, article.xp) :is(.xp-entry-l, .xp-whatis-sub, .rr-exec .pl-section-title) { color: #6E4E1E; }
:root[data-reading="on"] body:has(article.xp) .xp-whatis { background: #F3E8CD; border-color: rgba(60, 46, 24, 0.3); box-shadow: 0 0 0 4px #F3E8CD, 0 0 0 5px rgba(60, 46, 24, 0.3); }
:root[data-reading="on"] body:has(article.xp) .xp-whatis-h { border-bottom-color: rgba(60, 46, 24, 0.3); }
:root[data-reading="on"] body:has(.rx) .rx { --rx-accent: #7B2D1F; }
:root[data-reading="on"] body:has(.rx) .rx-t-longarc .rx-type { color: #7B2D1F; }
:root[data-reading="on"] body:has(.rx) :is(.rx-t-issue, .rx-t-tracker, .rx-t-dataset, .rx-t-dashboard) .rx-type { color: #1F5C4A; }
:root[data-reading="on"] body:has(article.xp) { --xp-tint: #EBDDBA; --xp-text: #1D1912; --xp-rule: rgba(60, 46, 24, 0.24); }
:root[data-reading="on"] :is(.prose, .xp-prose, .nr-prose, .jr-prose, .rr-prose, .pl-abstract, .xp-short-text) {
  font-family: var(--font-serif); font-optical-sizing: auto; font-size: 1.2rem; line-height: 1.72;
  font-variant-numeric: oldstyle-nums proportional-nums; color: #1D1912;
  hyphens: auto; -webkit-hyphens: auto; text-wrap: pretty;
}
:root[data-reading="on"] :is(.prose, .xp-prose, .nr-prose, .jr-prose, .rr-prose) p { font-size: inherit; line-height: inherit; }
@media (min-width: 700px) {
  :root[data-reading="on"] :is(.prose, .xp-prose, .nr-prose, .jr-prose, .rr-prose) p { text-align: justify; }
}
:root[data-reading="on"] :is(.prose, .xp-prose, .nr-prose, .jr-prose, .rr-prose) > p:first-of-type::first-letter {
  float: left; margin: 0.06em 0.09em 0 0; font-size: 3.6em; line-height: 0.82; font-weight: 600; color: #7B2D1F;
}
:root[data-reading="on"] :is(.prose, .xp-prose, .nr-prose, .jr-prose, .rr-prose) :is(h2, h3) {
  font-family: var(--font-serif); color: #1D1912; font-variant-caps: normal;
}
:root[data-reading="on"] :is(.prose, .xp-prose, .nr-prose, .jr-prose, .rr-prose) h2 {
  padding-top: 0.6em; border-top: 2px solid #2C251A; box-shadow: inset 0 1px 0 #F3E8CD, inset 0 3px 0 rgba(60, 46, 24, 0.5);
}
:root[data-reading="on"] :is(.prose, .xp-prose, .nr-prose, .jr-prose, .rr-prose) a { color: #6E2619; text-decoration-color: rgba(110, 38, 25, 0.45); }
:root[data-reading="on"] :is(.prose, .xp-prose, .nr-prose, .jr-prose, .rr-prose) blockquote { border-left-color: #7B2D1F; color: #2C251A; }
:root[data-reading="on"] :is(.prose, .xp-prose, .nr-prose, .jr-prose, .rr-prose) img { filter: sepia(0.25) contrast(1.02); }
@media (prefers-reduced-motion: no-preference) {
  :root[data-reading] body { transition: background-color 0.3s ease; }
}
