:root {
  --papier: #f6f3ec;
  --carte: #fffdf8;
  --encre: #1c1b19;
  --encre-2: #57534b;
  --encre-3: #8a857b;
  --trait: #e3ddd0;
  --trait-fort: #cfc7b6;
  --accent: #b4441c;
  --accent-doux: #f6e3d8;
  --bon: #1e7f4f;
  --bon-doux: #e1f1e7;
  --alerte: #a15c00;
  --alerte-doux: #fbefd9;
  --erreur: #b42318;
  --erreur-doux: #fbe4e1;
  --titre-c: #e07a1f;
  --texte-c: #2f6fdb;
  --signature-c: #1e9e5a;
  --cle-c: #d93a3a;
  --rayon: 10px;
  --ombre: 0 1px 2px rgb(28 27 25 / 6%), 0 4px 16px rgb(28 27 25 / 6%);
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--papier);
  color: var(--encre);
  font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", "Noto Sans Arabic", "Geeza Pro", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { line-height: 1.2; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 26px; font-weight: 650; }
h2 { font-size: 18px; font-weight: 650; }
h3 { font-size: 13px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.06em; color: var(--encre-2); }
p { margin: 0; }
.discret { color: var(--encre-2); }
.petit { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- barre du haut ---------- */
.barre {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 24px;
  background: rgb(246 243 236 / 92%);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--trait);
}
.marque { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 650; font-size: 16px; }
.logo { color: var(--encre); display: flex; }
.voyants { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.voyant {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 12.5px; color: var(--encre-2);
  background: var(--carte); border: 1px solid var(--trait);
}
.voyant::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--encre-3); }
.voyant.ok::before { background: var(--bon); }
.voyant.non::before { background: var(--alerte); }
.voyant.ko::before { background: var(--erreur); }

.page { max-width: 1320px; margin: 0 auto; padding: 28px 24px 64px; }

