.navigation-actions .theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    flex: none;
    min-width: 44px;
    min-height: 44px;
    padding-inline: .6rem;
    border: 1px solid #ffffff80;
    border-radius: 2rem;
    background: #ffffff12;
    color: white;
    font: 600 .88rem/1 'Source Sans', sans-serif;
}
.theme-toggle svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.theme-toggle .theme-sun, [data-theme=dark] .theme-toggle .theme-moon { display: none; }
[data-theme=dark] .theme-toggle .theme-sun { display: inline; }
@media (max-width: 560px), (min-width: 951px) and (max-width: 1450px) {
    .navigation-actions .theme-toggle span { display: none; }
    .navigation-actions { gap: 4px; }
}

html[data-theme=dark] {
    --dusk: #142c36;
    --panel: #233f49;
    --deep: #10252e;
    --cream: #fff7eb;
    --secondary: #c1d3d4;
    --mint: #98e8d7;
    --rose: #ffb6c5;
    --rule: #7a9898;
    background: var(--dusk);
}
html[data-theme=dark] .jfj-home {
    --editorial-red: var(--rose);
    --editorial-meta: var(--secondary);
    color: var(--cream);
    background: var(--dusk);
}
html[data-theme=dark] .jfj-home :is(.masthead,.homepage-footer,.footer-legal,.footer-about,.masthead-brand) {
    color: var(--cream); background: var(--panel);
}
html[data-theme=dark] .jfj-home .brand-logo { filter: brightness(0) invert(96%); }
html[data-theme=dark] .navigation-bar { background: #872842; }
html[data-theme=dark] .jfj-home :is(.nav-panel,.nav-search,.main-navigation.is-open,.share-options) { color: var(--cream); background: var(--deep); }

html[data-theme=dark] #main .front-edition,
html[data-theme=dark] #main .front-edition :is(.front-hero,.front-hero>div,.front-community) { color: var(--cream); background: var(--dusk); }
html[data-theme=dark] #main .front-edition :is(.front-tracker,.front-watch,.front-publication) {
    background-color: var(--panel);
    background-image: radial-gradient(ellipse at bottom right, #436a6c, transparent 60%);
}
html[data-theme=dark] .front-publication::before { opacity: .1; }

html[data-theme=dark] #main :is(.listing-header,.listing-search,.category-lead-text,.listing-empty,
    .reader-toolbar,.reader-audio,.share-options,.story-follow,.person-card,.person-initial,.directory-note,
    .person-profile,.organisation-principles section,.organisation-work-grid section,.contact-details>div,
    .organisation-next,.organisation-document,.map-category-group,.map-database,.contact-tips,
    .report-reader-index,.report-parts section,.article-body blockquote,.article-body figcaption,
    .map-page-grid>a,.sitemap-year-links>a,.topic-shortcuts a,.coverage-navigation a,.reader-more) {
    color: var(--cream); background-color: var(--panel); border-color: var(--rule);
}
html[data-theme=dark] .jfj-home :is(#main,.masthead,.homepage-footer) :is(h1,h2,h3,h4,h5,p,li,label,summary,strong) { color: var(--cream); }
html[data-theme=dark] .jfj-home :is(#main,.masthead,.homepage-footer,.nav-panel) a { color: var(--mint); }
html[data-theme=dark] .jfj-home #main :is(h1,h2,h3,h4) a { color: var(--cream); }
html[data-theme=dark] .jfj-home #main :is(.eyebrow,.article-kicker,.story-label,.story-label a) { color: var(--rose); }
html[data-theme=dark] .jfj-home :is(#main,.masthead,.homepage-footer) :is(time,small,.byline,.reading-time,.reader-status,.article-meta,.brand-tagline) { color: var(--secondary); }
html[data-theme=dark] .jfj-home :is(input,textarea,select,.reader-toolbar button,.reader-toolbar summary,.directory-view a,.page-navigation a) {
    color: var(--cream); background: var(--deep); border-color: var(--rule);
}
html[data-theme=dark] .jfj-home input::placeholder { color: var(--secondary); }
html[data-theme=dark] #main :is(.button,.front-button,.publication-download,.front-tracker button) { background: #902d48; color: white; }
html[data-theme=dark] .jfj-home :focus-visible { outline: 3px solid var(--mint); outline-offset: 2px; }
html[data-theme=dark] .jfj-home .masthead .social-links a,
html[data-theme=dark] .jfj-home .navigation-bar :is(.nav-panel a:hover,.main-navigation>a:hover,.nav-dropdown>summary:hover),
html[data-theme=dark] .jfj-home footer.homepage-footer a:is(:hover,:focus-visible) {
    background: var(--deep); color: var(--mint);
}
html[data-theme=dark] #main :is(.article-embed-consent,.article-lead-image,.category-lead-figure,.investigation-database-entry) {
    background: var(--deep); color: var(--cream);
}
html[data-theme=dark] .jfj-home .masthead :is(.masthead-location,.masthead-mission) { color: var(--secondary); }
html[data-theme=dark] .jfj-home #main .share-options a { background: var(--deep); color: var(--mint); }

/* Keep the keyboard entry point readable against either canvas. */
html[data-theme=dark] .jfj-home .skip { background: var(--cream); color: var(--deep); }
html[data-theme=dark] .masthead-location .text-brand { color: var(--rose); }
html[data-theme=light] .navigation-bar .nav-panel a { color: #184e50; }

/* The tracker and video sections retain their curved lower edge in dusk. */
html[data-theme=dark] #main .front-edition :is(.front-tracker,.front-watch) {
    background-image: linear-gradient(to bottom, #504751, transparent),
        radial-gradient(ellipse 80% 125% at 108% 160%, #476c70 75%, #416368 97%, transparent 100%);
}
html[data-theme=dark] #main .front-edition .front-publication {
    background: var(--panel);
}
html[data-theme=dark] #main .front-publication::before { opacity: .2; }

@media (min-width: 951px) and (max-width: 1100px) {
    .jfj-home .navigation-bar .mobile-menu-button {
        display: flex; align-items: center; gap: .5rem; min-height: 48px;
    }
    .jfj-home .navigation-bar .main-navigation {
        display: none; position: absolute; inset: 100% 0 auto;
        max-height: calc(100dvh - 48px); overflow-y: auto;
        padding: .5rem 5vw; background: #fffdf9; color: #183f42;
    }
    .jfj-home .navigation-bar .main-navigation.is-open { display: block; }
    .jfj-home .main-navigation :is(a,summary) { display: flex; align-items: center; min-height: 44px; color: inherit; }
    .jfj-home .main-navigation .nav-panel { position: static; box-shadow: none; }
    .jfj-home .navigation-actions { margin-left: auto; }
    html[data-theme=dark] .jfj-home .navigation-bar .main-navigation { background: var(--deep); color: var(--cream); }
}

/* Give the publication identity, section title and reading surface distinct depths. */
html[data-theme=dark] .jfj-home .masthead {
    background: linear-gradient(105deg, #12363e, #214b53 64%, #17333f);
}
html[data-theme=dark] .jfj-home .masthead-brand { background: transparent; }
html[data-theme=dark] #main .listing-header {
    background: linear-gradient(110deg, #224750, #203a46 70%);
    border-block-start-color: #de7491;
}
html[data-theme=dark] #main .contact-tips { border-inline-start-color: var(--mint); }
html[data-theme=dark] .jfj-home #main :is(.organisation-navigation,.policy-navigation,.topic-shortcuts,.coverage-navigation) a {
    background: var(--panel);
    border-color: var(--rule);
    color: var(--mint);
    min-height: 44px;
}
html[data-theme=dark] .jfj-home #main :is(.organisation-navigation,.policy-navigation,.topic-shortcuts,.coverage-navigation) a:is(:hover,:focus-visible) {
    background: #315660;
    color: var(--cream);
    text-decoration: underline;
    text-underline-offset: .2em;
}
html[data-theme=dark] .jfj-home #main :is(.organisation-navigation,.policy-navigation,.topic-shortcuts,.coverage-navigation) a[aria-current="page"] {
    background: #823047;
    color: var(--cream);
    border-color: #da8498;
    font-weight: 700;
    box-shadow: inset 0 -3px #f4afbe;
}
