:root {
  --tenant-bg: #fafafa;
  --tenant-surface: #ffffff;
  --tenant-text: #09090b;
  --tenant-muted: #3f3f46;
  --tenant-subtle: #71717a;
  --tenant-accent: #ec4899;
  --tenant-blue: #2563eb;
  --tenant-blue-hover: #1d4ed8;
  --tenant-border: #e4e4e7;
  --cg-bg: #161310;
  --cg-accent: #f59e0b;
  --cg-accent-hover: #d97706;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background-color: var(--tenant-bg);
  color: var(--tenant-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

/* =========================
   Top Sticky Anchor Ad
   ========================= */
.ad-anchor-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2147483640;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--tenant-border);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  transition: transform 0.25s ease;
}

.ad-anchor-bar.collapsed {
  transform: translateY(-100%);
}

.ad-anchor-inner {
  max-width: 980px;
  margin: 0 auto;
  padding: 6px 12px;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 70px;
}

.ad-anchor-toggle {
  position: absolute;
  bottom: -24px;
  right: 16px;
  background: #ffffff;
  border: 1px solid var(--tenant-border);
  border-top: none;
  border-radius: 0 0 8px 8px;
  padding: 2px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--tenant-muted);
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.06);
}

/* =========================
   Header (65px)
   ========================= */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  height: 65px;
  border-bottom: 1px solid var(--tenant-border);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
}

.header-inner {
  max-width: 1152px;
  height: 100%;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-logo {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--tenant-text);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--tenant-accent);
  display: inline-block;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 24px;
  font-size: 14px;
  font-weight: 500;
  color: var(--tenant-muted);
}

.header-nav a:hover {
  color: var(--tenant-text);
}

.mobile-menu-btn {
  display: none;
  background: #ffffff;
  border: 1px solid var(--tenant-border);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

@media (max-width: 767px) {
  .header-nav {
    display: none;
  }
  .header-nav.open {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 65px;
    left: 0;
    right: 0;
    background: #ffffff;
    border-bottom: 1px solid var(--tenant-border);
    padding: 16px;
    gap: 14px;
    align-items: flex-start;
  }
  .mobile-menu-btn {
    display: inline-flex;
    align-items: center;
  }
}

/* =========================
   Main Reading Layout
   ========================= */
.page-shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 16px 48px;
  position: relative;
}

/* Give room below anchor ad when expanded */
body.has-anchor-open {
  padding-top: 76px;
}

.article-column {
  max-width: 760px;
  margin: 0 auto;
}

.article-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: var(--tenant-subtle);
  margin-bottom: 14px;
}

.btn-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--tenant-blue);
  color: #ffffff;
  font-size: 14px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
}

.btn-pill:hover {
  background: var(--tenant-blue-hover);
}

.btn-pill-outline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #ffffff;
  color: var(--tenant-text);
  border: 1px solid var(--tenant-border);
  font-size: 14px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
}

.btn-pill-outline:hover {
  background: #f4f4f5;
}

.v5-title {
  font-size: 26.8px;
  line-height: 1.1;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--tenant-text);
  margin: 0 0 20px;
}

@media (min-width: 768px) {
  .v5-title {
    font-size: 48px;
  }
}

@media (min-width: 1024px) {
  .v5-title {
    font-size: 56px;
  }
}

.article-subheading {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--tenant-text);
  margin: 24px 0 18px;
}

.hero-figure {
  margin: 0 0 28px;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--tenant-border);
  background: #f4f4f5;
}

.hero-figure img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: cover;
}

/* Exact Matrix Prose Sizing */
.v5-prose {
  position: relative;
}

.v5-prose p {
  font-size: 24px !important;
  line-height: 44px !important;
  color: var(--tenant-text);
  margin: 0 0 24px;
  font-weight: 400;
}

.v5-prose p strong {
  font-weight: 700;
}

/* =========================
   Desktop Right TOC Sidebar
   ========================= */
.toc-sidebar {
  display: none;
}

@media (min-width: 1280px) {
  .page-with-toc {
    display: grid;
    grid-template-columns: minmax(0, 760px) 300px;
    justify-content: center;
    gap: 40px;
    align-items: start;
  }

  .page-with-toc .article-column {
    margin: 0;
  }

  .toc-sidebar {
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 96px;
    width: 300px;
    background: #ffffff;
    border: 1px solid var(--tenant-border);
    border-radius: 14px;
    padding: 18px;
    gap: 12px;
  }
}

.toc-heading {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--tenant-subtle);
}

.toc-article-title {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
  color: var(--tenant-text);
}

.toc-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--tenant-muted);
  background: #fafafa;
  border: 1px solid var(--tenant-border);
}

.toc-item.active,
.toc-item:hover {
  border-color: var(--tenant-blue);
  color: var(--tenant-blue);
  background: #eff6ff;
}

