/* =========================================================
   LE DÉPÔT — bouton rond et fenêtre d'ajout
   Le formulaire ne traîne plus au milieu de la page : un bouton
   rond en bas à droite, et une fenêtre qui s'ouvre par-dessus.
   ========================================================= */

.fab{
  position:fixed;right:22px;bottom:22px;z-index:60;
  width:58px;height:58px;border-radius:50%;border:0;cursor:pointer;
  background:var(--accent);color:var(--on-accent);
  box-shadow:0 4px 10px rgba(43,38,32,.18), 0 14px 34px -12px rgba(43,38,32,.55);
  display:grid;place-items:center;
  transition:transform .15s ease, box-shadow .15s ease;
}
.fab:hover{transform:translateY(-2px) scale(1.04)}
.fab:active{transform:scale(.96)}
.fab svg{width:26px;height:26px;stroke:currentColor;stroke-width:2.2;fill:none;stroke-linecap:round}
.fab .bulle{
  position:absolute;right:72px;white-space:nowrap;
  background:var(--ink);color:var(--ground);border-radius:var(--r-pill);
  font-family:var(--f-ui);font-size:12.5px;font-weight:500;padding:7px 13px;
  opacity:0;pointer-events:none;transition:opacity .15s ease;
}
.fab:hover .bulle{opacity:1}
@media (max-width:520px){ .fab{right:16px;bottom:16px;width:54px;height:54px} .fab .bulle{display:none} }

.voile{
  position:fixed;inset:0;z-index:70;background:rgba(43,38,32,.34);
  backdrop-filter:blur(3px);display:grid;place-items:end center;padding:0;
}
.voile[hidden]{display:none}
@media (min-width:640px){ .voile{place-items:center} }

.fenetre{
  background:var(--surface);width:min(760px,100%);max-height:94vh;overflow:auto;
  border:1px solid var(--rule);border-radius:var(--r-lg) var(--r-lg) 0 0;
  box-shadow:0 -6px 40px -10px rgba(43,38,32,.45);
  padding:22px 22px 26px;
  animation:monte .22s ease;
}
@media (min-width:640px){ .fenetre{border-radius:var(--r-lg);animation:apparait .18s ease} }
@keyframes monte{from{transform:translateY(26px);opacity:.6}to{transform:none;opacity:1}}
@keyframes apparait{from{transform:scale(.97);opacity:0}to{transform:none;opacity:1}}

.fenetre .tete{display:flex;align-items:flex-start;gap:14px;margin-bottom:4px}
.fenetre h2{font-family:var(--f-disp);font-weight:600;font-size:21px;margin:0;flex:1}
.fenetre .fermer{
  border:0;background:var(--surface-2);color:var(--muted);cursor:pointer;
  width:32px;height:32px;border-radius:50%;font-size:18px;line-height:1;flex:0 0 auto;
}
.fenetre .fermer:hover{background:var(--rule);color:var(--ink)}
.fenetre .sous{font-family:var(--f-ui);font-size:13px;color:var(--muted);line-height:1.6;margin:0 0 14px}

.champs{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:12px}
.champs .large{grid-column:1/-1}
label.ch{display:flex;flex-direction:column;gap:5px;font-family:var(--f-ui);font-size:12px;font-weight:600;color:var(--muted)}
label.ch input,label.ch select{
  font-family:var(--f-ui);font-size:15px;padding:10px 12px;border-radius:var(--r);
  border:1px solid var(--rule-strong);background:var(--surface);color:var(--ink);width:100%;
}
label.ch input:focus,label.ch select:focus{outline:2px solid var(--accent);outline-offset:1px;border-color:var(--accent)}

.zone{
  margin-top:14px;border:1.5px dashed var(--rule-strong);border-radius:var(--r);
  padding:24px 16px;text-align:center;font-family:var(--f-ui);font-size:13.5px;
  color:var(--muted);cursor:pointer;line-height:1.6;
}
.zone:hover{border-color:var(--accent);color:var(--accent)}
.zone.pret{border-color:var(--ok);color:var(--ok);background:var(--ok-bg)}
.zone b{display:block;font-size:14.5px;color:inherit;margin-bottom:2px}

