/* =============================================================================
   Surfaces et traces (UQTR, MAP1007, sections 3.1 à 3.3) — feuille de style
   Couleurs institutionnelles : vert 0E8954, or DBA326, noir.
   Même charte que les applications de MPU1054 (Séries de Taylor, Séries de
   fonctions…) : en-tête UQTR, vues à gauche, panneau de cartes à droite.
   La surface est verte (dégradé selon la hauteur, comme dans les figures des
   notes) ; les traces x = a, y = b et z = c sont rouge, bleue et or.
   ============================================================================= */

:root {
  --vert: #0E8954;
  --vert-fonce: #0B6E43;
  --vert-moyen: #87C4AA;
  --vert-clair: #B7DCCC;
  --vert-pale: #E4F2EB;
  --or: #DBA326;
  --or-fonce: #9C7414;
  --or-moyen: #E9C87D;
  --or-clair: #F2DFB3;
  --or-pale: #FBF4E2;
  --rouge: #C0392B;
  --rouge-clair: #F6D5D1;
  --gris: #4D4D4D;
  --gris-moyen: #9E9E9E;
  --gris-clair: #D4D4D4;
  --fond: #F5F4EE;
  --carte: #FFFFFF;
  --bord: #E3E1D8;
  --texte: #1C1C1A;
  --texte-2: #63625B;
  --ombre: 0 1px 2px rgba(0, 0, 0, .04), 0 6px 18px rgba(20, 40, 30, .06);
  --rayon: 10px;
  --police: "Carlito", "Calibri", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --police-math: "KaTeX_Main", "Latin Modern Roman", "STIX Two Text", "Cambria", "Georgia", "Times New Roman", serif;
  /* les trois plans et leurs traces */
  --tx: #C0392B;
  --ty: #2563A8;
  --tz: #C48F16;
  --tz-texte: #8A6410;
  --tx-pale: #FBEAE7;
  --ty-pale: #E6EEF8;
  --tz-pale: #FBF2DC;
  /* les courbes de niveau f(x, y) = k */
  --tk: #7B4BAE;
  --tk-texte: #6A3E9C;
  --tk-pale: #F1EAF8;
  /* chemins (section 3.2), comme dans les diapositives */
  --ch-axeX: #0E8954;
  --ch-axeY: #B03AA0;
  --ch-droite: #E38B1F;
  --ch-parabole: #2563A8;
  --ch-paraboleX: #C0392B;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  font: 15px/1.4 var(--police);
  color: var(--texte);
  background: var(--fond);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
i { font-family: var(--police-math); font-style: italic; }
.math-libelle { font-family: var(--police-math); font-size: 16px; white-space: nowrap; }
.math-libelle i { font-family: "KaTeX_Math", var(--police-math); }
sub, sup { font-size: .72em; line-height: 0; }
button, input { font-family: inherit; }
.visuellement-cache {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.katex { font-size: 1.08em; }

/* ---------------------------------------------------------------- En-tête */
.entete {
  position: relative;
  flex: none;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 9px 20px 11px;
  background: #fff;
  border-bottom: 4px solid var(--or);
  z-index: 2;
}
.entete::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -6px;
  height: 2px;
  background: var(--vert);
}
.logo { height: 38px; width: auto; }
.titre { min-width: 0; }
.titre h1 {
  margin: 0;
  font-size: 21px;
  line-height: 1.15;
  font-weight: 700;
  color: var(--vert);
  letter-spacing: .01em;
}
.sous-titre { margin: 3px 0 0; font-size: 12.5px; color: var(--texte-2); }
.actions { margin-left: auto; display: flex; gap: 8px; }

/* ---------------------------------------------------------------- Disposition */
.principal {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 400px;
  gap: 12px;
  padding: 16px 12px 12px;
}
body.sans-panneau .principal { grid-template-columns: minmax(0, 1fr); }
body.sans-panneau .panneau { display: none; }

/* La zone graphique est une grille : l'en-tête, les vues (3D et vignettes), la commande, les outils.
   La disposition des vues (app.js, appliquerDisposition) écrit les gabarits ; celui-ci est la
   disposition par défaut (la 3D en grand, les trois traces en colonne à droite). Les traits entre
   les cases sont l'écart de 1 px, sur le fond de la grille. */
.zone-graphe {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 2.25fr) minmax(0, 1fr);
  grid-template-rows: auto repeat(3, minmax(0, 1fr)) auto auto;
  grid-template-areas: "entete entete" "v3d vx" "v3d vy" "v3d vz" "cmd cmd" "outils outils";
  gap: 1px;
  background: var(--bord);
  border: 1px solid var(--bord);
  border-radius: var(--rayon);
  box-shadow: var(--ombre);
  overflow: hidden;
  container-type: inline-size;
  container-name: zone;
}
.entete-zone { grid-area: entete; display: flex; align-items: stretch; min-width: 0; background: #FBFAF6; }
#conteneur-3d { grid-area: v3d; }
#vignette-0 { grid-area: vx; }
#vignette-1 { grid-area: vy; }
#vignette-2 { grid-area: vz; }
#vignette-carte { grid-area: chemins; }
#vignette-niveaux { grid-area: vn; }
#commande { grid-area: cmd; }
.barre-outils { grid-area: outils; }
.vue-cachee { display: none !important; }

/* le choix de la disposition, à droite des onglets */
.dispositions { flex: none; display: flex; align-items: center; gap: 4px; padding: 0 10px; border-left: 1px solid var(--bord); }
.btn-dispo {
  display: inline-flex;
  padding: 5px 6px;
  border: 1px solid var(--bord);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  transition: border-color .12s, background .12s;
}
.btn-dispo svg { width: 22px; height: 15px; display: block; }
.btn-dispo rect { fill: var(--vert-pale); stroke: #6B7F74; stroke-width: 1.1; }
.btn-dispo:hover { border-color: var(--vert); }
.btn-dispo[aria-pressed="true"] { background: var(--or-pale); border-color: var(--or); }
.btn-dispo[aria-pressed="true"] rect { fill: var(--or-clair); stroke: var(--or-fonce); }
.btn-dispo:focus-visible { outline: 2px solid var(--or); outline-offset: 1px; }
/* sur un téléphone, les vues s'empilent (app.js) : pas de choix de disposition */
@media (max-width: 560px) { .dispositions { display: none; } }

/* les boutons d'une vue : mettre en grand, seule, toutes les vues (et, côte à côte, les autres vues) */
.boutons-vue { position: absolute; top: 3px; right: 6px; z-index: 3; display: flex; align-items: center; gap: 3px; }
.outils-3d { position: absolute; top: 8px; right: 10px; z-index: 2; display: flex; align-items: center; gap: 8px; }
.outils-3d .boutons-vue { position: static; }
.btn-vue {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 28px;
  min-height: 26px;
  padding: 0 7px;
  font: 600 12.5px/1 var(--police);
  color: var(--texte);
  background: rgba(255, 255, 255, .95);
  border: 1px solid var(--bord);
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color .12s, background .12s;
}
.btn-vue svg { width: 14px; height: 14px; flex: none; }
.btn-vue:hover { border-color: var(--vert); background: #F6FBF8; }
.btn-vue:focus-visible { outline: 2px solid var(--or); outline-offset: 1px; }
/* côte à côte : le sélecteur de la vue de droite (3D, x, y, z), dans la couleur des plans */
.autres-vues { display: inline-flex; background: rgba(255, 255, 255, .95); border: 1px solid var(--bord); border-radius: 6px; overflow: hidden; }
.autres-vues:empty { display: none; }
.autres-vues button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  min-height: 24px;
  padding: 0 7px;
  font: italic 14.5px/1 var(--police-math);
  color: var(--texte-2);
  background: transparent;
  border: 0;
  border-left: 1px solid var(--bord);
  cursor: pointer;
}
.autres-vues button:first-child { border-left: 0; }
.autres-vues button svg { width: 15px; height: 15px; }
.autres-vues button[data-autre="vx"] { color: var(--tx); }
.autres-vues button[data-autre="vy"] { color: var(--ty); }
.autres-vues button[data-autre="vz"] { color: var(--tz); }
.autres-vues button:hover { background: #F6FBF8; }
.autres-vues button[aria-pressed="true"] { background: var(--or-pale); box-shadow: inset 0 -2px 0 var(--or); }
.autres-vues button:focus-visible { outline: 2px solid var(--or); outline-offset: -2px; }
.autres-vues .katex { font-size: 1em; }
.boutons-vue:has(.autres-vues:not(:empty)) .libelle-vue { display: none; }
.zone-graphe .vignette > .vignette-tete { padding-right: var(--place-boutons, 96px); }

/* ---------------------------------------------------------------- Onglets */
.onglets {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  background: #FBFAF6;
}
.onglet {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  min-width: 0;
  padding: 6px 6px 7px;
  border: 0;
  border-right: 1px solid var(--bord);
  background: transparent;
  color: var(--texte-2);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.onglet:last-child { border-right: 0; }
.onglet:hover { background: #F3F7F4; color: var(--texte); }
.onglet-nom { font-size: 13.5px; font-weight: 700; letter-spacing: .02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.onglet-formule { font-size: 13px; line-height: 1.2; min-height: 1.6em; display: flex; align-items: center; }
.onglet-nom .court { display: none; }
.onglet-formule .katex { font-size: 1em; }
.onglet[aria-selected="true"] { background: #fff; color: var(--vert-fonce); }
.onglet[aria-selected="true"]::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 3px;
  background: var(--or);
}
.onglet:focus-visible { outline: 2px solid var(--or); outline-offset: -3px; }
.onglet-formule .court { display: none; }
/* trois onglets : les noms courts (Traces, Niveaux, Limites) quand la zone est étroite */
@container zone (max-width: 700px) {
  .onglet-nom .long { display: none; }
  .onglet-nom .court { display: inline; }
}
@container zone (max-width: 520px) {
  .onglet-formule .long { display: none; }
  .onglet-formule .court { display: inline; }
}

/* ---------------------------------------------------------------- Vue 3D */
.vue3d-conteneur { position: relative; min-width: 0; min-height: 0; background: #fff; container-type: inline-size; container-name: vue3d; }
.vue3d {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
}
.vue3d.tourne { cursor: grabbing; }
.vue3d.sur-surface { cursor: crosshair; }
.etiquettes { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.etiq {
  position: absolute;
  transform: translate(-50%, -50%);
  padding: 0 3px;
  font-size: 12.5px;
  line-height: 1.05;
  white-space: nowrap;
  color: var(--texte);
}
.etiq .katex { font-size: 1.04em; }
.etiq.axe { font-size: 15px; color: var(--gris); }
.etiq.axe .katex { font-size: 1.1em; }
.etiq.grad { font-size: 11px; color: var(--texte-2); font-variant-numeric: tabular-nums; }
.etiq.plan { padding: 1px 7px; font-size: 12.5px; color: #fff; border-radius: 999px; box-shadow: 0 1px 4px rgba(0, 0, 0, .18); }
.etiq.plan .katex { font-size: 1em; }
.etiq.plan.p0 { background: var(--tx); }
.etiq.plan.p1 { background: var(--ty); }
.etiq.plan.p2 { background: var(--tz); }
.etiq.plan.p3 { background: var(--tk); }
.etiq.point { transform: translate(8px, -110%); font-size: 12px; background: rgba(255, 255, 255, .88); border-radius: 3px; }
.etiq.point .katex { font-size: 1em; }
.etiq.limite { transform: translate(10px, -50%); font-size: 12px; background: rgba(255, 255, 255, .9); border-radius: 3px; font-weight: 700; }
.etiq.limite .katex { font-size: 1em; }

.titre-graphe {
  position: absolute;
  top: 8px; left: 12px;
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 3px 10px;
  font-size: 13px;
  color: var(--texte-2);
  background: rgba(255, 255, 255, .92);
  border: 1px solid var(--bord);
  border-radius: 999px;
  pointer-events: none;
  z-index: 1;
  max-width: calc(100% - var(--place-outils, 270px));
  white-space: nowrap;
  overflow: hidden;
}
.titre-graphe b { color: var(--texte); font-weight: 700; }
.titre-graphe .katex { font-size: 1.04em; }
.vues-rapides { display: flex; gap: 4px; }
/* une petite vue 3D : le titre cède la place aux boutons (app.js, .sans-titre), puis les vues rapides */
.vue3d-conteneur.sans-titre .titre-graphe { display: none; }
@container vue3d (max-width: 330px) { .vues-rapides, .outils-3d .libelle-vue { display: none; } }
.btn.mini { padding: 3px 8px; font-size: 12.5px; font-family: var(--police-math); font-style: italic; background: rgba(255, 255, 255, .92); }
.btn.mini[data-vue="3d"] { font-family: var(--police); font-style: normal; font-weight: 700; }
.message-3d {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  max-width: 80%;
  margin: 0;
  padding: 8px 14px;
  font-size: 14px;
  color: var(--texte-2);
  text-align: center;
  background: rgba(255, 255, 255, .95);
  border: 1px solid var(--bord);
  border-radius: 8px;
  z-index: 2;
}

/* ---------------------------------------------------------------- Vues 2D */
/* les vignettes sont des cases de la grille de la zone graphique */
.vues2d { display: contents; }
.vignette {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: #fff;
  container-type: inline-size;
  container-name: vignette;
}
@container vignette (max-width: 330px) { .boutons-vue .libelle-vue { display: none; } }
/* la vue en grand : texte et traits plus gros, pour la projection en classe */
.vignette.grande { --h-tete: 36px; }
.vignette.grande .vignette-tete { font-size: 15px; min-height: 36px; }
.vignette.grande .etiq2d.grad2d { font-size: 13px; }
.vignette.grande .etiq2d.axe { font-size: 18px; }
.vignette.grande .etiq2d.fantome, .vignette.grande .etiq2d.famille { font-size: 13.5px; }
.vignette.grande .etiq2d.limite { font-size: 15px; }
.vignette.grande .g-courbe { stroke-width: 4.2; }
.vignette.grande .g-famille { stroke-width: 2.4; }
.vignette.grande .g-fantome { stroke-width: 1.8; }
.vignette.grande .g-chemin { stroke-width: 3.4; }
.vignette.inactive .graphe2d, .vignette.inactive .etiquettes { opacity: .35; }
.vignette-tete {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 4px 8px 2px;
  font-size: 12.5px;
  color: var(--texte-2);
  overflow: hidden;
  white-space: nowrap;
}
.vignette-tete .katex { font-size: 1em; }
.vignette-tete .pastille-plan {
  flex: none;
  padding: 1px 7px;
  color: #fff;
  border-radius: 999px;
  font-size: 12px;
}
.vignette-tete .pastille-plan .katex { font-size: 1em; }
.vignette[data-plan="0"] .pastille-plan { background: var(--tx); }
.vignette[data-plan="1"] .pastille-plan { background: var(--ty); }
.vignette[data-plan="2"] .pastille-plan { background: var(--tz); }
.vignette[data-plan="3"] .pastille-plan { background: var(--tk); }
.vignette-tete .type { margin-left: auto; padding-left: 6px; font-weight: 700; color: var(--texte); }
/* le type de la trace suit sa pastille (l'en-tête ne montre pas l'équation) */
.vignette-tete .pastille-plan + .type { margin-left: 0; padding-left: 2px; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
/* --h-tete : la hauteur de l'en-tête (plus haute au-dessus du graphe des chemins, sur deux lignes) */
.graphe2d {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  top: var(--h-tete, 30px);
  width: 100%;
  height: calc(100% - var(--h-tete, 30px));
  display: block;
  user-select: none;
  -webkit-user-select: none;
  touch-action: pan-y;
}
.vignette .etiquettes { top: var(--h-tete, 30px); }
/* les traces en 2D (SVG) */
.g-grille { stroke: #F0EFEA; stroke-width: 1; }
.g-axe { stroke: var(--gris); stroke-width: 1.2; }
.g-fleche { fill: var(--gris); }
.g-fantome { fill: none; stroke: #C9C7BE; stroke-width: 1.2; stroke-linejoin: round; }
.g-courbe { fill: none; stroke-width: 2.6; stroke-linejoin: round; stroke-linecap: round; }
.g-courbe.p0 { stroke: var(--tx); }
.g-courbe.p1 { stroke: var(--ty); }
.g-courbe.p2 { stroke: var(--tz); }
.g-courbe.p3 { stroke: var(--tk); }
/* plusieurs courbes : la famille de traces, dans la couleur du plan */
.g-famille { fill: none; stroke-width: 1.7; stroke-linejoin: round; stroke-linecap: round; opacity: .85; }
.g-famille.p0 { stroke: var(--tx); }
.g-famille.p1 { stroke: var(--ty); }
.g-famille.p2 { stroke: var(--tz); }
.g-famille.p3 { stroke: var(--tk); }
.g-chemin { fill: none; stroke-width: 2.4; stroke-linejoin: round; stroke-linecap: round; }
.g-limite { stroke-width: 1.3; stroke-dasharray: 5 4; }
.g-ligne-t0 { stroke: var(--gris-moyen); stroke-width: 1; stroke-dasharray: 3 3; }
.g-trou { fill: #fff; stroke-width: 2; }
.g-point { stroke: #fff; stroke-width: 1.6; }
.g-survol { fill: var(--texte); stroke: #fff; stroke-width: 1.6; }
.etiq2d { position: absolute; font-size: 11px; color: var(--texte-2); white-space: nowrap; transform: translate(-50%, -50%); }
.etiq2d.axe { font-size: 13px; color: var(--gris); }
.etiq2d.grad2d { font-size: 10.5px; color: var(--texte-2); font-variant-numeric: tabular-nums; }
.etiq2d.gauche { transform: translate(-100%, -50%); }
.etiq2d.axe .katex { font-size: 1.06em; }
.etiq2d.fantome { font-size: 10.5px; color: #9C9A90; background: rgba(255, 255, 255, .85); padding: 0 2px; border-radius: 2px; }
.etiq2d.fantome .katex { font-size: 1em; }
.etiq2d.famille { font-size: 10.5px; font-weight: 700; background: rgba(255, 255, 255, .88); padding: 0 2px; border-radius: 2px; }
.etiq2d.famille .katex { font-size: 1em; }
.etiq2d.famille.p0 { color: var(--tx); }
.etiq2d.famille.p1 { color: var(--ty); }
.etiq2d.famille.p2 { color: var(--tz-texte); }
.etiq2d.famille.p3 { color: var(--tk-texte); }
.etiq2d.vide { font-size: 12.5px; color: var(--texte-2); background: rgba(255, 255, 255, .9); padding: 2px 8px; border-radius: 6px; white-space: normal; text-align: center; max-width: 80%; }
.etiq2d.vide .katex { font-size: 1em; }
.etiq2d.limite { font-size: 12.5px; font-weight: 700; color: var(--texte); background: rgba(255, 255, 255, .9); padding: 0 3px; border-radius: 3px; transform: translate(4px, -50%); }
.etiq2d.limite .katex { font-size: 1em; }

/* ---------------------------------------------------------------- Commande (curseurs) */
.commande {
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 2px 18px;
  padding: 6px 14px 7px;
  background: #FFFEFA;
}
/* une seule vue (une trace) : son curseur seulement */
.commande.commande-seule .colonne-plan { flex: 0 1 640px; }
.rangee-plan {
  flex: 1 1 250px;
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(70px, 1fr) 3.6em auto;
  align-items: center;
  gap: 6px;
}
.rangee-plan.actif-clavier .bascule-plan { box-shadow: 0 0 0 2px var(--or); }
.rangee-plan input[type="range"] { width: 100%; margin: 0; }
.rangee-plan[data-plan="0"] input[type="range"] { accent-color: var(--tx); }
.rangee-plan[data-plan="1"] input[type="range"] { accent-color: var(--ty); }
.rangee-plan[data-plan="2"] input[type="range"] { accent-color: var(--tz); }
.rangee-plan[data-plan="3"] input[type="range"] { accent-color: var(--tk); }
.rangee-plan[data-chemin="droite"] input[type="range"] { accent-color: var(--ch-droite); }
.rangee-plan[data-chemin="parabole"] input[type="range"] { accent-color: var(--ch-parabole); }
.rangee-plan output { text-align: right; font-variant-numeric: tabular-nums; font-size: 14.5px; font-weight: 700; }
.rangee-plan[data-plan="0"] output { color: var(--tx); }
.rangee-plan[data-plan="1"] output { color: var(--ty); }
.rangee-plan[data-plan="2"] output { color: var(--tz-texte); }
.rangee-plan[data-plan="3"] output { color: var(--tk-texte); }
.bascule-plan {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 8px 1px 5px;
  border-radius: 999px;
  cursor: pointer;
  user-select: none;
}
.bascule-plan.x { background: var(--tx-pale); }
.bascule-plan.y { background: var(--ty-pale); }
.bascule-plan.z { background: var(--tz-pale); }
.bascule-plan.k { background: var(--tk-pale); }
.bascule-plan.chemin-droite, .bascule-plan.chemin-parabole { padding-left: 8px; cursor: default; }
.bascule-plan.chemin-droite { background: #FCEBD6; }
.bascule-plan.chemin-parabole { background: var(--ty-pale); }
.bascule-plan input { margin: 0; width: 15px; height: 15px; }
.bascule-plan.x input { accent-color: var(--tx); }
.bascule-plan.y input { accent-color: var(--ty); }
.bascule-plan.z input { accent-color: var(--tz); }
.bascule-plan.k input { accent-color: var(--tk); }
.rangee-plan .btn.balayer { padding: 2px 8px; min-width: 2.2em; font-size: 12px; }
.rangee-plan .btn.balayer.en-cours { background: var(--or); border-color: var(--or); }
.indice-commande { font-size: 12px; color: var(--texte-2); white-space: nowrap; }
/* Sous chaque curseur : « Plusieurs courbes » (les traces x = k pour plusieurs valeurs de k) */
.colonne-plan { flex: 1 1 250px; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.colonne-plan > .rangee-plan { flex: none; }
.rangee-famille { display: flex; flex-wrap: wrap; align-items: center; gap: 3px 5px; min-height: 24px; font-size: 12.5px; color: var(--texte-2); white-space: normal; }
.bascule-famille { display: inline-flex; align-items: center; gap: 5px; padding: 0 3px 0 6px; white-space: nowrap; cursor: pointer; user-select: none; }
.bascule-famille:hover { color: var(--texte); }
.bascule-famille input { margin: 0; width: 14px; height: 14px; }
.colonne-plan[data-plan="0"] .bascule-famille input { accent-color: var(--tx); }
.colonne-plan[data-plan="1"] .bascule-famille input { accent-color: var(--ty); }
.colonne-plan[data-plan="2"] .bascule-famille input { accent-color: var(--tz); }
.colonne-plan[data-plan="3"] .bascule-famille input { accent-color: var(--tk); }
/* courbes de niveau : un seul curseur, de largeur raisonnable */
.colonne-plan[data-plan="3"] { flex: 0 1 640px; }
.colonne-plan[data-plan="3"].sans-fonction { opacity: .45; }
.reglages-famille { flex: 1 1 130px; min-width: 0; display: inline-flex; align-items: center; gap: 3px; }
.reglages-famille .btn.petit { padding: 0 7px; min-height: 22px; line-height: 20px; font-size: 13px; }
.nb-famille { min-width: 1.4em; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.colonne-plan[data-plan="0"] .nb-famille { color: var(--tx); }
.colonne-plan[data-plan="1"] .nb-famille { color: var(--ty); }
.colonne-plan[data-plan="2"] .nb-famille { color: var(--tz-texte); }
.valeurs-famille {
  flex: 1 1 60px;
  min-width: 0;
  padding: 2px 6px;
  font: 12.5px/1.25 "Latin Modern Mono", Consolas, Menlo, monospace;
  color: var(--texte);
  border: 1px solid var(--bord);
  border-radius: 5px;
  background: #FCFCFA;
}
.valeurs-famille:focus { border-color: var(--vert); outline: none; background: #fff; }
.valeurs-famille.invalide { border-color: var(--rouge); box-shadow: 0 0 0 2px rgba(192, 57, 43, .12); }

/* ---------------------------------------------------------------- Barre d'outils */
.barre-outils {
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  padding: 7px 12px;
  background: #FBFAF6;
}
.groupe-btn { display: flex; gap: 5px; }
.groupe-btn.droite { margin-left: auto; }
.barre-outils .btn { padding: 5px 10px; }
.bascule { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; color: var(--texte-2); cursor: pointer; user-select: none; }
.bascule input { accent-color: var(--vert); width: 15px; height: 15px; margin: 0; }

.bulle {
  position: absolute;
  padding: 5px 10px;
  font-size: 13px;
  line-height: 1.4;
  color: var(--texte);
  background: #fff;
  border: 1px solid var(--bord);
  border-left: 4px solid var(--or);
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .12);
  z-index: 5;
  pointer-events: none;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.bulle .katex { font-size: 1.02em; }
.bulle .petit { color: var(--texte-2); font-size: 12px; }

/* ---------------------------------------------------------------- Panneau */
.panneau {
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 2px;
  scrollbar-width: thin;
  scrollbar-color: #CFCDC4 transparent;
}
.carte {
  background: var(--carte);
  border: 1px solid var(--bord);
  border-radius: var(--rayon);
  padding: 12px 14px 13px;
  box-shadow: var(--ombre);
}
.carte h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 9px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--vert);
}
.carte h2::after { content: ""; flex: 1; height: 1px; background: var(--bord); }
.rangee { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rangee.droite { justify-content: flex-end; margin-top: 14px; }
.indice { margin: 7px 0 0; font-size: 12.5px; color: var(--texte-2); line-height: 1.45; }
.indice .katex { font-size: 1em; }

/* L'équation */
.champ-terme { display: flex; align-items: center; gap: 8px; margin-top: 2px; }
.pastille { flex: none; width: 12px; height: 12px; border-radius: 3px; }
.pastille.s { background: linear-gradient(180deg, #4FA97D, #E9C87D); box-shadow: inset 0 0 0 1px var(--vert-fonce); }
.champ-terme input {
  flex: 1;
  min-width: 0;
  padding: 7px 10px;
  font: 15px/1.2 "Latin Modern Mono", Consolas, Menlo, monospace;
  color: var(--texte);
  border: 1px solid var(--bord);
  border-radius: 8px;
  background: #FCFCFA;
}
.champ-terme input:focus { border-color: var(--vert); background: #fff; outline: none; box-shadow: 0 0 0 3px rgba(14, 137, 84, .12); }
.champ-terme input.invalide { border-color: var(--rouge); box-shadow: 0 0 0 3px rgba(192, 57, 43, .1); }
.apercu-terme {
  min-height: 40px;
  margin: 6px 0 2px;
  padding: 5px 8px;
  background: #FBFAF6;
  border-radius: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}
.apercu-terme .katex-display { margin: 0; }
.apercu-terme .katex-display > .katex { text-align: left; white-space: nowrap; }
.apercu-terme.perime { opacity: .45; }
.erreur { margin: 4px 0 6px; font-size: 13px; color: var(--rouge); }
.erreur code { font-size: 12.5px; background: var(--rouge-clair); padding: 0 4px; border-radius: 3px; color: #7A1F15; }

/* Les exemples : un titre par groupe (sections 3.1, 3.2, 3.3, tableau 3.5), puis les
   équations, comme dans les applications de MPU1054 */
.exemples-tete {
  margin: 11px 0 5px;
  padding-top: 9px;
  border-top: 1px dashed var(--bord);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--texte-2);
}
#exemples .exemples-tete:first-child { margin-top: 12px; }
.exemples { display: flex; flex-wrap: wrap; gap: 5px; }
.exemple {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  overflow: hidden;
  padding: 3px 9px;
  font-size: 12.5px;
  border: 1px solid var(--bord);
  border-radius: 999px;
  background: #fff;
  cursor: pointer;
  transition: border-color .12s, background .12s;
}
.exemple:hover { border-color: var(--vert); background: #F6FBF8; }
.exemple[aria-pressed="true"] { border-color: var(--or); background: var(--or-pale); }
.exemple .katex { font-size: 1.06em; }

/* L'en-tête du graphe des chemins (onglet des limites) : les chemins (cases à cocher,
   qui servent aussi de légende), le point (a, b) et le verdict, en quelques mots */
.vignette-tete.tete-chemins { flex-wrap: wrap; white-space: normal; column-gap: 10px; row-gap: 3px; padding: 4px 8px 3px; overflow: visible; }
.tete-chemins.sans-fonction > * { display: none; }
/* au-dessus du graphe des chemins : seuls les chemins (la première ligne) laissent la place aux boutons de la vue */
.zone-graphe .vignette > .vignette-tete.tete-chemins { padding-right: 8px; }
/* (un flottant vide, de la hauteur d'une ligne, fait de la place aux boutons sur la première ligne seulement) */
.tete-chemins .choix-chemins { flex: 1 1 100%; min-width: 0; display: block; line-height: 0; }
.tete-chemins .choix-chemins::before { content: ""; float: right; width: calc(var(--place-boutons, 96px) - 8px); height: 24px; }
.tete-chemins .choix-chemin { margin: 0 4px 5px 0; vertical-align: middle; line-height: normal; }
#vignette-carte > .boutons-vue { top: 2px; }
.choix-chemins { display: flex; flex-wrap: wrap; gap: 4px; }
.choix-chemin {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 1px 8px 1px 5px;
  border: 1px solid var(--bord);
  border-radius: 999px;
  background: #fff;
  color: var(--texte);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: border-color .12s;
}
.choix-chemin:hover { border-color: var(--c); }
.choix-chemin input { margin: 0; width: 14px; height: 14px; accent-color: var(--c); }
.choix-chemin .trait { width: 14px; height: 3px; border-radius: 2px; background: var(--c); }
.choix-chemin.eteint { color: var(--texte-2); }
.choix-chemin.eteint .trait { opacity: .3; }
.point-limite { display: inline-flex; align-items: center; gap: 2px; color: var(--texte); white-space: nowrap; }
.point-limite .math-libelle { margin-right: 4px; }
.point-limite input {
  width: 3.4em;
  padding: 1px 4px;
  font: 13px/1.2 "Latin Modern Mono", Consolas, Menlo, monospace;
  text-align: center;
  color: var(--texte);
  border: 1px solid var(--bord);
  border-radius: 5px;
  background: #FCFCFA;
}
.point-limite input:focus { border-color: var(--vert); outline: none; background: #fff; }
.vignette-tete .verdict-court { white-space: normal; text-align: right; }
.verdict-court.div { color: #A33224; }
.verdict-court.conv { color: var(--vert-fonce); }
.verdict-court.aucune { color: var(--texte-2); font-weight: 600; }

/* ---------------------------------------------------------------- Boutons */
.btn {
  border: 1px solid var(--bord);
  background: #fff;
  color: var(--texte);
  border-radius: 8px;
  padding: 6px 11px;
  font-size: 14px;
  line-height: 1.2;
  cursor: pointer;
  transition: border-color .12s, background .12s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--vert); background: #F6FBF8; }
.btn.primaire { background: var(--vert); color: #fff; border-color: var(--vert); }
.btn.primaire:hover { background: var(--vert-fonce); border-color: var(--vert-fonce); }
.btn.petit { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .45; cursor: default; }
.btn:disabled:hover { border-color: var(--bord); background: #fff; }
.btn.confirme { border-color: var(--vert); background: #E4F2EB; }
.btn[aria-pressed="true"] { border-color: var(--or); background: var(--or-pale); }
input:focus-visible, select:focus-visible, button:focus-visible { outline: 2px solid var(--or); outline-offset: 1px; }
.btn.langue { font-weight: 700; letter-spacing: .04em; border-color: var(--or); min-width: 3em; }
.btn.langue:hover { background: var(--or-clair); }

/* ---------------------------------------------------------------- Aide */
dialog {
  border: 0;
  border-radius: 12px;
  padding: 0;
  max-width: 760px;
  width: calc(100% - 40px);
  max-height: calc(100% - 40px);
  color: var(--texte);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .28);
}
dialog::backdrop { background: rgba(20, 30, 25, .45); }
.aide-corps { padding: 18px 24px 20px; border-top: 5px solid var(--or); }
dialog h2 { margin: 0 0 8px; color: var(--vert); font-size: 19px; }
dialog h3 { margin: 14px 0 5px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--texte-2); }
dialog p { margin: 0 0 6px; line-height: 1.45; }
dialog ul { margin: 0; padding-left: 18px; }
dialog li { margin: 3px 0; line-height: 1.45; }
dialog code { font: 13px "Latin Modern Mono", Consolas, Menlo, monospace; background: #F1F0EA; padding: 0 4px; border-radius: 3px; }
kbd {
  font: 12px var(--police);
  background: #F1F0EA;
  border: 1px solid var(--bord);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 6px;
}
.pied { margin: 2px 0 4px; font-size: 12px; color: var(--texte-2); text-align: center; }

/* Résultats des tests (index.html?test=1) */
#tests {
  position: fixed; left: 12px; bottom: 12px; z-index: 60;
  max-height: 60vh; overflow: auto;
  margin: 0; padding: 10px 14px;
  background: rgba(255, 255, 255, .97);
  border: 1px solid var(--bord); border-radius: 8px;
  font: 12.5px/1.45 "Latin Modern Mono", Consolas, Menlo, monospace;
  box-shadow: var(--ombre);
  white-space: pre-wrap;
  max-width: 46vw;
}

/* ---------------------------------------------------------------- Écrans moyens et étroits */
@media (max-width: 1180px) {
  .principal { grid-template-columns: minmax(0, 1fr) 350px; }
}
@media (max-width: 960px) {
  body { overflow: auto; height: auto; min-height: 100%; }
  .principal { display: flex; flex-direction: column; padding: 10px 8px 12px; }
  .zone-graphe { flex: none; height: max(760px, min(96vh, 900px)); }
  .panneau { overflow: visible; padding-right: 0; }
  .sous-titre { display: none; }
  .masque-etroit { display: none; }
  .entete { gap: 10px; padding: 8px 10px 10px; }
  .logo { height: 30px; }
  .titre h1 { font-size: 18px; }
  .actions { gap: 5px; }
  .actions .btn { padding: 5px 8px; font-size: 13px; }
}
@media (max-width: 560px) {
  .libelle { display: none; }
  .onglet-nom { font-size: 12px; letter-spacing: 0; white-space: normal; text-align: center; line-height: 1.1; }
  .onglet-formule { font-size: 11px; }
  .onglet { padding: 5px 3px 6px; }
  .titre-graphe { font-size: 12px; padding: 2px 8px; max-width: calc(100% - 150px); }
  .commande { padding: 6px 8px 7px; gap: 2px 8px; }
  .barre-outils { gap: 6px 8px; padding: 7px 8px; }
  .barre-outils .btn { padding: 5px 8px; font-size: 13.5px; }
  .groupe-btn.droite { margin-left: 0; }
  .zone-graphe { height: 1080px; }
  .indice-commande { display: none; }
}

/* =============================================================================
   Intégrée dans une page de mathopo.ca (index.html?embed=1 ; la classe « integre »
   est posée par index.html). Sans l’en-tête UQTR (la page du site donne le titre),
   sur fond blanc, avec la police et les gris du site. Le vert, l’or et les
   couleurs des traces ne changent pas.
   ============================================================================= */
.integre {
  --vert: #0b7a57;
  --vert-fonce: #085e42;
  --fond: #ffffff;
  --bord: #dde4e0;
  --texte: #1d2b3a;
  --texte-2: #47576a;
  --ombre: none;
  --rayon: 8px;
  --police: "Source Sans 3", system-ui, -apple-system, "Segoe UI", sans-serif;
}
.integre .entete, .integre .pied { display: none; }
.integre .principal { padding: 0; gap: 16px; }
.integre .carte h2 {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: var(--texte);
}
.integre .exemples-tete { font-size: 13px; font-weight: 600; letter-spacing: 0; text-transform: none; }
.integre .onglet-nom { font-weight: 600; letter-spacing: 0; }
.integre .onglets, .integre .entete-zone { background: #F7F9F8; }
@media (max-width: 960px) {
  /* Cadre étroit : la page du site donne au cadre la hauteur de l'application
     (data-hauteur-etroit), qui défile avec la page ; la hauteur des vues ne
     dépend donc pas de celle du cadre. */
  .integre body { min-height: 0; }
  .integre .principal { padding: 0; }
  .integre .zone-graphe { height: 820px; }
}
@media (max-width: 560px) {
  .integre .zone-graphe { height: 1080px; }
}
/* une seule vue sur un téléphone : la zone n'est pas plus haute que cette vue (app.js) */
@media (max-width: 560px) {
  .zone-graphe.seule-telephone, .integre .zone-graphe.seule-telephone { height: auto; }
}
