#globalHeader .ibl-topbar.ibl-subjects-enhanced {
  grid-template-columns: auto max-content minmax(0, 1fr) !important;
  grid-template-rows: auto !important;
}

#globalHeader .ibl-topbar.ibl-subjects-enhanced > .ibl-brand {
  grid-column: 1 !important;
  grid-row: 1 !important;
}

#globalHeader .ibl-topbar.ibl-subjects-enhanced > .ibl-subjects-nav {
  grid-column: 2 !important;
  grid-row: 1 !important;
}

#globalHeader .ibl-topbar.ibl-subjects-enhanced > .ibl-account-actions {
  grid-column: 3 !important;
  grid-row: 1 !important;
  justify-self: end !important;
}

/*
 * The shared layout still contains a legacy hover-to-open rule for this menu.
 * Keep it click-controlled so the pointer cannot make it flicker while crossing
 * the small gap between the account button and the dropdown.
 */
#globalHeader .ibl-account-actions:not([data-open="true"]) .ibl-account-menu {
  display: none !important;
}

#globalHeader .ibl-account-actions[data-open="true"] .ibl-account-menu {
  display: grid !important;
}

#globalHeader .ibl-account-icon,
#globalHeader .ibl-account-icon:hover,
#globalHeader .ibl-account-icon:focus-visible {
  color: #12305a !important;
  -webkit-text-fill-color: #12305a !important;
  background: transparent !important;
  box-shadow: none !important;
  text-shadow: none !important;
  transform: none !important;
}

#globalHeader .ibl-account-menu a,
#globalHeader .ibl-account-menu a:hover,
#globalHeader .ibl-account-menu a:focus,
#globalHeader .ibl-account-menu a:focus-visible {
  color: #12305a !important;
  -webkit-text-fill-color: #12305a !important;
  opacity: 1 !important;
  text-decoration: none !important;
  text-shadow: none !important;
}

#globalHeader .ibl-account-menu a:hover,
#globalHeader .ibl-account-menu a:focus-visible {
  background: #f2f6fb !important;
}

.ibl-subjects-nav {
  box-sizing: border-box;
  position: static;
  min-height: 38px;
  padding-left: clamp(16px, 2vw, 26px);
  border-left: 1px solid rgba(18, 48, 90, 0.14);
  display: flex;
  align-items: center;
  font-family: var(--ibl-ui-font, Inter, ui-sans-serif, system-ui, sans-serif);
}

.ibl-subjects-trigger {
  min-height: 40px;
  margin: 0;
  padding: 0 17px;
  border: 0;
  border-radius: 999px;
  display: inline-flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  color: #12305a;
  background: transparent;
  box-shadow: none;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: color 160ms ease, background 160ms ease;
}

.ibl-subjects-trigger:hover,
.ibl-subjects-trigger:focus-visible,
.ibl-subjects-nav[data-open="true"] .ibl-subjects-trigger {
  color: #12305a;
  background: #f2f4f7;
}

.ibl-subjects-trigger:focus-visible,
.ibl-subjects-choice:focus-visible,
.ibl-subjects-resource:focus-visible {
  outline: 3px solid rgba(27, 104, 251, 0.24);
  outline-offset: 2px;
}

.ibl-subjects-chevron {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  stroke-width: 2;
  transition: transform 160ms ease;
}

.ibl-subjects-nav[data-open="true"] .ibl-subjects-trigger .ibl-subjects-chevron {
  transform: rotate(180deg);
}

.ibl-subjects-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  z-index: 50;
  width: min(1180px, calc(100vw - 32px));
  min-height: 330px;
  max-height: min(590px, calc(100vh - 110px));
  padding: 0;
  border: 1px solid rgba(18, 48, 90, 0.08);
  border-radius: 16px;
  display: grid;
  grid-template-columns: minmax(230px, 1.05fr) minmax(240px, 1.05fr) minmax(205px, 1fr) minmax(205px, 1fr);
  overflow: auto;
  color: #0e2c57;
  background: #fff;
  box-shadow: 0 16px 38px rgba(20, 36, 50, 0.16);
  transform: translateX(-50%);
}

