/* MediaBox Mini App — mobile d'abord, couleurs du thème Telegram (clair/sombre automatiques). */
:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --bg2: var(--tg-theme-secondary-bg-color, #f1f2f5);
  --txt: var(--tg-theme-text-color, #111);
  --doux: var(--tg-theme-hint-color, #7d8590);
  --lien: var(--tg-theme-link-color, #2481cc);
  --bouton: var(--tg-theme-button-color, #2481cc);
  --bouton-txt: var(--tg-theme-button-text-color, #fff);
  --haut: env(safe-area-inset-top, 0px);
  --bas: env(safe-area-inset-bottom, 0px);
  --rayon: 12px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--txt);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
body { overscroll-behavior-y: contain; padding-bottom: var(--bas); }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }

#hors-telegram { text-align: center; padding: 20vh 24px; }

/* ── En-tête collant ── */
#entete { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 8px 0 4px;
  border-bottom: 1px solid color-mix(in srgb, var(--doux) 18%, transparent); }
.recherche { padding: 0 12px 6px; }
#q { width: 100%; height: 40px; border: 0; border-radius: 10px; padding: 0 14px; font-size: 16px;
  background: var(--bg2); color: var(--txt); outline: none; -webkit-appearance: none; }
#q::placeholder { color: var(--doux); }
.rangee { display: flex; gap: 6px; overflow-x: auto; padding: 4px 12px; scrollbar-width: none; }
.rangee::-webkit-scrollbar { display: none; }
.rangee button { flex: none; padding: 7px 13px; border-radius: 999px; background: var(--bg2);
  white-space: nowrap; font-size: 14px; }
.rangee button.actif { background: var(--bouton); color: var(--bouton-txt); }
#portee button { flex: 1; text-align: center; }
.puces button { padding: 5px 11px; font-size: 13px; background: transparent;
  border: 1px solid color-mix(in srgb, var(--doux) 35%, transparent); }
.puces button.actif { border-color: var(--bouton); }

/* ── Grille de couvertures ── */
.compte { padding: 10px 14px 2px; color: var(--doux); font-size: 13px; min-height: 26px; }
.grille { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 10px; padding: 8px 12px 24px; }
@media (min-width: 560px) { .grille { grid-template-columns: repeat(5, 1fr); } }
@media (min-width: 860px) { .grille { grid-template-columns: repeat(7, 1fr); } }
.carte { text-align: left; display: block; width: 100%; min-width: 0; }
.couv { position: relative; aspect-ratio: 2 / 3; border-radius: 8px; overflow: hidden; background: var(--bg2);
  box-shadow: 0 1px 4px rgba(0,0,0,.18); }
.couv img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0; transition: opacity .25s; }
.couv img.pret { opacity: 1; }
.couv .faux { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  padding: 8px; text-align: center; font-weight: 600; font-size: 12px; color: #fff; word-break: break-word; }
.couv .pastille { position: absolute; top: 5px; right: 5px; font-size: 12px; background: rgba(0,0,0,.55);
  color: #fff; border-radius: 6px; padding: 1px 5px; }
.carte .t { margin-top: 6px; font-size: 13px; font-weight: 600; line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.carte .a { color: var(--doux); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.carte:active .couv { transform: scale(.97); }
.squelette .couv { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .55; } }
.vide { text-align: center; color: var(--doux); padding: 48px 24px; }
.vide b { display: block; color: var(--txt); font-size: 17px; margin-bottom: 6px; }

/* ── Fiche (feuille plein écran) ── */
.fiche { position: fixed; inset: 0; z-index: 20; background: var(--bg); overflow-y: auto;
  padding-top: var(--haut); animation: monte .22s ease-out; }
@keyframes monte { from { transform: translateY(24px); opacity: 0; } }
.fiche-contenu { max-width: 640px; margin: 0 auto; padding: 14px 16px calc(32px + var(--bas)); }
.fiche .tete { display: flex; gap: 14px; }
.fiche .tete .couv { width: 36%; max-width: 160px; flex: none; }
.fiche h1 { font-size: 19px; line-height: 1.25; margin: 2px 0 6px; }
.fiche .auteur { color: var(--lien); margin-bottom: 8px; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.meta span { background: var(--bg2); border-radius: 999px; padding: 3px 10px; font-size: 12px; }
.fiche .resume { margin: 16px 0 4px; white-space: pre-line; }
.fiche .resume.replie { display: -webkit-box; -webkit-line-clamp: 7; -webkit-box-orient: vertical; overflow: hidden; }
.fiche .plus { color: var(--lien); padding: 4px 0; }
.fiche h2 { font-size: 15px; margin: 22px 0 8px; }
.liste-liens { display: flex; flex-direction: column; gap: 2px; }
.liste-liens button { text-align: left; padding: 9px 12px; background: var(--bg2); border-radius: 10px;
  font-size: 14px; display: flex; gap: 8px; align-items: baseline; }
.liste-liens button .pt { flex: none; }
.liste-liens button .nom { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.encart { margin: 14px 0; padding: 14px; border-radius: var(--rayon); background: var(--bg2); }
.encart p { margin: 0 0 10px; }
.encart p:last-child { margin: 0; }
.encart .btn { height: 42px; font-size: 15px; width: 100%; }

.toast { position: fixed; left: 50%; bottom: calc(24px + var(--bas)); transform: translateX(-50%); z-index: 40;
  max-width: 88vw; background: rgba(20,20,22,.92); color: #fff; padding: 10px 16px; border-radius: 12px;
  font-size: 14px; text-align: center; }

/* ── Actions de la fiche, compte, don ── */
.petites { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.pastille-action { padding: 6px 11px; border-radius: 999px; background: var(--bg2); font-size: 13px; }
.btn { width: 100%; height: 46px; border-radius: 12px; font-weight: 600; font-size: 15px;
  background: var(--bouton); color: var(--bouton-txt); }
.btn.second-large { background: var(--bg2); color: var(--txt); }
.actions { display: flex; flex-direction: column; gap: 8px; margin-top: 18px; }
.grille > .panneau-compte { grid-column: 1 / -1; }
.panneau-compte { padding: 4px 4px 24px; }
.texte-bot { line-height: 1.5; }
.texte-bot code { font-family: ui-monospace, monospace; background: var(--bg2); padding: 0 4px; border-radius: 4px; }
