/* Éditeur de tableur façon Excel (genre « tableur »). Contrat : EDITEURS.md. Style Finexy
   (DESIGN.md) : jetons de app.css seulement, mode sombre compris. Les couleurs choisies par
   l'utilisateur (texte, fond des cases) sont du contenu et restent telles quelles.
   Toutes les règles sont préfixées ex-. */
.ex {
  --ex-grille: color-mix(in srgb, var(--border) 82%, var(--foreground) 6%);
  --ex-tete: var(--muted);
  --ex-tete-dans: color-mix(in srgb, var(--primary) 11%, var(--muted));
  --ex-trait: var(--foreground);
  --ex-sel-fond: color-mix(in srgb, var(--primary) 9%, transparent);
  position: absolute; inset: 0; display: flex; flex-direction: column; min-height: 0;
  background: var(--background); color: var(--foreground); font-size: 13px; line-height: 16px;
}

/* Barre d'outils */
.ex .ex-barre {
  display: flex; align-items: center; gap: 2px; flex: none; padding: 6px var(--e3); overflow-x: auto; overflow-y: hidden;
  background: var(--background); border-bottom: 1px solid var(--border); scrollbar-width: none;
}
.ex .ex-barre::-webkit-scrollbar { display: none; }
.ex .ex-groupe { display: flex; align-items: center; gap: 2px; flex: none; padding-right: 6px; margin-right: 4px; border-right: 1px solid var(--border); }
.ex .ex-groupe:last-child { border-right: 0; margin-right: 0; padding-right: 0; }
.ex .ex-btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 2px; flex: none;
  min-width: 32px; height: 32px; padding: 0 6px; border: 0; border-radius: var(--r-sm); background: transparent;
  color: var(--muted-foreground); font: inherit; font-size: 12px; font-weight: 600; cursor: pointer;
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent;
  transition: background-color .15s var(--courbe), color .15s var(--courbe), transform .1s var(--courbe);
}
.ex .ex-ico { width: 17px; height: 17px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ex .ex-ico-mini { width: 12px; height: 12px; margin-right: -2px; opacity: .7; }
.ex .ex-btn-texte { padding: 0 6px 0 10px; }
.ex .ex-btn-lib { min-width: 26px; text-align: left; }
@media (hover: hover) { .ex .ex-btn:hover:not(:disabled) { background: var(--accent); color: var(--accent-foreground); } }
.ex .ex-btn:active:not(:disabled) { transform: scale(.96); }
.ex .ex-btn:focus-visible { outline: none; box-shadow: var(--anneau); color: var(--foreground); }
.ex .ex-btn[aria-pressed="true"], .ex .ex-btn[aria-expanded="true"] { background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary); }
.ex .ex-btn:disabled { opacity: .38; cursor: default; }
.ex .ex-btn.ex-teinte::after {
  content: ""; position: absolute; left: 8px; right: 8px; bottom: 4px; height: 3px; border-radius: 2px;
  background: var(--ex-teinte); box-shadow: 0 0 0 1px color-mix(in srgb, var(--foreground) 14%, transparent);
}

/* Barre de formule */
.ex .ex-formule {
  display: flex; align-items: center; gap: 6px; flex: none; padding: 6px var(--e3);
  background: var(--background); border-bottom: 1px solid var(--border);
}
.ex .ex-nom {
  flex: none; width: 104px; height: 30px; box-sizing: border-box; padding: 0 10px; border: 1px solid var(--input);
  border-radius: var(--r-sm); background: var(--input-bg); color: var(--foreground); font: inherit; font-size: 13px; font-weight: 600;
}
.ex .ex-sep-v { width: 1px; height: 20px; background: var(--border); flex: none; }
.ex .ex-fx {
  display: inline-flex; align-items: center; justify-content: center; flex: none; width: 30px; height: 30px; padding: 0;
  border: 0; border-radius: var(--r-sm); background: transparent; color: var(--muted-foreground); cursor: pointer;
}
@media (hover: hover) { .ex .ex-fx:hover { background: var(--accent); color: var(--foreground); } }
.ex .ex-fx[aria-expanded="true"] { background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary); }
.ex .ex-saisie {
  flex: 1; min-width: 0; height: 30px; box-sizing: border-box; padding: 6px 10px; border: 1px solid var(--input);
  border-radius: var(--r-sm); background: var(--input-bg); color: var(--foreground); font: inherit; font-size: 13px; line-height: 16px;
  resize: none; overflow: hidden; white-space: pre;
}
.ex .ex-nom:focus-visible, .ex .ex-saisie:focus, .ex .ex-fx:focus-visible { outline: none; border-color: var(--ring); box-shadow: var(--anneau); }