/* Mobile/Tablet Floating Chapters Pill */
.floating-chapters-btn {
  position: fixed;
  right: 16px;
  bottom: 92px;
  z-index: 45;
  background: var(--tenant-blue);
  color: #ffffff;
  border: none;
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.35);
  cursor: pointer;
}

@media (min-width: 1280px) {
  .floating-chapters-btn {
    display: none;
  }
}

.chapters-drawer {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(9, 9, 11, 0.45);
  display: none;
  justify-content: flex-end;
}

.chapters-drawer.open {
  display: flex;
}

.chapters-drawer-panel {
  width: min(340px, 88vw);
  background: #ffffff;
  height: 100%;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: -8px 0 30px rgba(0, 0, 0, 0.15);
}

/* =========================
   Ad Containers & Preview Badges
   ========================= */
.ad-container {
  margin: 26px auto;
  width: 100%;
  display: flex;
  justify-content: center;
}

.ad-slot-box {
  width: 100%;
  border: 1.5px dashed #94a3b8;
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border-radius: 10px;
  padding: 12px 14px;
  text-align: center;
  color: #334155;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.ad-slot-box.size-anchor {
  min-height: 58px;
  max-width: 728px;
  padding: 6px 12px;
}

.ad-slot-box.size-mrec {
  min-height: 250px;
  max-width: 336px;
}

.ad-slot-box.size-tall {
  min-height: 600px;
  max-width: 300px;
}

.ad-slot-box.size-leaderboard {
  min-height: 90px;
  max-width: 728px;
}

.ad-slot-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 999px;
  background: #e2e8f0;
  color: #1e293b;
}

.ad-slot-meta {
  font-size: 12px;
  color: #64748b;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* =========================
   Gate 1: Offerwall Style (Google Funding Choices style)
   ========================= */
.offerwall-gate {
  position: relative;
  margin: 24px 0;
  border-radius: 16px;
  border: 1px solid var(--tenant-border);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.08);
  padding: 26px 20px;
  text-align: center;
  z-index: 20;
}

.offerwall-gate.unlocked {
  display: none;
}

.offerwall-icon {
  width: 44px;
  height: 44px;
  margin: 0 auto 12px;
  border-radius: 999px;
  background: #eff6ff;
  color: var(--tenant-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 800;
}

.offerwall-title {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 8px;
}

.offerwall-desc {
  font-size: 14px;
  color: var(--tenant-muted);
  max-width: 460px;
  margin: 0 auto 18px;
  line-height: 1.5;
}

.offerwall-btn {
  background: var(--tenant-blue);
  color: #ffffff;
  border: none;
  border-radius: 10px;
  padding: 12px 24px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

.offerwall-btn:hover {
  background: var(--tenant-blue-hover);
}

/* Blurred content behind gates */
.gated-block.is-blurred {
  filter: blur(7px);
  user-select: none;
  pointer-events: none;
  max-height: 220px;
  overflow: hidden;
  position: relative;
}

.gated-block.is-blurred::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(250, 250, 250, 0.15), rgba(250, 250, 250, 0.96));
}

/* =========================
   Gate 2: Middle-of-Page Blur (.cg-veil) + Dark Bottom Lock Bar (.cg-bar)
   Exact parity with matrix.treeiq.biz
   ========================= */
.cg-veil {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 9000;
  pointer-events: auto;
  background: rgba(248, 247, 244, 0.30);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 90px);
  mask-image: linear-gradient(180deg, transparent 0, #000 90px);
}

@supports not ((backdrop-filter: blur(7px)) or (-webkit-backdrop-filter: blur(7px))) {
  .cg-veil {
    background: rgba(248, 247, 244, 0.96);
  }
}

.cg-veil.cg-hide {
  display: none;
}

.cg-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9050;
  transform: translateY(120%);
  transition: transform 0.45s cubic-bezier(0.2, 0.8, 0.2, 1);
  padding: 48px 16px 16px;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(22, 19, 16, 0), #161310 38%);
}

.cg-bar.cg-show {
  transform: translateY(0);
  pointer-events: auto;
}

.cg-card {
  max-width: 560px;
  margin: 0 auto;
  background: #161310;
  color: #f8f4ec;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  box-shadow: 0 18px 50px -12px rgba(0, 0, 0, 0.55);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.cg-ico {
  flex: none;
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: #161310;
  background: linear-gradient(135deg, #f0a500, #e8762b);
}

.cg-txt {
  flex: 1;
  min-width: 0;
}

.cg-title {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 2px;
  line-height: 1.3;
  color: #f8f4ec;
}

.cg-sub {
  font-size: 12.5px;
  color: rgba(248, 244, 236, 0.62);
  margin: 0;
  line-height: 1.4;
}

.cg-btn {
  flex: none;
  cursor: pointer;
  border: 0;
  font-family: inherit;
  font-weight: 700;
  font-size: 14px;
  color: #161310;
  background: linear-gradient(135deg, #f0a500, #e8762b);
  padding: 13px 20px;
  border-radius: 11px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  transition: transform 0.15s, box-shadow 0.15s;
}

.cg-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px -6px #e8762b;
}

.cg-btn[disabled] {
  opacity: 0.55;
  cursor: progress;
  box-shadow: none;
  transform: none;
}

.cg-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(20px);
  background: #1c1b1a;
  color: #ffffff;
  font-size: 13.5px;
  font-weight: 500;
  padding: 12px 18px;
  border-radius: 11px;
  z-index: 9070;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
  box-shadow: 0 12px 32px -8px rgba(0, 0, 0, 0.4);
}

