/* =========================================================
   TEHRAN GHATE — PAGE
   ========================================================= */
:root {
  --tg-red: #ef232d;
  --tg-red-dark: #c8121b;
  --tg-line: rgba(255, 255, 255, 0.09);
  --tg-txt: rgba(255, 255, 255, 0.72);
  --tg-dim: rgba(255, 255, 255, 0.48);
}

.tg-page {
  position: relative;
  overflow: hidden;
  padding-bottom: 3rem;
}

.tg-page__glow {
  position: absolute;
  width: 42rem;
  height: 42rem;
  border-radius: 9999px;
  filter: blur(120px);
  pointer-events: none;
  opacity: .42;
  z-index: 0;
}
.tg-page__glow--a {
  top: -16rem;
  inset-inline-start: -12rem;
  background: radial-gradient(circle, rgba(239,35,45,.3), transparent 65%);
}
.tg-page__glow--b {
  bottom: -18rem;
  inset-inline-end: -14rem;
  background: radial-gradient(circle, rgba(120,120,255,.12), transparent 65%);
}

/* Hero */
.tg-hero {
  position: relative;
  z-index: 1;
  padding: 5.75rem 0 2rem;
}
.tg-hero--has-bg { padding: 4.5rem 0 2.75rem; }
.tg-hero__media {
  position: absolute;
  inset: 0;
  z-index: -1;
}
.tg-hero__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: .28;
  filter: saturate(.7);
}
.tg-hero__veil {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to top, #050505 10%, rgba(5,5,5,.72) 55%, rgba(5,5,5,.9)),
    radial-gradient(70% 55% at 50% 0%, rgba(239,35,45,.16), transparent 70%);
}
.tg-hero__title {
  margin: .9rem 0 0;
  color: #fff;
  font-size: clamp(1.55rem, 4vw, 2.7rem);
  font-weight: 900;
  line-height: 1.35;
}
.tg-hero__subtitle {
  margin: .85rem 0 0;
  max-width: 46rem;
  color: var(--tg-txt);
  font-size: clamp(.875rem, 2vw, 1.05rem);
  line-height: 1.9;
}
.tg-hero__line {
  display: block;
  height: 1px;
  margin-top: 1.75rem;
  background: linear-gradient(to left, transparent, rgba(239,35,45,.45), rgba(255,255,255,.08), transparent);
}
.tg-hero__meta {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin: 1.35rem 0 0;
  padding: 0;
  list-style: none;
}
.tg-chip {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .4rem .85rem;
  border: 1px solid var(--tg-line);
  border-radius: 9999px;
  background: rgba(255,255,255,.04);
  backdrop-filter: blur(12px);
  color: var(--tg-txt);
  font-size: .7rem;
  font-weight: 700;
}
.tg-chip svg { width: .95rem; height: .95rem; color: var(--tg-red); }

/* Breadcrumb */
.tg-crumb ol {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--tg-dim);
  font-size: .75rem;
}
.tg-crumb li { display: inline-flex; align-items: center; gap: .35rem; }
.tg-crumb a { color: rgba(255,255,255,.62); text-decoration: none; }
.tg-crumb a:hover { color: var(--tg-red); }
.tg-crumb i { font-style: normal; color: rgba(255,255,255,.22); }
.tg-crumb [aria-current="page"] { color: rgba(255,255,255,.88); font-weight: 700; }

/* Grid */
.tg-page__body { position: relative; z-index: 1; padding-top: 2rem; }
.tg-page__grid { display: grid; gap: 1.5rem; }
@media (min-width: 1024px) {
  .tg-page--toc .tg-page__grid {
    grid-template-columns: 16.5rem minmax(0, 1fr);
    gap: 2rem;
    align-items: start;
  }
}

/* Prose */
.page-prose {
  color: var(--tg-txt);
  font-size: .95rem;
  line-height: 2.15;
  word-break: break-word;
}
@media (min-width: 768px) { .page-prose { font-size: 1rem; } }
.page-prose > *:first-child { margin-top: 0 !important; }
.page-prose > *:last-child { margin-bottom: 0 !important; }
.page-prose p { margin: 0 0 1.3rem; }

