/* ═══════════════════════════════════════════════════════════════
   CheraghBargh Mag — Color theme mode (light stays default)
   Dark tokens apply only under html[data-theme="dark"]
   ═══════════════════════════════════════════════════════════════ */

html {
  color-scheme: light;
}

/* ── Dark palette + remap of existing --cb-* tokens ─────────── */
html[data-theme="dark"] {
  color-scheme: dark;

  --theme-dark-background: #020617;
  --theme-dark-surface: #0F172A;
  --theme-dark-surface-elevated: #172033;
  --theme-dark-accent: #617CBA;
  --theme-dark-accent-strong: #4F69A8; /* solid buttons with white text */
  --theme-dark-accent-hover: #738DCA;
  --theme-dark-icon: #909FB4;
  --theme-dark-text: #F8FAFC;
  --theme-dark-text-muted: #CBD5E1;
  --theme-dark-border: rgba(144, 159, 180, 0.22);
  --theme-dark-input: #111C30;
  --theme-dark-focus: #93C5FD;
  --theme-dark-overlay: rgba(2, 6, 23, 0.72);
  --theme-dark-danger: #F87171;
  --theme-dark-success: #34D399;
  --theme-dark-warning: #FBBF24;

  --cb-bg: var(--theme-dark-background);
  --cb-bg-soft: #0B1220;
  --cb-soft: var(--theme-dark-background);
  --cb-surface: var(--theme-dark-surface);
  --cb-surface-2: var(--theme-dark-surface-elevated);
  --cb-muted-surface: var(--theme-dark-input);
  --cb-navy: var(--theme-dark-accent);
  --cb-navy-dark: var(--theme-dark-accent-strong);
  --cb-navy-rgb: 97 124 186;
  --cb-text: var(--theme-dark-text);
  --cb-text-2: var(--theme-dark-text-muted);
  --cb-muted: var(--theme-dark-icon);
  --cb-muted-2: #94A3B8;
  --site-border-color: var(--theme-dark-border);
  --cb-border: var(--theme-dark-border);
  --cb-border-2: rgba(144, 159, 180, 0.32);
  --cb-line: var(--theme-dark-border);
  --cb-shadow-card: 0 1px 3px rgba(0, 0, 0, 0.35);
  --cb-shadow-search: 0 1px 2px rgba(0, 0, 0, 0.4);
  --cb-shadow-page: 0 10px 35px rgba(0, 0, 0, 0.35);
  --grey-1: var(--theme-dark-text-muted);
}