.cg-toast.cg-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 520px) {
  .cg-card {
    padding: 14px;
    gap: 12px;
  }
  .cg-ico {
    width: 40px;
    height: 40px;
  }
  .cg-btn {
    padding: 11px 16px;
  }
}

/* =========================
   Rewarded Video Ad Player Modal (GPT Rewarded style)
   ========================= */
.rva-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2147483647;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(2px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.rva-backdrop.open {
  display: flex;
}

.rva-frame {
  width: min(640px, 100%);
  background: #000000;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.75);
  position: relative;
}

.rva-topbar {
  height: 42px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #000000;
  color: #e4e4e7;
}

.rva-info-btn {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  background: transparent;
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.rva-close-btn {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  border: 1.5px solid rgba(255, 255, 255, 0.85);
  background: rgba(0, 0, 0, 0.6);
  color: #ffffff;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.rva-video-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #09090b;
}

.rva-video-wrap video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.rva-bottom-bar {
  background: linear-gradient(180deg, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.92) 35%);
  padding: 18px 14px 12px;
  position: relative;
  color: #ffffff;
}

.rva-controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 500;
}

.rva-left-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.rva-icon-btn {
  background: transparent;
  border: none;
  color: #ffffff;
  font-size: 16px;
  cursor: pointer;
  padding: 2px 4px;
}

.rva-progress-track {
  width: 100%;
  height: 3px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  overflow: hidden;
}

.rva-progress-fill {
  height: 100%;
  width: 0%;
  background: #ffffff;
  transition: width 0.2s linear;
}

.rva-confirm-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 15, 18, 0.92);
  color: #ffffff;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  gap: 14px;
  z-index: 10;
}

.rva-confirm-overlay.open {
  display: flex;
}

.rva-confirm-actions {
  display: flex;
  gap: 10px;
}

/* =========================
   Simple Interstitial Modal (Chapter transition)
   ========================= */
.ad-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2147483647;
  background: rgba(9, 9, 11, 0.82);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.ad-modal-backdrop.open {
  display: flex;
}

.ad-modal-card {
  width: min(460px, 100%);
  background: #ffffff;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

.ad-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #18181b;
  color: #ffffff;
  font-size: 13px;
  font-weight: 600;
}

.ad-modal-body {
  padding: 20px;
  text-align: center;
}

.ad-modal-close {
  background: #27272a;
  color: #ffffff;
  border: 1px solid #3f3f46;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.ad-modal-close:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* =========================
   Widgets: May you like / Share / Other posts
   ========================= */
.may-you-like {
  margin: 34px 0;
  padding: 20px;
  border-radius: 14px;
  background: #ffffff;
  border: 1px solid var(--tenant-border);
}

.widget-label {
  font-size: 14px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--tenant-subtle);
  margin: 0 0 14px;
}

.myl-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

@media (max-width: 640px) {
  .myl-grid {
    grid-template-columns: 1fr;
  }
}

.post-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--tenant-border);
  border-radius: 10px;
  overflow: hidden;
  background: #ffffff;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.post-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.06);
}

.post-card img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
}

.post-card-title {
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--tenant-text);
}

.share-bar {
  margin: 28px 0;
  padding: 16px 18px;
  background: #ffffff;
  border: 1px solid var(--tenant-border);
  border-radius: 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.share-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.share-chip {
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--tenant-border);
  background: #fafafa;
  font-size: 13px;
  font-weight: 600;
  color: var(--tenant-muted);
}

.share-chip:hover {
  background: #f4f4f5;
  color: var(--tenant-text);
}

.other-posts-section {
  max-width: 980px;
  margin: 36px auto 0;
  padding: 0 16px;
}

.other-posts-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

@media (max-width: 900px) {
  .other-posts-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .other-posts-grid {
    grid-template-columns: 1fr;
  }
}

.chapter-nav-box {
  margin: 28px 0;
  padding: 20px;
  border-radius: 14px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.site-footer-ads {
  margin-top: 32px;
  border-top: 1px solid var(--tenant-border);
  background: rgba(255, 255, 255, 0.95);
  padding: 16px;
}

/* Floating Config Inspector Pill (Dev helper — can hide in ads-config.js) */
.inspector-toggle {
  position: fixed;
  left: 16px;
  bottom: 16px;
  z-index: 2147483644;
  background: #18181b;
  color: #ffffff;
  border: 1px solid #3f3f46;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
}
