.theme-toggle {
  display: inline-grid; place-items: center; flex: none;
  width: 36px; height: 36px; padding: 0;
  border: 1px solid #77829a; border-radius: 50%; background: white; color: #1d2362; cursor: pointer;
}
.theme-toggle svg { display: block; }
.theme-toggle .theme-sun, [data-theme="dark"] .theme-toggle .theme-moon { display: none; }
[data-theme="dark"] .theme-toggle .theme-sun { display: inline; color: #ffb079; }
.theme-toggle:hover { border-color: currentColor; }
.menu-group .theme-toggle { margin-top: 8px; width: 44px; height: 44px; }
.theme-reset { font: inherit; color: inherit; background: transparent; border: 0; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
html[data-theme="light"] { color-scheme: light; }
html[data-theme="dark"] {
  color-scheme: dark;
  --nuit: #101524;
  --surface: #1b2337;
  --surface-haute: #26314a;
  --texte: #f4f6ff;
  --secondaire: #c9d2e5;
  --pale: var(--nuit);
  --line: #47536c;
  --champ: #7c89a1;
  --bouton-fond: #e0e7ff;
  --bouton-texte: #151c43;
  --bouton-survol: white;
  --fleche: url('assets/fleche-cap.svg');
  background: var(--nuit);
}
html[data-theme="dark"] {
  & .theme-toggle { background: var(--surface); color: var(--texte); border-color: var(--champ); }
  & body, & body.service { color: var(--texte); background: var(--nuit); }
  & body .hero, & body .inner-hero, & body .directory-banner {
    color: var(--texte); background: linear-gradient(110deg,#141b30 8%,#20294c 92%);
  }
  & body :is(.header,.hero-copy h1 strong,.hero-copy > p:not(.eyebrow):not(.hero-note),.inner-lead p,.hero .text-link.light,main > .crumb) { color: var(--texte); }
  & body .header .nav, & body.home .header:not(.compact) .nav, & body .header.compact .nav, & .nav nav.is-open {
    background: var(--surface); color: var(--texte); box-shadow: inset 0 0 0 1px var(--line);
  }
  & body .header .logo { content: url('assets/cap-logo-compact-inverse.svg'); filter: none; }
  & body :is(.convictions,.faq details,.opportunity,.reading,.entry,.empty-blog,.mobile-contents,.contact-layout,.directory-section a,.cabinet-badge,.cabinet-tiles > *,.cabinet-member > div,.cabinet-contact,.cabinet-news a,.cabinet-faq details,.directory-card) {
    background-color: var(--surface); color: var(--texte);
  }
  & body .listing .reading { background: transparent; }
  & body :is(.eyebrow,.step-num,.network,.step.reverse,.principles > div:nth-child(n),.guides > a:nth-child(n+2),.entries .entry > .offer-mount,.opportunity > .offer-mount) {
    color: var(--texte); background-color: var(--surface-haute);
  }
  & body :is(.project-panel,.step:not(.reverse),.valuation,.cabinet-edito,.directory-panel,footer) {
    background-color: #1c2545; color: var(--texte);
    --bouton-fond: #e0e7ff; --bouton-survol: white; --bouton-texte: #151c43;
  }
  & body :is(.guides > a:first-child,.news-list .entry,.reading th) { color: white; background-color: var(--ink); }
  & body :is(.tabs button:not([aria-selected=true]),.step.reverse p:not(.eyebrow),.principles span,.guides > a:nth-child(n+2) :is(span,b),.directory-link,.entry span,.reading a:not(.entry,.button,.bouton),.category,.faq details p,.demo-note,.form-status,.small-note,.table-hint,.directory-card .directory-link) { color: var(--secondaire); }
  & body .faq summary::after { color: var(--orange-clair); }
  & body :is(.text-link,.article-side a,.directory-section a):hover { color: var(--orange-clair); }
  & body .tabs button[aria-selected=true] { color: var(--nuit); background: #dce4ff; }
  & body .reading :is(.w-dyn-item,.feature33_item,.ent_main-1_card,.kn-box,.timeline_item-wrap,blockquote) { background: var(--surface-haute); }
  & body :is(.filter input,.demo-form input:not([type=radio]),.demo-form textarea,.cabinet-form input,.cabinet-form textarea,.demo-form .radio-button-field,.directory-input,.directory-radius) {
    background: var(--surface); color: var(--texte); border-color: var(--champ);
  }
  & body :is(.directory-radius select,.directory-input input) { color: var(--texte); }
  & body :is(input,textarea)::placeholder { color: #bac5db; opacity: 1; }
  & body .demo-form .radio-button-field:has(:checked) { background: var(--surface-haute); border-color: var(--orange-clair); }
  & body :is(.directory-controls .pin,.locate,.result-head button) { color: var(--texte); background-color: var(--surface-haute); }
  & body .cabinet-icon { background-color: #f8f9fb; border-radius: 5px; }
  & body .skip, & body .card-link b { color: var(--nuit); }
  & body .cabinet-news img, & body.editorial .inner-lead > img.diagram-photo { background-color: #e9ecf2; }
  & body :is(a,button,input,textarea,select,summary):focus-visible { outline-color: var(--orange-clair); box-shadow: 0 0 0 5px var(--nuit); }
  & #directory-map { background: #15263b; }
  & #directory-map .map-land { fill: #263548; stroke: #526680; }
  & #directory-map .map-regions { fill: #314357; stroke: #94a4b9; }
  & #directory-map .town-label { color: white; text-shadow: 0 1px 2px #101524, 0 -1px 2px #101524; }
  & #directory-map :is(.leaflet-popup-content-wrapper,.leaflet-popup-tip,.leaflet-control-zoom a,.leaflet-control-attribution) { background-color: var(--surface); color: var(--texte); }
  & #directory-map :is(.leaflet-control-attribution a,.leaflet-popup-content,.leaflet-popup-content a,.leaflet-popup-close-button) { color: var(--texte); }

  /* Les champs doivent se détacher du panneau même avant la saisie. */
  & body :is(.directory-input,.directory-radius,.locate,.result-head button) { box-shadow: inset 0 0 0 1px var(--champ); }
  & body .directory-radius option { color: var(--texte); background: var(--surface); }
  & body .demo-form .radio-button-field input { accent-color: #ffad76; }
  & body .demo-form .radio-button-field:has(:focus-visible) { outline: 2px solid var(--orange-clair); outline-offset: 3px; }
  & body :is(.demo-form,.cabinet-form) :is(input,textarea):user-invalid { border-color: #ffb1a8; }
  & body :is(.demo-form,.cabinet-form) .form-status:not(:empty) { color: var(--texte); }
  & body .hero .text-link.light:is(:hover,:focus-visible) { color: var(--orange-clair); }
  & body :is(.directory-search,.menu-toggle,.button,.bouton):not(:disabled):active { background-color: #ffc49d; color: #151c43; }
  & #directory-map .sector-pin:is(:hover,:focus-visible) span { background: #ffd6b7; border-color: #172137; }
  & #directory-map .leaflet-marker-icon:focus-visible { outline: 3px solid #fff; outline-offset: 1px; }
  & #directory-map .leaflet-tooltip:not(.town-label) { background: var(--surface); color: white; border-color: var(--champ); opacity: 1; }
  & #directory-map .leaflet-tooltip-top:not(.town-label)::before { border-top-color: var(--champ); }
  & #directory-map .leaflet-control-zoom a:is(:hover,:focus-visible), & #directory-map .leaflet-popup-close-button:hover { background-color: var(--surface-haute); color: white; }
  & #directory-map .leaflet-control-zoom a.leaflet-disabled { color: #a7b2c7; background: #242d40; cursor: default; }
  & #directory-map .leaflet-control-attribution { font-size: 12px; }
  & #directory-map .leaflet-control-attribution a { text-decoration: underline; }
  & #directory-map .map-radius { stroke: #ffad76; stroke-width: 2; }
}
@media (pointer: coarse), (max-width: 700px) {
  #directory-map .leaflet-control-zoom a { width: 44px; height: 44px; line-height: 44px; }
  #directory-map .leaflet-popup-close-button { width: 40px; height: 40px; line-height: 40px; }
  #directory-map .leaflet-popup-content { margin-right: 40px; }
}