.ibl-subjects-panel[hidden] {
  display: none !important;
}

.ibl-subjects-groups,
.ibl-subjects-courses,
.ibl-subjects-level {
  min-width: 0;
  padding: 24px 16px;
}

.ibl-subjects-groups,
.ibl-subjects-courses {
  border-right: 1px solid rgba(18, 48, 90, 0.1);
  display: grid;
  gap: 7px;
  align-content: start;
}

.ibl-subjects-level + .ibl-subjects-level {
  border-left: 1px solid rgba(18, 48, 90, 0.1);
}

#globalHeader .ibl-subjects-choice {
  width: 100%;
  min-height: 46px;
  margin: 0;
  padding: 9px 10px;
  border: 0 !important;
  border-radius: 9px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 16px;
  gap: 10px;
  align-items: center;
  color: #12305a !important;
  -webkit-text-fill-color: #12305a !important;
  background: transparent !important;
  box-shadow: none !important;
  text-shadow: none !important;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.25;
  text-align: left;
  cursor: pointer;
}

#globalHeader .ibl-subjects-choice:hover,
#globalHeader .ibl-subjects-choice.is-active {
  color: #12305a !important;
  background: #eef3f9 !important;
  box-shadow: none !important;
  transform: none !important;
}

.ibl-subjects-choice > span:first-child {
  min-width: 0;
  color: #12305a !important;
  -webkit-text-fill-color: #12305a !important;
  opacity: 1 !important;
}

.ibl-subjects-level {
  display: grid;
  gap: 14px;
  align-content: start;
}

.ibl-subjects-level h3 {
  margin: 2px 0 4px;
  color: #102f5b;
  font-family: var(--ibl-heading-font, Poppins, Inter, ui-sans-serif, system-ui, sans-serif);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
}

.ibl-subjects-resources {
  display: grid;
  gap: 3px;
}

.ibl-subjects-resource {
  min-height: 38px;
  padding: 8px 7px;
  border-radius: 7px;
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  color: #12305a;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.25;
  text-decoration: none;
}

a.ibl-subjects-resource:hover {
  color: #1b68fb;
  background: #f5f9ff;
  text-decoration: none;
}

.ibl-subjects-resource.is-unavailable {
  color: rgba(18, 48, 90, 0.54);
  cursor: default;
}

.ibl-subjects-resource small {
  padding: 3px 6px;
  border-radius: 999px;
  color: #735810;
  background: #fff4c7;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

@media (max-width: 900px) {
  .ibl-subjects-panel {
    grid-template-columns: minmax(190px, 0.9fr) minmax(205px, 1fr) minmax(175px, 1fr) minmax(175px, 1fr);
  }

  .ibl-subjects-groups,
  .ibl-subjects-courses,
  .ibl-subjects-level {
    padding: 18px 11px;
  }

  .ibl-subjects-choice {
    grid-template-columns: minmax(0, 1fr) 14px;
    gap: 7px;
    font-size: 13px;
  }
}

@media (max-width: 720px) {
  #globalHeader .ibl-topbar.ibl-subjects-enhanced {
    grid-template-columns: auto minmax(0, 1fr) !important;
    grid-template-rows: auto !important;
    gap: 12px !important;
  }

  #globalHeader .ibl-topbar.ibl-subjects-enhanced > .ibl-subjects-nav {
    display: none !important;
  }

  #globalHeader .ibl-topbar.ibl-subjects-enhanced > .ibl-account-actions {
    grid-column: 2 !important;
    grid-row: 1 !important;
    min-width: 0;
    flex-wrap: nowrap !important;
    justify-self: end !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ibl-subjects-trigger,
  .ibl-subjects-chevron {
    transition: none;
  }
}
