:root {
  --site-header-height: 88px;
}

html {
  scroll-padding-top: calc(var(--site-header-height) + 14px);
}

body {
  padding-top: var(--site-header-height);
}

.topbar {
  position: fixed;
  inset: 0 0 auto;
  width: 100%;
  max-width: none;
  height: var(--site-header-height);
  margin: 0;
  padding-inline: max(24px, calc((100vw - 1180px) / 2));
}

@media (max-width: 900px) {
  .topbar {
    padding-inline: 20px;
  }
}

.theme-toggle {
  display: inline-flex;
  flex: 0 0 auto;
  width: 48px;
  min-width: 48px;
  height: 42px;
  min-height: 42px;
  align-self: center;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 0;
  border: 1px solid rgba(116, 227, 240, 0.72);
  border-radius: 999px;
  color: #f7f9ff;
  background: linear-gradient(110deg, #119ca8, #3e6bd8 58%, #6e35d9);
  box-shadow: 0 8px 24px rgba(54, 102, 224, 0.28), inset 0 1px rgba(255, 255, 255, 0.2);
  font: 700 18px "Noto Kufi Arabic", sans-serif;
  cursor: pointer;
}

.theme-toggle span {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: rgba(5, 12, 27, 0.24);
  font-size: 21px;
  line-height: 1;
}

.theme-toggle:focus-visible {
  outline: 3px solid rgba(52, 123, 230, 0.42);
  outline-offset: 2px;
}

html[data-theme="light"] {
  color-scheme: light;
  background: #fbfaf5;
}

html[data-theme="light"] body {
  background: #fbfaf5;
}

html[data-theme="light"] .topbar {
  border-bottom-color: #d8ddd4;
  background: rgba(251, 250, 245, 0.96);
  box-shadow: 0 10px 32px rgba(17, 45, 48, 0.08);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}

html[data-theme="light"] .topbar::after {
  background: linear-gradient(90deg, transparent, #b58a45, transparent);
  opacity: 0.55;
}

html[data-theme="light"] .theme-toggle {
  border-color: #b79a5c;
  color: #fff;
  background: linear-gradient(110deg, #80662f, #b08a43);
  box-shadow: 0 8px 22px rgba(95, 73, 30, 0.2), inset 0 1px rgba(255, 255, 255, 0.25);
}

html[data-theme="light"] .theme-toggle span {
  color: #fff;
  background: rgba(50, 35, 8, 0.2);
}

.quran-index {
  top: calc(var(--site-header-height) + 6px);
}

@media (max-width: 720px) {
  :root {
    --mobile-safe-top: env(safe-area-inset-top, 0px);
    --site-header-height: calc(106px + var(--mobile-safe-top));
  }

  .topbar {
    display: grid;
    grid-template-rows: 56px 42px;
    align-content: start;
    justify-items: center;
    gap: 0;
    padding: calc(4px + var(--mobile-safe-top)) 16px 0;
    overflow: hidden;
  }

  .topbar .brand {
    width: 100px;
    height: 56px;
  }

  .topbar .brand img {
    width: 100px;
  }

  .topbar nav {
    width: 100%;
    height: 42px;
    min-width: 0;
    align-items: stretch;
    gap: 4px;
    padding: 0 0 4px;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-inline: contain;
    scroll-snap-type: inline proximity;
    -webkit-overflow-scrolling: touch;
  }

  .topbar nav a,
  .topbar .docs-soon,
  .topbar .theme-toggle {
    display: inline-flex;
    flex: 0 0 auto;
    height: 38px;
    align-items: center;
    justify-content: center;
    padding: 0 10px 7px;
    scroll-snap-align: start;
    font-size: 10px;
    line-height: 1;
  }

  .topbar .theme-toggle {
    position: absolute;
    z-index: 120;
    top: calc(10px + var(--mobile-safe-top));
    left: max(10px, env(safe-area-inset-left, 0px));
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 0;
    padding: 0;
    border-radius: 50%;
    font-size: 20px;
  }

  .topbar nav a.active::after {
    bottom: 1px;
  }

  .native-toolbar,
  .mutash-toolbar {
    top: var(--site-header-height);
  }

  .native-toolbar {
    z-index: 50;
  }
}

@media (max-width: 420px) {
  .topbar {
    padding-inline: 10px;
  }

  .topbar .theme-toggle {
    left: max(6px, env(safe-area-inset-left, 0px));
    width: 44px;
    min-width: 44px;
    padding: 0;
    font-size: 20px;
  }

  .topbar nav a,
  .topbar .docs-soon {
    padding-inline: 8px;
    font-size: 9px;
  }
}
