/* Interface autour du canvas : barre, outils, menus, fenêtres. Mêmes couleurs que theme.js. */

:root {
  --fond: rgb(16, 18, 24);
  --panneau: rgb(26, 29, 38);
  --panneau-haut: rgb(32, 36, 47);
  --ligne: rgb(58, 63, 78);
  --ligne-douce: rgb(40, 44, 56);
  --texte: rgb(225, 228, 235);
  --doux: rgb(140, 146, 160);
  --vert: rgb(80, 200, 120);
  --orange: rgb(255, 150, 40);
  --rouge: rgb(235, 80, 80);
  --bleu: rgb(80, 160, 255);
  --jaune: rgb(255, 215, 60);
  --accent: var(--vert);
  --rayon: 8px;
  font: 14px "Segoe UI", system-ui, Arial, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--fond); color: var(--texte); overflow: hidden; }
#appli { display: flex; flex-direction: column; height: 100%; }
#scene { flex: 1; min-height: 0; position: relative; }
canvas { display: block; }

button { font: inherit; color: inherit; }
kbd {
  font: 600 11px "Segoe UI", system-ui, sans-serif; color: var(--doux);
  border: 1px solid var(--ligne); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; min-width: 18px;
  display: inline-block; text-align: center; line-height: 16px;
}
svg.ic { width: 18px; height: 18px; flex: none; }
:focus-visible { outline: 2px solid var(--bleu); outline-offset: 2px; }

/* --- barre principale ------------------------------------------------------- */
.barre {
  height: 50px; flex: none; display: flex; align-items: center; gap: 10px; padding: 0 12px;
  background: var(--panneau); border-bottom: 1px solid var(--ligne-douce);
}
.marque { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; letter-spacing: .2px; margin-right: 10px; user-select: none; }
.marque svg { width: 26px; height: 26px; color: var(--texte); }
.espace { flex: 1; }

.onglets { display: flex; gap: 2px; height: 100%; }
.onglets button {
  background: none; border: 0; padding: 0 16px; height: 100%; cursor: pointer; color: var(--doux);
  font-weight: 600; font-size: 15px; position: relative;
}
.onglets button:hover { color: var(--texte); }
.onglets button[aria-selected="true"] { color: var(--texte); }
.onglets button[aria-selected="true"]::after {
  content: ""; position: absolute; left: 10px; right: 10px; bottom: 0; height: 3px; border-radius: 3px 3px 0 0; background: var(--accent);
}

.segment { display: inline-flex; background: var(--fond); border: 1px solid var(--ligne); border-radius: var(--rayon); padding: 2px; gap: 2px; }
.segment button {
  background: none; border: 0; border-radius: 6px; padding: 4px 12px; cursor: pointer; color: var(--doux); font-weight: 600; white-space: nowrap;
}
.segment button:hover:not(:disabled) { color: var(--texte); }
.segment button[aria-checked="true"] { background: var(--panneau-haut); color: var(--texte); box-shadow: 0 0 0 1px var(--ligne); }
.segment button:disabled { opacity: .4; cursor: default; }
.mode button[data-mode="match"][aria-checked="true"] { color: var(--jaune); }