/* Grille virtualisée */
.ex .ex-corps { position: relative; flex: 1; min-height: 0; }
.ex .ex-defile {
  position: absolute; inset: 0; overflow: auto; background: var(--card); outline: none; cursor: cell;
  touch-action: pan-x pan-y; overscroll-behavior: contain; font-variant-numeric: proportional-nums;
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent;
}
.ex .ex-defile.ex-redim-c { cursor: col-resize; }
.ex .ex-defile.ex-redim-r { cursor: row-resize; }
.ex .ex-espace { position: relative; }
.ex .ex-p { position: absolute; left: 0; top: 0; z-index: 1; }
.ex .ex-s { position: sticky; height: 0; }
.ex .ex-s-haut { top: 0; z-index: 4; }
.ex .ex-s-gauche { left: 0; z-index: 3; }
.ex .ex-s-coin { top: 0; left: 0; z-index: 5; }
.ex .ex-fond { position: absolute; left: 0; top: 0; background: var(--card); }
.ex .ex-s-haut > .ex-fond { box-shadow: 0 1px 0 var(--border); transition: box-shadow .2s var(--courbe); }
.ex .ex-s-gauche > .ex-fond { box-shadow: 1px 0 0 var(--border); transition: box-shadow .2s var(--courbe); }
.ex .ex-s-haut.ex-ombre > .ex-fond { box-shadow: 0 1px 0 var(--border), 0 6px 10px -8px oklch(0.2 0.03 262 / .35); }
.ex .ex-s-gauche.ex-ombre > .ex-fond { box-shadow: 1px 0 0 var(--border), 6px 0 10px -8px oklch(0.2 0.03 262 / .35); }
.ex .ex-cases { position: absolute; left: 0; top: 0; }
.ex .ex-r { position: absolute; left: 0; width: 0; }
.ex .ex-c {
  position: absolute; top: 0; height: 100%; box-sizing: border-box; display: flex; align-items: flex-end; gap: 4px;
  padding: 0 6px 4px; overflow: hidden; white-space: pre; color: var(--foreground);
  border-right: 1px solid var(--ex-grille); border-bottom: 1px solid var(--ex-grille);
}
.ex .ex-c.ex-fusion { z-index: 1; background: var(--card); }
.ex .ex-c.ex-deborde { z-index: 1; overflow: hidden; background: var(--card); }
.ex .ex-t { min-width: 0; overflow: hidden; }
.ex .ex-a-gauche { justify-content: flex-start; }
.ex .ex-a-centre { justify-content: center; }
.ex .ex-a-droite { justify-content: flex-end; }
.ex .ex-v-haut { align-items: flex-start; padding-top: 4px; }
.ex .ex-v-milieu { align-items: center; padding-bottom: 0; }
.ex .ex-c.ex-retour { white-space: pre-wrap; align-items: flex-start; padding-top: 4px; }
.ex .ex-c.ex-retour.ex-v-milieu { align-items: center; padding-top: 0; }
.ex .ex-c.ex-num, .ex .ex-stat b { font-variant-numeric: tabular-nums; }
.ex .ex-retour .ex-t { overflow-wrap: anywhere; }
.ex .ex-gras { font-weight: 600; }
.ex .ex-ital { font-style: italic; }
.ex .ex-soul .ex-t { text-decoration: underline; }
.ex .ex-barre-t .ex-t { text-decoration: line-through; }
.ex .ex-soul-barre .ex-t { text-decoration: underline line-through; }
.ex .ex-erreur { color: var(--destructive); font-weight: 600; }
.ex .ex-avec-filtre { padding-right: 3px; }
.ex .ex-avec-filtre .ex-t { flex: 1 1 auto; }
.ex .ex-a-droite.ex-avec-filtre .ex-t { text-align: right; }
.ex .ex-filtre-btn {
  display: inline-flex; align-items: center; justify-content: center; flex: none; width: 20px; height: 20px; margin: 0 0 -1px auto; padding: 0;
  border: 1px solid var(--border); border-radius: 6px; background: var(--card); color: var(--muted-foreground); cursor: pointer;
}
.ex .ex-filtre-btn .ex-ico { width: 13px; height: 13px; }
.ex .ex-filtre-btn.actif { color: var(--primary); border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); background: color-mix(in srgb, var(--primary) 10%, var(--card)); }
@media (hover: hover) { .ex .ex-filtre-btn:hover { color: var(--foreground); border-color: var(--input-strong); } }

