/* ==========================================================================
   MathPath Unified Rock-Solid Sticky Topbar (Shared across ALL pages)
   Prevents layout shift, width jumping, scrollbar jitter, and missing items.
   ========================================================================== */

html {
  scrollbar-gutter: stable;
}

.topbar {
  position: sticky !important;
  top: 0 !important;
  z-index: 80 !important;
  width: 100% !important;
  min-height: 66px !important;
  background: rgba(223, 242, 244, 0.94) !important;
  backdrop-filter: blur(14px) !important;
  -webkit-backdrop-filter: blur(14px) !important;
  border-bottom: 1px solid rgba(44, 34, 73, 0.09) !important;
  font-family: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif !important;
}

.topbar-inner {
  max-width: 1180px !important;
  width: 100% !important;
  margin: 0 auto !important;
  padding: 0.68rem 1.25rem !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 0.85rem !important;
  flex-wrap: nowrap !important;
}

.topbar .brand {
  display: inline-flex !important;
  align-items: center !important;
  gap: 0.65rem !important;
  text-decoration: none !important;
  flex-shrink: 0 !important;
  color: #2c2249 !important;
}

.topbar .brand-mark {
  width: 40px !important;
  height: 40px !important;
  border: 3px solid #ffffff !important;
  border-radius: 13px !important;
  background: #ff5b50 !important;
  color: #281e3d !important;
  display: grid !important;
  place-items: center !important;
  font: 800 1.25rem/1 "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif !important;
  box-shadow: 0 4px 0 #c6d3d5 !important;
  flex-shrink: 0 !important;
}

.topbar .brand-title {
  font: 800 1.22rem/1.1 "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif !important;
  letter-spacing: -0.04em !important;
  color: #2c2249 !important;
  white-space: nowrap !important;
}

.topbar .brand-sub {
  font-size: 0.72rem !important;
  font-weight: 600 !important;
  line-height: 1.25 !important;
  color: #5d5e76 !important;
  letter-spacing: 0 !important;
  white-space: nowrap !important;
}

.topbar .nav-links {
  display: flex !important;
  align-items: center !important;
  justify-content: flex-end !important;
  gap: 0.22rem !important;
  flex-wrap: nowrap !important;
  white-space: nowrap !important;
}

.topbar .nav-link {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  text-decoration: none !important;
  padding: 0.42rem 0.68rem !important;
  border-radius: 999px !important;
  border: 2px solid transparent !important;
  font-size: 0.83rem !important;
  font-weight: 700 !important;
  line-height: 1.2 !important;
  color: #2c2249 !important;
  background: transparent !important;
  white-space: nowrap !important;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease !important;
}

.topbar .nav-link:hover {
  background: rgba(255, 255, 255, 0.82) !important;
  color: #7548ca !important;
}

.topbar .nav-link.is-active {
  background: #7548ca !important;
  border-color: #7548ca !important;
  color: #ffffff !important;
}

.topbar .nav-link.nav-pill-study {
  background: #fff0c7 !important;
  border: 2px solid #e9c978 !important;
  color: #6b4b07 !important;
}

.topbar .nav-link.nav-pill-study:hover {
  background: #ffe4a1 !important;
  color: #5b3f04 !important;
}

.topbar .nav-link.nav-pill-study.is-active {
  background: #7548ca !important;
  border-color: #7548ca !important;
  color: #ffffff !important;
}

@media (max-width: 1080px) {
  .topbar-inner {
    flex-wrap: wrap !important;
    gap: 0.6rem !important;
  }
  .topbar .nav-links {
    flex-wrap: wrap !important;
    justify-content: flex-start !important;
  }
}

@media (max-width: 640px) {
  .topbar-inner {
    padding: 0.6rem 0.9rem !important;
  }
  .topbar .nav-link {
    padding: 0.36rem 0.56rem !important;
    font-size: 0.78rem !important;
  }
}

/* Global Print Watermark across ALL printable pages (prints even with Background Graphics off) */
@media print {
  body::after {
    content: "MathPath.study" !important;
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) rotate(-30deg) !important;
    font-family: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif !important;
    font-size: 4.5rem !important;
    font-weight: 800 !important;
    letter-spacing: 0.08em !important;
    color: rgba(100, 116, 139, 0.13) !important;
    white-space: nowrap !important;
    pointer-events: none !important;
    user-select: none !important;
    z-index: 9999 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
  body::before {
    content: "MathPath.study" !important;
    position: fixed !important;
    right: 4mm !important;
    bottom: 2mm !important;
    font-family: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif !important;
    font-size: 0.72rem !important;
    font-weight: 700 !important;
    letter-spacing: 0.04em !important;
    color: rgba(100, 116, 139, 0.55) !important;
    white-space: nowrap !important;
    pointer-events: none !important;
    user-select: none !important;
    z-index: 9999 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
}