.pastille-manette {
  display: flex; align-items: center; gap: 7px; height: 32px; padding: 0 11px; border-radius: 16px;
  background: var(--fond); border: 1px solid var(--ligne); cursor: pointer; max-width: 300px;
}
.pastille-manette:hover { border-color: var(--doux); }
.pastille-manette .point { width: 9px; height: 9px; border-radius: 50%; background: var(--orange); flex: none; }
.pastille-manette.ok .point { background: var(--vert); box-shadow: 0 0 6px rgba(80, 200, 120, .7); }
.pastille-manette.ko .point { background: var(--rouge); }
.pastille-manette .nom { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pastille-manette .freq { color: var(--doux); font-size: 12px; white-space: nowrap; }

button.icone {
  width: 34px; height: 34px; display: inline-grid; place-items: center; padding: 0;
  background: none; border: 1px solid transparent; border-radius: var(--rayon); cursor: pointer; color: var(--doux);
}
button.icone:hover { background: var(--panneau-haut); color: var(--texte); border-color: var(--ligne); }
button.icone[aria-expanded="true"] { background: var(--panneau-haut); color: var(--texte); }

/* --- menu déroulant ---------------------------------------------------------- */
.menu-ancre { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; min-width: 330px; padding: 6px;
  background: var(--panneau-haut); border: 1px solid var(--ligne); border-radius: 10px; box-shadow: 0 12px 32px rgba(0, 0, 0, .5);
}
.menu button {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 6px;
  background: none; cursor: pointer; text-align: left;
}
.menu button:hover, .menu button:focus-visible { background: var(--ligne-douce); outline: none; }
.menu button i { color: var(--doux); display: inline-flex; }
.menu button kbd, .menu button .droite { margin-left: auto; }
.menu hr { border: 0; border-top: 1px solid var(--ligne); margin: 6px 4px; }
.menu .version { color: var(--doux); font-size: 12px; padding: 6px 10px 2px; }

/* --- barre d'outils de l'onglet ------------------------------------------------ */
.outils {
  height: 44px; flex: none; display: flex; align-items: center; gap: 8px; padding: 0 12px;
  border-bottom: 1px solid var(--ligne-douce); background: var(--fond);
}
.outils .groupe { display: none; align-items: center; gap: 6px; flex: none; }
.outils .groupe.visible { display: flex; }
.outils .lot { display: flex; gap: 2px; }
.outils .sep { width: 1px; height: 22px; background: var(--ligne); margin: 0 4px; }
.outils .groupe > button:not(.icone), .outils .lot > button:not(.icone) {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 11px;
  background: var(--panneau); border: 1px solid var(--ligne); border-radius: var(--rayon); cursor: pointer;
  color: var(--texte); white-space: nowrap; font-weight: 500;
}
.outils button.icone { width: 30px; height: 30px; border-color: var(--ligne); background: var(--panneau); color: var(--texte); }
.outils button:hover:not(:disabled) { border-color: var(--doux); }
.outils button:disabled { opacity: .35; cursor: default; }
.outils button i { display: inline-flex; color: var(--doux); }
.outils button.actif { border-color: var(--accent); background: rgba(80, 200, 120, .12); }
.outils button.actif i { color: var(--accent); }
.outils button.actif-jaune { border-color: var(--jaune); background: rgba(255, 215, 60, .1); }
.outils button.actif-jaune i { color: var(--jaune); }
.outils [hidden] { display: none !important; }
i.direct { width: 8px; height: 8px; border-radius: 50%; background: var(--doux); }
button.actif i.direct { background: var(--rouge); box-shadow: 0 0 6px rgba(235, 80, 80, .8); animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .45; } }
.etat {
  flex: 1; min-width: 0; text-align: right; color: var(--doux); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px;
}
.etat.jaune { color: var(--jaune); }
.etat.rouge { color: var(--rouge); }
.etat.vert { color: var(--vert); }
#appli.verrou .onglets, #appli.verrou .outils .groupe, #appli.verrou .mode { opacity: .35; pointer-events: none; }

/* --- fenêtres ------------------------------------------------------------------ */
dialog.fenetre {
  padding: 0; border: 1px solid var(--ligne); border-radius: 14px; background: var(--panneau); color: var(--texte);
  box-shadow: 0 24px 64px rgba(0, 0, 0, .6); overflow: hidden;
}
dialog.fenetre::backdrop { background: rgba(8, 10, 14, .72); }
dialog.fenetre[open] { display: flex; flex-direction: column; animation: apparition .14s ease-out; }
@keyframes apparition { from { opacity: 0; transform: translateY(8px) scale(.99); } }
.fenetre .entete { display: flex; align-items: center; gap: 14px; padding: 14px 16px 14px 22px; border-bottom: 1px solid var(--ligne-douce); }
.fenetre h2 { margin: 0; font-size: 19px; }
.fenetre .fermer { margin-left: auto; }