.page-prose h2,
.page-prose h3,
.page-prose h4 {
  position: relative;
  margin: 2.4rem 0 1rem;
  color: #fff;
  font-weight: 900;
  line-height: 1.5;
  scroll-margin-top: 6.5rem;
}
.page-prose h2 {
  padding-inline-start: .95rem;
  font-size: clamp(1.15rem, 3vw, 1.5rem);
}
.page-prose h2::before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  top: .35em;
  width: 4px;
  height: 1.1em;
  border-radius: 9999px;
  background: linear-gradient(180deg, var(--tg-red), var(--tg-red-dark));
  box-shadow: 0 0 16px rgba(239,35,45,.55);
}
.page-prose h3 { font-size: clamp(1.02rem, 2.5vw, 1.2rem); }

.page-prose a:not(.tg-share__btn) {
  color: #ff5a63;
  font-weight: 700;
  text-decoration: none;
  border-bottom: 1px dashed rgba(239,35,45,.45);
}
.page-prose a:not(.tg-share__btn):hover {
  color: #fff;
  border-bottom-color: #fff;
}

.page-prose ul,
.page-prose ol {
  margin: 0 0 1.4rem;
  padding: 0;
  list-style: none;
}
.page-prose li {
  position: relative;
  margin-bottom: .65rem;
  padding-inline-start: 1.55rem;
}
.page-prose ul > li::before {
  content: "";
  position: absolute;
  inset-inline-start: .15rem;
  top: .82em;
  width: 7px;
  height: 7px;
  border-radius: 9999px;
  background: var(--tg-red);
  box-shadow: 0 0 10px rgba(239,35,45,.7);
}
.page-prose ol { counter-reset: tgli; }
.page-prose ol > li {
  counter-increment: tgli;
  padding-inline-start: 2.1rem;
}
.page-prose ol > li::before {
  content: counter(tgli);
  position: absolute;
  inset-inline-start: 0;
  top: .3em;
  display: grid;
  place-items: center;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 9999px;
  border: 1px solid rgba(239,35,45,.4);
  background: rgba(239,35,45,.14);
  color: #fff;
  font-size: .7rem;
  font-weight: 800;
}

