:root {
  --fond: #f3f5f1;
  --panneau: #ffffff;
  --panneau-2: #eef1eb;
  --bord: #dde2d8;
  --texte: #1b2019;
  --doux: #5c6658;
  --accent: #3b8a26;
  --accent-fort: #2f7220;
  --accent-texte: #ffffff;
  --rouge: #c4392f;
  --rouge-fond: #fbeceb;
  --jaune: #a8700f;
  --jaune-fond: #fbf3e2;
  --bleu: #2f6db5;
  --bleu-fond: #e8f0fa;
  --vert-fond: #e8f4e2;
  --gris: #8a9187;
  --console: #10140f;
  --console-texte: #d6dfd2;
  --ombre: 0 1px 2px rgb(0 0 0 / 5%), 0 6px 20px rgb(0 0 0 / 4%);
  --rayon: 12px;
  --mono: ui-monospace, "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fond: #111411;
    --panneau: #191d18;
    --panneau-2: #20251f;
    --bord: #2b3229;
    --texte: #e5ebe2;
    --doux: #98a393;
    --accent: #5db93d;
    --accent-fort: #6fcb4e;
    --accent-texte: #0c1209;
    --rouge: #ef6559;
    --rouge-fond: #2f1a18;
    --jaune: #e2ae45;
    --jaune-fond: #2c2414;
    --bleu: #6aa6ec;
    --bleu-fond: #16233a;
    --vert-fond: #18281a;
    --gris: #6f786b;
    --console: #0b0e0a;
    --ombre: 0 1px 2px rgb(0 0 0 / 30%);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--fond);
  color: var(--texte);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
a:hover { color: var(--accent-fort); }
code { font-family: var(--mono); font-size: .92em; background: var(--panneau-2); padding: 1px 5px; border-radius: 5px; }
h1, h2 { margin: 0; line-height: 1.25; }
h2 { font-size: 1.05rem; margin-bottom: 14px; }
p { margin: 0 0 10px; }
p:last-child { margin-bottom: 0; }
.doux { color: var(--doux); }
.petit { font-size: .85rem; }
.chargement { padding: 40px; text-align: center; color: var(--doux); }

