/* App dark theme (html[data-theme="dark"]), loaded after every other app stylesheet. Light mode is untouched: every
   rule here is scoped to the dark theme.

   Palette: the brand's dark green family, in an elevation scale.
     page #0e1f20 · sidebar #102526 · cards #15292a · raised (inputs, chips, menus) #1c3335 · hairlines rgba(255,255,255,.08)
     primary #1d644a (white text 5.6:1) · links #9dceab · muted text #a9bdba (7.7:1 on cards)

   The frame (top bar, sidebar, banners, the website switcher) is drawn dark directly. The page content keeps the
   existing engine, invert(.9) hue-rotate(180deg) over #app-content (ahrefs-theme.css), which gives every tool a dark
   version, and this file corrects what that engine got wrong:
     - a multiply tint (#ecffff) under the inversion turns its neutral greys into the green family, so the page lands
       on #0e1f20 and borders on the green hairline;
     - cards, raised controls, the primary button, links and muted text get the SOURCE colours that land on the tokens
       above after the inversion (solved in scratchpad/darksolve.py; comments give the result on screen);
     - completed steps keep readable titles (no strikethrough), photos are dimmed, illustrations sit in a soft tile. */

html[data-theme="dark"]{--dk-page:#0e1f20;--dk-side:#102526;--dk-card:#15292a;--dk-raised:#1c3335;--dk-line:rgba(255,255,255,.08);--dk-line-strong:rgba(255,255,255,.14);--dk-text:#e6eeec;--dk-muted:#a9bdba;--dk-link:#9dceab;--dk-primary:#1d644a;--dk-primary-hover:#227256;color-scheme:dark;background:var(--dk-page)}

/* ---- Frame ---- */
html[data-theme="dark"] body,
html[data-theme="dark"] #app.rf-shell,
html[data-theme="dark"] #app.rf-shell .rf-main,
html[data-theme="dark"] #app.rf-shell .rf-content{background:var(--dk-page)!important}
html[data-theme="dark"] #app.rf-shell .rf-header{background:var(--dk-page)!important;box-shadow:0 1px 0 var(--dk-line)!important}
html[data-theme="dark"] #app.rf-shell .rf-side{background:var(--dk-side)!important;border-right:1px solid var(--dk-line)!important}
html[data-theme="dark"] #app.rf-shell .rf-brand{background:var(--dk-side)!important;box-shadow:0 1px 0 var(--dk-line)}
html[data-theme="dark"] #app.rf-shell .rf-nav-section-label{color:var(--dk-muted)!important}
html[data-theme="dark"] #app.rf-shell .rf-nav-item{color:#d7e3e0!important}
html[data-theme="dark"] #app.rf-shell .rf-nav-item .ic{color:var(--dk-muted)!important}
html[data-theme="dark"] #app.rf-shell .rf-nav-item:hover,html[data-theme="dark"] #app.rf-shell .rf-nav-item.is-active{background:rgba(157,206,171,.10)!important;color:#fff!important}
html[data-theme="dark"] #app.rf-shell .rf-nav-item.is-active .ic{color:var(--dk-link)!important}
html[data-theme="dark"] #app.rf-shell .rf-promo{background:var(--dk-card)!important;border:1px solid var(--dk-line)!important;box-shadow:none!important}
html[data-theme="dark"] #app.rf-shell .rf-header :is(input,button:not(.rf-combo-trigger):not(.rf-theme-toggle)){background:var(--dk-raised)!important;border-color:var(--dk-line-strong)!important;color:var(--dk-text)!important}
html[data-theme="dark"] #app.rf-shell .rf-header :is(small,.muted,[class*="sub"]){color:var(--dk-muted)!important}
html[data-theme="dark"] #app.rf-shell .rf-verify-banner{background:var(--dk-card)!important;border-bottom:1px solid var(--dk-line)!important;color:var(--dk-text)!important}
html[data-theme="dark"] #app.rf-shell .rf-verify-banner :is(p,strong,span){color:var(--dk-text)!important}
html[data-theme="dark"] #app.rf-shell .rf-verify-banner .ic{color:var(--dk-link)!important}
html[data-theme="dark"] #app.rf-shell .rf-verify-banner .rf-btn{background:var(--dk-raised)!important;border-color:var(--dk-line-strong)!important;color:var(--dk-text)!important}
html[data-theme="dark"] #app.rf-shell .rf-verify-dismiss{color:var(--dk-muted)!important}

/* ---- Content: tint the inversion into the green family ---- */
html[data-theme="dark"] #app.rf-shell #app-content{position:relative;isolation:isolate}
html[data-theme="dark"] #app.rf-shell #app-content::after{content:"";position:absolute;inset:0;z-index:2147483000;background:#ecffff;mix-blend-mode:multiply;pointer-events:none}

/* Cards one step above the page (on screen #15292a) */
html[data-theme="dark"] #app.rf-shell #app-content :is(.rf-card,.panel,.ws-project,.ws-site-card,.ws-portfolio,.ws-empty,.orr-card,.st-plan-card,.kx-trend-card,.rf-notice,.ws-add-card,.wd-tile,.wd-kpis,.rx-panel,.trk-hero-side,.ov-wins,.wd-onboard,.wd-steps>li,.wd-step){background:#eff6f7!important}
/* Cards inside a card: one more step (on screen #1c3335) */
html[data-theme="dark"] #app.rf-shell #app-content :is(.rf-card,.panel,.ov-wins) :is(.ov-next-card,.ov-wins-list>li,.wd-steps>li){background:#dfebee!important}

/* Raised controls: inputs, selects, chips, secondary buttons (on screen #1c3335) */
html[data-theme="dark"] #app.rf-shell #app-content :is(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),select,textarea,.rf-input,.rf-chip,.rf-seg button,.wd-filters button,.wd-chip,.rf-btn:not(.dark):not(.ghost)){background-color:#dfebee!important}
html[data-theme="dark"] #app.rf-shell #app-content :is(.wd-filters button,.rf-chip,.wd-chip):is(.is-active,[aria-pressed="true"],[aria-selected="true"]){background-color:#c4dcd7!important;color:#000!important}

/* Primary button: the brand green with white text (on screen #1d644a, 5.6:1) */
html[data-theme="dark"] #app.rf-shell #app-content .rf-btn.dark{background:#7dccac!important;border-color:#7dccac!important;color:#000!important}
html[data-theme="dark"] #app.rf-shell #app-content .rf-btn.dark:hover{background:#64c09d!important;border-color:#64c09d!important}

/* One link colour (on screen #9dceab) */
html[data-theme="dark"] #app.rf-shell #app-content :is(a:not(.rf-btn),.wd-next,.text-button,.rf-link,.ms-col.is-link .ms-note,.ws-card-link,.wd-kw b){color:#003d12!important}

/* Secondary text that the inversion left too faint (on screen #a9bdba) */
html[data-theme="dark"] #app.rf-shell #app-content :is(.ws-source-note,.ws-project-context small,.ms-note,.rf-muted,.wd-sub,.ws-card small){color:#283e3a!important}

/* Completed onboarding steps: readable, no strikethrough; the check carries the state (on screen #b7c8c5) */
html[data-theme="dark"] #app.rf-shell #app-content .is-done,
html[data-theme="dark"] #app.rf-shell #app-content .is-done *{text-decoration:none!important;opacity:1!important}
html[data-theme="dark"] #app.rf-shell #app-content .is-done :is(strong,b,h3,h4,span:not(.ic)){color:#1b2e2b!important}

/* Photos and covers: the engine turns them back to their own colours; dim them so they do not glare */
html[data-theme="dark"] #app.rf-shell #app-content :is(.wd-cover,.ws-cover) img{opacity:.78}
/* Illustrations keep their white ground, so they sit in a soft rounded tile */
html[data-theme="dark"] #app.rf-shell #app-content img[src*="/illustrations/"],
html[data-theme="dark"] #app.rf-shell #app-content img[src*="/images/"][src$=".webp"]:not(.wd-cover img){border-radius:14px}

/* Dialogs (top layer, outside #app-content) get the same engine */
html[data-theme="dark"] dialog{filter:invert(.9) hue-rotate(180deg)}
html[data-theme="dark"] dialog :is(img,video,picture){filter:invert(1) hue-rotate(180deg)}
html[data-theme="dark"] dialog::backdrop{background:rgba(5,14,15,.6)}
html[data-theme="dark"] #app.rf-shell #app-content .rf-btn.dark *{color:#000!important}
/* The crawl-loading illustration: one rounded tile, not a tile inside a tile */
html[data-theme="dark"] #app.rf-shell #app-content .do-scan-art{background:none!important;padding:0!important}
html[data-theme="dark"] #app.rf-shell #app-content .do-scan-art img{opacity:1}

/* Transparent illustrations (the -alpha.webp cut-outs) sit straight on the card: no tile, no rounding */
html[data-theme="dark"] #app.rf-shell #app-content img[src*="-alpha.webp"]{border-radius:0!important;opacity:1}
