/* le barbery v 1.0 — adaptation web de l'applet java d'olivier gillet (2001).
   même papier que la v3 : ivoire, encre, bleu graphique, cinabre. commandes au texte, aucune pilule. */
:root {
  --fond: #faf7f2;
  --blanc: #fffdf9;
  --encre: #1c1c1c;
  --encre2: #4a4741;
  --gris: #85817a;
  --filet: #e0dad0;
  --filet2: #bfb9ae;
  --lien: #3b5873;
  --bleu: #0a5ea8;
  --rouge: #b8391f;
  --titre: "IM Fell English", "Times New Roman", serif;
  --mot: "EB Garamond", "Times New Roman", serif;
  --cmd: "Old Standard TT", "Times New Roman", serif;
  --haut: 3.4rem;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { height: 100%; }
body { margin: 0; display: flex; flex-direction: column; min-height: 100dvh; height: 100dvh; background: var(--fond); color: var(--encre); font-family: var(--cmd); font-size: 14px; line-height: 1.45; -webkit-font-smoothing: antialiased; overflow-x: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: none; padding: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
a { color: var(--lien); text-decoration: none; }
a:hover { color: var(--bleu); }
[hidden] { display: none !important; }
svg { width: 1.2em; height: 1.2em; flex: none; }
:focus-visible { outline: 1.5px solid var(--bleu); outline-offset: 2px; }
::selection { background: rgba(10, 94, 168, .15); }

/* ---- en-tête ---- */
.haut { flex: none; min-height: var(--haut); display: flex; align-items: baseline; flex-wrap: wrap; gap: .3rem 1.2rem; padding: .9rem 24px .55rem; border-bottom: 1px solid var(--filet); }
.marque { font-family: var(--titre); font-size: 1.75rem; line-height: 1; color: var(--encre); }
.marque:hover { color: var(--encre); }
.marque .ver { font-style: italic; font-size: .62em; color: var(--rouge); margin-left: .15em; }
.reglages { display: flex; flex-wrap: wrap; gap: .4rem 1.1rem; align-items: baseline; min-width: 0; padding: .1rem 0 .7rem; }
.reglages select { flex: 1 1 8rem; }
.emploi { margin-left: auto; }
.reglages select, .rang-mode select { appearance: none; -webkit-appearance: none; background: transparent; border: none; border-bottom: 1px solid var(--filet2); border-radius: 0; padding: .1rem 1.1rem .1rem 0; font-family: var(--cmd); font-size: .88rem; color: var(--encre2); cursor: pointer; max-width: 100%;
  background-image: linear-gradient(45deg, transparent 50%, var(--lien) 50%), linear-gradient(-45deg, transparent 50%, var(--lien) 50%); background-size: 5px 5px; background-position: right 5px top 55%, right 0 top 55%; background-repeat: no-repeat; }
.reglages select option, .rang-mode select option { color: #1c1c1c; background: #fff; }
.emploi { font-family: var(--titre); font-style: italic; font-size: .98rem; white-space: nowrap; }

/* ---- plan de travail : les trois colonnes de l'applet (180 / 520 / 260) ---- */
.onglets { display: none; }
.plan { flex: 1; min-height: 34rem; display: grid; grid-template-columns: 15.5rem minmax(0, 1.75fr) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; grid-template-areas: "per bar pai" "opt bar pai"; }
.panneau { position: relative; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.percoler { grid-area: per; padding: 1rem 16px 0; border-right: 1px solid var(--filet); }
.barberyser { grid-area: bar; border-right: 1px solid var(--filet); }
.paillasser { grid-area: pai; }
.options { grid-area: opt; border-right: 1px solid var(--filet); border-top: 1px solid var(--filet); padding: .5rem 16px .8rem; display: flex; flex-direction: column; }
.titre { margin: 0; font-family: var(--titre); font-weight: 400; font-style: italic; font-size: 1.05rem; color: var(--encre2); letter-spacing: .02em; }
.barberyser .titre, .paillasser .titre { position: absolute; z-index: 2; left: 18px; top: 1rem; pointer-events: none; }

/* ---- percoler : les recherches et les filtres de la v3 ---- */
.lexique { display: flex; flex-direction: column; flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: thin; }
.recherche { display: flex; flex-direction: column; gap: .45rem; margin: .7rem 0 .3rem; }
.rang-mode { display: flex; align-items: baseline; gap: .6rem; }
.rang-mode select { flex: 1; min-width: 0; font-size: .92rem; }
.interrupteur { flex: none; display: inline-flex; gap: .45rem; font-size: .8rem; }
.interrupteur button { color: var(--gris); }
.interrupteur button.actif { color: var(--bleu); }
.interrupteur button:disabled { opacity: .3; cursor: default; }
.recherche input { border: none; border-bottom: 1.5px solid var(--encre); border-radius: 0; background: transparent; padding: .2rem 0; font-family: var(--mot); font-size: 1.15rem; outline: none; caret-color: var(--bleu); min-width: 0; -webkit-appearance: none; appearance: none; }
.recherche input::-webkit-search-cancel-button { display: none; }
.commande { font-family: var(--cmd); color: var(--lien); font-size: .95rem; padding: .2rem 0; text-align: left; align-self: flex-start; transition: color .15s; }
.commande:hover { color: var(--bleu); }
.commande::before { content: "→ "; color: var(--bleu); }
.commande.rouge { color: var(--rouge); }
.commande.rouge::before { color: var(--rouge); }
.plis { margin-bottom: .3rem; }
.pli-tete { display: flex; align-items: center; gap: .45rem; width: 100%; padding: .32rem 0; font-size: .84rem; color: var(--encre2); text-align: left; border-bottom: 1px solid var(--filet); }
.pli-tete svg { width: .85rem; height: .85rem; color: var(--lien); transform: rotate(-90deg); transition: transform .2s; }
.pli-tete[aria-expanded="true"] svg { transform: none; }
.pli-tete .badge { margin-left: auto; font-size: .72rem; color: var(--bleu); }
.pli-corps { padding: .4rem 0 .6rem; border-bottom: 1px solid var(--filet); }
.rang { display: flex; align-items: baseline; flex-wrap: wrap; gap: .2rem .7rem; margin: .3rem 0; }
.lib { min-width: 3.6rem; font-size: .72rem; color: var(--gris); }
.opts { display: flex; flex-wrap: wrap; gap: .05rem .7rem; font-size: .8rem; color: var(--encre2); }
.opts button.actif { color: var(--bleu); }
.opts button:hover { color: var(--encre); }
.opts button.actif:hover { color: var(--bleu); }
.rang input[type=text], .rang select { font-size: .82rem; color: var(--encre); border: none; border-bottom: 1px solid var(--filet2); padding: .1rem 0; min-width: 0; -webkit-appearance: none; appearance: none; border-radius: 0; background: transparent; }
.rang input[type=text] { width: 100%; max-width: 13rem; }
.rang input:focus, .rang select:focus { outline: none; border-color: var(--bleu); }
.rang input::placeholder { color: var(--gris); }
.plage { display: inline-flex; gap: .8rem; }
.texte { font-size: .8rem; color: var(--lien); }
.clavier { display: flex; flex-wrap: wrap; gap: .1rem .2rem; }
.clavier button { display: flex; flex-direction: column; align-items: center; min-width: 2rem; padding: .1rem .1rem; line-height: 1.1; }
.clavier button:hover b { color: var(--bleu); }
.clavier b { font-family: var(--cmd); font-weight: 400; font-size: .92rem; }
.clavier i { font-family: var(--mot); font-size: .66rem; color: var(--gris); }
.clavier .sep { width: 100%; height: .15rem; }
.progres { flex: none; height: 2px; background: var(--filet); margin: .2rem 0 .4rem; position: relative; overflow: hidden; }
.progres span { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: var(--bleu); }
.etat { margin: 0 0 .3rem; font-size: .8rem; color: var(--encre2); min-height: 1.1em; }
.etat b { font-weight: 400; color: var(--encre); }
.richesse { display: inline-flex; align-items: baseline; gap: .3rem; }
.richesse button { color: var(--bleu); width: 1.1rem; font-size: 1rem; }
.richesse button:disabled { opacity: .3; cursor: default; }
.liste { list-style: none; margin: 0; padding: 0 0 .3rem; flex: 1 0 4rem; overflow-y: auto; scrollbar-width: thin; }
.liste button { display: flex; flex-wrap: wrap; column-gap: .45rem; align-items: baseline; width: 100%; text-align: left; padding: .1rem 0; }
.liste b { font-family: var(--mot); font-weight: 400; font-size: 1.08rem; }
.liste i { font-family: var(--cmd); font-size: .76rem; color: var(--gris); }
.liste .dec { flex-basis: 100%; display: inline-flex; align-items: center; gap: .3rem; font-size: .74rem; color: var(--gris); margin-top: -.15rem; }
.liste .dec svg { width: .9rem; height: .9rem; color: var(--lien); }
.liste button:hover b, .liste .choisi b { color: var(--bleu); }
.liste .inter { font-size: .72rem; color: var(--gris); margin-top: .4rem; }
.suite { margin: 0; font-size: .82rem; }
.suite button { color: var(--lien); padding: .2rem 0; }
.copies { flex: none; display: flex; flex-wrap: wrap; gap: .2rem 1.1rem; padding: .35rem 0 .6rem; border-top: 1px solid var(--filet); }
.copies button, .copie { display: inline-flex; align-items: center; gap: .35rem; font-size: .84rem; color: var(--encre2); }
.copies button svg, .copie svg { width: 1.05rem; height: 1.05rem; color: var(--lien); }
.copies button:hover, .copie:hover { color: var(--bleu); }
#barbDabord[aria-pressed="false"] { color: var(--gris); }
#barbDabord[aria-pressed="false"] svg { color: var(--gris); }

/* ---- invitation (version libre) ---- */
.verrou { margin: .4rem 0 .6rem; font-size: .84rem; color: var(--encre2); line-height: 1.4; }
.verrou a { color: var(--rouge); font-weight: 700; }
.pied-arbre { position: absolute; left: 18px; right: 18px; bottom: .5rem; z-index: 2; display: flex; align-items: baseline; justify-content: center; flex-wrap: wrap; gap: .2rem 1.2rem; pointer-events: none; }
.pied-arbre > * { pointer-events: auto; }
.barberyser .verrou { margin: 0; text-align: center; }
.bulle { position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%); background: var(--encre); color: var(--fond); padding: .45rem 1rem; font-size: .86rem; z-index: 70; max-width: calc(100vw - 32px); }

/* ---- les toiles ---- */
.toile { position: relative; flex: 1; min-height: 0; overflow: hidden; }
.toile canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; }

/* ---- palette d'outils ---- */
.outils { position: absolute; z-index: 2; right: 10px; top: .55rem; display: flex; gap: .15rem; }
.outils button { width: 2.6rem; height: 2.6rem; display: grid; place-items: center; position: relative; }
.outils img, .options img { width: 30px; height: 30px; display: block; opacity: .82; transition: opacity .15s; }
.outils button:hover img, .outils button.actif img, .options button:hover img { opacity: 1; }
.outils button.actif img { outline: 1.5px solid var(--bleu); outline-offset: 1px; }
.outils button.actif::after { content: ""; position: absolute; left: 50%; bottom: .05rem; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: var(--rouge); }
.paillasser .toile { cursor: default; }
.paillasser[data-o="1"] .toile { cursor: crosshair; }
.paillasser[data-o="2"] .toile { cursor: copy; }
.paillasser[data-o="3"] .toile { cursor: grab; }
.paillasser[data-o="4"] .toile { cursor: zoom-in; }

/* ---- options ---- */
.options button { display: flex; align-items: center; gap: .6rem; padding: .32rem 0; text-align: left; color: var(--encre2); font-size: .9rem; transition: color .15s; }
.options button:hover { color: var(--bleu); }
#optSon.muet img { opacity: .4; }

/* ---- la poche ---- */
.poche { position: fixed; inset: 0; z-index: 50; background: rgba(28, 28, 28, .18); display: grid; place-items: center; padding: 16px; }
.poche-feuille { width: min(26rem, 100%); max-height: calc(100dvh - 32px); display: flex; flex-direction: column; background: var(--blanc); border: 1px solid var(--filet2); box-shadow: 0 18px 40px -18px rgba(0,0,0,.35); padding: 1rem 1.1rem .8rem; }
.poche h2 { margin: 0 0 .6rem; font-family: var(--titre); font-weight: 400; font-style: italic; font-size: 1.3rem; }
.poche textarea { flex: 1; min-height: 14rem; resize: vertical; border: 1px solid var(--filet); background: var(--fond); padding: .5rem .6rem; font-family: var(--mot); font-size: 1.1rem; line-height: 1.35; outline: none; border-radius: 0; }
.poche textarea:focus { border-color: var(--filet2); }
.poche-cmd { display: flex; flex-wrap: wrap; gap: .2rem 1.4rem; margin-top: .5rem; }

/* ---- menus contextuels (les popupmenu de l'applet) ---- */
.menu-contexte { position: fixed; z-index: 60; min-width: 11rem; background: var(--blanc); border: 1px solid var(--filet2); box-shadow: 0 12px 30px -12px rgba(0,0,0,.3); padding: .3rem 0; display: flex; flex-direction: column; }
.menu-contexte button { text-align: left; padding: .42rem 1rem .42rem 1.6rem; font-size: .95rem; position: relative; white-space: nowrap; }
.menu-contexte button:hover { color: var(--bleu); }
.menu-contexte button.coche::before { content: "✓"; position: absolute; left: .55rem; color: var(--bleu); }
.menu-contexte hr { border: none; border-top: 1px solid var(--filet); margin: .25rem 0; }
.menu-contexte .tete { padding: .2rem 1rem .3rem 1.6rem; font-family: var(--mot); font-size: 1.05rem; color: var(--gris); font-style: italic; max-width: 16rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- tablettes ---- */
@media (max-width: 1080px) {
  .plan { grid-template-columns: 14rem minmax(0, 1fr); grid-template-rows: minmax(0, 1.2fr) minmax(0, 1fr) auto; grid-template-areas: "per bar" "per pai" "opt pai"; }
  .paillasser { border-top: 1px solid var(--filet); }
  .barberyser { border-right: none; }
}

/* ---- téléphones : un panneau à la fois, onglets à trait bleu ---- */
@media (max-width: 720px) {
  :root { --haut: 3rem; }
  .haut { padding: .75rem 16px 0; }
  .marque { font-size: 1.5rem; }
  .haut { padding-bottom: .45rem; }
  .emploi { margin-left: auto; font-size: .9rem; }
  .reglages select { min-width: 0; font-size: .82rem; }
  .onglets { display: flex; gap: 1.2rem; padding: 0 16px; border-bottom: 1px solid var(--filet); height: 2.5rem; align-items: stretch; }
  .onglets button { position: relative; font-family: var(--titre); font-style: italic; font-size: 1.02rem; color: var(--encre2); white-space: nowrap; }
  .onglets button.actif { color: var(--bleu); }
  .onglets button.actif::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--bleu); }
  .onglets { flex: none; }
  .plan { flex: 1; min-height: 26rem; display: flex; flex-direction: column; }
  .panneau { flex: 1; border: none !important; }
  .plan[data-p="percoler"] .barberyser, .plan[data-p="percoler"] .paillasser,
  .plan[data-p="barberyser"] .percoler, .plan[data-p="barberyser"] .paillasser,
  .plan[data-p="paillasser"] .percoler, .plan[data-p="paillasser"] .barberyser { display: none; }
  .titre { display: none; }
  .percoler { padding-top: .2rem; }
  .options { flex: none; flex-direction: row; justify-content: space-between; gap: .4rem; border-right: none; padding: .35rem 12px calc(.4rem + env(safe-area-inset-bottom)); }
  .options button { flex: 1 1 0; min-width: 0; flex-direction: column; gap: .1rem; font-size: .72rem; line-height: 1.15; text-align: center; padding: .2rem 0; }
  .options img { width: 26px; height: 26px; }
  .outils { left: 8px; right: auto; top: .3rem; }
  .recherche input { font-size: 1.2rem; }
  .percoler { padding: 0 16px; }
}

/* ---- livrées d'origine (fichiers .res de 2001) : couleurs et images posées par app.js en variables ---- */
body:not(.papier) { background: var(--l-fond); color: var(--l-lex-texte); --filet: color-mix(in srgb, var(--l-lex-texte) 24%, transparent); --filet2: color-mix(in srgb, var(--l-lex-texte) 42%, transparent); }
body:not(.papier) .haut, body:not(.papier) .onglets { --encre: var(--l-lex-texte); --encre2: var(--l-lex-texte); --gris: color-mix(in srgb, var(--l-lex-texte) 62%, transparent); --lien: var(--l-lex-texte); --bleu: color-mix(in srgb, #2f86d6 70%, var(--l-lex-texte)); }
body:not(.papier) .percoler { background: linear-gradient(color-mix(in srgb, var(--l-lex) var(--voile, 40%), transparent), color-mix(in srgb, var(--l-lex) var(--voile, 40%), transparent)), var(--i-lex, none) center top / cover no-repeat var(--l-lex); color: var(--l-lex-texte);
  --encre: var(--l-lex-texte); --encre2: var(--l-lex-texte); --gris: color-mix(in srgb, var(--l-lex-texte) 62%, transparent); --lien: var(--l-lex-texte); --bleu: color-mix(in srgb, #2f86d6 70%, var(--l-lex-texte)); }
body:not(.papier) .lexique { background: color-mix(in srgb, var(--l-lex) 74%, transparent); margin: .6rem -10px 0; padding: 0 10px; }
body:not(.papier) .barberyser { background: linear-gradient(color-mix(in srgb, var(--l-arbre) var(--voile, 40%), transparent), color-mix(in srgb, var(--l-arbre) var(--voile, 40%), transparent)), var(--i-arbre, none) center / cover no-repeat var(--l-arbre); color: var(--l-arbre-texte); --encre2: var(--l-arbre-texte); --encre: var(--l-arbre-texte); --lien: var(--l-arbre-texte); }
body:not(.papier) .barberyser .titre, body:not(.papier) .paillasser .titre, body:not(.papier) .pied-arbre > * { background: color-mix(in srgb, var(--l-arbre) 78%, transparent); padding: .05rem .4rem; }
body:not(.papier) .paillasser .titre { color: var(--l-mot, #000); background: color-mix(in srgb, var(--l-esquisse) 78%, transparent); }
body:not(.papier) .paillasser .toile { background: linear-gradient(color-mix(in srgb, var(--l-esquisse) var(--voile, 40%), transparent), color-mix(in srgb, var(--l-esquisse) var(--voile, 40%), transparent)), var(--i-esquisse, none) center / cover no-repeat var(--l-esquisse); }
body:not(.papier) .outils { background: linear-gradient(color-mix(in srgb, var(--l-outil) var(--voile, 40%), transparent), color-mix(in srgb, var(--l-outil) var(--voile, 40%), transparent)), var(--i-boite, none) center / cover no-repeat var(--l-outil); padding: 0 4px; }
body:not(.papier) .options { background: linear-gradient(color-mix(in srgb, var(--l-outil) var(--voile, 40%), transparent), color-mix(in srgb, var(--l-outil) var(--voile, 40%), transparent)), var(--i-pad, none) center / cover no-repeat var(--l-outil); color: var(--l-outil-texte); --encre2: var(--l-outil-texte); --bleu: color-mix(in srgb, #2f86d6 70%, var(--l-outil-texte)); }
body:not(.papier) .options button span { background: color-mix(in srgb, var(--l-outil) 70%, transparent); padding: 0 .25rem; }
body:not(.papier) .poche-feuille { background: var(--l-poche); color: #1c1c1c; }
body:not(.papier) .verrou a { color: inherit; text-decoration: none; font-weight: 700; }
.copies.tete-liste { border-top: none; padding: 0 0 .2rem; }
.copies button img { width: 22px; height: 22px; opacity: .85; }
body[data-livree="pourlesnuls-standard"] .barberyser { background-size: min(70%, 420px) auto; background-position: center 55%; }
body[data-livree="pourlesnuls-standard"] .percoler, body[data-livree="pourlesnuls-standard"] .paillasser .toile { background-size: contain; background-position: center bottom; }
.voile { display: flex; align-items: center; gap: .5rem; flex: 1 1 100%; color: var(--gris); font-size: 1rem; }
.voile input { flex: 1; min-width: 0; accent-color: var(--bleu); }
body.papier .voile { display: none; }
