.mdm-flyout-bar {
  --mdm-flyout-bg: #121820;
  --mdm-flyout-border: #233142;
  --mdm-flyout-text: #f4f6f8;
  --mdm-flyout-muted: #b9c2ce;
  --mdm-flyout-highlight: #ddc07a;
  --mdm-flyout-green: #7fff00;
  --mdm-flyout-panel: #0c1118;
  --mdm-flyout-hover: #182230;
  --mdm-flyout-offset: 0px;

  position: relative;
  z-index: 40;
  width: 100%;
  max-width: 100%;
  margin-left: 0;
  margin-right: 0;
  box-sizing: border-box;
  border-top: 1px solid var(--mdm-flyout-border);
  border-bottom: 0;
  background: linear-gradient(180deg, var(--mdm-flyout-bg) 0%, #0d131a 100%);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
  overflow: visible;
}

.mdm-flyout-mobile-toggle {
  display: none;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 38px;
  padding: 0 12px;
  border: 0;
  background: transparent;
  color: var(--mdm-flyout-text);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.mdm-flyout-mobile-caret {
  color: var(--mdm-flyout-highlight);
  transition: transform 0.15s ease;
}

.mdm-flyout-bar.is-mobile-open .mdm-flyout-mobile-caret {
  transform: rotate(180deg);
}

.mdm-flyout-top-list {
  list-style: none;
  margin: 0;
  padding: 0 12px 0 calc(12px + var(--mdm-flyout-offset));
  display: flex;
  align-items: stretch;
  gap: 4px;
  overflow: visible;
  justify-content: center;
}

#mdm-flyout-top-list {
  margin-top: 5px;
}

@media (min-width: 961px) {
  .mdm-flyout-top-list {
    padding-left: 12px;
  }
}

.mdm-flyout-top-item {
  position: relative;
  flex: 0 0 auto;
}

.mdm-flyout-top-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 12px;
  color: var(--mdm-flyout-text);
  text-decoration: none;
  font-size: 14px;
  font-family: Arial, sans-serif;
  font-weight: 400;
  letter-spacing: 0.01em;
  border-radius: 6px;
}

.mdm-flyout-top-button:hover,
.mdm-flyout-top-button:focus-visible,
.mdm-flyout-top-button:active,
.mdm-flyout-top-item.is-open > .mdm-flyout-top-button {
  background: var(--mdm-flyout-hover);
  color: var(--mdm-flyout-muted);
}

.mdm-flyout-top-title {
  white-space: nowrap;
}

.mdm-flyout-caret {
  font-size: 11px;
  color: var(--mdm-flyout-muted);
}

.mdm-flyout-top-item.is-open .mdm-flyout-caret {
  color: var(--mdm-flyout-muted);
}

.mdm-flyout-panel {
  position: absolute;
  left: 0;
  top: calc(100% + 5px);
  min-width: 260px;
  max-width: min(90vw, 420px);
  border: 1px solid var(--mdm-flyout-border);
  border-radius: 10px;
  background: var(--mdm-flyout-panel);
  box-shadow: 0 14px 26px rgba(0, 0, 0, 0.35), 0 0 14px rgba(255, 255, 255, 0.18);
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
  /* visibility:hidden is what actually removes the closed panel from the
     tab order and from the accessibility tree. opacity and pointer-events
     only hide it from sight and from the mouse: without this, every link
     inside every closed submenu stayed keyboard focusable, so a keyboard
     user tabbing across the menu bar fell into invisible links, and a
     screen reader announced the entire menu contents at all times.

     The 0.15s delay on visibility lets the fade-out finish before the
     panel is removed, so the animation is unchanged. */
  visibility: hidden;
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0s linear 0.15s;
}

.mdm-flyout-top-item.is-open > .mdm-flyout-panel {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
  /* No delay when opening - the panel must be focusable immediately. */
  visibility: visible;
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0s;
}

.mdm-flyout-sub-list {
  margin: 0;
  padding: 6px;
  list-style: none;
}

.mdm-flyout-sub-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--mdm-flyout-text);
  text-decoration: none;
  font-size: 14px;
  font-family: Arial, sans-serif;
  font-weight: 400;
  padding: 8px 10px;
  border-radius: 7px;
}

.mdm-flyout-sub-link:hover {
  background: var(--mdm-flyout-hover);
  color: var(--mdm-flyout-green);
}

.mdm-flyout-sub-link:focus-visible,
.mdm-flyout-sub-link:active {
  background: var(--mdm-flyout-hover);
  color: var(--mdm-flyout-green);
}

