/* Thèmes des documents, communs aux trois éditeurs (editeur-themes.js, EDITEURS.md 3.4) : panneau
   « Thème » de l'éditeur, étape « Choisis un style » de la création et miniatures. Style Finexy
   (DESIGN.md), jetons de app.css, mode sombre compris. Les couleurs des miniatures sont celles du
   thème montré (contenu de l'utilisateur), posées en variables --th-*. Préfixe eth-. */

/* Panneau à droite de la zone de l'éditeur, comme l'historique */
.eth-panneau {
  display: flex; flex-direction: column; width: 340px; flex: none; min-height: 0;
  border-left: 1px solid var(--border); background: var(--background); outline: none;
}
.eth-panneau .eth-tete {
  display: flex; align-items: center; justify-content: space-between; gap: var(--e2);
  padding: var(--e3) var(--e3) var(--e2) var(--e4);
}
.eth-panneau .eth-titre { display: flex; align-items: center; gap: var(--e2); margin: 0; font-size: 16px; line-height: 24px; }
.eth-panneau .eth-titre .eth-ico { width: 18px; height: 18px; color: var(--primary); }
.eth-panneau .eth-corps { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 0 var(--e4) var(--e4); display: grid; align-content: start; gap: var(--e4); }
.eth-panneau .eth-pied {
  display: flex; justify-content: flex-end; flex-wrap: wrap; gap: var(--e2); padding: var(--e3) var(--e4);
  border-top: 1px solid var(--border);
}
.eth-panneau .eth-section { display: grid; gap: var(--e2); min-width: 0; }
.eth-panneau .eth-h { margin: 0; font-size: 12px; line-height: 16px; font-weight: 600; letter-spacing: .02em; color: var(--muted-foreground); }
.eth-panneau .eth-plier { border-top: 1px solid var(--border); padding-top: var(--e3); }
.eth-panneau .eth-resume {
  display: flex; flex-direction: column; gap: 2px; padding: var(--e2); margin: 0 calc(-1 * var(--e2)); border-radius: var(--r);
  cursor: pointer; list-style: none; color: var(--foreground); font-size: 14px; letter-spacing: 0;
}
.eth-panneau .eth-resume::-webkit-details-marker { display: none; }
.eth-panneau .eth-resume small { font-weight: 400; font-size: 12px; color: var(--muted-foreground); }
.eth-panneau .eth-resume::after {
  content: ""; position: absolute; right: var(--e4); width: 8px; height: 8px; margin-top: 6px;
  border-right: 1.6px solid currentColor; border-bottom: 1.6px solid currentColor; transform: rotate(45deg); opacity: .6;
}
.eth-panneau .eth-plier { position: relative; }
.eth-panneau .eth-plier[open] .eth-resume::after { transform: rotate(-135deg); margin-top: 10px; }
@media (hover: hover) { .eth-panneau .eth-resume:hover { background: var(--accent); } }
.eth-panneau .eth-resume:focus-visible { outline: none; box-shadow: var(--anneau); }
.eth-panneau .eth-perso { display: grid; gap: var(--e2); padding-top: var(--e2); }
.eth-panneau .eth-sous { margin: var(--e2) 0 0; font-size: 13px; line-height: 20px; }
.eth-panneau .eth-sans { justify-self: start; }
.eth-panneau .eth-annonce { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.eth-panneau .eth-aide, .eth-dialogue .eth-aide { margin: 0; font-size: 12px; line-height: 18px; color: var(--muted-foreground); }
.eth-ico { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* Grille des cartes de thème */
.eth-panneau .eth-grille, .eth-dialogue .eth-grille { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--e3); }
.eth-dialogue .eth-grille-large { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); max-height: min(62dvh, 560px); overflow: auto; padding: 4px; margin: -4px; }
.eth-panneau .eth-carte-hote, .eth-dialogue .eth-carte-hote { position: relative; display: grid; min-width: 0; }
.eth-panneau .eth-carte, .eth-dialogue .eth-carte {
  display: grid; gap: 6px; min-width: 0; padding: 6px 6px 8px; border: 0; border-radius: 14px; background: var(--card);
  box-shadow: var(--anneau-doux); color: var(--card-foreground); font: inherit; text-align: left; cursor: pointer;
  transition: box-shadow .15s var(--courbe), transform .12s var(--courbe), background-color .15s var(--courbe);
}
@media (hover: hover) { .eth-panneau .eth-carte:hover, .eth-dialogue .eth-carte:hover { background: var(--accent); } }
.eth-panneau .eth-carte:active, .eth-dialogue .eth-carte:active { transform: scale(.98); }
.eth-panneau .eth-carte:focus-visible, .eth-dialogue .eth-carte:focus-visible { outline: none; box-shadow: var(--anneau-doux), var(--anneau); }
.eth-panneau .eth-carte[aria-checked="true"], .eth-dialogue .eth-carte[aria-checked="true"] { box-shadow: 0 0 0 2px var(--primary); }
.eth-panneau .eth-carte[aria-checked="true"]:focus-visible { box-shadow: 0 0 0 2px var(--primary), var(--anneau); }
.eth-panneau .eth-carte-nom, .eth-dialogue .eth-carte-nom {
  padding: 0 4px; font-size: 12px; line-height: 16px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.eth-panneau .eth-suppr { position: absolute; right: 4px; bottom: 2px; min-width: 28px; min-height: 28px; padding: 0; }
.eth-panneau .eth-suppr .eth-ico { width: 14px; height: 14px; }
.eth-panneau .eth-suppr.eth-danger { color: var(--destructive); background: color-mix(in srgb, var(--destructive) 10%, transparent); }
.eth-panneau .eth-carte-hote .eth-carte-nom { padding-right: 30px; }

/* Personnaliser */
.eth-panneau .eth-couleurs { display: grid; gap: var(--e2); }
.eth-panneau .eth-ligne-couleur { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; }
.eth-panneau .eth-lib { display: flex; align-items: center; gap: var(--e2); font-size: 13px; line-height: 20px; min-width: 0; }
.eth-panneau .eth-couleur {
  width: 32px; height: 32px; flex: none; padding: 0; border: 0; border-radius: 50%; background: none; cursor: pointer;
  box-shadow: 0 0 0 1px var(--border);
}
.eth-panneau .eth-couleur::-webkit-color-swatch-wrapper { padding: 0; }
.eth-panneau .eth-couleur::-webkit-color-swatch { border: 0; border-radius: 50%; }
.eth-panneau .eth-couleur::-moz-color-swatch { border: 0; border-radius: 50%; }
.eth-panneau .eth-couleur:focus-visible { outline: none; box-shadow: 0 0 0 1px var(--border), var(--anneau); }
.eth-panneau .eth-pastilles { display: flex; flex-wrap: wrap; gap: 4px; padding-left: 40px; }
.eth-panneau .eth-pastille {
  width: 22px; height: 22px; padding: 0; border: 0; border-radius: 6px; background: var(--c); cursor: pointer;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--foreground) 16%, transparent);
  transition: transform .12s var(--courbe);
}
@media (hover: hover) { .eth-panneau .eth-pastille:hover { transform: scale(1.12); } }
.eth-panneau .eth-pastille:focus-visible { outline: none; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--foreground) 16%, transparent), var(--anneau); }
.eth-panneau .eth-choix { display: grid; gap: var(--e2); }
.eth-panneau .eth-champ { display: grid; grid-template-columns: 96px minmax(0, 1fr); align-items: center; gap: var(--e2); }
.eth-panneau .eth-select { min-height: 34px; font-size: 13px; }
.eth-panneau .eth-alertes {
  margin: 0; padding: var(--e2) var(--e3) var(--e2) var(--e6); border-radius: var(--r);
  background: color-mix(in srgb, var(--destructive) 8%, var(--card)); color: var(--foreground); font-size: 12px; line-height: 18px;
}
.eth-panneau .eth-enregistrer { display: flex; flex-wrap: wrap; gap: var(--e2); margin-top: var(--e2); }
.eth-panneau .eth-nom { flex: 1 1 140px; min-width: 0; min-height: 34px; font-size: 13px; }
.eth-panneau .eth-enregistrer .btn { flex: 1 1 auto; justify-content: center; white-space: normal; }