.page-prose blockquote {
  margin: 1.8rem 0;
  padding: 1.2rem 1.35rem;
  border: 1px solid rgba(239,35,45,.22);
  border-inline-start: 3px solid var(--tg-red);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(239,35,45,.09), rgba(239,35,45,.02));
  color: rgba(255,255,255,.9);
  font-weight: 600;
}
.page-prose img {
  display: block;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--tg-line);
  border-radius: 20px;
}
.page-prose figure { margin: 1.8rem 0; }
.page-prose figcaption {
  margin-top: .65rem;
  color: var(--tg-dim);
  font-size: .75rem;
  text-align: center;
}
.page-prose table {
  display: block;
  width: 100%;
  margin: 1.8rem 0;
  overflow-x: auto;
  border-collapse: collapse;
  border: 1px solid var(--tg-line);
  border-radius: 16px;
  font-size: .82rem;
  white-space: nowrap;
}
.page-prose thead th {
  padding: .8rem 1rem;
  background: rgba(239,35,45,.14);
  color: #fff;
  font-weight: 800;
  text-align: right;
}
.page-prose tbody td {
  padding: .75rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.05);
}
.page-prose tbody tr:nth-child(even) { background: rgba(255,255,255,.02); }
.page-prose code {
  padding: .12rem .4rem;
  border: 1px solid var(--tg-line);
  border-radius: 8px;
  background: rgba(255,255,255,.06);
  color: #ff8a90;
  font-size: .82em;
  direction: ltr;
}
.page-prose pre {
  margin: 1.6rem 0;
  padding: 1.1rem;
  overflow-x: auto;
  border: 1px solid var(--tg-line);
  border-radius: 16px;
  background: rgba(0,0,0,.55);
  direction: ltr;
  text-align: left;
}
.page-prose pre code {
  padding: 0;
  border: 0;
  background: none;
  color: rgba(255,255,255,.85);
}
.page-prose hr {
  margin: 2.3rem 0;
  border: 0;
  height: 1px;
  background: linear-gradient(to left, transparent, rgba(255,255,255,.12), rgba(239,35,45,.35), transparent);
}
.page-prose strong,
.page-prose b { color: #fff; font-weight: 800; }

/* Pager */
.tg-pager {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
  align-items: center;
  margin-top: 2rem;
  padding-top: 1.35rem;
  border-top: 1px solid var(--tg-line);
  font-size: .82rem;
}
.tg-pager__label { color: var(--tg-dim); font-weight: 700; }
.tg-pager a span,
.tg-pager > span {
  display: inline-grid;
  place-items: center;
  min-width: 2.05rem;
  height: 2.05rem;
  border: 1px solid var(--tg-line);
  border-radius: 9999px;
  font-weight: 800;
}
.tg-pager > span {
  border-color: rgba(239,35,45,.45);
  background: linear-gradient(180deg, var(--tg-red), var(--tg-red-dark));
  color: #fff;
}
.tg-pager a { color: var(--tg-txt); text-decoration: none; border: 0 !important; }

/* TOC */
.tg-toc { display: none; }
@media (min-width: 1024px) { .tg-toc { display: block; } }
.tg-toc__head {
  display: flex;
  align-items: center;
  gap: .5rem;
  color: #fff;
  font-size: .82rem;
  font-weight: 900;
}
.tg-toc__head svg { width: 1.05rem; height: 1.05rem; color: var(--tg-red); }
.tg-toc__nav {
  margin-top: .95rem;
  max-height: 62vh;
  overflow: auto;
  scrollbar-width: thin;
}
.tg-toc__list {
  margin: 0;
  padding: 0;
  list-style: none;
}
.tg-toc__list a {
  display: block;
  padding: .45rem .55rem;
  border-radius: 10px;
  color: var(--tg-dim);
  font-size: .78rem;
  font-weight: 600;
  line-height: 1.7;
  text-decoration: none;
  transition: .2s ease;
}
.tg-toc__list a:hover,
.tg-toc__list a.is-active {
  color: #fff;
  background: rgba(239,35,45,.12);
}
.tg-toc__list .is-h3 { padding-inline-start: 1rem; font-size: .74rem; }
.tg-toc__progress {
  margin-top: .9rem;
  height: 3px;
  border-radius: 9999px;
  background: rgba(255,255,255,.08);
  overflow: hidden;
}
.tg-toc__bar {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--tg-red), #ff6b73);
  transition: width .15s linear;
}

/* Children */
.tg-children__title {
  display: flex;
  align-items: center;
  gap: .55rem;
  margin: 0 0 1rem;
  color: #fff;
  font-size: 1.1rem;
  font-weight: 900;
}
.tg-children__dot {
  width: .55rem;
  height: .55rem;
  border-radius: 9999px;
  background: var(--tg-red);
  box-shadow: 0 0 12px rgba(239,35,45,.7);
}
.tg-children__grid {
  display: grid;
  gap: .85rem;
  grid-template-columns: 1fr;
}
@media (min-width: 640px) {
  .tg-children__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.tg-child { transition: transform .25s ease, border-color .25s ease; }
.tg-child:hover { transform: translateY(-2px); }
.tg-child__name {
  display: block;
  color: #fff;
  font-size: .95rem;
  font-weight: 800;
  line-height: 1.6;
}
.tg-child__excerpt {
  display: block;
  margin-top: .35rem;
  color: var(--tg-dim);
  font-size: .78rem;
  line-height: 1.8;
}
.tg-child__arrow {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 9999px;
  border: 1px solid var(--tg-line);
  color: var(--tg-txt);
  transition: .25s ease;
}
.tg-child__arrow svg { width: 1rem; height: 1rem; }
.tg-child:hover .tg-child__arrow {
  border-color: rgba(239,35,45,.45);
  background: rgba(239,35,45,.16);
  color: #fff;
}

/* Share */
.tg-share {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .75rem 1rem;
  padding: 1rem 0 0;
}
.tg-share__label {
  color: var(--tg-dim);
  font-size: .8rem;
  font-weight: 700;
}
.tg-share__row { display: flex; flex-wrap: wrap; gap: .5rem; }
.tg-share__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.2rem;
  padding: 0 .9rem;
  border: 1px solid var(--tg-line);
  border-radius: 9999px;
  background: rgba(255,255,255,.04);
  color: rgba(255,255,255,.8);
  font-size: .75rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: .2s ease;
}
.tg-share__btn:hover {
  border-color: rgba(239,35,45,.4);
  background: rgba(239,35,45,.14);
  color: #fff;
}

