/* Formateur et validateur XML */
.o-xml { --x-nom: #9a3412; --x-attr: #1748b0; --x-val: #0b7a3e; --x-com: #6b7280; --x-cdata: #8a2be2; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .o-xml { --x-nom: #ffb27a; --x-attr: #8fb3ff; --x-val: #7ee0a5; --x-com: #a3acbf; --x-cdata: #d0a8ff; }
}
:root[data-theme="dark"] .o-xml { --x-nom: #ffb27a; --x-attr: #8fb3ff; --x-val: #7ee0a5; --x-com: #a3acbf; --x-cdata: #d0a8ff; }

.o-xml-modes { margin-bottom: 12px; }
.o-xml-modes .btn, .o-xml-vues .btn { min-height: 40px; }
.atelier .o-xml-modes .btn[aria-pressed="true"], .atelier .o-xml-vues .btn[aria-pressed="true"] { background: var(--marque); border-color: var(--marque); color: var(--sur-marque); }
.o-xml-barre { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.o-xml-titre { display: block; font-weight: 600; color: var(--texte); margin-bottom: 6px; }
.o-xml-barre .o-xml-titre { margin-bottom: 0; }
.o-xml-outils { display: flex; flex-wrap: wrap; gap: 6px; }
.o-xml-outils .btn { min-height: 38px; padding-top: 4px; padding-bottom: 4px; }
.o-xml textarea { font-family: var(--mono); font-size: .9rem; line-height: 1.45; white-space: pre; overflow: auto; tab-size: 4; }
.o-xml-entree { min-height: 220px; }
.o-xml-entree[hidden] { display: none; }
.o-xml-entree.survol, .o-xml-boite.survol { outline: 3px dashed var(--marque); outline-offset: 2px; }
.o-xml-sortie { min-height: 320px; background: var(--surface-2); }
.o-xml textarea:focus-visible, .o-xml select:focus-visible, .o-xml input:focus-visible, .o-xml button:focus-visible { outline: 3px solid var(--marque); outline-offset: 1px; }
.o-xml-boite { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; min-height: 120px; padding: 14px; border: 1px dashed var(--bord); border-radius: var(--rayon-petit); background: var(--surface-2); }
.o-xml-boite[hidden] { display: none; }
.o-xml-boite p { margin: 0; font-weight: 600; overflow-wrap: anywhere; }

.o-xml-etat-bloc { margin: 12px 0; display: grid; gap: 8px; }
.o-xml-etat { display: block; padding: 10px 14px; border-radius: var(--rayon-petit); background: var(--surface-2); color: var(--texte-2); font-weight: 600; overflow-wrap: anywhere; }
.o-xml-etat.ok { background: var(--ok-fond); color: var(--ok-texte); }
.o-xml-etat.erreur { background: var(--erreur-fond); color: var(--erreur-texte); }
.o-xml-extrait { margin: 0; padding: 10px 12px; border: 1px solid var(--bord); border-radius: var(--rayon-petit); background: var(--surface-2); color: var(--texte); font-family: var(--mono); font-size: .88rem; line-height: 1.5; overflow-x: auto; white-space: pre; tab-size: 2; }
.o-xml-extrait mark { background: var(--erreur-texte); color: var(--erreur-fond); border-radius: 3px; padding: 0 1px; }
.o-xml-no { color: var(--texte-2); user-select: none; }
.o-xml-nav { margin: 0; color: var(--texte-2); font-size: .88rem; overflow-wrap: anywhere; }
.o-xml-aller { justify-self: start; }
.o-xml-extrait[hidden], .o-xml-nav[hidden], .o-xml-aller[hidden] { display: none; }

.o-xml-reglages label.case input { flex: none; }
.o-xml-stats { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 14px; }
.o-xml-stats div { flex: 1 1 140px; padding: 8px 12px; border: 1px solid var(--bord); border-radius: var(--rayon-petit); background: var(--surface-2); }
.o-xml-stats dt { color: var(--texte-2); font-size: .82rem; }
.o-xml-stats dd { margin: 0; color: var(--texte); font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

.o-xml-vues { display: flex; gap: 6px; margin-bottom: 8px; }
.o-xml-info { margin: 0 0 8px; }

.o-xml-arbre-bloc { border: 1px solid var(--bord); border-radius: var(--rayon-petit); padding: 10px; background: var(--surface); }
.o-xml-arbre-bloc[hidden] { display: none; }
.o-xml-arbre-outils { display: flex; flex-wrap: wrap; align-items: end; gap: 8px; }
.o-xml-cherche { flex: 1 1 240px; display: flex; flex-direction: column; gap: 4px; font-size: .88rem; color: var(--texte-2); }
.o-xml-cherche input { display: block; width: 100%; min-height: 40px; padding: 6px 10px; border: 1px solid var(--bord); border-radius: var(--rayon-petit); background: var(--surface); color: var(--texte); font: inherit; }
.o-xml-trouves { font-size: .88rem; color: var(--texte-2); }
.o-xml-trouves p { margin: 8px 0 4px; }
.o-xml-trouves ul { list-style: none; margin: 0 0 8px; padding: 0; max-height: 180px; overflow: auto; border-bottom: 1px solid var(--bord); }
.o-xml-trouves li { padding: 2px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); }
.o-xml-trouve { border: 0; background: none; padding: 2px 4px; color: var(--marque); font: inherit; text-decoration: underline; cursor: pointer; }
.o-xml-chemin-ligne { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 8px 0; font-size: .88rem; color: var(--texte-2); }
.o-xml-chemin { flex: 1 1 200px; min-width: 0; padding: 6px 10px; border-radius: var(--rayon-petit); background: var(--surface-2); color: var(--texte); font-family: var(--mono); overflow-wrap: anywhere; }
.o-xml-chemin-ligne .btn { min-height: 36px; padding-top: 2px; padding-bottom: 2px; }

.o-xml-arbre { max-height: 520px; overflow: auto; font-family: var(--mono); font-size: .88rem; line-height: 1.5; }
.o-xml-arbre ul { list-style: none; margin: 0; padding: 0; }
.o-xml-enfants { padding-left: 18px !important; border-left: 1px dotted var(--bord); margin-left: 9px !important; }
.o-xml-enfants[hidden] { display: none; }
.o-xml-ligne { display: flex; align-items: center; gap: 0; min-height: 26px; white-space: nowrap; }
.o-xml-ligne > .o-xml-sel { margin-left: 2px; }
.o-xml-ligne > .o-xml-attr { margin-left: 4px; }
.o-xml-bascule, .o-xml-puce { flex: none; width: 22px; height: 22px; }
.o-xml-bascule { border: 0; border-radius: 4px; background: none; color: var(--texte-2); cursor: pointer; padding: 0; font: inherit; line-height: 22px; }
.o-xml-bascule::before { content: "▸"; display: inline-block; transition: transform .12s; }
.o-xml-bascule[aria-expanded="true"]::before { transform: rotate(90deg); }
.o-xml-bascule:hover { background: var(--surface-2); }
.o-xml-sel, .o-xml-attr { border: 0; border-radius: 4px; background: none; padding: 0 2px; font: inherit; cursor: pointer; color: var(--texte); }
.o-xml-nom { color: var(--x-nom); font-weight: 600; }
.o-xml-sel:hover, .o-xml-attr:hover { background: var(--surface-2); }
.o-xml-n.sel > .o-xml-ligne > .o-xml-sel, .o-xml-attr.sel { background: var(--marque); color: var(--sur-marque); }
.o-xml-an { color: var(--x-attr); }
.o-xml-av { color: var(--x-val); }
.o-xml-attr.sel .o-xml-an, .o-xml-attr.sel .o-xml-av { color: inherit; }
.o-xml-nom-fin { color: var(--x-nom); }
.o-xml-texte { color: var(--texte); white-space: pre; }
.o-xml-com { color: var(--x-com); font-style: italic; }
.o-xml-cdata { color: var(--x-cdata); white-space: pre; }
.o-xml-resume { color: var(--texte-2); margin-left: 6px; font-size: .82rem; }
.o-xml-plus { padding: 4px 0 4px 26px; }
.o-xml-plus .btn { min-height: 32px; padding: 2px 12px; font-size: .85rem; }
.o-xml-arbre-vide { color: var(--texte-2); font-family: var(--police); margin: 6px 0; }

.o-xml-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 14px 0 8px; }
.o-xml-actions .btn { min-height: 42px; }
.o-xml-actions .tirage-message { flex-basis: 100%; }
.o-xml .o-xml-note { display: block; }

@media (prefers-reduced-motion: reduce) { .o-xml-bascule::before { transition: none; } }
@media (max-width: 640px) {
  .o-xml-entree { min-height: 170px; }
  .o-xml-sortie { min-height: 240px; }
  .o-xml-stats div { flex-basis: 40%; padding: 6px 10px; }
  .o-xml-modes .btn { flex: 1 1 40%; }
}