/* Étape « Choisis un style » */
dialog.eth-dialogue { width: min(860px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 0; overflow: hidden; }
.eth-dialogue .eth-dlg { display: grid; gap: var(--e4); padding: var(--e6); max-height: calc(100dvh - 32px); grid-template-rows: auto minmax(0, 1fr) auto; }
.eth-dialogue .eth-dlg-tete { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--e3); }
.eth-dialogue .eth-dlg-titre { margin: 0 0 4px; font-size: 20px; line-height: 28px; letter-spacing: -.015em; }
.eth-dialogue .eth-dlg-pied { display: flex; justify-content: flex-end; gap: var(--e2); }
.eth-dialogue .eth-fermer { margin: -6px -6px 0 0; }

/* Miniatures : une page, une feuille ou une diapo dans les couleurs du thème */
.eth-mini {
  position: relative; display: block; aspect-ratio: 4 / 3; overflow: hidden; border-radius: 9px;
  background: var(--th-fond); color: var(--th-texte); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--foreground) 10%, transparent);
  font-family: var(--th-police-texte); container-type: inline-size;
}
.eth-mini i { display: block; font-style: normal; }
.eth-mini .eth-s1 { background: var(--th-s1); } .eth-mini .eth-s2 { background: var(--th-s2); }
.eth-mini .eth-s3 { background: var(--th-s3); } .eth-mini .eth-s4 { background: var(--th-s4); }

