/* MyStoryBook — feuille de style unique.
   Mobile-first, thème clair/sombre automatique, aucune dépendance externe. */

:root {
  --fond: #f6f6f9;
  --surface: #ffffff;
  --surface-2: #eef0f6;
  --texte: #1c1e26;
  --texte-2: #5b6070;
  --bord: #e2e4ee;
  --accent: #6d5ef0;
  --accent-fonce: #5546e0;
  --accent-doux: #eeebff;
  --ok: #1e9e6a;
  --ok-doux: #e2f6ed;
  --alerte: #b7791f;
  --alerte-doux: #fdf3e2;
  --danger: #d64545;
  --danger-doux: #fdeaea;
  --rayon: 12px;
  --ombre: 0 1px 3px rgb(20 22 40 / .07), 0 8px 24px rgb(20 22 40 / .06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --fond: #14151c;
    --surface: #1d1f29;
    --surface-2: #262835;
    --texte: #eceef6;
    --texte-2: #9aa0b4;
    --bord: #31344455;
    --accent: #8d80ff;
    --accent-fonce: #a99fff;
    --accent-doux: #2c2a45;
    --ok: #46c58e;
    --ok-doux: #1c3a2e;
    --alerte: #e0a94f;
    --alerte-doux: #3c3220;
    --danger: #ef7070;
    --danger-doux: #442326;
    --ombre: 0 1px 3px rgb(0 0 0 / .4);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--fond);
  color: var(--texte);
}
h1 { font-size: 1.45rem; margin: 0 0 .35rem; letter-spacing: -.02em; }
h2 { font-size: 1.05rem; margin: 1.6rem 0 .7rem; }
h3 { font-size: .95rem; margin: 0 0 .4rem; }
p { margin: .3rem 0; }
a { color: var(--accent); text-decoration: none; }
code, .mono { font-family: ui-monospace, "Cascadia Code", Menlo, monospace; font-size: .86em; }

/* ---- structure : barre latérale (desktop) / barre basse (mobile) ---- */
.coquille { display: flex; min-height: 100dvh; }
.lateral {
  width: 230px; flex-shrink: 0;
  padding: 1.1rem .9rem;
  display: flex; flex-direction: column; gap: 1.2rem;
  border-right: 1px solid var(--bord);
  background: var(--surface);
  position: sticky; top: 0; height: 100dvh;
}
.marque { display: flex; align-items: center; gap: .55rem; font-weight: 700; font-size: 1.05rem; padding: .2rem .4rem; }
.marque-icone { font-size: 1.3rem; }
.nav-liens { display: flex; flex-direction: column; gap: .15rem; }
.nav-liens a {
  display: flex; align-items: center; gap: .65rem;
  padding: .55rem .7rem; border-radius: 9px;
  color: var(--texte-2); font-weight: 500;
}
.nav-liens a .ic { width: 1.2rem; text-align: center; }
.nav-liens a:hover { background: var(--surface-2); color: var(--texte); }
.nav-liens a.actif { background: var(--accent-doux); color: var(--accent-fonce); }
.nav-pied { margin-top: auto; }
.badge-jobs {
  display: inline-block; padding: .3rem .7rem; border-radius: 999px;
  background: var(--accent-doux); color: var(--accent-fonce);
  font-size: .8rem; font-weight: 600;
}
.vue { flex: 1; padding: 1.6rem clamp(1rem, 4vw, 2.6rem) 5.5rem; max-width: 1060px; }

@media (max-width: 760px) {
  .coquille { flex-direction: column; }
  .lateral {
    position: fixed; bottom: 0; top: auto; z-index: 40;
    width: 100%; height: auto; flex-direction: row; align-items: center;
    padding: .35rem .5rem calc(.35rem + env(safe-area-inset-bottom));
    border-right: 0; border-top: 1px solid var(--bord);
  }
  .marque, .nav-pied { display: none; }
  .nav-liens { flex-direction: row; width: 100%; justify-content: space-around; gap: 0; }
  .nav-liens a { flex-direction: column; gap: .1rem; font-size: .62rem; padding: .35rem .5rem; }
  .nav-liens a .ic { font-size: 1.15rem; width: auto; }
  .vue { padding: 1.1rem .9rem 5.5rem; }
}

