.zaher-theme-switch {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid rgba(var(--color-primary-rgb), 0.18);
  border-radius: 999px;
  background: rgba(var(--color-white-rgb), 0.72);
}

.zaher-theme-choice {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--color-secondary);
  font-family: var(--font-primary);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  transition: background-color .2s ease, color .2s ease, box-shadow .2s ease;
}

.zaher-theme-choice:hover {
  color: var(--color-primary);
}

.zaher-theme-choice.is-active {
  background: #fff;
  box-shadow: 0 2px 9px rgba(36, 52, 71, .13);
  color: var(--color-primary-dark);
}

.zaher-theme-choice[data-theme-choice="dark"].is-active {
  background: #17232e;
  color: #ff9a3d;
}

[data-theme="dark"] {
  --color-default: #e8eef4;
  --color-default-rgb: 232, 238, 244;
  --color-secondary: #c4d0da;
  --color-secondary-rgb: 196, 208, 218;
  --color-secondary-light: #8ea2b3;
  --color-secondary-light-rgb: 142, 162, 179;
  --color-secondary-dark: #eef6fb;
  --color-secondary-dark-rgb: 238, 246, 251;
  --zaher-surface: #111b24;
  --zaher-surface-soft: #17232e;
  --zaher-border: rgba(154, 184, 204, .18);
}

[data-theme="dark"] body {
  background: #0b131b;
  color: var(--color-default);
}

[data-theme="dark"] body.content-library-page {
  background:
    radial-gradient(circle at 92% 12%, rgba(20, 157, 179, .1), transparent 28rem),
    radial-gradient(circle at 8% 88%, rgba(244, 119, 33, .05), transparent 25rem),
    #09131b !important;
  color: #dbe7ef;
}

[data-theme="dark"] .home-merged::before {
  background:
    linear-gradient(90deg, rgba(7, 15, 22, .94), rgba(11, 25, 35, .84) 50%, rgba(7, 15, 22, .94)),
    rgba(7, 15, 22, .82);
}

[data-theme="dark"] .header.sticked,
[data-theme="dark"] .header,
[data-theme="dark"] .navbar .dropdown ul,
[data-theme="dark"] .modal-content,
[data-theme="dark"] .inner-page,
[data-theme="dark"] .features,
[data-theme="dark"] .about,
[data-theme="dark"] .contact,
[data-theme="dark"] .card,
[data-theme="dark"] .service-item,
[data-theme="dark"] table,
[data-theme="dark"] .content-library,
[data-theme="dark"] .content-library__main,
[data-theme="dark"] .content-library__sidebar,
[data-theme="dark"] .content-library__card,
[data-theme="dark"] .simulation-card,
[data-theme="dark"] .simulation-view,
[data-theme="dark"] .home-news,
[data-theme="dark"] .home-video {
  background-color: var(--zaher-surface) !important;
  border-color: var(--zaher-border) !important;
  color: var(--color-default);
}

[data-theme="dark"] .section-bg,
[data-theme="dark"] .footer,
[data-theme="dark"] thead,
[data-theme="dark"] tbody,
[data-theme="dark"] tr,
[data-theme="dark"] .content-library__category-button,
[data-theme="dark"] .home-news__item {
  background-color: var(--zaher-surface-soft) !important;
  border-color: var(--zaher-border) !important;
  color: var(--color-default);
}

[data-theme="dark"] h1,
[data-theme="dark"] h2,
[data-theme="dark"] h3,
[data-theme="dark"] h4,
[data-theme="dark"] h5,
[data-theme="dark"] h6,
[data-theme="dark"] .navbar a,
[data-theme="dark"] .navbar a:focus,
[data-theme="dark"] .content-library__card-title,
[data-theme="dark"] .home-news__copy strong {
  color: #f2f7fb;
}

[data-theme="dark"] input,
[data-theme="dark"] textarea,
[data-theme="dark"] select {
  background: #17232e !important;
  border-color: var(--zaher-border) !important;
  color: #f2f7fb !important;
}

[data-theme="dark"] .zaher-theme-switch {
  background: #162633;
  border-color: rgba(var(--color-primary-rgb), .35);
}

/* Code and file library: use the real component selectors, not generic cards. */
[data-theme="dark"] .content-library {
  background: transparent !important;
}

[data-theme="dark"] .content-library > .container {
  border-color: rgba(142, 162, 179, .2) !important;
  background: rgba(13, 26, 36, .96) !important;
  box-shadow: 0 28px 80px rgba(0, 0, 0, .42) !important;
}

[data-theme="dark"] .content-library__header h1,
[data-theme="dark"] .content-library__category-title,
[data-theme="dark"] .library-card h3 {
  color: #f3f8fb !important;
}

[data-theme="dark"] .content-library__header p,
[data-theme="dark"] .library-card__description,
[data-theme="dark"] .library-card__meta,
[data-theme="dark"] .content-library__empty {
  color: #a9bac8 !important;
}

[data-theme="dark"] .content-library #tabs .nav-link {
  border-color: rgba(142, 162, 179, .18) !important;
  background: #182733 !important;
  box-shadow: 0 10px 24px rgba(0, 0, 0, .22) !important;
  color: #dce8ef !important;
}

[data-theme="dark"] .content-library #tabs .nav-link:hover {
  background: #203442 !important;
  color: #fff !important;
}