/* En têtes */
.ex .ex-r-tete { top: 0; height: 26px; }
.ex .ex-tc, .ex .ex-tl {
  position: absolute; box-sizing: border-box; display: flex; align-items: center; justify-content: center;
  color: var(--muted-foreground); background: var(--ex-tete); font-size: 12px; font-weight: 400;
  border-right: 1px solid var(--ex-grille); border-bottom: 1px solid var(--ex-grille);
}
.ex .ex-tc { top: 0; height: 26px; }
.ex .ex-tl { left: 0; width: var(--ex-hw); justify-content: flex-end; padding-right: 10px; }
.ex .ex-tc.dans, .ex .ex-tl.dans { background: var(--ex-tete-dans); color: var(--foreground); font-weight: 600; }
.ex .ex-tc.dans { box-shadow: inset 0 -2px 0 var(--primary); }
.ex .ex-tl.dans { box-shadow: inset -2px 0 0 var(--primary); }
.ex .ex-tc.pleine, .ex .ex-tl.pleine { background: color-mix(in srgb, var(--primary) 20%, var(--muted)); }
.ex .ex-coin {
  position: absolute; left: 0; top: 0; width: var(--ex-hw); height: 26px; padding: 0; border: 0;
  border-right: 1px solid var(--ex-grille); border-bottom: 1px solid var(--ex-grille); background: var(--ex-tete); cursor: pointer;
}
.ex .ex-coin::after {
  content: ""; position: absolute; right: 5px; bottom: 5px; border: 5px solid transparent;
  border-right-color: var(--input-strong); border-bottom-color: var(--input-strong); border-radius: 0 0 2px 0;
}

/* Sélection */
.ex .ex-sel { position: absolute; left: 0; top: 0; z-index: 2; pointer-events: none; }
.ex .ex-sel > div { position: absolute; box-sizing: border-box; }
.ex .ex-plage { background: var(--ex-sel-fond); border: 1px solid var(--primary); }
.ex .ex-active { box-shadow: inset 0 0 0 2px var(--muted-foreground); }
.ex .ex-defile:focus .ex-active, .ex .ex-defile:focus-within .ex-active { box-shadow: inset 0 0 0 2px var(--primary); }
.ex .ex-plage.sans-h { border-top-width: 0; }
.ex .ex-plage.sans-b { border-bottom-width: 0; }
.ex .ex-plage.sans-g { border-left-width: 0; }
.ex .ex-plage.sans-d { border-right-width: 0; }
.ex .ex-copie { border: 2px dashed var(--primary); }
.ex .ex-recopie { border: 2px dashed var(--muted-foreground); background: color-mix(in srgb, var(--muted-foreground) 6%, transparent); }
.ex .ex-pointage { border: 2px solid var(--chart-4); background: color-mix(in srgb, var(--chart-4) 10%, transparent); }
.ex .ex-sel > .ex-poignee {
  width: 9px; height: 9px; margin: -5px 0 0 -5px; border: 1.5px solid var(--card); border-radius: 2px;
  background: var(--primary); pointer-events: auto; cursor: crosshair;
}
.ex .ex-sel > .ex-bout { display: none; }
.ex.ex-tactile .ex-sel > .ex-poignee { display: none; }
.ex.ex-tactile .ex-sel > .ex-bout {
  display: block; width: 22px; height: 22px; margin: -11px 0 0 -11px; border: 2px solid var(--primary); border-radius: 50%;
  background: var(--card); box-shadow: var(--ombre-flotte); pointer-events: auto; touch-action: none;
}
.ex .ex-sel > .ex-bout::after { content: ""; position: absolute; inset: -10px; }
@media (prefers-reduced-motion: no-preference) {
  .ex .ex-copie { animation: ex-fourmis 1s linear infinite; border-style: dashed; }
}
@keyframes ex-fourmis { 50% { border-color: color-mix(in srgb, var(--primary) 45%, transparent); } }