.parametres { width: min(980px, 94vw); height: min(720px, 90vh); }
.recherche {
  display: flex; align-items: center; gap: 8px; margin-left: 24px; flex: 0 1 320px; height: 34px; padding: 0 10px;
  background: var(--fond); border: 1px solid var(--ligne); border-radius: var(--rayon); color: var(--doux);
}
.recherche:focus-within { border-color: var(--bleu); }
.recherche input { flex: 1; min-width: 0; background: none; border: 0; outline: none; color: var(--texte); font: inherit; }
.parametres .corps { flex: 1; display: flex; min-height: 0; }
.categories { width: 230px; flex: none; padding: 10px; border-right: 1px solid var(--ligne-douce); overflow-y: auto; background: rgb(22, 25, 33); }
.categories button {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; margin-bottom: 2px;
  background: none; border: 0; border-radius: var(--rayon); cursor: pointer; color: var(--doux); text-align: left; font-weight: 500;
}
.categories button:hover { color: var(--texte); background: var(--ligne-douce); }
.categories button.actif { color: var(--texte); background: var(--panneau-haut); box-shadow: inset 3px 0 0 var(--accent); }
.categories button .nb { margin-left: auto; font-size: 11px; color: var(--fond); background: var(--doux); border-radius: 8px; padding: 0 6px; }

.contenu { flex: 1; overflow-y: auto; padding: 8px 28px 28px; scroll-behavior: smooth; }
.contenu section > h3 { font-size: 22px; margin: 18px 0 4px; }
.contenu section > .intro { color: var(--doux); margin: 0 0 8px; max-width: 640px; line-height: 1.45; }
.contenu .groupe-reglages { margin-top: 18px; }
.contenu .groupe-reglages > h4 { margin: 0 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .8px; color: var(--doux); font-weight: 700; }
.carte { background: var(--fond); border: 1px solid var(--ligne-douce); border-radius: 10px; }
.reglage { display: flex; align-items: center; gap: 18px; padding: 12px 14px; border-top: 1px solid var(--ligne-douce); min-height: 56px; }
.reglage:first-child { border-top: 0; }
.reglage .libelle { flex: 1; min-width: 0; }
.reglage .libelle strong { display: block; font-weight: 600; }
.reglage .libelle small { display: block; color: var(--doux); font-size: 12.5px; margin-top: 2px; line-height: 1.35; }
.reglage .controle { display: flex; align-items: center; gap: 10px; flex: none; }
.reglage.modifie .libelle strong::after { content: "modifié"; margin-left: 8px; font-size: 10.5px; font-weight: 700; color: var(--bleu); text-transform: uppercase; letter-spacing: .5px; vertical-align: 1px; }
.reglage.invalide input[type="number"] { border-color: var(--rouge); }
.raz { visibility: hidden; color: var(--doux); }
.reglage.modifie .raz { visibility: visible; }
.reglage button.raz { width: 28px; height: 28px; }

input[type="range"] { width: 200px; accent-color: var(--accent); cursor: pointer; }
input[type="number"], select {
  height: 32px; background: var(--panneau); color: var(--texte); border: 1px solid var(--ligne); border-radius: 6px; font: inherit; padding: 0 8px;
}
input[type="number"] { width: 82px; text-align: right; }
select { min-width: 260px; cursor: pointer; }
input[type="number"]:focus, select:focus { border-color: var(--bleu); outline: none; }
.unite { color: var(--doux); font-size: 12.5px; min-width: 28px; }
.lecture-valeur { min-width: 52px; text-align: right; font-variant-numeric: tabular-nums; }

