:root {
  --rouge: #e8505b;
  --rouge-f: #c93a45;
  --fond: #fbf7f2;
  --carte: #ffffff;
  --texte: #2b2725;
  --doux: #7a716b;
  --bord: #ece4da;
  --vert: #2e9d5b;
  --orange: #e29a26;
  --rayon: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fond: #1d1a19; --carte: #282423; --texte: #f1ebe6; --doux: #a89e97; --bord: #3a3432;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--fond); color: var(--texte);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: var(--rouge-f); }
@media (prefers-color-scheme: dark) { a { color: #ff8a93; } }
h1 { font-size: 1.5rem; margin: 1.2rem 0 .8rem; }
h2 { font-size: 1.1rem; margin: 0 0 .8rem; }
h2 small { color: var(--doux); font-weight: normal; font-size: .85rem; }
code, pre { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .85em; }

.barre {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap;
  background: var(--rouge); color: #fff; padding: .6rem 1rem;
  padding-top: max(.6rem, env(safe-area-inset-top));
}
.logo { color: #fff; text-decoration: none; font-weight: 700; font-size: 1.15rem; }
.barre nav { display: flex; gap: .25rem; }
.barre nav a {
  color: #fff; text-decoration: none; padding: .35rem .7rem; border-radius: 999px; font-size: .95rem;
}
.barre nav a.actif { background: rgba(255,255,255,.22); }
main { max-width: 720px; margin: 0 auto; padding: .5rem 1rem 3rem; }

.carte {
  background: var(--carte); border: 1px solid var(--bord); border-radius: var(--rayon);
  padding: 1rem; margin: 1rem 0; box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.connexion { max-width: 380px; margin: 3rem auto; }
.ligne { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.ligne > input, .ligne > select { flex: 1 1 200px; }
.centre { text-align: center; }

label { display: block; margin: .6rem 0; font-size: .95rem; }
label.case { display: flex; align-items: center; gap: .5rem; }
input[type=text], input[type=password], input[type=number], select {
  display: block; width: 100%; margin-top: .3rem; padding: .7rem .8rem; font: inherit;
  border: 1px solid var(--bord); border-radius: 10px; background: var(--fond); color: var(--texte);
}
.ligne input, .ligne select { margin-top: 0; }
input[type=range] { width: 100%; accent-color: var(--rouge); }
input[type=checkbox] { width: 1.2rem; height: 1.2rem; accent-color: var(--rouge); }

.bouton {
  display: inline-block; border: 0; border-radius: 999px; padding: .7rem 1.2rem; font: inherit; font-weight: 600;
  background: var(--rouge); color: #fff; text-decoration: none; cursor: pointer; margin: .3rem 0;
}
.bouton:active { transform: scale(.98); }
.bouton.secondaire { background: transparent; color: var(--texte); border: 1px solid var(--bord); }
.bouton.danger { background: #b3261e; }
.lien { background: none; border: 0; padding: .4rem; font: inherit; cursor: pointer; color: var(--rouge-f); text-decoration: underline; }
.danger.lien { color: #b3261e; }
.icone {
  width: 2.5rem; height: 2.5rem; border-radius: 50%; border: 1px solid var(--bord); background: var(--fond);
  color: var(--texte); font-size: 1rem; cursor: pointer;
}
.icone.danger { color: #b3261e; }

.flash { padding: .8rem 1rem; border-radius: 10px; margin: 1rem 0; background: #e3f4ea; color: #1d5e37; }
.flash.erreur { background: #fde4e2; color: #8c1d18; }
.flash.info { background: #fff1d6; color: #7a4b00; }
.erreur { color: #b3261e; }
.info { background: #fff1d6; color: #7a4b00; padding: .6rem .8rem; border-radius: 10px; }
.meta { color: var(--doux); font-size: .85rem; }
.vide { color: var(--doux); font-style: italic; }

.etat-box { display: flex; flex-direction: column; gap: .2rem; }
.etat-box > div { display: flex; align-items: center; gap: .5rem; }
.pastille { font-size: .8rem; padding: .15rem .55rem; border-radius: 999px; color: #fff; }
.pastille.vert { background: var(--vert); } .pastille.orange { background: var(--orange); } .pastille.gris { background: #9a918b; }

.liste { list-style: none; padding: 0; margin: 0; }
.liste li a {
  display: flex; flex-direction: column; gap: .15rem; text-decoration: none; color: inherit;
  background: var(--carte); border: 1px solid var(--bord); border-radius: var(--rayon); padding: .9rem 1rem; margin-bottom: .6rem;
}
.liste .titre { font-weight: 600; font-size: 1.05rem; }

.titre-edit { display: flex; gap: .5rem; align-items: center; margin: .5rem 0; }
.titre-edit input { font-size: 1.3rem; font-weight: 700; margin: 0; }

.pistes { padding: 0; margin: 0; list-style: none; counter-reset: p; }
.pistes li { border-top: 1px solid var(--bord); padding: .7rem 0; counter-increment: p; }
.pistes li:first-child { border-top: 0; }
.piste-haut { display: flex; justify-content: space-between; gap: .5rem; align-items: baseline; }
.piste-titre::before { content: counter(p) ". "; color: var(--doux); }
.piste-actions { display: flex; gap: .4rem; margin-top: .4rem; }
audio { width: 100%; margin-top: .8rem; }

.depot {
  display: block; position: relative; border: 2px dashed var(--bord); border-radius: var(--rayon);
  padding: 1.6rem 1rem; text-align: center; cursor: pointer; margin: 0;
}
.depot.survol { border-color: var(--rouge); background: rgba(232,80,91,.06); }
.depot input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.depot span { font-weight: 600; }
.options { display: flex; flex-wrap: wrap; gap: 0 1.2rem; align-items: end; }
.options > label:first-child { flex: 1 1 220px; }
.envois { list-style: none; padding: 0; margin: .8rem 0 0; }
.envois li { padding: .6rem 0; border-top: 1px solid var(--bord); }
.envoi-nom { font-weight: 600; overflow-wrap: anywhere; }
.barre-prog { height: 6px; background: var(--bord); border-radius: 99px; overflow: hidden; margin: .4rem 0; }
.barre-prog span { display: block; height: 100%; width: 0; background: var(--rouge); transition: width .2s; }
.envois li.ok .barre-prog span { background: var(--vert); }
.envois li.erreur .envoi-etat { color: #b3261e; }

.figs { list-style: none; padding: 0; margin: 0 0 .8rem; }
.figs li { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .4rem 0; }
.fig-haut { display: flex; flex-direction: column; }

.appairage { text-align: center; padding: 2rem 1rem; }
.appairage .grand { font-size: 1.3rem; font-weight: 700; }
.appairage label { text-align: left; }
.anneau {
  width: 110px; height: 110px; margin: 0 auto 1rem; border-radius: 50%;
  border: 6px solid var(--rouge); opacity: .85; animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { transform: scale(.85); opacity: .5; } 50% { transform: scale(1); opacity: 1; } }
.code { background: var(--fond); border: 1px solid var(--bord); border-radius: 10px; padding: .8rem; overflow-x: auto; white-space: pre; }
.zone-danger { margin-top: 2rem; text-align: center; }

/* Bibliothèque */
.biblio-liste { list-style: none; padding: 0; margin: .5rem 0 1rem; }
.biblio-liste li { display: flex; gap: .6rem; align-items: flex-start; padding: .45rem 0; border-bottom: 1px solid var(--bord); }
.biblio-liste li:last-child { border-bottom: 0; }
.biblio-liste small { color: var(--doux); }
.biblio-msg { min-height: 1.2em; margin: .5rem 0 0; }
@media (max-width: 440px) {
  .barre nav { gap: 0; max-width: 100%; overflow-x: auto; }
  .barre nav a { padding: .35rem .5rem; font-size: .88rem; white-space: nowrap; }
}
