/* Palette d'alpha : bouton dans l'en-tête et panneau (style, couleurs, images, logo, langue).
   Les couleurs viennent des rôles du thème en cours, avec repli sur les rôles des feuilles Études et Véhicules
   électriques, puis sur les valeurs d'origine : la palette se lit sur toutes les pages. Les aperçus des styles sont plus bas. */
.palette, .palette__panneau {
  --pal-fond: var(--carte, var(--card, #ffffff));
  --pal-texte: var(--texte, var(--txt, #25313b));
  --pal-doux: var(--texte-doux, var(--soft, #5a6a75));
  --pal-bord: var(--bord, var(--line, #dfe5ea));
  --pal-accent: var(--accent, #2f6f94);
  --pal-doux-fond: var(--accent-doux, var(--tint, #e3edf3));
  --pal-rayon: min(var(--rayon, 14px), 18px);
}
.palette { position: relative; display: inline-flex; align-items: center; flex: none; }
.palette__panneau *, .palette__panneau *::before, .palette__panneau *::after { box-sizing: border-box; }
.palette *, .palette *::before, .palette *::after { box-sizing: border-box; }
.palette__bouton {
  display: inline-grid; place-items: center; width: 40px; height: 40px; padding: 0; margin: 0;
  border: 1px solid var(--pal-bord); border-radius: 50%; background: transparent; color: var(--pal-doux);
  cursor: pointer; -webkit-tap-highlight-color: transparent; font: inherit;
}
.palette__bouton:hover, .palette__bouton[aria-expanded="true"] { color: var(--pal-accent); border-color: var(--pal-accent); background: var(--pal-doux-fond); }
.palette__bouton:focus-visible, .palette__theme:focus-visible { outline: 2px solid var(--pal-accent); outline-offset: 2px; }
.palette__icone { display: block; width: 20px; height: 20px; }
/* Sur le bandeau sombre du tableau */
.palette--entete .palette__bouton { color: #ccd6e0; border-color: rgba(255, 255, 255, .28); }
.palette--entete .palette__bouton:hover, .palette--entete .palette__bouton[aria-expanded="true"] { color: #ffffff; border-color: rgba(255, 255, 255, .6); background: rgba(255, 255, 255, .12); }
.palette--entete .palette__bouton:focus-visible { outline-color: #ffffff; }

.palette__panneau {
  position: fixed; z-index: 1000; top: 56px; left: 8px; width: min(360px, calc(100vw - 16px)); max-height: calc(100vh - 72px);
  overflow-y: auto; overscroll-behavior: contain; padding: 12px; color: var(--pal-texte); background: var(--pal-fond);
  border: 1px solid var(--pal-bord); border-radius: var(--pal-rayon);
  box-shadow: 0 2px 4px rgba(0, 0, 0, .12), 0 16px 40px rgba(0, 0, 0, .22);
  font: 14px/1.4 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; text-align: left;
}
.palette__panneau[hidden] { display: none; }
.palette__tete { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 2px 4px 10px; }
.palette__titre { font-weight: 700; font-size: 15px; color: var(--pal-texte); }
.palette__etat { font-size: 12.5px; color: var(--pal-doux); min-height: 1.4em; }
/* Style : quatre aperçus côte à côte (src/themes.php, palette_apercu), une rangée de quatre au bureau comme au
   téléphone ; le nom du style dessous, la coche du style en cours en haut à droite. Les aperçus sont plus bas. */
.palette__apercus { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.palette__apercus li { margin: 0; padding: 0; min-width: 0; }
.palette__theme {
  position: relative; display: flex; flex-direction: column; align-items: stretch; gap: 5px; width: 100%; height: 100%;
  padding: 4px; margin: 0; text-align: center; font: inherit; color: var(--pal-texte);
  background: transparent; border: 1px solid var(--pal-bord); border-radius: calc(var(--pal-rayon) * .7); cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.palette__theme:hover { border-color: var(--pal-accent); }
.palette__theme[aria-pressed="true"] { border-color: var(--pal-accent); box-shadow: inset 0 0 0 1px var(--pal-accent); background: var(--pal-doux-fond); }
.palette__nom { display: block; padding: 0 2px 2px; font-weight: 500; font-size: 12px; line-height: 1.2; overflow-wrap: anywhere; }
.palette__theme[aria-pressed="true"] .palette__nom { font-weight: 700; }
.palette__coche {
  display: none; position: absolute; top: -6px; right: -6px; width: 18px; height: 18px; padding: 3px; border-radius: 50%;
  color: #ffffff; background: var(--pal-accent); box-shadow: 0 0 0 2px var(--pal-fond);
}
.ad-html .palette__coche { color: #0c0e12; }
.palette__theme[aria-pressed="true"] .palette__coche { display: block; }
@media (min-width: 560px) {
  .palette__panneau { width: 420px; }
  .palette__panneau { width: 640px; max-width: calc(100vw - 16px); }
}
/* Téléphone : un panneau qui monte du bas de l'écran, toujours entier, la page derrière ne défile pas. */
@media (max-width: 559px) {
  .palette__panneau {
    left: 0 !important; right: 0; top: auto !important; bottom: 0; width: 100%; max-width: none;
    max-height: 85vh !important; max-height: 85dvh !important; border-radius: 18px 18px 0 0; border-bottom: 0;
    padding: 8px 14px calc(16px + env(safe-area-inset-bottom));
    box-shadow: 0 -8px 40px rgba(0, 0, 0, .28), 0 0 0 100vmax rgba(10, 16, 22, .32);
  }
  .palette__tete { padding-top: 14px; position: relative; }
  .palette__tete::before { content: ""; position: absolute; top: 2px; left: 50%; width: 40px; height: 4px; margin-left: -20px; border-radius: 2px; background: var(--pal-bord); }
  html.palette-ouverte, html.palette-ouverte body { overflow: hidden; }
}
@media (prefers-reduced-motion: no-preference) {
  .palette__panneau:not([hidden]) { animation: palette-entree .14s ease-out; }
  @keyframes palette-entree { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
}

/* Aperçus des styles (src/themes.php, palette_apercu) : la même petite boîte dans chacun des quatre styles, avec ses
   couleurs, sa police, ses filets et sa densité. Boîtes vivantes et Minimaliste suivent les Couleurs choisies
   (attribut data-pa-teinte de la liste, mis à jour par palette.js ; valeurs de teintes.css) ; Terminal et Éditorial
   gardent les leurs, comme sur la page. Images masquées : plus d'icône, le texte seul. */
.pa {
  display: block; position: relative; height: 86px; overflow: hidden; padding: 6px 5px 0; border-radius: 5px; text-align: left;
  font: 400 9.5px/1.25 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; letter-spacing: 0;
  color: var(--pa-texte); background: var(--pa-fond); box-shadow: inset 0 0 0 1px rgba(128, 128, 128, .25);
}
.pa-boite { display: block; }
.pa-tete { display: flex; align-items: baseline; gap: 4px; min-width: 0; }
.pa-titre { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; color: var(--pa-titre); }
.pa-n { flex: none; color: var(--pa-doux); font-size: .9em; }
@media (max-width: 559px) { .pa-n { display: none; } } /* au téléphone, le titre entier plutôt que le compte */
.pa-lien { display: flex; align-items: center; gap: 4px; height: 14px; min-width: 0; }
.pa-nom { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pa-ico {
  position: relative; flex: 0 0 10px; width: 10px; height: 10px; overflow: hidden; border-radius: 2px; display: grid; place-items: center;
  background: var(--pa-accent-doux); color: var(--pa-accent); font-size: 7px; font-weight: 700; line-height: 1;
}
.pa-ico img { position: absolute; inset: 0; width: 100%; height: 100%; }
.pa-lien--4 { display: none; }
:root[data-images="non"] .pa-ico { display: none; }

/* Boîtes vivantes : une boîte claire et cadrée sur le fond de la page. */
.pa--f, .pa--m {
  --pa-fond: #f6f6f3; --pa-carte: #ffffff; --pa-texte: #2d363f; --pa-doux: #66707a; --pa-bord: #e6e6e0;
  --pa-titre: #3f6984; --pa-accent: #2b5a80; --pa-accent-doux: #e7eef4;
}
.pa--f .pa-boite { padding: 4px 4px 3px; background: var(--pa-carte); border: 1px solid var(--pa-bord); border-radius: 4px; box-shadow: 0 1px 2px rgba(27, 35, 44, .05); }
.pa--f .pa-tete { padding: 0 1px 3px; margin-bottom: 2px; border-bottom: 1px solid var(--pa-bord); }
/* Minimaliste : du texte sur le fond, sans cadre ni icône, un filet sous le titre, plus d'air. */
.pa--m { --pa-fond: #ffffff; --pa-carte: #ffffff; --pa-doux: #6b737b; --pa-bord: #ececea; padding-left: 7px; padding-right: 7px; }
.pa--m .pa-tete { padding-bottom: 3px; margin-bottom: 3px; border-bottom: 1px solid var(--pa-bord); }
.pa--m .pa-lien { height: 15px; }
/* Terminal : sombre et dense, titre et compteurs en chasse fixe, un accent bleu froid. */
.pa--d {
  --pa-fond: #0c0e12; --pa-carte: #12151b; --pa-texte: #e1e5ec; --pa-doux: #a9b1bd; --pa-bord: #222731;
  --pa-titre: #e1e5ec; --pa-accent: #82b1ff; --pa-accent-doux: #191d25; --pa-mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}
.pa--d .pa-boite { padding: 4px 4px 2px; background: var(--pa-carte); border: 1px solid var(--pa-bord); border-radius: 3px; }
.pa--d .pa-tete { margin-bottom: 2px; }
.pa--d .pa-titre { font-family: var(--pa-mono); font-weight: 700; font-size: .95em; letter-spacing: -.04em; }
.pa--d .pa-n { margin-left: auto; font-family: var(--pa-mono); }
.pa--d .pa-lien { height: 13px; }
.pa--d .pa-ico img { filter: grayscale(.3) brightness(.95); }
.pa--d .pa-plus { display: block; margin-top: 1px; padding-top: 1px; border-top: 1px dashed var(--pa-bord); font: 600 .9em/1.3 var(--pa-mono); color: var(--pa-accent); }
/* Éditorial : noir et blanc, filet épais en tête, numéro de rubrique, titre de journal, filets fins entre les liens. */
.pa--e {
  --pa-fond: #ffffff; --pa-texte: #0b0b0b; --pa-doux: #555555; --pa-bord: #e2e2e0; --pa-titre: #0b0b0b; --pa-accent: #0b0b0b; --pa-accent-doux: #e2e2e0;
  font-family: "Helvetica Neue", Helvetica, "Nimbus Sans", "Arial Nova", Arial, sans-serif; padding-left: 6px; padding-right: 6px;
}
.pa--e .pa-boite { padding-top: 2px; border-top: 2px solid #0b0b0b; }
.pa--e .pa-tete { display: block; margin-bottom: 2px; }
.pa--e .pa-num { display: block; font-size: .8em; color: var(--pa-doux); }
.pa--e .pa-titre { display: block; font-weight: 700; letter-spacing: -.01em; }
.pa--e .pa-lien { height: 13px; border-top: 1px solid var(--pa-bord); }
.pa--e .pa-ico { border-radius: 0; }
.pa--e .pa-ico img { filter: grayscale(1) contrast(1.05); opacity: .8; }

/* Couleurs choisies (mêmes valeurs que teintes.css), sur Boîtes vivantes et Minimaliste seulement. */
.palette__apercus[data-pa-teinte="ardoise"] :is(.pa--f, .pa--m) { --pa-fond: #f1f3f5; --pa-carte: #ffffff; --pa-texte: #2b3742; --pa-doux: #5f6b77; --pa-bord: #dfe4e9; --pa-titre: #4a6680; --pa-accent: #3d5a73; --pa-accent-doux: #e4ebf1; }
.palette__apercus[data-pa-teinte="brume"] :is(.pa--f, .pa--m) { --pa-fond: #f2f5f3; --pa-carte: #fbfcfb; --pa-texte: #2f3b36; --pa-doux: #64716b; --pa-bord: #dfe6e2; --pa-titre: #4b7666; --pa-accent: #3f6f5e; --pa-accent-doux: #e3eeea; }
.palette__apercus[data-pa-teinte="lavande"] :is(.pa--f, .pa--m) { --pa-fond: #f6f4f9; --pa-carte: #ffffff; --pa-texte: #332c40; --pa-doux: #6f6880; --pa-bord: #e7e3ee; --pa-titre: #6b5791; --pa-accent: #6a4f9a; --pa-accent-doux: #eee8f6; }
.palette__apercus[data-pa-teinte="aurore"] :is(.pa--f, .pa--m) { --pa-fond: #fbf6f3; --pa-carte: #ffffff; --pa-texte: #3b2c28; --pa-doux: #7a6762; --pa-bord: #efe3dd; --pa-titre: #9a4c3b; --pa-accent: #a84a35; --pa-accent-doux: #f8e9e3; }
.palette__apercus[data-pa-teinte="minuit"] :is(.pa--f, .pa--m) { --pa-fond: #14181d; --pa-carte: #1b2128; --pa-texte: #d3d9df; --pa-doux: #929da8; --pa-bord: #29313a; --pa-titre: #9bbdd3; --pa-accent: #8fb9da; --pa-accent-doux: #213040; }
.palette__apercus[data-pa-teinte="minuit"] .pa--f .pa-boite { box-shadow: none; }

/* Bureau : des aperçus plus grands, quatre liens. */
@media (min-width: 560px) {
  .pa { height: 108px; padding: 8px 7px 0; font-size: 11px; }
  .pa-lien { height: 16px; gap: 5px; }
  .pa--m .pa-lien { height: 17px; }
  .pa--d .pa-lien, .pa--e .pa-lien { height: 15px; }
  .pa-ico { flex-basis: 12px; width: 12px; height: 12px; font-size: 8px; }
  .pa-lien--4 { display: flex; }
  .palette__nom { font-size: 13px; }
}

/* Logo d'alpha : quatre dessins du même mot, une seule encre. */
.palette__sous { margin: 14px 4px 8px; font-size: 12.5px; color: var(--pal-doux); }
.palette__logos { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.palette__logo {
  display: flex; align-items: center; justify-content: center; gap: 6px; height: 42px; margin: 0; padding: 0 6px;
  font: 760 17px/1 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; letter-spacing: -.01em;
  color: var(--pal-texte); background: transparent; border: 1px solid var(--pal-bord); border-radius: calc(var(--pal-rayon) * .7); cursor: pointer;
}
.palette__logo:hover { background: var(--pal-doux-fond); border-color: var(--pal-accent); }
.palette__logo[aria-pressed="true"] { border-color: var(--pal-accent); box-shadow: inset 0 0 0 1px var(--pal-accent); background: var(--pal-doux-fond); }
.palette__logo:focus-visible { outline: 2px solid var(--pal-accent); outline-offset: 2px; }
.af-logo-b { font-family: Georgia, "Times New Roman", serif !important; font-style: italic; font-weight: 600 !important; letter-spacing: 0 !important; }
.af-logo-c { display: inline-flex; align-items: center; gap: 7px; }
.af-logo-c .af-logo-sceau { display: inline-grid; place-items: center; width: 22px; height: 22px; border: 1.5px solid currentColor; border-radius: 6px; font: 600 14px/1 Georgia, serif; font-style: normal; }
.af-logo-d { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace !important; font-weight: 600 !important; letter-spacing: -.02em !important; }
.af-logo-d .af-logo-curseur { color: var(--accent, #2b5a80); }
@media (max-width: 559px) { .palette__logos { grid-template-columns: 1fr 1fr; } }

/* Accueils Terminal et Éditorial : bouton fin, à la mesure de leur en-tête. */
.ad-barre .palette__bouton, .ae-bar .palette__bouton { width: 32px; height: 30px; border-radius: 7px; }
.ae-bar .palette__bouton { border-radius: 0; border-color: #0b0b0b; color: #0b0b0b; }
.ad-barre .palette__bouton { border-radius: 4px; }
.ad-barre .palette__icone, .ae-bar .palette__icone { width: 16px; height: 16px; }
.ad-html .palette__panneau { --pal-fond: #12151b; --pal-texte: #e1e5ec; --pal-doux: #a9b1bd; --pal-bord: #222731; --pal-accent: #82b1ff; --pal-doux-fond: #191d25; }

/* Langue, et sections ajoutées par une page (vues d'un sujet) */
.palette__langues { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.palette__langue, .palette__vue {
  display: flex; align-items: center; justify-content: center; height: 34px; padding: 0 8px; font-size: 13.5px; color: var(--pal-texte);
  text-decoration: none; border: 1px solid var(--pal-bord); border-radius: calc(var(--pal-rayon) * .7);
}
a.palette__langue:hover, a.palette__vue:hover { background: var(--pal-doux-fond); border-color: var(--pal-accent); color: var(--pal-accent); }
span.palette__langue, .palette__vue[aria-current] { border-color: var(--pal-accent); box-shadow: inset 0 0 0 1px var(--pal-accent); background: var(--pal-doux-fond); }
.palette__vues { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
@media (max-width: 559px) { .palette__langues { grid-template-columns: 1fr 1fr; } }

/* Couleurs (teintes) et bouton Images (src/themes.php, palette_bouton). */
:root[data-style="d"] .palette__teintes, :root[data-style="e"] .palette__teintes { display: none; }
.palette__pastilles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.palette__teinte { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid var(--pal-bord); border-radius: 9px;
  background: transparent; color: var(--pal-texte); font: inherit; font-size: 13px; cursor: pointer; text-align: left; }
.palette__teinte:hover { border-color: var(--pal-accent); }
.palette__teinte[aria-pressed="true"] { border-color: var(--pal-accent); box-shadow: inset 0 0 0 1px var(--pal-accent); font-weight: 600; }
.palette__teinte:focus-visible, .palette__images:focus-visible { outline: 2px solid var(--pal-accent); outline-offset: 2px; }
.palette__pastille { position: relative; flex: none; width: 22px; height: 22px; border-radius: 50%; overflow: hidden; border: 1px solid rgba(0, 0, 0, .12); }
.palette__pastille i { position: absolute; inset: 0; }
.palette__pastille i + i { inset: 50% 0 0 0; }
.palette__pastille--alpha i { background: #f6f6f3; } .palette__pastille--alpha i + i { background: #2b5a80; }
.palette__pastille--ardoise i { background: #f1f3f5; } .palette__pastille--ardoise i + i { background: #3d5a73; }
.palette__pastille--brume i { background: #f2f5f3; } .palette__pastille--brume i + i { background: #3f6f5e; }
.palette__pastille--lavande i { background: #f6f4f9; } .palette__pastille--lavande i + i { background: #6a4f9a; }
.palette__pastille--aurore i { background: #fbf6f3; } .palette__pastille--aurore i + i { background: #a84a35; }
.palette__pastille--minuit i { background: #14181d; } .palette__pastille--minuit i + i { background: #8fb9da; }
.palette__images { display: flex; align-items: center; gap: 10px; width: 100%; margin-top: 12px; padding: 8px 10px; border: 1px solid var(--pal-bord);
  border-radius: 9px; background: transparent; color: var(--pal-texte); font: inherit; cursor: pointer; text-align: left; }
.palette__images-t { flex: 1; display: grid; }
.palette__images-t strong { font-size: 13.5px; }
.palette__images-t small { font-size: 12px; color: var(--pal-doux); }
.palette__images-etat { font-size: 12.5px; color: var(--pal-doux); min-width: 64px; text-align: right; }
.palette__interrupteur { position: relative; flex: none; width: 34px; height: 20px; border-radius: 999px; background: var(--pal-bord); transition: background .15s; }
.palette__interrupteur i { position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: transform .15s; }
.palette__images[aria-pressed="true"] .palette__interrupteur { background: var(--pal-accent); }
.palette__images[aria-pressed="true"] .palette__interrupteur i { transform: translateX(14px); }
@media (prefers-reduced-motion: reduce) { .palette__interrupteur, .palette__interrupteur i { transition: none; } }
