.thmt-banner-global,
.thmt-banner-middle-zone {
  --thmt-z-top: 99990;
  --thmt-z-side: 99980;
  --thmt-z-bottom: 99985;
  --thmt-side-width: 150px;
  --thmt-side-height: 500px;
  --thmt-side-gap: 10px;
  box-sizing: border-box;
}

.thmt-banner-global *,
.thmt-banner-middle-zone * {
  box-sizing: border-box;
}

.thmt-banner-slot {
  position: relative;
  overflow: hidden;
  background: #0d1014;
  border: 1px solid #d7dde5;
  border-radius: 8px;
  contain: paint;
}

.thmt-banner-media,
.thmt-banner-slot img,
.thmt-banner-slot video {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  object-fit: contain;
  object-position: center;
  border: 0;
  pointer-events: none;
}

.thmt-banner-video {
  background: #0d1014;
}

.thmt-banner-link {
  position: absolute;
  inset: 0;
  z-index: 2;
}

.thmt-banner-debug-badge {
  position: absolute;
  z-index: 3;
  left: 5px;
  top: 5px;
  max-width: calc(100% - 10px);
  padding: 4px 7px;
  overflow: hidden;
  color: #111827;
  background: rgba(255,255,255,.94);
  border-radius: 999px;
  font: 900 9px/1 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
}

.thmt-banner-horizontal {
  width: 100%;
  aspect-ratio: 728 / 90;
}

/* V9 sides — media is never mounted under 1201px. */
.thmt-banner-side-rail {
  position: fixed;
  top: 112px;
  z-index: var(--thmt-z-side);
  display: flex;
  flex-direction: column;
  gap: var(--thmt-side-gap);
  width: var(--thmt-side-width);
  transform-origin: top left;
  contain: layout paint;
  will-change: transform;
}

.thmt-banner-side-right {
  transform-origin: top right;
}

.thmt-banner-vertical {
  flex: 0 0 var(--thmt-side-height);
  width: var(--thmt-side-width);
  height: var(--thmt-side-height);
}

/* V9 MIDDLE — normal document flow. Media is IntersectionObserver-mounted. */
.thmt-banner-middle-zone {
  clear: both;
  margin: 14px 0;
  padding: 10px;
  background: #f8fafc;
  border: 1px solid #e5e9ef;
  border-radius: 12px;
}

.thmt-banner-middle-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 9px;
}

.thmt-banner-middle {
  width: 100%;
  aspect-ratio: 6 / 5;
}

/* V9 BOTTOM — fixed within detected site bounds. */
.thmt-banner-bottom-row {
  position: fixed;
  left: 188px;
  right: 188px;
  bottom: 8px;
  z-index: var(--thmt-z-bottom);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
  margin: 0;
  padding: 6px;
  background: #fff;
  border: 1px solid #e3e8ef;
  border-radius: 10px;
  box-shadow: 0 -2px 8px rgba(15,23,42,.08);
  contain: layout paint;
}

@media (max-width: 1200px) {
  .thmt-banner-side-rail {
    display: none !important;
  }

  .thmt-banner-bottom-row {
    left: 14px !important;
    right: 14px !important;
  }
}

@media (max-width: 760px) {
  .thmt-banner-bottom-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .thmt-banner-middle-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .thmt-banner-bottom-row {
    left: 8px !important;
    right: 8px !important;
    bottom: 6px;
  }

  body.thmt-banner-v9-enabled {
    padding-bottom: 220px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .thmt-banner-video {
    visibility: hidden;
  }
}