/* ---- composants ---- */
.carte {
  background: var(--surface); border: 1px solid var(--bord);
  border-radius: var(--rayon); box-shadow: var(--ombre);
  padding: 1rem 1.1rem; margin-bottom: 1rem;
}
.grille { display: grid; gap: .9rem; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.grille .carte { margin: 0; }
.entete-page { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.sous-titre { color: var(--texte-2); font-size: .9rem; }

.btn {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .5rem .95rem; border-radius: 9px; border: 1px solid var(--bord);
  background: var(--surface); color: var(--texte);
  font: inherit; font-weight: 600; font-size: .88rem; cursor: pointer;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primaire { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primaire:hover { background: var(--accent-fonce); border-color: var(--accent-fonce); }
.btn-danger { color: var(--danger); border-color: var(--danger-doux); background: transparent; }
.btn-danger:hover { background: var(--danger-doux); }
.btn-petit { padding: .3rem .65rem; font-size: .8rem; }

.pastille {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .12rem .55rem; border-radius: 999px;
  font-size: .74rem; font-weight: 600; white-space: nowrap;
  background: var(--surface-2); color: var(--texte-2);
}
.pastille.ok { background: var(--ok-doux); color: var(--ok); }
.pastille.alerte { background: var(--alerte-doux); color: var(--alerte); }
.pastille.danger { background: var(--danger-doux); color: var(--danger); }
.pastille.accent { background: var(--accent-doux); color: var(--accent-fonce); }

.champ { display: block; margin-bottom: .85rem; }
.champ > span { display: block; font-size: .82rem; font-weight: 600; color: var(--texte-2); margin-bottom: .3rem; }
.champ input[type="text"], .champ input[type="password"], .champ input[type="number"],
.champ select, .champ textarea {
  width: 100%; padding: .55rem .7rem;
  border: 1px solid var(--bord); border-radius: 9px;
  background: var(--fond); color: var(--texte); font: inherit;
}
.champ textarea { resize: vertical; min-height: 90px; }
.champ textarea.mono { font-family: ui-monospace, Menlo, monospace; font-size: .82rem; line-height: 1.5; }
.champ input:focus, .champ select:focus, .champ textarea:focus {
  outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent;
}
.champ-case { display: flex; align-items: center; gap: .5rem; margin-bottom: .6rem; font-size: .9rem; }
.aide { font-size: .78rem; color: var(--texte-2); }

.banniere {
  border-radius: var(--rayon); padding: .8rem 1rem; margin-bottom: 1rem;
  font-size: .88rem; border: 1px solid transparent;
}
.banniere.info { background: var(--accent-doux); color: var(--accent-fonce); }
.banniere.alerte { background: var(--alerte-doux); color: var(--alerte); }
.banniere.danger { background: var(--danger-doux); color: var(--danger); }

/* ---- pipeline (stepper vertical) ---- */
.etape {
  display: flex; gap: .8rem; align-items: flex-start;
  padding: .7rem 0; border-bottom: 1px solid var(--bord);
}
.etape:last-child { border-bottom: 0; }
.etape-puce {
  width: 1.9rem; height: 1.9rem; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; font-size: .85rem; font-weight: 700;
  background: var(--surface-2); color: var(--texte-2);
}
.etape.faite .etape-puce { background: var(--ok-doux); color: var(--ok); }
.etape.dispo .etape-puce { background: var(--accent-doux); color: var(--accent-fonce); }
.etape-corps { flex: 1; min-width: 0; }
.etape-titre { font-weight: 600; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.etape-raison { font-size: .8rem; color: var(--texte-2); margin-top: .15rem; }

/* ---- médias ---- */
.grille-medias { display: grid; gap: .7rem; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
.media {
  border: 1px solid var(--bord); border-radius: 10px; overflow: hidden;
  background: var(--surface-2); cursor: pointer; text-align: center;
}
.media .apercu { height: 110px; display: flex; align-items: center; justify-content: center; font-size: 2rem; overflow: hidden; }
.media img { width: 100%; height: 110px; object-fit: cover; display: block; }
.media .media-nom {
  font-size: .72rem; padding: .3rem .4rem; word-break: break-all;
  background: var(--surface); border-top: 1px solid var(--bord);
}

/* ---- personnages ---- */
.perso { text-align: center; }
.perso img { width: 100%; max-height: 260px; object-fit: contain; border-radius: 9px; background: var(--surface-2); }
.perso .actions { display: flex; gap: .4rem; justify-content: center; flex-wrap: wrap; margin-top: .6rem; }

/* ---- journal ---- */
.journal {
  background: #101018; color: #cfd4e6;
  border-radius: 10px; padding: .8rem 1rem;
  font-family: ui-monospace, Menlo, monospace; font-size: .76rem; line-height: 1.5;
  max-height: 320px; overflow: auto; white-space: pre-wrap; word-break: break-word;
}

/* ---- modales & toasts ---- */
.voile {
  position: fixed; inset: 0; z-index: 60;
  background: rgb(10 10 20 / .55);
  display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.modale {
  background: var(--surface); border-radius: 14px; box-shadow: var(--ombre);
  width: min(560px, 100%); max-height: 88dvh; overflow: auto; padding: 1.2rem 1.3rem;
}
.modale-large { width: min(860px, 100%); }
.modale-actions { display: flex; gap: .6rem; justify-content: flex-end; margin-top: 1.1rem; flex-wrap: wrap; }
.toasts {
  position: fixed; z-index: 80; bottom: calc(1rem + env(safe-area-inset-bottom)); right: 1rem;
  display: flex; flex-direction: column; gap: .5rem; max-width: min(380px, calc(100vw - 2rem));
}
@media (max-width: 760px) { .toasts { bottom: 4.6rem; left: 1rem; } }
.toast {
  background: var(--surface); border: 1px solid var(--bord); border-left: 4px solid var(--accent);
  border-radius: 10px; box-shadow: var(--ombre);
  padding: .65rem .9rem; font-size: .86rem;
  animation: apparition .18s ease-out;
}
.toast.ok { border-left-color: var(--ok); }
.toast.erreur { border-left-color: var(--danger); }
@keyframes apparition { from { opacity: 0; transform: translateY(8px); } }

.tableau { width: 100%; border-collapse: collapse; font-size: .88rem; }
.tableau th, .tableau td { text-align: left; padding: .45rem .6rem; border-bottom: 1px solid var(--bord); }
.tableau th { color: var(--texte-2); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }

.stat { text-align: center; padding: 1.1rem .6rem; }
.stat .valeur { font-size: 1.7rem; font-weight: 700; letter-spacing: -.02em; }
.stat .libelle { font-size: .8rem; color: var(--texte-2); }

details.pli { border: 1px solid var(--bord); border-radius: 10px; margin-bottom: .6rem; background: var(--surface); }
details.pli > summary {
  cursor: pointer; padding: .65rem .9rem; font-weight: 600; font-size: .9rem;
  list-style: none; display: flex; align-items: center; gap: .5rem;
}
details.pli > summary::before { content: "▸"; transition: transform .15s; color: var(--texte-2); }
details.pli[open] > summary::before { transform: rotate(90deg); }
details.pli > .pli-corps { padding: 0 .9rem .9rem; }
.vide { text-align: center; color: var(--texte-2); padding: 2.2rem 1rem; }
.vide .gros { font-size: 2.2rem; }