/* Page de texte */
.eth-mini-texte { background: color-mix(in srgb, var(--th-fond) 70%, var(--muted)); }
.eth-mini .eth-m-page {
  position: absolute; left: 14%; right: 14%; top: 9%; bottom: -6%; display: flex; flex-direction: column; gap: 5cqw;
  padding: 9cqw 9cqw 0; background: var(--th-fond); border-radius: 3px; box-shadow: 0 2px 8px -2px rgb(0 0 0 / .18);
}
.eth-mini .eth-m-page .eth-m-titre { font: 700 11cqw/1.1 var(--th-police-titre); color: var(--th-titre); padding-bottom: 2cqw; letter-spacing: -.01em; }
.eth-mini[data-th-titres="filet"] .eth-m-page .eth-m-titre { border-bottom: 1.5px solid var(--th-accent); padding-bottom: 3cqw; }
.eth-mini[data-th-titres="majuscules"] .eth-m-page .eth-m-titre { text-transform: uppercase; letter-spacing: .08em; font-size: 8.5cqw; }
.eth-mini[data-th-titres="barre"] .eth-m-page .eth-m-titre { border-left: 3px solid var(--th-accent); padding-left: 4cqw; }
.eth-mini .eth-m-lignes { display: grid; gap: 3cqw; }
.eth-mini .eth-m-lignes i { height: 2.4cqw; border-radius: 2px; background: var(--th-texte); opacity: .55; }
.eth-mini .eth-m-lignes i:nth-child(2) { width: 88%; }
.eth-mini .eth-m-lignes .eth-m-lien { width: 40%; background: var(--th-accent); opacity: 1; }
.eth-mini .eth-m-puces { display: grid; gap: 3cqw; padding-left: 9cqw; }
.eth-mini .eth-m-puces i { position: relative; height: 2.4cqw; width: 70%; border-radius: 2px; background: var(--th-texte); opacity: .5; }
.eth-mini .eth-m-puces i::before { content: ""; position: absolute; left: -6cqw; top: -.4cqw; width: 3.2cqw; height: 3.2cqw; border-radius: 50%; background: var(--th-accent); }
.eth-mini[data-th-puces="carre"] .eth-m-puces i::before { border-radius: 1px; }
.eth-mini[data-th-puces="tiret"] .eth-m-puces i::before { height: 1.2cqw; top: .6cqw; border-radius: 0; }
.eth-mini[data-th-puces="losange"] .eth-m-puces i::before { border-radius: 0; transform: rotate(45deg) scale(.85); }
.eth-mini[data-th-puces="fleche"] .eth-m-puces i::before { border-radius: 0; background: none; border-top: 1.2px solid var(--th-accent); border-right: 1.2px solid var(--th-accent); transform: rotate(45deg) scale(.8); }
.eth-mini .eth-m-hr { height: 0; border-top: 1px solid color-mix(in srgb, var(--th-texte) 30%, var(--th-fond)); }
.eth-mini[data-th-filets="double"] .eth-m-hr { border-top: 3px double color-mix(in srgb, var(--th-texte) 40%, var(--th-fond)); }
.eth-mini[data-th-filets="pointille"] .eth-m-hr { border-top: 1.5px dotted color-mix(in srgb, var(--th-texte) 50%, var(--th-fond)); }
.eth-mini[data-th-filets="epais"] .eth-m-hr { border-top: 3px solid var(--th-accent); }
.eth-mini[data-th-filets="ornement"] .eth-m-hr { width: 30%; align-self: center; border-top: 2px solid var(--th-accent); }
.eth-mini .eth-m-tab { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; }
.eth-mini .eth-m-tab i { height: 6cqw; background: var(--th-accent); }
.eth-mini[data-th-tableaux="doux"] .eth-m-tab i { background: var(--th-doux); }
.eth-mini[data-th-tableaux="filet"] .eth-m-tab i { background: none; border-bottom: 2px solid var(--th-accent); }