/* CTA */
.tg-cta__title {
  margin: 0;
  color: #fff;
  font-size: clamp(1.15rem, 3vw, 1.55rem);
  font-weight: 900;
  line-height: 1.5;
}
.tg-cta__text {
  margin: .55rem 0 0;
  color: var(--tg-txt);
  font-size: .9rem;
  line-height: 1.9;
}

/* Mobile TOC (optional floating) */
@media (max-width: 1023px) {
  .tg-toc-mobile {
    position: fixed;
    inset-inline-end: 1rem;
    bottom: 1.1rem;
    z-index: 40;
  }
}
/* =========================================================
   TEHRAN GHATE — WORDPRESS GALLERY (columns 1–9)
   ========================================================= */

/* ---------- Reset پیش‌فرض وردپرس / float ---------- */
.page-prose .gallery,
.tg-page .gallery,
.entry-content .gallery {
  display: block;
  width: 100%;
  margin: 2rem 0;
  clear: both;
}

.page-prose .gallery br,
.tg-page .gallery > br.clear,
.tg-page .gallery br[style*="clear"] {
  display: none !important;
}

/* ظرف داخلی (ساختار شما) + بدون gallery-inner */
.page-prose .gallery .gallery-inner,
.tg-page .gallery .gallery-inner,
.page-prose .gallery,
.tg-page .gallery {
  /* grid روی خود .gallery وقتی gallery-inner ندارد */
}

.page-prose .gallery .gallery-inner,
.tg-page .gallery .gallery-inner {
  display: grid;
  gap: 0.85rem;
  width: 100%;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* اگر gallery-inner نبود، خود gallery گرید شود */
.page-prose .gallery:not(:has(.gallery-inner)),
.tg-page .gallery:not(:has(.gallery-inner)) {
  display: grid;
  gap: 0.85rem;
}

/* آیتم‌ها */
.page-prose .gallery .gallery-item,
.tg-page .gallery .gallery-item {
  position: relative;
  float: none !important;
  width: 100% !important;   /* override style="width:50%" و مشابه */
  max-width: none !important;
  margin: 0 !important;
  padding: 0 !important;
  text-align: center;
  box-sizing: border-box;
}

.page-prose .gallery .gallery-icon,
.tg-page .gallery .gallery-icon {
  position: relative;
  display: block;
  overflow: hidden;
  width: 100%;
  margin: 0;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.03);
  box-shadow:
    0 18px 40px -28px rgba(0, 0, 0, 0.85),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  transition:
    transform 0.3s ease,
    border-color 0.3s ease,
    box-shadow 0.3s ease;
}