/* Soft color transitions after first paint only */
html.cbmag-theme-transitions,
html.cbmag-theme-transitions body,
html.cbmag-theme-transitions .cbmag-desktop-header,
html.cbmag-theme-transitions .cbmag-mobile-header,
html.cbmag-theme-transitions .cbmag-shell,
html.cbmag-theme-transitions .cbmag-theme-toggle__menu {
  transition:
    background-color 0.2s ease,
    color 0.2s ease,
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

@media (prefers-reduced-motion: reduce) {
  html.cbmag-theme-transitions,
  html.cbmag-theme-transitions body,
  html.cbmag-theme-transitions .cbmag-desktop-header,
  html.cbmag-theme-transitions .cbmag-mobile-header,
  html.cbmag-theme-transitions .cbmag-shell,
  html.cbmag-theme-transitions .cbmag-theme-toggle__menu {
    transition: none !important;
  }
}

/* ── Theme toggle control ───────────────────────────────────── */
.cbmag-theme-toggle {
  position: relative;
  flex-shrink: 0;
}

.cbmag-theme-toggle__button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  margin: 0;
  padding: 0;
  border: 1px solid var(--site-border-color, #E1E1E1);
  border-radius: 999px;
  background: var(--cb-surface, #fff);
  color: var(--cb-navy, #323C60);
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.cbmag-theme-toggle__button:hover {
  background: var(--cb-muted-surface, #EEF1F5);
}

.cbmag-theme-toggle__button:focus-visible {
  outline: 2px solid var(--theme-dark-focus, var(--cb-orange, #F6A033));
  outline-offset: 2px;
}

.cbmag-theme-toggle__icon {
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  line-height: 1;
}

.cbmag-theme-toggle__icon i {
  display: block;
  width: 1em;
  text-align: center;
  font-size: inherit;
  line-height: 1;
}

html[data-theme-preference="system"] .cbmag-theme-toggle__icon[data-icon="system"],
html[data-theme-preference="light"] .cbmag-theme-toggle__icon[data-icon="light"],
html[data-theme-preference="dark"] .cbmag-theme-toggle__icon[data-icon="dark"],
html:not([data-theme-preference]) .cbmag-theme-toggle__icon[data-icon="system"] {
  display: inline-flex;
}

.cbmag-theme-toggle__icon[hidden] {
  display: none !important;
}

.cbmag-theme-toggle__menu {
  position: absolute;
  top: calc(100% + 0.4rem);
  inset-inline-end: 0;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 10.5rem;
  padding: 0.35rem;
  border: 1px solid var(--site-border-color, #E1E1E1);
  border-radius: 0.9rem;
  background: var(--cb-surface, #fff);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.14);
}

.cbmag-theme-toggle__menu[hidden] {
  display: none !important;
}

.cbmag-theme-toggle__option {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  margin: 0;
  padding: 0.55rem 0.7rem;
  border: 0;
  border-radius: 0.65rem;
  background: transparent;
  color: var(--cb-text, #111827);
  font-size: 0.875rem;
  font-weight: 700;
  text-align: start;
  cursor: pointer;
}

.cbmag-theme-toggle__option:hover,
.cbmag-theme-toggle__option:focus-visible {
  background: color-mix(in srgb, var(--cb-navy, #323C60) 10%, transparent);
  outline: none;
}

.cbmag-theme-toggle__option.is-active {
  background: color-mix(in srgb, var(--cb-navy, #323C60) 16%, transparent);
  color: var(--cb-navy, #323C60);
}

.cbmag-theme-toggle__option-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  flex-shrink: 0;
  border-radius: 999px;
  font-size: 0.8125rem;
  line-height: 1;
  color: #64748B;
  background: #F1F5F9;
}

.cbmag-theme-toggle__option-icon i {
  display: block;
  width: 1em;
  text-align: center;
  line-height: 1;
}

.cbmag-theme-toggle__option[data-cbmag-theme-option="light"] .cbmag-theme-toggle__option-icon {
  color: #D97706;
  background: #FEF3C7;
}

.cbmag-theme-toggle__option[data-cbmag-theme-option="dark"] .cbmag-theme-toggle__option-icon {
  color: #334155;
  background: #E2E8F0;
}

.cbmag-theme-toggle__option[data-cbmag-theme-option="system"] .cbmag-theme-toggle__option-icon {
  color: #64748B;
  background: #F1F5F9;
}

.cbmag-theme-toggle__option.is-active .cbmag-theme-toggle__option-icon {
  box-shadow: inset 0 0 0 1px rgba(38, 54, 95, 0.18);
}

html[data-theme="dark"] .cbmag-theme-toggle__button {
  background: var(--theme-dark-surface);
  border-color: var(--theme-dark-border);
  color: var(--theme-dark-icon);
}

html[data-theme="dark"] .cbmag-theme-toggle__button:hover {
  background: var(--theme-dark-surface-elevated);
  color: var(--theme-dark-text);
}

html[data-theme="dark"] .cbmag-theme-toggle__menu {
  background: var(--theme-dark-surface);
  border-color: var(--theme-dark-border);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.45);
}

html[data-theme="dark"] .cbmag-theme-toggle__option {
  color: var(--theme-dark-text);
}

html[data-theme="dark"] .cbmag-theme-toggle__option:hover,
html[data-theme="dark"] .cbmag-theme-toggle__option:focus-visible {
  background: rgba(97, 124, 186, 0.16);
}

html[data-theme="dark"] .cbmag-theme-toggle__option.is-active {
  background: rgba(97, 124, 186, 0.24);
  color: var(--theme-dark-text);
}

html[data-theme="dark"] .cbmag-theme-toggle__option[data-cbmag-theme-option="light"] .cbmag-theme-toggle__option-icon {
  color: #FBBF24;
  background: rgba(251, 191, 36, 0.16);
}

html[data-theme="dark"] .cbmag-theme-toggle__option[data-cbmag-theme-option="dark"] .cbmag-theme-toggle__option-icon {
  color: #CBD5E1;
  background: #334155;
}

html[data-theme="dark"] .cbmag-theme-toggle__option[data-cbmag-theme-option="system"] .cbmag-theme-toggle__option-icon {
  color: #94A3B8;
  background: #1E293B;
}

html[data-theme="dark"] .cbmag-theme-toggle__option.is-active .cbmag-theme-toggle__option-icon {
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.35);
}

/* Compact variant for tight mobile rows */
.cbmag-theme-toggle--compact .cbmag-theme-toggle__button {
  width: 2.5rem;
  height: 2.5rem;
}

/* Mobile: keep theme menu fully inside the viewport */
@media (max-width: 1023.98px) {
  html:has(.cbmag-theme-toggle.is-open) {
    overflow-x: clip;
  }

  .cbmag-theme-toggle.is-open {
    z-index: 120;
  }

  .cbmag-theme-toggle__menu {
    position: fixed;
    top: 21%;
    right: 12px;
    left: auto;
    inset-inline: auto;
    z-index: 120;
    width: auto;
    min-width: 10.5rem;
    max-width: calc(100vw - 24px);
    max-height: calc(100dvh - 24px);
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    transform: none;
  }
}

/* ── Core surfaces (Tailwind utilities used in templates) ───── */
html[data-theme="dark"] body {
  background-color: var(--theme-dark-background);
  color: var(--theme-dark-text);
}

html[data-theme="dark"] .bg-cbsoft,
html[data-theme="dark"] .bg-\[\#EEF1F5\],
html[data-theme="dark"] .bg-\[\#F2F3F5\] {
  background-color: var(--theme-dark-background) !important;
}

html[data-theme="dark"] .bg-white,
html[data-theme="dark"] .bg-white\/95,
html[data-theme="dark"] .bg-slate-50,
html[data-theme="dark"] .bg-slate-100 {
  background-color: var(--theme-dark-surface) !important;
}

html[data-theme="dark"] .bg-slate-200,
html[data-theme="dark"] .bg-slate-300 {
  background-color: var(--theme-dark-surface-elevated) !important;
}

html[data-theme="dark"] .text-slate-950,
html[data-theme="dark"] .text-slate-900,
html[data-theme="dark"] .text-slate-800,
html[data-theme="dark"] .text-gray-900,
html[data-theme="dark"] .text-black {
  color: var(--theme-dark-text) !important;
}

html[data-theme="dark"] .text-slate-700,
html[data-theme="dark"] .text-slate-600,
html[data-theme="dark"] .text-slate-500 {
  color: var(--theme-dark-text-muted) !important;
}

html[data-theme="dark"] .text-slate-400,
html[data-theme="dark"] .text-slate-300 {
  color: var(--theme-dark-icon) !important;
}

html[data-theme="dark"] .text-cbnavy {
  color: var(--theme-dark-text) !important;
}

html[data-theme="dark"] .border-slate-100,
html[data-theme="dark"] .border-slate-200,
html[data-theme="dark"] .border-slate-200\/80,
html[data-theme="dark"] .border-cbline,
html[data-theme="dark"] .divide-slate-100 > :not([hidden]) ~ :not([hidden]),
html[data-theme="dark"] .divide-slate-200 > :not([hidden]) ~ :not([hidden]) {
  border-color: var(--theme-dark-border) !important;
}

html[data-theme="dark"] .hover\:bg-slate-100:hover,
html[data-theme="dark"] .hover\:bg-slate-50:hover {
  background-color: var(--theme-dark-surface-elevated) !important;
}

html[data-theme="dark"] .bg-cbnavy {
  background-color: var(--theme-dark-accent-strong) !important;
}

html[data-theme="dark"] .hover\:bg-cbnavyDark:hover,
html[data-theme="dark"] .hover\:bg-cbnavy:hover {
  background-color: var(--theme-dark-accent-strong) !important;
}

/* Keep white text on accent hover — .text-cbnavy uses !important */
html[data-theme="dark"] .hover\:text-white:hover,
html[data-theme="dark"] .hover\:text-white:focus-visible,
html[data-theme="dark"] a.hover\:bg-cbnavy:hover,
html[data-theme="dark"] a.hover\:bg-cbnavy:focus-visible {
  color: #fff !important;
}

html[data-theme="dark"] .focus\:border-cbnavy:focus,
html[data-theme="dark"] .focus\:ring-cbnavy:focus {
  border-color: var(--theme-dark-focus) !important;
}

html[data-theme="dark"] .hover\:bg-white\/95:hover {
  background-color: var(--theme-dark-surface-elevated) !important;
}

html[data-theme="dark"] .shadow-cbCard,
html[data-theme="dark"] .shadow-sm,
html[data-theme="dark"] .shadow {
  box-shadow: var(--cb-shadow-card) !important;
}

/* ── Header / nav / menus ───────────────────────────────────── */
html[data-theme="dark"] .cbmag-desktop-header,
html[data-theme="dark"] .cbmag-mobile-header {
  background-color: rgba(15, 23, 42, 0.94) !important;
  border-color: var(--theme-dark-border) !important;
  color: var(--theme-dark-text);
}

html[data-theme="dark"] .cbmag-nav-link {
  color: var(--theme-dark-text-muted);
}

html[data-theme="dark"] .cbmag-nav-link:hover,
html[data-theme="dark"] .cbmag-nav-link.active {
  color: var(--theme-dark-text);
  background-color: rgba(97, 124, 186, 0.14);
}

/* Megamenu panel + items — app.css hardcodes white bg/border on panel & hover slate */
html[data-theme="dark"] .cbmag-nav-dropdown {
  background-color: var(--theme-dark-surface) !important;
  border-color: var(--theme-dark-border) !important;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.45);
}

html[data-theme="dark"] .cbmag-nav-dropdown-link {
  background-color: var(--theme-dark-surface);
  border: 1px solid var(--theme-dark-border);
  color: var(--theme-dark-text-muted);
}

html[data-theme="dark"] .cbmag-nav-dropdown-link:hover,
html[data-theme="dark"] .cbmag-nav-dropdown-link:focus-visible {
  background-color: rgba(97, 124, 186, 0.18);
  border-color: rgba(97, 124, 186, 0.35);
  color: var(--theme-dark-text);
}

html[data-theme="dark"] .cbmag-nav-dropdown-link:active {
  background-color: rgba(97, 124, 186, 0.28);
  color: var(--theme-dark-text);
}

html[data-theme="dark"] .cbmag-nav-dropdown-link.active {
  background-color: rgba(97, 124, 186, 0.22);
  border-color: rgba(97, 124, 186, 0.4);
  color: var(--theme-dark-text);
}

html[data-theme="dark"] [role="dialog"].fixed.inset-0 {
  background-color: var(--theme-dark-background) !important;
}

/* Mobile category drawer (.cbmag-menu-row) — app.css hardcodes slate-900 / slate-100 */
html[data-theme="dark"] .cbmag-menu-row {
  border-color: var(--theme-dark-border);
}

html[data-theme="dark"] .cbmag-menu-row__head {
  color: var(--theme-dark-text);
}

html[data-theme="dark"] .cbmag-menu-row__head a {
  color: var(--theme-dark-text);
}

html[data-theme="dark"] .cbmag-menu-row__head > span:first-child,
html[data-theme="dark"] .cbmag-menu-row__toggle {
  color: var(--theme-dark-icon);
}

html[data-theme="dark"] .cbmag-menu-row__head a:hover,
html[data-theme="dark"] .cbmag-menu-row__head a:focus-visible {
  color: var(--theme-dark-text);
  background-color: rgba(97, 124, 186, 0.14);
}

html[data-theme="dark"] .cbmag-menu-row__children a {
  color: var(--theme-dark-text-muted);
}

html[data-theme="dark"] .cbmag-menu-row__children a:hover,
html[data-theme="dark"] .cbmag-menu-row__children a:focus-visible {
  color: var(--theme-dark-text);
  background-color: rgba(97, 124, 186, 0.14);
}

/* ── Forms / search ─────────────────────────────────────────── */
html[data-theme="dark"] input[type="text"],
html[data-theme="dark"] input[type="email"],
html[data-theme="dark"] input[type="url"],
html[data-theme="dark"] input[type="tel"],
html[data-theme="dark"] input[type="number"],
html[data-theme="dark"] input[type="password"],
html[data-theme="dark"] textarea,
html[data-theme="dark"] select {
  background-color: var(--theme-dark-input);
  border-color: var(--theme-dark-border);
  color: var(--theme-dark-text);
}

html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder {
  color: var(--theme-dark-icon);
}

/* Search — dark: soft inset depth without harsh white highlights */
html[data-theme="dark"] .cbmag-search-pill,
html[data-theme="dark"] form:has(> .cbmag-search-input),
html[data-theme="dark"] .cbmag-branded-search {
  --cbmag-search-bg: #1E293B;
  --cbmag-search-text: #CBD5E1;
  --cbmag-search-placeholder: #64748B;
  --cbmag-search-icon-bg: #334155;
  --cbmag-search-icon: #E2E8F0;
  --cbmag-search-icon-border: #475569;
  --cbmag-search-shadow:
    inset 0 3px 3px rgba(0, 0, 0, 0.35),
    inset 0 -1px 2px rgba(255, 255, 255, 0.05),
    0 0 0 1px rgba(51, 65, 85, 0.65);
  --cbmag-search-btn-shadow:
    inset 0 1px 1px rgba(255, 255, 255, 0.08),
    0 1px 2px 0.5px rgba(0, 0, 0, 0.35);
}

html[data-theme="dark"] .cbmag-search-input,
html[data-theme="dark"] .cbmag-branded-search__input,
html[data-theme="dark"] .cbmag-search-pill__input,
html[data-theme="dark"] .cbmag-search input[type="search"] {
  background-color: var(--cbmag-search-bg) !important;
  border: 0 !important;
  color: var(--cbmag-search-text) !important;
  box-shadow: var(--cbmag-search-shadow) !important;
}

html[data-theme="dark"] .cbmag-search-input:focus,
html[data-theme="dark"] .cbmag-branded-search__input:focus,
html[data-theme="dark"] .cbmag-search-pill__input:focus {
  box-shadow:
    inset 0 3px 3px rgba(0, 0, 0, 0.35),
    inset 0 -1px 2px rgba(255, 255, 255, 0.05),
    0 0 0 1px rgba(71, 85, 105, 0.9) !important;
}

html[data-theme="dark"] .cbmag-search-input::placeholder,
html[data-theme="dark"] .cbmag-branded-search__input::placeholder,
html[data-theme="dark"] .cbmag-search-pill__input::placeholder {
  color: var(--cbmag-search-placeholder) !important;
  font-weight: 300 !important;
}

html[data-theme="dark"] .cbmag-search-btn,
html[data-theme="dark"] .cbmag-branded-search__btn,
html[data-theme="dark"] .cbmag-search-pill__btn {
  background: var(--cbmag-search-icon-bg) !important;
  border: 1px solid var(--cbmag-search-icon-border) !important;
  color: var(--cbmag-search-icon) !important;
  box-shadow: var(--cbmag-search-btn-shadow) !important;
}

html[data-theme="dark"] .cbmag-search-btn:hover,
html[data-theme="dark"] .cbmag-branded-search__btn:hover,
html[data-theme="dark"] .cbmag-search-pill__btn:hover {
  background: #475569 !important;
  border-color: #64748B !important;
  color: #F8FAFC !important;
  box-shadow:
    inset 0 1px 1px rgba(255, 255, 255, 0.1),
    0 1px 2px 0.5px rgba(0, 0, 0, 0.4) !important;
}

html[data-theme="dark"] .cbmag-search-btn:focus-visible,
html[data-theme="dark"] .cbmag-branded-search__btn:focus-visible,
html[data-theme="dark"] .cbmag-search-pill__btn:focus-visible {
  outline-color: rgba(148, 163, 184, 0.85);
}

html[data-theme="dark"] .cbmag-search-btn:active,
html[data-theme="dark"] .cbmag-branded-search__btn:active,
html[data-theme="dark"] .cbmag-search-pill__btn:active {
  background: #293548 !important;
  border-color: #334155 !important;
  color: #F8FAFC !important;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.45) !important;
  transform: translateY(1px);
}

html[data-theme="dark"] .cbmag-live-search {
  border-color: var(--theme-dark-border);
  background: var(--theme-dark-surface);
  box-shadow: 0 12px 28px rgba(2, 6, 23, 0.55);
}

html[data-theme="dark"] .cbmag-live-search__item {
  color: var(--theme-dark-text);
}

html[data-theme="dark"] .cbmag-live-search__item:hover,
html[data-theme="dark"] .cbmag-live-search__item:focus-visible {
  background: var(--theme-dark-surface-elevated, #334155);
  color: #F8FAFC;
}

html[data-theme="dark"] .cbmag-live-search__status {
  color: var(--theme-dark-text-muted, #94A3B8);
}

html[data-theme="dark"] .cbmag-live-search__all {
  border-top-color: var(--theme-dark-border);
  color: #93C5FD;
}

html[data-theme="dark"] .cbmag-live-search__all:hover,
html[data-theme="dark"] .cbmag-live-search__all:focus-visible {
  background: var(--theme-dark-background, #0F172A);
}

/* ── Cards / boxes / sections ───────────────────────────────── */
html[data-theme="dark"] .cbmag-card,
html[data-theme="dark"] .cbmag-post-card,
html[data-theme="dark"] .cbmag-mini-card,
html[data-theme="dark"] .cbmag-featured-card,
html[data-theme="dark"] .cbmag-sidebar-box,
html[data-theme="dark"] .cbmag-toc,
html[data-theme="dark"] .cbmag-share-box,
html[data-theme="dark"] .cbmag-author-box,
html[data-theme="dark"] .cbmag-faq,
html[data-theme="dark"] .cbmag-related,
html[data-theme="dark"] .cbmag-tabs-scroll {
  background-color: var(--theme-dark-surface);
  border-color: var(--theme-dark-border);
  color: var(--theme-dark-text);
}

@media (min-width: 1024px) {
  html[data-theme="dark"] .lg\:bg-white {
    background-color: var(--theme-dark-surface) !important;
  }

  html[data-theme="dark"] .lg\:bg-cbsoft {
    background-color: var(--theme-dark-background) !important;
  }
}

html[data-theme="dark"] .cbmag-hero-section {
  background-color: var(--theme-dark-surface);
}

@media (min-width: 1024px) {
  html[data-theme="dark"] .cbmag-hero-section {
    background-color: var(--theme-dark-background);
  }
}

/* Hero category pill — app.css hardcodes white background */
html[data-theme="dark"] .cbmag-hero-caption__cat {
  background-color: var(--theme-dark-surface-elevated);
  color: var(--theme-dark-text);
  border: 1px solid var(--theme-dark-border);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

html[data-theme="dark"] a.cbmag-hero-caption__cat:hover,
html[data-theme="dark"] a.cbmag-hero-caption__cat:focus-visible {
  background-color: var(--theme-dark-accent-strong);
  border-color: rgba(97, 124, 186, 0.45);
  color: #fff;
}

/* Category tab chips under hero — white bg/border hardcoded in app.css */
html[data-theme="dark"] .cbmag-tab-btn:not([aria-selected="true"]):not(.active) {
  background-color: var(--theme-dark-surface);
  border-color: var(--theme-dark-border);
  color: var(--theme-dark-text-muted);
}

html[data-theme="dark"] .cbmag-tab-btn:not([aria-selected="true"]):not(.active):hover,
html[data-theme="dark"] .cbmag-tab-btn:not([aria-selected="true"]):not(.active):focus-visible {
  background-color: var(--theme-dark-surface-elevated);
  border-color: rgba(97, 124, 186, 0.35);
  color: var(--theme-dark-text);
}

html[data-theme="dark"] .cbmag-tab-btn:not([aria-selected="true"]):not(.active):active {
  background-color: rgba(97, 124, 186, 0.22);
  color: var(--theme-dark-text);
}

html[data-theme="dark"] .cbmag-tab-btn[aria-selected="true"],
html[data-theme="dark"] .cbmag-tab-btn.active {
  background-color: var(--theme-dark-accent-strong);
  border-color: var(--theme-dark-accent-strong);
  color: #fff;
}

html[data-theme="dark"] .cbmag-tab-btn[aria-selected="true"]:hover,
html[data-theme="dark"] .cbmag-tab-btn.active:hover,
html[data-theme="dark"] .cbmag-tab-btn[aria-selected="true"]:focus-visible,
html[data-theme="dark"] .cbmag-tab-btn.active:focus-visible {
  background-color: var(--theme-dark-accent);
  border-color: var(--theme-dark-accent);
  color: #fff;
}

/* Home spotlight lists */
html[data-theme="dark"] .cbmag-spotlight-item__link {
  background-color: var(--theme-dark-surface);
  border-color: var(--theme-dark-border);
  color: var(--theme-dark-text);
}

html[data-theme="dark"] .cbmag-spotlight-item__link:hover {
  background-color: var(--theme-dark-surface-elevated);
  border-color: rgba(97, 124, 186, 0.35);
}

html[data-theme="dark"] .cbmag-spotlight-item__title {
  color: var(--theme-dark-text);
}

html[data-theme="dark"] .cbmag-spotlight-item__excerpt {
  color: var(--theme-dark-text-muted);
}

html[data-theme="dark"] .cbmag-spotlight-item__meta {
  color: var(--theme-dark-icon);
}

html[data-theme="dark"] .cbmag-spotlight-item__meta span + span::before {
  color: var(--theme-dark-border);
}

html[data-theme="dark"] .cbmag-spotlight-item__media {
  background: var(--theme-dark-input);
}

html[data-theme="dark"] .cbmag-hot-badge {
  background: rgba(234, 88, 12, 0.94);
  border-color: rgba(251, 191, 36, 0.42);
  color: #fff7ed;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
}

/* Video mosaic — overlay text stays light; only chrome adapts */
html[data-theme="dark"] .cbmag-video-tile {
  background: var(--theme-dark-input);
}

html[data-theme="dark"] .cbmag-video-tile__play {
  background: rgba(2, 6, 23, 0.62);
  border-color: rgba(255, 255, 255, 0.28);
}

html[data-theme="dark"] .cbmag-video-modal {
  background: rgba(2, 6, 23, 0.92);
}

/* Home “مشاهده همه مقالات” — outline + hover fill */
html[data-theme="dark"] a.inline-flex.rounded-full.border.border-cbnavy {
  border-color: var(--theme-dark-accent);
  color: var(--theme-dark-accent);
}

html[data-theme="dark"] a.inline-flex.rounded-full.border.border-cbnavy:hover,
html[data-theme="dark"] a.inline-flex.rounded-full.border.border-cbnavy:focus-visible,
html[data-theme="dark"] a.inline-flex.rounded-full.border.border-cbnavy:active {
  background-color: var(--theme-dark-accent-strong) !important;
  border-color: var(--theme-dark-accent-strong);
  color: #fff !important;
}

/* Skeleton placeholders */
html[data-theme="dark"] .animate-pulse,
html[data-theme="dark"] [class*="skeleton"] {
  background-color: var(--theme-dark-surface-elevated);
}

/* ── Footer ─────────────────────────────────────────────────── */
html[data-theme="dark"] .cbmag-footer-mobile,
html[data-theme="dark"] footer.bg-white,
html[data-theme="dark"] .cbmag-footer-desktop {
  background-color: var(--theme-dark-surface) !important;
  border-color: var(--theme-dark-border) !important;
  color: var(--theme-dark-text-muted);
}

html[data-theme="dark"] .cbmag-footer-mobile a,
html[data-theme="dark"] footer a {
  color: var(--theme-dark-text-muted);
}

html[data-theme="dark"] .cbmag-footer-mobile a:hover,
html[data-theme="dark"] footer a:hover {
  color: var(--theme-dark-text);
}

/* ── Single: category badge above title ─────────────────────── */
/* Uses var(--cb-soft) which remaps to page background — too dark */
html[data-theme="dark"] .cbmag-badge {
  background-color: var(--theme-dark-surface-elevated);
  color: var(--theme-dark-text);
  border: 1px solid var(--theme-dark-border);
}

html[data-theme="dark"] a.cbmag-badge:hover,
html[data-theme="dark"] a.cbmag-badge:focus-visible {
  background-color: var(--theme-dark-accent-strong);
  border-color: var(--theme-dark-accent-strong);
  color: #fff;
}

/* ── Share bar (hardcoded #fff / #334155 in app.css) ────────── */
html[data-theme="dark"] .cbmag-share-bar__label {
  color: var(--theme-dark-text-muted);
}

html[data-theme="dark"] .cbmag-share-bar__btn {
  background-color: var(--theme-dark-surface-elevated);
  border-color: var(--theme-dark-border);
  box-shadow: none;
  color: var(--theme-dark-icon);
}

html[data-theme="dark"] .cbmag-share-bar__btn:hover,
html[data-theme="dark"] .cbmag-share-bar__btn:focus-visible {
  background-color: rgba(97, 124, 186, 0.22);
  border-color: rgba(97, 124, 186, 0.4);
}

html[data-theme="dark"] .cbmag-share-bar__btn:active {
  background-color: rgba(97, 124, 186, 0.32);
}

html[data-theme="dark"] .cbmag-share-bar__btn svg path,
html[data-theme="dark"] .cbmag-share-bar__btn svg g path {
  fill: var(--theme-dark-icon);
}

html[data-theme="dark"] .cbmag-share-bar__btn:hover svg path,
html[data-theme="dark"] .cbmag-share-bar__btn:hover svg g path,
html[data-theme="dark"] .cbmag-share-bar__btn:focus-visible svg path,
html[data-theme="dark"] .cbmag-share-bar__btn:focus-visible svg g path {
  fill: var(--theme-dark-text);
}

html[data-theme="dark"] .cbmag-share__title {
  color: var(--theme-dark-text-muted);
}

html[data-theme="dark"] .cbmag-share-btn {
  background-color: var(--theme-dark-surface-elevated);
  border-color: var(--theme-dark-border);
  color: var(--theme-dark-text-muted);
}

/* ── Sidebar / TOC / comments ───────────────────────────────── */
html[data-theme="dark"] .cbmag-toc,
html[data-theme="dark"] .cbmag-toc-mobile,
html[data-theme="dark"] .cbmag-toc-desktop,
html[data-theme="dark"] .cbmag-toc-box {
  background-color: var(--theme-dark-surface);
  border-color: var(--theme-dark-border);
  color: var(--theme-dark-text);
}

html[data-theme="dark"] .cbmag-toc-summary,
html[data-theme="dark"] .cbmag-toc-heading {
  color: var(--theme-dark-text);
}

html[data-theme="dark"] .cbmag-toc-summary__icon {
  background: rgba(97, 124, 186, 0.22);
  color: var(--theme-dark-text);
}

html[data-theme="dark"] .cbmag-toc-link,
html[data-theme="dark"] .cbmag-sidebar-cat {
  color: var(--theme-dark-text-muted);
}

/* TOC numbers: brighter than surface so digits stay readable at rest */
html[data-theme="dark"] .cbmag-toc-num {
  background: rgba(97, 124, 186, 0.28);
  color: var(--theme-dark-text);
}

html[data-theme="dark"] .cbmag-sidebar-cat__count {
  color: var(--theme-dark-icon);
}

html[data-theme="dark"] .cbmag-sidebar-cat:hover,
html[data-theme="dark"] .cbmag-sidebar-cat.is-active,
html[data-theme="dark"] .cbmag-toc-link:hover,
html[data-theme="dark"] .cbmag-toc-link:focus-visible,
html[data-theme="dark"] .cbmag-toc-link.is-active {
  background: rgba(97, 124, 186, 0.16);
  color: var(--theme-dark-text);
}

html[data-theme="dark"] .cbmag-toc-link:hover .cbmag-toc-num,
html[data-theme="dark"] .cbmag-toc-link:focus-visible .cbmag-toc-num {
  background: rgba(97, 124, 186, 0.42);
  color: var(--theme-dark-text);
}

html[data-theme="dark"] .cbmag-sidebar-cat:hover .cbmag-sidebar-cat__count,
html[data-theme="dark"] .cbmag-sidebar-cat.is-active .cbmag-sidebar-cat__count {
  color: var(--theme-dark-accent);
}

html[data-theme="dark"] .cbmag-toc-link.is-active .cbmag-toc-num {
  background: var(--theme-dark-accent-strong);
  color: #fff;
}

/* Article body — app.css hardcodes slate colors on .cbmag-prose */
html[data-theme="dark"] .cbmag-prose,
html[data-theme="dark"] .cbmag-prose.entry-content {
  color: var(--theme-dark-text-muted);
}

html[data-theme="dark"] .cbmag-prose p,
html[data-theme="dark"] .cbmag-prose.entry-content p,
html[data-theme="dark"] .cbmag-prose li,
html[data-theme="dark"] .cbmag-prose.entry-content li {
  color: var(--theme-dark-text-muted);
}

html[data-theme="dark"] .cbmag-prose h2,
html[data-theme="dark"] .cbmag-prose h3,
html[data-theme="dark"] .cbmag-prose h4,
html[data-theme="dark"] .cbmag-prose h5,
html[data-theme="dark"] .cbmag-prose h6,
html[data-theme="dark"] .cbmag-prose.entry-content h2,
html[data-theme="dark"] .cbmag-prose.entry-content h3,
html[data-theme="dark"] .cbmag-prose.entry-content h4,
html[data-theme="dark"] .cbmag-prose.entry-content h5,
html[data-theme="dark"] .cbmag-prose.entry-content h6 {
  color: var(--theme-dark-text);
}

html[data-theme="dark"] .cbmag-prose.entry-content a {
  color: var(--theme-dark-accent-hover);
}

html[data-theme="dark"] .cbmag-prose.entry-content a:hover,
html[data-theme="dark"] .cbmag-prose.entry-content a:focus-visible {
  color: var(--theme-dark-text);
}

html[data-theme="dark"] .cbmag-prose.entry-content strong,
html[data-theme="dark"] .cbmag-prose.entry-content b {
  color: var(--theme-dark-text);
}

html[data-theme="dark"] .cbmag-prose.entry-content code,
html[data-theme="dark"] .cbmag-prose.entry-content kbd {
  background: var(--theme-dark-surface-elevated);
  color: var(--theme-dark-text);
  border-color: var(--theme-dark-border);
}

html[data-theme="dark"] .cbmag-prose.entry-content figcaption,
html[data-theme="dark"] .cbmag-prose.entry-content .wp-caption-text {
  color: var(--theme-dark-icon);
}

html[data-theme="dark"] .cbmag-prose.entry-content table thead th {
  background: var(--theme-dark-accent-strong);
  color: #fff;
  border-color: var(--theme-dark-border);
}

html[data-theme="dark"] .cbmag-prose.entry-content table td,
html[data-theme="dark"] .cbmag-prose.entry-content table th {
  border-color: var(--theme-dark-border);
  color: var(--theme-dark-text-muted);
}

html[data-theme="dark"] .cbmag-prose.entry-content table tbody tr:nth-child(even) {
  background: rgba(23, 32, 51, 0.85);
}

html[data-theme="dark"] .cbmag-prose.entry-content table tbody tr:hover td {
  background: rgba(97, 124, 186, 0.12);
}

/* Article tables in .cbmag-table-scroll — night mode only */
html[data-theme="dark"] .cbmag-prose.entry-content .cbmag-table-scroll {
  background: #0F172A;
  border-color: rgba(148, 163, 184, 0.22);
  color: #E2E8F0;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.4) #0F172A;
}

html[data-theme="dark"] .cbmag-prose.entry-content .cbmag-table-scroll::-webkit-scrollbar {
  height: 8px;
}

html[data-theme="dark"] .cbmag-prose.entry-content .cbmag-table-scroll::-webkit-scrollbar-track {
  background: #0F172A;
  border-radius: 999px;
}

html[data-theme="dark"] .cbmag-prose.entry-content .cbmag-table-scroll::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.35);
  border-radius: 999px;
}

html[data-theme="dark"] .cbmag-prose.entry-content .cbmag-table-scroll::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.5);
}

html[data-theme="dark"] .cbmag-prose.entry-content .cbmag-table-scroll table {
  background: #0F172A;
  color: #E2E8F0;
}

html[data-theme="dark"] .cbmag-prose.entry-content .cbmag-table-scroll th,
html[data-theme="dark"] .cbmag-prose.entry-content .cbmag-table-scroll td {
  background: #0F172A;
  border-color: rgba(148, 163, 184, 0.22);
  color: #E2E8F0;
}

html[data-theme="dark"] .cbmag-prose.entry-content .cbmag-table-scroll thead th,
html[data-theme="dark"] .cbmag-prose.entry-content .cbmag-table-scroll tr:first-child > th {
  background: #1E293B;
  color: #F8FAFC;
  border-color: rgba(148, 163, 184, 0.22);
}

html[data-theme="dark"] .cbmag-prose.entry-content .cbmag-table-scroll tbody tr:nth-child(even) td {
  background: #132033;
  color: #E2E8F0;
}

html[data-theme="dark"] .cbmag-prose.entry-content .cbmag-table-scroll tbody tr:hover td {
  background: #1A2740;
  color: #E2E8F0;
}

html[data-theme="dark"] .cbmag-prose.entry-content .cbmag-table-scroll a {
  color: #93C5FD;
}

html[data-theme="dark"] .cbmag-prose.entry-content .cbmag-table-scroll a:hover,
html[data-theme="dark"] .cbmag-prose.entry-content .cbmag-table-scroll a:focus-visible {
  color: #F8FAFC;
}

html[data-theme="dark"] .cbmag-prose.entry-content blockquote {
  background: var(--theme-dark-surface-elevated);
  border-color: var(--theme-dark-accent);
  color: var(--theme-dark-text-muted);
}

html[data-theme="dark"] .cbmag-post-thumbnail {
  border-color: var(--theme-dark-border);
}

html[data-theme="dark"] .cbmag-article-actions__btn {
  background: var(--theme-dark-surface);
  border-color: var(--theme-dark-border);
  color: var(--theme-dark-text-muted);
}

html[data-theme="dark"] .cbmag-article-actions__btn:hover,
html[data-theme="dark"] .cbmag-article-actions__btn:focus-visible {
  background: var(--theme-dark-surface-elevated);
  border-color: rgba(97, 124, 186, 0.35);
  color: var(--theme-dark-text);
}

html[data-theme="dark"] .cbmag-article-actions__popover {
  background: var(--theme-dark-surface);
  border-color: var(--theme-dark-border);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
}

html[data-theme="dark"] .cbmag-article-actions__share-link {
  color: var(--theme-dark-text);
}

html[data-theme="dark"] .cbmag-article-actions__share-link:hover,
html[data-theme="dark"] .cbmag-article-actions__share-link:focus-visible {
  background: var(--theme-dark-surface-elevated);
  color: #fff;
}

html[data-theme="dark"] .cbmag-article-actions--mobile {
  background: color-mix(in srgb, var(--theme-dark-surface) 92%, transparent);
  border-color: var(--theme-dark-border);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
}

html[data-theme="dark"] .cbmag-article-actions--mobile .cbmag-article-actions__btn {
  background: transparent;
  border-color: transparent;
}

/*
 * Comments section — unified surface #0F172A.
 * Source of conflict: #commentform uses utility bg-cbsoft, which dark-mode
 * remaps to --theme-dark-background (#020617) via .bg-cbsoft !important.
 */
html[data-theme="dark"] #comments,
html[data-theme="dark"] #comments .cbmag-comment-list {
  color: var(--theme-dark-text);
  background-color: transparent;
}

html[data-theme="dark"] #comments #respond,
html[data-theme="dark"] #comments #respond.comment-respond,
html[data-theme="dark"] #comments .comment-respond,
html[data-theme="dark"] #comments #commentform,
html[data-theme="dark"] #comments #commentform.bg-cbsoft {
  background-color: var(--theme-dark-surface) !important; /* #0F172A */
  border-color: var(--theme-dark-border) !important;
  color: var(--theme-dark-text);
}

html[data-theme="dark"] #comments #respond label,
html[data-theme="dark"] #comments #reply-title,
html[data-theme="dark"] #comments .cbmag-comments-title {
  color: var(--theme-dark-text) !important;
}

html[data-theme="dark"] #comments #cancel-comment-reply-link {
  color: var(--theme-dark-accent);
}

html[data-theme="dark"] #comments #cancel-comment-reply-link:hover,
html[data-theme="dark"] #comments #cancel-comment-reply-link:focus-visible {
  color: var(--theme-dark-text);
}

html[data-theme="dark"] #comments #commentform input[type="text"],
html[data-theme="dark"] #comments #commentform input[type="email"],
html[data-theme="dark"] #comments #commentform textarea,
html[data-theme="dark"] #comments #commentform .bg-white {
  background-color: var(--theme-dark-input) !important;
  border-color: var(--theme-dark-border) !important;
  color: var(--theme-dark-text) !important;
}

html[data-theme="dark"] #comments #commentform input::placeholder,
html[data-theme="dark"] #comments #commentform textarea::placeholder {
  color: var(--theme-dark-icon);
}

html[data-theme="dark"] #comments #commentform input:focus,
html[data-theme="dark"] #comments #commentform textarea:focus {
  border-color: var(--theme-dark-focus) !important;
}

html[data-theme="dark"] #comments #cbmag-comment-submit,
html[data-theme="dark"] #comments #respond .form-submit input,
html[data-theme="dark"] #comments #respond .submit {
  background-color: var(--theme-dark-accent-strong);
  color: #fff;
}

html[data-theme="dark"] #comments #cbmag-comment-submit:hover,
html[data-theme="dark"] #comments #cbmag-comment-submit:focus-visible,
html[data-theme="dark"] #comments #respond .form-submit input:hover,
html[data-theme="dark"] #comments #respond .submit:hover {
  background-color: var(--theme-dark-accent);
  color: #fff;
}

html[data-theme="dark"] #comments #cbmag-comment-submit:active {
  background-color: var(--theme-dark-accent-strong);
  color: #fff;
}


/* Notices */
html[data-theme="dark"] .cbmag-notice,
html[data-theme="dark"] .woocommerce-message,
html[data-theme="dark"] .woocommerce-info {
  background: var(--theme-dark-surface-elevated);
  border-color: var(--theme-dark-border);
  color: var(--theme-dark-text);
}

html[data-theme="dark"] .woocommerce-error,
html[data-theme="dark"] .cbmag-notice--error {
  border-color: var(--theme-dark-danger);
  color: var(--theme-dark-text);
}

/* Pagination */
html[data-theme="dark"] .cbmag-pagination a,
html[data-theme="dark"] .cbmag-pagination span,
html[data-theme="dark"] .page-numbers {
  background: var(--theme-dark-surface);
  border-color: var(--theme-dark-border);
  color: var(--theme-dark-text-muted);
}

html[data-theme="dark"] .cbmag-pagination .current,
html[data-theme="dark"] .page-numbers.current {
  background: var(--theme-dark-accent-strong);
  border-color: var(--theme-dark-accent-strong);
  color: #fff;
}

/* Focus ring */
html[data-theme="dark"] :focus-visible {
  outline-color: var(--theme-dark-focus);
}

/* Logo swap: light/dark variants via data-theme (no JS DOM swap) */
.cbmag-logo-wrap--has-dark .cbmag-logo__dark {
  display: none;
}

html[data-theme="dark"] .cbmag-logo-wrap--has-dark .cbmag-logo__light {
  display: none;
}

html[data-theme="dark"] .cbmag-logo-wrap--has-dark .cbmag-logo__dark {
  display: inline-block !important;
}

/* Logo: lighten only when no dedicated dark logo is present */
html[data-theme="dark"] .cbmag-logo-wrap:not(.cbmag-logo-wrap--has-dark) img,
html[data-theme="dark"] .custom-logo-link:not(.cbmag-logo-wrap--has-dark) img {
  filter: brightness(1.12) contrast(1.05);
}

html[data-theme="dark"] .cbmag-logo {
  color: var(--theme-dark-text);
}

/* Toast / overlays if present */
html[data-theme="dark"] .cbmag-toast,
html[data-theme="dark"] [data-cbmag-toast] {
  background: var(--theme-dark-surface-elevated);
  color: var(--theme-dark-text);
  border-color: var(--theme-dark-border);
}

/* Breadcrumb */
html[data-theme="dark"] .cbmag-breadcrumb,
html[data-theme="dark"] .breadcrumb {
  color: var(--theme-dark-icon);
}

html[data-theme="dark"] .cbmag-breadcrumb a,
html[data-theme="dark"] .breadcrumb a {
  color: var(--theme-dark-text-muted);
}

/* Disabled */
html[data-theme="dark"] :disabled,
html[data-theme="dark"] .disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* Comment cards — utility bg-white remap + explicit surface */
html[data-theme="dark"] .cbmag-comment-list > li,
html[data-theme="dark"] .cbmag-comment-list article,
html[data-theme="dark"] .cbmag-comment,
html[data-theme="dark"] #comments .comment {
  background-color: var(--theme-dark-surface) !important;
  border-color: var(--theme-dark-border) !important;
  color: var(--theme-dark-text);
}

html[data-theme="dark"] .cbmag-comment-list .text-slate-600,
html[data-theme="dark"] #comments .comment .text-slate-600 {
  color: var(--theme-dark-text-muted) !important;
}

/* Ensure orange brand accent stays readable */
html[data-theme="dark"] .text-cborange {
  color: var(--cb-orange, #F6A033) !important;
}

/* Article shell already remaps bg-white → surface; keep meta readable */
html[data-theme="dark"] [data-cbmag-article] > h1,
html[data-theme="dark"] [data-cbmag-article] h1.text-slate-950 {
  color: var(--theme-dark-text) !important;
}