.icone { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ------------------------------------------------ coque */

.coque { display: grid; grid-template-columns: 230px minmax(0, 1fr); min-height: 100vh; }
.cote {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 20px;
  padding: 18px 12px;
  background: var(--panneau); border-right: 1px solid var(--bord);
}
.marque { display: flex; align-items: center; gap: 10px; padding: 4px 10px; color: var(--texte); text-decoration: none; }
.marque span { display: flex; flex-direction: column; line-height: 1.1; }
.marque small { color: var(--doux); font-size: .75rem; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a, .pied-cote a, .pied-cote .lien {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px;
  color: var(--doux); text-decoration: none; font-weight: 500;
}
.nav a:hover, .pied-cote a:hover, .pied-cote .lien:hover { background: var(--panneau-2); color: var(--texte); }
.nav a.actif, .pied-cote a.actif { background: var(--vert-fond); color: var(--accent); }
.pied-cote { margin-top: auto; display: flex; flex-direction: column; gap: 2px; border-top: 1px solid var(--bord); padding-top: 12px; }
.lien { background: none; border: 0; font: inherit; cursor: pointer; text-align: left; width: 100%; }

.colonne { min-width: 0; }
.entete {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 18px clamp(16px, 4vw, 40px);
  border-bottom: 1px solid var(--bord); background: var(--panneau);
}
.entete h1 { font-size: 1.3rem; }
.entete-droite { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.adresse {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--bord); background: var(--panneau-2); color: var(--texte);
  border-radius: 8px; padding: 5px 10px; cursor: pointer; font: inherit;
}
.adresse code { background: none; padding: 0; }
.adresse:hover { border-color: var(--accent); }
.principal { padding: 24px clamp(16px, 4vw, 40px) 64px; max-width: 1080px; }
.pile { display: flex; flex-direction: column; gap: 18px; }

@media (max-width: 800px) {
  .coque { grid-template-columns: minmax(0, 1fr); }
  .cote {
    position: sticky; z-index: 5; height: auto; flex-direction: row; align-items: center; gap: 8px;
    padding: 8px 12px; border-right: 0; border-bottom: 1px solid var(--bord); overflow-x: auto;
  }
  .marque small, .marque strong { display: none; }
  .marque { padding: 4px; }
  .nav { flex-direction: row; }
  .nav a, .pied-cote a, .pied-cote .lien { padding: 8px; white-space: nowrap; }
  .nav a span, .pied-cote span { display: none; }
  .nav a.actif span { display: inline; }
  .pied-cote { flex-direction: row; margin: 0 0 0 auto; border: 0; padding: 0; }
}

/* ------------------------------------------------ éléments */

.carte { background: var(--panneau); border: 1px solid var(--bord); border-radius: var(--rayon); padding: 20px; box-shadow: var(--ombre); }
.carte > * + * { margin-top: 12px; }
.carte > h2 + * { margin-top: 0; }

.bouton {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 38px; padding: 8px 14px;
  border: 1px solid var(--bord); border-radius: 8px;
  background: var(--panneau); color: var(--texte);
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.bouton:hover { border-color: var(--doux); color: var(--texte); }
.bouton:disabled { opacity: .55; cursor: wait; }
.bouton.principal { background: var(--accent); border-color: var(--accent); color: var(--accent-texte); }
.bouton.principal:hover { background: var(--accent-fort); border-color: var(--accent-fort); }
.bouton.danger { color: var(--rouge); }
.bouton.danger:hover { border-color: var(--rouge); }
.bouton.grand { min-height: 46px; padding: 10px 22px; font-size: 1rem; }
.bouton.danger.grand { background: var(--rouge); border-color: var(--rouge); color: #fff; }
.bouton.petit { min-height: 32px; padding: 5px 12px; font-size: .9rem; }
.bouton.large { width: 100%; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.actions.centre { justify-content: center; }
.actions.collant { position: sticky; bottom: 12px; z-index: 2; }

input:not([type=checkbox]):not([type=radio]):not([type=range]), select {
  width: 100%; min-height: 40px; padding: 8px 11px;
  border: 1px solid var(--bord); border-radius: 8px;
  background: var(--panneau-2); color: var(--texte); font: inherit;
}
input:focus-visible, select:focus-visible, .bouton:focus-visible, a:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.champ { display: flex; flex-direction: column; gap: 5px; }
.libelle { font-weight: 600; font-size: .92rem; }
.aide { color: var(--doux); font-size: .85rem; }
.formulaire { display: flex; flex-direction: column; gap: 14px; }
.formulaire.etroit { max-width: 420px; }
.formulaire-ligne { display: flex; gap: 8px; flex-wrap: wrap; }
.formulaire-ligne input { flex: 1 1 180px; width: auto; }
.grille-champs { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px 20px; }
.case { display: flex; gap: 10px; align-items: flex-start; }
.case input { margin-top: 4px; }

.interrupteur {
  appearance: none; flex: none; position: relative; width: 44px; height: 24px; margin: 0;
  border-radius: 99px; background: var(--bord); cursor: pointer; transition: background .15s;
}
.interrupteur::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgb(0 0 0 / 25%); transition: transform .15s;
}
.interrupteur:checked { background: var(--accent); }
.interrupteur:checked::after { transform: translateX(20px); }
.interrupteur:disabled { opacity: .5; }

.ligne-reglage { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.ligne-reglage p { margin: 2px 0 0; font-size: .88rem; }
.ligne-ram { display: flex; align-items: center; gap: 16px; }
.ligne-ram input { flex: 1; accent-color: var(--accent); }
.avance summary { cursor: pointer; font-weight: 600; margin: 8px 0 14px; }
.danger-zone { border-color: color-mix(in srgb, var(--rouge) 35%, var(--bord)); }

.pastille { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; font-size: .9rem; }
.pastille .point { width: 9px; height: 9px; border-radius: 50%; background: var(--gris); }
.pastille.vert .point { background: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.pastille.jaune .point { background: var(--jaune); animation: battement 1.2s infinite; }
.pastille.rouge .point { background: var(--rouge); }
.pastille.vert { color: var(--accent); }
.pastille.jaune { color: var(--jaune); }
.pastille.rouge { color: var(--rouge); }
@keyframes battement { 50% { opacity: .35; } }

.badge { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: .78rem; font-weight: 600; background: var(--panneau-2); color: var(--doux); }
.badge.vert { background: var(--vert-fond); color: var(--accent); }
.badge.bleu { background: var(--bleu-fond); color: var(--bleu); }
.badge.rouge { background: var(--rouge-fond); color: var(--rouge); }
.badges { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 3px; }

.alerte { padding: 10px 14px; border-radius: 8px; background: var(--jaune-fond); color: var(--texte); border: 1px solid color-mix(in srgb, var(--jaune) 30%, transparent); }
.alerte.erreur { background: var(--rouge-fond); border-color: color-mix(in srgb, var(--rouge) 30%, transparent); }
.alerte.ok { background: var(--vert-fond); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.vide { color: var(--doux); font-style: italic; }

.bandeau {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px clamp(16px, 4vw, 40px); font-size: .92rem;
  border-bottom: 1px solid var(--bord); background: var(--bleu-fond);
}
.bandeau span:last-child { color: var(--doux); overflow-wrap: anywhere; }
.bandeau.ok { background: var(--vert-fond); }
.bandeau.erreur { background: var(--rouge-fond); }
.roue { width: 14px; height: 14px; border: 2px solid var(--bleu); border-right-color: transparent; border-radius: 50%; animation: tour .8s linear infinite; }
@keyframes tour { to { transform: rotate(360deg); } }

/* ------------------------------------------------ listes */

.liste { list-style: none; margin: 0; padding: 0; }
.ligne { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--bord); }
.liste .ligne:first-child { border-top: 0; }
.ligne.eteinte > :not(.ligne-actions) { opacity: .55; }
.ligne-texte { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ligne-texte .doux { font-size: .88rem; overflow-wrap: anywhere; }
.ligne-texte a { color: inherit; text-decoration: none; }
.ligne-texte a:hover { text-decoration: underline; }
.ligne-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.ligne-actions select { width: auto; min-height: 34px; }
.ligne-actions .bouton { min-height: 34px; padding: 5px 11px; }
.tete { border-radius: 6px; image-rendering: pixelated; background: var(--panneau-2); flex: none; }
.icone-mod { width: 40px; height: 40px; border-radius: 9px; object-fit: cover; flex: none; background: var(--panneau-2); }
.icone-mod.defaut { display: grid; place-items: center; font-weight: 700; color: var(--doux); }
.icone-mod.petit { width: 32px; height: 32px; border-radius: 6px; }
@media (max-width: 560px) {
  .ligne { flex-wrap: wrap; }
  .ligne-actions { width: 100%; justify-content: flex-start; }
}

/* ------------------------------------------------ tableau de bord */

.statut { border-left: 4px solid var(--gris); }
.statut.vert { border-left-color: var(--accent); }
.statut.jaune { border-left-color: var(--jaune); }
.statut.rouge { border-left-color: var(--rouge); }
.statut-haut { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.grosse-adresse { font-family: var(--mono); font-size: clamp(1.3rem, 4vw, 1.8rem); font-weight: 700; margin: 6px 0 2px; overflow-wrap: anywhere; }
.tuiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.tuile { background: var(--panneau); border: 1px solid var(--bord); border-radius: var(--rayon); padding: 16px; display: flex; flex-direction: column; gap: 6px; box-shadow: var(--ombre); }
.tuile-titre { color: var(--doux); font-size: .85rem; font-weight: 600; }
.tuile-valeur { font-size: 1.45rem; font-variant-numeric: tabular-nums; }
.tuile .doux { font-size: .85rem; }
.tetes { display: flex; flex-wrap: wrap; gap: 4px; }
.jauge { height: 8px; border-radius: 99px; background: var(--panneau-2); overflow: hidden; }
.jauge span { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .4s; }
.etapes { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 6px; }

/* ------------------------------------------------ console */

.console-carte { padding: 0; overflow: hidden; }
.console {
  height: min(62vh, 640px); overflow-y: auto; padding: 14px 16px;
  background: var(--console); color: var(--console-texte);
  font: 12.5px/1.55 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere;
}
.console .warn { color: #e8c15c; }
.console .err { color: #ff7b6e; }
.console .info { color: #8fdc6e; }
.console .moi { color: #7fb7ff; }
.console .reponse { color: #ffffff; }
.console .doux { color: #8a9687; font-style: italic; }
.carte.console-carte > * + * { margin-top: 0; }
.ligne-console { display: flex; align-items: center; gap: 8px; padding: 10px; border-top: 1px solid var(--bord); background: var(--panneau); }
.ligne-console .invite { font-family: var(--mono); color: var(--accent); font-weight: 700; padding-left: 6px; }
.ligne-console input { font-family: var(--mono); }

/* ------------------------------------------------ version et mods */

.choix-types { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; }
.choix-type { position: relative; display: flex; gap: 10px; padding: 14px; border: 1px solid var(--bord); border-radius: 10px; cursor: pointer; background: var(--panneau-2); }
.choix-type:has(input:checked) { border-color: var(--accent); background: var(--vert-fond); box-shadow: inset 0 0 0 1px var(--accent); }
.choix-type input { margin-top: 4px; accent-color: var(--accent); }
.choix-corps { display: flex; flex-direction: column; gap: 3px; }
.choix-corps .doux { font-size: .86rem; line-height: 1.4; }
.version-actuelle { display: flex; flex-direction: column; gap: 2px; font-size: 1.05rem; }
.version-actuelle .doux { font-size: .88rem; }

.resultats { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.resultat { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border: 1px solid var(--bord); border-radius: 10px; background: var(--panneau-2); }
.resultat .icone-mod { width: 48px; height: 48px; }
.resultat-texte { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.resultat-titre { font-weight: 700; color: var(--texte); text-decoration: none; }
.resultat-titre:hover { text-decoration: underline; color: var(--texte); }
.resultat p { font-size: .88rem; margin: 4px 0; color: var(--doux); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.resultat .badge { align-self: flex-start; }

.lien-invitation input { font-family: var(--mono); font-size: .85rem; }
.infos { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; }
.infos dt { color: var(--doux); }
.infos dd { margin: 0; font-weight: 600; }

/* ------------------------------------------------ connexion */

.ecran-connexion { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.boite-connexion { width: 100%; max-width: 400px; background: var(--panneau); border: 1px solid var(--bord); border-radius: 16px; padding: 32px 28px; box-shadow: var(--ombre); }
.boite-connexion .logo { display: block; margin-bottom: 14px; }
.boite-connexion h1 { font-size: 1.45rem; margin-bottom: 4px; }
.boite-connexion > .doux { margin-bottom: 22px; }

/* ------------------------------------------------ notifications */

#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 50; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast { padding: 11px 16px; border-radius: 10px; background: var(--texte); color: var(--fond); box-shadow: 0 6px 24px rgb(0 0 0 / 20%); font-weight: 500; transition: opacity .4s, transform .4s; }
.toast.erreur { background: var(--rouge); color: #fff; }
.toast.part { opacity: 0; transform: translateY(6px); }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
