.mfb-taxgrid-wrapper { width:100%; }

/* TOC */
.mfb-taxgrid-toc { display:flex; flex-wrap:wrap; gap:.5rem; margin:0 0 1rem; }
.mfb-taxgrid-toc a { text-decoration:none; border:1px solid #ddd; padding:.25rem .5rem; font-size:.85rem; border-radius:.25rem; }

/* Grid + headings */
.mfb-taxgrid {
  display:grid;
  gap: var(--mfb-gutter, 16px);

  /* Mobile first: phones */
  grid-template-columns: repeat(var(--mfb-cols-phone, 2), minmax(0,1fr));
}

/* Small tablets (iPad mini-ish) */
@media (min-width: 700px) {
  .mfb-taxgrid {
    grid-template-columns: repeat(var(--mfb-cols-smtab, 3), minmax(0,1fr));
  }
}

/* Large tablets and up (iPad Air/desktop) */
@media (min-width: 920px) {
  .mfb-taxgrid {
    grid-template-columns: repeat(var(--mfb-cols-lgtab, 4), minmax(0,1fr));
  }
}

.mfb-taxgrid-letter { grid-column:1 / -1; margin:.5rem 0; }
.mfb-taxgrid-letter span { display:inline-block; font-weight:700; font-size:1.1rem; opacity:.75; }

/* Cards */
.mfb-taxgrid-card { display:flex; flex-direction:column; gap:.5rem; align-items: center; margin-bottom:30px}
.mfb-taxgrid-thumb { display:block; width:100%; overflow:hidden; }
.mfb-taxgrid-thumb img,
.mfb-taxgrid-thumb .mfc-headshot { width:100%; height:100%; object-fit:cover; display:block; }

/* Fallback letter block (creator-credit compatible) */
.mfc-headshot.mfc-fallback {
  display:flex; align-items:center; justify-content:center;
  background:#e9ecef; color:#222; font-weight:700; font-size:2.25rem;
  line-height:1; user-select:none;
}

/* Shape controls — apply to <img> and fallback box */
.mfb-shape--square  .mfb-taxgrid-thumb img,
.mfb-shape--square  .mfb-taxgrid-thumb .mfc-headshot { border-radius:0; }

.mfb-shape--rounded .mfb-taxgrid-thumb img,
.mfb-shape--rounded .mfb-taxgrid-thumb .mfc-headshot { border-radius:12px; }

.mfb-shape--circle  .mfb-taxgrid-thumb img,
.mfb-shape--circle  .mfb-taxgrid-thumb .mfc-headshot { border-radius:9999px; }

/* Meta */
.mfb-taxgrid-meta { display:flex; align-items:center; gap:.5rem; }
.mfb-taxgrid-title { text-decoration:none; font-weight:600; text-align: center}
.mfb-taxgrid-count { font-size:.85rem; }

/* Pagination (your standard markup) */
.mfb-pagination { margin: 1rem 0 0; }
.mfb-pagination ul { display:flex; gap:.4rem; list-style:none; padding:0; margin:0; flex-wrap:wrap; }
.mfb-pagination li a,
.mfb-pagination li span {
  display:inline-block; padding:.4rem .6rem; border:1px solid #ddd; border-radius:.25rem; text-decoration:none;
}
.mfb-pagination li .current { background:#222; color:#fff; border-color:#222; }

/* 4-column stage (>=920px): if count ≡ 1 mod 4, center last card by spanning 2 middle cols */
@media (min-width: 920px) {
  .mfb-taxgrid > .mfb-taxgrid-card:last-child:nth-child(4n + 1) {
    grid-column: 2 / span 2;
  }
}

/* 3-column stage (700–919px): if count ≡ 1 mod 3, put last card in the middle column */
@media (min-width: 700px) and (max-width: 919.98px) {
  .mfb-taxgrid > .mfb-taxgrid-card:last-child:nth-child(3n + 1) {
    grid-column: 2;
  }
}

/* 2-column stage (<=699px): if count is odd, center last card across the row */
@media (max-width: 699.98px) {
  .mfb-taxgrid > .mfb-taxgrid-card:last-child:nth-child(2n + 1) {
    grid-column: 1 / -1;
    justify-self: center;
    max-width: 28rem; /* keeps it from stretching too wide when spanning both cols */
    width: 50%;
  }
}