[data-theme="dark"] .content-library #tabs .nav-link.active {
  border-color: rgba(53, 184, 201, .42) !important;
  background: linear-gradient(145deg, #22adc1, #087f92) !important;
  color: #fff !important;
}

[data-theme="dark"] .library-card {
  border-color: rgba(142, 162, 179, .18) !important;
  background: #15232e !important;
  box-shadow: 0 16px 38px rgba(0, 0, 0, .28) !important;
}

[data-theme="dark"] .library-card:hover {
  border-color: rgba(53, 184, 201, .42) !important;
  box-shadow: 0 22px 48px rgba(0, 0, 0, .38) !important;
}

[data-theme="dark"] .library-card__icon {
  border-color: rgba(53, 184, 201, .28) !important;
  background: linear-gradient(145deg, rgba(53, 184, 201, .18), rgba(20, 157, 179, .08)) !important;
  color: #55c7d6 !important;
}

[data-theme="dark"] .library-card__format {
  background: rgba(244, 119, 33, .16) !important;
  color: #ff9a57 !important;
}

[data-theme="dark"] .library-card__meta {
  border-color: rgba(142, 162, 179, .15) !important;
}

[data-theme="dark"] .library-card__action--secondary {
  border-color: rgba(85, 199, 214, .35) !important;
  background: #0d1b25 !important;
  color: #71d5e1 !important;
}

[data-theme="dark"] .library-card__action--secondary:hover {
  border-color: rgba(255, 154, 87, .7) !important;
  background: rgba(244, 119, 33, .12) !important;
  color: #ffad73 !important;
}

[data-theme="dark"] .code-card__preview,
[data-theme="dark"] .file-card__preview {
  border-color: rgba(142, 162, 179, .18) !important;
  background: #09131b !important;
}

[data-theme="dark"] .code-card__preview pre,
[data-theme="dark"] .code-card__preview code {
  background: transparent !important;
  color: #d6e3eb !important;
}

[data-theme="dark"] .content-library__empty {
  border-color: rgba(53, 184, 201, .28) !important;
  background: rgba(20, 157, 179, .08) !important;
}

/* Simulations gallery and full-screen viewer. */
[data-theme="dark"] body.simulation-page,
[data-theme="dark"] body.simulation-page .inner-page,
[data-theme="dark"] body.simulation-page #container_view {
  background: #09131b !important;
  color: #dbe7ef !important;
}

[data-theme="dark"] .simulation-hub,
[data-theme="dark"] .simulation-full {
  border-color: rgba(53, 184, 201, .24) !important;
  background: #0d1a24 !important;
  box-shadow: 0 26px 74px rgba(0, 0, 0, .42) !important;
}

[data-theme="dark"] .simulation-hub__head h2,
[data-theme="dark"] .simulation-hub__head p,
[data-theme="dark"] .simulation-card__body strong,
[data-theme="dark"] .simulation-full h2 {
  color: #f3f8fb !important;
}

[data-theme="dark"] .simulation-card {
  border-color: rgba(142, 162, 179, .18) !important;
  background: #15232e !important;
  box-shadow: 0 16px 38px rgba(0, 0, 0, .28) !important;
  color: #e6f0f5 !important;
}

[data-theme="dark"] .simulation-card:hover {
  border-color: rgba(53, 184, 201, .42) !important;
  box-shadow: 0 22px 48px rgba(0, 0, 0, .4) !important;
}

[data-theme="dark"] .simulation-card__media {
  background: linear-gradient(135deg, #132733, #10241f) !important;
}

[data-theme="dark"] .simulation-card__body small {
  color: #9fb1bf !important;
}

[data-theme="dark"] .simulation-card__body em,
[data-theme="dark"] .simulation-hub__head span,
[data-theme="dark"] .simulation-view__eyebrow {
  color: #55c7d6 !important;
}

[data-theme="dark"] .simulation-full__bar {
  border-color: rgba(53, 184, 201, .2) !important;
  background: linear-gradient(135deg, #13232e, #0d1a24) !important;
}

[data-theme="dark"] .simulation-back {
  border-color: rgba(53, 184, 201, .3) !important;
  background: #172a36 !important;
  color: #55c7d6 !important;
}

[data-theme="dark"] .simulation-frame {
  background: #071018 !important;
  color-scheme: dark;
}

/* Footer has its own nested backgrounds, so style both levels explicitly. */
[data-theme="dark"] .footer,
[data-theme="dark"] .footer .footer-content {
  background: #0d1a24 !important;
  color: #dbe7ef !important;
}

[data-theme="dark"] .footer .footer-legal {
  background: #07111a !important;
  color: #dbe7ef !important;
}

[data-theme="dark"] .footer .copyright,
[data-theme="dark"] .footer .credits {
  color: #c6d5df !important;
}

[data-theme="dark"] .footer .social-links a {
  border: 1px solid rgba(142, 162, 179, .2);
  background: #142632 !important;
  color: #eaf3f8 !important;
}

[data-theme="dark"] .footer .social-links a:hover {
  background: var(--color-primary) !important;
  color: #fff !important;
}

@media (max-width: 1279px) {
  .navbar .zaher-menu-theme {
    padding: 8px 20px;
  }

  .zaher-theme-switch {
    width: 100%;
  }

  .zaher-theme-choice {
    flex: 1;
    justify-content: center;
  }
}