/* Feuille de tableur */
.eth-mini .eth-m-feuille { position: absolute; inset: 9% 7%; display: grid; grid-template-columns: 1.15fr 1fr; gap: 6cqw; align-items: end; }
.eth-mini .eth-m-grille { display: grid; gap: 0; border-radius: 3px; overflow: hidden; box-shadow: 0 0 0 1px color-mix(in srgb, var(--th-texte) 14%, transparent); }
.eth-mini .eth-m-ligne { display: grid; grid-template-columns: repeat(3, 1fr); height: 9cqw; border-top: 1px solid color-mix(in srgb, var(--th-texte) 12%, transparent); }
.eth-mini .eth-m-ligne i { margin: auto 2.5cqw; height: 2cqw; border-radius: 1px; background: var(--th-texte); opacity: .45; }
.eth-mini .eth-m-tete { border-top: 0; background: var(--th-accent); }
.eth-mini .eth-m-tete i { background: var(--th-sur-accent); opacity: .9; }
.eth-mini[data-th-tableaux="plein"] .eth-m-bande { background: var(--th-doux); }
.eth-mini[data-th-tableaux="doux"] .eth-m-tete { background: var(--th-doux); }
.eth-mini[data-th-tableaux="doux"] .eth-m-tete i, .eth-mini[data-th-tableaux="filet"] .eth-m-tete i { background: var(--th-titre); }
.eth-mini[data-th-tableaux="filet"] .eth-m-tete { background: none; border-bottom: 2px solid var(--th-accent); }
.eth-mini .eth-m-graph { display: flex; align-items: flex-end; gap: 3cqw; height: 60%; padding: 0 2cqw; border-bottom: 1px solid color-mix(in srgb, var(--th-texte) 35%, transparent); }
.eth-mini .eth-m-graph i { flex: 1; height: calc(var(--v) * 100%); border-radius: 2px 2px 0 0; }

/* Diapo */
.eth-mini-presentation { aspect-ratio: 16 / 10; }
.eth-mini .eth-m-diapo { position: absolute; inset: 0; padding: 11cqw 9cqw; display: flex; flex-direction: column; gap: 3cqw; }
.eth-mini .eth-m-diapo .eth-m-titre { position: relative; font: 700 17cqw/1 var(--th-police-titre); color: var(--th-titre); }
.eth-mini[data-th-titres="majuscules"] .eth-m-diapo .eth-m-titre { text-transform: uppercase; letter-spacing: .06em; font-size: 14cqw; }
.eth-mini .eth-m-diapo .eth-m-filet { position: relative; width: 22%; height: 2cqw; border-radius: 2px; background: var(--th-accent); }
.eth-mini .eth-m-diapo .eth-m-lignes { position: relative; width: 50%; gap: 2.6cqw; margin-top: 2cqw; }
.eth-mini .eth-m-diapo .eth-m-lignes i { height: 2.2cqw; }
.eth-mini .eth-m-forme { position: absolute; right: -10%; top: -18%; width: 48%; aspect-ratio: 1; border-radius: 50%; background: var(--th-doux); }
.eth-mini[data-th-cadres="droit"] .eth-m-forme { border-radius: 0; transform: rotate(12deg); }
.eth-mini[data-th-cadres="cadre"] .eth-m-forme { border-radius: 4px; box-shadow: inset 0 0 0 3cqw var(--th-fond), 0 0 0 1px color-mix(in srgb, var(--th-texte) 20%, transparent); }
.eth-mini .eth-m-barres { position: absolute; right: 9cqw; bottom: 11cqw; width: 30%; height: 34%; display: flex; align-items: flex-end; gap: 2cqw; }
.eth-mini .eth-m-barres i { flex: 1; height: calc(var(--v) * 100%); border-radius: 1.5px 1.5px 0 0; }

@media (max-width: 820px) {
  .ed-corps > .eth-panneau { position: absolute; inset: 0; z-index: 6; width: auto; border-left: 0; }
  .eth-dialogue .eth-dlg { padding: var(--e4); }
  .eth-dialogue .eth-grille-large { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) {
  .eth-panneau .eth-carte, .eth-dialogue .eth-carte, .eth-panneau .eth-pastille { transition: none; }
}
@media print {
  html.impression-document .eth-panneau { display: none !important; }
}