.interrupteur { position: relative; width: 44px; height: 24px; flex: none; }
.interrupteur input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.interrupteur span { position: absolute; inset: 0; border-radius: 12px; background: var(--ligne); transition: background .15s; }
.interrupteur span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--texte); transition: transform .15s; }
.interrupteur input:checked + span { background: var(--accent); }
.interrupteur input:checked + span::after { transform: translateX(20px); }
.interrupteur input:focus-visible + span { outline: 2px solid var(--bleu); outline-offset: 2px; }

.cases { display: flex; flex-wrap: wrap; gap: 6px; }
.cases label {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border: 1px solid var(--ligne); border-radius: 16px; cursor: pointer; color: var(--doux); user-select: none;
}
.cases label:has(input:checked) { border-color: var(--accent); color: var(--texte); background: rgba(80, 200, 120, .1); }
.cases input { accent-color: var(--accent); margin: 0; }

.bouton {
  height: 32px; padding: 0 14px; border-radius: var(--rayon); border: 1px solid var(--ligne); background: var(--panneau); cursor: pointer; font-weight: 600; white-space: nowrap;
}
.bouton:hover { border-color: var(--doux); }
.bouton.principal { border-color: var(--accent); background: rgba(80, 200, 120, .14); }
.bouton.danger { border-color: rgba(235, 80, 80, .6); color: var(--rouge); }
.bouton.danger.confirmer { background: var(--rouge); color: var(--fond); border-color: var(--rouge); }

.zone-texte { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.zone-texte textarea {
  width: 100%; height: 46vh; resize: vertical; background: var(--fond); color: var(--texte); border: 1px solid var(--ligne); border-radius: 10px;
  padding: 12px; font: 13px Consolas, "Courier New", monospace; line-height: 1.45; tab-size: 4;
}
.zone-texte .boutons { display: flex; gap: 10px; align-items: center; }
.zone-texte .message { flex: 1; text-align: right; font-size: 13px; }
.message.erreur { color: var(--rouge); }
.message.ok { color: var(--vert); }
.aucun-resultat { color: var(--doux); padding: 40px 0; text-align: center; }
.cache { display: none !important; }

.parametres .pied { display: flex; align-items: center; gap: 12px; padding: 10px 22px; border-top: 1px solid var(--ligne-douce); color: var(--doux); font-size: 12.5px; }
.parametres .pied .info { display: inline-flex; align-items: center; gap: 8px; }
.parametres .pied .enregistre { margin-left: auto; color: var(--vert); font-weight: 600; opacity: 0; transition: opacity .3s; }
.parametres .pied .enregistre.visible { opacity: 1; transition: none; }
.parametres .pied .enregistre.erreur { color: var(--rouge); }

.petite { width: min(760px, 94vw); }
.raccourcis { display: grid; grid-template-columns: 1fr 1fr; gap: 0 28px; padding: 6px 24px 22px; }
.raccourcis h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .8px; color: var(--doux); margin: 16px 0 8px; }
.raccourcis dl { display: grid; grid-template-columns: max-content 1fr; gap: 7px 14px; margin: 0; align-items: center; }
.raccourcis dt { white-space: nowrap; }
.raccourcis dd { margin: 0; }

#plantage {
  position: fixed; inset: 20px; background: var(--panneau); color: var(--rouge); padding: 20px; border-radius: 12px; overflow: auto; z-index: 50;
}
#plantage pre { color: var(--texte); white-space: pre-wrap; }

/* Fenêtre étroite : on réduit la barre plutôt que de la couper. */
@media (max-width: 1180px) {
  .marque span, .pastille-manette .freq { display: none; }
  .outils button:not(.icone) i:not(.direct) { display: none; }
}
@media (max-width: 980px) {
  .pastille-manette .nom { display: none; }
  .onglets button { padding: 0 10px; }
  .categories { width: 64px; }
  .categories button span, .categories button .nb { display: none; }
  .recherche { margin-left: 8px; }
}