.mdm-flyout-badge-new {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 1px 6px;
  border-radius: 999px;
  background: #2d8f64;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.mdm-flyout-lock {
  color: #e7a96f;
  font-size: 12px;
}

.mdm-flyout-locked {
  opacity: 0.7;
}

.mdm-flyout-top-button.mdm-flyout-locked:hover,
.mdm-flyout-top-button.mdm-flyout-locked:focus-visible,
.mdm-flyout-top-button.mdm-flyout-locked:active,
.mdm-flyout-top-item.is-open > .mdm-flyout-top-button.mdm-flyout-locked {
  opacity: 1;
}

.mdm-flyout-coming-soon {
  padding: 12px;
  font-size: 13px;
  color: var(--mdm-flyout-muted);
}

@media (max-width: 960px) {
  .mdm-flyout-bar {
    width: 100%;
    margin-left: 0;
    margin-right: 0;
    padding: 5px 0;
    border-top: 0;
    background: transparent;
    box-shadow: none;
  }

  .mdm-flyout-bar .mdm-flyout-mobile-toggle {
    display: flex;
    min-height: 52px;
    /* Leave a safe lane for the site's fixed Saved/Reference tabs, which can
       occupy the far-left edge on tool pages. */
    padding: 0 15px 0 48px;
    border: 1px solid rgba(221, 192, 122, 0.58);
    border-radius: 12px;
    background: linear-gradient(180deg, #1a2230 0%, #111821 100%);
    color: #fff9ed;
    font-size: 15px;
    font-weight: 800;
    letter-spacing: 0.035em;
    text-transform: none;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 5px 14px rgba(0, 0, 0, 0.22);
  }

  .mdm-flyout-bar .mdm-flyout-mobile-toggle:hover,
  .mdm-flyout-bar .mdm-flyout-mobile-toggle:active,
  .mdm-flyout-bar.is-mobile-open .mdm-flyout-mobile-toggle {
    border-color: var(--mdm-flyout-highlight);
    background: linear-gradient(180deg, #222c3a 0%, #16202b 100%);
    color: #fff;
  }

  .mdm-flyout-bar .mdm-flyout-mobile-toggle:focus-visible {
    outline: 3px solid rgba(221, 192, 122, 0.3);
    outline-offset: 3px;
  }

  .mdm-flyout-mobile-label {
    display: inline-flex;
    align-items: center;
    gap: 11px;
  }

  .mdm-flyout-mobile-icon {
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    width: 21px;
    height: 21px;
  }

  .mdm-flyout-mobile-icon span {
    display: block;
    width: 100%;
    height: 2px;
    border-radius: 999px;
    background: var(--mdm-flyout-highlight);
  }

  .mdm-flyout-mobile-caret {
    display: inline-grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border: 1px solid rgba(221, 192, 122, 0.42);
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.18);
    font-size: 13px;
  }

  .mdm-flyout-top-list {
    display: none;
    flex-direction: column;
    gap: 0;
    padding: 4px 8px 10px;
    overflow: visible;
  }

  .mdm-flyout-bar.is-mobile-open .mdm-flyout-top-list {
    display: flex;
  }

  .mdm-flyout-top-item {
    width: 100%;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
  }

  .mdm-flyout-top-button {
    display: flex;
    width: 100%;
    justify-content: space-between;
    min-height: 40px;
    padding: 0 10px;
    font-size: 14px;
    border-radius: 0;
  }

  .mdm-flyout-panel {
    position: static;
    min-width: 0;
    max-width: none;
    margin: 0 0 8px;
    border-radius: 8px;
    box-shadow: none;
    max-height: 0;
    overflow: hidden;
    border-width: 0;
    opacity: 1;
    transform: none;
    pointer-events: none;
    /* Same reasoning as the desktop rule above. max-height:0 with
       overflow:hidden clips the collapsed panel visually but leaves its
       links in the tab order, so the mobile accordion was fully tabbable
       while appearing closed. */
    visibility: hidden;
    transition: max-height 0.2s ease, visibility 0s linear 0.2s;
  }

  .mdm-flyout-top-item.is-open > .mdm-flyout-panel {
    /* The link count changes in Mega Dungeon Menus, so a fixed height clips
       newly added entries. JavaScript sets this to the panel's real height. */
    max-height: var(--mdm-flyout-panel-height, 1000px);
    pointer-events: auto;
    border-width: 1px;
    visibility: visible;
    transition: max-height 0.2s ease, visibility 0s;
  }

  .mdm-flyout-sub-list {
    padding: 4px;
  }

  .mdm-flyout-sub-link {
    min-height: 36px;
    font-size: 14px;
  }
}
