/* Pixel art mathématique : la grille à gauche, la légende (ou la palette) à droite */
#features.px-section { padding-top: 1em; }
.px-outil { max-width: 72em; margin: 0 auto; text-align: left; }
.px-outil *:focus-visible { outline: 3px solid #f2b01e; outline-offset: 2px; }
.px-outil:fullscreen { background: #fff; padding: 1em 2em; overflow: auto; max-width: none; }
.px-outil:-webkit-full-screen { background: #fff; padding: 1em 2em; overflow: auto; max-width: none; }

/* Barre du haut : Dessiner / Fiche élève / Correction au centre, plein écran à droite */
.px-barre { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: .6em; margin-bottom: .8em; }
.px-barre .px-seg { grid-column: 2; font: 600 1.05em/1.2 'Fredoka', 'Nunito', sans-serif; }
.px-plein { grid-column: 3; justify-self: end; width: 2.6em; height: 2.6em; border-radius: 50%; border: 2px solid #e5e5e5; background: #fff; color: #16855a; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.px-plein:hover { border-color: #16855a; }
.px-plein .icon:before { margin: 0; }

/* Choix en « segments » (un seul possible) */
.px-seg { display: inline-flex; flex-wrap: wrap; background: #f1f4f2; border-radius: 2em; padding: .25em; gap: .2em; }
.px-seg .px-puce { border: 0; background: transparent; color: #666; padding: .45em 1.15em; }
.px-seg .px-puce:hover { background: #fff; }
.px-seg .px-puce.actif { background: #16855a; color: #fff; box-shadow: 0 2px 6px rgba(22, 133, 90, .25); }

.px-carte { display: grid; grid-template-columns: minmax(0, 1fr) 16em; gap: 1.2em; align-items: start; background: #fff; border: 2px solid #e5e5e5; border-radius: 1.2em; padding: 1em 1.2em; }
.px-outil:fullscreen .px-carte { grid-template-columns: minmax(0, 1fr) 18em; }

/* La grille : la taille du texte suit la largeur d'une case (--n cases, --l caractères au plus) */
.px-grille { container-type: inline-size; width: 100%; max-width: 40em; margin: 0 auto; }
.px-outil:fullscreen .px-grille { max-width: calc(100vh - 9em); }
/* plein écran : la grille à gauche (à la hauteur de l'écran), palette, réglages et modèles en colonne à droite */
.px-outil:fullscreen { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 1.5em; align-items: start; align-content: start; padding: .8em 1.5em; }
.px-outil:fullscreen > .px-barre { grid-column: 1 / -1; }
.px-outil:fullscreen > .px-carte { display: contents; }
.px-outil:fullscreen .px-grille { grid-column: 1; grid-row: 2 / span 4; width: calc(100vh - 6em); max-width: 50vw; margin: 0; }
.px-outil:fullscreen .px-legende, .px-outil:fullscreen > .px-reglages, .px-outil:fullscreen > .px-galerie, .px-outil:fullscreen > .px-code-zone { grid-column: 2; }
.px-outil:fullscreen > .px-reglages { margin-top: 0; }
/* fiche élève et correction projetées : la grille passe avant les réglages (qui restent dans « Dessiner ») */
.px-outil:fullscreen:has(.px-g:not(.dessin)) > .px-reglages, .px-outil:fullscreen:has(.px-g:not(.dessin)) > .px-galerie { display: none; }
.px-outil:fullscreen .px-palette { grid-template-columns: repeat(auto-fill, minmax(7em, 1fr)); }
.px-outil:fullscreen .px-tacts { grid-template-columns: repeat(auto-fit, minmax(14em, 1fr)); margin-top: .6em; padding-top: .6em; }
.px-g { display: grid; grid-template-columns: repeat(var(--n), 1fr); border: 2px solid #444; background: #fff; -webkit-user-select: none; user-select: none; }
.px-g.dessin { touch-action: none; cursor: crosshair; }
.px-c { aspect-ratio: 1; text-align: center; border-right: 1px solid #bbb; border-bottom: 1px solid #bbb; display: flex; align-items: center; justify-content: center; overflow: hidden; white-space: nowrap; color: #333;
	font: 600 min(calc(100cqw / var(--n) / var(--l) * 1.55), calc(100cqw / var(--n) * .36))/1.1 'Nunito', sans-serif; letter-spacing: -.02em; }
.px-g .px-c.bord-d { border-right: 0; }
.px-g .px-c.bord-b { border-bottom: 0; }
.px-g.corr .px-c { color: rgba(0, 0, 0, .55); }
.px-g.corr .px-c.fonce { color: rgba(255, 255, 255, .8); }

/* Colonne de droite : palette, ou légende + actions */
.px-legende h3 { margin: 0 0 .6em; font: 600 1.05em/1.3 'Fredoka', 'Nunito', sans-serif; color: #444; }
.px-leg { display: flex; align-items: center; gap: .6em; padding: .3em .2em; color: #444; line-height: 1.3; }
.px-leg b { font: 700 1.15em/1.2 'Fredoka', 'Nunito', sans-serif; color: #333; }
.px-pastille { flex: none; width: 1.6em; height: 1.6em; border-radius: .4em; border: 2px solid rgba(0, 0, 0, .25); }
.px-palette { display: grid; grid-template-columns: 1fr 1fr; gap: .4em; }
.px-coul { display: flex; align-items: center; gap: .5em; padding: .35em .5em; border: 2px solid #eee; border-radius: .8em; cursor: pointer; color: #555; font-size: .92em; -webkit-user-select: none; user-select: none; }
.px-coul:hover { border-color: #5cc79a; }
.px-coul.actif { border-color: #16855a; background: #eaf7f1; color: #16855a; font-weight: 700; }
.px-note { margin: .8em 0 0; padding: .6em .8em; border-radius: 10px; background: #fff6e0; color: #7a5200; font-size: .9em; line-height: 1.35; }
.px-tacts { display: grid; gap: .5em; margin-top: 1.1em; padding-top: 1em; border-top: 2px dashed #eee; }
.px-tact { display: flex; align-items: center; gap: .7em; padding: .55em .7em; border: 2px solid #e5e5e5; border-radius: .9em; background: #fff; cursor: pointer; color: #444; line-height: 1.25; -webkit-user-select: none; user-select: none; transition: border-color .2s, background .2s; }
.px-tact:hover { border-color: #16855a; background: #f6fcf9; }
.px-tact .icon { flex: none; width: 2.2em; height: 2.2em; border-radius: 50%; background: #eaf7f1; color: #16855a; display: flex; align-items: center; justify-content: center; }
.px-tact .icon:before { margin: 0; }
.px-tact:first-child .icon { background: #16855a; color: #fff; }
.px-tact b { display: block; font-weight: 700; font-size: .95em; }
.px-tact small { display: block; color: #888; font-size: .8em; }
.px-legende .pdf-rappel { margin: .2em 0 0; font-size: .82em; color: #16855a; line-height: 1.4; }

/* Réglages, sous l'outil : taille et calculs côte à côte */
.px-reglages { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1em; margin-top: 1em; padding: 1em 1.2em; background: #fff; border: 2px solid #e5e5e5; border-radius: 1.2em; }
.px-groupe { display: flex; flex-direction: column; gap: .5em; align-items: flex-start; }
.px-groupe:first-child { flex-direction: row; flex-wrap: wrap; align-items: center; gap: .5em 1em; padding-bottom: 1em; border-bottom: 2px dashed #eee; }
.px-titre { font-weight: 600; color: #555; font-size: .9em; }
.px-titre .icon { color: #16855a; margin-right: .3em; }
.px-puces { display: flex; flex-wrap: wrap; gap: .5em; }
.px-puce { padding: .35em 1em; border: 2px solid #e5e5e5; border-radius: 2em; background: #fff; color: #777; cursor: pointer; font-size: .92em; -webkit-user-select: none; user-select: none; }
.px-puce:hover { border-color: #5cc79a; }
.px-puce.actif { background: #16855a; border-color: #16855a; color: #fff; }
.px-groupe-large { min-width: 0; }
.px-nb { display: inline-block; min-width: 1.4em; margin-left: .3em; padding: 0 .35em; border-radius: 1em; background: #f2b01e; color: #fff; font-size: .8em; line-height: 1.4em; text-align: center; }
.px-activites { display: grid; gap: .55em; width: 100%; }
.px-activites { gap: .7em; }
.px-theme { display: flex; flex-direction: column; gap: .35em; }
.px-theme-nom { font-size: .74em; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: #999; }
.px-theme .px-puces { gap: .35em; }
.px-coche { font-size: .82em; padding: .25em .75em; }
.px-coche .icon:before { margin: 0; }
.px-choisies { display: flex; flex-wrap: wrap; align-items: center; gap: .4em; width: 100%; margin: .2em 0 0; padding: .7em .8em; background: #f6fcf9; border-radius: .9em; text-align: left; }
.px-choisies-t { font-size: .85em; font-weight: 700; color: #16855a; margin-right: .3em; }
.px-choisies-t small { font-weight: 600; color: #8bbfa8; margin-left: .2em; }
.px-choix { display: inline-flex; align-items: center; gap: .4em; padding: .2em .65em; border-radius: 2em; background: #fff; border: 1px solid #cfe9dc; color: #444; font-size: .8em; line-height: 1.5; }
.px-choix[role=button] { cursor: pointer; }
.px-choix[role=button]:hover { border-color: #c0392b; }
.px-choix small { font-weight: 700; color: #16855a; }
.px-choix .icon { color: #aaa; font-size: .85em; }
.px-choix .icon:before { margin: 0; }
.px-choix[role=button]:hover .icon { color: #c0392b; }
.px-limite { width: 100%; font-size: .8em; color: #b76a06; }
/* Galerie de modèles : une catégorie à la fois, en tuiles */
.px-galerie { margin-top: 1em; padding: 1em 1.2em; background: #fff; border: 2px solid #e5e5e5; border-radius: 1.2em; }
.px-galerie-tete { display: flex; flex-wrap: wrap; gap: .6em 1.2em; align-items: center; justify-content: center; margin-bottom: .9em; }
.px-galerie-tete .px-titre .icon { color: #16855a; margin-right: .3em; }
.px-puce small { opacity: .7; margin-left: .2em; }
.px-vignettes { display: grid; grid-template-columns: repeat(auto-fill, minmax(7.5em, 1fr)); gap: .7em; }
.px-tuile { display: flex; flex-direction: column; align-items: center; gap: .4em; padding: .6em .4em .5em; border: 2px solid #eee; border-radius: 1em; background: #fafafa; cursor: pointer; color: #555; font-size: .88em; line-height: 1.2; text-align: center; -webkit-user-select: none; user-select: none; transition: border-color .2s, transform .2s; }
.px-tuile:hover { border-color: #5cc79a; transform: translateY(-2px); }
.px-tuile svg { width: 4.2em; height: 4.2em; background: #fff; border: 1px solid #ddd; }
@media (prefers-reduced-motion: reduce) { .px-tuile { transition: none; } .px-tuile:hover { transform: none; } }
.px-astuce { margin: 1em 0 0; text-align: center; font-size: .82em; color: #999; }
.px-astuce .icon { color: #5cc79a; margin-right: .3em; }

/* Code de série */
.px-code-zone { max-width: 72em; margin: 1.2em auto 0; display: grid; gap: .8em; background: #fff; border: 2px solid #e5e5e5; border-radius: 1.2em; padding: 1em 1.2em; text-align: left; }
.px-code-zone .cc-bloc > span:first-child { display: block; font-weight: 600; color: #555; margin-bottom: .4em; }
.px-code-zone:empty { display: none; }

@media screen and (max-width: 736px) {
	.px-seg { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; scrollbar-width: none; }
	.px-seg .px-puce { padding: .4em .8em; white-space: nowrap; }
	.px-barre { grid-template-columns: minmax(0, 1fr) auto; }
	.px-barre .px-seg { grid-column: 1; font-size: .92em; }
	.px-plein { grid-column: 2; }
	.px-palette { grid-template-columns: 1fr 1fr 1fr; }
	.px-reglages, .px-galerie, .px-carte { padding: .8em; }
}
@media screen and (max-width: 980px) {
	.px-carte, .px-reglages, .px-activites { grid-template-columns: minmax(0, 1fr); }
}

/* Impression : la grille et sa légende seulement */
.px-imp-titre { display: none; }
@page { size: A4 portrait; margin: 1cm; }
@media print {
	#header, #banner, #footer, #nav, #titleBar, #navPanel, .px-barre, .px-reglages, .px-galerie, .px-astuce, .px-code-zone, .px-tacts, .px-note, .retours-zone, .retours-voile, .pdf-rappel { display: none !important; }
	html, body, #page-wrapper, #features.px-section, #features .container { margin: 0 !important; padding: 0 !important; background: #fff !important; min-height: 0 !important; }
	.px-outil { max-width: none; }
	.px-carte { display: block; border: 0; padding: 0; break-inside: avoid; }
	.px-imp-titre { display: block; font: 600 16pt/1.3 'Fredoka', 'Nunito', sans-serif; margin: 0 0 .3em; color: #000; }
	.px-imp-titre small { font: 400 11pt 'Nunito', sans-serif; color: #444; }
	.px-grille { max-width: 17cm; margin: 0 auto; }
	.px-legende { margin-top: .5cm; display: grid; grid-template-columns: 1fr 1fr; gap: .1cm .8cm; }
	.px-legende h3 { grid-column: 1 / -1; margin: 0; }
	.px-g, .px-g *, .px-pastille { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