/* Édition en place */
.ex .ex-editeur {
  position: absolute; z-index: 6; box-sizing: border-box; margin: 0; padding: 3px 5px; min-height: 26px;
  border: 2px solid var(--primary); border-radius: 2px; background: var(--card); color: var(--foreground);
  font: inherit; font-size: 13px; line-height: 16px; resize: none; outline: none; overflow: hidden; white-space: pre;
  box-shadow: var(--ombre-flotte); -webkit-user-select: text; user-select: text; cursor: text;
}
.ex .ex-editeur.ex-a-droite { text-align: right; }
.ex .ex-editeur.ex-a-centre { text-align: center; }

/* Graphiques posés sur la feuille */
.ex .ex-graphs { position: absolute; left: 0; top: 0; z-index: 3; }
.ex .ex-graph {
  position: absolute; box-sizing: border-box; display: flex; flex-direction: column; overflow: hidden; cursor: default;
  background: var(--card); border-radius: 16px; box-shadow: var(--ombre-carte), 0 0 0 1px var(--border);
  outline: none; transition: box-shadow .15s var(--courbe);
}
.ex .ex-graph:focus-visible, .ex .ex-graph:focus-within { box-shadow: var(--ombre-flotte), 0 0 0 2px var(--ring); }
.ex .ex-graph-tete {
  display: flex; align-items: center; gap: 6px; flex: none; height: 36px; padding: 0 6px 0 10px; cursor: grab; touch-action: none;
}
.ex .ex-graph-tete:active { cursor: grabbing; }
.ex .ex-graph-poignee { width: 14px; height: 14px; color: var(--muted-foreground); opacity: .7; }
.ex .ex-graph-titre { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 600; }
.ex .ex-graph-outils { display: flex; gap: 2px; opacity: 0; transition: opacity .15s var(--courbe); }
.ex .ex-graph:hover .ex-graph-outils, .ex .ex-graph:focus-within .ex-graph-outils { opacity: 1; }
@media (hover: none) { .ex .ex-graph-outils { opacity: 1; } }
.ex .ex-graph-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; padding: 0; border: 0;
  border-radius: 50%; background: transparent; color: var(--muted-foreground); cursor: pointer;
}
.ex .ex-graph-btn .ex-ico { width: 15px; height: 15px; }
@media (hover: hover) { .ex .ex-graph-btn:hover { background: var(--accent); color: var(--foreground); } }
.ex .ex-graph-btn:focus-visible { outline: none; box-shadow: var(--anneau); }
.ex .ex-graph-corps { flex: 1; min-height: 0; padding: 0 8px 8px; }
.ex .ex-g-svg, .ex-impression .ex-g-svg { display: block; width: 100%; height: 100%; overflow: visible; font-family: inherit; }
.ex .ex-graph-taille {
  position: absolute; right: 2px; bottom: 2px; width: 16px; height: 16px; cursor: nwse-resize; touch-action: none;
  background: linear-gradient(135deg, transparent 55%, var(--input-strong) 55% 62%, transparent 62% 72%, var(--input-strong) 72% 79%, transparent 79%);
  border-radius: 0 0 12px 0; opacity: .7;
}
.ex .ex-s1, .ex-impression .ex-s1 { fill: var(--th-s1, var(--chart-1)); }
.ex .ex-s2, .ex-impression .ex-s2 { fill: var(--th-s2, var(--chart-2)); }
.ex .ex-s3, .ex-impression .ex-s3 { fill: var(--th-s3, var(--chart-4)); }
.ex .ex-s4, .ex-impression .ex-s4 { fill: var(--th-s4, var(--chart-5)); }
.ex .ex-s5, .ex-impression .ex-s5 { fill: var(--th-s5, var(--chart-3)); }
.ex .ex-s6, .ex-impression .ex-s6 { fill: var(--th-s6, var(--sidebar-primary)); }
.ex .ex-t1, .ex-impression .ex-t1 { stroke: var(--th-s1, var(--chart-1)); }
.ex .ex-t2, .ex-impression .ex-t2 { stroke: var(--th-s2, var(--chart-2)); }
.ex .ex-t3, .ex-impression .ex-t3 { stroke: var(--th-s3, var(--chart-4)); }
.ex .ex-t4, .ex-impression .ex-t4 { stroke: var(--th-s4, var(--chart-5)); }
.ex .ex-t5, .ex-impression .ex-t5 { stroke: var(--th-s5, var(--chart-3)); }
.ex .ex-t6, .ex-impression .ex-t6 { stroke: var(--th-s6, var(--sidebar-primary)); }
.ex .ex-g-part, .ex-impression .ex-g-part { stroke: var(--card); stroke-width: 2; }
.ex .ex-g-barre { transition: opacity .15s var(--courbe); }
@media (hover: hover) { .ex .ex-g-barre:hover, .ex .ex-g-part:hover { opacity: .82; } }
.ex .ex-g-ligne, .ex-impression .ex-g-ligne { fill: none; stroke-width: 2.25; stroke-linejoin: round; stroke-linecap: round; }
.ex .ex-g-point, .ex-impression .ex-g-point { fill: var(--card); stroke-width: 2; }
.ex .ex-g-grille, .ex-impression .ex-g-grille { stroke: var(--border); stroke-width: 1; }
.ex .ex-g-axe, .ex-impression .ex-g-axe { stroke: var(--border-strong); stroke-width: 1; }
.ex .ex-g-lib, .ex-impression .ex-g-lib { fill: var(--muted-foreground); font-size: 11px; }
.ex .ex-g-leg, .ex-impression .ex-g-leg { fill: var(--foreground); font-size: 11.5px; }
.ex .ex-g-vide { fill: var(--muted-foreground); font-size: 13px; }