/* ---------- boutons et champs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 16px;
  border-radius: 8px; border: 1px solid var(--trait-fort);
  background: var(--carte); color: var(--encre);
  font-weight: 560; cursor: pointer; text-decoration: none;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: #fff; border-color: var(--encre-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.principal { background: var(--encre); color: var(--papier); border-color: var(--encre); }
.btn.principal:hover { background: #33312d; }
.btn.valider { background: var(--bon); color: #fff; border-color: var(--bon); }
.btn.valider:hover { background: #186a41; }
.btn.danger { color: var(--erreur); }
.btn.mini { min-height: 30px; padding: 0 10px; font-size: 13px; border-radius: 7px; }
.btn.lien { border: 0; background: none; padding: 0; min-height: 0; color: var(--encre-2); text-decoration: underline; text-underline-offset: 3px; }
.btn:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

label.champ { display: grid; gap: 6px; font-size: 13.5px; font-weight: 560; color: var(--encre-2); }
input[type=text], input[type=datetime-local], textarea, select {
  width: 100%; padding: 9px 11px;
  border: 1px solid var(--trait-fort); border-radius: 8px;
  background: #fff; color: var(--encre); font-weight: 400; font-size: 15px;
}
textarea { min-height: 84px; resize: vertical; }

.segment { display: inline-flex; border: 1px solid var(--trait-fort); border-radius: 8px; overflow: hidden; background: #fff; }
.segment button { border: 0; background: none; padding: 7px 12px; cursor: pointer; font-size: 13.5px; color: var(--encre-2); }
.segment button + button { border-left: 1px solid var(--trait); }
.segment button[aria-pressed=true] { background: var(--encre); color: var(--papier); }

/* ---------- accueil ---------- */
.entete { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.entete p { margin-top: 6px; }
.grille { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 18px; }
.carte {
  background: var(--carte); border: 1px solid var(--trait); border-radius: var(--rayon);
  box-shadow: var(--ombre);
}
a.vignette { display: flex; flex-direction: column; text-decoration: none; overflow: hidden; transition: transform .15s, box-shadow .15s; }
a.vignette:hover { transform: translateY(-2px); box-shadow: 0 2px 4px rgb(28 27 25 / 8%), 0 10px 28px rgb(28 27 25 / 10%); }
.vignette .apercu { aspect-ratio: 4 / 3; background: #ece7dc center / contain no-repeat; border-bottom: 1px solid var(--trait); }
.vignette .corps { padding: 12px 14px 14px; display: grid; gap: 8px; }
.vignette .sujet { font-weight: 600; }
.ligne { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.vide { padding: 56px 24px; text-align: center; display: grid; gap: 14px; justify-items: center; }

.pastille {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 560;
  background: #ece7dc; color: var(--encre-2); white-space: nowrap;
}
.pastille.attente { background: var(--alerte-doux); color: var(--alerte); }
.pastille.encours { background: #e3ecfb; color: #234f9c; }
.pastille.bon { background: var(--bon-doux); color: var(--bon); }
.pastille.erreur { background: var(--erreur-doux); color: var(--erreur); }

/* ---------- dépôt ---------- */
.depot { max-width: 760px; margin: 0 auto; display: grid; gap: 20px; }
.zone-depot {
  display: grid; place-items: center; gap: 10px; text-align: center;
  min-height: 300px; padding: 28px;
  border: 2px dashed var(--trait-fort); border-radius: 14px; background: var(--carte);
  cursor: pointer; transition: border-color .15s, background .15s;
}
.zone-depot.survol { border-color: var(--accent); background: var(--accent-doux); }
.zone-depot img { max-height: 380px; max-width: 100%; border-radius: 6px; box-shadow: var(--ombre); }
.zone-depot .icone { width: 44px; height: 44px; color: var(--encre-3); }

/* ---------- page d'un dessin ---------- */
.fil { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; color: var(--encre-2); font-size: 14px; }
.titre-dessin { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.etapes { display: flex; gap: 0; margin: 0 0 22px; padding: 0; list-style: none; overflow-x: auto; }
.etapes li {
  display: flex; align-items: center; gap: 8px; padding: 8px 14px 8px 0; margin-right: 14px;
  font-size: 13.5px; color: var(--encre-3); white-space: nowrap; position: relative;
}
.etapes li:not(:last-child)::after { content: ""; width: 22px; height: 1px; background: var(--trait-fort); margin-left: 6px; }
.etapes .rond {
  width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  font-size: 12px; font-weight: 650; border: 1px solid var(--trait-fort); background: var(--carte);
}
.etapes li.fait { color: var(--encre-2); }
.etapes li.fait .rond { background: var(--encre); border-color: var(--encre); color: var(--papier); }
.etapes li.actif { color: var(--encre); font-weight: 600; }
.etapes li.actif .rond { border: 2px solid var(--accent); color: var(--accent); }

.disposition { display: grid; grid-template-columns: minmax(0, 1fr) 270px; gap: 22px; align-items: start; }
.disposition.pleine { grid-template-columns: minmax(0, 1fr); }
.disposition.pleine .versions { position: static; }
.versions { padding: 16px; display: grid; gap: 10px; position: sticky; top: 78px; }
.versions ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.versions a {
  display: grid; gap: 2px; padding: 9px 10px; border-radius: 8px; text-decoration: none;
  border: 1px solid transparent;
}
.versions a:hover { background: #f3efe6; }
.versions a.courante { border-color: var(--trait-fort); background: #fff; }
.versions .remarque { font-size: 12.5px; color: var(--encre-2); font-style: italic; }

/* ---------- éditeur de zones ---------- */
.editeur { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 18px; align-items: start; }
.scene-cadre { padding: 14px; display: grid; justify-items: center; gap: 10px; }
.scene { position: relative; display: inline-block; line-height: 0; user-select: none; -webkit-user-select: none; touch-action: none; }
.scene img { max-width: 100%; max-height: calc(100vh - 230px); min-height: 200px; display: block; border-radius: 4px; }
.scene svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.scene.placer svg { cursor: crosshair; }
.zone { cursor: move; }
.poignee { cursor: nwse-resize; }
.poignee.ne, .poignee.sw { cursor: nesw-resize; }
.legende-scene { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--encre-2); line-height: 1.4; }
.legende-scene span { display: inline-flex; align-items: center; gap: 6px; }
.legende-scene i { width: 12px; height: 12px; border-radius: 3px; border: 2px solid; display: inline-block; }

.panneau { padding: 16px; display: grid; gap: 18px; position: sticky; top: 78px; max-height: calc(100vh - 96px); overflow: auto; }
.bloc { display: grid; gap: 8px; }
.bloc + .bloc { padding-top: 16px; border-top: 1px solid var(--trait); }
.liste-zones { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; }
.liste-zones li {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 7px; font-size: 13.5px; cursor: pointer;
  border: 1px solid transparent;
}
.liste-zones li:hover { background: #f3efe6; }
.liste-zones li.choisi { border-color: var(--trait-fort); background: #fff; }
.liste-zones .lu { color: var(--encre-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.liste-zones .pastille-c { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.liste-zones .suppr { margin-left: auto; border: 0; background: none; color: var(--encre-3); cursor: pointer; font-size: 16px; line-height: 1; padding: 2px 4px; }
.liste-zones .suppr:hover { color: var(--erreur); }

.note {
  padding: 10px 12px; border-radius: 8px; font-size: 13.5px; line-height: 1.45;
  background: #f1ede3; color: var(--encre-2); border-left: 3px solid var(--encre-3);
}
.note.claude { background: var(--accent-doux); border-left-color: var(--accent); color: #5c2a14; }
.note.alerte { background: var(--alerte-doux); border-left-color: var(--alerte); color: #6b3d00; }
.note.erreur { background: var(--erreur-doux); border-left-color: var(--erreur); color: #7a1a12; }
.note.bon { background: var(--bon-doux); border-left-color: var(--bon); color: #134d30; }
.actions { display: grid; gap: 8px; }

/* ---------- attente, rendu ---------- */
.attente-carte { padding: 28px; display: grid; gap: 18px; }
.progres { height: 10px; border-radius: 999px; background: #ebe5d8; overflow: hidden; }
.progres > div { height: 100%; background: var(--encre); border-radius: 999px; transition: width .6s ease; }
.progres.indetermine > div { width: 30% !important; animation: va-et-vient 1.4s ease-in-out infinite; }
@keyframes va-et-vient { 0% { transform: translateX(-100%); } 100% { transform: translateX(340%); } }
.planche { width: 100%; border-radius: 8px; border: 1px solid var(--trait); }
.roue { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--trait-fort); border-top-color: var(--encre); animation: tourne .8s linear infinite; flex: none; }
@keyframes tourne { to { transform: rotate(360deg); } }

/* ---------- validation ---------- */
.validation { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 24px; align-items: start; }
.ecran {
  background: #111; border-radius: 18px; padding: 8px; box-shadow: var(--ombre);
  width: min(380px, calc((100vh - 200px) * 9 / 16));
}
.ecran video { width: 100%; aspect-ratio: 9 / 16; display: block; border-radius: 12px; background: #000; }
.verif { padding: 18px; display: grid; gap: 16px; }
.mesures { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.mesure { padding: 10px 12px; border-radius: 8px; background: #f3efe6; display: grid; gap: 2px; }
.mesure b { font-size: 16px; font-variant-numeric: tabular-nums; }
.mesure span { font-size: 12px; color: var(--encre-2); }
.mesure.ok b::after { content: " ✓"; color: var(--bon); font-size: 13px; }
.mesure.hors b::after { content: " !"; color: var(--alerte); font-size: 13px; }
.bande { width: 100%; border-radius: 6px; border: 1px solid var(--trait); }
.reseaux { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.reseaux label { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--trait); border-radius: 8px; background: #fff; font-size: 14px; cursor: pointer; }
.pubs { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; font-size: 13.5px; }
.pubs li { display: flex; justify-content: space-between; gap: 8px; }
details.journal summary { cursor: pointer; font-size: 13px; color: var(--encre-2); }
details.journal pre { white-space: pre-wrap; font-size: 11.5px; line-height: 1.4; background: #1c1b19; color: #e9e4d8; padding: 12px; border-radius: 8px; max-height: 280px; overflow: auto; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px);
  background: var(--encre); color: var(--papier); padding: 10px 16px; border-radius: 10px;
  font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px);
}
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.toast.erreur { background: var(--erreur); }

/* ---------- petits écrans ---------- */
@media (max-width: 1080px) {
  .disposition { grid-template-columns: 1fr; }
  .versions { position: static; }
  .editeur { grid-template-columns: 1fr; }
  .panneau { position: static; max-height: none; }
}
@media (max-width: 720px) {
  .barre { padding: 10px 16px; }
  .voyants { display: none; }
  .page { padding: 20px 16px 48px; }
  h1 { font-size: 22px; }
  .validation { grid-template-columns: 1fr; justify-items: center; }
  .ecran { width: min(100%, 360px); }
  .verif { width: 100%; }
  .reseaux { grid-template-columns: 1fr; }
  .scene img { max-height: 70vh; }
}

/* ---------- connexion ---------- */
.connexion { max-width: 380px; margin: 8vh auto 0; padding: 28px; display: grid; gap: 18px; }
.connexion .segment { width: 100%; }
.connexion .segment button { flex: 1; padding: 9px 12px; }
input[type=password] {
  width: 100%; padding: 9px 11px;
  border: 1px solid var(--trait-fort); border-radius: 8px;
  background: #fff; color: var(--encre); font-weight: 400; font-size: 16px;
}
.compte { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--encre-2); }
