/* Compact, keyboard-accessible light/graphite switch. */
.header-tools{display:flex;align-items:center;gap:2px;flex:none}
.header-tools .icon-button{flex:none}
.theme-toggle{border-radius:50%}
.theme-toggle[hidden]{display:none}
html[data-theme] .theme-toggle[hidden]{display:grid;visibility:hidden}
.theme-toggle:hover{background:var(--surface)}
.theme-icon-sun{display:none}
html[data-theme="dark"] .theme-icon-moon{display:none}
html[data-theme="dark"] .theme-icon-sun{display:block}
.brand{min-width:0}
.brand img{min-width:0;max-width:min(330px,100%)}
@media(max-width:760px){.brand img{max-width:min(220px,100%)}}
@media(max-width:440px){.brand img{max-width:min(160px,100%)}}
@media(max-width:380px){.brand img{max-width:min(140px,100%)}}

/* Screen-only overrides keep the existing light theme and print styles intact. */
@media screen{
    :root[data-theme="dark"]{
        color-scheme:dark;
        --paper:#272a2d;
        --surface:#32373a;
        --ink:#e8ebe5;
        --muted:#b0bab3;
        --line:#4b5350;
        --deep:#263c32;
        --lime:#c7dda0;
        --accent:#b6cd9f;
        --on-accent:#203126;
    }
    html[data-theme="dark"]{background:var(--paper)}
    html[data-theme="dark"] ::selection{background:#b6cd9f;color:#203126}
    html[data-theme="dark"] :is(a,button,input,textarea,select):focus-visible{outline-color:#bed4a8}
    html[data-theme="dark"] .skip-link{background:var(--surface);color:var(--ink)}
    html[data-theme="dark"] .utility{background:#22312b;color:#cad4cb}
    html[data-theme="dark"] .brand-square{background:var(--accent)}
    /* Light monochrome presentation of the same logo, without changing its file.
       Screen blending also removes a white image background after inversion. */
    html[data-theme="dark"] :is(.brand,.footer-brand) img{filter:grayscale(1) invert(1);mix-blend-mode:screen}
    html[data-theme="dark"] .button-dark{background:var(--accent);color:var(--on-accent)}
    html[data-theme="dark"] .button-dark:hover{background:#c9ddb2}
    html[data-theme="dark"] .button-lime{color:var(--on-accent)}
    html[data-theme="dark"] .button-lime:hover{background:#d6e8b6}
    html[data-theme="dark"] .button-outline{border-color:#98aa9d}
    html[data-theme="dark"] .text-link{color:var(--ink)}
    html[data-theme="dark"] :is(.story-labels .eyebrow,.jobs-card>.eyebrow,.archive-header>.eyebrow){color:var(--accent)}
    html[data-theme="dark"] :is(.lead-excerpt,.post-meta,.topic-number){color:var(--muted)}
    html[data-theme="dark"] .post-meta a{color:#c3d4b5}
    html[data-theme="dark"] :is(.section-heading,.article-latest-heading){border-top-color:#91a486}
    html[data-theme="dark"] .access-label{background:#354035;color:#d1e2bf;border-color:#68745c}
    html[data-theme="dark"] .sponsored-label{background:#403b32;color:#e9d4ae;border-color:#776d59}
    html[data-theme="dark"] :is(.newsletter-box,.content-cta){color:var(--ink)}
    html[data-theme="dark"] .newsletter-box>p{color:#c3cfc5}
    html[data-theme="dark"] :is(.newsletter-note,.newsletter-benefits){color:#c3cfc5}
    html[data-theme="dark"] .newsletter-benefits li{border-top-color:#526257}
    html[data-theme="dark"] .newsletter-form input[type="email"]{background:#262d29;color:var(--ink);border-color:#849187}
    html[data-theme="dark"] .newsletter-form input::placeholder{color:#b5beb7;opacity:1}
    html[data-theme="dark"] .form-error{color:#ffcab8}
    html[data-theme="dark"] .gi-footer{background:#2d3234}
    html[data-theme="dark"] :is(.footer-top .nav a,.footer-connect>a,.footer-work-link){color:#c0cdbf}
    html[data-theme="dark"] .footer-bottom{color:var(--muted);border-top-color:var(--line)}
    html[data-theme="dark"] .article-disclosure{background:#343b35}
    html[data-theme="dark"] .article-content a{text-decoration-color:#a6bf91}
    html[data-theme="dark"] .article-content blockquote{color:#d0dcc6;border-left-color:#9eb78b}
    html[data-theme="dark"] .article-content pre{background:#222f28;color:#e4eadf}
    html[data-theme="dark"] .article-content :is(th,td){border-color:var(--line)}
    html[data-theme="dark"] :is(.kg-bookmark-container,.kg-product-card-container,.kg-file-card-container,.kg-audio-card,.kg-toggle-card){background:var(--surface);color:var(--ink);border-color:var(--line)}
    html[data-theme="dark"] :is(.kg-product-card-container,.kg-file-card-container,.kg-audio-card,.kg-toggle-card){box-shadow:inset 0 0 0 1px var(--line)}
    html[data-theme="dark"] :is(.kg-bookmark-title,.kg-product-card-title,.kg-product-card-description,.kg-file-card-title,.kg-audio-title,.kg-toggle-heading-text,.kg-toggle-content){color:var(--ink)}
    html[data-theme="dark"] :is(.kg-bookmark-description,.kg-bookmark-metadata,.kg-file-card-caption,.kg-file-card-metadata,.kg-audio-current-time,.kg-audio-duration){color:var(--muted)}
    html[data-theme="dark"] :is(.kg-toggle-card-icon,.kg-audio-play-icon,.kg-audio-pause-icon,.kg-audio-playback-rate,.kg-file-card-icon){color:var(--ink)}
    html[data-theme="dark"] :is(.kg-callout-card-grey,.kg-callout-card-white){background:var(--surface);color:var(--ink)}
    html[data-theme="dark"] .kg-product-card-button{background:var(--accent);color:var(--on-accent)}
    html[data-theme="dark"] .content-cta h2{color:var(--ink)}
    html[data-theme="dark"] .content-cta p{color:#c3cfc5}
    html[data-theme="dark"] .reading-progress::-webkit-progress-value{background:var(--accent)}
    html[data-theme="dark"] .reading-progress::-moz-progress-bar{background:var(--accent)}
}

/* Authored Green Insider HTML cards carry their own light-only CSS inside posts.
   Scope these overrides to the known components, with enough specificity to
   beat those later <style> blocks. Do not recolor images or arbitrary embeds. */
@media screen{
    html[data-theme="dark"] .article-content #giq-article{
        background:var(--paper);color:var(--ink);
    }
    html[data-theme="dark"] .article-content #giq-article a{color:var(--ink)}
    html[data-theme="dark"] .article-content #giq-article :is(.giq-note,caption){color:var(--muted)}
    html[data-theme="dark"] .article-content #giq-article blockquote{color:#d0dcc6;border-left-color:#9eb78b}
    html[data-theme="dark"] .article-content #giq-article :is(hr,th,td){border-color:var(--line)}
    html[data-theme="dark"] .article-content #giq-article thead{background:var(--surface)}

    /* Shared tokens used by the questionnaire planner and PPWR calculator. */
    html[data-theme="dark"] .article-content :is(#gi-questionnaire-planner-v1,#gi-ppwr-article){
        --gi-paper:var(--paper);
        --gi-ink:var(--ink);
        --gi-muted:var(--muted);
        --gi-dark:var(--deep);
        --gi-surface:var(--surface);
        --gi-lime:var(--lime);
        --gi-border:var(--line);
        color-scheme:dark;
    }
    html[data-theme="dark"] .article-content #gi-questionnaire-planner-v1 .giqp-head{color:var(--ink)}
    html[data-theme="dark"] .article-content #gi-questionnaire-planner-v1 :is(select,textarea){border-color:#849187}
    html[data-theme="dark"] .article-content #gi-questionnaire-planner-v1 input[type="checkbox"]{accent-color:var(--accent)}
    html[data-theme="dark"] .article-content #gi-questionnaire-planner-v1 button{
        background:var(--accent);color:var(--on-accent);border-color:var(--accent);
    }
    html[data-theme="dark"] .article-content #gi-questionnaire-planner-v1 button:hover{background:#c9ddb2}
    html[data-theme="dark"] .article-content #gi-questionnaire-planner-v1 :is(button,input,select,summary,textarea):focus-visible{outline-color:#bed4a8}
    html[data-theme="dark"] .article-content #gi-questionnaire-cost{
        background:var(--paper);color:var(--ink);border-color:var(--line);color-scheme:dark;
    }
    html[data-theme="dark"] .article-content #gi-questionnaire-cost h3{color:var(--ink)}
    html[data-theme="dark"] .article-content #gi-questionnaire-cost input{
        background:var(--paper);color:var(--ink);border-color:#849187;
    }
    html[data-theme="dark"] .article-content #gi-questionnaire-cost .giqc-result{background:var(--deep);color:var(--ink)}

    html[data-theme="dark"] .article-content #gi-ppwr-article :is(.gi-note,figcaption,small){color:var(--muted)}
    html[data-theme="dark"] .article-content #gi-ppwr-article thead{background:var(--surface)}
    html[data-theme="dark"] .article-content #gi-ppwr-article input{background:var(--paper);border-color:#849187}
    html[data-theme="dark"] .article-content #gi-ppwr-article .gi-result{background:var(--deep);color:var(--ink)}

    /* Carbon-accounting cost table and CBAM first-bill tools. */
    html[data-theme="dark"] .article-content .gi-cost{background:var(--paper);color:var(--ink);border-color:var(--line)}
    html[data-theme="dark"] .article-content .gi-cost :is(.head,.summary),
    html[data-theme="dark"] .article-content .gi-cost thead th{background:var(--surface);border-color:var(--line)}
    html[data-theme="dark"] .article-content .gi-cost :is(.eyebrow,.total){color:var(--accent)}
    html[data-theme="dark"] .article-content .gi-cost h3{color:var(--ink)}
    html[data-theme="dark"] .article-content .gi-cost :is(p,.note,figcaption){color:var(--muted)}
    html[data-theme="dark"] .article-content .gi-cost :is(input,button){background:var(--paper);color:var(--ink);border-color:#849187}
    html[data-theme="dark"] .article-content .gi-cost button:hover:not(:disabled){background:var(--surface)}
    html[data-theme="dark"] .article-content .gi-cost :is(th,td){border-color:var(--line)}
    html[data-theme="dark"] .article-content .gi-cost tbody tr:hover{background:var(--surface)}
    html[data-theme="dark"] .article-content .gi-cost .error{color:#ffcab8}
    html[data-theme="dark"] .article-content .gi-cost :focus-visible{outline-color:#bed4a8}

    /* These cards shadow the theme's --ink/--line/--muted on their own root. */
    html[data-theme="dark"] .article-content .gi-cbam{
        --ink:#e8ebe5;--muted:#b0bab3;--line:#4b5350;--green:var(--accent);
    }
    html[data-theme="dark"] .article-content .gi-cbam .gi-panel{background:var(--paper)}
    html[data-theme="dark"] .article-content .gi-cbam :is(.gi-head,th,.gi-tag),
    html[data-theme="dark"] .article-content .gi-cbam .gi-summary>div{background:var(--surface)}
    html[data-theme="dark"] .article-content .gi-cbam :is(input,select,button){background:var(--paper);border-color:#849187}
    html[data-theme="dark"] .article-content .gi-cbam button:hover,
    html[data-theme="dark"] .article-content .gi-cbam tbody tr:hover{background:var(--surface)}
    html[data-theme="dark"] .article-content .gi-cbam .gi-error{color:#ffcab8}
    html[data-theme="dark"] .article-content .gi-cbam :focus-visible{outline-color:#bed4a8}
}
