/* ═══════════════════════════════════════════════════════════
   Prompt de poche — feuille de style
   Mobile d'abord (c'est une appli Android en devenir) : cibles tactiles de
   44 px au moins, zones sûres (encoche, barre de gestes), aucun effet qui
   dépende du survol, un seul défilement vertical.

   Rayons et ombres : l'échelle du site (/shared/jetons.css), jamais de
   littéral — controle-jetons.mjs le refuserait. La teinte des ombres est
   --ombre-teinte, posée ci-dessous (l'encre de l'appli, jamais du noir nu).
   ═══════════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --ombre-teinte: 26, 22, 20;
  --fond: #faf6f0;
  --panneau: #ffffff;
  --panneau-2: #f4ede4;
  --trait: rgba(26, 22, 20, 0.13);
  --encre: #1a1614;
  --doux: #6b5f56;
  --accent: #a9622d;
  --accent-fort: #7e4519;
  --accent-clair: #f6e8da;
  --sur-accent: #ffffff;
  --ok: #2f7a4f;
  --alerte: #a8442a;
  --alerte-clair: #fbece8;
  --dock-h: 62px;
  --haut-h: 56px;
  --bas: env(safe-area-inset-bottom, 0px);
  --police: 'DM Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --police-titre: 'Fraunces', Georgia, serif;
  color-scheme: light;
}
html[data-theme="sombre"] {
  --ombre-teinte: 0, 0, 0;
  --fond: #16120f;
  --panneau: #211b17;
  --panneau-2: #2b231e;
  --trait: rgba(243, 236, 228, 0.16);
  --encre: #f3ece4;
  --doux: #b3a69a;
  --accent: #e0955c;
  --accent-fort: #f0b383;
  --accent-clair: #3a2a1e;
  --sur-accent: #1a1209;
  --ok: #6cc48f;
  --alerte: #f08a6f;
  --alerte-clair: #3a1f19;
  color-scheme: dark;
}

html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--haut-h) + 12px); }
body {
  font-family: var(--police);
  background: var(--fond);
  color: var(--encre);
  line-height: 1.5;
  font-size: 16px;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; -webkit-appearance: none; appearance: none; touch-action: manipulation; }
textarea, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ── barre du haut ─────────────────────────────────────── */
.barre {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  height: calc(var(--haut-h) + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) 16px 0;
  background: var(--fond);
  border-bottom: 1px solid var(--trait);
}
.barre-titre { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo { font-size: 26px; line-height: 1; }
.barre h1 { font-family: var(--police-titre); font-size: 1.2rem; font-weight: 600; line-height: 1.15; }
.barre p { font-size: .76rem; color: var(--doux); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.barre-actions { display: flex; gap: 6px; flex: 0 0 auto; }
.barre-btn { width: 44px; height: 44px; border-radius: var(--r-pill); font-size: 20px; background: var(--panneau-2); display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }

/* ── contenu ───────────────────────────────────────────── */
#ecran { max-width: 720px; margin: 0 auto; padding: 18px 16px calc(var(--dock-h) + 110px + var(--bas)); outline: none; }
.etiquette { display: block; font-weight: 700; font-size: 1.05rem; margin-bottom: 8px; }
.etiquette.petit { font-size: .92rem; }
.etiquette em { font-weight: 400; color: var(--doux); font-style: normal; }

.champ { position: relative; }
textarea, select, input[type="text"], input[type="search"] {
  width: 100%;
  background: var(--panneau);
  border: 1.5px solid var(--trait);
  border-radius: var(--r-md);
  padding: 12px 14px;
  line-height: 1.5;
  box-shadow: var(--sh-1);
}
textarea { resize: vertical; min-height: 130px; font-size: 1rem; }
textarea:focus, select:focus, input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 4px var(--accent-clair); }
.champ-pied { display: flex; justify-content: flex-end; font-size: .75rem; color: var(--doux); padding: 4px 4px 0; }

.outils { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.puce {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  flex: 1 1 auto; min-height: 44px; padding: 0 12px;
  border-radius: var(--r-pill);
  background: var(--panneau); border: 1.5px solid var(--trait);
  font-weight: 600; font-size: .88rem; white-space: nowrap;
}
.puce[aria-expanded="true"] { background: var(--accent-clair); border-color: var(--accent); }
.idees { margin-top: 18px; }
.idees-titre { font-size: .76rem; text-transform: uppercase; letter-spacing: .06em; color: var(--doux); font-weight: 700; margin-bottom: 8px; }
.idees-liste { display: flex; flex-wrap: wrap; gap: 8px; }
.idee { min-height: 40px; padding: 0 14px; border-radius: var(--r-pill); background: var(--accent-clair); color: var(--accent-fort); font-weight: 600; font-size: .84rem; text-align: left; }
.resume { font-size: .8rem; color: var(--doux); margin-top: 10px; line-height: 1.45; }

.rangee-haut { margin: 0 0 10px; }
.bloc {
  background: var(--panneau); border: 1px solid var(--trait);
  border-radius: var(--r-lg); padding: 14px; margin-top: 14px; box-shadow: var(--sh-1);
}
.bloc h3 { font-size: .98rem; margin-bottom: 8px; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.bloc h3 small { font-weight: 400; color: var(--doux); font-size: .78rem; }
.bloc .etiquette { margin-bottom: 6px; }
.note { font-size: .78rem; color: var(--doux); margin-top: 8px; }
.rangee { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

/* ── boutons ───────────────────────────────────────────── */
.btn-1, .btn-2 {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; border-radius: var(--r-md);
  font-weight: 700; text-align: center; line-height: 1.2;
}
.btn-1 { background: var(--accent); color: var(--sur-accent); box-shadow: var(--sh-2); }
.btn-1:active { transform: translateY(1px); }
.btn-1[disabled] { opacity: .5; box-shadow: none; }
.btn-1.grand { width: 100%; min-height: 54px; font-size: 1.05rem; }
.btn-2 { background: var(--panneau-2); border: 1.5px solid var(--trait); }
.btn-lien { color: var(--accent-fort); font-weight: 700; min-height: 44px; padding: 0 8px; font-size: .9rem; white-space: nowrap; flex: 0 0 auto; }
.icone { width: 44px; height: 44px; border-radius: var(--r-pill); font-size: 20px; background: var(--panneau-2); }
.icone[aria-pressed="true"] { background: var(--accent-clair); }

/* ── bouton d'action principal, au pouce ───────────────── */
.cta {
  position: fixed; left: 0; right: 0; z-index: 25;
  bottom: calc(var(--dock-h) + var(--bas));
  padding: 24px 16px 10px;
  background: linear-gradient(to top, var(--fond) 62%, transparent);
  pointer-events: none;
}
.cta .btn-1 { max-width: 720px; margin: 0 auto; display: flex; pointer-events: auto; }

/* ── la barre d'actions du bas ─────────────────────────── */
.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; justify-content: center;
  height: calc(var(--dock-h) + var(--bas));
  padding: 0 4px var(--bas);
  background: var(--panneau);
  border-top: 1px solid var(--trait);
  box-shadow: var(--sh-3);
}
.dock button {
  flex: 1 1 0; max-width: 120px; min-width: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border-radius: var(--r-md); color: var(--doux);
}
.d-ico { font-size: 21px; line-height: 1; }
.d-lib { font-size: .68rem; font-weight: 600; letter-spacing: .01em; }
.dock button[aria-current="true"] { color: var(--accent-fort); background: var(--accent-clair); }
.dock button:active { background: var(--panneau-2); }

/* ── écran résultat ────────────────────────────────────── */
.rappel { display: flex; align-items: center; gap: 8px; justify-content: space-between;
  background: var(--panneau-2); border-radius: var(--r-md); padding: 8px 8px 8px 14px; }
.rappel-texte { min-width: 0; display: flex; flex-direction: column; font-size: .88rem; }
.rappel-lib { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--doux); font-weight: 700; }
#rappel-besoin { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.versions { display: flex; gap: 8px; overflow-x: auto; padding: 12px 2px 4px; scrollbar-width: none; }
.versions::-webkit-scrollbar { display: none; }
.versions:empty { display: none; }
.version {
  flex: 0 0 auto; min-height: 40px; padding: 0 16px; border-radius: var(--r-pill);
  background: var(--panneau); border: 1.5px solid var(--trait); font-weight: 700; font-size: .88rem;
}
.version[aria-selected="true"] { background: var(--accent); color: var(--sur-accent); border-color: var(--accent); }

.carte-prompt { background: var(--panneau); border: 1px solid var(--trait); border-radius: var(--r-lg); margin-top: 10px; box-shadow: var(--sh-2); overflow: hidden; }
.carte-tete { display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 4px 16px; }
.carte-tete h2 { font-size: .98rem; font-family: var(--police-titre); }
.carte-outils { display: flex; gap: 2px; }
.prompt-texte {
  display: block; width: 100%;
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: .84rem; line-height: 1.6;
  white-space: pre-wrap; overflow-wrap: anywhere;
  padding: 6px 16px 16px; background: transparent; border: 0; border-radius: 0; box-shadow: none; min-height: 0;
}
textarea.prompt-texte { min-height: 280px; background: var(--panneau-2); margin: 0 12px 12px; width: calc(100% - 24px); border-radius: var(--r-md); padding: 12px; }
.indic { padding: 0 16px 12px; font-size: .82rem; color: var(--accent-fort); display: flex; align-items: center; gap: 8px; }
.pastille { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); animation: bat 1s ease-in-out infinite; }
@keyframes bat { 50% { opacity: .25; transform: scale(.7); } }
.carte-test { padding: 4px 12px 10px; }
.carte-test .btn-1 { width: 100%; min-height: 48px; }
#bloc-test { scroll-margin-top: 68px; }
.test-texte { white-space: pre-wrap; overflow-wrap: anywhere; font-size: .92rem; line-height: 1.55; max-height: 60dvh; overflow-y: auto; padding: 10px 12px; border-radius: var(--r-md); background: var(--panneau-2); }
.test-texte:empty { display: none; }
.carte-actions { display: flex; gap: 8px; padding: 0 12px 12px; flex-wrap: wrap; }
.carte-actions .btn-2 { flex: 1 1 0; min-height: 44px; font-size: .88rem; padding: 0 10px; }

.scores { display: grid; gap: 8px; }
.score { display: grid; grid-template-columns: 112px 1fr 24px; align-items: center; gap: 8px; font-size: .8rem; }
.score-barre { height: 8px; border-radius: var(--r-pill); background: var(--panneau-2); overflow: hidden; }
.score-barre i { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
.score b { text-align: right; }
.moyenne { font-weight: 700; color: var(--accent-fort); }
.amelio { margin-top: 10px; font-size: .84rem; color: var(--doux); background: var(--accent-clair); border-radius: var(--r-md); padding: 10px 12px; }

.question { margin-bottom: 14px; }
.question label { display: block; font-size: .9rem; font-weight: 600; margin-bottom: 6px; line-height: 1.4; }
.question textarea { min-height: 64px; }
#bt-affiner { width: 100%; }

.erreur { margin-top: 14px; background: var(--alerte-clair); color: var(--alerte); border-radius: var(--r-md); padding: 12px 14px; font-size: .9rem; font-weight: 600; }

/* ── feuilles (fenêtres du bas) ────────────────────────── */
.voile { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, .45); animation: fond .18s ease; }
@keyframes fond { from { opacity: 0; } }
.feuille {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 61;
  max-width: 720px; margin: 0 auto;
  max-height: 88dvh; display: flex; flex-direction: column;
  background: var(--panneau); border-radius: var(--r-xl) var(--r-xl) 0 0;
  box-shadow: var(--sh-3);
  padding-bottom: var(--bas);
  animation: monte .22s ease;
}
@keyframes monte { from { transform: translateY(40px); opacity: 0; } }
.feuille.haute { height: 88dvh; }
.feuille-prise { width: 40px; height: 4px; border-radius: var(--r-pill); background: var(--trait); margin: 8px auto 0; flex: 0 0 auto; }
.feuille-tete { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 8px 6px 18px; flex: 0 0 auto; }
.feuille-tete h2 { font-family: var(--police-titre); font-size: 1.15rem; }
.feuille-fermer { width: 44px; height: 44px; border-radius: var(--r-pill); font-size: 18px; background: var(--panneau-2); }
.feuille-corps { overflow-y: auto; overscroll-behavior: contain; padding: 4px 16px 18px; flex: 1 1 auto; }
.feuille-corps > p { margin: 4px 0 12px; color: var(--doux); font-size: .9rem; }

.liste { display: grid; gap: 8px; list-style: none; }
.item {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  min-height: 56px; padding: 10px 14px;
  background: var(--panneau-2); border: 1.5px solid transparent; border-radius: var(--r-md);
}
a.item { text-decoration: none; color: inherit; }
.item:active { border-color: var(--accent); }
.item-ico { font-size: 22px; flex: 0 0 auto; width: 30px; text-align: center; }
.item-txt { min-width: 0; flex: 1 1 auto; display: flex; flex-direction: column; }
.item-txt b { font-size: .96rem; line-height: 1.3; }
.item-txt small { font-size: .78rem; color: var(--doux); line-height: 1.35; margin-top: 1px; }
.item-txt small.a-verifier { color: var(--alerte); font-weight: 600; margin-top: 3px; }
.item-fin { color: var(--doux); flex: 0 0 auto; }
.item.danger b { color: var(--alerte); }

.rubrique { margin-bottom: 10px; border: 1px solid var(--trait); border-radius: var(--r-md); overflow: hidden; }
.rubrique > summary {
  list-style: none; cursor: pointer; min-height: 52px; padding: 12px 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-weight: 700; background: var(--panneau-2);
}
.rubrique > summary::-webkit-details-marker { display: none; }
.rubrique > summary::after { content: '▾'; color: var(--doux); transition: transform .15s; }
.rubrique[open] > summary::after { transform: rotate(180deg); }
.rubrique > summary small { font-weight: 400; color: var(--doux); font-size: .78rem; margin-left: auto; }
.rubrique-corps { padding: 8px; display: grid; gap: 8px; }

.astuce { text-align: left; width: 100%; padding: 12px 14px; border-radius: var(--r-md); background: var(--panneau); border: 1.5px solid var(--trait); }
.astuce b { display: block; font-size: .92rem; }
.astuce small { display: block; color: var(--doux); font-size: .78rem; margin-top: 2px; line-height: 1.4; }
.astuce .ajouter { display: inline-block; margin-top: 8px; color: var(--accent-fort); font-weight: 700; font-size: .82rem; }
.erreur-item { padding: 12px 14px; background: var(--panneau); border: 1px solid var(--trait); border-radius: var(--r-md); }
.erreur-item b { display: block; margin-bottom: 4px; font-size: .94rem; }
.erreur-item p { font-size: .84rem; color: var(--doux); margin-bottom: 8px; }
.avant, .apres { font-size: .82rem; padding: 8px 10px; border-radius: var(--r-sm); margin-top: 6px; line-height: 1.45; }
.avant { background: var(--alerte-clair); }
.apres { background: var(--accent-clair); }
.avant::before { content: '✗ '; font-weight: 700; color: var(--alerte); }
.apres::before { content: '✓ '; font-weight: 700; color: var(--ok); }

.reglage { display: grid; gap: 6px; margin-bottom: 14px; }
.reglage label { font-weight: 700; font-size: .9rem; }
select { min-height: 48px; background-image: none; }
.interrupteur { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; background: var(--panneau-2); border-radius: var(--r-md); min-height: 56px; }
.interrupteur small { display: block; color: var(--doux); font-size: .76rem; line-height: 1.35; }
.interrupteur input { width: 26px; height: 26px; accent-color: var(--accent); flex: 0 0 auto; }

.lien-partage { width: 100%; font-size: .78rem; padding: 10px 12px; min-height: 0; height: 72px; resize: none; font-family: ui-monospace, monospace; }
.alerte-bloc { background: var(--alerte-clair); color: var(--alerte); border-radius: var(--r-md); padding: 12px 14px; font-size: .86rem; margin-bottom: 12px; line-height: 1.45; }
.alerte-bloc ul { margin: 6px 0 0 18px; }
.vide { text-align: center; color: var(--doux); padding: 28px 10px; font-size: .92rem; }
.pile { display: grid; gap: 10px; }
.apercu-prompt { white-space: pre-wrap; font-family: ui-monospace, monospace; font-size: .82rem; background: var(--panneau-2); border-radius: var(--r-md); padding: 12px; max-height: 38dvh; overflow-y: auto; line-height: 1.55; overflow-wrap: anywhere; }

/* ── message passager ──────────────────────────────────── */
#toast {
  position: fixed; left: 50%; z-index: 90; transform: translate(-50%, 20px);
  bottom: calc(var(--dock-h) + var(--bas) + 84px);
  width: max-content; max-width: min(92vw, 520px);
  display: flex; align-items: center; gap: 12px;
  background: var(--encre); color: var(--fond);
  padding: 12px 16px; border-radius: var(--r-md); box-shadow: var(--sh-3);
  font-size: .9rem; font-weight: 600;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
#toast.visible { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
#toast button { color: var(--accent); font-weight: 800; min-height: 36px; padding: 0 4px; filter: brightness(1.4); }


/* ── grands écrans : on garde la forme d'appli, centrée ── */
@media (min-width: 760px) {
  .dock { left: 50%; right: auto; width: 720px; transform: translateX(-50%); border-radius: var(--r-lg) var(--r-lg) 0 0; border: 1px solid var(--trait); border-bottom: 0; }
  .d-lib { font-size: .74rem; }
}
@media (max-width: 359px) { .d-lib { font-size: .62rem; } .score { grid-template-columns: 92px 1fr 22px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* « En test » : pastille posée à côté du moteur dans l'en-tête (version ouverte). */
.pastille-test{display:inline-block;margin-left:6px;padding:1px 7px;border-radius:var(--r-pill);border:1px solid currentColor;color:var(--accent-fort);font-size:.68rem;font-weight:700;letter-spacing:.04em;text-transform:uppercase;vertical-align:1px}
