:root {
  --fond: #f4f2ec; --carte: #fffdf8; --texte: #23231f; --doux: #6d6a60; --bord: #e2ddd0;
  --vert: #1f6f4a; --vert-clair: #e3efe7; --orange: #b85c1c; --orange-clair: #f8e7d8;
  --rouge: #a8322d; --rayon: 12px;
}
@media (prefers-color-scheme: dark) {
  :root { --fond: #171815; --carte: #22231f; --texte: #ecebe4; --doux: #a19e93; --bord: #36372f;
          --vert: #5cbf8c; --vert-clair: #20352a; --orange: #e59a5c; --orange-clair: #3a2a1c; --rouge: #e0726c; }
}
* { 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; }
main { max-width: 760px; margin: 0 auto; padding: 16px 16px calc(32px + env(safe-area-inset-bottom)); }
a { color: var(--vert); }
h1 { font-size: 1.45rem; margin: 18px 0 10px; }
h2 { font-size: 1.05rem; margin: 0 0 8px; }
code, pre { font-family: ui-monospace, Menlo, monospace; font-size: .85rem; }
pre { white-space: pre-wrap; word-break: break-word; background: var(--fond); padding: 8px; border-radius: 8px; max-height: 320px; overflow: auto; }

.entete { position: sticky; top: 0; z-index: 5; background: var(--vert); color: #fff; padding: 10px 16px 0; }
.entete .logo { color: #fff; font-weight: 700; text-decoration: none; display: block; margin-bottom: 6px; }
.entete nav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 12px; }
.entete nav a { color: #fff; opacity: .8; text-decoration: none; padding: 8px 10px 10px; white-space: nowrap; border-bottom: 3px solid transparent; }
.entete nav a.actif { opacity: 1; border-color: #fff; font-weight: 600; }

.carte { display: block; background: var(--carte); border: 1px solid var(--bord); border-radius: var(--rayon); padding: 14px; margin: 12px 0; }
.lien-carte { color: inherit; text-decoration: none; }
.lien-carte:active { background: var(--vert-clair); }
.titre-action { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.titre-action h2 { margin: 0; }
.aide { color: var(--doux); font-size: .88rem; margin: 4px 0; }
.vide { color: var(--doux); font-style: italic; }
.compteur { background: var(--vert); color: #fff; border-radius: 99px; font-size: .85rem; padding: 1px 9px; vertical-align: middle; }

label { display: block; font-size: .88rem; color: var(--doux); margin: 8px 0; }
input, select, textarea { display: block; width: 100%; margin-top: 4px; font: inherit; font-size: 16px; color: var(--texte);
  background: var(--fond); border: 1px solid var(--bord); border-radius: 8px; padding: 9px 10px; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--vert); outline-offset: 1px; }
label.case { display: flex; gap: 8px; align-items: center; color: var(--texte); }
label.case input { width: auto; margin: 0; }
.rangee { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.rangee label { margin: 8px 0; }

button, .bouton { display: inline-block; font: inherit; font-weight: 600; border: 0; border-radius: 8px; padding: 10px 16px;
  background: var(--vert); color: #fff; cursor: pointer; text-decoration: none; }
button.secondaire { background: var(--vert-clair); color: var(--vert); }
button.danger { background: transparent; color: var(--rouge); border: 1px solid currentColor; }
button.discret { background: transparent; color: var(--doux); padding: 6px 10px; }
button.large { width: 100%; margin-top: 12px; }
.boutons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

.flash { white-space: pre-line; padding: 12px 14px; border-radius: var(--rayon); margin: 12px 0; background: var(--vert-clair); }
.flash.erreur { background: var(--orange-clair); color: var(--orange); }

.dicter { display: flex; gap: 8px; align-items: stretch; margin-top: 4px; }
.dicter textarea { margin: 0; flex: 1; }
.dicter button { flex: 0 0 auto; max-width: 110px; }

.questions { border-color: var(--orange); background: var(--orange-clair); }
.ligne-question { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px solid var(--bord); }
.ligne-question:first-of-type { border-top: 0; }
.ligne-question form { flex: 0 0 auto; }
.ligne-question.inactive { opacity: .5; }
.mini { display: flex; }

.article { border-top: 1px solid var(--bord); }
.article:first-of-type { border-top: 0; }
.article summary { list-style: none; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; padding: 10px 0; cursor: pointer; }
.article summary::-webkit-details-marker { display: none; }
.article .nom { font-weight: 600; flex: 1 1 auto; }
.article[open] summary { color: var(--vert); }
.edition { padding: 0 0 12px; }
.qte { font-variant-numeric: tabular-nums; }
.qte.manquante { color: var(--orange); font-weight: 700; }
.qte.habitude::after { content: " ↺"; color: var(--doux); }
.badge { font-size: .76rem; padding: 2px 8px; border-radius: 99px; background: var(--vert-clair); color: var(--vert); white-space: nowrap; }
.badge.doux { background: var(--fond); color: var(--doux); }
.badge.alerte { background: var(--orange-clair); color: var(--orange); }

.ajout { border-top: 1px dashed var(--bord); margin-top: 10px; padding-top: 6px; }
.ligne-habitude { display: grid; grid-template-columns: 1fr 72px 82px auto auto; gap: 6px; align-items: center; padding: 6px 0; border-top: 1px solid var(--bord); }
.ligne-habitude:first-child { border-top: 0; }
.ligne-habitude input { margin: 0; padding: 7px; }
.ligne-habitude button:not(.discret) { padding: 7px 11px; }

.journal summary { padding: 8px 0; border-top: 1px solid var(--bord); cursor: pointer; font-size: .92rem; }
.journal .date { color: var(--doux); font-variant-numeric: tabular-nums; margin-right: 4px; }
.connexion { max-width: 380px; margin: 12vh auto 0; }
.connexion button { width: 100%; margin-top: 8px; }

@media (max-width: 420px) {
  .dicter { flex-direction: column; }
  .dicter button { max-width: none; }
  .ligne-habitude { grid-template-columns: 1fr 60px 64px auto; }
  .ligne-habitude .discret { grid-column: 4; }
}

.ligne-catalogue { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 0;
  border-top: 1px solid var(--bord); color: inherit; text-decoration: none; }
.ligne-catalogue:first-child { border-top: 0; }
.ligne-catalogue .nom { font-weight: 600; min-width: 0; }
.ligne-catalogue .nom .aide { display: block; font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ligne-catalogue .cote { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; flex: 0 0 auto; }
.ligne-catalogue.inactive { opacity: .45; }
