/* Miya — mise en page commune : le haut de la page reste fixe, le reste défile dans son propre cadre.
   UN seul endroit pour toutes les pages (listes, fiches, formulaires). Une page n'écrit aucune règle de défilement :
   elle pose seulement les repères miyaPfStart / miyaPfSplit / miyaPfEnd (auth/page-chrome.php).
   Téléphone : même principe, avec le haut réduit au minimum. La page Facture n'est pas concernée sur téléphone. */

body:has(> main > .pfBody){
  height:100vh;height:calc(100dvh - var(--miya-kb,0px));overflow:hidden;
  display:flex;flex-direction:column;
}
body:has(> main > .pfBody) > main{
  flex:1 1 auto;min-height:0;
  display:flex;flex-direction:column;
  padding-bottom:0;
}
.pfTop{flex:0 0 auto;background:var(--miya-surface);position:relative;z-index:2}
/* La cage : un grand cadre fixe, dessiné comme les cartes de Miya. Seul son contenu défile, bord et coins ne bougent jamais. */
.pfBody{
  flex:1 1 auto;min-height:0;
  box-sizing:border-box;
  border:2px solid var(--miya-brand);border-radius:18px;background:var(--miya-surface);
  overflow-x:hidden;overflow-y:auto;
  -webkit-overflow-scrolling:touch;overscroll-behavior:contain;
  padding:14px 14px 4px;
  margin:0 0 calc(14px + env(safe-area-inset-bottom));
}
/* Une liste est elle-même la cage : sa carte ne dessine pas un deuxième bord. */
.pfBody .miyaCard.affList{border:0!important;border-radius:0;background:none;box-shadow:none;padding:0!important;margin:0}
.pfBody .miyaCard.affList + .miyaHint,.pfBody .miyaCard + .miyaHint{margin-top:8px}
.pfBody > :last-child{margin-bottom:10px}
.pfTop > :last-child{margin-bottom:10px}

/* ---------- Téléphone : le même principe, le haut réduit au minimum ---------- */
@media (max-width:899px){
  body:has(> main > .pfBody) > main{padding-top:8px}
  .pfTop .affCrumb{margin:0 0 2px;font-size:13px;line-height:1.2}
  .pfTop .miyaHead{margin:0 0 6px;gap:8px}
  .pfTop .miyaHead .miyaPageTitle,.pfTop > .miyaPageTitle{font-size:21px;line-height:1.15}
  .pfTop .miyaKindTitle{margin:0 0 6px;font-size:19px;line-height:1.15;gap:2px 0}
  .pfTop .miyaKindTitle > *{font-size:inherit}
  .pfTop .miyaKindNum,.pfTop .miyaKindTitle span:not(.miyaKind){font-size:15px}
  .pfTop .affSearch{margin:0 0 6px;gap:8px}
  .pfTop .miyaRound .miyaRoundDot{transform:scale(.88)}
  .pfTop > :last-child{margin-bottom:6px}
  .pfTop .agHead{margin:0}
  .pfTop .agRow2{gap:6px;margin:0 0 4px}
  .pfTop .agRound{width:34px;height:34px}
  .pfBody{padding:10px 10px 2px;border-radius:14px;margin-bottom:calc(8px + env(safe-area-inset-bottom))}
}
@media (max-width:520px){
  .pfTop .miyaKind{flex:0 0 auto;padding:0 10px 0 0;margin:0 10px 0 0;border-right:3px solid var(--miya-brand-soft)}
  .pfTop .miyaKindLabel{flex:1 1 0;min-width:0;margin:0 0 0 8px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-size:14px}
  .pfTop .miyaKindNum{flex:0 0 auto}
}

/* ---------- Le cadre : barre de défilement fine, écartée des coins arrondis, sans flèches ---------- */
.pfBody::-webkit-scrollbar{width:10px}
.pfBody::-webkit-scrollbar-track{background:transparent;margin:18px 0}
.pfBody::-webkit-scrollbar-thumb{background:rgba(120,90,100,.40);border-radius:6px;border:2px solid transparent;background-clip:padding-box}
.pfBody::-webkit-scrollbar-thumb:hover{background:rgba(120,90,100,.65);background-clip:padding-box}
.pfBody::-webkit-scrollbar-button{display:none;width:0;height:0}
@supports not selector(::-webkit-scrollbar){.pfBody{scrollbar-width:thin}}

/* ---------- Flèches page précédente / suivante (js/pagefixe.js) ---------- */
.miyNav{display:flex;justify-content:space-between;align-items:center;gap:10px;margin:0 0 4px;min-height:24px}
.miyNavB{display:inline-flex;align-items:center;gap:5px;min-width:0;max-width:46%;margin:0;padding:2px 0;border:0;background:none;color:var(--miya-brand);font:700 14px/1.2 inherit;font-family:inherit;cursor:pointer}
.miyNavB svg{flex:0 0 auto;width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.miyNavB span{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.miyNavB:disabled{opacity:.3;cursor:default}
.miyNavB:not(:disabled):hover span{text-decoration:underline}
@media (max-width:899px){.miyNavB{font-size:13px}.miyNav{min-height:22px}}

.miyNavB .symInline svg{width:18px;height:18px}

/* ---------- Dans le grand cadre : pas de cadre dans le cadre ----------
   Les blocs posés dans la cage n'ont plus de contour : un fond très léger (comme les bulles de Messages) les distingue.
   Un bloc ouvert garde un petit espace avec le suivant. Règle commune : aucune page n'écrit la sienne. */
.pfBody .miyaCard:not(.affList),.pfBody .miyaAdminPage .miyaCard:not(.affList){
  border:0;border-radius:14px;box-shadow:none;
  background:var(--miya-surface-soft);
  margin:0 0 10px;
}
.pfBody .miyaCard:not(.affList) .ivPassage,.pfBody .miyaCard:not(.affList) .ivMsg,.pfBody .miyaCard:not(.affList) .affItem{border:0;background:var(--miya-surface-soft)}
.pfBody .miyaCard:not(.affList) .ivMsg.is-mine{background:color-mix(in srgb,var(--miya-accent) 6%,var(--miya-surface))}
.pfBody .ivPassage,.pfBody .ivMsg{border:0;background:var(--miya-surface-soft)}
.pfBody .ivMsg.is-mine{background:color-mix(in srgb,var(--miya-accent) 6%,var(--miya-surface))}
.pfBody .ivMsg.is-new{box-shadow:inset 3px 0 0 var(--miya-brand)}