.fenetre .btn{width:100%;margin-top:16px;padding:13px}
.fenetre .deux{margin:14px 0 18px}
.msg{font-family:var(--f-ui);font-size:13px;margin-top:12px;padding:11px 14px;border-radius:var(--r);display:none;line-height:1.5}
.msg.ok{display:block;background:var(--ok-bg);color:var(--ok);border:1px solid var(--ok)}
.msg.ko{display:block;background:var(--ko-bg);color:var(--ko);border:1px solid var(--ko)}

/* --- l'éditeur : deux volets, et la liste des chapitres --- */
.fenetre .deux{display:grid;grid-template-columns:1fr 1fr;gap:8px}
.fenetre .deux button{
  font-family:var(--f-ui);font-size:13.5px;font-weight:600;cursor:pointer;padding:10px 8px;
  background:var(--surface);color:var(--muted);border:1px solid var(--rule);border-radius:var(--r);
}
.fenetre .deux button[aria-selected="true"]{background:var(--ink);border-color:var(--ink);color:var(--ground)}
.chap-off{display:none!important}

/* --- l'organisation : parties et chapitres --- */
.orga{display:flex;flex-direction:column;gap:16px;max-height:52vh;overflow:auto;
  padding:2px 2px 4px}
.orga>.grp{flex:0 0 auto}
.grp{border:1px solid var(--rule);border-radius:var(--r);overflow:hidden;background:var(--surface)}
.grp-tete{display:flex;align-items:center;gap:10px;padding:9px 12px;background:var(--surface-2);
  border-bottom:1px solid var(--rule);font-family:var(--f-ui)}
.grp-tete .nm{flex:1;min-width:0;font-size:11px;font-weight:700;letter-spacing:.13em;
  text-transform:uppercase;color:var(--accent);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.grp-vide{font-family:var(--f-ui);font-size:12.5px;color:var(--muted);padding:12px 14px}
.ligne-chap{display:flex;align-items:center;gap:10px;padding:9px 12px;
  border-bottom:1px solid var(--rule);font-family:var(--f-ui);font-size:13.5px}
.ligne-chap:last-child{border-bottom:0}
.ligne-chap.off{opacity:.45}
.ligne-chap .rg{font-size:11px;font-weight:700;letter-spacing:.08em;color:var(--accent);
  background:var(--accent-bg);border-radius:7px;padding:3px 8px;flex:0 0 auto}
.ligne-chap .ti{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.fl{display:flex;flex-direction:column;gap:2px;flex:0 0 auto}
.act{display:flex;gap:5px;flex-wrap:wrap;justify-content:flex-end;flex:0 0 auto}
.mini{font-family:var(--f-ui);font-size:11.5px;font-weight:600;cursor:pointer;
  padding:4px 9px;border-radius:var(--r-pill);border:1px solid var(--rule-strong);
  background:var(--surface);color:var(--muted);line-height:1.3}
.mini:hover:not(:disabled){background:var(--surface-2);color:var(--ink)}
.mini:disabled{opacity:.3;cursor:default}
.mini.danger:hover:not(:disabled){border-color:var(--ko);color:var(--ko)}
.fl .mini{padding:1px 6px;font-size:11px}

.ajouts{display:grid;grid-template-columns:1fr;gap:14px;margin-top:18px}
@media (min-width:640px){ .ajouts{grid-template-columns:1fr 1fr} }
.bloc-ajout{border:1px dashed var(--rule-strong);border-radius:var(--r);padding:14px}
.bloc-ajout .lg{font-family:var(--f-ui);font-size:11px;font-weight:700;letter-spacing:.13em;
  text-transform:uppercase;color:var(--muted);margin-bottom:10px}
.bloc-ajout .btn{margin-top:12px;padding:10px}

/* sur un téléphone, les boutons passent sous le titre du chapitre */
@media (max-width:560px){
  .ligne-chap{flex-wrap:wrap}
  .ligne-chap .ti{flex:1 1 100%;order:3;white-space:normal}
  .act{flex:1 1 100%;order:4;justify-content:flex-start}
}