.page-prose .gallery .gallery-icon::after,
.tg-page .gallery .gallery-icon::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(
    180deg,
    transparent 45%,
    rgba(0, 0, 0, 0.35) 100%
  );
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.page-prose .gallery .gallery-item:hover .gallery-icon,
.tg-page .gallery .gallery-item:hover .gallery-icon {
  transform: translateY(-3px);
  border-color: rgba(239, 35, 45, 0.35);
  box-shadow:
    0 22px 48px -26px rgba(239, 35, 45, 0.35),
    0 18px 40px -28px rgba(0, 0, 0, 0.9),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.page-prose .gallery .gallery-item:hover .gallery-icon::after,
.tg-page .gallery .gallery-item:hover .gallery-icon::after {
  opacity: 1;
}

/* لینک + تصویر */
.page-prose .gallery .gallery-icon a,
.tg-page .gallery .gallery-icon a {
  display: block;
  border: 0 !important;
  line-height: 0;
}

.page-prose .gallery .gallery-icon img,
.tg-page .gallery .gallery-icon img,
.page-prose .gallery img,
.tg-page .gallery img {
  display: block;
  width: 100% !important;
  max-width: 100% !important;
  height: auto !important;
  margin: 0 auto;
  border: 0 !important;
  border-radius: 0; /* radius روی parent */
  object-fit: cover;
  aspect-ratio: 16 / 9; /* نزدیک نسبت 1024×571 */
  transition: transform 0.45s ease;
}

.page-prose .gallery .gallery-item:hover img,
.tg-page .gallery .gallery-item:hover img {
  transform: scale(1.04);
}

/* کپشن */
.page-prose .gallery .gallery-caption,
.tg-page .gallery .gallery-caption {
  margin: 0.55rem 0 0;
  padding: 0 0.25rem;
  color: rgba(255, 255, 255, 0.48);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.7;
  text-align: center;
}

/* ---------- Desktop / پیش‌فرض: columns 1–9 ---------- */
.page-prose .gallery.gallery-columns-1 .gallery-inner,
.tg-page .gallery.gallery-columns-1 .gallery-inner,
.page-prose .gallery.gallery-columns-1:not(:has(.gallery-inner)),
.tg-page .gallery.gallery-columns-1:not(:has(.gallery-inner)) {
  grid-template-columns: minmax(0, 1fr);
}

.page-prose .gallery.gallery-columns-2 .gallery-inner,
.tg-page .gallery.gallery-columns-2 .gallery-inner,
.page-prose .gallery.gallery-columns-2:not(:has(.gallery-inner)),
.tg-page .gallery.gallery-columns-2:not(:has(.gallery-inner)) {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.page-prose .gallery.gallery-columns-3 .gallery-inner,
.tg-page .gallery.gallery-columns-3 .gallery-inner,
.page-prose .gallery.gallery-columns-3:not(:has(.gallery-inner)),
.tg-page .gallery.gallery-columns-3:not(:has(.gallery-inner)) {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.page-prose .gallery.gallery-columns-4 .gallery-inner,
.tg-page .gallery.gallery-columns-4 .gallery-inner,
.page-prose .gallery.gallery-columns-4:not(:has(.gallery-inner)),
.tg-page .gallery.gallery-columns-4:not(:has(.gallery-inner)) {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.page-prose .gallery.gallery-columns-5 .gallery-inner,
.tg-page .gallery.gallery-columns-5 .gallery-inner,
.page-prose .gallery.gallery-columns-5:not(:has(.gallery-inner)),
.tg-page .gallery.gallery-columns-5:not(:has(.gallery-inner)) {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.page-prose .gallery.gallery-columns-6 .gallery-inner,
.tg-page .gallery.gallery-columns-6 .gallery-inner,
.page-prose .gallery.gallery-columns-6:not(:has(.gallery-inner)),
.tg-page .gallery.gallery-columns-6:not(:has(.gallery-inner)) {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.page-prose .gallery.gallery-columns-7 .gallery-inner,
.tg-page .gallery.gallery-columns-7 .gallery-inner,
.page-prose .gallery.gallery-columns-7:not(:has(.gallery-inner)),
.tg-page .gallery.gallery-columns-7:not(:has(.gallery-inner)) {
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.page-prose .gallery.gallery-columns-8 .gallery-inner,
.tg-page .gallery.gallery-columns-8 .gallery-inner,
.page-prose .gallery.gallery-columns-8:not(:has(.gallery-inner)),
.tg-page .gallery.gallery-columns-8:not(:has(.gallery-inner)) {
  grid-template-columns: repeat(8, minmax(0, 1fr));
}

.page-prose .gallery.gallery-columns-9 .gallery-inner,
.tg-page .gallery.gallery-columns-9 .gallery-inner,
.page-prose .gallery.gallery-columns-9:not(:has(.gallery-inner)),
.tg-page .gallery.gallery-columns-9:not(:has(.gallery-inner)) {
  grid-template-columns: repeat(9, minmax(0, 1fr));
}

/* ---------- Tablet ≤ 1024px ---------- */
@media (max-width: 1024px) {
  .page-prose .gallery .gallery-inner,
  .tg-page .gallery .gallery-inner,
  .page-prose .gallery:not(:has(.gallery-inner)),
  .tg-page .gallery:not(:has(.gallery-inner)) {
    gap: 0.75rem;
  }

  /* 5–9 ستون → حداکثر 4 */
  .page-prose .gallery.gallery-columns-5 .gallery-inner,
  .tg-page .gallery.gallery-columns-5 .gallery-inner,
  .page-prose .gallery.gallery-columns-5:not(:has(.gallery-inner)),
  .tg-page .gallery.gallery-columns-5:not(:has(.gallery-inner)),
  .page-prose .gallery.gallery-columns-6 .gallery-inner,
  .tg-page .gallery.gallery-columns-6 .gallery-inner,
  .page-prose .gallery.gallery-columns-6:not(:has(.gallery-inner)),
  .tg-page .gallery.gallery-columns-6:not(:has(.gallery-inner)),
  .page-prose .gallery.gallery-columns-7 .gallery-inner,
  .tg-page .gallery.gallery-columns-7 .gallery-inner,
  .page-prose .gallery.gallery-columns-7:not(:has(.gallery-inner)),
  .tg-page .gallery.gallery-columns-7:not(:has(.gallery-inner)),
  .page-prose .gallery.gallery-columns-8 .gallery-inner,
  .tg-page .gallery.gallery-columns-8 .gallery-inner,
  .page-prose .gallery.gallery-columns-8:not(:has(.gallery-inner)),
  .tg-page .gallery.gallery-columns-8:not(:has(.gallery-inner)),
  .page-prose .gallery.gallery-columns-9 .gallery-inner,
  .tg-page .gallery.gallery-columns-9 .gallery-inner,
  .page-prose .gallery.gallery-columns-9:not(:has(.gallery-inner)),
  .tg-page .gallery.gallery-columns-9:not(:has(.gallery-inner)) {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* ---------- Mobile landscape / small tablet ≤ 768px ---------- */
@media (max-width: 768px) {
  .page-prose .gallery,
  .tg-page .gallery {
    margin: 1.5rem 0;
  }

  .page-prose .gallery .gallery-inner,
  .tg-page .gallery .gallery-inner,
  .page-prose .gallery:not(:has(.gallery-inner)),
  .tg-page .gallery:not(:has(.gallery-inner)) {
    gap: 0.65rem;
  }

  .page-prose .gallery .gallery-icon,
  .tg-page .gallery .gallery-icon {
    border-radius: 14px;
  }

  /* 1 ستون همان 1 */
  .page-prose .gallery.gallery-columns-1 .gallery-inner,
  .tg-page .gallery.gallery-columns-1 .gallery-inner,
  .page-prose .gallery.gallery-columns-1:not(:has(.gallery-inner)),
  .tg-page .gallery.gallery-columns-1:not(:has(.gallery-inner)) {
    grid-template-columns: minmax(0, 1fr);
  }

  /* 2 ستون همان 2 */
  .page-prose .gallery.gallery-columns-2 .gallery-inner,
  .tg-page .gallery.gallery-columns-2 .gallery-inner,
  .page-prose .gallery.gallery-columns-2:not(:has(.gallery-inner)),
  .tg-page .gallery.gallery-columns-2:not(:has(.gallery-inner)) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  /* 3+ → حداکثر 2 ستون */
  .page-prose .gallery.gallery-columns-3 .gallery-inner,
  .tg-page .gallery.gallery-columns-3 .gallery-inner,
  .page-prose .gallery.gallery-columns-3:not(:has(.gallery-inner)),
  .tg-page .gallery.gallery-columns-3:not(:has(.gallery-inner)),
  .page-prose .gallery.gallery-columns-4 .gallery-inner,
  .tg-page .gallery.gallery-columns-4 .gallery-inner,
  .page-prose .gallery.gallery-columns-4:not(:has(.gallery-inner)),
  .tg-page .gallery.gallery-columns-4:not(:has(.gallery-inner)),
  .page-prose .gallery.gallery-columns-5 .gallery-inner,
  .tg-page .gallery.gallery-columns-5 .gallery-inner,
  .page-prose .gallery.gallery-columns-5:not(:has(.gallery-inner)),
  .tg-page .gallery.gallery-columns-5:not(:has(.gallery-inner)),
  .page-prose .gallery.gallery-columns-6 .gallery-inner,
  .tg-page .gallery.gallery-columns-6 .gallery-inner,
  .page-prose .gallery.gallery-columns-6:not(:has(.gallery-inner)),
  .tg-page .gallery.gallery-columns-6:not(:has(.gallery-inner)),
  .page-prose .gallery.gallery-columns-7 .gallery-inner,
  .tg-page .gallery.gallery-columns-7 .gallery-inner,
  .page-prose .gallery.gallery-columns-7:not(:has(.gallery-inner)),
  .tg-page .gallery.gallery-columns-7:not(:has(.gallery-inner)),
  .page-prose .gallery.gallery-columns-8 .gallery-inner,
  .tg-page .gallery.gallery-columns-8 .gallery-inner,
  .page-prose .gallery.gallery-columns-8:not(:has(.gallery-inner)),
  .tg-page .gallery.gallery-columns-8:not(:has(.gallery-inner)),
  .page-prose .gallery.gallery-columns-9 .gallery-inner,
  .tg-page .gallery.gallery-columns-9 .gallery-inner,
  .page-prose .gallery.gallery-columns-9:not(:has(.gallery-inner)),
  .tg-page .gallery.gallery-columns-9:not(:has(.gallery-inner)) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ---------- Mobile خیلی کوچک ≤ 420px ---------- */
@media (max-width: 420px) {
  /* فقط columns-1 تک‌ستونه؛ بقیه حداقل 2 تا شلوغ/دراز نشود */
  .page-prose .gallery.gallery-columns-1 .gallery-inner,
  .tg-page .gallery.gallery-columns-1 .gallery-inner,
  .page-prose .gallery.gallery-columns-1:not(:has(.gallery-inner)),
  .tg-page .gallery.gallery-columns-1:not(:has(.gallery-inner)) {
    grid-template-columns: minmax(0, 1fr);
  }

  .page-prose .gallery:not(.gallery-columns-1) .gallery-inner,
  .tg-page .gallery:not(.gallery-columns-1) .gallery-inner,
  .page-prose .gallery:not(.gallery-columns-1):not(:has(.gallery-inner)),
  .tg-page .gallery:not(.gallery-columns-1):not(:has(.gallery-inner)) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
  }

  .page-prose .gallery .gallery-icon,
  .tg-page .gallery .gallery-icon {
    border-radius: 12px;
  }

  .page-prose .gallery .gallery-caption,
  .tg-page .gallery .gallery-caption {
    font-size: 0.68rem;
  }
}

/* ---------- لینک سفارشی gallery-custom-link ---------- */
.page-prose .gallery.gallery-custom-link .gallery-icon a,
.tg-page .gallery.gallery-custom-link .gallery-icon a {
  position: relative;
}

/* ---------- dl/dt/dd قدیمی وردپرس (اگر هنوز باشد) ---------- */
.page-prose .gallery dl.gallery-item,
.tg-page .gallery dl.gallery-item {
  float: none !important;
  width: 100% !important;
  margin: 0 !important;
}

.page-prose .gallery dt.gallery-icon,
.tg-page .gallery dt.gallery-icon {
  margin: 0;
}