/* Pied : onglets des feuilles et calculs de la sélection */
.ex .ex-pied {
  display: flex; align-items: center; gap: var(--e1); flex: none; min-height: 46px; padding: 6px var(--e3);
  background: var(--sidebar); border-top: 1px solid var(--border);
}
.ex .ex-onglets { display: flex; align-items: center; gap: 4px; min-width: 0; flex: 0 1 auto; overflow-x: auto; scrollbar-width: none; padding: 2px; }
.ex .ex-onglets::-webkit-scrollbar { display: none; }
.ex .ex-onglet {
  display: inline-flex; align-items: center; gap: 4px; flex: none; min-height: 32px; padding: 0 14px; border: 0; border-radius: 999px;
  background: transparent; color: var(--muted-foreground); font: inherit; font-size: 13px; font-weight: 600; white-space: nowrap; cursor: pointer;
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent;
  transition: background-color .15s var(--courbe), color .15s var(--courbe);
}
.ex .ex-onglet[aria-selected="true"] { padding-right: 8px; background: var(--sidebar-primary); color: var(--sidebar-primary-foreground); }
@media (hover: hover) { .ex .ex-onglet:not([aria-selected="true"]):hover { background: var(--sidebar-accent); color: var(--foreground); } }
.ex .ex-onglet:focus-visible { outline: none; box-shadow: var(--anneau); }
.ex .ex-onglet.ex-glisse { position: relative; z-index: 2; box-shadow: var(--ombre-flotte); cursor: grabbing; }
.ex .ex-onglet-nom { max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.ex .ex-onglet-options { display: inline-flex; width: 18px; height: 18px; align-items: center; justify-content: center; border-radius: 50%; }
.ex .ex-onglet-options .ex-ico { width: 13px; height: 13px; }
@media (hover: hover) { .ex .ex-onglet-options:hover { background: color-mix(in srgb, var(--sidebar-primary-foreground) 18%, transparent); } }
.ex .ex-onglet-champ {
  flex: none; width: 140px; height: 32px; box-sizing: border-box; padding: 0 12px; border: 1px solid var(--ring); border-radius: 999px;
  background: var(--input-bg); color: var(--foreground); font: inherit; font-size: 13px; font-weight: 600; box-shadow: var(--anneau); outline: none;
}
.ex .ex-ajout-feuille {
  display: inline-flex; align-items: center; justify-content: center; flex: none; width: 32px; height: 32px; padding: 0;
  border: 0; border-radius: 50%; background: transparent; color: var(--muted-foreground); cursor: pointer;
}
@media (hover: hover) { .ex .ex-ajout-feuille:hover { background: var(--sidebar-accent); color: var(--foreground); } }
.ex .ex-ajout-feuille:focus-visible { outline: none; box-shadow: var(--anneau); }
.ex .ex-stats { display: flex; align-items: center; gap: var(--e4); margin-left: auto; min-width: 0; overflow: hidden; font-size: 12px; color: var(--muted-foreground); white-space: nowrap; }
.ex .ex-stat b { margin-left: 6px; color: var(--foreground); font-weight: 600; }

/* Menus, palettes, filtre */
.ex .ex-pop {
  position: absolute; z-index: 40; box-sizing: border-box; min-width: 210px; max-width: min(360px, calc(100% - 16px)); overflow: auto;
  padding: 6px; background: var(--popover); color: var(--popover-foreground); border-radius: var(--r);
  box-shadow: var(--ombre-flotte), 0 0 0 1px var(--border); font-size: 14px; line-height: 20px;
}
@media (prefers-reduced-motion: no-preference) {
  .ex .ex-pop { animation: ex-apparait .14s var(--courbe); transform-origin: top left; }
}
@keyframes ex-apparait { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
.ex .ex-pop-item {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 34px; box-sizing: border-box; padding: 6px 10px;
  border: 0; border-radius: var(--r-sm); background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.ex .ex-pop-item .ex-ico { color: var(--muted-foreground); }
@media (hover: hover) { .ex .ex-pop-item:hover { background: var(--accent); } }
.ex .ex-pop-item:focus-visible { outline: none; background: var(--accent); box-shadow: inset 0 0 0 2px var(--ring); }
.ex .ex-pop-item[aria-checked="true"] { color: var(--primary); font-weight: 600; }
.ex .ex-pop-item[aria-checked="true"]::after { content: "✓"; margin-left: auto; padding-left: 8px; }
.ex .ex-pop-lib { min-width: 0; }
.ex .ex-pop-aide { margin-left: auto; padding-left: 12px; font-size: 12px; color: var(--muted-foreground); font-weight: 400; white-space: nowrap; }
.ex .ex-pop-item[aria-checked="true"] .ex-pop-aide { margin-left: auto; }
.ex .ex-pop-fonctions { width: 340px; max-height: 420px; }
.ex .ex-pop-fonctions .ex-pop-item { flex-wrap: wrap; gap: 0 10px; }
.ex .ex-pop-fonctions .ex-pop-lib { font-weight: 600; min-width: 96px; }
.ex .ex-pop-fonctions .ex-pop-aide { margin-left: 0; padding-left: 0; white-space: normal; }
.ex .ex-pop-titre { padding: 4px 8px 6px; font-size: 12px; font-weight: 600; color: var(--muted-foreground); }
.ex .ex-pop-sep { height: 1px; margin: 6px 4px; background: var(--border); }
.ex .ex-pop-lab { display: grid; gap: 4px; padding: 4px 6px; font-size: 12px; font-weight: 600; color: var(--muted-foreground); }
.ex .ex-pop-recherche { width: 100%; box-sizing: border-box; color: var(--foreground); font-weight: 400; }
.ex .ex-pop-filtre .ex-pop-recherche { margin: 2px 0 4px; }
.ex .ex-pop-coches { display: grid; gap: 1px; max-height: 220px; overflow: auto; padding: 2px; }
.ex .ex-coche { display: flex; align-items: center; gap: 8px; min-height: 30px; padding: 2px 8px; border-radius: var(--r-sm); cursor: pointer; }
.ex .ex-coche[hidden] { display: none; }
@media (hover: hover) { .ex .ex-coche:hover { background: var(--accent); } }
.ex .ex-coche input { width: 16px; height: 16px; margin: 0; accent-color: var(--primary); }
.ex .ex-coche-tout { font-weight: 600; }
.ex .ex-muet { color: var(--muted-foreground); font-style: italic; }
.ex .ex-pop-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 8px 4px 2px; }
.ex .ex-pop-palette { min-width: 0; }
.ex .ex-swatches { display: grid; grid-template-columns: repeat(4, 34px); gap: 8px; padding: 2px 8px 8px; }
.ex .ex-swatch {
  width: 34px; height: 34px; padding: 0; border: 1px solid color-mix(in srgb, var(--foreground) 16%, transparent); border-radius: 50%;
  cursor: pointer; transition: transform .1s var(--courbe);
}
.ex .ex-swatch:active { transform: scale(.94); }
.ex .ex-swatch:focus-visible, .ex .ex-swatch[aria-checked="true"] { outline: none; box-shadow: 0 0 0 2px var(--popover), 0 0 0 4px var(--ring); }

.ex .ex-annonce { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.ex.ex-lecture .ex-saisie { color: var(--muted-foreground); }
.ex-impression { display: none; }

/* Téléphone */
@media (max-width: 640px) {
  .ex .ex-barre { padding: 4px var(--e2); }
  .ex .ex-btn { min-width: 40px; height: 40px; }
  .ex .ex-formule { padding: 6px var(--e2); gap: 4px; }
  .ex .ex-nom { width: 70px; padding: 0 6px; font-size: 16px; height: 36px; }
  .ex .ex-saisie { font-size: 16px; height: 36px; padding: 7px 8px; line-height: 20px; }
  .ex .ex-fx { width: 34px; height: 36px; }
  .ex .ex-sep-v { display: none; }
  .ex .ex-editeur { font-size: 16px; line-height: 18px; }
  .ex .ex-pied { padding: 4px var(--e2); }
  .ex .ex-onglet { min-height: 36px; }
  .ex .ex-ajout-feuille { width: 36px; height: 36px; }
  .ex .ex-stat:not(:first-child) { display: none; }
  .ex .ex-pop-item { min-height: 40px; }
}

/* Impression (PDF) : la plage utilisée de la feuille active, en tableau */
@media print {
  html.impression-document .ex { display: none !important; }
  html.impression-document .ex-impression {
    --card: #fff; --border: #d5dae3; --border-strong: #9aa3b2; --foreground: #111; --muted-foreground: #555;
    display: block !important; color: #111; font: 10pt/1.35 var(--f);
  }
  html.impression-document .ex-imp-titre { margin: 0 0 2mm; font-size: 15pt; font-weight: 600; }
  html.impression-document .ex-imp-sous { margin: 0 0 4mm; color: #555; font-size: 9pt; }
  html.impression-document .ex-imp-sous:empty { display: none; }
  html.impression-document .ex-imp-table { border-collapse: collapse; table-layout: fixed; width: auto; max-width: 100%; }
  html.impression-document .ex-imp-table tr { break-inside: avoid; }
  html.impression-document .ex-imp-c {
    padding: 1.2mm 2mm; border: .2mm solid #c9ced8; vertical-align: bottom; white-space: pre-wrap; overflow-wrap: anywhere;
    color: #111; -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
  html.impression-document .ex-imp-c.ex-a-droite { text-align: right; }
  html.impression-document .ex-imp-c.ex-a-centre { text-align: center; }
  html.impression-document .ex-imp-c.ex-v-haut { vertical-align: top; }
  html.impression-document .ex-imp-c.ex-v-milieu { vertical-align: middle; }
  html.impression-document .ex-imp-c.ex-gras { font-weight: 600; }
  html.impression-document .ex-imp-c.ex-ital { font-style: italic; }
  html.impression-document .ex-imp-c.ex-soul { text-decoration: underline; }
  html.impression-document .ex-imp-c.ex-barre-t { text-decoration: line-through; }
  html.impression-document .ex-imp-c.ex-erreur { color: #b42318; }
  html.impression-document .ex-imp-graph { break-inside: avoid; margin: 6mm 0 0; max-width: 170mm; }
  html.impression-document .ex-imp-graph figcaption { margin-bottom: 2mm; font-weight: 600; }
  html.impression-document .ex-imp-graph .ex-g-svg { height: auto; aspect-ratio: auto; }
}

/* Thème du classeur (editeur-themes.js, EDITEURS.md 3.4) : la grille prend le fond, le texte et la
   police du thème ; l'en tête et les bandes sont posés case par case par editeur-tableur.js. */
.ex.ex-avec-theme .ex-defile {
  --card: var(--th-fond); --foreground: var(--th-texte);
  --ex-grille: color-mix(in srgb, var(--th-texte) 16%, var(--th-fond));
  --border: color-mix(in srgb, var(--th-texte) 22%, var(--th-fond));
  color: var(--th-texte); font-family: var(--th-police-texte);
}
.ex.ex-avec-theme .ex-defile .ex-c { --ex-trait: var(--th-texte); }
.ex.ex-avec-theme .ex-graph { color: var(--th-texte); }
.ex.ex-avec-theme .ex-graph-titre { font-family: var(--th-police-titre); color: var(--th-titre); }
.ex .ex-btn[aria-haspopup="dialog"].ex-btn-texte { padding: 0 6px 0 8px; gap: 4px; }
.ex-impression.ex-avec-theme { font-family: var(--th-police-texte); color: var(--th-texte); }
.ex-impression.ex-avec-theme .ex-imp-titre { font-family: var(--th-police-titre); color: var(--th-titre); }
