:root {
  --papier: #faf6ee; --carte: #fffdf8; --encre: #2a2521; --doux: #756b61; --trait: #e3d9c8;
  --accent: #a8481f; --accent-fond: #f6e6dc; --ok: #3c7a4a; --ok-fond: #e3f1e6; --alerte: #b3261e; --alerte-fond: #fbe7e4;
  --encart: #e9f0f6; --encart-trait: #5f86a8;
  --lecture: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --ui: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --papier: #1f1b18; --carte: #29231f; --encre: #efe6d8; --doux: #a89c8d; --trait: #3d352e;
    --accent: #e08a5c; --accent-fond: #3a2a21; --ok: #7fc08e; --ok-fond: #223427; --alerte: #f29a92; --alerte-fond: #3b2422;
    --encart: #22303b; --encart-trait: #7aa3c4; }
}
* { box-sizing: border-box; }
html { font-size: 17px; }
body { margin: 0; background: var(--papier); color: var(--encre); font-family: var(--ui); line-height: 1.5; }
a { color: var(--accent); }
.haut { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.5rem; padding: .7rem 1.2rem;
  border-bottom: 1px solid var(--trait); background: var(--carte); position: sticky; top: 0; z-index: 5; }
.marque { font-family: var(--lecture); font-size: 1.35rem; font-weight: 700; text-decoration: none; color: var(--encre); }
.plume { color: var(--accent); }
.livre-courant { text-decoration: none; color: var(--encre); border: 1px solid var(--trait); border-radius: 999px; padding: .3rem .8rem;
  font-size: .95rem; max-width: 16rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.livre-courant:hover, .livre-courant.actif { border-color: var(--accent); color: var(--accent); }
nav { display: flex; flex-wrap: wrap; gap: .1rem .3rem; }
nav a { text-decoration: none; color: var(--doux); padding: .35rem .7rem; border-radius: 999px; font-size: .95rem; }
nav a:hover { background: var(--accent-fond); }
nav a.actif { background: var(--accent); color: #fff; }
main { max-width: 62rem; margin: 0 auto; padding: 1.5rem 1.2rem 7rem; }
h1 { font-family: var(--lecture); font-size: 1.9rem; margin: .2rem 0 1rem; }
h2 { font-family: var(--lecture); font-size: 1.3rem; margin: 1.8rem 0 .6rem; }
.lead, .note { color: var(--doux); }
.note { font-size: .92rem; }
label { display: block; font-weight: 600; margin: 1rem 0 .3rem; }
input[type=text], input[type=url], input[type=password], select, textarea {
  width: 100%; padding: .6rem .75rem; font: inherit; color: var(--encre); background: var(--carte);
  border: 1px solid var(--trait); border-radius: 10px; }
textarea { font-family: var(--lecture); line-height: 1.55; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
button, .bouton { font: inherit; cursor: pointer; border: 1px solid var(--trait); background: var(--carte); color: var(--encre);
  padding: .5rem 1rem; border-radius: 999px; text-decoration: none; display: inline-block; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.danger { color: var(--alerte); }
button.petit { padding: .25rem .7rem; font-size: .88rem; }
button:disabled { opacity: .5; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; gap: .6rem; margin: 1rem 0; }
.carte { background: var(--carte); border: 1px solid var(--trait); border-radius: 14px; padding: 1rem 1.2rem; margin: .8rem 0; }
.carte h3 { margin: 0 0 .3rem; font-size: 1.05rem; }
.rangee { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; justify-content: space-between; }
.badge { display: inline-block; font-size: .78rem; padding: .1rem .55rem; border-radius: 999px; background: var(--trait); color: var(--doux); }
.badge.ok { background: var(--ok-fond); color: var(--ok); }
.badge.ko { background: var(--alerte-fond); color: var(--alerte); }
.badge.att { background: var(--accent-fond); color: var(--accent); }
.erreur { background: var(--alerte-fond); color: var(--alerte); padding: .6rem .9rem; border-radius: 10px; margin: .6rem 0; }
.info { background: var(--accent-fond); padding: .6rem .9rem; border-radius: 10px; margin: .6rem 0; }
.etoiles { color: var(--accent); letter-spacing: .1em; }
.vide { color: var(--doux); font-style: italic; padding: 1rem 0; }
details { margin: 1rem 0; } summary { cursor: pointer; color: var(--doux); }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { text-align: left; vertical-align: top; padding: .5rem .6rem; border-bottom: 1px solid var(--trait); }
th { color: var(--doux); font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip { background: var(--accent-fond); color: var(--accent); padding: .15rem .7rem; border-radius: 999px; text-decoration: none; font-size: .9rem; }

/* Enregistrement */
.micro { display: flex; align-items: center; gap: 1rem; margin: 1.2rem 0; flex-wrap: wrap; }
.rec { background: var(--accent); color: #fff; border: 0; font-size: 1.15rem; font-weight: 600; padding: .9rem 1.8rem; }
.rec.enreg { background: var(--alerte); animation: pouls 1.6s infinite; }
@keyframes pouls { 50% { box-shadow: 0 0 0 10px rgba(179,38,30,.15); } }
#timer { font-variant-numeric: tabular-nums; color: var(--doux); font-size: 1.1rem; }
.niveau { width: 8rem; height: .5rem; background: var(--trait); border-radius: 99px; overflow: hidden; }
.niveau i { display: block; height: 100%; width: 0; background: var(--ok); transition: width .1s; }

/* Livre */
.livre { display: grid; grid-template-columns: 15rem 1fr; gap: 2rem; align-items: start; }
.sommaire { position: sticky; top: 4.5rem; font-size: .95rem; max-height: calc(100vh - 6rem); overflow: auto; }
.sommaire h4 { margin: 1rem 0 .3rem; color: var(--doux); font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; }
.sommaire a { display: block; padding: .15rem .5rem; text-decoration: none; color: var(--encre); border-radius: 6px; }
.sommaire a:hover { background: var(--accent-fond); }
.sommaire a.actif { background: var(--accent-fond); color: var(--accent); font-weight: 600; }
.sommaire a.vide-p { color: var(--doux); }
.fiche { font-family: var(--lecture); font-size: 1.08rem; line-height: 1.75; background: var(--carte); border: 1px solid var(--trait);
  border-radius: 14px; padding: 1.5rem 2rem; }
.fiche h1 { font-size: 2.1rem; margin-top: 0; }
.fiche h2 { font-size: 1.45rem; border-bottom: 1px solid var(--trait); padding-bottom: .2rem; }
.fiche h3 { font-size: 1.15rem; }
.fiche p { margin: .8rem 0; } .fiche li { margin: .2rem 0; }
.fiche a.mort { color: var(--doux); text-decoration: line-through; }
.fiche a.interne { text-decoration: none; border-bottom: 1px dotted var(--accent); }
.fiche blockquote { margin: 1rem 0; padding-left: 1rem; border-left: 3px solid var(--trait); color: var(--doux); }
.fiche figure { margin: 1.2rem 0; text-align: center; } .fiche figure img { max-width: 100%; border-radius: 8px; }
.fiche figcaption { font-size: .92rem; color: var(--doux); font-style: italic; }
.encart { background: var(--encart); border-left: 4px solid var(--encart-trait); border-radius: 0 10px 10px 0; padding: .7rem 1rem;
  margin: 1.2rem 0; font-family: var(--ui); font-size: .93rem; line-height: 1.55; }
.encart strong.t { display: block; color: var(--encart-trait); margin-bottom: .2rem; }
.encart p { margin: .4rem 0; }
.mentions { margin-top: 1.5rem; }

/* Bandeau de tâche */
.job { position: fixed; left: 50%; bottom: 1rem; transform: translateX(-50%); width: min(34rem, calc(100% - 2rem));
  background: var(--carte); border: 1px solid var(--accent); border-radius: 14px; padding: .8rem 1rem; box-shadow: 0 8px 30px rgba(0,0,0,.18); z-index: 20; }
.job .barre { height: .5rem; background: var(--trait); border-radius: 99px; overflow: hidden; margin-top: .5rem; }
.job .barre i { display: block; height: 100%; background: var(--accent); transition: width .5s; }
.toast { position: fixed; top: 4.5rem; right: 1rem; background: var(--encre); color: var(--papier); padding: .7rem 1rem; border-radius: 10px;
  max-width: 24rem; z-index: 30; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.toast.mauvais { background: var(--alerte); color: #fff; }
.spin { display: inline-block; width: .9rem; height: .9rem; border: 2px solid var(--trait); border-top-color: var(--accent);
  border-radius: 50%; animation: tour 1s linear infinite; vertical-align: -2px; margin-right: .4rem; }
@keyframes tour { to { transform: rotate(360deg); } }
.grille2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.mini { width: 4.5rem; height: 4.5rem; object-fit: cover; border-radius: 8px; }
@media (max-width: 760px) {
  .livre, .grille2 { grid-template-columns: 1fr; }
  .sommaire { position: static; max-height: none; }
  .fiche { padding: 1rem 1.1rem; }
}

/* Version web */
.lien-carte { color: inherit; text-decoration: none; }
.lien-carte:hover { border-color: var(--accent); }
.qr-bloc { justify-content: flex-start; align-items: flex-start; gap: 1.2rem; margin-top: 1rem; }
.qr { background: #fff; padding: .4rem; border-radius: 8px; line-height: 0; }
#livre-courant[hidden] { display: none; }
